public function prepare($name = "", $value = NULL)
 {
     try {
         $virtPath = LBoxConfigSystem::getInstance()->getParamByPath("photogallery/output/path_virtual");
         switch ($name) {
             case "url":
                 $value = str_replace(LBOX_PATH_PROJECT, "", $this->getPath());
                 break;
             case "name":
                 if (strlen($value) < 1) {
                     $value = $this->instance->filename;
                 }
                 break;
             case "thumbnail":
                 $class = get_class($this->instance);
                 if (($thumb = $this->instance->getChildren()->current()) instanceof $class) {
                     $myClassName = get_class($this);
                     $thumb->setOutputFilter(new $myClassName($thumb));
                     $value = $thumb;
                 } else {
                     $value = NULL;
                 }
                 break;
             default:
         }
         return $value;
     } catch (Exception $e) {
         throw $e;
     }
 }
Exemple #2
0
 /**
  * Vraci ve spravnem tvaru URL string pozadovane stranky
  * @return string
  * @throws Exception
  */
 public static function getPagingURLString($pageNum = 0)
 {
     try {
         if (!is_numeric($pageNum) || $pageNum < 1) {
             throw new LBoxException("\$pageNum " . LBoxException::MSG_PARAM_INT_NOTNULL, LBoxException::CODE_BAD_PARAM);
         }
         $pagingUrlParamPattern = LBoxConfigSystem::getInstance()->getParamByPath("output/paging/paging_url_param_pattern");
         $pagingUrlParamExample = LBoxConfigSystem::getInstance()->getParamByPath("output/paging/paging_url_param_example");
         if (!preg_match("/{$pagingUrlParamPattern}/", $pagingUrlParamExample, $regs)) {
             //if (!ereg($pagingUrlParamPattern, $pagingUrlParamExample, $regs)) {
             throw new LBoxExceptionConfig(LBoxExceptionConfig::MSG_PAGING_URLPARAM_EXAMPLE_NOT_CORRESPOND_PATTERN, LBoxExceptionConfig::CODE_PAGING_URLPARAM_EXAMPLE_NOT_CORRESPOND_PATTERN);
         }
         // zrusime z pole prvni klic s celym stringem
         unset($regs[0]);
         // nalezneme key numerickeho parametru - stranky (abysme ho snadno mohli zamenit)
         foreach ($regs as $k => $reg) {
             if (is_numeric($reg)) {
                 $regsPageKey = $k;
             }
         }
         $pageNumPattern = $regs[$regsPageKey];
         return str_ireplace($pageNumPattern, $pageNum, $pagingUrlParamExample);
     } catch (Exception $e) {
         throw $e;
     }
 }
 protected function getDir()
 {
     try {
         return LBoxConfigSystem::getInstance()->getParamByPath("records/cache/path") . SLASH . $this->recordType;
     } catch (Exception $e) {
         throw $e;
     }
 }
