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


PHP get_client_ip函数代码示例

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


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

示例1: addUser

 public function addUser()
 {
     $username = I('post.username', 0);
     $password = I('post.password', 0);
     ($username === 0 || $password === 0) && $this->error("大哥别瞎搞!");
     $username = checkUsername($username);
     if (!$username) {
         $this->ajaxReturn("大哥别瞎注册!");
         exit;
     }
     $user = M('user');
     $queryResult = $user->where("username = '%s'", $username)->find();
     if ($queryResult) {
         $this->ajaxReturn("user_exist");
         exit;
     }
     $data = array('id' => "", 'username' => $username, 'password' => pwEncrypt($username, $password), 'lasttime' => time(), 'lastip' => get_client_ip());
     $result = $user->add($data);
     if ($result) {
         $this->ajaxReturn("ok");
         exit;
     } else {
         $this->ajaxReturn("注册失败!");
         exit;
     }
 }
开发者ID:Lingdu0,项目名称:thinkphp_blog,代码行数:26,代码来源:LoginController.class.php

示例2: index

 public function index()
 {
     $sysinfo = M('sys')->order('id asc')->find();
     $this->assign('sys', $sysinfo);
     $appid = $sysinfo['web_appid'];
     $appsecret = $sysinfo['web_appsecret'];
     if (!defined('VIRIFY')) {
         virifylocal();
     }
     $_scene = M('scene');
     $where['scenecode_varchar'] = I('get.id', 0);
     $where['delete_int'] = 0;
     $_scene_list = $_scene->where($where)->select();
     // print_r($_scene_list); exit('dddd');
     $sysinfo = M('sys')->order('id asc')->find();
     if ($sysinfo['is_user_anli_shenghe'] && !isset($_GET['preview'])) {
         if ($_scene_list[0]["shenhe"] != 1) {
             $this->error('抱歉,您的场景还没通过管理员审核', '/#/main');
         }
     }
     $argu2 = array();
     $argu2['title'] = $_scene_list[0]["scenename_varchar"];
     $argu2['url'] = C('IS_OPEN_STATIC') ? 'v-' . $_scene_list[0]["scenecode_varchar"] : 'index.php?c=view&id=' . $_scene_list[0]["scenecode_varchar"];
     $argu2['desc'] = $_scene_list[0]["desc_varchar"];
     $argu2['imgsrc'] = $_scene_list[0]["thumbnail_varchar"];
     $this->assign("confinfo2", $argu2);
     $mydd = get_client_ip();
     if ($mydd !== '127.0.0.1') {
         $confinfo = $this->get_js_sdk($appid, $appsecret);
     }
     $this->assign("confinfo", $confinfo);
     $this->display(HTML_VESION);
 }
开发者ID:sdgdsffdsfff,项目名称:html5Editor,代码行数:33,代码来源:ViewController.class.php

示例3: login

 public function login()
 {
     #是否显示验证码
     $msg = '';
     if (IS_POST) {
         $name = I('name');
         $password = I('password');
         if (!empty($name) && !empty($password)) {
             #验证用户信息
             $user_info = D('Common/Admin')->loginCheck($name, $password);
             #记录登录日志
             $log_data = array('admin_id' => isset($user_info['id']) ? $user_info['id'] : 0, 'login_time' => date('Y-m-d H:i:s'), 'login_ip' => get_client_ip());
             $log_result = D('Common/Adminlog')->log_add($log_data);
             #跳转
             if (isset($user_info['id'])) {
                 session('user', $user_info['id']);
                 redirect(U('admin/Index/index'));
             } else {
                 $this->error('登录失败,用户名或密码错误。');
             }
         } else {
             $this->error('登录失败,用户名或密码错误。');
         }
     }
     $this->display();
 }
开发者ID:cassileShu,项目名称:ebxzj,代码行数:26,代码来源:IndexController.class.php

示例4: login

 /**
  * 后台登陆控制器
  */
 public function login()
 {
     $arr = array('user_login' => I('user_login'), 'user_pass' => encrypt(I('user_pass'), C('ENCRYPTION_KEY')), 'remember-me' => I('remember-me'));
     //处理下次自动登录
     if ($arr['remember-me'] == 1) {
         $account = $arr['user_login'];
         $ip = get_client_ip(0, true);
         $value = $account . '|' . $ip;
         $value = encrypt($value, C('ENCRYPTION_KEY'));
         @setcookie('remember-me', $value, time() + 7 * 24 * 3600, "/");
     }
     $user = M('user')->where(array('user_login' => $arr['user_login']))->find();
     $userinfo = D('user')->getInfo($user['id']);
     if ($user['user_status'] == 0) {
         $this->error('账号被禁用,请联系管理员...');
     }
     if ($user['user_type'] != '管理员') {
         $this->error('无权限登录...');
     }
     if (!$user || $user['user_pass'] != $arr['user_pass']) {
         $this->error('账号密码错误,请重试...');
     }
     $data = array('id' => $user['id'], 'last_login_ip' => get_client_ip(0, true), 'last_login_time' => date("Y-m-d H:i:s"));
     $result = M('user')->save($data);
     if (!$result) {
         $this->error('登录失败,请重试...');
     }
     session('uid', $user['id']);
     session('username', $userinfo['username']);
     session('last_login_time', $data['last_login_time']);
     session('last_login_ip', $data['last_login_ip']);
     $this->success('登陆成功', U('Index/index'));
 }
开发者ID:lizhi0610,项目名称:hgnu,代码行数:36,代码来源:LoginController.class.php

示例5: index

 public function index()
 {
     if (IS_POST) {
         $User = M("User");
         $username = I('post.username');
         $password = I('post.password');
         $where['username'] = $username;
         $result = $User->where($where)->find();
         if ($result != NULL && $result != false) {
             if (md5($result['salt'] . $password) == $result['password']) {
                 $data['lastlogin'] = date('Y-m-d H:i:s');
                 $data['ip'] = get_client_ip();
                 $User->where($result)->data($data)->save();
                 $result['msg'] = 'succeed';
                 $this->ajaxReturn($result);
             } else {
                 $error['msg'] = 'password error';
                 $this->ajaxReturn($error);
             }
         } else {
             $error['msg'] = 'username error';
             $this->ajaxReturn($error);
         }
     }
 }
开发者ID:Rlilyyyy,项目名称:nansnan,代码行数:25,代码来源:WebapiController.class.php

示例6: publish

 public function publish($content, $uid, $reid = 0)
 {
     if (mb_strlen($content) > 255) {
         $data = array('content' => mb_substr($content, 0, 255, 'utf8'), 'content_over' => mb_substr($content, 255, 25, 'utf8'));
     } else {
         $data = array('content' => $content);
     }
     $data['ip'] = get_client_ip(1);
     $data['uid'] = $uid;
     if ($reid > 0) {
         $data['reid'] = $reid;
     }
     if ($this->create($data)) {
         $tid = $this->add();
         if ($tid) {
             if ($reid > 0) {
                 $this->setRecount($reid);
             }
             return $tid;
         } else {
             return 0;
         }
     } else {
         return $this->getError();
     }
 }
开发者ID:xqx930807,项目名称:weibo,代码行数:26,代码来源:TopicModel.class.php

示例7: login

 public function login()
 {
     if (!IS_POST) {
         E('无效的页面');
     }
     $Verify = new \Think\Verify();
     //if(!$Verify->check($code)) $this->error('验证码错误');
     $db = M('login');
     $user = $db->where(array('username' => I('username')))->find();
     if (!$user || $user['password'] != I('password', '', md5)) {
         $this->error('账号或密码错误');
     }
     //更新最后一次登录时间及IP
     $data = array('id' => $user['id'], 'logintime' => time(), 'loginip' => get_client_ip());
     $db->save($data);
     session('uid', $user['id']);
     session('username', $user['username']);
     session('name', $user['name']);
     session('logintime', date('Y-m-d H:i:s', $user['logintime']));
     session('loginip', $user['loginip']);
     if ($user['jd'] == '1') {
         session('admin', '1');
     } else {
         session('admin', '0');
     }
     if (I('username') == 'admin') {
         session('iadmin', 1);
     } else {
         session('iadmin', 0);
     }
     $this->redirect('/Home/Index/index');
 }
开发者ID:omusico,项目名称:SmallCrm,代码行数:32,代码来源:LoginController.class.php

示例8: login

 public function login()
 {
     if (!IS_POST) {
         halt('页面不存在3');
     }
     // 		if(I('code','','md5')!=session('verify')){
     // 			$this->error('验证码错误');
     // 		}
     $username = I('username');
     $pwd = I('password', '', 'md5');
     $user = M('user')->where(array('username' => $username))->find();
     if (!$user || $user['password'] != $pwd) {
         $this->error('账号或密码错误!');
     }
     if ($user['lock']) {
         $this->error('用户被锁了');
     }
     $data = array('id' => $user['id'], 'logintime' => time(), 'loginip' => get_client_ip());
     M('user')->save($data);
     session('uid', $user['id']);
     session('username', $user['username']);
     session('logintime', date('Y-m-d H:i:s', $user['logintime']));
     session('loginip', $user['loginip']);
     $this->redirect('Admin/Index/index');
 }
开发者ID:highestgoodlikewater,项目名称:Thinkphp-Wishing-Wall,代码行数:25,代码来源:LoginAction.class.php

示例9: grade_login

 public function grade_login()
 {
     if (!check_verify(I('code', ''))) {
         $this->error('验证码错误');
     }
     $username = I('username');
     $user = M('user')->where(array('username' => $username))->find();
     $pwd = I('password', '', 'md5');
     if (!$user | $user['password'] != $pwd) {
         $this->error('用户名或密码错误');
     }
     if ($user['lock']) {
         $this->error('用户被锁定,请联系管理员解锁');
     }
     $data = array('id' => $user['id'], 'logintime' => time(), 'loginip' => get_client_ip());
     M('user')->save($data);
     session(C('USER_AUTH_KEY'), $user['id']);
     session('username', $user['username']);
     session('lastlogintime', date('Y-m-d H:i', $user['logintime']));
     session('lastloginip', $user['loginip']);
     if ($user['username'] == C('RBAC_SUPERADMIN')) {
         session(C('ADMIN_AUTH_KEY'), true);
     }
     import('Org.Util.Rbac');
     Rbac::saveAccessList();
     //        dump($_SESSION);die;
     $this->redirect('Grade/Grade/grade_index');
 }
开发者ID:RqHe,项目名称:aunet1,代码行数:28,代码来源:IndexController.class.php

示例10: login

 public function login()
 {
     if (!IS_POST) {
         $this->error('页面不存在');
     }
     //p($_POST);
     if (!isset($_POST['submit'])) {
         return false;
     }
     //安全一点再判断一下
     //验证码对比
     $code = I('verify');
     //if(!check_verify($code))$this->error('验证码错误');//测试系统,忽略认证
     $name = I('uname');
     $pwd = md5(I('pwd'));
     $db = M('admin');
     $user = $db->where(array('username' => $name))->find();
     if (!$user || $user['password'] != $pwd) {
         $this->error('账号或密码错误');
     }
     if ($user['lock']) {
         $this->error('账号被锁定');
     }
     $data = array('id' => $user['id'], 'logintime' => time(), 'loginip' => get_client_ip());
     $db->save($data);
     session('uid', $user['id']);
     session('username', $user['username']);
     session('logintime', date('Y-m-d H:i', $user['logintime']));
     session('now', date('Y-m-d H:i', time()));
     session('loginip', $user['loginip']);
     session('admin', $user['admin']);
     $this->success('正在登陆...', __APP__);
 }
开发者ID:omusico,项目名称:Thinkphp3.2.3-weibo,代码行数:33,代码来源:LoginController.class.php

示例11: index

 public function index()
 {
     if (IS_POST) {
         $ip = get_client_ip();
         $time = time();
         $map['ip'] = array('eq', $ip);
         //留言间隔
         $Set = D('Set')->find();
         $model = D('Message');
         $Message = $model->where($map)->order('id desc')->find();
         if ($time - $Message['create_time'] < $Set['messageinterval']) {
             $this->error('每条留言需间隔' . $Set['messageinterval'] / 60 . '分钟!');
         }
         if ($vo = $model->create()) {
             //保存当前数据对象
             //  $list = $model->add();
             // if ($list !== false){
             if ($model->add()) {
                 //	 $this->ajaxReturn(0,"留言成功!",1);
                 $this->success('留言成功!');
             } else {
                 //失败提示
                 //  $this->ajaxReturn('添加失败',0);
                 $this->error('提交失败!');
             }
         } else {
             $this->error($model->getError());
         }
     } else {
         $this->display();
     }
 }
开发者ID:zhezhisama,项目名称:zz,代码行数:32,代码来源:MessageAction.class.php

示例12: _initialize

 /**
  * 后台控制器初始化
  */
 protected function _initialize()
 {
     // 获取当前用户ID
     if (defined('UID')) {
         return;
     }
     define('UID', is_login());
     if (!UID) {
         // 还没登录 跳转到登录页面
         $this->redirect('Public/login');
     }
     /* 读取数据库中的配置 */
     $config = S('DB_CONFIG_DATA');
     if (!$config) {
         $config = D('Config')->lists();
         S('DB_CONFIG_DATA', $config);
     }
     C($config);
     //添加配置
     // 是否是超级管理员
     define('IS_ROOT', is_administrator());
     if (!IS_ROOT && C('ADMIN_ALLOW_IP')) {
         // 检查IP地址访问
         if (!in_array(get_client_ip(), explode(',', C('ADMIN_ALLOW_IP')))) {
             $this->error('403:禁止访问');
         }
     }
 }
