Move some functions that were previously declared in admin/global.php to a new includ...
[bugdar.git] / admin / global.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Bugdar
5 || # Copyright (c)2004-2009 Blue Static
6 || #
7 || # This program is free software; you can redistribute it and/or modify
8 || # it under the terms of the GNU General Public License as published by
9 || # the Free Software Foundation; version 2 of the License.
10 || #
11 || # This program is distributed in the hope that it will be useful, but
12 || # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 || # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 || # more details.
15 || #
16 || # You should have received a copy of the GNU General Public License along
17 || # with this program; if not, write to the Free Software Foundation, Inc.,
18 || # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 || ###################################################################
20 \*=====================================================================*/
21
22 chdir('./../');
23
24 require_once('./includes/init.php');
25 require_once('./includes/functions.php');
26 require_once('./includes/functions_admin.php');
27
28 // ###################################################################
29 // setup admin templates
30
31 require_once ISSO . '/DecoratorHelpers.php';
32
33 require_once ISSO . '/Template.php';
34 BSTemplate::$dbCacheTable = TABLE_PREFIX . 'template';
35 BSTemplate::$templatePath = 'admin/templates/%s.html';
36
37 $globaltemplates = array(
38 'doctype',
39 'nav',
40 'headinclude',
41 'footer',
42 );
43
44 $start = microtime();
45 BSTemplate::cache(array_merge($globaltemplates, (array)$fetchtemplates));
46 BSApp::debug('time for tpl cache: ' . BSFunctions::fetch_microtime_diff($start));
47
48 BSTemplate::$globalVars = array(
49 'templates' => array(
50 'doctype' => BSTemplate::fetch('doctype')->evaluate()->getTemplate(),
51 'nav' => BSTemplate::fetch('nav')->evaluate()->getTemplate(),
52 'headinclude' => BSTemplate::fetch('headinclude')->evaluate()->getTemplate(),
53 'title' => T('Bugdar Administration')
54 )
55 );
56
57 // ###################################################################
58
59 if (can_perform('canadminpanel'))
60 {
61 $session = $db->queryFirst("SELECT * FROM " . TABLE_PREFIX . "adminsession WHERE sessionid = '" . $input->inputEscape(COOKIE_PREFIX . 'adminsession') . "'");
62 if ($session AND $session['userid'] == bugdar::$userinfo['userid'] AND $session['dateline'] >= (TIMENOW - 3600))
63 {
64 // renew the cookie
65 BSFunctions::cookie(COOKIE_PREFIX . 'adminsession', $session['sessionid'], false);
66 }
67 else
68 {
69 BSFunctions::cookie(COOKIE_PREFIX . 'adminsession', false);
70 admin_login();
71 }
72 }
73 else
74 {
75 BSFunctions::cookie(COOKIE_PREFIX . 'adminsession', false);
76 admin_login();
77 }
78
79 ?>