当前位置: 首页>>代码示例>>PHP>>正文


PHP RainTPL::rewriteEngine方法代码示例

本文整理汇总了PHP中RainTPL::rewriteEngine方法的典型用法代码示例。如果您正苦于以下问题:PHP RainTPL::rewriteEngine方法的具体用法?PHP RainTPL::rewriteEngine怎么用?PHP RainTPL::rewriteEngine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RainTPL的用法示例。


在下文中一共展示了RainTPL::rewriteEngine方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: Config

$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';
    $error['title'] = 'Login error';
    $error['content'] = '<p>The provided username or password is incorrect.</p>';
    $tpl->assign('error', $error, RainTPL::RAINTPL_IGNORE_SANITIZE);
开发者ID:qwertygc,项目名称:Freeder,代码行数:31,代码来源:init.php

示例2: install

/**
 * 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;
}
开发者ID:qwertygc,项目名称:Freeder,代码行数:65,代码来源:install.php


注:本文中的RainTPL::rewriteEngine方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。