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


PHP getClientIP函数代码示例

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


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

示例1: checkChinaIP

function checkChinaIP()
{
    $ip = getClientIP();
    $cIP = explode(".", $ip);
    $ipList = split("\n", file_get_contents(__DIR__ . "/china_ip"));
    foreach ($ipList as $value) {
        if (!$value) {
            continue;
        }
        $ips = explode(" ", $value);
        $minIP = explode(".", $ips[0]);
        $maxIP = explode(".", $ips[1]);
        $match = true;
        foreach ($cIP as $idx => $part) {
            if ($part < $minIP[$idx] || $part > $maxIP[$idx]) {
                $match = false;
                break;
            }
        }
        if ($match) {
            return true;
        }
    }
    return false;
    //return true;
}
开发者ID:jimmyshen007,项目名称:webproject,代码行数:26,代码来源:checkip.php

示例2: tg

 /**
  * 推广连接
  * www.xxx.com/action/Method/站长ID/游戏ID/cpa、cps、。。。/子ID/?ref=url
  * yy.51yx.com/index/tg/12312312/13/2/11/?ref=url
  */
 public function tg()
 {
     $master_id = $_GET[2];
     //站长ID
     $game_id = $_GET[3];
     //游戏ID
     $type = $_GET[4];
     //推广类型 cpa/cps
     $sub_code = $_GET[5];
     //子站长ID
     $ref = $_GET['ref'];
     setcookie(WEBMASTER, $master_id, 0, '/', DOMAIN);
     setcookie(AD_GAME_ID, $game_id, 0, '/', DOMAIN);
     setcookie(SPREAD_TYPE, $type, 0, '/', DOMAIN);
     //CPS 为2	CPA:1   其它:0
     setcookie(SUB_CODE, $sub_code, 0, '/', DOMAIN);
     $ip = getClientIP();
     //记点击日志
     //站长ID,游戏ID,子站长ID,访问IP
     $content = $master_id . ',' . $game_id . ',\'' . $sub_code . '\' ' . $ip;
     @log_info($content, $file = "tg_click_");
     if ($ref) {
         $this->gotourl($ref);
     } else {
         $this->gotourl('/member/register');
     }
     exit;
 }
开发者ID:noikiy,项目名称:webgame,代码行数:33,代码来源:index.php

示例3: setSessionFile

function setSessionFile($data)
{
    $dir = getSysDir();
    $handle = fopen($dir . '/etc/session/sess' . md5(getClientIP()), 'wt');
    $res = fwrite($handle, $data);
    fclose($handle);
    return $res;
}
开发者ID:jokopurnomoa,项目名称:OSJ-X,代码行数:8,代码来源:DefaultIO.php

示例4: addToLog

function addToLog($userid, $action, $description)
{
    $userid = makeStringSafe($userid);
    $action = makeStringSafe($action);
    $description = makeStringSafe($description);
    $mysqldate = getCurrentMySQLDateTime();
    $ip = getClientIP();
    $hostname = getClientHostname();
    doQuery("INSERT INTO " . getDBPrefix() . "_log SET user_id = '" . $userid . "', action_type = '" . $action . "', action_description = '" . $description . "', date = '" . $mysqldate . "', ip = '" . $ip . "', hostname='" . $hostname . "'");
}
开发者ID:ramielrowe,项目名称:Reservation-System-V1,代码行数:10,代码来源:db_log_functions.php

示例5: createInstantReport

 public static function createInstantReport($message, $senderid, $requestid, $route, array $response)
 {
     // Request id
     $dataToInsert['user_id'] = 1;
     // active user id
     $dataToInsert['request_id'] = $requestid;
     $dataToInsert['request_route'] = $route;
     $dataToInsert['senderid'] = $senderid;
     $dataToInsert['message'] = $message;
     $dataToInsert['data'] = $response;
     //json
     $dataToInsert['sender_ip'] = getClientIP();
     CloudsmsReports::create($dataToInsert);
 }
