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


PHP site::redirect方法代码示例

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


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

示例1: success

 }
 public static function success($note, $redirect = false)
 {
     self::add('success', $note);
     if ($redirect) {
         site::redirect($redirect);
         die;
     }
开发者ID:artbypravesh,项目名称:morningpages,代码行数:8,代码来源:notes.php

示例2: action_twittercallback

 public function action_twittercallback()
 {
     if (arr::get($_GET, 'denied', false)) {
         notes::error('Seems like you didn\'t want to log in with Twitter anyway. Feel free to try again if it was a mistake!');
         site::redirect();
     }
     $token = arr::get($_GET, 'oauth_token', false);
     $verifier = arr::get($_GET, 'oauth_verifier', false);
     if (!$token || !$verifier) {
         notes::error('Something went wrong in the process, and we didn\'t get the expected data back from Twitter. Please try again');
         site::redirect();
     }
     $connection = new TwitterOAuth(arr::get($this->creds, 'key'), arr::get($this->creds, 'secret'), Session::instance()->get_once('twitter_oauth_token'), Session::instance()->get_once('twitter_oauth_token_secret'));
     $token = $connection->getAccessToken($verifier);
     $oauth_token = arr::get($token, 'oauth_token', '');
     $oauth_token_secret = arr::get($token, 'oauth_token_secret', '');
     $user_id = arr::get($token, 'user_id', '');
     $screen_name = arr::get($token, 'screen_name', '');
     $oauth = ORM::factory('Oauth')->where('type', '=', 'twitter')->where('token', '=', $oauth_token)->find();
     if ($oauth->loaded()) {
         try {
             $user = $oauth->user;
             user::force_login($user);
         } catch (exception $e) {
             if ($user->loaded()) {
                 if (user::logged()) {
                     // Random error, but user got logged in. We don't care, YOLO!
                 } else {
                     notes::error('Whoops! Something wen\'t wrong and we couldn\'t log you in. Please try again or send us a message if the problem persists.');
                     Kohana::$log->add(Log::ERROR, '1. Couldnt log user in: ' . $e->getMessage());
                 }
             }
         }
         site::redirect('write');
     } else {
         try {
             $user = ORM::factory('User');
             $user->username = $screen_name;
             $user->validation_required(false)->save();
             $user->add_role('login');
             $oauth = ORM::factory('Oauth');
             $oauth->user_id = $user->id;
             $oauth->type = 'twitter';
             $oauth->token = $oauth_token;
             $oauth->token_secret = $oauth_token_secret;
             $oauth->service_id = $user_id;
             $oauth->screen_name = $screen_name;
             $oauth->save();
             user::force_login($user);
         } catch (exception $e) {
             Kohana::$log->add(Log::ERROR, '2. Couldnt create user: ' . $e->getMessage());
             notes::error('Whoops! Something wen\'t wrong and we couldn\'t log you in. Please try again or send us a message if the problem persists.');
         }
         site::redirect('/write');
     }
 }
开发者ID:artbypravesh,项目名称:morningpages,代码行数:56,代码来源:Auth.php

示例3: action_show

 public function action_show()
 {
     $token = $this->request->param('id');
     $mail = ORM::factory('Mail')->where('token', '=', $token)->find();
     if ($mail->loaded()) {
         $view = View::factory('templates/mail');
         $view->mail = $mail;
         echo $view;
     } else {
         notes::add('error', 'Mail not found!');
         site::redirect('');
         die;
     }
 }
开发者ID:artbypravesh,项目名称:morningpages,代码行数:14,代码来源:Mail.php

示例4: add

    /**
	 * Add a message to the "popnotes" session.
	 * @param String Type of message.
	 * @param String Message
	 * @return void
	 */
    public static function add($type, $note, $redirect = false)
    {
        $session = Session::instance();
        $popnotes = $session->get('popnotes');
        if (!$popnotes) {
            $popnotes = array();
        }
        $content = array('type' => $type, 'note' => $note);
        $popnotes[] = $content;
        $session->set('popnotes', $popnotes);
开发者ID:artbypravesh,项目名称:morningpages,代码行数:16,代码来源:notes.php

示例5: require_login

 public function require_login($msg = true, $redirect = false)
 {
     if ($msg === true) {
         $msg = 'You must be logged in to see this page';
     }
     if (!user::logged()) {
         if ($msg) {
             notes::error($msg);
         }
         if ($redirect) {
             site::redirect($redirect);
         } else {
             user::redirect('login');
         }
     }
 }
开发者ID:artbypravesh,项目名称:morningpages,代码行数:16,代码来源:Project.php

示例6: before

 public function before()
 {
     if (!user::logged('admin') && $this->request->action() !== 'media') {
         site::redirect();
     }
     if ($this->request->action() === 'media' || $this->request->action() === 'uploads') {
         // Do not template media files
         $this->auto_render = FALSE;
     } else {
         parent::before();
         $this->template->controller = str_replace('cms_', '', $this->request->controller());
         $this->template->action = $this->request->action();
         $file = $this->template->controller . '/' . $this->template->action;
         $file = str_replace('_', '/', $file);
         if (file_exists(Kohana::find_file('views', $file))) {
             $this->template->view = View::factory($file);
         }
     }
 }
开发者ID:artbypravesh,项目名称:morningpages,代码行数:19,代码来源:Cms.php

示例7: action_contact

 public function action_contact()
 {
     $errors = false;
     if ($_POST) {
         $val = Validation::factory($_POST);
         $val->rule('sprot', 'exact_length', array(':value', 1));
         $val->rule('email', 'not_empty');
         $val->rule('email', 'email');
         $val->rule('suggestion', 'not_empty');
         if ($val->check()) {
             notes::success('Your message has been sent and we will get back to you as soon as possible. Thanks!');
             $mail = mail::create('suggestion')->to('morningpagesnet@gmail.com')->from(arr::get($_POST, 'email', ''))->content(arr::get($_POST, 'suggestion') . '<br /><br />.E-mail: ' . arr::get($_POST, 'email', ''))->subject('Message to ' . site::option('sitename'))->send();
             site::redirect('contact');
         } else {
             $errors = $val->errors('suggestions');
         }
     }
     $this->bind('errors', $errors);
     seo::instance()->title("Contact Morning Pages");
     seo::instance()->description("Feel free to contact MorningPages.net if you have questions or concerns about your account, the site or for more information regarding your Morning Pages.");
 }
开发者ID:artbypravesh,项目名称:morningpages,代码行数:21,代码来源:Page.php

示例8: action_talk

 public function action_talk()
 {
     $tag = $this->request->param('tag');
     $talk = $this->request->param('talk');
     if (user::logged()) {
         // Iterate views
         if ($talk->user_id != user::get()->id) {
             $talk->views = $talk->views + 1;
             try {
                 $talk->save();
             } catch (ORM_Validation_Exception $e) {
                 //var_dump($e->errors());
             }
         }
         // Set when the user last saw the topic
         $user = user::get();
         $viewed = $user->talkviews->where('talk_id', '=', $talk->id)->find();
         if (!$viewed->loaded()) {
             $viewed->user_id = $user->id;
             $viewed->talk_id = $talk->id;
         }
         $viewed->last = time();
         $viewed->save();
     }
     $replies = $talk->replies->where('op', '!=', 1);
     $counter = $talk->replies->where('op', '!=', 1);
     $limit = Kohana::$config->load('talk')->get('pagination_limit');
     $numreplies = $counter->count_all();
     $numpages = ceil($numreplies / $limit);
     $page = (int) arr::get($_GET, 'page', 0);
     if ($_POST) {
         $this->require_login();
         $reply = ORM::factory('Talkreply');
         $reply->values($_POST);
         $reply->user_id = user::get()->id;
         $reply->talk_id = $talk->id;
         try {
             $reply->save();
             $page = $numpages;
             $talk->last_reply = time();
             $talk->save();
             $subscriptions = $talk->subscriptions->find_all();
             if ((bool) $subscriptions->count()) {
                 foreach ($subscriptions as $subscription) {
                     if ($subscription->user_id != $reply->user_id) {
                         mail::create('talkreplyposted')->to($subscription->user->email)->tokenize(array('username' => $subscription->user->username, 'sendername' => $reply->user->username, 'title' => $talk->title, 'reply' => $reply->content, 'link' => HTML::anchor(URL::site($talk->url() . '?page=' . $page . '#comment-' . $reply->id, 'http'), $talk->title)))->send();
                     }
                 }
             }
             $vote = ORM::factory('User_Talkvote');
             $vote->type = 'talkreply';
             $vote->user_id = user::get()->id;
             $vote->object_id = $reply->id;
             $vote->save();
             notes::success('Your reply has been posted.');
             site::redirect($talk->url() . '?page=' . $page . '#comment-' . $reply->id);
         } catch (ORM_Validation_Exception $e) {
             notes::error('Whoops! Your submission contained errors. Please review it and submit again');
             $errors = $e->errors();
         }
     }
     if ($page < 1) {
         $page = 1;
     }
     if ($page > $numpages) {
         $page = $numpages;
     }
     $replies = $replies->limit($limit);
     if ($page - 1 > 0) {
         $replies = $replies->offset($limit * ($page - 1));
     }
     $replies = $replies->find_all();
     $this->bind('tag', $tag);
     $this->bind('talk', $talk);
     $this->bind('replies', $replies);
     $this->bind('tags', ORM::factory('Talktag')->find_all());
     $this->bind('numpages', $numpages);
     $this->bind('currentpage', $page);
     seo::instance()->title($talk->title);
     seo::instance()->description("Talk About Morning Pages, or anything else you might find interesting. Use this area to ask questions, make friends, or find out information about Morning Pages.");
 }
开发者ID:artbypravesh,项目名称:morningpages,代码行数:81,代码来源:Talk.php

示例9: action_signup

 public function action_signup()
 {
     $errors = false;
     $password = false;
     if ($_POST) {
         $user = ORM::factory('User');
         try {
             user::create($_POST);
             notes::add('success', 'You are now signed up. Welcome!');
             if (user::logged()) {
                 site::redirect('write');
             } else {
                 // should log this error (user wasnt logged in with user::create())
                 user::redirect('login');
             }
         } catch (ORM_Validation_Exception $e) {
             $errors = $e->errors('models');
         }
     }
     $this->bind('errors', $errors);
 }
开发者ID:artbypravesh,项目名称:morningpages,代码行数:21,代码来源:User.php

示例10: format_post

// Création de l'objet soap
if ($royaume->is_online()) {
    $soap = new TCSoap(array('soap_user' => $array_soap['soap_user'], 'soap_pass' => $array_soap['soap_pass'], 'soap_port' => $array_soap['soap_port'], 'addr' => $array_soap['addr']));
}
function format_post($post)
{
    return htmlentities($post, ENT_QUOTES, 'UTF-8');
}
if (count($_POST) < 100) {
    array_map('format_post', $_POST);
}
$injection_detect = false;
foreach ($_POST as $result) {
    if ($site->sqlDetect($result)) {
        $injection_detect = true;
    }
}
if ($injection_detect == true) {
    $site->redirect('index.php?page=home', 0);
}
require_once 'model/model_header.php';
if (!empty($model)) {
    require_once $model;
    // Appel du modele de la page
}
$sql->deconnexion();
// Déconnexion de la base de données
ob_start();
require_once "view/view.php";
// Appel de la vue de la page
ob_end_flush();
开发者ID:Goret,项目名称:Site_ava,代码行数:31,代码来源:controleur.php


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