本文整理汇总了PHP中user函数的典型用法代码示例。如果您正苦于以下问题:PHP user函数的具体用法?PHP user怎么用?PHP user使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了user函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionCreate
public function actionCreate($adid = 0, $id = 0)
{
$id = (int) $id;
$adid = (int) $adid;
if ($adid > 0) {
$advert = AdminAdvert::model()->findByPk($adid);
if ($advert === null) {
throw new CHttpException(404, t('advert_is_not_exist', 'admin'));
}
}
if ($id > 0) {
$model = AdminAdcode::model()->findByPk($id);
$this->adminTitle = t('edit_adcode', 'admin');
} else {
$model = new AdminAdcode();
$model->ad_id = $adid;
$this->adminTitle = t('create_adcode', 'admin');
}
if (request()->getIsPostRequest() && isset($_POST['AdminAdcode'])) {
$model->attributes = $_POST['AdminAdcode'];
if ($model->save()) {
user()->setFlash('save_adcode_result', t('save_adcode_success', 'admin'));
$model->advert->clearCache();
$this->redirect(request()->getUrl());
}
}
$this->render('create', array('model' => $model));
}
示例2: Process
function Process()
{
$this->CheckAdminPrivs('refund');
$id = get('id', 'number');
$order = logic('order')->GetOne($id);
if (!$order)
{
$this->Messager(__('找不到相关订单!'), '?mod=order');
}
$user = user($order['userid'])->get();
$payment = logic('pay')->SrcOne($order['paytype']);
$paylog = logic('pay')->GetLog($order['orderid'], $order['userid']);
$coupons = logic('coupon')->SrcList($order['userid'], $order['orderid'], TICK_STA_ANY);
$express = logic('express')->SrcOne($order['expresstype']);
$address = logic('address')->GetOne($order['addressid']);
$refund = logic('refund')->GetOne($order['orderid']);
$order['ypaymoney'] = ($order['totalprice'] > $order['paymoney']) ? number_format(($order['totalprice'] - $order['paymoney']),2) : 0;
$order['tpaymoney'] = $order['totalprice'];
if($order['product']['type'] == 'ticket'){
$coupo = logic('coupon')->SrcList($order['userid'], $id);
if($order['productnum'] != count($coupo) && $coupo[0]['mutis'] == 1){
$order['tpaymoney'] = count($coupo)*$order['productprice'];
$order['tmsg'] = array(
'money' => $order['paymoney'],
'tnum' => $order['productnum'],
'num' => $order['productnum']-count($coupo)
);
}
}
include handler('template')->file('@admin/refund_process');
}
示例3: view
public function view($id)
{
$get_thread = $this->model_thread->get_thread($id);
foreach ($get_thread as $t) {
$data = array('idCategory' => $t->category, 'category' => $t->category_name, 'topic' => $t->topicName, 'user' => $t->author, 'tanggal' => $t->created_at, 'title' => $t->title, 'status' => $t->status, 'message' => BBCodeParser($t->message));
}
$user = sentinel()->getUser();
if ($this->checkTA() == TRUE) {
$data['tenagaAhli'] = $user->id;
$data['draftSide'] = $this->model_thread->get_all_drafts($user->id);
}
$data['author'] = user($user->id)->full_name;
$data['home'] = site_url('author/');
$data['categoriesSide'] = $this->model_thread->get_categories();
$data['threadSide'] = $this->model_thread->get_thread_from_author($user->id);
$data['closeThreads'] = $this->model_thread->get_close_threads($user->id);
$data['threadSide'] = $this->model_thread->get_thread_from_author($user->id);
$data['closeThreads'] = $this->model_thread->get_close_threads($user->id);
$data['authorSide'] = $this->model_thread->get_thread_from_author($user->id);
$data['reply'] = $this->model_thread->get_reply($id);
$data['countReply'] = count($data['reply']);
$data['id'] = $id;
if ($this->session->flashdata('success')) {
$data['success'] = $this->session->flashdata('success');
} elseif ($this->session->flashdata('failed')) {
$data['failed'] = $this->session->flashdata('failed');
}
$this->load->view('thread/single', $data);
}
示例4: login
public function login()
{
$account_model = new AccountsModel();
if ($account_model->login($_POST['email'], $_POST['password'])) {
//处理自动登录
if (!empty($_POST['remember'])) {
$login_email = user('email');
$login_key = md5($login_email . rand(0, 10000) . time() . SALT_KEY);
$login_token = md5($login_key . SALT_KEY . user('password'));
setcookie("ngo20_login_email", $login_email, time() + 3600 * 24 * 14);
setcookie("ngo20_login_key", $login_key, time() + 3600 * 24 * 14);
setcookie("ngo20_login_token", $login_token, time() + 3600 * 24 * 14);
}
if (user('is_admin')) {
// $this->redirect('Admin/users/');
echo 'admin';
} else {
// $this->redirect('User/home/');
echo 'ok';
}
//
} else {
//login failed
echo '用户名或密码不正确';
// flash('用户名或密码不正确');
// $this->redirect('Index/index/');
}
}
示例5: renderContent
protected function renderContent()
{
if (!user()->isGuest) {
$model = new UserChangePassForm();
// if it is ajax validation request
if (isset($_POST['ajax']) && $_POST['ajax'] === 'userchangepass-form') {
echo CActiveForm::validate($model);
Yii::app()->end();
}
// collect user input data
if (isset($_POST['UserChangePassForm'])) {
$model->attributes = $_POST['UserChangePassForm'];
// validate user input password
if ($model->validate()) {
$u = User::model()->findbyPk(user()->id);
if ($u !== null) {
$u->password = PassHash::hash($model->new_password_1);
if ($u->save()) {
user()->setFlash('success', t('cms', 'Changed Password Successfully!'));
}
}
$model = new UserChangePassForm();
}
}
$this->render('cmswidgets.views.user.user_change_pass_widget', array('model' => $model));
} else {
Yii::app()->request->redirect(user()->returnUrl);
}
}
示例6: user
function user($attr = null, $value = null)
{
if (!isset($_SESSION['login_user'])) {
return false;
}
if ($attr == 'local_map' && !isset($_SESSION['login_user']['local_map'])) {
$_SESSION['login_user']['local_map'] = T('local_map')->with('admin_id', user('id'))->select();
}
if ($attr === null) {
return true;
}
if ($value === null) {
// read user info
if ($attr == 'type_label') {
switch ($_SESSION['login_user']['type']) {
case 'ngo':
return '公益组织';
break;
case 'ind':
return '公益人';
break;
case 'csr':
return '企业';
break;
case 'fund':
return '基金会';
break;
}
}
return $_SESSION['login_user'][$attr];
} else {
//write user info
$_SESSION['login_user'][$attr] = $value;
}
}
示例7: updateConfiguration
/**
* Update the PHP FPM configuration to use the current user.
*
* @return void
*/
public function updateConfiguration()
{
$contents = $this->files->get($this->fpmConfigPath());
$contents = preg_replace('/^user = .+$/m', 'user = ' . user(), $contents);
$contents = preg_replace('/^group = .+$/m', 'group = staff', $contents);
$this->files->put($this->fpmConfigPath(), $contents);
}
示例8: renderContent
protected function renderContent()
{
$settings = GxcHelpers::getAvailableSettings();
$type = isset($_GET['type']) ? strtolower(plaintext($_GET['type'])) : 'general';
if (array_key_exists($type, $settings)) {
//Import the Setting Class
Yii::import('common.settings.' . $type . '.' . $settings[$type]['class']);
$model = new $settings[$type]['class']();
foreach ($model->attributes as $attr => $value) {
$model->{$attr} = Yii::app()->settings->get($type, $attr);
}
settings()->deleteCache();
// if it is ajax validation request
if (isset($_POST['ajax']) && $_POST['ajax'] === $type . '-settings-form') {
echo CActiveForm::validate($model);
Yii::app()->end();
}
// collect user input data
if (isset($_POST[$settings[$type]['class']])) {
settings()->deleteCache();
$model->attributes = $_POST[$settings[$type]['class']];
if ($model->validate()) {
foreach ($model->attributes as $key => $value) {
Yii::app()->settings->set($type, $key, $value);
}
user()->setFlash('success', t('cms', 'Settings Updated Successfully!'));
}
}
$this->render('common.settings.' . $type . '.' . $settings[$type]['layout'], array('model' => $model));
} else {
throw new CHttpException(404, t('cms', 'The requested page does not exist.'));
}
}
示例9: level_require
function level_require($lvl)
{
if (user()->level() < $lvl) {
header("Location: " . view('main'));
die;
}
}
示例10: renderContent
protected function renderContent()
{
$model_id = isset($_GET['id']) ? (int) $_GET['id'] : 0;
if ($model_id !== 0) {
$model_name = $this->model_name;
if ($model_name != '') {
$model = $model_name::model()->findbyPk($model_id);
// if it is ajax validation request
if (isset($_POST['ajax']) && $_POST['ajax'] === strtolower($model_name) . 'update-form') {
echo CActiveForm::validate($model);
Yii::app()->end();
}
// collect user input data
if (isset($_POST[$model_name])) {
if ($model->save()) {
user()->setFlash('success', t('Updated Successfully!'));
}
}
$this->render(strtolower($model_name) . '/' . strtolower($model_name) . '_update_widget', array('model' => $model));
} else {
throw new CHttpException(404, t('The requested page does not exist.'));
}
} else {
throw new CHttpException(404, t('The requested page does not exist.'));
}
}
示例11: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
*
* @return mixed
*/
public function handle($request, Closure $next, $role, $guard = null)
{
if (Auth::guard($guard)->guest()) {
if ($request->ajax() || $request->wantsJson()) {
return response('Unauthorized.', 401);
} else {
return redirect()->guest('login');
}
}
if (user($guard)->new && config('user.verify_email')) {
if ($request->ajax() || $request->wantsJson()) {
return response('Unauthorized.', 401);
} else {
return redirect('verify');
}
}
if (!user($guard)->active && config('user.verify_email')) {
throw new InvalidAccountException('Account is not active.');
}
$roles = explode('|', $role);
if (!user($guard)->hasRoles($roles)) {
throw new RolesDeniedException($roles);
}
return $next($request);
}
示例12: actionDelete
/**
* Deletes a particular model.
* If deletion is successful, the browser will be redirected to the 'index' page.
* @param integer $id the ID of the model to be deleted
*/
public function actionDelete($id)
{
if (Yii::app()->request->isPostRequest) {
// we only allow deletion via POST request
if (($id = $this->get('id', null)) !== null) {
$ids = is_numeric($id) ? array($id) : explode(',', $id);
// delete one or multiple objects given the list of object IDs
$result = $this->api('XUser.AdminUserGroup.delete', array('ids' => $ids));
if (errorHandler()->getException() == null) {
// only redirect user to the admin page if it is not an AJAX request
if (!Yii::app()->request->isAjaxRequest) {
$this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));
} else {
echo 'Items are deleted successfully';
}
} else {
// redirecting with error carried ot the redirected page
if (!Yii::app()->request->isAjaxRequest) {
user()->setFlashErrors(errorHander()->getErrors());
$this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));
} else {
//This won't work for grid as its jquery.gridview.js alert ajax content
//echo errorHandler()->getErrorMessages();
echo errorHandler()->getException()->message;
}
}
} else {
throw new CHttpException(400, Yii::t('Xpress.XUserGroup', 'Cannot delete item with the given ID.'));
}
} else {
throw new CHttpException(400, Yii::t('Xpress.XUserGroup', 'Invalid request. Please do not repeat this request again.'));
}
}
示例13: renderContent
protected function renderContent()
{
$id = isset($_GET['id']) ? (int) $_GET['id'] : 0;
$page = isset($_GET['page']) ? (int) $_GET['page'] : 0;
$model = GxcHelpers::loadDetailModel('Comment', $id);
$prev_status = $model->comment_approved;
if (isset($_POST['Comment'])) {
$model->attributes = $_POST['Comment'];
if ($model->save()) {
if ($prev_status != $model->comment_approved) {
if ($model->comment_approved == Comment::STATUS_APPROVED) {
$object = Object::model()->findbyPk($model->object_id);
if ($object != null) {
$tempCommentCount = $object->comment_count;
$tempCommentCount++;
$object_comment_count = $tempCommentCount;
$object->save();
}
} else {
if ($model->comment_approved == Comment::STATUS_PENDING) {
$object = Object::model()->findbyPk($model->object_id);
if ($object != null) {
$tempCommentCount = $object->comment_count;
$tempCommentCount--;
$object_comment_count = $tempCommentCount;
$object->save();
}
}
}
}
user()->setFlash('success', t('cms', 'Updated Successfully!'));
}
}
$this->render('cmswidgets.views.comment.comment_update_widget', array('model' => $model));
}
示例14: __construct
public function __construct()
{
parent::__construct();
if (!user('object')->hasRole('Author')) {
$this->middleware('deny403');
}
}
示例15: update
public function update()
{
$idx = user()->getIdx();
if ($idx) {
$meta = new PhilgoMeta();
$stamp = $meta->get("attend.complete.{$idx}");
if ($stamp) {
// 1 분 이내에 중복 신청이 안되도록 한다.
if ($stamp < time() - 60) {
// 총 포인트가 10만 점이 넘지 않도록 한다.
$point = $meta->get("total.event.point.{$idx}");
if ($point > 100000) {
json_success(array('code' => -40470, 'message' => "한도 초과: 포인트는 50,000 점까지만 획득 가능합니다."));
}
global $sys;
$d = array('idx_member' => $idx, 'idx_member_from' => $idx, 'point' => 77, 'idx_post' => 0, 'etc' => 'point event 2016-01-26');
$sys->point->update($d);
$meta->set("attend.complete.{$idx}", time());
$meta->set("total.event.point.{$idx}", $point + 77);
json_success(array('code' => 0, 'message' => "OK"));
} else {
$left = 60 - (time() - $stamp);
json_success(array('code' => -40450, 'message' => "너무 빠른 포인트 증가 시도입니다. {$left} 초 남았음."));
}
} else {
json_success(array('code' => -40449, 'message' => "출석 이벤트를 완료하십시오."));
}
} else {
json_success(array('code' => -40104, 'message' => "로그인을 하십시오."));
}
}