`~~~
/**
* 根据用户IP获取用户地理位置
* $ip 用户ip
*/
public function get_position($ip){
if(empty($ip)){
return '缺少用户ip';
}
$url = 'http://ip.taobao.com/service/getIpInfo.php?ip='.$ip;
$ipContent = file_get_contents($url);
$ipContent = json_decode($ipContent,true);
return $ipContent;
}
/**
* 用户设备类型
* @return string
*/
public static function clientOS() {
$agent = strtolower($_SERVER['HTTP_USER_AGENT']);
if(strpos($agent, 'windows nt')) {
$platform = 'windows';
} elseif(strpos($agent, 'macintosh')) {
$platform = 'mac';
} elseif(strpos($agent, 'ipod')) {
$platform = 'ipod';
} elseif(strpos($agent, 'ipad')) {
$platform = 'ipad';
} elseif(strpos($agent, 'iphone')) {
$platform = 'iphone';
} elseif (strpos($agent, 'android')) {
$platform = 'android';
} elseif(strpos($agent, 'unix')) {
$platform = 'unix';
} elseif(strpos($agent, 'linux')) {
$platform = 'linux';
} else {
$platform = 'other';
}
return $platform;
}
/**
* 判断请求是否是移动端
* @return bool
*/
public static function isMobile()
{
$user_agent = $_SERVER['HTTP_USER_AGENT'];
$mobile_agents = array ('iphone','android','phone','mobile','wap','netfront','java','opera mobi',
'opera mini','ucweb','windows ce','symbian','series','webos','sony','blackberry','dopod',
'nokia','samsung','palmsource','xda','pieplus','meizu','midp','cldc','motorola','foma',
'docomo','up.browser','up.link','blazer','helio','hosin','huawei','novarra','coolpad',
'techfaith','alcatel','amoi','ktouch','nexian','ericsson','philips','sagem','wellcom',
'bunjalloo','maui','smartphone','iemobile','spice','bird','zte-','longcos','pantech',
'gionee','portalmmm','jig browser','hiptop','benq','haier','^lct','320x320','240x320',
'176x220','windows phone','cect','compal','ctl','lg','nec','tcl','daxian','dbtel','eastcom',
'konka','kejian','lenovo','mot','soutec','sgh','sed','capitel','panasonic','sonyericsson',
'sharp','panda','zte','acer','acoon','acs-','abacho','ahong','airness','anywhereyougo.com',
'applewebkit/525','applewebkit/532','asus','audio','au-mic','avantogo','becker','bilbo',
'bleu','cdm-','danger','elaine','eric','etouch','fly ','fly_','fly-','go.web','goodaccess',
'gradiente','grundig','hedy','hitachi','htc','hutchison','inno','ipad','ipaq','ipod',
'jbrowser','kddi','kgt','kwc','lg ','lg2','lg3','lg4','lg5','lg7','lg8','lg9','lg-','lge-',
'lge9','maemo','mercator','meridian','micromax','mini','mitsu','mmm','mmp','mobi','mot-',
'moto','nec-','newgen','nf-browser','nintendo','nitro','nook','obigo','palm','pg-',
'playstation','pocket','pt-','qc-','qtek','rover','sama','samu','sanyo','sch-','scooter',
'sec-','sendo','sgh-','siemens','sie-','softbank','sprint','spv','tablet','talkabout',
'tcl-','teleca','telit','tianyu','tim-','toshiba','tsm','utec','utstar','verykool','virgin',
'vk-','voda','voxtel','vx','wellco','wig browser','wii','wireless','xde','pad','gt-p1000');
$ismobile = false;
foreach ($mobile_agents as $device) {
if (stristr($user_agent, $device)) {
$ismobile = true;
break;
}
}
return $ismobile;
}
~~~`
- 公共页面js
- 公共页面添加js
- 公共页面编辑js
- 公共页面列表js
- 文件上传方法
- 分类相关
- 获取ip
- Response类
- Curl类
- JWT
- tp5.1下redis的使用
- tp5.1使用RabbitMQ
- tp5.1+easywechat相关
- tp5.1+easywechat实现小程序登录
- uniapp页面
- tp控制器
- git相关操作
- php文件操作
- 大文件上传
- laravel队列
- 1.安装laravel并进行相关配置
- nginx反向代理解决微信公众号,小程序,微信支付域名限制,回调
- readme
- do
- 杂项
- cas单点登录
- tp6跨域(中间件不起作用版)
- php算法
- 冒泡排序
- knn算法
- 使用es
- 使用mongdb
- tp6+rabbirmq
- 一些问题
- php文件操作/文件操作的一些方法
- 客户端请求相关