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