git-svn-id: file:///home/shish/svn/shimmie2/branches/branch_2.2@811 7f39781d-f577-437e-ae19-be835c7a54ca
This commit is contained in:
shish 2008-04-11 06:14:59 +00:00
parent 1fd2fe084b
commit ce8d6f71fd
22 changed files with 104 additions and 63 deletions

View File

@ -2,7 +2,6 @@
/** /**
* Name: Comment Word Ban * Name: Comment Word Ban
* Author: Shish <webmaster@shishnet.org> * Author: Shish <webmaster@shishnet.org>
* Link: http://trac.shishnet.org/shimmie2/
* License: GPLv2 * License: GPLv2
* Description: For stopping spam and other comment abuse * Description: For stopping spam and other comment abuse
*/ */

View File

@ -1,4 +1,10 @@
<?php <?php
/**
* Name: Bulk Add
* Author: Shish <webmaster@shishnet.org>
* License: GPLv2
* Description: Bulk add server-side images
*/
class BulkAdd extends Extension { class BulkAdd extends Extension {
var $theme; var $theme;

View File

@ -1,4 +1,10 @@
<?php <?php
/**
* Name: Downtime
* Author: Shish <webmaster@shishnet.org>
* License: GPLv2
* Description: Show a "down for maintenance" page
*/
class Downtime extends Extension { class Downtime extends Extension {
var $theme; var $theme;

View File

@ -2,7 +2,6 @@
/** /**
* Name: Emoticon Filter * Name: Emoticon Filter
* Author: Shish <webmaster@shishnet.org> * Author: Shish <webmaster@shishnet.org>
* Link: http://trac.shishnet.org/shimmie2/
* License: GPLv2 * License: GPLv2
* Description: Turn :smile: into a link to smile.gif * Description: Turn :smile: into a link to smile.gif
*/ */

View File

@ -1,4 +1,10 @@
<?php <?php
/**
* Name: System Info
* Author: Shish <webmaster@shishnet.org>
* License: GPLv2
* Description: Show various bits of system information, for debugging
*/
class ET extends Extension { class ET extends Extension {
var $theme; var $theme;

View File

@ -2,7 +2,6 @@
/** /**
* Name: EventLog * Name: EventLog
* Author: Shish <webmaster@shishnet.org> * Author: Shish <webmaster@shishnet.org>
* Link: http://trac.shishnet.org/shimmie2/
* License: GPLv2 * License: GPLv2
* Description: A log of things that happen, for abuse tracking * Description: A log of things that happen, for abuse tracking
*/ */

View File

@ -2,7 +2,6 @@
/** /**
* Name: Home Extension * Name: Home Extension
* Author: Bzchan <bzchan@animemahou.com> * Author: Bzchan <bzchan@animemahou.com>
* Link: http://trac.shishnet.org/shimmie2/
* License: GPLv2 * License: GPLv2
* Description: Extension adds a page "home" containing user specified * Description: Extension adds a page "home" containing user specified
* links and a counter showing total number of posts. The * links and a counter showing total number of posts. The

View File

@ -1,4 +1,10 @@
<?php <?php
/**
* Name: IP Ban
* Author: Shish <webmaster@shishnet.org>
* License: GPLv2
* Description: Ban IP addresses
*/
// RemoveIPBanEvent {{{ // RemoveIPBanEvent {{{
class RemoveIPBanEvent extends Event { class RemoveIPBanEvent extends Event {

View File

@ -1,4 +1,10 @@
<?php <?php
/**
* Name: News
* Author: Shish <webmaster@shishnet.org>
* License: GPLv2
* Description: Show a short amonut of text in a block on the post list
*/
class News extends Extension { class News extends Extension {
var $theme; var $theme;

View File

@ -2,7 +2,6 @@
/** /**
* Name: Image Scores (Numeric) * Name: Image Scores (Numeric)
* Author: Shish <webmaster@shishnet.org> * Author: Shish <webmaster@shishnet.org>
* Link: http://trac.shishnet.org/shimmie2/
* License: GPLv2 * License: GPLv2
* Description: Allow users to score images * Description: Allow users to score images
*/ */

View File

@ -1,4 +1,10 @@
<?php <?php
/**
* Name: Regen Thumb
* Author: Shish <webmaster@shishnet.org>
* License: GPLv2
* Description: Regenerate a thumbnail image
*/
class RegenThumb extends Extension { class RegenThumb extends Extension {
var $theme; var $theme;

View File

@ -1,5 +1,4 @@
<?php <?php
/* /*
* Name: Report Images * Name: Report Images
* Author: ATravelingGeek <atg@atravelinggeek.com> * Author: ATravelingGeek <atg@atravelinggeek.com>

View File

@ -2,7 +2,6 @@
/** /**
* Name: Resolution Limiter * Name: Resolution Limiter
* Author: Shish <webmaster@shishnet.org> * Author: Shish <webmaster@shishnet.org>
* Link: http://trac.shishnet.org/shimmie2/
* License: GPLv2 * License: GPLv2
* Description: Allows the admin to set min / max image dimentions * Description: Allows the admin to set min / max image dimentions
*/ */

View File

@ -2,7 +2,6 @@
/** /**
* Name: RSS for Comments * Name: RSS for Comments
* Author: Shish <webmaster@shishnet.org> * Author: Shish <webmaster@shishnet.org>
* Link: http://trac.shishnet.org/shimmie2/
* License: GPLv2 * License: GPLv2
* Description: Self explanitory * Description: Self explanitory
*/ */

View File

@ -1,4 +1,11 @@
<?php <?php
/**
* Name: RSS for Images
* Author: Shish <webmaster@shishnet.org>
* License: GPLv2
* Description: Self explanitory
*/
class RSS_Images extends Extension { class RSS_Images extends Extension {
// event handling {{{ // event handling {{{

View File

@ -2,7 +2,6 @@
/** /**
* Name: Site Description * Name: Site Description
* Author: Shish <webmaster@shishnet.org> * Author: Shish <webmaster@shishnet.org>
* Link: http://trac.shishnet.org/shimmie2/
* License: GPLv2 * License: GPLv2
* Description: Sets the "description" meta-info in the page header, for * Description: Sets the "description" meta-info in the page header, for
* eg search engines to read * eg search engines to read

View File

@ -1,10 +1,10 @@
<?php <?php
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /**
* Name: Tagger * * Name: Tagger
* Description: Advanced Tagging v2 * * Description: Advanced Tagging v2
* Author: Artanis (Erik Youngren) <artanis.00@gmail.com> * * Author: Artanis (Erik Youngren) <artanis.00@gmail.com>
* Do not remove this notice. * * Do not remove this notice.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ */
class Tagger extends Extension { class Tagger extends Extension {
var $theme; var $theme;

View File

@ -2,10 +2,8 @@
/** /**
* Name: Simple Wiki * Name: Simple Wiki
* Author: Shish <webmaster@shishnet.org> * Author: Shish <webmaster@shishnet.org>
* Link: http://trac.shishnet.org/shimmie2/
* License: GPLv2 * License: GPLv2
* Description: A simple wiki, for those who don't want the * Description: A simple wiki, for those who don't want the hugeness of mediawiki
* hugeness of mediawiki
*/ */
// WikiUpdateEvent {{{ // WikiUpdateEvent {{{

View File

@ -2,7 +2,6 @@
/** /**
* Name: Word Filter * Name: Word Filter
* Author: Shish <webmaster@shishnet.org> * Author: Shish <webmaster@shishnet.org>
* Link: http://trac.shishnet.org/shimmie2/
* License: GPLv2 * License: GPLv2
* Description: Simple search and replace * Description: Simple search and replace
*/ */

View File

@ -1,4 +1,10 @@
<?php <?php
/**
* Name: Image Zoom
* Author: Shish <webmaster@shishnet.org>
* License: GPLv2
* Description: Scales down too-large images using browser based scaling
*/
class Zoom extends Extension { class Zoom extends Extension {
var $theme; var $theme;

View File

@ -7,6 +7,40 @@
* Description: A thing for point & click extension management * Description: A thing for point & click extension management
*/ */
class ExtensionInfo { // {{{
var $ext_name, $name, $link, $author, $email, $description;
function ExtensionInfo($main) {
$matches = array();
$data = file_get_contents($main);
preg_match("#contrib/(.*)/main.php#", $main, $matches);
$this->ext_name = $matches[1];
$this->name = $matches[1];
if(preg_match("/Name: (.*)/", $data, $matches)) {
$this->name = $matches[1];
}
if(preg_match("/Link: (.*)/", $data, $matches)) {
$this->link = $matches[1];
}
if(preg_match("/Author: (.*) [<\(](.*@.*)[>\)]/", $data, $matches)) {
$this->author = $matches[1];
$this->email = $matches[2];
}
else if(preg_match("/Author: (.*)/", $data, $matches)) {
$this->author = $matches[1];
}
if(preg_match("/Description: (.*)/", $data, $matches)) {
$this->description = $matches[1];
}
$this->enabled = $this->is_enabled($this->ext_name);
}
private function is_enabled($fname) {
return file_exists("ext/$fname");
}
} // }}}
class ExtManager extends Extension { class ExtManager extends Extension {
var $theme; var $theme;
@ -42,37 +76,11 @@ class ExtManager extends Extension {
private function get_extensions() { private function get_extensions() {
$extensions = array(); $extensions = array();
foreach(glob("contrib/*/main.php") as $main) { foreach(glob("contrib/*/main.php") as $main) {
$extension = array(); $extensions[] = new ExtensionInfo($main);
$matches = array();
$data = file_get_contents($main);
preg_match("#contrib/(.*)/main.php#", $main, $matches);
$extension["ext_name"] = $matches[1];
if(preg_match("/Name: (.*)/", $data, $matches)) {
$extension["name"] = $matches[1];
}
if(preg_match("/Link: (.*)/", $data, $matches)) {
$extension["link"] = $matches[1];
}
if(preg_match("/Author: (.*) [<\(](.*@.*)[>\)]/", $data, $matches)) {
$extension["author"] = $matches[1];
$extension["email"] = $matches[2];
}
else if(preg_match("/Author: (.*)/", $data, $matches)) {
$extension["author"] = $matches[1];
}
if(preg_match("/Description: (.*)/", $data, $matches)) {
$extension["description"] = $matches[1];
}
$extension["enabled"] = $this->is_enabled($extension["ext_name"]);
$extensions[] = $extension;
} }
return $extensions; return $extensions;
} }
private function is_enabled($fname) {
return file_exists("ext/$fname");
}
private function set_things($settings) { private function set_things($settings) {
foreach(glob("contrib/*/main.php") as $main) { foreach(glob("contrib/*/main.php") as $main) {
$matches = array(); $matches = array();
@ -88,7 +96,12 @@ class ExtManager extends Extension {
if($enabled) { if($enabled) {
// enable if currently disabled // enable if currently disabled
if(!file_exists("ext/$fname")) { if(!file_exists("ext/$fname")) {
$this->enable_extension($fname); if(function_exists("symlink")) {
symlink("../contrib/$fname", "ext/$fname");
}
else {
full_copy("contrib/$fname", "ext/$fname");
}
} }
} }
else { else {
@ -98,15 +111,6 @@ class ExtManager extends Extension {
} }
} }
} }
private function enable_extension($fname) {
if(function_exists("symlink")) {
symlink("../contrib/$fname", "ext/$fname");
}
else {
full_copy("contrib/$fname", "ext/$fname");
}
}
} }
add_event_listener(new ExtManager()); add_event_listener(new ExtManager());
?> ?>

View File

@ -8,13 +8,13 @@ class ExtManagerTheme extends Themelet {
<tr><th>Name</th><th>Author</th><th>Description</th><th>Enabled</th></tr> <tr><th>Name</th><th>Author</th><th>Description</th><th>Enabled</th></tr>
"; ";
foreach($extensions as $extension) { foreach($extensions as $extension) {
$ext_name = $extension["ext_name"]; $ext_name = $extension->ext_name;
$h_name = empty($extension["name"]) ? $ext_name : html_escape($extension["name"]); $h_name = empty($extension->name) ? $ext_name : html_escape($extension->name);
$h_email = html_escape($extension["email"]); $h_email = html_escape($extension->email);
$h_link = isset($extension["link"]) ? html_escape($extension["link"]) : ""; $h_link = isset($extension->link) ? html_escape($extension->link) : "";
$h_author = html_escape($extension["author"]); $h_author = html_escape($extension->author);
$h_description = html_escape($extension["description"]); $h_description = html_escape($extension->description);
$h_enabled = $extension["enabled"] ? " checked='checked'" : ""; $h_enabled = $extension->enabled ? " checked='checked'" : "";
$html .= " $html .= "
<tr> <tr>
" . ( " . (