本文整理汇总了PHP中getClientIp函数的典型用法代码示例。如果您正苦于以下问题:PHP getClientIp函数的具体用法?PHP getClientIp怎么用?PHP getClientIp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getClientIp函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dologin
public function dologin()
{
$this->form_validation->set_rules('username', 'Username', 'required');
$this->form_validation->set_rules('password', 'Password', 'required');
if ($this->form_validation->run() == FALSE) {
errorRedirct('backend/user/login', '用户名和密码不能为空');
die;
} else {
$username = $this->input->post('username');
$password = $this->input->post('password');
$this->load->model('backend/adminUser');
$adminUserInfo = $this->adminUser->getAdminUserByName($username);
if (empty($adminUserInfo)) {
errorRedirct('backend/user/login', '登录失败,账号不存在');
die;
}
if (!$adminUserInfo['status']) {
errorRedirct('backend/user/login', '登录失败,账号已失效');
die;
}
if ($adminUserInfo['password'] != md5($password)) {
errorRedirct('backend/user/login', '登录失败,密码错误');
die;
}
// 更新用户登录时间
$fields = array('last_ip' => getClientIp(), 'last_time' => time());
$this->adminUser->updateUserInfo($adminUserInfo['user_id'], $fields);
$data = array('userId' => $adminUserInfo['user_id'], 'userName' => $adminUserInfo['user_name'], 'realName' => $adminUserInfo['real_name']);
$this->session->set_userdata($data);
successRedirct($this->config->item('rbac_default_index'), "登录成功!");
}
}
示例2: checkGeo
/**
* check client province in ad's geo target
* input array province number
* return boolean
*/
public function checkGeo($listCountries, $listProvinces)
{
if (empty($listCountries)) {
return true;
}
$retval = false;
$ip = getClientIp();
//live
//test tren local
if (isLocal()) {
$ip = '115.78.162.134';
// test
}
$geoip = GeoBaseModel::getGeoByIp($ip);
if ($geoip) {
if (empty($listProvinces)) {
$retval = in_array($geoip->country_code, $listCountries);
} else {
$province = "{$geoip->country_code}:{$geoip->region}";
$retval = in_array($province, $listProvinces);
}
}
// pr($geoip);
// pr($retval);
return $retval;
}
示例3: getCurUserHostAddress
function getCurUserHostAddress($userAddress = NULL)
{
if (is_null($userAddress)) {
$userAddress = getClientIp();
}
return preg_replace("[^0-9a-zA-Z.=]", '_', $userAddress);
}
示例4: getOpenID
/**
* 授权
*/
public function getOpenID()
{
$weObj = new \System\lib\Wechat\Wechat($this->config("WEIXIN_CONFIG"));
$this->weObj = $weObj;
if (empty($_GET['code']) && empty($_GET['state'])) {
$callback = getHostUrl();
$reurl = $weObj->getOauthRedirect($callback, "1");
redirect($reurl, 0, '正在发送验证中...');
exit;
} elseif (intval($_GET['state']) == 1) {
$accessToken = $weObj->getOauthAccessToken();
// 是否有用户记录
$isUser = $this->table('user')->where(["openid" => $accessToken['openid'], 'is_on' => 1])->get(null, true);
/*var_dump($isUser);exit();*/
if ($isUser == null) {
//没有此用户跳转至输入注册的页面
header("LOCATION:" . getHost() . "/register.html");
} else {
$userID = $isUser['id'];
$updateUser = $this->table('user')->where(['id' => $userID])->update(['last_login' => time(), 'last_ip' => ip2long(getClientIp())]);
$_SESSION['userInfo'] = ['openid' => $isUser['openid'], 'userid' => $isUser['id'], 'nickname' => $isUser['nickname'], 'user_img' => $isUser['user_img']];
//var_dump($_SESSION['userInfo']['openid']);exit();
header("LOCATION:http://onebuy.ping-qu.com");
//进入网站成功
//用户取消授权
//
//$this->R('','90006');
}
}
}
示例5: checkGeo
public function checkGeo()
{
$targetGeo = json_decode($this->target_geo);
if ($targetGeo) {
$clientCountry = strtolower(geoip_country_code_by_name(getClientIp()));
if (in_array($clientCountry, $targetGeo)) {
return true;
}
}
return false;
}
示例6: __construct
/**
* 错误列表显示
*
* @param string $message
* @param code $code
*/
public function __construct($message = 0, $code = null)
{
if (_CLI_) {
$file = $this->getFile();
$line = $this->getLine();
$now = date('Y-m-d H:i:s');
$out = <<<EOF
==================================================================================
-- Uncaught exception!
--时间:{$now}
--信息:{$message}
--代码:{$code}
--文件:{$file}
--行数:{$line}
==================================================================================
EOF;
echo $out;
} elseif (_DEV_) {
$this->_viewer = Leb_View::getInstance();
$this->_viewer->setLayoutPath('_template/layout/');
$this->_viewer->setLayout('exception');
$this->_viewer->setTemplate($this->_exceptionFile);
$this->_viewer->title = '出错了!';
$time = date('Y-m-d H:i:s', time());
$this->_viewer->time = $time;
$this->_viewer->message = $message;
$this->_viewer->code = $code;
$this->_viewer->file = $this->getFile();
$this->_viewer->line = $this->getLine();
$this->_viewer->run();
Leb_Debuger::showVar();
} elseif (defined('_ER_PAGE_')) {
$this->_viewer = Leb_View::getInstance();
$this->_viewer->setLayoutPath('_template/layout/');
$this->_viewer->setLayout('exception');
$this->_viewer->setTemplate(_ER_PAGE_);
$this->_viewer->title = '出错了!';
$time = date('Y-m-d H:i:s', time());
$this->_viewer->time = $time;
$this->_viewer->message = $message;
$this->_viewer->code = $code;
$this->_viewer->file = $this->getFile();
$this->_viewer->line = $this->getLine();
$this->_viewer->run();
Leb_Debuger::showVar();
}
if (_RUNTIME_) {
$now = time();
$file = _RUNTIME_ . date('-Y-m-d', $now);
$line = date('H:i:s') . "\t" . getClientIp() . "\r\n";
}
}
示例7: passDataToApplication
function passDataToApplication($url)
{
$_SERVER['REQUEST_URI'] = modifyUrl($url);
$_GET['loggedAt'] = getLoggedAt();
$_GET['cip'] = getClientIp();
$_GET['ua'] = $_SERVER['HTTP_USER_AGENT'];
require_once __DIR__ . '/../app/bootstrap.php.cache';
require_once __DIR__ . '/../app/AppKernel.php';
$kernel = new AppKernel('prod', false);
$kernel->loadClassCache();
$request = \Symfony\Component\HttpFoundation\Request::createFromGlobals();
$kernel->handle($request);
}
示例8: isValid
public function isValid($ip = null)
{
empty($ip) && ($ip = getClientIp(1));
if (!is_numeric($ip)) {
$ip = ip2long($ip);
}
if (in_array($ip, $this->_ipWhiteListLong)) {
return true;
}
foreach ($this->_ipWhiteListLongRange as $range) {
if ($ip >= $range[0] && $ip <= $range[1]) {
return true;
}
}
return false;
}
示例9: addAction
function addAction($primkey, $urid, $page, $systemtype = USCIC_SMS, $actiontype = 1)
{
global $db;
$query = 'INSERT INTO ' . Config::dbSurveyData() . '_actions (primkey, sessionid, urid, suid, ipaddress, systemtype, action, actiontype, params, language, mode, version) VALUES (';
if ($primkey != '') {
$query .= '\'' . prepareDatabaseString($primkey) . '\', ';
} else {
$query .= 'NULL, ';
}
$query .= '\'' . session_id() . '\', ';
if ($urid != '') {
$query .= '\'' . $urid . '\', ';
} else {
$query .= 'NULL, ';
}
if ($systemtype == USCIC_SURVEY) {
$query .= getSurvey() . ', ';
} else {
$query .= 'NULL, ';
}
$query .= '\'' . prepareDatabaseString(getClientIp()) . '\', ';
$query .= $systemtype . ', ';
$query .= '\'' . prepareDatabaseString($page) . '\', ';
$query .= $actiontype . ', ';
if (Config::logParams()) {
//log post vars?
$query .= ' AES_ENCRYPT(\'' . prepareDatabaseString(serialize($_POST)) . '\', \'' . Config::logActionParamsKey() . '\'), ';
} else {
$query .= ' NULL, ';
}
if ($systemtype == USCIC_SURVEY) {
$query .= getSurveyLanguage() . ', ';
$query .= getSurveyMode() . ', ';
$query .= getSurveyVersion();
} else {
$query .= 'NULL, NULL, NULL';
}
$query .= ")";
$db->executeQuery($query);
if (isset($this->LogActions[$primkey])) {
//unset so it is read in again..
unset($this->LogActions[$primkey]);
}
}
示例10: loginAction
/**
* 登录动作
*/
private function loginAction($manager, $loginStatus, $isAutoLogin)
{
$_SESSION['manager_id'] = $manager['id'];
$_SESSION['manager_name'] = $manager['manager_name'];
$_SESSION['role_base_id'] = $manager['role_base_id'];
$_SESSION['autoLogin'] = $loginStatus;
if ($isAutoLogin == 1) {
$expire = 60 * 60 * 24 * 7;
$timeout = time() + $expire;
$token = md5(uniqid(rand(), TRUE));
$autoLogin = ['manager_id' => $manager['manager_id'], 'identifier' => $manager['identifier'], 'timeout' => $timeout];
//$this->S()->set($token,$autoLogin,60*60*24*7);
setcookie('OneTrade-AUTOLOGIN', $token, $timeout, '/');
}
//更新用户信息
$data = ['last_ip' => getClientIp(), 'manager_endlogin' => time()];
$this->table('manager')->where(['id' => $manager['id']])->update($data);
$this->R();
}
示例11: checkGeo
/**
* check client province in ad's geo target
* input array province number
* return boolean
*/
public function checkGeo($listCountries, $listProvinces)
{
if (empty($listCountries) || isLocal()) {
return true;
}
$retval = false;
$ip = getClientIp();
//live
$geoip = GeoBaseModel::getGeoByIp($ip);
pr($geoip);
if ($geoip) {
if (empty($listProvinces)) {
$retval = in_array($geoip->country_code, $listCountries);
} else {
$province = "{$geoip->country_code}:{$geoip->region}";
$retval = in_array($province, $listProvinces);
}
}
return $retval;
}
示例12: save
/**
* Saves data
* @return bool
* @uses get()
* @uses $file
*/
public function save()
{
//Gets existing data
$data = $this->get();
$agent = filter_input(INPUT_SERVER, 'HTTP_USER_AGENT');
$ip = getClientIp();
//Clears the first log (last in order of time), if it has been saved
// less than an hour ago and the user agent and the IP address are
// the same
if (!empty($data[0]) && (new Time($data[0]->time))->modify('+1 hour')->isFuture() && $data[0]->agent === $agent && $data[0]->ip === $ip) {
unset($data[0]);
}
//Adds log for current request
array_unshift($data, (object) am(['ip' => getClientIp(), 'time' => new Time()], parse_user_agent(), compact('agent')));
//Keeps only the first records
$data = array_slice($data, 0, config('users.login_log'));
//Serializes
$data = serialize($data);
return $this->file->write($data);
}
示例13: CSCorpModel
<?php
require '../../../lib.php';
$openId = TestUser::user()->id();
$companyId = TestUser::user()->companyId();
$model = new CSCorpModel();
$api = OpenHelper::api();
$result = $api->getDeptList($companyId, $model->getToken($companyId), getClientIp());
OpenUtils::outputJson($result);
示例14: CSCorpModel
<?php
require '../../../lib.php';
$openId = TestUser::user()->id();
$companyId = TestUser::user()->companyId();
$model = new CSCorpModel();
$api = OpenHelper::api();
$userlist = $api->getUserList($companyId, $model->getToken($companyId), getClientIp());
OpenUtils::outputJson($userlist);
示例15: get_the_title
<div class="wpcf7" id="wpcf7-f137-p135-o1" dir="ltr" lang="en-US">
<div class="screen-reader-response"></div>
<form name="" action="/commercial/town-center-acacia-estates/#wpcf7-f137-p135-o1" method="post" class="wpcf7-form" novalidate="novalidate">
<div style="display: none;">
<input name="_wpcf7" value="137" type="hidden">
<input name="_wpcf7_version" value="4.1.1" type="hidden">
<input name="_wpcf7_locale" value="en_US" type="hidden">
<input name="_wpcf7_unit_tag" value="wpcf7-f137-p135-o1" type="hidden">
<input name="_wpnonce" value="715fc56071" type="hidden">
<input name="property" value="<?php
echo get_the_title();
?>
" type="hidden">
<input name="propertyType" value="commercial" type="hidden">
<input type="hidden" name="clientIp" id="clientIp" value="<?php
echo getClientIp();
?>
" />
</div>
<div class="col-md-6">
<div class="form-group ">
<span class="wpcf7-form-control-wrap fname">
<input name="fname" value="" size="40" class="wpcf7-form-control wpcf7-text wpcf7-validates-as-required form-control" id="fname" aria-required="true" aria-invalid="false" placeholder="First Name" type="text">
</span>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<span class="wpcf7-form-control-wrap lname">