Exemple #4
0
 protected function __construct($id = "", $group = "")
 {
     try {
         parent::__construct($id, $group);
         $this->lifeTime = LBoxConfigSystem::getInstance()->getParamByPath("output/cache/expiration");
     } catch (Exception $e) {
         throw $e;
     }
 }
 /**
  * @return LBoxConfigSystem
  * @throws Exception
  */
 public static function getInstance()
 {
     $className = __CLASS__;
     try {
         if (!isset(self::$instance)) {
             self::$instance = new $className();
         }
         return self::$instance;
     } catch (Exception $e) {
         throw $e;
     }
 }
 /**
  * combines code from defined "document root relative" paths and returns path to destination file
  * @param array files
  */
 public function combine($files = array())
 {
     try {
         if (strlen(LBoxJSCombine) < 1) {
             throw new LBoxException("\$extOut: " . LBoxException::MSG_INSTANCE_VAR_STRING_NOTNULL, LBoxException::CODE_BAD_CLASS_VAR);
         }
         if (count($files) < 1) {
             throw new LBoxException(LBoxException::MSG_PARAM_ARRAY_NOTNULL, LBoxException::CODE_BAD_PARAM);
         }
         $sDocRoot = $_SERVER['DOCUMENT_ROOT'];
         $destination = $this->getPathDestination();
         LBoxUtil::createDirByPath($destination);
         // get and merge code
         $sCode = "";
         $aLastModifieds = array();
         foreach ($files as $file) {
             $file = LBOX_PATH_PROJECT . $file;
             $file = str_ireplace('project/project/', 'project/', $file);
             if (!file_exists($file)) {
                 throw new LBoxExceptionFilesystem("{$file}: " . LBoxExceptionFilesystem::MSG_FILE_NOT_EXISTS, LBoxExceptionFilesystem::CODE_FILE_NOT_EXISTS);
             }
             $aLastModifieds[] = filemtime($file);
             $sCode .= file_get_contents($file) . "\n";
         }
         // sort dates, newest first
         rsort($aLastModifieds);
         $fileName = md5($aLastModifieds[0]) . ".js";
         $destinationFile = "{$destination}/{$fileName}";
         // cache the data
         if (!file_exists($destinationFile)) {
             //LBoxFirePHP::warn("$destinationFile zatim NEexistuje - vytvarim novy");
             switch (LBoxConfigSystem::getInstance()->getParamByPath("output/js_compress")) {
                 case 1:
                     $sCode = $this->compress($sCode);
                     break;
                 case -1:
                     if (LBOX_REQUEST_IP != "127.0.0.1") {
                         $sCode = $this->compress($sCode);
                     }
                     break;
             }
             $sCode = "/*merged from files: " . implode($files, ",\n") . "*/" . $sCode;
             $fo = fopen($destinationFile, "w");
             fwrite($fo, $sCode);
             fclose($fo);
         } else {
             //LBoxFirePHP::log("$destinationFile uz existuje");
         }
         return str_replace(LBOX_PATH_PROJECT, "", $destinationFile);
     } catch (Exception $e) {
         throw $e;
     }
 }
Exemple #7
0
 /**
  * Vraci hodnotu paging (po kolika se ma strankovat)
  * @return int
  * @throws LBoxException
  */
 protected function getListPaging()
 {
     try {
         $out = LBoxConfigManagerProperties::getInstance()->getPropertyByName("news_list_limit")->getContent();
         if (strlen($out) < 1) {
             $out = LBoxConfigSystem::getInstance()->getParamByPath("output/paging/paging_by_default");
         }
         return (int) $out;
     } catch (Exception $e) {
         throw $e;
     }
 }
Exemple #8
0
 /**
  * pretizeno o automaticke vytvareni sablony z defaultni
  * @return string
  */
 protected function getTemplatePath()
 {
     try {
         $pathTemplate = parent::getTemplatePath();
         if (!file_exists($pathTemplate)) {
             $srcPath = LBoxConfigSystem::getInstance()->getParamByPath("pages/templates/path") . SLASH . LBoxConfigSystem::getInstance()->getParamByPath("pages/templates/default");
             LBoxUtil::copyFile($srcPath, $pathTemplate);
         }
         return $pathTemplate;
     } catch (Exception $e) {
         throw $e;
     }
 }
 /**
  * Vraci nazev tridy z parametru, nebo system config default
  * @return string
  * @throws LBoxException
  */
 public function getClassName()
 {
     try {
         if (strlen($value = $this->__get($this->attNames["class"])) > 0) {
             return $value;
         } else {
             $default = LBoxConfigSystem::getInstance()->getParamByPath("components/classes/default");
             if (strlen($default) < 1) {
                 throw new LBoxExceptionConfigComponent(LBoxExceptionConfigComponent::MSG_CLASS_DEFAULT_NOTFOUND, LBoxExceptionConfigComponent::CODE_CLASS_DEFAULT_NOTFOUND);
             }
             return $default;
         }
     } catch (Exception $e) {
         throw $e;
     }
 }
Exemple #10
0
 /**
  * vraci cestu k adresari sablon emailu
  * @return string
  */
 protected function getTemplatesPath()
 {
     try {
         return LBoxConfigSystem::getInstance()->getParamByPath("emails/templates/path");
     } catch (Exception $e) {
         throw $e;
     }
 }
 /**
  * getter na instanci cache
  * @return LBoxCacheData
  */
 protected function getCache()
 {
     try {
         if (self::$cache instanceof LBoxCacheData) {
             return self::$cache;
         }
         self::$cache = LBoxCacheData::getInstance("front", "", LBoxConfigSystem::getInstance()->getParamByPath("output/cache/path"));
         self::$cache->setAutoSave(false);
         return self::$cache;
     } catch (Exception $e) {
         throw $e;
     }
 }
