From 0a1e8f2af4db3cf722aa80a678f27d16fc17993c Mon Sep 17 00:00:00 2001 From: "green-ponies (jgen)" Date: Sat, 4 Feb 2012 12:20:49 -0500 Subject: [PATCH 01/20] Store config values that are used inside a loop. --- ext/tag_list/theme.php | 16 ++++++++++------ ext/upload/main.php | 2 ++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/ext/tag_list/theme.php b/ext/tag_list/theme.php index 99d83664..7014bb3c 100644 --- a/ext/tag_list/theme.php +++ b/ext/tag_list/theme.php @@ -69,23 +69,27 @@ class TagListTheme extends Themelet { */ public function display_popular_block(Page $page, $tag_infos) { global $config; + + $info_link = $config->get_string('info_link'); + $tag_list_num = $config->get_bool("tag_list_numbers"); $html = ""; $n = 0; + foreach($tag_infos as $row) { $tag = $row['tag']; $h_tag = html_escape($tag); $h_tag_no_underscores = str_replace("_", " ", $h_tag); $count = $row['count']; if($n++) $html .= "\n
"; - if(!is_null($config->get_string('info_link'))) { - $link = str_replace('$tag', $tag, $config->get_string('info_link')); - $html .= " ?"; + if(!is_null($info_link)) { + $link = str_replace('$tag', $tag, $info_link); + $html .= ' ?'; } $link = $this->tag_link($row['tag']); - $html .= " $h_tag_no_underscores"; - if($config->get_bool("tag_list_numbers")) { - $html .= " $count"; + $html .= ' '.$h_tag_no_underscores.''; + if($tag_list_num) { + $html .= ' '.$count.''; } } diff --git a/ext/upload/main.php b/ext/upload/main.php index 979ab413..8d2281fa 100644 --- a/ext/upload/main.php +++ b/ext/upload/main.php @@ -58,6 +58,8 @@ class Upload extends SimpleExtension { $this->is_full = false; } else { + // TODO: This size limit should be configureable by the admin... + // currently set to 100 MB $this->is_full = $free_num < 100*1024*1024; } From 68e9bd694ef492a2516c119e7c8e993f6e21e5e4 Mon Sep 17 00:00:00 2001 From: "green-ponies (jgen)" Date: Sat, 4 Feb 2012 14:17:52 -0500 Subject: [PATCH 02/20] Storing copies of config variables outside of for loops. --- core/page.class.php | 10 +++++++--- ext/comment/theme.php | 9 ++++++--- ext/tag_list/theme.php | 13 +++++++++---- ext/upload/theme.php | 3 ++- themes/danbooru/comment.theme.php | 8 ++++++-- 5 files changed, 30 insertions(+), 13 deletions(-) diff --git a/core/page.class.php b/core/page.class.php index 6570632b..356febdf 100644 --- a/core/page.class.php +++ b/core/page.class.php @@ -289,7 +289,11 @@ class Page { { global $config; - if (!$config->get_bool("autocache_css") && !$config->get_bool("autocache_js")) { + // store local copy for speed. + $autocache_css = $config->get_bool("autocache_css"); + $autocache_js = config->get_bool("autocache_js") + + if (!$autocache_css && !$autocache_js) { return false; // caching disabled } @@ -307,7 +311,7 @@ class Page { $data_href = get_base_href(); /* ----- CSS Files ----- */ - if ($config->get_bool("autocache_css")) + if ($autocache_css) { // First get all the CSS from the lib directory $contents_from_lib = ''; @@ -374,7 +378,7 @@ class Page { /* ----- JavaScript Files ----- */ - if ($config->get_bool("autocache_js")) + if ($autocache_js) { $data = ''; $js_files = glob("lib/*.js"); diff --git a/ext/comment/theme.php b/ext/comment/theme.php index 56afa513..15911c47 100644 --- a/ext/comment/theme.php +++ b/ext/comment/theme.php @@ -35,14 +35,17 @@ class CommentListTheme extends Themelet { // parts for each image $position = 10; + + $comment_limit = $config->get_int("comment_list_count", 10); + $comment_captcha = $config->get_bool('comment_captcha'); + foreach($images as $pair) { $image = $pair[0]; $comments = $pair[1]; $thumb_html = $this->build_thumb_html($image); - $comment_html = ""; - $comment_limit = $config->get_int("comment_list_count", 10); + $comment_count = count($comments); if($comment_limit > 0 && $comment_count > $comment_limit) { $hidden = $comment_count - $comment_limit; @@ -59,7 +62,7 @@ class CommentListTheme extends Themelet { } } else { if ($can_post) { - if(!$config->get_bool('comment_captcha')) { + if(!$comment_captcha) { $comment_html .= $this->build_postbox($image->id); } else { diff --git a/ext/tag_list/theme.php b/ext/tag_list/theme.php index 7014bb3c..23065572 100644 --- a/ext/tag_list/theme.php +++ b/ext/tag_list/theme.php @@ -70,6 +70,7 @@ class TagListTheme extends Themelet { public function display_popular_block(Page $page, $tag_infos) { global $config; + // store local copies for speed. $info_link = $config->get_string('info_link'); $tag_list_num = $config->get_bool("tag_list_numbers"); @@ -107,19 +108,23 @@ class TagListTheme extends Themelet { public function display_refine_block(Page $page, $tag_infos, $search) { global $config; + // store local copy for speed. + $info_link = $config->get_string('info_link'); + $html = ""; $n = 0; + foreach($tag_infos as $row) { $tag = $row['tag']; $h_tag = html_escape($tag); $h_tag_no_underscores = str_replace("_", " ", $h_tag); if($n++) $html .= "\n
"; - if(!is_null($config->get_string('info_link'))) { - $link = str_replace('$tag', $tag, $config->get_string('info_link')); - $html .= " ?"; + if(!is_null($info_link)) { + $link = str_replace('$tag', $tag, $info_link); + $html .= ' ?'; } $link = $this->tag_link($row['tag']); - $html .= " $h_tag_no_underscores"; + $html .= ' '.$h_tag_no_underscores.''; $html .= $this->ars($tag, $search); } diff --git a/ext/upload/theme.php b/ext/upload/theme.php index 9e66e457..c237493d 100644 --- a/ext/upload/theme.php +++ b/ext/upload/theme.php @@ -18,6 +18,7 @@ class UploadTheme extends Themelet { $upload_list = ""; $upload_count = $config->get_int('upload_count'); + for($i=0; $i<$upload_count; $i++) { $a=$i+1; @@ -53,7 +54,7 @@ class UploadTheme extends Themelet { ". ""; - if($a==$config->get_int('upload_count')){ + if($a == $upload_count){ $upload_list .=""; }else{ $js1 = 'javascript:$(function() { diff --git a/themes/danbooru/comment.theme.php b/themes/danbooru/comment.theme.php index ff728eac..a9ee90e1 100644 --- a/themes/danbooru/comment.theme.php +++ b/themes/danbooru/comment.theme.php @@ -25,6 +25,10 @@ class CustomCommentListTheme extends CommentListTheme { // parts for each image $position = 10; + + $comment_captcha = $config->get_bool('comment_captcha'); + $comment_limit = $config->get_int("comment_list_count", 10); + foreach($images as $pair) { $image = $pair[0]; $comments = $pair[1]; @@ -42,7 +46,7 @@ class CustomCommentListTheme extends CommentListTheme { $r = class_exists("Ratings") ? "Rating ".Ratings::rating_to_human($image->rating) : ""; $comment_html = "Date $p $s User $un $s $r
Tags $t

 "; - $comment_limit = $config->get_int("comment_list_count", 10); + $comment_count = count($comments); if($comment_limit > 0 && $comment_count > $comment_limit) { $hidden = $comment_count - $comment_limit; @@ -57,7 +61,7 @@ class CustomCommentListTheme extends CommentListTheme { $comment_html .= $this->build_postbox($image->id); } else { - if(!$config->get_bool('comment_captcha')) { + if(!$comment_captcha) { $comment_html .= $this->build_postbox($image->id); } else { From cd1f5d9ed0a133af3563234602ee1530db33b62a Mon Sep 17 00:00:00 2001 From: "green-ponies (jgen)" Date: Sat, 4 Feb 2012 14:49:48 -0500 Subject: [PATCH 03/20] Missed a semicolon. --- core/page.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/page.class.php b/core/page.class.php index 356febdf..2995814c 100644 --- a/core/page.class.php +++ b/core/page.class.php @@ -291,7 +291,7 @@ class Page { // store local copy for speed. $autocache_css = $config->get_bool("autocache_css"); - $autocache_js = config->get_bool("autocache_js") + $autocache_js = config->get_bool("autocache_js"); if (!$autocache_css && !$autocache_js) { return false; // caching disabled From 3b028696a06fe55af9912400f41d247ac38db79d Mon Sep 17 00:00:00 2001 From: "green-ponies (jgen)" Date: Sat, 4 Feb 2012 15:35:21 -0500 Subject: [PATCH 04/20] Rewind arrays before foreach loops over all the elements. (fixed a small typo as well) --- contrib/favorites/theme.php | 2 ++ contrib/log_db/theme.php | 2 ++ contrib/rating/main.php | 3 +++ core/config.class.php | 1 + core/imageboard.pack.php | 9 +++++++++ core/page.class.php | 4 ++-- ext/upload/main.php | 4 ++++ 7 files changed, 23 insertions(+), 2 deletions(-) diff --git a/contrib/favorites/theme.php b/contrib/favorites/theme.php index 4bb452ae..14a4fd39 100644 --- a/contrib/favorites/theme.php +++ b/contrib/favorites/theme.php @@ -24,6 +24,8 @@ class FavoritesTheme extends Themelet { $i_favorites = count($username_array); $html = "$i_favorites people:"; + reset($username_array); // rewind to first element in array. + foreach($username_array as $row) { $username = html_escape($row); $html .= "
$username"; diff --git a/contrib/log_db/theme.php b/contrib/log_db/theme.php index 6ac2d3a1..1d3d8ccf 100644 --- a/contrib/log_db/theme.php +++ b/contrib/log_db/theme.php @@ -41,6 +41,8 @@ class LogDatabaseTheme extends Themelet { \n"; $n = 0; + reset($events); // rewind to first element in array. + foreach($events as $event) { $oe = ($n++ % 2 == 0) ? "even" : "odd"; $c = $this->pri_to_col($event['priority']); diff --git a/contrib/rating/main.php b/contrib/rating/main.php index b246b14e..ba1546ab 100644 --- a/contrib/rating/main.php +++ b/contrib/rating/main.php @@ -40,6 +40,9 @@ class Ratings implements Extension { while(true) { $images = Image::find_images($n, 100, Tag::explode($_POST["query"])); if(count($images) == 0) break; + + reset($images); // rewind to first element in array. + foreach($images as $image) { send_event(new RatingSetEvent($image, $user, $_POST['rating'])); } diff --git a/core/config.class.php b/core/config.class.php index 2f918173..92c27b23 100644 --- a/core/config.class.php +++ b/core/config.class.php @@ -188,6 +188,7 @@ class DatabaseConfig extends BaseConfig { */ public function save($name=null) { if(is_null($name)) { + reset($this->values); // rewind the array to the first element foreach($this->values as $name => $value) { $this->save($name); } diff --git a/core/imageboard.pack.php b/core/imageboard.pack.php index 1be135fa..d215337e 100644 --- a/core/imageboard.pack.php +++ b/core/imageboard.pack.php @@ -770,6 +770,8 @@ class Image { } } + reset($terms); // rewind to first element in array. + // turn each term into a specific type of querylet foreach($terms as $term) { $negative = false; @@ -1002,8 +1004,15 @@ class Tag { } } + /** + * This function takes a list (array) of tags and changes any tags that have aliases + * + * @param $tags Array of tags + * @return Array of tags + */ public static function resolve_list($tags) { $tags = Tag::explode($tags); + reset($tags); // rewind array to the first element. $new = array(); foreach($tags as $tag) { $new_set = explode(' ', Tag::resolve_alias($tag)); diff --git a/core/page.class.php b/core/page.class.php index 2995814c..411c9053 100644 --- a/core/page.class.php +++ b/core/page.class.php @@ -291,7 +291,7 @@ class Page { // store local copy for speed. $autocache_css = $config->get_bool("autocache_css"); - $autocache_js = config->get_bool("autocache_js"); + $autocache_js = $config->get_bool("autocache_js"); if (!$autocache_css && !$autocache_js) { return false; // caching disabled @@ -396,7 +396,7 @@ class Page { // Minify the JS if enabled. if ($config->get_bool("autocache_min_js")){ // not supported yet. - // TODO: add support for Minifying CSS files. + // TODO: add support for Minifying JS files. } // compute the MD5 sum of the concatenated JavaScript files diff --git a/ext/upload/main.php b/ext/upload/main.php index 8d2281fa..2aee068f 100644 --- a/ext/upload/main.php +++ b/ext/upload/main.php @@ -152,12 +152,14 @@ class Upload extends SimpleExtension { $tags = ''; // Tags aren't changed when uploading. Set to null to stop PHP warnings. if(count($_FILES)) { + reset($_FILES); // rewind to first element in array. foreach($_FILES as $file) { $ok = $this->try_upload($file, $tags, $source, $image_id); break; // leave the foreach loop. } } else { + reset($_POST); // rewind to first element in array. foreach($_POST as $name => $value) { if(substr($name, 0, 3) == "url" && strlen($value) > 0) { $ok = $this->try_transload($value, $tags, $source, $image_id); @@ -188,9 +190,11 @@ class Upload extends SimpleExtension { $source = isset($_POST['source']) ? $_POST['source'] : null; $ok = true; foreach($_FILES as $file) { + reset($_FILES); // rewind to first element in array. $ok = $ok & $this->try_upload($file, $tags, $source); } foreach($_POST as $name => $value) { + reset($_POST); // rewind to first element in array. if(substr($name, 0, 3) == "url" && strlen($value) > 0) { $ok = $ok & $this->try_transload($value, $tags, $source); } From d3d395c3472c62fcc96e4a300c326f10c3474250 Mon Sep 17 00:00:00 2001 From: Daku Date: Wed, 1 Feb 2012 19:16:55 +0000 Subject: [PATCH 05/20] reset image id function for admin this basically grabs all the image_id's > sets them all from 1-whatever (so it would be like you never deleted an image) --- contrib/admin/main.php | 43 +++++++++++++++++++++++++++++++++++++++++ contrib/admin/theme.php | 1 + 2 files changed, 44 insertions(+) diff --git a/contrib/admin/main.php b/contrib/admin/main.php index 3d03915d..de3bf10a 100644 --- a/contrib/admin/main.php +++ b/contrib/admin/main.php @@ -78,6 +78,10 @@ class AdminPage extends SimpleExtension { case 'database dump': $this->dbdump($page); break; + case 'reset image ids': + $this->reset_imageids(); + $redirect = true; + break; } if($redirect) { @@ -175,5 +179,44 @@ class AdminPage extends SimpleExtension { } } */ + + private function reset_imageids() { + global $database; + //This might be a bit laggy on boards with lots of images (?) + //Seems to work fine with 1.2k~ images though. + $i = 0; + $image = $database->get_all("SELECT * FROM images ORDER BY images.id ASC"); + /*$score_log = $database->get_all("SELECT message FROM score_log");*/ + foreach($image as $img){ + $xid = $img[0]; + $i = $i + 1; + $table = array( //Might be missing some tables? + "image_tags", "tag_histories", "image_reports", "comments", "user_favorites", "tag_histories", + "numeric_score_votes", "pool_images", "slext_progress_cache", "notes"); + + $sql = + "SET FOREIGN_KEY_CHECKS=0; + UPDATE images + SET id=".$i. + " WHERE id=".$xid.";"; //id for images + + foreach($table as $tbl){ + $sql .= " + UPDATE ".$tbl." + SET image_id=".$i." + WHERE image_id=".$xid.";"; + } + + /*foreach($score_log as $sl){ + //This seems like a bad idea. + //TODO: Might be better for log_info to have an $id option (which would then affix the id to the table?) + preg_replace(".Image \\#[0-9]+.", "Image #".$i, $sl); + }*/ + $sql .= " SET FOREIGN_KEY_CHECKS=1;"; + $database->execute($sql); + } + $count = (count($image)) + 1; + $database->execute("ALTER TABLE images AUTO_INCREMENT=".$count); + } } ?> diff --git a/contrib/admin/theme.php b/contrib/admin/theme.php index 18cc9687..37d1f7e2 100644 --- a/contrib/admin/theme.php +++ b/contrib/admin/theme.php @@ -26,6 +26,7 @@ class AdminPageTheme extends Themelet { + From 26b688fe9b6d19c7d8b5ef354c2b6eb5003db817 Mon Sep 17 00:00:00 2001 From: Daku Date: Thu, 2 Feb 2012 00:56:17 +0000 Subject: [PATCH 06/20] bookmarklet now supports oreno.imouto --- ext/upload/bookmarklet.js | 40 ++++++++++++++++++++++++++++++--------- ext/upload/theme.php | 8 ++++---- 2 files changed, 35 insertions(+), 13 deletions(-) diff --git a/ext/upload/bookmarklet.js b/ext/upload/bookmarklet.js index 2838bdca..86710973 100644 --- a/ext/upload/bookmarklet.js +++ b/ext/upload/bookmarklet.js @@ -4,22 +4,45 @@ var maxsze = (maxsze.match("(?:\.*[0-9])")) * 1024; //This assumes we are only working with MB. var toobig = "The file you are trying to upload is too big to upload!"; var notsup = "The file you are trying to upload is not supported!"; +if (CA === 0 || CA > 2){ //Default + if (confirm("OK = Use Current tags.\nCancel = Use new tags.")==true){ + }else{ + var tag=prompt("Enter Tags",""); + var chk=1; //This makes sure it doesn't use current tags. + } +}else if (CA === 1){ //Current Tags +}else if (CA === 2){ //New Tags + var tag=prompt("Enter Tags",""); + var chk=1; +} -if (confirm("OK = Use Current tags.\nCancel = Use new tags.")==true){}else{var tag=prompt("Enter Tags","");var chk=1;}; - -// Danbooru +// Danbooru | oreno.imouto if(document.getElementById("post_tags") !== null){ if (typeof tag !=="ftp://ftp." && chk !==1){var tag=document.getElementById("post_tags").value;} - var rtg=document.getElementById("stats").innerHTML.match("

  • Rating: (.*)<\/li>")[1]; var srx="http://" + document.location.hostname + document.location.href.match("\/post\/show\/[0-9]+\/"); + var hrs=document.getElementById("highres").href; + if(srx.search("oreno\\.imouto") >= 0){ + var rtg=document.getElementById("stats").innerHTML.match("
  • Rating: (.*) Rating: (.*)<\/li>")[1]; + } if(tag.search(/\bflash\b/)===-1){ - var filesze=document.getElementById("stats").innerHTML.match("[0-9] \\(((?:\.*[0-9])) ([a-zA-Z]+)"); + if(srx.search("oreno\\.imouto") >= 0){ //oreno's theme seems to have moved the filesize + var filesze = document.getElementById("highres").innerHTML.match("[a-zA-Z0-9]+ \\(+([0-9]+\\.[0-9]+) ([a-zA-Z]+)"); + }else{ + var filesze=document.getElementById("stats").innerHTML.match("[0-9] \\(((?:\.*[0-9])) ([a-zA-Z]+)"); + } if(filesze[2] == "MB"){var filesze = filesze[1] * 1024;}else{var filesze = filesze[2].match("[0-9]+");} - if(supext.search(document.getElementById("highres").href.match("http\:\/\/.*\\.([a-z0-9]+)")[1]) !== -1){ + if(supext.search(hrs.match("http\:\/\/.*\\.([a-z0-9]+)")[1]) !== -1){ if(filesze <= maxsze){ - location.href=ste+document.getElementById("highres").href+"&tags="+tag+"&rating="+rtg+"&source="+srx; + if(srx.search("oreno\\.imouto") >= 0){ + //this regex tends to be a bit picky with tags -_-;; + var hrs=hrs.match("(http\:\/\/[a-z0-9]+\.[a-z]+\.org\/[a-z0-9]+\/[a-z0-9]+)\/[a-z0-9A-Z%_]+(\.[a-zA-Z0-9]+)"); + var hrs=hrs[1]+hrs[2]; //this should bypass hotlink protection + } + location.href=ste+hrs+"&tags="+tag+"&rating="+rtg+"&source="+srx; }else{alert(toobig);} }else{alert(notsup);} }else{ @@ -29,6 +52,7 @@ if(document.getElementById("post_tags") !== null){ } } /* Shimmie +One problem with shimmie is each theme does not show the same info as other themes (I.E only the danbooru & lite themes show statistics) Shimmie doesn't seem to have any way to grab tags via id unless you have the ability to edit tags. Have to go the round about way of checking the title for tags. This crazy way of checking "should" work with older releases though (Seems to work with 2009~ ver) */ @@ -36,7 +60,6 @@ else if(document.getElementsByTagName("title")[0].innerHTML.search("Image [0-9.- if (typeof tag !=="ftp://ftp." && chk !==1){var tag=document.getElementsByTagName("title")[0].innerHTML.match("Image [0-9.-]+\: (.*)")[1];} //TODO: Make rating show in statistics. var srx="http://" + document.location.hostname + document.location.href.match("\/post\/view\/[0-9]+"); - /*TODO: Figure out regex for shortening file link. I.E http://blah.net/_images/1234abcd/everysingletag.png > http://blah.net/_images/1234abcd.png*/ /*TODO: Make file size show on all themes (Only seems to show in lite/Danbooru themes.)*/ if(tag.search(/\bflash\b/)==-1){ var img = document.getElementById("main_image").src; @@ -52,7 +75,6 @@ else if(document.getElementsByTagName("title")[0].innerHTML.search("Image [0-9.- } // Gelbooru else if(document.getElementById("tags") !== null){ - //Gelbooru has an annoying anti-hotlinking thing which doesn't seem to like the bookmarklet. if (typeof tag !=="ftp://ftp." && chk !==1){var tag=document.getElementById("tags").value;} var rtg=document.getElementById("stats").innerHTML.match("
  • Rating: (.*)<\/li>")[1]; //Can't seem to grab source due to url containing a & diff --git a/ext/upload/theme.php b/ext/upload/theme.php index 9e66e457..0e5e7127 100644 --- a/ext/upload/theme.php +++ b/ext/upload/theme.php @@ -145,8 +145,7 @@ class UploadTheme extends Themelet { { /* Imageboard > Shimmie Bookmarklet This is more or less, an upgraded version of the "Danbooru>Shimmie" bookmarklet. - At the moment this works with Shimmie & Danbooru. - It would also work with Gelbooru but unless someone can figure out how to bypass their hotlinking..meh. + At the moment this works with Shimmie/Danbooru/Gelbooru/oreno.imouto. The bookmarklet is now also loaded via the .js file in this folder. */ //Bookmarklet checks if shimmie supports ext. If not, won't upload to site/shows alert saying not supported. @@ -156,8 +155,9 @@ class UploadTheme extends Themelet { if(file_exists("ext/handle_mp3")){$supported_ext .= " mp3";} if(file_exists("ext/handle_svg")){$supported_ext .= " svg";} $title = "Booru to " . $config->get_string('title'); - $html .= '

    '. - $title . ' (Click when looking at an image page. Works on sites running Shimmie/Danbooru/Gelbooru. (This also grabs the tags/rating/source!))'; + //CA=0: Ask to use current or new tags | CA=1: Always use current tags | CA=2: Always use new tags + $html .= '

    '. + $title . ' (Click when looking at an image page. Works on sites running Shimmie/Danbooru/Gelbooru/oreno.imouto. (This also grabs the tags/rating/source!))'; } } From a25f4054707a691b2ad06683c41d8ecaaded8895 Mon Sep 17 00:00:00 2001 From: Daku Date: Thu, 2 Feb 2012 13:01:40 +0000 Subject: [PATCH 07/20] bookmarklet now supports sankaku and konachan --- ext/upload/bookmarklet.js | 14 +++++++++----- ext/upload/theme.php | 4 ++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/ext/upload/bookmarklet.js b/ext/upload/bookmarklet.js index 86710973..5f45c6fc 100644 --- a/ext/upload/bookmarklet.js +++ b/ext/upload/bookmarklet.js @@ -16,19 +16,19 @@ if (CA === 0 || CA > 2){ //Default var chk=1; } -// Danbooru | oreno.imouto +// Danbooru | oreno.imouto | konachan | sankakucomplex if(document.getElementById("post_tags") !== null){ if (typeof tag !=="ftp://ftp." && chk !==1){var tag=document.getElementById("post_tags").value;} var srx="http://" + document.location.hostname + document.location.href.match("\/post\/show\/[0-9]+\/"); var hrs=document.getElementById("highres").href; - if(srx.search("oreno\\.imouto") >= 0){ + if(srx.search("oreno\\.imouto") >= 0 || srx.search("konachan\\.com") >= 0){ var rtg=document.getElementById("stats").innerHTML.match("

  • Rating: (.*) Rating: (.*)<\/li>")[1]; } if(tag.search(/\bflash\b/)===-1){ - if(srx.search("oreno\\.imouto") >= 0){ //oreno's theme seems to have moved the filesize + if(srx.search("oreno\\.imouto") >= 0 || srx.search("konachan\\.com") >= 0){ //oreno's theme seems to have moved the filesize var filesze = document.getElementById("highres").innerHTML.match("[a-zA-Z0-9]+ \\(+([0-9]+\\.[0-9]+) ([a-zA-Z]+)"); }else{ var filesze=document.getElementById("stats").innerHTML.match("[0-9] \\(((?:\.*[0-9])) ([a-zA-Z]+)"); @@ -39,10 +39,14 @@ if(document.getElementById("post_tags") !== null){ if(filesze <= maxsze){ if(srx.search("oreno\\.imouto") >= 0){ //this regex tends to be a bit picky with tags -_-;; - var hrs=hrs.match("(http\:\/\/[a-z0-9]+\.[a-z]+\.org\/[a-z0-9]+\/[a-z0-9]+)\/[a-z0-9A-Z%_]+(\.[a-zA-Z0-9]+)"); + var hrs=hrs.match("(http\:\/\/[a-z0-9]+\.[a-z]+\.[a-z]\/[a-z0-9]+\/[a-z0-9]+)\/[a-z0-9A-Z%_-]+(\.[a-zA-Z0-9]+)"); var hrs=hrs[1]+hrs[2]; //this should bypass hotlink protection + }else if(srx.search("konachan\\.com") >= 0){ + //konachan affixs konachan.com to the start of the tags, this requires different regex + var hrs=hrs.match("(http\:\/\/[a-z0-9]+\.[a-z]+\.[a-z]\/[a-z0-9]+\/[a-z0-9]+)\/[a-z0-9A-Z%_]+\.[a-zA-Z0-9%_-]+(\.[a-z0-9A-Z]+)") + var hrs=hrs[1]+hrs[2]; } - location.href=ste+hrs+"&tags="+tag+"&rating="+rtg+"&source="+srx; + location.href="|"+ste+hrs+"&tags="+tag+"&rating="+rtg+"&source="+srx; }else{alert(toobig);} }else{alert(notsup);} }else{ diff --git a/ext/upload/theme.php b/ext/upload/theme.php index 0e5e7127..47cc9147 100644 --- a/ext/upload/theme.php +++ b/ext/upload/theme.php @@ -145,7 +145,7 @@ class UploadTheme extends Themelet { { /* Imageboard > Shimmie Bookmarklet This is more or less, an upgraded version of the "Danbooru>Shimmie" bookmarklet. - At the moment this works with Shimmie/Danbooru/Gelbooru/oreno.imouto. + At the moment this is known to work with Shimmie/Danbooru/Gelbooru/oreno.imouto/konachan/sankakucomplex. The bookmarklet is now also loaded via the .js file in this folder. */ //Bookmarklet checks if shimmie supports ext. If not, won't upload to site/shows alert saying not supported. @@ -157,7 +157,7 @@ class UploadTheme extends Themelet { $title = "Booru to " . $config->get_string('title'); //CA=0: Ask to use current or new tags | CA=1: Always use current tags | CA=2: Always use new tags $html .= '

    '. - $title . ' (Click when looking at an image page. Works on sites running Shimmie/Danbooru/Gelbooru/oreno.imouto. (This also grabs the tags/rating/source!))'; + $title . ' (Click when looking at an image page. Works on sites running Shimmie/Danbooru/Gelbooru. (This also grabs the tags/rating/source!))'; } } From 1f871a69e14e50c88c439acfd6e811880f533a6a Mon Sep 17 00:00:00 2001 From: Daku Date: Thu, 2 Feb 2012 13:22:33 +0000 Subject: [PATCH 08/20] fixing flash again :x --- ext/upload/bookmarklet.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/upload/bookmarklet.js b/ext/upload/bookmarklet.js index 5f45c6fc..ba0f79ed 100644 --- a/ext/upload/bookmarklet.js +++ b/ext/upload/bookmarklet.js @@ -20,7 +20,6 @@ if (CA === 0 || CA > 2){ //Default if(document.getElementById("post_tags") !== null){ if (typeof tag !=="ftp://ftp." && chk !==1){var tag=document.getElementById("post_tags").value;} var srx="http://" + document.location.hostname + document.location.href.match("\/post\/show\/[0-9]+\/"); - var hrs=document.getElementById("highres").href; if(srx.search("oreno\\.imouto") >= 0 || srx.search("konachan\\.com") >= 0){ var rtg=document.getElementById("stats").innerHTML.match("

  • Rating: (.*) = 0 || srx.search("konachan\\.com") >= 0){ //oreno's theme seems to have moved the filesize var filesze = document.getElementById("highres").innerHTML.match("[a-zA-Z0-9]+ \\(+([0-9]+\\.[0-9]+) ([a-zA-Z]+)"); }else{ From 6e602aa430491b45dd6baadf2a91d31d57463c97 Mon Sep 17 00:00:00 2001 From: Daku Date: Thu, 2 Feb 2012 13:25:27 +0000 Subject: [PATCH 09/20] forgot to remove this... --- ext/upload/bookmarklet.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/upload/bookmarklet.js b/ext/upload/bookmarklet.js index ba0f79ed..687d0c20 100644 --- a/ext/upload/bookmarklet.js +++ b/ext/upload/bookmarklet.js @@ -46,7 +46,7 @@ if(document.getElementById("post_tags") !== null){ var hrs=hrs.match("(http\:\/\/[a-z0-9]+\.[a-z]+\.[a-z]\/[a-z0-9]+\/[a-z0-9]+)\/[a-z0-9A-Z%_]+\.[a-zA-Z0-9%_-]+(\.[a-z0-9A-Z]+)") var hrs=hrs[1]+hrs[2]; } - location.href="|"+ste+hrs+"&tags="+tag+"&rating="+rtg+"&source="+srx; + location.href=ste+hrs+"&tags="+tag+"&rating="+rtg+"&source="+srx; }else{alert(toobig);} }else{alert(notsup);} }else{ From 9efce5378cee5ed5eac90d8b3ae6f19a8306cd11 Mon Sep 17 00:00:00 2001 From: Daku Date: Thu, 2 Feb 2012 21:00:00 +0000 Subject: [PATCH 10/20] small fix for bookmarklet image url --- ext/upload/bookmarklet.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/upload/bookmarklet.js b/ext/upload/bookmarklet.js index 687d0c20..cf951acd 100644 --- a/ext/upload/bookmarklet.js +++ b/ext/upload/bookmarklet.js @@ -19,7 +19,7 @@ if (CA === 0 || CA > 2){ //Default // Danbooru | oreno.imouto | konachan | sankakucomplex if(document.getElementById("post_tags") !== null){ if (typeof tag !=="ftp://ftp." && chk !==1){var tag=document.getElementById("post_tags").value;} - var srx="http://" + document.location.hostname + document.location.href.match("\/post\/show\/[0-9]+\/"); + var srx="http://" + document.location.hostname + document.location.href.match("\/post\/show\/[0-9]+"); if(srx.search("oreno\\.imouto") >= 0 || srx.search("konachan\\.com") >= 0){ var rtg=document.getElementById("stats").innerHTML.match("
  • Rating: (.*) Date: Sat, 4 Feb 2012 23:58:19 +0000 Subject: [PATCH 11/20] this should fix bookmarklet not working with nice urls --- ext/upload/theme.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/upload/theme.php b/ext/upload/theme.php index 47cc9147..17410a96 100644 --- a/ext/upload/theme.php +++ b/ext/upload/theme.php @@ -156,7 +156,7 @@ class UploadTheme extends Themelet { if(file_exists("ext/handle_svg")){$supported_ext .= " svg";} $title = "Booru to " . $config->get_string('title'); //CA=0: Ask to use current or new tags | CA=1: Always use current tags | CA=2: Always use new tags - $html .= '

    '. + $html .= '

    '. $title . ' (Click when looking at an image page. Works on sites running Shimmie/Danbooru/Gelbooru. (This also grabs the tags/rating/source!))'; } From 1fd565fa87a2c7ce25fd847030ee499261df585c Mon Sep 17 00:00:00 2001 From: Daku Date: Mon, 6 Feb 2012 05:23:37 +0000 Subject: [PATCH 12/20] can't check if rating is null if it doesn't exist... --- themes/danbooru/view.theme.php | 2 +- themes/lite/view.theme.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/themes/danbooru/view.theme.php b/themes/danbooru/view.theme.php index 31c553e9..ae5895e6 100644 --- a/themes/danbooru/view.theme.php +++ b/themes/danbooru/view.theme.php @@ -38,7 +38,7 @@ class CustomViewImageTheme extends ViewImageTheme { $html .= "
    Source: link"; } - if(!is_null($image->rating) && file_exists("ext/rating")) { + if(file_exists("ext/rating")) { if($image->rating == null || $image->rating == "u"){ $image->rating = "u"; } diff --git a/themes/lite/view.theme.php b/themes/lite/view.theme.php index 70fd4583..1327b33a 100644 --- a/themes/lite/view.theme.php +++ b/themes/lite/view.theme.php @@ -44,7 +44,7 @@ class CustomViewImageTheme extends ViewImageTheme { $html .= "
    Source: link"; } - if(!is_null($image->rating) && file_exists("ext/rating")) { + if(file_exists("ext/rating")) { if($image->rating == null || $image->rating == "u"){ $image->rating = "u"; } From 07e786101d40318426a78aa8c335359eedf5e760 Mon Sep 17 00:00:00 2001 From: Daku Date: Mon, 6 Feb 2012 06:52:04 +0000 Subject: [PATCH 13/20] download all images function for admin --- .gitignore | 4 +++- contrib/admin/main.php | 26 ++++++++++++++++++++++++++ contrib/admin/theme.php | 1 + 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 6dd0495a..1258151b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,10 @@ .svn +backup +data config.php images +imgdump-*.zip thumbs -data sql.log shimmie.log !lib/images diff --git a/contrib/admin/main.php b/contrib/admin/main.php index de3bf10a..c7e5b1a1 100644 --- a/contrib/admin/main.php +++ b/contrib/admin/main.php @@ -82,6 +82,9 @@ class AdminPage extends SimpleExtension { $this->reset_imageids(); $redirect = true; break; + case 'image dump': + $this->imgdump($page); + break; } if($redirect) { @@ -218,5 +221,28 @@ class AdminPage extends SimpleExtension { $count = (count($image)) + 1; $database->execute("ALTER TABLE images AUTO_INCREMENT=".$count); } + + private function imgdump($page) { + global $database; + $zip = new ZipArchive; + $images = $database->get_all("SELECT * FROM images"); + $filename = 'imgdump-'.date('Ymd').'.zip'; + + if($zip->open($filename, 1 ? ZIPARCHIVE::OVERWRITE:ZIPARCHIVE::CREATE)===TRUE){ + foreach($images as $img){ + $hash = $img["hash"]; + preg_match("^[A-Za-z0-9]{2}^", $hash, $matches); + $img_loc = "images/".$matches[0]."/".$hash; + if(file_exists($img_loc)){ + $zip->addFile($img_loc, $hash.".".$img["ext"]); + } + + } + $zip->close(); + } + $page->set_mode("redirect"); + $page->set_redirect(make_link($filename)); //Fairly sure there is better way to do this.. + //TODO: Delete file after downloaded? + } } ?> diff --git a/contrib/admin/theme.php b/contrib/admin/theme.php index 37d1f7e2..c1126fdb 100644 --- a/contrib/admin/theme.php +++ b/contrib/admin/theme.php @@ -27,6 +27,7 @@ class AdminPageTheme extends Themelet { + From 80970f924ebc6398e39fd6ecd114cab4d19ddf14 Mon Sep 17 00:00:00 2001 From: Daku Date: Mon, 6 Feb 2012 07:08:38 +0000 Subject: [PATCH 14/20] this should be here >_< --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 1258151b..57872564 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ .svn backup -data config.php +data images imgdump-*.zip thumbs From e92d4f6809e2b3e2a942543f06e214203368c60a Mon Sep 17 00:00:00 2001 From: Daku Date: Mon, 6 Feb 2012 10:22:57 +0000 Subject: [PATCH 15/20] fixes gelbooru with bookmarklet --- ext/upload/bookmarklet.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/upload/bookmarklet.js b/ext/upload/bookmarklet.js index cf951acd..590adaef 100644 --- a/ext/upload/bookmarklet.js +++ b/ext/upload/bookmarklet.js @@ -87,6 +87,6 @@ else if(document.getElementById("tags") !== null){ //Since Gelbooru does not allow flash, no need to search for flash tag. //Gelbooru doesn't show file size in statistics either... if(supext.search(gmi.match("http\:\/\/.*\\.([a-z0-9]+)")[1]) !== -1){ - location.href=ste+gmi+"&tags="+tag+"&rating="+rtg[1];//+"&source="+srx; + location.href=ste+gmi+"&tags="+tag+"&rating="+rtg;//+"&source="+srx; }else{alert(notsup);} } From cca3ce513ad3d2e80232b505e097b87c7c36c6f1 Mon Sep 17 00:00:00 2001 From: Daku Date: Tue, 7 Feb 2012 00:02:30 +0000 Subject: [PATCH 16/20] added confirm/warning to resetting image ids --- contrib/admin/theme.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/contrib/admin/theme.php b/contrib/admin/theme.php index c1126fdb..e72a372a 100644 --- a/contrib/admin/theme.php +++ b/contrib/admin/theme.php @@ -19,9 +19,20 @@ class AdminPageTheme extends Themelet { public function display_form(Page $page) { global $user; - $html = " - ".make_form(make_link("admin_utils"))." - From 5af54bb9e091d2a6166f30044e6e370a6c792920 Mon Sep 17 00:00:00 2001 From: "green-ponies (jgen)" Date: Tue, 7 Feb 2012 20:05:38 -0500 Subject: [PATCH 17/20] Added some more comments and type hints. --- core/imageboard.pack.php | 11 ++++++++--- core/user.class.php | 3 +++ core/util.inc.php | 29 +++++++++++++++++++++++++++-- 3 files changed, 38 insertions(+), 5 deletions(-) diff --git a/core/imageboard.pack.php b/core/imageboard.pack.php index ca198452..084cd712 100644 --- a/core/imageboard.pack.php +++ b/core/imageboard.pack.php @@ -106,8 +106,10 @@ class Image { /** * Search for an array of images + * + * @retval Array */ - public static function find_images($start, $limit, $tags=array()) { + public static function find_images(/*int*/ $start, /*int*/ $limit, $tags=array()) { assert(is_numeric($start)); assert(is_numeric($limit)); assert(is_array($tags)); @@ -383,7 +385,7 @@ class Image { /** * Set the image's source URL */ - public function set_source($source) { + public function set_source(/*string*/ $source) { global $database; if(empty($source)) $source = null; if($source != $this->source) { @@ -392,7 +394,10 @@ class Image { } } - + /** + * Check if the image is locked. + * @retval bool + */ public function is_locked() { return ($this->locked === true || $this->locked == "Y" || $this->locked == "t"); } diff --git a/core/user.class.php b/core/user.class.php index 0c98597b..843d6c9d 100644 --- a/core/user.class.php +++ b/core/user.class.php @@ -216,6 +216,7 @@ class User { /** * Get a snippet of HTML which will render the user's avatar, be that * a local file, a remote file, a gravatar, a something else, etc + * @retval String of HTML */ public function get_avatar_html() { // FIXME: configurable @@ -242,6 +243,8 @@ class User { * authtok = md5(sesskey, salt), presented to the user in web forms, to make sure that * the form was generated within the session. Salted and re-hashed so that * reading a web page from the user's cache doesn't give access to the session key + * + * @retval String containing auth token (MD5sum) */ public function get_auth_token() { global $config; diff --git a/core/util.inc.php b/core/util.inc.php index 3529fb87..8ddb2fb3 100644 --- a/core/util.inc.php +++ b/core/util.inc.php @@ -190,12 +190,26 @@ function undb_bool($val) { if($val === false || $val == 'N' || $val == 'n' || $val == 'F' || $val == 'f' || $val === 0) return false; } -function startsWith($haystack, $needle) { +/** + * Checks if a given string contains another at the beginning. + * + * @param $haystack String to examine. + * @param $needle String to look for. + * @retval bool + */ +function startsWith(/*string*/ $haystack, /*string*/ $needle) { $length = strlen($needle); return (substr($haystack, 0, $length) === $needle); } -function endsWith($haystack, $needle) { +/** + * Checks if a given string contains another at the end. + * + * @param $haystack String to examine. + * @param $needle String to look for. + * @retval bool + */ +function endsWith(/*string*/ $haystack, /*string*/ $needle) { $length = strlen($needle); $start = $length * -1; //negative return (substr($haystack, $start) === $needle); @@ -621,6 +635,7 @@ function log_msg($section, $priority, $message) { send_event(new LogEvent($section, $priority, $message)); } +// More shorthand ways of logging function log_debug($section, $message) {log_msg($section, SCORE_LOG_DEBUG, $message);} function log_info($section, $message) {log_msg($section, SCORE_LOG_INFO, $message);} function log_warning($section, $message) {log_msg($section, SCORE_LOG_WARNING, $message);} @@ -847,6 +862,13 @@ function send_event(Event $event) { // string representation of a number, it's two numbers separated by a space. // What the fuck were the PHP developers smoking. $_load_start = microtime(true); + +/** + * Collects some debug information (execution time, memory usage, queries, etc) + * and formats it to stick in the footer of the page. + * + * @retval String of debug info to add to the page. + */ function get_debug_info() { global $config, $_event_count, $database, $_execs, $_load_start; @@ -1051,6 +1073,9 @@ function _load_extensions() { ctx_log_endok(); } +/** + * Used to display fatal errors to the web user. + */ function _fatal_error(Exception $e) { $version = VERSION; $message = $e->getMessage(); From ac1b3d00e296da55b944f94c6a9dc305a1b34ba0 Mon Sep 17 00:00:00 2001 From: "green-ponies (jgen)" Date: Tue, 7 Feb 2012 20:13:58 -0500 Subject: [PATCH 18/20] Some more comments. --- core/event.class.php | 11 +++++++++++ core/page.class.php | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/core/event.class.php b/core/event.class.php index cbff2fcf..e6511cff 100644 --- a/core/event.class.php +++ b/core/event.class.php @@ -39,6 +39,8 @@ class PageRequestEvent extends Event { * Test if the requested path matches a given pattern. * * If it matches, store the remaining path elements in $args + * + * @retval bool */ public function page_matches(/*string*/ $name) { $parts = explode("/", $name); @@ -57,6 +59,11 @@ class PageRequestEvent extends Event { return true; } + /** + * Get the n th argument of the page request (if it exists.) + * @param $n integer + * @retval The argmuent (string) or NULL + */ public function get_arg(/*int*/ $n) { $offset = $this->part_count + $n; if($offset >= 0 && $offset < $this->arg_count) { @@ -67,6 +74,10 @@ class PageRequestEvent extends Event { } } + /** + * Returns the number of arguments the page request has. + * @retval int + */ public function count_args() { return (int)($this->arg_count - $this->part_count); } diff --git a/core/page.class.php b/core/page.class.php index 4060d4f7..e3102ccc 100644 --- a/core/page.class.php +++ b/core/page.class.php @@ -237,7 +237,7 @@ class Page { protected function add_auto_html_headers() { $data_href = get_base_href(); - $this->add_html_header(""); + $this->add_html_header(""); /* Attempt to cache the CSS & JavaScript files */ if ($this->add_cached_auto_html_headers() === FALSE) { From 0cdc3033979021f03c9dd41b62138b1305ef46c8 Mon Sep 17 00:00:00 2001 From: "green-ponies (jgen)" Date: Tue, 7 Feb 2012 20:25:05 -0500 Subject: [PATCH 19/20] Just more comments. --- ext/upload/main.php | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/ext/upload/main.php b/ext/upload/main.php index 938a27fa..571a56af 100644 --- a/ext/upload/main.php +++ b/ext/upload/main.php @@ -1,5 +1,5 @@ get_bool("upload_anon") || !$user->is_anonymous()); } - // Helper function based on the one from the online PHP Documentation - // which is licensed under Creative Commons Attribution 3.0 License - // TODO: Make these messages user/admin editable + /** + * Returns a descriptive error message for the specified PHP error code. + * + * This is a helper function based on the one from the online PHP Documentation + * which is licensed under Creative Commons Attribution 3.0 License + * + * TODO: Make these messages user/admin editable + * + * @param $error_code PHP error code (int) + * @retval String + */ private function upload_error_message($error_code) { switch ($error_code) { case UPLOAD_ERR_INI_SIZE: @@ -247,6 +261,10 @@ class Upload extends SimpleExtension { } } + /** + * Handle an upload. + * @retval bool TRUE on upload successful. + */ private function try_upload($file, $tags, $source, $replace='') { global $page; global $config; @@ -293,6 +311,10 @@ class Upload extends SimpleExtension { return $ok; } + /** + * Handle an transload. + * @retval bool TRUE on transload successful. + */ private function try_transload($url, $tags, $source, $replace='') { global $page; global $config; From 2d443f0be9c3fef126886a9f3df8081226cfc8b1 Mon Sep 17 00:00:00 2001 From: "green-ponies (jgen)" Date: Tue, 7 Feb 2012 21:52:11 -0500 Subject: [PATCH 20/20] Mostly just adding the Link to comments. --- contrib/ban_words/main.php | 1 + contrib/bulk_add/main.php | 5 ++++- contrib/et/main.php | 3 +++ contrib/featured/main.php | 1 + contrib/handle_flash/main.php | 3 ++- contrib/handle_svg/main.php | 3 ++- contrib/ipban/main.php | 1 + contrib/log_db/main.php | 5 +++-- contrib/news/main.php | 1 + contrib/numeric_score/main.php | 1 + contrib/random_image/main.php | 1 + contrib/rating/main.php | 1 + contrib/regen_thumb/main.php | 1 + contrib/site_description/main.php | 1 + ext/tag_list/main.php | 18 +++++++++++++++--- ext/upgrade/main.php | 3 ++- 16 files changed, 40 insertions(+), 9 deletions(-) diff --git a/contrib/ban_words/main.php b/contrib/ban_words/main.php index aee98417..f64b1f69 100644 --- a/contrib/ban_words/main.php +++ b/contrib/ban_words/main.php @@ -2,6 +2,7 @@ /* * Name: Comment Word Ban * Author: Shish + * Link: http://code.shishnet.org/shimmie2/ * License: GPLv2 * Description: For stopping spam and other comment abuse * Documentation: diff --git a/contrib/bulk_add/main.php b/contrib/bulk_add/main.php index 0fa89029..c31d43fb 100644 --- a/contrib/bulk_add/main.php +++ b/contrib/bulk_add/main.php @@ -2,6 +2,7 @@ /* * Name: Bulk Add * Author: Shish + * Link: http://code.shishnet.org/shimmie2/ * License: GPLv2 * Description: Bulk add server-side images * Documentation: @@ -30,7 +31,9 @@ class BulkAdd extends SimpleExtension { $this->theme->display_admin_block(); } - + /** + * Generate the necessary DataUploadEvent for a given image and tags. + */ private function add_image($tmpname, $filename, $tags) { assert(file_exists($tmpname)); diff --git a/contrib/et/main.php b/contrib/et/main.php index dd6babe2..088d21f6 100644 --- a/contrib/et/main.php +++ b/contrib/et/main.php @@ -29,6 +29,9 @@ class ET extends SimpleExtension { } } + /** + * Collect the information and return it in a keyed array. + */ private function get_info() { global $config, $database; global $_event_listeners; // yay for using secret globals \o/ diff --git a/contrib/featured/main.php b/contrib/featured/main.php index 12f06b08..83ace62e 100644 --- a/contrib/featured/main.php +++ b/contrib/featured/main.php @@ -2,6 +2,7 @@ /* * Name: Featured Image * Author: Shish + * Link: http://code.shishnet.org/shimmie2/ * License: GPLv2 * Description: Bring a specific image to the users' attentions * Documentation: diff --git a/contrib/handle_flash/main.php b/contrib/handle_flash/main.php index 013528ac..21b19b30 100644 --- a/contrib/handle_flash/main.php +++ b/contrib/handle_flash/main.php @@ -2,7 +2,8 @@ /* * Name: Handle Flash * Author: Shish - * Description: Handle Flash files + * Link: http://code.shishnet.org/shimmie2/ + * Description: Handle Flash files. (No thumbnail is generated for flash files) */ class FlashFileHandler extends DataHandlerExtension { diff --git a/contrib/handle_svg/main.php b/contrib/handle_svg/main.php index e2d02a3f..bab0cf14 100644 --- a/contrib/handle_svg/main.php +++ b/contrib/handle_svg/main.php @@ -2,7 +2,8 @@ /* * Name: Handle SVG * Author: Shish - * Description: Handle SVG files + * Link: http://code.shishnet.org/shimmie2/ + * Description: Handle SVG files. (No thumbnail is generated for SVG files) */ class SVGFileHandler implements Extension { diff --git a/contrib/ipban/main.php b/contrib/ipban/main.php index bd9a11d0..3af43ead 100644 --- a/contrib/ipban/main.php +++ b/contrib/ipban/main.php @@ -2,6 +2,7 @@ /* * Name: IP Ban * Author: Shish + * Link: http://code.shishnet.org/shimmie2/ * License: GPLv2 * Description: Ban IP addresses * Documentation: diff --git a/contrib/log_db/main.php b/contrib/log_db/main.php index 2e51ce24..da5a590c 100644 --- a/contrib/log_db/main.php +++ b/contrib/log_db/main.php @@ -1,8 +1,9 @@ + * Link: http://code.shishnet.org/shimmie2/ + * Description: Keep a record of SCore events (in the database). * Visibility: admin */ diff --git a/contrib/news/main.php b/contrib/news/main.php index 69c87255..bd3f8388 100644 --- a/contrib/news/main.php +++ b/contrib/news/main.php @@ -2,6 +2,7 @@ /* * Name: News * Author: Shish + * Link: http://code.shishnet.org/shimmie2/ * License: GPLv2 * Description: Show a short amount of text in a block on the post list * Documentation: diff --git a/contrib/numeric_score/main.php b/contrib/numeric_score/main.php index 0e7d5181..79a0ca35 100755 --- a/contrib/numeric_score/main.php +++ b/contrib/numeric_score/main.php @@ -2,6 +2,7 @@ /* * Name: Image Scores (Numeric) * Author: Shish + * Link: http://code.shishnet.org/shimmie2/ * License: GPLv2 * Description: Allow users to score images * Documentation: diff --git a/contrib/random_image/main.php b/contrib/random_image/main.php index bad07792..75fcccf0 100644 --- a/contrib/random_image/main.php +++ b/contrib/random_image/main.php @@ -2,6 +2,7 @@ /* * Name: Random Image * Author: Shish + * Link: http://code.shishnet.org/shimmie2/ * License: GPLv2 * Description: Do things with a random image * Documentation: diff --git a/contrib/rating/main.php b/contrib/rating/main.php index b246b14e..e672c311 100644 --- a/contrib/rating/main.php +++ b/contrib/rating/main.php @@ -2,6 +2,7 @@ /* * Name: Image Ratings * Author: Shish + * Link: http://code.shishnet.org/shimmie2/ * License: GPLv2 * Description: Allow users to rate images "safe", "questionable" or "explicit" */ diff --git a/contrib/regen_thumb/main.php b/contrib/regen_thumb/main.php index cf3e2eb6..22950666 100644 --- a/contrib/regen_thumb/main.php +++ b/contrib/regen_thumb/main.php @@ -2,6 +2,7 @@ /* * Name: Regen Thumb * Author: Shish + * Link: http://code.shishnet.org/shimmie2/ * License: GPLv2 * Description: Regenerate a thumbnail image * Documentation: diff --git a/contrib/site_description/main.php b/contrib/site_description/main.php index 43ed38b1..5f294e3b 100644 --- a/contrib/site_description/main.php +++ b/contrib/site_description/main.php @@ -2,6 +2,7 @@ /* * Name: Site Description * Author: Shish + * Link: http://code.shishnet.org/shimmie2/ * License: GPLv2 * Visibility: admin * Description: A description for search engines diff --git a/ext/tag_list/main.php b/ext/tag_list/main.php index c30aacb6..c7d57716 100644 --- a/ext/tag_list/main.php +++ b/ext/tag_list/main.php @@ -1,7 +1,8 @@ + * Link: http://code.shishnet.org/shimmie2/ * Description: Show the tags in various ways */ @@ -107,13 +108,18 @@ class TagList extends SimpleExtension { return make_link("post/list/$u_tag/1"); } + /** + * Get the minimum number of times a tag needs to be used + * in order to be considered in the tag list. + * @retval int + */ private function get_tags_min() { if(isset($_GET['mincount'])) { return int_escape($_GET['mincount']); } else { global $config; - return $config->get_int('tags_min'); + return $config->get_int('tags_min'); // get the default. } } @@ -170,6 +176,8 @@ class TagList extends SimpleExtension { $tags_min = $this->get_tags_min(); $starts_with = $this->get_starts_with(); + + // check if we have a cached version $cache_key = "data/tag_cloud-" . md5("tc" . $tags_min . $starts_with) . ".html"; if(file_exists($cache_key)) {return file_get_contents($cache_key);} @@ -205,6 +213,8 @@ class TagList extends SimpleExtension { $tags_min = $this->get_tags_min(); $starts_with = $this->get_starts_with(); + + // check if we have a cached version $cache_key = "data/tag_alpha-" . md5("ta" . $tags_min . $starts_with) . ".html"; if(file_exists($cache_key)) {return file_get_contents($cache_key);} @@ -239,6 +249,8 @@ class TagList extends SimpleExtension { global $database; $tags_min = $this->get_tags_min(); + + // check if we have a cached version $cache_key = "data/tag_popul-" . md5("tp" . $tags_min) . ".html"; if(file_exists($cache_key)) {return file_get_contents($cache_key);} diff --git a/ext/upgrade/main.php b/ext/upgrade/main.php index 35854e1d..7445d2d4 100644 --- a/ext/upgrade/main.php +++ b/ext/upgrade/main.php @@ -1,7 +1,8 @@ + * Link: http://code.shishnet.org/shimmie2/ * Description: Keeps things happy behind the scenes * Visibility: admin */