| 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 | /* Toutes les pages du bureau passent ici. On utilise une sémaphore pour |
|---|
| 32 | s'assurer que personne ne pourra accéder à 2 pages du bureau en même temps. |
|---|
| 33 | */ |
|---|
| 34 | |
|---|
| 35 | /* |
|---|
| 36 | Si vous voulez mettre le bureau en maintenance, décommentez le code ci-dessous |
|---|
| 37 | et mettez votre ip dans le IF pour que seule votre ip puisse accéder au bureau : |
|---|
| 38 | */ |
|---|
| 39 | |
|---|
| 40 | /* |
|---|
| 41 | if (getenv("REMOTE_ADDR")!="81.56.98.108") { |
|---|
| 42 | echo "Le bureau AlternC est en vacances jusqu'a minuit pour maintenance.<br> |
|---|
| 43 | Merci de revenir plus tard."; |
|---|
| 44 | exit(); |
|---|
| 45 | } |
|---|
| 46 | */ |
|---|
| 47 | |
|---|
| 48 | // 1. Get a semaphore id for the alternc magic number (18577) |
|---|
| 49 | $alternc_sem = sem_get ( 18577 ); |
|---|
| 50 | // 2. Declare the shutdown function, that release the semaphore |
|---|
| 51 | function alternc_shutdown() { |
|---|
| 52 | global $alternc_sem; |
|---|
| 53 | @sem_release( $alternc_sem ); |
|---|
| 54 | } |
|---|
| 55 | // 3. Register the shutdown function |
|---|
| 56 | register_shutdown_function("alternc_shutdown"); |
|---|
| 57 | // 4. Acquire the semaphore : with that process, |
|---|
| 58 | sem_acquire( $alternc_sem ); |
|---|
| 59 | |
|---|
| 60 | if (ini_get("safe_mode")) { |
|---|
| 61 | echo "SAFE MODE IS ENABLED for the web panel ! It's a bug in your php or apache configuration, please fix it !!"; |
|---|
| 62 | exit(); |
|---|
| 63 | } |
|---|
| 64 | |
|---|
| 65 | // For people who want to authenticate with HTTP AUTH |
|---|
| 66 | if (isset($_GET['http_auth'])) $http_auth=strval($_GET['http_auth']); |
|---|
| 67 | if (isset($http_auth) && $http_auth) { |
|---|
| 68 | if (empty($_SERVER['PHP_AUTH_USER']) || empty($_SERVER['PHP_AUTH_PW'])) { |
|---|
| 69 | header('WWW-Authenticate: Basic realm="Test Authentication System"'); |
|---|
| 70 | header('HTTP/1.0 401 Unauthorized'); |
|---|
| 71 | exit(); |
|---|
| 72 | } |
|---|
| 73 | } |
|---|
| 74 | if (!empty($_SERVER['PHP_AUTH_USER']) && !empty($_SERVER['PHP_AUTH_PW'])) { |
|---|
| 75 | // Gruiiik |
|---|
| 76 | $_REQUEST["username"]=$_SERVER['PHP_AUTH_USER']; |
|---|
| 77 | $_REQUEST["password"]=$_SERVER['PHP_AUTH_PW']; |
|---|
| 78 | } |
|---|
| 79 | |
|---|
| 80 | |
|---|
| 81 | $help_baseurl="http://www.aide-alternc.org/"; |
|---|
| 82 | |
|---|
| 83 | /* PHPLIB inclusions : */ |
|---|
| 84 | $root="/var/alternc/bureau/"; |
|---|
| 85 | /* Server Domain Name */ |
|---|
| 86 | $host=getenv("HTTP_HOST"); |
|---|
| 87 | |
|---|
| 88 | /* Global variables (AlternC configuration) */ |
|---|
| 89 | require_once($root."class/local.php"); |
|---|
| 90 | |
|---|
| 91 | require_once($root."class/db_mysql.php"); |
|---|
| 92 | require_once($root."class/functions.php"); |
|---|
| 93 | require_once($root."class/variables.php"); |
|---|
| 94 | |
|---|
| 95 | // Redirection si appel à https://(!fqdn)/ |
|---|
| 96 | if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"]=="on" && $host!=$L_FQDN) { |
|---|
| 97 | header("Location: https://$L_FQDN/"); |
|---|
| 98 | } |
|---|
| 99 | |
|---|
| 100 | |
|---|
| 101 | // Classe héritée de la classe db de la phplib. |
|---|
| 102 | /** |
|---|
| 103 | * Class for MySQL management in the bureau |
|---|
| 104 | * |
|---|
| 105 | * This class heriting from the db class of the phplib manages |
|---|
| 106 | * the connection to the MySQL database. |
|---|
| 107 | */ |
|---|
| 108 | |
|---|
| 109 | class DB_system extends DB_Sql { |
|---|
| 110 | var $Host,$Database,$User,$Password; |
|---|
| 111 | |
|---|
| 112 | /** |
|---|
| 113 | * Creator |
|---|
| 114 | */ |
|---|
| 115 | function DB_system() { |
|---|
| 116 | global $L_MYSQL_HOST,$L_MYSQL_DATABASE,$L_MYSQL_LOGIN,$L_MYSQL_PWD; |
|---|
| 117 | $this->Host = $L_MYSQL_HOST; |
|---|
| 118 | $this->Database = $L_MYSQL_DATABASE; |
|---|
| 119 | $this->User = $L_MYSQL_LOGIN; |
|---|
| 120 | $this->Password = $L_MYSQL_PWD; |
|---|
| 121 | } |
|---|
| 122 | } |
|---|
| 123 | |
|---|
| 124 | $db= new DB_system(); |
|---|
| 125 | |
|---|
| 126 | // Current User ID = the user whose commands are made on behalf of. |
|---|
| 127 | $cuid=0; |
|---|
| 128 | |
|---|
| 129 | |
|---|
| 130 | $classes=array(); |
|---|
| 131 | /* CLASSES PHP : automatic include : */ |
|---|
| 132 | $c=opendir($root."class/"); |
|---|
| 133 | while ($di=readdir($c)) { |
|---|
| 134 | if (ereg("^m_(.*)\\.php$",$di,$match)) { // $ |
|---|
| 135 | $name1="m_".$match[1]; |
|---|
| 136 | $name2=$match[1]; |
|---|
| 137 | $classes[]=$name2; |
|---|
| 138 | require_once($root."class/".$name1.".php"); |
|---|
| 139 | } |
|---|
| 140 | } |
|---|
| 141 | closedir($c); |
|---|
| 142 | /* THE DEFAULT CLASSES ARE : |
|---|
| 143 | dom, ftp, mail, quota, bro, admin, mem, mysql, err |
|---|
| 144 | */ |
|---|
| 145 | |
|---|
| 146 | |
|---|
| 147 | /* Language */ |
|---|
| 148 | include_once("lang_env.php"); |
|---|
| 149 | |
|---|
| 150 | $mem=new m_mem(); |
|---|
| 151 | $err=new m_err(); |
|---|
| 152 | |
|---|
| 153 | /* Check the User identity (if required) */ |
|---|
| 154 | if (!defined('NOCHECK')) { |
|---|
| 155 | if (!$mem->checkid()) { |
|---|
| 156 | $error=$err->errstr(); |
|---|
| 157 | include("index.php"); |
|---|
| 158 | exit(); |
|---|
| 159 | } |
|---|
| 160 | } |
|---|
| 161 | |
|---|
| 162 | for($i=0;$i<count($classes);$i++) { |
|---|
| 163 | if ($classes[$i]!="mem" && $classes[$i]!="err") { |
|---|
| 164 | $name2=$classes[$i]; |
|---|
| 165 | $name1="m_".$name2; |
|---|
| 166 | $$name2= new $name1(); |
|---|
| 167 | } |
|---|
| 168 | } |
|---|
| 169 | |
|---|
| 170 | ?> |
|---|