public function ip() { import('ORG.Net.IpLocation'); // 导入IpLocation类 $Ip = new IpLocation(); // 实例化类 $location = $Ip->getlocation('218.79.93.194'); // 获取某个IP地址所在的位置 $area = $Ip->getlocation(); dump($area); }
function IP($ip = '', $file = 'UTFWry.dat') { import("@.ORG.IpLocation"); $iplocation = new IpLocation($file); $location = $iplocation->getlocation($ip); return $location; }
public function index() { echo $_POST['keyword']; //搜索 if (!empty($_GET['keyword'])) { if ($_GET['searchtype'] == 'uid') { $condition_user['uid'] = $_GET['keyword']; } else { if ($_GET['searchtype'] == 'nickname') { $condition_user['nickname'] = array('like', '%' . $_GET['keyword'] . '%'); } else { if ($_GET['searchtype'] == 'phone') { $condition_user['phone'] = array('like', '%' . $_GET['keyword'] . '%'); } } } } $database_user = D('User'); $count_user = $database_user->where($condition_user)->count(); import('@.ORG.system_page'); $p = new Page($count_user, 15); $user_list = $database_user->field(true)->where($condition_user)->order('`uid` DESC')->limit($p->firstRow . ',' . $p->listRows)->select(); if (!empty($user_list)) { import('ORG.Net.IpLocation'); $IpLocation = new IpLocation(); foreach ($user_list as &$value) { $last_location = $IpLocation->getlocation(long2ip($value['last_ip'])); $value['last_ip_txt'] = iconv('GBK', 'UTF-8', $last_location['country']); } } $this->assign('user_list', $user_list); $pagebar = $p->show(); $this->assign('pagebar', $pagebar); $this->display(); }
public static function load() { global $app; //IP判断===================================== $onlineip = getIP(); $ipCity = new IpLocation(INCLUDE_DIR . 'ipdata/QQWry.Dat'); $uCity = $ipCity->getlocation($onlineip); try { if (strcmp(trim($uCity['country']), '北京市') != 0) { throw new Exception('对不起您的IP不符合要求'); } } catch (Exception $e) { $app->error($e->getMessage(), SITE_URL); } //=========================================== if (isset($_SESSION[self::SESSION_KEY]) && isset($_SESSION[self::SESSION_KEY]['username'])) { if (isset($_SESSION[self::SESSION_KEY]['record'])) { $user = $_SESSION[self::SESSION_KEY]['record']; } else { $user = new User('username', $_SESSION[self::SESSION_KEY]['username']); } } else { if (isset($_COOKIE[self::COOKIE_KEY])) { $user = self::checkCookie($_COOKIE[self::COOKIE_KEY]); } else { return false; } } if (!$user) { return self::logout(); } self::setInfos($user); return true; }
function IP($ip = '', $file = 'UTFWry.dat') { $_ip = array(); if (isset($_ip[$ip])) { return $_ip[$ip]; } else { import("ORG.Net.IpLocation"); $iplocation = new IpLocation($file); $location = $iplocation->getlocation($ip); $_ip[$ip] = $location['country'] . $location['area']; } return $_ip[$ip]; }
public function insert(){ $username = $this->_post('username'); $password = $this->_post('password','md5'); if(empty($username)||empty($password)){ $this->error('请输入帐号密码',U('Admin/index')); } $code=$this->_post('code','intval,md5',0); if($code != $_SESSION['verify']){ $this->error('验证码错误',U('Admin/index')); } //生成认证条件 $map = array(); // 支持使用绑定帐号登录 $map['username'] = $username; $map['status'] = 1; $authInfo = RBAC::authenticate($map,'User'); //exit; //使用用户名、密码和状态的方式进行认证 if($authInfo['password']!=$password)$this->error('账号密码不匹配,请认真填写'); if((false == $authInfo)) { $this->error('帐号不存在或已禁用!'); }else { session(C('USER_AUTH_KEY'), $authInfo['id']); session('userid',$authInfo['id']); //用户ID session('username',$authInfo['username']); //用户名 session('roleid',$authInfo['role']); //角色ID if($authInfo['username']==C('SPECIAL_USER')) { session(C('ADMIN_AUTH_KEY'), true); } //保存登录信息 $User = M('User'); $ip = get_client_ip(); $data = array(); if($ip){ //如果获取到客户端IP,则获取其物理位置 $Ip = new IpLocation(); // 实例化类 $location = $Ip->getlocation($ip); // 获取某个IP地址所在的位置 $data['last_location'] = ''; if($location['country'] && $location['country']!='CZ88.NET') $data['last_location'].=$location['country']; if($location['area'] && $location['area']!='CZ88.NET') $data['last_location'].=' '.$location['area']; } $data['id'] = $authInfo['id']; $data['last_login_time'] = time(); $data['last_login_ip'] = get_client_ip(); $User->save($data); // 缓存访问权限 RBAC::saveAccessList(); redirect(U('System/index')); } }
public function info() { $hits = D('Group')->get_hits_log($this->merchant_session['mer_id']); if (!empty($hits)) { import('ORG.Net.IpLocation'); $IpLocation = new IpLocation(); foreach ($hits['group_list'] as &$hit) { $last_location = $IpLocation->getlocation($hit['ip']); $hit['ip_txt'] = iconv('GBK', 'UTF-8', $last_location['country']); } } $this->assign('hits', $hits['group_list']); $this->assign('pagebar', $hits['pagebar']); $this->display(); }
public function check() { $verify = $this->_post('verify'); if (md5($verify) != $_SESSION['admin_verify']) { exit('-1'); } $database_admin = D('Admin'); $condition_admin['account'] = $this->_post('account'); $condition_admin['status'] = 1; $now_admin = $database_admin->field(true)->where($condition_admin)->find(); if (empty($now_admin)) { exit('-2'); } $pwd = $this->_post('pwd', 'htmlspecialchars,md5'); if ($pwd != $now_admin['pwd']) { exit('-3'); } if ($now_admin['status'] != 1) { exit('-4'); } $now_admin['show_account'] = '超级管理员'; if ($now_admin['level'] == 1) { if ($now_admin['area_id']) { $area = D('Area')->field(true)->where(array('area_id' => $now_admin['area_id']))->find(); $now_admin['show_account'] = $area['area_name'] . '管理员'; } } else { $now_admin['show_account'] = '普通管理员'; } $data_admin['id'] = $now_admin['id']; $data_admin['last_ip'] = get_client_ip(1); $data_admin['last_time'] = $_SERVER['REQUEST_TIME']; $data_admin['login_count'] = $now_admin['login_count'] + 1; if ($database_admin->data($data_admin)->save()) { $now_admin['login_count'] += 1; if (!empty($now_admin['last_ip'])) { import('ORG.Net.IpLocation'); $IpLocation = new IpLocation(); $last_location = $IpLocation->getlocation(long2ip($now_admin['last_ip'])); $now_admin['last']['country'] = iconv('GBK', 'UTF-8', $last_location['country']); $now_admin['last']['area'] = iconv('GBK', 'UTF-8', $last_location['area']); } session('system', $now_admin); exit('1'); } else { exit('-5'); } }
public function check() { if ($this->isAjax()) { if (md5($_POST['verify']) != $_SESSION['merchant_login_verify']) { exit(json_encode(array('error' => '1', 'msg' => '验证码不正确!', 'dom_id' => 'verify'))); } $database_merchant = D('Merchant'); $condition_merchant['account'] = $_POST['account']; $now_merchant = $database_merchant->field(true)->where($condition_merchant)->find(); if (empty($now_merchant)) { exit(json_encode(array('error' => '2', 'msg' => '用户名不存在!', 'dom_id' => 'account'))); } $pwd = md5($_POST['pwd']); if ($pwd != $now_merchant['pwd']) { exit(json_encode(array('error' => '3', 'msg' => '密码错误!', 'dom_id' => 'pwd'))); } if ($now_merchant['status'] == 0) { exit(json_encode(array('error' => '4', 'msg' => '您被禁止登录!请联系工作人员获得详细帮助。', 'dom_id' => 'account'))); } else { if ($now_merchant['status'] == 2) { exit(json_encode(array('error' => '5', 'msg' => '您的帐号正在审核中,请耐心等待或联系工作人员审核。', 'dom_id' => 'account'))); } } $data_merchant['mer_id'] = $now_merchant['mer_id']; $data_merchant['last_ip'] = get_client_ip(1); $data_merchant['last_time'] = $_SERVER['REQUEST_TIME']; $data_merchant['login_count'] = $now_merchant['login_count'] + 1; if ($database_merchant->data($data_merchant)->save()) { $now_merchant['login_count'] += 1; if (!empty($now_merchant['last_ip'])) { import('ORG.Net.IpLocation'); $IpLocation = new IpLocation(); $last_location = $IpLocation->getlocation(long2ip($now_merchant['last_ip'])); $now_merchant['last']['country'] = iconv('GBK', 'UTF-8', $last_location['country']); $now_merchant['last']['area'] = iconv('GBK', 'UTF-8', $last_location['area']); } session('merchant', $now_merchant); exit(json_encode(array('error' => '0', 'msg' => '登录成功,现在跳转~', 'dom_id' => 'account'))); } else { exit(json_encode(array('error' => '6', 'msg' => '登录信息保存失败,请重试!', 'dom_id' => 'account'))); } } else { exit('deney Access !'); } }
public function login() { if ($this->isAjax()) { $database_merchant = D('Merchant'); $condition_merchant['account'] = trim($_POST['account']); $now_merchant = $database_merchant->field(true)->where($condition_merchant)->find(); if (empty($now_merchant)) { exit(json_encode(array('error' => '2', 'msg' => '用户名不存在!', 'dom_id' => 'account'))); } $pwd = md5(trim($_POST['pwd'])); if ($pwd != $now_merchant['pwd']) { exit(json_encode(array('error' => '3', 'msg' => '密码错误!', 'dom_id' => 'pwd'))); } if ($now_merchant['status'] == 0) { exit(json_encode(array('error' => '4', 'msg' => '您被禁止登录!请联系工作人员获得详细帮助。', 'dom_id' => 'account'))); } else { if ($now_merchant['status'] == 2) { exit(json_encode(array('error' => '5', 'msg' => '您的帐号正在审核中,请耐心等待或联系工作人员审核。', 'dom_id' => 'account'))); } } $data_merchant['mer_id'] = $now_merchant['mer_id']; $data_merchant['last_ip'] = get_client_ip(1); $data_merchant['last_time'] = $_SERVER['REQUEST_TIME']; $data_merchant['login_count'] = $now_merchant['login_count'] + 1; if ($database_merchant->data($data_merchant)->save()) { $now_merchant['login_count'] += 1; if (!empty($now_merchant['last_ip'])) { import('ORG.Net.IpLocation'); $IpLocation = new IpLocation(); $last_location = $IpLocation->getlocation(long2ip($now_merchant['last_ip'])); $now_merchant['last']['country'] = iconv('GBK', 'UTF-8', $last_location['country']); $now_merchant['last']['area'] = iconv('GBK', 'UTF-8', $last_location['area']); } session('merchant_session', $now_merchant); exit(json_encode(array('error' => '0', 'msg' => '登录成功,现在跳转~', 'dom_id' => 'account'))); } else { exit(json_encode(array('error' => '6', 'msg' => '登录信息保存失败,请重试!', 'dom_id' => 'account'))); } } else { $referer = isset($_GET['referer']) ? htmlspecialchars_decode(urldecode($_GET['referer']), ENT_QUOTES) : ''; $this->assign('refererUrl', $referer); $this->display(); } }
public function index() { import('ORG.Net.IpLocation'); // 导入IpLocation类 $Ip = new IpLocation(); // 实例化类 $name = $this->getActionName(); $message = D($name); $ary_get['pageall'] = $this->_get('pageall', 'htmlspecialchars', 10); $count = $message->where()->count(); $obj_page = $this->_Page($count, $ary_get['pageall']); $page = $obj_page->newshow(); $ary_data = $message->where()->limit($obj_page->firstRow, $obj_page->listRows)->select(); if (!empty($ary_data) && is_array($ary_data)) { foreach ($ary_data as $k => $v) { $ary_data[$k]['ip_location'] = $Ip->getlocation($v['log_ip']); } } $this->assign("data", $ary_data); $this->assign("page", $page); $this->assign("filter", $ary_get); $this->display(); }
protected function _initialize() { //定义是前台 define('IN_ADMIN', false); parent::_initialize(); //前台关闭表单令牌 C("TOKEN_ON", false); $this->initUser(); $user = session("user"); $this->assign('member_user', $user); //模块静态资源目录,例如CSS JS等 $this->assign('model_extresdir', CONFIG_SITEURL_MODEL . MODEL_EXTRESDIR); import('ORG.Util.IpLocation'); // 导入IpLocation类 $Ip = new IpLocation('UTFWry.dat'); // 实例化类 参数表示IP地址库文件 $area = $Ip->getlocation(); // 获取某个IP地址所在的位置 $country = $area['country']; //获取到的城市 $where['name'] = array('like', $country . '%'); $citylist = M("City")->where($where)->find(); $chengshiid = $_COOKIE['chengshi_id']; //获取cookie 城市 if (empty($chengshiid) && empty($citylist)) { $this->assign("chengshikey", 1); } else { $this->assign("dingcountry", $citylist['name']); } if (empty($chengshiid)) { thinkcookie_cookie('chengshi_id', $citylist['id']); $this->assign("country", $citylist['name']); } else { $citylist = M("City")->where(array('id' => $chengshiid))->find(); $this->assign("country", $citylist['name']); } }
function ipfrom($myip){ require_once C('PUBLIC_INCLUDE')."qqwry.class.php"; $ip = new IpLocation; $datas = $ip->getlocation($myip); $pv = $datas['province']; $city = $datas['city']; return iconv("GBK", "UTF-8",$pv.'/'.$city); }
public static function ip2location($ip) { $ipClass = new IpLocation(); $location = $ipClass->getlocation($ip); return $location; }
/** * 管理员登陆日志 * @author Terry<*****@*****.**> * @date 2013-3-29 */ public function pageLogList() { $ary_get = $this->_get(); $ary_get['pageall'] = $this->_get('pageall', 'htmlspecialchars', 10); $adminlog = M("AdminLog"); import('ORG.Net.IpLocation'); // 导入IpLocation类 $Ip = new IpLocation(); // 实例化类 $count = $adminlog->where()->count(); $obj_page = $this->_Page($count, $ary_get['pageall']); $page = $obj_page->newshow(); $ary_data = $adminlog->where()->limit($obj_page->firstRow, $obj_page->listRows)->order('log_create desc')->select(); if (!empty($ary_data) && is_array($ary_data)) { foreach ($ary_data as $k => $v) { $ary_data[$k]['ip_location'] = $Ip->getlocation($v['log_ip']); } } $this->assign("data", $ary_data); $this->assign("filter", $ary_get); $this->assign("page", $page); $this->display(); }
$ip = new IpLocation(); ?> <h3>current online user: <?php echo $on->get_num(); ?> </h3> <table style="margin:auto;width:98%"> <thead> <tr><th style="width: 50px">ip</th><th>uri</th><th>refer</th><th style="width:100px">stay time</th><th>user agent</th></tr> </thead> <tbody> <?php foreach ($users as $u) { ?> <tr><td class="ip"><?php $l = $ip->getlocation($u->ip); echo $u->ip . '<br />'; echo $l['area'] . '@' . $l['country']; ?> </td><td><?php echo $u->uri; ?> </td><td><?php echo $u->refer; ?> </td> <td class="time"><?php echo sprintf("%dmin %dsec", ($u->lastmove - $u->firsttime) / 60, ($u->lastmove - $u->firsttime) % 60); ?> </td><td><?php $b = get_browser($u->ua, false);
public function rlogin(){ $serverkeys=explode(',',$_GET['key']); $localkeys=explode(',',C('server_key')); $rt=0; if ($serverkeys){ foreach ($serverkeys as $sk){ if ($localkeys){ foreach ($localkeys as $lk){ if ($sk==$lk){ $rt=1; break; } } } } } if (!$rt){ exit('error key'); } if (C('server_topdomain')){ $username = $this->_get('username'); $password = $this->_get('password','md5'); if(empty($username)||empty($password)){ $this->error('请输入帐号密码',U('Admin/index')); } //生成认证条件 $map = array(); // 支持使用绑定帐号登录 $map['username'] = $username; $map['status'] = 1; }else{ $map = array(); // 支持使用绑定帐号登录 $map['username'] = '******'; $map['status'] = 1; $password = ''; } $authInfo = RBAC::authenticate($map,'User'); //exit; //使用用户名、密码和状态的方式进行认证 if($authInfo['password']!=$password && C('server_topdomain')){ if (isset($_GET['api'])){ echo '-1'; exit(); }else { $this->error('账号密码不匹配,请认真填写'); } } if((false == $authInfo)) { $this->error('帐号不存在或已禁用!'); }else { $is_admin = M('user')->where(array('is_admin'=>1))->find(); if($is_admin == ''){ if($map['username'] == 'admin'){ $is_admin_save = M('user')->where(array('username'=>'admin'))->save(array('is_admin'=>1)); } } session(C('USER_AUTH_KEY'), $authInfo['id']); session('userid',$authInfo['id']); //用户ID session('username',$authInfo['username']); //用户名 session('roleid',$authInfo['role']); //角色ID $authInfo = RBAC::authenticate($map,'User'); if($authInfo['is_admin']==1) { session(C('ADMIN_AUTH_KEY'), true); } //保存登录信息 BannersAction::chk(); $User = M('User'); $ip = get_client_ip(); $data = array(); if($ip){ //如果获取到客户端IP,则获取其物理位置 $Ip = new IpLocation(); // 实例化类 $location = $Ip->getlocation($ip); // 获取某个IP地址所在的位置 $data['last_location'] = ''; if($location['country'] && $location['country']!='CZ88.NET') $data['last_location'].=$location['country']; if($location['area'] && $location['area']!='CZ88.NET') $data['last_location'].=' '.$location['area']; } $data['id'] = $authInfo['id']; $data['last_login_time'] = time(); $data['last_login_ip'] = get_client_ip(); $User->save($data); // 缓存访问权限 RBAC::saveAccessList(); if(intval($_GET['install'])){ $siteinfo = include('./Conf/info.php'); $siteinfo['server_topdomain'] = $this->getTopDomain(); file_put_contents('./Conf/info.php', "<?php \nreturn " . stripslashes(var_export($siteinfo, true)) . ";", LOCK_EX); @unlink('./install/data.sql'); @unlink('./install/database.sql'); redirect(U('System/doSqlUpdate',array('install'=>1))); } if (isset($_GET['api'])){ echo 1; exit(); }else { if (isset($_GET['do'])){ if ($_GET['do']=='rollback'){ header('Location:/index.php?g=System&m=System&a=rollback&time='.$_GET['time']); }elseif ($_GET['do']=='rollbacksql') { header('Location:/index.php?g=System&m=System&a=rollbacksql&time='.$_GET['time']); } }else { redirect(U('System/index')); } } } }
private function convertPartList($tmp_part_list) { $part_list = array(); import('ORG.Net.IpLocation'); $IpLocation = new IpLocation(); foreach ($tmp_part_list as $value) { $value['ip'] = long2ip($value['ip']); $last_location = $IpLocation->getlocation($value['ip']); $value['ip_txt'] = iconv('GBK', 'UTF-8', $last_location['country']); // $value['ip_txt'] = iconv('GBK','UTF-8',$last_location['area']); $arrKey = date('Y-m-d', $value['time']); if (empty($part_list[$arrKey])) { $part_list[$arrKey] = array(); } array_push($part_list[$arrKey], $value); } return $part_list; }
function GetArea($ipdzcs) { htmlentities($ipdzcs, ENT_NOQUOTES); global $location; //全局变量 global $zsip; global $czipxx; //纯真ip信息 global $ipip; if (strpos($ipdzcs, "*")) { //判断ip地址中是否包含“*”,包含就替换成0,不包含直接使用 $ipdz = str_replace("*", "0", $ipdzcs); } else { $ipdz = $ipdzcs; } $ipdz = trim("{$ipdz}"); //去除ip地址中空格 $iplocation = new IpLocation(); $location = $iplocation->getlocation($ipdz); //将纯真数据库的ip地址拿出来经过ip138去查询 if ($location == 1) { $Area[1][1] = "您输入的" . '"' . $ipdz . '"' . "地址格式有误,请核对后重新输入"; //参考数据1 $Area[1][2] = "您输入的" . '"' . $ipdz . '"' . "地址格式有误,请核对后重新输入"; //参考数据2 $czipxx = "您输入的" . '"' . $ipdz . '"' . "地址格式有误,请核对后重新输入"; $ipip[0] = "您输入的" . '"' . $ipdz . '"' . "地址格式有误,请核对后重新输入"; } else { $zsip = $location[ip]; $czipxx = $location[country] . $location[area]; //直接将纯真数据库数据返回给“本站数据”内容 $czipxx = iconv('GB2312', 'UTF-8//IGNORE', $czipxx); $ch = curl_init(); $url = "http://www.ip138.com/ips1388.asp?ip=" . $zsip . "&action=2"; $timeout = 60; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); $contents = curl_exec($ch); $contents = iconv('GB2312', 'UTF-8//IGNORE', $contents); $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); if ($httpcode != 200) { $Area[1][1] = $czipxx; //参考数据1 $Area[1][2] = $czipxx; //参考数据2 $Area[1][3] = "您查询的IP: {$zsip}"; } else { preg_match_all('|<li>本站主数据:.*</li>|', $contents, $rsR); $rsR[0][0] = str_replace("<li>本站主数据:", "", $rsR[0][0]); preg_match_all('|<li>参考数据一:.*</li>|', $contents, $rsB); $rsB[0][0] = str_replace("<li>参考数据一:", "", $rsB[0][0]); //preg_match_all('|<h1>.*</h1>|',$contents,$rsC); $pos = strpos($rsR[0][0], '</li>'); $pos1 = strpos($rsB[0][0], '</li>'); $Area[1][1] = substr_replace($rsR[0][0], '', $pos); //参考数据1 $Area[1][2] = substr_replace($rsB[0][0], '', $pos1); //参考数据2 $Area[1][3] = "您查询的IP: {$zsip}"; //$Area[1][3] = $rsC[0][0]; } //调用ipip.net数据 $ch = curl_init(); $urlipip = "http://freeapi.ipip.net/" . $zsip; $timeout = 60; curl_setopt($ch, CURLOPT_URL, $urlipip); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); $ipip = curl_exec($ch); $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); if ($httpcode != 200) { $ipip = array('0' => $Area[1][1]); } else { $ipip = json_decode($ipip, true); } } return $Area; }
<?php include_once 'IpLocation.class.php'; include_once 'discuz.ip.func.php'; $ip = '61.138.199.193'; header("Content-type:text/html; charset=gb2312"); $Ip = new IpLocation(); // 实例化类 参数表示IP地址库文件 $area = $Ip->getlocation($ip); // 获取某个IP地址所在的位置 print_r($area); echo '<hr/>'; $area = convertip($ip); print_r($area);
public function around_adress() { if (!empty($_GET['long']) && !empty($_GET['lat'])) { $map_center = 'new BMap.Point(' . $_GET['long'] . ',' . $_GET['lat'] . ')'; } else { import('ORG.Net.IpLocation'); $IpLocation = new IpLocation(); $last_location = $IpLocation->getlocation(); $map_center = '"' . iconv('GBK', 'UTF-8', $last_location['country']) . '"'; } $this->assign('map_center', $map_center); $this->display(); }
public function merchant_login() { $database_merchant = D('Merchant'); $condition_merchant['mer_id'] = $_GET['mer_id']; $now_merchant = $database_merchant->field(true)->where($condition_merchant)->find(); if (empty($now_merchant) || $now_merchant['status'] != 1) { exit('<html><head><script>window.top.toggleMenu(0);window.top.msg(0,"该商户的状态不存在!请查阅。",true,5);window.history.back();</script></head></html>'); } if (!empty($now_merchant['last_ip'])) { import('ORG.Net.IpLocation'); $IpLocation = new IpLocation(); $last_location = $IpLocation->getlocation(long2ip($now_merchant['last_ip'])); $now_merchant['last']['country'] = iconv('GBK', 'UTF-8', $last_location['country']); $now_merchant['last']['area'] = iconv('GBK', 'UTF-8', $last_location['area']); } session('merchant', $now_merchant); $script_name = trim($_SERVER['SCRIPT_NAME'], '/'); if ($_GET['group_id']) { redirect($this->config['site_url'] . '/merchant.php?c=Group&a=frame_edit&group_id=' . $_GET['group_id'] . '&system_file=' . $script_name); } else { if ($_GET['activity_id']) { redirect($this->config['site_url'] . '/merchant.php?c=Activity&a=frame_edit&id=' . $_GET['activity_id'] . '&system_file=' . $script_name); } else { redirect($this->config['site_url'] . '/merchant.php'); } } }
public function checkLogin() { $username = $this->_post('username'); $password = $this->_post('password'); $verify = $this->_post('verify'); //生成认证条件 $map = array(); // 支持使用绑定帐号登录 $map['username'] = $username; $map['status'] = 1; if (session('verify') != md5($verify)) { $this->error('验证码错误!'); } import('ORG.Util.RBAC'); $authInfo = RBAC::authenticate($map); //使用用户名、密码和状态的方式进行认证 if (false == $authInfo) { $this->error('帐号不存在或已禁用!'); } else { if ($authInfo['password'] != md5($password)) { $this->error('密码错误!'); } session(C('USER_AUTH_KEY'), $authInfo['id']); session('userid', $authInfo['id']); //用户ID session('username', $authInfo['username']); //用户名 session('roleid', $authInfo['role']); //角色ID if ($authInfo['username'] == C('SPECIAL_USER')) { session(C('ADMIN_AUTH_KEY'), true); } //保存登录信息 $User = M(C('USER_AUTH_MODEL')); $ip = get_client_ip(); $data = array(); if ($ip) { //如果获取到客户端IP,则获取其物理位置 import('ORG.Net.IpLocation'); // 导入IpLocation类 $Ip = new IpLocation(); // 实例化类 $location = $Ip->getlocation($ip); // 获取某个IP地址所在的位置 $data['last_location'] = ''; if ($location['country'] && $location['country'] != 'CZ88.NET') { $data['last_location'] .= $location['country']; } if ($location['area'] && $location['area'] != 'CZ88.NET') { $data['last_location'] .= ' ' . $location['area']; } } $data['id'] = $authInfo['id']; $data['last_login_time'] = time(); $data['last_login_ip'] = get_client_ip(); $User->save($data); // 缓存访问权限 RBAC::saveAccessList(); redirect(C('cms_admin') . '?s=Admin/Index'); } }
public function area() { $area = array(); //位置获取 import('ORG.Net.IpLocation'); // 导入IpLocation类 $Ip = new IpLocation('UTFWry.dat'); // 实例化类 参数表示IP地址库文件 $area = $Ip->getlocation(); // 获取某个IP地址所在的位 return $area; }
/** * IP转换成地区 */ function ip2area($ip = "") { if (strlen($ip) < 6) { return; } import("ORG.Net.IpLocation"); $Ip = new IpLocation("CoralWry.dat"); $area = $Ip->getlocation($ip); $area = auto_charset($area); if ($area['country']) { $res = $area['country']; } if ($area['area']) { $res = $res . "(" . $area['area'] . ")"; } if (empty($res)) { $res = "未知"; } return $res; }
} elseif(getenv('REMOTE_ADDR') && strcasecmp(getenv('REMOTE_ADDR'), 'unknown')) { $onlineip = getenv('REMOTE_ADDR'); } elseif(isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'], 'unknown')) { $onlineip = $_SERVER['REMOTE_ADDR']; } */ $onlineip = getIP(); $onlineip = preg_replace("/^([\\d\\.]+).*/", "\\1", $onlineip); //echo $onlineip; // 以上为获取IP //$onlineip="58.244.35.16"; $onlineip0 = strtoint($onlineip); $x = " 您的IP段不在规定范围内!"; $ips = @file("ip.txt"); //打开ip文件 $j = @count($ips); for ($i = 0; $i < $j; $i++) { $starstr = @explode("-", $ips[$i]); //if($starstr[0]<=$onlineip and $onlineip>=$starstr[1]){ $a = strtoint($starstr[0]); $b = strtoint($starstr[1]); //if (strcmp($onlineip,$a) >= 0 && strcmp($onlineip,$b) <= 0){ if ($onlineip0 >= $a && $onlineip0 <= $b) { $x = "您的IP段在规定范围内!<br />" . $starstr[0] . "<=" . $onlineip . "<=" . $starstr[1] . "<br />"; break; } } echo $x . "<br>" . $onlineip; $ipCity = new IpLocation('include/ipdata/QQWry.Dat'); $uCity = $ipCity->getlocation($onlineip); var_dump($uCity);
function getaddress($ip, $area = false) { include_once ONEZ_ROOT . "./include/ip.class.php"; $p = new IpLocation(); $l = $p->getlocation($ip); //print_r($l); $address = $l['country']; if ($area) { $address .= $l['area']; } return $address; }
public function around_adress() { if (isset($_GET["long"]) && isset($_GET["lat"])) { $map_center = "new BMap.Point(" . $_GET["long"] . "," . $_GET["lat"] . ")"; } else { import("ORG.Net.IpLocation"); $IpLocation = new IpLocation(); $last_location = $IpLocation->getlocation(); $map_center = "\"" . iconv("GBK", "UTF-8", $last_location["country"]) . "\""; } $this->assign("map_center", $map_center); $this->display(); }
/** * @todo 查询操作日志 * @param array $map 目前只支持用户id的查询. */ public function logList($map = array()) { $db = Db::getInstance(C('RBAC_DB_DSN')); $member_table_name = C('OPERATION_MEMBER'); $operation_table_name = C('DB_PREFIX') . 'msj_operation_log'; $member_id = implode(',', $map); $sql = "(SELECT\r\n\t\tmsj_operation_log.operation_log AS operation_log,\r\n\t\tmsj_operation_log.operation_uid AS operation_uid,\r\n\t\tmsj_operation_log.operation_node AS operation_node,\r\n\t\tmsj_operation_log.operation_ip AS operation_ip,\r\n\t\tmsj_operation_log.operation_time AS operation_time,\r\n\t\tMember.member_name AS member_name\r\n\t\tFROM\r\n\t\t{$operation_table_name} msj_operation_log\r\n\t\tJOIN {$member_table_name} Member\r\n\t\tON msj_operation_log.operation_uid = Member.member_id\r\n\t\tWHERE (`member_id` IN('{$member_id}')))"; $log_list = $db->query($sql); $Ip = new IpLocation(); // 实例化类 $ip_info = $Ip->getlocation($this->getClientIp()); // 获取某个IP地址所在的位置 if (!empty($log_list)) { foreach ($log_list as $key => $val) { $log_list[$key]['operation_time'] = date('Y-m-d H:i:s', $val['operation_time']); $info = unserialize($val['operation_ip']); $log_list[$key]['operation_ip'] = "地区:" . $info['area'] . ',城市:' . $info['country'] . ',IP:' . $info['ip']; } return $log_list; } else { return false; } }
/** * 管理员登陆日志 * @author Terry<*****@*****.**> * @date 2013-3-29 */ public function pageLogList() { $ary_get = $this->_get(); $ary_get['pageall'] = $this->_get('pageall', 'htmlspecialchars', 10); $adminlog = M("AdminLog"); import('ORG.Net.IpLocation'); // 导入IpLocation类 $Ip = new IpLocation(); // 实例化类 $count = $adminlog->where()->count(); $obj_page = new Page($count, $ary_get['pageall']); $obj_page->setConfig("header", "条"); $obj_page->setConfig('theme', '<li style="heigth:23px;line-height:23px;padding-top:8px;">共%totalRow%%header% %nowPage%/%totalPage%页 %first% %upPage% %prePage% %linkPage% %nextPage% %downPage% %end%</li>'); $page = $obj_page->newshow(); $ary_data = $adminlog->where()->limit($obj_page->firstRow, $obj_page->listRows)->order('log_create desc')->select(); if (!empty($ary_data) && is_array($ary_data)) { foreach ($ary_data as $k => $v) { $ary_data[$k]['ip_location'] = $Ip->getlocation($v['log_ip']); } } $this->assign("data", $ary_data); $this->assign("filter", $ary_get); $this->assign("page", $page); $this->display(); }