点评系统一如既往的好用,功能细化到令人发指的地步,值得推荐,本资源不像论坛那样购买会员然后要回复或者积分等级才能下载,下载了未必能用,本资源立即下载即用,减少了论坛的繁琐流程,没有任何限制,不限制任何域名。 正式版更新内容: 手机版变化如下:
点评系统一如既往的好用,功能细化到令人发指的地步,值得推荐,本资源不像论坛那样购买会员然后要回复或者积分等级才能下载,下载了未必能用,本资源立即下载即用,减少了论坛的繁琐流程,没有任何限制,不限制任何域名。
<?php /** * 通用函数库 * @author moufer<moufer@163.com> * @copyright (C)2001-2007 Moufersoft */ !defined('IN_MUDDER') && exit('Access Denied'); define('MF_INT_KEY', '_int_keyid'); define('MF_INT', 'intval'); define('MF_FLOAT', 'floatval'); define('MF_HTML', '_HTML'); define('MF_TEXT', '_T'); //取得$_GET里的变量 function _get($var, $default = null, $convert_fun='') { if(isset($_GET[$var])) { if($convert_fun) return $convert_fun($_GET[$var]); return $_GET[$var]; } return $default; } //取得$_GET里的变量 function _post($var, $default = null, $convert_fun='') { if(isset($_POST[$var])) { if($convert_fun) return $convert_fun($_POST[$var]); return $_POST[$var]; } return $default; } //取得$_COOKIE里的变量 function _cookie($var, $default = null, $prefix = 1) { global $_G; if($prefix) { return isset($_G['cookie'][$var]) ? $_G['cookie'][$var] : $default; } else { return isset($_COOKIE[$var]) ? $_COOKIE[$var] : $default; } } //取得一个输入变量 function _input($var, $default = null, $convert_fun='', $sx='pg') { $r = $default; $c = strlen($sx); $funs = array('p'=>'_post','g'=>'_get'); for($i=0;$i<$c;$i++) { $x = $sx{$i}; $f = isset($funs[$x]) ? $funs[$x] : ''; if(!$f) continue; $r = $f($var, $default, $convert_fun); if(!empty($r) && $r != $default) return $r; } if(!$r) $r = $default; return $r; } //设置$_POST里的变量 function set_post($var, $value = '') { $_POST[$var] = $value; } //设置$_POST里的变量 function set_get($var, $value = '') { $_GET[$var] = $value; } //设置cookie function set_cookie($var, $value, $life = 0, $prefix = 1) { $life = $life ? _G('timestamp') + $life : 0; $secure = $_SERVER['SERVER_PORT'] == '443' ? 1 : 0; $var = ($prefix ? _G('cookiepre') : '') . $var; return setcookie($var, $value, $life, _G('cookiepath'), _G('cookiedomain'), $secure); } //删除cookie function del_cookie($var, $prefix = 1) { if(is_array($var)) { foreach($var as $val) set_cookie($val, '', -360000, $prefix); } else { set_cookie($var, '', -360000, $prefix); } } // Get Global value function &_G() { global $_G; $max_level = 5; $result = ''; $args_num = func_num_args(); if($args_num > $max_level) return $result; $args = func_get_args(); $val =& $_G; foreach ($args as $v) { if(!isset($val[$v])) return $result; $val =& $val[$v]; } return $val; } /** * 获取公共配置文件夹(APP_ROOT/config/)文件数据 * @static var array $config * @param string $key 支持二维,三维数组查询,如:aa.bbb,表示: 二维数组['aaa']['bbb'];参数为"@all":表示获取指定文件的全部数据; * @param string $config_file_name 需要获取数据的文件(不写.php),默认获取global.php里的 * @return array|null */ function config($key, $module = 'modoer') { static $config = array(); if(!$module) $module = 'modoer'; if(!isset($config[$module])) { $config[$module] = _G('loader')->variable('config', $module); } if($key == '@all') return $config[$module]; if(strpos($key, '.')) { $keys = explode('.', $key); $tmp =& $config[$module]; foreach ($keys as $k) { if(!is_array($tmp) || !isset($tmp[$k])) return null; $tmp =& $tmp[$k]; } return $tmp; } else { if(isset($config[$module][$key])) return $config[$module][$key]; } return null; } //获取一个数字型的数据库主键id值 function _int_keyid($string) { if(is_array($string)) { foreach($string as $key => $val) $string[$key] = _int_keyid($val); return $string; } else { return abs((int)$string); } } //过滤HTML,用于Text function _T($string) { if(is_array($string)) { foreach($string as $key => $val) $string[$key] = _T($val); return $string; } else { $string = is_string($string) ? preg_replace("/&(#[0-9]+|[a-z]+);/i", "&$1;", htmlspecialchars($string, ENT_QUOTES)) : $string; return str_replace($wu, $rp, trim($string)); } } //过滤HTML,用于TextArea function _TA($string) { return preg_replace("/(\r\n|\n\r|\n|\r)/", "\r\n", _T($string)); } //支持HTML格式,过滤可能引起安全问题的HTML标记 function _HTML($string) { $search_arr = array("/(javascript|jscript|js|vbscript|vbs|about):/i","/on(mouse|exit|error|click|dblclick|key|load|unload|change|move|submit|reset|cut|copy|select|start|stop)/i","/<script([^>]*)>/i","/<iframe([^>]*)>/i","/<frame([^>]*)>/i","/<link([^>]*)>/i","/@import/i"); $replace_arr = array("\\1\n:","on\n\\1","<script\\1>","<iframe\\1>","<frame\\1>","<link\\1>","@\nimport"); $string = preg_replace($search_arr, $replace_arr, $string); //$string = str_replace("&#", "&\n#", $string); return $string; } //格式化换行符号 function _NL($string) { return trim(preg_replace("/\s*(\r\n|\n\r|\n|\r)\s*/", "\r\n", $string)); } //把字符串转化为JS的字符变量 function _JStr($string) { return str_replace(array('"', "\r\n", "\n"), array('\"', '', ''), $string); } //把一维数组转换为字符串 function _ArrayToStr($array, $split=',') { if(empty($array)) return ''; if(!is_array($array)) return $array; return implode($split, $array); } //简单加密 function authcode($string, $operation = 'DECODE') { $string = $operation == 'DECODE' ? base64_decode($string) : base64_encode($string); return $string; } //数组格式化 function arrayeval($array, $level = 0) { if(!is_array($array)) { return "'".$array."'"; } if(is_array($array) && function_exists('var_export')) { return var_export($array, true); } $space = ''; for($i = 0; $i <= $level; $i++) { $space .= "\t"; } $evaluate = "array (\n\r"; $comma = $space; if(is_array($array)) { foreach($array as $key => $val) { $key = is_string($key) ? '\''.add_cs_lashes($key).'\'' : $key; $val = !is_array($val) && (!preg_match("/^\-?[0-9]\d*$/", $val) || strlen($val) > 12) ? '\''.add_cs_lashes($val, '\'\\').'\'' : $val; if(is_array($val)) { $evaluate .= "$comma$key => ".arrayeval($val, $level + 1); } else { $evaluate .= "$comma$key => $val"; } $comma = ",\n\r$space"; } } $evaluate .= "\n\r$space)"; return $evaluate; } //以 C 语言风格使用反斜线转义字符串中的字符 function add_cs_lashes($string) { return $string ? addcslashes($string, '\'\\') : ''; } //转换数组里的全部数值 function new_intval($number) { if(is_array($number)) foreach($number as $key => $val) $number[$key] = new_intval($val); else return intval($number); return $number; } //Un-quotes a quoted string function strip_slashes($string, $filter_line=false) { if(is_array($string)) foreach($string as $key => $val) $string[$key] = strip_slashes($val); else $string = is_string($string) ? stripslashes($string) : $string; if($filter_line) $string = str_replace(array("\r\n","\n"),'', $string); return $string; } //过滤SQL function strip_sql($string) { $pattern_arr = array("/ union /i", "/ select /i", "/ update /i", "/ outfile /i", "/ or /i"); $replace_arr = array(' union ', ' select ', ' update ',' outfile ', ' or '); return is_array($string) ? array_map('strip_sql', $string) : preg_replace($pattern_arr, $replace_arr, $string); } //过滤orderby function strip_order($string) { $string = preg_replace('/.?select.+from.+/i', '', $string); $string = preg_replace("/.?delete.+from.+/i", '', $string); $string = preg_replace("/.?update.+set.+/i", '', $string); $string = preg_replace("/.?select.+union.+/i", '', $string); return $string; } //转换浮点数 function cfloat($float) { $num = (float)$float; return $num; } //从开端截取 function trimmed_title($text, $limit=12, $ext='') { if ($limit) { $val = csubstr($text, 0, $limit); return $val[1] ? $val[0].$ext : $val[0]; } else { return $text; } } //截取 function csubstr($text, $start=0, $limit=12) { $charset = _G('charset'); if (function_exists('mb_substr')) { $more = (mb_strlen($text, $charset) > $limit) ? true : false; $text = mb_substr($text, $start, $limit, $charset); return array($text, $more); } elseif (function_exists('iconv_substr')) { $more = (iconv_strlen($text) > $limit) ? true : false; $text = iconv_substr($text, $start, $limit, $charset); return array($text, $more); } elseif (strtolower($charset) == "utf-8") { preg_match_all("/[\x01-\x7f]|[\xc2-\xdf][\x80-\xbf]|\xe0[\xa0-\xbf][\x80-\xbf]|[\xe1-\xef][\x80-\xbf][\x80-\xbf]|\xf0[\x90-\xbf][\x80-\xbf][\x80-\xbf]|[\xf1-\xf7][\x80-\xbf][\x80-\xbf][\x80-\xbf]/", $text, $ar); if(func_num_args() >= 3) { if (count($ar[0])>$limit) { $more = true; $text = join("",array_slice($ar[0],$start,$limit))."..."; } else { $more = false; $text = join("",array_slice($ar[0],$start,$limit)); } } else { $more = false; $text = join("",array_slice($ar[0],$start)); } return array($text, $more); } else { $fStart = 0; $fStart = $fStart * 2; $limit = $limit * 2; $strlen = strlen($text); for ( $i = 0; $i < $strlen; $i++ ) { if ($i >= $fStart && $i < ($fStart + $limit ) ) { if (ord(substr($text, $i, 1)) > 129) $tmpstr .= substr($text, $i, 2); else $tmpstr .= substr($text, $i, 1); } if (ord(substr($text, $i, 1)) > 129 ) $i++; } $more = strlen($tmpstr) < $strlen; return array($tmpstr, $more); } } //计算字符数量,非占用字节 function strlen_ex($str) { $charset = _G('charset'); if(function_exists('mb_strlen')) { return mb_strlen($str, $charset); } elseif(function_exists('iconv_strlen')) { return iconv_strlen($str, $charset); } elseif($charset == 'utf-8') { preg_match_all("/[\x01-\x7f]|[\xc2-\xdf][\x80-\xbf]|\xe0[\xa0-\xbf][\x80-\xbf]|[\xe1-\xef][\x80-\xbf][\x80-\xbf]|\xf0[\x90-\xbf][\x80-\xbf][\x80-\xbf]|[\xf1-\xf7][\x80-\xbf][\x80-\xbf][\x80-\xbf]/", $str, $ar); return count($ar[0]); } else { $len = 0; $strlen = strlen($str); for( $i = 0; $i < $strlen; $i++ ) { $len++; if (ord(substr($str, $i, 1)) > 129 ) $i++; } return $len; } } //截取,按字节数量截取 function substr_ex($text, $start=0, $limit=255) { $charset = _G('charset'); list($s,) = csubstr($text, $start, $limit); $len = strlen($s); if($len <= $limit) return $s; $i = $l =0; $mo = $charset == 'utf-8' ? 3 : 2; $str = ''; while($l < $limit) { $z = floor(($limit - $l) / $mo); !$z && $z = 1; $y = csubstr($s, $i, $z); $i += $z; $l = strlen($str) + strlen($y[0]); if($l <= $limit) { $str .= $y[0]; } else { break; } } return $str; } //转换unix时间戳 function newdate($date, $format='Y-m-d H:i', $dnum=2, $dunit='月') { $timestamp = _G('timestamp'); $date == 'NOW' ? $timestamp : $date; if(!$date) return ''; $date = is_numeric($date) ? $date : (!$date ? $timestamp : strtotime($date)); $date = ($date == -1 || !$date) ? $timestamp : $date; if($format != 'w2style') { return date($format, $date); } else { $tm = $timestamp - $date; $num = 0; if($tm < 60) { $num = $tm; $unit = 'second'; } elseif($tm < 3600) { $num = floor($tm / 60); $unit = 'minute'; } elseif($tm < 3600 * 24) { $num = floor($tm / 3600); $unit = 'hour'; } elseif($tm < 3600 * 24 * 30) { $num = floor($tm / (3600 * 24)); $unit = 'day'; } elseif($tm < 3600 * 24 * 30 * 365) { $num = floor($tm / (3600 * 24 * 30)); $unit = 'month'; } if($dnum <= $num && $dunit == $unit) { return date('Y-m-d H:i', $date); } return $num > 0 ? (lang('global_time_format', array($num, lang('global_time_'.$unit)))) : date('Y-m-d', $date); } } //判断电子邮件 function isemail($email) { return strlen($email) > 6 && preg_match("/^[\w\-\.]+@[\w\-\.]+(\.\w+)+$/", $email); } //判断是不是图片 function is_image($imgfile) { if(!$imgfile) return; $ext = strtolower(pathinfo($imgfile, PATHINFO_EXTENSION)); $exts = array('png','jpeg','jpg','gif'); if(!in_array($ext, $exts)) return false; if(!function_exists('getimagesize')) return false; if(!is_file($imgfile)) return false; return @getimagesize($imgfile); } //判断字符串是否被序列化 function is_serialized( $data ) { // if it isn't a string, it isn't serialized if ( !is_string( $data ) ) return false; $data = trim( $data ); if ( 'N;' == $data ) return true; if ( !preg_match( '/^([adObis]):/', $data, $badions ) ) return false; switch ( $badions[1] ) { case 'a' : case 'O' : case 's' : if ( preg_match( "/^{$badions[1]}:[0-9]+:.*[;}]\$/s", $data ) ) return true; break; case 'b' : case 'i' : case 'd' : if ( preg_match( "/^{$badions[1]}:[0-9.E-]+;\$/", $data ) ) return true; break; } return false; } //判断文件是否可写 function is__writable($path) { if ($path{strlen($path)-1}=='/') return is__writable($path.uniqid(mt_rand()).'.tmp'); else if (is_dir($path)) return is__writable($path.'/'.uniqid(mt_rand()).'.tmp'); $rm = file_exists($path); $f = @fopen($path, 'a'); if ($f===false) return false; fclose($f); if (!$rm) unlink($path); return true; } //获取随机数 ALL(数字或字母),NUM(数字),WORD(字母) function random($length=8, $idtype='ALL') { PHP_VERSION < '4.2.0' && mt_srand((double)microtime() * 1000000); $hash = ''; for ($i = 0; $i < $length; $i++) { if ( 'NUM' == $idtype ) { if (0==$i) { $hash .= chr(rand(49, 57)); } else { $hash .= chr(rand(48, 57)); } } else if ( 'WORD' == $idtype ){ $hash .= chr(rand(65, 90)); } else { if ( 0==$i ) { $hash .= chr(rand(65, 90)); } else { $hash .= (0==rand(0,1))?chr(rand(65, 90)):chr(rand(48,57)); } } } return $hash; } //生成参数序列 function create_identifier($params) { return substr(md5(serialize($params)),0,8); } //生成表单序列 function create_formhash($p1, $p2, $p3) { $authkey = _G('cfg','authkey'); return substr(md5($authkey . $p1 . $p2 . $p3), 8, 8); } //替换全角数字 function cdc2dbc($number) { $search_arr = array('0','1','2','3','4','5','6','7','8','9'); $replace_arr = array('0','1','2','3','4','5','6','7','8','9'); return str_replace($search_arr, $replace_arr, $number); } //判断字串长度范围 function string_length($string, $min, $max) { return strlen($string) >= $min && strlen($string) <= $max;