0
0
mirror of https://github.com/postfixadmin/postfixadmin.git synced 2024-09-19 11:12:15 +02:00
postfixadmin/common.php

97 lines
2.8 KiB
PHP
Raw Permalink Normal View History

<?php
2021-07-07 22:41:59 +02:00
require_once(dirname(__FILE__) . '/vendor/autoload.php');
2018-01-26 15:45:57 +01:00
/**
* Postfix Admin
*
* LICENSE
* This source file is subject to the GPL license that is bundled with
* this package in the file LICENSE.TXT.
*
* Further details on the project are available at http://postfixadmin.sf.net
*
* @license GNU GPL v2 or later.
*
* File: common.php
* All pages should include this file - which itself sets up the necessary
* environment and ensures other functions are loaded.
*/
// See: https://github.com/postfixadmin/postfixadmin/pull/541 - try and check if the user has a turkish locale and warn?
$old = setlocale(LC_ALL, 'C');
2022-07-15 11:29:55 +02:00
if (preg_match('/_TR/i', $old)) {
error_log("WARNING: You may have a Turkish locale set; this breaks the loading of some libraries (Smarty) we depend upon.");
// don't revert back to $old?
2022-07-15 11:29:55 +02:00
} else {
setlocale(LC_ALL, $old); // revert back.
}
if (!defined('POSTFIXADMIN')) {
define('POSTFIXADMIN', 1);
if (!defined('POSTFIXADMIN_CLI')) { // postfixadmin-cli
// this is the default; see also https://sourceforge.net/p/postfixadmin/bugs/347/
2018-01-26 15:45:57 +01:00
session_cache_limiter('nocache');
session_name('postfixadmin_session');
session_start();
2018-01-26 15:45:57 +01:00
if (empty($_SESSION['flash'])) {
$_SESSION['flash'] = array();
}
// avoid clickjacking attacks?
header('X-Frame-Options: DENY');
}
}
$incpath = dirname(__FILE__);
2018-01-26 15:45:57 +01:00
if (!is_file("$incpath/config.inc.php")) {
die("config.inc.php is missing!");
}
2018-12-27 23:01:53 +01:00
global $CONF;
require_once("$incpath/config.inc.php");
2018-12-27 23:01:53 +01:00
2019-01-03 20:35:33 +01:00
if (isset($CONF['configured']) && !defined('PHPUNIT_TEST')) {
2018-01-26 15:45:57 +01:00
if ($CONF['configured'] == false) {
2019-01-01 21:38:07 +01:00
die("Please edit config.local.php - change \$CONF['configured'] to true after specifying appropriate local settings (database_type etc)");
}
}
2020-09-28 21:33:54 +02:00
Config::getInstance()->setAll($CONF);
2020-03-12 21:45:51 +01:00
$PALANG = [];
2020-09-28 21:33:54 +02:00
require_once("$incpath/languages/language.php");
require_once("$incpath/functions.inc.php");
if (defined('POSTFIXADMIN_CLI')) {
$language = 'en'; # TODO: make configurable or autodetect from locale settings
} else {
2018-01-26 15:45:57 +01:00
$language = check_language(); # TODO: storing the language only at login instead of calling check_language() on every page would save some processor cycles ;-)
$_SESSION['lang'] = $language;
}
2018-12-28 20:31:43 +01:00
if (!empty($language)) {
2018-12-27 23:01:53 +01:00
require_once("$incpath/languages/" . $language . ".lang");
}
2018-01-26 15:45:57 +01:00
if (!empty($CONF['language_hook']) && function_exists($CONF['language_hook'])) {
$hook_func = $CONF['language_hook'];
2018-01-26 15:45:57 +01:00
$PALANG = $hook_func($PALANG, $language);
}
Config::write('__LANG', $PALANG);
if (!defined('POSTFIXADMIN_CLI')) {
2021-02-17 22:29:18 +01:00
if (!isset($PALANG)) {
2020-09-28 21:33:54 +02:00
die("environment not setup correctly");
}
2020-09-28 21:33:54 +02:00
Smarty_Autoloader::register();
}
/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */