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

📄 function.php

📁 php论坛源码论坛软件系统亦称电子公告板(BBS)系统
💻 PHP
字号:
<?php
!function_exists('readover') && exit('Forbidden');

function updatecache_debate(){
	global $db;
	$query = $db->query("SELECT * FROM pw_hack WHERE hk_name LIKE 'debate_%'");
	$homedb = "<?php\r\n";
	while(@extract(deb_db_cv($db->fetch_array($query)))){
		$hk_name = deb_key_cv($hk_name);
		$homedb .= "\$$hk_name='$hk_value';\r\n";
	}
	$homedb .= "\n?>";
	writeover(D_P.'data/bbscache/debate_config.php', $homedb);
}
function updatecache_debatec(){
	global $db;
	$rs=$db->query("select * from pw_debateclass");
	$writemsg="<?php\n\$debateclassdb=array(\n";
	while($debate=deb_db_cv($db->fetch_array($rs))){
		$writemsg.="\t'$debate[cid]'=>'$debate[cname]',\n";
	}
	$writemsg.=");\n?>";
	writeover(D_P."data/bbscache/debate_class.php",$writemsg);
}
function debatesort_cache(){
	global $db;
	$query  = $db->query("SELECT uid,author,posts FROM pw_debateinfo ORDER BY posts DESC LIMIT 10");
	while($rt = $db->fetch_array($query)){
		$dedb[] = $rt;
	}
	$query  = $db->query("SELECT uid,author,replys FROM pw_debateinfo WHERE replys>0 ORDER BY replys DESC LIMIT 10");
	while($rt = $db->fetch_array($query)){
		$replydb[] = $rt;
	}
	writeover(D_P.'data/bbscache/debatesort_cache.php',"<?php\r\n\$dedb=".deb_var_export($dedb).";\r\n\$replydb=".deb_var_export($replydb).";\r\n?>");
}
function debateindex_cache(){
	global $db;
	$newdebatedb=$hotdebatedb=array();
	$query  = $db->query("SELECT did,title,author,authorid,dateline,content,obvote,revote,views,sortid,obtitle,retitle FROM pw_debatethreads WHERE isvisible=1 AND sortid>0 ORDER BY dateline DESC LIMIT 10");
	while($rt = $db->fetch_array($query)){
		$rt['dateline']	 = get_date($rt['dateline']);
		$rt['content']	 = substrs($rt['content'],232);

		$summvote		 = $rt['obvote']+$rt['revote'];
		$rt['obimgwidth']= floor(80*$rt['obvote']/($summvote+1));
		$rt['reimgwidth']= floor(80*$rt['revote']/($summvote+1));
		$rt['sortname']	 = $debateclassdb[$rt['sortid']];
		$rt['obtitle']	 = substrs($rt['obtitle'],34);
		$rt['retitle']	 = substrs($rt['retitle'],34);
		$newdebatedb[] = $rt;
	}
	$query  = $db->query("SELECT did,title,author,authorid,dateline,content,digest,obvote,revote,views,sortid,obtitle,retitle FROM pw_debatethreads WHERE isvisible=1 AND sortid>0 ORDER BY views DESC LIMIT 10");
	while($rt = $db->fetch_array($query)){
		$rt['dateline']	 = get_date($rt['dateline']);
		$rt['content']	 = substrs($rt['content'],232);
		$summvote		 = $rt['obvote']+$rt['revote'];
		$rt['obimgwidth']= floor(80*$rt['obvote']/($summvote+1));
		$rt['reimgwidth']= floor(80*$rt['revote']/($summvote+1));
		$rt['sortname']	 = $debateclassdb[$rt['sortid']];
		$rt['obtitle']	 = substrs($rt['obtitle'],34);
		$rt['retitle']	 = substrs($rt['retitle'],34);
		$hotdebatedb[] = $rt;
	}
	writeover(D_P.'data/bbscache/debateindex_cache.php',"<?php\r\n\$newdebatedb=".deb_var_export($newdebatedb).";\r\n\$hotdebatedb=".deb_var_export($hotdebatedb).";\r\n?>");
}
function ajaxpage($count,$page,$numofpage,$did,$type,$max=0){
	global $tablecolor;
	$total=$numofpage;
	$max && $numofpage > $max && $numofpage=$max;
	if($numofpage <= 1 || !is_numeric($page)){
		return '';
	}else{
		$pages="<div class=\"page\"><a id=\"page_0\" style=\"cursor:pointer\" onClick=\"turnpage(1,$did,$type)\" style=\"font-weight:bold\">&laquo;</a>";
		$flag=0;
		for($i=$page-3;$i<=$page-1;$i++){
			if($i<1) continue;
			$pages.="<a id=\"page_$i\" style=\"cursor:pointer\" onClick=\"turnpage($i,$did,$type)\">$i</a>";
		}
		$pages.="<b> $page </b>";
		if($page<$numofpage){
			for($i=$page+1;$i<=$numofpage;$i++){
				$pages.="<a id=\"page_$i\" style=\"cursor:pointer\" onClick=\"turnpage($i,$did,$type)\">$i</a>";
				$flag++;
				if($flag==4) break;
			}
		}
		$pages.="<a style=\"cursor:hand;\" onClick=\"turnpage($numofpage,$did,$type)\" style=\"font-weight:bold\">&raquo;</a> Pages: ( $page/$total total )</div>";
		return $pages;
	}
}
function deb_var_export($input,$f=1,$t=''){
	$output = '';
	if(is_array($input)){
		$output .= "array(\r\n";
		foreach($input as $key => $value){
			$output .= $t."\t".deb_var_export($key,$f,$t."\t").' => '.deb_var_export($value,$f,$t."\t");
			$output .= ",\r\n";
		}
		$output .= $t.')';
	} elseif(is_string($input)){
		$output .= $f ? "'".str_replace(array("\\","'"),array("\\\\","\'"),$input)."'" : "'$input'";
	} elseif(is_int($input) || is_double($input)){
		$output .= (string)$input;
	} elseif(is_bool($input)){
		$output .= $input ? 'true' : 'false';
	} else{
		$output .= 'NULL';
	}
	return $output;
}
function deb_db_cv($array){
	if(is_array($array)){
		foreach($array as $key=>$value){
			$array[$key]=str_replace(array("\\","'"),array("\\\\","\'"),$value);
		}
	}
	return $array;
}
function deb_key_cv($key){
	$key = str_replace(
		array(';','\\','/','(',')','$'),
		'',
		$key
	);
	return $key;
}
?>

⌨️ 快捷键说明

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