本文整理汇总了PHP中ISafe::set方法的典型用法代码示例。如果您正苦于以下问题:PHP ISafe::set方法的具体用法?PHP ISafe::set怎么用?PHP ISafe::set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISafe
的用法示例。
在下文中一共展示了ISafe::set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onCreateController
/**
* @brief theme和skin进行选择
*/
public static function onCreateController()
{
$controller = func_num_args() > 0 && func_get_arg(0) ? func_get_arg(0) : IWeb::$app->controller;
/**
* 对于theme和skin的判断流程
* 1,直接从URL中获取是否已经设定了方案__theme,__skin
* 2,从cookie获取数据
*/
$urlTheme = IReq::get('__theme');
$urlSkin = IReq::get('__skin');
if ($urlTheme && $urlSkin && preg_match('|^\\w+$|', $urlTheme) && preg_match('|^\\w+$|', $urlSkin)) {
ISafe::set('__theme', $theme = $urlTheme);
ISafe::set('__skin', $skin = $urlSkin);
} elseif (ISafe::get('__theme') && ISafe::get('__skin')) {
$theme = ISafe::get('__theme');
$skin = ISafe::get('__skin');
}
if (isset($theme) && isset($skin)) {
$themePath = IWeb::$app->getViewPath() . $theme . "/" . IWeb::$app->controller->getId();
if (is_dir($themePath)) {
$controller->theme = $theme;
$controller->skin = $skin;
}
}
}
示例2: login
/**
* @brief 商家登录动作
*/
public function login()
{
$seller_name = IFilter::act(IReq::get('username'));
$password = IReq::get('password');
$message = '';
if ($seller_name == '') {
$message = '登录名不能为空';
} else {
if ($password == '') {
$message = '密码不能为空';
} else {
$sellerObj = new IModel('seller');
$sellerRow = $sellerObj->getObj('seller_name = "' . $seller_name . '" and is_del = 0 and is_lock = 0');
if ($sellerRow && $sellerRow['password'] == md5($password)) {
$dataArray = array('login_time' => ITime::getDateTime());
$sellerObj->setData($dataArray);
$where = 'id = ' . $sellerRow["id"];
$sellerObj->update($where);
//存入私密数据
ISafe::set('seller_id', $sellerRow['id']);
ISafe::set('seller_name', $sellerRow['seller_name']);
ISafe::set('seller_pwd', $sellerRow['password']);
$this->redirect('/seller/index');
} else {
$message = '用户名与密码不匹配';
}
}
}
if ($message != '') {
$this->redirect('index', false);
Util::showMessage($message);
}
}
示例3: user_ico_upload
function user_ico_upload()
{
$user_id = ISafe::get('user_id');
$result = array('isError' => true);
if (isset($_FILES['attach']['name']) && $_FILES['attach']['name'] != '') {
$photoObj = new PhotoUpload();
$photoObj->setThumb(100, 100, 'user_ico');
$photo = $photoObj->run();
if (!empty($photo['attach']['thumb']['user_ico'])) {
$user_id = ISafe::get('user_id');
$user_obj = new IModel('user');
$dataArray = array('head_ico' => $photo['attach']['thumb']['user_ico']);
$user_obj->setData($dataArray);
$where = 'id = ' . $user_id;
$isSuss = $user_obj->update($where);
if ($isSuss !== false) {
$result['isError'] = false;
$result['data'] = IUrl::creatUrl() . $photo['attach']['thumb']['user_ico'];
ISafe::set('head_ico', $dataArray['head_ico']);
} else {
$result['message'] = '上传失败';
}
} else {
$result['message'] = '上传失败';
}
} else {
$result['message'] = '请选择图片';
}
echo '<script type="text/javascript">parent.callback_user_ico(' . JSON::encode($result) . ');</script>';
}
示例4: getAuthorize
/**
* 获取版权信息,存储到缓存中进行比对
* @return boolean
*/
public static function getAuthorize()
{
$iwebshopAuthorize = ISafe::get('iwebshopAuthorize');
if ($iwebshopAuthorize === null) {
$return = self::send('_c=system&_a=authorize&host=' . IUrl::getHost());
$iwebshopAuthorize = isset($return['success']) && $return['success'] == 1 ? true : false;
ISafe::set('iwebshopAuthorize', $iwebshopAuthorize);
}
return $iwebshopAuthorize;
}
示例5: onCreateController
/**
* @brief theme和skin进行选择
*/
public static function onCreateController()
{
$controller = func_num_args() > 0 ? func_get_arg(0) : IWeb::$app->controller;
//判断是否为后台管理控制器
if (in_array($controller->getId(), self::$syscontroller)) {
defined("IWEB_SCENE") ? "" : define("IWEB_SCENE", self::SCENE_SYSDEFAULT);
$controller->theme = self::$sysTheme;
$controller->skin = self::$sysSkin;
} elseif (in_array($controller->getId(), self::$sellercontroller)) {
defined("IWEB_SCENE") ? "" : define("IWEB_SCENE", self::SCENE_SYSSELLER);
$controller->theme = self::$sysSellerTheme;
$controller->skin = self::$sysSellerSkin;
} else {
defined("IWEB_SCENE") ? "" : define("IWEB_SCENE", self::SCENE_SITE);
/**
* 对于theme和skin的判断流程
* 1,直接从URL中获取是否已经设定了方案__theme,__skin
* 2,获取cookie中的方案名称
* 3,读取config配置中的默认方案
*/
$urlTheme = IReq::get('__theme');
$urlSkin = IReq::get('__skin');
if ($urlTheme && $urlSkin && preg_match('|^\\w+$|', $urlTheme) && preg_match('|^\\w+$|', $urlSkin)) {
ISafe::set('__theme', $controller->theme = $urlTheme);
ISafe::set('__skin', $controller->skin = $urlSkin);
} elseif (ISafe::get('__theme') && ISafe::get('__skin')) {
$controller->theme = ISafe::get('__theme');
$controller->skin = ISafe::get('__skin');
} else {
if (isset(IWeb::$app->config['theme'])) {
//根据不同的客户端进行智能选择
if (is_array(IWeb::$app->config['theme'])) {
$client = IClient::getDevice();
$controller->theme = isset(IWeb::$app->config['theme'][$client]) ? IWeb::$app->config['theme'][$client] : current(IWeb::$app->config['theme']);
} else {
$controller->theme = IWeb::$app->config['theme'];
}
}
if (isset(IWeb::$app->config['skin'])) {
//根据不同的客户端进行智能选择
if (is_array(IWeb::$app->config['skin'])) {
$client = IClient::getDevice();
$controller->skin = isset(IWeb::$app->config['skin'][$client]) ? IWeb::$app->config['skin'][$client] : current(IWeb::$app->config['skin']);
} else {
$controller->skin = IWeb::$app->config['skin'];
}
}
}
}
//修正runtime配置
IWeb::$app->runtimePath = IWeb::$app->getRuntimePath() . $controller->theme . '/';
IWeb::$app->webRunPath = IWeb::$app->getWebRunPath() . $controller->theme . '/';
}
示例6: login_act
function login_act()
{
$admin_name = IFilter::act(IReq::get('admin_name'));
$password = IReq::get('password');
$captcha = IReq::get('captcha', 'post');
$message = '';
if ($admin_name == '') {
$message = '登录名不能为空';
} else {
if ($password == '') {
$message = '密码不能为空';
} else {
if ($captcha != ISafe::get('Captcha')) {
$message = '验证码输入不正确';
} else {
$adminObj = new IModel('admin');
$adminRow = $adminObj->getObj('admin_name = "' . $admin_name . '"');
if (!empty($adminRow) && $adminRow['password'] == md5($password) && $adminRow['is_del'] == 0) {
$dataArray = array('last_ip' => IClient::getIp(), 'last_time' => ITime::getDateTime());
$adminObj->setData($dataArray);
$where = 'id = ' . $adminRow["id"];
$adminObj->update($where);
//根据角色分配权限
if ($adminRow['role_id'] == 0) {
ISafe::set('admin_right', 'administrator');
ISafe::set('admin_role_name', '超级管理员');
} else {
$roleObj = new IModel('admin_role');
$where = 'id = ' . $adminRow["role_id"] . ' and is_del = 0';
$roleRow = $roleObj->getObj($where);
ISafe::set('admin_right', $roleRow['rights']);
ISafe::set('admin_role_name', $roleRow['name']);
}
ISafe::set('admin_id', $adminRow['id']);
ISafe::set('admin_name', $adminRow['admin_name']);
ISafe::set('admin_pwd', $adminRow['password']);
$this->redirect('/system/default');
} else {
$message = '用户名与密码不匹配';
}
}
}
}
if ($message != '') {
$this->admin_name = $admin_name;
$this->redirect('index', false);
Util::showMessage($message);
}
}
示例7: getCaptcha
/**
* @brief 生成验证码
* @return image图像
*/
public function getCaptcha()
{
//清空布局
$this->layout = '';
//配置参数
$width = IReq::get('w') ? IReq::get('w') : 130;
$height = IReq::get('h') ? IReq::get('h') : 45;
$wordLength = IReq::get('l') ? IReq::get('l') : 5;
$fontSize = IReq::get('s') ? IReq::get('s') : 25;
//创建验证码
$ValidateObj = new Captcha();
$ValidateObj->width = $width;
$ValidateObj->height = $height;
$ValidateObj->maxWordLength = $wordLength;
$ValidateObj->minWordLength = $wordLength;
$ValidateObj->fontSize = $fontSize;
$ValidateObj->CreateImage($text);
//设置验证码
ISafe::set('captcha', $text);
}
示例8: bindUser
public function bindUser($userInfo, $oauthId)
{
$oauthUserObj = new IModel('oauth_user');
$oauthUserRow = $oauthUserObj->getObj("oauth_user_id = '{$userInfo['id']}' and oauth_id = '{$oauthId}' ", 'user_id');
//没有绑定账号
if (empty($oauthUserRow)) {
$userObj = new IModel('user');
$userCount = $userObj->getObj("username = '{$userInfo['name']}'", 'count(*) as num');
//没有重复的用户名
if ($userCount['num'] == 0) {
$username = $userInfo['name'];
} else {
//随即分配一个用户名
$username = $userInfo['name'] . $userCount['num'];
}
ISafe::set('oauth_username', $username);
ISession::set('oauth_id', $oauthId);
ISession::set('oauth_userInfo', $userInfo);
$this->redirect('bind_user');
} else {
$userObj = new IModel('user');
$tempRow = $userObj->getObj("id = '{$oauthUserRow['user_id']}'");
$userRow = CheckRights::isValidUser($tempRow['username'], $tempRow['password']);
CheckRights::loginAfter($userRow);
//自定义跳转页面
$callback = ISafe::get('callback');
if ($callback && !strpos($callback, 'reg') && !strpos($callback, 'login')) {
$this->redirect($callback);
} else {
$this->redirect('/ucenter/index');
}
}
}
示例9: password_edit
function password_edit()
{
$user_id = $this->user['user_id'];
$fpassword = IReq::get('fpassword');
$password = IReq::get('password');
$repassword = IReq::get('repassword');
$userObj = new IModel('user');
$where = 'id = ' . $user_id;
$userRow = $userObj->getObj($where);
if (!preg_match('|\\w{6,32}|', $password)) {
$message = '密码格式不正确,请重新输入';
} else {
if ($password != $repassword) {
$message = '二次密码输入的不一致,请重新输入';
} else {
if (md5($fpassword) != $userRow['password']) {
$message = '原始密码输入错误';
} else {
$passwordMd5 = md5($password);
$dataArray = array('password' => $passwordMd5);
$userObj->setData($dataArray);
$result = $userObj->update($where);
if ($result) {
ISafe::set('user_pwd', $passwordMd5);
$message = '密码修改成功';
} else {
$message = '密码修改失败';
}
}
}
}
$this->redirect('password', false);
Util::showMessage($message);
}
示例10: products
function products()
{
$date = array();
//接收商品id
if (IReq::get('id') === null) {
IError::show(403, "传递的参数不正确");
}
$goods_id = IFilter::act(IReq::get('id'), 'int');
//使用商品id获得商品信息
$tb_goods = new IModel('goods');
$goods_info = $tb_goods->query('id=' . $goods_id . " AND is_del=0");
if (count($goods_info) > 0) {
$date = $goods_info[0];
$date['content1'] = $goods_info[0]['content'];
//品牌名称
$tb_brand = new IModel('brand');
$brand_info = $tb_brand->query('id=' . $date['brand_id']);
if (count($brand_info) > 0) {
$date['brand'] = $brand_info[0]['name'];
}
} else {
IError::show(403, "这件商品不存在");
}
//获取商品分类
$categoryObj = new IModel('category_extend as ca,category as c');
$categoryRow = $categoryObj->getObj('ca.goods_id = ' . $goods_id . ' and ca.category_id = c.id', 'c.id,c.name');
$date['category'] = $categoryRow;
//获得省份
$tb_areas = new IQuery('areas');
$tb_areas->where = 'parent_id=0';
$areas_info = $tb_areas->find();
$date['city'] = $areas_info;
//获得规格
$tb_goods_attribute = new IQuery('goods_attribute');
$tb_goods_attribute->fields = ' spec_id ';
$tb_goods_attribute->group = ' spec_id ';
$tb_goods_attribute->where = " goods_id='" . $goods_id . "' and spec_id!='' ";
$attribute_info = $tb_goods_attribute->find();
if (count($attribute_info) > 0) {
$spec_ids = array();
$i = 0;
$tb_attribute = new IQuery('goods_attribute');
$ids = '';
foreach ($attribute_info as $value) {
$tb_attribute->fields = ' spec_value,spec_id ';
$tb_attribute->where = ' goods_id=' . $date['id'] . ' and spec_id=' . $value['spec_id'];
$tb_info = $tb_attribute->find();
$spec_ids[$i]['value'] = $tb_info;
//获得规格名
$tb_spec = new IQuery('spec');
$tb_spec->fields = 'name';
$tb_spec->where = 'id=' . $value['spec_id'];
$spec_info = $tb_spec->find();
if (count($spec_info) > 0) {
$spec_ids[$i]['name'] = $spec_info[0]['name'];
}
$i++;
$ids .= $value['spec_id'] . ',';
}
$date['spec_ids'] = $spec_ids;
$date['ids'] = $ids;
}
//商品图片
$tb_goods_photo = new IQuery('goods_photo_relation as g');
$tb_goods_photo->fields = 'p.id AS photo_id,p.img ';
$tb_goods_photo->join = 'left join goods_photo as p on p.id=g.photo_id ';
$tb_goods_photo->where = ' g.goods_id=' . $goods_id;
$photo_info = $tb_goods_photo->find();
//清除已经不存在的图片
foreach ($photo_info as $key => $value) {
if (!isset($value['photo_id']) || !isset($value['img']) || $value['photo_id'] == null || $value['img'] == null) {
unset($photo_info[$key]);
}
$absolute_img = IWeb::$app->getBasePath();
$absolute_img = $absolute_img . "./" . $value['img'];
if (!file_exists($absolute_img)) {
unset($photo_info[$key]);
}
}
if (count($photo_info) > 0) {
//把默认图片调到第一个
$goods_img = $goods_info[0]['img'];
$tmp = array();
foreach ($photo_info as $key => $value) {
if ($value['img'] == $goods_img) {
$tmp[] = $value;
unset($photo_info[$key]);
}
}
$tmp = array_merge($tmp, $photo_info);
$photo_info = $tmp;
}
$date['photo'] = $photo_info;
//商品是否参加活动 ---抢购
$date['active'] = IReq::get('promo') ? IReq::get('promo') : '';
if ($date['active']) {
//商品参加活动 ---抢购
$tb_promotion = new IQuery('promotion as p');
$tb_promotion->fields = ' award_value,end_time,user_group ';
$tb_promotion->where = 'type=1 and `condition`=' . $goods_id . ' and NOW() between start_time and end_time';
//.........这里部分代码省略.........
示例11: buy
/**
* 列表展示
* @author keenhome@126.com
* @date 2013-4-30
*/
public function buy()
{
$gid = IFilter::act(IReq::get('gid'), 'int');
$tb_goods = new IModel('goods');
//增加点击次数
if (!ISafe::get('visit' . $gid)) {
$tb_goods->setData(array('click' => 'click + 1'));
$tb_goods->update('id = ' . $gid, 'click');
ISafe::set('click' . $gid, '1');
}
$goodsRow = $tb_goods->getObj('ID = ' . $gid, 'url');
if (count($goodsRow) > 0 && $goodsRow['url']) {
header("Location:" . $goodsRow['url']);
} else {
header("Location:/");
}
}
示例12: loginAfter
/**
* @brief 登录后的处理
* @param array $userRow 用户数组信息
*/
public static function loginAfter($userRow)
{
//用户私密数据
ISafe::set('user_id', $userRow['id']);
ISafe::set('username', $userRow['username']);
ISafe::set('head_ico', $userRow['head_ico']);
ISafe::set('user_pwd', $userRow['password']);
ISafe::set('last_login', isset($userRow['last_login']) ? $userRow['last_login'] : '');
//更新最后一次登录时间
$memberObj = new IModel('member');
$dataArray = array('last_login' => ITime::getDateTime());
$memberObj->setData($dataArray);
$where = 'user_id = ' . $userRow["id"];
$memberObj->update($where);
$memberRow = $memberObj->getObj($where, 'exp');
//根据经验值分会员组
$groupObj = new IModel('user_group');
$groupRow = $groupObj->getObj($memberRow['exp'] . ' between minexp and maxexp and minexp > 0 and maxexp > 0', 'id', 'discount', 'desc');
if (!empty($groupRow)) {
$dataArray = array('group_id' => $groupRow['id']);
$memberObj->setData($dataArray);
$memberObj->update('user_id = ' . $userRow["id"]);
}
}
示例13: admin_repwd_act
/**
*修改管理员密码
*/
function admin_repwd_act()
{
//提取密码 [ 密码设置 ]
$password = IReq::get('password', 'post');
$repassword = IReq::get('repassword', 'post');
if ($password && $password === $repassword) {
$passwordMd5 = md5($password);
$adminObj = new IModel('admin');
$adminObj->setData(array('password' => $passwordMd5));
$adminObj->update('id = ' . $this->admin['admin_id']);
//同步更新safe
ISafe::set('admin_pwd', $passwordMd5);
$this->redirect('default');
} else {
$message = '密码不能为空,并且二次输入的必须一致';
$this->redirect('admin_repwd', false);
Util::showMessage($message);
}
}
示例14: bindUser
public function bindUser($userInfo, $oauthId)
{
$oauthUserObj = new IModel('oauth_user');
$oauthUserRow = $oauthUserObj->getObj("oauth_user_id = '{$userInfo['id']}' and oauth_id = '{$oauthId}' ", 'user_id');
//没有绑定账号
if (empty($oauthUserRow)) {
$userObj = new IModel('user');
$userCount = $userObj->getObj("username = '{$userInfo['name']}'", 'count(*) as num');
//没有重复的用户名
if ($userCount['num'] == 0) {
$username = $userInfo['name'];
} else {
//随即分配一个用户名
$username = $userInfo['name'] . $userCount['num'];
}
ISafe::set('oauth_username', $username);
ISession::set('oauth_id', $oauthId);
ISession::set('oauth_userInfo', $userInfo);
$this->redirect('bind_user');
} else {
$userObj = new IModel('user');
$userRow = $userObj->getObj("id = '{$oauthUserRow['user_id']}'");
$this->loginAfter($userRow);
//自定义跳转页面
$callback = ISafe::get('callback');
if ($callback != null && $callback != '' && $callback != "/simple/reg" && $callback != "/simple/login") {
$this->redirect($callback);
} else {
$this->redirect('/ucenter/index');
}
}
}
示例15: admin_edit_act
function admin_edit_act()
{
$id = IFilter::act(IReq::get('id', 'post'));
$adminObj = new IModel('admin');
//错误信息
$message = null;
$dataArray = array('id' => $id, 'admin_name' => IFilter::string(IReq::get('admin_name', 'post')), 'role_id' => IFilter::act(IReq::get('role_id', 'post')), 'email' => IFilter::string(IReq::get('email', 'post')));
//检查管理员name唯一性
$isPass = $this->check_admin($dataArray['admin_name'], $id);
if ($isPass == false) {
$message = $dataArray['admin_name'] . '管理员已经存在,请更改名字';
}
//提取密码 [ 密码设置 ]
$password = IReq::get('password', 'post');
$repassword = IReq::get('repassword', 'post');
//修改操作
if ($id) {
if ($password != null || $repassword != null) {
if ($password == null || $repassword == null || $password != $repassword) {
$message = '密码不能为空,并且二次输入的必须一致';
} else {
$dataArray['password'] = md5($password);
}
}
//有错误
if ($message != null) {
$this->adminRow = $dataArray;
$this->redirect('admin_edit', false);
Util::showMessage($message);
} else {
$where = 'id = ' . $id;
$adminObj->setData($dataArray);
$adminObj->update($where);
//同步更新safe
ISafe::set('admin_name', $dataArray['admin_name']);
ISafe::set('admin_pwd', $dataArray['password']);
}
} else {
if ($password == null || $repassword == null || $password != $repassword) {
$message = '密码不能为空,并且二次输入的必须一致';
} else {
$dataArray['password'] = md5($password);
}
if ($message != null) {
$this->adminRow = $dataArray;
$this->redirect('admin_edit', false);
Util::showMessage($message);
} else {
$dataArray['create_time'] = ITime::getDateTime();
$adminObj->setData($dataArray);
$adminObj->add();
}
}
$this->redirect('admin_list');
}