e = null) { if (empty($value) || empty($table)) { return false; } $map[$condition] = $value; $info = M(ucfirst($table))->where($map); if (empty($field)) { $info = $info->field(true)->find(); } else { $info = $info->getField($field); } return $info; } function get_link($link_id = null, $field = 'url') { $link = ''; if (empty($link_id)) { return $link; } $link = M('Url')->getById($link_id); if (empty($field)) { return $link; } else { return $link[$field]; } } function get_cover($cover_id, $field = null, $is_thumb = 0, $width = '100%', $height = '100%', $mime = 'jpg', $is_water = 0, $quality = 100) { $theme = C('DEFAULT_THEME') ? C('DEFAULT_THEME') : C('THEME'); if (empty($cover_id)) { if ($field == 'path') { return C('PIC_HOST') . __ROOT__ . '/Public/Home/' . $theme . '/images/default1.png'; } else { return false; } } $picture = M('Picture')->where(array('status' => 1))->getById($cover_id); if (!empty($picture['url'])) { $picture['url'] = str_replace('img1.qbaoting.com', 'img3.qbaoting.cn', $picture['url']); } if ($field == 'path') { if (empty($picture)) { return C('PIC_HOST') . __ROOT__ . '/Public/Home/' . $theme . '/images/default1.png'; } if (!empty($picture['url'])) { $picture['path'] = $picture['url']; } else { if (if_url($picture['path']) === true) { $picture['path'] = trim($picture['path']); } else { $thumb_dir = '/thumb'; $pic_infos = pathinfo($picture['path']); $is_thumb_true = ($is_thumb && (strtoupper($pic_infos['extension']) == 'JPG' || strtoupper($pic_infos['extension']) == 'JPEG' || strtoupper($pic_infos['extension']) == 'PNG')); if (C('PIC_HOST_MORE')) { $path_sign = data_auth_sign($picture['path']); $is_url = substr($path_sign, 0, 1); $pic_count = count(C('PIC_HOST_MORE')) - 1; if (!is_int($is_url) || $is_url > $pic_count) { $is_url = ord($is_url) % $pic_count; } if ($is_thumb_true) { $picture['path'] = C("PIC_HOST_MORE.$is_url") . __ROOT__ . $thumb_dir . trim($picture['path']); } else { $picture['path'] = C("PIC_HOST_MORE.$is_url") . __ROOT__ . trim($picture['path']); } } else { if ($is_thumb_true) { $picture['path'] = C('PIC_HOST') . __ROOT__ . $thumb_dir . trim($picture['path']); } else { $picture['path'] = C('PIC_HOST') . __ROOT__ . trim($picture['path']); } } if ($is_thumb_true) { $picture['path'] = set_thumb_path($picture['path'], $width, $height, $is_water, $mime, $quality, $is_thumb); } } } } return empty($field) ? $picture : trim($picture[$field]); } function get_thumb($cover_id, $original = '', $size = '') { $details = get_cover($cover_id, 'path'); if (basename($details) == 'default1.png' && $original && $size) { $size = explode('x', $size); if (is_numeric($size[0]) && is_numeric($size[1])) { return get_cover($original, 'path', 2, $size[0], $size[1]); } } else { return $details; } } function get_pic_host($path) { if (empty($path)) { return null; } if (strstr($path, 'http://') || strstr($path, 'ftp://')) { return $path; } if (substr($path, 0, 1) !== "/") { $path = "/" . $path; } if (C('PIC_HOST_MORE')) { $path_sign = data_auth_sign($path); $is_url = substr($path_sign, 0, 1); $pic_count = count(C('PIC_HOST_MORE')) - 1; if (!is_int($is_url) || $is_url > $pic_count) { $is_url = ord($is_url) % $pic_count; } $picture_path = C("PIC_HOST_MORE.$is_url") . trim($path); } else { $picture_path = C('PIC_HOST') . trim($path); } return $picture_path; } function set_thumb_path($src = '', $width = '100%', $height = '100%', $is_water = 0, $mime = 'jpg', $quality = 100, $is_thumb = 1) { if (empty($src)) { return false; } if (empty($width) && empty($height)) { return $src; } if (strstr($width, '%') || strstr($height, '%')) { $image = new \Think\Image(); $image->open($src); if ($w = strstr($width, '%', true)) { $width = intval($image->width() * $w / 100); } if ($h = strstr($height, '%', true)) { $height = intval($image->height() * $h / 100); } } $src_params = pathinfo($src); $basename = basename($src, '.' . $src_params['extension']); if ($is_thumb == 1) { $name = $src_params['dirname'] . DIRECTORY_SEPARATOR . $basename . '_' . $width . '_' . $height . ($is_water ? '_water' : '') . '.' . $src_params['extension']; } else { $name = $src_params['dirname'] . DIRECTORY_SEPARATOR . $basename . '_' . $width . '_' . $height . ($is_water ? '_water' : '') . '_crop.' . $src_params['extension']; } return $name; } function if_url($url, $completion = false) { if (substr($url, 0, 7) === 'http://' || substr($url, 0, 8) === 'https://') { return true; } elseif ($completion) { return 'http://' . $url; } else { return false; } } function check_document_position($pos = 0, $contain = 0) { if (empty($pos) || empty($contain)) { return false; } $res = $pos & $contain; if ($res !== 0) { return true; } else { return false; } } function get_stemma($pids, Model &$model, $field = 'id') { $collection = array(); if (empty($pids)) { return $collection; } if (is_array($pids)) { $pids = trim(implode(',', $pids), ','); } $result = $model->field($field)->where(array('pid' => array('IN', (string)$pids)))->select(); $child_ids = array_column((array)$result, 'id'); while (!empty($child_ids)) { $collection = array_merge($collection, $result); $result = $model->field($field)->where(array('pid' => array('IN', $child_ids)))->select(); $child_ids = array_column((array)$result, 'id'); } return $collection; } function check_category($id, $model = 'Category') { if (is_array($id)) { $type = get_category_by_model($id['category_id'], 'type', $model); $type = explode(",", $type); return in_array($id['type'], $type); } else { $publish = get_category_by_model($id, 'allow_publish', $model); return $publish ? true : false; } } function check_category_model($info, $model = 'Category') { $cate = get_category_by_model($info['category_id'], $model); $array = explode(',', $info['pid'] ? $cate['model_sub'] : $cate['model']); return in_array($info['model_id'], $array); } function get_pinyin_first($str, $all = false) { $pinyin = new \OT\PinYin(); $rs = $pinyin->getFirstPY($str); if ($rs === '' || $rs === false) { return ''; } $rs = !$all ? substr($rs, 0, 1) : $rs; return $rs; } function request_by_curl($url, $method = 'get', $data = '', $timeout = 100) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, false); if ($method == 'post') { curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); } curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); $result = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); for ($depth = 3; $depth > 0; $depth--) { if ($httpCode == '200') { break; } $result = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); } curl_close($ch); return $depth <= 0 ? false : $result; } function get_staticpage($id) { if (empty($id)) { return false; } return M('StaticPage')->getById($id); } function showText($key, $field, $checkbox = false, $module = MODULE_NAME) { $pre = 'FIELD_' . strtoupper($module) . '_'; if (!$field) { return ''; } $config = C($pre . strtoupper($field)); if (!is_array($config)) { return ''; } if ($checkbox === false) { return $config[$key]; } else { $rs = array(); foreach ($config as $k => $v) { if ($k & $key) { $rs[] = $v; } } $num = $checkbox['num']; if (!empty($num) && $num > 0) { return implode(',', array_slice($rs, 0, $num)); } else { return implode(',', $rs); } } } function showFormat($key, $config) { $map = array( 'card_type' => C('PACKAGE_CARD_TYPE'), 'status' => array('1' => '可领取', '-1' => '不可领取'), 'server_type' => C('PACKAGE_PARTICLE_SERVER_TYPE'), ); if (!$map[$config]) { return; } $config = $map[$config]; return $config[$key]; } function showCheckbox($key, $config, $num = 0) { $map = array( 'card_type' => C('PACKAGE_GAME_TYPE'), 'conditions' => C('PACKAGE_CARD_CONDITIONS'), ); if (!$map[$config]) { return; } $rs = array(); foreach ($map[$config] as $k => $v) { if ($k & $key) { $rs[] = $v; } } if ($num > 0) { return implode(',', array_slice($rs, 0, $num)); } else { return implode(',', $rs); } } function showCardAll($id) { if (!is_numeric($id)) { return null; } return M('Card')->where('did=' . $id)->count(); } function showCardSur($id) { if (!is_numeric($id)) { return null; } $map = array( 'did' => $id, 'draw_status' => 0, ); return M('Card')->where($map)->count(); } function getStaticExt() { $class = 'Common\\Library\\TempCreateLibrary'; $staticInstance = new $class(); return $staticInstance->ext; } function getWName($theme = null) { $theme = $theme ? $theme : I('t'); $theme = $theme ? $theme : C('DEFAULT_THEME'); $theme = $theme ? $theme : C('THEME'); if (is_numeric(substr($theme, 0, 1))) { return 'P' . strtolower($theme); } else { return ucfirst(strtolower($theme)); } } function WidgetSEO($args = array(), $theme = null, $name = 'SEO') { $m = 'Home'; return R($m . '/' . getWName($theme) . '/' . $name, $args, 'Widget'); } function getCrumbs($args = array(), $theme = null, $name = "Breadcrumb") { $m = 'Home'; return R($m . '/' . getWName($theme) . '/' . $name, $args, 'Widget'); } function basestaticUrl($type, $id = null, $model = null, $page = null, $mobile = false, $hot = false) { static $staticInstance; $sturl = array( 'Document' => array('model' => 'Document', 'module' => 'Document', 'category' => 'Category'), 'Gallery' => array('model' => 'Gallery', 'module' => 'Gallery', 'category' => 'GalleryCategory'), 'Package' => array('model' => 'Package', 'module' => 'Package', 'category' => 'PackageCategory'), 'Down' => array('model' => 'Down', 'module' => 'Down', 'category' => 'DownCategory'), 'Feature' => array('model' => 'Feature', 'module' => 'Feature', 'category' => 'FeatureCategory'), ); if (!$model) { $t = MODULE_NAME; $params['model'] = $t; $params['module'] = $t; $params['category'] = ($t == 'Document') ? 'Category' : $t . 'Category'; } else { $params = $sturl[ucfirst(strtolower($model))]; } $s = md5(json_encode($params . $model)); if ($mobile) { $s .= 'M'; } if (!$staticInstance[$s]) { $class = 'Common\\Library\\TempCreateLibrary'; $staticInstance[$s] = new $class($params); if ($mobile) { $config = C('MOBILE_' . strtoupper($model)); $property = array( 'the_lists_path' => $config['lists'], 'the_hot_list_path' => $config['hot_lists'], 'the_detail_path' => $config['detail'], 'the_moduleindex_path' => $config['index'], 'theme' => C('MOBILE_THEME'), ); $staticInstance[$s]->setProperty($property); } } switch (strtolower($type)) { case 'detail': if (!is_numeric($id)) { return; } $path = $staticInstance[$s]->getDetailUrl($id); break; case 'lists': if (!is_numeric($id)) { return; } $path = $staticInstance[$s]->getListsUrl($id, $page, $hot); break; case 'index': $path = $staticInstance[$s]->getIndexUrl(); break; } return $path; } function staticUrl($type, $id = null, $model = null, $page = null, $mobile = false, $hot = false) { $url = basestaticUrl($type, $id, $model, $page, $mobile, $hot); return staticUrlRewrite($url, false); } function staticUrlMobile($type, $id = null, $model = null, $page = null, $mobile = true, $hot = false) { $url = basestaticUrl($type, $id, $model, $page, $mobile, $hot); return staticUrlRewrite($url, true); } function staticTagsUrl($id = null, $model = 'Tags', $page = null, $is_mobile = false) { if (is_numeric($id)) { $tagModelArray = array( 'Tags', 'ProductTags', ); if (in_array($model, $tagModelArray)) { $params = array( 'static_url' => C('STATIC_CREATE_URL'), ); $class = 'Common\\Library\\TempCreateLibrary'; $staticInstance = new $class($params); $url = $staticInstance->getTagListsUrl($id, $model, $page, $is_mobile); return staticUrlRewrite($url, false); } } } function staticUrlRewrite($url, $mobile) { if (empty($url)) { return ''; } $preg = $mobile ? C('MOBILE_STATIC_URL_REWRITE') : C('STATIC_URL_REWRITE'); $preg = is_array($preg) ? array_filter($preg) : $preg; if (empty($preg)) { return $url; } foreach ($preg as $key => $value) { $url = preg_replace($key, $value, $url); } return $url; } function widget($str) { $str = html_entity_decode($str); parse_str($str, $arrays); $arrays['length'] = $arrays['length'] ? $arrays['length'] : 65535; if ($arrays['cat']) { $in = 'category_id in (\'' . implode('\',\'', $arrays['cat']) . '\')'; } if ($arrays['tag']) { $tags = M('tags_map')->select(); foreach ($tags as $k => $v) { if (in_array($v['tid'], $arrays['tag'])) { $maps[] = $v['did']; } } $in .= ' and id in (\'' . implode('\',\'', $maps) . '\')'; } $results = M('down')->where($in)->select(); return array_slice($results, intval($arrays['offset']), $arrays['length']); } function dir_create($path, $mode = 0777) { if (is_dir($path)) { return true; } $ftp_enable = 0; $path = str_replace('\\', '/', $path); if (substr($path, -1) != '/') { $path = $path . '/'; } $temp = explode('/', $path); $cur_dir = ''; $max = count($temp) - 1; for ($i = 0; $i < $max; $i++) { $cur_dir .= $temp[$i] . '/'; if (@is_dir($cur_dir)) { continue; } @mkdir($cur_dir, 0777, true); @chmod($cur_dir, 0777); } return is_dir($path); } function getWidgetPath($id, $if_url = false, $suffix_url = '') { $info = M('StaticPage')->field('path,multipage_index,multipage')->where('id=' . $id)->find(); if (empty($info)) { return '/'; } $Path = str_replace('{page}', '1', $info['path']); $SURL = C('STATIC_URL'); if ($SURL && $if_url) { !empty($suffix_url) && $SURL = $suffix_url; $SURL = substr($SURL, -1) == '/' ? substr($SURL, 0, strrpos($SURL, '/')) : $SURL; $Path = $SURL . str_replace('//', '/', "/" . $Path); } else { $Path = str_replace('//', '/', "/" . $Path); } if ($info['multipage_index'] && $info['multipage']) { $Path = substr($Path, 0, strrpos($Path, '/') + 1); $Path = $info['multipage_index'] == 'index' ? $Path : $Path . $info['multipage_index'] . getStaticExt(); } elseif (empty($info['multipage'])) { $suf = substr($Path, strrpos($Path, '/') + 1); $Path = substr($Path, 0, strrpos($Path, '/') + 1); $Path = $suf == 'index' ? $Path : $Path . $suf . getStaticExt(); } return $Path; } function getCPath($id, $type) { $type = strtolower($type); if (empty($type)) { return; } switch ($type) { case 'company': if (empty($id)) { return; } $getPath = M('Company')->where('id=' . $id)->getField('path'); $getPath = str_replace("page_{page}", "", $getPath); break; case 'feature': if (empty($id)) { return; } $getPath = C(FEATURE_ZT_DIR) . '/' . M('Feature')->where('id=' . $id)->getField('url_token'); break; case 'special': if (empty($id)) { return; } $getPath = C(FEATURE_K_DIR) . '/' . M('Special')->where('id=' . $id)->getField('url_token'); break; case 'batch': if (empty($id)) { return; } $getPath = C(FEATURE_ZQ_DIR) . '/' . M('Batch')->where('id=' . $id)->getField('url_token'); break; } if (substr($getPath, -1) != "/") { $getPath = $getPath . "/"; return $getPath; } return $getPath; } function isUrl($s) { return preg_match('/^http[s]?:\/\/' . '(([0-9]{1,3}\.){3}[0-9]{1,3}' . '|' . '([0-9a-z_!~*\'()-]+\.)*' . '([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]\.' . '[a-z]{2,6})' . '(:[0-9]{1,4})?' . '((\/\?)|' . '(\/[0-9a-zA-Z_!~\'\(\)\[\]\.;\?:@&=\+\$,%#-\/^\*\|]*)?)$/', $s) == 1; } function getRelationZone($id) { $arr = get_base_by_tag($id, 'down', 'batch', 'product'); if ($arr['url_token'] == "") { return $arr['url_token']; } else { return C(FEATURE_ZQ_DIR) . '/' . $arr['url_token']; } } function array_sort($multi_array, $sort_key, $sort = SORT_ASC) { if (is_array($multi_array)) { foreach ($multi_array as $row_array) { if (is_array($row_array)) { $key_array[] = $row_array[$sort_key]; } else { return false; } } } else { return false; } array_multisort($key_array, $sort, $multi_array); return $multi_array; } function array_multi2single($array = null) { $arr = array(); foreach ($array as $value) { foreach ($value as $val) { $arr[] = $val; } } return $arr; } function getDownTag($id) { $array = array(); $tags = M('TagsMap')->where("did='$id' AND type='down'")->limit(2)->select(); foreach ($tags as $k => $val) { $array[] = M('Tags')->where('id=' . $val['tid'])->getField('title'); } $s = implode(',', $array); return $s; } function getArticleTag($id) { $array = array(); $tags = M('TagsMap')->where("did='$id' AND type='document'")->limit(20)->select(); if ($tags) { $ids = array_column($tags, 'tid'); $order = "FIELD(id," . join(',', $ids) . ")"; $array = M('Tags')->where(array('id' => array('in', $ids)))->order($order)->select(); } return $array; } function getCrumb($id, $module) { $id = is_numeric($id) ? $id : '0'; $module = strtolower($module); $module = empty($module) ? 'document' : $module; $cid = M('' . $module . '')->where('id = ' . $id)->getField('category_id'); if ($module == 'down') { $category = M('DownCategory')->where('id = ' . $cid)->find(); } else { $category = M('Category')->where('id = ' . $cid)->find(); } $categoryTitle = $category['title']; $categoryUrl = $category['path_lists']; $categoryUrl = str_replace("{category_id}_{page}", $cid . "_1.html", $categoryUrl); $categoryUrl = str_replace("page_{page}", "page_1.html", $categoryUrl); $array['title'] = $categoryTitle; $array['url'] = $categoryUrl; return $array; } function getFileUrl($id) { if (empty($id)) { return; } $address = M('DownAddress')->where('did=' . $id)->find(); $site_id = $address['site_id']; $url = $address['url']; if (is_numeric($site_id)) { $url = formatAddress($url, $site_id); } return $url; } function kbToMb($size) { if (empty($size)) { return; } return round($size / 1024); } function get_rand($proArr) { $result = ''; $proSum = array_sum($proArr); foreach ($proArr as $key => $proCur) { $randNum = mt_rand(1, $proSum); if ($randNum <= $proCur) { $result = $key; break; } else { $proSum -= $proCur; } } unset($proArr); return $result; } function builtQrcode($str) { vendor("phpqrcode.phpqrcode"); $str = empty($str) ? '下载地址不存在' : $str; $level = 'L'; $size = 4; $name = md5($str); $filename = 'Static/qrcode/' . $name . '.png'; if (!file_exists('Static/qrcode/')) { mkdir('Static/qrcode/', 0777); } @chmod('Static/qrcode/', 0777); QRcode::png($str, $filename, $level, $size, 2); return __ROOT__ . '/' . 'qrcode/' . $name . '.png'; } function getCateUrl($id, $module) { if (empty($id)) { return; } $module = strtolower($module); switch ($module) { case 'document': $cid = M('Document')->where(array("id" => $id))->getField('category_id'); $url = staticUrl('lists', $cid, 'Document'); $url = empty($url) ? '' : $url; break; case 'down': $cid = M('Down')->where(array("id" => $id))->getField('category_id'); $url = staticUrl('lists', $cid, 'Down'); $url = empty($url) ? '' : $url; break; } return $url; } function getCateName($id, $module) { if (empty($id)) { return; } $module = strtolower($module); switch ($module) { case 'document': $cid = M('Document')->where('id=' . $id)->getField('category_id'); $name = M('Category')->where('id=' . $cid)->getField('title'); $name = empty($name) ? '未定义分类' : $name; break; case 'down': $cid = M('Down')->where('id=' . $id)->getField('category_id'); $name = M('DownCategory')->where('id=' . $cid)->getField('title'); $name = empty($name) ? '未定义分类' : $name; break; case 'package': $cid = M('Package')->where('id=' . $id)->getField('category_id'); $name = M('PackageCategory')->where('id=' . $cid)->getField('title'); $name = empty($name) ? '未定义分类' : $name; break; } return $name; } function getCateId($id, $module) { if (empty($id)) { return; } $module = strtolower($module); switch ($module) { case 'document': $cid = M('Document')->where('id=' . $id)->getField('category_id'); $name = empty($cid) ? '未定义ID' : $cid; break; case 'down': $cid = M('Down')->where('id=' . $id)->getField('category_id'); $name = empty($cid) ? '未定义ID' : $cid; break; } return $name; } function multi_array_sort($multi_array, $sort_key, $sort = SORT_ASC) { if (is_array($multi_array)) { foreach ($multi_array as $row_array) { if (is_array($row_array)) { $key_array[] = $row_array[$sort_key]; } else { return false; } } } else { return false; } array_multisort($key_array, $sort, $multi_array); return $multi_array; } function mobileTagUrl($name) { if (empty($name)) { return; } return C('MOBILE_STATIC_URL') . "/tag/" . $name . "/"; } function getPackageType($id) { if (empty($id)) { return; } $name = M('PackageCategory')->where('id=' . $id)->getField('title'); if (empty($name)) { return ""; } else { return $name; } } function specialDate($str) { if (empty($str)) { return; } return date('Y/m/d', $str); } function getSystem($id) { if (empty($id)) { return; } $d = M('DownDmain')->where("id='$id'")->getField('system'); switch ($d) { case '1': return "安卓"; exit(); case '2': return "IOS"; exit(); } } function getLanguage($id, $type = '') { if (empty($id)) { return; } if ($type == 'soft') { $d = M('down_dsoft')->where("id='$id'")->getField('language'); } else { $d = M('DownDmain')->where("id='$id'")->getField('language'); } $language = ""; switch ($d) { case '1': return "简体"; exit(); case '2': return "繁体"; exit(); case '3': return "英文"; exit(); case '4': return "多国语言[中文]"; exit(); case '5': return "日文"; exit(); case '6': return "其他"; exit(); } } function checked($item) { $item = str_replace('&', '&', $item); parse_str($item, $items); $results = array(); foreach ($items as $k => &$v) { $in = implode('\',\'', $v); $temps = R('Feature/' . $k, array('in' => $in)); $temps && $results = array_merge($results, $temps); } return $results; } function remove_xss($val) { $val = preg_replace('/([\x00-\x08,\x0b-\x0c,\x0e-\x19])/', '', $val); $search = 'abcdefghijklmnopqrstuvwxyz'; $search .= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; $search .= '1234567890!@#$%^&*()'; $search .= '~`";:?+/={}[]-_|\'\\'; for ($i = 0; $i < strlen($search); $i++) { $val = preg_replace('/(&#[xX]0{0,8}' . dechex(ord($search[$i])) . ';?)/i', $search[$i], $val); $val = preg_replace('/(�{0,8}' . ord($search[$i]) . ';?)/', $search[$i], $val); } $ra1 = array('javascript', 'vbscript', 'expression', 'applet', 'meta', 'xml', 'blink', 'link', 'style', 'script', 'embed', 'object', 'iframe', 'frame', 'frameset', 'ilayer', 'layer', 'bgsound', 'title', 'base'); $ra2 = 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'); $ra = array_merge($ra1, $ra2); $found = true; while ($found == true) { $val_before = $val; for ($i = 0; $i < sizeof($ra); $i++) { $pattern = '/'; for ($j = 0; $j < strlen($ra[$i]); $j++) { if ($j > 0) { $pattern .= '('; $pattern .= '(&#[xX]0{0,8}([9ab]);)'; $pattern .= '|'; $pattern .= '|(�{0,8}([9|10|13]);)'; $pattern .= ')*'; } $pattern .= $ra[$i][$j]; } $pattern .= '/i'; $replacement = substr($ra[$i], 0, 2) . '' . substr($ra[$i], 2); $val = preg_replace($pattern, $replacement, $val); if ($val_before == $val) { $found = false; } } } return $val; } function formatAddress($url, $sit_id) { if (empty($url)) { return null; } if (is_numeric($sit_id) && strtolower(substr($url, 0, 8)) != "https://" && strtolower(substr($url, 0, 7)) != "http://" && strtolower(substr($url, 0, 6)) != "ftp://" && strtolower(substr($url, 0, 16) != "itms-services://")) { if (substr($url, 0, 1) == '/') { $url = substr($url, 1); } $down = M('presetSite')->where('id =' . $sit_id)->getField('site_url'); if (strtolower(substr($down, 0, 7)) != "http://" && strtolower(substr($down, 0, 8)) != "https://" && strtolower(substr($down, 0, 6)) != "ftp://" && strtolower(substr($down, 0, 16) != "itms-services://")) { $down = "http://" . $down; } if (substr($down, -1, 1) != '/') { $down = $down . '/'; } $url = $down . $url; } return $url; } function ifBatchDetail($id, $model = 'document') { $temp = C('FEATURE_ZQ_D_DTEMP'); if (empty($temp)) { return false; } if (!is_numeric($id)) { return false; } $map = array( 'type' => $model, 'did' => $id, ); $tid = M('ProductTagsMap')->where($map)->getField('tid'); if (!$tid) { return false; } $batch_map = array( 'm.type' => 'batch', 'm.tid' => $tid, 'b.pid' => 0, ); $rs = M('ProductTagsMap')->alias('m')->join('onethink_batch b on m.did=b.id')->where($batch_map)->getField('did'); return $rs; } function commonWidget($method, $arr) { return R('Common/Widget/' . $method, $arr, 'Controller'); } function ajax_return_data_format(array $data, $message = '操作成功', $status_code = 1) { $message = $status_code ? $message : '操作失败'; $_tmp_array = array('data' => $data, 'message' => $message, 'status_code' => $status_code); return $_tmp_array; } function p() { header("Content-type:text/html;charset=utf-8"); $argc = func_get_args(); echo '
'; foreach ($argc as $var) { print_r($var); echo '
'; } echo '
'; exit; return; } function vd() { header("Content-type:text/html;charset=utf-8"); $argc = func_get_args(); foreach ($argc as $var) { var_dump($var); echo '
'; } exit; return; } function get_device_type($type = false) { $agent = $_SERVER['HTTP_USER_AGENT']; if (stripos($agent, "iPhone") || strpos($agent, "iPad")) { $platform = 'iPhone'; $where = '&&system=2'; } else if (stripos($agent, "Android")) { $platform = 'Android'; $where = '&&system=1'; } else { $platform = ''; $where = ''; } if ($type) { return $platform; } else { return $where; } } function str_replace_once($needle, $replace, $haystack) { $pos = strpos($haystack, $needle); if ($pos === false) { return $haystack; } return substr_replace($haystack, $replace, $pos, strlen($needle)); } function rand_where($model, $row = 1, $where = 1, $field = 'id') { if (empty($model)) { return; } $model = C('DB_PREFIX') . strtolower($model); $num = M()->query("select (((SELECT min($field) FROM (SELECT $field FROM $model WHERE $where order by $field DESC limit $row) as rtg) - (SELECT MIN($field) FROM $model WHERE $where))*RAND() + (SELECT MIN($field) FROM $model WHERE $where)) k"); return "$field >= " . round($num[0]['k']) . ' AND ' . $where; } function gotoMail($mail) { $t = explode('@', $mail); $t = strtolower($t[1]); if ($t == '163.com') { return 'mail.163.com'; } else if ($t == 'vip.163.com') { return 'vip.163.com'; } else if ($t == '126.com') { return 'mail.126.com'; } else if ($t == 'qq.com' || $t == 'vip.qq.com' || $t == 'foxmail.com') { return 'mail.qq.com'; } else if ($t == 'gmail.com') { return 'mail.google.com'; } else if ($t == 'sohu.com') { return 'mail.sohu.com'; } else if ($t == 'tom.com') { return 'mail.tom.com'; } else if ($t == 'vip.sina.com') { return 'vip.sina.com'; } else if ($t == 'sina.com.cn' || $t == 'sina.com') { return 'mail.sina.com.cn'; } else if ($t == 'tom.com') { return 'mail.tom.com'; } else if ($t == 'yahoo.com.cn' || $t == 'yahoo.cn') { return 'mail.cn.yahoo.com'; } else if ($t == 'tom.com') { return 'mail.tom.com'; } else if ($t == 'yeah.net') { return 'www.yeah.net'; } else if ($t == '21cn.com') { return 'mail.21cn.com'; } else if ($t == 'hotmail.com') { return 'www.hotmail.com'; } else if ($t == 'sogou.com') { return 'mail.sogou.com'; } else if ($t == '188.com') { return 'www.188.com'; } else if ($t == '139.com') { return 'mail.10086.cn'; } else if ($t == '189.cn') { return 'webmail15.189.cn/webmail'; } else if ($t == 'wo.com.cn') { return 'mail.wo.com.cn/smsmail'; } else if ($t == '139.com') { return 'mail.10086.cn'; } else { return ''; } } function getParentCategory($category_id = 0, $table = 'PackageCategory') { $result = array(); $where = array(); $where['status'] = 1; $where['id'] = $category_id; $cateInfo = M($table)->field(array('id', 'name', 'title', 'pid', 'path_lists'))->where($where)->find(); if ($cateInfo) { $result[] = $cateInfo; if (intval($cateInfo['pid']) > 0) { $result = array_merge(getParentCategory($cateInfo['pid'], $table), $result); } } return $result; } function getProvince($province_id = 0) { if ($province_id > 0) { $province = M('Province')->where(array('id' => $province_id))->find(); } else { $province = M('Province')->select(); } return $province; } function getCity($city_id = 0) { if ($city_id > 0) { $city = M('City')->where(array('id' => $city_id))->find(); } else { $city = M('City')->select(); } return $city; } function getArea($area_id = 0) { if ($area_id > 0) { $area = M('Area')->where(array('id' => $area_id))->find(); } else { $area = M('Area')->select(); } return $area; } function createdPlacePath($pinyin, $category_id) { $path_province = C('PLACE_PROVINCE_STATIC_PATH'); $path_province = str_replace('{pinyin}', $pinyin, $path_province); $dir = C('STATIC_ROOT') . '/' . $path_province; $dir = substr($dir, 0, strrpos($dir, '/')); if (!is_dir($dir)) { mkdir($dir, 0755, true); } $path = $path_province; $path_cate = C('PLACE_CATE_STATIC_PATH'); $path_cate = str_replace('{pinyin}', $pinyin, $path_cate); $path_cate = str_replace('{category_id}', $category_id, $path_cate); $dir = C('STATIC_ROOT') . '/' . $path_cate; $dir = substr($dir, 0, strrpos($dir, '/')); if (!is_dir($dir)) { mkdir($dir, 0755, true); } } function sort_cate_data($cateArray, $id = 0) { static $formatCat = array(); static $floor = 0; foreach ($cateArray as $key => $val) { if ($val['pid'] == $id) { $val['title'] = $val['title']; $val['floor'] = $floor; $formatCat[$val['id']] = $val; unset($cateArray[$key]); $floor++; sort_cate_data($cateArray, $val['id']); $floor--; } } return $formatCat; } function get_pinyin($_String, $_Code = 'UTF8') { $_DataKey = "a|ai|an|ang|ao|ba|bai|ban|bang|bao|bei|ben|beng|bi|bian|biao|bie|bin|bing|bo|bu|ca|cai|can|cang|cao|ce|ceng|cha" . "|chai|chan|chang|chao|che|chen|cheng|chi|chong|chou|chu|chuai|chuan|chuang|chui|chun|chuo|ci|cong|cou|cu|" . "cuan|cui|cun|cuo|da|dai|dan|dang|dao|de|deng|di|dian|diao|die|ding|diu|dong|dou|du|duan|dui|dun|duo|e|en|er" . "|fa|fan|fang|fei|fen|feng|fo|fou|fu|ga|gai|gan|gang|gao|ge|gei|gen|geng|gong|gou|gu|gua|guai|guan|guang|gui" . "|gun|guo|ha|hai|han|hang|hao|he|hei|hen|heng|hong|hou|hu|hua|huai|huan|huang|hui|hun|huo|ji|jia|jian|jiang" . "|jiao|jie|jin|jing|jiong|jiu|ju|juan|jue|jun|ka|kai|kan|kang|kao|ke|ken|keng|kong|kou|ku|kua|kuai|kuan|kuang" . "|kui|kun|kuo|la|lai|lan|lang|lao|le|lei|leng|li|lia|lian|liang|liao|lie|lin|ling|liu|long|lou|lu|lv|luan|lue" . "|lun|luo|ma|mai|man|mang|mao|me|mei|men|meng|mi|mian|miao|mie|min|ming|miu|mo|mou|mu|na|nai|nan|nang|nao|ne" . "|nei|nen|neng|ni|nian|niang|niao|nie|nin|ning|niu|nong|nu|nv|nuan|nue|nuo|o|ou|pa|pai|pan|pang|pao|pei|pen" . "|peng|pi|pian|piao|pie|pin|ping|po|pu|qi|qia|qian|qiang|qiao|qie|qin|qing|qiong|qiu|qu|quan|que|qun|ran|rang" . "|rao|re|ren|reng|ri|rong|rou|ru|ruan|rui|run|ruo|sa|sai|san|sang|sao|se|sen|seng|sha|shai|shan|shang|shao|" . "she|shen|sheng|shi|shou|shu|shua|shuai|shuan|shuang|shui|shun|shuo|si|song|sou|su|suan|sui|sun|suo|ta|tai|" . "tan|tang|tao|te|teng|ti|tian|tiao|tie|ting|tong|tou|tu|tuan|tui|tun|tuo|wa|wai|wan|wang|wei|wen|weng|wo|wu" . "|xi|xia|xian|xiang|xiao|xie|xin|xing|xiong|xiu|xu|xuan|xue|xun|ya|yan|yang|yao|ye|yi|yin|ying|yo|yong|you" . "|yu|yuan|yue|yun|za|zai|zan|zang|zao|ze|zei|zen|zeng|zha|zhai|zhan|zhang|zhao|zhe|zhen|zheng|zhi|zhong|" . "zhou|zhu|zhua|zhuai|zhuan|zhuang|zhui|zhun|zhuo|zi|zong|zou|zu|zuan|zui|zun|zuo"; $_DataValue = "-20319|-20317|-20304|-20295|-20292|-20283|-20265|-20257|-20242|-20230|-20051|-20036|-20032|-20026|-20002|-19990" . "|-19986|-19982|-19976|-19805|-19784|-19775|-19774|-19763|-19756|-19751|-19746|-19741|-19739|-19728|-19725" . "|-19715|-19540|-19531|-19525|-19515|-19500|-19484|-19479|-19467|-19289|-19288|-19281|-19275|-19270|-19263" . "|-19261|-19249|-19243|-19242|-19238|-19235|-19227|-19224|-19218|-19212|-19038|-19023|-19018|-19006|-19003" . "|-18996|-18977|-18961|-18952|-18783|-18774|-18773|-18763|-18756|-18741|-18735|-18731|-18722|-18710|-18697" . "|-18696|-18526|-18518|-18501|-18490|-18478|-18463|-18448|-18447|-18446|-18239|-18237|-18231|-18220|-18211" . "|-18201|-18184|-18183|-18181|-18012|-17997|-17988|-17970|-17964|-17961|-17950|-17947|-17931|-17928|-17922" . "|-17759|-17752|-17733|-17730|-17721|-17703|-17701|-17697|-17692|-17683|-17676|-17496|-17487|-17482|-17468" . "|-17454|-17433|-17427|-17417|-17202|-17185|-16983|-16970|-16942|-16915|-16733|-16