开发者ID:xingluxin,项目名称:jianshen,代码行数:31,代码来源:AdminController.class.php

示例13: init_follow

 function init_follow($openid, $token = '', $has_subscribe = false)
 {
     empty($token) && ($token = get_token());
     addWeixinLog($openid . '::_' . $token, 'init_follow_in');
     if (empty($openid) || $openid == -1 || empty($token) || $token == -1) {
         return false;
     }
     $data['token'] = $token;
     $data['openid'] = $openid;
     $datas = $data;
     $uid = M('public_follow')->where($data)->getField('uid');
     addWeixinLog($uid, 'init_follow_check_uid');
     if ($uid) {
         return $uid;
     }
     // 自动注册
     $config = getAddonConfig('UserCenter', $token);
     $user = array('experience' => intval($config['experience']), 'score' => intval($config['score']), 'reg_ip' => get_client_ip(1), 'reg_time' => NOW_TIME, 'last_login_ip' => get_client_ip(1), 'last_login_time' => NOW_TIME, 'status' => 1, 'is_init' => 1, 'is_audit' => 1, 'come_from' => 1);
     $user2 = getWeixinUserInfo($openid);
     $user = array_merge($user, $user2);
     $data['uid'] = $uid = D('Common/User')->add($user);
     if ($has_subscribe !== false) {
         $data['has_subscribe'] = $has_subscribe;
     }
     M('public_follow')->add($data);
     return $uid;
 }
开发者ID:chenpusn,项目名称:haozhixian_bak,代码行数:27,代码来源:FollowModel.class.php

示例14: save

 static function save($type = '', $destination = '', $extra = '')
 {
     if (empty(self::$log)) {
         return;
     }
     $type = $type ? $type : C('LOG_TYPE');
     if (self::FILE == $type) {
         // 文件方式记录日志信息
         if (empty($destination)) {
             $destination = C('LOG_PATH') . date('y_m_d') . '.log';
         }
         //检测日志文件大小,超过配置大小则备份日志文件重新生成
         if (is_file($destination) && floor(C('LOG_FILE_SIZE')) <= filesize($destination)) {
             rename($destination, dirname($destination) . '/' . time() . '-' . basename($destination));
         }
     } else {
         $destination = $destination ? $destination : C('LOG_DEST');
         $extra = $extra ? $extra : C('LOG_EXTRA');
     }
     $now = date(self::$format);
     error_log($now . ' ' . get_client_ip() . ' ' . $_SERVER['REQUEST_URI'] . "\r\n" . implode('', self::$log) . "\r\n", $type, $destination, $extra);
     // 保存后清空日志缓存
     self::$log = array();
     //clearstatcache();
 }
开发者ID:kumfo,项目名称:YYphp,代码行数:25,代码来源:Log.class.php

示例15: signin

 /**
  * 帐号注册
  */
 function signin()
 {
     if (IS_POST) {
         $post = I('post.');
         if ($post['email'] == '') {
             $this->error('邮件地址不能为空!');
         }
         if ($post['verification_code'] != $_SESSION['verification_code']) {
             $this->error('你输入的验证码不正确!');
         }
         $this->_check_email($post['email']);
         $data['email'] = $post['email'];
         $data['register_time'] = NOW_TIME;
         $data['register_ip'] = get_client_ip(1);
         if ($this->user->add($data) !== false) {
             $link = PDM_URL . '?c=account&a=authentication&sign=' . pdm_code($post['email']);
             $tpl = file_get_contents(PDM_INC_PATH . 'ThirdParty/PHPMailer/templates/register_success.htm');
             $tpl = str_replace('#EMAIL#', $data['email'], $tpl);
             $tpl = str_replace('#SYSTEM_NAME#', PDM_NAME, $tpl);
             $tpl = str_replace('#DATE#', date('Y年m月d日'), $tpl);
             $tpl = str_replace('#LINK#', $link, $tpl);
             pdm_sendmail($data['email'], '密码管理系统注册确认', $tpl);
             $this->success('帐号注册成功,请到你的邮件中确认激活!', '', 5);
         } else {
             $this->error('帐号注册失败!');
         }
     } else {
         $this->display();
     }
 }
开发者ID:wsunxa,项目名称:pdm,代码行数:33,代码来源:AccountAction.class.php


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