Ejemplo n.º 1
0
 public function onSetupBuilding(SetupBuildingEvent $event)
 {
     $sb = new SetupBlock("Sitemap");
     $sb->add_bool_option("sitemap_generatefull", "Generate full sitemap");
     $sb->add_label("<br>(Enabled: every image and tag in sitemap, generation takes longer)");
     $sb->add_label("<br>(Disabled: only display the last 50 uploads in the sitemap)");
     $event->panel->add_block($sb);
 }
Ejemplo n.º 2
0
 public function onSetupBuilding(SetupBuildingEvent $event)
 {
     $sb = new SetupBlock("Image Rotate");
     $sb->add_bool_option("rotate_enabled", "Allow rotating images: ");
     $sb->add_label("<br>Default Orientation: ");
     $sb->add_int_option("rotate_default_deg");
     $sb->add_label(" deg");
     $event->panel->add_block($sb);
 }
Ejemplo n.º 3
0
 public function onSetupBuilding(SetupBuildingEvent $event)
 {
     $sb = new SetupBlock("Tagger");
     $sb->add_int_option("ext_tagger_search_delay", "Delay queries by ");
     $sb->add_label(" milliseconds.");
     $sb->add_label("<br/>Limit queries returning more than ");
     $sb->add_int_option("ext_tagger_tag_max");
     $sb->add_label(" tags to ");
     $sb->add_int_option("ext_tagger_limit");
     $event->panel->add_block($sb);
 }
Ejemplo n.º 4
0
 public function receive_event(Event $event)
 {
     global $config, $database, $page, $user;
     if (is_null($this->theme)) {
         $this->theme = get_theme_object($this);
     }
     if ($event instanceof InitExtEvent) {
         $config->set_default_int("history_limit", -1);
         // shimmie is being installed so call install to create the table.
         if ($config->get_int("ext_tag_history_version") < 3) {
             $this->install();
         }
     }
     if ($event instanceof PageRequestEvent && $event->page_matches("tag_history")) {
         if ($event->get_arg(0) == "revert") {
             // this is a request to revert to a previous version of the tags
             if ($config->get_bool("tag_edit_anon") || !$user->is_anonymous()) {
                 $this->process_revert_request($_POST['revert']);
             }
         } else {
             if ($event->count_args() == 1) {
                 // must be an attempt to view a tag history
                 $image_id = int_escape($event->get_arg(0));
                 $this->theme->display_history_page($page, $image_id, $this->get_tag_history_from_id($image_id));
             } else {
                 $this->theme->display_global_page($page, $this->get_global_tag_history());
             }
         }
     }
     if ($event instanceof DisplayingImageEvent) {
         // handle displaying a link on the view page
         $this->theme->display_history_link($page, $event->image->id);
     }
     if ($event instanceof ImageDeletionEvent) {
         // handle removing of history when an image is deleted
         $this->delete_all_tag_history($event->image->id);
     }
     if ($event instanceof SetupBuildingEvent) {
         $sb = new SetupBlock("Tag History");
         $sb->add_label("Limit to ");
         $sb->add_int_option("history_limit");
         $sb->add_label(" entires per image");
         $sb->add_label("<br>(-1 for unlimited)");
         $event->panel->add_block($sb);
     }
     if ($event instanceof TagSetEvent) {
         $this->add_tag_history($event->image, $event->tags);
     }
     if ($event instanceof UserBlockBuildingEvent) {
         if ($user->is_admin()) {
             $event->add_link("Tag Changes", make_link("tag_history"));
         }
     }
 }
Ejemplo n.º 5
0
 public function onSetupBuilding($event)
 {
     $sb = new SetupBlock("Image Resize");
     $sb->add_bool_option("resize_enabled", "Allow resizing images: ");
     $sb->add_label("<br>Preset/Default Width: ");
     $sb->add_int_option("resize_default_width");
     $sb->add_label(" px");
     $sb->add_label("<br>Preset/Default Height: ");
     $sb->add_int_option("resize_default_height");
     $sb->add_label(" px");
     $sb->add_label("<br>(enter 0 for no default)");
     $event->panel->add_block($sb);
 }
