📄 func.php
字号:
<?
function page_menu($totalnum) {
global $p,$PHP_SELF,$type;
$recnum = 20;
$listnum = 10;
$pagenum = $p;
if(!$p){$pagenum = 1; $p = 1;}
if($p > $listnum) {
if ($p == 1) {
echo "\n";
}
else {
$PrevPage = $p-1;
echo "<a href=$PHP_SELF?type=$type&p=1 title=首页>[1]</a>\n";
}
}
$term = $listnum;$f = 1;$l = $term;while ($f <= $totalnum) {
if (($f <= $p) && ($p <= $l)) {
$prevp = $f - 1;
if ($prevp > 0) {
echo "<a href=$PHP_SELF?type=$type&p=$prevp title=\"前 $listnum页\">[Prev]</a>-";
}
else {
echo "\n";
}
if ($l <= $totalnum) {
for ($page = $f; $page <= $l; $page++) {
if ($page == $p) {
echo "[<font color=red title=当前页>$page</font>]";
}
else {
echo "<a href=$PHP_SELF?type=$type&p=$page title=$page页>[$page]</a>";
}
}
}
else {
for ($page = $f; $page <= $totalnum; $page++) {
if ($page == $p) {
echo "[<font color=red title=当前页>$page</font>]";
}
else {
echo "<a href=$PHP_SELF?type=$type&p=$page title=$page页>[$page]</a>";
}
}
}
$nextp = $l + 1;
if ($nextp <= $totalnum) {
echo "-<a href=$PHP_SELF?type=$type&p=$nextp title=\"后 $listnum页\">[Next]</a>";
}
else {
echo "";
}
}
$f = $f + $term;
$l = $l + $term;
}
if($nextp <= $totalnum){
echo "<a href=$PHP_SELF?type=$type&p=$totalnum title=尾页>[$totalnum]</a>\n";
}
}
/////////////////安检函数/////////////////////////////
function safe_cover($s) {
$s=str_replace("|","│",$s);
$s=str_replace("<","<",$s);
$s=str_replace(">",">",$s);
$s=str_replace("\t","",$s);
$s=str_replace("\n","<br>",$s);
$s=str_replace("\r","",$s);
$bad="他妈的|妈的|他爸的|操你妈|狗娘的|狗日的|shit|日你娘|日你妈|娘的|日你姐|fuck|龟儿子|龟孙子|兔崽子";
$bad_array=explode("|",$bad);
$co=count($bad_array)-1;
for ($i=0;$i<=$co;$i++) {
$s=str_replace($bad_array[$i],"xxx",$s);
}
return $s; }
/////////////////获取文件类型函数/////////////////////
function get_file_type($type1)
{
if ( !$type1 ) { $ftype = "unknown.gif "; return $ftype; }
if( eregi($type1, "html")) { $ftype = "html.gif"; }
elseif( eregi($type1, "exe")) { $ftype = "exe.gif"; }
elseif( eregi($type1, "zip|gz|tar")) { $ftype = "zip.gif"; }
elseif( eregi($type1, "rar")) { $ftype = "rar.gif"; }
elseif( eregi($type1, "gif")) { $ftype = "gif.gif"; }
elseif( eregi($type1, "php3|phtml|inc")) { $ftype = "php3.gif"; }
elseif( eregi($type1, "jpeg|jpg")) { $ftype = "jpg.gif"; }
elseif( eregi($type1, "bmp")) { $ftype = "bmp.gif"; }
elseif( eregi($type1, "mid")) { $ftype = "mid.gif"; }
elseif( eregi($type1, "wav")) { $ftype = "wav.gif"; }
elseif( eregi($type1, "mp3")) { $ftype = "mp3.gif"; }
elseif( eregi($type1, "ra")) { $ftype = "ra.gif"; }
elseif( eregi($type1, "mpeg|asf|mpg|avi|asx|mov")) { $ftype = "mpeg.gif"; }
elseif( eregi($type1, "doc")) { $ftype = "doc.gif"; }
elseif( eregi($type1, "hwp")) { $ftype = "hwp.gif"; }
elseif( eregi($type1, "xls")) { $ftype = "xls.gif"; }
elseif( eregi($type1, "ppt")) { $ftype = "ppt.gif"; }
elseif( eregi($type1, "cgi|pl|pm")) { $ftype = "cgi.gif"; }
elseif( eregi($type1, "js|css|class")) { $ftype = "js.gif"; }
elseif( eregi($type1, "swf")) { $ftype = "swf.gif"; }
elseif( eregi($type1, "txt")) { $ftype = "text.gif"; }
elseif( eregi($type1, "dat")) { $ftype = "dat.gif"; }
else { $ftype = "unknown.gif"; }
return $ftype;
}
/////////////////错误显示函数/////////////////////
function error_0($msg,$turn_page) {
echo "<HTML>";
echo "<HEAD>";
echo "<META http-equiv='Content-Type' content='text/html; charset=gb2312'>";
echo "<TITLE>执行错误</TITLE>";
echo "<LINK href=\"style.css\" type=text/css rel=stylesheet>";
echo "</HEAD>";
echo "<BODY BGCOLOR='EFEFEF' MARGINWIDTH='0' MARGINHEIGHT='0' LEFTMARGIN='0' TOPMARGIN='0'>";
echo "<br><br><br><br><br><br><br><br><br>";
echo "<CENTER>";
echo "<div align=center><TABLE bgColor=#8585d6 border=0 cellSpacing=0 height=30 width=60%>";
echo "<TBODY>";
echo "<TR>";
echo "<TD vAlign=center width='100%' bgcolor='#a6a7d9'> <font color=#ffffff>管理系统——<font color=red>执行错误</font></font></TD>";
echo "</TR></TBODY></TABLE></DIV>";
echo "<table align=center bgcolor=#808080 border=0 cellpadding=3 cellspacing=1 width='60%'>";
echo "<tbody>";
echo "<tr bgcolor='EFEFEF'>";
echo "<td>注意:<br> <font color=red>*$msg</font></td>";
echo "</tr>";
echo "<tr bgcolor='EFEFEF'>";
echo "<td>";
echo "<p align='right'> 若您有什么问题,请联系管理员 <input name=Submit type=submit value=\"按此返回\" onClick=\"location.href='javascript:history.back(1)'\" style=\"font-family: 宋体, Arial; font-size: 9pt; height:20px;background-color:#f3f3f3;border:1 solid black\" onMouseOver =\"this.style.backgroundColor='#a6a7d9'\" onMouseOut =\"this.style.backgroundColor='#f3f3f3'\"> ";
echo "</p>";
echo "</td> ";
echo "</tr> ";
echo "</tbody>";
echo "</table>";
echo "</CENTER>";
echo "</BODY>";
echo "</HTML>";
}
/////////////////正确显示函数/////////////////////
function error_1($msg,$turn_page) {
echo "<HTML>";
echo "<HEAD>";
echo "<META http-equiv='Content-Type' content='text/html; charset=gb2312'>";
echo "<TITLE>执行错误</TITLE>";
echo "<LINK href=\"style.css\" type=text/css rel=stylesheet>";
echo "</HEAD>";
echo "<BODY BGCOLOR='EFEFEF' MARGINWIDTH='0' MARGINHEIGHT='0' LEFTMARGIN='0' TOPMARGIN='0'>";
echo "<br><br><br><br><br><br><br><br><br>";
echo "<CENTER>";
echo "<div align=center><TABLE bgColor=#8585d6 border=0 cellSpacing=0 height=30 width=60%>";
echo "<TBODY>";
echo "<TR>";
echo "<TD vAlign=center width='100%' bgcolor='#a6a7d9'> <font color=#ffffff>管理系统——<font color=green>执行正确</font></font></TD>";
echo "</TR></TBODY></TABLE></DIV>";
echo "<table align=center bgcolor=#808080 border=0 cellpadding=3 cellspacing=1 width='60%'>";
echo "<tbody>";
echo "<tr bgcolor='EFEFEF'>";
echo "<td>注意:<br> <font color=green>*$msg</font></td>";
echo "</tr>";
echo "<tr bgcolor='EFEFEF'>";
echo "<td>";
echo "<p align='right'> 若您有什么问题,请联系管理员 <input name=Submit type=submit value=\"按此返回\" onClick=\"location.href='javascript:history.back(1)'\" style=\"font-family: 新细明体, 宋体, Arial; font-size: 9pt; height:20px;background-color:#f3f3f3;border:1 solid black\" onMouseOver =\"this.style.backgroundColor='#a6a7d9'\" onMouseOut =\"this.style.backgroundColor='#f3f3f3'\"> ";
echo "</p>";
echo "</td> ";
echo "</tr> ";
echo "</tbody>";
echo "</table>";
echo "</CENTER>";
echo "</BODY>";
echo "</HTML>";
}
/////////////////文件分行写入尾-写入最后一行,去掉最上面一行//////
function add_new_file($dir,$file_new,$file_num) {
$file_typenew=file("$dir");
$file_typenew_count=count($file_typenew);
if ($file_typenew_count<$file_num) {
$fp_typenew=fopen("$dir","a+");
flock($fp_typenew,3);
fwrite($fp_typenew,$file_new);
fclose($fp_typenew);}
elseif ($file_typenew_count>=$file_num) {
$fp_typenew=fopen("$dir","w");
flock($fp_typenew,3);
for ($i=1;$i<=$file_num-1;$i++) {
fwrite($fp_typenew,$file_typenew[$i]);
}
fwrite($fp_typenew,$file_new);
fclose($fp_typenew);
}
}
/////////////////删除文件夹与它下面的文件//////////////////////////////
function delfile($path) {
$handle=opendir($path);
@chdir($path);
while (($file=readdir($handle))!="")
{
if (($file==".") OR ($file=="..")) continue;
if (is_dir($file))
delfile($file);
else
{
if (@unlink($file))
$msg_1[]="<dd>删除编号 <font color=green>".$file."</font>文章 …… <font color=blue>成功!</font><br>";
else
$msg_1[]="<dd>删除编号 <font color=green>".$file."</font>文章 …… <font color=red>失败!</font><br>";
}
}
closedir($handle);
@chdir("..");
if (@rmdir($path))
$msg_1[]="<dd>删除目录 <font color=green>".$path."</font>…… <font color=red>成功!</font><br>";
else
$msg_1[]="<dd>删除目录 <font color=green>".$path."</font>…… <font color=red>失败!</font><br>";
$msg_count=count($msg_1);
static $msg;
for ($i=0; $i<=$msg_count;$i++){
$msg.=$msg_1[$i];}
$msg.="<p> <font color=green>*您成功删除此二级分类</font></p>";
$turn_page="form.php";
error_1($msg,$turn_page);
exit;
}
/////////////////分类option显示方法//////////////////////////////
function make_type() {
$type_info=file("../data/xq.php");
$type_count=count($type_info);
for($i=0; $i<$type_count; $i++) {
$detail=explode("|", $type_info[$i]);
if ($detail[0]=="form") echo"<option value=\"$detail[1]\">--$detail[2]--</option>";
else echo"<option value=\"$detail[1]\">$detail[2]</option>";
}
}
function make_spe() {
$type_info=file("../data/xq.cgi");
$type_count=count($type_info);
for($i=0; $i<$type_count; $i++) {
$detail=explode("|", $type_info[$i]);
echo"<option value=\"$detail[1]\">$detail[2]</option>";
}
}
function make_onlytype() {
$type_info=file("../data/xq.php");
$type_count=count($type_info);
for($i=0; $i<$type_count; $i++) {
$detail=explode("|", $type_info[$i]);
if ($detail[0]=="type") echo"<option value=\"$detail[1]\">$detail[2]</option>";
}
}
/////////////////////////////////////////////////////////////////
function getextension($file) {
$pos=strrpos($file, ".");
if (is_string ($pos) && !$pos) {
return "";
} else {
$ext=substr($file, $pos+1);
return $ext;
}
}
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -