Exemplo n.º 1
0
 function Signin($row)
 {
     Module::Module($row);
     switch (Url::get('cmd')) {
         case 'check_account':
             $this->check_account();
             exit;
         case 'check_email':
             $this->check_email();
             exit;
         case 'check_security_code':
             $this->check_security_code();
             exit;
         case 'check_email_format':
             $this->check_email_format();
             exit;
         default:
             if (!User::is_login()) {
                 require_once 'forms/signin.php';
                 $this->add_form(new SigninForm());
             } else {
                 $href = base64_decode(Url::get('href'));
                 if ($href) {
                     $href = str_replace('SID=' . $_COOKIE['PHPSESSID'], '', $href);
                     Url::redirect_url($href);
                 } else {
                     Url::redirect();
                 }
             }
             break;
     }
 }
Exemplo n.º 2
0
 function AdminNews($row)
 {
     Module::Module($row);
     if (User::is_admin()) {
         $cmd = Url::get('cmd');
         switch ($cmd) {
             case "edit":
             case "add_item":
                 require_once 'forms/detail.php';
                 $this->add_form(new AdminNewsDetail());
                 break;
             case "delete":
                 $url = urldecode(Url::get('url'));
                 $id = Url::get('id');
                 if (!is_numeric($id)) {
                     Url::redirect('admin_news_item');
                     return;
                 }
                 DB::delete_id('news_item', $id);
                 eb_memcache::do_remove('news_item:' . $id);
                 Url::redirect_url($url);
                 break;
             default:
                 require_once 'forms/list.php';
                 $this->add_form(new AdminNewsForm());
                 break;
         }
     } else {
         Url::access_denied();
     }
 }
Exemplo n.º 3
0
 public function leave()
 {
     if ($this->_user->isPlaying()) {
         $this->_user->exitBattlefield();
     }
     Url::redirect(Url::generate('Play'));
 }
Exemplo n.º 4
0
 function RegisterSuccess($row)
 {
     Module::Module($row);
     switch (Url::get('cmd')) {
         case 'notify':
             //Thông báo kích hoạt tài khoản (nếu bật chế độ cần kích hoạt - USER_ACTIVE_ON = true )
             if (!User::is_login() && USER_ACTIVE_ON) {
                 require_once 'forms/notify.php';
                 $this->add_form(new NotifyForm());
             } else {
                 Url::redirect_current();
             }
             break;
         case 'active':
             //Kích hoạt tài khoản
             if (!User::is_login() && USER_ACTIVE_ON) {
                 require_once 'forms/active.php';
                 $this->add_form(new ActiveForm());
             } else {
                 Url::redirect('profile', array('user_id' => User::id(), 'user_name' => User::user_name()));
             }
             break;
         case 'activated':
         default:
             require_once 'forms/register_success.php';
             $this->add_form(new RegisterSuccessForm());
             break;
     }
 }
Exemplo n.º 5
0
 function IntroBannerForm()
 {
     Form::Form('IntroBannerForm');
     //ngannv tùy biến dung  JW Image Rotator
     $this->link_js(FOLDER_JS . 'imagerotator/swfobject.js');
     $cmd = Url::get("cmd");
     $id = Url::get("id", 0);
     if ($cmd == 'del_hb' && $id) {
         if (file_exists(DATA_PATH . "home_banner/{$id}.swf")) {
             @unlink(DATA_PATH . "home_banner/{$id}.swf");
         }
         if (file_exists(DATA_PATH . "home_banner/{$id}.gif")) {
             @unlink(DATA_PATH . "home_banner/{$id}.gif");
         }
         if (file_exists(DATA_PATH . "home_banner/{$id}.jpg")) {
             @unlink(DATA_PATH . "home_banner/{$id}.jpg");
         }
         if (file_exists(DATA_PATH . "home_banner/{$id}.jpeg")) {
             @unlink(DATA_PATH . "home_banner/{$id}.jpeg");
         }
         if (file_exists(DATA_PATH . "home_banner/{$id}.png")) {
             @unlink(DATA_PATH . "home_banner/{$id}.png");
         }
         Url::redirect();
     }
 }
Exemplo n.º 6
0
 public function create()
 {
     Session::init();
     if (Session::get('username')) {
         if (Session::get('admin')) {
             Url::redirect('exec');
         }
     } else {
         Url::redirect('');
     }
     $data['title'] = 'Wishlist';
     $tripId = \helpers\Session::get("tripId");
     $data['applicants'] = $this->mab->get_wishlist($tripId);
     $data['roster'] = $this->mab->get_official_roster($tripId);
     foreach ($data['applicants'] as $applicants_info) {
         $applicants_info->age = $this->mab->get_age_at_time($applicants_info->dateOfBirth, date('Y-m-d', time()));
     }
     if (isset($_POST['draft'])) {
         $trip_id = $this->mab->verify_applicant($_POST['applicationId']);
         if ($trip_id == NULL) {
             $this->mab->add_to_trip($_POST['applicationId'], $tripId);
             $this->mab->applicant_becomes_person($_POST['applicationId']);
             $this->mab->person_becomes_trip_member($_POST['applicationId'], $tripId);
         } else {
             if ($trip_id == $tripId) {
                 echo 'This is your participant';
             } else {
                 echo 'Application has already been drafted.';
             }
         }
     }
     View::rendertemplate('header', $data);
     View::render('wishlist/wishlist', $data, $error);
     View::rendertemplate('footer', $data);
 }
Exemplo n.º 7
0
 function AdminUsers($row)
 {
     Module::Module($row);
     if (User::is_admin()) {
         $cmd = Url::get('cmd');
         switch ($cmd) {
             case "edit_user":
             case "add_user":
                 require_once 'forms/detail.php';
                 $this->add_form(new AdminUserDetail());
                 break;
             case "list_users":
                 require_once 'forms/list.php';
                 $this->add_form(new AdminListUsersForm());
                 break;
             case "delete_user":
                 $id = Url::get('id');
                 if (!is_numeric($id)) {
                     Url::redirect('admin_users');
                     return;
                 }
                 break;
         }
     } else {
         Url::access_denied();
     }
 }
Exemplo n.º 8
0
 public function edit($id)
 {
     $data['title'] = 'Edit User';
     $data['row'] = $this->_model->getuser($id);
     if (isset($_POST['submit'])) {
         $username = $_POST['username'];
         $password = $_POST['password'];
         $email = $_POST['email'];
         if ($username == '') {
             $error[] = 'Username is required';
         }
         if ($password == '') {
             $error[] = 'Password is required';
         }
         if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
             $error[] = 'Email is not valid';
         }
         if (!$error) {
             $postdata = array('username' => $username, 'password' => \helpers\password::make($password), 'email' => $email);
             $where = array('memberID' => $id);
             $this->_model->update_user($postdata, $where);
             Session::set('message', 'User Updated');
             Url::redirect('admin/users');
         }
     }
     View::renderadmintemplate('header', $data);
     View::render('admin/edituser', $data, $error);
     View::renderadmintemplate('footer', $data);
 }
 function SignIn($row)
 {
     Module::Module($row);
     if (User::is_login()) {
         if ($data = Session::get('user_data') and $data['home_page']) {
             Url::redirect_url($data['home_page']);
         } else {
             Url::redirect('home');
         }
     } else {
         // xoa toan bo du lieu dang co truoc khi dang nhap
         if (Session::is_set('user_id')) {
             $id = Session::get('user_id');
             DB::update('account', array('last_online_time' => time()), 'id=\'' . $id . '\'');
             setcookie('user_id', "", time() - 3600);
             Session::destroy('user_id');
         }
         //if(URL::get("m")== "mobile"){
         //	require_once 'forms/mlogin.php';
         //	$this->add_form(new SignInmForm);
         //}else{
         require_once 'forms/sign_in.php';
         $this->add_form(new SignInForm());
         //}
     }
 }
Exemplo n.º 10
0
 function AdminNewsCategory($row)
 {
     Module::Module($row);
     if (User::is_admin()) {
         $cmd = Url::get('cmd');
         switch ($cmd) {
             case "edit":
             case "add_category":
                 require_once 'forms/detail.php';
                 $this->add_form(new AdminNewsCategoryDetail());
                 break;
             case "delete":
                 $id = Url::get('id');
                 if (!is_numeric($id)) {
                     Url::redirect('admin_news_category');
                     return;
                 }
                 DB::delete_id('news_category', $id);
                 eb_memcache::do_remove('news_category/all');
                 eb_memcache::do_remove('news_category:' . $id);
                 Url::redirect('admin_news_category');
                 break;
             default:
                 require_once 'forms/list.php';
                 $this->add_form(new AdminNewsCategoryForm());
                 break;
         }
     } else {
         Url::access_denied();
     }
 }
Exemplo n.º 11
0
 function ForgotPassword($row)
 {
     Module::Module($row);
     $user_id = (int) Url::get('id');
     if ($user_id) {
         $user = DB::fetch("SELECT user_name,email FROM user WHERE id={$user_id}");
         if ($user && md5($user['user_name'] . $user['email']) == Url::get('u')) {
             $new_password = $this->random_string();
             $user_name = $user['user_name'];
             $subject = 'Khôi phục mật khẩu thành công!';
             $messenger = file_get_contents('templates/ForgotPassword/reset_password.html');
             $message = str_replace('[[|user_name|]]', $user_name, $messenger);
             $message = str_replace('[[|password|]]', $new_password, $message);
             if (System::sendEBEmail($user['email'], $subject, $message)) {
                 DB::update('user', array('password' => User::encode_password($new_password)), "id={$user_id}");
                 Url::redirect_current(array('action' => 'reset_success'));
             } else {
                 Url::redirect_current(array('action' => 'reset_error'));
             }
         } else {
             Url::redirect('home');
         }
     }
     require_once 'forms/forgot_password.php';
     $this->add_form(new ForgotPasswordForm());
 }
 public function create()
 {
     Session::init();
     if (Session::get('username')) {
         if (!Session::get('admin')) {
             Url::redirect('welcome');
         }
     } else {
         Url::redirect('');
     }
     $data['title'] = 'Application Analytics';
     $data['gender'] = $this->mab->get_gender();
     $data['yearsInSchool'] = $this->mab->get_years_in_school();
     $data['apps'] = $this->mab->get_apps_by_issue();
     $data['apps1'] = $this->mab->get_apps_by_issue_rank(1);
     $data['apps2'] = $this->mab->get_apps_by_issue_rank(2);
     $data['apps3'] = $this->mab->get_apps_by_issue_rank(3);
     $data['apps_by_college'] = $this->mab->get_apps_by_college();
     $data['marketing_data'] = $this->mab->get_marketing_data();
     $data['issues'] = $this->apply_model->getAllIssues();
     if (isset($_POST['submit'])) {
         $issueId = $_POST['issues'];
         $data['issues_by_gender'] = $this->mab->get_issues_by_gender($issueId);
     }
     View::rendertemplate('exec_header', $data);
     View::render('analytics/application_analytics', $data, $error);
     View::rendertemplate('footer', $data);
 }
Exemplo n.º 13
0
 function draw()
 {
     global $display;
     if (User::id() != 0) {
         if (User::$current->data["avatar_url"] != "") {
             $avatar = '<img src="' . AZLib::getImageThumb(User::$current->data["avatar_url"], 100, 100, 0, User::$current->data["img_server"]) . '" />';
         } else {
             $avatar = '<img src="style/images/no_avatar_item.gif" width="94" height="94"/>';
         }
         $display->add('avatar', $avatar);
         $display->add('user_name', User::$current->data["user_name"]);
         $display->add('get_cmd', Url::get('cmd'));
         $display->add('get_action', Url::get('action'));
         $display->add('get_page', Url::get('page'));
         $display->add('get_page', AZNet::$page['name']);
         $display->add('get_cmd', Url::get('cmd'));
         $display->add('user_name', User::user_name());
         $display->add('can_edit_blast', User::is_admin() || !User::is_block());
         $blast = User::$current->data['blast'];
         $avatar_link = '';
         $avatar_url = 'style/images/no_avatar_item.gif';
         if (User::$current->data['avatar_url'] != '') {
             $avatar_link = "http://" . CGlobal::$img_server[User::$current->data['img_server']] . User::$current->data['avatar_url'];
             $avatar_url = AZLib::getImageThumb(User::$current->data['avatar_url'], 80, 80, 0, User::$current->data['img_server']);
         }
         if ($blast == '') {
             $blast = '...';
         } else {
             $blast = ' ' . $blast;
             if (strpos($blast, 'http://')) {
                 $user_blast = $blast;
                 while (strpos($user_blast, 'http://')) {
                     $tmp = substr($user_blast, strpos($user_blast, 'http://'));
                     if (strpos($tmp, ' ') || strpos($tmp, '<')) {
                         if (strpos($tmp, ' ') && strpos($tmp, '<') && strpos($tmp, ' ') > strpos($tmp, '<')) {
                             $blast_url = substr($tmp, 0, strpos($tmp, '<'));
                         } else {
                             $blast_url = substr($tmp, 0, strpos($tmp, ' '));
                         }
                     } else {
                         $blast_url = $tmp;
                     }
                     $user_blast = str_replace($blast_url, '', $user_blast);
                 }
                 $new_blast_url = ' <a rel="nofollow" href="' . $blast_url . '" target="_blank">Click here</a>';
                 $blast = substr($user_blast . $new_blast_url, 1);
             }
         }
         $display->add('avatar_link', $avatar_link);
         $display->add('avatar_url', $avatar_url);
         $display->add('blast', $blast);
         $display->add('user_id', User::id());
         $TopMenu = $display->output('TopMenu', true, 'Personal');
         $display->add('TopMenu', $TopMenu);
         $display->output('change_pass', false, 'Personal');
     } else {
         Url::redirect('home');
     }
 }
Exemplo n.º 14
0
 function RegisterSuccessForm()
 {
     Form::Form('RegisterSuccessForm');
     if (!User::is_login()) {
         Url::redirect('home');
     }
     $this->link_css('style/postItem.css');
 }
Exemplo n.º 15
0
 protected function login()
 {
     if (Router::$IS_AJAX || Router::$IS_IFRAME) {
         $this->renderError('请先登录!');
     }
     $backUrl = Url::getCurrentUrl(array('back-url' => null));
     $url = Url::make('//uc.hqoj.net/login/', array('back-url' => $backUrl));
     Url::redirect($url);
 }
Exemplo n.º 16
0
 /**
  * Logout action
  */
 public function doLogout()
 {
     $user = Registry::getUser();
     if ($user->id) {
         //Logout
         $user->logout();
     }
     //Redirect to index
     Url::redirect();
 }
Exemplo n.º 17
0
 public function create()
 {
     Session::init();
     if (Session::get('username')) {
         if (!Session::get('admin')) {
             Url::redirect('welcome');
         }
     } else {
         Url::redirect('');
     }
     $data['title'] = 'Register Trip';
     $data['site_leaders'] = $this->mab->list_of_site_leaders();
     $data['seasons'] = $this->mab->get_seasons();
     $data['issues'] = $this->mab->get_issues();
     $data['site_leaders'] = $this->mab->get_site_leaders();
     $data['site_leader_names'] = array();
     foreach ($data['site_leaders'] as $site_leader) {
         //$site_leader->fullName = site_leader->firstName;
         array_push($data['site_leader_names'], $site_leader->firstName . ' ' . $site_leader->lastName);
     }
     $data['issues_names'] = array();
     foreach ($data['issues'] as $issue) {
         array_push($data['issues_names'], $issue->issueName);
     }
     $data['season_names'] = array();
     foreach ($data['seasons'] as $season) {
         array_push($data['season_names'], $season->name);
     }
     $issue = $_POST['issue'];
     $site_leader1 = $_POST['site_leader1'];
     $site_leader2 = $_POST['site_leader2'];
     $userName = $_POST['user_name'];
     $seasonId = $_POST['season'];
     if (isset($_POST['create_trip_account'])) {
         $tripId = $this->mab->create_trip_account($issue, $userName, $seasonId);
         if ($tripId == 0) {
             echo 'YOU F****D UP';
         } else {
             $this->mab->update_site_leaders($tripId, $site_leader1);
             $this->mab->update_site_leaders($tripId, $site_leader2);
             $valid_chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNIPQRSTUVWXYZ0123456789';
             $salt = $this->password->generate_salt();
             $random_password = $this->password->get_random_password($valid_chars, 10);
             $passhash = $this->password->get_hash($random_password, $salt);
             $this->mab->insert_into_auth($tripId, $passhash, $salt);
             echo $random_password;
             //burnnnedd
             //M7gho1LC1j
             //winter1 - hycocsvxGD
         }
     }
     View::rendertemplate('exec_header', $data);
     View::render('register/registerTrip', $data, $error);
     View::rendertemplate('footer', $data);
 }
Exemplo n.º 18
0
 function NewsList($row)
 {
     Module::Module($row);
     $news_catid = (int) Url::get('news_catid', 0);
     if ($news_catid) {
         require_once 'forms/NewsList.php';
         $this->add_form(new NewsListForm());
     } else {
         Url::redirect("news");
     }
 }
Exemplo n.º 19
0
 function __construct()
 {
     Form::Form('PublicNewsForm');
     $id = Url::get('id', 0);
     if ($id) {
         $this->news = DB::select("news", "id={$id}");
     }
     if (!$this->name) {
         Url::redirect('admin_news');
     }
 }
Exemplo n.º 20
0
 public function delete()
 {
     $url = Registry::getUrl();
     $id = $_REQUEST["id"] ? $_REQUEST["id"] : $url->vars[0];
     $user = new User($id);
     if ($user->id) {
         if ($user->delete()) {
             Registry::addMessage("Usuario eliminado satisfactoriamente", "success");
         }
     }
     Url::redirect(Url::site("users"));
 }
Exemplo n.º 21
0
 public function delete()
 {
     $url = Registry::getUrl();
     $id = $_REQUEST["id"] ? $_REQUEST["id"] : $url->vars[0];
     $tipo = new Tipo($id);
     if ($tipo->id) {
         if ($tipo->delete()) {
             Registry::addMessage("Tipo de entrada eliminado satisfactoriamente", "success");
         }
     }
     Url::redirect(Url::site("tipos"));
 }
Exemplo n.º 22
0
 public function action_add_item($feed_id)
 {
     $form = Uniform::factory('Krss_Item');
     //check form and feed
     if ($form->sent() and $data = $form->bind($_POST)->check() and $feed = Jelly::select('krss_feed', $feed_id) and $feed->loaded()) {
         $data['feed'] = $feed;
         Jelly::factory('krss_item')->set($data)->save();
         $redirect_to = isset($_GET['redirect_to']) ? $_GET['redirect_to'] : KRSS . '/feed/show/' . $feed_id;
         Url::redirect($redirect_to);
     }
     $this->template->content = View::factory('krss/add_item')->set(array('form' => $form));
 }
Exemplo n.º 23
0
 public function __construct()
 {
     parent::__construct();
     // 校验登陆
     if (empty($this->loginUserInfo)) {
         $this->login();
     }
     // 获取$contestId
     $contestId = (int) Request::getREQUEST('contest-id', 0);
     if (empty($contestId)) {
         $this->render404('比赛ID不存在!');
     }
     // 获取$contestInfo
     $this->contestInfo = OjContestInterface::getDetail(array('id' => $contestId));
     if (empty($this->contestInfo) || $this->contestInfo['hidden']) {
         $this->render404('比赛不存在!');
     }
     if ($this->contestInfo['type'] == ContestVars::TYPE_APPLY) {
         $this->applyInfo = OjContestApplyInterface::getDetail(array('contest_id' => $contestId, 'user_id' => $this->loginUserInfo['id']));
     }
     // 管理员
     $isOjAdmin = RootCommonInterface::allowed(array('user_id' => $this->loginUserInfo['id'], 'path' => '/hqoj/admin'));
     if ($isOjAdmin || $this->contestInfo['user_id'] == $this->loginUserInfo['id']) {
         $this->isContestAdmin = true;
     }
     // 如果未注册,未输入密码,比赛未开始,那么跳转到比赛首页
     if (Router::$CONTROLLER != 'index') {
         if ($this->contestInfo['type'] == ContestVars::TYPE_APPLY) {
             if (empty($this->applyInfo) || $this->applyInfo['status'] != ContestVars::APPLY_ACCEPTED) {
                 $this->setNotice('error', '您未通过报名!');
                 $url = '/?contest-id=' . $contestId;
                 Url::redirect($url);
             }
         } else {
             if ($this->contestInfo['type'] == ContestVars::TYPE_PASSWORD) {
                 if ($this->password != $this->contestInfo['password']) {
                     $this->setNotice('error', '请输入密码!');
                     $url = '/?contest-id=' . $contestId;
                     Url::redirect($url);
                 }
             }
         }
         if (time() < $this->contestInfo['begin_time']) {
             $this->setNotice('error', '比赛未开始!');
             $url = '/?contest-id=' . $contestId;
             Url::redirect($url);
         }
     }
     $this->view->assign(array('contestInfo' => $this->contestInfo, 'applyInfo' => $this->applyInfo, 'password' => $this->password, 'isContestAdmin' => $this->isContestAdmin));
 }
Exemplo n.º 24
0
 public function delete()
 {
     $url = Registry::getUrl();
     $id = $_REQUEST["id"] ? $_REQUEST["id"] : $url->vars[0];
     $mosca = new Mosca($id);
     if ($mosca->id) {
         if ($mosca->delete()) {
             Registry::addMessage("Mosca eliminada satisfactoriamente", "success");
             //Log
             Log::add(LOG_DELETE_MOSCA, $mosca);
         }
     }
     Url::redirect(Url::site("moscas"));
 }
Exemplo n.º 25
0
 function __construct()
 {
     Form::Form('NewsDetailForm');
     $id = Url::get('news_id', 0);
     if ($id) {
         if (!CGlobal::$news_details) {
             CGlobal::$news_details = DB::select("news", "id={$id}");
         }
         if (CGlobal::$news_details && (CGlobal::$news_details['status'] == 1 || CGlobal::$news_details['status'] == 0 && User::have_permit(ADMIN_NEWS))) {
             $this->news = CGlobal::$news_details;
         }
     }
     if (!$this->news) {
         Url::redirect('news_list', array('news_catid', 'azname'));
     } else {
         DB::query("UPDATE news SET view_num=view_num+1 WHERE id =" . $this->news['id']);
     }
     $news_title = $this->news['title'];
     $catid = $this->news['news_catid'];
     $str_keywords = '';
     $str_catSub = '';
     $meta_keywords = '';
     $meta_desc = '';
     if (isset(CGlobal::$allNewsCategories[$catid])) {
         $news_title .= " - " . CGlobal::$allNewsCategories[$catid]['name'];
         $curMainCat = CGlobal::$allNewsCategories[$catid];
         $str_catSub = $curMainCat['name'];
         if ($curMainCat['keywords']) {
             $meta_keywords .= ($meta_keywords ? ', ' : '') . $curMainCat['keywords'];
         }
         if ($curMainCat['description']) {
             $meta_desc .= ($meta_desc ? ', ' : '') . $curMainCat['description'];
         }
     }
     if ($this->news['brief']) {
         CGlobal::$meta_desc = AZLib::cleanHtml($this->news['brief']);
     } elseif ($meta_desc != '') {
         CGlobal::$meta_desc = $meta_desc;
     }
     if ($meta_keywords != '') {
         CGlobal::$keywords = $meta_keywords;
     } elseif ($str_catSub != '') {
         CGlobal::$keywords = $str_catSub;
     }
     CGlobal::$website_title = stripslashes($news_title) . ' - Tin tức';
     //CGlobal::$website_title = AznetLib::subString($news_title,0,100,true);
     //		$this->link_css('style/aznet/jquery.lightbox.css');
     //		$this->link_js('javascript/jquery/lightbox/jquery.lightbox.js');
 }
Exemplo n.º 26
0
 public function create()
 {
     Session::init();
     if (Session::get('username')) {
         if (Session::get('admin')) {
             Url::redirect('exec');
         }
     } else {
         Url::redirect('');
     }
     $data['title'] = 'Draft Board';
     View::rendertemplate('header', $data);
     View::render('draft/draft', $data, $error);
     View::rendertemplate('footer', $data);
 }
Exemplo n.º 27
0
 public function create()
 {
     Session::init();
     if (Session::get('username')) {
         if (!Session::get('admin')) {
             Url::redirect('welcome');
         }
     } else {
         Url::redirect('');
     }
     $data['title'] = 'Register Site Leader';
     View::rendertemplate('exec_header', $data);
     View::render('createAccount/createAccount', $data, $error);
     View::rendertemplate('footer', $data);
 }
Exemplo n.º 28
0
 /**
  * Push Error Message to Session for display on page user is redirected to
  * @param $error_msg  string  Message Text
  * @param $redirect_to_page  string  URL Page Name for Redirect
  */
 public static function push($error_msg, $redirect_to_page = null)
 {
     // Check to see if there is already a error message session
     if (isset($_SESSION['error_message'])) {
         // Clean error message Session
         unset($_SESSION['error_message']);
     }
     // Send error message to session
     $_SESSION['error_message'] = $error_msg;
     // Check to see if a redirect to page is supplied
     if (isset($redirect_to_page)) {
         // Redirect User to Given Page
         Url::redirect($redirect_to_page);
     }
 }
Exemplo n.º 29
0
 public function defaultAction()
 {
     // 如果已经选定专题,那么跳转
     if (Request::getGET('from') == 'nav') {
         $setId = (int) Cookie::get('current_set');
         if ($setId) {
             $url = '/set_problem/?set-id=' . $setId;
             Url::redirect($url);
         }
     }
     Cookie::delete('current_set');
     $pageSize = 50;
     // 获取参数
     $page = Pager::get();
     $title = Request::getGET('title');
     $username = Request::getGET('username');
     // 构建where
     $where = array();
     $where[] = array('hidden', '=', 0);
     if (!empty($title)) {
         $where[] = array('title', 'LIKE', "%{$title}%");
     }
     if (!empty($username)) {
         $userInfo = UserCommonInterface::getByLoginName(array('login_name' => $username));
         $where[] = array('user_id', '=', Arr::get('id', $userInfo, 0));
     }
     // 获取列表
     $order = array('listing_status' => 'DESC', 'refresh_at' => 'DESC', 'id' => 'DESC');
     $offset = ($page - 1) * $pageSize;
     $setList = OjProblemSetInterface::getList(array('where' => $where, 'order' => $order, 'limit' => $pageSize, 'offset' => $offset));
     $allCount = OjProblemSetInterface::getCount($where);
     foreach ($setList as &$setInfo) {
         $problemJson = $setInfo['problem_set'];
         $globalIds = json_decode($problemJson, true);
         $setInfo['count'] = count($globalIds);
     }
     // 获取用户
     $userHash = array();
     if (!empty($setList)) {
         $userIds = array_unique(array_column($setList, 'user_id'));
         $userHash = UserCommonInterface::getById(array('id' => $userIds));
     }
     // 缓存部分的html
     $html = array();
     $html['pager'] = $this->view->fetch(array('renderAllCount' => $allCount, 'renderPageSize' => $pageSize, 'renderRadius' => 8), 'widget/pager.php');
     // 输出
     $this->renderFramework(array('html' => $html, 'setList' => $setList, 'userHash' => $userHash), 'set/list.php');
 }
Exemplo n.º 30
-2
 public function delete()
 {
     $url = Registry::getUrl();
     $id = $_REQUEST["id"] ? $_REQUEST["id"] : $url->vars[0];
     $entrada = new Entrada($id);
     if ($entrada->id) {
         if ($entrada->delete()) {
             Registry::addMessage("Entrada eliminada satisfactoriamente", "success");
             //Log
             Log::add(LOG_DELETE_ENTRADA, $entrada);
         }
     }
     Url::redirect(Url::site("entradas"));
 }