Esempio n. 1
0
 /**
  * spousti zobrazeni pozadovane stranky
  * @throws LBoxException
  */
 public static function run()
 {
     try {
         // starting timer
         LBoxTimer::getInstance();
         // init acces
         AccesRecord::getInstance();
         if (self::getPageCfg()->cache_off) {
             LBoxCacheManagerFront::getInstance()->switchListeningOff();
         }
         self::executeInit();
         // caching
         //var_dump(LBoxCacheManagerFront::getInstance()->wasFormSentNow());die;
         //if (self::getPage()->showConnivance()) {
         //LBoxFirePHP::table($_SERVER, "_SERVER");
         if (LBoxCacheManagerFront::getInstance()->isCacheON()) {
             if (!LBoxXTProject::isLoggedSuperAdmin() && !LBoxXTDBFree::isLogged() && !LBoxCacheManagerFront::getInstance()->wasFormSentNow()) {
                 if (count(self::getDataPost()) < 1) {
                     if (LBoxCacheManagerFront::getInstance()->doesCacheExists()) {
                         // send last modification header
                         LBoxFirePHP::warn("cache loaded in " . LBoxTimer::getInstance()->getTimeOfLife() . "s");
                         header("Last-Modified: " . gmdate("D, d M Y H:i:s", LBoxCacheManagerFront::getInstance()->getLastCacheModificationTime()) . " GMT");
                         echo LBoxCacheManagerFront::getInstance()->getData();
                         LBoxCacheManagerFront::getInstance()->__destruct();
                         return;
                     }
                 }
             }
             $content = self::getRequestContent();
             echo $content;
             if (!LBoxXTProject::isLoggedSuperAdmin() && !LBoxXTDBFree::isLogged() && !LBoxCacheManagerFront::getInstance()->wasFormSentNow()) {
                 if (count(self::getDataPost()) < 1) {
                     // vystup z nenalezenych URL neukladame - mohlo by umoznit snadno zahltit cache!
                     if (self::getPageCfg()->id != LBoxConfigSystem::getInstance()->getParamByPath("pages/page404")) {
                         //kontrola jestli vystup neni jen vypis exception
                         if (strlen(strip_tags($content)) > 0) {
                             LBoxCacheManagerFront::getInstance()->saveData($content);
                             LBoxFirePHP::warn("cache stored in " . LBoxTimer::getInstance()->getTimeOfLife() . "s");
                         } else {
                             LBoxFirePHP::error("cache NOT stored because output suppose to contain only exception message!");
                         }
                     }
                 }
             }
             LBoxCacheManagerFront::getInstance()->__destruct();
         } else {
             LBoxFirePHP::warn("cache VYPNUTA");
             echo self::getRequestContent();
         }
         /*}
         		else {
         			echo self::getRequestContent();
         		}*/
     } catch (Exception $e) {
         throw $e;
     }
 }