Exemple #12
0
<?php

session_start();
require "../../../../../../../lBox/lib/loader.php";
try {
    if (!LBoxXT::isLoggedAdmin()) {
        throw new LBoxExceptionXT(LBoxExceptionXT::MSG_NOT_LOGGED . " acces.id=" . AccesRecord::getInstance()->id, LBoxExceptionXT::CODE_NOT_LOGGED);
    }
} catch (Exception $e) {
    echo "<hr />";
    echo "Exception code:  <font style='color:blue'>" . $e->getCode() . "</font>";
    echo "<br />";
    echo "Exception message: <font style='color:blue'>" . nl2br($e->getMessage()) . "</font>";
    /*echo "<br />";
    echo "Thrown by: '". $e->getFile() ."'";
    echo "<br />";
    echo "on line: '". $e->getLine() ."'.";
    echo "<br />";
    echo "<br />";
    echo "Stack trace:";
    echo "<br />";
    echo nl2br($e->getTraceAsString());*/
    echo "<hr />";
    die;
}
$sfd_root_path = LBOX_PATH_PROJECT;
$sfd_dir = LBoxConfigSystem::getInstance()->getParamByPath("wsw/img/path") . "/";
$sfd_dir_rel = str_replace("\\", "/", LBOX_PATH_PROJECT . $sfd_dir);
 /**
  * getter na pattern, podle ktereho se bude sestavovat URL param pagingu
  * @return string
  */
 protected function getPatternURLParam()
 {
     try {
         $out = LBoxConfigSystem::getInstance()->getParamByPath("paging/url_param_pattern");
         $out = str_replace("<paging_id>", "(\\w+)", $out);
         $out = str_replace("<paging_page>", "(.+)", $out);
         return $out;
     } catch (Exception $e) {
         throw $e;
     }
 }
Exemple #14
0
 public function getParamDirect($name = "")
 {
     try {
         if (strlen($this->params[$name]) < 1) {
             $value = NULL;
             switch ($name) {
                 case "url":
                     $URLParamPattern = LBoxConfigSystem::getInstance()->getParamByPath("paging/url_param_pattern");
                     $URLParamPattern = str_replace("<paging_id>", $this->paging->getPagingID(), $URLParamPattern);
                     $URLParam = str_replace("<paging_page>", $this->number, $URLParamPattern);
                     $URLParamPattern = str_replace("<paging_page>", "(\\d+)", $URLParamPattern);
                     $URLParam = str_replace("/", "", $URLParam);
                     $URLParam = str_replace("\\", "", $URLParam);
                     if ($this->getNumber() > 1) {
                         $value = LBoxUtil::getURLWithParams(array($URLParam), LBoxUtil::getURLWithoutParamsByPattern($URLParamPattern));
                     } else {
                         $value = LBoxUtil::getURLWithoutParamsByPattern($URLParamPattern);
                     }
                     break;
                 default:
                     $value = NULL;
             }
             return $this->params[$name] = $value;
         } else {
             return $this->params[$name];
         }
     } catch (Exception $e) {
         throw $e;
     }
 }
 /**
  * returns if is debug on in config
  * @return bool
  */
 protected function isDebugOn()
 {
     try {
         switch (LBoxConfigSystem::getInstance()->getParamByPath("debug/components")) {
             case -1:
                 return LBOX_REQUEST_IP == "127.0.0.1";
                 break;
             case 0:
                 return false;
                 break;
             case 1:
                 return true;
                 break;
         }
     } catch (Exception $e) {
         throw $e;
     }
 }
Exemple #16
0
 /**
  * Vraci aktualni stranku, nebo NULL pokud jde o 404
  * @return LBoxPage
  */
 protected function getPage()
 {
     try {
         // pokud je aktualni stranka 404, tak vracet NULL, aby byl formular nastaven na vytvoreni nove stranky
         return LBoxFront::getPage()->id == LBoxConfigSystem::getInstance()->getParamByPath("pages/page404") ? NULL : LBoxFront::getPage();
     } catch (Exception $e) {
         throw $e;
     }
 }
