示例#1
0
文件: edit.php 项目: TeNNoX/Salic
use Salic\Settings\LangSettings;
require_once 'Salic.php';
if (!Utils::validAuthentication()) {
    exit;
    // Utils should call exit(), but just to be sure...
}
$lang = strtolower(@$_GET['lang']);
if (empty($lang)) {
    $lang = LangSettings::get()->default;
}
if (!LangSettings::get()->exists($lang)) {
    echo "Invalid Language: '{$lang}'";
    exit;
}
$salic = new SalicMng($lang);
$salic->initTwig();
$page = strtolower(@$_GET['page']);
if (!empty($page) && !Validator::checkPageKey($page)) {
    Utils::dieWith404('there\'s an invalid symbol in the pagekey.');
}
if (empty($page)) {
    // default page
    try {
        $page = Settings\NavSettings::get()->homepage;
    } catch (\Exception $e) {
        Utils::dieWithError($e, 'Homepage determination', $salic);
        exit;
    }
}
$salic->renderPage($page);
示例#2
0
文件: index.php 项目: TeNNoX/Salic
namespace Salic;

use Salic\Settings\LangSettings;
use Salic\Settings\NavSettings;
require_once 'Salic.php';
$page = strtolower($_GET['page']);
if (!empty($page) && !Validator::checkPageKey($page)) {
    Utils::dieWith404('there\'s an invalid symbol in the pagekey.');
}
// LANGUAGE SELECTION
try {
    if (array_key_exists('lang', $_GET)) {
        $lang = $_GET['lang'];
        if (!Settings\LangSettings::get()->exists($lang)) {
            Utils::dieWith404("the language '{$lang}' is invalid.");
        }
    } else {
        $lang = Utils::getDefaultLanguageFromHeader();
        // language is not given, redirect to the best one
        http_response_code(302);
        //TODO: how to redirect properly for localisation?
        header("Location:/{$lang}/{$page}");
        echo "Redirect: <a href='/{$lang}/{$page}'>/{$lang}/{$page}</a>";
        exit;
    }
} catch (\Exception $e) {
    Utils::dieWithError($e, 'Language determination');
    exit;
}
$salic = new Salic($lang);