Ejemplo n.º 6
0
 public function receive_event(Event $event)
 {
     global $config, $database, $page, $user;
     //if(is_null($this->theme)) $this->theme = get_theme_object($this);
     if ($event instanceof ImageInfoBoxBuildingEvent) {
         if (!$config->get_bool("tageditcloud_disable")) {
             if ($this->can_tag($event->image)) {
                 if (!($cfg_minusage = $config->get_int("tageditcloud_minusage"))) {
                     $cfg_minusage = 2;
                 }
                 if (!($cfg_defcount = $config->get_int("tageditcloud_defcount"))) {
                     $cfg_defcount = 40;
                 }
                 if (!($cfg_maxcount = $config->get_int("tageditcloud_maxcount"))) {
                     $cfg_maxcount = 4096;
                 }
                 if ($config->get_string("tageditcloud_sort") != "p") {
                     $event->add_part($this->build_tag_map($event->image, $cfg_minusage, false), 40);
                 } else {
                     $event->add_part($this->build_tag_map($event->image, $cfg_defcount, $cfg_maxcount), 40);
                 }
             }
         }
     }
     if ($event instanceof InitExtEvent) {
         $config->set_default_bool("tageditcloud_disable", false);
         $config->set_default_bool("tageditcloud_usedfirst", true);
         $config->set_default_string("tageditcloud_sort", 'a');
         $config->set_default_int("tageditcloud_minusage", 2);
         $config->set_default_int("tageditcloud_defcount", 40);
         $config->set_default_int("tageditcloud_maxcount", 4096);
     }
     if ($event instanceof SetupBuildingEvent) {
         $sort_by = array('Alphabetical' => 'a', 'Popularity' => 'p');
         $sb = new SetupBlock("Tag Edit Cloud");
         $sb->add_bool_option("tageditcloud_disable", "Disable Tag Selection Cloud: ");
         $sb->add_choice_option("tageditcloud_sort", $sort_by, "<br>Sort the tags by:");
         $sb->add_bool_option("tageditcloud_usedfirst", "<br>Always show used tags first: ");
         $sb->add_label("<br><b>Alpha sort</b>:<br>Only show tags used at least ");
         $sb->add_int_option("tageditcloud_minusage");
         $sb->add_label(" times.<br><b>Popularity sort</b>:<br>Show ");
         $sb->add_int_option("tageditcloud_defcount");
         $sb->add_label(" tags by default.<br>Show a maximum of ");
         $sb->add_int_option("tageditcloud_maxcount");
         $sb->add_label(" tags.");
         $event->panel->add_block($sb);
     }
 }
Ejemplo n.º 7
0
 public function onSetupBuilding(SetupBuildingEvent $event)
 {
     $sb = new SetupBlock("Banned Phrases");
     $sb->add_label("One per line, lines that start with slashes are treated as regex<br/>");
     $sb->add_longtext_option("banned_words");
     $event->panel->add_block($sb);
 }
Ejemplo n.º 8
0
 public function onSetupBuilding($event)
 {
     $sb = new SetupBlock("Blocks");
     $sb->add_label("See <a href='" . make_link("ext_doc/blocks") . "'>the docs</a> for formatting");
     $sb->add_longtext_option("blocks_text");
     $event->panel->add_block($sb);
 }
Ejemplo n.º 9
0
 public function onSetupBuilding(SetupBuildingEvent $event)
 {
     $sb = new SetupBlock("Google Analytics");
     $sb->add_text_option("google_analytics_id", "Analytics ID: ");
     $sb->add_label("<br>(eg. UA-xxxxxxxx-x)");
     $event->panel->add_block($sb);
 }
Ejemplo n.º 10
0
 public function onSetupBuilding(SetupBuildingEvent $event)
 {
     $sb = new SetupBlock("Word Filter");
     $sb->add_longtext_option("word_filter");
     $sb->add_label("<br>(each line should be search term and replace term, separated by a comma)");
     $event->panel->add_block($sb);
 }
Ejemplo n.º 11
0
 public function onSetupBuilding($event)
 {
     $sb = new SetupBlock("Archive Handler Options");
     $sb->add_text_option("archive_tmp_dir", "Temporary folder: ");
     $sb->add_text_option("archive_extract_command", "<br>Extraction command: ");
     $sb->add_label("<br>%f for archive, %d for temporary directory");
     $event->panel->add_block($sb);
 }
Ejemplo n.º 12
0
 public function onSetupBuilding(SetupBuildingEvent $event)
 {
     $sb = new SetupBlock("Banned Phrases");
     $sb->add_label("One per line, lines that start with slashes are treated as regex<br/>");
     $sb->add_longtext_option("banned_words");
     $failed = array();
     foreach ($this->get_words() as $word) {
         if ($word[0] == '/') {
             if (preg_match($word, "") === false) {
                 $failed[] = $word;
             }
         }
     }
     if ($failed) {
         $sb->add_label("Failed regexes: " . join(", ", $failed));
     }
     $event->panel->add_block($sb);
 }
Ejemplo n.º 13
0
 public function onSetupBuilding(SetupBuildingEvent $event)
 {
     $sort_by = array('Alphabetical' => 'a', 'Popularity' => 'p', 'Relevance' => 'r');
     $sb = new SetupBlock("Tag Edit Cloud");
     $sb->add_bool_option("tageditcloud_disable", "Disable Tag Selection Cloud: ");
     $sb->add_choice_option("tageditcloud_sort", $sort_by, "<br>Sort the tags by:");
     $sb->add_bool_option("tageditcloud_usedfirst", "<br>Always show used tags first: ");
     $sb->add_label("<br><b>Alpha sort</b>:<br>Only show tags used at least ");
     $sb->add_int_option("tageditcloud_minusage");
     $sb->add_label(" times.<br><b>Popularity/Relevance sort</b>:<br>Show ");
     $sb->add_int_option("tageditcloud_defcount");
     $sb->add_label(" tags by default.<br>Show a maximum of ");
     $sb->add_int_option("tageditcloud_maxcount");
     $sb->add_label(" tags.");
     $sb->add_label("<br><b>Relevance sort</b>:<br>Ignore tags (space separated): ");
     $sb->add_text_option("tageditcloud_ignoretags");
     $event->panel->add_block($sb);
 }
