2007-04-16 11:58:25 +00:00
|
|
|
<?php
|
2008-04-11 06:12:07 +00:00
|
|
|
/**
|
|
|
|
* Name: System Info
|
|
|
|
* Author: Shish <webmaster@shishnet.org>
|
|
|
|
* License: GPLv2
|
2009-01-16 08:18:41 +00:00
|
|
|
* Description: Show various bits of system information
|
|
|
|
* Documentation:
|
|
|
|
* Knowing the information that this extension shows can be
|
|
|
|
* very useful for debugging. There's also an option to send
|
|
|
|
* your stats to my database, so I can get some idea of how
|
|
|
|
* shimmie is used, which servers I need to support, which
|
|
|
|
* versions of PHP I should test with, etc.
|
2008-04-11 06:12:07 +00:00
|
|
|
*/
|
2007-04-16 11:58:25 +00:00
|
|
|
|
2008-08-23 12:08:19 +00:00
|
|
|
class ET implements Extension {
|
2007-06-30 01:19:11 +00:00
|
|
|
var $theme;
|
2007-08-24 22:29:34 +00:00
|
|
|
|
2008-08-23 12:08:19 +00:00
|
|
|
public function receive_event(Event $event) {
|
2009-05-11 14:04:33 +00:00
|
|
|
global $config, $database, $page, $user;
|
2008-09-06 16:59:02 +00:00
|
|
|
if(is_null($this->theme)) $this->theme = get_theme_object($this);
|
2007-06-30 01:19:11 +00:00
|
|
|
|
2008-09-06 17:48:03 +00:00
|
|
|
if(($event instanceof PageRequestEvent) && $event->page_matches("system_info")) {
|
2009-05-11 14:04:33 +00:00
|
|
|
if($user->is_admin()) {
|
|
|
|
$this->theme->display_info_page($page, $this->get_info());
|
2007-04-16 11:58:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-22 09:41:30 +00:00
|
|
|
if($event instanceof UserBlockBuildingEvent) {
|
2009-05-11 14:04:33 +00:00
|
|
|
if($user->is_admin()) {
|
2007-06-30 01:19:11 +00:00
|
|
|
$event->add_link("System Info", make_link("system_info"));
|
|
|
|
}
|
2007-04-16 11:58:25 +00:00
|
|
|
}
|
|
|
|
}
|
2007-08-24 22:29:34 +00:00
|
|
|
|
2009-05-11 14:04:33 +00:00
|
|
|
private function get_info() {
|
|
|
|
global $config, $database;
|
2007-05-16 21:23:01 +00:00
|
|
|
global $_event_listeners; // yay for using secret globals \o/
|
2007-04-16 11:58:25 +00:00
|
|
|
|
2007-06-30 01:19:11 +00:00
|
|
|
$info = array();
|
|
|
|
$info['site_title'] = $config->get_string("title");
|
|
|
|
$info['site_theme'] = $config->get_string("theme");
|
2009-07-20 03:27:21 +00:00
|
|
|
$info['site_url'] = "http://" . $_SERVER["HTTP_HOST"] . get_base_href();
|
2007-04-16 11:58:25 +00:00
|
|
|
|
2007-09-18 09:21:58 +00:00
|
|
|
$info['sys_shimmie'] = VERSION;
|
|
|
|
$info['sys_schema'] = $config->get_string("db_version");
|
2007-06-30 01:19:11 +00:00
|
|
|
$info['sys_php'] = phpversion();
|
|
|
|
$info['sys_os'] = php_uname();
|
2009-07-20 03:27:21 +00:00
|
|
|
$info['sys_disk'] = to_shorthand_int(disk_total_space("./") - disk_free_space("./")) . " / " .
|
|
|
|
to_shorthand_int(disk_total_space("./"));
|
2007-06-30 01:19:11 +00:00
|
|
|
$info['sys_server'] = $_SERVER["SERVER_SOFTWARE"];
|
|
|
|
include "config.php"; // more magical hax
|
2007-04-16 11:58:25 +00:00
|
|
|
$proto = preg_replace("#(.*)://.*#", "$1", $database_dsn);
|
|
|
|
$db = $database->db->ServerInfo();
|
2007-06-30 01:19:11 +00:00
|
|
|
$info['sys_db'] = "$proto / {$db['version']}";
|
2007-04-16 11:58:25 +00:00
|
|
|
|
2007-06-30 01:19:11 +00:00
|
|
|
$info['stat_images'] = $database->db->GetOne("SELECT COUNT(*) FROM images");
|
|
|
|
$info['stat_comments'] = $database->db->GetOne("SELECT COUNT(*) FROM comments");
|
|
|
|
$info['stat_users'] = $database->db->GetOne("SELECT COUNT(*) FROM users");
|
|
|
|
$info['stat_tags'] = $database->db->GetOne("SELECT COUNT(*) FROM tags");
|
2007-07-05 21:30:37 +00:00
|
|
|
$info['stat_image_tags'] = $database->db->GetOne("SELECT COUNT(*) FROM image_tags");
|
2007-04-16 11:58:25 +00:00
|
|
|
|
2007-05-16 21:23:01 +00:00
|
|
|
$els = array();
|
|
|
|
foreach($_event_listeners as $el) {
|
|
|
|
$els[] = get_class($el);
|
|
|
|
}
|
2007-06-30 01:19:11 +00:00
|
|
|
$info['sys_extensions'] = join(', ', $els);
|
2009-01-04 19:18:37 +00:00
|
|
|
|
2007-05-16 21:28:56 +00:00
|
|
|
//$cfs = array();
|
2008-01-05 00:22:19 +00:00
|
|
|
//foreach($database->get_all("SELECT name, value FROM config") as $pair) {
|
2007-05-16 21:28:56 +00:00
|
|
|
// $cfs[] = $pair['name']."=".$pair['value'];
|
|
|
|
//}
|
2007-06-30 01:19:11 +00:00
|
|
|
//$info[''] = "Config: ".join(", ", $cfs);
|
2007-04-16 11:58:25 +00:00
|
|
|
|
2007-06-30 01:19:11 +00:00
|
|
|
return $info;
|
2007-04-16 11:58:25 +00:00
|
|
|
}
|
|
|
|
// }}}
|
|
|
|
}
|
|
|
|
add_event_listener(new ET());
|
|
|
|
?>
|