开发者ID:leelam,项目名称:cloudsms,代码行数:14,代码来源:CloudsmsReports.php

示例6: activation

 public function activation()
 {
     $this->loadModel('common_model');
     $json = $_GET['jsoncallback'];
     $user_name = $_REQUEST['user_name'];
     $game_id = $_REQUEST['game_id'];
     $card_no = $_REQUEST['card_no'];
     //判断激活码是否有效
     $query = $this->common_model->checkActivationCode($card_no);
     if ($query) {
         if (empty($json)) {
             echo json_encode(array('actionErrors' => 'e1'));
         } else {
             echo $json . "(" . json_encode(array('actionErrors' => 'e1')) . ")";
         }
         exit;
     }
     //判断账号是否已经被激活过
     $query = $this->common_model->checkUserActivation($game_id, $user_name);
     if ($query) {
         if (empty($json)) {
             echo json_encode(array('actionErrors' => 'e3'));
         } else {
             echo $json . "(" . json_encode(array('actionErrors' => 'e3')) . ")";
         }
         exit;
     }
     //判断用户或激活码是否可用
     $query = $this->common_model->checkActivation($game_id, $user_name, $card_no);
     if ($query) {
         if (empty($json)) {
             echo json_encode(array('actionErrors' => 'e2'));
         } else {
             echo $json . "(" . json_encode(array('actionErrors' => 'e2')) . ")";
         }
         exit;
     }
     $active_ip = getClientIP();
     //IP地址
     $result = $this->common_model->activation($card_no, $user_name, $active_ip, $game_id);
     if ($result) {
         if (empty($json)) {
             echo json_encode(array('actionErrors' => 'succ'));
         } else {
             echo $json . "(" . json_encode(array('actionErrors' => 'succ')) . ")";
         }
     }
     exit;
 }
开发者ID:noikiy,项目名称:webgame,代码行数:49,代码来源:ajax.php

示例7: check_formlimitation

 public function check_formlimitation($formID, $dayrange = 1, $limitation = 5)
 {
     $WebSiteID = $this->session->userdata('WebSiteID');
     $sql = "SELECT COUNT(*) Total FROM tbl_restrictions_form_limitations WHERE WebSiteID='" . $WebSiteID . "' AND FormID='" . $formID . "' AND ClientIP='" . getClientIP() . "' AND CreateTime> DATEADD(day,-" . $dayrange . ",GETDATE())";
     $query = $this->db->query($sql);
     $row = $query->row();
     $Total = $row->Total;
     $sql = "INSERT INTO tbl_restrictions_form_limitations (WebSiteID, FormID, ClientIP) VALUES ('" . $WebSiteID . "','" . $formID . "','" . getClientIP() . "')";
     $query = $this->db->query($sql);
     if ($Total >= $limitation) {
         return false;
     } else {
         return true;
     }
 }
开发者ID:mdbhk,项目名称:retailersurvey.themdbfamily.com,代码行数:15,代码来源:restriction_model.php

示例8: writeLog

function writeLog($msg)
{
    $time = Date('Y-m-d h:i:s');
    $ip = getClientIP();
    $info = "{$time}--{$ip} ------>{$msg}";
    //echo  $info;
    $fp = fopen("/data/web/open.valsun.cn/log.txt", "a+");
    //追加写入
    if ($fp) {
        $flag = fwrite($fp, $info . "\r\n");
        if (!$flag) {
            echo "写入文件失败<br>";
        }
    } else {
        echo "打开文件失败";
    }
    fclose($fp);
}
开发者ID:ohjack,项目名称:newErp,代码行数:18,代码来源:functions.php

示例9: writeLog

function writeLog($msg)
{
    $time = Date('Y-m-d h:i:s');
    $log_path = WEB_PATH . 'log.txt';
    $ip = getClientIP();
    $info = "{$time}--{$ip} ------>{$msg}";
    //echo  $info;
    $fp = fopen($log_path, "a+");
    //追加写入
    if ($fp) {
        $flag = fwrite($fp, $info . "\r\n");
        if (!$flag) {
            echo "写入文件失败<br>";
        }
    } else {
        echo "打开文件失败";
    }
    fclose($fp);
}
开发者ID:ohjack,项目名称:newErp,代码行数:19,代码来源:functions.php

示例10: userInfoCache

 public static function userInfoCache($token, $userid)
 {
     self::initDB();
     $data = Auth::getUserInfo($token);
     //鉴权系统拉取权限
     $userinfo = json_decode($data, TRUE);
     if (json_last_error() != JSON_ERROR_NONE) {
         //json数据解析出错
         $errCode = 1;
         $errMsg = '解析鉴权系统返回json出错!';
         return false;
     }
     $sql = "select lastUpdateTime from pc_user where userPowerId = {$userid}";
     $row = self::$dbConn->fetch_first($sql);
     $time = time();
     $ip = getClientIP();
     //客户端ip
     //var_dump($userinfo);exit;
     $username = mysql_real_escape_string($userinfo['userName']);
     $phone = mysql_real_escape_string($userinfo['phone']);
     $email = mysql_real_escape_string($userinfo['email']);
     if (!empty($row)) {
         if (json_decode(intval($userinfo['lastUpdateTime']), TRUE) > $row['lastUpdateTime']) {
             //鉴权系统信息已更新 更新本地数据
             $up_sql = "update pc_user set userName = '{$username}', userTel='{$phone}', userMail='{$email}', userIp = '{$ip}', userActive = userActive+1, lastUpdateTime={$time} where userPowerId={$userid}";
             self::$dbConn->query($up_sql);
         } else {
             //信息没有更新 则只更新登陆次数
             $up_sql = "update pc_user set userActive=userActive+1 where userPowerId={$userid}";
             //echo $up_sql;exit;
             self::$dbConn->query($up_sql);
         }
     } else {
         //没找到结果集 新增用户数据
         $in_sql = "insert into pc_user values (null, {$userid}, '{$username}', '', '' , '' , '' , '', '', '', '{$phone}', '{$email}', '{$ip}', 1, '', {$time}, 0, {$time})";
         self::$dbConn->query($up_sql);
     }
     //存储用户权限信息到memcache
     self::cacheUserInfoToMemcache($userid, $userinfo['power']);
     return $userinfo;
 }
开发者ID:ohjack,项目名称:newErp,代码行数:41,代码来源:userCache.model.php

示例11: getGlobal

 public function getGlobal()
 {
     $m_user = $this->load("User");
     //判断cookie是否有-自动登录
     $cookie_auth = $this->getCookie('auth');
     if ($cookie_auth) {
         $clean = array();
         list($identifier, $token) = explode(':', $cookie_auth);
         if (ctype_alnum($identifier) && ctype_alnum($token)) {
             $clean['identifier'] = $identifier;
             $clean['token'] = $token;
         }
         $record = $m_user->Where(array("identifier" => $clean['identifier']))->Field("id,email,identifier,identifier_token,login_time,point,refuse")->SelectOne();
         if ($record && $record["refuse"]) {
             if ($clean['token'] != $record['identifier_token']) {
                 //$this->redirect("Login/index");
             } elseif ($clean['identifier'] != md5("SALTISDIFFCULT" . md5($record["email"] . "SALTISDIFFCULT"))) {
                 //$this->redirect("Login/index");
             } else {
                 //更新
                 if ($record["login_time"] < strtotime(date("Y-m-d"))) {
                     $m_user->UpdateByID(array("login_time" => time(), "login_ip" => getClientIP(), "point" => $record["point"] + 2), $record["id"]);
                 }
                 $this->setSession('uid', $record["id"]);
                 $this->setSession('email', $record["email"]);
             }
         }
     }
     //根据session uid 获取该用户的信息
     $session_uid = $this->getSession("uid");
     $session_email = $this->getSession("email");
     if (isset($session_uid) && !empty($session_uid)) {
         $current_user_info = $m_user->Where(array("id" => $session_uid))->Field("id,email,username")->SelectOne();
         $current_user_info = deep_htmlspecialchars_decode($current_user_info);
         $this->getView()->assign("current_user_info", $current_user_info);
     }
 }
