コード例 #1
0
 /**
  * Constructor
  *
  * @param string $tpl_dir Template directory. It must be set the first time you use the class
  * @return RainTPL
  */
 function RainTPL($tpl_dir = null, $tpl_compile_dir = null, $base_dir = null)
 {
     if ($tpl_dir) {
         RainTPL::$tpl_dir = $tpl_dir . (substr($tpl_dir, -1, 1) != "/" ? "/" : "");
     }
     if ($tpl_compile_dir) {
         RainTPL::$tpl_compile_dir = $tpl_compile_dir;
     }
     if ($base_dir) {
         RainTPL::$base_dir = $base_dir;
     }
 }
コード例 #2
0
 /**
  * Constructor..
  * PDOException throwable
  */
 public function __construct($templateDirectory, $cacheDirectory, $templateExtension = 'html', $templatePrefix = '', $debug = false)
 {
     RainTPL::$tpl_dir = $templateDirectory;
     // template directory
     RainTPL::$cache_dir = $cacheDirectory;
     // cache directory
     RainTPL::$tpl_ext = $templateExtension;
     RainTPL::$path_replace = false;
     $this->rainTPL = new RainTPL();
     $this->dataDispatcher = new DataDispatcher();
     $this->tplDir = $templateDirectory;
     $this->tplExt = $templateExtension;
     $this->tplPrefix = $templatePrefix;
     $this->debug = $debug;
 }
