This repository has been archived on 2024-09-05. You can view files and clone it, but cannot push or open issues or pull requests.
shimmie2/ext/et/main.php

87 lines
2.9 KiB
PHP
Raw Normal View History

<?php
2009-08-20 22:37:17 +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.
*/
class ET extends Extension {
public function onPageRequest(PageRequestEvent $event) {
2012-01-27 16:52:12 +00:00
global $user;
if($event->page_matches("system_info")) {
2012-03-31 14:48:02 +00:00
if($user->can("view_sysinfo")) {
2012-01-27 16:52:12 +00:00
$this->theme->display_info_page($this->get_info());
}
}
2012-01-27 16:52:12 +00:00
}
public function onUserBlockBuilding(UserBlockBuildingEvent $event) {
2012-01-27 16:52:12 +00:00
global $user;
2012-03-31 14:48:02 +00:00
if($user->can("view_sysinfo")) {
2012-01-27 16:52:12 +00:00
$event->add_link("System Info", make_link("system_info"));
}
}
/**
* Collect the information and return it in a keyed array.
*/
private function get_info() {
global $config, $database;
global $_event_listeners; // yay for using secret globals \o/
$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();
$info['sys_shimmie'] = VERSION;
$info['sys_schema'] = $config->get_string("db_version");
$info['sys_php'] = phpversion();
$info['sys_db'] = $database->db->getAttribute(PDO::ATTR_DRIVER_NAME);
$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("./"));
$info['sys_server'] = $_SERVER["SERVER_SOFTWARE"];
$info['thumb_engine'] = $config->get_string("thumb_engine");
$info['thumb_quality'] = $config->get_int('thumb_quality');
$info['thumb_width'] = $config->get_int('thumb_width');
$info['thumb_height'] = $config->get_int('thumb_height');
$info['thumb_mem'] = $config->get_int("thumb_max_memory");
2011-01-01 16:28:04 +00:00
$info['stat_images'] = $database->get_one("SELECT COUNT(*) FROM images");
$info['stat_comments'] = $database->get_one("SELECT COUNT(*) FROM comments");
$info['stat_users'] = $database->get_one("SELECT COUNT(*) FROM users");
$info['stat_tags'] = $database->get_one("SELECT COUNT(*) FROM tags");
$info['stat_image_tags'] = $database->get_one("SELECT COUNT(*) FROM image_tags");
$els = array();
foreach(get_declared_classes() as $class) {
$rclass = new ReflectionClass($class);
if($rclass->isAbstract()) {
// don't do anything
}
elseif(is_subclass_of($class, "Extension")) {
$els[] = $class;
}
}
$info['sys_extensions'] = join(', ', $els);
2009-01-04 19:18:37 +00:00
//$cfs = array();
//foreach($database->get_all("SELECT name, value FROM config") as $pair) {
// $cfs[] = $pair['name']."=".$pair['value'];
//}
//$info[''] = "Config: ".join(", ", $cfs);
return $info;
}
}
?>