【php开源代码栏目提醒】:文章导读:在新的一年中,各位网友都进入紧张的学习或是工作阶段。网学会员整理了php开源代码-adminfunctions.php的相关内容供大家参考,祝大家在新的一年里工作和学习顺利!
<?php
// 鎿嶄綔鎻愮ず椤甸潰
function redirect($msg, $url = 'javascript:history.go(-1);', $min='2') {
global $smarty;
$smarty->assign("url", $url);
$smarty->assign("min", $min);
$smarty->assign("msg", $msg);
$smarty->display("redirect.dll");
PageEnd();
}
// 鎺у埗闈㈡澘鍚勯〉闈㈤〉鑴?
function cpfooter() {
global $smarty,$base,$adminitem,$action,$starttime,$DB,$FY_VERSION,$FY_RELEASE;
$mtime = explode(' ', microtime());
$totaltime = number_format(($mtime[1] + $mtime[0] - $starttime), 6);
$gzip = $base['gzipcompress'] ? 'enabled' : 'disabled';
$debuginfo = 'Processed in '.$totaltime.' second(s), '.$DB->querycount.' queries, Gzip '.$gzip;
$smarty->assign("debuginfo", $debuginfo);
$smarty->display("footer.dll");
PageEnd();
}
// 杩斿洖GD鍑芥暟鐗堟湰鍙?
function gd_version() {
if (function_exists('gd_info')) {
$GDArray = gd_info();
$gd_version_number = $GDArray['GD Version'] ? $GDArray['GD Version'] : 0;
unset($GDArray);
} else {
$gd_version_number = 0;
}
return $gd_version_number;
}
//鐩綍鐨勫疄闄呭ぇ灏?
function dirsize($dir) {
$dh = @opendir($dir);
$size = 0;
while($file = @readdir($dh)) {
if ($file != '.' && $file != '..') {
$path = $dir.'/'.$file;
if (@is_dir($path)) {
$size += dirsize($path);
} else {
$size += @filesize($path);
}
}
}
@closedir($dh);
return $size;
}
//鐩綍涓暟
function dircount($dir) {
$dh = @opendir($dir);
$count = 0;
while($file = @readdir($dh)) {
if ($file != '.' && $file != '..') {
$path = $dir.'/'.$file;
if (@is_dir($path)) {
$count++;
}
}
}
@closedir($dh);
return $count;
}
// 鑾峰彇鏁版嵁搴撳ぇ灏忓崟浣?
function get_real_size($size) {
$kb = 1024; // Kilobyte
$mb = 1024 * $kb; // Megabyte
$gb = 1024 * $mb; // Gigabyte
$tb = 1024 * $gb; // Terabyte
if($size < $kb) {
return $size.' Byte';
}else if($size < $mb) {
return round($size/$kb,2).' KB';
}else if($size < $gb) {
return round($size/$mb,2).' MB';
}else if($size < $tb) {
return round($size/$gb,2).' GB';
}else {
return round($size/$tb,2).' TB';
}
}
// 鍚庡彴鐧诲綍璁板綍
function loginresult($result) {
global $timestamp,$onlineip,$fy_user;
writelog(ROOT.'cache/log/loginlog.php', "<?PHP exit('Access Denied'); ?>\t$fy_user\t$timestamp\t$onlineip\t$result\n");
}
// 鍚庡彴绠$悊璁板綍
function getlog() {
global $timestamp, $onlineip, $fy_user;
if ($_POST['action']) {
$action = $_POST['action'];
$script = str_replace('go=', '', $_SERVER['QUERY_STRING']);
writelog(ROOT.'cache/log/adminlog.php', "<?
PHP exit('Access Denied'); ?>\t$timestamp\t".htmlspecialchars($fy_user)."\t$onlineip\t".htmlspecialchars(trim($action))."\t".htmlspecialchars(trim($script))."\n");
}
}
// 鍐欐棩蹇?
function writelog($filename,$filedata)
{
@$fp=fopen($filename, 'a');
@flock($fp, 2);
@fwrite($fp, $filedata);
@fclose($fp);
@chmod($filename, 0777);
}
// 妫鏌ユ爣棰樻槸鍚︾鍚堥昏緫
function checktitle($title) {
if(!$title || strlen($title) > 120) {
$result = '鏍囬涓嶈兘涓虹┖骞朵笖涓嶈兘瓒呰繃120涓瓧绗?br />';
return $result;
}
}
// 妫鏌ュ垎绫绘槸鍚﹀凡閫夋嫨
function checkcate($cid) {
if(!$cid) {
$result = '浣犺繕娌℃湁閫夋嫨鍒嗙被<br />';
return $result;
}
}
// 妫鏌ユ彁浜ゅ唴瀹规槸鍚︾鍚堥昏緫
function checkcontent($content) {
if(!$content || strlen($content) < 4) {
$result .= '鍐呭涓嶈兘涓虹┖骞朵笖涓嶈兘灏戜簬4涓瓧绗?br />';
return $result;
}
}
// 妫鏌ユ彁浜ゅ叧閿瓧鏄惁绗﹀悎閫昏緫
function checkkeywords($keywords) {
$v = explode(',', $keywords);
$v_num = count($v);
if ($v_num > 5) {
$result .= '鏍囩(Tags)鐨勫叧閿瓧涓嶈兘瓒呰繃5涓?br />';
return $result;
} else {
for($i=0; $i<$v_num; $i++) {
if(strlen($v[$i]) > 15) {
$result .= '鏍囩(Tags)鐨勬瘡涓叧閿瓧涓嶈兘瓒呰繃15涓瓧绗? ".htmlspecialchars($v[$i])." 瓒呰繃浜?5涓瓧绗?br />';
return $result;
}
}
}
}
// 妫鏌ユ彁浜ag鏄惁绗﹀悎閫昏緫
function checktag($tag) {
$tag = str_replace('锛?, ',', $tag);
if (strrpos($tag, ',')) {
$result .= '鍏抽敭瀛椾腑涓嶈兘鍚湁鈥?鈥濇垨鈥滐紝鈥濆瓧绗?br />';
return $result;
}
if(strlen($tag) > 15) {
$result .= '鍏抽敭瀛椾笉鑳借秴杩?5涓瓧绗?br />';
return $result;
}
}
// 妫鏌ラ摼鎺RL鏄惁绗﹀悎閫昏