function refreshCacheDir() { $dirTmp = Site::racine() . Config::getCacheDir() . 'Smarty/' . $this->templateName . '/'; if (!is_dir($dirTmp)) { if (!mkdir($dirTmp, 0777, true)) { Site::error('Impossible de creer le dossier de cache : ' . $dirTmp); return false; } } $this->cache_dir = $dirTmp; return true; }
public function prepare($_qry, $_options = NULL) { Debug::write("SQL prepare : " . $_qry, 2); self::$count = self::$count + 1; try { // Should be caught through Site.class.php, but still... just in case if ($_options === null) { return parent::prepare($_qry); } else { return parent::prepare($_qry, $_options); } } catch (PDOException $e) { Site::error(Site::app_error, "Database error", $GLOBALS['config']['security']['displayExplicitErrors'] === true ? $e->getMessage() : $GLOBALS['config']['errors']['framework']['503']); } }
if ($site->fdat['id']) { $site->debug->msg("EDIT: ID = " . $site->fdat['id']); # $all_parents = $site->get_obj_all_parents($site->fdat['id']); # echo "all_parents=".printr($all_parents); $objekt = new Objekt(array(objekt_id => $site->fdat['id'], on_sisu => 1, no_cache => 1)); # kui objektil on rohkem, kui 1 parent, siis loodame objekti uuesti uue parentiga: if ($objekt->all['parents_count'] > 1 && $objekt->parent_id != $site->fdat['parent_id']) { $site->debug->msg("EDIT: Leidsin mitu parenti (" . $objekt->all['parents_count'] . "). Kasutan parent_id=" . $site->fdat['parent_id']); unset($objekt); $objekt = new Objekt(array(objekt_id => $site->fdat['id'], parent_id => $site->fdat['parent_id'], no_cache => 1, on_sisu => 1)); } $tyyp['tyyp_id'] = $objekt->all['tyyp_id']; $site->debug->msg("EDIT: " . $objekt->debug->get_msgs()); $site->debug->msg("EDIT: Tyyp_id detected: " . $tyyp['tyyp_id']); if (!$objekt->objekt_id) { $site->error("EDIT: Vale objekti ID"); } } else { # default parent for file (folder "public/") if ($site->fdat['op'] == 'new' && $site->fdat['tyyp_id'] == 21 && !$site->fdat['parent_id']) { # file object and no parent ID set # get folder ID of "public/", Bug #2342 $sql = $site->db->prepare("SELECT objekt_id FROM obj_folder WHERE relative_path = ? LIMIT 1", $site->CONF['file_path']); $sth = new SQL($sql); $tmp = $sth->fetch(); $site->fdat['parent_id'] = $tmp['objekt_id']; } $parent_objekt = new Objekt(array(objekt_id => $site->fdat['parent_id'], no_cache => 1)); } # / GET PARENT OBJECT ###################
/** * [From request, find what controller file is concerned] */ protected function findController() { self::$path_to_controller = CONTROLLERS_DIR; // initialize path if (!empty(self::$sections)) { foreach (self::$sections as $section) { if (is_dir(self::$path_to_controller . strtolower($section))) { self::$path_to_controller .= strtolower($section) . "/"; } elseif (file_exists(self::$path_to_controller . ucwords(strtolower($section)) . ".class.php")) { self::$controller_file_to_load = ucwords(strtolower($section)) . ".class.php"; } else { if ($GLOBALS['config']['controller']['loadLastKnownController'] === false) { Site::error(Site::HTTP_error, "404", $GLOBALS['config']['errors']['framework']['404']); } else { break; } } } } if (empty(self::$controller_file_to_load)) { self::$controller_file_to_load = "Index.class.php"; } //TODO : change .class.php to .php if not poo self::$controller_name_to_load = str_replace(".class.php", "", self::$controller_file_to_load); }
/** * [A kind of destructor. * loads template, replace patterns and display the content to the web browser] */ public function display() { if (empty($this->template)) { if (!isset($GLOBALS['config']['HTML']['template']) || empty($GLOBALS['config']['HTML']['template'])) { Site::error(Site::app_error, "10", $GLOBALS['config']['errors']['framework']['10']); } elseif (!is_dir(HTML_DIR . $GLOBALS['config']['HTML']['template'])) { Site::error(Site::app_error, "11", $GLOBALS['config']['errors']['framework']['11']); } $this->template = HTML_DIR . $GLOBALS['config']['HTML']['template'] . "/" . $GLOBALS['config']['HTML']['template'] . ".template"; } if (is_readable($this->template)) { ob_start(); include $this->template; $this->content = ob_get_clean(); } else { Site::error(Site::app_error, "12", $GLOBALS['config']['errors']['framework']['12']); } if (empty($this->items)) { Debug::write("No pattern to be replaced were found in this template !", 0); } $this->replaceDefaultUserContent(); $this->setLocaleContent("global"); if ($this->locale) { $this->setLocaleContent($this->locale); } $this->replaceAllContent(); /** * look for unreplaced patterns */ preg_match_all("/%%[^%]*%%/", $this->content, $ressources_config_file); preg_match_all("/##[^#]*##/", $this->content, $ressources_locale); $unreplaced_patterns = array_merge($ressources_locale[0], $ressources_config_file[0]); if (!empty($unreplaced_patterns)) { foreach ($unreplaced_patterns as $pattern) { $current = "'" . $pattern . "' "; $msg = empty($msg) ? $current : $msg . $current; $this->setContent($pattern, ""); } $msg = preg_replace("/%/", "", $msg); Debug::write("One or several HTML field hasn't been replaced : " . htmlentities($msg), 0); if (!isset($GLOBALS['config']['HTML']['view']['suppressUnmatchedPatterns']) || $GLOBALS['config']['HTML']['view']['suppressUnmatchedPatterns'] === true) { $this->replaceAllContent(); } //delete unreplaced patterns from HTML template } echo $this->content; }
*/ if (isset($GLOBALS['config']['DEBUG']['enabled']) && $GLOBALS['config']['DEBUG']['enabled'] == true) { Debug::build(); } /** * Security checks * Keep in mind it just does a BASIC check on world-permission on files/folders under DOCUMENT_ROOT ; and a quick check on php.ini */ if ($GLOBALS['config']['security']['skipLocalChecks'] === false) { //Setup CoreController::startCapturing(); $successful_Check = true; /** * php.ini config */ echo "<u>Checking php.ini file ...</u><br />"; php_iniChecks(); echo "******************<br />"; /** * File rights */ echo "<u>Checking file permissions ...</u><br />"; localSecurityChecks(ROOT_DIR); // Can be found in FUNCTIONS_DIR . security.php //Cleaning $output = CoreController::stopCapturing(); if ($GLOBALS["successful_Check"] === false) { Site::error(Site::app_error, "Some misconfiguration were detected. <br />Please fix them in order to run this framework safely", $output); } unset($successful_Check, $checks); }