Ejemplo n.º 14
0
 public function onSetupBuilding(SetupBuildingEvent $event)
 {
     //global $config;
     $thumbers = array();
     $thumbers['None'] = "static";
     $thumbers['ffmpeg'] = "ffmpeg";
     $sb = new SetupBlock("Video Thumbnail Options");
     $sb->add_choice_option("video_thumb_engine", $thumbers, "Engine: ");
     //if($config->get_string("video_thumb_engine") == "ffmpeg") {
     $sb->add_label("<br>Path to ffmpeg: ");
     $sb->add_text_option("thumb_ffmpeg_path");
     //}
     // Some older versions of ffmpeg have trouble with the automatic aspect ratio scaling.
     // This adds an option in the Board Config to disable the aspect ratio scaling.
     $sb->add_label("<br>");
     $sb->add_bool_option("video_thumb_ignore_aspect_ratio", "Ignore aspect ratio when creating thumbnails: ");
     $event->panel->add_block($sb);
 }
Ejemplo n.º 15
0
 public function onSetupBuilding(SetupBuildingEvent $event)
 {
     $sb = new SetupBlock("Mailing Options");
     $sb->add_text_option("mail_sub", "Subject prefix: ");
     $sb->add_text_option("mail_img", "<br>Banner Image URL: ");
     $sb->add_text_option("mail_style", "<br>Style URL: ");
     $sb->add_longtext_option("mail_fot", "<br>Footer (Use HTML)");
     $sb->add_label("<br><i>Should measure 550x110px. Use an absolute URL</i>");
     $event->panel->add_block($sb);
 }
Ejemplo n.º 16
0
 public function onSetupBuilding(SetupBuildingEvent $event)
 {
     $sort_by = array();
     $sort_by['Alphabetical'] = 'a';
     $sort_by['Tag Count'] = 't';
     $sb = new SetupBlock("Browser Search");
     $sb->add_bool_option("disable_search_suggestions", "Disable search suggestions: ");
     $sb->add_label("<br>");
     $sb->add_choice_option("search_suggestions_results_order", $sort_by, "Sort the suggestions by:");
     $event->panel->add_block($sb);
 }
Ejemplo n.º 17
0
 public function receive_event(Event $event)
 {
     if ($event instanceof TextFormattingEvent) {
         $event->formatted = $this->filter($event->formatted);
         $event->stripped = $this->filter($event->stripped);
     }
     if ($event instanceof SetupBuildingEvent) {
         $sb = new SetupBlock("Word Filter");
         $sb->add_longtext_option("word_filter");
         $sb->add_label("<br>(each line should be search term and replace term, separated by a comma)");
         $event->panel->add_block($sb);
     }
 }
Ejemplo n.º 18
0
 public function onSetupBuilding(SetupBuildingEvent $event)
 {
     $sb = new SetupBlock("Resolution Limits");
     $sb->add_label("Min ");
     $sb->add_int_option("upload_min_width");
     $sb->add_label(" x ");
     $sb->add_int_option("upload_min_height");
     $sb->add_label(" px");
     $sb->add_label("<br>Max ");
     $sb->add_int_option("upload_max_width");
     $sb->add_label(" x ");
     $sb->add_int_option("upload_max_height");
     $sb->add_label(" px");
     $sb->add_label("<br>(-1 for no limit)");
     $sb->add_label("<br>Ratios ");
     $sb->add_text_option("upload_ratios");
     $sb->add_label("<br>(eg. '4:3 16:9', blank for no limit)");
     $event->panel->add_block($sb);
 }
Ejemplo n.º 19
0
 public function receive_event(Event $event)
 {
     if (is_null($this->theme)) {
         $this->theme = get_theme_object($this);
     }
     if ($event instanceof DisplayingImageEvent) {
         global $page, $config, $user;
         if ($config->get_bool("tag_edit_anon") || $user->id != $config->get_int("anon_id") && $config->get_bool("ext_tagger_enabled")) {
             $this->theme->build_tagger($page, $event);
         }
     }
     if ($event instanceof SetupBuildingEvent) {
         $sb = new SetupBlock("Tagger");
         $sb->add_bool_option("ext_tagger_enabled", "Enable Tagger");
         $sb->add_int_option("ext_tagger_search_delay", "<br/>Delay queries by ");
         $sb->add_label(" milliseconds.");
         $sb->add_label("<br/>Limit queries returning more than ");
         $sb->add_int_option("ext_tagger_tag_max");
         $sb->add_label(" tags to ");
         $sb->add_int_option("ext_tagger_limit");
         $event->panel->add_block($sb);
     }
 }
