當前位置: 首頁>>代碼示例>>PHP>>正文


PHP XWB_plugin::getIP方法代碼示例

本文整理匯總了PHP中XWB_plugin::getIP方法的典型用法代碼示例。如果您正苦於以下問題:PHP XWB_plugin::getIP方法的具體用法?PHP XWB_plugin::getIP怎麽用?PHP XWB_plugin::getIP使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在XWB_plugin的用法示例。


在下文中一共展示了XWB_plugin::getIP方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: sitePushback2share

 /**
  * 構造函數
  */
 function sitePushback2share()
 {
     $this->_userConfig['ip'] = DB::mysqli_escape(XWB_plugin::getIP());
     $this->_userConfig['uid'] = (int) XWB_plugin::pCfg('pushback_uid');
     $this->_userConfig['username'] = DB::mysqli_escape(XWB_plugin::convertEncoding((string) XWB_plugin::pCfg('pushback_username'), 'UTF-8', XWB_S_CHARSET));
     $this->_userConfig['timestamp'] = (int) TIMESTAMP;
     //DZ已有的變量,直接使用之
     if ($this->_userConfig['uid'] < 1) {
         $this->_userConfig['uid'] = 0;
         $this->_userConfig['username'] = 'Guest';
     }
 }
開發者ID:chibimiku,項目名稱:xweibo_for_discuz_x2_php7,代碼行數:15,代碼來源:sitePushback2share.class.php

示例2: verify

 /**
  * 進行身份驗證
  * 請保證傳參所用字符集和論壇字符集一致,否則請先自行轉換再傳參
  * @param string $username
  * @param string $password
  * @param int $questionid
  * @param string $answer
  * @param boolen $isuid 使用UID驗證麽?
  * @return array
  *    第一個數組下標($return[0])若大於0,則表示驗證成功的登錄uid。否則為錯誤信息:
  *   	 -1:UC用戶不存在,或者被刪除
  *    	 -2:密碼錯
  *   	 -3:安全提問錯
  *   	 -4:用戶沒有在dz注冊
  *    第二個數組下標($return[1])若大於等於0,則表示驗證成功的adminid;
  *   	 否則為-1,表示驗證失敗
  */
 function verify($username, $password, $questionid = '', $answer = '', $isuid = 0)
 {
     $return = array(0 => -1, 1 => -1);
     $ip = XWB_plugin::getIP();
     /**
      * 校驗用戶輸入錯誤密碼的次數
      */
     $failedlogins = $this->db->fetch_first("select * from " . XWB_S_TBPRE . "failedlogins where `ip`='{$ip}'");
     if ($failedlogins && $failedlogins['count'] >= 5) {
         $return[0] = -5;
         return $return;
     }
     /**
      * 校驗用戶輸入的用戶名和密碼是否正確
      */
     if (true === UCENTER) {
         //加載Ucenter客戶端文件
         include_once ROOT_PATH . './api/uc_client/client.php';
         $uc_result = uc_user_login($username, $password, $isuid, 0, $questionid, $answer);
         $ucuid = $uc_result[0];
         if ($ucuid < 1) {
             $return[0] = $ucuid;
             return $return;
         }
     }
     $member = $this->db->fetch_first("SELECT `uid`, `password`, `nickname`, `username`, `role_type`, `salt` FROM " . XWB_S_TBPRE . "members WHERE `nickname`='{$username}'");
     if ($member) {
         /**
          * 在記事狗係統中比對用戶輸入的密碼
          */
         if ($member['password'] == jsg_member_password($password, $member['salt'])) {
             $return[0] = (int) $member['uid'];
             $return[1] = 'admin' == $member['role_type'] ? 1 : 0;
         } else {
             $return[0] = -2;
             /**
              * 更新密碼輸入錯誤的次數
              */
             if ($failedlogins) {
                 $this->db->query("update " . XWB_S_TBPRE . "failedlogins set `count`='" . (max(1, (int) $failedlogins['count']) + 1) . "', `lastupdate`='" . time() . "' where `ip`='{$ip}'");
             } else {
                 $this->db->query("insert into " . XWB_S_TBPRE . "failedlogins (`ip`,`count`,`lastupdate`) values ('{$ip}','1','" . time() . "')");
             }
         }
     }
     return $return;
 }
開發者ID:YouthAndra,項目名稱:huaitaoo2o,代碼行數:64,代碼來源:siteUserVerifier.class.php

