public function onSetupBuilding(SetupBuildingEvent $event) { $privs = array(); $privs['Safe Only'] = 's'; $privs['Safe and Unknown'] = 'su'; $privs['Safe and Questionable'] = 'sq'; $privs['Safe, Questionable, Unknown'] = 'squ'; $privs['All'] = 'sqeu'; $sb = new SetupBlock("Image Ratings"); $sb->add_choice_option("ext_rating_anon_privs", $privs, "Anonymous: "); $sb->add_choice_option("ext_rating_user_privs", $privs, "<br>Users: "); $sb->add_choice_option("ext_rating_admin_privs", $privs, "<br>Admins: "); $event->panel->add_block($sb); }
public function onSetupBuilding(SetupBuildingEvent $event) { $sb = new SetupBlock("Blotter"); $sb->add_int_option("blotter_recent", "<br />Number of recent entries to display: "); $sb->add_text_option("blotter_color", "<br />Color of important updates: (ABCDEF format) "); $sb->add_choice_option("blotter_position", array("Top of page" => "subheading", "In navigation bar" => "left"), "<br>Position: "); $event->panel->add_block($sb); }
public function onSetupBuilding(SetupBuildingEvent $event) { $sb = new SetupBlock("Custom HTML Headers"); // custom headers $sb->add_longtext_option("custom_html_headers", "HTML Code to place within <head></head> on all pages<br>"); // modified title $sb->add_choice_option("sitename_in_title", array("none" => 0, "as prefix" => 1, "as suffix" => 2), "<br>Add website name in title"); $event->panel->add_block($sb); }
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); }
public function onSetupBuilding($event) { $counters = array(); foreach (glob("ext/home/counters/*") as $counter_dirname) { $name = str_replace("ext/home/counters/", "", $counter_dirname); $counters[ucfirst($name)] = $name; } $sb = new SetupBlock("Home Page"); $sb->add_longtext_option("home_links", 'Page Links - Example: [/post/list|Posts]<br>'); $sb->add_longtext_option("home_text", "<br>Page Text:<br>"); $sb->add_choice_option("home_counter", $counters, "<br>Counter: "); $event->panel->add_block($sb); }
public function onSetupBuilding(SetupBuildingEvent $event) { $counters = array(); foreach (glob("ext/home/counters/*") as $counter_dirname) { $name = str_replace("ext/home/counters/", "", $counter_dirname); $counters[ucfirst($name)] = $name; } $sb = new SetupBlock("Home Page"); $sb->add_longtext_option("home_links", 'Page Links (Use BBCode, leave blank for defaults)'); $sb->add_longtext_option("home_text", "<br>Page Text:<br>"); $sb->add_choice_option("home_counter", $counters, "<br>Counter: "); $event->panel->add_block($sb); }
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); } }
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); }
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); }
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); } }
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); }
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> <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); }
public function onSetupBuilding($event) { $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 (!in_array("OS", $_SERVER) || $_SERVER["OS"] != 'Windows_NT') { $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 "); $sb->add_shorthand_int_option("thumb_mem_limit", "<br>Max memory use: "); $event->panel->add_block($sb); }
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 AdminBuildingEvent) { $this->theme->display_bulk_rater(); } if ($event instanceof PageRequestEvent && $event->page_matches("admin/bulk_rate")) { global $database, $user, $page; if (!$user->is_admin()) { throw PermissionDeniedException(); } else { $n = 0; while (true) { $images = Image::find_images($n, 100, Tag::explode($_POST["query"])); if (count($images) == 0) { break; } foreach ($images as $image) { send_event(new RatingSetEvent($image, $user, $_POST['rating'])); } $n += 100; } #$database->execute(" # update images set rating=? where images.id in ( # select image_id from image_tags join tags # on image_tags.tag_id = tags.id where tags.tag = ?); # ", array($_POST["rating"], $_POST["tag"])); $page->set_mode("redirect"); $page->set_redirect(make_link("admin")); } } if ($event instanceof InitExtEvent) { if ($config->get_int("ext_ratings2_version") < 2) { $this->install(); } $config->set_default_string("ext_rating_anon_privs", 'squ'); $config->set_default_string("ext_rating_user_privs", 'sqeu'); $config->set_default_string("ext_rating_admin_privs", 'sqeu'); } if ($event instanceof RatingSetEvent) { $this->set_rating($event->image->id, $event->rating); } if ($event instanceof ImageInfoBoxBuildingEvent) { if ($this->can_rate()) { $event->add_part($this->theme->get_rater_html($event->image->id, $event->image->rating), 80); } } if ($event instanceof ImageInfoSetEvent) { if ($this->can_rate() && isset($_POST["rating"])) { send_event(new RatingSetEvent($event->image, $user, $_POST['rating'])); } } if ($event instanceof SetupBuildingEvent) { $privs = array(); $privs['Safe Only'] = 's'; $privs['Safe and Unknown'] = 'su'; $privs['Safe and Questionable'] = 'sq'; $privs['Safe, Questionable, Unknown'] = 'squ'; $privs['All'] = 'sqeu'; $sb = new SetupBlock("Image Ratings"); $sb->add_choice_option("ext_rating_anon_privs", $privs, "Anonymous: "); $sb->add_choice_option("ext_rating_user_privs", $privs, "<br>Users: "); $sb->add_choice_option("ext_rating_admin_privs", $privs, "<br>Admins: "); $event->panel->add_block($sb); } if ($event instanceof ParseLinkTemplateEvent) { $event->replace('$rating', $this->theme->rating_to_name($event->image->rating)); } if ($event instanceof SearchTermParseEvent) { $matches = array(); if (is_null($event->term) && $this->no_rating_query($event->context)) { $set = Ratings::privs_to_sql(Ratings::get_user_privs($user)); $event->add_querylet(new Querylet("rating IN ({$set})")); } if (preg_match("/^rating=([sqeu]+)\$/", $event->term, $matches)) { $sqes = $matches[1]; $arr = array(); for ($i = 0; $i < strlen($sqes); $i++) { $arr[] = "'" . $sqes[$i] . "'"; } $set = join(', ', $arr); $event->add_querylet(new Querylet("rating IN ({$set})")); } if (preg_match("/^rating=(safe|questionable|explicit|unknown)\$/", strtolower($event->term), $matches)) { $text = $matches[1]; $char = $text[0]; $event->add_querylet(new Querylet("rating = ?", array($char))); } } }
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} > {$limit})"); } } }
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} > {$limit})"); } } }
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 & Conditions:<br>"); $sb->add_choice_option("avatar_host", $hosts, "<br>Avatars: "); if ($config->get_string("avatar_host") == "gravatar") { $sb->add_label("<br> <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); }
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); }
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); } }
public function onSetupBuilding($event) { $sb = new SetupBlock("Logging (Database)"); $sb->add_choice_option("log_db_priority", array("Debug" => SCORE_LOG_DEBUG, "Info" => SCORE_LOG_INFO, "Warning" => SCORE_LOG_WARNING, "Error" => SCORE_LOG_ERROR, "Critical" => SCORE_LOG_CRITICAL), "Debug Level: "); $event->panel->add_block($sb); }
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); }
public function onSetupBuilding($event) { $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 (!in_array("OS", $_SERVER) || $_SERVER["OS"] != 'Windows_NT') { $sb->add_bool_option("image_show_meta", "<br>Show metadata: "); } $sb->add_bool_option("image_jquery_confirm", "<br>Confirm Delete with jQuery: "); $expires = array(); $expires['1 Minute'] = 60; $expires['1 Hour'] = 3600; $expires['1 Day'] = 86400; $expires['1 Month (31 days)'] = 2678400; //(60*60*24*31) $expires['1 Year'] = 31536000; // 365 days (60*60*24*365) $expires['Never'] = 3153600000.0; // 100 years.. $sb->add_choice_option("image_expires", $expires, "<br>Image Expiration: "); $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 "); $sb->add_shorthand_int_option("thumb_mem_limit", "<br>Max memory use: "); $event->panel->add_block($sb); }