source: trunk/bureau/class/config.php @ 1025

Revision 1025, 4.4 KB checked in by benjamin, 7 years ago (diff)

force https parameter, Closes #71

Line 
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/* // Uncomment the following lines and put your IP between the "" to put the dekstop in maintenance mode :
41if (getenv("REMOTE_ADDR")!="81.56.98.108") {
42  echo "Le bureau AlternC est en vacances jusqu'a minuit pour maintenance.<br>
43Merci de revenir plus tard.";
44  exit();
45}
46*/
47
48
49
50// 1. Get a semaphore id for the alternc magic number (18577)
51$alternc_sem = sem_get ( 18577 );
52// 2. Declare the shutdown function, that release the semaphore
53function alternc_shutdown() {
54  global $alternc_sem;
55  @sem_release( $alternc_sem );
56}
57// 3. Register the shutdown function
58register_shutdown_function("alternc_shutdown");
59// 4. Acquire the semaphore : with that process,
60sem_acquire( $alternc_sem );
61
62if (!get_magic_quotes_gpc()) {
63  echo "MAGIC QUOTES GPC IS DISABLED ! It's a bug in your php4 configuration, please fix it !!";
64  exit();
65}
66
67
68
69/* PHPLIB inclusions : */
70$root="/var/alternc/bureau/";
71/* Server Domain Name */
72$host=getenv("HTTP_HOST");
73
74/* Global variables (AlternC configuration) */
75require_once($root."class/local.php");
76
77require_once($root."class/db_mysql.php");
78require_once($root."class/functions.php");
79require_once($root."class/variables.php");
80
81if (!$_SERVER["HTTPS"]) {
82  $conf=variable_init();
83  if ($conf["force_https"]) {
84    header("Location: https://".$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"]);
85  }
86}
87
88// Classe héritée de la classe db de la phplib.
89/**
90* Class for MySQL management in the bureau
91*
92* This class heriting from the db class of the phplib manages
93* the connection to the MySQL database.
94*/
95
96class DB_system extends DB_Sql {
97  var $Host,$Database,$User,$Password;
98
99  /**
100  * Creator
101  */
102  function DB_system() {
103    global $L_MYSQL_HOST,$L_MYSQL_DATABASE,$L_MYSQL_LOGIN,$L_MYSQL_PWD;
104    $this->Host     = $L_MYSQL_HOST;
105    $this->Database = $L_MYSQL_DATABASE;
106    $this->User     = $L_MYSQL_LOGIN;
107    $this->Password = $L_MYSQL_PWD;
108  }
109}
110
111$db= new DB_system();
112
113// Current User ID = the user whose commands are made on behalf of.
114$cuid=0;
115
116$classes=array();
117/* CLASSES PHP4 : automatic include : */
118$c=opendir($root."class/");
119while ($di=readdir($c)) {
120  if (ereg("^m_(.*)\\.php$",$di,$match)) { // $
121    $name1="m_".$match[1];
122    $name2=$match[1];
123    $classes[]=$name2;
124    require_once($root."class/".$name1.".php");
125  }
126}
127closedir($c);
128/* THE DEFAULT CLASSES ARE :
129   dom, ftp, mail, quota, bro, admin, mem, mysql, err
130*/
131
132
133/* Language */
134bindtextdomain("alternc", "/var/alternc/bureau/locales");
135
136if (!$do_not_set_lang_env) {
137  include("lang_env.php");
138}
139
140$mem=new m_mem();
141$err=new m_err();
142
143/* Check the User identity (if required) */
144if (!defined('NOCHECK')) {
145  if (!$mem->checkid()) {
146    $error=$err->errstr();
147    include("index.php");
148    exit();
149  }
150} 
151
152for($i=0;$i<count($classes);$i++) {
153  if ($classes[$i]!="mem" && $classes[$i]!="err") {
154    $name2=$classes[$i];
155    $name1="m_".$name2;
156    $$name2= new $name1();
157  }
158}
159
160?>
Note: See TracBrowser for help on using the repository browser.