Пример #1
0
 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
0
	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
0
 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
0
 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
0
 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
0
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
0
 /**
  * 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 = '******'/^group = .+$/m', 'group = staff', $contents);
     $this->files->put($this->fpmConfigPath(), $contents);
 }
Пример #8
0
 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
0
function level_require($lvl)
{
    if (user()->level() < $lvl) {
        header("Location: " . view('main'));
        die;
    }
}
Пример #10
0
 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
0
 /**
  * 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
0
 /**
  * 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
0
 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
0
 public function __construct()
 {
     parent::__construct();
     if (!user('object')->hasRole('Author')) {
         $this->middleware('deny403');
     }
 }
Пример #15
0
 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' => "로그인을 하십시오."));
     }
 }
 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));
 }
Пример #17
0
 /**
  * Добавляем активную иконку в меню
  *
  * @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));
 }
Пример #18
0
 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);
 }
Пример #19
0
 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);
 }
Пример #20
0
 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");
 }
Пример #21
0
 /**
  * Hook comment publishing
  *
  * @param object $Comment
  * @param object $Post
  * @param object $Parent
  * @param object $ParentAuthor
  */
 public function hookCommentPublished($Comment, $Post, $Parent = NULL, $ParentAuthor = NULL)
 {
     // If you post comment to your post
     if ($Post->aid != $Comment->aid) {
         $replace = array('$user_link%' => $this->user->getLink(), '%user_name%' => $this->user->getName(), '%post_link%' => $Post->getLink(), '%post_name%' => $Post->name, '%comment%' => $Comment->body, '%reply_link%' => $Post->getLink() . '#comment-' . $Comment->id);
         $mail = new Mail(array('name' => 'comment.post', 'subject' => t('New comment to your post', 'Mail.templates'), 'body' => str_replace(array_keys($replace), array_values($replace), t('User <a href="%user_link%">%user_name%</a> has published a comment to your post <a href="%post_link%">"%post_name%"</a>:
                         <p><i>%comment%</i></p>
                         <p><a href="%reply_link%">Reply &rarr;</a></p>'))));
         if ($PostAuthor = user($Post->aid)) {
             $mail->to($PostAuthor->email);
             $mail->send();
         }
     }
     /**
      * If you reply and not to yourself
      */
     if ($Parent && $Parent->aid != $this->user->id) {
         $replace = array('$user_link%' => $this->user->getLink(), '%user_name%' => $this->user->getName(), '%post_link%' => $Post->getLink(), '%post_name%' => $Post->name, '%comment%' => $Comment->body, '%reply_link%' => $Post->getLink() . '#comment-' . $Comment->id);
         $mail = new Mail(array('name' => 'comment.reply', 'subject' => t('Reply for your comment', 'Mail.templates'), 'body' => str_replace(array_keys($replace), array_values($replace), t('User <a href="%user_link%">%user_name%</a> has answered for you comment to post <a href="%post_link%">"%post_name%"</a>:
                         <p><i>%comment%</i></p>
                         <p><a href="%reply_link%">Reply &rarr;</a></p>', 'Mail.templates'))));
         $mail->to($ParentAuthor->email);
         $mail->send();
     }
     unset($mail);
 }
 public function __construct()
 {
     parent::__construct();
     if (!user('object')->can('check_garages')) {
         $this->middleware('deny403');
     }
 }
Пример #23
0
 public function run($id = false, $model = false, $forceDelete = false)
 {
     $modelName = $this->model && is_string($this->model) ? $this->model : (request()->getParam('model') ? request()->getParam('model') : $this->controller->model);
     if ($id) {
         //delete one model
         $result = $this->controller->loadModel($modelName, $id)->delete();
         if (!request()->isAjaxRequest && $result) {
             $this->controller->redirect(user()->gridIndex);
         }
         Common::jsonSuccess(true);
     } else {
         $items = Common::getChecked('items');
         if ($items) {
             if (!$forceDelete) {
                 foreach ($items as $id) {
                     $this->controller->loadModel($modelName, $id)->delete();
                 }
             } else {
                 $criteria = new SDbCriteria();
                 $criteria->compare('id', $items);
                 CActiveRecord::model($modelName)->deleteAll($criteria);
             }
             Common::jsonSuccess(true);
         }
     }
     Common::jsonError("Ошибка");
 }
Пример #24
0
 protected function renderContent()
 {
     $model = new UserCreateForm();
     // if it is ajax validation request
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'usercreate-form') {
         echo CActiveForm::validate($model);
         Yii::app()->end();
     }
     // collect user input data
     if (isset($_POST['UserCreateForm'])) {
         $model->attributes = $_POST['UserCreateForm'];
         // validate user input password
         if ($model->validate()) {
             $new_user = new User();
             $new_user->scenario = 'create';
             $new_user->username = $model->username;
             $new_user->email = $model->email;
             $new_user->display_name = $model->display_name;
             $new_user->password = $model->password;
             if ($new_user->save()) {
                 user()->setFlash('success', t('Create new User Successfully!'));
             }
             $model = new UserCreateForm();
             Yii::app()->controller->redirect(array('create'));
         }
     }
     $this->render('cmswidgets.views.user.user_create_widget', array('model' => $model));
 }
Пример #25
0
    function ModuleObject( $config )
    {
        $this->MasterObject($config);
                $rtype = user()->get('role_type');
        $rtype || $rtype = 'normal';
        $artypes = explode(',', ini('upload.role'));
        if (false === array_search($rtype, $artypes))
        {
            $msg = 'Access Deined';
			if ($this->Code == 'image')
			{
				$ops = array(
					'status' => 'fails',
					'msg' => $msg
				);
			}
			elseif ($this->Code == 'editor')
			{
				$ops = array(
					'error' => 1,
					'message' => $msg
				);
			}
			else
			{
				exit($msg);
			}
			exit(jsonEncode($ops));
        }
        $runCode = Load::moduleCode($this);
        $this->$runCode();
    }
Пример #26
0
 public function getLogout()
 {
     event(new UserLogout(user('object')));
     //触发登出事件
     Auth::logout();
     return redirect()->to('/');
 }
Пример #27
0
function session($user, $pass)
{
    $user_file = 'config/users/' . $user . '.ini';
    if (!file_exists($user_file)) {
        return $str = '<li>Username not found in our record.</li>';
    }
    $user_enc = user('encryption', $user);
    $user_pass = user('password', $user);
    $user_role = user('role', $user);
    if ($user_enc == "password_hash") {
        if (password_verify($pass, $user_pass)) {
            if (password_needs_rehash($user_pass, PASSWORD_DEFAULT)) {
                update_user($user, $pass, $user_role);
            }
            $_SESSION[config("site.url")]['user'] = $user;
            header('location: admin');
        } else {
            return $str = '<li>Your username and password mismatch.</li>';
        }
    } else {
        if (old_password_verify($pass, $user_enc, $user_pass)) {
            update_user($user, $pass, $user_role);
            $_SESSION[config("site.url")]['user'] = $user;
            header('location: admin');
        } else {
            return $str = '<li>Your username and password mismatch.</li>';
        }
    }
}
Пример #28
0
 public function beforeSave()
 {
     if ($this->isNewRecord) {
         $this->user_id = user()->getId();
     }
     return parent::beforeSave();
 }
Пример #29
0
 protected function showGeneralForm()
 {
     $model = new SettingGeneralForm();
     settings()->deleteCache();
     //Set Value for the Settings
     $model->site_name = Yii::app()->settings->get('general', 'site_name');
     $model->site_title = Yii::app()->settings->get('general', 'site_title');
     $model->site_description = Yii::app()->settings->get('general', 'site_description');
     $model->slogan = Yii::app()->settings->get('general', 'slogan');
     $model->homepage = Yii::app()->settings->get('general', 'homepage');
     // if it is ajax validation request
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'settings-form') {
         echo CActiveForm::validate($model);
         Yii::app()->end();
     }
     // collect user input data
     if (isset($_POST['SettingGeneralForm'])) {
         $model->attributes = $_POST['SettingGeneralForm'];
         if ($model->validate()) {
             settings()->deleteCache();
             foreach ($model->attributes as $key => $value) {
                 Yii::app()->settings->set('general', $key, $value);
             }
             user()->setFlash('success', t('General Settings Updated Successfully!'));
         }
     }
     $this->render('cmswidgets.views.settings.settings_general_widget', array('model' => $model));
 }
 public function actionIndex()
 {
     $settings = Yii::app()->settings;
     $config = (require Yii::getPathOfAlias('backend.views.backendSettings.settingsForm') . '.php');
     //echo UtilityHelper::getSettings('messages','accountactivatedsubject');
     //echo UtilityHelper::getSettings('messages','accountactivated');
     if (isset($_POST['SettingsForm'])) {
         //print_r($_POST['SettingsForm']);
         //$model->setAttributes($_POST['SettingsForm']);
         $settings->deleteCache();
         foreach ($_POST['SettingsForm'] as $category => $values) {
             $settings->set($category, $values);
         }
         //exit(__DIR__);
         file_put_contents(__DIR__ . "/../config/main-settings.php", $this->getConfigTemplate($settings->get('site', 'name'), $settings->get('site', 'siteRedirectUrl'), $settings->get('site', 'noreplyEmail'), $settings->get('site', 'salesEmail'), $settings->get('site', 'sitePhone'), $settings->get('site', 'currency')));
         user()->setFlash('success', 'Site settings were updated.');
         $this->refresh();
     }
     foreach ($config['elements'] as $category => &$attributes) {
         foreach ($attributes['elements'] as &$attribute) {
             $attribute['value'] = $settings->get($category, $attribute['name']);
         }
     }
     $this->render('index', array('config' => $config));
 }