Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

common.php 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <?php
  2. /**
  3. * Postfix Admin
  4. *
  5. * LICENSE
  6. * This source file is subject to the GPL license that is bundled with
  7. * this package in the file LICENSE.TXT.
  8. *
  9. * Further details on the project are available at http://postfixadmin.sf.net
  10. *
  11. * @version $Id: common.php 1846 2016-05-22 16:57:09Z christian_boltz $
  12. * @license GNU GPL v2 or later.
  13. *
  14. * File: common.php
  15. * All pages should include this file - which itself sets up the necessary
  16. * environment and ensures other functions are loaded.
  17. */
  18. if(!defined('POSTFIXADMIN')) { # already defined if called from setup.php
  19. define('POSTFIXADMIN', 1); # checked in included files
  20. if (!defined('POSTFIXADMIN_CLI')) {
  21. // this is the default; see also https://sourceforge.net/p/postfixadmin/bugs/347/
  22. session_cache_limiter('nocache');
  23. session_name('postfixadmin_session');
  24. session_start();
  25. if (defined('POSTFIXADMIN_LOGOUT')) {
  26. session_unset();
  27. session_destroy();
  28. session_start();
  29. }
  30. if(empty($_SESSION['flash'])) {
  31. $_SESSION['flash'] = array();
  32. }
  33. }
  34. }
  35. $incpath = dirname(__FILE__);
  36. (ini_get('magic_quotes_gpc') ? ini_set('magic_quotes_runtime', '0') : '1');
  37. (ini_get('magic_quotes_gpc') ? ini_set('magic_quotes_sybase', '0') : '1');
  38. if(ini_get('register_globals') == 'on') {
  39. die("Please turn off register_globals; edit your php.ini");
  40. }
  41. /**
  42. * @param string $class
  43. * __autoload implementation, for use with spl_autoload_register().
  44. */
  45. function postfixadmin_autoload($class) {
  46. $PATH = dirname(__FILE__) . '/model/' . $class . '.php';
  47. if(is_file($PATH)) {
  48. require_once($PATH);
  49. return true;
  50. }
  51. return false;
  52. }
  53. spl_autoload_register('postfixadmin_autoload');
  54. require_once("$incpath/variables.inc.php");
  55. if(!is_file("$incpath/config.inc.php")) {
  56. die("config.inc.php is missing!");
  57. }
  58. require_once("$incpath/config.inc.php");
  59. if(isset($CONF['configured'])) {
  60. if($CONF['configured'] == FALSE) {
  61. die("Please edit config.inc.php - change \$CONF['configured'] to true after setting your database settings");
  62. }
  63. }
  64. Config::write($CONF);
  65. require_once("$incpath/languages/language.php");
  66. require_once("$incpath/functions.inc.php");
  67. if (defined('POSTFIXADMIN_CLI')) {
  68. $language = 'en'; # TODO: make configurable or autodetect from locale settings
  69. } else {
  70. $language = check_language (); # TODO: storing the language only at login instead of calling check_language() on every page would save some processor cycles ;-)
  71. $_SESSION['lang'] = $language;
  72. }
  73. require_once("$incpath/languages/" . $language . ".lang");
  74. if(!empty($CONF['language_hook']) && function_exists($CONF['language_hook'])) {
  75. $hook_func = $CONF['language_hook'];
  76. $PALANG = $hook_func ($PALANG, $language);
  77. }
  78. Config::write('__LANG', $PALANG);
  79. if (!defined('POSTFIXADMIN_CLI')) {
  80. if(!is_file("$incpath/smarty.inc.php")) {
  81. die("smarty.inc.php is missing! Something is wrong...");
  82. }
  83. require_once ("$incpath/smarty.inc.php");
  84. }
  85. /* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */
  86. ?>