Example #1
0
 public function action_index()
 {
     // load language
     \Lang::load('account');
     if (\Input::method() == 'POST') {
         // store data for model
         $data['account_email'] = \Security::strip_tags(trim(\Input::post('account_email')));
         // validate form.
         $validate = \Validation::forge();
         $validate->add('account_email', \Lang::get('account_email'), array(), array('required', 'valid_email'));
         if (!\Extension\NoCsrf::check(null, null, null, null, false)) {
             // validate token failed
             $output['form_status'] = 'error';
             $output['form_status_message'] = \Lang::get('fslang_invalid_csrf_token');
         } elseif (!$validate->run()) {
             // validate failed
             $output['form_status'] = 'error';
             $output['form_status_message'] = $validate->show_errors();
         } else {
             // check registered emails with not confirm
             $query = \Model_Accounts::query()->select('account_id', 'account_username', 'account_email')->where('account_email', $data['account_email'])->where('account_last_login', null)->where('account_status', '0')->where('account_confirm_code', '!=', 'NULL');
             if ($query->count() <= 0) {
                 $output['form_status'] = 'error';
                 $output['form_status_message'] = \Lang::get('account_didnot_found_entered_email');
             } else {
                 $row = $query->get_one();
                 // generate confirm code
                 $data['account_confirm_code'] = \Str::random('alnum', 6);
                 $data['account_username'] = $row->account_username;
                 $options['not_notify_admin'] = true;
                 // send email to let user confirm registration
                 $result = \Model_Accounts::forge()->sendRegisterEmail($data, $options);
                 if ($result === true) {
                     $account = \Model_Accounts::find($row->account_id);
                     $account->account_confirm_code = $data['account_confirm_code'];
                     $account->save();
                     $output['form_status'] = 'success';
                     $output['form_status_message'] = \Lang::get('account_registration_completed_need_confirm');
                 } else {
                     $output['form_status'] = 'error';
                     $output['form_status_message'] = $result;
                 }
             }
         }
         // re-populate form
         $output['account_email'] = trim(\Input::post('account_email'));
     }
     // <head> output ----------------------------------------------------------------------------------------------
     $output['page_title'] = $this->generateTitle(\Lang::get('account_resend_confirm_registration_email'));
     // <head> output ----------------------------------------------------------------------------------------------
     return $this->generatePage('front/templates/account/resendactivate_v', $output, false);
 }
Example #2
0
 /**
  * gmt date. the timezone up to current user data.
  *
  * @param string $date_format date format can use both date() function or strftime() function
  * @param integer $timestamp localtime timestamp.
  * @param type $timezone php timezone (http://www.php.net/manual/en/timezones.php)
  * @return null
  */
 public static function gmtDate($date_format = '%Y-%m-%d %H:%M:%S', $timestamp = '', $timezone = '')
 {
     // check empty date format
     if (empty($date_format)) {
         $date_format = '%Y-%m-%d %H:%M:%S';
     }
     // check timestamp
     if (empty($timestamp)) {
         $timestamp = time();
     } else {
         if (!self::isValidTimeStamp($timestamp)) {
             $timestamp = strtotime($timestamp);
         }
     }
     // make very sure that selected timezone is in the timezone list or converted to real timezone.
     if ($timezone != null) {
         $timezone = static::isValidTimezone($timezone);
     }
     // check timezone
     if ($timezone == null) {
         $account_model = new \Model_Accounts();
         $cookie = $account_model->getAccountCookie();
         $site_timezone = static::getRealTimezoneValue(\Model_Config::getval('site_timezone'));
         if (!isset($cookie['account_id'])) {
             // not member or not log in. use default config timezone.
             $timezone = $site_timezone;
         } else {
             // find timezone for current user.
             $row = \Model_Accounts::find($cookie['account_id']);
             if (!empty($row)) {
                 $timezone = static::getRealTimezoneValue($row->account_timezone);
             } else {
                 $timezone = $site_timezone;
             }
         }
         unset($account_model, $cookie, $row, $site_timezone);
     }
     // what format of the date_format (use date() value or strftime() value)
     if (strpos($date_format, '%') !== false) {
         // use strftime() format
         return \Date::forge($timestamp)->set_timezone($timezone)->format($date_format);
     } else {
         // use date() format
         return date($date_format, strtotime(\Date::forge($timestamp)->set_timezone($timezone)->format('%Y-%m-%d %H:%M:%S')));
     }
 }
