コード例 #1
0
ファイル: LoginGuard.php プロジェクト: pleonasm/bsg
 /**
  *
  */
 public function __invoke()
 {
     $loggedIn = $this->loginContext->currentUser();
     if (!$loggedIn) {
         $this->redirector->redirect(303, '/');
         return false;
     }
     return true;
 }
コード例 #2
0
ファイル: AuthComponent.php プロジェクト: reallysend/miniPHP
 /**
  * Handles unauthenticated access attempt.
  *
  */
 public function unauthenticated()
 {
     $this->controller->login->logOut(Session::getUserId());
     if ($this->request->isAjax()) {
         $this->controller->response->setStatusCode(403)->send();
     } else {
         Redirector::Login();
     }
 }
コード例 #3
0
ファイル: TodoController.php プロジェクト: mrSerg161/miniPHP
 public function delete()
 {
     $todoId = Encryption::decryptIdWithDash($this->request->data("todo_id"));
     $this->todo->delete($todoId);
     // in case of normal post request
     Session::set('success', "Todo has been deleted");
     Redirector::to(PUBLIC_ROOT . "Todo");
     // in case of ajax
     // echo $this->view->JSONEncode(array("success" => "Todo has been deleted"));
 }
コード例 #4
0
ファイル: application.php プロジェクト: alex-ch/test
    public function render()
    {
        error_reporting(E_ALL);
        ini_set('display_errors', 1);
        Application::loadLibrary('olmi/request');
        Application::loadLibrary('core/router');
        $url = ltrim($_SERVER['REQUEST_URI'], '/');
        $user_session = Application::getUserSession();
        $user_logged = $user_session->getUserAccount();
        Router::setDefaultModuleName($user_logged ? 'profile' : 'login');
        Router::route($url);
        $page = Application::getPage();
        $page = Application::getPage();
        $page->setTitle('OCS');
        $page->addMeta(array('name' => 'viewport', 'content' => 'width=device-width, initial-scale=1'));
        $page->addMeta(array('charset' => 'utf-8'));
        $page->addStylesheet(coreResourceLibrary::getStaticPath('/bootstrap/css/bootstrap.min.css'));
        $page->addStylesheet(coreResourceLibrary::getStaticPath('/bootstrap/css/bootstrap-theme.min.css'));
        $page->addStylesheet(coreResourceLibrary::getStaticPath('jquery-ui/jquery-ui-bootstrap.css'));
        $page->addStylesheet(coreResourceLibrary::getStaticPath('/css/admin.css'));
        $page->addScript(coreResourceLibrary::getStaticPath('/js/jquery-1.11.3.min.js'));
        $page->addScript(coreResourceLibrary::getStaticPath('/jquery-ui/jquery-ui.min.js'));
        $page->addScript(coreResourceLibrary::getStaticPath('/bootstrap/js/bootstrap.min.js'));
        $page->addScript(coreResourceLibrary::getStaticPath('/js/application.js'));
        $page->addLiteral('
				<script type="text/javascript">
					jQuery(document).ready(function(){
						App.init();
					});
				</script>
			
			');
        $smarty = Application::getSmarty();
        $module_name = Router::getModuleName();
        $module_params = Router::getModuleParams();
        if ($module_name) {
            $module = Application::getResourceInstance('module', $module_name);
            if (coreAccessControlLibrary::accessAllowed($user_logged, $module)) {
                $content = call_user_func(array($module, 'run'), $module_params);
            } else {
                Application::stackError(Application::gettext('You have no permission to login'));
                $user_session->logout();
                Redirector::redirect(Application::getSeoUrl('/login?back=' . Router::getSourceUrl()));
            }
        } else {
            $content = Application::runModule('page404');
        }
        $smarty->assign('content', $content);
        $html_head = $page->getHtmlHead();
        $smarty->assign('html_head', $html_head);
        /*$smarty->assign('header', Application::getBlock('header'));
        		$smarty->assign('footer', Application::getBlock('footer'));*/
        $template_path = coreResourceLibrary::getTemplatePath('index');
        $smarty->display($template_path);
    }
コード例 #5
0
 public static function RedirectToModule($module, $subModule, $action, $type, $params = '', $replace = FALSE, $code = NULL)
 {
     if (self::$mRedirected && !$replace) {
         return;
     }
     /*
      * modified by galih galih@gmail.com
      * add ascomponent paramater when first request from html send ascomponent parameter too
      */
     if (isset($_GET['ascomponent'])) {
         $location .= '&ascomponent=1';
     }
     self::$mRedirected = TRUE;
     self::$mRedirectedTo = Dispatcher::Instance()->GetUrl($module, $subModule, $action, $type) . '&' . $params;
     header('Location: ' . self::$mRedirectedTo, $replace, $code);
 }
コード例 #6
0
 /**
  * Try to process an error with Error controller
  * If it fails, redirect to default main page
  * @param string $module Current module
  * @param number $errorNum
  * @return boolean
  */
 static function loadError($module, $errorNum)
 {
     // Prepare error num function
     $errorAction = 'e' . $errorNum;
     // Try to open the app error controller
     $file = kw::$app_dir . 'private/modules/' . $module . '/controllers/errors.php';
     if (is_file($file)) {
         include $file;
         // It can be a child from errorsController, for this reason don't use "instanceof"
         $obj = new errorsController($module, 'errors', $errorAction);
         $obj->main();
         // If no exist, it will load a generic function (__call())
         return true;
     }
     // FAIL... redirect to the main page
     Redirector::url(kw::$dir);
     return false;
 }
コード例 #7
0
ファイル: index.php プロジェクト: rockbarato/Redirector
<?php

require 'Redirector.php';
define('ANDROID_URL', 'https://play.google.com/store/apps/details?id=com.android.chrome&hl=es_419');
define('iOS_URL', 'https://itunes.apple.com/us/app/chrome-web-browser-by-google/id535886823?mt=8');
define('OPTIONAL_URL', 'https://www.google.com/chrome/');
try {
    $redirector = new Redirector(ANDROID_URL, iOS_URL, OPTIONAL_URL);
    $redirector->distribute();
} catch (Exception $e) {
    echo 'Excepción: ', $e->getMessage();
}
コード例 #8
0
 /**
  * logout
  *
  */
 public function logOut()
 {
     $this->login->logOut(Session::getUserId());
     Redirector::login();
 }
コード例 #9
0
ファイル: webHandler.php プロジェクト: rasismeiro/cintient
            $value = ucfirst($value);
        });
        $GLOBALS['templateMethod'] = lcfirst(implode($subSectionPieces));
    }
    if ($GLOBALS['section'] != 'default') {
        $GLOBALS['templateFile'] = $GLOBALS['section'] . '/' . $GLOBALS['subSection'] . '.tpl';
        $GLOBALS['templateMethod'] = $GLOBALS['section'] . '_' . $GLOBALS['templateMethod'];
    }
    if (method_exists('TemplateManager', $GLOBALS['templateMethod'])) {
        #if DEBUG
        SystemEvent::raise(SystemEvent::DEBUG, "Routing to known template function. [FUNCTION=TemplateManager::{$GLOBALS['templateMethod']}] [URI={$GLOBALS['uri']}]", __METHOD__);
        #endif
        TemplateManager::$GLOBALS['templateMethod']();
        $GLOBALS['smarty']->assign('globals_settings', $GLOBALS['settings']);
        $GLOBALS['smarty']->assign('globals_section', $GLOBALS['section']);
        $GLOBALS['smarty']->assign('globals_subSection', $GLOBALS['subSection']);
        $GLOBALS['smarty']->assign('globals_user', $GLOBALS['user']);
        $GLOBALS['smarty']->assign('globals_project', $GLOBALS['project']);
        ob_end_clean();
        $GLOBALS['smarty']->display($GLOBALS['templateFile']);
        exit;
    }
    #if DEBUG
    SystemEvent::raise(SystemEvent::DEBUG, "Unknown template function. [FUNCTION=TemplateManager::{$GLOBALS['templateMethod']}] [URI={$GLOBALS['uri']}]", __METHOD__);
    #endif
}
/* +----------------------------------------------------------------+ *\
|* | RESTAURANT AT THE END OF THE UNIVERSE                          | *|
\* +----------------------------------------------------------------+ */
Redirector::redirectAndExit(Redirector::NOT_FOUND);
コード例 #10
0
 function RequestDenied()
 {
     $dbMsg = SysLog::Instance()->getAllError();
     print_r($dbMsg);
     if ($this->IsLoggedIn()) {
         echo "Request denied, insufficient access permission!";
         SysLog::Instance()->log('Security: Request denied, insufficient access permission!', 'security');
     } else {
         // hasn't logged in yet or session expired, do redirect to login page
         if ($_SERVER['HTTP_X_GTFWXHRREQUESTSIGNATURE'] != '') {
             // yes, it is breaking the http rule as the http 401 error isn't meant
             // to use with redirection, but this http error code comes handy
             // when handling xhr request since the xhr object transparently
             // follow http redirection which isn't desired by this framework
             // so, an http 401 error will include a redirection header
             // at the end, instead of embedding page within page, user will be
             // redirected to login page
             $error_code = 401;
         } else {
             $error_code = NULL;
         }
         Redirector::RedirectToUrl($this->mAuthentication->GetLoginPage(), TRUE, $error_code, FALSE);
     }
 }
コード例 #11
0
 function Dispatch()
 {
     // send header first
     header('Cache-Control: no-cache, must-revalidate');
     header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
     if (isset($_SERVER['HTTP_X_GTFWMODULETYPE'])) {
         $type = $_SERVER['HTTP_X_GTFWMODULETYPE'];
     } else {
         $type = null;
     }
     //SysLog::Log("HEADER: " .$_SERVER['X-GtfwModuleType'], 'dispatcher');
     SysLog::Log("HEADER: " . $type, 'dispatcher');
     $module = '';
     $submodule = '';
     $action = '';
     $type = '';
     if (Configuration::Instance()->GetValue('application', 'url_type') == 'Long') {
         if (isset($_REQUEST['mod']) && isset($_REQUEST['sub']) && isset($_REQUEST['act']) && isset($_REQUEST['typ']) || $_REQUEST['typ'] == "rest") {
             // hack for requests/responses that don't need obfuscation
             if (in_array($_REQUEST['typ'], Configuration::Instance()->GetValue('application', 'url_obfuscator_exception'))) {
                 Configuration::Instance()->RegisterHook($this);
             }
             //
             $module = $this->Decrypt($_REQUEST['mod']);
             $submodule = $this->Decrypt($_REQUEST['sub']);
             $action = $this->Decrypt($_REQUEST['act']);
             $type = $this->Decrypt($_REQUEST['typ']);
             SysLog::Log("Long URL \$_REQUEST", 'dispatcher');
         } else {
             SysLog::Log("No \$_REQUEST set for Long URL {$_REQUEST['mod']}", 'dispatcher');
         }
     } elseif (Configuration::Instance()->GetValue('application', 'url_type') == 'Short') {
         if (isset($_REQUEST['mid'])) {
             $module_id = $this->Decrypt($_REQUEST['mid']);
             $request_translated = $this->TranslateRequestToLong($module_id);
             if (is_array($request_translated)) {
                 $module = $request_translated[0];
                 $submodule = $request_translated[1];
                 $action = $request_translated[2];
                 $type = $request_translated[3];
             }
         }
     } elseif (Configuration::Instance()->GetValue('application', 'url_type') == 'Path') {
         list(, , $module, , $submodule, , $action, , $type, ) = explode('/', $_SERVER['PATH_INFO']);
         $module = $this->Decrypt($module);
         $submodule = $this->Decrypt($submodule);
         $action = $this->Decrypt($action);
         $type = $this->Decrypt($type);
     }
     SysLog::Log("Translated request: {$module}/{$submodule}/{$action}/{$type} from " . print_r($_REQUEST, true), 'dispatcher');
     // default
     if ($module == '' && $submodule == '' && $action == '' && $type == '') {
         $module = Configuration::Instance()->GetValue('application', 'default_module');
         $submodule = Configuration::Instance()->GetValue('application', 'default_submodule');
         $action = Configuration::Instance()->GetValue('application', 'default_action');
         $type = Configuration::Instance()->GetValue('application', 'default_type');
     }
     // hack to overide any typ specified before.
     if (isset($_COOKIE['GtfwModuleType'])) {
         $type = $_COOKIE['GtfwModuleType']->Raw();
         // delete the cookie
         setcookie('GtfwModuleType', '', mktime(5, 0, 0, 7, 26, 1997));
     }
     if (isset($_SERVER['HTTP_X_GTFWMODULETYPE'])) {
         $type = $_SERVER['HTTP_X_GTFWMODULETYPE'];
     }
     SysLog::Log("Final request: {$module}/{$submodule}/{$action}/{$type}", 'dispatcher');
     $this->mModule = $module;
     $this->mSubModule = $submodule;
     $this->mAction = $action;
     $this->mType = $type;
     if (class_exists('ServiceSecurity')) {
         if (ServiceSecurity::Instance()->AllowedToAccess($module, $submodule, $action, $type)) {
             list($file_path, $class_name) = $this->GetModule($module, $submodule, $action, $type);
             if (FALSE === $file_path) {
                 $dbMsg = SysLog::Instance()->getAllError();
                 if (!empty($dbMsg)) {
                     echo "<pre>";
                     for ($i = 0; $i < count($dbMsg); $i++) {
                         echo $dbMsg[$i];
                     }
                     echo "</pre>";
                 }
                 die('Service Not Found');
             } else {
                 $this->DispacherSend($type, $file_path, $class_name);
             }
         }
     } else {
         SysLog::Instance()->log("Security::Instance()->AllowedToAccess({$module}, {$submodule}, {$action}, {$type})", 'sanitizer');
         if (Security::Instance()->AllowedToAccess($module, $submodule, $action, $type)) {
             list($file_path, $class_name) = $this->GetModule($module, $submodule, $action, $type);
             if (FALSE === $file_path) {
                 $this->ModuleNotFound();
             } else {
                 if (!Security::Instance()->IsProtocolCheckPassed($module, $submodule, $action, $type)) {
                     // redirect to https or http
                     $url = Configuration::Instance()->GetValue('application', 'baseaddress');
                     if (!isset($_SERVER['HTTPS'])) {
                         $url = preg_replace('/^http:/', 'https:', $url);
                     }
                     $url .= $this->GetUrl($module, $submodule, $action, $type);
                     Redirector::RedirectToUrl($url);
                 } else {
                     $this->DispacherSend($type, $file_path, $class_name);
                 }
             }
         } else {
             Security::Instance()->RequestDenied();
         }
     }
 }
コード例 #12
0
 public static function project_edit()
 {
     if (!isset($GLOBALS['project']) || !$GLOBALS['project'] instanceof Project) {
         SystemEvent::raise(SystemEvent::ERROR, "Problems fetching requested project.", __METHOD__);
         Redirector::redirectToUri(UrlManager::getForDashboard());
         exit;
     }
     $GLOBALS['smarty']->assign('project_availableConnectors', ScmConnector::getAvailableConnectors());
 }
コード例 #13
0
ファイル: kw.php プロジェクト: JosepRivaille/StyleCombo
 /**
  * This function load main functions kernel and include controllers, models and others
  * It just prepare the get base ($module, $controller, $action) and launch $controller->main();
  * Also checks if controller file exists to load the error controller
  * It load APP configuration too
  * @param unknown $def_module Default module
  * @param unknown $def_controller Default controller
  * @param unknown $def_action Default action
  */
 static function start($def_module, $def_controller, $def_action)
 {
     // Cargamos el idioma
     self::loadlang();
     // preparamos una URL con los valores recibidos y utilizando los de defecto si nos falta alguno importante (o todos)
     $module = kw::get('l', $def_module);
     $controller = kw::get('c', $def_controller);
     $action = kw::get('a', $def_action);
     $file = kw::$app_dir . 'private/modules/' . $module . '/controllers/' . $controller . '.php';
     // Cargamos la configuracion propia de la aplicacion (es mas rapido hacerlo manualmente que a traves de la funcion)
     require kw::$app_dir . 'private/config/app.conf.php';
     require kw::$app_dir . 'private/config/config.conf.php';
     // Comprobamos si existe el archivo del controlador
     if (!is_file($file)) {
         // El controlador no existe...
         $controller = 'errors';
         $file = kw::$app_dir . 'private/modules/' . $module . '/controllers/' . $controller . '.php';
         // Tampoco el archivo de error
         if (!is_file($file)) {
             Redirector::rewrite($def_module, $def_controller, $def_action);
         }
         // El de error existe...
         $action = 'e404';
     }
     // Cargamos el controlador
     include $file;
     // Create the main APP
     $c = $controller . 'Controller';
     $app = new $c($module, $controller, $action);
     // $controller extend KWController?
     if (is_subclass_of($app, 'KWController')) {
         // Launch the app, it will load all (controller and after view)
         if (!$app->main()) {
             // APP instatie fail (action no exist and is an error)
             Redirector::rewrite($def_module, $def_controller, $def_action);
         }
     } else {
         echo $controller, ' ', kw::t('must extends KWController');
         die;
     }
 }
コード例 #14
0
 function RedirectTo($url, $replace = FALSE, $code = NULL)
 {
     Redirector::RedirectToUrl($url, $replace, $code);
     $this->mRedirected = TRUE;
 }
コード例 #15
0
ファイル: login.php プロジェクト: alex-ch/test
 protected function onSuccessLogin()
 {
     Redirector::redirect($this->back_url ? $this->back_url : Application::getSeoUrl("/"));
 }
コード例 #16
0
ファイル: index.php プロジェクト: rtripault/Redirector
<?php

/**
 * @package redirector
 * @subpackage controllers
 */
require_once dirname(dirname(__FILE__)) . '/model/redirector/redirector.class.php';
$redirector = new Redirector($modx);
return $redirector->initialize('mgr');
コード例 #17
0
ファイル: Scaffold.php プロジェクト: ngnpope/jerity
 /**
  * Do everything required for the scaffold, including processing actions and
  * creating/displaying the page.
  *
  * @param   array   $schema  The schema for the database.
  * @param   \PDO    $db      The database connection to use.
  * @param   string  $table   The table to be used.
  *
  * @return  string  The generated page to be displayed.
  */
 public static function doScaffold(array $schema, \PDO $db, $table = null)
 {
     $scaffold = new Scaffold($schema, $db);
     if ($scaffold->processActions() === true) {
         $url = self::cleanUrl();
         Redirector::redirect($url);
     }
     $action = isset($_GET[self::FORM_PREFIX . '_method']) ? $_GET[self::FORM_PREFIX . '_method'] : 'list';
     if (is_null($table) && isset($_GET[self::FORM_PREFIX . '_table'])) {
         $table = $_GET[self::FORM_PREFIX . '_table'];
     }
     return $scaffold->generatePage($table, $action);
 }
コード例 #18
0
ファイル: Controller.php プロジェクト: reallysend/miniPHP
 /**
  * forces SSL request
  *
  * @see core/components/SecurityComponent::secureRequired()
  */
 public function forceSSL()
 {
     $secured = "https://" . $this->request->currentUrl();
     Redirector::to($secured);
 }
コード例 #19
0
ファイル: Controller.php プロジェクト: omarelgabry/miniphp
 /**
  * forces SSL request
  *
  * @see core/components/SecurityComponent::secureRequired()
  */
 public function forceSSL()
 {
     $secured = "https://" . $this->request->fullUrlWithoutProtocol();
     return $this->redirector->to($secured);
 }