本文整理汇总了PHP中tools::val方法的典型用法代码示例。如果您正苦于以下问题:PHP tools::val方法的具体用法?PHP tools::val怎么用?PHP tools::val使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tools
的用法示例。
在下文中一共展示了tools::val方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionIndex
public function actionIndex()
{
$action = tools::val('action', 't');
//操作类型,是登录、注册还是绑定
if (!in_array($action, array('login', 'reg', 'bind'))) {
throw new CHttpException(403, '缺少参数');
}
if (in_array($action, array('login', 'reg')) && zmf::uid()) {
$this->message(0, '您已登录,请勿该操作', $this->referer);
} elseif ($action == 'bind' && !zmf::uid()) {
$this->redirect(array('site/login'));
}
zmf::setCookie('lastWeiboAction', $action, $this->cookieTime);
$code_url = $this->weiboService->getAuthorizeURL($this->WB_CALLBACK_URL);
$this->redirect($code_url);
}
示例2: checkApp
public function checkApp()
{
$code = tools::val('appcode', 1);
$time = tools::val('time', 1);
$version = tools::val('version', 1);
$platform = strtolower(tools::val('platform', 1));
if (!$code || !$time || !$platform || !$version) {
self::output(self::getErrorInfo('notInService'), 403);
}
if ($platform == 'ios') {
$_code = $this->iosKey;
$this->appPlatform = 'ios';
} else {
$_code = $this->androidKey;
$this->appPlatform = 'android';
}
$this->appCode = $_code;
$this->version = $version;
if (md5($time . $_code) != $code) {
self::output(self::getErrorInfo('dataIncorrect'), 403);
}
}
示例3: actionUpdate
public function actionUpdate($type)
{
if (!in_array($type, array('info', 'passwd', 'tags'))) {
$this->message(0, '您的操作有误');
}
if (isset($_POST) and !empty($_POST)) {
$model = new Users();
if ($type == 'info') {
$intoData['truename'] = zmf::filterInput($_POST['truename'], 't', 1);
if (!$intoData['truename']) {
$this->message(0, '用户名不能为空');
}
//如果用户修改了用户名,则判断是否被使用
if ($intoData['truename'] != $this->userInfo['truename']) {
$info = Users::getInfoByName($intoData['truename']);
if ($info) {
$this->message(0, '该用户名已被使用');
}
}
$intoData['sex'] = tools::val('sex');
$intoData['areaid'] = tools::val('areaid');
$intoData['content'] = zmf::filterInput($_POST['desc'], 't', 1);
} elseif ($type == 'passwd') {
$old = zmf::filterInput($_POST['old_password'], 't', 1);
$info = Users::model()->findByPk($this->uid);
if (!$old) {
$this->message(0, '请输入原始密码');
} elseif (md5($old) != $info['password']) {
$this->message(0, '原始密码不正确');
}
if (!$_POST['password']) {
$this->message(0, '请输入密码');
} elseif (strlen($_POST['password']) < 5) {
$this->message(0, '新密码过短,请重新输入');
}
$intoData['password'] = md5($_POST['password']);
} elseif ($type == 'tags') {
//相关标签
$tags = $_POST['tagnames'];
$tags = !empty($tags) ? array_unique(array_filter($tags)) : array();
$tagids = array();
if (!empty($tags)) {
foreach ($tags as $str) {
$_tmp = explode('-', $str);
if ($_tmp[1] > 0) {
//添加对应关系
if (Tags::addRelation($_tmp[1], $this->uid, 'user')) {
$tagids[] = $_tmp[1];
}
} else {
//查找是否有对应话题
$_tagid = Tags::findAndAdd($_tmp[0], 'user', $this->uid);
if ($_tagid) {
$tagids[] = $_tagid;
}
}
}
$tagids = !empty($tagids) ? array_unique(array_filter($tagids)) : array();
}
$tagStr = join(',', $tagids);
$intoData['tagids'] = $tagStr;
}
zmf::delFCache("userInfo-{$this->uid}");
if ($model->updateByPk($this->uid, $intoData)) {
$this->message(1, '修改成功', Yii::app()->createUrl('users/config'));
} else {
$this->message(1, '修改成功', Yii::app()->createUrl('users/config'));
}
}
$suggestTags = array();
if ($type == 'tags') {
//推荐的标签
$suggestTags = Tags::getTops('posts');
}
$data = array('info' => $this->userInfo, 'type' => $type, 'suggestTags' => $suggestTags);
$this->render('update', $data);
}
示例4: actionUpdate
public function actionUpdate($type)
{
if (!in_array($type, array('info', 'passwd'))) {
$this->message(0, '您的操作有误');
}
if (isset($_POST) and !empty($_POST)) {
$model = new Users();
if ($type == 'info') {
$intoData['username'] = zmf::filterInput($_POST['username'], 't', 1);
if (!$intoData['username']) {
$this->message(0, '用户名不能为空');
}
//如果用户修改了用户名,则判断是否被使用
if ($intoData['username'] != $this->userInfo['username']) {
$info = Users::getInfoByName($intoData['username']);
if ($info) {
$this->message(0, '该用户名已被使用');
}
}
$intoData['sex'] = tools::val('sex');
$desc = zmf::filterInput($_POST['desc'], 't', 1);
$desc = zmf::subStr($desc, 32, 0, '');
} elseif ($type == 'passwd') {
$old = zmf::filterInput($_POST['old_password'], 't', 1);
$info = Users::model()->findByPk($this->uid);
if (!$old) {
$this->message(0, '请输入原始密码');
} elseif (md5($old) != $info['password']) {
$this->message(0, '原始密码不正确');
}
if (!$_POST['password']) {
$this->message(0, '请输入密码');
} elseif (strlen($_POST['password']) < 5) {
$this->message(0, '新密码过短,请重新输入');
}
$intoData['password'] = md5($_POST['password']);
}
if ($model->updateByPk($this->uid, $intoData)) {
if ($type == 'info' && $desc) {
UserInfo::addAttr($this->uid, 'info', 'desc', $desc);
}
$this->message(1, '修改成功', Yii::app()->createUrl('users/config'));
} else {
if ($type == 'info' && $desc) {
UserInfo::addAttr($this->uid, 'info', 'desc', $desc);
}
$this->message(1, '修改成功', Yii::app()->createUrl('users/config'));
}
}
$data = array('info' => $this->userInfo, 'type' => $type);
$this->render('update', $data);
}
示例5: actionLogin
public function actionLogin($from = '')
{
if (!Yii::app()->user->isGuest) {
$this->message(0, '您已登录,请勿重复操作');
}
if (!$from) {
$from = 'login';
}
$bind = tools::val('bind', 't');
$model = new LoginForm();
//登录
$modelUser = new Users();
//注册
if ($bind == 'weibo') {
$strdata = zmf::getCookie('userWeiboData');
//取出cookie中用户的微博信息
if ($strdata) {
$data = unserialize($strdata);
$modelUser->truename = $data['screen_name'];
}
} elseif ($bind == 'qq') {
$strdata = zmf::getCookie('userQQData');
//取出cookie中用户的微博信息
if ($strdata) {
$data = unserialize($strdata);
$modelUser->truename = $data['nickname'];
}
} elseif ($bind == 'weixin') {
$strdata = zmf::getCookie('userWeixinData');
//取出cookie中用户的微博信息
if ($strdata) {
$data = unserialize($strdata);
$modelUser->truename = $data['nickname'];
}
}
if (isset($_POST['ajax']) && $_POST['ajax'] === 'login-form') {
echo CActiveForm::validate($model);
Yii::app()->end();
}
if (isset($_POST['ajax']) && $_POST['ajax'] === 'users-addUser-form') {
echo CActiveForm::validate($modelUser);
Yii::app()->end();
}
//登录
if (isset($_POST['LoginForm'])) {
$from = 'login';
$model->attributes = $_POST['LoginForm'];
if ($model->validate()) {
$hasBind = false;
//判断是否绑定过微博
if ($bind == 'weibo') {
$strdata = zmf::getCookie('userWeiboData');
//取出cookie中用户的微博信息
if (!$strdata) {
$model->addError('email', '未能获取微博绑定信息,请重试');
} else {
$binddata = unserialize($strdata);
}
//根据当前用户名获取他是否已经绑定过
$email = $_POST['LoginForm']['email'];
$validator = new CEmailValidator();
if ($validator->validateValue($email)) {
$user = Users::model()->find('email=:email', array(':email' => $email));
} else {
$user = Users::model()->find('truename=:truename', array(':truename' => $email));
}
if ($user) {
$bindInfo = UserSina::model()->findByPk($user['id']);
if ($bindInfo) {
$hasBind = true;
}
$binddata['uid'] = $user['id'];
}
} elseif ($bind == 'qq') {
$strdata = zmf::getCookie('userQQData');
//取出cookie中用户的微博信息
if (!$strdata) {
$model->addError('email', '未能获取微博绑定信息,请重试');
} else {
$binddata = unserialize($strdata);
}
//根据当前用户名获取他是否已经绑定过
$email = $_POST['LoginForm']['email'];
$validator = new CEmailValidator();
if ($validator->validateValue($email)) {
$user = Users::model()->find('email=:email', array(':email' => $email));
} else {
$user = Users::model()->find('truename=:truename', array(':truename' => $email));
}
if ($user) {
$bindInfo = UserQq::model()->findByPk($user['id']);
if ($bindInfo) {
$hasBind = true;
}
$binddata['uid'] = $user['id'];
}
} elseif ($bind == 'weixin') {
$strdata = zmf::getCookie('userWeixinData');
//取出cookie中用户的微博信息
if (!$strdata) {
//.........这里部分代码省略.........
示例6: floatNavUrl
public static function floatNavUrl($title, $areaid, $htmlOptions = array())
{
$c = Yii::app()->getController()->id;
$a = Yii::app()->getController()->getAction()->id;
if (in_array($c, array('posts'))) {
return CHtml::link($title, $areaid ? array('posts/story', 'areaid' => $areaid) : 'javascript:;', $htmlOptions);
} elseif (in_array($c, array('question'))) {
return CHtml::link($title, $areaid ? array('question/index', 'areaid' => $areaid) : 'javascript:;', $htmlOptions);
} elseif (in_array($c, array('position', 'poipost'))) {
return CHtml::link($title, $areaid ? array('position/index', 'areaid' => $areaid) : 'javascript:;', $htmlOptions);
} elseif (in_array($c, array('travel'))) {
return CHtml::link($title, $areaid ? array('travel/index', 'areaid' => $areaid) : 'javascript:;', $htmlOptions);
} elseif (in_array($c, array('yueban'))) {
return CHtml::link($title, $areaid ? array('yueban/index', 'areaid' => $areaid, 'year' => tools::val('year'), 'month' => tools::val('month'), 'day' => tools::val('day')) : 'javascript:;', $htmlOptions);
} elseif (in_array($c, array('goods'))) {
return CHtml::link($title, $areaid ? array('goods/index', 'areaid' => $areaid) : 'javascript:;', $htmlOptions);
} else {
return CHtml::link($title, $areaid ? array('index/show', 'areaid' => $areaid) : 'javascript:;', $htmlOptions);
}
}
示例7: actionMedia
public function actionMedia()
{
$id = tools::val('id');
if (!$id || !is_numeric($id)) {
throw new CHttpException(404, 'The requested page does not exist.');
}
$userInfo = Users::getUserInfo($id);
if (!$userInfo || $userInfo['status'] != Posts::STATUS_PASSED) {
throw new CHttpException(404, '您所查看的页面不存在或已删除');
}
$criteria = new CDbCriteria();
$criteria->order = 'hits DESC';
// $criteria->select='id,truename,`desc`,avatar,posts,hits';
$criteria->condition = "uid='{$id}' AND status=" . Posts::STATUS_PASSED;
$count = Naodong::model()->count($criteria);
$pager = new CPagination($count);
$pager->pageSize = $this->pageSize;
$pager->applyLimit($criteria);
$posts = Naodong::model()->findAll($criteria);
$posts = self::foreachNaodong($posts);
Posts::updateCount($id, 'Users');
$this->pageTitle = $userInfo['truename'] . ' - ' . zmf::config('sitename');
$this->mobileTitle = $userInfo['truename'];
$this->pageDescription = $userInfo['desc'] != '' ? $userInfo['desc'] : zmf::config('siteDesc');
$this->render('media', array('pages' => $pager, 'posts' => $posts, 'userInfo' => $userInfo));
}
示例8: actionMergecookie
/**
* 合并用户关注的地区
*/
public function actionMergecookie()
{
$type = tools::val('type', 't', 1);
if (!in_array($type, array('add', 'del'))) {
$this->jsonOutPut(0, '不允许的类型');
}
$uid = zmf::uid();
switch ($type) {
case 'add':
$this->checkLogin();
$cache = zmf::getCookie('myLikeAreas');
if ($cache) {
//取出只存在于cookie的地区id
$items = AreaLikes::model()->findAll(array('select' => 'logid', 'condition' => "uid={$uid} AND logid NOT IN({$cache})"));
$ids = array_keys(CHtml::listData($items, 'logid', ''));
if (!empty($ids)) {
$extraInfo = Users::getExtra($this->userInfo);
if ($extraInfo['likeAreas']) {
$arr = explode(',', $extraInfo['likeAreas']);
}
foreach ($ids as $id) {
$attr = array('uid' => $uid, 'logid' => $id);
$model = new AreaLikes();
$model->attributes = $attr;
if ($model->save()) {
$arr[] = $id;
}
}
$arr = array_unique(array_filter($arr));
$extraInfo['likeAreas'] = join(',', $arr);
Users::updateExtra($uid, $extraInfo);
}
}
zmf::delCookie('myLikeAreas');
$this->jsonOutPut(1, '合并成功');
break;
case 'del':
zmf::delCookie('myLikeAreas');
$this->jsonOutPut(1, '删除成功');
break;
}
}