Alternc  3.2
Alternc logiel libre pour l'hébergement
 All Data Structures Namespaces Files Functions Variables Pages
config.php
Go to the documentation of this file.
1 <?php
2 /*
3  $Id: config.php,v 1.12 2005/12/18 09:51:32 benjamin Exp $
4  ----------------------------------------------------------------------
5  AlternC - Web Hosting System
6  Copyright (C) 2002 by the AlternC Development Team.
7  http://alternc.org/
8  ----------------------------------------------------------------------
9  Based on:
10  Valentin Lacambre's web hosting softwares: http://altern.org/
11  ----------------------------------------------------------------------
12  LICENSE
13 
14  This program is free software; you can redistribute it and/or
15  modify it under the terms of the GNU General Public License (GPL)
16  as published by the Free Software Foundation; either version 2
17  of the License, or (at your option) any later version.
18 
19  This program is distributed in the hope that it will be useful,
20  but WITHOUT ANY WARRANTY; without even the implied warranty of
21  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  GNU General Public License for more details.
23 
24  To read the license please visit http://www.gnu.org/copyleft/gpl.html
25  ----------------------------------------------------------------------
26  Original Author of file: Benjamin Sonntag
27  Purpose of file: General configuration file for AlternC Desktop
28  ----------------------------------------------------------------------
29 */
30 
31 define('DO_XHPROF_STATS', FALSE);
32 if (DO_XHPROF_STATS) require_once('/usr/share/alternc/panel/admin/xhprof_header.php');
33 
34 // To enable the display of the alternc debug error, do the following :
35 // # touch /etc/alternc/alternc_display_php_error
36 if (file_exists('/etc/alternc/alternc_display_php_error')) {
37  ini_set('display_errors', true);
38 }
39 session_name('AlternC_Panel');
40 session_start();
41 
42 /*
43  Si vous voulez mettre le bureau en maintenance, décommentez le code ci-dessous
44  et mettez votre ip dans le IF pour que seule votre ip puisse accéder au bureau :
45 */
46 
47 /* * /
48 if (getenv("REMOTE_ADDR")!="127.0.0.1") {
49  echo "Le bureau AlternC est en vacances jusqu'a minuit pour maintenance.<br>
50 Merci de revenir plus tard.";
51  exit();
52 }
53 /* */
54 
55 /* Toutes les pages du bureau passent ici. On utilise une sémaphore pour
56  s'assurer que personne ne pourra accéder à 2 pages du bureau en même temps.
57 */
58 /* * /
59 // 1. Get a semaphore id for the alternc magic number (18577)
60 $alternc_sem = sem_get ( 18577 );
61 // 2. Declare the shutdown function, that release the semaphore
62 function alternc_shutdown() {
63  global $alternc_sem;
64  @sem_release( $alternc_sem );
65 }
66 // 3. Register the shutdown function
67 register_shutdown_function("alternc_shutdown");
68 // 4. Acquire the semaphore : with that process,
69 sem_acquire( $alternc_sem );
70 /* */
71 
72 if (ini_get("safe_mode")) {
73  echo "SAFE MODE IS ENABLED for the web panel ! It's a bug in your php or apache configuration, please fix it !!";
74  exit();
75 }
76 
77 // For people who want to authenticate with HTTP AUTH
78 if (isset($_GET['http_auth'])) $http_auth=strval($_GET['http_auth']);
79 if (isset($http_auth) && $http_auth) {
80  if (empty($_SERVER['PHP_AUTH_USER']) || empty($_SERVER['PHP_AUTH_PW'])) {
81  header('WWW-Authenticate: Basic realm="Test Authentication System"');
82  header('HTTP/1.0 401 Unauthorized');
83  exit();
84  }
85 }
86 if (!empty($_SERVER['PHP_AUTH_USER']) && !empty($_SERVER['PHP_AUTH_PW'])) {
87  // Gruiiik
88  $_REQUEST["username"]=$_SERVER['PHP_AUTH_USER'];
89  $_REQUEST["password"]=$_SERVER['PHP_AUTH_PW'];
90  }
91 
92 
93 $help_baseurl="http://www.aide-alternc.org/";
94 
95 /* Server Domain Name */
96 $host=getenv("HTTP_HOST");
97 
98 /* Global variables (AlternC configuration) */
99 require_once(dirname(__FILE__)."/local.php");
100 
101 // Define constants from vars of /etc/alternc/local.sh
102 // The you can't choose where is the AlternC Panel
103 define('ALTERNC_MAIL', "$L_ALTERNC_MAIL");
104 define('ALTERNC_HTML', "$L_ALTERNC_HTML");
106  define('ALTERNC_LOGS_ARCHIVE', "$L_ALTERNC_LOGS_ARCHIVE");
107 define('ALTERNC_LOGS', "$L_ALTERNC_LOGS");
108 define('ALTERNC_PANEL', "/usr/share/alternc/panel");
109 define('ALTERNC_LOCALES', ALTERNC_PANEL."/locales");
110 define('ALTERNC_LOCK_JOBS', '/var/run/alternc/jobs-lock');
111 define('ALTERNC_LOCK_PANEL', '/var/lib/alternc/panel/nologin.lock');
112 define('ALTERNC_APACHE2_GEN_TMPL_DIR', '/etc/alternc/templates/apache2/');
113 define('ALTERNC_VHOST_DIR',"/var/lib/alternc/apache-vhost/");
114 define('ALTERNC_VHOST_FILE',ALTERNC_VHOST_DIR."vhosts_all.conf");
115 define('ALTERNC_VHOST_MANUALCONF',ALTERNC_VHOST_DIR."manual/");
116 
117 
118 /* PHPLIB inclusions : */
120 
121 require_once($root."/class/db_mysql.php");
122 require_once($root."/class/functions.php");
123 
124 // Redirection si appel à https://(!fqdn)/
125 if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"]=="on" && $host!=$L_FQDN) {
126  header("Location: https://$L_FQDN/");
127 }
128 
129 
130 // Classe héritée de la classe db de la phplib.
131 /**
132 * Class for MySQL management in the bureau
133 *
134 * This class heriting from the db class of the phplib manages
135 * the connection to the MySQL database.
136 */
137 
138 class DB_system extends DB_Sql {
140 
141  /**
142  * Creator
143  */
144  function DB_system() {
145  global $L_MYSQL_HOST,$L_MYSQL_DATABASE,$L_MYSQL_LOGIN,$L_MYSQL_PWD;
146  $this->Host = $L_MYSQL_HOST;
147  $this->Database = $L_MYSQL_DATABASE;
148  $this->User = $L_MYSQL_LOGIN;
149  $this->Password = $L_MYSQL_PWD;
150  }
151 }
152 
153 $db= new DB_system();
154 
155 // Current User ID = the user whose commands are made on behalf of.
157 
158 
159 $classes=array();
160 /* CLASSES PHP : automatic include : */
161 foreach ( glob( $root."class/m_*.php") as $di ) {
162  if (preg_match("#${root}class/m_(.*)\\.php$#",$di,$match)) { // $
163  $classes[]=$match[1];
164  require_once($di);
165  }
166 }
167 /* THE DEFAULT CLASSES ARE :
168  dom, ftp, mail, quota, bro, admin, mem, mysql, err, variables
169 */
170 
171 // Load file for the system class.
172 // Those class will not be build by default.
173 // They may contain forbidden action for the panel, for example: exec, system
174 // or files operations
175 // We can imagine load those class only for command-line scripts.
176 foreach ( glob( $root."class/class_system_*.php") as $fcs ) {
177  if (is_readable($fcs)) require_once($fcs);
178 }
179 
180 /* Language */
181 include_once("lang_env.php");
182 
184 $mem=new m_mem();
185 $err=new m_err();
188 
189 /* Check the User identity (if required) */
190 if (!defined('NOCHECK')) {
191  if (!$mem->checkid()) {
192  $error=$err->errstr();
193  include("index.php");
194  exit();
195  }
196 }
197 
198 for($i=0;$i<count($classes);$i++) {
199  $name2=$classes[$i];
200  if (isset($$name2)) continue; // for already instancied class like mem, err or authip
201  $name1="m_".$name2;
202  $$name2= new $name1();
203 }
204 
205 $oldid=intval(isset($_COOKIE['oldid'])?$_COOKIE['oldid']:'');
207 if ($admin->enabled) $isinvited=true;
208 
209 if ($oldid && $oldid!=$cuid) {
210  $isinvited=true;
211 }
212 
213 ?>