Esempio n. 1
0
 public function onSetupBuilding(SetupBuildingEvent $event)
 {
     $sb = new SetupBlock("Pools");
     $sb->add_int_option("poolsMaxImportResults", "Max results on import: ");
     $sb->add_int_option("poolsImagesPerPage", "<br>Images per page: ");
     $sb->add_int_option("poolsListsPerPage", "<br>Index list items per page: ");
     $sb->add_int_option("poolsUpdatedPerPage", "<br>Updated list items per page: ");
     $sb->add_bool_option("poolsInfoOnViewImage", "<br>Show pool info on image: ");
     $sb->add_bool_option("poolsShowNavLinks", "<br>Show 'Prev' & 'Next' links when viewing pool images: ");
     $sb->add_bool_option("poolsAutoIncrementOrder", "<br>Autoincrement order when post is added to pool:");
     //$sb->add_bool_option("poolsAdderOnViewImage", "<br>Show pool adder on image: ");
     $event->panel->add_block($sb);
 }
Esempio n. 2
0
 public function onSetupBuilding(SetupBuildingEvent $event)
 {
     $sb = new SetupBlock("Image Resize");
     $sb->add_bool_option("resize_enabled", "Allow resizing images: ");
     $sb->add_bool_option("resize_upload", "<br>Resize on upload: ");
     $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);
 }
Esempio n. 3
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);
     }
 }
Esempio n. 4
0
 public function onSetupBuilding(SetupBuildingEvent $event)
 {
     global $config;
     $sb = new SetupBlock("Holiday Theme");
     $sb->add_bool_option("holiday_aprilfools", "Enable April Fools");
     $event->panel->add_block($sb);
 }
Esempio n. 5
0
 public function onSetupBuilding(SetupBuildingEvent $event)
 {
     $sb = new SetupBlock("Downtime");
     $sb->add_bool_option("downtime", "Disable non-admin access: ");
     $sb->add_longtext_option("downtime_message", "<br>");
     $event->panel->add_block($sb);
 }
Esempio n. 6
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);
 }
Esempio n. 7
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);
 }
Esempio n. 8
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);
 }
Esempio n. 9
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);
 }
Esempio n. 10
0
 public function onSetupBuilding(SetupBuildingEvent $event)
 {
     $sb = new SetupBlock("Pools");
     $sb->add_int_option("poolsMaxImportResults", "Max results on import: ");
     $sb->add_int_option("poolsImagesPerPage", "<br>Images per page: ");
     $sb->add_int_option("poolsListsPerPage", "<br>Index list items per page: ");
     $sb->add_int_option("poolsUpdatedPerPage", "<br>Updated list items per page: ");
     $sb->add_bool_option("poolsInfoOnViewImage", "<br>Show pool info on image: ");
     //$sb->add_bool_option("poolsAdderOnViewImage", "<br>Show pool adder on image: ");
     $event->panel->add_block($sb);
 }
Esempio n. 11
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);
 }
Esempio n. 12
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 SetupBuildingEvent) {
         $sb = new SetupBlock("Downtime");
         $sb->add_bool_option("downtime", "Disable non-admin access: ");
         $sb->add_longtext_option("downtime_message", "<br>");
         $event->panel->add_block($sb);
     }
     if ($event instanceof PageRequestEvent) {
         if ($config->get_bool("downtime")) {
             $this->check_downtime($event);
             $this->theme->display_notification($page);
         }
     }
 }
Esempio n. 13
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);
     }
 }
Esempio n. 14
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})");
         }
     }
 }
Esempio n. 15
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);
 }
Esempio n. 16
0
 public function onSetupBuilding(SetupBuildingEvent $event)
 {
     $sb = new SetupBlock("Random Image");
     $sb->add_bool_option("show_random_block", "Show Random Block: ");
     $event->panel->add_block($sb);
 }
Esempio n. 17
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);
 }
Esempio n. 18
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);
 }