开发者ID:GobYang,项目名称:thaidh,代码行数:37,代码来源:C_Basic.php

示例12: getClientIP

<?php

//测试负载均衡的ip地址
echo 'HTTP_HOST'.$_SERVER['HTTP_HOST'].',REMOTE_ADDR '.$_SERVER["REMOTE_ADDR"].',SERVER_NAME'.$_SERVER['SERVER_NAME'].',getClientIP'.getClientIP();


/** 
 * 获取客户端ip 
 */   
 function getClientIP() {
    $ip = "unknown";  
    /* 
     * 访问时用localhost访问的,读出来的是“::1”是正常情况。 
     * ::1说明开启了ipv6支持,这是ipv6下的本地回环地址的表示。 
     * 使用ip地址访问或者关闭ipv6支持都可以不显示这个。 
     * */  
    if (isset($_SERVER)) {  
        if (isset($_SERVER["HTTP_X_FORWARDED_FOR"])) {  
            $ip = $_SERVER["HTTP_X_FORWARDED_FOR"];  
        } elseif (isset($_SERVER["HTTP_CLIENT_ip"])) {  
            $ip = $_SERVER["HTTP_CLIENT_ip"];  
        } else {  
            $ip = $_SERVER["REMOTE_ADDR"];  
        }  
    } else {  
        if (getenv('HTTP_X_FORWARDED_FOR')) {  
            $ip = getenv('HTTP_X_FORWARDED_FOR');  
        } elseif (getenv('HTTP_CLIENT_ip')) {  
            $ip = getenv('HTTP_CLIENT_ip');  
        } else {  
            $ip = getenv('REMOTE_ADDR');  
开发者ID:bajian,项目名称:js-web-skills,代码行数:31,代码来源:remoteIp.php

示例13: detectCountry

function detectCountry($mysqli, $cod_pais = '')
{
    /*$url = "http://ipinfo.io/";
      $ch = curl_init();
      curl_setopt($ch, CURLOPT_URL, $url);
      curl_setopt($ch, CURLOPT_HEADER, 0);*/
    //Con esta opcion almaceno el resultado en una variable
    //curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    //session_start();
    if (isset($cod_pais) && $cod_pais != '') {
        $pais = $cod_pais;
    } else {
        // Usamos la API de GEO plugin + mas el header TTP_X_FORWARDED_FOR
        $data = unserialize(file_get_contents('http://www.geoplugin.net/php.gp?ip=' . getClientIP()));
        $pais = $data['geoplugin_countryCode'];
    }
    if ($pais) {
        //$resp = json_decode(curl_exec($ch));
        $cod_pais = $pais;
        //$resp->country;
        $query = "SELECT id, pais, flag FROM paises WHERE cod_pais='{$cod_pais}'";
        $result = $mysqli->query($query);
        $tablaPaisdatos = $result->fetch_assoc();
        $tablaPais = array('id' => $tablaPaisdatos['id'], 'cod_pais' => $cod_pais, 'pais' => $tablaPaisdatos['pais'], 'flag' => $tablaPaisdatos['flag']);
        if ($cod_pais != 'US') {
            $query2 = "SELECT id, idioma, cod_idioma FROM idiomas WHERE idiomas.id = (select id_idioma from pais_idioma where pais_idioma.id_pais = {$tablaPaisdatos['id']})";
            $result2 = $mysqli->query($query2);
            $idioma = $result2->fetch_assoc();
            $idioma_sel = $idioma['idioma'];
        } else {
            $idioma = array("id" => "2", "idioma" => "Ingles", "cod_idioma" => "IN");
            $idioma_sel = "Ingles";
        }
        $_SESSION['pais'] = array('id' => $tablaPais['id'], 'cod_pais' => $tablaPais['cod_pais'], 'pais' => $tablaPais['pais'], 'flag' => $tablaPais['flag'], 'idioma' => $idioma_sel, 'cod_idioma' => $idioma['cod_idioma'], 'id_idioma' => $idioma['id']);
    } else {
        $_SESSION['pais'] = array('pais' => 'Argentina', 'cod_pais' => "AR", 'idioma' => 'ES', 'flag' => 'images/flags/ar.png', 'id_idioma' => '1', 'cod_idioma' => 'ES', 'id' => '1');
        $_SESSION['ciudad'] = 'Rosario';
    }
    //curl_close($ch);
}
开发者ID:sebasnob,项目名称:iga-la,代码行数:40,代码来源:functions.php

示例14: getClientIP

 $txtAuthorizeLoginId = $row["authorize_loginid"];
 $txtAuthorizeTransKey = $row["authorize_transkey"];
 $txtCurrency = "USD";
 $txtAuthorizeEmail = $row["authorize_email"];
 $txtAuthorizeTestMode = $row["authorize_test_mode"];
 if ($txtAuthorizeTestMode == "Y") {
     $txtAuthorizeTestMode = "on";
 } else {
     $txtAuthorizeTestMode = "off";
 }
 $gift_coupon_flag = 0;
 $message = "";
 $paymentsuccessful = false;
 $paymenterror = "";
 $referrer = $_SERVER["HTTP_REFERER"];
 $Cust_ip = getClientIP();
 $txtAddress = $txtAddress1;
 if (!$ddlCountry) {
     $ddlCountry = $bill_country;
 }
 if (!$txtState) {
     $txtState = $bill_state;
 }
 $Company = "-NA-";
 $Phone = $txtPhone;
 if ($txtLastName == "") {
     $txtLastName = "-NA-";
 }
 require "../authorize-product-listing.php";
 //process the card and return result. Comment this line and uncomment the two lines below to make payment test mode
 //$paymentsuccessful = true;
开发者ID:kevinsmasters,项目名称:purecatskillsmarketplace,代码行数:31,代码来源:product-listing-payment-cc.php

示例15: strAddslashes

 $loginUser = strAddslashes(trim($_POST['login-user']));
 $loginPwd = stripslashes(trim($_POST['login-pwd']));
 if (strlen($loginUser) < 2 || strlen($loginUser) > 45 || strlen($loginPwd) < 6 || strlen($loginPwd) > 18) {
     echo "0 用户名或者密码不符合要求";
 } else {
     $DB->connect($mysql_host, $mysql_user, $mysql_pass, $mysql_dbname);
     if (!emailcheck($loginUser)) {
         $LoginType = "lower(`name`)";
     } else {
         $LoginType = "`email`";
     }
     $userArr = $TB->getMemberInfo($LoginType, strtolower($loginUser));
     if (!empty($userArr['uid'])) {
         if ($userArr['password'] == md5($loginPwd)) {
             $loginTime = time();
             $loginIp = getClientIP();
             loginCookie($userArr['uid'], $userArr['name'], $userArr['groupid'], $loginIp, $loginTime);
             $loginInfo['securekey'] = createSecureKey(10);
             $loginInfo['lastdate'] = $loginTime;
             $loginInfo['lastip'] = $loginIp;
             if ($userArr['lastdate'] != date("Y.m.d")) {
                 $loginInfo['integral'] = array("`integral`+1");
             }
             $DB->query($DB->update_sql("`" . $table_member . "`", $loginInfo, "`uid`=" . $userArr['uid']));
             echo "1 登录成功";
         } else {
             echo "0 您输入的密码不正确";
         }
     } else {
         echo "0 通行证账号不存在";
     }
开发者ID:tanny2015,项目名称:DataStructure,代码行数:31,代码来源:login.php


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