/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 = ' ' . $msg; $goto = '如果你的浏览器没反应,请点击这里...'; } else { if ($url == 'olmsg') { $time_echo = $goto = ''; } else { $time_echo = 'setTimeout(\'JumpUrl()\',3000);'; $goto = '如果你的浏览器没反应,请点击这里...'; } } include MYMPS_ROOT . '/template/global/mymps_message.html'; } else { if (empty($msg) && !empty($url)) { Header('HTTP/1.1 303 See Other'); Header('Location: ' . $url); } } } if (!defined('NO_EXIT')) { $mymps_global = $db = $db_mymps = $charset = $timestamp = NULL; exit; } } function show_msg($msgs, $ms = '') { global $charset; global $db; global $db_mymps; if (!empty($ms) && $ms == 'record') { while (list($k, $v) = each($msgs)) { $str .= '
' . $v . '
'; } write_admin_record(SpHtml2Text($str)); } else { if (!empty($ms) && $ms != 'record') { write_admin_record($ms); } } $title = $mymps_global[SiteName] . '提示信息!'; include MYMPS_ROOT . '/template/global/mymps_msg.html'; while (list($k, $v) = each($msgs)) { $str .= '
' . $v . '
'; } echo $str . ''; } function mymps_goto($url = '') { return ''; } function is_member_info($id, $type = 'public') { global $db; global $db_mymps; if (empty($id)) { write_msg('操作失败!您没有选择对象!'); } $type = $type == 'public' ? 'AND a.info_level != 0' : ''; $post = $db->getRow('SELECT a.*,b.modid FROM `' . $db_mymps . 'information` AS a LEFT JOIN `' . $db_mymps . 'category` AS b ON a.catid = b.catid WHERE a.id = \'' . $id . '\' ' . $type); return $post; } function setParam($param1, $rewrite = 'active', $pre = '', $htmlpath = '') { if ($rewrite == 'rewrite') { $param = $pre; foreach ($param1 as $key) { ${$key} =& $GLOBALS[$key]; $param .= ${$key} != NULL ? urlencode($key) . '-' . ${$key} . '-' : ''; } } else { if ($rewrite == 'rewrite_py') { $param = ''; foreach ($param1 as $key) { ${$key} =& $GLOBALS[$key]; $param .= ${$key} != NULL ? urlencode($key) . '-' . ${$key} . '-' : ''; } } else { if ($rewrite == 'html') { $param = $htmlpath; } else { if ($rewrite == 'active') { if (defined('IN_ADMIN')) { foreach ($param1 as $key) { ${$key} =& $GLOBALS[$key]; $param .= urlencode($key) . '=' . ${$key} . '&'; } } else { foreach ($param1 as $key) { ${$key} =& $GLOBALS[$key]; $param .= ${$key} != NULL ? urlencode($key) . '=' . ${$key} . '&' : ''; } } } } } } return $param; } function get_page_idin2($column = 'id', $sql = '', $number = '') { global $mymps_global; global $db; global $db_mymps; $page = $number ? ' LIMIT 0,' . $number : ''; $query = $db->query($sql . $page); while ($row = $db->fetchRow($query)) { $idin .= $row[$column] . ','; } $idin = $idin ? substr($idin, 0, -1) : NULL; return $idin; } function get_page_idin($column = 'id', $sql = '', $cfg_page = '') { global $page; global $per_page; global $per_screen; global $pages_num; global $rows_num; global $mymps_global; global $db; global $db_mymps; $page = empty($page) || $page < 0 || !is_numeric($page) ? 1 : $page; $per_page = $cfg_page ? $cfg_page : ($per_page ? $per_page : $mymps_global['cfg_page_line']); $per_screen = !isset($per_screen) ? 10 : $per_screen; $pages_num = ceil($rows_num / $per_page); $query = $db->query($sql . ' limit ' . ($page - 1) * $per_page . ', ' . $per_page); while ($row = $db->fetchRow($query)) { $idin .= $row[$column] . ','; } $idin = $idin ? substr($idin, 0, -1) : NULL; return $idin; } function page1($sqlstr = '', $per_page = '') { global $page; global $per_screen; global $pages_num; global $rows_num; global $mymps_global; global $db; global $db_mymps; $page = empty($page) || $page < 0 || !is_numeric($page) ? 1 : $page; $per_page = $per_page ? $per_page : $mymps_global['cfg_page_line']; $per_screen = !isset($per_screen) ? 10 : $per_screen; $pages_num = ceil($rows_num / $per_page); return $db->getAll($sqlstr . ' limit ' . ($page - 1) * $per_page . ', ' . $per_page); } function page2($rewrite = 'active', $ext = '.html') { global $rows_num; global $page; global $pages_num; global $per_page; global $param; global $per_screen; global $dir_typename; $font_size = '10pt'; $mid = ceil(($per_screen + 1) / 2); $nav = ''; if ($page <= $mid) { $begin = 1; } else { if ($pages_num - $mid < $page) { $begin = $pages_num - $per_screen + 1; } else { $begin = $page - $mid + 1; } } $begin = $begin < 0 ? 1 : $begin; if ($rewrite == 'active') { $nav .= '共' . $rows_num . '记录 '; if (1 < $page) { $nav .= '<上一页'; } if ($begin != 1) { $nav .= '1 ...'; } $end = $pages_num < $begin + $per_screen ? $pages_num + 1 : $begin + $per_screen; for ($i = $begin; $i < $end; $i++) { if (!empty($i)) { $nav .= $page != $i ? '' . $i . ' ' : ' ' . $i . ' '; } } if ($end != $pages_num + 1) { $nav .= '... ' . $pages_num . ''; } if ($page < $pages_num) { $nav .= '下一页>'; } } else { if ($rewrite == 'rewrite') { $nav .= '共' . $rows_num . '记录 '; if (1 < $page) { $nav .= '<上一页'; } if ($begin != 1) { $nav .= '1 ...'; } $end = $pages_num < $begin + $per_screen ? $pages_num + 1 : $begin + $per_screen; for ($i = $begin; $i < $end; $i++) { if (!empty($i)) { $nav .= $page != $i ? '' . $i . ' ' : ' ' . $i . ' '; } } if ($end != $pages_num + 1) { $nav .= '... ' . $pages_num . ''; } if ($page < $pages_num) { $nav .= '下一页>'; } } else { if ($rewrite == 'rewrite_py') { $param = '/' . $dir_typename . '/' . $param; $nav .= '共' . $rows_num . '记录 '; if (1 < $page) { $nav .= '<上一页'; } if ($begin != 1) { $nav .= '1 ...'; } $end = $pages_num < $begin + $per_screen ? $pages_num + 1 : $begin + $per_screen; for ($i = $begin; $i < $end; $i++) { if (!empty($i)) { $nav .= $page != $i ? '' . $i . ' ' : ' ' . $i . ' '; } } if ($end != $pages_num + 1) { $nav .= '... ' . $pages_num . ''; } if ($page < $pages_num) { $nav .= '下一页>'; } } else { if ($rewrite == 'html') { $nav .= '共' . $rows_num . '记录 '; if (1 < $page) { $nav .= '<上一页'; } if ($begin != 1) { $nav .= '1 ...'; } $end = $pages_num < $begin + $per_screen ? $pages_num + 1 : $begin + $per_screen; for ($i = $begin; $i < $end; $i++) { if (!empty($i)) { $nav .= $page != $i ? '' . $i . ' ' : ' ' . $i . ' '; } } if ($end != $pages_num + 1) { $nav .= '... ' . $pages_num . ''; } if ($page < $pages_num) { $nav .= '下一页>'; } } } } } if (defined('IN_ADMIN') && 1 < $pages_num) { $nav .= '
'; } return $nav; } function get_advertisement($page = 'index') { $data = read_static_cache('adv_' . $page); return $data; } function GetUrl() { global $mymps_global; $url = (strstr($mymps_global['SiteUrl'], 'https:') ? 'https://' : 'http://') . $_SERVER['HTTP_HOST']; if (isset($_SERVER['REQUEST_URI'])) { $url .= $_SERVER['REQUEST_URI']; } else { $url .= $_SERVER['PHP_SELF']; if (!empty($_SERVER['QUERY_STRING'])) { $url .= '?' . $_SERVER['QUERY_STRING']; } } return $url; } function GetTime($time = '', $c = 'Y-m-d H:i:s') { return $time ? date($c, $time) : ''; } function globalassign() { global $mymps_global; global $docunav; global $city; if (CURSCRIPT == 'store') { $docunav = get_member_docunav(); } } function mymps_tpl($str, $curscript = '') { global $mymps_global; $mymps_global['SiteStat'] = htmlspecialchars_decode($mymps_global['SiteStat']); $mymps_global['SiteStat'] = str_replace('type=\'/javascript\'', 'type=\'text/javascript\'', $mymps_global['SiteStat']); $curscript = $curscript ? $curscript : CURSCRIPT; if (defined('IN_SMT')) { if ($curscript == 'wap') { $tpldir = 'm'; $templateid = 8; $tplfile = MYMPS_ROOT . '/' . $tpldir . '/template/' . $str . '.html'; $objfile = MYMPS_DATA . '/templates/' . $templateid . '_' . $str . '.tpl.php'; } else { if ($curscript == 'search') { $tpldir = 'search'; $templateid = 7; $tplfile = MYMPS_TPL . '/' . $tpldir . '/' . $str . '.html'; $objfile = MYMPS_DATA . '/templates/' . $templateid . '_' . $str . '.tpl.php'; } else { if ($curscript == 'store') { $tpldir = 'spaces/store'; $templateid = '6'; $tplfile = MYMPS_TPL . '/' . $tpldir . '/' . $str . '.html'; $objfile = MYMPS_DATA . '/templates/' . $templateid . '_' . $str . '.tpl.php'; } else { if ($curscript == 'coupon') { $tpldir = 'plugin/coupon/template'; $templateid = '5'; $tplfile = MYMPS_ROOT . '/' . $tpldir . '/' . $str . '.html'; $objfile = MYMPS_DATA . '/templates/' . $templateid . '_' . $str . '.tpl.php'; } else { if ($curscript == 'group') { $tpldir = 'plugin/group/template'; $templateid = '4'; $tplfile = MYMPS_ROOT . '/' . $tpldir . '/' . $str . '.html'; $objfile = MYMPS_DATA . '/templates/' . $templateid . '_' . $str . '.tpl.php'; } else { if ($curscript == 'goods') { $tpldir = 'plugin/goods/template'; $templateid = '3'; $tplfile = MYMPS_ROOT . '/' . $tpldir . '/' . $str . '.html'; $objfile = MYMPS_DATA . '/templates/' . $templateid . '_' . $str . '.tpl.php'; } else { if ($curscript == 'space') { $tpldir = 'spaces/person'; $templateid = 2; $tplfile = MYMPS_TPL . '/' . $tpldir . '/' . $str . '.html'; $objfile = MYMPS_DATA . '/templates/' . $templateid . '_' . $str . '.tpl.php'; } else { $tpldir = $tpldir ? $tpldir : TPLDIR; $templateid = $templateid ? $templateid : TEMPLATEID; $tplfile = MYMPS_TPL . '/' . $tpldir . '/' . $str . '.html'; $objfile = MYMPS_DATA . '/templates/' . $templateid . '_' . $str . '.tpl.php'; } } } } } } } @chktplrefresh($objfile, $tplfile, filemtime($objfile), $templateid, $tpldir); return $objfile; } else { return 'template/' . $str . '.tpl.php'; } } function unknown_err_msg() { $msgs = '未知错误,可能与你提交的参数有关

获取更多帮助请前往Mymps官方网站'; write_msg($msgs, 'olmsg'); } function Spcnw_mid($str, $start, $slen) { $str_len = strlen($str); $strs = array(); for ($i = 0; $i < $str_len; $i++) { if (128 < ord($str[$i])) { if ($i + 1 < $str_len) { $strs[] = $str[$i] . $str[$i + 1]; } else { $strs[] = ''; } $i++; } else { $strs[] = $str[$i]; } } $wlen = count($strs); if ($wlen < $start) { return ''; } $restr = ''; $startdd = $start; $enddd = $startdd + $slen; for ($i = $startdd; $i < $enddd; $i++) { if (!isset($strs[$i])) { break; } $restr .= $strs[$i]; } return $restr; } function Text2Html($txt) { $txt = str_replace(' ', ' ', $txt); $txt = str_replace('<', '<', $txt); $txt = str_replace('>', '>', $txt); $txt = preg_replace('/[' . "\r\n" . ']{1,}/isU', '
' . "\r\n", $txt); return $txt; } function SpHtml2Text($str) { $str = preg_replace('/||/isU', '', $str); $alltext = ''; $start = 1; for ($i = 0; $i < strlen($str); $i++) { if ($start == 0 && $str[$i] == '>') { $start = 1; } else { if ($start == 1) { if ($str[$i] == '<') { $start = 0; $alltext .= ' '; } else { if (31 < ord($str[$i])) { $alltext .= $str[$i]; } } } } } $alltext = str_replace(' ', ' ', $alltext); $alltext = preg_replace('/&([^;&]*)(;|&)/', '', $alltext); $alltext = preg_replace('/[ ]+/s', ' ', $alltext); return $alltext; } function clear_html($str = '', $clearbr = true) { $str = preg_replace('/