2007-09-22 12:59:41 +02:00
< ? 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 .
*
2007-09-30 17:53:54 +02:00
* File : common . php
* All pages should include this file - which itself sets up the necessary
* environment and ensures other functions are loaded .
*/
2007-12-02 20:23:08 +01:00
2021-03-09 21:34:09 +01:00
if ( ! defined ( 'POSTFIXADMIN' )) {
define ( 'POSTFIXADMIN' , 1 );
2011-10-18 01:19:57 +02:00
2021-03-09 21:34:09 +01:00
if ( ! defined ( 'POSTFIXADMIN_CLI' )) { // postfixadmin-cli
2015-07-12 14:09:34 +02:00
// 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' );
2016-05-22 18:57:09 +02:00
session_name ( 'postfixadmin_session' );
2011-10-18 01:19:57 +02:00
session_start ();
2013-11-11 01:06:27 +01:00
2018-01-26 15:45:57 +01:00
if ( empty ( $_SESSION [ 'flash' ])) {
2011-10-18 01:19:57 +02:00
$_SESSION [ 'flash' ] = array ();
}
2021-08-04 21:38:06 +02:00
// avoid clickjacking attacks?
header ( 'X-Frame-Options: DENY' );
2011-02-08 00:31:12 +01:00
}
2008-04-10 12:17:50 +02:00
}
2007-12-02 20:23:08 +01:00
2007-09-22 12:59:41 +02:00
$incpath = dirname ( __FILE__ );
2013-04-02 00:12:10 +02:00
2018-01-26 15:45:57 +01:00
if ( ! is_file ( " $incpath /config.inc.php " )) {
2009-04-08 22:17:24 +02:00
die ( " config.inc.php is missing! " );
2007-09-22 12:59:41 +02:00
}
2018-12-27 23:01:53 +01:00
global $CONF ;
2007-10-07 19:41:29 +02:00
require_once ( " $incpath /config.inc.php " );
2009-04-08 22:17:24 +02:00
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) " );
2009-04-08 22:17:24 +02:00
}
2007-10-04 16:57:39 +02:00
}
2009-04-08 22:17:24 +02:00
2020-09-28 21:33:54 +02:00
Config :: getInstance () -> setAll ( $CONF );
2013-10-31 21:52:45 +01:00
2020-03-12 21:45:51 +01:00
$PALANG = [];
2020-09-28 21:33:54 +02:00
2007-12-30 02:32:33 +01:00
require_once ( " $incpath /languages/language.php " );
2007-09-22 12:59:41 +02:00
require_once ( " $incpath /functions.inc.php " );
2011-10-18 01:19:57 +02:00
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 ;-)
2011-10-18 01:19:57 +02:00
$_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 " );
}
2007-09-22 12:59:41 +02:00
2018-01-26 15:45:57 +01:00
if ( ! empty ( $CONF [ 'language_hook' ]) && function_exists ( $CONF [ 'language_hook' ])) {
2011-08-23 23:23:16 +02:00
$hook_func = $CONF [ 'language_hook' ];
2018-01-26 15:45:57 +01:00
$PALANG = $hook_func ( $PALANG , $language );
2011-08-23 23:23:16 +02:00
}
2013-10-31 21:52:45 +01:00
Config :: write ( '__LANG' , $PALANG );
2013-10-13 20:11:18 +02:00
2011-10-18 01:19:57 +02:00
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 " );
2011-10-18 01:19:57 +02:00
}
2020-09-28 21:33:54 +02:00
require_once ( __DIR__ . '/lib/smarty/libs/Autoloader.php' );
Smarty_Autoloader :: register ();
2009-11-06 20:16:14 +01:00
}
2018-01-25 21:27:09 +01:00
2008-01-06 20:39:08 +01:00
/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */