当前位置: 首页>>代码示例>>PHP>>正文


PHP Routes::redirect方法代码示例

本文整理汇总了PHP中Routes::redirect方法的典型用法代码示例。如果您正苦于以下问题:PHP Routes::redirect方法的具体用法?PHP Routes::redirect怎么用?PHP Routes::redirect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Routes的用法示例。


在下文中一共展示了Routes::redirect方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 function __construct()
 {
     if (!$this->checkIsUser()) {
         Routes::redirect();
     }
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         $params = array();
         $params['secret'] = '6Lf3ZxMTAAAAANVc5p92ISpeXZp8oTTrOr5WS6iD';
         // Secret key
         if (!empty($_POST) && isset($_POST['g-recaptcha-response'])) {
             $params['response'] = urlencode($_POST['g-recaptcha-response']);
         }
         $params['remoteip'] = $_SERVER['REMOTE_ADDR'];
         $params_string = http_build_query($params);
         $requestURL = 'https://www.google.com/recaptcha/api/siteverify?' . $params_string;
         $curl = curl_init();
         curl_setopt_array($curl, array(CURLOPT_RETURNTRANSFER => 1, CURLOPT_URL => $requestURL));
         $response = curl_exec($curl);
         curl_close($curl);
         $response = @json_decode($response, true);
         if ($response["success"] != true && !$this->checkIsUser()) {
             echo '<h3 class="alert alert-danger">Captcha - bład w weryfikacji</h3>';
         } elseif ($response["success"] || self::$isLogged) {
             if ($this->addPost($_POST)) {
                 header('Location: ' . parent::config()['url']);
             }
         }
     } else {
         $this->setPostModel();
     }
 }
开发者ID:masteruser20,项目名称:Blog,代码行数:31,代码来源:AddPost.php

示例2: __construct

 function __construct($action = 'index', $recordId = null)
 {
     if (!$this->checkIsUser()) {
         Routes::redirect();
     }
     switch ($action) {
         case 'index':
             $this->setAddressBookModel();
             self::$data['action'] = $action;
             break;
         case 'add':
             self::$data['action'] = $action;
             if ($_SERVER['REQUEST_METHOD'] == 'POST') {
                 $this->addContact();
             }
             break;
         case 'delete':
             self::$data['action'] = $action;
             $this->deleteContact($recordId);
             $this->setAddressBookModel();
             break;
         case 'edit':
             self::$data['action'] = $action;
             if ($_SERVER['REQUEST_METHOD'] == 'POST') {
                 $this->addContact($_POST['id_contact']);
             }
             $this->setAddressBookModel((int) $recordId);
             break;
     }
     new Sidebar($this->sideMenuItems());
 }
开发者ID:masteruser20,项目名称:Blog,代码行数:31,代码来源:AddressBook.php

示例3: profile_edit

 /**
  * Edit personnal information
  */
 public function profile_edit($params)
 {
     $this->setView('profile_edit.php');
     $this->setTitle(__('USER_EDIT_TITLE'));
     $is_logged = isset(User_Model::$auth_data);
     $is_student = $is_logged && isset(User_Model::$auth_data['student_number']);
     // Authorization
     if (!$is_student) {
         throw new ActionException('Page', 'error404');
     }
     $user = User_Model::$auth_data;
     // Birthday
     $user['birthday'] = date(__('USER_EDIT_FORM_BIRTHDAY_FORMAT'), strtotime($user['birthday']));
     // Saving data
     if (isset($_POST['mail']) && isset($_POST['msn']) && isset($_POST['jabber']) && isset($_POST['address']) && isset($_POST['zipcode']) && isset($_POST['city']) && isset($_POST['cellphone']) && isset($_POST['phone']) && isset($_POST['birthday'])) {
         try {
             // Other info
             $data = array('mail' => $_POST['mail'], 'msn' => $_POST['msn'], 'jabber' => $_POST['jabber'], 'address' => $_POST['address'], 'zipcode' => $_POST['zipcode'], 'city' => $_POST['city'], 'cellphone' => $_POST['cellphone'], 'phone' => $_POST['phone'], 'birthday' => $_POST['birthday']);
             $this->model->save((int) User_Model::$auth_data['id'], $data);
             Routes::redirect('student', array('username' => User_Model::$auth_data['username']));
         } catch (FormException $e) {
             foreach ($data as $key => $value) {
                 $user[$key] = $value;
             }
             $this->set('form_error', $e->getError());
         }
     }
     $this->set('user', $user);
     $this->addJSCode('User.initEdit();');
 }
开发者ID:hugonicolas,项目名称:Site,代码行数:33,代码来源:User.php

示例4: __construct

 function __construct($mode, $action = null)
 {
     if (!$this->isAdmin()) {
         Routes::redirect();
     }
     self::$data['mode'] = $mode;
     if ($action && isset($action['action'])) {
         $functionToFire = $action['action'] . ucfirst($mode);
         if (isset($action['id'])) {
             self::$data['action'] = $action['action'];
             $this->{$functionToFire}($action['id']);
         } else {
             self::$data['action'] = $action['action'];
             $this->{$functionToFire}();
         }
     }
     $this->{$mode}();
 }
开发者ID:masteruser20,项目名称:Blog,代码行数:18,代码来源:Admin.php

示例5: add

 /**
  * Add a group
  */
 public function add($params)
 {
     $this->setView('add.php');
     $this->setTitle(__('GROUP_ADD_TITLE'));
     $is_logged = isset(User_Model::$auth_data);
     $is_admin = $is_logged && User_Model::$auth_data['admin'] == '1';
     // Authorization
     if (!$is_admin) {
         throw new ActionException('Page', 'error404');
     }
     $group = array();
     // Saving data
     if (isset($_POST['name']) && isset($_POST['creation_date']) && isset($_POST['mail']) && isset($_POST['description'])) {
         $uploaded_files = array();
         try {
             // Members
             $members = array();
             if (isset($_POST['members_ids']) && is_array($_POST['members_ids'])) {
                 foreach ($_POST['members_ids'] as $id) {
                     if (ctype_digit($id)) {
                         $id = (int) $id;
                         $members[$id] = array('title' => isset($_POST['member_title_' . $id]) ? $_POST['member_title_' . $id] : '', 'admin' => isset($_POST['member_admin_' . $id]));
                     }
                 }
             }
             // Other info
             $data = array('name' => $_POST['name'], 'creation_date' => $_POST['creation_date'], 'mail' => $_POST['mail'], 'description' => $_POST['description'], 'members' => $members);
             // Avatar
             if (isset($_FILES['avatar']) && !is_array($_FILES['avatar']['name'])) {
                 if ($_FILES['avatar']['size'] > Config::UPLOAD_MAX_SIZE_PHOTO) {
                     throw new FormException('avatar');
                 }
                 if ($avatarpath = File::upload('avatar')) {
                     $uploaded_files[] = $avatarpath;
                     try {
                         $img = new Image();
                         $img->load($avatarpath);
                         $type = $img->getType();
                         if ($type == IMAGETYPE_JPEG) {
                             $ext = 'jpg';
                         } else {
                             if ($type == IMAGETYPE_GIF) {
                                 $ext = 'gif';
                             } else {
                                 if ($type == IMAGETYPE_PNG) {
                                     $ext = 'png';
                                 } else {
                                     throw new Exception();
                                 }
                             }
                         }
                         if ($img->getWidth() > 800) {
                             $img->setWidth(800, true);
                         }
                         $img->setType(IMAGETYPE_JPEG);
                         $img->save($avatarpath);
                         // Thumb
                         $avatarthumbpath = $avatarpath . '.thumb';
                         $img->thumb(Config::$AVATARS_THUMBS_SIZES[0], Config::$AVATARS_THUMBS_SIZES[1]);
                         $img->setType(IMAGETYPE_JPEG);
                         $img->save($avatarthumbpath);
                         unset($img);
                         $uploaded_files[] = $avatarthumbpath;
                         $data['avatar_path'] = $avatarthumbpath;
                         $data['avatar_big_path'] = $avatarpath;
                     } catch (Exception $e) {
                         throw new FormException('avatar');
                     }
                 }
             }
             $url_name = $this->model->create($data);
             Routes::redirect('group', array('group' => $url_name));
         } catch (FormException $e) {
             foreach ($uploaded_files as $uploaded_file) {
                 File::delete($uploaded_file);
             }
             foreach ($data as $key => $value) {
                 $group[$key] = $value;
             }
             $group['members'] = Student_Model::getInfoByUsersIds(array_keys($members));
             foreach ($group['members'] as &$member) {
                 if (isset($members[(int) $member['user_id']])) {
                     $member['title'] = $members[(int) $member['user_id']]['title'];
                     $member['admin'] = $members[(int) $member['user_id']]['admin'] ? '1' : '0';
                 }
             }
             $this->set('form_error', $e->getError());
         }
     }
     $this->set('group', $group);
     $this->addJSCode('Group.initEdit();');
 }
开发者ID:Godefroy,项目名称:iseplive,代码行数:95,代码来源:Group.php

示例6: edit

 /**
  * Edit a user
  */
 public function edit($params)
 {
     $this->setView('edit.php');
     $is_logged = isset(User_Model::$auth_data);
     $is_admin = $is_logged && User_Model::$auth_data['admin'] == '1';
     // Authorization
     if (!$is_admin) {
         throw new ActionException('Page', 'error404');
     }
     try {
         $student = $this->model->getInfo($params['username']);
     } catch (Exception $e) {
         throw new ActionException('Page', 'error404');
     }
     $this->setTitle(__('STUDENT_EDIT_TITLE', array('username' => $student['username'])));
     // Birthday
     $student['birthday'] = date(__('USER_EDIT_FORM_BIRTHDAY_FORMAT'), strtotime($student['birthday']));
     // Saving data
     if (isset($_POST['mail']) && isset($_POST['msn']) && isset($_POST['jabber']) && isset($_POST['address']) && isset($_POST['zipcode']) && isset($_POST['city']) && isset($_POST['cellphone']) && isset($_POST['phone']) && isset($_POST['birthday']) && isset($_POST['firstname']) && isset($_POST['lastname']) && isset($_POST['student_number']) && isset($_POST['promo'])) {
         $uploaded_files = array();
         try {
             // Other info
             $user_data = array('mail' => $_POST['mail'], 'msn' => $_POST['msn'], 'jabber' => $_POST['jabber'], 'address' => $_POST['address'], 'zipcode' => $_POST['zipcode'], 'city' => $_POST['city'], 'cellphone' => $_POST['cellphone'], 'phone' => $_POST['phone'], 'birthday' => $_POST['birthday']);
             $student_data = array('firstname' => $_POST['firstname'], 'lastname' => $_POST['lastname'], 'student_number' => $_POST['student_number'], 'promo' => $_POST['promo'], 'cesure' => isset($_POST['cesure']));
             // Avatar
             if (isset($_FILES['avatar']) && !is_array($_FILES['avatar']['name'])) {
                 if ($_FILES['avatar']['size'] > Config::UPLOAD_MAX_SIZE_PHOTO) {
                     throw new FormException('avatar');
                 }
                 if ($avatarpath = File::upload('avatar')) {
                     $uploaded_files[] = $avatarpath;
                     try {
                         $img = new Image();
                         $img->load($avatarpath);
                         $type = $img->getType();
                         if ($type == IMAGETYPE_JPEG) {
                             $ext = 'jpg';
                         } else {
                             if ($type == IMAGETYPE_GIF) {
                                 $ext = 'gif';
                             } else {
                                 if ($type == IMAGETYPE_PNG) {
                                     $ext = 'png';
                                 } else {
                                     throw new Exception();
                                 }
                             }
                         }
                         if ($img->getWidth() > 800) {
                             $img->setWidth(800, true);
                         }
                         $img->setType(IMAGETYPE_JPEG);
                         $img->save($avatarpath);
                         // Thumb
                         $avatarthumbpath = $avatarpath . '.thumb';
                         $img->thumb(Config::$AVATARS_THUMBS_SIZES[0], Config::$AVATARS_THUMBS_SIZES[1]);
                         $img->setType(IMAGETYPE_JPEG);
                         $img->save($avatarthumbpath);
                         unset($img);
                         $uploaded_files[] = $avatarthumbpath;
                         $student_data['avatar_path'] = $avatarthumbpath;
                         $student_data['avatar_big_path'] = $avatarpath;
                     } catch (Exception $e) {
                         throw new FormException('avatar');
                     }
                 }
             }
             $user_model = new User_Model();
             $user_model->save((int) $student['id'], $user_data);
             $this->model->save($student['username'], $student_data);
             Routes::redirect('student', array('username' => $params['username']));
         } catch (FormException $e) {
             foreach ($uploaded_files as $uploaded_file) {
                 File::delete($uploaded_file);
             }
             foreach ($student_data as $key => $value) {
                 $student[$key] = $value;
             }
             foreach ($user_data as $key => $value) {
                 $student[$key] = $value;
             }
             $this->set('form_error', $e->getError());
         }
     }
     $this->set('student', $student);
     $this->addJSCode('User.initEdit();');
 }
开发者ID:Godefroy,项目名称:iseplive,代码行数:90,代码来源:Student.php


注:本文中的Routes::redirect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。