function bq()
{
echo '超全局php文件开发人员QQ' . '1931422288' . '
';#版权信息
exit();#退出程序
}
#说明
function sm()
{
echo '' .
'文件使用方法在php解释器目录下的php.ini auto_prepend_file配置引入绝对路径方法的引入这个文件过来' . '
#当前地址
function dz()
{
$dz = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];#当前地址
return ($dz);#返回当前地址
}
#上一个地址
function fh()
{
$fh = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';#上一个地址
return ($fh);
}
#前端框架
function qdkj()
{
echo "
";
}
#过滤符号
function glfh($str)
{
$search = [' ', ' ', "\n", "\r", "\t"];
$replace = ['', '', '', '', ''];
return str_replace($search, $replace, $str);
}
#获取运行网站路径
function yxlj()
{
$a = $_SERVER['DOCUMENT_ROOT'];#获取运行目录
$a = strpos($a, 'public');#判断是否是框架运行目录
if ($a != 0) {
#如果是框架运行目录
$AAA = $_SERVER['DOCUMENT_ROOT'];#获取运行目录
return substr($AAA, 0, -6);#返回运行目录
} else {
#如果是原生运行目录
return $_SERVER['DOCUMENT_ROOT'];#返回运行目录
}
}
#数据库操作
function sjk($sql)
{
$e = yxlj();#获取运行目录
$e = $e . '/' . 'sjk.txt';#获取数据库配置文件路径
$myFile = file($e);#读取数据库配置文件
#读取数据库配置文件
$b = glfh($myFile[0]);#读取数据库配置文件ip和端口号
$c = glfh($myFile[1]);#读取数据库配置文件用户名
$f = glfh($myFile[2]);#读取数据库配置文件密码
$g = glfh($myFile[3]);#读取数据库配置文件库名
#连接配置
$db = mysqli_connect($b, $c, $f, $g);#连接数据库
#设置字符编码
mysqli_query($db, "set names 'utf8'");#设置字符编码
# 执行查询
$exe_res = mysqli_query($db, $sql);#执行查询
#如果是查询操作
if (is_object($exe_res)) {
# 返回数据
$data = mysqli_fetch_all($exe_res, MYSQLI_ASSOC);#返回数据
return $data;#返回数据
} else {
#如果是增删改操作
return $exe_res;#返回数据
}
mysqli_close($db);#关闭数据库连接
#关闭数据库连接
}
#跳转提示
function tzts($a, $b, $c = '')
{
#直接跳转
if ($a == 1) {
header("Location:$b");#直接跳转
#直接跳转
exit();
} else if ($a == 2) {
#程序成功时跳转并提示3秒延时
echo "
#判断是不是空字符串
function skzfc($fname)
{
if (strlen($fname) > 0) {
return FALSE;#不是空字符串
} else {
return TRUE;#是空字符串
}
}
#分页
function fy($user, $ts)
{
bc();
$fy = count($user) / $ts;
if (is_int($fy)) {
} else {
$fy = intval($fy) + 1;
#一共有多少页
}
if (empty($_GET['y']) || $_GET['y'] <= 1) {
$page = 1;
#第几页
} else {
$page = $_GET['y'];
if ($_GET['y'] < 0) {
$page = 1;
}
}
$indexinpage = $ts;
#分页条数
$newarr = array_slice($user, ($page - 1) * $indexinpage, $indexinpage);
#当前分页数据
return [$newarr, $page, $fy];
}
#获取当前地址并去参数
function dzl()
{
$f = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
#获取当前地址
$g = substr($f, 0, strrpos($f, '?'));
#获取当前地址没有参数的
return ($g);
}
#分页模板
function fymb($a, $z)
{
$b = $a[1] - 1;
$d = $a[2];
$e = $a[1];
$f = $a[1] + 1;
$p = jddz();
$g = dz();
$k = dzl();
if (empty($_GET['y'])) {
tzts(1, "$g?y=1");
}
$s = count($a[0]);
$n = count($z);
#获取当前地址没有参数的
echo "
#前端禁止查看代码
function qdjz()
{
echo '';
}
#随机图片
function sjtp()
{
$a = rand(0, 999999999999999999) . '.jpg';
#随机数
return $a;
}
function ym()
{
return 'http://' . $_SERVER['HTTP_HOST'];
#获取当前的域名
}
#三维数组转二维数组
function swszzew($d)
{
foreach ($d as $key => $v) {
$new_arr[] = $v[0];
}
return ($new_arr);
#三维数组转二维数组
}
#搜索
function ss($user, $ac)
{
#二维数组的模糊查询
$arr = $result = [];
foreach ($user as $key => $value) {
foreach ($value as $valu) {
#查询关键字
if (strstr($valu, $ac) !== FALSE) {
array_push($arr, $key);
}
}
}
foreach ($arr as $key => $value) {
if (array_key_exists($value, $user)) {
array_push($result, $user[$value]);
}
}
if (empty($result)) {
#如果查询结果为空
echo '
#包含端口号的完整url
function jddz()
{
return 'http://' . $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT'] . $_SERVER['REQUEST_URI'];
}
#获取当前地址的参数
function dzcs()
{
return $_SERVER['QUERY_STRING'];
}
#判断字符串是否相等
function zfcxd($str1, $str2)
{
if ($str1 == $str2) {
return TRUE;
} else {
return FALSE;
}
}
#是否登录了
function sfdl()
{
if (empty($_SESSION['dl'])) {
tzts(3, ym(), '您好你还没有登陆呢');#跳转到登录页面
} else {
return $_SESSION['dl'];#返回登录的用户名
}
}
#赋值登录session会话
function fzhh($a)
{
$_SESSION['dl'] = $a;
}
#获取登录session会话值
function hqhh()
{
return $_SESSION['dl'];
}
#是否已经登录了
function yjdl($a)
{
if (empty($_SESSION['dl'])) {
} else {
tzts(3, $a, '您已经登录了无需重新登录');
}
}
#检查数据
function jc($a, $b = '')
{
if ($b != '') {
#检查数据类型
echo '
';
var_dump($a);
exit();
} else {
#检查数据
echo '';
print_r($a);
exit();
}
}#退出登录
function tc()
{
session_destroy();#销毁session
tzts(2, ym(), '退出登录成功');
}#对象转数组
function dxzsz(&$object)
{
$object = json_decode(json_encode($object), TRUE);
return $object;
}#字符串转码
function zfzm($wjmaa, $toType)
{
if ($toType == 'UTF-8') {
header("content-Type: text/html; charset=Utf-8");#设置编码
$string = mb_convert_encoding($wjmaa, "GBK", "UTF-8");
} else if ($toType == 'GBK') {
header("content-Type: text/html; charset=GBK");
$string = mb_convert_encoding($wjmaa, "UTF-8", "GBK");
}
return $string;
}#文件下载
function wjxz($filename)
{
header('Content-Type: application/octet-stream');#文件类型
#多类型文件下载
header('Content-Disposition: attachment; filename=' . $filename);#下载文件名
#下载文件名
header('content-length:' . filesize($filename));#文件大小
//文件大小
@readfile($filename);
//读取文件并写入到输出缓冲
}#百分比
function bfb($z)
{
return sprintf('%01.2f', $z * 100) . '%';
}#四舍五入留两位小数
function sswr($x)
{
return round($x, 2);#四舍五入
}#一维数组转二维
function ywszzew($data)
{
$newarray = [];
foreach ($data as $a) {
$newarray[] = $a;
}
return $newarray;
}#一维数组键名替换
function ywszjmth($newarray, $a, $b)
{
$newarray[$a] = $newarray[$b];#替换键名
unset($newarray[$b]);#删除原来的键名
}#比例
function bl($value1, $value2, $gcd)
{
if ($gcd == 0) {
return strval($value1) . ' : ' . strval($value2);#如果最大公约数为0
}
return strval($value1 / $gcd) . ' : ' . strval($value2 / $gcd);#返回比例
}#异步刷新
function ybsx($a)
{
echo "";
}#手机号
function sjh($str)
{
$a = preg_match('/^0?(13|14|15|17|18)[0-9]{9}$/', $str);#匹配手机号
if ($a == 1) {
return $str;#返回手机号
} else {
return false;#返回false
}
}#输出
function sc($a, $b)
{
if ($b == 1) {
echo "$a";
} else if ($b == 2) {
echo "$a";
} else if ($b == 3) {
echo "$a";
}
}#空格
function kg()
{
echo ' ';
}#获取用户ip
function ip()
{
$ip = $_SERVER['REMOTE_ADDR'];#获取ip
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;
}
}
} else if (
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'];
} else if (
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'];
} else if (
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;#返回ip
}#当前时间
function sj($a = '')
{
if ($a == '') {
return date('Y-m-d H:i:s');#返回当前时间
} elseif ($a == 1) {
return date('Y-m-d');
} elseif ($a == 2) {
return str_replace("-", "", date('Y-m-d'));#替换掉指定的符号
}}
#链接样式
function lj()
{
echo '';
}function getCode($num, $w, $h)
{
$code = '';
for ($i = 0; $i < $num; $i++) {
$code .= rand(0, 9);
}
//4位验证码也可以用rand(1000,9999)直接生成
//将生成的验证码写入session,备验证时用
session_start();
// 存储 session 数据
$_SESSION['yzm'] = $code;
//创建图片,定义颜色值
header('Content-type: image/PNG');
$im = imagecreate($w, $h);
$black = imagecolorallocate($im, 0, 0, 0);
$gray = imagecolorallocate($im, 200, 200, 200);
$bgcolor = imagecolorallocate($im, 255, 255, 255);
//填充背景
imagefill($im, 0, 0, $gray);
//画边框
imagerectangle($im, 0, 0, $w - 1, $h - 1, $black);
//随机绘制两条虚线,起干扰作用
$style = [
$black, $black, $black, $black, $black,
$gray, $gray, $gray, $gray, $gray,
];
imagesetstyle($im, $style);
$y1 = rand(0, $h);
$y2 = rand(0, $h);
$y3 = rand(0, $h);
$y4 = rand(0, $h);
imageline($im, 0, $y1, $w, $y3, IMG_COLOR_STYLED);
imageline($im, 0, $y2, $w, $y4, IMG_COLOR_STYLED);
//在画布上随机生成大量黑点,起干扰作用;
for ($i = 0; $i < 80; $i++) {
imagesetpixel($im, rand(0, $w), rand(0, $h), $black);
}
//将数字随机显示在画布上,字符的水平间距和位置都按一定波动范围随机生成
$strx = rand(3, 8);
for ($i = 0; $i < $num; $i++) {
$strpos = rand(1, 6);
imagestring($im, 5, $strx, $strpos, substr($code, $i, 1), $black);
$strx += rand(8, 12);
}
imagepng($im);
//输出图片
imagedestroy($im);
//释放图片所占内存
}#图片验证码
function yzm()
{
getCode(4, 50, 20);
}#随机压缩包
function sjysb()
{
$a = rand(0, 99999999) . '.zip';
#随机数
return $a;
}#是否是手机设备
function sfsjsb()
{
$useragent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
$useragent_commentsblock = preg_match('|\(.*?\)|', $useragent, $matches) > 0 ? $matches[0] : '';
function CheckSubstrs($substrs, $text)
{
foreach ($substrs as $substr)
if (FALSE !== strpos($text, $substr)) {
return TRUE;
}
return FALSE;
}$mobile_os_list = ['Google Wireless Transcoder', 'Windows CE', 'WindowsCE', 'Symbian', 'Android', 'armv6l', 'armv5', 'Mobile', 'CentOS', 'mowser', 'AvantGo', 'Opera Mobi', 'J2ME/MIDP', 'Smartphone', 'Go.Web', 'Palm', 'iPAQ'];
$mobile_token_list = ['Profile/MIDP', 'Configuration/CLDC-', '160×160', '176×220', '240×240', '240×320', '320×240', 'UP.Browser', 'UP.Link', 'SymbianOS', 'PalmOS', 'PocketPC', 'SonyEricsson', 'Nokia', 'BlackBerry', 'Vodafone', 'BenQ', 'Novarra-Vision', 'Iris', 'NetFront', 'HTC_', 'Xda_', 'SAMSUNG-SGH', 'Wapaka', 'DoCoMo', 'iPhone', 'iPod'];
$found_mobile = CheckSubstrs($mobile_os_list, $useragent_commentsblock) ||
CheckSubstrs($mobile_token_list, $useragent);
if ($found_mobile) {
return TRUE;
} else {
return FALSE;
}
}#会话过期时间
function hhgqsj($expire = 0)
{
if ($expire == 0) {
$expire = ini_get('session.gc_maxlifetime');
} else {
ini_set('session.gc_maxlifetime', $expire);
}
if (empty($_COOKIE['PHPSESSID'])) {
session_set_cookie_params($expire);
session_start();
} else {
session_start();
setcookie('PHPSESSID', session_id(), time() + $expire);
}
}#乱码
function lm()
{
echo '';
header('content-type:text/html;charset=utf-8');
}#邮箱
function yq($a)
{
if (!preg_match('/([\w\-]+\@[\w\-]+\.[\w\-]+)/', $a)) {
return TRUE;
} else {
return FALSE;
}
}#获取验证码
function hqyzm()
{
return $_SESSION['yzm'];
}#是否是管理员
function sfgly()
{
if (empty($_SESSION['gly'])) {
tzts(3, ym(), '您好你不是管理员没有权限');
} else {
return $_SESSION['gly'];
}
}#赋值管理员session会话
function fzgly($a)
{
#创建seeion会话
$_SESSION['gly'] = $a;
#赋值seeion会话
}#时间差
function sjc($a, $b)
{
$time1 = strtotime($a);
$time2 = strtotime($b);
$diff_seconds = $time2 - $time1;
$diff_days = floor($diff_seconds / 86400);
return $diff_days;
}#整数转字符串
function zszzfc($num)
{
$str = strval($num);
return strrev($str);
}#按钮链接
function anlj($a)
{
echo "onClick=location.href='$a'";
}#是不是整数
function sfszs($age)
{
if (!is_numeric($age) || strpos($age, '.') !== FALSE) {
tzts(3, fh(), '您输入的不是整数');
} else {
return $age;
}
}#隐藏
function yc()
{
echo "type='hidden'";
#输入框里面的隐藏属性
}#锁定
function sd()
{
echo "readonly='readonly'";
}#是否是小数
function sfsxs($nubs)
{
if (strpos($nubs, '.') !== FALSE) {
return $nubs;
} else {
tzts(3, fh(), '您输入的不是小数');
}
}#输出文本信息
function scwbxx($file_path)
{
if (file_exists($file_path)) {
$fp = fopen($file_path, 'r');
$str = fread($fp, filesize($file_path));
//指定读取大小,这里把整个文件内容读取出来
echo $str = str_replace("\r\n", '
', $str);
fclose($fp);
}
}#获取json
function hqjson($v)
{
$a = file_get_contents($v);
$re = json_decode($a, TRUE);
return $re;
}#删除文件夹
function scwjj($dir)
{
// 关闭所有PHP错误报告
error_reporting(0);
$iter = new RecursiveDirectoryIterator($dir);
foreach (
new RecursiveIteratorIterator($iter, RecursiveIteratorIterator::CHILD_FIRST) as $f
) {
if ($f->isDir()) {
rmdir($f->getPathname());
} else {
unlink($f->getPathname());
}
}
rmdir($dir);
#删除该文件夹
}#是不是json
/**
* 校验json字符串
*
* @param string $stringData
*
* @return bool
*/
function sbsjson($stringData)
{
return is_null(json_decode($stringData));
}#缓存
function hc()
{
$e = yxlj();
$e = $e . '/' . 'hc.txt';
$myFile = file($e);
#读取数据库配置文件
$b = glfh($myFile[0]);
$c = glfh($myFile[1]);
$y = glfh($myFile[2]);
$redis = new Redis();
$redis->connect($b, $c, 1000);
#连接3秒redis后关闭
$redis->auth($y);
return $redis;
}#超链接
function clj($a, $b)
{
echo "$b";
}#报错取消
function bc()
{
error_reporting(0);
#屏蔽php解释器的报错
}#文件值存在
function wjzcz($b, $a)
{
global $c;
foreach ($b as $v) {
if (glfh($v) == $a) {
$c = 0;
$c++;
}
}
if ($c != 0) {
return 1;
#如果txt文件的某一行字符串跟这个参数二的值相等返回1
} else {
return 0;
#如果txt文件的某一行字符串跟这个参数二的值不相等返回0
}
}#声明会话开启
function hh()
{
session_start();
#开启session
}#图片文件
function tpwj($a, $b)
{
$c = sjtp();
$type1 = $_FILES[$a]['name'];
$type = substr($type1, strripos($type1, '.') + 1);
#获取文件后缀名
$filetype = ['jpg', 'jpeg', 'gif', 'bmp', 'png', 'tif', 'gif', 'pcx', 'tga', 'exif', 'fpx', 'svg', 'psd', 'cdr', 'pcd', 'dxf', 'ufo', 'eps', 'ai', 'raw', 'WMF', 'webp', 'avif', 'apng'];
if (!in_array($type, $filetype)) {
tzts(3, fh(), '您只能上传图片类型文件或没有选择图片哦');
} else {
move_uploaded_file($_FILES[$a]['tmp_name'], $b . "/$c");
return $c;
}
}#表单文件上传属性
function bdwj()
{
echo 'enctype="multipart/form-data"';
#文件上传表单的属性
}#获取输入框值
function hqz($a)
{
echo "$('#$a').val();";
}#无限级
class wxj
{
static function wxjff($cates, $pid = 0)
{
#无限极类的方法
$newArr = [];
foreach ($cates as $c) {
if ($c['pid'] == $pid) {
$c['child'] = self::wxjff($cates, $c['cat_id']);
$newArr[] = $c;
}
}
return $newArr;
}
}#随机数
function sjs()
{
return rand(0, 999999999999999999);
}#输入提示
function ts($a)
{
echo "placeholder='$a'";
}#获取指定键值
function hqzdjz($a, $b)
{
global $c;
$c = [];
foreach ($a as $v) {
array_push($c, $v[$b]);
return implode(',', $c);
}
}/**
* 图片压缩处理
*
* @param string $sFile 源图片路径
* @param int $iWidth 自定义图片宽度
* @param int $iHeight 自定义图片高度
*
* @return string 压缩后的图片路径
*/
function ystp($sFile, $iWidth, $iHeight)
{
//图片公共路径
$public_path = '';
//判断该图片是否存在
if (!file_exists($public_path . $sFile)) return $sFile;
//判断图片格式(图片文件后缀)
$extend = explode('.', $sFile);
$attach_fileext = strtolower($extend[count($extend) - 1]);
if (!in_array($attach_fileext, ['jpg', 'jpeg', 'gif', 'bmp', 'png', 'tif', 'gif', 'pcx', 'tga', 'exif', 'fpx', 'svg', 'psd', 'cdr', 'pcd', 'dxf', 'ufo', 'eps', 'ai', 'raw', 'WMF', 'webp', 'avif', 'apng'])) {
return '';
}
//压缩图片文件名称
$sFileNameS = str_replace('.' . $attach_fileext, '_' . $iWidth . '_' . $iHeight . '.' . $attach_fileext, $sFile);
//判断是否已压缩图片,若是则返回压缩图片路径
if (file_exists($public_path . $sFileNameS)) {
return $sFileNameS;
}
//生成压缩图片,并存储到原图同路径下
resizeImage($public_path . $sFile, $public_path . $sFileNameS, $iWidth, $iHeight);
if (!file_exists($public_path . $sFileNameS)) {
return $sFile;
}
return $sFileNameS;
}#是否是url
function sflj($a)
{
if (!filter_var($a, FILTER_VALIDATE_URL)) {
tzts(3, fh(), '不是正确的url');
} else {
return $a;
}
}#获取数组的长度
function hqszcd($a)
{
return count($a);
}#获取二维数组对应的键的值
function hqewszdydjdz($b, $a)
{
return array_column($b, $a);
}#数组分割成字符串
function szfgzfc($a, $b)
{
return implode("$a", $b);
}#随机数组的键值
function sjszjz($b, $a)
{
return array_rand($b, $a);
}#数组的键和值调反
function szjzdf($a)
{
return array_flip($a);
}#删除文件
function scwj($a)
{
unlink($a);
}function jm($action, $string)
{
$output = false;
$encrypt_method = "AES-256-CBC";
$secret_key = 'MySecretKey';
$secret_iv = 'MySecretIv';
// hash
$key = hash('sha256', $secret_key);
// iv - encrypt method AES-256-CBC expects 16 bytes
$iv = substr(hash('sha256', $secret_iv), 0, 16);
if ($action == 'encrypt') {
#加密
$output = openssl_encrypt($string, $encrypt_method, $key, 0, $iv);
$output = base64_encode($output);
} else if ($action == 'decrypt') {
#解密 $string是加密后的字符串
$output = openssl_decrypt(base64_decode($string), $encrypt_method, $key, 0, $iv);
}
return $output;
}#随机字符串
function sjzfc()
{
$strs = "QWERTYUIOPASDFGHJKLZXCVBNM1234567890qwertyuiopasdfghjklzxcvbnm";
$name = substr(str_shuffle($strs), mt_rand(0, strlen($strs) - 11), 10);
return $name;
}#访问限制
function fwxz($a)
{
$t = strtotime(date('Y-m-d 23:59:59'));
if (!isset($_COOKIE['frequency'])) {
setcookie('frequency', 1, $t);
} else {
if ($_COOKIE['frequency'] >= $a) exit('访问次数过多怀疑cc请每天再来访问吧');
setcookie('frequency', $_COOKIE['frequency'] + 1, $t);
}
}#返回接口
// json数据格式整理
function jk($data, $code = 200)
{
if ($code == 200) {
$array = array(
'code' => $code,
'msg' => 'success',
'data' => $data
);
} else {
$array = array(
'code' => $code,
'msg' => $data
);
}
echo json_encode($array);
exit;
}#浏览器缓存永久保存
function llq($a, $b)
{
setcookie("$a", "$b", time() + 99993600);
}#运行耗时
function yxhs($b, $a)
{
$c = strtotime($b) - strtotime($a);
#运行耗时多少秒
if ($c > 60) {
$d = $c % 60;
$e = intval($c / 60);
echo "运行耗时$e 分$d 秒";
} elseif ($c < 60) {
echo "运行耗时$c 秒";
}
}#加载元素
function jzys($c, $a, $b)
{
if ($c == 0) {
#无限定时执行加载节点替换
echo "";
} elseif ($c == 1) {
#定时一次执行加载节点替换
echo "setTimeout(setTime,1000);
function setTime(){
$('$a').load('$b');
}";
} elseif ($c == 2) {
#直接加载节点替换
echo "$('$a').load('$b')";
}
}#获取用户的操作系统
function czxt()
{
$user_OSagent = $_SERVER['HTTP_USER_AGENT'];
if (strpos($user_OSagent, "NT 6.1")) {
$visitor_os = "Windows 7";
} elseif (strpos($user_OSagent, "NT 5.1")) {
$visitor_os = "Windows XP (SP2)";
} elseif (strpos($user_OSagent, "NT 5.2") && strpos($user_OSagent, "WOW64")) {
$visitor_os = "Windows XP 64-bit Edition";
} elseif (strpos($user_OSagent, "NT 5.2")) {
$visitor_os = "Windows 2003";
} elseif (strpos($user_OSagent, "NT 6.0")) {
$visitor_os = "Windows Vista";
} elseif (strpos($user_OSagent, "NT 5.0")) {
$visitor_os = "Windows 2000";
} elseif (strpos($user_OSagent, "4.9")) {
$visitor_os = "Windows ME";
} elseif (strpos($user_OSagent, "NT 4")) {
$visitor_os = "Windows NT 4.0";
} elseif (strpos($user_OSagent, "98")) {
$visitor_os = "Windows 98";
} elseif (strpos($user_OSagent, "95")) {
$visitor_os = "Windows 95";
} elseif (strpos($user_OSagent, "NT")) {
$visitor_os = "Windows 较高版本";
} elseif (strpos($user_OSagent, "Mac")) {
$visitor_os = "Mac";
} elseif (strpos($user_OSagent, "Linux")) {
$visitor_os = "Linux";
} elseif (strpos($user_OSagent, "Unix")) {
$visitor_os = "Unix";
} elseif (strpos($user_OSagent, "FreeBSD")) {
$visitor_os = "FreeBSD";
} elseif (strpos($user_OSagent, "SunOS")) {
$visitor_os = "SunOS";
} elseif (strpos($user_OSagent, "BeOS")) {
$visitor_os = "BeOS";
} elseif (strpos($user_OSagent, "OS/2")) {
$visitor_os = "OS/2";
} elseif (strpos($user_OSagent, "PC")) {
$visitor_os = "Macintosh";
} elseif (strpos($user_OSagent, "AIX")) {
$visitor_os = "AIX";
} elseif (strpos($user_OSagent, "IBM OS/2")) {
$visitor_os = "IBM OS/2";
} elseif (strpos($user_OSagent, "BSD")) {
$visitor_os = "BSD";
} elseif (strpos($user_OSagent, "NetBSD")) {
$visitor_os = "NetBSD";
} else {
$visitor_os = "其它操作系统";
}
return $visitor_os;
}#获取手机设备型号
function sjsb()
{
$user_agent = $_SERVER['HTTP_USER_AGENT'];
if (stripos($user_agent, "iPhone") !== false) {
$brand = 'iPhone';
} else if (stripos($user_agent, "SAMSUNG") !== false || stripos($user_agent, "Galaxy") !== false || strpos($user_agent, "GT-") !== false || strpos($user_agent, "SCH-") !== false || strpos($user_agent, "SM-") !== false) {
$brand = '三星';
} else if (stripos($user_agent, "Huawei") !== false || stripos($user_agent, "Honor") !== false || stripos($user_agent, "H60-") !== false || stripos($user_agent, "H30-") !== false) {
$brand = '华为';
} else if (stripos($user_agent, "Lenovo") !== false) {
$brand = '联想';
} else if (strpos($user_agent, "MI-ONE") !== false || strpos($user_agent, "MI 1S") !== false || strpos($user_agent, "MI 2") !== false || strpos($user_agent, "MI 3") !== false || strpos($user_agent, "MI 4") !== false || strpos($user_agent, "MI-4") !== false) {
$brand = '小米';
} else if (strpos($user_agent, "HM NOTE") !== false || strpos($user_agent, "HM201") !== false) {
$brand = '红米';
} else if (stripos($user_agent, "Coolpad") !== false || strpos($user_agent, "8190Q") !== false || strpos($user_agent, "5910") !== false) {
$brand = '酷派';
} else if (stripos($user_agent, "ZTE") !== false || stripos($user_agent, "X9180") !== false || stripos($user_agent, "N9180") !== false || stripos($user_agent, "U9180") !== false) {
$brand = '中兴';
} else if (stripos($user_agent, "OPPO") !== false || strpos($user_agent, "X9007") !== false || strpos($user_agent, "X907") !== false || strpos($user_agent, "X909") !== false || strpos($user_agent, "R831S") !== false || strpos($user_agent, "R827T") !== false || strpos($user_agent, "R821T") !== false || strpos($user_agent, "R811") !== false || strpos($user_agent, "R2017") !== false) {
$brand = 'OPPO';
} else if (strpos($user_agent, "HTC") !== false || stripos($user_agent, "Desire") !== false) {
$brand = 'HTC';
} else if (stripos($user_agent, "vivo") !== false) {
$brand = 'vivo';
} else if (stripos($user_agent, "K-Touch") !== false) {
$brand = '天语';
} else if (stripos($user_agent, "Nubia") !== false || stripos($user_agent, "NX50") !== false || stripos($user_agent, "NX40") !== false) {
$brand = '努比亚';
} else if (strpos($user_agent, "M045") !== false || strpos($user_agent, "M032") !== false || strpos($user_agent, "M355") !== false) {
$brand = '魅族';
} else if (stripos($user_agent, "DOOV") !== false) {
$brand = '朵唯';
} else if (stripos($user_agent, "GFIVE") !== false) {
$brand = '基伍';
} else if (stripos($user_agent, "Gionee") !== false || strpos($user_agent, "GN") !== false) {
$brand = '金立';
} else if (stripos($user_agent, "HS-U") !== false || stripos($user_agent, "HS-E") !== false) {
$brand = '海信';
} else if (stripos($user_agent, "Nokia") !== false) {
$brand = '诺基亚';
} else {
$brand = '其他手机';
}
return $brand;
}/**
* 判断是否存在特殊字符,可判断中英文及特殊符号混合串
* 存在返回true
* @param string $str
* @return boolean
*/
#有没有特殊字符
function ymytsfh($str)
{
//$前要加反斜杠
$specialChars = "~·`!!@#\$¥%^…&*()()—-_=+[]{}【】、|\\;:;:'\"“‘,./<>《》??,。";
//特殊符号数组
$specialArr = array();
$len = mb_strlen($specialChars, 'UTF-8');
for ($i = 0; $i < $len; $i++) {
$specialArr[] = mb_substr($specialChars, $i, 1, 'UTF-8');
}
//待比较字符串数组
$arr = array();
$len = mb_strlen($str, 'UTF-8');
for ($i = 0; $i < $len; $i++) {
$arr[] = mb_substr($str, $i, 1, 'UTF-8');
}
foreach ($arr as $v) {
if (in_array($v, $specialArr)) {
return true;
}
}
return false;
}#远程下载
function ycxz($image, $rename)
{
$s = strripos($rename, '\\');
$name = substr($rename, $s + 1); #截到最后一个/后面的字符
$j = trim($rename, "$name"); #截取到的目录
bc();
mkdir($j, 0777);#创建目录
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 0);
curl_setopt($ch, CURLOPT_URL, $image);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// https请求 不验证证书和hosts
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
// 从证书中检查SSL加密算法是否存在(默认不需要验证)
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
$file_content = curl_exec($ch);
curl_close($ch);
$downloaded_file = fopen($rename, 'w+');
fwrite($downloaded_file, $file_content);
fclose($downloaded_file);
}#数组转码
// 第一个参数为当前编码,第二个参数为转换后的编码,第三个参数是一维或者二维数组
function szzm($in_charset, $out_charset, $arr)
{
foreach ($arr as $k => & $v) {
if (is_array($v)) {
foreach ($v as $kk => & $vv) {
$vv = iconv($in_charset, $out_charset, $vv);
}
} else {
$v = iconv($in_charset, $out_charset, $v);
}
}
return $arr;
}#php数组转为csv下载
/**
* 创建(导出)Excel数据表格
* @param array $list 要导出的数组格式的数据
* @param string $filename 导出的Excel表格数据表的文件名
* @param array $header Excel表格的表头
* @param array $index $list数组中与Excel表格表头$header中每个项目对应的字段的名字(key值)
* 比如: $header = array('编号','姓名','性别','年龄');
* $index = array('id','username','sex','age');
* $list = array(array('id'=>1,'username'=>'YQJ','sex'=>'男','age'=>24));
* @return [array] [数组]
*/
function csv($list, $filename, $header = array(), $index = array())
{
header("Content-type:application/vnd.ms-excel");
header("Content-Disposition:filename=" . $filename . ".csv");
$teble_header = implode("\t", $header);
$strexport = $teble_header . "\r";
foreach ($list as $row) {
foreach ($index as $val) {
$strexport .= $row[$val] . "\t";
}
$strexport .= "\r";
}
$strexport = iconv('UTF-8', "GB2312//IGNORE", $strexport);
exit($strexport);
}#日期格式转时间戳
function rqzsjc($a)
{
return mktime(intval($a));
}#截取字符串中的数字
function jqzfcdsz($serial)
{
$pattern = '/\d+/';
if (preg_match_all($pattern, $serial, $arr)) {
return implode($arr[0]);
}
}