Ejemplo n.º 20
0
 public function receive_event(Event $event)
 {
     if ($event instanceof InitExtEvent) {
         global $config;
         $config->set_default_string('banned_words', "\nviagra\nporn\n\t\t\t");
     }
     if ($event instanceof CommentPostingEvent) {
         global $config;
         $banned = $config->get_string("banned_words");
         $comment = strtolower($event->comment);
         foreach (explode("\n", $banned) as $word) {
             $word = trim(strtolower($word));
             if (strlen($word) == 0) {
                 // line is blank
                 continue;
             } else {
                 if ($word[0] == '/') {
                     // lines that start with slash are regex
                     if (preg_match($word, $comment)) {
                         throw new CommentPostingException("Comment contains banned terms");
                     }
                 } else {
                     // other words are literal
                     if (strpos($comment, $word) !== false) {
                         throw new CommentPostingException("Comment contains banned terms");
                     }
                 }
             }
         }
     }
     if ($event instanceof SetupBuildingEvent) {
         $sb = new SetupBlock("Banned Phrases");
         $sb->add_label("One per line, lines that start with slashes are treated as regex<br/>");
         $sb->add_longtext_option("banned_words");
         $event->panel->add_block($sb);
     }
 }
Ejemplo n.º 21
0
 public function onSetupBuilding(SetupBuildingEvent $event)
 {
     $tes = array();
     $tes["Disabled"] = "none";
     if (function_exists("curl_init")) {
         $tes["cURL"] = "curl";
     }
     $tes["fopen"] = "fopen";
     $tes["WGet"] = "wget";
     $sb = new SetupBlock("Upload");
     $sb->position = 10;
     // Output the limits from PHP so the user has an idea of what they can set.
     $sb->add_int_option("upload_count", "Max uploads: ");
     $sb->add_label("<i>PHP Limit = " . ini_get('max_file_uploads') . "</i>");
     $sb->add_shorthand_int_option("upload_size", "<br/>Max size per file: ");
     $sb->add_label("<i>PHP Limit = " . ini_get('upload_max_filesize') . "</i>");
     $sb->add_choice_option("transload_engine", $tes, "<br/>Transload: ");
     $sb->add_bool_option("upload_tlsource", "<br/>Use transloaded URL as source if none is provided: ");
     $event->panel->add_block($sb);
 }
Ejemplo n.º 22
0
 public function receive_event(Event $event)
 {
     global $page;
     global $config;
     if ($event instanceof InitExtEvent) {
         $config->set_default_string("search_suggestions_results_order", 'a');
     }
     // Add in header code to let the browser know that the search plugin exists
     if ($event instanceof PageRequestEvent) {
         // We need to build the data for the header
         global $config;
         $search_title = $config->get_string('title');
         $search_file_url = make_link('browser_search/please_dont_use_this_tag_as_it_would_break_stuff__search.xml');
         $page->add_html_header("<link rel='search' type='application/opensearchdescription+xml' title='{$search_title}' href='{$search_file_url}'>");
     }
     // The search.xml file that is generated on the fly
     if ($event instanceof PageRequestEvent && $event->page_matches("browser_search/please_dont_use_this_tag_as_it_would_break_stuff__search.xml")) {
         // First, we need to build all the variables we'll need
         $search_title = $config->get_string('title');
         //$search_form_url =  $config->get_string('base_href'); //make_link('post/list');
         $search_form_url = make_link('post/list/{searchTerms}');
         $suggenton_url = make_link('browser_search/') . "{searchTerms}";
         $icon_b64 = base64_encode(file_get_contents("favicon.ico"));
         // Now for the XML
         $xml = "\n\t\t\t\t<SearchPlugin xmlns='http://www.mozilla.org/2006/browser/search/' xmlns:os='http://a9.com/-/spec/opensearch/1.1/'>\n\t\t\t\t<os:ShortName>{$search_title}</os:ShortName>\n\t\t\t\t<os:InputEncoding>UTF-8</os:InputEncoding>\n\t\t\t\t<os:Image width='16' height='16'>data:image/x-icon;base64,{$icon_b64}</os:Image>\n\t\t\t\t<SearchForm>{$search_form_url}</SearchForm>\n\t\t\t\t<os:Url type='text/html' method='GET' template='{$search_form_url}'>\n\t\t\t\t  <os:Param name='search' value='{searchTerms}'/>\n\t\t\t\t</os:Url>\n\t\t\t\t<Url type='application/x-suggestions+json' template='{$suggenton_url}'/>\n\t\t\t\t</SearchPlugin>\n\t\t\t";
         // And now to send it to the browser
         $page->set_mode("data");
         $page->set_type("text/xml");
         $page->set_data($xml);
     } else {
         if ($event instanceof PageRequestEvent && ($event->page_matches("browser_search") && !$config->get_bool("disable_search_suggestions"))) {
             global $database;
             // We have to build some json stuff
             $tag_search = $event->get_arg(0);
             // Now to get DB results
             if ($config->get_string("search_suggestions_results_order") == "a") {
                 $tags = $database->execute("SELECT tag FROM tags WHERE tag LIKE ? AND count > 0 ORDER BY tag ASC LIMIT 30", array($tag_search . "%"));
             } else {
                 $tags = $database->execute("SELECT tag FROM tags WHERE tag LIKE ? AND count > 0 ORDER BY count DESC LIMIT 30", array($tag_search . "%"));
             }
             // And to do stuff with it. We want our output to look like:
             // ["shimmie",["shimmies","shimmy","shimmie","21 shimmies","hip shimmies","skea shimmies"],[],[]]
             $json_tag_list = "";
             $tags_array = array();
             foreach ($tags as $tag) {
                 array_push($tags_array, $tag['tag']);
             }
             $json_tag_list .= implode("\",\"", $tags_array);
             //			$json_tag_list = implode($tags_array,", ");
             //			$json_tag_list = "\"".implode($tags_array,"\", \"")."\"";
             // And now for the final output
             $json_string = "[\"{$tag_search}\",[\"{$json_tag_list}\"],[],[]]";
             $page->set_mode("data");
             $page->set_data($json_string);
         }
     }
     if ($event instanceof SetupBuildingEvent) {
         $sort_by = array();
         $sort_by['Alphabetical'] = 'a';
         $sort_by['Tag Count'] = 't';
         $sb = new SetupBlock("Browser Search");
         $sb->add_bool_option("disable_search_suggestions", "Disable search suggestions: ");
         $sb->add_label("<br>");
         $sb->add_choice_option("search_suggestions_results_order", $sort_by, "Sort the suggestions by:");
         $event->panel->add_block($sb);
     }
 }
Ejemplo n.º 23
0
 public function onSetupBuilding(SetupBuildingEvent $event)
 {
     $sb = new SetupBlock("Tag Map Options");
     $sb->add_int_option("tags_min", "Only show tags used at least ");
     $sb->add_label(" times");
     $sb->add_bool_option("tag_list_pages", "<br>Paged tag lists: ");
     $event->panel->add_block($sb);
     $sb = new SetupBlock("Popular / Related Tag List");
     $sb->add_int_option("tag_list_length", "Show top ");
     $sb->add_label(" related tags");
     $sb->add_int_option("popular_tag_list_length", "<br>Show top ");
     $sb->add_label(" popular tags");
     $sb->add_text_option("info_link", "<br>Tag info link: ");
     $sb->add_choice_option("tag_list_image_type", array("Image's tags only" => "tags", "Show related" => "related"), "<br>Image tag list: ");
     $sb->add_choice_option("tag_list_related_sort", array("Tag Count" => "tagcount", "Alphabetical" => "alphabetical"), "<br>Sort related list by: ");
     $sb->add_choice_option("tag_list_popular_sort", array("Tag Count" => "tagcount", "Alphabetical" => "alphabetical"), "<br>Sort popular list by: ");
     $sb->add_bool_option("tag_list_numbers", "<br>Show tag counts: ");
     $event->panel->add_block($sb);
 }
Ejemplo n.º 24
0
 public function onSetupBuilding($event)
 {
     $sb = new SetupBlock("Comment Options");
     $sb->add_bool_option("comment_anon", "Allow anonymous comments: ");
     $sb->add_bool_option("comment_captcha", "<br>Require CAPTCHA for anonymous comments: ");
     $sb->add_label("<br>Limit to ");
     $sb->add_int_option("comment_limit");
     $sb->add_label(" comments per ");
     $sb->add_int_option("comment_window");
     $sb->add_label(" minutes");
     $sb->add_label("<br>Show ");
     $sb->add_int_option("comment_count");
     $sb->add_label(" recent comments on the index");
     $sb->add_label("<br>Show ");
     $sb->add_int_option("comment_list_count");
     $sb->add_label(" comments per image on the list");
     $event->panel->add_block($sb);
 }
Ejemplo n.º 25
0
 public function receive_event(Event $event)
 {
     if ($event instanceof ImageAdditionEvent) {
         global $config;
         $min_w = $config->get_int("upload_min_width", -1);
         $min_h = $config->get_int("upload_min_height", -1);
         $max_w = $config->get_int("upload_max_width", -1);
         $max_h = $config->get_int("upload_max_height", -1);
         $ratios = explode(" ", $config->get_string("upload_ratios", ""));
         $image = $event->image;
         if ($min_w > 0 && $image->width < $min_w) {
             throw new UploadException("Image too small");
         }
         if ($min_h > 0 && $image->height < $min_h) {
             throw new UploadException("Image too small");
         }
         if ($max_w > 0 && $image->width > $max_w) {
             throw new UploadException("Image too large");
         }
         if ($max_h > 0 && $image->height > $max_h) {
             throw new UploadException("Image too large");
         }
         if (count($ratios) > 0) {
             $ok = false;
             $valids = 0;
             foreach ($ratios as $ratio) {
                 $parts = explode(":", $ratio);
                 if (count($parts) < 2) {
                     continue;
                 }
                 $valids++;
                 $width = $parts[0];
                 $height = $parts[1];
                 if ($image->width / $width == $image->height / $height) {
                     $ok = true;
                     break;
                 }
             }
             if ($valids > 0 && !$ok) {
                 throw new UploadException("Image needs to be in one of these ratios: " . html_escape($config->get_string("upload_ratios", "")));
             }
         }
     }
     if ($event instanceof SetupBuildingEvent) {
         $sb = new SetupBlock("Resolution Limits");
         $sb->add_label("Min ");
         $sb->add_int_option("upload_min_width");
         $sb->add_label(" x ");
         $sb->add_int_option("upload_min_height");
         $sb->add_label(" px");
         $sb->add_label("<br>Max ");
         $sb->add_int_option("upload_max_width");
         $sb->add_label(" x ");
         $sb->add_int_option("upload_max_height");
         $sb->add_label(" px");
         $sb->add_label("<br>(-1 for no limit)");
         $sb->add_label("<br>Ratios ");
         $sb->add_text_option("upload_ratios");
         $sb->add_label("<br>(eg. '4:3 16:9', blank for no limit)");
         $event->panel->add_block($sb);
     }
 }
Ejemplo n.º 26
0
 public function onSetupBuilding($event)
 {
     $sb = new SetupBlock("Index Options");
     $sb->position = 20;
     $sb->add_label("Index table size ");
     $sb->add_int_option("index_width");
     $sb->add_label(" x ");
     $sb->add_int_option("index_height");
     $sb->add_label(" images");
     $event->panel->add_block($sb);
 }
Ejemplo n.º 27
0
 public function receive_event(Event $event)
 {
     global $config, $database, $page, $user;
     if ($this->theme == null) {
         $this->theme = get_theme_object($this);
     }
     if ($event instanceof InitExtEvent) {
         $config->set_default_int("tag_list_length", 15);
         $config->set_default_int("popular_tag_list_length", 15);
         $config->set_default_int("tags_min", 3);
         $config->set_default_string("info_link", 'http://en.wikipedia.org/wiki/$tag');
         $config->set_default_string("tag_list_image_type", 'related');
         $config->set_default_bool("tag_list_pages", false);
     }
     if ($event instanceof PageRequestEvent && $event->page_matches("tags")) {
         $this->theme->set_navigation($this->build_navigation());
         switch ($event->get_arg(0)) {
             default:
             case 'map':
                 $this->theme->set_heading("Tag Map");
                 $this->theme->set_tag_list($this->build_tag_map());
                 break;
             case 'alphabetic':
                 $this->theme->set_heading("Alphabetic Tag List");
                 $this->theme->set_tag_list($this->build_tag_alphabetic());
                 break;
             case 'popularity':
                 $this->theme->set_heading("Tag List by Popularity");
                 $this->theme->set_tag_list($this->build_tag_popularity());
                 break;
             case 'categories':
                 $this->theme->set_heading("Popular Categories");
                 $this->theme->set_tag_list($this->build_tag_categories());
                 break;
         }
         $this->theme->display_page($page);
     }
     if ($event instanceof PageRequestEvent && $event->page_matches("api/internal/tag_list/complete")) {
         $all = $database->get_all("SELECT tag FROM tags WHERE tag LIKE :search AND count > 0 LIMIT 10", array("search" => $_GET["s"] . "%"));
         $res = array();
         foreach ($all as $row) {
             $res[] = $row["tag"];
         }
         $page->set_mode("data");
         $page->set_type("text/plain");
         $page->set_data(implode("\n", $res));
     }
     if ($event instanceof PostListBuildingEvent) {
         if ($config->get_int('tag_list_length') > 0) {
             if (!empty($event->search_terms)) {
                 $this->add_refine_block($page, $event->search_terms);
             } else {
                 $this->add_popular_block($page);
             }
         }
     }
     if ($event instanceof DisplayingImageEvent) {
         if ($config->get_int('tag_list_length') > 0) {
             if ($config->get_string('tag_list_image_type') == 'related') {
                 $this->add_related_block($page, $event->image);
             } else {
                 $this->add_tags_block($page, $event->image);
             }
         }
     }
     if ($event instanceof SetupBuildingEvent) {
         $sb = new SetupBlock("Tag Map Options");
         $sb->add_int_option("tags_min", "Only show tags used at least ");
         $sb->add_label(" times");
         $sb->add_bool_option("tag_list_pages", "<br>Paged tag lists: ");
         $event->panel->add_block($sb);
         $sb = new SetupBlock("Popular / Related Tag List");
         $sb->add_int_option("tag_list_length", "Show top ");
         $sb->add_label(" related tags");
         $sb->add_int_option("popular_tag_list_length", "<br>Show top ");
         $sb->add_label(" popular tags");
         $sb->add_text_option("info_link", "<br>Tag info link: ");
         $sb->add_choice_option("tag_list_image_type", array("Image's tags only" => "tags", "Show related" => "related"), "<br>Image tag list: ");
         $sb->add_bool_option("tag_list_numbers", "<br>Show tag counts: ");
         $event->panel->add_block($sb);
     }
 }
Ejemplo n.º 28
0
 public function onSetupBuilding(SetupBuildingEvent $event)
 {
     $themes = array();
     foreach (glob("themes/*") as $theme_dirname) {
         $name = str_replace("themes/", "", $theme_dirname);
         $human = str_replace("_", " ", $name);
         $human = ucwords($human);
         $themes[$human] = $name;
     }
     if (isset($_SERVER["HTTP_HOST"])) {
         $host = $_SERVER["HTTP_HOST"];
     } else {
         $host = $_SERVER["SERVER_NAME"];
         if ($_SERVER["SERVER_PORT"] != "80") {
             $host .= ":" . $_SERVER["SERVER_PORT"];
         }
     }
     $full = (@$_SERVER["HTTPS"] ? "https://" : "http://") . $host . $_SERVER["PHP_SELF"];
     $test_url = str_replace("/index.php", "/nicetest", $full);
     $nicescript = "<script language='javascript'>\n\t\t\tfunction getHTTPObject() {\n\t\t\t\tif (window.XMLHttpRequest){\n\t\t\t\t\treturn new XMLHttpRequest();\n\t\t\t\t}\n\t\t\t\telse if(window.ActiveXObject){\n\t\t\t\t\treturn new ActiveXObject('Microsoft.XMLHTTP');\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tcheckbox = document.getElementById('nice_urls');\n\t\t\tout_span = document.getElementById('nicetest');\n\n\t\t\tcheckbox.disabled = true;\n\t\t\tout_span.innerHTML = '(testing...)';\n\n\t\t\t\$(document).ready(function() {\n\t\t\t\tvar http_request = getHTTPObject();\n\t\t\t\thttp_request.open('GET', '{$test_url}', false);\n\t\t\t\thttp_request.send(null);\n\n\t\t\t\tif(http_request.status == 200 && http_request.responseText == 'ok') {\n\t\t\t\t\tcheckbox.disabled = false;\n\t\t\t\t\tout_span.innerHTML = '(tested ok)';\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tcheckbox.disabled = true;\n\t\t\t\t\tout_span.innerHTML = '(test failed)';\n\t\t\t\t}\n\t\t\t});\n\t\t</script>";
     $sb = new SetupBlock("General");
     $sb->position = 0;
     $sb->add_text_option("title", "Site title: ");
     $sb->add_text_option("front_page", "<br>Front page: ");
     $sb->add_text_option("main_page", "<br>Main page: ");
     $sb->add_text_option("contact_link", "<br>Contact URL: ");
     $sb->add_choice_option("theme", $themes, "<br>Theme: ");
     //$sb->add_multichoice_option("testarray", array("a" => "b", "c" => "d"), "<br>Test Array: ");
     $sb->add_bool_option("nice_urls", "<br>Nice URLs: ");
     $sb->add_label("<span id='nicetest'>(Javascript inactive, can't test!)</span>{$nicescript}");
     $event->panel->add_block($sb);
     $sb = new SetupBlock("Remote API Integration");
     $sb->add_label("<a href='http://akismet.com/'>Akismet</a>");
     $sb->add_text_option("comment_wordpress_key", "<br>API key: ");
     $sb->add_label("<br>&nbsp;<br><a href='" . recaptcha_get_signup_url($_SERVER["HTTP_HOST"], "Shimmie") . "'>ReCAPTCHA</a>");
     $sb->add_text_option("api_recaptcha_privkey", "<br>Private key: ");
     $sb->add_text_option("api_recaptcha_pubkey", "<br>Public key: ");
     $event->panel->add_block($sb);
 }
Ejemplo n.º 29
0
 public function onSetupBuilding(Event $event)
 {
     global $config;
     $hosts = array("None" => "none", "Gravatar" => "gravatar");
     $sb = new SetupBlock("User Options");
     $sb->add_bool_option("login_signup_enabled", "Allow new signups: ");
     $sb->add_longtext_option("login_tac", "<br>Terms &amp; Conditions:<br>");
     $sb->add_choice_option("avatar_host", $hosts, "<br>Avatars: ");
     if ($config->get_string("avatar_host") == "gravatar") {
         $sb->add_label("<br>&nbsp;<br><b>Gravatar Options</b>");
         $sb->add_choice_option("avatar_gravatar_type", array('Default' => 'default', 'Wavatar' => 'wavatar', 'Monster ID' => 'monsterid', 'Identicon' => 'identicon'), "<br>Type: ");
         $sb->add_choice_option("avatar_gravatar_rating", array('G' => 'g', 'PG' => 'pg', 'R' => 'r', 'X' => 'x'), "<br>Rating: ");
     }
     $event->panel->add_block($sb);
 }
Ejemplo n.º 30
0
 public function receive_event(Event $event)
 {
     global $config, $database, $page, $user;
     if (is_null($this->theme)) {
         $this->theme = get_theme_object($this);
     }
     // f*****g PHP "security" measures -_-;;;
     $free_num = @disk_free_space(realpath("./images/"));
     if ($free_num === FALSE) {
         $is_full = false;
     } else {
         $is_full = $free_num < 100 * 1024 * 1024;
     }
     if ($event instanceof InitExtEvent) {
         $config->set_default_int('upload_count', 3);
         $config->set_default_int('upload_size', '1MB');
         $config->set_default_bool('upload_anon', false);
         $config->set_default_bool('upload_replace', true);
     }
     if ($event instanceof PostListBuildingEvent) {
         if ($this->can_upload($user)) {
             if ($is_full) {
                 $this->theme->display_full($page);
             } else {
                 $this->theme->display_block($page);
             }
         }
     }
     if ($event instanceof PageRequestEvent) {
         if ($event->page_matches("upload/replace")) {
             /* Upload & Replace Image Request */
             if (!$config->get_bool("upload_replace")) {
                 throw new UploadException("Upload Replacing Images is not enabled.");
             }
             // check if the user is an administrator and can upload files.
             if (!$user->is_admin()) {
                 $this->theme->display_permission_denied($page);
             } else {
                 if ($is_full) {
                     throw new UploadException("Can not replace Image: disk nearly full");
                 }
                 // Try to get the image ID
                 $image_id = int_escape($event->get_arg(0));
                 if (empty($image_id)) {
                     $image_id = isset($_POST['image_id']) ? $_POST['image_id'] : null;
                 }
                 if (empty($image_id)) {
                     throw new UploadException("Can not replace Image: No valid Image ID given.");
                 }
                 $image_old = Image::by_id($image_id);
                 if (is_null($image_old)) {
                     $this->theme->display_error($page, "Image not found", "No image in the database has the ID #{$image_id}");
                 }
                 if (count($_FILES) + count($_POST) > 0) {
                     if (count($_FILES) > 1) {
                         throw new UploadException("Can not upload more than one image for replacing.");
                     }
                     $source = isset($_POST['source']) ? $_POST['source'] : null;
                     $tags = '';
                     // Tags aren't changed when uploading. Set to null to stop PHP warnings.
                     if (count($_FILES)) {
                         foreach ($_FILES as $file) {
                             $ok = $this->try_upload($file, $tags, $source, $image_id);
                             break;
                             // leave the foreach loop.
                         }
                     } else {
                         foreach ($_POST as $name => $value) {
                             if (substr($name, 0, 3) == "url" && strlen($value) > 0) {
                                 $ok = $this->try_transload($value, $tags, $source, $image_id);
                                 break;
                                 // leave the foreach loop.
                             }
                         }
                     }
                     $this->theme->display_upload_status($page, $ok);
                 } else {
                     if (!empty($_GET['url'])) {
                         $url = $_GET['url'];
                         $ok = $this->try_transload($url, $tags, $url, $image_id);
                         $this->theme->display_upload_status($page, $ok);
                     } else {
                         $this->theme->display_replace_page($page, $image_id);
                     }
                 }
             }
             // END of if admin / can_upload
         } else {
             if ($event->page_matches("upload")) {
                 if (!$this->can_upload($user)) {
                     $this->theme->display_permission_denied($page);
                 } else {
                     /* Regular Upload Image */
                     if (count($_FILES) + count($_POST) > 0) {
                         $tags = Tag::explode($_POST['tags']);
                         $source = isset($_POST['source']) ? $_POST['source'] : null;
                         $ok = true;
                         foreach ($_FILES as $file) {
                             $ok = $ok & $this->try_upload($file, $tags, $source);
                         }
                         foreach ($_POST as $name => $value) {
                             if (substr($name, 0, 3) == "url" && strlen($value) > 0) {
                                 $ok = $ok & $this->try_transload($value, $tags, $source);
                             }
                         }
                         $this->theme->display_upload_status($page, $ok);
                     } else {
                         if (!empty($_GET['url'])) {
                             $url = $_GET['url'];
                             $tags = array('tagme');
                             if (!empty($_GET['tags']) && $_GET['tags'] != "null") {
                                 $tags = Tag::explode($_GET['tags']);
                             }
                             $ok = $this->try_transload($url, $tags, $url);
                             $this->theme->display_upload_status($page, $ok);
                         } else {
                             if (!$is_full) {
                                 $this->theme->display_page($page);
                             }
                         }
                     }
                 }
                 // END of if  can_upload
             }
         }
     }
     // END of if PageRequestEvent
     if ($event instanceof SetupBuildingEvent) {
         $tes = array();
         $tes["Disabled"] = "none";
         if (function_exists("curl_init")) {
             $tes["cURL"] = "curl";
         }
         $tes["fopen"] = "fopen";
         $tes["WGet"] = "wget";
         $sb = new SetupBlock("Upload");
         $sb->position = 10;
         // Output the limits from PHP so the user has an idea of what they can set.
         $sb->add_label("<i>PHP's Upload Limit = " . ini_get('max_file_uploads') . "</i><br/>");
         $sb->add_int_option("upload_count", "Max uploads: ");
         $sb->add_label("<br/><i>PHP's Max Size Upload = " . ini_get('upload_max_filesize') . "</i><br/>");
         $sb->add_shorthand_int_option("upload_size", "<br/>Max size per file: ");
         $sb->add_bool_option("upload_anon", "<br/>Allow anonymous uploads: ");
         $sb->add_bool_option("upload_replace", "<br/>Allow replacing images: ");
         $sb->add_choice_option("transload_engine", $tes, "<br/>Transload: ");
         $event->panel->add_block($sb);
     }
     if ($event instanceof DataUploadEvent) {
         if ($is_full) {
             throw new UploadException("Upload failed; disk nearly full");
         }
         if (filesize($event->tmpname) > $config->get_int('upload_size')) {
             $size = to_shorthand_int(filesize($event->tmpname));
             $limit = to_shorthand_int($config->get_int('upload_size'));
             throw new UploadException("File too large ({$size} &gt; {$limit})");
         }
     }
 }