本文整理汇总了PHP中App::redirect方法的典型用法代码示例。如果您正苦于以下问题:PHP App::redirect方法的具体用法?PHP App::redirect怎么用?PHP App::redirect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类App
的用法示例。
在下文中一共展示了App::redirect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: s003
/**
* POST /uom
*
*/
public function s003()
{
$error;
try {
$req = App::request();
if ($req->isPost()) {
$post = $req->post();
$attributes = array("uom_nama" => $post["uom_nama"], "aktif" => isset($post["aktif"]) ? 1 : 0);
$table = UOM::table();
if (is_null($post["gen_id"]) || $post["gen_id"] == "") {
$table->insert($attributes);
} else {
$where = "uom_nama = '" . $post["gen_id"] . "'";
$table->update($attributes, $where);
}
}
} catch (Exception $e) {
$error = $e->getMessage();
ZiUtil::unique_error($error);
App::flash('error', $post["uom_nama"] . ' ' . ZiUtil::unique_error($error));
App::redirect('unitOM.a001');
}
App::flash('info', 'Data Tersimpan : ' . $post["uom_nama"]);
App::redirect('unitOM.index');
}
示例2: init
/**
* Initializes the Google Drive connection
*
* @param array $params Any connection params needed
* @return object
**/
public static function init($params = [])
{
// Get the params
$pparams = Plugin::params('filesystem', 'googledrive');
$app_id = isset($params['app_id']) && $params['app_id'] != '' ? $params['app_id'] : $pparams->get('app_id');
$app_secret = isset($params['app_secret']) && $params['app_secret'] != '' ? $params['app_secret'] : $pparams->get('app_secret');
$client = new \Google_Client();
$client->setClientId($app_id);
$client->setClientSecret($app_secret);
$client->addScope(Google_Service_Drive::DRIVE);
$client->setAccessType('offline');
$client->setApprovalPrompt('force');
$client->setIncludeGrantedScopes(true);
if (isset($params['app_token'])) {
$accessToken = $params['app_token'];
// json encode turned our array into an object, we need to undo that
$accessToken = (array) $accessToken;
} else {
\Session::set('googledrive.app_id', $app_id);
\Session::set('googledrive.app_secret', $app_secret);
\Session::set('googledrive.connection_to_set_up', Request::getVar('connection', 0));
// Set upp a return and redirect to Google for auth
$return = Request::getVar('return') ? Request::getVar('return') : Request::current(true);
$return = base64_encode($return);
$redirectUri = trim(Request::root(), '/') . '/developer/callback/googledriveAuthorize';
$client->setRedirectUri($redirectUri);
Session::set('googledrive.state', $return);
App::redirect($client->createAuthUrl());
}
$client->setAccessToken($accessToken);
$service = new \Google_Service_Drive($client);
$adapter = new \Hypweb\Flysystem\GoogleDrive\GoogleDriveAdapter($service, 'root');
return $adapter;
}
示例3: onAfterRoute
/**
* Hook for after parsing route
*
* @return void
*/
public function onAfterRoute()
{
// First, check for presence of subject dn, which is the minimum required field
if (!isset($_SERVER['SSL_CLIENT_S_DN']) || !$_SERVER['SSL_CLIENT_S_DN']) {
\App::redirect($this->params->get('failure_location', '/invalidcert.php'));
return;
}
if (\User::isGuest()) {
// If so, redirect to login
Request::setVar('option', 'com_users');
Request::setVar('task', 'user.login');
Request::setVar('authenticator', 'certificate');
Request::setVar('return', base64_encode(\Request::current()));
return;
}
// Check if user is registered and if current session is linked to cert identity
$hzad = \Hubzero\Auth\Domain::getInstance('authentication', 'certificate', $_SERVER['SSL_CLIENT_I_DN_CN']);
if ($link = \Hubzero\Auth\Link::getInstance($hzad->id, $_SERVER['SSL_CLIENT_S_DN_CN'])) {
if ($link->user_id == \User::get('id')) {
// All clear...return nothing
return;
}
}
// Otherwise, we have a cert-based user that doesn't match the current user
Request::setVar('option', 'com_users');
Request::setVar('task', 'user.logout');
$this->event->stop();
}
示例4: init
/**
* Initializes the github connection
*
* @param array $params Any connection params needed
* @return object
**/
public static function init($params = [])
{
// Get the params
$pparams = Plugin::params('filesystem', 'github');
$app_key = isset($params['app_key']) ? $params['app_key'] : $pparams['app_key'];
$app_secret = isset($params['app_secret']) ? $params['app_secret'] : $pparams['app_secret'];
\Session::set('github.app_key', $app_key);
\Session::set('github.app_secret', $app_secret);
$repository = isset($params['repository']) ? $params['repository'] : $pparams['repository'];
$credentials = [];
if (isset($params['username']) && isset($params['password'])) {
$credentials = [Settings::AUTHENTICATE_USING_PASSWORD, $params['username'], $params['password']];
} else {
$accessToken = Session::get('github.token', false);
if (!$accessToken) {
$base = 'https://github.com/login/oauth/authorize';
$params = '?client_id=' . $app_key;
$scope = '&scope=user,repo';
$return = Request::getVar('return') ? Request::getVar('return') : Request::current(true);
$return = base64_encode($return);
$state = '&state=' . $return;
Session::set('github.state', $return);
App::redirect($base . $params . $scope . $state);
}
$credentials = [Settings::AUTHENTICATE_USING_TOKEN, $accessToken];
}
$settings = new Settings($params['repository'], $credentials);
$api = new Api(new \Github\Client(), $settings);
// Return the adapter
return new GithubAdapter($api);
}
示例5: displayTask
/**
* Pub view for project files, notes etc.
*
* @return void
*/
public function displayTask()
{
require_once PATH_CORE . DS . 'components' . DS . 'com_projects' . DS . 'tables' . DS . 'publicstamp.php';
// Incoming
$stamp = Request::getVar('s', '');
// Clean up stamp value (only numbers and letters)
$regex = array('/[^a-zA-Z0-9]/');
$stamp = preg_replace($regex, '', $stamp);
// Load item reference
$objSt = new Tables\Stamp($this->database);
if (!$stamp || !$objSt->loadItem($stamp)) {
App::redirect(Route::url('index.php?option=' . $this->_option));
return;
}
// Can only serve files or notes at the moment
if (!in_array($objSt->type, array('files', 'notes', 'publications'))) {
App::redirect(Route::url('index.php?option=' . $this->_option));
return;
}
// Serve requested item
$content = Event::trigger('projects.serve', array($objSt->type, $objSt->projectid, $objSt->reference));
// Output
foreach ($content as $out) {
if ($out) {
return $out;
}
}
// Redirect if nothing fetched
App::redirect(Route::url('index.php?option=' . $this->_option));
return;
}
示例6: init
/**
* Initializes the dropbox connection
*
* @param array $params Any connection params needed
* @return \League\Flysystem\Dropbox\DropboxAdapter
**/
public static function init($params = [])
{
// Get the params
$pparams = Plugin::params('filesystem', 'dropbox');
if (isset($params['app_token'])) {
$accessToken = $params['app_token'];
} else {
$info = ['key' => isset($params['app_key']) ? $params['app_key'] : $pparams->get('app_key'), 'secret' => isset($params['app_secret']) ? $params['app_secret'] : $pparams->get('app_secret')];
\Session::set('dropbox.app_key', $info['key']);
\Session::set('dropbox.app_secret', $info['secret']);
\Session::set('dropbox.connection_to_set_up', Request::getVar('connection', 0));
$appInfo = \Dropbox\AppInfo::loadFromJson($info);
$clientIdentifier = 'hubzero-cms/2.0';
$redirectUri = trim(Request::root(), '/') . '/developer/callback/dropboxAuthorize';
$csrfTokenStore = new \Dropbox\ArrayEntryStore($_SESSION, 'dropbox-auth-csrf-token');
$oauth = new \Dropbox\WebAuth($appInfo, $clientIdentifier, $redirectUri, $csrfTokenStore);
// Redirect to dropbox
// We hide the return url in the state field...that's not exactly what
// it was intended for, but it does the trick
$return = Request::getVar('return') ? Request::getVar('return') : Request::current(true);
$return = base64_encode($return);
App::redirect($oauth->start($return));
}
$app_secret = isset($params['app_secret']) ? $params['app_secret'] : $pparams->get('app_secret');
// Create the client
$client = new \Dropbox\Client($accessToken, $app_secret);
// Return the adapter
return new \League\Flysystem\Dropbox\DropboxAdapter($client, isset($params['subdir']) ? $params['subdir'] : null);
}
示例7: getUserMessageListAction
public function getUserMessageListAction()
{
$objRecipient = User::fetchById($this->getParam('user_id'));
if (!is_object($objRecipient)) {
App::redirect('/index/404');
}
$this->view->objRecipient = $objRecipient;
$this->view->objUser = App_Auth::getInstance()->getUser();
}
示例8: validate_login
public static function validate_login()
{
session_regenerate_id();
if (empty($_SESSION['HTTP_USER_AGENT'])) {
App::redirect('security');
}
if (isset($_SESSION) and $_SESSION['HTTP_USER_AGENT'] != md5($_SERVER['HTTP_USER_AGENT'])) {
App::redirect('security/logout');
}
}
示例9: delete
public function delete()
{
$module = $this->registry->core->getParam();
$updateXmlFile = ROOTPATH . 'sql' . DS . $module . DS . 'mysql_update' . DS . 'update.xml';
if (is_file($updateXmlFile)) {
$this->gekoLab->uninstall($updateXmlFile);
}
$this->gekoLab->deletePackageHistory($module);
App::redirect(__ADMINPANE__ . '/gekolab');
}
示例10: handleError
/**
* Method to handle an error condition.
*
* @param Exception &$error The Exception object to be handled.
* @return void
*/
public static function handleError(&$error)
{
$renderer = new \Hubzero\Error\Renderer\Page(App::get('document'), App::get('template')->template, App::get('config')->get('debug'));
// Make sure the error is a 404 and we are not in the administrator.
if (!App::isAdmin() and $error->getCode() == 404) {
// Render the error page.
$renderer->render($error);
}
// Get the full current URI.
$uri = JURI::getInstance();
$current = $uri->toString(array('scheme', 'host', 'port', 'path', 'query', 'fragment'));
// Attempt to ignore idiots.
if (strpos($current, 'mosConfig_') !== false || strpos($current, '=http://') !== false) {
// Render the error page.
$renderer->render($error);
}
// See if the current url exists in the database as a redirect.
$db = App::get('db');
$db->setQuery('SELECT ' . $db->quoteName('new_url') . ', ' . $db->quoteName('published') . ' FROM ' . $db->quoteName('#__redirect_links') . ' WHERE ' . $db->quoteName('old_url') . ' = ' . $db->quote($current), 0, 1);
$link = $db->loadObject();
// If no published redirect was found try with the server-relative URL
if (!$link or $link->published != 1) {
$currRel = $uri->toString(array('path', 'query', 'fragment'));
$db->setQuery('SELECT ' . $db->quoteName('new_url') . ', ' . $db->quoteName('published') . ' FROM ' . $db->quoteName('#__redirect_links') . ' WHERE ' . $db->quoteName('old_url') . ' = ' . $db->quote($currRel), 0, 1);
$link = $db->loadObject();
}
// If a redirect exists and is published, permanently redirect.
if ($link and $link->published == 1) {
App::redirect($link->new_url, null, null, true, false);
} else {
$referer = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER'];
$db->setQuery('SELECT id FROM ' . $db->quoteName('#__redirect_links') . ' WHERE old_url= ' . $db->quote($current));
$res = $db->loadResult();
if (!$res) {
// If not, add the new url to the database.
$query = $db->getQuery(true);
$query->insert($db->quoteName('#__redirect_links'), false);
$columns = array($db->quoteName('old_url'), $db->quoteName('new_url'), $db->quoteName('referer'), $db->quoteName('comment'), $db->quoteName('hits'), $db->quoteName('published'), $db->quoteName('created_date'));
$query->columns($columns);
$query->values($db->Quote($current) . ', ' . $db->Quote('') . ' ,' . $db->Quote($referer) . ', ' . $db->Quote('') . ',1,0, ' . $db->Quote(Date::toSql()));
$db->setQuery($query);
$db->query();
} else {
// Existing error url, increase hit counter
$query = $db->getQuery(true);
$query->update($db->quoteName('#__redirect_links'));
$query->set($db->quoteName('hits') . ' = ' . $db->quoteName('hits') . ' + 1');
$query->where('id = ' . (int) $res);
$db->setQuery((string) $query);
$db->query();
}
// Render the error page.
$renderer->render($error);
}
}
示例11: __construct
public function __construct($message, $code = 0, $messageToLogFile = NULL)
{
parent::__construct($message, $code, $messageToLogFile);
if (__ENABLE_DEBUG__ == 0) {
App::redirect('admin/mainside');
}
$this->errorDesignPath = 'error/index/index.tpl';
echo "<pre>";
echo $this->errorText;
die;
}
示例12: logout
public function logout()
{
if ($this->registry->router->getAdministrativeMode() == 1) {
App::getModel('Frontend/login/login')->destroyAdminAutologinKey();
Session::flush();
App::redirect('login');
} else {
Session::flush();
App::redirect('');
}
}
示例13: __construct
public function __construct($message, $code = 0, $messageToLogFile = NULL)
{
parent::__construct($message, $code, $messageToLogFile);
if (__ENABLE_DEBUG__ == 0) {
App::redirect('admin/mainside');
}
$this->errorDesignPath = 'error/index/index.tpl';
App::getModel('template')->assign('SHOP_NAME', App::getRegistry()->session->getActiveShopName());
App::getModel('template')->assign('error', preg_replace('/(\\n|\\r)+/', '\\n', nl2br(addslashes($this->errorText))));
App::getModel('template')->display($this->errorDesignPath);
die;
}
示例14: __construct
/**
* Construct a new App_test object
*
* @param String $uri an optional relative URI (e.g. "/folder/file")
*/
public function __construct($uri = NULL)
{
$this->is_testing = TRUE;
parent::__construct($uri);
if (Config::get('TESTING_ENABLED') !== TRUE) {
parent::redirect('', array('exit' => TRUE));
}
$this->reset_folder();
$this->test_run = NULL;
// Translations need validating
Translate::validate();
}
示例15: handleError
/**
* Handle an error
*
* @param object $error
* @return void
*/
public static function handleError(&$error)
{
// Make sure the error is a 403 and we are in the frontend.
if ($error->getCode() == 403 and App::isSite()) {
// Redirect to the home page
App::redirect('index.php', Lang::txt('PLG_SYSTEM_LOGOUT_REDIRECT'), null, true, false);
} else {
// Render the error page.
$renderer = new \Hubzero\Error\Renderer\Page(App::get('document'), App::get('template')->template, App::get('config')->get('debug'));
$renderer->render($error);
}
}