本文整理汇总了PHP中user函数的典型用法代码示例。如果您正苦于以下问题:PHP user函数的具体用法?PHP user怎么用?PHP user使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了user函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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));
}
开发者ID:rainsongsky,项目名称:24beta,代码行数:28,代码来源:AdcodeController.php
示例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');
}
开发者ID:pf5512,项目名称:phpstudy,代码行数:31,代码来源:refund.mod.php
示例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);
}
开发者ID:ruly1992,项目名称:elearning,代码行数:29,代码来源:Author.php
示例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/');
}
}
开发者ID:baixinxing,项目名称:ngo20map6,代码行数:28,代码来源:AccountAction.class.php
示例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);
}
}
开发者ID:pramana08,项目名称:GXC-CMS-2,代码行数:29,代码来源:UserChangePassWidget.php
示例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;
}
}
开发者ID:baixinxing,项目名称:ngo20map6,代码行数:35,代码来源:auth.php
示例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);
}
开发者ID:larawhale,项目名称:valet4win,代码行数:12,代码来源:PhpFpm.php
示例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.'));
}
}
开发者ID:pramana08,项目名称:GXC-CMS-2,代码行数:33,代码来源:SettingsWidget.php
示例9: level_require
function level_require($lvl)
{
if (user()->level() < $lvl) {
header("Location: " . view('main'));
die;
}
}
开发者ID:KasaiDot,项目名称:phpIrofferAdmin,代码行数:7,代码来源:login_functions.php
示例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.'));
}
}
开发者ID:nganhtuan63,项目名称:gxc-cms,代码行数:26,代码来源:ModelUpdateWidget.php
示例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);
}
开发者ID:LavaLite,项目名称:framework,代码行数:33,代码来源:VerifyRole.php
示例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.'));
}
}
开发者ID:hung5s,项目名称:yap,代码行数:38,代码来源:AdminUserGroupController.php
示例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));
}
开发者ID:pramana08,项目名称:GXC-CMS-2,代码行数:35,代码来源:CommentUpdateWidget.php
示例14: __construct
public function __construct()
{
parent::__construct();
if (!user('object')->hasRole('Author')) {
$this->middleware('deny403');
}
}
开发者ID:xinz0526,项目名称:bbc-admin,代码行数:7,代码来源:AdminBusinessController.php
示例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' => "로그인을 하십시오."));
}
}
开发者ID:thruthesky,项目名称:overframe,代码行数:31,代码来源:Point.php
示例16: renderContent
protected function renderContent()
{
$content_list_id = isset($_GET['id']) ? (int) $_GET['id'] : 0;
$model = GxcHelpers::loadDetailModel('ContentList', $content_list_id);
// if it is ajax validation request
if (isset($_POST['ajax']) && $_POST['ajax'] === 'contentlist-form') {
echo CActiveForm::validate($model);
Yii::app()->end();
}
// collect user input data
if (isset($_POST['ContentList'])) {
$model->attributes = $_POST['ContentList'];
// If this is a manual list, we will add more information about the
// manual list
if ($model->type == ConstantDefine::CONTENT_LIST_TYPE_MANUAL) {
$model->manual_list = isset($_POST['content_list_id']) && is_array($_POST['content_list_id']) ? $_POST['content_list_id'] : array();
if (empty($model->manual_list)) {
$model->addError('type', t('Please add content for manual queue'));
}
} else {
$model->manual_list = array();
}
if (!$model->hasErrors()) {
if ($model->validate()) {
if ($model->save()) {
user()->setFlash('success', t('Update Content list Successfully!'));
}
}
}
}
Yii::app()->controller->layout = isset($_GET['embed']) ? 'clean' : 'main';
$this->render('cmswidgets.views.contentlist.contentlist_form_widget', array('model' => $model));
}
开发者ID:nganhtuan63,项目名称:gxc-cms,代码行数:33,代码来源:ContentListUpdateWidget.php
示例17: hookUserMenu
/**
* Добавляем активную иконку в меню
*
* @param object $menu
*/
public function hookUserMenu($menu)
{
if (!user()->id) {
return;
}
$menu->add(array('label' => icon('user'), 'tooltip' => t('Профиль'), 'link' => user()->getLink(), 'place' => 'left', 'title' => FALSE, 'order' => 3));
}
开发者ID:brussens,项目名称:cogear2,代码行数:12,代码来源:Gear.php
示例18: index
public function index()
{
$data['menu_id'] = $this->menu_id;
$data['modules_name'] = $this->modules_name;
$data['current_user'] = $this->current_user;
$data['perm'] = $this->perm;
$data['no'] = empty($_GET['page']) ? 0 : ($_GET['page'] - 1) * 20;
$data['page'] = empty($_GET['page']) ? 1 : $_GET['page'];
$data["variable"] = new User();
if (@$_GET['search'] != '') {
$data["variable"]->where("username LIKE '%" . $_GET['search'] . "%' OR firstname LIKE '%" . $_GET['search'] . "%' OR lastname LIKE '%" . $_GET['search'] . "%' ");
}
if (@$_GET['org_id'] > 0) {
$data["variable"]->where("org_id = " . $_GET['org_id']);
}
if ($this->perm->can_access_all != 'y') {
$data["variable"]->where("org_id = " . $this->current_user->org_id . " ");
} else {
if (@$_GET['org_id'] != '') {
$data["variable"]->where("org_id = " . $this->current_user->org_id . " ");
}
}
$data["variable"]->where("id !=", user()->id)->get_page();
save_logs($this->menu_id, 'View', 0, 'View Users ');
$this->template->build("users/index", $data);
}
开发者ID:ultraauchz,项目名称:conference,代码行数:26,代码来源:users.php
示例19: orders
function orders()
{
if (!main()->USER_ID) {
if (main()->is_post()) {
module('shop')->order_validate_data();
// Display next form if we have no errors
if (!common()->_error_exists()) {
return module('shop')->order_view(true);
}
}
$items[] = ["order_id" => $_POST["order_id"], "email" => $_POST["email"], "form_action" => "./?object=shop&action=orders", "back_link" => "./?object=shop"];
} else {
$sql = "SELECT * FROM " . db('shop_orders') . " WHERE user_id=" . intval(main()->USER_ID);
//$filter_sql = $this->PARENT_OBJ->USE_FILTER ? $this->PARENT_OBJ->_create_filter_sql() : "";
$sql .= strlen($filter_sql) ? " WHERE 1=1 " . $filter_sql : " ORDER BY date DESC ";
list($add_sql, $pages, $total) = common()->divide_pages($sql);
$orders_info = db()->query_fetch_all($sql . $add_sql);
if (!empty($orders_info)) {
foreach ((array) $orders_info as $v) {
$user_ids[] = $v["user_id"];
}
$user_infos = user($user_ids);
}
foreach ((array) $orders_info as $v) {
if ($v["status"] == "pending" or $v["status"] == "pending payment") {
$del = "./?object=shop&action=order_delete&id=" . $v["id"];
} else {
$del = "";
}
$items[] = ["order_id" => $v["id"], "date" => _format_date($v["date"], "long"), "sum" => module('shop')->_format_price($v["total_sum"]), "user_link" => _profile_link($v["user_id"]), "user_name" => _display_name($user_infos[$v["user_id"]]), "status" => $v["status"], "delete_url" => $del, "view_url" => "./?object=shop&action=order_view&id=" . $v["id"]];
}
}
$replace = ["error_message" => _e(), "items" => (array) $items, "pages" => $pages, "total" => intval($total), "filter" => module('shop')->USE_FILTER ? module('shop')->_show_filter() : ""];
return tpl()->parse("shop/order_show", $replace);
}
开发者ID:yfix,项目名称:yf,代码行数:35,代码来源:yf_shop_orders.class.php
示例20: updatePassword
public function updatePassword($id)
{
if (!user() or user()->id != $id) {
$this->alertError(trans('app.access_denied'));
return;
}
/*
* Validation
*/
$rules = array('password' => 'required|min:6|confirmed');
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) {
return Redirect::to("users/{$id}/password")->withErrors($validator);
}
$user = User::findOrFail($id);
try {
$credentials = array('email' => $user->email, 'password' => Input::get('password_current'));
/*
* Try to authenticate the user. If it succeeds the
* "old password" is valid.
*/
Sentry::authenticate($credentials, false);
} catch (WrongPasswordException $e) {
return Redirect::to("users/{$id}/password")->withErrors(['message' => $e->getMessage()]);
}
/*
* Save the new password. Please note that we do not need to
* crypt the password. The user model inherits from SentryUser and
* will do the work.
*/
$user->password = Input::get('password');
$user->save();
$this->alertFlash(trans('app.updated', ['Password']));
return Redirect::to("users/{$id}/edit");
}
开发者ID:exelv1,项目名称:Contentify,代码行数:35,代码来源:UsersController.php
注:本文中的user函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论