/** * Sets the template dir * @param String $paramTemplateDir new template directory */ public function setTemplateDir($paramTemplateDir) { if (!is_string($paramTemplateDir)) { throw new IllegalArgumentException("Invalid argument, string expected."); } raintpl::$tpl_dir = $paramTemplateDir; }
function generate($template, $data = null) { $this->load_library('rain.tpl.class'); raintpl::$tpl_dir = ROOT . "/application/templates/email/"; // template directory $tpl = new raintpl(); //include Rain TPL if (isset($data)) { $data = Utils::decode($data); $tpl->assign($data); } if (!get_config('email.debug_templates')) { $this->message = @$tpl->draw($template, true); } else { $this->message = $tpl->draw($template, true); } // draw the template }
function generate_page($url, $title, $content) { global $CSS_STYLE; raintpl::$tpl_dir = './tpl/'; // template directory raintpl::$cache_dir = "./cache/"; // cache directory raintpl::$base_url = url(); // base URL of blog raintpl::configure('path_replace', false); raintpl::configure('debug', true); $tpl = new raintpl(); //include Rain TPL $tpl->assign("url", $url); $tpl->assign("tinyurl", md5($url)); $tpl->assign("title", $title); $tpl->assign("isLogged", Session::isLogged()); if (Session::isLogged()) { $tpl->assign("username", $_SESSION['username']); $tpl->assign("logpage", "./log.php?logout"); $tpl->assign("logname", "Logout"); } else { $tpl->assign("logpage", "./log.php"); $tpl->assign("logname", "Login"); } $tpl->assign("content", $content); $tpl->assign("version", VERSION); $tpl->draw("article"); // draw the template }
ini_set('session.use_only_cookies', 1); // Prevent PHP form using sessionID in URL if cookies are disabled. ini_set('session.use_trans_sid', false); session_name('shaarli'); // Start session if needed (Some server auto-start sessions). if (session_id() == '') { session_start(); } // Regenerate session ID if invalid or not defined in cookie. if (isset($_COOKIE['shaarli']) && !is_session_id_valid($_COOKIE['shaarli'])) { session_regenerate_id(true); $_COOKIE['shaarli'] = session_id(); } include "inc/rain.tpl.class.php"; //include Rain TPL raintpl::$tpl_dir = $GLOBALS['config']['RAINTPL_TPL']; // template directory raintpl::$cache_dir = $GLOBALS['config']['RAINTPL_TMP']; // cache directory $pluginManager = PluginManager::getInstance(); $pluginManager->load($GLOBALS['config']['ENABLED_PLUGINS']); ob_start(); // Output buffering for the page cache. // In case stupid admin has left magic_quotes enabled in php.ini: if (get_magic_quotes_gpc()) { function stripslashes_deep($value) { $value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value); return $value; } $_POST = array_map('stripslashes_deep', $_POST);
TODO: penser a ajouter la gestion des utilisateurs et des fichiers sauvegarder via XML: http://php.net/manual/en/function.simplexml-load-string.php */ if (isset($_GET['logout'])) { Session::logout(); header('Location: index.php'); die; } else { if (isset($_POST['login']) && isset($_POST['password'])) { $user = User::getUser('./conf/', $_POST['login']); if ($user && $user->getPassword() != null && Session::login($_POST['login'], User::getHashPassword($_POST['password']), $user->getLogin(), $user->getPassword())) { if (Session::isLogged() && $_SESSION['username'] != null && !is_dir('./' . SAVED_PATH . '/' . $_SESSION['username'])) { mkdir('./' . SAVED_PATH . '/' . $_SESSION['username'], 0705); } header('Location: index.php'); die; } } } raintpl::$tpl_dir = './tpl/'; // template directory raintpl::$cache_dir = "./cache/"; // cache directory raintpl::$base_url = url(); // base URL of blog raintpl::configure('path_replace', false); raintpl::configure('debug', true); $tpl = new raintpl(); //include Rain TPL $tpl->draw("login"); // draw the template
<?php /*** include the controller class ***/ include __SITE_PATH . '/application/' . 'controller_base.class.php'; /*** include the registry class ***/ include __SITE_PATH . '/application/' . 'registry.class.php'; /*** include the router class ***/ include __SITE_PATH . '/application/' . 'router.class.php'; /*** include the template class ***/ //include __SITE_PATH . '/application/' . 'template.class.php'; // Original TPL Class include __SITE_PATH . '/application/' . 'rainTPL.class.php'; raintpl::$tpl_dir = __SITE_PATH . '/views/'; raintpl::$cache_dir = __SITE_PATH . '/cache/'; raintpl::configure('base_url', __SITE_PATH); $config = parse_ini_file("application/config.ini", 1); /*** auto load model classes ***/ function __autoload($class_name) { $filename = strtolower($class_name) . '.class.php'; $file = __SITE_PATH . '/model/' . $filename; if (file_exists($file) == false) { return false; } include $file; } /*** a new registry object ***/ $registry = new registry(); $registry->DB_Conn = $config['db_conn']; $registry->config = $config; /*** create the database registry object ***/ $registry->database = new db($registry->DB_Conn);
session_set_cookie_params($cookie['lifetime'], dirname($_SERVER["SCRIPT_NAME"]) . '/'); // Default cookie expiration and path. // PHP Settings ini_set('max_input_time', '60'); // High execution time in case of problematic imports/exports. ini_set('memory_limit', '128M'); // Try to set max upload file size and read (May not work on some hosts). ini_set('post_max_size', '16M'); ini_set('upload_max_filesize', '16M'); checkphpversion(); error_reporting(E_ALL ^ E_WARNING); // See all error except warnings. //error_reporting(-1); // See all errors (for debugging only) include "inc/rain.tpl.class.php"; //include Rain TPL raintpl::$tpl_dir = "tpl_bilbo/"; // template directory if (!is_dir('tmp')) { mkdir('tmp', 0705); chmod('tmp', 0705); } raintpl::$cache_dir = dirname(__FILE__) . "/../data/tmp/"; // cache directory ob_start(); // Output buffering for the page cache. // In case stupid admin has left magic_quotes enabled in php.ini: if (get_magic_quotes_gpc()) { function stripslashes_deep($value) { $value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value); return $value;
/** * Creates new Rain instance if it doesn't already exist, and returns it. * * @throws RuntimeException If Rain lib directory does not exist. * @return RainInstance */ private function getInstance() { if (!self::$rainInstance) { if (!is_dir(self::$rainDirectory)) { throw new \RuntimeException('Cannot set the Rain lib directory : ' . self::$rainDirectory . '. Directory does not exist.'); } require_once self::$rainDirectory . '/rain.tpl.class.php'; raintpl::$tpl_dir = self::$rainTemplatesDirectory; raintpl::$cache_dir = self::$rainCacheDirectory; self::$rainInstance = new \raintpl(); } return self::$rainInstance; }
function Raintpl_View($tpl_dir, $cache_dir, $base_url) { raintpl::$tpl_dir = $tpl_dir; raintpl::$cache_dir = $cache_dir; raintpl::$base_url = $base_url; }
/** * Creates new Rain instance if it doesn't already exist, and returns it. * * @throws RuntimeException If Rain lib directory does not exist. * @return RainInstance */ private function getInstance() { if (!$this->rainInstance) { if (!is_dir($this->rainDirectory)) { throw new RuntimeException('Cannot set the Rain lib directory : ' . $this->rainDirectory . '. Directory does not exist.'); } require_once $this->rainDirectory . '/rain.tpl.class.php'; raintpl::$tpl_dir = $this->rainTemplatesDirectory; raintpl::$cache_dir = $this->rainCacheDirectory; $this->rainInstance = new raintpl(); } return $this->rainInstance; }
} else { stop(); } break; case 'gen_users_xls': $ajaxer = 3; raintpl::$tpl_dir = ROOT_DIR . '/root/template/ajax/'; if (defined('ALLOW_generate_xls') && ALLOW_generate_xls == true) { require_once ENGINE_DIR . '/modules/generate/generate_xls.php'; } else { stop(); } break; case 'gen_users_xls_st': $ajaxer = 3; raintpl::$tpl_dir = ROOT_DIR . '/root/template/ajax/'; if (defined('ALLOW_generate_xls') && ALLOW_generate_xls == true) { require_once ENGINE_DIR . '/modules/generate/generate_xls.st.php'; } else { stop(); } break; } } else { stop(); } break; case 'admins': if (LEVEL == 1) { $thispage = "Администраторы"; if (isset($_POST['ss'])) {
} // Start session if needed (Some server auto-start sessions). // PHP Settings ini_set('max_input_time', '60'); // High execution time in case of problematic imports/exports. ini_set('memory_limit', '128M'); // Try to set max upload file size and read (May not work on some hosts). ini_set('post_max_size', '16M'); ini_set('upload_max_filesize', '16M'); checkphpversion(); error_reporting(E_ALL ^ E_WARNING); // See all error except warnings. //error_reporting(-1); // See all errors (for debugging only) include "inc/rain.tpl.class.php"; //include Rain TPL raintpl::$tpl_dir = "tpl/"; // template directory if (!is_dir('tmp')) { mkdir('tmp', 0705); chmod('tmp', 0705); } raintpl::$cache_dir = "tmp/"; // cache directory ob_start(); // Output buffering for the page cache. // In case stupid admin has left magic_quotes enabled in php.ini: if (get_magic_quotes_gpc()) { function stripslashes_deep($value) { $value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value); return $value;