本文整理匯總了PHP中CRequest::getIp方法的典型用法代碼示例。如果您正苦於以下問題:PHP CRequest::getIp方法的具體用法?PHP CRequest::getIp怎麽用?PHP CRequest::getIp使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CRequest
的用法示例。
在下文中一共展示了CRequest::getIp方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: __construct
/**
* 構造函數
*/
public function __construct()
{
if ($this->Args('isajax', 'int') == 1) {
$this->isAjax = 1;
}
if (!self::isLogin()) {
if ($this->isAjax) {
$this->displayAjax(false, '您還沒有登陸,請先登錄');
}
return CResponse::getInstance()->redirect(array('c' => 'base', 'a' => 'index'));
}
$status = self::checkRight();
// 用戶資源
if ($this->layout == 'layout_main') {
$userData = CSession::get('user');
$this->assign('userdata', $userData);
}
// 檢查權限
if (false == $status) {
// 判斷請求方式
if ($this->isAjax) {
$this->displayAjax(false, '您沒有權限執行此操作!');
}
// 分析錯誤信息
$data['from'] = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
// ip歸屬地
$data['ip'] = CRequest::getIp();
$data['ipArea'] = IPArea::getArea(CRequest::getIp());
$data['agent'] = CRequest::getAgent();
$this->assign('data', $data);
$this->display('alert/noright');
exit;
}
}
示例2: isInternalIP
/**
* 判斷是否內部IP
*/
public static function isInternalIP($ip = null)
{
if (empty($ip)) {
$ip = CRequest::getIp();
}
$internalIp = array('125.71.211.185');
//獲取內部IP
$setIP = CConfig::getInstance('site')->load('ipList');
if (!empty($setIP) && is_array($setIP)) {
$internalIp = $setIP;
}
if (in_array($ip, $setIP)) {
return true;
}
return false;
}
示例3: setInitData
/**
* 設置基礎數據
*/
public static function setInitData($viewObject)
{
$prefix = CConfig::getInstance()->load('ACTION_PREFIX');
$viewObject->assign('thisUrl', urlencode(CRequest::getUrl()));
$viewObject->assign('base64Url', CEncrypt::safe_b64encode(CRequest::getUrl()));
$viewObject->assign('controller', CRequest::getController());
$viewObject->assign('action', CRequest::getAction());
$viewObject->assign('actionPre', $prefix);
$viewObject->assign('ip', CRequest::getIp());
$viewObject->assign('module', CRequest::getModule());
$viewObject->assign('time', time());
$viewObject->assign('sessionID', session_id());
$viewObject->assign('path', CRequest::getPath());
$viewObject->assign('staticUrl', CConfig::getInstance('site')->load('staticUrl'));
$viewObject->assign('uploadStaticUrl', CConfig::getInstance('site')->load('uploadStaticUrl'));
$viewObject->assign('siteName', CConfig::getInstance('site')->load('siteName'));
}
示例4: userLogin
/**
* 用戶登陸
*/
public function userLogin($checkData)
{
$result = array('status' => false, 'message' => '發生錯誤,處理失敗');
// 檢查
if (!isset($checkData['status']) || false == $checkData['status'] || empty($checkData['userData'])) {
$result['message'] = '登錄失敗';
return $result;
}
// 用戶資料
$userData = $checkData['userData'];
// 獲取權限
$groupList = CModel::factory('adminUserGroupModel')->getGroupList();
// 不存在管理組
if (!isset($groupList[$userData['groupId']])) {
// 記錄日誌
$result['message'] = '沒有權限登錄(group)';
return $result;
}
// 填充組信息
$userData['groupData'] = $groupList[$userData['groupId']];
// 獲取菜單
$menuData = AdminMenu::getUserMenu($userData);
// 保存菜單
$userData['menu'] = $menuData['menu'];
// 保存權限
$userData['rightAll'] = $menuData['allRight'];
$userData['isInternal'] = intval(IPArea::isInternalIP());
// 獲取導航
// 登陸地
if ($userData['isInternal'] == 1) {
$userData['loginArea'] = '公司內部';
} else {
$userData['loginArea'] = IPArea::getArea(CRequest::getIp());
}
// 保存狀態
CSession::set('user', $userData);
$result = array('status' => true, 'urlPram' => array('c' => 'admin', 'a' => 'index'));
// 返回數據
return $result;
}