本文整理汇总了PHP中real_ip函数的典型用法代码示例。如果您正苦于以下问题:PHP real_ip函数的具体用法?PHP real_ip怎么用?PHP real_ip使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了real_ip函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sendsms
function sendsms($mobile, $content)
{
$log = date('Y-m-d H:i:s', time()) . " | " . real_ip() . " | " . $mobile . " | " . $content . "\r\n";
file_put_contents(dirname(dirname(__FILE__)) . "/sms_log_" . $GLOBALS['_CFG']['ihuyi_sms_user_name'] . ".log", $log, FILE_APPEND);
//配置信息
$target = "http://106.ihuyi.cn/webservice/sms.php?method=Submit";
//替换成自己的测试账号,参数顺序和wenservice对应
$post_data = "account=" . $GLOBALS['_CFG']['ihuyi_sms_user_name'] . "&password=" . md5($GLOBALS['_CFG']['ihuyi_sms_pass_word']) . "&md5=1&mobile=" . $mobile . "&content=" . urlencode($content);
$gets = '<?xml version="1.0" encoding="utf-8"?>
<SubmitResult xmlns="http://106.ihuyi.cn/">
<code>2</code>
<msg>提交成功</msg>
<smsid>67472311</smsid>
</SubmitResult>';
if ($GLOBALS['_CFG']['ihuyi_sms_debug'] == 0) {
$gets = ihuyi_Post($post_data, $target);
}
$gets_arr = xml_to_array($gets);
file_put_contents(dirname(dirname(__FILE__)) . "/sms_log_" . $GLOBALS['_CFG']['ihuyi_sms_user_name'] . ".log", '发送状态:' . $gets_arr['SubmitResult']['msg'] . "\r\n", FILE_APPEND);
if ($gets_arr['SubmitResult']['code'] == 2) {
return true;
} else {
return $gets_arr['SubmitResult']['msg'];
}
}
示例2: info
public static function info($msg, $ecode, $etype, $uid, $schoolid, $requrl, array $param)
{
global $G_X;
if ($requrl == '') {
$requrl = $_SERVER['REQUEST_URI'];
}
if (!$param || count($param) < 1) {
$param = $_REQUEST;
}
$Update = array();
$Update['eventtime'] = time();
$Update['eventtype'] = $etype;
$Update['schoolid'] = $schoolid;
$Update['eventdesc'] = $msg;
$Update['message'] = print_r($param, true);
$Update['userid'] = $uid;
$Update['requesturl'] = $requrl;
$Update['code'] = $ecode;
$Update['detailcode'] = $G_X['events'][$etype][$ecode];
$ip = real_ip();
if ($ip == 'unknown') {
$ip = "192.168.0.1";
}
$Update['ip'] = ip2long($ip);
require_once PUBLIB_PATH . 'database/DbFactory.php';
$db = DbFactory::Create();
$id = $db->Insert(self::$tbname, $Update, true);
}
示例3: contact_us
public function contact_us($data)
{
$this->db->set('date_on', 'NOW()', FALSE);
$this->db->set('ip_address', real_ip());
$this->db->insert('contact', $data);
return $this->db->insert_id();
}
示例4: admin_log
/**
* 记录管理员的操作内容
*
* @access public
* @param string $sn 数据的唯一值
* @param string $action 操作的类型
* @param string $content 操作的内容
* @param string $log_info 直接插入操作的内容
* @return void
*/
function admin_log($sn = '', $action, $content, $log_info = '')
{
if (!$log_info) {
$log_info = $GLOBALS['_LANG']['log_action'][$action] . $GLOBALS['_LANG']['log_action'][$content] . ': ' . addslashes($sn);
}
$sql = 'INSERT INTO ' . $GLOBALS['ecs']->table('admin_log') . ' (log_time, user_id, log_info, ip_address) ' . " VALUES ('" . gmtime() . "', {$_SESSION['admin_id']}, '" . stripslashes($log_info) . "', '" . real_ip() . "')";
$GLOBALS['db']->query($sql);
}
示例5: check_sms_verifycode
/**
* 检查手机验证码
*
* @access public
* @param string $mobile 手机号
* @param string $verifycode 手机验证码
* @param string $act 绑定类型
*
* @return bool $bool
*/
function check_sms_verifycode($mobile, $verifycode, $act = SMS_REGISTER)
{
global $db, $ecs, $_CFG;
$ip = real_ip();
$expire = gmtime() - intval($_CFG['ecsdxt_sms_validtime']);
//验证码10分钟内有效
$SQL = "SELECT COUNT(id) FROM " . $ecs->table('verifycode') . " WHERE mobile='{$mobile}' AND verifycode='{$verifycode}' AND getip='{$ip}' AND status=1 AND `type`={$act} AND dateline>={$expire}";
return $db->getOne($SQL) > 0;
}
示例6: phoxy_conf
function phoxy_conf()
{
$ret = phoxy_default_conf();
global $_SERVER;
$ret["ip"] = real_ip();
$ret['adminip'] = false;
$ret['api_xss_prevent'] = PRODUCTION;
if (!$ret['adminip']) {
ini_set('display_errors', 'Off');
}
return $ret;
}
示例7: cls_session
function cls_session(&$db, $session_table, $session_data_table, $session_name = 'ECS_ID', $session_id = '')
{
$GLOBALS['_SESSION'] = array();
if (!empty($GLOBALS['cookie_path'])) {
$this->session_cookie_path = $GLOBALS['cookie_path'];
} else {
$this->session_cookie_path = '/';
}
if (!empty($GLOBALS['cookie_domain'])) {
$this->session_cookie_domain = $GLOBALS['cookie_domain'];
} else {
$this->session_cookie_domain = '';
}
if (!empty($GLOBALS['cookie_secure'])) {
$this->session_cookie_secure = $GLOBALS['cookie_secure'];
} else {
$this->session_cookie_secure = false;
}
$this->session_name = $session_name;
$this->session_table = $session_table;
$this->session_data_table = $session_data_table;
$this->db =& $db;
//$this->_ip = real_ip();以下代码解决登陆问题
if (isset($_COOKIE['real_ipd']) && !empty($_COOKIE['real_ipd'])) {
$this->_ip = $_COOKIE['real_ipd'];
} else {
$this->_ip = real_ip();
setcookie("real_ipd", $this->_ip, time() + 36000, $this->session_cookie_path);
}
if ($session_id == '' && !empty($_COOKIE[$this->session_name])) {
$this->session_id = $_COOKIE[$this->session_name];
} else {
$this->session_id = $session_id;
}
if ($this->session_id) {
$tmp_session_id = substr($this->session_id, 0, 32);
if ($this->gen_session_key($tmp_session_id) == substr($this->session_id, 32)) {
$this->session_id = $tmp_session_id;
} else {
$this->session_id = '';
}
}
$this->_time = time();
if ($this->session_id) {
$this->load_session();
} else {
$this->gen_session_id();
setcookie($this->session_name, $this->session_id . $this->gen_session_key($this->session_id), 0, $this->session_cookie_path, $this->session_cookie_domain, $this->session_cookie_secure);
}
register_shutdown_function(array(&$this, 'close_session'));
}
示例8: update_user_info
/**
* 更新用户SESSION,COOKIE及登录时间、登录次数。
*
* @access public
* @return void
*/
function update_user_info()
{
if (!$_SESSION['user_id']) {
return false;
}
/* 查询会员信息 */
$time = date('Y-m-d');
$sql = 'SELECT u.user_money,u.email, u.pay_points, u.user_rank, u.rank_points, ' . ' IFNULL(b.type_money, 0) AS user_bonus, u.last_login, u.last_ip' . ' FROM ' . $this->pre . 'users AS u ' . ' LEFT JOIN ' . $this->pre . 'user_bonus AS ub' . ' ON ub.user_id = u.user_id AND ub.used_time = 0 ' . ' LEFT JOIN ' . $this->pre . 'bonus_type AS b' . " ON b.type_id = ub.bonus_type_id AND b.use_start_date <= '{$time}' AND b.use_end_date >= '{$time}' " . " WHERE u.user_id = '{$_SESSION['user_id']}'";
if ($row = $this->row($sql)) {
/* 更新SESSION */
$_SESSION['last_time'] = $row['last_login'];
$_SESSION['last_ip'] = $row['last_ip'];
$_SESSION['login_fail'] = 0;
$_SESSION['email'] = $row['email'];
/* 判断是否是特殊等级,可能后台把特殊会员组更改普通会员组 */
if ($row['user_rank'] > 0) {
$sql = "SELECT special_rank from " . $this->pre . "user_rank where rank_id='{$row['user_rank']}'";
$res = $this->row($sql);
if ($res['special_rank'] === '0' || $res['special_rank'] === null) {
$sql = "update " . $this->pre . "users set user_rank='0' where user_id='{$_SESSION['user_id']}'";
$this->query($sql);
$row['user_rank'] = 0;
}
}
/* 取得用户等级和折扣 */
if ($row['user_rank'] == 0) {
// 非特殊等级,根据等级积分计算用户等级(注意:不包括特殊等级)
$sql = 'SELECT rank_id, discount FROM ' . $this->pre . "user_rank WHERE special_rank = '0' AND min_points <= " . intval($row['rank_points']) . ' AND max_points > ' . intval($row['rank_points']);
if ($row = $this->row($sql)) {
$_SESSION['user_rank'] = $row['rank_id'];
$_SESSION['discount'] = $row['discount'] / 100.0;
} else {
$_SESSION['user_rank'] = 0;
$_SESSION['discount'] = 1;
}
} else {
// 特殊等级
$sql = 'SELECT rank_id, discount FROM ' . $this->pre . "user_rank WHERE rank_id = '{$row['user_rank']}'";
if ($row = $this->row($sql)) {
$_SESSION['user_rank'] = $row['rank_id'];
$_SESSION['discount'] = $row['discount'] / 100.0;
} else {
$_SESSION['user_rank'] = 0;
$_SESSION['discount'] = 1;
}
}
}
/* 更新登录时间,登录次数及登录ip */
$sql = "UPDATE " . $this->pre . "users SET" . " visit_count = visit_count + 1, " . " last_ip = '" . real_ip() . "'," . " last_login = '" . gmtime() . "'" . " WHERE user_id = '" . $_SESSION['user_id'] . "'";
$this->query($sql);
}
示例9: addtj
function addtj()
{
global $ecs;
$domain = $ecs->get_domain();
$ip = real_ip();
//getIP();
$client = new soapclient68('http://api.68ecshop.com/record.php?wsdl', true);
$client->soap_defencoding = 'UTF-8';
$client->decode_utf8 = false;
$client->xml_encoding = 'UTF-8';
//参数转为数组形式传递
$paras = array('domain' => $domain, 'ip' => $ip);
//目标方法没有参数时,可省略后面的参数
$result = $client->call('addTongji', $paras);
}
示例10: _do_login
/**
* 执行登陆操作
* 这个函数要跟 frontend.base.php 中的 _do_login 保持一致
*/
function _do_login($user_id)
{
$mod_user =& m('member');
$user_info = $mod_user->get(array('conditions' => "user_id = '{$user_id}'", 'join' => 'has_store', 'fields' => 'user_id, user_name, reg_time, last_login, last_ip, store_id'));
/* 店铺ID */
$my_store = empty($user_info['store_id']) ? 0 : $user_info['store_id'];
/* 保证基础数据整洁 */
unset($user_info['store_id']);
/* 分派身份 */
$this->visitor->assign($user_info);
/* 更新用户登录信息 */
$mod_user->edit("user_id = '{$user_id}'", "last_login = '" . gmtime() . "', last_ip = '" . real_ip() . "', logins = logins + 1");
/* 更新购物车中的数据 */
$mod_cart =& m('cart');
$mod_cart->edit("(user_id = '{$user_id}' OR session_id = '" . SESS_ID . "') AND store_id <> '{$my_store}'", array('user_id' => $user_id, 'session_id' => SESS_ID));
}
示例11: _do_login
/**
* 执行登陆操作
*
* @param int $user_id
* @return bool
*/
function _do_login($user_id)
{
$mod_user =& m('member');
$user_info = $mod_user->get(array('conditions' => $user_id, 'join' => 'manage_mall', 'fields' => 'this.user_id, user_name, reg_time, last_login, last_ip, privs'));
if (!$user_info['privs']) {
$this->show_warning('not_admin');
return false;
}
/* 分派身份 */
$this->visitor->assign(array('user_id' => $user_info['user_id'], 'user_name' => $user_info['user_name'], 'reg_time' => $user_info['reg_time'], 'last_login' => $user_info['last_login'], 'last_ip' => $user_info['last_ip']));
/* 更新登录信息 */
$time = gmtime();
$ip = real_ip();
$mod_user->edit($user_id, "last_login = '{$time}', last_ip='{$ip}', logins = logins + 1");
return true;
}
示例12: cls_session
function cls_session(&$db, $session_table, $session_data_table, $session_name = 'ECS_ID', $session_id = '')
{
$GLOBALS['_SESSION'] = array();
if (!empty($GLOBALS['cookie_path'])) {
$this->session_cookie_path = $GLOBALS['cookie_path'];
} else {
$this->session_cookie_path = '/';
}
if (!empty($GLOBALS['cookie_domain'])) {
$this->session_cookie_domain = $GLOBALS['cookie_domain'];
} else {
$this->session_cookie_domain = '';
}
if (!empty($GLOBALS['cookie_secure'])) {
$this->session_cookie_secure = $GLOBALS['cookie_secure'];
} else {
$this->session_cookie_secure = false;
}
$this->session_name = $session_name;
$this->session_table = $session_table;
$this->session_data_table = $session_data_table;
$this->db =& $db;
$this->_ip = real_ip();
if ($session_id == '' && !empty($_COOKIE[$this->session_name])) {
$this->session_id = $_COOKIE[$this->session_name];
} else {
$this->session_id = $session_id;
}
if ($this->session_id) {
$tmp_session_id = substr($this->session_id, 0, 32);
if ($this->gen_session_key($tmp_session_id) == substr($this->session_id, 32)) {
$this->session_id = $tmp_session_id;
} else {
$this->session_id = '';
}
}
$this->_time = time();
if ($this->session_id) {
$this->load_session();
} else {
$this->gen_session_id();
setcookie($this->session_name, $this->session_id . $this->gen_session_key($this->session_id), time() + 86400 * 7, $this->session_cookie_path, $this->session_cookie_domain, $this->session_cookie_secure);
//代码修改 By www.68ecshop.com
}
register_shutdown_function(array(&$this, 'close_session'));
}
示例13: SessionProcessor
/**
* 构造函数
*
* @author weberliu
* @param object $db 数据库对象
* @param stirng $session_table 数据表名
* @param string $session_data_table 数据存储表名
* @param string $session_name session名称
* @param string $session_id session_id
* @return void
*/
function SessionProcessor(&$db, $session_table, $session_data_table, $session_name = 'ECM_ID', $session_id = '')
{
session_set_save_handler(array(&$this, "_sess_open"), array(&$this, "_sess_close"), array(&$this, "_sess_read"), array(&$this, "_sess_write"), array(&$this, "_sess_destroy"), array(&$this, "_sess_gc"));
$this->gmtime = gmtime();
$this->max_life_time = 1440;
$this->session_cookie_path = COOKIE_PATH;
$this->session_cookie_domain = COOKIE_DOMAIN;
//如果开启二级域名,且未设置COOKIE作用域,则缺省为上级域
if (defined('ENABLED_SUBDOMAIN') && ENABLED_SUBDOMAIN && !COOKIE_DOMAIN) {
$tmp_arr = parse_url(SITE_URL);
if (count(explode('.', $tmp_arr['host'])) > 2) {
$cookie_domain = substr($tmp_arr['host'], strpos($tmp_arr['host'], '.'));
} else {
// 形如ecmall.com这样的域名
$cookie_domain = '.' . $tmp_arr['host'];
}
$this->session_cookie_domain = $cookie_domain;
}
$this->session_cookie_secure = false;
$this->session_name = $session_name;
$this->session_table = $session_table;
$this->session_data_table = $session_data_table;
$this->db =& $db;
$this->_ip = real_ip();
/*处理session id*/
if ($session_id == '' && !empty($_COOKIE[$this->session_name])) {
$this->session_id = $_COOKIE[$this->session_name];
} else {
$this->session_id = $session_id;
}
if ($this->session_id) {
$tmp_session_id = substr($this->session_id, 0, 32);
if ($this->gen_session_key($tmp_session_id) == substr($this->session_id, 32)) {
$this->session_id = $tmp_session_id;
} else {
$this->session_id = '';
}
}
if (!$this->session_id) {
$this->gen_session_id();
session_id($this->session_id . $this->gen_session_key($this->session_id));
/*setcookie($this->session_name, $this->session_id . $this->gen_session_key($this->session_id), 0,
$this->session_cookie_path, $this->session_cookie_domain, $this->session_cookie_secure);*/
}
}
示例14: WriteLog
/**
* 写入日志,统计所需要
* @author Neil
*/
function WriteLog($return = '')
{
global $G_X;
session_start();
$int = real_ip() . "[|cut|]";
$int .= date('Y-m-d H:i:s', $_SERVER['REQUEST_TIME']) . "[|cut|]";
$int .= $G_X['appkey'] . "[|cut|]";
$int .= (session_id() ?: '-') . "[|cut|]";
$int .= $_SERVER['REQUEST_METHOD'] . "[|cut|]";
$int .= "record.php[|cut|]";
$int .= ($_SERVER['HTTP_REFERER'] ?: '-') . "[|cut|]";
$int .= ($_SERVER['QUERY_STRING'] ?: '-') . "[|cut|]";
$int .= $_SERVER['HTTP_USER_AGENT'] . "[|cut|]";
$int .= '-';
$int .= PHP_EOL;
$log = ERRLOG_PATH . 'm_wonaonao_record_' . date('H') . '.log';
error_log($int, 3, $log);
}
示例15: visit_stats
/**
* 统计访问信息
*
* @access public
* @return void
*/
function visit_stats()
{
if (C('visit_stats') == 'off') {
return;
}
$time = gmtime();
/* 检查客户端是否存在访问统计的cookie */
$visit_times = !empty($_COOKIE['ECS']['visit_times']) ? intval($_COOKIE['ECS']['visit_times']) + 1 : 1;
setcookie('ECS[visit_times]', $visit_times, $time + 86400 * 365, '/');
$browser = get_user_browser();
$os = get_os();
$ip = real_ip();
$area = ecs_geoip($ip);
/* 语言 */
if (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
$pos = strpos($_SERVER['HTTP_ACCEPT_LANGUAGE'], ';');
$lang = addslashes($pos !== false ? substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, $pos) : $_SERVER['HTTP_ACCEPT_LANGUAGE']);
} else {
$lang = '';
}
/* 来源 */
if (!empty($_SERVER['HTTP_REFERER']) && strlen($_SERVER['HTTP_REFERER']) > 9) {
$pos = strpos($_SERVER['HTTP_REFERER'], '/', 9);
if ($pos !== false) {
$domain = substr($_SERVER['HTTP_REFERER'], 0, $pos);
$path = substr($_SERVER['HTTP_REFERER'], $pos);
/* 来源关键字 */
if (!empty($domain) && !empty($path)) {
save_searchengine_keyword($domain, $path);
}
} else {
$domain = $path = '';
}
} else {
$domain = $path = '';
}
$sql = 'INSERT INTO ' . $this->pre . 'stats ( ' . 'ip_address, visit_times, browser, system, language, area, ' . 'referer_domain, referer_path, access_url, access_time' . ') VALUES (' . "'{$ip}', '{$visit_times}', '{$browser}', '{$os}', '{$lang}', '{$area}', " . "'" . addslashes($domain) . "', '" . addslashes($path) . "', '" . addslashes(PHP_SELF) . "', '" . $time . "')";
$this->query($sql);
}