<?php
header("Cache-control: no-cache");
header('Content-type:text/html;charset=utf-8');
include ("include/config.php");
require_once('include/safe_8.php');
$type = htmlspecialchars(trim($_GET['type']), ENT_QUOTES);
if(!($type)){
	header('Content-Type: text/html');
	header("HTTP/1.1 404 Not Found");
	echo '<html>';
	echo '<head><title>404 Not Found</title></head>';
	echo '<body>';
	echo '<center><h1>404 Not Found</h1></center>';
	echo '<hr><center>nginx</center>';
	echo '</body>';
	echo '</html>';
	exit();
}
$filename  = 'b_' . $type;    //缓存文件名
$filepath = $cacheurl . 'list/';//缓存保存的路径目录
$fdir = $filepath.$filename.'.inc';
$lastflesh = @filemtime($fdir);
$timestamp = time();
!is_dir($filepath) ? mkdir($filepath, 0777, true) : null; //创建目录
if(!file_exists($fdir) or ($lastflesh + (24*60*60) <= $timestamp)){ //4小时
ob_start();
include ("include/conn.php");
	$sql1 = mysql_query("select * from `db_class` where `name`='$type' ") or die('404');
	$rs1 = mysql_fetch_array($sql1);
	$fname = $rs1['name'];
	$ftitle = $rs1['title'];
	$fid = $rs1['id'];
	if($fid == ''){
	header('Content-Type: text/html');
	header("HTTP/1.1 404 Not Found");
	echo '<html>';
	echo '<head><title>404 Not Found</title></head>';
	echo '<body>';
	echo '<center><h1>404 Not Found</h1></center>';
	echo '<hr><center>nginx</center>';
	echo '</body>';
	echo '</html>';
	exit();
	}

	//获取本栏目文档
	$sql10 = mysql_query("SELECT * FROM `db_thumb` WHERE `fid`=$fid ORDER BY `id` DESC LIMIT 0 , 40");
	while ($r10 = mysql_fetch_array($sql10)) {
		$r11 = mysql_fetch_array(mysql_query("SELECT * FROM `db_class` WHERE `id`=" . $r10['fid']));
		$r13 = mysql_fetch_array(mysql_query("SELECT * FROM `db_scb` WHERE `id`=" . $r10['id']));
		$list .= $r10['id'] . '@@' . $r13['title'] . '@@' . $r10['thumb'] . '@@' . $r11['name'] . '##';
	}

//关闭数据库
mysql_close();//处理为内容
$info = "$ftitle%%$fname%%$list";
	if($info!=null){//写入缓存
	$fp = @fopen($fdir,'w');
	@fwrite($fp,$info);
	@fclose($fp);
	} else {
		header('Content-Type: text/html');
		header("HTTP/1.1 404 Not Found");
		echo '<html>';
		echo '<head><title>404 Not Found</title></head>';
		echo '<body>';
		echo '<center><h1>404 Not Found</h1></center>';
		echo '<hr><center>nginx</center>';
		echo '</body>';
		echo '</html>';
		exit();
	}
} else {
	$info = file_get_contents($fdir);//读取本地缓存
}
//解析
$info = explode("%%", $info);