Esempio n. 2
0
                continue;
            }
            $paramsString .= strlen($paramsString) > 0 ? "&" : "";
            $paramsString .= "{$k}={$v}";
        }
        $ret->Data->data_url = LBOX_REQUEST_URL_VIRTUAL . "?{$paramsString}";
        header("HTTP/1.1 200 OK");
        die(json_encode($ret));
    }
    if (!$_POST && count($_GET) > 0) {
        // get the node data
        $typeRecord = $_GET["type"];
        $idColname = eval("return {$typeRecord}::\$idColName;");
        $record = new $typeRecord($_GET["id"]);
        $out = array();
        foreach ($record as $param => $value) {
            $out[$param] = $value;
        }
        header("HTTP/1.1 200 OK");
        die(json_encode($out));
    }
} catch (Exception $e) {
    LBoxFirePHP::throwException($e);
    $ret = new stdclass();
    // PHP base class
    $ret->Exception = new stdclass();
    $ret->Exception->code = $e->getCode();
    $ret->Exception->message = $e->getMessage();
    header("HTTP/1.1 200 OK");
    die(json_encode($ret));
}
Esempio n. 3
0
 protected function debug($sql)
 {
     if (!self::$debug) {
         return;
     }
     if (strtolower(self::$debug) == "firephp") {
         switch (true) {
             case is_numeric(strpos($sql, "UPDATE")):
             case is_numeric(strpos($sql, "DELETE")):
                 LBoxFirePHP::warn(round(LBoxTimer::getInstance()->getTimeOfLife(), 5) . " - " . str_replace("\n", "", self::$queryCount . ": " . $sql));
                 break;
             default:
                 LBoxFirePHP::log(round(LBoxTimer::getInstance()->getTimeOfLife(), 5) . " - " . str_replace("\n", "", self::$queryCount . ": " . $sql));
         }
     } else {
         switch (true) {
             case is_numeric(strpos($sql, "UPDATE")):
             case is_numeric(strpos($sql, "DELETE")):
                 $bg = "#962C2C";
                 break;
             case is_numeric(strpos($sql, "INSERT")):
                 $bg = "#6BC764";
                 break;
             default:
                 $bg = "#5D5D5D";
         }
         $color = "#ffffff";
         $msg = "<table><th bgcolor='{$bg}' align='left'><font color='#C0C0C0'>" . round(LBoxTimer::getInstance()->getTimeOfLife(), 5) . "</font></th><th bgcolor='{$bg}' align='left'><b><font color='{$color}'>" . nl2br(self::$queryCount . ": " . $sql) . "</font></b></th></table>\n";
         echo $msg;
         flush();
     }
 }
 protected function __construct()
 {
     try {
         // nacteni dat z cache do pameti
         $this->recordTypes = (array) unserialize($this->getCache()->getDataDirect());
         ksort($this->recordTypes);
         LBoxFirePHP::table($this->recordTypes, "data v cachi indexovani URLs vs records types (" . count($this->recordTypes) . ")");
     } catch (Exception $e) {
         throw $e;
     }
 }
Esempio n. 5
0
 /**
  * vycisti libovolnou groupu cache podle parametru
  * @param string $group
  * @param string $mode ingroup | notingroup | old  callback_myFunc - see http://pear.php.net/manual/en/package.caching.cache-lite.cache-lite.clean.php
  */
 public function cleanConcrete($group = false, $mode = "ingroup")
 {
     try {
         if (!$this->getCache()->clean($group, $mode)) {
             throw new LBoxExceptionCache(LBoxExceptionCache::MSG_CACHE_CANNOT_WRITE, LBoxExceptionCache::CODE_CACHE_CANNOT_WRITE);
         }
         LBoxFirePHP::warn("cache smazana: \$group='{$group}' \$dir='" . $this->getDir() . "'");
     } catch (Exception $e) {
         throw $e;
     }
 }
Esempio n. 6
0
function throwExceptionToFirePHP(Exception $e)
{
    LBoxFirePHP::throwException($e);
}
Esempio n. 7
0
 /**
  * adds columns by $columns - columns must be defined in $atttributes
  * @param array $columns
  * @throws Exception
  */
 protected function addColumns($columns = array())
 {
     try {
         $tableName = $this->getClassVar("tableName");
         $attributes = $this->getClassVar("attributes");
         $cols = array();
         LBoxFirePHP::log("adding columns into '{$tableName}': " . implode(", ", $columns));
         foreach ($columns as $column) {
             foreach ($attributes as $attribute) {
                 if ($attribute["name"] == $column) {
                     $cols[] = $attribute;
                 }
                 // write empty param for checkAttributesColumnsExists checking
                 $this->params[$column] = "";
             }
         }
         $this->getDb()->initiateQuery($this->getQueryBuilder()->getAddColumns($tableName, $cols));
         $this->resetCache();
         $this->isCacheSynchronized = false;
     } catch (Exception $e) {
         throw $e;
     }
 }