2007-09-22 12:59:41 +02:00
< ? php
2007-09-30 17:53:54 +02:00
/**
* Postfix Admin
*
* LICENSE
* This source file is subject to the GPL license that is bundled with
* this package in the file LICENSE . TXT .
*
2013-11-10 16:57:32 +01:00
* Further details on the project are available at http :// postfixadmin . sf . net
2007-09-30 17:53:54 +02:00
*
* @ version $Id $
* @ 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 .
*/
2007-12-02 20:23:08 +01:00
2009-10-20 21:25:20 +02:00
if ( ! defined ( 'POSTFIXADMIN' )) { # already defined if called from setup.php
2011-02-08 00:31:12 +01:00
define ( 'POSTFIXADMIN' , 1 ); # checked in included files
2011-10-18 01:19:57 +02:00
if ( ! defined ( 'POSTFIXADMIN_CLI' )) {
2015-07-12 14:09:34 +02:00
// this is the default; see also https://sourceforge.net/p/postfixadmin/bugs/347/
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
if ( defined ( 'POSTFIXADMIN_LOGOUT' )) {
session_unset ();
session_destroy ();
session_start ();
}
2011-10-18 01:19:57 +02:00
if ( empty ( $_SESSION [ 'flash' ])) {
$_SESSION [ 'flash' ] = array ();
}
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__ );
2007-09-28 21:28:24 +02:00
( ini_get ( 'magic_quotes_gpc' ) ? ini_set ( 'magic_quotes_runtime' , '0' ) : '1' );
( ini_get ( 'magic_quotes_gpc' ) ? ini_set ( 'magic_quotes_sybase' , '0' ) : '1' );
2007-09-22 12:59:41 +02:00
2009-04-02 22:49:32 +02:00
if ( ini_get ( 'register_globals' ) == 'on' ) {
2007-11-26 08:38:56 +01:00
die ( " Please turn off register_globals; edit your php.ini " );
}
2013-04-02 00:12:10 +02:00
/**
* @ param string $class
* __autoload implementation , for use with spl_autoload_register () .
*/
function postfixadmin_autoload ( $class ) {
$PATH = dirname ( __FILE__ ) . '/model/' . $class . '.php' ;
if ( is_file ( $PATH )) {
require_once ( $PATH );
return true ;
}
return false ;
}
spl_autoload_register ( 'postfixadmin_autoload' );
2007-09-22 12:59:41 +02: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
}
2007-10-07 19:41:29 +02:00
require_once ( " $incpath /config.inc.php " );
2009-04-08 22:17:24 +02:00
2007-10-04 16:57:39 +02:00
if ( isset ( $CONF [ 'configured' ])) {
if ( $CONF [ 'configured' ] == FALSE ) {
2009-04-08 22:17:24 +02:00
die ( " Please edit config.inc.php - change \$ CONF['configured'] to true after setting your database settings " );
}
2007-10-04 16:57:39 +02:00
}
2009-04-08 22:17:24 +02:00
2013-10-31 21:52:45 +01:00
Config :: write ( $CONF );
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 {
$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 ;
}
require_once ( " $incpath /languages/ " . $language . " .lang " );
2007-09-22 12:59:41 +02:00
2014-01-14 17:00:42 +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' ];
2011-10-18 01:19:57 +02: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:37:52 +02:00
2011-10-18 01:19:57 +02:00
if ( ! defined ( 'POSTFIXADMIN_CLI' )) {
if ( ! is_file ( " $incpath /smarty.inc.php " )) {
die ( " smarty.inc.php is missing! Something is wrong... " );
}
require_once ( " $incpath /smarty.inc.php " );
2009-11-06 20:16:14 +01:00
}
2008-01-06 20:39:08 +01:00
/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */
2009-11-06 20:23:07 +01:00
?>