Beispiel #1
0
 /**
  * Função para definir uso de cache na Query
  * 
  * @access public
  * @return \MySQLTableCached
  */
 public function Cache($iTimeout = 3600)
 {
     Storage::Set("cachedb.timeout", $iTimeout);
     Events::Set("BeforeQuery", function ($sSQL, $fCallback) {
         if (Storage::Get("cachedb.enabled", false)) {
             $mCache = @CacheDB::Get(sha1($sSQL));
             if ($mCache !== false && !is_null($mCache)) {
                 if ($fCallback) {
                     $fCallback(json_decode($mCache, true), null);
                 }
                 return true;
             } else {
                 return false;
             }
         } else {
             return false;
         }
     });
     Events::Set("AfterQuery", function ($sSQL, $aResult) {
         if (Storage::Get("cachedb.enabled", false)) {
             @CacheDB::Set(sha1($sSQL), json_encode($aResult), Storage::Get("cachedb.timeout", 3600));
         }
     });
     return $this;
 }
Beispiel #2
0
 /**
  * Function to call the event
  * 
  * @static
  * @access public
  * @param string $sName
  * @param array $aParams
  * @return mixed
  */
 public static function Call($sName, $aParams = null)
 {
     $oThis = self::CreateInstanceIfNotExists();
     $sName = strtolower(str_replace(array("/", "\\", "--"), "-", $sName));
     //Bugfix
     if (array_key_exists($sName, $oThis->aEvents)) {
         switch ($oThis->aEvents[$sName]["type"]) {
             case "perroute":
                 $sCurrentRoute = strtolower(str_replace(array("/", "\\", "--"), "-", Storage::Get("route")));
                 //Bugfix
                 $sRoute = strtolower($oThis->aEvents[$sName]["method"] . "_" . $oThis->aEvents[$sName]["route"]);
                 if ($sRoute == $sCurrentRoute) {
                     return call_user_func($oThis->aEvents[$sName]["func"], $aParams);
                 }
                 break;
             case "default":
                 return call_user_func($oThis->aEvents[$sName]["func"], $aParams);
                 break;
         }
     } else {
         return false;
     }
 }
Beispiel #3
0
 /**
  * Function to load modules
  * 
  * @static
  * @access public
  * @return void
  */
 public static function LoadApp()
 {
     //If the module exists Express should be loaded first
     if (is_dir(Storage::Join("dir.app", "express"))) {
         if (file_exists(Storage::Join("dir.app", "express" . SP . "settings.php"))) {
             require_once Storage::Join("dir.app", "express" . SP . "settings.php");
         }
         if (file_exists(Storage::Join("dir.app", "express" . SP . "include.php"))) {
             require_once Storage::Join("dir.app", "express" . SP . "include.php");
         }
         if (file_exists(Storage::Join("dir.app", "express" . SP . "routes.php"))) {
             require_once Storage::Join("dir.app", "express" . SP . "routes.php");
         }
         if (file_exists(Storage::Join("dir.app", "express" . SP . "events.php"))) {
             require_once Storage::Join("dir.app", "express" . SP . "events.php");
         }
     }
     //Load Modules
     $aModulesDirectories = glob(Storage::Get("dir.app") . "*", GLOB_ONLYDIR);
     foreach ($aModulesDirectories as $sModuleDiretory) {
         $bStatus = file_exists($sModuleDiretory . SP . "status.txt") ? intval(file_get_contents($sModuleDiretory . SP . "status.txt")) == 1 : false;
         $bInstaled = file_exists($sModuleDiretory . SP . "settings.php");
         if ($bStatus && $bInstaled && basename($sModuleDiretory) != "express") {
             if (file_exists($sModuleDiretory . SP . "settings.php") && $bStatus) {
                 require_once $sModuleDiretory . SP . "settings.php";
             }
             if (file_exists($sModuleDiretory . SP . "include.php") && $bStatus) {
                 require_once $sModuleDiretory . SP . "include.php";
             }
             if (file_exists($sModuleDiretory . SP . "routes.php") && $bStatus) {
                 require_once $sModuleDiretory . SP . "routes.php";
             }
             if (file_exists($sModuleDiretory . SP . "events.php") && $bStatus) {
                 require_once $sModuleDiretory . SP . "events.php";
             }
         }
     }
 }
Beispiel #4
0
 /**
  * Function to send output
  *
  * @access public
  * @return void
  */
 public static function Send()
 {
     $oThis = self::CreateInstanceIfNotExists();
     if (is_object($oThis->oSmarty)) {
         $oThis->CreateCacheCSS();
         $oThis->CreateCacheJS();
         Storage::AssignSmarty($oThis->oSmarty);
         Events::Call("BeforeSendingOutput");
         $oThis->oSmarty->display($oThis->sTemplateFilename);
     } else {
         $oThis = self::CreateInstanceIfNotExists();
         $oThis->CreateCacheCSS();
         $oThis->CreateCacheJS();
         $oThis->IncludeTemplate();
         $oThis->ReplaceVars();
         $oThis->RemoveUndefinedVars();
         $oThis->CheckConditions();
         //$oThis->ClearList();
         Events::Call("BeforeSendingOutput");
         @header('HTTP/1.1 200 OK');
         @header("Content-Type: text/html; charset=" . strtoupper(Storage::Get("app.charset", "UTF-8")), true);
         try {
             //var_dump($oThis->sBuffer); die();
             eval('?> ' . $oThis->sBuffer);
             die;
         } catch (Exception $e) {
             die($e->getMessage());
         }
     }
 }