public function index() { echo "<meta content='text/html'; charset=utf-8 />"; $db = new IpModel(); $data['ip'] = $this->getIp(); if ($db->add($data)) { echo "( ^_^ )你好,额是机器人程序,额需要获取你的手机IP来判断你使用的手机还是电脑!,非常感谢你为我提供了一条IP地址:" . $data['ip'] . "<p>下次你访问t-y.me的时候我会将你引导至手机版页面,不信你<a href='http://t-y.me'>点这里试试看</a>"; //dump($db->select()); } else { echo "( ^_^ ) 呵呵,额是机器人程序,我已经记住你了!下次你访问t-y.me的时候我会将你引导至手机版页面,不信你<a href='http://t-y.me'>点这里试试看</a>"; //dump($db->select()); } }
public function delete() { $id = request('id'); if (IpModel::delete($id)) { $this->success($this->reffer()); } else { $this->error(); } }
public static function calcIp($ip) { $ipList = IpModel::getList(); $ipArray = explode('.', $ip); $ret = array(); foreach ($ipList as $item) { if ($item['s_01'] > $ipArray[0] || $item['s_02'] > $ipArray[1] || $item['s_03'] > $ipArray[2] || $item['s_04'] > $ipArray[3] || $item['e_01'] < $ipArray[0] || $item['e_02'] < $ipArray[1] || $item['e_03'] < $ipArray[2] || $item['s_04'] > $ipArray[3]) { continue; } $ret = $item; } return $ret; }
protected function checkWap() { if ($_SESSION['is_wap'] === false) { return false; exit; } $db = new IpModel(); $ip = explode('.', $this->getIp()); $map['ip'] = array('like', $ip['0'] . '.' . $ip['1'] . '.' . $ip['2'] . '%'); $rs = $db->where($map)->count(); //电脑访问 if ($rs == 0) { $_SESSION['is_wap'] = false; } else { //手机访问 $_SESSION['is_wap'] = true; header("Location:wap.php"); exit; echo "<meta content='text/html'; charset=utf-8 />"; echo '正在跳转...或者' . "<a href='" . __APP__ . "/wap.php'>点击进入</a>"; } }