Now that the extension manager is working, the non-essential extensions can be made optional

git-svn-id: file:///home/shish/svn/shimmie2/trunk@803 7f39781d-f577-437e-ae19-be835c7a54ca
This commit is contained in:
shish
2008-04-11 05:28:36 +00:00
parent f7218a677d
commit ff199a7c63
13 changed files with 0 additions and 0 deletions

View File

@@ -1,67 +0,0 @@
<?php
class ET extends Extension {
var $theme;
public function receive_event($event) {
if(is_null($this->theme)) $this->theme = get_theme_object("et", "ETTheme");
if(is_a($event, 'PageRequestEvent') && ($event->page_name == "system_info")) {
if($event->user->is_admin()) {
$this->theme->display_info_page($event->page, $this->get_info());
}
}
if(is_a($event, 'UserBlockBuildingEvent')) {
if($event->user->is_admin()) {
$event->add_link("System Info", make_link("system_info"));
}
}
}
// do it {{{
private function get_info() {
global $database;
global $config;
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");
$info['site_genre'] = "[please write something here]";
$info['site_url'] = isset($_SERVER['SCRIPT_URI']) ? dirname($_SERVER['SCRIPT_URI']) : "???";
$info['sys_shimmie'] = VERSION;
$info['sys_schema'] = $config->get_string("db_version");
$info['sys_php'] = phpversion();
$info['sys_os'] = php_uname();
$info['sys_server'] = $_SERVER["SERVER_SOFTWARE"];
include "config.php"; // more magical hax
$proto = preg_replace("#(.*)://.*#", "$1", $database_dsn);
$db = $database->db->ServerInfo();
$info['sys_db'] = "$proto / {$db['version']}";
$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");
$info['stat_image_tags'] = $database->db->GetOne("SELECT COUNT(*) FROM image_tags");
$els = array();
foreach($_event_listeners as $el) {
$els[] = get_class($el);
}
$info['sys_extensions'] = join(', ', $els);
//$cfs = array();
//foreach($database->get_all("SELECT name, value FROM config") as $pair) {
// $cfs[] = $pair['name']."=".$pair['value'];
//}
//$info[''] = "Config: ".join(", ", $cfs);
return $info;
}
// }}}
}
add_event_listener(new ET());
?>

View File

@@ -1,54 +0,0 @@
<?php
class ETTheme extends Themelet {
/*
* Create a page showing info
*
* $info = an array of ($name => $value)
*/
public function display_info_page($page, $info) {
$page->set_title("System Info");
$page->set_heading("System Info");
$page->add_block(new NavBlock());
$page->add_block(new Block("Data which is to be sent:", $this->build_data_form($info)));
}
protected function build_data_form($info) {
$data = <<<EOD
Optional:
Add this site to the public shimmie users list: No
Site title: {$info['site_title']}
Theme: {$info['site_theme']}
Genre: {$info['site_genre']}
URL: {$info['site_url']}
System stats:
Shimmie: {$info['sys_shimmie']}
Schema: {$info['sys_schema']}
PHP: {$info['sys_php']}
OS: {$info['sys_os']}
Server: {$info['sys_server']}
Database: {$info['sys_db']}
Extensions: {$info['sys_extensions']}
Shimmie stats:
Images: {$info['stat_images']}
Comments: {$info['stat_comments']}
Users: {$info['stat_users']}
Tags: {$info['stat_tags']}
Applications: {$info['stat_image_tags']}
EOD;
$html = <<<EOD
<form action='http://shimmie.shishnet.org/register.php' method='POST'>
<input type='hidden' name='registration_api' value='1'>
<textarea name='data' rows='20' cols='80'>$data</textarea>
<br><input type='submit' value='Click to send to Shish'>
<br>Your stats are useful so that I know which combinations
of web servers / databases / etc I need to support,
<br>and so that I can get some idea of how people use shimmie generally
</form>
EOD;
return $html;
}
}
?>