--- /dev/null
+<?php
+/*=====================================================================*\
+|| ###################################################################
+|| # Bugdar
+|| # Copyright (c)2002-2013 Blue Static
+|| #
+|| # This program is free software; you can redistribute it and/or modify
+|| # it under the terms of the GNU General Public License as published by
+|| # the Free Software Foundation; version 2 of the License.
+|| #
+|| # This program is distributed in the hope that it will be useful, but
+|| # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+|| # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+|| # more details.
+|| #
+|| # You should have received a copy of the GNU General Public License along
+|| # with this program; if not, write to the Free Software Foundation, Inc.,
+|| # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+|| ###################################################################
+\*=====================================================================*/
+
+namespace bugdar\admin;
+
+use \bugdar;
+use \hoplite\http;
+
+require_once HOPLITE_ROOT . '/http/action.php';
+
+class HomeAction extends http\Action
+{
+ public function Invoke(http\Request $request, http\Response $response)
+ {
+ $response->body = 'Hello World';
+ }
+}
+
+/*
+require_once('./global.php');
+
+NavLinks::optionsPages();
+$navigator->set_focus('tab', 'options', null);
+$navigator->set_focus('link', 'options-pages-home', 'options-pages');
+
+$admin->page_start(T('Home'));
+
+// ###################################################################
+
+if (!(defined('NO_VERSION_CHECK') AND constant('NO_VERSION_CHECK') == true))
+{
+ $check = @file_get_contents('http://www.bluestatic.org/versioncheck.php?prod=bugdar&ver=' . str_replace(' ', '-', $bugsys->options['trackerversion']));
+ if (strpos($check, '<version-check>') !== false)
+ {
+ $check = $bugsys->xml->parse($check);
+ if (isset($check['version-check']['update']))
+ {
+ $admin->page_code('<div style="background-color: white; border-color: red; border-width: 2px; border-style: solid; color: red; padding: 4px"><div style="font-size: 18px; font-weight: bold">' . T('Update Avaliable') . ':</div>' . sprintf(T('Your installation of Bugdar is out-of-date. You are running version <strong>%1$s</strong> and the latest version is <strong>%2$s</strong>. You can download the update at <a href="http://www.bluestatic.org">Blue Static\'s website</a>. You are strongly encouraged to apply all updates to fix bugs and any security issues (if present).'), $bugsys->options['trackerversion'], $check['version-check']['update']['value']) . '</div>');
+ }
+ else if (isset($check['version-check']['up-to-date']))
+ {
+ $admin->page_code('<div style="background-color: white; border-color: green; border-width: 2px; border-style: solid; color: green; padding: 4px"><div style="font-size: 18px; font-weight: bold">' . T('Up-to-Date') . ':</div>' . sprintf(T('Your installation of Bugdar is up-to-date. You are running version <strong>%1$s</strong>.'), $bugsys->options['trackerversion']) . '</div>');
+ }
+ }
+}
+
+// ###################################################################
+
+$admin->table_start();
+$admin->table_head(T('Welcome to the Bugdar Admin Panel'));
+
+// -------------------------------------------------------------------
+$admin->row_span(T('Version Information'), 'thead');
+$admin->row_text(T('Bugdar Version'), $bugsys->options['trackerversion']);
+$admin->row_text(T('PHP Version'), phpversion());
+
+$mysql = $db->query_first("SELECT VERSION() AS version");
+$admin->row_text(T('MySQL Version'), $mysql['version']);
+
+$admin->row_text(T('Web Server'), ($_SERVER['SERVER_SOFTWARE'] ? $_SERVER['SERVER_SOFTWARE'] : $SERVER['SERVER_SOFTWARE']));
+
+// -------------------------------------------------------------------
+$admin->row_span(T('Server Options'), 'thead');
+
+$mysql = $db->query_first("SHOW VARIABLES LIKE 'max_allowed_packet'");
+$admin->row_text(T('MySQL: Maximum Packet Size'), $mysql['Value']);
+
+$admin->row_text(T('MySQL: Maximum Upload Size'), $funct->fetch_max_attachment_size());
+
+$mysql = $db->query_first("SHOW VARIABLES LIKE 'ft_min_word_len'");
+$admin->row_text(T('MySQL: Full-Text Search Minimum Word Length'), $mysql['Value']);
+
+$admin->row_text(T('PHP: Safe Mode'), ((ini_get('safe_mode') == 1 OR strtolower(ini_get('safe_mode')) == 'on') ? T('Yes') : T('No')));
+$admin->row_text(T('PHP: Register Globals'), ((ini_get('register_globals') == 1 OR strtolower(ini_get('register_globals')) == 'on') ? T('Yes') : T('No')));
+$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')));
+$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')));
+
+// -------------------------------------------------------------------
+
+$admin->table_end();
+
+$admin->page_end();
+
+*/
\ No newline at end of file
/*=====================================================================*\
|| ###################################################################
|| # Bugdar
-|| # Copyright (c)2002-2007 Blue Static
+|| # Copyright (c)2002-2013 Blue Static
|| #
|| # This program is free software; you can redistribute it and/or modify
|| # it under the terms of the GNU General Public License as published by
|| ###################################################################
\*=====================================================================*/
-require_once('./global.php');
+namespace bugdar\admin;
-NavLinks::optionsPages();
-$navigator->set_focus('tab', 'options', null);
-$navigator->set_focus('link', 'options-pages-home', 'options-pages');
+use \bugdar;
+use \hoplite\http;
-$admin->page_start(T('Home'));
+chdir('../');
+require_once './includes/init.php';
-// ###################################################################
+require_once HOPLITE_ROOT . '/http/output_filter.php';
+require_once HOPLITE_ROOT . '/http/response_code.php';
+require_once HOPLITE_ROOT . '/http/root_controller.php';
+require_once HOPLITE_ROOT . '/http/url_map.php';
-if (!(defined('NO_VERSION_CHECK') AND constant('NO_VERSION_CHECK') == true))
+/**
+ * @implements \hoplite\http\RootControllerDelegate
+ */
+class FrontController
{
- $check = @file_get_contents('http://www.bluestatic.org/versioncheck.php?prod=bugdar&ver=' . str_replace(' ', '-', $bugsys->options['trackerversion']));
- if (strpos($check, '<version-check>') !== false)
+ /** @var \hoplite\http\RootController */
+ private $controller = NULL;
+
+ public function __construct(http\RootController $controller)
{
- $check = $bugsys->xml->parse($check);
- if (isset($check['version-check']['update']))
- {
- $admin->page_code('<div style="background-color: white; border-color: red; border-width: 2px; border-style: solid; color: red; padding: 4px"><div style="font-size: 18px; font-weight: bold">' . T('Update Avaliable') . ':</div>' . sprintf(T('Your installation of Bugdar is out-of-date. You are running version <strong>%1$s</strong> and the latest version is <strong>%2$s</strong>. You can download the update at <a href="http://www.bluestatic.org">Blue Static\'s website</a>. You are strongly encouraged to apply all updates to fix bugs and any security issues (if present).'), $bugsys->options['trackerversion'], $check['version-check']['update']['value']) . '</div>');
- }
- else if (isset($check['version-check']['up-to-date']))
- {
- $admin->page_code('<div style="background-color: white; border-color: green; border-width: 2px; border-style: solid; color: green; padding: 4px"><div style="font-size: 18px; font-weight: bold">' . T('Up-to-Date') . ':</div>' . sprintf(T('Your installation of Bugdar is up-to-date. You are running version <strong>%1$s</strong>.'), $bugsys->options['trackerversion']) . '</div>');
- }
+ $this->controller = $controller;
}
-}
-
-// ###################################################################
-
-$admin->table_start();
-$admin->table_head(T('Welcome to the Bugdar Admin Panel'));
-
-// -------------------------------------------------------------------
-$admin->row_span(T('Version Information'), 'thead');
-$admin->row_text(T('Bugdar Version'), $bugsys->options['trackerversion']);
-$admin->row_text(T('PHP Version'), phpversion());
-$mysql = $db->query_first("SELECT VERSION() AS version");
-$admin->row_text(T('MySQL Version'), $mysql['version']);
+ public function WillRouteRequest(http\Request $request, http\Response $response)
+ {
+ // TODO(port): Write a new cookie function.
+ global $funct;
-$admin->row_text(T('Web Server'), ($_SERVER['SERVER_SOFTWARE'] ? $_SERVER['SERVER_SOFTWARE'] : $SERVER['SERVER_SOFTWARE']));
+ $cookie = COOKIE_PREFIX . 'adminsession';
-// -------------------------------------------------------------------
-$admin->row_span(T('Server Options'), 'thead');
+ if (can_perform('canadminpanel')) {
+ $stmt = bugdar::$db->Prepare("SELECT * FROM ". TABLE_PREFIX . "adminsession WHERE sessionid = ?");
+ $stmt->Execute(array(bugdar::$input->InputClean('c', $cookie, http\Input::TYPE_STR)));
+ $session = $stmt->FetchObject();
-$mysql = $db->query_first("SHOW VARIABLES LIKE 'max_allowed_packet'");
-$admin->row_text(T('MySQL: Maximum Packet Size'), $mysql['Value']);
+ if ($session && $session->userid == bugdar::$user['userid'] && $session->dateline >= TIMENOW - 3600) {
+ // Renew the cookie.
+ $funct->cookie($cookie, $session->sessionid, false);
+ return;
+ }
+ }
-$admin->row_text(T('MySQL: Maximum Upload Size'), $funct->fetch_max_attachment_size());
+ $funct->cookie($cookie, NULL);
+ $this->LoginPage();
+ }
-$mysql = $db->query_first("SHOW VARIABLES LIKE 'ft_min_word_len'");
-$admin->row_text(T('MySQL: Full-Text Search Minimum Word Length'), $mysql['Value']);
+ public function LoginPage()
+ {
+ $this->controller->StopWithCode(http\ResponseCode::FORBIDDEN);
+ }
+}
-$admin->row_text(T('PHP: Safe Mode'), ((ini_get('safe_mode') == 1 OR strtolower(ini_get('safe_mode')) == 'on') ? T('Yes') : T('No')));
-$admin->row_text(T('PHP: Register Globals'), ((ini_get('register_globals') == 1 OR strtolower(ini_get('register_globals')) == 'on') ? T('Yes') : T('No')));
-$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')));
-$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')));
+$controller = new http\RootController($GLOBALS);
+$controller->set_delegate(new FrontController($controller));
-// -------------------------------------------------------------------
+$url_map = new http\UrlMap($controller);
+$url_map->set_file_loader(function($name, $value) {
+ require_once BUGDAR_ROOT . '/admin/' . $value;
+ return 'bugdar\\admin\\' . $name . 'Action';
+});
+$controller->set_url_map($url_map);
-$admin->table_end();
+$url_map->set_map(array(
+ '' => 'home',
+ 'fields' => 'fields',
+));
-$admin->page_end();
+$output_filter = new http\OutputFilter($controller);
+$controller->set_output_filter($output_filter);
+$controller->Run();