Esempio n. 19
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_bool('report_image_show_thumbs', true);
         if ($config->get_int("ext_report_image_version") < 1) {
             $this->install();
         }
     }
     if ($event instanceof PageRequestEvent && $event->page_matches("image_report")) {
         if ($event->get_arg(0) == "add") {
             if (isset($_POST['image_id']) && isset($_POST['reason'])) {
                 $image_id = int_escape($_POST['image_id']);
                 send_event(new AddReportedImageEvent($image_id, $user->id, $_POST['reason']));
                 $page->set_mode("redirect");
                 $page->set_redirect(make_link("post/view/{$image_id}"));
             }
         } else {
             if ($event->get_arg(0) == "remove") {
                 if (isset($_POST['id'])) {
                     if ($user->is_admin()) {
                         send_event(new RemoveReportedImageEvent($_POST['id']));
                         $page->set_mode("redirect");
                         $page->set_redirect(make_link("image_report/list"));
                     }
                 }
             } else {
                 if ($event->get_arg(0) == "list") {
                     if ($user->is_admin()) {
                         $this->theme->display_reported_images($page, $this->get_reported_images());
                     }
                 }
             }
         }
     }
     if ($event instanceof AddReportedImageEvent) {
         $database->Execute("INSERT INTO image_reports(image_id, reporter_id, reason)\n\t\t\t\t\tVALUES (?, ?, ?)", array($event->image_id, $event->reporter_id, $event->reason));
     }
     if ($event instanceof RemoveReportedImageEvent) {
         $database->Execute("DELETE FROM image_reports WHERE id = ?", array($event->id));
     }
     if ($event instanceof DisplayingImageEvent) {
         if ($config->get_bool('report_image_anon') || !$user->is_anonymous()) {
             $this->theme->display_image_banner($page, $event->image);
         }
     }
     if ($event instanceof SetupBuildingEvent) {
         $sb = new SetupBlock("Report Image Options");
         $sb->add_bool_option("report_image_anon", "Allow anonymous image reporting: ");
         $sb->add_bool_option("report_image_show_thumbs", "<br>Show thumbnails in admin panel: ");
         $event->panel->add_block($sb);
     }
     if ($event instanceof UserBlockBuildingEvent) {
         if ($user->is_admin()) {
             $event->add_link("Reported Images", make_link("image_report/list"));
         }
     }
     if ($event instanceof ImageDeletionEvent) {
         $database->Execute("DELETE FROM image_reports WHERE image_id = ?", array($event->image->id));
     }
 }
Esempio n. 20
0
 public function onSetupBuilding($event)
 {
     $sb = new SetupBlock("Image Zoom");
     $sb->add_bool_option("image_zoom", "Zoom by default: ");
     $event->panel->add_block($sb);
 }
Esempio n. 21
0
 public function onSetupBuilding($event)
 {
     $sb = new SetupBlock("Wiki");
     $sb->add_bool_option("wiki_edit_anon", "Allow anonymous edits: ");
     $sb->add_bool_option("wiki_edit_user", "<br>Allow user edits: ");
     $event->panel->add_block($sb);
 }
Esempio n. 22
0
 public function onSetupBuilding(Event $event)
 {
     $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>");
     $event->panel->add_block($sb);
 }
Esempio n. 23
0
 public function onSetupBuilding(SetupBuildingEvent $event)
 {
     global $config;
     $sb = new SetupBlock("Image Options");
     $sb->position = 30;
     // advanced only
     //$sb->add_text_option("image_ilink", "Image link: ");
     //$sb->add_text_option("image_tlink", "<br>Thumbnail link: ");
     $sb->add_text_option("image_tip", "Image tooltip: ");
     $sb->add_choice_option("upload_collision_handler", array('Error' => 'error', 'Merge' => 'merge'), "<br>Upload collision handler: ");
     if (function_exists("exif_read_data")) {
         $sb->add_bool_option("image_show_meta", "<br>Show metadata: ");
     }
     $event->panel->add_block($sb);
     $thumbers = array();
     $thumbers['Built-in GD'] = "gd";
     $thumbers['ImageMagick'] = "convert";
     $sb = new SetupBlock("Thumbnailing");
     $sb->add_choice_option("thumb_engine", $thumbers, "Engine: ");
     $sb->add_label("<br>Size ");
     $sb->add_int_option("thumb_width");
     $sb->add_label(" x ");
     $sb->add_int_option("thumb_height");
     $sb->add_label(" px at ");
     $sb->add_int_option("thumb_quality");
     $sb->add_label(" % quality ");
     if ($config->get_string("thumb_engine") == "convert") {
         $sb->add_label("<br>ImageMagick Binary: ");
         $sb->add_text_option("thumb_convert_path");
     }
     if ($config->get_string("thumb_engine") == "gd") {
         $sb->add_shorthand_int_option("thumb_mem_limit", "<br>Max memory use: ");
     }
     $event->panel->add_block($sb);
 }
