PostfixAdmin - web based virtual user administration interface for Postfix mail servers https://postfixadmin.github.io/postfixadmin/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

77 lines
2.3 KiB

  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 :
  10. * http://www.postfixadmin.com or http://postfixadmin.sf.net
  11. *
  12. * @version $Id$
  13. * @license GNU GPL v2 or later.
  14. *
  15. * File: common.php
  16. * All pages should include this file - which itself sets up the necessary
  17. * environment and ensures other functions are loaded.
  18. */
  19. if(!defined('POSTFIXADMIN')) {
  20. session_start();
  21. }
  22. define('POSTFIXADMIN', 1); # checked in included files
  23. function incorrect_setup() {
  24. global $incpath;
  25. # we ask the user to delete setup.php, which makes a blind redirect a bad idea
  26. if(!is_file("$incpath/setup.php")) {
  27. die ("config.inc.php does not exist or is not configured correctly. Please re-install setup.php and create/fix your config.");
  28. } else {
  29. # common.php is indirectly included in setup.php (via upgrade.php) - avoid endless redirect loop
  30. if (!preg_match('/setup\.php$/', $_SERVER['SCRIPT_NAME'])) {
  31. header("Location: setup.php");
  32. exit(0);
  33. }
  34. }
  35. }
  36. $incpath = dirname(__FILE__);
  37. (ini_get('magic_quotes_gpc') ? ini_set('magic_quotes_runtime', '0') : '1');
  38. (ini_get('magic_quotes_gpc') ? ini_set('magic_quotes_sybase', '0') : '1');
  39. if(ini_get('register_globals')) {
  40. die("Please turn off register_globals; edit your php.ini");
  41. }
  42. require_once("$incpath/variables.inc.php");
  43. if(!is_file("$incpath/config.inc.php")) {
  44. // incorrectly setup...
  45. incorrect_setup();
  46. }
  47. require_once("$incpath/config.inc.php");
  48. if(isset($CONF['configured'])) {
  49. if($CONF['configured'] == FALSE) {
  50. incorrect_setup();
  51. }
  52. }
  53. require_once("$incpath/languages/language.php");
  54. require_once("$incpath/functions.inc.php");
  55. require_once("$incpath/languages/" . check_language () . ".lang");
  56. /**
  57. * @param string $class
  58. * __autoload implementation, for use with spl_autoload_register().
  59. */
  60. function postfixadmin_autoload($class) {
  61. $PATH = dirname(__FILE__) . '/model/' . $class . '.php';
  62. if(is_file($PATH)) {
  63. require_once($PATH);
  64. return true;
  65. }
  66. return false;
  67. }
  68. spl_autoload_register('postfixadmin_autoload');
  69. /* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */