本文整理汇总了PHP中router::redirect方法的典型用法代码示例。如果您正苦于以下问题:PHP router::redirect方法的具体用法?PHP router::redirect怎么用?PHP router::redirect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类router
的用法示例。
在下文中一共展示了router::redirect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct()
{
parent::__construct();
if (!config::item('news_blog', 'news') && uri::segment(1) != 'news') {
router::redirect('news/' . utf8::substr(uri::getURI(), 5));
}
}
示例2: confirm
public function confirm($action = '')
{
// Do we have necessary data?
if (input::get('oauth_token') && input::get('oauth_verifier')) {
// Get temporary access token
$this->initialize(session::item('twitter', 'remote_connect', 'token'), session::item('twitter', 'remote_connect', 'secret'));
$access = $this->twitter->getAccessToken(input::get('oauth_verifier'));
// Do we have temporary token?
if ($access) {
// Get saved token
$token = $this->getToken(0, $access['user_id']);
// Do we have saved token or are we logging in?
if ($token || $action == 'login' && $token) {
$this->users_model->login($token['user_id']);
router::redirect(session::item('slug') . '#home');
} elseif (!$token || $action == 'signup') {
// Get user data
$this->initialize($access['oauth_token'], $access['oauth_token_secret']);
$user = $this->getUser($access['user_id']);
// Do we have user data?
if ($user && isset($user->id)) {
$connection = array('name' => 'twitter', 'twitter_id' => $user->id, 'token' => $access['oauth_token'], 'secret' => $access['oauth_token_secret']);
session::set(array('connection' => $connection), '', 'remote_connect');
$account = array('username' => isset($user->name) ? $user->name : '');
session::set(array('account' => $account), '', 'signup');
router::redirect('users/signup#account');
}
}
}
}
router::redirect('users/login');
}
示例3: signUP
public function signUP($username, $pass, $passControl)
{
if ($pass !== $passControl) {
return 'The passwords do not match.';
}
if (!ctype_alnum(str_replace(array('-', '_'), '', $username))) {
return 'This username contains forbidden characters. Please stick to alphanumerics, hyphens, and underscores.';
}
if (strlen(trim($username)) < 4 || strlen(trim($username)) > 32) {
return 'Your username is either too short or too long. It has to consist of 4-32 characters.';
}
if (strlen(trim($pass)) < 4 || strlen(trim($pass)) > 32) {
return 'This is not a valid password (too short or too long).';
}
$userRows = database::fetchRows('users', 'id', 'name', $username);
if ($userRows->num_rows != 1) {
$user['name'] = trim($username);
$user['password'] = trim($pass);
database::addRow('users', $user);
$_SESSION['user'] = $username;
$_SESSION['loggedIn'] = true;
router::redirect('u/' . $username);
} else {
return 'This username has already been taken.';
}
}
示例4: __construct
public function __construct()
{
parent::__construct();
if (!users_helper::isLoggedin() || !session::permission('site_access_cp', 'system')) {
router::redirect('cp/users/login');
}
}
示例5: _sendFeedback
protected function _sendFeedback()
{
// Check if demo mode is enabled
if (input::demo()) {
return false;
}
// Extra rules
$rules = array('name' => array('rules' => array('required', 'is_string', 'trim', 'min_length' => 2, 'max_length' => 255)), 'email' => array('rules' => array('required', 'is_string', 'trim', 'valid_email', 'min_length' => 4, 'max_length' => 255)), 'subject' => array('rules' => array('required', 'is_string', 'trim', 'min_length' => 5, 'max_length' => 255)), 'message' => array('rules' => array('required', 'is_string', 'trim', 'min_length' => 10, 'max_length' => 10000)));
if (config::item('feedback_captcha', 'feedback') == 1 || config::item('feedback_captcha', 'feedback') == 2 && !users_helper::isLoggedin()) {
$rules['captcha'] = array('rules' => array('is_captcha'));
}
validate::setRules($rules);
// Validate form values
if (!validate::run($rules)) {
return false;
}
// Get values
$email = input::post('email');
$subject = input::post('subject');
$message = input::post('message') . "\n\n--\n" . input::post('name') . ' <' . input::post('email') . '>' . "\n" . input::ipaddress();
// Send feedback
if (!$this->feedback_model->sendFeedback($email, $subject, $message)) {
if (!validate::getTotalErrors()) {
view::setError(__('send_error', 'system'));
}
return false;
}
// Success
view::setInfo(__('message_sent', 'feedback'));
router::redirect('feedback');
}
示例6: __construct
public function __construct()
{
parent::__construct();
// Is this control panel?
if (strtolower(uri::segment(1)) == 'cp' && !$this->isLoggedin() && (uri::segment(2) != 'users' || uri::segment(3) != 'login')) {
router::redirect('cp/users/login');
}
}
示例7: confirm
public function confirm()
{
$class = uri::segment(4);
$action = uri::segment(5) == 'signup' ? 'signup' : 'login';
$service = $this->users_authentication_model->getService($class);
if ($service) {
loader::library('authentication/' . uri::segment(4), $service['settings'], 'users_authentication_' . $class . '_model');
$this->{'users_authentication_' . $class . '_model'}->confirm($action);
}
router::redirect('users/login');
}
示例8: __construct
public function __construct()
{
parent::__construct();
// Is user loggedin ?
if (!users_helper::isLoggedin()) {
router::redirect('users/login');
} elseif (!config::item('visitors_active', 'users')) {
error::show404();
}
loader::model('users/visitors', array(), 'users_visitors_model');
}
示例9: __construct
public function __construct()
{
parent::__construct(true);
// Is user loggedin ?
if (!users_helper::isLoggedin()) {
router::redirect('users/login');
} elseif (!config::item('invoices_active', 'billing')) {
router::redirect('users/settings');
}
loader::model('billing/gateways');
loader::model('billing/transactions');
}
示例10: delete
public function delete()
{
// Get URI vars
$typeID = (int) uri::segment(6);
$fieldID = (int) uri::segment(7);
// Get user type
if (!$typeID || !($type = $this->users_types_model->getType($typeID))) {
view::setError(__('no_type', 'users_types'));
router::redirect('cp/userstypes');
}
// Delete profile question
$this->deleteField('users', 'users_data_' . $type['keyword'], $typeID, $fieldID);
}
示例11: index
public function index()
{
if ($_POST) {
if ($this->model->Feedback($_POST)) {
Session::setSession('done', 'Ваше письмо отправлено!');
router::redirect($_SERVER['REQUEST_URI']);
exit;
} else {
Session::setSession('done', 'Ошибка в отправлении письма!');
router::redirect($_SERVER['REQUEST_URI']);
}
}
}
示例12: checkout
public function checkout()
{
// Get URI vars
$planID = (int) uri::segment(4);
$gatewayID = uri::segment(5);
// Get plan
if (!$planID || !($plan = $this->plans_model->getPlan($planID, false)) || !$plan['active']) {
view::setError(__('no_plan', 'billing_plans'));
router::redirect('billing/plans');
}
$retval = $this->process($gatewayID, session::item('user_id'), 'plans', $planID, $plan['name'], $plan['price'], '', 'billing/plans');
if (!$retval) {
router::redirect('billing/plans/payment/' . $planID);
}
}
示例13: checkout
public function checkout()
{
// Get URI vars
$packageID = (int) uri::segment(4);
$gatewayID = uri::segment(5);
// Get package
if (!$packageID || !($package = $this->credits_model->getPackage($packageID)) || !$package['active']) {
view::setError(__('no_package', 'billing_credits'));
router::redirect('billing/credits');
}
// Set package name
$name = __('credits_info', 'billing_credits', array('%s' => $package['credits']));
$retval = $this->process($gatewayID, session::item('user_id'), 'credits', $packageID, $name, $package['price'], '', 'billing/credits');
if (!$retval) {
router::redirect('billing/credits/payment/' . $packageID);
}
}
示例14: editMyblog
public function editMyblog()
{
if (Session::getSession('id_edit')) {
config::set('heading', 'РЕДАКТИРОВАНИЕ');
$id = Session::getSession('id_edit');
$this->data['one_blog'] = $this->model->getOneBlog($id);
} else {
Session::setSession('error', 'блог с таким идентификатором не найден');
router::redirect(DEFAULT_PATH . 'myblog/');
}
if ($_POST and isset($_POST['edit_done']) and clearData($_POST['edit_done']) and clearData($_POST['edit_done_text']) and clearData($_POST['edit_done_topic'])) {
$id = clearData($_POST['edit_done']);
$text = clearData($_POST['edit_done_text'], true);
$topic = clearData($_POST['edit_done_topic']);
if ($this->model->editRecord($id, $topic, $text)) {
router::redirect($_SERVER['REQUEST_URI']);
} else {
Session::setSession('error', 'Ошибка в редактировании блога!');
router::redirect($_SERVER['REQUEST_URI']);
}
}
}
示例15: process
protected function process($gatewayID, $userID, $type, $productID, $name, $amount, $params = '', $cancel = '', $success = '')
{
// Set return URLs
$cancel = $cancel ? $cancel : 'users/settings';
$success = $success ? $success : 'billing/invoices';
// Get payment type
if (!($type = $this->payments_model->getPaymentType($type))) {
return false;
}
// Get gateway
if (!$gatewayID || !($gateway = $this->gateways_model->getGateway($gatewayID)) || !$gateway['active']) {
view::setError(__('no_gateway', 'billing_gateways'));
return false;
}
// Create invoice
if (!($invoiceID = $this->transactions_model->saveInvoice(0, $userID, $type['type_id'], $productID, $name, $amount, $params))) {
view::setError(__('invoice_error', 'billing_transactions'));
return false;
}
// Get invoice
if (!($invoice = $this->transactions_model->getInvoice($invoiceID))) {
view::setError(__('no_invoice', 'billing_transactions'));
return false;
}
// Load payment library
$payment = loader::library('payments/' . $gateway['keyword'], $gateway['settings'], null);
// Get payment method
$form = $payment->getForm($invoiceID, $name, $amount, $cancel, $success);
// Is this a URL?
if (preg_match('|^\\w+://|i', $form)) {
router::redirect($form);
} elseif (preg_match('|^<form|i', $form)) {
view::load('billing/redirect', array('form' => $form));
return true;
}
view::setError(__('payment_invalid', 'billing_transactions'));
}