From de98e869382422417d9cfddae6d2302ee11c1037 Mon Sep 17 00:00:00 2001 From: Matthew Barbour Date: Wed, 7 Aug 2019 14:53:59 -0500 Subject: [PATCH] ExtensionInfo conversions what have I done --- core/_bootstrap.php | 24 +- core/extension.php | 194 +++++++-- core/page.php | 4 +- core/send_event.php | 14 +- core/sys_config.php | 2 - ext/admin/info.php | 33 ++ ext/admin/main.php | 20 - ext/admin/theme.php | 2 +- ext/alias_editor/info.php | 24 ++ ext/alias_editor/main.php | 10 - ext/arrowkey_navigation/info.php | 23 + ext/arrowkey_navigation/main.php | 10 +- ext/artists/info.php | 23 + ext/artists/main.php | 38 +- ext/autocomplete/info.php | 17 + ext/autocomplete/main.php | 5 - ext/ban_words/info.php | 36 ++ ext/ban_words/main.php | 20 - ext/bbcode/info.php | 40 ++ ext/bbcode/main.php | 26 +- ext/blocks/info.php | 21 + ext/blocks/main.php | 7 - ext/blotter/info.php | 22 + ext/blotter/main.php | 10 +- ext/browser_search/info.php | 30 ++ ext/browser_search/main.php | 13 - ext/bulk_actions/info.php | 23 + ext/bulk_actions/main.php | 11 +- ext/bulk_add/info.php | 31 ++ ext/bulk_add/main.php | 15 - ext/bulk_add_csv/info.php | 34 ++ ext/bulk_add_csv/main.php | 26 +- ext/bulk_remove/info.php | 23 + ext/bulk_remove/main.php | 42 +- ext/comment/info.php | 25 ++ ext/comment/main.php | 17 +- ext/cron_uploader/info.php | 28 ++ ext/cron_uploader/main.php | 8 - ext/custom_html_headers/info.php | 30 ++ ext/custom_html_headers/main.php | 30 +- ext/danbooru_api/info.php | 61 +++ ext/danbooru_api/main.php | 47 --- ext/downtime/info.php | 28 ++ ext/downtime/main.php | 12 - ext/emoticons/info.php | 29 ++ ext/emoticons/main.php | 14 +- ext/et/info.php | 25 ++ ext/et/main.php | 12 - ext/ext_manager/info.php | 26 ++ ext/ext_manager/main.php | 156 +------ ext/ext_manager/theme.php | 33 +- ext/favorites/info.php | 25 ++ ext/favorites/main.php | 15 +- ext/featured/info.php | 35 ++ ext/featured/main.php | 21 +- ext/forum/info.php | 21 + ext/forum/main.php | 26 +- ext/google_analytics/info.php | 24 ++ ext/google_analytics/main.php | 14 +- ext/handle_404/info.php | 23 + ext/handle_404/main.php | 9 +- ext/handle_archive/info.php | 25 ++ ext/handle_archive/main.php | 10 - ext/handle_flash/info.php | 19 + ext/handle_flash/main.php | 6 - ext/handle_ico/info.php | 18 + ext/handle_ico/main.php | 5 - ext/handle_mp3/info.php | 18 + ext/handle_mp3/main.php | 5 - ext/handle_pixel/info.php | 20 + ext/handle_pixel/main.php | 6 - ext/handle_static/info.php | 24 ++ ext/handle_static/main.php | 8 - ext/handle_svg/info.php | 19 + ext/handle_svg/main.php | 6 - ext/handle_video/info.php | 28 ++ ext/handle_video/main.php | 14 - ext/hellban/info.php | 14 + ext/hellban/main.php | 3 - ext/help_pages/info.php | 19 + ext/help_pages/main.php | 397 +++++++++++++++++- ext/holiday/info.php | 20 + ext/holiday/main.php | 8 +- ext/home/info.php | 31 ++ ext/home/main.php | 15 - ext/image/config.php | 21 + ext/image/info.php | 24 ++ ext/image/main.php | 31 +- ext/image_hash_ban/info.php | 26 ++ ext/image_hash_ban/main.php | 9 - ext/image_view_counter/info.php | 27 ++ ext/image_view_counter/main.php | 19 +- ext/index/info.php | 169 ++++++++ ext/index/main.php | 154 ------- ext/ipban/info.php | 28 ++ ext/ipban/main.php | 12 - ext/link_image/info.php | 17 + ext/link_image/main.php | 6 +- ext/livefeed/info.php | 22 + ext/livefeed/main.php | 8 - ext/log_db/info.php | 21 + ext/log_db/main.php | 7 - ext/log_logstash/info.php | 21 + ext/log_logstash/main.php | 7 - ext/log_net/info.php | 21 + ext/log_net/main.php | 7 - ext/mail/info.php | 22 + ext/mail/main.php | 14 +- ext/media/info.php | 20 + ext/media/main.php | 7 - ext/not_a_tag/info.php | 20 + ext/not_a_tag/main.php | 8 +- ext/notes/info.php | 20 + ext/notes/main.php | 7 - ext/numeric_score/info.php | 23 + ext/numeric_score/main.php | 10 - ext/oekaki/info.php | 19 + ext/oekaki/main.php | 5 - ext/ouroboros_api/info.php | 42 ++ ext/ouroboros_api/main.php | 51 +-- ext/pm/info.php | 26 ++ ext/pm/main.php | 10 - ext/pm_triggers/info.php | 21 + ext/pm_triggers/main.php | 6 - ext/pools/info.php | 22 + ext/pools/main.php | 13 +- ext/post_titles/info.php | 18 + ext/post_titles/main.php | 6 - ext/qr_code/info.php | 21 + ext/qr_code/main.php | 9 +- ext/random_image/info.php | 36 ++ ext/random_image/main.php | 20 - ext/random_list/info.php | 26 ++ ext/random_list/main.php | 10 - ext/rating/info.php | 35 ++ ext/rating/main.php | 21 - ext/regen_thumb/info.php | 25 ++ ext/regen_thumb/main.php | 20 +- ext/relationships/info.php | 20 + .../main.php | 7 - .../style.css | 0 .../test.php | 0 .../theme.php | 0 ext/report_image/info.php | 24 ++ ext/report_image/main.php | 9 - ext/res_limit/info.php | 20 + ext/res_limit/main.php | 8 +- ext/resize/info.php | 26 ++ ext/resize/main.php | 38 +- ext/rotate/info.php | 25 ++ ext/rotate/main.php | 54 +-- ext/rss_comments/info.php | 23 + ext/rss_comments/main.php | 9 - ext/rss_images/info.php | 20 + ext/rss_images/main.php | 8 +- ext/rule34/info.php | 25 ++ ext/rule34/main.php | 11 - ext/setup/info.php | 20 + ext/setup/main.php | 6 - ext/shimmie_api/info.php | 33 ++ ext/shimmie_api/main.php | 18 - ext/site_description/info.php | 26 ++ ext/site_description/main.php | 12 +- ext/sitemap/info.php | 23 + ext/sitemap/main.php | 9 - ext/source_history/info.php | 18 + ext/source_history/main.php | 55 ++- ext/statsd/info.php | 25 ++ ext/statsd/main.php | 9 - ext/system/info.php | 19 + ext/system/main.php | 6 - ext/tag_categories/info.php | 18 + ext/tag_categories/main.php | 9 +- ext/tag_edit/info.php | 55 +++ ext/tag_edit/main.php | 40 -- ext/tag_editcloud/info.php | 19 + ext/tag_editcloud/main.php | 11 +- ext/tag_history/info.php | 17 + ext/tag_history/main.php | 51 +-- ext/tag_list/info.php | 20 + ext/tag_list/main.php | 18 +- ext/tagger/info.php | 18 + ext/tagger/main.php | 6 - ext/tips/info.php | 8 +- ext/tips/main.php | 1 - ext/transcode/info.php | 25 ++ ext/transcode/main.php | 26 +- ext/trash/info.php | 20 + ext/trash/main.php | 11 +- ext/update/info.php | 21 + ext/update/main.php | 8 +- ext/upgrade/info.php | 22 + ext/upgrade/main.php | 9 +- ext/upload/info.php | 20 + ext/upload/main.php | 8 +- ext/user/events.php | 85 ++++ ext/user/info.php | 18 + ext/user/main.php | 74 +--- ext/varnish/info.php | 22 + ext/varnish/main.php | 7 - ext/view/events/displaying_image_event.php | 11 +- ext/view/info.php | 20 + ext/view/main.php | 15 - ext/wiki/info.php | 23 + ext/wiki/main.php | 10 +- ext/word_filter/info.php | 21 + ext/word_filter/main.php | 7 - themes/danbooru/comment.theme.php | 6 +- themes/danbooru/view.theme.php | 4 +- themes/danbooru2/comment.theme.php | 6 +- themes/danbooru2/view.theme.php | 4 +- themes/lite/view.theme.php | 2 +- 212 files changed, 3449 insertions(+), 1628 deletions(-) create mode 100644 ext/admin/info.php create mode 100644 ext/alias_editor/info.php create mode 100644 ext/arrowkey_navigation/info.php create mode 100644 ext/artists/info.php create mode 100644 ext/autocomplete/info.php create mode 100644 ext/ban_words/info.php create mode 100644 ext/bbcode/info.php create mode 100644 ext/blocks/info.php create mode 100644 ext/blotter/info.php create mode 100644 ext/browser_search/info.php create mode 100644 ext/bulk_actions/info.php create mode 100644 ext/bulk_add/info.php create mode 100644 ext/bulk_add_csv/info.php create mode 100644 ext/bulk_remove/info.php create mode 100644 ext/comment/info.php create mode 100644 ext/cron_uploader/info.php create mode 100644 ext/custom_html_headers/info.php create mode 100644 ext/danbooru_api/info.php create mode 100644 ext/downtime/info.php create mode 100644 ext/emoticons/info.php create mode 100644 ext/et/info.php create mode 100644 ext/ext_manager/info.php create mode 100644 ext/favorites/info.php create mode 100644 ext/featured/info.php create mode 100644 ext/forum/info.php create mode 100644 ext/google_analytics/info.php create mode 100644 ext/handle_404/info.php create mode 100644 ext/handle_archive/info.php create mode 100644 ext/handle_flash/info.php create mode 100644 ext/handle_ico/info.php create mode 100644 ext/handle_mp3/info.php create mode 100644 ext/handle_pixel/info.php create mode 100644 ext/handle_static/info.php create mode 100644 ext/handle_svg/info.php create mode 100644 ext/handle_video/info.php create mode 100644 ext/hellban/info.php create mode 100644 ext/help_pages/info.php create mode 100644 ext/holiday/info.php create mode 100644 ext/home/info.php create mode 100644 ext/image/config.php create mode 100644 ext/image/info.php create mode 100644 ext/image_hash_ban/info.php create mode 100644 ext/image_view_counter/info.php create mode 100644 ext/index/info.php create mode 100644 ext/ipban/info.php create mode 100644 ext/link_image/info.php create mode 100644 ext/livefeed/info.php create mode 100644 ext/log_db/info.php create mode 100644 ext/log_logstash/info.php create mode 100644 ext/log_net/info.php create mode 100644 ext/mail/info.php create mode 100644 ext/media/info.php create mode 100644 ext/not_a_tag/info.php create mode 100644 ext/notes/info.php create mode 100644 ext/numeric_score/info.php create mode 100644 ext/oekaki/info.php create mode 100644 ext/ouroboros_api/info.php create mode 100644 ext/pm/info.php create mode 100644 ext/pm_triggers/info.php create mode 100644 ext/pools/info.php create mode 100644 ext/post_titles/info.php create mode 100644 ext/qr_code/info.php create mode 100644 ext/random_image/info.php create mode 100644 ext/random_list/info.php create mode 100644 ext/rating/info.php create mode 100644 ext/regen_thumb/info.php create mode 100644 ext/relationships/info.php rename ext/{relatationships => relationships}/main.php (95%) rename ext/{relatationships => relationships}/style.css (100%) rename ext/{relatationships => relationships}/test.php (100%) rename ext/{relatationships => relationships}/theme.php (100%) create mode 100644 ext/report_image/info.php create mode 100644 ext/res_limit/info.php create mode 100644 ext/resize/info.php create mode 100644 ext/rotate/info.php create mode 100644 ext/rss_comments/info.php create mode 100644 ext/rss_images/info.php create mode 100644 ext/rule34/info.php create mode 100644 ext/setup/info.php create mode 100644 ext/shimmie_api/info.php create mode 100644 ext/site_description/info.php create mode 100644 ext/sitemap/info.php create mode 100644 ext/source_history/info.php create mode 100644 ext/statsd/info.php create mode 100644 ext/system/info.php create mode 100644 ext/tag_categories/info.php create mode 100644 ext/tag_edit/info.php create mode 100644 ext/tag_editcloud/info.php create mode 100644 ext/tag_history/info.php create mode 100644 ext/tag_list/info.php create mode 100644 ext/tagger/info.php create mode 100644 ext/transcode/info.php create mode 100644 ext/trash/info.php create mode 100644 ext/update/info.php create mode 100644 ext/upgrade/info.php create mode 100644 ext/upload/info.php create mode 100644 ext/user/events.php create mode 100644 ext/user/info.php create mode 100644 ext/varnish/info.php create mode 100644 ext/view/info.php create mode 100644 ext/wiki/info.php create mode 100644 ext/word_filter/info.php diff --git a/core/_bootstrap.php b/core/_bootstrap.php index a6d65ee3..6467f4d8 100644 --- a/core/_bootstrap.php +++ b/core/_bootstrap.php @@ -22,12 +22,11 @@ $tracer_enabled = constant('TRACE_FILE')!==null; // load base files $_tracer->begin("Bootstrap"); -$_tracer->begin("Opening files"); +$_tracer->begin("Opening core files"); $_shm_files = array_merge( zglob("core/*.php"), zglob("core/{".ENABLED_MODS."}/*.php"), - zglob("ext/{".ENABLED_EXTS."}/info.php"), - zglob("ext/{".ENABLED_EXTS."}/main.php") + zglob("ext/*/info.php") ); foreach ($_shm_files as $_shm_filename) { if (basename($_shm_filename)[0] != "_") { @@ -38,6 +37,22 @@ unset($_shm_files); unset($_shm_filename); $_tracer->end(); +$_tracer->begin("Loading extension info"); +ExtensionInfo::load_all_extension_info(); +Extension::determine_enabled_extensions(); +$_tracer->end(); + +$_tracer->begin("Opening enabled extension files"); +$_shm_files = zglob("ext/{".Extension::get_enabled_extensions_as_string()."}/main.php"); +foreach ($_shm_files as $_shm_filename) { + if (basename($_shm_filename)[0] != "_") { + require_once $_shm_filename; + } +} +unset($_shm_files); +unset($_shm_filename); +$_tracer->end(); + // connect to the database $_tracer->begin("Connecting to DB"); $database = new Database(); @@ -53,8 +68,7 @@ unset($themelet); $page = class_exists("CustomPage") ? new CustomPage() : new Page(); $_tracer->end(); -// hook up event handlers -$_tracer->begin("Loading extensions"); +$_tracer->begin("Loading extensions/event listeners"); _load_event_listeners(); $_tracer->end(); diff --git a/core/extension.php b/core/extension.php index be7b8d24..e97e2d38 100644 --- a/core/extension.php +++ b/core/extension.php @@ -83,32 +83,24 @@ */ abstract class Extension { - /** @var array which DBs this ext supports (blank for 'all') */ - protected $db_support = []; + public $key; /** @var Themelet this theme's Themelet object */ public $theme; public $info; - public function __construct() - { - $class = get_called_class(); - $this->theme = $this->get_theme_object($class); - $this->info = ExtensionInfo::get_for_extension($class); - } + private static $enabled_extensions = []; - public function is_supported(): bool + public function __construct($class = null) { - if($this->info!=null) { - return $this->info->supported; - } else { - global $database; - return ( - empty($this->db_support) || - in_array($database->get_driver_name(), $this->db_support) - ); + $class = $class ?? get_called_class(); + $this->theme = $this->get_theme_object($class); + $this->info = ExtensionInfo::get_for_extension_class($class); + if($this->info===null) { + throw new Exception("Info class not found for extension $class"); } + $this->key = $this->info->key; } /** @@ -136,45 +128,183 @@ abstract class Extension { return 50; } + + public static function determine_enabled_extensions() + { + self::$enabled_extensions = []; + foreach(array_merge(ExtensionInfo::get_core_extensions(), + explode(",", EXTRA_EXTS)) as $key) { + $ext = ExtensionInfo::get_by_key($key); + if($ext===null) { + continue; + } + self::$enabled_extensions[] = $ext->key; + } + } + + public static function is_enabled(string $key): ?bool + { + return in_array($key, self::$enabled_extensions); + } + + public static function get_enabled_extensions(): array + { + return self::$enabled_extensions; + } + public static function get_enabled_extensions_as_string(): string + { + return implode(",",self::$enabled_extensions); + } } abstract class ExtensionInfo { + // Every credit you get costs us RAM. It stops now. + public const SHISH_NAME = "Shish"; + public const SHISH_EMAIL = "webmaster@shishnet.org"; + public const SHIMMIE_URL = "http://code.shishnet.org/shimmie2/"; + public const SHISH_AUTHOR = [self::SHISH_NAME=>self::SHISH_EMAIL]; + + public const LICENSE_GPLV2 = "GPLv2"; + public const LICENSE_MIT = "MIT"; + public const LICENSE_WTFPL = "WTFPL"; + + public const VISIBLE_ADMIN = "admin"; + private const VALID_VISIBILITY = [self::VISIBLE_ADMIN]; + + public $key; + + public $core = false; + + public $beta = false; + public $name; - public $authors; + public $authors = []; public $link; public $license; public $version; public $visibility; public $description; public $documentation; - public $supported; - public $db_support; - public function __construct() - { - $this->supported = $this->is_supported(); - } + /** @var array which DBs this ext supports (blank for 'all') */ + public $db_support = []; + + private $supported = null; + private $support_info = null; public function is_supported(): bool { - global $database; - return ( - empty($this->db_support) || - in_array($database->get_driver_name(), $this->db_support) - ); + if($this->supported===null) { + $this->check_support(); + } + return $this->supported; } - public static function get_for_extension(string $base): ?ExtensionInfo + public function get_support_info(): string + { + if($this->supported===null) { + $this->check_support(); + } + return $this->support_info; + } + + private static $all_info_by_key = []; + private static $all_info_by_class = []; + private static $core_extensions = []; + + protected function __construct() + { + if(empty($this->key)) { + throw new Exception("key field is required"); + } + if(empty($this->name)) { + throw new Exception("name field is required for extension $this->key"); + } + if(!empty($this->visibility)&&!in_array($this->visibility, self::VALID_VISIBILITY)) { + throw new Exception("Invalid visibility for extension $this->key"); + } + if(!is_array($this->db_support)) { + throw new Exception("db_support has to be an array for extension $this->key"); + } + if(!is_array($this->authors)) { + throw new Exception("authors has to be an array for extension $this->key"); + } + } + + public function is_enabled(): bool + { + return Extension::is_enabled($this->key); + } + + private function check_support() + { + global $database; + $this->support_info = ""; + if(!empty($this->db_support)&&!in_array($database->get_driver_name(), $this->db_support)) { + $this->support_info .= "Database not supported. "; + } + // Additional checks here as needed + + $this->supported = empty($this->support_info); + } + + public static function get_all(): array + { + return array_values(self::$all_info_by_key); + } + + public static function get_all_keys(): array + { + return array_keys(self::$all_info_by_key); + } + + public static function get_core_extensions(): array + { + return self::$core_extensions; + } + + public static function get_by_key(string $key): ?ExtensionInfo + { + if(array_key_exists($key, self::$all_info_by_key)) { + return self::$all_info_by_key[$key]; + } else { + return null; + } + } + + public static function get_for_extension_class(string $base): ?ExtensionInfo { $normal = $base.'Info'; - if (class_exists($normal)) { - return new $normal(); + if (array_key_exists($normal, self::$all_info_by_class)) { + return self::$all_info_by_class[$normal]; } else { return null; } } + + public static function load_all_extension_info() + { + + foreach (get_declared_classes() as $class) { + $rclass = new ReflectionClass($class); + if ($rclass->isAbstract()) { + // don't do anything + } elseif (is_subclass_of($class, "ExtensionInfo")) { + $extension_info = new $class(); + if(array_key_exists($extension_info->key, self::$all_info_by_key)) { + throw new Exception("Extension Info $class with key $extension_info->key has already been loaded"); + } + + self::$all_info_by_key[$extension_info->key] = $extension_info; + self::$all_info_by_class[$class] = $extension_info; + if($extension_info->core===true) { + self::$core_extensions[] = $extension_info->key; + } + } + } + } } /** diff --git a/core/page.php b/core/page.php index 7efa2833..49bb0ec9 100644 --- a/core/page.php +++ b/core/page.php @@ -468,7 +468,7 @@ class Page /*** Generate CSS cache files ***/ $css_latest = $config_latest; $css_files = array_merge( - zglob("ext/{" . ENABLED_EXTS . "}/style.css"), + zglob("ext/{" . Extension::get_enabled_extensions_as_string() . "}/style.css"), zglob("themes/$theme_name/style.css") ); foreach ($css_files as $css) { @@ -499,7 +499,7 @@ class Page "vendor/bower-asset/js-cookie/src/js.cookie.js", "ext/handle_static/modernizr-3.3.1.custom.js", ], - zglob("ext/{" . ENABLED_EXTS . "}/script.js"), + zglob("ext/{" . Extension::get_enabled_extensions_as_string() . "}/script.js"), zglob("themes/$theme_name/script.js") ); foreach ($js_files as $js) { diff --git a/core/send_event.php b/core/send_event.php index 8542e08c..10f91c32 100644 --- a/core/send_event.php +++ b/core/send_event.php @@ -44,7 +44,7 @@ function _set_event_listeners(): void $extension = new $class(); // skip extensions which don't support our current database - if (!$extension->is_supported()) { + if (!$extension->info->is_supported()) { continue; } @@ -88,16 +88,6 @@ function _dump_event_listeners(array $event_listeners, string $path): void file_put_contents($path, $p); } -function ext_is_live(string $ext_name): bool -{ - if (class_exists($ext_name)) { - /** @var Extension $ext */ - $ext = new $ext_name(); - return $ext->is_supported(); - } - return false; -} - /** @private */ global $_shm_event_count; @@ -109,7 +99,7 @@ $_shm_event_count = 0; function send_event(Event $event): void { global $tracer_enabled; - + global $_shm_event_listeners, $_shm_event_count, $_tracer; if (!isset($_shm_event_listeners[get_class($event)])) { return; diff --git a/core/sys_config.php b/core/sys_config.php index 5dc80459..8692f97e 100644 --- a/core/sys_config.php +++ b/core/sys_config.php @@ -40,7 +40,6 @@ _d("SEARCH_ACCEL", false); // boolean use search accelerator _d("WH_SPLITS", 1); // int how many levels of subfolders to put in the warehouse _d("VERSION", '2.7-beta'); // string shimmie version _d("TIMEZONE", null); // string timezone -_d("CORE_EXTS", "bbcode,user,mail,upload,image,view,handle_pixel,ext_manager,setup,upgrade,handle_404,handle_static,comment,tag_list,index,tag_edit,alias_editor,media,help_pages,system"); // extensions to always enable _d("EXTRA_EXTS", ""); // string optional extra extensions _d("BASE_URL", null); // string force a specific base URL (default is auto-detect) _d("MIN_PHP_VERSION", '7.1');// string minimum supported PHP version @@ -53,4 +52,3 @@ _d("ENABLED_MODS", "imageboard"); * directly, only the things they're built from */ _d("SCORE_VERSION", 'develop/'.VERSION); // string SCore version -_d("ENABLED_EXTS", CORE_EXTS.",".EXTRA_EXTS); diff --git a/ext/admin/info.php b/ext/admin/info.php new file mode 100644 index 00000000..84db9927 --- /dev/null +++ b/ext/admin/info.php @@ -0,0 +1,33 @@ + + * Link: http://code.shishnet.org/shimmie2/ + * License: GPLv2 + * Description: Various things to make admins' lives easier + * Documentation: + + */ + +class AdminPageInfo extends ExtensionInfo +{ + public const KEY = "admin"; + + public $key = self::KEY; + public $name = "Admin Controls"; + public $url = self::SHIMMIE_URL; + public $authors = self::SHISH_AUTHOR; + public $license = self::LICENSE_GPLV2; + public $description = "Various things to make admins' lives easier"; + public $documentation = +"Various moderate-level tools for admins; for advanced, obscure, and possibly dangerous tools see the shimmie2-utils script set +