Esempio n. 24
0
 public function receive_event(Event $event)
 {
     global $config, $database, $page, $user;
     if (is_null($this->theme)) {
         $this->theme = get_theme_object($this);
     }
     $is_full = disk_free_space(realpath("./images/")) < 100 * 1024 * 1024;
     if ($event instanceof InitExtEvent) {
         global $config;
         $config->set_default_int('upload_count', 3);
         $config->set_default_int('upload_size', '1MB');
         $config->set_default_bool('upload_anon', false);
     }
     if ($event instanceof PostListBuildingEvent) {
         global $user;
         if ($this->can_upload($user)) {
             if ($is_full) {
                 $this->theme->display_full($page);
             } else {
                 $this->theme->display_block($page);
             }
         }
     }
     if ($event instanceof PageRequestEvent && $event->page_matches("upload")) {
         if (count($_FILES) + count($_POST) > 0) {
             $tags = Tag::explode($_POST['tags']);
             $source = isset($_POST['source']) ? $_POST['source'] : null;
             if ($this->can_upload($user)) {
                 $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 {
                 $this->theme->display_permission_denied($page);
             }
         } else {
             if (!empty($_GET['url'])) {
                 global $user;
                 if ($this->can_upload($user)) {
                     $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 {
                     $this->theme->display_permission_denied($page);
                 }
             } else {
                 if (!$is_full) {
                     $this->theme->display_page($page);
                 }
             }
         }
     }
     if ($event instanceof SetupBuildingEvent) {
         $sb = new SetupBlock("Upload");
         $sb->position = 10;
         $sb->add_int_option("upload_count", "Max uploads: ");
         $sb->add_shorthand_int_option("upload_size", "<br>Max size per file: ");
         $sb->add_bool_option("upload_anon", "<br>Allow anonymous uploads: ");
         $sb->add_choice_option("transload_engine", array("Disabled" => "none", "cURL" => "curl", "fopen" => "fopen", "WGet" => "wget"), "<br>Transload: ");
         $event->panel->add_block($sb);
     }
     if ($event instanceof DataUploadEvent) {
         global $config;
         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})");
         }
     }
 }
Esempio n. 25
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);
 }
Esempio n. 26
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);
     }
 }
Esempio 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);
     }
 }
Esempio n. 28
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 PageRequestEvent && $event->page_matches("tag_edit")) {
         if ($event->get_arg(0) == "replace") {
             if ($user->is_admin() && isset($_POST['search']) && isset($_POST['replace'])) {
                 $search = $_POST['search'];
                 $replace = $_POST['replace'];
                 $this->mass_tag_edit($search, $replace);
                 $page->set_mode("redirect");
                 $page->set_redirect(make_link("admin"));
             }
         }
     }
     if ($event instanceof ImageInfoSetEvent) {
         if ($this->can_tag()) {
             send_event(new TagSetEvent($event->image, $_POST['tag_edit__tags']));
             if ($this->can_source()) {
                 send_event(new SourceSetEvent($event->image, $_POST['tag_edit__source']));
             }
         } else {
             $this->theme->display_error($page, "Error", "Anonymous tag editing is disabled");
         }
     }
     if ($event instanceof TagSetEvent) {
         $event->image->set_tags($event->tags);
     }
     if ($event instanceof SourceSetEvent) {
         $event->image->set_source($event->source);
     }
     if ($event instanceof ImageDeletionEvent) {
         $event->image->delete_tags_from_image();
     }
     if ($event instanceof AdminBuildingEvent) {
         $this->theme->display_mass_editor($page);
     }
     // When an alias is added, oldtag becomes inaccessable
     if ($event instanceof AddAliasEvent) {
         $this->mass_tag_edit($event->oldtag, $event->newtag);
     }
     if ($event instanceof ImageInfoBoxBuildingEvent) {
         if ($config->get_bool("tag_edit_anon") || !$user->is_anonymous()) {
             $event->add_part($this->theme->get_tag_editor_html($event->image), 40);
         }
         if ($config->get_bool("source_edit_anon") || !$user->is_anonymous()) {
             $event->add_part($this->theme->get_source_editor_html($event->image), 41);
         }
     }
     if ($event instanceof SetupBuildingEvent) {
         $sb = new SetupBlock("Tag Editing");
         $sb->add_bool_option("tag_edit_anon", "Allow anonymous tag editing: ");
         $sb->add_bool_option("source_edit_anon", "<br>Allow anonymous source editing: ");
         $event->panel->add_block($sb);
     }
 }
Esempio n. 29
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);
 }
Esempio n. 30
0
 public function onSetupBuilding(SetupBuildingEvent $event)
 {
     $sb = new SetupBlock("Image View Counter");
     $sb->add_bool_option("image_viewcounter_adminonly", "Display view counter only to admin");
     $event->panel->add_block($sb);
 }