public static function showCity() { $ip = Ip::getClientIp(); $url = "http://ip.taobao.com/service/getIpInfo2.php?ip={$ip}"; $data = Http::get($url); $data = json_decode($data, true); return $data; }
public function __construct($state, $action) { session_start(); parent::__construct($state, $action); $this->ip = Ip::getClientIp(); if ($action == 'set' || $action == 'set_tmp_log') { Switcher::close('postRefererCheck'); Switcher::close('masterDbPostOnly'); } }
public function __construct($state, $action) { session_start(); $_SESSION['group'] = 1; parent::__construct($state, $action); $this->ip = Ip::getClientIp(); $sysAdmin = true; $this->setView('sysAdmin', $sysAdmin); $this->username = '******'; }
public function testGetIpReturnsIp() { $ip = '127.0.0.1'; $_SERVER['HTTP_CLIENT_IP'] = $ip; $this->assertEquals($ip, Ip::getClientIp()); unset($_SERVER['HTTP_CLIENT_IP']); $_SERVER['HTTP_X_FORWARDED_FOR'] = $ip; $this->assertEquals($ip, Ip::getClientIp()); unset($_SERVER['HTTP_X_FORWARDED_FOR']); $_SERVER['REMOTE_ADDR'] = $ip; $this->assertEquals($ip, Ip::getClientIp()); }
public static function show() { $ip = Ip::getClientIp(); $url = "http://ip.taobao.com/service/getIpInfo2.php?ip={$ip}"; $data = Http::get($url); $data = json_decode($data, true); $city = false; if (isset($data['code']) && $data['code'] == 0) { $city = $data['data']['city']; } return $city; }
public function __construct($state, $action) { SESSION_START(); parent::__construct($state, $action); $this->ip = Ip::getClientIp(); /* //控制外网IP访问管理功能 if (substr($this->ip, 0, 3) != '10.') { header("HTTP/1.0 404 Not Found"); exit; } */ }
public function __construct($state, $action) { SESSION_START(); parent::__construct($state, $action); $this->ip = Ip::getClientIp(); if (in_array($action, array('debug'))) { Switcher::close('postRefererCheck'); } //控制外网IP访问管理功能 if (substr($this->ip, 0, 3) != '10.') { header("HTTP/1.0 404 Not Found"); exit; } }
/** * 上传后处理 */ public function index() { if (!IS_POST && !Q("session.uid")) { $this->error("页面不存在!"); } if (Q("session.usergroup") != 1) { $this->error("您没有上传权限,请联系管理员!"); } if (!C("UPLOAD_ON")) { $this->error("管理员已禁用上传功能,请联系管理员!"); } $uploadIp = explode(",", C("UPLOAD_IP")); $userip = Ip::getClientIp(); foreach ($uploadIp as $value) { if ($userip == $value) { $this->error("管理员不允许这台电脑上传!"); break; } } $vName = Q("post.vname"); $cateone = Q("post.cate-one"); $catetwo = Q("post.cate-two") ? Q("post.cate-two") : ""; $cate = $catetwo ? $catetwo : $cateone; $cachetime = Q("post.cachetime", null, "intval"); $uuid = Q("post.uuid") ? Q("post.uuid") : Q("session.uuid"); $xml = Q("post.xml"); $xml = $this->upload_video($xml); $uploadKeywords = explode(",", C("UPLOAD_KEYWORDS")); foreach ($uploadKeywords as $value) { if (strpos($vName, $value) > -1 || strpos($xml, $value) > -1) { $this->error("上传内容有非法关键字!"); break; } } $uploadUrl = explode(",", C("UPLOAD_URL")); foreach ($uploadUrl as $value) { if (strpos($xml, $value) > -1) { $this->error("上传内容有非法视频地址!"); break; } } if (!$vName || !$cateone || !$xml || !$uuid) { $this->error("上传内容或名称不得为空!"); } $fix = C("LIST_FIX"); $category = M("category"); $video = M("video"); $cid = $category->field("cid,cntitle")->where(array("entitle" => $cate))->find(); $db = array("content" => $xml, "cnname" => $vName, "uploadtime" => time(), "cachetime" => $cachetime, "uid" => Q("session.uid"), "cid" => $cid["cid"]); $replace = 0; if ($vid = $video->field("vid")->where(array("cnname" => $vName))->find()) { $vid = $vid["vid"]; $replace = array("vid" => $vid, "content" => $xml, "cachetime" => $cachetime, "cid" => $cid["cid"]); } else { if ($video->create()) { $video->add($db); $vid = $video->getInsertId(); M("user")->inc("count", "uid=" . Q("session.uid"), 1); } else { $this->error("添加失败!"); } } $unionStyle = $this->union_style($vName, $cid["cntitle"], 0); $prefix = $this->upload_prefix(); $assign = array("vname" => $vName, "vid" => $vid, "dingji" => $unionStyle[0], "erji" => $unionStyle[1], "uuid" => $uuid, "prefix" => $prefix); $this->assign("replace", $replace); $this->assign("assign", $assign); $this->display(); }
public function getIp($v) { return Ip::getClientIp(); }
/** * get user ip */ public function getUserIp() { return Ip::getClientIp(); }
public function __construct($state, $action) { parent::__construct($state, $action); $this->ip = Ip::getClientIp(); }