Example #3
0
 public function action_viewlogins($account_id = '')
 {
     // set redirect url
     $redirect = $this->getAndSetSubmitRedirection();
     // check permission
     if (\Model_AccountLevelPermission::checkAdminPermission('account_perm', 'account_viewlogin_log_perm') == false) {
         \Session::set_flash('form_status', array('form_status' => 'error', 'form_status_message' => \Lang::get('admin_permission_denied', array('page' => \Uri::string()))));
         \Response::redirect($redirect);
     }
     // viewing guest logins?
     if ($account_id == '0') {
         \Response::redirect($redirect);
     }
     // load language
     \Lang::load('account');
     \Lang::load('accountlogins');
     // read flash message for display errors.
     $form_status = \Session::get_flash('form_status');
     if (isset($form_status['form_status']) && isset($form_status['form_status_message'])) {
         $output['form_status'] = $form_status['form_status'];
         $output['form_status_message'] = $form_status['form_status_message'];
     }
     unset($form_status);
     // get accounts data for this account.
     $account = \Model_Accounts::find($account_id);
     if ($account == null) {
         // not found account.
         \Response::redirect($redirect);
     }
     $output['account'] = $account;
     $output['account_id'] = $account_id;
     unset($account);
     // set sort variable for sortable in views.
     $next_sort = \Security::strip_tags(trim(\Input::get('sort')));
     if ($next_sort == null || $next_sort == 'DESC') {
         $next_sort = 'ASC';
     } else {
         $next_sort = 'DESC';
     }
     $output['next_sort'] = $next_sort;
     unset($next_sort);
     // list logins -----------------------------------------------------------------------------------------------------
     $option['limit'] = \Model_Config::getval('content_admin_items_perpage');
     $option['offset'] = trim(\Input::get('page')) != null ? ((int) \Input::get('page') - 1) * $option['limit'] : 0;
     if (\Security::strip_tags(trim(\Input::get('orders'))) != null) {
         $option['orders'] = \Security::strip_tags(trim(\Input::get('orders')));
     }
     if (\Security::strip_tags(trim(\Input::get('sort'))) != null) {
         $option['sort'] = \Security::strip_tags(trim(\Input::get('sort')));
     }
     $list_logins = \Model_AccountLogins::listLogins(array('account_id' => $account_id), $option);
     // pagination config
     $config['pagination_url'] = \Uri::main() . \Uri::getCurrentQuerystrings(true, true, false);
     $config['total_items'] = $list_logins['total'];
     $config['per_page'] = $option['limit'];
     $config['uri_segment'] = 'page';
     $config['num_links'] = 3;
     $config['show_first'] = true;
     $config['show_last'] = true;
     $config['first-inactive'] = "\n\t\t<li class=\"disabled\">{link}</li>";
     $config['first-inactive-link'] = '<a href="#">{page}</a>';
     $config['first-marker'] = '&laquo;';
     $config['last-inactive'] = "\n\t\t<li class=\"disabled\">{link}</li>";
     $config['last-inactive-link'] = '<a href="#">{page}</a>';
     $config['last-marker'] = '&raquo;';
     $config['previous-marker'] = '&lsaquo;';
     $config['next-marker'] = '&rsaquo;';
     $pagination = \Pagination::forge('viewlogins_pagination', $config);
     $output['list_logins'] = $list_logins;
     $output['pagination'] = $pagination;
     unset($config, $list_logins, $option, $pagination);
     // <head> output ----------------------------------------------------------------------------------------------
     $output['page_title'] = $this->generateTitle(\Lang::get('account_view_login_history'));
     // <head> output ----------------------------------------------------------------------------------------------
     // breadcrumb -------------------------------------------------------------------------------------------------
     $page_breadcrumb = [];
     $page_breadcrumb[0] = ['name' => \Lang::get('admin_admin_home'), 'url' => \Uri::create('admin')];
     $page_breadcrumb[1] = ['name' => \Lang::get('account_accounts'), 'url' => \Uri::create('admin/account')];
     $page_breadcrumb[2] = ['name' => \Lang::get('account_view_login_history'), 'url' => \Uri::main()];
     $output['page_breadcrumb'] = $page_breadcrumb;
     unset($page_breadcrumb);
     // breadcrumb -------------------------------------------------------------------------------------------------
     return $this->generatePage('admin/templates/account/viewlogins_v', $output, false);
 }
Example #4
0
 private function checkAccountData($account_id = '')
 {
     if ($account_id == null) {
         $cookie_account = \Model_Accounts::forge()->getAccountCookie('admin');
         $account_id = 0;
         if (isset($cookie_account['account_id'])) {
             $account_id = $cookie_account['account_id'];
         }
     }
     if ($account_id == 0 || !is_numeric($account_id)) {
         return \Lang::get('acperm_account_not_found');
     }
     $account = \Model_Accounts::find($account_id);
     // if not found account.
     if ($account == null) {
         unset($account);
         return \Lang::get('acperm_account_not_found');
     }
     // set level groups for check that this admin can set permission for this user.
     // lower admin level cannot add/edit/delete/change permission for admin that has higher level.
     $level_groups = array();
     foreach ($account->account_level as $lvl) {
         $level_groups[] = $lvl->level_group_id;
     }
     if (\Model_Accounts::forge()->canIAddEditAccount($level_groups) == false) {
         \Lang::load('account');
         return \Lang::get('account_you_cannot_edit_account_that_contain_role_higher_than_yours');
     }
     return $account;
 }
Example #5
0
 public function action_index()
 {
     // is user logged in?
     if (\Model_Accounts::isMemberLogin() == false) {
         \Response::redirect(\Uri::create('account/login') . '?rdr=' . urlencode(\Uri::main()));
     }
     // load language
     \Lang::load('account');
     \Lang::load('accountlogins');
     // get account id
     $cookie_account = \Model_Accounts::forge()->getAccountCookie();
     // get account data
     $row = \Model_Accounts::find($cookie_account['account_id']);
     if ($row == null) {
         // not found user data.
         unset($row);
         \Response::redirect(\Uri::main());
     }
     $output['account'] = $row;
     // set sort variable for sortable in views.
     $next_sort = \Security::strip_tags(trim(\Input::get('sort')));
     if ($next_sort == null || $next_sort == 'DESC') {
         $next_sort = 'ASC';
     } else {
         $next_sort = 'DESC';
     }
     $output['next_sort'] = $next_sort;
     unset($next_sort);
     // list logins -----------------------------------------------------------------------------------------------------
     $option['limit'] = \Model_Config::getval('content_items_perpage');
     $option['offset'] = trim(\Input::get('page')) != null ? ((int) \Input::get('page') - 1) * $option['limit'] : 0;
     if (\Security::strip_tags(trim(\Input::get('orders'))) != null) {
         $option['orders'] = \Security::strip_tags(trim(\Input::get('orders')));
     }
     if (\Security::strip_tags(trim(\Input::get('sort'))) != null) {
         $option['sort'] = \Security::strip_tags(trim(\Input::get('sort')));
     }
     $data['account_id'] = $cookie_account['account_id'];
     $data['site_id'] = \Model_Sites::getSiteId();
     $list_logins = \Model_AccountLogins::listLogins($data, $option);
     // pagination config
     $config['pagination_url'] = \Uri::main() . \Uri::getCurrentQuerystrings(true, true, false);
     $config['total_items'] = $list_logins['total'];
     $config['per_page'] = $option['limit'];
     $config['uri_segment'] = 'page';
     $config['num_links'] = 3;
     $config['show_first'] = true;
     $config['show_last'] = true;
     $config['first-inactive'] = "\n\t\t<li class=\"disabled\">{link}</li>";
     $config['first-inactive-link'] = '<a href="#">{page}</a>';
     $config['first-marker'] = '&laquo;';
     $config['last-inactive'] = "\n\t\t<li class=\"disabled\">{link}</li>";
     $config['last-inactive-link'] = '<a href="#">{page}</a>';
     $config['last-marker'] = '&raquo;';
     $config['previous-marker'] = '&lsaquo;';
     $config['next-marker'] = '&rsaquo;';
     $pagination = \Pagination::forge('viewlogins_pagination', $config);
     $output['list_logins'] = $list_logins;
     $output['pagination'] = $pagination;
     unset($config, $data, $list_logins, $option, $pagination);
     // <head> output ----------------------------------------------------------------------------------------------
     $output['page_title'] = $this->generateTitle(\Lang::get('account_login_history'));
     // <head> output ----------------------------------------------------------------------------------------------
     return $this->generatePage('front/templates/account/viewlogins_v', $output, false);
 }