Lowercase all tags: +
Set all tags to lowercase for consistency +

Recount tag use: +
If the counts of images per tag get messed up somehow, this will reset them, and remove any unused tags +

Database dump: +
Download the contents of the database in plain text format, useful for backups. +

Image dump: +
Download all the images as a .zip file (Requires ZipArchive)"; +} diff --git a/ext/admin/main.php b/ext/admin/main.php index 423460c8..dc9e9f63 100644 --- a/ext/admin/main.php +++ b/ext/admin/main.php @@ -1,24 +1,4 @@ - * Link: http://code.shishnet.org/shimmie2/ - * License: GPLv2 - * Description: Various things to make admins' lives easier - * Documentation: - * Various moderate-level tools for admins; for advanced, obscure, and - * possibly dangerous tools see the shimmie2-utils script set - *

Lowercase all tags: - *
Set all tags to lowercase for consistency - *

Recount tag use: - *
If the counts of images per tag get messed up somehow, this will - * reset them, and remove any unused tags - *

Database dump: - *
Download the contents of the database in plain text format, useful - * for backups. - *

Image dump: - *
Download all the images as a .zip file (Requires ZipArchive) - */ /** * Sent when the admin page is ready to be added to diff --git a/ext/admin/theme.php b/ext/admin/theme.php index 1abe6542..3ad3d6b7 100644 --- a/ext/admin/theme.php +++ b/ext/admin/theme.php @@ -60,7 +60,7 @@ class AdminPageTheme extends Themelet public function dbq_html($terms) { - if(ext_is_live("Trash")) { + if(Extension::is_enabled(TrashInfo::KEY)) { $warning = "This delete method will bypass the trash
"; } if (class_exists("ImageBan")) { diff --git a/ext/alias_editor/info.php b/ext/alias_editor/info.php new file mode 100644 index 00000000..4990ac6d --- /dev/null +++ b/ext/alias_editor/info.php @@ -0,0 +1,24 @@ + + * Link: http://code.shishnet.org/shimmie2/ + * License: GPLv2 + * Description: Edit the alias list + * Documentation: + */ + +class AliasEditorInfo extends ExtensionInfo +{ + public const KEY = "alias_editor"; + + public $key = self::KEY; + public $name = "Alias Editor"; + public $url = self::SHIMMIE_URL; + public $authors = self::SHISH_AUTHOR; + public $license = self::LICENSE_GPLV2; + public $description = "Edit the alias list"; + public $documentation = 'The list is visible at /alias/list; only site admins can edit it, other people can view and download it'; + public $core = true; +} diff --git a/ext/alias_editor/main.php b/ext/alias_editor/main.php index 36edbfbb..537b0e63 100644 --- a/ext/alias_editor/main.php +++ b/ext/alias_editor/main.php @@ -1,14 +1,4 @@ - * Link: http://code.shishnet.org/shimmie2/ - * License: GPLv2 - * Description: Edit the alias list - * Documentation: - * The list is visible at /alias/list; only - * site admins can edit it, other people can view and download it - */ class AddAliasEvent extends Event { diff --git a/ext/arrowkey_navigation/info.php b/ext/arrowkey_navigation/info.php new file mode 100644 index 00000000..ee6b88f2 --- /dev/null +++ b/ext/arrowkey_navigation/info.php @@ -0,0 +1,23 @@ + + * Link: http://www.drudexsoftware.com/ + * License: GPLv2 + * Description: Allows viewers no navigate between images using the left & right arrow keys. + * Documentation: + * Simply enable this extention in the extention manager to enable arrow key navigation. + */ +class ArrowkeyNavigationInfo extends ExtensionInfo +{ + public const KEY = "arrowkey_navigation"; + + public $key = self::KEY; + public $name = "Arrow Key Navigation"; + public $url = "http://www.drudexsoftware.com/"; + public $authors = ["Drudex Software"=>"support@drudexsoftware.com"]; + public $license = self::LICENSE_GPLV2; + public $description = "Allows viewers no navigate between images using the left & right arrow keys."; + public $documentation = +"Simply enable this extension in the extension manager to enable arrow key navigation."; +} diff --git a/ext/arrowkey_navigation/main.php b/ext/arrowkey_navigation/main.php index 209fbf04..640d2b12 100644 --- a/ext/arrowkey_navigation/main.php +++ b/ext/arrowkey_navigation/main.php @@ -1,13 +1,5 @@ - * Link: http://www.drudexsoftware.com/ - * License: GPLv2 - * Description: Allows viewers no navigate between images using the left & right arrow keys. - * Documentation: - * Simply enable this extention in the extention manager to enable arrow key navigation. - */ + class ArrowkeyNavigation extends Extension { /** diff --git a/ext/artists/info.php b/ext/artists/info.php new file mode 100644 index 00000000..5da88896 --- /dev/null +++ b/ext/artists/info.php @@ -0,0 +1,23 @@ + + * Alpha + * License: GPLv2 + * Description: Simple artists extension + * Documentation: + * + */ +class ArtistsInfo extends ExtensionInfo +{ + public const KEY = "artists"; + + public $key = self::KEY; + public $name = "Artists System"; + public $url = self::SHIMMIE_URL; + public $authors = ["Sein Kraft"=>"mail@seinkraft.info","Alpha"=>"alpha@furries.com.ar"]; + public $license = self::LICENSE_GPLV2; + public $description = "Simple artists extension"; + public $beta = true; +} diff --git a/ext/artists/main.php b/ext/artists/main.php index b1f6efcc..64d42acb 100644 --- a/ext/artists/main.php +++ b/ext/artists/main.php @@ -1,13 +1,5 @@ - * Alpha - * License: GPLv2 - * Description: Simple artists extension - * Documentation: - * - */ + class AuthorSetEvent extends Event { /** @var Image */ @@ -67,7 +59,7 @@ class Artists extends Extension public function onInitExt(InitExtEvent $event) { global $config, $database; - + if ($config->get_int("ext_artists_version") < 1) { $database->create_table("artists", " id SCORE_AIPK, @@ -78,7 +70,7 @@ class Artists extends Extension notes TEXT, FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE "); - + $database->create_table("artist_members", " id SCORE_AIPK, artist_id INTEGER NOT NULL, @@ -213,7 +205,7 @@ class Artists extends Extension $userIsLogged = !$user->is_anonymous(); $userIsAdmin = $user->is_admin(); - + $images = Image::find_images(0, 4, Tag::explode($artist['name'])); $this->theme->show_artist($artist, $aliases, $members, $urls, $images, $userIsLogged, $userIsAdmin); @@ -222,9 +214,9 @@ class Artists extends Extension //$this->theme->show_new_member_composer($artistID); //$this->theme->show_new_url_composer($artistID); } - + $this->theme->sidebar_options("editor", $artistID, $userIsAdmin); - + break; } @@ -235,10 +227,10 @@ class Artists extends Extension $aliases = $this->get_alias($artistID); $members = $this->get_members($artistID); $urls = $this->get_urls($artistID); - + if (!$user->is_anonymous()) { $this->theme->show_artist_editor($artist, $aliases, $members, $urls); - + $userIsAdmin = $user->is_admin(); $this->theme->sidebar_options("editor", $artistID, $userIsAdmin); } else { @@ -627,7 +619,7 @@ class Artists extends Extension $i++; } - + // if we have more ids than urls, then some urls have been deleted -- delete them from db while ($i < count($urlsIDsAsArray)) { $this->delete_url($urlsIDsAsArray[$i++]); @@ -746,7 +738,7 @@ class Artists extends Extension //delete double "separators" $urls = str_replace("\r\n", "\n", $urls); $urls = str_replace("\n\r", "\n", $urls); - + $urlsArray = explode("\n", $urls); foreach ($urlsArray as $url) { if (!$this->url_exists($artistID, $url)) { @@ -798,7 +790,7 @@ class Artists extends Extension "SELECT * FROM artist_members WHERE artist_id = ?", [$artistID] ); - + $num = count($result); for ($i = 0 ; $i < $num ; $i++) { $result[$i]["name"] = stripslashes($result[$i]["name"]); @@ -814,7 +806,7 @@ class Artists extends Extension "SELECT id, url FROM artist_urls WHERE artist_id = ?", [$artistID] ); - + $num = count($result); for ($i = 0 ; $i < $num ; $i++) { $result[$i]["url"] = stripslashes($result[$i]["url"]); @@ -850,7 +842,7 @@ class Artists extends Extension [$artistID] ); } - + /* * HERE WE GET THE LIST OF ALL ARTIST WITH PAGINATION */ @@ -914,7 +906,7 @@ class Artists extends Extension , $artistsPerPage ] ); - + $number_of_listings = count($listing); for ($i = 0 ; $i < $number_of_listings ; $i++) { @@ -936,7 +928,7 @@ class Artists extends Extension $this->theme->list_artists($listing, $pageNumber + 1, $totalPages); } - + /* * HERE WE ADD AN ALIAS */ diff --git a/ext/autocomplete/info.php b/ext/autocomplete/info.php new file mode 100644 index 00000000..3d420496 --- /dev/null +++ b/ext/autocomplete/info.php @@ -0,0 +1,17 @@ + + * Description: Adds autocomplete to search & tagging. + */ + +class AutoCompleteInfo extends ExtensionInfo +{ + public const KEY = "autocomplete"; + + public $key = self::KEY; + public $name = "Autocomplete"; + public $authors = ["Daku"=>"admin@codeanimu.net"]; + public $description = "Adds autocomplete to search & tagging."; +} diff --git a/ext/autocomplete/main.php b/ext/autocomplete/main.php index 187f45e5..80344672 100644 --- a/ext/autocomplete/main.php +++ b/ext/autocomplete/main.php @@ -1,9 +1,4 @@ - * Description: Adds autocomplete to search & tagging. - */ class AutoComplete extends Extension { diff --git a/ext/ban_words/info.php b/ext/ban_words/info.php new file mode 100644 index 00000000..6b56c045 --- /dev/null +++ b/ext/ban_words/info.php @@ -0,0 +1,36 @@ + + * Link: http://code.shishnet.org/shimmie2/ + * License: GPLv2 + * Description: For stopping spam and other comment abuse + * Documentation: + * + */ + +class BanWordsInfo extends ExtensionInfo +{ + public const KEY = "ban_words"; + + public $key = self::KEY; + public $name = "Comment Word Ban"; + public $url = self::SHIMMIE_URL; + public $authors = self::SHISH_AUTHOR; + public $license = self::LICENSE_GPLV2; + public $description = "For stopping spam and other comment abuse"; + public $documentation = +"Allows an administrator to ban certain words +from comments. This can be a very simple but effective way +of stopping spam; just add \"viagra\", \"porn\", etc to the +banned words list. +

Regex bans are also supported, allowing more complicated +bans like /http:.*\.cn\// to block links to +chinese websites, or /.*?http.*?http.*?http.*?http.*?/ +to block comments with four (or more) links in. +

Note that for non-regex matches, only whole words are +matched, eg banning \"sex\" would block the comment \"get free +sex call this number\", but allow \"This is a photo of Bob +from Essex\""; +} diff --git a/ext/ban_words/main.php b/ext/ban_words/main.php index 5e0761b3..c6f636a1 100644 --- a/ext/ban_words/main.php +++ b/ext/ban_words/main.php @@ -1,24 +1,4 @@ - * Link: http://code.shishnet.org/shimmie2/ - * License: GPLv2 - * Description: For stopping spam and other comment abuse - * Documentation: - * Allows an administrator to ban certain words - * from comments. This can be a very simple but effective way - * of stopping spam; just add "viagra", "porn", etc to the - * banned words list. - *

Regex bans are also supported, allowing more complicated - * bans like /http:.*\.cn\// to block links to - * chinese websites, or /.*?http.*?http.*?http.*?http.*?/ - * to block comments with four (or more) links in. - *

Note that for non-regex matches, only whole words are - * matched, eg banning "sex" would block the comment "get free - * sex call this number", but allow "This is a photo of Bob - * from Essex" - */ class BanWords extends Extension { diff --git a/ext/bbcode/info.php b/ext/bbcode/info.php new file mode 100644 index 00000000..06798aab --- /dev/null +++ b/ext/bbcode/info.php @@ -0,0 +1,40 @@ + + * Link: http://code.shishnet.org/shimmie2/ + * License: GPLv2 + * Description: Turns BBCode into HTML + */ + +class BBCodeInfo extends ExtensionInfo +{ + public const KEY = "bbcode"; + + public $key = self::KEY; + public $name = "BBCode"; + public $url = self::SHIMMIE_URL; + public $authors = self::SHISH_AUTHOR; + public $license = self::LICENSE_GPLV2; + public $core = true; + public $description = "Turns BBCode into HTML"; + public $documentation = +" Supported tags: +

"; +} diff --git a/ext/bbcode/main.php b/ext/bbcode/main.php index f7c834f3..fd6c7658 100644 --- a/ext/bbcode/main.php +++ b/ext/bbcode/main.php @@ -1,29 +1,5 @@ - * Link: http://code.shishnet.org/shimmie2/ - * License: GPLv2 - * Description: Turns BBCode into HTML - * Documentation: - * Supported tags: - * - */ + class BBCode extends FormatterExtension { diff --git a/ext/blocks/info.php b/ext/blocks/info.php new file mode 100644 index 00000000..23d24604 --- /dev/null +++ b/ext/blocks/info.php @@ -0,0 +1,21 @@ + + * Link: http://code.shishnet.org/shimmie2/ + * License: GPLv2 + * Description: Add HTML to some space (News, Ads, etc) + */ + +class BlocksInfo extends ExtensionInfo +{ + public const KEY = "blocks"; + + public $key = self::KEY; + public $name = "Generic Blocks"; + public $url = self::SHIMMIE_URL; + public $authors = self::SHISH_AUTHOR; + public $license = self::LICENSE_GPLV2; + public $description = "Add HTML to some space (News, Ads, etc)"; +} diff --git a/ext/blocks/main.php b/ext/blocks/main.php index 197b5d9f..b172f201 100644 --- a/ext/blocks/main.php +++ b/ext/blocks/main.php @@ -1,11 +1,4 @@ - * Link: http://code.shishnet.org/shimmie2/ - * License: GPLv2 - * Description: Add HTML to some space (News, Ads, etc) - */ class Blocks extends Extension { diff --git a/ext/blotter/info.php b/ext/blotter/info.php new file mode 100644 index 00000000..d03891ec --- /dev/null +++ b/ext/blotter/info.php @@ -0,0 +1,22 @@ + [http://seemslegit.com/] + * License: GPLv2 + * Description: + */ +class BlotterInfo extends ExtensionInfo +{ + public const KEY = "blotter"; + + public $key = self::KEY; + public $name = "Blotter"; + public $url = "http://seemslegit.com/"; + public $authors = ["Zach Hall"=>"zach@sosguy.net"]; + public $license = self::LICENSE_GPLV2; + public $description = "Displays brief updates about whatever you want on every page. +Colors and positioning can be configured to match your site's design. + +Development TODO at http://github.com/zshall/shimmie2/issues"; +} diff --git a/ext/blotter/main.php b/ext/blotter/main.php index 3e18b1a9..12f70fc7 100644 --- a/ext/blotter/main.php +++ b/ext/blotter/main.php @@ -1,13 +1,5 @@ [http://seemslegit.com/] - * License: GPLv2 - * Description: Displays brief updates about whatever you want on every page. - * Colors and positioning can be configured to match your site's design. - * - * Development TODO at http://github.com/zshall/shimmie2/issues - */ + class Blotter extends Extension { public function onInitExt(InitExtEvent $event) diff --git a/ext/browser_search/info.php b/ext/browser_search/info.php new file mode 100644 index 00000000..ba353e4c --- /dev/null +++ b/ext/browser_search/info.php @@ -0,0 +1,30 @@ + + * Some code (and lots of help) by Artanis (Erik Youngren ) from the 'tagger' extention - Used with permission + * Link: http://atravelinggeek.com/ + * License: GPLv2 + * Description: Allows the user to add a browser 'plugin' to search the site with real-time suggestions + * Version: 0.1c, October 26, 2007 + * Documentation: + * + */ + +class BrowserSearchInfo extends ExtensionInfo +{ + public const KEY = "browser_search"; + + public $key = self::KEY; + public $name = "Browser Search"; + public $url = "http://atravelinggeek.com/"; + public $authors = ["ATravelingGeek"=>"atg@atravelinggeek.com"]; + public $license = self::LICENSE_GPLV2; + public $version = "0.1c, October 26, 2007"; + public $description = "Allows the user to add a browser 'plugin' to search the site with real-time suggestions"; + public $documentation = +"Once installed, users with an opensearch compatible browser should see their search box light up with whatever \"click here to add a search engine\" notification they have + +Some code (and lots of help) by Artanis (Erik Youngren ) from the 'tagger' extension - Used with permission"; +} diff --git a/ext/browser_search/main.php b/ext/browser_search/main.php index 301ca0db..f29b5765 100644 --- a/ext/browser_search/main.php +++ b/ext/browser_search/main.php @@ -1,17 +1,4 @@ - * Some code (and lots of help) by Artanis (Erik Youngren ) from the 'tagger' extention - Used with permission - * Link: http://atravelinggeek.com/ - * License: GPLv2 - * Description: Allows the user to add a browser 'plugin' to search the site with real-time suggestions - * Version: 0.1c, October 26, 2007 - * Documentation: - * Once installed, users with an opensearch compatible browser should see - * their search box light up with whatever "click here to add a search - * engine" notification they have - */ class BrowserSearch extends Extension { diff --git a/ext/bulk_actions/info.php b/ext/bulk_actions/info.php new file mode 100644 index 00000000..00c66576 --- /dev/null +++ b/ext/bulk_actions/info.php @@ -0,0 +1,23 @@ +, contributions by Shish and Agasa. + */ + + +class BulkActionsInfo extends ExtensionInfo +{ + public const KEY = "bulk_actions"; + + public $key = self::KEY; + public $name = "Bulk Actions"; + public $authors = ["Matthew Barbour"=>"matthew@darkholme.net"]; + public $license = self::LICENSE_WTFPL; + public $description = "Provides query and selection-based bulk action support"; + public $documentation = "Provides bulk action section in list view. Allows performing actions against a set of images based on query or manual selection. Based on Mass Tagger by Christian Walde , contributions by Shish and Agasa."; +} diff --git a/ext/bulk_actions/main.php b/ext/bulk_actions/main.php index 0bfaf1da..9ccd5e74 100644 --- a/ext/bulk_actions/main.php +++ b/ext/bulk_actions/main.php @@ -1,13 +1,4 @@ , contributions by Shish and Agasa. - */ - class BulkActionBlockBuildingEvent extends Event { @@ -203,7 +194,7 @@ class BulkActions extends Extension { return $a["position"] - $b["position"]; } - + private function delete_items(iterable $items): int { $total = 0; diff --git a/ext/bulk_add/info.php b/ext/bulk_add/info.php new file mode 100644 index 00000000..333bf0ba --- /dev/null +++ b/ext/bulk_add/info.php @@ -0,0 +1,31 @@ + + * Link: http://code.shishnet.org/shimmie2/ + * License: GPLv2 + * Description: Bulk add server-side images + * Documentation: + */ + +class BulkAddInfo extends ExtensionInfo +{ + public const KEY = "builk_add"; + + public $key = self::KEY; + public $name = "Bulk Add"; + public $url = self::SHIMMIE_URL; + public $authors = self::SHISH_AUTHOR; + public $license = self::LICENSE_GPLV2; + public $description = "Bulk add server-side images"; + public $documentation = +" Upload the images into a new directory via ftp or similar, go to + shimmie's admin page and put that directory in the bulk add box. + If there are subdirectories, they get used as tags (eg if you + upload into /home/bob/uploads/holiday/2008/ and point + shimmie at /home/bob/uploads, then images will be + tagged \"holiday 2008\") +

Note: requires the \"admin\" extension to be enabled +"; +} diff --git a/ext/bulk_add/main.php b/ext/bulk_add/main.php index 0feaa87b..94a9b7f1 100644 --- a/ext/bulk_add/main.php +++ b/ext/bulk_add/main.php @@ -1,19 +1,4 @@ - * Link: http://code.shishnet.org/shimmie2/ - * License: GPLv2 - * Description: Bulk add server-side images - * Documentation: - * Upload the images into a new directory via ftp or similar, go to - * shimmie's admin page and put that directory in the bulk add box. - * If there are subdirectories, they get used as tags (eg if you - * upload into /home/bob/uploads/holiday/2008/ and point - * shimmie at /home/bob/uploads, then images will be - * tagged "holiday 2008") - *

Note: requires the "admin" extension to be enabled - */ class BulkAddEvent extends Event { diff --git a/ext/bulk_add_csv/info.php b/ext/bulk_add_csv/info.php new file mode 100644 index 00000000..a2e6af69 --- /dev/null +++ b/ext/bulk_add_csv/info.php @@ -0,0 +1,34 @@ + + * License: GPLv2 + * Description: Bulk add server-side images with metadata from CSV file + * Documentation: + * + * + */ + +class BulkAddCSVInfo extends ExtensionInfo +{ + public const KEY = "bulk_add_csv"; + + public $key = self::KEY; + public $name = "Bulk Add CSV"; + public $url = self::SHIMMIE_URL; + public $authors = ["velocity37"=>"velocity37@gmail.com"]; + public $license = self::LICENSE_GPLV2; + public $description = "Bulk add server-side images with metadata from CSV file"; + public $documentation = +"Modification of \"Bulk Add\" by Shish.

+Adds images from a CSV with the five following values:
+\"/path/to/image.jpg\",\"spaced tags\",\"source\",\"rating s/q/e\",\"/path/thumbnail.jpg\"
+e.g. \"/tmp/cat.png\",\"shish oekaki\",\"shimmie.shishnet.org\",\"s\",\"tmp/custom.jpg\"

+Any value but the first may be omitted, but there must be five values per line.
+e.g. \"/why/not/try/bulk_add.jpg\",\"\",\"\",\"\",\"\"

+Image thumbnails will be displayed at the AR of the full image. Thumbnails that are +normally static (e.g. SWF) will be displayed at the board's max thumbnail size

+Useful for importing tagged images without having to do database manipulation.
+

Note: requires \"Admin Controls\" and optionally \"Image Ratings\" to be enabled

"; +} diff --git a/ext/bulk_add_csv/main.php b/ext/bulk_add_csv/main.php index d1648a7d..a567c1ca 100644 --- a/ext/bulk_add_csv/main.php +++ b/ext/bulk_add_csv/main.php @@ -1,22 +1,4 @@ - * License: GPLv2 - * Description: Bulk add server-side images with metadata from CSV file - * Documentation: - * Modification of "Bulk Add" by Shish.

- * Adds images from a CSV with the five following values:
- * "/path/to/image.jpg","spaced tags","source","rating s/q/e","/path/thumbnail.jpg"
- * e.g. "/tmp/cat.png","shish oekaki","shimmie.shishnet.org","s","tmp/custom.jpg"

- * Any value but the first may be omitted, but there must be five values per line.
- * e.g. "/why/not/try/bulk_add.jpg","","","",""

- * Image thumbnails will be displayed at the AR of the full image. Thumbnails that are - * normally static (e.g. SWF) will be displayed at the board's max thumbnail size

- * Useful for importing tagged images without having to do database manipulation.
- *

Note: requires "Admin Controls" and optionally "Image Ratings" to be enabled

- * - */ class BulkAddCSV extends Extension { @@ -40,7 +22,7 @@ class BulkAddCSV extends Extension } if ($event->cmd == "bulk-add-csv") { global $user; - + //Nag until CLI is admin by default if (!$user->is_admin()) { print "Not running as an admin, which can cause problems.\n"; @@ -96,11 +78,11 @@ class BulkAddCSV extends Extension $this->theme->add_status("Error", "$csvfile doesn't appear to be a csv file"); return; } - + $linenum = 1; $list = ""; $csvhandle = fopen($csvfile, "r"); - + while (($csvdata = fgetcsv($csvhandle, 0, ",")) !== false) { if (count($csvdata) != 5) { if (strlen($list) > 0) { @@ -133,7 +115,7 @@ class BulkAddCSV extends Extension } $linenum += 1; } - + if (strlen($list) > 0) { $this->theme->add_status("Adding $csvfile", $list); } diff --git a/ext/bulk_remove/info.php b/ext/bulk_remove/info.php new file mode 100644 index 00000000..7f90b825 --- /dev/null +++ b/ext/bulk_remove/info.php @@ -0,0 +1,23 @@ + + * Link: http://www.drudexsoftware.com/ + * License: GPLv2 + * Description: Allows admin to delete many images at once through Board Admin. + * Documentation: + * + */ +class BulkRemoveInfo extends ExtensionInfo +{ + public const KEY = "bulk_remove"; + + public $key = self::KEY; + public $name = "Bulk Remove"; + public $beta = true; + public $url = "http://www.drudexsoftware.com/"; + public $authors = ["Drudex Software"=>"support@drudexsoftware.com"]; + public $license = self::LICENSE_GPLV2; + public $description = "Allows admin to delete many images at once through Board Admin."; +} diff --git a/ext/bulk_remove/main.php b/ext/bulk_remove/main.php index 75da254b..0509d616 100644 --- a/ext/bulk_remove/main.php +++ b/ext/bulk_remove/main.php @@ -1,13 +1,5 @@ - * Link: http://www.drudexsoftware.com/ - * License: GPLv2 - * Description: Allows admin to delete many images at once through Board Admin. - * Documentation: - * - */ + //todo: removal by tag returns 1 less image in test for some reason, actually a combined search doesn't seem to work for shit either class BulkRemove extends Extension @@ -23,7 +15,7 @@ class BulkRemove extends Extension } } } - + public function onAdminBuilding(AdminBuildingEvent $event) { global $page; @@ -55,12 +47,12 @@ class BulkRemove extends Extension // set vars $images_for_removal = []; $error = ""; - + $min_id = $_POST['remove_id_min']; $max_id = $_POST['remove_id_max']; $tags = $_POST['remove_tags']; - - + + // if using id range to remove (comined removal with tags) if ($min_id != "" && $max_id != "") { // error if values are not correctly entered @@ -68,46 +60,46 @@ class BulkRemove extends Extension intval($max_id) < intval($min_id)) { $error = "Values not correctly entered for removal between id."; } else { // if min & max id are valid - + // Grab the list of images & place it in the removing array foreach (Image::find_images(intval($min_id), intval($max_id)) as $image) { array_push($images_for_removal, $image); } } } - + // refine previous results or create results from tags if ($tags != "") { $tags_arr = explode(" ", $_POST['remove_tags']); - + // Search all images with the specified tags & add to list foreach (Image::find_images(1, 2147483647, $tags_arr) as $image) { array_push($images_for_removal, $image); } } - - + + // if no images were found with the given info if (count($images_for_removal) == 0) { $error = "No images selected for removal"; } - + //var_dump($tags_arr); return [ "error" => $error, "images_for_removal" => $images_for_removal]; } - + // displays confirmation to admin before removal private function show_confirm() { global $page; - + // set vars $determined_imgs = $this->determine_images(); $error = $determined_imgs["error"]; $images_for_removal = $determined_imgs["images_for_removal"]; - + // if there was an error in determine_images() if ($error != "") { $page->add_block(new Block("Cannot remove images", $error)); @@ -115,14 +107,14 @@ class BulkRemove extends Extension } // generates the image array & places it in $_POST["bulk_remove_images"] $_POST["bulk_remove_images"] = $images_for_removal; - + // Display confirmation message $html = make_form(make_link("bulk_remove")). "Are you sure you want to PERMANENTLY remove ". count($images_for_removal) ." images?
"; $page->add_block(new Block("Confirm Removal", $html)); } - + private function do_bulk_remove() { global $page; @@ -133,7 +125,7 @@ class BulkRemove extends Extension "Please use Board Admin to use bulk remove." )); } - + // $image_arr = $_POST["bulk_remove_images"]; } diff --git a/ext/comment/info.php b/ext/comment/info.php new file mode 100644 index 00000000..600d1eab --- /dev/null +++ b/ext/comment/info.php @@ -0,0 +1,25 @@ + + * Link: http://code.shishnet.org/shimmie2/ + * License: GPLv2 + * Description: Allow users to make comments on images + * Documentation: + * Formatting is done with the standard formatting API (normally BBCode) + */ + +class CommentListInfo extends ExtensionInfo +{ + public const KEY = "comment"; + + public $key = self::KEY; + public $name = "Image Comments"; + public $url = self::SHIMMIE_URL; + public $authors = self::SHISH_AUTHOR; + public $license = self::LICENSE_GPLV2; + public $description = "Allow users to make comments on images"; + public $documentation = "Formatting is done with the standard formatting API (normally BBCode)"; + public $core = true; +} diff --git a/ext/comment/main.php b/ext/comment/main.php index f58a3076..619f355e 100644 --- a/ext/comment/main.php +++ b/ext/comment/main.php @@ -1,13 +1,4 @@ - * Link: http://code.shishnet.org/shimmie2/ - * License: GPLv2 - * Description: Allow users to make comments on images - * Documentation: - * Formatting is done with the standard formatting API (normally BBCode) - */ require_once "vendor/ifixit/php-akismet/akismet.class.php"; @@ -382,7 +373,7 @@ class CommentList extends Extension global $database, $user; $where = SPEED_HAX ? "WHERE posted > now() - interval '24 hours'" : ""; - + $total_pages = $database->cache->get("comment_pages"); if (empty($total_pages)) { $total_pages = (int)($database->get_one(" @@ -394,7 +385,7 @@ class CommentList extends Extension $total_pages = max($total_pages, 1); $current_page = clamp($current_page, 1, $total_pages); - + $threads_per_page = 10; $start = $threads_per_page * ($current_page - 1); @@ -407,13 +398,13 @@ class CommentList extends Extension LIMIT :limit OFFSET :offset ", ["limit"=>$threads_per_page, "offset"=>$start]); - $user_ratings = ext_is_live("Ratings") ? Ratings::get_user_privs($user) : ""; + $user_ratings = Extension::is_enabled(RatingsInfo::KEY) ? Ratings::get_user_privs($user) : ""; $images = []; while ($row = $result->fetch()) { $image = Image::by_id($row["image_id"]); if ( - ext_is_live("Ratings") && !is_null($image) && + Extension::is_enabled(RatingsInfo::KEY) && !is_null($image) && strpos($user_ratings, $image->rating) === false ) { $image = null; // this is "clever", I may live to regret it diff --git a/ext/cron_uploader/info.php b/ext/cron_uploader/info.php new file mode 100644 index 00000000..138d1565 --- /dev/null +++ b/ext/cron_uploader/info.php @@ -0,0 +1,28 @@ +, Matthew Barbour + * Link: http://www.yaoifox.com/ + * License: GPLv2 + * Description: Uploads images automatically using Cron Jobs + * Documentation: Installation guide: activate this extension and navigate to www.yoursite.com/cron_upload + */ + +class CronUploaderInfo extends ExtensionInfo +{ + public const KEY = "cron_uploader"; + + public $key = self::KEY; + public $name = "Cron Uploader"; + public $url = self::SHIMMIE_URL; + public $authors = ["YaoiFox"=>"admin@yaoifox.com", "Matthew Barbour"=>"matthew@darkholme.net"]; + public $license = self::LICENSE_GPLV2; + public $description = "Uploads images automatically using Cron Jobs"; + + public function __construct() + { + $this->documentation = "Installation guide: activate this extension and navigate to System Config screen."; + parent::__construct(); + } +} diff --git a/ext/cron_uploader/main.php b/ext/cron_uploader/main.php index 99ed9697..0d97e522 100644 --- a/ext/cron_uploader/main.php +++ b/ext/cron_uploader/main.php @@ -1,13 +1,5 @@ , Matthew Barbour - * Link: http://www.yaoifox.com/ - * License: GPLv2 - * Description: Uploads images automatically using Cron Jobs - * Documentation: Installation guide: activate this extension and navigate to www.yoursite.com/cron_upload - */ class CronUploader extends Extension { diff --git a/ext/custom_html_headers/info.php b/ext/custom_html_headers/info.php new file mode 100644 index 00000000..fec79af6 --- /dev/null +++ b/ext/custom_html_headers/info.php @@ -0,0 +1,30 @@ + + * Link: http://www.drudexsoftware.com + * License: GPLv2 + * Description: Allows admins to modify & set custom <head> content + * Documentation: + * + */ +class custom_html_headersInfo extends ExtensionInfo +{ + public const KEY = "custom_html_headers"; + + public $key = self::KEY; + public $name = "Custom HTML Headers"; + public $url = "http://www.drudexsoftware.com"; + public $authors = ["Drudex Software"=>"support@drudexsoftware.com"]; + public $license = self::LICENSE_GPLV2; + public $description = "Allows admins to modify & set custom <head> content"; + public $documentation = +"When you go to board config you can find a block named Custom HTML Headers. +In that block you can simply place any thing you can place within <head></head> + +This can be useful if you want to add website tracking code or other javascript. +NOTE: Only use if you know what you're doing. + +You can also add your website name as prefix or suffix to the title of each page on your website."; +} diff --git a/ext/custom_html_headers/main.php b/ext/custom_html_headers/main.php index 58715e9b..05bf22fb 100644 --- a/ext/custom_html_headers/main.php +++ b/ext/custom_html_headers/main.php @@ -1,19 +1,5 @@ - * Link: http://www.drudexsoftware.com - * License: GPLv2 - * Description: Allows admins to modify & set custom <head> content - * Documentation: - * When you go to board config you can find a block named Custom HTML Headers. - * In that block you can simply place any thing you can place within <head></head> - * - * This can be useful if you want to add website tracking code or other javascript. - * NOTE: Only use if you know what you're doing. - * - * You can also add your website name as prefix or suffix to the title of each page on your website. - */ + class custom_html_headers extends Extension { # Adds setup block for custom content @@ -36,38 +22,38 @@ class custom_html_headers extends Extension $event->panel->add_block($sb); } - + public function onInitExt(InitExtEvent $event) { global $config; $config->set_default_int("sitename_in_title", 0); } - + # Load Analytics tracking code on page request public function onPageRequest(PageRequestEvent $event) { $this->handle_custom_html_headers(); $this->handle_modified_page_title(); } - + private function handle_custom_html_headers() { global $config, $page; - + $header = $config->get_string('custom_html_headers', ''); if ($header!='') { $page->add_html_header($header); } } - + private function handle_modified_page_title() { global $config, $page; - + // get config values $site_title = $config->get_string(SetupConfig::TITLE); $sitename_in_title = $config->get_int("sitename_in_title"); - + // if feature is enabled & sitename isn't already in title // (can occur on index & other pages) if ($sitename_in_title != 0 && !strstr($page->title, $site_title)) { diff --git a/ext/danbooru_api/info.php b/ext/danbooru_api/info.php new file mode 100644 index 00000000..89047d3b --- /dev/null +++ b/ext/danbooru_api/info.php @@ -0,0 +1,61 @@ + +Description: Allow Danbooru apps like Danbooru Uploader for Firefox to communicate with Shimmie +Documentation: + +*/ + +class DanbooruApiInfo extends ExtensionInfo +{ + public const KEY = "danbooru_api"; + + public $key = self::KEY; + public $name = "Danbooru Client API"; + public $authors = ["JJS"=>"jsutinen@gmail.com"]; + public $description = "Allow Danbooru apps like Danbooru Uploader for Firefox to communicate with Shimmie"; + public $documentation = +"

Notes: +
danbooru API based on documentation from danbooru 1.0 - + http://attachr.com/7569 +
I've only been able to test add_post and find_tags because I use the + old danbooru firefox extension for firefox 1.5 +

Functions currently implemented: +

    +
  • add_post - title and rating are currently ignored because shimmie does not support them +
  • find_posts - sort of works, filename is returned as the original filename and probably won't help when it comes to actually downloading it +
  • find_tags - id, name, and after_id all work but the tags parameter is ignored just like danbooru 1.0 ignores it +
+ +CHANGELOG +13-OCT-08 8:00PM CST - JJS +Bugfix - Properly escape source attribute + +17-SEP-08 10:00PM CST - JJS +Bugfix for changed page name checker in PageRequestEvent + +13-APR-08 10:00PM CST - JJS +Properly escape the tags returned in find_tags and find_posts - Caught by ATravelingGeek +Updated extension info to be a bit more clear about its purpose +Deleted add_comment code as it didn't do anything anyway + +01-MAR-08 7:00PM CST - JJS +Rewrote to make it compatible with Shimmie trunk again (r723 at least) +It may or may not support the new file handling stuff correctly, I'm only testing with images and the danbooru uploader for firefox + +21-OCT-07 9:07PM CST - JJS +Turns out I actually did need to implement the new parameter names +for danbooru api v1.8.1. Now danbooruup should work when used with /api/danbooru/post/create.xml +Also correctly redirects the url provided by danbooruup in the event +of a duplicate image. + +19-OCT-07 4:46PM CST - JJS +Add compatibility with danbooru api v1.8.1 style urls +for find_posts and add_post. NOTE: This does not implement +the changes to the parameter names, it is simply a +workaround for the latest danbooruup firefox extension. +Completely compatibility will probably involve a rewrite with a different URL +"; +} diff --git a/ext/danbooru_api/main.php b/ext/danbooru_api/main.php index cb55766f..75a4a535 100644 --- a/ext/danbooru_api/main.php +++ b/ext/danbooru_api/main.php @@ -1,51 +1,4 @@ -Description: Allow Danbooru apps like Danbooru Uploader for Firefox to communicate with Shimmie -Documentation: -

Notes: -
danbooru API based on documentation from danbooru 1.0 - - http://attachr.com/7569 -
I've only been able to test add_post and find_tags because I use the - old danbooru firefox extension for firefox 1.5 -

Functions currently implemented: -

    -
  • add_post - title and rating are currently ignored because shimmie does not support them -
  • find_posts - sort of works, filename is returned as the original filename and probably won't help when it comes to actually downloading it -
  • find_tags - id, name, and after_id all work but the tags parameter is ignored just like danbooru 1.0 ignores it -
- -CHANGELOG -13-OCT-08 8:00PM CST - JJS -Bugfix - Properly escape source attribute - -17-SEP-08 10:00PM CST - JJS -Bugfix for changed page name checker in PageRequestEvent - -13-APR-08 10:00PM CST - JJS -Properly escape the tags returned in find_tags and find_posts - Caught by ATravelingGeek -Updated extension info to be a bit more clear about its purpose -Deleted add_comment code as it didn't do anything anyway - -01-MAR-08 7:00PM CST - JJS -Rewrote to make it compatible with Shimmie trunk again (r723 at least) -It may or may not support the new file handling stuff correctly, I'm only testing with images and the danbooru uploader for firefox - -21-OCT-07 9:07PM CST - JJS -Turns out I actually did need to implement the new parameter names -for danbooru api v1.8.1. Now danbooruup should work when used with /api/danbooru/post/create.xml -Also correctly redirects the url provided by danbooruup in the event -of a duplicate image. - -19-OCT-07 4:46PM CST - JJS -Add compatibility with danbooru api v1.8.1 style urls -for find_posts and add_post. NOTE: This does not implement -the changes to the parameter names, it is simply a -workaround for the latest danbooruup firefox extension. -Completely compatibility will probably involve a rewrite with a different URL - -*/ class DanbooruApi extends Extension { diff --git a/ext/downtime/info.php b/ext/downtime/info.php new file mode 100644 index 00000000..fd8df943 --- /dev/null +++ b/ext/downtime/info.php @@ -0,0 +1,28 @@ + + * Link: http://code.shishnet.org/shimmie2/ + * License: GPLv2 + * Description: Show a "down for maintenance" page + * Documentation: + * + */ + +class DowntimeInfo extends ExtensionInfo +{ + public const KEY = "downtime"; + + public $key = self::KEY; + public $name = "Downtime"; + public $url = self::SHIMMIE_URL; + public $authors = self::SHISH_AUTHOR; + public $license = self::LICENSE_GPLV2; + public $description = "Show a \"down for maintenance\" page"; + public $documentation = +"Once installed there will be some more options on the config page -- +Ticking \"disable non-admin access\" will mean that regular and anonymous +users will be blocked from accessing the site, only able to view the +message specified in the box."; +} diff --git a/ext/downtime/main.php b/ext/downtime/main.php index 97f8682e..979b119f 100644 --- a/ext/downtime/main.php +++ b/ext/downtime/main.php @@ -1,16 +1,4 @@ - * Link: http://code.shishnet.org/shimmie2/ - * License: GPLv2 - * Description: Show a "down for maintenance" page - * Documentation: - * Once installed there will be some more options on the config page -- - * Ticking "disable non-admin access" will mean that regular and anonymous - * users will be blocked from accessing the site, only able to view the - * message specified in the box. - */ class Downtime extends Extension { diff --git a/ext/emoticons/info.php b/ext/emoticons/info.php new file mode 100644 index 00000000..0e48a602 --- /dev/null +++ b/ext/emoticons/info.php @@ -0,0 +1,29 @@ + + * Link: http://code.shishnet.org/shimmie2/ + * License: GPLv2 + * Description: Lets users use graphical smilies + * Documentation: + * + */ + +class EmoticonsInfo extends ExtensionInfo +{ + public const KEY = "emoticons"; + + public $key = self::KEY; + public $name = "Emoticon Filter"; + public $url = self::SHIMMIE_URL; + public $authors = self::SHISH_AUTHOR; + public $license = self::LICENSE_GPLV2; + public $description = "Lets users use graphical smilies"; + public $documentation = +"This extension will turn colon-something-colon into a link +to an image with that something as the name, eg :smile: +becomes a link to smile.gif +

Images are stored in /ext/emoticons/default/, and you can +add more emoticons by uploading images into that folder."; +} diff --git a/ext/emoticons/main.php b/ext/emoticons/main.php index 37d48d73..b3514425 100644 --- a/ext/emoticons/main.php +++ b/ext/emoticons/main.php @@ -1,17 +1,5 @@ - * Link: http://code.shishnet.org/shimmie2/ - * License: GPLv2 - * Description: Lets users use graphical smilies - * Documentation: - * This extension will turn colon-something-colon into a link - * to an image with that something as the name, eg :smile: - * becomes a link to smile.gif - *

Images are stored in /ext/emoticons/default/, and you can - * add more emoticons by uploading images into that folder. - */ + /** * Class Emoticons diff --git a/ext/et/info.php b/ext/et/info.php new file mode 100644 index 00000000..3245f10c --- /dev/null +++ b/ext/et/info.php @@ -0,0 +1,25 @@ + + * License: GPLv2 + * Description: Show various bits of system information + * Documentation: + */ + +class ETInfo extends ExtensionInfo +{ + public const KEY = "et"; + + public $key = self::KEY; + public $name = "System Info"; + public $url = self::SHIMMIE_URL; + public $authors = self::SHISH_AUTHOR; + public $license = self::LICENSE_GPLV2; + public $description = "Show various bits of system information"; + public $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."; +} diff --git a/ext/et/main.php b/ext/et/main.php index 576765dd..f4f058d4 100644 --- a/ext/et/main.php +++ b/ext/et/main.php @@ -1,16 +1,4 @@ - * License: GPLv2 - * 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 { diff --git a/ext/ext_manager/info.php b/ext/ext_manager/info.php new file mode 100644 index 00000000..80ade6e9 --- /dev/null +++ b/ext/ext_manager/info.php @@ -0,0 +1,26 @@ + + * Link: http://code.shishnet.org/shimmie2/ + * License: GPLv2 + * Visibility: admin + * Description: A thing for point & click extension management + * Documentation: + */ + +class ExtManagerInfo extends ExtensionInfo +{ + public const KEY = "ext_manager"; + + public $key = self::KEY; + public $name = "Extension Manager"; + public $url = self::SHIMMIE_URL; + public $authors = self::SHISH_AUTHOR; + public $license = self::LICENSE_GPLV2; + public $visibility = self::VISIBLE_ADMIN; + public $description = "A thing for point & click extension management"; + public $documentation = "Allows the admin to view a list of all extensions and enable or disable them; also allows users to view the list of activated extensions and read their documentation"; + public $core = true; +} diff --git a/ext/ext_manager/main.php b/ext/ext_manager/main.php index 2af52b42..acb51ca3 100644 --- a/ext/ext_manager/main.php +++ b/ext/ext_manager/main.php @@ -1,134 +1,22 @@ - * Link: http://code.shishnet.org/shimmie2/ - * License: GPLv2 - * Visibility: admin - * Description: A thing for point & click extension management - * Documentation: - * Allows the admin to view a list of all extensions and enable or - * disable them; also allows users to view the list of activated - * extensions and read their documentation - */ -function __extman_extcmp(ExtensionManagerInfo $a, ExtensionManagerInfo $b): int + +function __extman_extcmp(ExtensionInfo $a, ExtensionInfo $b): int { + if($a->beta===true&&$b->beta===false) + return 1; + if($a->beta===false&&$b->beta===true) + return -1; + return strcmp($a->name, $b->name); } -class ExtensionManagerInfo +function __extman_extactive(ExtensionInfo $a): bool { - public $ext_name; - public $name; - public $link; - public $authors; - public $description; - public $documentation; - public $version; - public $visibility; - public $enabled; - public $supported; - - public function __construct($main) - { - $matches = []; - preg_match("#ext/(.*)/main.php#", $main, $matches); - $this->ext_name = $matches[1]; - $this->name = $this->ext_name; - $this->enabled = $this->is_enabled($this->ext_name); - - if(file_exists("ext/{$this->ext_name}/info.php")) { - include_once "ext/{$this->ext_name}/info.php"; - $class = get_class_from_file("ext/{$this->ext_name}/info.php"); - $info = new $class(); - - $this->name = $info->name; - $this->link = $info->link; - foreach ($info->authors as $key=>$value){ - $this->authors[] = new ExtensionAuthor($key, $value); - } - $this->description = $info->description; - $this->documentation = $info->documentation; - $this->version = $info->version; - $this->visibility = $info->visibility; - $this->supported = $info->supported; - } else { - $this->authors = []; - - $handle = fopen($main, "r"); - if ($handle === null) { - throw new Exception("Could not open extension file $main"); - } - try { - $line = fgets($handle); - - while ($line !== false) { - if (preg_match("/Name: (.*)/", $line, $matches)) { - $this->name = $matches[1]; - } elseif (preg_match("/Visibility: (.*)/", $line, $matches)) { - $this->visibility = $matches[1]; - } elseif (preg_match("/Link: (.*)/", $line, $matches)) { - $this->link = $matches[1]; - if ($this->link[0] == "/") { - $this->link = make_link(substr($this->link, 1)); - } - } elseif (preg_match("/Version: (.*)/", $line, $matches)) { - $this->version = $matches[1]; - } elseif (preg_match("/Authors?: (.*)/", $line, $matches)) { - $author_list = explode(',', $matches[1]); - foreach ($author_list as $author) { - if (preg_match("/(.*) [<\(](.*@.*)[>\)]/", $author, $matches)) { - $this->authors[] = new ExtensionAuthor($matches[1], $matches[2]); - } else { - $this->authors[] = new ExtensionAuthor($author, null); - } - } - } elseif (preg_match("/(.*)Description: ?(.*)/", $line, $matches)) { - $this->description = $matches[2]; - $start = $matches[1] . " "; - $start_len = strlen($start); - while (($line = fgets($handle)) !== false && - substr($line, 0, $start_len) == $start) { - $this->description .= " " . substr($line, $start_len); - } - continue; - } elseif (preg_match("/(.*)Documentation: ?(.*)/", $line, $matches)) { - $this->documentation = $matches[2]; - $start = $matches[1] . " "; - $start_len = strlen($start); - while (($line = fgets($handle)) !== false && - substr($line, 0, $start_len) == $start) { - $this->documentation .= " " . substr($line, $start_len); - } - $this->documentation = str_replace('$site', make_http(get_base_href()), $this->documentation); - continue; - } elseif (preg_match("/\*\//", $line, $matches)) { - break; - } - $line = fgets($handle); - } - } finally { - fclose($handle); - } - } - } - - private function is_enabled(string $fname): ?bool - { - $core = explode(",", CORE_EXTS); - $extra = explode(",", EXTRA_EXTS); - - if (in_array($fname, $extra)) { - return true; - } // enabled - if (in_array($fname, $core)) { - return null; - } // core - return false; // not enabled - } + return Extension::is_enabled($a->key); } + class ExtensionAuthor { public $name; @@ -172,7 +60,7 @@ class ExtManager extends Extension if ($event->page_matches("ext_doc")) { $ext = $event->get_arg(0); if (file_exists("ext/$ext/info.php")) { - $info = new ExtensionManagerInfo("ext/$ext/main.php"); + $info = ExtensionInfo::get_by_key($ext); $this->theme->display_doc($page, $info); } else { $this->theme->display_table($page, $this->get_extensions(false), false); @@ -218,14 +106,9 @@ class ExtManager extends Extension */ private function get_extensions(bool $all): array { - $extensions = []; - if ($all) { - $exts = zglob("ext/*/main.php"); - } else { - $exts = zglob("ext/{" . ENABLED_EXTS . "}/main.php"); - } - foreach ($exts as $main) { - $extensions[] = new ExtensionManagerInfo($main); + $extensions = ExtensionInfo::get_all(); + if (!$all) { + $extensions = array_filter($extensions,"__extman_extactive"); } usort($extensions, "__extman_extcmp"); return $extensions; @@ -233,16 +116,13 @@ class ExtManager extends Extension private function set_things($settings) { - $core = explode(",", CORE_EXTS); + $core = ExtensionInfo::get_core_extensions(); $extras = []; - foreach (glob("ext/*/main.php") as $main) { + foreach (ExtensionInfo::get_all_keys() as $key) { $matches = []; - preg_match("#ext/(.*)/main.php#", $main, $matches); - $fname = $matches[1]; - - if (!in_array($fname, $core) && isset($settings["ext_$fname"])) { - $extras[] = $fname; + if (!in_array($key, $core) && isset($settings["ext_$key"])) { + $extras[] = $key; } } diff --git a/ext/ext_manager/theme.php b/ext/ext_manager/theme.php index fcf8b64a..0c1702be 100644 --- a/ext/ext_manager/theme.php +++ b/ext/ext_manager/theme.php @@ -26,24 +26,24 @@ class ExtManagerTheme extends Themelet continue; } - $h_name = html_escape(empty($extension->name) ? $extension->ext_name : $extension->name); + $h_name = html_escape(($extension->beta===true ? "[BETA] ":"").(empty($extension->name) ? $extension->key : $extension->name)); $h_description = html_escape($extension->description); - $h_link = make_link("ext_doc/" . url_escape($extension->ext_name)); + $h_link = make_link("ext_doc/" . url_escape($extension->key)); - $h_enabled = ($extension->enabled === true ? " checked='checked'" : ($extension->enabled === false ? "" : " checked='checked'")); - $h_disabled = ($extension->supported===false || $extension->enabled===null? " disabled ": " " ); + $h_enabled = ($extension->is_enabled() === true ? " checked='checked'" : ""); + $h_disabled = ($extension->is_supported()===false || $extension->core===true? " disabled ": " " ); //baseline_open_in_new_black_18dp.png - $h_enabled_box = $editable ? "" : ""; + $h_enabled_box = $editable ? "" : ""; $h_docs = ($extension->documentation ? "â– " : ""); //TODO: A proper "docs" symbol would be preferred here. $html .= " - + {$h_enabled_box} - + {$h_docs} - {$h_description} " .($extension->supported===false ? "Database not supported" : ""). " + {$h_description} ".$extension->get_support_info()." "; } $h_set = $editable ? "" : ""; @@ -66,16 +66,16 @@ class ExtManagerTheme extends Themelet $col_1 = ""; $col_2 = ""; foreach($extensions as $extension) { - $ext_name = $extension->ext_name; + $ext_name = $extension->name; $h_name = empty($extension->name) ? $ext_name : html_escape($extension->name); $h_email = html_escape($extension->email); $h_link = isset($extension->link) ? "link)."\">Original Site" : ""; $h_doc = isset($extension->documentation) ? - "ext_name))."\">Documentation" : ""; + "name))."\">Documentation" : ""; $h_author = html_escape($extension->author); $h_description = html_escape($extension->description); - $h_enabled = $extension->enabled ? " checked='checked'" : ""; + $h_enabled = $extension->is_enabled() ? " checked='checked'" : ""; $h_author_link = empty($h_email) ? "$h_author" : "$h_author"; @@ -118,7 +118,7 @@ class ExtManagerTheme extends Themelet } */ - public function display_doc(Page $page, ExtensionManagerInfo $info) + public function display_doc(Page $page, ExtensionInfo $info) { $author = ""; if (count($info->authors) > 0) { @@ -127,12 +127,13 @@ class ExtManagerTheme extends Themelet $author .= "s"; } $author .= ":"; - foreach ($info->authors as $auth) { - if (!empty($auth->email)) { - $author .= "email) . "\">" . html_escape($auth->name) . ""; + foreach ($info->authors as $auth=>$email) { + if (!empty($email)) { + $author .= "" . html_escape($auth) . ""; } else { - $author .= html_escape($auth->name); + $author .= html_escape($auth); } + $author .= "
"; } } diff --git a/ext/favorites/info.php b/ext/favorites/info.php new file mode 100644 index 00000000..0e49b8d1 --- /dev/null +++ b/ext/favorites/info.php @@ -0,0 +1,25 @@ + + * License: GPLv2 + * Description: Allow users to favorite images + * Documentation: + */ + +class FavoritesInfo extends ExtensionInfo +{ + public const KEY = "favorites"; + + public $key = self::KEY; + public $name = "Favorites"; + public $authors = ["Daniel Marschall"=>"info@daniel-marschall.de"]; + public $license = self::LICENSE_GPLV2; + public $description = "Allow users to favorite images"; + public $documentation = +"Gives users a \"favorite this image\" button that they can press +

Favorites for a user can then be retrieved by searching for \"favorited_by=UserName\" +

Popular images can be searched for by eg. \"favorites>5\" +

Favorite info can be added to an image's filename or tooltip using the \$favorites placeholder"; +} diff --git a/ext/favorites/main.php b/ext/favorites/main.php index 950d6178..03d93a3e 100644 --- a/ext/favorites/main.php +++ b/ext/favorites/main.php @@ -1,17 +1,4 @@ - * License: GPLv2 - * Description: Allow users to favorite images - * Documentation: - * Gives users a "favorite this image" button that they can press - *

Favorites for a user can then be retrieved by searching for - * "favorited_by=UserName" - *

Popular images can be searched for by eg. "favorites>5" - *

Favorite info can be added to an image's filename or tooltip - * using the $favorites placeholder - */ class FavoriteSetEvent extends Event { @@ -54,7 +41,7 @@ class Favorites extends Extension "SELECT COUNT(*) AS ct FROM user_favorites WHERE user_id = :user_id AND image_id = :image_id", ["user_id"=>$user_id, "image_id"=>$image_id] ) > 0; - + $event->add_part($this->theme->get_voter_html($event->image, $is_favorited)); } } diff --git a/ext/featured/info.php b/ext/featured/info.php new file mode 100644 index 00000000..b28277e1 --- /dev/null +++ b/ext/featured/info.php @@ -0,0 +1,35 @@ + + * Link: http://code.shishnet.org/shimmie2/ + * License: GPLv2 + * Description: Bring a specific image to the users' attentions + * Documentation: + * + */ + +class FeaturedInfo extends ExtensionInfo +{ + public const KEY = "featured"; + + public $key = self::KEY; + public $name = "Featured Image"; + public $url = self::SHIMMIE_URL; + public $authors = self::SHISH_AUTHOR; + public $license = self::LICENSE_GPLV2; + public $description = "Bring a specific image to the users' attentions"; + public $documentation = +"Once enabled, a new \"feature this\" button will appear next +to the other image control buttons (delete, rotate, etc). +Clicking it will set the image as the site's current feature, +which will be shown in the side bar of the post list. +

Viewing a featured image +
Visit /featured_image/view +

Downloading a featured image +
Link to /featured_image/download. This will give +the raw data for an image (no HTML). This is useful so that you +can set your desktop wallpaper to be the download URL, refreshed +every couple of hours."; +} diff --git a/ext/featured/main.php b/ext/featured/main.php index ae5946dd..42fe7bbb 100644 --- a/ext/featured/main.php +++ b/ext/featured/main.php @@ -1,23 +1,4 @@ - * Link: http://code.shishnet.org/shimmie2/ - * License: GPLv2 - * Description: Bring a specific image to the users' attentions - * Documentation: - * Once enabled, a new "feature this" button will appear next - * to the other image control buttons (delete, rotate, etc). - * Clicking it will set the image as the site's current feature, - * which will be shown in the side bar of the post list. - *

Viewing a featured image - *
Visit /featured_image/view - *

Downloading a featured image - *
Link to /featured_image/download. This will give - * the raw data for an image (no HTML). This is useful so that you - * can set your desktop wallpaper to be the download URL, refreshed - * every couple of hours. - */ class Featured extends Extension { @@ -73,7 +54,7 @@ class Featured extends Extension $database->cache->set("featured_image_object:$fid", $image, 600); } if (!is_null($image)) { - if (ext_is_live("Ratings")) { + if (Extension::is_enabled(RatingsInfo::KEY)) { if (strpos(Ratings::get_user_privs($user), $image->rating) === false) { return; } diff --git a/ext/forum/info.php b/ext/forum/info.php new file mode 100644 index 00000000..5671e8b2 --- /dev/null +++ b/ext/forum/info.php @@ -0,0 +1,21 @@ + + * Alpha + * License: GPLv2 + * Description: Rough forum extension + * Documentation: + */ + +class ForumInfo extends ExtensionInfo +{ + public const KEY = "dorum"; + + public $key = self::KEY; + public $name = "Forum"; + public $authors = ["Sein Kraft"=>"mail@seinkraft.info","Alpha"=>"alpha@furries.com.ar"]; + public $license = self::LICENSE_GPLV2; + public $description = "Rough forum extension"; +} diff --git a/ext/forum/main.php b/ext/forum/main.php index db2ff1a8..6d422704 100644 --- a/ext/forum/main.php +++ b/ext/forum/main.php @@ -1,12 +1,4 @@ - * Alpha - * License: GPLv2 - * Description: Rough forum extension - * Documentation: - */ /* Todo: *Quote buttons on posts @@ -34,7 +26,7 @@ class Forum extends Extension FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE RESTRICT "); $database->execute("CREATE INDEX forum_threads_date_idx ON forum_threads(date)", []); - + $database->create_table("forum_posts", " id SCORE_AIPK, thread_id INTEGER NOT NULL, @@ -61,30 +53,30 @@ class Forum extends Extension $config->set_int("forum_version", 2); } } - + public function onSetupBuilding(SetupBuildingEvent $event) { $sb = new SetupBlock("Forum"); $sb->add_int_option("forumTitleSubString", "Title max long: "); $sb->add_int_option("forumThreadsPerPage", "
Threads per page: "); $sb->add_int_option("forumPostsPerPage", "
Posts per page: "); - + $sb->add_int_option("forumMaxCharsPerPost", "
Max chars per post: "); $event->panel->add_block($sb); } - + public function onUserPageBuilding(UserPageBuildingEvent $event) { global $database; - + $threads_count = $database->get_one("SELECT COUNT(*) FROM forum_threads WHERE user_id=?", [$event->display_user->id]); $posts_count = $database->get_one("SELECT COUNT(*) FROM forum_posts WHERE user_id=?", [$event->display_user->id]); - + $days_old = ((time() - strtotime($event->display_user->join_date)) / 86400) + 1; - + $threads_rate = sprintf("%.1f", ($threads_count / $days_old)); $posts_rate = sprintf("%.1f", ($posts_count / $days_old)); - + $event->add_stats("Forum threads: $threads_count, $threads_rate per day"); $event->add_stats("Forum posts: $posts_count, $posts_rate per day"); } @@ -249,7 +241,7 @@ class Forum extends Extension $result = $database->get_row("SELECT t.title FROM forum_threads AS t WHERE t.id = ? ", [$threadID]); return $result["title"]; } - + private function show_last_threads(Page $page, PageRequestEvent $event, $showAdminOptions = false) { global $config, $database; diff --git a/ext/google_analytics/info.php b/ext/google_analytics/info.php new file mode 100644 index 00000000..2c38ba63 --- /dev/null +++ b/ext/google_analytics/info.php @@ -0,0 +1,24 @@ + + * Link: http://drudexsoftware.com + * License: GPLv2 + * Description: Integrates Google Analytics tracking + * Documentation: + * + */ +class google_analyticsInfo extends ExtensionInfo +{ + public const KEY = "google_analytics"; + + public $key = self::KEY; + public $name = "Google Analytics"; + public $url = "http://drudexsoftware.com"; + public $authors = ["Drudex Software"=>"support@drudexsoftware.com"]; + public $license = self::LICENSE_GPLV2; + public $description = "Integrates Google Analytics tracking"; + public $documentation = +"User has to enter their Google Analytics ID in the Board Config to use this extension."; +} diff --git a/ext/google_analytics/main.php b/ext/google_analytics/main.php index 892e4890..f8ff53e8 100644 --- a/ext/google_analytics/main.php +++ b/ext/google_analytics/main.php @@ -1,13 +1,5 @@ - * Link: http://drudexsoftware.com - * License: GPLv2 - * Description: Integrates Google Analytics tracking - * Documentation: - * User has to enter their Google Analytics ID in the Board Config to use this extention. - */ + class google_analytics extends Extension { # Add analytics to config @@ -18,12 +10,12 @@ class google_analytics extends Extension $sb->add_label("
(eg. UA-xxxxxxxx-x)"); $event->panel->add_block($sb); } - + # Load Analytics tracking code on page request public function onPageRequest(PageRequestEvent $event) { global $config, $page; - + $google_analytics_id = $config->get_string('google_analytics_id', ''); if (stristr($google_analytics_id, "UA-")) { $page->add_html_header("