Ejemplo n.º 1
0
 /**
  * @param string $URI
  */
 public function parse($URI)
 {
     $parts = parse_url($URI);
     $this->Scheme = isset($parts['scheme']) ? $parts['scheme'] . '://' : null;
     $this->Host = isset($parts['host']) ? $parts['host'] : null;
     $this->Path = isset($parts['path']) ? $parts['path'] : null;
     $this->Query = isset($parts['query']) ? $parts['query'] : null;
     $this->Fragment = isset($parts['fragment']) ? $parts['fragment'] : null;
     $this->InversePath = Input::getVar('r', Input::GET);
     if (Config::PRETTY_URL && !$this->InversePath) {
         $this->InversePath = strpos($this->Path, 'index.php') ? substr($this->Path, strpos($this->Path, 'index.php') + 9, strlen($this->Path)) : $this->Path;
     }
 }
Ejemplo n.º 2
0
 public function Authenticate()
 {
     $Credentials = Input::getVar('Login', 'POST');
     $Authentication = false;
     $this->setLanguageFile();
     if (count($Credentials) == 2 && isset($Credentials['Email']) && isset($Credentials['Password'])) {
         if (Factory::getUser()->authenticate($Credentials['Email'], $Credentials['Password'], true)) {
             $Authentication = true;
         }
     }
     if ($Authentication) {
         Factory::getApplication()->redirectHome();
     } else {
         SystemMessage::addMessage('COM_AUTHENTICATION', SystemMessage::MSG_ERROR, 'COM_LOGIN-FAILED');
         if (isset($Credentials['Email'])) {
             Factory::getApplication()->redirect('Authentication/Login/', ['Login[Email]' => $Credentials['Email']]);
         } else {
             Factory::getApplication()->redirectLogin();
         }
     }
 }
Ejemplo n.º 3
0
 /**
  * Creates the route to according to the URI
  */
 public function route()
 {
     if (!isset($this->Route)) {
         $strRoute = $this->getRouteString();
         $Route = $this->getDefaultRouteMap();
         $Params = [];
         if (strlen($strRoute) >= 3) {
             if ($Rules = $this->getRules()) {
                 foreach ($Rules as $rKey => $rV) {
                     if (preg_match($this->getRuleRegex($rKey), $strRoute)) {
                         $Params = $this->getMapFromRule($rKey, $strRoute);
                         $strRoute = $rV;
                         break;
                     }
                 }
             }
             foreach ($this->getRouteMaps() as $Map) {
                 if (substr_count($Map, '/') === substr_count($strRoute, '/')) {
                     $Route = [$Map => $strRoute];
                 }
             }
         }
         $arMap = explode('/', Input::cleanVar(array_keys($Route)[0]));
         $arPath = explode('/', Input::cleanVar(array_values($Route)[0]));
         $cMap = count($arMap);
         for ($f = 0; $f < $cMap; $f++) {
             $this->Route[$arMap[$f]] = $arPath[$f];
         }
         foreach ($Params as $pKey => $pValue) {
             $this->Route[$pKey] = $pValue;
         }
         if (!$this->Route) {
             Factory::getLogger()->emergency('Can\'t Route Application exiting...');
         }
     }
 }
