⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 creathtm.php

📁 程序安装简便容易
💻 PHP
字号:
<?php
!$_SERVER['PHP_SELF'] && $_SERVER['PHP_SELF']=$_SERVER['SCRIPT_NAME'];
substr($_SERVER['PHP_SELF'],-9,-4)!=='admin' && exit('Forbidden');

include_once(R_P.'cache/set.php');

if($set['ifhtml']=='0') {
	$c_a='';
	$c_b=' checked';
} elseif($set['ifhtml']=='1') {
	$c_a=' checked';
	$c_b='';
}	

if(!empty($_GET['do'])) {
	if($_GET['do']=='set') {
		$ifhtml=$_POST['ifhtml'];
		$query=query("UPDATE duoxun_settings SET value='$ifhtml' WHERE name='ifhtml'");
		if($query) {
			settings();
			echo "<script language=\"javascript\">alert(\"设置成功!\")</script>";
			echo "<meta http-equiv='refresh' content='0;url=admin.php?job=creathtm'>";
			exit;
		} else {
			echo "<script language=\"javascript\">alert(\"设置失败!请重试!\")</script>";
			echo "<meta http-equiv='refresh' content='0;url=admin.php?job=creathtm'>";
			exit;
		}			
	} elseif($_GET['do']=='creat') {
		if($set['ifhtml']=='0') {
			echo "<script language=\"javascript\">alert(\"请将网站使用静态(html)页面设置为\“是\”!\")</script>";
			echo "<meta http-equiv='refresh' content='0;url=admin.php?job=creathtm'>";
			exit;
		}
		if(empty($_GET['go'])) {
			$per=!empty($_POST['percount']) ? $_POST['percount'] : 80;
			$output='开始生成静态(html)页面......';
			echo "<meta http-equiv='refresh' content='0;url=admin.php?job=creathtm&do=creat&go=news&per=$per&step=1'>";
		} elseif($_GET['go']=='news') {
			$step=$_GET['step'];
			$per=$_GET['per'];
			$start=($step-1)*$per;
			$to=$start+$per;
			
			$output='正在更新新闻的'.$start.'到'.$to.'项';
		
			$query=query("SELECT aid FROM duoxun_news ORDER BY topped ASC,postdate DESC LIMIT $start,$per");
			while($rs=fetch_array($query)) {
				$news_id[]=$rs;
			}
			foreach($news_id as $id) {
				$aid=$id['aid'];
				require_once(R_P.'cache/set.php');
				require_once(R_P.'cache/template.php');
				require_once(R_P.'cache/sort_cache.php');

				!file_exists(R_P.'cache/read_top.php') ? touch(R_P.'cache/read_top.php') : $read_top=readover(R_P.'cache/read_top.php');
				!file_exists(R_P.'cache/read_bottom.php') ? touch(R_P.'cache/read_bottom.php') : $read_bottom=readover(R_P.'cache/read_bottom.php');
				
				$sql="SELECT * FROM duoxun_news WHERE aid='$aid'";
				$rs=get_one($sql);
				$subject=$rs['subject'];
				$href_g=($set['ifhtml']==1 && file_exists(R_P.'news.html')) ? R_P.'news.html' : 'list.php?type=news&id='.$aid;
				$from=$rs['itfrom'];
				$author=$rs['author'];
				$date=getdate($rs['postdate']);
				$date=$date['year'].'/'.$date['mon'].'/'.$date['mday'];
				$hits=$rs['hits'];
				$content=$rs['content'];

				$guide=$subject.' - '.$set['news'].' - ';
				$guidee='<a href="'.$href_g.'">'.$set['news'].'</a>&nbsp;&gt;&nbsp;'.$subject;
				$fenye='';

				ob_start();
				include(R_P.$tplpath.'/readtpl.htm');
				writeover("$aid.html",ob_get_contents(),"rb+",0);
				ob_end_clean();
				chmod("$aid.html",0777);
			}
			$rs=get_one("SELECT COUNT(*) AS count FROM duoxun_news");
			if($to<$rs['count']) {
				$step++;
				echo "<meta http-equiv='refresh' content='0;url=admin.php?job=creathtm&do=creat&go=news&per=$per&step=$step'>";
			} else {
				echo "<meta http-equiv='refresh' content='0;url=admin.php?job=creathtm&do=creat&go=sort&per=$per&step=1'>";
			}
		} elseif($_GET['go']=='sort') {
			$step=$_GET['step'];
			$per=$_GET['per'];
			$start=($step-1)*$per;
			$to=$start+$per;
			
			$output='正在更新分类文章的'.$start.'到'.$to.'项';
		
			$query=query("SELECT aid,sid FROM duoxun_subject ORDER BY sid ASC,topped ASC,aid DESC LIMIT $start,$per");
			while($rs=fetch_array($query)) {
				$subject_id[]=$rs;
			}
			foreach($subject_id as $id) {
				require_once(R_P.'cache/set.php');
				require_once(R_P.'cache/template.php');
				require_once(R_P.'cache/sort_cache.php');

				$about="<a class=about href=\"about.php?type=about\" target=\"_blank\">关于$set[name]</a><font color=\"#666666\">
        				<span class=about> | </span><a class=about href=\"about.php?type=contact\" target=\"_blank\">联系我们</a><span class=about> | </span><a class=about href=\"about.php?type=hezuo\">合作建议</a>
        				<span class=about> | </span><a onclick=\"this.style.behavior='url(#default#homepage)';this.setHomePage('{$set['url']}')\" href=\"#\" class=about>设为首页</a>
        				<span class=about> | </span><a class=about href=\"javascript:window.external.addFavorite('{$set['url']}','{$set['name']}')\">加入收藏</a>
        				<span class=about> | </span><a class=about href=\"login.php\" target=\"_blank\">管理登录</a>";
				$powered="Powered by <a href=\"http://www.duoxun.com\" target=\"_blank\">www.DuoXun.com</a>&nbsp;ver$duoxun_version";


				!file_exists(R_P.'cache/read_top.php') ? touch(R_P.'cache/read_top.php') : $read_top=readover(R_P.'cache/read_top.php');
				!file_exists(R_P.'cache/read_bottom.php') ? touch(R_P.'cache/read_bottom.php') : $read_bottom=readover(R_P.'cache/read_bottom.php');

				$sid=$id['sid'];
				$aid=$id['aid'];

				$rs=get_one("SELECT * FROM duoxun_subject WHERE aid='$aid'");
				$subject=$rs['subject'];
				$from=$rs['itfrom'];
				$author=$rs['author'];
				$date=getdate($rs['postdate']);
				$date=$date['year'].'/'.$date['mon'].'/'.$date['mday'];
				$hits=$rs['hits'];
				$cnum=$rs['cnum'];

				$rs=get_one("SELECT name FROM duoxun_sort WHERE sid='$sid'");
				$href_g=($set['ifhtml']==1 && file_exists(R_P.'list_'.$sid.'.html')) ? R_P.'list_'.$sid.'.html' : 'list.php?id='.$sid;
				$guide=$subject.' - '.$rs['name'].' - ';
				$guidee=$href_g.$rs['name'].'</a>&nbsp;&gt;&nbsp;'.$subject;

				$query=query("SELECT * FROM duoxun_content WHERE aid='$aid' ORDER BY pid ASC");
				while($rs=fetch_array($query)) {
					$catedb[]=$rs;
				}
				if(count($catedb)<=1) {
					$fenye='';
					$content=$catedb[0]['content'];
					ob_start();
					include(R_P.$tplpath.'/readtpl.htm');
					writeover(R_P.$sid.'_'.$aid.'.html',ob_get_contents(),'rb+',0);
					ob_end_clean();
					@chmod(R_P.$sid.'_'.$aid.'.html',0777);
					unset($catedb);
				} elseif(count($catedb)>1) {
					foreach($catedb as $key=>$cate) {
						$key++;
						if($key==1) {
							$fenye='页码:<b><a href="'.$sid.'_'.$aid.'.html">'.$key.'</a></b>|';
							for($i=2;$i<count($catedb)+1;$i++) {
								$fenye.="<a href=".$sid."_".$aid."_".$i.".html>".$i."</a>|";
							}
							$content=$cate['content'];
							ob_start();
							include(R_P.$tplpath.'/readtpl.htm');
							writeover(R_P.$sid.'_'.$aid.'.html',ob_get_contents(),'rb+',0);
							ob_end_clean();
							@chmod(R_P.$sid.'_'.$aid.'.html',0777);
						} else {
							$fenye='页码:<a href="'.$sid.'_'.$aid.'.html">1</a>|';
							for($i=2;$i<count($catedb)+1;$i++) {
								$page=$i==$key ? '<b>'.$i.'</b>' : $i;
								$fenye.="<a href=".$sid."_".$aid."_".$i.".html>".$page."</a> |";
							}
							$content=$cate['content'];
							ob_start();
							include(R_P.$tplpath.'/readtpl.htm');
							writeover(R_P.$sid.'_'.$aid.'_'.$key.'.html',ob_get_contents(),'rb+',0);
							ob_end_clean();
							@chmod(R_P.$sid.'_'.$aid.'_'.$key.'.html',0777);
						}
					}
					unset($catedb);
				}						
			}
			$rs=get_one("SELECT COUNT(*) AS count FROM duoxun_subject");
			if($to<$rs['count']) {
				$step++;
				echo "<meta http-equiv='refresh' content='0;url=admin.php?job=creathtm&do=creat&go=sort&per=$per&step=$step'>";
			} else {
				echo "<meta http-equiv='refresh' content='0;url=admin.php?job=creathtm&do=creat&go=index&to=news'>";
			}
		} elseif($_GET['go']=='index') {
			if($_GET['to']=='news') {
				$output='正在更新新闻首页';
				ob_start();
				$_GET['type']='news';
				include_once('list.php');
				writeover("news.html",ob_get_contents(),"rb+",0);
				ob_end_clean();
				chmod("news.html",0777);
				echo "<meta http-equiv='refresh' content='0;url=admin.php?job=creathtm&do=creat&go=index&to=sort&too=0'>";
			} elseif($_GET['to']=='sort') {
				$query=query("SELECT sid FROM duoxun_sort ORDER BY sid ASC");
				while($rs=fetch_array($query)) {
					$siddb[]=$rs;
				}
				$num=count($siddb);
				$too=$_GET['too'];
				$n_s=$too+1;
				if($n_s>$num) {
					$output='准备更新最后一个分类首页';
					echo "<meta http-equiv='refresh' content='0;url=admin.php?job=creathtm&do=creat&go=index&to=list'>";
				} else {
					$output='正在更新第'.$n_s.'个分类首页';
					$sid=$siddb[$too]['sid'];
					ob_start();
					$_GET['type']='';
					$_GET['id']=$sid;
					include_once('list.php');
					writeover("list_$sid.html",ob_get_contents(),"rb+",0);
					ob_end_clean();
					chmod("list_$sid.html",0777);
					$too++;
					echo "<meta http-equiv='refresh' content='0;url=admin.php?job=creathtm&do=creat&go=index&to=sort&too=$too'>";
				}
			} elseif($_GET['to']=='list') {
				$output='正在更新最后一个分类首页';
				ob_start();
				$_GET['type']='';
				$_GET['id']='';
				include_once('list.php');
				writeover("list.html",ob_get_contents(),"rb+",0);
				ob_end_clean();
				chmod("list.html",0777);
				echo "<meta http-equiv='refresh' content='0;url=admin.php?job=creathtm&do=creat&go=index&to=reg'>";
			} elseif($_GET['to']=='reg') {
				$output='正在更新会员注册页面';
				ob_start();
				include_once('reg.php');
				writeover("reg.html",ob_get_contents(),"rb+",0);
				ob_end_clean();
				chmod("reg.html",0777);
				echo "<meta http-equiv='refresh' content='0;url=admin.php?job=creathtm&do=creat&go=index&to=login'>";
			} elseif($_GET['to']=='login') {
				$output='正在更新会员登录页面';
				ob_start();
				include_once('login.php');
				writeover("login.html",ob_get_contents(),"rb+",0);
				ob_end_clean();
				chmod("login.html",0777);
				echo "<meta http-equiv='refresh' content='0;url=admin.php?job=creathtm&do=creat&go=index&to=index'>";
			} elseif($_GET['to']=='index') {
				$output='正在更新网站首页';
				ob_start();
				include('index.php');
				writeover("index.html",ob_get_contents(),"rb+",0);
				ob_end_clean();
				chmod("index.html",0777);
				echo "<meta http-equiv='refresh' content='0;url=admin.php?job=creathtm&do=creat&go=over'>";
			}
		} elseif($_GET['go']=='over') {
			$output='完成相应操作!';
		}	
	} elseif($_GET['do']=='delete') {
		if($set['ifhtml']=='1') {
			echo "<script language=\"javascript\">alert(\"请将网站使用静态(html)页面设置为\“否\”!\")</script>";
			echo "<meta http-equiv='refresh' content='0;url=admin.php?job=creathtm'>";
			exit;
		}
		if(empty($_GET['step'])) {
			$output='正在删除静态(html)页面,请稍等......';
			@unlink('index.htm');
			if($handle = opendir('.')) {
				while (false !== ($file = readdir($handle))) {
					if(strpos($file,'html')!==false) {
        					@unlink($file);
					}
				}
			closedir($handle);
			}
			echo "<meta http-equiv='refresh' content='0;url=admin.php?job=creathtm&do=delete&step=over'>";
		} elseif($_GET['step']=='over') {
			$output='完成相应操作!';
		}
	}
}

require_once template('creathtm','admin');

?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -