/**
  *@OdinAuthLogin 
  */
 public function ini()
 {
     $msg = SessionHelper::getSystemSession('msg');
     if (AuthHelper::checkLogin()) {
         RedirectHelper::goToControllerAction("TestAuthentication", "getin");
     } else {
         if (!$msg) {
             $this->view('testAuthLogin');
         } else {
             $this->setVars("msg", $msg);
             $this->view('testAuthLogin');
         }
     }
 }
Пример #2
0
 /**
  * Loads the requested URL
  * 
  * @access public
  * @author Renie Siqueira da Silva
  * @since 1.0
  * @return void
  */
 public function run()
 {
     $controller_path = CONTROLLERS . $this->_controller . CONTROLLERSUFIX . ".php";
     if (!file_exists($controller_path)) {
         $this->dispatch404();
     }
     require_once $controller_path;
     $controller = $this->_controller . CONTROLLERSUFIX;
     $app = new $controller();
     $action = $this->_action;
     if (defined('RESTFULENABLE') && RESTFULENABLE) {
         if ($action == DEFAULTACTION || $action == null) {
             $found = false;
             $controllerMethods = get_class_methods($controller);
             foreach ($controllerMethods as $key => $value) {
                 $refM = new ReflectionMethod($controller, $value);
                 $methodArr = array();
                 preg_match("/(@REQUEST_METHOD )(.*)/", $refM->getDocComment(), $methodArr);
                 if (isset($methodArr[0])) {
                     if (trim(strtolower($methodArr[2])) == trim(strtolower(SYSTEM::$SERVER['REQUEST_METHOD']))) {
                         $action = $value;
                     }
                 }
             }
         } else {
             if (!method_exists($app, $action)) {
                 $this->dispatch404(true);
                 die;
             }
             $refM = new ReflectionMethod($controller, $action);
             $methodArr = array();
             preg_match("/(@REQUEST_METHOD )(.*)/", $refM->getDocComment(), $methodArr);
             if (isset($methodArr[0])) {
                 if (trim(strtolower($methodArr[2])) != trim(strtolower(SYSTEM::$SERVER['REQUEST_METHOD']))) {
                     $action = null;
                 }
             }
         }
         if ($action == null) {
             header(':', true, 405);
             die;
         }
     }
     $this->_action = $action;
     if (!method_exists($app, $this->_action)) {
         $this->dispatch404();
         die;
     }
     if (defined('AUTHENABLE') && AUTHENABLE) {
         $refC = new ReflectionClass($controller);
         $authMNeeded = array();
         preg_match("/@OdinAuth /", $refM->getDocComment(), $authMNeeded);
         $authCNeeded = array();
         preg_match("/@OdinAuth /", $refC->getDocComment(), $authCNeeded);
         $authLogin = array();
         preg_match("/@OdinAuthLogin /", $refM->getDocComment(), $authLogin);
         if (isset($authMNeeded[0]) || isset($authCNeeded[0])) {
             if (!AuthHelper::checkLogin()) {
                 if (defined('AUTHCONTROLLERERROR') && AUTHCONTROLLERERROR != "") {
                     SessionHelper::setSystemSession('requiredController', $this->_controller);
                     SessionHelper::setSystemSession('requiredAction', $this->_action);
                     SessionHelper::setSystemSession('requiredURL', true);
                     if (defined('AUTHCONTROLLERACTION') && AUTHCONTROLLERACTION != "") {
                         RedirectHelper::goToControllerAction(AUTHCONTROLLERERROR, AUTHACTIONERROR);
                     } else {
                         RedirectHelper::goToController(AUTHCONTROLLERERROR);
                     }
                 } else {
                     RedirectHelper::goToIndex();
                 }
             }
         } elseif (isset($authLogin[0])) {
             if (AuthHelper::checkLogin()) {
                 if (defined('AUTHCONTROLLERHOME') && AUTHCONTROLLERHOME != "") {
                     if (defined('AUTHACTIONHOME') && AUTHACTIONHOME != "" && (AUTHCONTROLLERHOME != AUTHCONTROLLERERROR && AUTHACTIONHOME != AUTHACTIONERROR || AUTHACTIONHOME != AUTHACTIONERROR || AUTHCONTROLLERHOME != AUTHCONTROLLERERROR)) {
                         RedirectHelper::goToControllerAction(AUTHCONTROLLERHOME, AUTHACTIONHOME);
                         exit;
                     } else {
                         echo "FURY OF ODIN!!!!!";
                         exit;
                     }
                 } else {
                     echo "FURY OF ODIN!!!!!";
                     exit;
                 }
             }
         }
     }
     try {
         $app->{$action}();
     } catch (Exception $e) {
         echo $e;
     }
 }
Пример #3
0
 /**
  * Loads the requested URL
  * 
  * @access public
  * @author Renie Siqueira da Silva
  * @since 1.0
  * @return void
  */
 public function run()
 {
     $controller_path = CONTROLLERS . $this->_controller . "Controller.php";
     if (!file_exists($controller_path)) {
         $this->dispatch404();
     }
     require_once $controller_path;
     $controller = $this->_controller . "Controller";
     $app = new $controller();
     if (!method_exists($app, $this->_action)) {
         $this->dispatch404();
     }
     $action = $this->_action;
     if (defined('AUTHENABLE') && AUTHENABLE) {
         $refM = new ReflectionMethod($controller, $action);
         $refC = new ReflectionClass($controller);
         $authMNeeded = array();
         preg_match("/@OdinAuth /", $refM->getDocComment(), $authMNeeded);
         $authCNeeded = array();
         preg_match("/@OdinAuth /", $refC->getDocComment(), $authCNeeded);
         $authLogin = array();
         preg_match("/@OdinAuthLogin /", $refM->getDocComment(), $authLogin);
         if (isset($authMNeeded[0]) || isset($authCNeeded[0])) {
             if (!AuthHelper::checkLogin()) {
                 if (defined('AUTHCONTROLLERERROR') && AUTHCONTROLLERERROR != "") {
                     SessionHelper::setSystemSession('requiredController', $this->_controller);
                     SessionHelper::setSystemSession('requiredAction', $this->_action);
                     SessionHelper::setSystemSession('requiredURL', true);
                     if (defined('AUTHCONTROLLERACTION') && AUTHCONTROLLERACTION != "") {
                         RedirectHelper::goToControllerAction(AUTHCONTROLLERERROR, AUTHACTIONERROR);
                     } else {
                         RedirectHelper::goToController(AUTHCONTROLLERERROR);
                     }
                 } else {
                     RedirectHelper::goToIndex();
                 }
             }
         } elseif (isset($authLogin[0])) {
             if (AuthHelper::checkLogin()) {
                 if (defined('AUTHCONTROLLERHOME') && AUTHCONTROLLERHOME != "") {
                     if (defined('AUTHACTIONHOME') && AUTHACTIONHOME != "" && (AUTHCONTROLLERHOME != AUTHCONTROLLERERROR && AUTHACTIONHOME != AUTHACTIONERROR || AUTHACTIONHOME != AUTHACTIONERROR || AUTHCONTROLLERHOME != AUTHCONTROLLERERROR)) {
                         RedirectHelper::goToControllerAction(AUTHCONTROLLERHOME, AUTHACTIONHOME);
                         exit;
                     } else {
                         RedirectHelper::goToUrl("odinphp.com/Fury");
                         exit;
                     }
                 } else {
                     RedirectHelper::goToUrl("odinphp.com/Fury");
                     exit;
                 }
             }
         }
     }
     try {
         $app->{$action}();
     } catch (Exception $e) {
         echo $e;
     }
 }