Ejemplo n.º 4
0
 /**
  * @param      $Results
  * @param      $ElementID
  * @param null $MaxPageSize
  * @return \Epsilon\Object\Object
  */
 public static function foundationListPaging($Results, $ElementID, $MaxPageSize = null)
 {
     $CurrentPage = Input::getVar("CurrentPage", "REQUEST");
     if (is_integer($MaxPageSize)) {
         $PageSize = $MaxPageSize;
     } else {
         $PageSize = Config::MAX_PAGE_SIZE;
     }
     $Paging = new Object(['HTML' => null, 'Init' => 0, 'Max' => $PageSize, 'Results' => 0, 'PageInit' => 0, 'PageMax' => 0, 'TotalPages' => 0, 'TotalResults' => 0]);
     if (is_array($Results)) {
         $TotalResults = count($Results);
     } else {
         if (is_numeric($Results)) {
             $TotalResults = $Results;
         } else {
             $TotalResults = 0;
         }
     }
     if ($TotalResults > 0) {
         $TotalPages = self::getTotalPages($TotalResults, $PageSize);
         if ($CurrentPage > $TotalPages) {
             $CurrentPage = $TotalPages;
         } elseif (!is_numeric($CurrentPage) || !((int) $CurrentPage > 0) || (int) $CurrentPage == 0) {
             $CurrentPage = 1;
         }
         if ($CurrentPage > 1) {
             $Init = ($CurrentPage - 1) * $PageSize;
             $Max = $PageSize;
             $PageInit = ($CurrentPage - 1) * $PageSize + 1;
             $PageMax = $PageInit + $PageSize - 1;
         } else {
             $Init = 0;
             $Max = $PageSize;
             $PageInit = 1;
             $PageMax = $PageInit + $Max - 1;
         }
         if ($PageMax >= $TotalResults) {
             $PageMax = $TotalResults;
         }
         $Pages = self::getPages($CurrentPage, $TotalPages);
         $HTML = "";
         $PreviousSet = false;
         if (is_string($ElementID)) {
             $ElementID = "\"{$ElementID}\"";
         } else {
             $ElementID = "null";
         }
         $eLanguage = Factory::getLanguage();
         $PagesCount = 0;
         foreach ($Pages as $p) {
             $PagesCount++;
             if (!$PreviousSet) {
                 $Previus = $CurrentPage - 1;
                 if ($CurrentPage != 1) {
                     $HTML .= "<ul class=\"pagination text-center\" role=\"navigation\" aria-label=\"Pagination\">\n<li class=\"pagination-previous\"><a href='javascript:goToPage({$Previus}, {$ElementID})'><span class=\"show-for-sr\">page</span> " . $eLanguage->_("LIST-RESULT-PREVIOUS") . "</a></li>\n";
                 } else {
                     $HTML .= "<ul class=\"pagination text-center\" role=\"navigation\" aria-label=\"Pagination\">\n<li class=\"pagination-previous disabled\"><span class=\"show-for-sr\">page</span> " . $eLanguage->_("LIST-RESULT-PREVIOUS") . "</li>\n";
                 }
                 $PreviousSet = true;
             }
             if ($CurrentPage == $p) {
                 $HTML .= "<li class='current'><span class=\"show-for-sr\">You're on page </span > {$p}</li > \n";
             } else {
                 $HTML .= " <li><a href = 'javascript:goToPage({$p},{$ElementID})' > {$p}</a ></li > \n";
             }
             if ($PagesCount == count($Pages)) {
                 $Next = $CurrentPage + 1;
                 if ($CurrentPage != $p) {
                     $HTML .= "<li class=\"pagination-next\"><a aria-label=\"Next page\" href='javascript:goToPage({$Next},{$ElementID})'>" . $eLanguage->_("LIST-RESULT-NEXT") . " <span class=\"show-for-sr\">page</span></a></li></ul>";
                 } else {
                     $HTML .= "<li class=\"pagination-next disabled\"><span class=\"show-for-sr\">page</span>" . $eLanguage->_("LIST-RESULT-NEXT") . "</li>\n</ul>";
                 }
             }
         }
         $Paging->setProperties(['HTML' => $HTML, 'Init' => $Init, 'Max' => $Max, 'Results' => $PageMax - $PageInit + 1, 'PageInit' => $PageInit, 'PageMax' => $PageMax, 'TotalPages' => $TotalPages, 'TotalResults' => $TotalResults]);
     }
     return $Paging;
 }
Ejemplo n.º 5
0
 /**
  * @return mixed
  */
 public static function getInstance()
 {
     if (!isset(self::$Instance)) {
         $dbh = Factory::getDBH();
         if (Input::getVar('TemplateID', 'REQUEST')) {
             $TemplateID = Input::getVar('TemplateID', 'REQUEST');
         } elseif (Factory::getCookie()->get('TemplateID')) {
             $TemplateID = Factory::getCookie()->get('TemplateID');
         } else {
             $TemplateID = null;
         }
         if ($TemplateID) {
             $stmt = $dbh->prepare('SELECT * FROM Template WHERE TemplateID = :TemplateID AND ApplicationID = :AppID');
             try {
                 $stmt->bindValue(':AppID', Factory::getApplication()->getApplicationID(), PDO::PARAM_STR);
                 $stmt->bindValue(':TemplateID', $TemplateID, PDO::PARAM_INT);
                 $stmt->execute();
                 $rst = $stmt->fetch(PDO::FETCH_OBJ);
                 if (is_object($rst)) {
                     $Class = $rst->Template;
                     self::$Instance = new $Class($dbh, $rst);
                 } else {
                     unset($rst);
                 }
             } catch (PDOException $e) {
                 $dbh->catchException($e, $stmt->queryString);
             }
         }
         if (!self::$Instance instanceof Template) {
             $stmt = $dbh->prepare('SELECT * FROM Template WHERE ApplicationID = :AppID AND Root = 1');
             $stmt->bindValue(':AppID', Factory::getApplication()->getApplicationID(), PDO::PARAM_STR);
             try {
                 $stmt->execute();
                 $rst = $stmt->fetch(PDO::FETCH_OBJ);
                 if (is_object($rst)) {
                     $Class = "Templates\\{$rst->Template}\\{$rst->Template}";
                     self::$Instance = new $Class($dbh, $rst);
                 }
             } catch (PDOException $e) {
                 $dbh->catchException($e, $stmt->queryString);
             }
             if (!self::$Instance) {
                 Factory::getLogger()->emergency('No Template found in Database exiting...');
             }
         }
     }
     return self::$Instance;
 }
Ejemplo n.º 6
0
 /**
  * @param      $Key
  * @param int  $ClearMethod
  * @param bool $Output
  * @return bool|string
  */
 public function _($Key, $ClearMethod = Input::HTML, $Output = false)
 {
     if (isset($this->arStrings[$Key])) {
         if ($Output) {
             $String = Output::_($this->arStrings[$Key], $ClearMethod);
         } else {
             $String = Input::_($this->arStrings[$Key], $ClearMethod);
         }
         return $String;
     } else {
         return null;
     }
 }