コード例 #3
0
ファイル: init.php プロジェクト: qwertygc/Freeder
}
// Load config from database
require_once INC_DIR . 'config.class.php';
$config = new Config();
date_default_timezone_set($config->timezone);
// Test wether an update should be done
if ($config->version !== Config::$versions[count(Config::$versions) - 1]) {
    require_once INC_DIR . 'update.php';
    update($config->version, Config::$versions[count(Config::$versions) - 1]);
    header('location: index.php');
    exit;
}
// Load Rain TPL
require_once INC_DIR . 'rain.tpl.class.php';
require_once INC_DIR . 'rewriting.class.php';
RainTPL::$tpl_dir = RELATIVE_TPL_DIR . $config->template;
RainTPL::$base_url = $config->base_url;
RewriteEngine::$rewrite_base = RainTPL::$base_url;
RainTPL::$rewriteEngine = new RewriteEngine();
$tpl = new RainTPL();
$tpl->assign('start_generation_time', microtime(true), RainTPL::RAINTPL_IGNORE_SANITIZE);
$tpl->assign('config', $config);
// CSRF protection
require_once INC_DIR . 'csrf.php';
// Sharing options
require_once INC_DIR . 'share.php';
// Manage users
require_once INC_DIR . 'users.php';
if (log_user_in() === false) {
    $error = array();
    $error['type'] = 'error';
コード例 #4
0
ファイル: dispatcher.class.php プロジェクト: Geolim4/Leelabot
 public function process($id, $data)
 {
     //Before processing anything, we check if the user has been authenticated
     if ($this->_authentication) {
         //If the user has not been authenticated, we return a blank page (the request has been return by authenticate())
         if (!$this->_main->authenticate($id, $data, array($this, 'userCheck'))) {
             return TRUE;
         }
     }
     foreach ($this->_pages as $regex => $call) {
         if (preg_match('#^' . $regex . '$#', strtolower($data['matches'][1]), $matches)) {
             //Setting initial environment for page process
             $page = strtolower($data['matches'][1]);
             $data['matches'] = $matches;
             $this->_design = TRUE;
             $this->_noCache = FALSE;
             $this->parser = new RainTPL();
             RainTPL::$tpl_dir = 'web/views/' . Leelabot::$instance->intl->getLocale() . '/';
             //Calling the page controller
             $fctrep = $call[0]->{$call}[1]($data);
             //Adding the design
             if ($this->_design) {
                 $content = $this->addDesign($page, $fctrep);
             } else {
                 $content = $fctrep;
             }
             //Sending the final page
             $this->_main->BufferSetReplyCode($id, 200);
             if ($this->_noCache) {
                 $this->_main->BufferAddHeader($id, 'Cache-Control', 'no-store, no-cache, must-revalidate');
             }
             $this->_main->BufferAppendData($id, $content);
             $this->_main->sendBuffer($id);
             return TRUE;
         }
     }
     $this->_site->callErrorPage(404, $id, $data);
 }
コード例 #5
0
ファイル: rewriting.php プロジェクト: qwertygc/Freeder
<?php

/*	Copyright (c) 2014 Freeder
 *	Released under a MIT License.
 *	See the file LICENSE at the root of this repo for copying permission.
 */
/**
 * This is a unit test file to check url rewriting.
 * Currently it only checks Rain TPL rewriting but it should also check Freeder's one when it will becom available.
 */
define('TESTING', 'raintpl');
// Defines what unit to test
define('INC_DIR', '../inc/');
if (TESTING == 'raintpl') {
    // Load Rain TPL
    require_once INC_DIR . 'rain.tpl.class.php';
    RainTPL::$tpl_dir = 'tpl_dir/';
    RainTPL::$base_url = 'base_url/';
    $tpl = new RainTPL();
    $tpl->draw('rewriting');
} else {
    if (TESTING == 'local') {
        require_once 'rewriting.inc.php';
        $html = file_get_contents('tpl_dir/rewriting.html');
        echo path_replace($html);
    }
}
コード例 #6
0
ファイル: template.class.php プロジェクト: venmos/go9999.com
 /**
  * 初始化模板
  *
  * @since 1.0.1
  *
  * @param bool $empty
  *
  * @return bool
  */
 private function initTemplate($empty = false)
 {
     if ($empty) {
         return true;
     }
     if (file_exists(FILE_PREFIX . 'content/theme/' . THEME . '/')) {
         RainTPL::$tpl_dir = FILE_PREFIX . 'content/theme/' . THEME . '/';
         RainTPL::$cache_dir = FILE_PREFIX . 'content/theme/' . THEME . '_cache/';
     } else {
         RainTPL::$tpl_dir = FILE_PREFIX . 'content/theme/default/';
         RainTPL::$cache_dir = FILE_PREFIX . 'content/theme/default_cache/';
     }
     RainTPL::$tpl_ext = 'tpl.php';
     RainTPL::$path_replace = false;
     $this->tpl = new RainTPL();
 }
コード例 #7
0
ファイル: install.php プロジェクト: qwertygc/Freeder
/**
 * Proceed to Freeder installation.
 */
function install()
{
    global $default_timezone;
    $current_user = get_current_user();
    $tmp = install_dir('tmp');
    if (!empty($tmp)) {
        exit('Unable to create or write to tmp/ folder. Please check write permissions on this folder.');
    }
    $login = isset($_POST['login']) ? $_POST['login'] : '';
    $timezone = isset($_POST['timezone']) ? $_POST['timezone'] : $default_timezone;
    require_once INC_DIR . 'rain.tpl.class.php';
    require_once INC_DIR . 'rewriting.class.php';
    RainTPL::$tpl_dir = RELATIVE_TPL_DIR . DEFAULT_THEME . '/';
    RainTPL::$base_url = dirname($_SERVER['SCRIPT_NAME']) . '/';
    RewriteEngine::$rewrite_base = RainTPL::$base_url;
    RainTPL::$rewriteEngine = new RewriteEngine();
    $tpl = new RainTPL();
    $tpl->assign('start_generation_time', microtime(true), RainTPL::RAINTPL_IGNORE_SANITIZE);
    $tpl->assign('login', $login, RainTPL::RAINTPL_HTML_SANITIZE);
    $tpl->assign('timezone', $timezone, RainTPL::RAINTPL_HTML_SANITIZE);
    if ($err = RainTPL::$rewriteEngine->write_htaccess()) {
        $error = array();
        $error['type'] = 'error';
        $error['title'] = 'Permissions error';
        $error['content'] = 'Unable to create or write .htaccess file. Check the writing rights of Freeder root directory. The user who executes Freeder — ' . sanitize($current_user) . ' — should be able to write in this directory. You may prefer to create the .htaccess file on your own and allow ' . sanitize($current_user) . ' to write only in .htaccess instead of in the whole Freeder root.';
        $tpl->assign('error', $error, RainTPL::RAINTPL_IGNORE_SANITIZE);
    }
    if (!empty($_POST['login']) && !empty($_POST['password']) && !empty($_POST['confirm_password']) && !empty($_POST['timezone'])) {
        if ($_POST['confirm_password'] != $_POST['password']) {
            $error = array();
            $error['type'] = 'error';
            $error['title'] = 'Password mismatch';
            $error['content'] = 'Passwords do not match!';
        } else {
            $error = install_dir(DATA_DIR);
            if (empty($error)) {
                $error = install_db();
                if (empty($error)) {
                    $_SESSION['user'] = new stdClass();
                    $_SESSION['user']->login = $_POST['login'];
                    $_SESSION['is_admin'] = 1;
                    header('location: index.php');
                    exit;
                } else {
                    $tpl->assign('error', $error, RainTPL::RAINTPL_IGNORE_SANITIZE);
                }
            } else {
                $tpl->assign('error', $error, RainTPL::RAINTPL_IGNORE_SANITIZE);
            }
        }
    } else {
        if (isset($_POST['login'])) {
            $error = array();
            $error['type'] = 'error';
            $error['title'] = 'Incomplete installation form';
            $error['content'] = 'You must fill every field.';
            $tpl->assign('error', $error, RainTPL::RAINTPL_IGNORE_SANITIZE);
        }
    }
    $tpl->draw('install');
    exit;
}
コード例 #8
0
ファイル: index.php プロジェクト: Phyks/miniflux_api
 $entries = [];
 foreach ($feeds as $feed) {
     if (!$feed["enabled"]) {
         continue;
     }
     // Update old feeds
     if (time() - $feed["last_checked"] >= 3600) {
         $client->execute('feed.update', ["feed_id" => $feed["id"]]);
     }
 }
 // Fetch entries
 $entries = $client->execute('item.list_unread');
 // Init RainTPL
 if (file_exists("tmp/") && is_writable("tmp/")) {
     require_once 'inc/rain.tpl.class.php';
     RainTPL::$tpl_dir = "tpl/zen/";
     RainTPL::$cache_dir = "tmp/";
     RainTPL::$base_url = $BASE_URL;
     $tpl = new RainTPL();
     $tpl->assign('start_generation_time', microtime(true), RainTPL::RAINTPL_IGNORE_SANITIZE);
 }
 function get_feed_from_entry($value, $feeds)
 {
     foreach ($feeds as $feed) {
         if ($value["feed_id"] == $feed["id"]) {
             return $feed;
         }
     }
     return null;
 }
 function get_entry_link($value)