From 6b4aad076922a425e1efcb06252d901ecddd3d5d Mon Sep 17 00:00:00 2001 From: LyLme Date: Tue, 22 Feb 2022 02:52:27 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=97=A0=E7=94=A8=E5=87=BD?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/function.php | 202 +------------------------------------------ 1 file changed, 2 insertions(+), 200 deletions(-) diff --git a/include/function.php b/include/function.php index 55363f8..d07a7be 100644 --- a/include/function.php +++ b/include/function.php @@ -30,101 +30,7 @@ function isMobile() { if (ismobile() == true) {$ua = 'wap';}else {$ua = 'pc';} -function get_curl($url,$post=0,$referer=0,$cookie=0,$header=0,$ua=0,$nobaody=0){ - $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL,$url); - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); - curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); - $httpheader[] = "Accept:*/*"; - $httpheader[] = "Accept-Encoding:gzip,deflate,sdch"; - $httpheader[] = "Accept-Language:zh-CN,zh;q=0.8"; - $httpheader[] = "Connection:close"; - curl_setopt($ch, CURLOPT_HTTPHEADER, $httpheader); - curl_setopt($ch, CURLOPT_TIMEOUT, 5); - if($post){ - curl_setopt($ch, CURLOPT_POST, 1); - curl_setopt($ch, CURLOPT_POSTFIELDS, $post); - } - if($header){ - curl_setopt($ch, CURLOPT_HEADER, TRUE); - } - if($cookie){ - curl_setopt($ch, CURLOPT_COOKIE, $cookie); - } - if($referer){ - if($referer==1){ - curl_setopt($ch, CURLOPT_REFERER, 'http://m.qzone.com/infocenter?g_f='); - }else{ - curl_setopt($ch, CURLOPT_REFERER, $referer); - } - } - if($ua){ - curl_setopt($ch, CURLOPT_USERAGENT,$ua); - }else{ - curl_setopt($ch, CURLOPT_USERAGENT,'Mozilla/5.0 (Linux; Android 4.4.2; NoxW Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/30.0.0.0 Mobile Safari/537.36'); - } - if($nobaody){ - curl_setopt($ch, CURLOPT_NOBODY,1); - } - curl_setopt($ch, CURLOPT_ENCODING, "gzip"); - curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); - $ret = curl_exec($ch); - curl_close($ch); - return $ret; -} -function real_ip(){ -$ip = $_SERVER['REMOTE_ADDR']; -if(isset($_SERVER['HTTP_X_FORWARDED_FOR']) && preg_match_all('#\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}#s', $_SERVER['HTTP_X_FORWARDED_FOR'], $matches)) { - foreach ($matches[0] AS $xip) { - if (!preg_match('#^(10|172\.16|192\.168)\.#', $xip)) { - $ip = $xip; - break; - } - } -} elseif (isset($_SERVER['HTTP_CLIENT_IP']) && preg_match('/^([0-9]{1,3}\.){3}[0-9]{1,3}$/', $_SERVER['HTTP_CLIENT_IP'])) { - $ip = $_SERVER['HTTP_CLIENT_IP']; -} elseif (isset($_SERVER['HTTP_CF_CONNECTING_IP']) && preg_match('/^([0-9]{1,3}\.){3}[0-9]{1,3}$/', $_SERVER['HTTP_CF_CONNECTING_IP'])) { - $ip = $_SERVER['HTTP_CF_CONNECTING_IP']; -} elseif (isset($_SERVER['HTTP_X_REAL_IP']) && preg_match('/^([0-9]{1,3}\.){3}[0-9]{1,3}$/', $_SERVER['HTTP_X_REAL_IP'])) { - $ip = $_SERVER['HTTP_X_REAL_IP']; -} -return $ip; -} -function get_ip_city($ip) -{ - $url = 'http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=json&ip='; - @$city = get_curl($url . $ip); - $city = json_decode($city, true); - if ($city['city']) { - $location = $city['province'].$city['city']; - } else { - $location = $city['province']; - } - if($location){ - return $location; - }else{ - return false; - } -} -function send_mail($to, $sub, $msg) { - global $conf; - include_once ROOT.'includes/smtp.class.php'; - $From = $conf['mail_name']; - $Host = $conf['mail_stmp']; - $Port = $conf['mail_port']; - $SMTPAuth = 1; - $Username = $conf['mail_name']; - $Password = $conf['mail_pwd']; - $Nickname = $conf['sitename']; - $SSL = false; - $mail = new SMTP($Host , $Port , $SMTPAuth , $Username , $Password , $SSL); - $mail->att = array(); - if($mail->send($to , $From , $sub , $msg, $Nickname)) { - return true; - } else { - return $mail->log; - } -} + function daddslashes($string, $force = 0, $strip = FALSE) { !defined('MAGIC_QUOTES_GPC') && define('MAGIC_QUOTES_GPC', get_magic_quotes_gpc()); if(!MAGIC_QUOTES_GPC || $force) { @@ -139,29 +45,6 @@ function daddslashes($string, $force = 0, $strip = FALSE) { return $string; } -function strexists($string, $find) { - return !(strpos($string, $find) === FALSE); -} - -function dstrpos($string, $arr) { - if(empty($string)) return false; - foreach((array)$arr as $v) { - if(strpos($string, $v) !== false) { - return true; - } - } - return false; -} - -function checkmobile() { - $useragent = strtolower($_SERVER['HTTP_USER_AGENT']); - $ualist = array('android', 'midp', 'nokia', 'mobile', 'iphone', 'ipod', 'blackberry', 'windows phone'); - if((dstrpos($useragent, $ualist) || strexists($_SERVER['HTTP_ACCEPT'], "VND.WAP") || strexists($_SERVER['HTTP_VIA'],"wap"))){ - return true; - }else{ - return false; - } -} function authcode($string, $operation = 'DECODE', $key = '', $expiry = 0) { $ckey_length = 4; @@ -204,91 +87,10 @@ function authcode($string, $operation = 'DECODE', $key = '', $expiry = 0) { } } -function random($length, $numeric = 0) { - $seed = base_convert(md5(microtime().$_SERVER['DOCUMENT_ROOT']), 16, $numeric ? 10 : 35); - $seed = $numeric ? (str_replace('0', '', $seed).'012340567890') : ($seed.'zZ'.strtoupper($seed)); - $hash = ''; - $max = strlen($seed) - 1; - for($i = 0; $i < $length; $i++) { - $hash .= $seed{mt_rand(0, $max)}; - } - return $hash; -} -function getSetting($k, $force = false){ - global $DB,$CACHE; - if($force) return $setting[$k] = $DB->get_row("SELECT v FROM web_config WHERE k='$k' limit 1"); - $cache = $CACHE->get($k); - return $cache[$k]; -} + function saveSetting($k, $v){ $v = daddslashes($v); return mysqli_query($GLOBALS['con'],"UPDATE `lylme_config` SET `v` = '$v' WHERE `lylme_config`.`k` = '$k';"); } -function showmsg($content = '未知的异常',$type = 4,$back = false) -{ -switch($type) -{ -case 1: - $panel="success"; -break; -case 2: - $panel="info"; -break; -case 3: - $panel="warning"; -break; -case 4: - $panel="danger"; -break; -} - -echo '
-
-

提示信息

-
-
'; -echo $content; - -if ($back) { - echo '
<< 返回上一页'; -} -else - echo '
<< 返回上一页'; - -echo '
-
'; -exit; -} -function sysmsg($msg = '未知的异常',$die = true) { - ?> - - - - - - 站点提示信息 - - - - 站点提示信息'; - echo $msg; ?> - - - \ No newline at end of file