Commit beac3bee authored by Hugo Leisink's avatar Hugo Leisink

Release 0.6

parents
monitor (0.7) stable; urgency=low
* Improved menu library.
* Account activity overview added to profile module.
-- Hugo Leisink <hugo@leisink.net> Sun, 13 Dec 2013 8:01:07 +0100
monitor (0.6) stable; urgency=low
* Host statistics module made faster.
* Pages module added.
* IP-Country conversion table updated.
* Small bugfixes.
-- Hugo Leisink <hugo@leisink.net> Sun, 13 Dec 2013 8:01:07 +0100
monitor (0.5) stable; urgency=low
* Renamed actions to events.
* Error while downloading webserver data logged as event.
* Generic messages, like high server load, logged as event.
* Removed unnecessary files and Banshee features.
* Small improvements and bugfixes.
-- Hugo Leisink <hugo@leisink.net> Sat, 31 May 2012 15:54:23 +0200
monitor (0.4) stable; urgency=low
* Banshee framework updated to version 3.0.
* Improved User-Agent parsing.
* Browser version filter in 'Web browsers' and 'Browsers with OSes' page.
* Detailed information for 'Host statistics' page.
* Server statistics list for each webserver.
* Session Manager added.
* Settings via CMS.
* Small improvements.
-- Hugo Leisink <hugo@leisink.net> Sat, 3 Mar 2012 14:39:44 +0100
monitor (0.3) stable; urgency=low
* Banshee framework updated to version 2.1.
* Improved Google referer handling.
* Count filter for Origins and Referer pages.
-- Hugo Leisink <hugo@leisink.net> Mon, 7 Jun 2010 20:47:21 +0200
monitor (0.2) stable; urgency=low
* Improved database setup script.
* Banshee bugfixes applied.
* Bugfix: using port number while fetching log.
-- Hugo Leisink <hugo@leisink.net> Mon, 19 Apr 2010 23:30:54 +0200
monitor (0.1) stable; urgency=low
* Initial release
-- Hugo Leisink <hugo@leisink.net> Fri, 12 Feb 2010 9:07:37 +0100
Hiawatha Monitor - Copyright (C) by Hugo Leisink <hugo@leisink.net>
The Hiawatha Monitor is free. The Hiawatha Monitor is built upon the Banshee PHP
framework. The license of the Banshee PHP framework still applies to the files
which are part of the Banshee PHP framework. For more information about the
license of the Banshee PHP framework, visit the Banshee website:
http://www.banshee-php.org/
UNDERSTAND HOW TO HIAWATHA MONITOR WORKS
=========================================
Read the information at http://www.hiawatha-webserver.org/howto/monitor to understand what the Hiawatha Monitor is and how it works..
CONFIGURE YOUR WEBSERVER
=========================
Use the following Hiawatha configuration for this website.
UrlToolkit {
ToolkitID = monitor
RequestURI isfile Return
Match ^/(css|images|js)/ Return
Match ^/(favicon.ico|robots.txt)$ Return
Match .*\?(.*) Rewrite /index.php?$1
Match .* Rewrite /index.php
}
VirtualHost {
Hostname = monitor.domain.com
WebsiteRoot = /var/www/monitor/public
AccessLogfile = /var/www/monitor/logfiles/access.log
ErrorLogfile = /var/www/monitor/logfiles/error.log
StartFile = index.php
ExecuteCGI = yes
# UseFastCGI = PHP5 # Use if you use PHP as a FastCGI daemon
TimeForCGI = 15
UseToolkit = monitor
}
CONFIGURE PHP
==============
The Hiawatha Monitor requires the following PHP modules:
php5-mysql and php5-xsl
Use the following PHP settings:
cgi.fix_pathinfo = 0 (when using FastCGI PHP), 1 (otherwise)
cgi.rfc2616_headers = 1
register_globals = Off
date.timezone = <your timezone>
CONFIGURE YOUR DATABASE
========================
Change the database settings in 'settings/website.conf' and run the script 'database/setup_database'.
The database already contains the following user:
admin:monitor
CONFIGURE CRON DAEMON
======================
Use the cron daemon to fetch the information from the webservers:
# Crontab
SHELL=/bin/sh
MAILTO=<account name of which you can read e-mail>
*/5 * * * * /path/to/monitor/website/database/fetch_webserver_logs
3 1 * * * /path/to/monitor/website/database/delete_old_logs
USING THE HIAWATHA MONITOR
===========================
Please note that it might take some time (about an hour) before host statistics show up. The reason is because of the fact that Hiawatha caches these statistics for performance reasons.
Don't forget to change the admin password and to check out the settings in the Settings administration page. When you're done testing, set DEBUG_MODE in settings/website.conf to 'no'.
<?php
class admin_controller extends controller {
private $menu = array(
"Authentication and authorization" => array(
"Users" => array("admin/user", "users.png"),
"Roles" => array("admin/role", "roles.png"),
"Access" => array("admin/access", "access.png")),
"Support and testing" => array(
"Action log" => array("admin/action", "action.png"),
"User switch" => array("admin/switch", "switch.png")),
"Content" => array(
"Hostnames" => array("admin/hostname", "hostname.gif"),
"Menu" => array("admin/menu", "menu.png"),
"News" => array("admin/news", "news.png"),
"Pages" => array("admin/page", "page.png"),
"Settings" => array("admin/settings", "settings.png"),
"Webservers" => array("admin/webserver", "webserver.png")));
public function execute() {
if (is_true(DEBUG_MODE)) {
$this->output->add_system_message("Website is running in debug mode. Set DEBUG_MODE in settings/website.conf to 'no'.");
}
$access_list = page_access_list($this->db, $this->user);
$private_pages = config_file("private_pages");
$this->output->open_tag("menu");
foreach ($this->menu as $text => $section) {
$this->output->open_tag("section", array(
"text" => $text,
"class" => str_replace(" ", "_", strtolower($text))));
foreach ($section as $text => $info) {
list($page, $icon) = $info;
if (in_array($page, $private_pages) == false) {
continue;
}
if (isset($access_list[$page])) {
$access = show_boolean($access_list[$page] > 0);
} else {
$access = show_boolean(true);
}
$this->output->add_tag("entry", $page, array(
"text" => $text,
"access" => $access,
"icon" => $icon));
}
$this->output->close_tag();
}
$this->output->close_tag();
}
}
?>
<?php
class admin_access_controller extends controller {
public function execute() {
if (($users = $this->model->get_all_users()) === false) {
$this->output->add_tag("result", "Database error.");
} else if (($modules = $this->model->get_private_modules()) === false) {
$this->output->add_tag("result", "Database error.");
} else if (($pages = $this->model->get_private_pages()) === false) {
$this->output->add_tag("result", "Database error.");
} else if (($roles = $this->model->get_all_roles()) === false) {
$this->output->add_tag("result", "Database error.");
} else {
$this->output->open_tag("overview");
/* Roles
*/
$this->output->open_tag("roles");
foreach ($roles as $role) {
$this->output->add_tag("role", $role["name"]);
}
$this->output->close_tag();
/* Users
*/
$this->output->open_tag("users");
foreach ($users as $user) {
$this->output->open_tag("user", array("name" => $user["username"]));
foreach ($roles as $role) {
$this->output->add_tag("role", in_array($role["id"], $user["roles"]) ? YES : NO);
}
$this->output->close_tag();
}
$this->output->close_tag();
/* Modules
*/
$this->output->open_tag("modules");
foreach ($modules as $module) {
$this->output->open_tag("module", array("url" => $module));
foreach ($roles as $role) {
$this->output->add_tag("access", $role[$module]);
}
$this->output->close_tag();
}
$this->output->close_tag();
/* Pages
*/
$this->output->open_tag("pages");
foreach ($pages as $page) {
$this->output->open_tag("page", array("url" => $page["url"]));
foreach ($roles as $role) {
$level = $page["access"][$role["id"]];
$this->output->add_tag("access", isset($level) ? $level : 0);
}
$this->output->close_tag();
}
$this->output->close_tag();
$this->output->close_tag();
}
}
}
?>
<?php
class admin_action_controller extends controller {
public function execute() {
if (valid_input($this->page->pathinfo[2], VALIDATE_NUMBERS, VALIDATE_NONEMPTY) == false) {
$offset = 0;
} else {
$offset = $this->page->pathinfo[2];
}
if (isset($_SESSION["admin_actionlog_size"]) == false) {
$_SESSION["admin_actionlog_size"] = $this->model->get_log_size();
}
$paging = new pagination($this->output, "admin_actionlog", $this->settings->admin_page_size, $_SESSION["admin_actionlog_size"]);
if (($log = $this->model->get_action_log($paging->offset, $paging->size)) === false) {
$this->output->add_tag("result", "Error reading action log.");
return;
}
$users = array($this->user->id => $this->user->username);
$this->output->open_tag("log");
$this->output->open_tag("list");
foreach ($log as $entry) {
$user_id = $entry["user_id"];
if (isset($users[$user_id]) == false) {
if (($user = $this->model->get_user($user_id)) !== false) {
$users[$user_id] = $user["username"];
}
}
$entry["username"] = isset($users[$user_id]) ? $users[$user_id] : "-";
$this->output->record($entry, "entry");
}
$this->output->close_tag();
$paging->show_browse_links();
$this->output->close_tag();
}
}
?>
<?php
class admin_hostname_controller extends controller {
public function execute() {
if ($_SERVER["REQUEST_METHOD"] == "POST") {
/* Handle form submit
*/
if ($this->model->update_hostnames($_POST["hostname"]) == false) {
$this->output->add_tag("result", "Error while updating hostname.");
} else {
$this->output->add_tag("result", "Hostnames have been updated.", array("url" => "admin"));
}
} else {
/* Show hostname form
*/
if (($hostnames = $this->model->get_hostnames()) === false) {
$this->output->add_tag("result", "Database error.");
} else {
$this->output->open_tag("hostnames");
foreach ($hostnames as $hostname) {
$this->output->add_tag("hostname", $hostname["hostname"], array(
"id" => $hostname["id"],
"visible" => show_boolean($hostname["visible"])));
}
$this->output->close_tag();
}
}
}
}
?>
<?php
class admin_menu_controller extends controller {
private $url = null;
private function show_menu_form($menu_id, $menu) {
$this->output->add_javascript("jquery/jquery.js");
$this->output->add_javascript("jquery/ui.core.js");
$this->output->add_javascript("jquery/ui.widget.js");
$this->output->add_javascript("jquery/ui.mouse.js");
$this->output->add_javascript("jquery/ui.sortable.js");
$this->output->add_javascript("admin/menu.js");
$this->output->open_tag("edit");
if (($parent = $this->model->get_menu($menu_id)) != false) {
$this->output->add_tag("parent", $parent["text"], array("id" => $parent["parent_id"]));
}
$this->output->open_tag("menu", array("id" => $menu_id));
$max_id = 0;
foreach ($menu as $item) {
unset($item["parent_id"]);
$this->output->record($item, "item");
if ($item["id"] > $max_id) {
$max_id = $item["id"];
}
}
$this->output->close_tag();
$this->output->add_tag("max_menu_id", $max_id + 1);
$this->output->close_tag();
if (count($menu) == 0) {
$this->output->onload_javascript("add_item('editmenu', 1)");
}
}
public function execute() {
$this->url = array("url" => "admin/menu");
if ($_SERVER["REQUEST_METHOD"] == "POST") {
/* Update menu
*/
if ($this->model->menu_oke($_POST) == false) {
foreach ($_POST["menu"] as $id => $value) {
$_POST["menu"][$id]["id"] = $id;
}
$this->show_menu_form($_POST["menu_id"], $_POST["menu"]);
} else if ($this->model->update_menu($_POST["menu_id"], $_POST["menu"]) == false) {
$this->output->add_tag("result", "Error while updating menu.", $url);
} else {
$this->output->add_tag("result", "The menu has been updated.", array("url" => "admin/menu/".$_POST["menu_id"]));
$this->output->remove_from_cache("menu");
$this->user->log_action("menu ".$_POST["menu_id"]." updated");
}
} else {
/* Show menu
*/
if (valid_input($this->page->pathinfo[2], VALIDATE_NUMBERS, VALIDATE_NONEMPTY) == false) {
$menu_id = 0;
} else if (($menu_id = (int)$this->page->pathinfo[2]) != 0) {
if (($parent = $this->model->get_menu($menu_id)) == false) {
$this->output->add_tag("result", "Menu not found.", $url);
return;
}
}
if (($menu = $this->model->get_menu_items($menu_id)) === false) {
$this->output->add_tag("result", "Database error!", $url);
} else {
$this->show_menu_form($menu_id, $menu);
}
}
}
}
?>
<?php
class admin_page_controller extends controller {
private function show_page_overview() {
if (($pages = $this->model->get_pages()) === false) {
$this->output->add_tag("result", "Database error.");
} else {
$this->output->open_tag("overview");
$this->output->open_tag("pages");
foreach ($pages as $page) {
$page["visible"] = show_boolean($page["visible"]);
$this->output->record($page, "page");
}
$this->output->close_tag();
$this->output->close_tag();
}
}
private function show_page_form($page) {
$this->output->set_xslt_parameter("admin_role_id", ADMIN_ROLE_ID);
$page["private"] = show_boolean($page["private"]);
$page["visible"] = show_boolean($page["visible"]);
$args = array();
if (isset($page["id"])) {
$args["id"] = $page["id"];
}
$this->output->open_tag("edit");
$this->output->open_tag("page", $args);
$this->output->record($page);
$this->output->open_tag("roles");
if (($roles = $this->model->get_roles()) != false) {
foreach ($roles as $role) {
$this->output->add_tag("role", $role["name"], array(
"id" => $role["id"],
"checked" => show_boolean($page["roles"][$role["id"]])));
}
}
$this->output->close_tag();
$this->output->close_tag();
$this->output->close_tag();
}
public function execute() {
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if ($_POST["submit_button"] == "Save page") {
/* Create or update page
*/
$_POST["url"] = rtrim($_POST["url"], "/ ");
if ($this->model->page_oke($_POST) == false) {
$this->show_page_form($_POST);
} else if (isset($_POST["id"]) == false) {
if ($this->model->create_page($_POST) === false) {
$this->output->add_message("Database error while creating page.");
$this->show_page_form($_POST);
} else {
$this->user->log_action("page ".$_POST["url"]." created");
$this->show_page_overview();
}
} else {
if ($this->model->update_page($_POST, $_POST["id"]) === false) {
$this->output->add_message("Database error while updating page.");
$this->show_page_form($_POST);
} else {
$this->user->log_action("page ".$_POST["id"]." updated");
$this->show_page_overview();
}
}
} else if ($_POST["submit_button"] == "Delete page") {
/* Delete page
*/
if ($this->model->delete_page($_POST["id"]) == false) {
$this->output->add_tag("result", "Database error while deleting page.");
} else {
$this->user->log_action("page ".$_POST["url"]." deleted");
$this->show_page_overview();
}
} else {
$this->output->add_tag("result", "Huh?");
}
} else if ($this->page->pathinfo[2] == "new") {
/* Show the user webform
*/
$page = array(
"url" => "/",
"language" => $this->settings->default_language,
"visible" => 1,
"roles" => array());
$this->show_page_form($page);
} else if (valid_input($this->page->pathinfo[2], VALIDATE_NUMBERS, VALIDATE_NONEMPTY)) {
/* Show the user webform
*/
if (($page = $this->model->get_page($this->page->pathinfo[2])) == false) {
$this->output->add_tag("result", "Page not found.");
} else {
$this->show_page_form($page);
}
} else {
/* Show a list of all users
*/
$this->show_page_overview();
}
}
}
?>
<?php
class admin_role_controller extends controller {
public function show_role_overview() {
if (($roles = $this->model->get_all_roles()) === false) {
$this->output->add_tag("result", "Database error.");
} else {
$this->output->open_tag("overview");
$this->output->open_tag("roles");
foreach ($roles as $role) {
$this->output->add_tag("role", $role["name"], array("id" => $role["id"], "users" => $role["users"]));
}
$this->output->close_tag();
$this->output->close_tag();
}
}
public function show_role_form($role) {
if (isset($role["id"]) == false) {
$editable = true;
$params = array();
} else {
$editable = ($role["id"] != ADMIN_ROLE_ID);
$params = array("id" => $role["id"]);
}
if (($pages = $this->model->get_restricted_pages()) === false) {
$this->output->add_tag("result", "Database error.");
return;
}
sort($pages);
$this->output->set_xslt_parameter("admin_role_id", ADMIN_ROLE_ID);
$this->output->open_tag("edit");
$this->output->add_tag("role", $role["name"], $params);
$this->output->open_tag("pages");
foreach ($pages as $page) {
$this->output->add_tag("page", $page, array("checked" => show_boolean($role[$page])));
}
$this->output->close_tag();
$this->output->open_tag("members");
if (($users = $this->model->get_role_members($role["id"])) !== false) {
foreach ($users as $user) {
$this->output->add_tag("member", $user["fullname"], array("id" => $user["id"]));
}
}
$this->output->close_tag();
$this->output->close_tag();
}