/is', $html, $ms);
$searchs[] = '<';
$replaces[] = '<';
$searchs[] = '>';
$replaces[] = '>';
if ($ms[1]) {
$allowtags = 'img|a|font|div|table|tbody|caption|tr|td|th|br|p|b|strong|i|u|em|span|ol|ul|li|blockquote|object|param|embed';
$ms[1] = array_unique($ms[1]);
foreach ($ms[1] as $value) {
$searchs[] = '<' . $value . '>';
$value = str_replace('&', '_uch_tmp_str_', $value);
$value = mhtmlspecialchars($value);
$value = str_replace('_uch_tmp_str_', '&', $value);
$value = str_replace(array('\\', '/*'), array('.', '/.'), $value);
$skipkeys = array('onabort', 'onactivate', 'onafterprint', 'onafterupdate', 'onbeforeactivate', 'onbeforecopy', 'onbeforecut', 'onbeforedeactivate', 'onbeforeeditfocus', 'onbeforepaste', 'onbeforeprint', 'onbeforeunload', 'onbeforeupdate', 'onblur', 'onbounce', 'oncellchange', 'onchange', 'onclick', 'oncontextmenu', 'oncontrolselect', 'oncopy', 'oncut', 'ondataavailable', 'ondatasetchanged', 'ondatasetcomplete', 'ondblclick', 'ondeactivate', 'ondrag', 'ondragend', 'ondragenter', 'ondragleave', 'ondragover', 'ondragstart', 'ondrop', 'onerror', 'onerrorupdate', 'onfilterchange', 'onfinish', 'onfocus', 'onfocusin', 'onfocusout', 'onhelp', 'onkeydown', 'onkeypress', 'onkeyup', 'onlayoutcomplete', 'onload', 'onlosecapture', 'onmousedown', 'onmouseenter', 'onmouseleave', 'onmousemove', 'onmouseout', 'onmouseover', 'onmouseup', 'onmousewheel', 'onmove', 'onmoveend', 'onmovestart', 'onpaste', 'onpropertychange', 'onreadystatechange', 'onreset', 'onresize', 'onresizeend', 'onresizestart', 'onrowenter', 'onrowexit', 'onrowsdelete', 'onrowsinserted', 'onscroll', 'onselect', 'onselectionchange', 'onselectstart', 'onstart', 'onstop', 'onsubmit', 'onunload', 'javascript', 'script', 'eval', 'behaviour', 'expression', 'style', 'class');
$skipstr = implode('|', $skipkeys);
$value = preg_replace(array('/(' . $skipstr . ')/i'), '.', $value);
if (!preg_match('/^[\\/|\\s]?(' . $allowtags . ')(\\s+|$)/is', $value)) {
$value = '';
}
$replaces[] = empty($value) ? '' : '<' . str_replace('"', '"', $value) . '>';
}
}
$html = trim(str_replace($searchs, $replaces, $html));
return $html;
}
function mhtmlspecialchars($string, $flags = NULL)
{
global $charset;
if (is_array($string)) {
foreach ($string as $key => $val) {
$string[$key] = mhtmlspecialchars($val, $flags);
}
} else {
if ($flags === NULL) {
$string = str_replace(array('&', '"', '<', '>'), array('&', '"', '<', '>'), $string);
if (strpos($string, '&#') !== false) {
$string = preg_replace('/&((#(\\d{3,5}|x[a-fA-F0-9]{4}));)/', '&\\1', $string);
}
} else {
if (PHP_VERSION < '5.4.0') {
$string = htmlspecialchars($string, $flags);
} else {
if ($charset == 'utf-8') {
$charset = 'UTF-8';
} else {
$charset = 'ISO-8859-1';
}
$string = htmlspecialchars($string, $flags, $charset);
}
}
}
return $string;
}
function get_shop_tpl($opt = '', $s_uid = '')
{
global $db;
global $db_mymps;
if ($s_uid) {
$member = get_member_group('', $s_uid);
$option = $member['allow_tpl'];
} else {
$option = $db->getAll('SELECT * FROM `' . $db_mymps . 'member_tpl`');
}
foreach ($option as $key => $v) {
$mymps .= '';
}
return $mymps;
}
function filter_str($msg)
{
$msg = str_replace('"', '"', $msg);
$msg = str_replace('\'', ''', $msg);
$msg = str_replace('<', '<', $msg);
$msg = str_replace('>', '>', $msg);
$msg = str_replace("\t", ' ', $msg);
$msg = str_replace(' ', ' ', $msg);
return $msg;
}
function get_member_docu($num = 10, $userid = '', $if_check = 1, $typeid = 0)
{
global $db;
global $db_mymps;
$where = 'WHERE 1';
$where .= $if_check == 1 ? ' AND a.if_check = \'1\'' : '';
$where .= $typeid ? ' AND a.typeid = \'' . $typeid . '\'' : '';
$where .= $userid ? ' AND a.userid = \'' . $userid . '\'' : '';
$num = $num ? 'LIMIT 0,' . $num : '';
$query = $db->query('SELECT a.*,b.id AS uid,b.tname FROM `' . $db_mymps . 'member_docu` AS a LEFT JOIN `' . $db_mymps . 'member` AS b ON a.userid = b.userid ' . $where . ' ORDER BY a.id DESC ' . $num);
while ($row = $db->fetchRow($query)) {
$arr['id'] = $row['id'];
$arr['uid'] = $row['uid'];
$arr['userid'] = $row['userid'];
$arr['tname'] = $row['tname'];
$arr['typeid'] = $row['typeid'];
$arr['title'] = $row['title'];
$arr['pubtime'] = $row['pubtime'];
$arr['imgpath'] = $row['imgpath'];
$arr['hit'] = $row['hit'];
$arr['pre_imgpath'] = $row['pre_imgpath'];
$arr['tname_uri'] = Rewrite('store', array('uid' => $row['uid'], 'part' => 'index'));
$arr['uri'] = Rewrite('store', array('uid' => $row['uid'], 'id' => $row['id'], 'part' => 'document'));
$arr['uri_m'] = mRewrite('store', array('uid' => $row['uid'], 'id' => $row['id'], 'part' => 'document'));
$docu[] = $arr;
$arr = NULL;
}
return $docu;
}
function msetcookie($var, $val, $life = 0)
{
global $cookiepre;
global $cookiedomain;
global $cookiepath;
global $timestamp;
$cookie_pre = $cookiepre . '_';
$cookie_path = $cookiepath ? $cookiepath : '/';
$life = $life ? $life : 3600;
$life = $timestamp + $life;
setcookie($cookie_pre . $var, $val, $life, $cookie_path, $cookiedomain);
}
function mgetcookie($var)
{
global $cookiepre;
$cookie_pre = $cookiepre . '_';
$tvar = $cookie_pre . $var;
return $_COOKIE[$tvar];
}
function is_email($email)
{
return 6 < strlen($email) && preg_match('/^[\\w\\-\\.]+@[\\w\\-\\.]+(\\.\\w+)+$/', $email);
}
function html2js($str)
{
$str = str_replace('\\', '\\\\', $str);
$str = str_replace('\'', '\\\'', $str);
$str = str_replace('"', '\\"', $str);
$str = str_replace('\\t', '', $str);
$str = explode("\r\n", $str);
for ($i = 0; $i < count($str); $i++) {
$re .= 'document.writeln("' . $str[$i] . '");' . "\r\n";
}
return $re;
}
function textarea_post_change($mymps_string)
{
return nl2br(str_replace(' ', ' ', mhtmlspecialchars(trim($mymps_string))));
}
function de_textarea_post_change($mymps_string)
{
return str_replace('
', ' ', str_replace(' ', ' ', trim($mymps_string)));
}
function random($length = 5, $strtolower = 1)
{
$hash = '';
$chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz';
$max = strlen($chars) - 1;
mt_srand((double) microtime() * 1000000);
for ($i = 0; $i < $length; $i++) {
$hash .= $chars[mt_rand(0, $max)];
}
if ($strtolower == 1) {
$hash = strtolower($hash);
}
return $hash;
}
function FileExt($filename)
{
if ($filename) {
$temp_arr = explode('.', $filename);
$file_ext = array_pop($temp_arr);
$file_ext = trim($file_ext);
$file_ext = strtolower($file_ext);
} else {
$file_ext = NULL;
}
return $file_ext;
}
function createfile($file, $str)
{
if (is_file($file)) {
@unlink($file);
}
$fp = fopen($file, 'w');
if (!is_writable($file)) {
return false;
}
if (!fwrite($fp, $str)) {
return false;
}
fclose($fp);
return $file;
}
function createdir($path)
{
if (!file_exists($path)) {
createdir(dirname($path));
mkdir($path, 511);
return true;
} else {
if (file_exists($path)) {
return true;
} else {
return false;
}
}
}
function DelDir($dirName)
{
if (!is_dir($dirName)) {
return false;
}
$handle = @opendir($dirName);
while (($file = @readdir($handle)) !== false) {
if ($file != '.' && $file != '..') {
$dir = $dirName . '/' . $file;
is_dir($dir) ? DelDir($dir) : @unlink($dir);
}
}
closedir($handle);
return rmdir($dirName);
}
function die_msg($msg)
{
return '
Mymps info:' . $msg . '
'; } function uc_call($func, $params = NULL) { restore_error_handler(); if (!function_exists($func)) { include_once MYMPS_ROOT . '/uc_client/client.php'; } $res = call_user_func_array($func, $params); return $res; } function get_editor($editor_name, $type, $value = '', $width = '100%', $height = '400px', $BasePath = '../include/kindeditor') { $html = ''; $html .= ''; switch ($type) { case 'Member': $html .= ''; break; case 'information': $html .= ''; break; default: $html .= ''; break; } $html .= ''; return $html; } function mymps_chk_randcode($getcode = '') { global $timestamp; session_start(); $getcode = trim(strtoupper($getcode)); $sessioncode = $_SESSION['chkcode']['code']; if ($timestamp < $_SESSION['chkcode']['time'] && $sessioncode == $getcode) { return true; } else { return false; } } function CheckUserID($uid, $msgtitle = '用户名') { for ($i = 0; isset($uid[$i]); $i++) { if (128 < ord($ck_uid[$i])) { if (isset($uid[$i + 1]) && 64 < ord($uid[$i + 1])) { $i++; } else { return $msgtitle . '可能含有乱码,建议你改用英文字母和数字组合!'; } } } return 'ok'; } function GetIP() { if (!empty($_SERVER['HTTP_CLIENT_IP'])) { $cip = $_SERVER['HTTP_CLIENT_IP']; } else { if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { $cip = $_SERVER['HTTP_X_FORWARDED_FOR']; } else { if (!empty($_SERVER['REMOTE_ADDR'])) { $cip = $_SERVER['REMOTE_ADDR']; } else { if (!pcclient()) { $cip = 'wap'; } else { $cip = ''; } } } } preg_match('/[\\d\\.]{7,15}/', $cip, $cips); $cip = isset($cips[0]) ? $cips[0] : 'unknown'; unset($cips); return $cip; } function utf8_unserialize($serial_str) { $out = @preg_replace('!s:(\\d+):"(.*?)";!se', '\'s:\'.strlen(\'$2\').\':"$2";\'', $serial_str); return unserialize($out); } function write_admin_record($msg) { global $admin_id; global $db_mymps; global $db; global $timestamp; $db->query('INSERT INTO `' . $db_mymps . 'admin_record_action` (id,adminid,ip,pubdate,action) VALUES (\'\',\'' . $admin_id . '\',\'' . getip() . '\',\'' . $timestamp . '\',\'' . $msg . '\')'); } function write_msg($msg = '', $url = 'javascript:history.go(-1);', $action = '') { global $charset; global $db; global $db_mymps; global $mymps_global; global $mymps_starttime; !empty($action) && write_admin_record($msg); if (defined('IN_AJAX')) { echo '' : 'window.location.href=\'' . $url . '\';'; } else { $hidden = $url == 'olmsg' ? 1 : ''; if (!empty($msg) && !empty($url)) { if ($url == 'javascript:history.go(-1);') { $time_echo = 'setTimeout(\'JumpUrl()\',4000);'; $msg = '