PreCache templates for performance.
[bugdar.git] / admin / home.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Bugdar
5 || # Copyright (c)2002-2013 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 namespace bugdar\admin;
23
24 use \bugdar;
25 use \hoplite\http;
26
27 require_once HOPLITE_ROOT . '/http/action.php';
28
29 class HomeAction extends http\Action implements TemplatePreCaching
30 {
31 public function TemplateSet()
32 {
33 return array('admin_index');
34 }
35
36 public function Invoke(http\Request $request, http\Response $response)
37 {
38 $response->data['title'] = T('Home');
39
40 $response->data['new_version_number'] = $this->_DoVersionCheck();
41 $response->data['current_version'] = Bugdar::$options['trackerversion'];
42
43 $response->context['template'] = 'admin_index';
44 }
45
46 // Contacts Blue Static to see if Bugdar is up-to-date. Returns NULL if the
47 // current version is the latest, or a string version number of the latest
48 // version.
49 private function _DoVersionCheck()
50 {
51 global $bugsys;
52
53 if (defined('NO_VERSION_CHECK') && constant('NO_VERSION_CHECK'))
54 return;
55
56 $check = @file_get_contents('https://www.bluestatic.org/versioncheck.php?prod=bugdar&ver=' . str_replace(' ', '-', Bugdar::$options['trackerversion']));
57 if (strpos($check, '<version-check>') !== false) {
58 if (!isset($check['version-check']['update']))
59 return NULL;
60
61 // TODO(rsesek): Switch to SimpleXML.
62 $check = $bugsys->xml->parse($check);
63 return $check['version-check']['update']['value'];
64 }
65 }
66 }
67
68 /*
69
70 $admin->table_start();
71 $admin->table_head(T('Welcome to the Bugdar Admin Panel'));
72
73 // -------------------------------------------------------------------
74 $admin->row_span(T('Version Information'), 'thead');
75 $admin->row_text(T('Bugdar Version'), $bugsys->options['trackerversion']);
76 $admin->row_text(T('PHP Version'), phpversion());
77
78 $mysql = $db->query_first("SELECT VERSION() AS version");
79 $admin->row_text(T('MySQL Version'), $mysql['version']);
80
81 $admin->row_text(T('Web Server'), ($_SERVER['SERVER_SOFTWARE'] ? $_SERVER['SERVER_SOFTWARE'] : $SERVER['SERVER_SOFTWARE']));
82
83 // -------------------------------------------------------------------
84 $admin->row_span(T('Server Options'), 'thead');
85
86 $mysql = $db->query_first("SHOW VARIABLES LIKE 'max_allowed_packet'");
87 $admin->row_text(T('MySQL: Maximum Packet Size'), $mysql['Value']);
88
89 $admin->row_text(T('MySQL: Maximum Upload Size'), $funct->fetch_max_attachment_size());
90
91 $mysql = $db->query_first("SHOW VARIABLES LIKE 'ft_min_word_len'");
92 $admin->row_text(T('MySQL: Full-Text Search Minimum Word Length'), $mysql['Value']);
93
94 $admin->row_text(T('PHP: Safe Mode'), ((ini_get('safe_mode') == 1 OR strtolower(ini_get('safe_mode')) == 'on') ? T('Yes') : T('No')));
95 $admin->row_text(T('PHP: Register Globals'), ((ini_get('register_globals') == 1 OR strtolower(ini_get('register_globals')) == 'on') ? T('Yes') : T('No')));
96 $admin->row_text(T('PHP: Magic Quotes GPC'), ((ini_get('magic_quotes_gpc') == 1 OR strtolower(ini_get('magic_quotes_gpc')) == 'on') ? T('Yes') : T('No')));
97 $admin->row_text(T('PHP: Magic Quotes Sybase'), ((ini_get('magic_quotes_sybase') == 1 OR strtolower(ini_get('magic_quotes_sybase')) == 'on') ? T('Yes') : T('No')));
98
99 // -------------------------------------------------------------------
100
101 $admin->table_end();
102
103 $admin->page_end();
104
105 */