本文整理汇总了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;
}