Exemple #17
0
if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) {
    ob_start("ob_gzhandler");
} else {
    ob_start();
}
//DbControl::$debug = "firephp";
//LBoxCache::$debug = true;
//LBoxLoaderConfig::getInstance()->debug = true;
DEFINE("LBOX_PATH_TEMPLATES_PAGES", LBoxConfigSystem::getInstance()->getParamByPath("pages/templates/path"));
DEFINE("LBOX_PATH_TEMPLATES_COMPONENTS", LBoxConfigSystem::getInstance()->getParamByPath("components/templates/path"));
DEFINE("LBOX_PATH_TEMPLATES_LAYOUTS", LBoxConfigSystem::getInstance()->getParamByPath("layouts/templates/path"));
DEFINE("LBOX_PATH_FILES_I18N", LBoxConfigSystem::getInstance()->getParamByPath("i18n/globalfiles/path"));
try {
    LBoxFront::run();
} catch (Exception $e) {
    switch (LBoxConfigSystem::getInstance()->getParamByPath("debug/exceptions")) {
        case 1:
            echo getExceptionNotice($e);
            break;
        case -1:
            if (LBOX_REQUEST_IP == "127.0.0.1") {
                echo getExceptionNotice($e);
            } else {
                echo $e->getMessage();
            }
            break;
        case 0:
            echo $e->getMessage();
            break;
    }
}
Exemple #18
0
// check xt session
if (!LBoxXTDBFree::isLogged(XT_GROUP) && !LBoxXTProject::isLoggedAdmin(XT_GROUP)) {
    header("HTTP/1.1 404 Not Found");
    die;
}
// firePHP debug
//LBoxFirePHP::log(LBoxConfigSystem::getInstance()->getParamByPath("metanodes/images/path"));
//LBoxFirePHP::table($_FILES['image'], "uploaded image data");
try {
    //////////////////////////////////////////////////////////////////////
    //	saving data
    //////////////////////////////////////////////////////////////////////
    if (strlen($tmpPath = $_FILES['image']['tmp_name']) > 0) {
        $imgName = $_FILES["image"]["name"];
        $userRecord = LBoxXTProject::isLogged() ? LBoxXTProject::getUserXTRecord() : LBoxXTDBFree::getUserXTRecord();
        $dirTarget = LBoxUtil::fixPathSlashes(LBoxConfigSystem::getInstance()->getParamByPath("metanodes/images/path") . SLASH . $userRecord->nick . SLASH . date("Ym"));
        $imgNameTarget = date("YmdHis") . "." . LBoxUtil::getExtByFilename($imgName);
        $imageURL = str_replace('\\', '/', LBoxUtil::fixPathSlashes(str_replace(LBOX_PATH_PROJECT, "", "{$dirTarget}/{$imgNameTarget}")));
        LBoxUtil::createDirByPath($dirTarget);
        if (!move_uploaded_file($tmpPath, "{$dirTarget}" . SLASH . "{$imgNameTarget}")) {
            throw new LBoxExceptionFilesystem(LBoxExceptionFilesystem::MSG_FILE_UPLOAD_ERROR, LBoxExceptionFilesystem::CODE_FILE_UPLOAD_ERROR);
        }
        $ret = new stdclass();
        // PHP base class
        $ret->status = "UPLOADED";
        $ret->image_url = $imageURL;
        header("HTTP/1.1 200 OK");
        header("content-type: text/html");
        die(json_encode($ret));
    }
} catch (Exception $e) {
Exemple #19
0
 /**
  * Vraci pocet dni, po ktere ma byt remember cookie aktivni
  * @return int
  * @throws Exception
  */
 protected static function getCookiePersistenceDays()
 {
     try {
         return (int) LBoxConfigSystem::getInstance()->getParamByPath("xt/remember_cookie_days");
     } catch (Exception $e) {
         throw $e;
     }
 }
Exemple #20
0
 /**
  * vraci celou cestu k sablone control (ovlivnenou atributem filenameTemplate instance control)
  * @return string
  */
 protected function getPathTemplate()
 {
     try {
         $pathTemplatesForms = LBoxConfigSystem::getInstance()->getParamByPath("metarecords/templates/path");
         return LBoxUtil::fixPathSlashes("{$pathTemplatesForms}/" . $this->filenameTemplate);
     } catch (Exception $e) {
         throw $e;
     }
 }
 public function prepare($name = "", $value = NULL)
 {
     switch ($name) {
         case "downloadUrl":
             $virtualPath = LBoxConfigSystem::getInstance()->getParamByPath("download/output/path_virtual");
             return "{$virtualPath}:" . $this->instance->getFile()->id;
             break;
         case "url":
             return $this->getURLDisplay();
             break;
         case "createdRSS":
             return gmdate("D, d M Y H:i:s", strtotime($this->instance->created)) . " GMT";
             break;
         case "downloadedCount":
             return $this->instance->getFile()->getFileDownloaded()->count();
             break;
         case "ratedTotal":
             // pocet hlasu znamkovani downloadu
             if (!$this->getRatingAVGRecord()) {
                 return 0;
             }
             return (int) $this->getRatingAVGRecord()->count;
             break;
         case "ratedAVG":
             // prumerna znamka downloadu
             if (!$this->getRatingAVGRecord()) {
                 return 0;
             }
             return $this->getRatingAVGRecord()->rating;
             break;
         case "ratedByUser":
             // jestli user uz znamkoval (podle IP)
             $ratings = new RatingsDownloadsRecords(array("ref_download" => $this->instance->id, "ip" => LBOX_REQUEST_IP));
             return $ratings->count() > 0;
             break;
         case "userMark":
             // jestli user uz znamkoval (podle IP)
             if (!($ratingRecord = $this->instance->getUserRating())) {
                 return NULL;
             } else {
                 return $ratingRecord->rating;
             }
             break;
         case "isAudio":
             switch (strtolower($this->instance->getFile()->ext)) {
                 case "mp3":
                     //case "ogg":
                     //case "wma":
                     //case "wav":
                     //case "aif":
                     //case "aiff":
                     return true;
                     break;
                 default:
                     return false;
             }
             break;
         default:
             return $value;
     }
 }
 /**
  *
  * @return PHPTAL
  */
 protected function getTAL()
 {
     try {
         if (!$this->TAL instanceof PHPTAL) {
             $this->TAL = new PHPTAL($this->getPathTemplate());
         }
         $translator = new LBoxTranslator($this->getPathTemplate());
         // zajistit existenci ciloveho adresare PHP kodu pro TAL:
         $phptalPhpCodeDestination = LBoxUtil::fixPathSlashes(LBoxConfigSystem::getInstance()->getParamByPath("output/tal/PHPTAL_PHP_CODE_DESTINATION"));
         LBoxUtil::createDirByPath($phptalPhpCodeDestination);
         $this->TAL->setTranslator($translator);
         $this->TAL->setForceReparse(LBoxConfigSystem::getInstance()->getParamByPath("output/tal/PHPTAL_FORCE_REPARSE"));
         $this->TAL->setPhpCodeDestination($phptalPhpCodeDestination);
         $this->TAL->SELF = $this;
         return $this->TAL;
     } catch (Exception $e) {
         throw $e;
     }
 }
Exemple #23
0
 /**
  * returns currently displaying language key
  * @return string
  */
 public static function getDisplayLanguage()
 {
     try {
         if (strlen(self::$displayLanguage) > 0) {
             return self::$displayLanguage;
         }
         $defaultLang = LBoxConfigSystem::getInstance()->getParamByPath("multilang/default_language");
         // check domain or return default
         try {
             $host = str_replace(".localhost", "", LBOX_REQUEST_URL_HOST);
             $host = str_replace("www.", "", $host);
             if (strlen($lang = LBoxConfigManagerLangdomains::getInstance()->getLangByDomain($host)) > 0) {
                 self::$displayLanguage = $lang;
             } else {
                 self::$displayLanguage = $defaultLang;
             }
             if (LBoxConfigManagerFront::gpcn('langchoose') == 'cookie') {
                 $cookies = self::getDataCookies();
                 if (strlen($cookies['lbox']['front']['lng']) > 0) {
                     self::$displayLanguage = $cookies['lbox']['front']['lng'];
                 }
                 if (strlen($_SESSION['lbox']['front']['lng']) > 0) {
                     self::$displayLanguage = $_SESSION['lbox']['front']['lng'];
                 }
             }
         } catch (LBoxExceptionConfig $e) {
             if ($e->getCode() == LBoxExceptionConfig::CODE_TYPE_NOT_FOUND) {
                 self::$displayLanguage = $defaultLang;
             }
         }
         return self::$displayLanguage;
     } catch (Exception $e) {
         throw $e;
     }
 }