📄 adminfunctions.php
字号:
<?php
error_reporting(7);
// ###################### Start cpheader #######################
function cpheader($headinsert="",$margin=10) {
global $gzipoutput,$nozip;
if ($gzipoutput and !headers_sent() and function_exists("ob_start") and function_exists("crc32") and function_exists("gzcompress") and !$nozip){
ob_start();
}
?>
<html><head>
<meta content="text/html; charset=gb2312" http-equiv="Content-Type">
<meta http-equiv="MSThemeCompatible" content="Yes">
<link rel="stylesheet" href="./cp.css">
<SCRIPT>
function switchSysBar(){
if (switchPoint.innerText==3){
switchPoint.innerText=4
document.all("frmTitle").style.display="none"
}
else{
switchPoint.innerText=3
document.all("frmTitle").style.display=""
}
}
</SCRIPT>
<?php
echo $headinsert;
?>
</head>
<body leftmargin="<?php echo $margin; ?>" topmargin="<?php echo $margin; ?>" marginwidth="<?php echo $margin; ?>" marginheight="<?php echo $margin; ?>">
<?php
}
// ###################### Start cpfooter #######################
function cpfooter() {
global $gzipoutput,$nozip,$level,$HTTP_ACCEPT_ENCODING;
?>
</BODY></HTML>
<?php
if ($gzipoutput and !headers_sent() and function_exists("ob_start") and function_exists("crc32") and function_exists("gzcompress") and !$nozip) {
if (strpos(" ".$HTTP_ACCEPT_ENCODING,"x-gzip")) {
$encoding = "x-gzip";
}
if (strpos(" ".$HTTP_ACCEPT_ENCODING,"gzip")) {
$encoding = "gzip";
}
if ($encoding) {
$text = ob_get_contents();
ob_end_clean();
header("Content-Encoding: $encoding");
$size = strlen($text);
$crc = crc32($text);
$returntext = "\x1f\x8b\x08\x00\x00\x00\x00\x00";
$returntext .= substr(gzcompress($text,$level),0,-4);
$returntext .= pack("V",$crc);
$returntext .= pack("V",$size);
echo $returntext;
exit;
}
}
}
// ##################### Save to AdminUtil Table ##################
function storetext($title, $text) {
global $DB_site;
$DB_site->query("REPLACE INTO adminutil (title, text) VALUES ('" . addslashes($title) . "', '" . addslashes($text) . "')");
return 0;
}
function readtext($title) {
global $DB_site;
$text = $DB_site->query_first("SELECT text
FROM adminutil
WHERE title = '$title'");
return $text['text'];
}
// ###################### Start CP redirect #######################
function cpredirect ($gotopage,$timeout=0) {
// performs a delayed javascript page redirection
echo "\n<script language=\"javascript\">\n";
if ($timeout==0) {
echo "window.location=\"$gotopage\";";
} else {
echo "myvar = \"\"; timeout = ".($timeout*10).";
function dorefresh() {
window.status=\"Redirecting\"+myvar; myvar = myvar + \" .\";
timerID = setTimeout(\"dorefresh();\", 100);
if (timeout > 0) { timeout -= 1; }
else { clearTimeout(timerID); window.status=\"\"; window.location=\"$gotopage\"; }
}
dorefresh();";
}
echo "\n</script>\n";
}
// ###################### Start getrowbg #######################
function getrowbg () {
// returns the current alternating class for <TR> rows in the CP.
global $bgcounter;
if ($bgcounter++%2==0) {
return "firstalt";
} else {
return "secondalt";
}
}
// ###################### Start maketableheader #######################
function maketableheader ($title,$anchor="",$htmlise=1,$colspan=2) {
// makes a two-cell spanning bar with a named <A> and a title
// then reinitialises the bgcolor counter.
global $bgcounter;
echo "<tr class='tblhead'><td colspan='$colspan'><a name=\"$anchor\"><font size='1'><b><span class='tblhead'>".iif($htmlise,htmlspecialchars($title),$title)."</span></b></font></a></td></tr>";
$bgcounter = 0;
}
// ###################### Start makedescription #######################
function makedescription($text,$htmlise=0) {
// makes a two-cell <tr> for text descriptions
echo "<tr class='".getrowbg()."' valign='top'><td colspan='2'>".iif($htmlise==0,$text,htmlspecialchars($text))."</td></tr>\n";
}
// ###################### Start restarttable #######################
function restarttable($insert="") {
// ends the form table, leaves a break and starts it again.
echo "</table></td></tr></table>";
if ($insert != "") {
echo $insert;
}
echo "<br><br>\n\n";
echo "<table cellpadding='1' cellspacing='0' border='0' align='center' width='90%' class='tblborder'><tr><td>\n";
echo "<table cellpadding='4' cellspacing='0' border='0' width='100%'>\n";
}
// ###################### Start writetofile #######################
function writetofile ($path,$data,$backup=0) {
// writes $data to $path renaming the old file if it exists
if (file_exists($path)!=0) {
if ($backup==1) {
$filenamenew=$path."old";
rename ($path,$filenamenew);
} else {
unlink($path);
}
}
if ($data!="") {
$filenum=fopen($path,"w");
fwrite($filenum,$data);
fclose($filenum);
}
}
// ###################### Start readfromfile #######################
function readfromfile ($path) {
// returns all data in $path, or nothing if it does not exist
if(file_exists($path)==0) {
return "";
} else {
$filesize=filesize($path);
$filenum=fopen($path,"r");
$filestuff=fread($filenum,$filesize);
fclose($filenum);
return $filestuff;
}
}
// ###################### Start makeinputcode #######################
function makeinputcode ($title,$name,$value="",$htmlise=1,$size=35) {
// makes code for an imput box: first column contains $title
// second column contains an input box of name, $name and value, $value. $value is "HTMLised"
if ($htmlise) {
$value=htmlspecialchars($value);
}
echo "<tr class='".getrowbg()."' valign='top'>\n<td><p>$title</p></td>\n<td><p><input type=\"text\" size=\"$size\" name=\"$name\" value=\"$value\"></p></td>\n</tr>\n";
}
// ###################### Start makelabelcode #######################
function makelabelcode ($title,$value=" ") {
echo "<tr class='".getrowbg()."' valign='top'>\n<td><p>$title</p></td>\n<td><p>$value</p></td>\n</tr>\n";
}
// ###################### Start makehrcode #######################
function makehrcode () {
// makes code for an <hr>
echo "<tr class='".getrowbg()."' valign='top'>\n<td colspan=2><hr></td>\n</tr>\n";
}
// ###################### Start makeuploadcode #######################
function makeuploadcode ($title,$name,$maxfilesize=1000000) {
// makes code for an imput box: first column contains $title
// second column contains an input box of name
echo "<tr class='".getrowbg()."' valign='top'>\n<td><p>$title</p></td>\n<td><p><INPUT TYPE=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"$maxfilesize\"><input type=\"file\" name=\"$name\"></p></td>\n</tr>\n";
}
// ###################### Start makehiddencode #######################
function makehiddencode ($name,$value="",$htmlise=1) {
// makes code for an imput box: first column contains $title
// second column contains an input box of name, $name and value, $value. $value is "HTMLised"
if ($htmlise) {
$value=htmlspecialchars($value);
}
echo "<input type=\"hidden\" name=\"$name\" value=\"$value\">\n";
}
// ###################### Start makepasswordcode #######################
function makepasswordcode ($title,$name,$value="",$htmlise=1,$size=35) {
// makes code for an imput box: first column contains $title
// second column contains an input box of name, $name and value, $value. $value is "HTMLised"
if ($htmlise) {
$value=htmlspecialchars($value);
}
echo "<tr class='".getrowbg()."' valign='top'>\n<td><p>$title</p></td>\n<td><p><input type=\"password\" size=\"$size\" name=\"$name\" value=\"$value\"></p></td>\n</tr>\n";
}
// ###################### Start makeyesnocode #######################
function makeyesnocode ($title,$name,$value=1) {
// Makes code for input buttons yes\no similar to makeinputcode
echo "<tr class='".getrowbg()."' valign='top'>\n
<td><p>$title</p></td>\n<td><p>是<input type='radio' name='$name' value='1' "
.iif($value==1 or ($name=='pmpopup' and $value==2),"checked","")."> 否 <input type='radio' name='$name' value='0' "
.iif($value==0,"checked","").">"
.iif($value==2 and $name=='customtitle'," User Set (no html)<input type='radio' name='$name' value='2' checked>","")
."</p></td>\n</tr>";
}
// ###################### Start maketextareacode #######################
function maketextareacode ($title,$name,$value="",$rows=4,$cols=40,$htmlise=1) {
// similar to makeinputcode, only for a text area
if ($htmlise) {
$value=htmlspecialchars($value);
}
echo "<tr class='".getrowbg()."' valign='top'>\n<td><p>$title</p></td>\n<td><p><textarea name=\"$name\" rows=\"$rows\" cols=\"$cols\">$value</textarea></p></td>\n</tr>\n";
}
// ###################### Start doformheader #######################
function doformheader ($phpscript,$action,$uploadform=0,$addtable=1,$name="name") {
// makes the standard form header, setting sctript to call and action to do
global $session,$tableadded;
echo "<form action=\"$phpscript.php\" ".iif($uploadform,"ENCTYPE=\"multipart/form-data\" ","")." name=\"$name\" method=\"post\">\n<input type=\"hidden\" name=\"s\" value=\"$session[sessionhash]\"><input type=\"hidden\" name=\"action\" value=\"$action\">\n";
if ($addtable==1) {
$tableadded = 1;
echo "<br><table cellpadding='1' cellspacing='0' border='0' align='center' width='90%' class='tblborder'><tr><td>\n";
echo "<table cellpadding='4' cellspacing='0' border='0' width='100%'>\n";
} else {
$tableadded = 0;
}
}
// ###################### Start doformfooter #######################
function doformfooter($submitname="提交",$resetname="复位",$colspan=2,$goback="") {
// closes the standard form table and makes a new one containing centred submit and reset buttons
global $tableadded;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -