Commit | Line | Data |
---|---|---|
0337d704 | 1 | <?php |
2 | /*************************************************************************** | |
5e1513f6 | 3 | * Copyright (C) 2003-2011 Polytechnique.org * |
0337d704 | 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 | ||
4a28e567 | 22 | class PlatalGlobals extends PlGlobals |
0337d704 | 23 | { |
5b98acfa FB |
24 | const DEBUG_NOCACHE = DEBUG_USERBASE; |
25 | ||
0337d704 | 26 | /** The x.org version */ |
612a2d8a | 27 | public $version = '@VERSION@'; |
0337d704 | 28 | |
29 | /** db params */ | |
900f65fb | 30 | public $dbdb = null; |
00112b2e | 31 | public $dbprefix = ''; |
612a2d8a | 32 | public $dbhost = 'localhost'; |
900f65fb FB |
33 | public $dbuser = null; |
34 | public $dbpwd = null; | |
612a2d8a | 35 | public $dbcharset = 'utf8'; |
72542de0 | 36 | |
25962601 | 37 | /** default skin */ |
38 | public $skin; | |
39 | public $register_skin; | |
40 | ||
47fa97fe | 41 | public function __construct() |
0337d704 | 42 | { |
4a28e567 | 43 | parent::__construct(array('platal.ini', 'platal.conf')); |
6cd1e622 FB |
44 | if (isset($GLOBALS['IS_XNET_SITE'])) { |
45 | $this->core->sitename = 'Polytechnique.net'; | |
46 | } | |
14a76559 FB |
47 | } |
48 | ||
49 | public function init() | |
50 | { | |
ebfdf077 FB |
51 | $this->bootstrap(array('NbIns'), array($this, 'updateNbIns')); |
52 | $this->bootstrap(array('NbValid'), array($this, 'updateNbValid')); | |
0337d704 | 53 | } |
ea6398d1 | 54 | |
34ade5a6 | 55 | public function asso($key = null) |
ea6398d1 | 56 | { |
edcea678 | 57 | static $fetched = false; |
ea6398d1 | 58 | static $aid = null; |
59 | ||
edcea678 | 60 | if (isset($GLOBALS['IS_XNET_SITE']) && !$fetched) { |
ea6398d1 | 61 | $gp = Get::v('n'); |
27ae65e3 | 62 | if ($p = strpos($gp, '/')) { |
63 | $gp = substr($gp, 0, $p); | |
64 | } | |
ea6398d1 | 65 | |
34ade5a6 | 66 | $aid = Group::get($gp); |
edcea678 | 67 | $fetched = true; |
ea6398d1 | 68 | } |
69 | if (empty($key)) { | |
70 | return $aid; | |
34ade5a6 FB |
71 | } elseif (isset($aid->$key) ) { |
72 | return $aid->$key; | |
ea6398d1 | 73 | } else { |
74 | return null; | |
75 | } | |
76 | } | |
ebfdf077 | 77 | |
ebfdf077 FB |
78 | public function updateNbIns() |
79 | { | |
80 | $res = XDB::query("SELECT COUNT(*) | |
6d1e6661 FB |
81 | FROM accounts |
82 | WHERE state = 'active'"); | |
ebfdf077 FB |
83 | $cnt = $res->fetchOneCell(); |
84 | $this->changeDynamicConfig(array('NbIns' => $cnt)); | |
85 | } | |
86 | ||
87 | public function updateNbValid() | |
88 | { | |
89 | $res = XDB::query("SELECT COUNT(*) | |
90 | FROM requests"); | |
91 | $this->changeDynamicConfig(array('NbValid' => $res->fetchOneCell())); | |
92 | } | |
0337d704 | 93 | |
5b98acfa FB |
94 | public function cacheEnabled() |
95 | { | |
96 | return ($this->debug & self::DEBUG_NOCACHE) == 0; | |
97 | } | |
98 | } | |
ebfdf077 FB |
99 | |
100 | /****************************************************************************** | |
101 | * Dynamic configuration update/edition stuff | |
102 | *****************************************************************************/ | |
103 | ||
a7de4ef7 | 104 | // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: |
0337d704 | 105 | ?> |