660176e1e031017dbbab50ae4068bdb689f763a5
[platal.git] / include / platal / globals.inc.php.in
1 <?php
2 /***************************************************************************
3 * Copyright (C) 2003-2006 Polytechnique.org *
4 * http://opensource.polytechnique.org/ *
5 * *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the Free Software *
18 * Foundation, Inc., *
19 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 ***************************************************************************/
21
22 class CoreConfig
23 {
24 var $locale = 'fr_FR';
25 }
26
27 class PlatalGlobals
28 {
29 var $page = 'XorgPage';
30 var $session;
31 var $menu;
32 var $hook;
33
34 /** The x.org version */
35 var $version = '@VERSION@';
36 var $debug = 0;
37
38 /** db params */
39 var $dbdb = 'x4dat';
40 var $dbhost = 'localhost';
41 var $dbuser = 'x4dat';
42 var $dbpwd = 'x4dat';
43
44 var $table_log_actions = 'logger.actions';
45 var $table_log_sessions = 'logger.sessions';
46 var $table_log_events = 'logger.events';
47
48 /** The class to use for session handling. */
49 var $session = 'DiogenesCoreSession';
50
51 /** logger */
52 var $tauth = array('native'=>'auth_user_md5');
53 var $tlabel = array('native'=>'X.Org');
54
55 /** paths */
56 var $baseurl;
57 var $spoolroot;
58
59 function PlatalGlobals($sess)
60 {
61 $this->session = $sess;
62
63 $base = empty($_SERVER['HTTPS']) ? 'http://' : 'https://';
64 $this->baseurl = trim($base.$_SERVER['SERVER_NAME'].dirname($_SERVER['PHP_SELF']), '/');
65 $this->spoolroot = dirname(dirname(dirname(__FILE__)));
66 }
67
68 function dbconnect()
69 {
70 @mysql_connect($this->dbhost, $this->dbuser, $this->dbpwd);
71 @mysql_select_db($this->dbdb);
72 }
73
74 function read_config()
75 {
76 $array = parse_ini_file($this->spoolroot.'/configs/platal.ini', true);
77 foreach ($array as $cat => $conf) {
78 $c = strtolower($cat);
79 foreach ($conf as $k => $v) {
80 $this->$c->$k = $v;
81 }
82 }
83
84 $array = parse_ini_file($this->spoolroot.'/configs/platal.conf', true);
85 if (!is_array($array)) {
86 return;
87 }
88
89 foreach ($array as $cat=>$conf) {
90 $c = strtolower($cat);
91 foreach ($conf as $key=>$val) {
92 if ($c == 'core' && isset($this->$key)) {
93 $this->$key=$val;
94 } else {
95 $this->$c->$key = $val;
96 }
97 }
98 }
99 }
100
101 function setlocale()
102 {
103 global $globals;
104 setlocale(LC_MESSAGES, $globals->core->locale);
105 setlocale(LC_TIME, $globals->core->locale);
106 setlocale(LC_CTYPE, $globals->core->locale);
107 }
108 }
109
110 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker:
111 ?>