当前位置: 首页>>代码示例>>PHP>>正文


PHP getIp函数代码示例

本文整理汇总了PHP中getIp函数的典型用法代码示例。如果您正苦于以下问题:PHP getIp函数的具体用法?PHP getIp怎么用?PHP getIp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了getIp函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: calc_auth_key

 private function calc_auth_key($u, $ip = false)
 {
     if (!$ip) {
         $ip = getIp();
     }
     return substr(md5($u['username'] . $u['password'] . $ip), 10);
 }
开发者ID:jjvein,项目名称:my_php_framework,代码行数:7,代码来源:twtapiuserwrapper.class.php

示例2: addMember

 /**
  * 注册商城会员
  *
  * @param	array $param 会员信息
  * @return	array 数组格式的返回结果
  */
 public function addMember($param)
 {
     if (empty($param)) {
         return false;
     }
     $member_info = array();
     $member_info['member_id'] = $param['member_id'];
     $member_info['member_name'] = trim($param['member_name']);
     $member_info['member_passwd'] = md5(trim($param['member_passwd']));
     $member_info['member_email'] = trim($param['member_email']);
     $member_info['member_mobile'] = trim($param['member_mobile']);
     $member_info['member_time'] = time();
     $member_info['member_login_time'] = $member_info['member_time'];
     $member_info['member_old_login_time'] = $member_info['member_time'];
     $member_info['member_login_ip'] = getIp();
     $member_info['member_old_login_ip'] = $member_info['member_login_ip'];
     $member_info['member_truename'] = $param['member_truename'];
     $member_info['member_qq'] = $param['member_qq'];
     $member_info['member_sex'] = $param['member_sex'];
     $member_info['member_avatar'] = $param['member_avatar'];
     $member_info['member_qqopenid'] = $param['member_qqopenid'];
     $member_info['member_qqinfo'] = $param['member_qqinfo'];
     $member_info['member_sinaopenid'] = $param['member_sinaopenid'];
     $member_info['member_sinainfo'] = $param['member_sinainfo'];
     $result = Db::insert('member', $member_info);
     if ($result) {
         return Db::getLastId();
     } else {
         return false;
     }
 }
开发者ID:my1977,项目名称:shopnc,代码行数:37,代码来源:member.model.php

示例3: addMsg

 /**
  * add chat msg
  *
  * @param
  * @return array
  */
 public function addMsg($msg)
 {
     $msg['f_ip'] = getIp();
     $msg['r_state'] = '1';
     //state:1--read ,2--unread
     $msg['add_time'] = time();
     $m_id = $this->table('chat_msg')->insert($msg);
     if ($m_id > 0) {
         $msg['m_id'] = $m_id;
         unset($msg['r_state']);
         $this->table('chat_log')->insert($msg);
         $msg['m_id'] = $m_id;
         $msg['add_time'] = date('Y-m-d H:i:s', $msg['add_time']);
         $t_msg = $msg['t_msg'];
         $goods_id = 0;
         $goods_info = array();
         $pattern = '#' . SHOP_SITE_URL . '/index.php\\?act=goods&op=index&goods_id=(\\d+)$#';
         preg_match($pattern, $t_msg, $matches);
         if (intval($matches[1]) < 1) {
             //伪静态
             $pattern = '#' . SHOP_SITE_URL . '/item-(\\d+)\\.html$#';
             preg_match($pattern, $t_msg, $matches);
         }
         $goods_id = intval($matches[1]);
         if ($goods_id >= 1) {
             $goods_info = $this->getGoodsInfo($goods_id);
             $goods_id = intval($goods_info['goods_id']);
         }
         $msg['goods_id'] = $goods_id;
         $msg['goods_info'] = $goods_info;
         return $msg;
     } else {
         return 0;
     }
 }
开发者ID:noikiy,项目名称:shopnc-minion,代码行数:41,代码来源:web_chat.model.php

示例4: hasPool

function hasPool()
{
    require 'classes/db_connection.php';
    require 'config/dbconfig.php';
    require 'functions/fun-net.inc.php';
    // Get Remote user IP
    $remoteIP = getIp();
    $conn = new db_connection($hostname, $username, $password, $database);
    $result = $conn->select("user_control", array("username"), "address='{$remoteIP}'");
    //
    if ($conn->affected_rows() == 1) {
        $data = $conn->fetch_array($result);
        $login = $data['username'];
        $result = $conn->select("tec_users", array("nome"), "login='{$login}'");
        $data = $conn->fetch_array($result);
        $nome = $data['nome'];
        $_SESSION['IP'] = $remoteIP;
        $_SESSION['LOGIN'] = $login;
    } else {
        $nome = "404";
    }
    // Return array of values
    //$info[] = array();
    $info['IP'] = $remoteIP;
    $info['USER'] = $nome;
    $info['LOGIN'] = $login;
    print json_encode($info);
}
开发者ID:wborbajr,项目名称:TecnodataApp,代码行数:28,代码来源:index-act.php

示例5: createSession

 /**
  * 登录时创建会话SESSION
  *
  * @param array $member_info 会员信息
  */
 public function createSession($member_info = array())
 {
     if (empty($member_info) || !is_array($member_info)) {
         return;
     }
     $_SESSION['is_login'] = '1';
     $_SESSION['member_id'] = $member_info['member_id'];
     $_SESSION['member_name'] = $member_info['member_name'];
     $_SESSION['member_email'] = $member_info['member_email'];
     $_SESSION['is_buy'] = $member_info['is_buy'];
     $_SESSION['avatar'] = $member_info['member_avatar'];
     $seller_info = Model('seller')->getSellerInfo(array('member_id' => $_SESSION['member_id']));
     $_SESSION['store_id'] = $seller_info['store_id'];
     if (trim($member_info['member_qqopenid'])) {
         $_SESSION['openid'] = $member_info['member_qqopenid'];
     }
     if (trim($member_info['member_sinaopenid'])) {
         $_SESSION['slast_key']['uid'] = $member_info['member_sinaopenid'];
     }
     if (!empty($member_info['member_login_time'])) {
         //登录时间更新
         $update_info = array('member_login_num' => $member_info['member_login_num'] + 1, 'member_login_time' => time(), 'member_old_login_time' => $member_info['member_login_time'], 'member_login_ip' => getIp(), 'member_old_login_ip' => $member_info['member_login_ip']);
         $this->updateMember($update_info, $member_info['member_id']);
     }
 }
开发者ID:bubargaininc,项目名称:oak_oak,代码行数:30,代码来源:goods_sheji.model.php

示例6: index

 public function index()
 {
     $this->load->helper('ip');
     $this->load->model('tongji_model');
     $referer = '';
     if (preg_match('/' . str_replace('.', '\\.', $_SERVER['HTTP_HOST']) . '/i', $_SERVER['HTTP_REFERER'])) {
         $referer = '直接访问';
     } elseif (preg_match('/baidu\\.com/i', $_SERVER['HTTP_REFERER'])) {
         $referer = '百度';
     } elseif (preg_match('/google\\.\\w+/i', $_SERVER['HTTP_REFERER'])) {
         $referer = '谷歌';
     } elseif (preg_match('/so\\.com/i', $_SERVER['HTTP_REFERER'])) {
         $referer = '360搜索';
     } elseif (preg_match('/sogou\\.com/i', $_SERVER['HTTP_REFERER'])) {
         $referer = '搜狗';
     } else {
         $referer = 'NULL';
     }
     $user_agent = $_GET['userAgent'];
     if (empty($user_agent)) {
         $user_agent = 'NULL';
     }
     $this->tongji_model->insert(array('ip' => ip2long(getIp()), 'date' => date('Y-m-d', time()), 'user_agent' => $user_agent, 'referer' => $referer));
     die(json_encode(array('code' => 200, 'message' => '成功')));
 }
开发者ID:jaya-project,项目名称:zycms,代码行数:25,代码来源:Tongji.php

示例7: doLogin

 function doLogin()
 {
     if (!verifyHash($_POST['hash'])) {
         $this->error('非验证的来源!');
     }
     if (empty($_POST['username'])) {
         $this->error('帐号不能为空!');
     }
     if (empty($_POST['password'])) {
         $this->error('密码不能为空!');
     }
     if (empty($_POST['verify'])) {
         $this->error('验证码不能为空!');
     }
     if ($_SESSION['verify'] != strtolower($_POST['verify'])) {
         $this->error('验证码错误!');
     }
     $info = m('User')->getRowByName($_POST['username']);
     if (empty($info)) {
         $this->error('账号不存在');
     }
     if ($info['password'] != md5($_POST['password'])) {
         $this->error('密码错误!');
     }
     $_SESSION['user_id'] = $info['id'];
     $_SESSION['user_name'] = $info['username'];
     $_SESSION['shop_id'] = $info['shop_id'];
     $_SESSION['shop_name'] = $info['shop_name'];
     $_SESSION['role_id'] = $info['role_id'];
     $data = array();
     $data['login_time'] = time();
     $data['ip_address'] = getIp();
     m('User')->update($data, "id='{$info['id']}'");
     $this->success('登录成功!', url());
 }
开发者ID:frycnx,项目名称:jxc,代码行数:35,代码来源:Login.php

示例8: login

 public function login()
 {
     $verify = I('verify');
     if (check_verify($verify)) {
         $db = D('UserRelation');
         if ($userInfo = $db->getUserInfo()) {
             if ($userInfo['status'] == 1) {
                 $this->error('用户已被锁定,请联系管理员');
                 return false;
             }
             $rid = '';
             foreach ($userInfo['role'] as $k => $v) {
                 $rid .= $v['rid'] . ',';
             }
             $_SESSION['admin']['id'] = $userInfo['id'];
             $_SESSION['admin']['username'] = $userInfo['username'];
             $_SESSION['admin']['rid'] = trim($rid, ',');
             if (I('remember') == 'on') {
                 $ip = get_client_ip();
                 $setcookie = base64_encode($userInfo['id'] . '|' . $ip);
                 setcookie('adminuser', $setcookie, time() + 24 * 60 * 60, '/');
             }
             $data = array('loginIp' => getIp(), 'loginTime' => date('Y-m-d H:i:s'));
             M('user')->where(array('id' => $userInfo['id']))->save($data);
             $this->success('登陆成功', U('Index/index'));
         } else {
             $msg = $db->getError() ? $db->getError() : '用户名或密码不正确';
             $this->error($msg);
         }
     } else {
         $this->error('验证码不正确');
     }
 }
开发者ID:xupp,项目名称:ThinkPHP,代码行数:33,代码来源:LoginController.class.php

示例9: actionCreate

 /**
  *
  * @return mixed
  */
 public function actionCreate()
 {
     global $API_CODE;
     if (isset($_POST['user'])) {
         //Validation
         $new_data_error_msg = '';
         if (!strlen(trim($_POST['user'])) || !strlen(trim($_POST['content']))) {
             $new_data_error_msg = t('FILL_NOT_COMPLETE');
         } elseif (strlen($_POST['content'] > 580)) {
             $new_data_error_msg = t('WORDS_TOO_LONG');
         } elseif (ZFramework::app()->valid_code_open == 1 && gd_loaded() && !$this->_verifyCode->check($_POST['valid_code'])) {
             $new_data_error_msg = t('CAPTCHA_WRONG');
         }
         if ($new_data_error_msg) {
             if (defined('API_MODE')) {
                 $error_array = array('error_code' => '400', 'error' => $API_CODE['400'], 'error_detail' => $new_data_error_msg);
                 die(function_exists('json_encode') ? json_encode($error_array) : CJSON::encode($error_array));
             }
             if (!empty($_POST['ajax'])) {
                 die($new_data_error_msg);
             } else {
                 show_message($new_data_error_msg, true, 'index.php');
             }
         }
         // Ready to send query to database
         $user = $this->_model->escape_string($_POST['user']);
         if (!isset($_SESSION['admin']) && $_POST['user'] == ZFramework::app()->admin) {
             $user = 'anonymous';
         }
         $userExists = $this->_model->queryAll(sprintf(parse_tbprefix("SELECT * FROM <sysuser> WHERE username='%s'"), $this->_model->escape_string($_POST['user'])));
         if ($userExists && @$_SESSION['user'] != $_POST['user']) {
             $user = 'anonymous';
         }
         $content = $this->_model->escape_string($_POST['content']);
         if (isset($_SESSION['uid'])) {
             $sql_insert = sprintf(parse_tbprefix("INSERT INTO <post> ( uid , content , post_time , ip ) VALUES ( %d , '%s' , %d , '%s' )"), $_SESSION['uid'], $content, time(), getIp());
         } else {
             $sql_insert = sprintf(parse_tbprefix("INSERT INTO <post> ( uname , content , post_time , ip ) VALUES ( '%s' ,'%s' , %d , '%s')"), $user, $content, time(), getIp());
         }
         // Send query to database
         if (!$this->_model->query($sql_insert)) {
             die($this->_model->error());
         }
         performEvent('PostController/actionCreate', array($user, $content, time() + ZFramework::app()->timezone * 60 * 60));
         if (defined('API_MODE')) {
             $json_array = array('insert_id' => $this->_model->insert_id());
             die(function_exists('json_encode') ? json_encode($json_array) : CJSON::encode($json_array));
         }
         if (isset($_POST['ajax'])) {
             echo 'OK';
             return TRUE;
         }
     }
     if (defined('API_MODE')) {
         $error_array = array('error_code' => '400', 'error' => $API_CODE['400'], 'error_detail' => t('ONLY_POST'));
         die(function_exists('json_encode') ? json_encode($error_array) : CJSON::encode($error_array));
     }
     header("Location:index.php");
 }
开发者ID:yunsite,项目名称:yuan-pad,代码行数:63,代码来源:PostController.php

示例10: read

 function read($key)
 {
     $Query = mysql_query("select `sessionvalue` from `sessions` where `sessionkey`='" . $key . "' and `sessionexpiry`>'" . date("Y-m-d H:i:s") . "' and `sessionip`='" . getIp() . "'", $this->oDB);
     $aValue = mysql_fetch_assoc($Query);
     if (empty($aValue)) {
         return NULL;
     }
     return $aValue["sessionvalue"];
 }
开发者ID:kissthink,项目名称:ym_oauth,代码行数:9,代码来源:session.php

示例11: die2

function die2($debug_str)
{
    global $private_network;
    if (preg_match($private_network, getIp())) {
        die($debug_str);
    } else {
        die("GENERIC_ERROR");
    }
}
开发者ID:Kamaropoulos,项目名称:RyzomCore,代码行数:9,代码来源:client_install.php

示例12: replaceData

 private function replaceData($data)
 {
     $data['ip'] = getIp();
     $data['ratingspage_id'] = $data['id'];
     $data['ratingspage_type'] = str_replace("\\", "_", Crypt::decrypt($data['model']));
     $data['rating'] = $data['value'];
     if (Sentry::check()) {
         $data['user_id'] = Sentry::getUser()->id;
     }
     return $data;
 }
开发者ID:arturishe21,项目名称:rating,代码行数:11,代码来源:RatingController.php

示例13: init

	/**
	 * 初始化,未启用内存保存时默认使用lock表存储
	 *
	 * @param unknown_type $type
	 */
	private static function init($type){
		if (C('cache_open')){
			self::$lock = Cache::getInstance('cacheredis');
		}else{
			self::$lock = new lock();
		}
		if (!isset(self::$processid[$type])){
			$ip = sprintf('%u',ip2long(getIp()));
			self::$processid[$type] = str_pad($ip,10,'0').self::parsekey($type);;
			self::$lockid[$type] = str_pad($ip,11,'0').self::parsekey($type);;
		}
	}