$ftitle = $info[0];
$fname = $info[1];
$list = $info[2];
if($_GET['type'] != $fname){
	header('Content-Type: text/html');
	header("HTTP/1.1 404 Not Found");
	echo '<html>';
	echo '<head><title>404 Not Found</title></head>';
	echo '<body>';
	echo '<center><h1>404 Not Found</h1></center>';
	echo '<hr><center>nginx</center>';
	echo '</body>';
	echo '</html>';
	exit();
}
//解析本栏目文档
$related = explode("##",$list);
$e = 1;
foreach($related as $value){
	$linkarr = explode("@@",$value);
	if ($e <= 40 && $linkarr[0] !='' && $linkarr[0] !='0') {
			$rd1 .= '<li><div class="pic"><a href="/' . $linkarr[3] . '/' . $linkarr[0] . '.html" title="' . $linkarr[1] . '"><img src="' . $picurl . 'file/image/pic/'. $linkarr[2] .'" alt="' . $linkarr[1] . '" /></a></div><a href="/' . $linkarr[3] . '/' . $linkarr[0] . '.html" title="' . $linkarr[1] . '"><h3>' . $linkarr[1] . '</h3></a></li>';
		}
	$e++;
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="applicable-device" content="mobile" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<title>奇酷啦<?=$ftitle;?>大全 - <?=$webname;?></title>
<link rel="canonical" href="<?=$murl;?>/<?=$fname;?>/">
<link rel="stylesheet" href="/images/style.css" type="text/css" />
<script src="/images/m.js"></script>
<style>.search{display:none}</style>
</head>
<body>
<div class="header">
    <div class="main">
        <a href="/" title="奇酷啦<?=$ftitle;?>大全" class="logo"></a>
        <div class='lanmu'></div>
        <div class="zuowen_search">
        </div>
        <div class="zuowen_login"></div>
    </div>
</div>
<script>
    function subForm() {
        var a = document.getElementById("keywords").value;
        if (a.length < 2) {
            alert("请输入内容大于2个字")
        } else {
            window.open('/s/' + a);
        }
    }
</script>
<div class="zuowen_nav">
    <div class="main">
        <ul>
            <li <?php if($fname == ''){echo ' class="active"';}?>><a href="/">首页</a></li>
            <li <?php if($fname == 'shouchaobao'){echo ' class="active"';}?>><a href="/shouchaobao/">手抄报</a></li>
            <li <?php if($fname == 'jianbihua'){echo ' class="active"';}?>><a href="/jianbihua/">简笔画</a></li>
            <li <?php if($fname == 'heibanbao'){echo ' class="active"';}?>><a href="/heibanbao/">黑板报</a></li>
            <li <?php if($fname == 'heka'){echo ' class="active"';}?>><a href="/heka/">贺卡</a></li>
            <li <?php if($fname == 'touxiang'){echo ' class="active"';}?>><a href="/touxiang/">头像</a></li>
            <li <?php if($fname == 'bizhi'){echo ' class="active"';}?>><a href="/bizhi/">壁纸</a></li>
            <li <?php if($tfname == 'gaoqing'){echo ' class="active"';}?>><a href="/gaoqing/">高清</a></li>
        </ul>
    </div>
</div>
<div class="tit">
    <a href="//www.qikula.com">奇酷啦</a> > <a href="/<?=$fname;?>/"><?=$ftitle;?></a> >
    <div class="but">
        <span id="search-btn"></span>
        <span id="menu"></span>
    </div>
</div>
<div class="search">
    <form name="formsearch" method="get" action="/search"  target="_blank" class="search_left">
        <input type="hidden" name="s" value="qikula">
        <input type="hidden" name="nsid" id="nsid" value="1">
        <input type="text" value="想找什么，来这里试试"  name="wd" id="search-keyword" class="stext" onfocus="this.value=''" onblur="if(!value){value=defaultValue;}">
        <input type="submit" id="searchButton" class="sbt" value="">
    </form>
</div>
<div class="indexbox">
    <ul class="indexlist piclist">
        <?=$rd1;?>
    </ul>
</div>
<div class="footer">
    <p>CopyRight © 2026 <a href="/">奇酷啦</a> www.qikula.com <script>tj();</script></p>
    <p><a href="https://beian.miit.gov.cn/" rel="nofollow">皖ICP备07003335号-25</a> </p>
    <p>声明：如发现政治性、事实性、技术性差错和版权方面的问题及不良信息，请联系我们。删除邮箱：40179832@qq.com。</p>
</div>
<script src="https://lf9-cdn-tos.bytecdntp.com/cdn/expire-1-M/jquery/1.10.2/jquery.min.js"></script>
<script charset="utf-8" type="text/javascript" src="/images/p.js"></script>
</body>
</html>