mirror of
https://github.com/postfixadmin/postfixadmin.git
synced 2024-09-19 19:22:14 +02:00
common.php:
- merge with scripts/common.php - don't start/use session in CLI mode - don't load smarty.inc.php in CLI mode - hardcode language to 'en' in CLI mode (was done in postfixadmin-cli.php before) scripts/postfixadmin-cli.php - __bootstrap(): - use common.php instead of scripts/common.php - don't load languages/language.php and languages/en.lang (already done via common.php) - don't call language_hook (already done via common.php) scripts/common.php: - deleted - dropped helper functions low(), up(), r() and pr() which were just shortnames for existing PHP functions git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1214 a1433add-5e2c-0410-b055-b7f2511e0802
This commit is contained in:
parent
7bcd041d45
commit
4611b111e3
32
common.php
32
common.php
@ -18,10 +18,13 @@
|
||||
*/
|
||||
|
||||
if(!defined('POSTFIXADMIN')) { # already defined if called from setup.php
|
||||
session_start();
|
||||
define('POSTFIXADMIN', 1); # checked in included files
|
||||
if(empty($_SESSION['flash'])) {
|
||||
$_SESSION['flash'] = array();
|
||||
|
||||
if (!defined('POSTFIXADMIN_CLI')) {
|
||||
session_start();
|
||||
if(empty($_SESSION['flash'])) {
|
||||
$_SESSION['flash'] = array();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -48,12 +51,19 @@ if(isset($CONF['configured'])) {
|
||||
|
||||
require_once("$incpath/languages/language.php");
|
||||
require_once("$incpath/functions.inc.php");
|
||||
$_SESSION['lang'] = $language = check_language (); # TODO: storing the language only at login instead of calling check_language() on every page would save some processor cycles ;-)
|
||||
require_once("$incpath/languages/" . $_SESSION['lang'] . ".lang");
|
||||
|
||||
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");
|
||||
|
||||
if($CONF['language_hook'] != '' && function_exists($CONF['language_hook'])) {
|
||||
$hook_func = $CONF['language_hook'];
|
||||
$PALANG = $hook_func ($PALANG, $_SESSION['lang']);
|
||||
$PALANG = $hook_func ($PALANG, $language);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -71,11 +81,11 @@ function postfixadmin_autoload($class) {
|
||||
}
|
||||
spl_autoload_register('postfixadmin_autoload');
|
||||
|
||||
//*****
|
||||
if(!is_file("$incpath/smarty.inc.php")) {
|
||||
die("smarty.inc.php is missing! Something is wrong...");
|
||||
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");
|
||||
}
|
||||
require_once ("$incpath/smarty.inc.php");
|
||||
//*****
|
||||
/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */
|
||||
?>
|
||||
|
@ -1,113 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* 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://www.postfixadmin.com or http://postfixadmin.sf.net
|
||||
*
|
||||
* @version $Id: common.php 733 2009-10-20 19:25:20Z christian_boltz $
|
||||
* @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.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
$incpath = PATH;
|
||||
(ini_get('magic_quotes_gpc') ? ini_set('magic_quotes_runtime', '0') : '1');
|
||||
(ini_get('magic_quotes_gpc') ? ini_set('magic_quotes_sybase', '0') : '1');
|
||||
|
||||
if(ini_get('register_globals') == 'on') {
|
||||
die("Please turn off register_globals; edit your php.ini");
|
||||
}
|
||||
require_once("$incpath/variables.inc.php");
|
||||
/*
|
||||
if(!is_file("$incpath/config.inc.php")) {
|
||||
die("config.inc.php is missing!");
|
||||
}
|
||||
require_once("$incpath/config.inc.php");
|
||||
*/
|
||||
if(isset($CONF['configured'])) {
|
||||
if($CONF['configured'] == FALSE) {
|
||||
die("Please edit config.inc.php - change \$CONF['configured'] to true after setting your database settings");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
require_once("$incpath/languages/language.php");
|
||||
require_once("$incpath/functions.inc.php");
|
||||
require_once("$incpath/languages/en.lang");
|
||||
*/
|
||||
/**
|
||||
* @param string $class
|
||||
* __autoload implementation, for use with spl_autoload_register().
|
||||
*/
|
||||
function postfixadmin_autoload2($class) {
|
||||
$PATH = CORE_INCLUDE_PATH.'/../model/' . $class . '.php';
|
||||
|
||||
if(is_file($PATH)) {
|
||||
require_once($PATH);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
spl_autoload_register('postfixadmin_autoload2');
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Convenience method for strtolower().
|
||||
*
|
||||
* @param string $str String to lowercase
|
||||
* @return string Lowercased string
|
||||
*/
|
||||
function low($str) {
|
||||
return strtolower($str);
|
||||
}
|
||||
/**
|
||||
* Convenience method for strtoupper().
|
||||
*
|
||||
* @param string $str String to uppercase
|
||||
* @return string Uppercased string
|
||||
*/
|
||||
function up($str) {
|
||||
return strtoupper($str);
|
||||
}
|
||||
/**
|
||||
* Convenience method for str_replace().
|
||||
*
|
||||
* @param string $search String to be replaced
|
||||
* @param string $replace String to insert
|
||||
* @param string $subject String to search
|
||||
* @return string Replaced string
|
||||
*/
|
||||
function r($search, $replace, $subject) {
|
||||
return str_replace($search, $replace, $subject);
|
||||
}
|
||||
/**
|
||||
* Print_r convenience function, which prints out <PRE> tags around
|
||||
* the output of given array. Similar to debug().
|
||||
*
|
||||
* @see debug()
|
||||
* @param array $var Variable to print out
|
||||
* @param boolean $showFrom If set to true, the method prints from where the function was called
|
||||
*/
|
||||
function pr($var) {
|
||||
if (Configure::read() > 0) {
|
||||
echo "<pre>";
|
||||
print_r($var);
|
||||
echo "</pre>";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */
|
@ -213,10 +213,8 @@ class PostfixAdmin {
|
||||
}
|
||||
$includes = array(
|
||||
PATH.'/config.inc.php',
|
||||
PATH.'/languages/language.php',
|
||||
PATH.'/functions.inc.php',
|
||||
PATH.'/languages/en.lang', # TODO: honor $CONF[default_language] and/or language from $_ENV
|
||||
CORE_INCLUDE_PATH.'/common.php',
|
||||
PATH.'/common.php',
|
||||
CORE_INCLUDE_PATH.'/inflector.php',
|
||||
);
|
||||
|
||||
@ -226,16 +224,11 @@ class PostfixAdmin {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Config::getInstance();
|
||||
Config::write($CONF);
|
||||
|
||||
Lang::getInstance();
|
||||
|
||||
if($CONF['language_hook'] != '' && function_exists($CONF['language_hook'])) {
|
||||
$hook_func = $CONF['language_hook'];
|
||||
$PALANG = $hook_func ($PALANG, 'en'); # $includes is also hardcoded to 'en' - see TODO above
|
||||
}
|
||||
|
||||
Lang::write($PALANG);
|
||||
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user