示例3: statUrl

 /**
  * 生成統計上報url(當$html參數為true時,可使用返回的內容,通過客戶端進行上報)
  * @param string $type stat類型
  * @param array $args stat參數
  * @param bool 生成html?默認為否
  * @param bool 是否產生random?默認為是
  * @return string
  */
 function statUrl($type, $args = array(), $html = false, $random = true)
 {
     if (defined('XWB_P_STAT_DISABLE')) {
         return '';
     }
     $statUrl = 'http://beacon.x.weibo.com/a.gif';
     //stat參數公用部分添加
     $args['pjt'] = XWB_P_PROJECT;
     $args['dsz'] = XWB_S_VERSION;
     $args['ver'] = XWB_P_VERSION;
     $args['xt'] = $type;
     $args['akey'] = isset($args['akey']) ? $args['akey'] : XWB_APP_KEY;
     $args['ip'] = XWB_plugin::getIP();
     //新浪用戶uid,最好強製傳值,否則會異步計算錯誤
     if (!isset($args['uid'])) {
         $args['uid'] = XWB_plugin::getBindInfo("sina_uid");
     }
     $args['uid'] = !is_numeric($args['uid']) || 1 > $args['uid'] ? '' : $args['uid'];
     if (true === $random) {
         $args['random'] = rand(1, 999999);
     }
     $statUrl .= '?' . http_build_query($args);
     if (defined('XWB_P_DEBUG') && true == XWB_P_DEBUG) {
         $logmsg = "上報的URL為:" . $statUrl;
         XWB_plugin::LOG($logmsg, 'statRecord', false);
     }
     if (false == $html) {
         return $statUrl;
     } else {
         return '<img src="' . $statUrl . '" style="display:none" />';
     }
 }
開發者ID:chibimiku,項目名稱:xweibo_for_discuz_x2_php7,代碼行數:40,代碼來源:core.class.php

示例4: generateSessionHash

 /**
  * 生成一個session id校驗
  * @uses XWB_P_ROOT , XWB_plugin
  * @param string $id
  */
 function generateSessionHash($id)
 {
     $key = '';
     if (!empty($_SERVER['HTTP_USER_AGENT'])) {
         $key .= $_SERVER['HTTP_USER_AGENT'];
     }
     $key = XWB_P_ROOT . XWB_plugin::getIP() . $id;
     return sprintf('%08x', crc32($key));
 }
開發者ID:chibimiku,項目名稱:xweibo_for_discuz_x2_php7,代碼行數:14,代碼來源:session_operator_simulator.class.php

示例5: oAuthRequest

 /**
  * Format and sign an OAuth / API request
  * 目前僅支持get和post方法
  *
  * @return array
  */
 function oAuthRequest($url, $method, $parameters, $useType = true, $multi = false)
 {
     $request = ns_OAuthRequest::from_consumer_and_token($this->token, $method, $url, $parameters);
     $method = strtoupper($method);
     switch ($method) {
         case 'GET':
             $this->last_req_url = $request->to_url();
             $this->http->setUrl($request->to_url());
             break;
         case 'POST':
             $this->last_req_url = $request->get_normalized_http_url();
             $this->http->setUrl($request->get_normalized_http_url());
             $this->http->setData($request->to_postdata($multi));
             if ($multi) {
                 $header_array = array();
                 $header_array2 = array();
                 if ($multi) {
                     $header_array2 = array("Content-Type: multipart/form-data; boundary=" . $GLOBALS['__CLASS']['ns_OAuthRequest']['__STATIC']['boundary'], "Expect: ");
                 }
                 foreach ($header_array as $k => $v) {
                     array_push($header_array2, $k . ': ' . $v);
                 }
                 if (!defined('CURLOPT_HTTPHEADER')) {
                     define('CURLOPT_HTTPHEADER', 10023);
                 }
                 $config = array(CURLOPT_HTTPHEADER => $header_array2);
                 $this->http->setConfig($config);
             }
             break;
         default:
             trigger_error('WRONG REQUEST METHOD IN WEIBO CLASS!', E_USER_ERROR);
             break;
     }
     $this->http->setHeader('API-RemoteIP', (string) XWB_plugin::getIP());
     $time_start = microtime();
     $result = $this->http->request(strtolower($method));
     $time_end = microtime();
     $time_process = array_sum(explode(" ", $time_end)) - array_sum(explode(" ", $time_start));
     if ($useType === false || $useType === true) {
         $result = xwb_util_json::decode($result, true);
     }
     $code = $this->http->getState();
     if (200 != $code) {
         $this->_delBindCheck(isset($result['error']) ? (string) $result['error'] : (string) $result);
         $this->req_error_count++;
     }
     if (defined('XWB_DEV_LOG_ALL_RESPOND') && XWB_DEV_LOG_ALL_RESPOND == true) {
         $this->logRespond($this->last_req_url, $method, (int) $code, $result, array('param' => $parameters, 'time_process' => $time_process, 'triggered_error' => $this->http->get_triggered_error(), 'base_string' => $request->base_string, 'key_string' => $request->key_string));
     }
     if (200 != $code) {
         if (0 == $code) {
             $result = array("error_code" => "50000", "error" => "timeout");
         }
         if ($useType === true) {
             if (!is_array($result)) {
                 $result = array('error' => (string) $result, 'error_code' => $code);
             }
             $this->setError($result);
         }
     }
     return $result;
 }
開發者ID:Jaedeok-seol,項目名稱:discuz_template,代碼行數:68,代碼來源:weibo2_0.class.php


注:本文中的XWB_plugin::getIP方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。