示例#1
0
文件: conf.lib.php 项目: Ricain/Spic
function conf_read($key)
{
    conf_cache();
    if (!isset($GLOBALS[__FILE__]["settings"][$key])) {
        return "";
    }
    return $GLOBALS[__FILE__]["settings"][$key];
}
示例#2
0
文件: index.php 项目: Ricain/Spic
<?php

/**
 * Spic <https://github.com/ricain/spic>
 * @author Jean Mercadier <jmercadier.fr>
 * @license The MIT License
 */
define("SPIC_VERSION", "v1.1");
require_once __DIR__ . "/private/lib/conf.lib.php";
require_once __DIR__ . "/private/lib/dir.lib.php";
require_once __DIR__ . "/private/lib/secu.lib.php";
require_once __DIR__ . "/private/lib/util.lib.php";
conf_cache();
$forcessl = conf_read("forcessl");
if ((strcmp($forcessl, "true") == 0 || intval($forcessl) == 1) && strcmp($_SERVER["HTTP_X_FORWARDED_PROTO"], "https") != 0 && (!isset($_SERVER["HTTPS"]) || strcmp($_SERVER["HTTPS"], "on"))) {
    header("Status: 301 Moved Permanently");
    header("Location: https://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]);
    exit;
}
$url = strtolower(conf_read("url"));
if (util_empty($url)) {
    echo "URL NOT DEFINED IN CONFIG FILE. Does the file exist? Any syntax error?";
    exit;
}
$req = ltrim(str_replace(parse_url($url, PHP_URL_PATH), "", strtolower($_SERVER['REQUEST_URI'])), "/");
if (util_empty($req)) {
    if (secu_isloged()) {
        include __DIR__ . "/private/page/home.page.php";
    } else {
        header("Location: ./login");
    }