开发者ID:noikiy,项目名称:ejia,代码行数:17,代码来源:process.php

示例14: getCity

function getCity()
{
    $ip = getIp();
    $uri = "http://api.map.baidu.com/location/ip?ak=A20cb515b0fa284cb99c36956c06e737&ip={$ip}&coor=bd09ll";
    $str = file_get_contents($uri);
    $cityArr = json_decode($str);
    if ($cityArr->{'status'} == 0) {
        return $cityArr->{'content'}->{'address_detail'}->{'city'};
    } else {
        return '';
    }
}
开发者ID:Jim-MK,项目名称:strom,代码行数:12,代码来源:weather.php

示例15: saveAction

 public function saveAction()
 {
     $this->_helper->layout->disableLayout();
     $parameters = $this->getRequest()->getParams();
     $errors = array();
     $auth = Zend_Auth::getInstance();
     $publication = new Publication($parameters['f_publication']);
     if ($auth->getIdentity()) {
         $acceptanceRepository = $this->getHelper('entity')->getRepository('Newscoop\\Entity\\Comment\\Acceptance');
         $user = new User($auth->getIdentity());
         $userIp = getIp();
         if ($acceptanceRepository->checkParamsBanned($user->m_data['Name'], $user->m_data['EMail'], $userIp, $parameters['f_publication'])) {
             $errors[] = $this->view->translate('You have been banned from writing feedbacks.');
         }
     } else {
         $errors[] = $this->view->translate('You are not logged in.');
     }
     if (!array_key_exists('f_feedback_content', $parameters) || empty($parameters['f_feedback_content'])) {
         $errors[] = $this->view->translate('Feedback content was not filled in.');
     }
     if (empty($errors)) {
         $feedbackRepository = $this->getHelper('entity')->getRepository('Newscoop\\Entity\\Feedback');
         $feedback = new Feedback();
         $values = array('user' => $auth->getIdentity(), 'publication' => $parameters['f_publication'], 'section' => $parameters['f_section'], 'article' => $parameters['f_article'], 'subject' => $parameters['f_feedback_subject'], 'message' => $parameters['f_feedback_content'], 'url' => $parameters['f_feedback_url'], 'time_created' => new DateTime(), 'language' => $parameters['f_language'], 'status' => 'pending', 'attachment_type' => 'none', 'attachment_id' => 0);
         if (isset($parameters['image_id'])) {
             $values['attachment_type'] = 'image';
             $values['attachment_id'] = $parameters['image_id'];
             $feedbackRepository->save($feedback, $values);
             $feedbackRepository->flush();
             $current_user = $this->_helper->service('user')->getCurrentUser();
             $this->_helper->service->getService('dispatcher')->notify('image.delivered', new GenericEvent($this, array('user' => $current_user)));
             $this->view->response = $this->view->translate('File is uploaded and your message is sent.');
         } else {
             if (isset($parameters['document_id'])) {
                 $values['attachment_type'] = 'document';
                 $values['attachment_id'] = $parameters['document_id'];
                 $feedbackRepository->save($feedback, $values);
                 $feedbackRepository->flush();
                 $current_user = $this->_helper->service('user')->getCurrentUser();
                 $this->_helper->service->getService('dispatcher')->notify('document.delivered', new GenericEvent($this, array('user' => $current_user)));
                 $this->view->response = $this->view->translate('File is uploaded and your message is sent.');
             } else {
                 $feedbackRepository->save($feedback, $values);
                 $feedbackRepository->flush();
                 $this->view->response = $this->view->translate('Your message is sent.');
             }
         }
     } else {
         $errors = implode('<br>', $errors);
         $errors = $this->view->translate('Following errors have been found:') . '<br>' . $errors;
         $this->view->response = $errors;
     }
 }
开发者ID:nidzix,项目名称:Newscoop,代码行数:53,代码来源:FeedbackController.php


注:本文中的getIp函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。