remove EOL whitespace

This commit is contained in:
Shish 2009-01-04 11:18:37 -08:00
parent 966180aef5
commit 11873e9601
78 changed files with 360 additions and 358 deletions

View File

@ -20,7 +20,7 @@ porn
global $config; global $config;
$banned = $config->get_string("banned_words"); $banned = $config->get_string("banned_words");
$comment = strtolower($event->comment); $comment = strtolower($event->comment);
foreach(explode("\n", $banned) as $word) { foreach(explode("\n", $banned) as $word) {
$word = trim(strtolower($word)); $word = trim(strtolower($word));
if(strlen($word) == 0) { if(strlen($word) == 0) {

View File

@ -10,16 +10,16 @@
* October 26, 2007 * October 26, 2007
* *
*/ */
class BrowserSearch implements Extension { class BrowserSearch implements Extension {
public function receive_event(Event $event) { public function receive_event(Event $event) {
global $page; global $page;
global $config; global $config;
if($event instanceof InitExtEvent) { if($event instanceof InitExtEvent) {
$config->set_default_string("search_suggestions_results_order", 'a'); $config->set_default_string("search_suggestions_results_order", 'a');
} }
// Add in header code to let the browser know that the search plugin exists // Add in header code to let the browser know that the search plugin exists
if($event instanceof PageRequestEvent) { if($event instanceof PageRequestEvent) {
// We need to build the data for the header // We need to build the data for the header
@ -28,23 +28,23 @@ class BrowserSearch implements Extension {
$search_file_url = make_link('browser_search/please_dont_use_this_tag_as_it_would_break_stuff__search.xml'); $search_file_url = make_link('browser_search/please_dont_use_this_tag_as_it_would_break_stuff__search.xml');
$page->add_header("<link rel='search' type='application/opensearchdescription+xml' title='$search_title' href='$search_file_url'>"); $page->add_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 // 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")) { 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 // First, we need to build all the variables we'll need
$search_title = $config->get_string('title'); $search_title = $config->get_string('title');
//$search_form_url = $config->get_string('base_href'); //make_link('post/list'); //$search_form_url = $config->get_string('base_href'); //make_link('post/list');
$search_form_url = make_link('post/list/{searchTerms}'); $search_form_url = make_link('post/list/{searchTerms}');
$suggenton_url = make_link('browser_search/')."{searchTerms}"; $suggenton_url = make_link('browser_search/')."{searchTerms}";
// Now for the XML // Now for the XML
$xml = " $xml = "
<SearchPlugin xmlns='http://www.mozilla.org/2006/browser/search/' xmlns:os='http://a9.com/-/spec/opensearch/1.1/'> <SearchPlugin xmlns='http://www.mozilla.org/2006/browser/search/' xmlns:os='http://a9.com/-/spec/opensearch/1.1/'>
<os:ShortName>$search_title</os:ShortName> <os:ShortName>$search_title</os:ShortName>
<os:InputEncoding>UTF-8</os:InputEncoding> <os:InputEncoding>UTF-8</os:InputEncoding>
<os:Image width='16' <os:Image width='16'
height='16'>data:image/x-icon;base64,AAABAAEAEBAAAAEACABoBQAAFgAAACgAAAAQAAAAIAAAAAEACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWFhYAfX19AH9/fwCAgIAAgYGBAIODgwCEhIQAhoaGAIeHhwCJiYkAioqKAIyMjACPj48AkJCQAJKSkgCTk5MAlZWVAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEREREREREREREREREREREREAAAAAAAAAAAAAABERERERAAEBAQEBAQEBAQAAEREREQABAQEBAQEBAQEAAQAREREAAQEBAQEBAQEBAAEBABERAAEBAQEBAQEBAQABAQAREQAGBgUEAwIBAQEAAgEAEREADAwMCwsKCQkHAAkIABERABAQEBAQEA4ODAANDQAREQAQEBAQEBAQEBAAEBAAEREAEBAQEBAQEBAQABAQABERAAAAAAAAAAAAAAAQEAAREREAEBAPEBAQEBAQABAAEREREQAQEBAQEBAPEBAAABERERERAAAAAAAAAAAAAAAREREREREREREREREREREREf//AACADwAAgAcAAIADAACAAQAAgAEAAIABAACAAQAAgAEAAIABAACAAQAAgAEAAMABAADgAQAA8AEAAP//AAA=</os:Image> height='16'>data:image/x-icon;base64,AAABAAEAEBAAAAEACABoBQAAFgAAACgAAAAQAAAAIAAAAAEACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWFhYAfX19AH9/fwCAgIAAgYGBAIODgwCEhIQAhoaGAIeHhwCJiYkAioqKAIyMjACPj48AkJCQAJKSkgCTk5MAlZWVAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEREREREREREREREREREREREAAAAAAAAAAAAAABERERERAAEBAQEBAQEBAQAAEREREQABAQEBAQEBAQEAAQAREREAAQEBAQEBAQEBAAEBABERAAEBAQEBAQEBAQABAQAREQAGBgUEAwIBAQEAAgEAEREADAwMCwsKCQkHAAkIABERABAQEBAQEA4ODAANDQAREQAQEBAQEBAQEBAAEBAAEREAEBAQEBAQEBAQABAQABERAAAAAAAAAAAAAAAQEAAREREAEBAPEBAQEBAQABAAEREREQAQEBAQEBAPEBAAABERERERAAAAAAAAAAAAAAAREREREREREREREREREREREf//AACADwAAgAcAAIADAACAAQAAgAEAAIABAACAAQAAgAEAAIABAACAAQAAgAEAAMABAADgAQAA8AEAAP//AAA=</os:Image>
<SearchForm>$search_form_url</SearchForm> <SearchForm>$search_form_url</SearchForm>
<os:Url type='text/html' method='GET' template='$search_form_url'> <os:Url type='text/html' method='GET' template='$search_form_url'>
@ -53,56 +53,56 @@ class BrowserSearch implements Extension {
<Url type='application/x-suggestions+json' template='$suggenton_url'/> <Url type='application/x-suggestions+json' template='$suggenton_url'/>
</SearchPlugin> </SearchPlugin>
"; ";
// And now to send it to the browser // And now to send it to the browser
$page->set_mode("data"); $page->set_mode("data");
$page->set_type("text/xml"); $page->set_type("text/xml");
$page->set_data($xml); $page->set_data($xml);
} }
else if(($event instanceof PageRequestEvent) && ( else if(($event instanceof PageRequestEvent) && (
$event->page_matches("browser_search") && $event->page_matches("browser_search") &&
!$config->get_bool("disable_search_suggestions") !$config->get_bool("disable_search_suggestions")
)) { )) {
global $database; global $database;
// We have to build some json stuff // We have to build some json stuff
$tag_search = $event->get_arg(0); $tag_search = $event->get_arg(0);
// Now to get DB results // Now to get DB results
if($config->get_string("search_suggestions_results_order") == "a") { 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."%")); $tags = $database->execute("SELECT tag FROM tags WHERE tag LIKE ? AND count > 0 ORDER BY tag ASC LIMIT 30",array($tag_search."%"));
} else { } else {
$tags = $database->execute("SELECT tag FROM tags WHERE tag LIKE ? AND count > 0 ORDER BY count DESC LIMIT 30",array($tag_search."%")); $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: // And to do stuff with it. We want our output to look like:
// ["shimmie",["shimmies","shimmy","shimmie","21 shimmies","hip shimmies","skea shimmies"],[],[]] // ["shimmie",["shimmies","shimmy","shimmie","21 shimmies","hip shimmies","skea shimmies"],[],[]]
$json_tag_list = ""; $json_tag_list = "";
$tags_array = array(); $tags_array = array();
foreach($tags as $tag) { foreach($tags as $tag) {
array_push($tags_array,$tag['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,", "); // $json_tag_list = implode($tags_array,", ");
// $json_tag_list = "\"".implode($tags_array,"\", \"")."\""; // $json_tag_list = "\"".implode($tags_array,"\", \"")."\"";
// And now for the final output // And now for the final output
$json_string = "[\"$tag_search\",[\"$json_tag_list\"],[],[]]"; $json_string = "[\"$tag_search\",[\"$json_tag_list\"],[],[]]";
$page->set_mode("data"); $page->set_mode("data");
$page->set_data($json_string); $page->set_data($json_string);
} }
if($event instanceof SetupBuildingEvent) { if($event instanceof SetupBuildingEvent) {
$sort_by = array(); $sort_by = array();
$sort_by['Alphabetical'] = 'a'; $sort_by['Alphabetical'] = 'a';
$sort_by['Tag Count'] = 't'; $sort_by['Tag Count'] = 't';
$sb = new SetupBlock("Browser Search"); $sb = new SetupBlock("Browser Search");
$sb->add_bool_option("disable_search_suggestions", "Disable search suggestions when using browser-based search: "); $sb->add_bool_option("disable_search_suggestions", "Disable search suggestions when using browser-based search: ");
$sb->add_label("<br>"); $sb->add_label("<br>");

View File

@ -47,18 +47,18 @@ class BulkAdd implements Extension {
private function add_dir($base, $subdir="") { private function add_dir($base, $subdir="") {
global $page; global $page;
if(!is_dir($base)) { if(!is_dir($base)) {
$this->theme->add_status("Error", "$base is not a directory"); $this->theme->add_status("Error", "$base is not a directory");
return; return;
} }
$list = ""; $list = "";
$dir = opendir("$base/$subdir"); $dir = opendir("$base/$subdir");
while($filename = readdir($dir)) { while($filename = readdir($dir)) {
$fullpath = "$base/$subdir/$filename"; $fullpath = "$base/$subdir/$filename";
if(is_link($fullpath)) { if(is_link($fullpath)) {
// ignore // ignore
} }

View File

@ -26,7 +26,7 @@ class BulkAddTheme extends Themelet {
used as tags for the images within. used as tags for the images within.
<br>Note: this is the folder as seen by the server -- you need to <br>Note: this is the folder as seen by the server -- you need to
upload via FTP or something first. upload via FTP or something first.
<p><form action='".make_link("bulk_add")."' method='POST'> <p><form action='".make_link("bulk_add")."' method='POST'>
Directory to add: <input type='text' name='dir' size='40'> Directory to add: <input type='text' name='dir' size='40'>
<input type='submit' value='Add'> <input type='submit' value='Add'>

View File

@ -36,21 +36,21 @@ Also correctly redirects the url provided by danbooruup in the event
of a duplicate image. of a duplicate image.
19-OCT-07 4:46PM CST - JJS 19-OCT-07 4:46PM CST - JJS
Add compatibility with danbooru api v1.8.1 style urls Add compatibility with danbooru api v1.8.1 style urls
for find_posts and add_post. NOTE: This does not implement for find_posts and add_post. NOTE: This does not implement
the changes to the parameter names, it is simply a the changes to the parameter names, it is simply a
workaround for the latest danbooruup firefox extension. workaround for the latest danbooruup firefox extension.
Completely compatibility will probably involve a rewrite with a different URL Completely compatibility will probably involve a rewrite with a different URL
*/ */
class DanbooruApi implements Extension class DanbooruApi implements Extension
{ {
// Receive the event // Receive the event
public function receive_event(Event $event) public function receive_event(Event $event)
{ {
// Check if someone is accessing /api/danbooru (us) // Check if someone is accessing /api/danbooru (us)
if(($event instanceof PageRequestEvent) && ($event->page_matches("api")) && ($event->get_arg(0) == 'danbooru')) if(($event instanceof PageRequestEvent) && ($event->page_matches("api")) && ($event->get_arg(0) == 'danbooru'))
{ {
// execute the danbooru processing code // execute the danbooru processing code
$this->api_danbooru($event); $this->api_danbooru($event);
@ -65,7 +65,7 @@ class DanbooruApi implements Extension
} }
} }
} }
// Danbooru API // Danbooru API
private function api_danbooru($event) private function api_danbooru($event)
{ {
@ -77,31 +77,31 @@ class DanbooruApi implements Extension
$page->set_type("application/xml"); $page->set_type("application/xml");
//debug //debug
//$page->set_type("text/plain"); //$page->set_type("text/plain");
$results = array(); $results = array();
/* /*
add_post() add_post()
Adds a post to the database. Adds a post to the database.
Parameters Parameters
* login: login * login: login
* password: password * password: password
* file: file as a multipart form * file: file as a multipart form
* source: source url * source: source url
* title: title **IGNORED** * title: title **IGNORED**
* tags: list of tags as a string, delimited by whitespace * tags: list of tags as a string, delimited by whitespace
* md5: MD5 hash of upload in hexadecimal format * md5: MD5 hash of upload in hexadecimal format
* rating: rating of the post. can be explicit, questionable, or safe. **IGNORED** * rating: rating of the post. can be explicit, questionable, or safe. **IGNORED**
Notes Notes
* The only necessary parameter is tags and either file or source. * The only necessary parameter is tags and either file or source.
* If you want to sign your post, you need a way to authenticate your account, either by supplying login and password, or by supplying a cookie. * If you want to sign your post, you need a way to authenticate your account, either by supplying login and password, or by supplying a cookie.
* If an account is not supplied or if it doesnt authenticate, he post will be added anonymously. * If an account is not supplied or if it doesnt authenticate, he post will be added anonymously.
* If the md5 parameter is supplied and does not match the hash of whats on the server, the post is rejected. * If the md5 parameter is supplied and does not match the hash of whats on the server, the post is rejected.
Response Response
The response depends on the method used: The response depends on the method used:
Post Post
* X-Danbooru-Location set to the URL for newly uploaded post. * X-Danbooru-Location set to the URL for newly uploaded post.
Get Get
* Redirected to the newly uploaded post. * Redirected to the newly uploaded post.
*/ */
if(($event->get_arg(1) == 'add_post') || (($event->get_arg(1) == 'post') && ($event->get_arg(2) == 'create.xml'))) if(($event->get_arg(1) == 'add_post') || (($event->get_arg(1) == 'post') && ($event->get_arg(2) == 'create.xml')))
@ -137,7 +137,7 @@ class DanbooruApi implements Extension
if(isset($_REQUEST['post']['source']) && !empty($_REQUEST['post']['source'])) if(isset($_REQUEST['post']['source']) && !empty($_REQUEST['post']['source']))
{ {
$source = $_REQUEST['post']['source']; $source = $_REQUEST['post']['source'];
} else } else
{ {
$source = null; $source = null;
} }
@ -146,19 +146,19 @@ class DanbooruApi implements Extension
$url = isset($_REQUEST['source']) ? $_REQUEST['source'] : $_REQUEST['post']['source']; $url = isset($_REQUEST['source']) ? $_REQUEST['source'] : $_REQUEST['post']['source'];
$source = $url; $source = $url;
$tmp_filename = tempnam("/tmp", "shimmie_transload"); $tmp_filename = tempnam("/tmp", "shimmie_transload");
// Are we using fopen wrappers or curl? // Are we using fopen wrappers or curl?
if($config->get_string("transload_engine") == "fopen") if($config->get_string("transload_engine") == "fopen")
{ {
$fp = fopen($url, "r"); $fp = fopen($url, "r");
if(!$fp) { if(!$fp) {
header("HTTP/1.0 409 Conflict"); header("HTTP/1.0 409 Conflict");
header("X-Danbooru-Errors: fopen read error"); header("X-Danbooru-Errors: fopen read error");
} }
$data = ""; $data = "";
$length = 0; $length = 0;
while(!feof($fp) && $length <= $config->get_int('upload_size')) while(!feof($fp) && $length <= $config->get_int('upload_size'))
{ {
$data .= fread($fp, 8192); $data .= fread($fp, 8192);
$length = strlen($data); $length = strlen($data);
@ -170,7 +170,7 @@ class DanbooruApi implements Extension
fclose($fp); fclose($fp);
} }
if($config->get_string("transload_engine") == "curl") if($config->get_string("transload_engine") == "curl")
{ {
$ch = curl_init($url); $ch = curl_init($url);
$fp = fopen($tmp_filename, "w"); $fp = fopen($tmp_filename, "w");
@ -184,13 +184,13 @@ class DanbooruApi implements Extension
} }
$file = $tmp_filename; $file = $tmp_filename;
$filename = basename($url); $filename = basename($url);
} else } else
{ // Nothing was specified at all { // Nothing was specified at all
header("HTTP/1.0 409 Conflict"); header("HTTP/1.0 409 Conflict");
header("X-Danbooru-Errors: no input files"); header("X-Danbooru-Errors: no input files");
return; return;
} }
// Get tags out of url // Get tags out of url
$posttags = tag_explode(isset($_REQUEST['tags']) ? $_REQUEST['tags'] : $_REQUEST['post']['tags']); $posttags = tag_explode(isset($_REQUEST['tags']) ? $_REQUEST['tags'] : $_REQUEST['post']['tags']);
$hash = md5_file($file); $hash = md5_file($file);
@ -206,7 +206,7 @@ class DanbooruApi implements Extension
} }
// Upload size checking is now performed in the upload extension // Upload size checking is now performed in the upload extension
// It is also currently broken due to some confusion over file variable ($tmp_filename?) // It is also currently broken due to some confusion over file variable ($tmp_filename?)
// Does it exist already? // Does it exist already?
$existing = Image::by_hash($config, $database, $hash); $existing = Image::by_hash($config, $database, $hash);
if(!is_null($existing)) { if(!is_null($existing)) {
@ -222,7 +222,7 @@ class DanbooruApi implements Extension
$metadata['extension'] = $fileinfo['extension']; $metadata['extension'] = $fileinfo['extension'];
$metadata['tags'] = $posttags; $metadata['tags'] = $posttags;
$metadata['source'] = $source; $metadata['source'] = $source;
try { try {
$nevent = new DataUploadEvent($user, $file, $metadata); $nevent = new DataUploadEvent($user, $file, $metadata);
send_event($nevent); send_event($nevent);
@ -243,23 +243,23 @@ class DanbooruApi implements Extension
header("X-Danbooru-Errors: ". $ex->getMessage()); header("X-Danbooru-Errors: ". $ex->getMessage());
return; return;
} }
} else } else
{ {
header("HTTP/1.0 409 Conflict"); header("HTTP/1.0 409 Conflict");
header("X-Danbooru-Errors: authentication error"); header("X-Danbooru-Errors: authentication error");
return; return;
} }
} }
/* /*
find_posts() find_posts()
Find all posts that match the search criteria. Posts will be ordered by id descending. Find all posts that match the search criteria. Posts will be ordered by id descending.
Parameters Parameters
* md5: md5 hash to search for (comma delimited) * md5: md5 hash to search for (comma delimited)
* id: id to search for (comma delimited) * id: id to search for (comma delimited)
* tags: what tags to search for * tags: what tags to search for
* limit: limit * limit: limit
* offset: offset * offset: offset
* after_id: limit results to posts added after this id * after_id: limit results to posts added after this id
*/ */
if(($event->get_arg(1) == 'find_posts') || (($event->get_arg(1) == 'post') && ($event->get_arg(2) == 'index.xml'))) if(($event->get_arg(1) == 'find_posts') || (($event->get_arg(1) == 'post') && ($event->get_arg(2) == 'index.xml')))
@ -285,7 +285,7 @@ class DanbooruApi implements Extension
$tags = isset($_GET['tags']) ? tag_explode($_GET['tags']) : array(); $tags = isset($_GET['tags']) ? tag_explode($_GET['tags']) : array();
$results = Image::find_images($config,$database,$start,$limit,$tags); $results = Image::find_images($config,$database,$start,$limit,$tags);
} }
// Now we have the array $results filled with Image objects // Now we have the array $results filled with Image objects
// Let's display them // Let's display them
$xml = "<posts>\n"; $xml = "<posts>\n";
@ -302,13 +302,13 @@ class DanbooruApi implements Extension
$xml .= "</posts>"; $xml .= "</posts>";
$page->set_data($xml); $page->set_data($xml);
} }
/* /*
find_tags() Find all tags that match the search criteria. find_tags() Find all tags that match the search criteria.
Parameters Parameters
* id: A comma delimited list of tag id numbers. * id: A comma delimited list of tag id numbers.
* name: A comma delimited list of tag names. * name: A comma delimited list of tag names.
* tags: any typical tag query. See Tag#parse_query for details. * tags: any typical tag query. See Tag#parse_query for details.
* after_id: limit results to tags with an id number after after_id. Useful if you only want to refresh * after_id: limit results to tags with an id number after after_id. Useful if you only want to refresh
*/ */
if($event->get_arg(1) == 'find_tags') if($event->get_arg(1) == 'find_tags')
@ -335,16 +335,16 @@ class DanbooruApi implements Extension
$results[] = array($sqlresult->fields['count'], $sqlresult->fields['tag'], $sqlresult->fields['id']); $results[] = array($sqlresult->fields['count'], $sqlresult->fields['tag'], $sqlresult->fields['id']);
} }
} }
} }
/* Currently disabled to maintain identical functionality to danbooru 1.0's own "broken" find_tags /* Currently disabled to maintain identical functionality to danbooru 1.0's own "broken" find_tags
elseif(isset($_GET['tags'])) elseif(isset($_GET['tags']))
{ {
$start = isset($_GET['after_id']) ? int_escape($_GET['offset']) : 0; $start = isset($_GET['after_id']) ? int_escape($_GET['offset']) : 0;
$tags = tag_explode($_GET['tags']); $tags = tag_explode($_GET['tags']);
} }
*/ */
else else
{ {
$start = isset($_GET['after_id']) ? int_escape($_GET['offset']) : 0; $start = isset($_GET['after_id']) ? int_escape($_GET['offset']) : 0;
$sqlresult = $database->execute("SELECT id,tag,count FROM tags WHERE count > 0 AND id >= ? ORDER BY id DESC",array($start)); $sqlresult = $database->execute("SELECT id,tag,count FROM tags WHERE count > 0 AND id >= ? ORDER BY id DESC",array($start));
@ -354,7 +354,7 @@ class DanbooruApi implements Extension
$sqlresult->MoveNext(); $sqlresult->MoveNext();
} }
} }
// Tag results collected, build XML output // Tag results collected, build XML output
$xml = "<tags>\n"; $xml = "<tags>\n";
foreach($results as $tag) foreach($results as $tag)
@ -364,7 +364,7 @@ class DanbooruApi implements Extension
$xml .= "</tags>"; $xml .= "</tags>";
$page->set_data($xml); $page->set_data($xml);
} }
// Hackery for danbooruup 0.3.2 providing the wrong view url. This simply redirects to the proper // Hackery for danbooruup 0.3.2 providing the wrong view url. This simply redirects to the proper
// Shimmie view page // Shimmie view page
// Example: danbooruup says the url is http://shimmie/api/danbooru/post/show/123 // Example: danbooruup says the url is http://shimmie/api/danbooru/post/show/123
@ -375,7 +375,7 @@ class DanbooruApi implements Extension
header("Location: $fixedlocation"); header("Location: $fixedlocation");
} }
} }
// Turns out I use this a couple times so let's make it a utility function // Turns out I use this a couple times so let's make it a utility function
// Authenticates a user based on the contents of the login and password parameters // Authenticates a user based on the contents of the login and password parameters
// or makes them anonymous. Does not set any cookies or anything permanent. // or makes them anonymous. Does not set any cookies or anything permanent.
@ -404,7 +404,7 @@ class DanbooruApi implements Extension
// From htmlspecialchars man page on php.net comments // From htmlspecialchars man page on php.net comments
// If tags contain quotes they need to be htmlified // If tags contain quotes they need to be htmlified
private function xmlspecialchars($text) private function xmlspecialchars($text)
{ {
return str_replace('&#039;', '&apos;', htmlspecialchars($text, ENT_QUOTES)); return str_replace('&#039;', '&apos;', htmlspecialchars($text, ENT_QUOTES));
} }

View File

@ -31,7 +31,7 @@ class Downtime implements Extension {
$user = $event->context->user; $user = $event->context->user;
$config = $event->context->config; $config = $event->context->config;
if($config->get_bool("downtime") && !$user->is_admin() && if($config->get_bool("downtime") && !$user->is_admin() &&
($event instanceof PageRequestEvent) && !$this->is_safe_page($event)) { ($event instanceof PageRequestEvent) && !$this->is_safe_page($event)) {
$msg = $config->get_string("downtime_message"); $msg = $config->get_string("downtime_message");
$this->theme->display_message($msg); $this->theme->display_message($msg);

View File

@ -57,7 +57,7 @@ class ET implements Extension {
$els[] = get_class($el); $els[] = get_class($el);
} }
$info['sys_extensions'] = join(', ', $els); $info['sys_extensions'] = join(', ', $els);
//$cfs = array(); //$cfs = array();
//foreach($database->get_all("SELECT name, value FROM config") as $pair) { //foreach($database->get_all("SELECT name, value FROM config") as $pair) {
// $cfs[] = $pair['name']."=".$pair['value']; // $cfs[] = $pair['name']."=".$pair['value'];

View File

@ -12,7 +12,7 @@ class ETTheme extends Themelet {
$page->add_block(new NavBlock()); $page->add_block(new NavBlock());
$page->add_block(new Block("Information:", $this->build_data_form($info))); $page->add_block(new Block("Information:", $this->build_data_form($info)));
} }
protected function build_data_form($info) { protected function build_data_form($info) {
$data = <<<EOD $data = <<<EOD
Optional: Optional:

View File

@ -26,7 +26,7 @@ class EventLog implements Extension {
break; break;
} }
} }
$columns = array("name", "date", "owner_ip", "event"); $columns = array("name", "date", "owner_ip", "event");
$orders = array("ASC", "DESC"); $orders = array("ASC", "DESC");
@ -34,7 +34,7 @@ class EventLog implements Extension {
if(isset($_GET['sort']) && in_array($_GET['sort'], $columns)) { if(isset($_GET['sort']) && in_array($_GET['sort'], $columns)) {
$sort = $_GET['sort']; $sort = $_GET['sort'];
} }
$order = "DESC"; $order = "DESC";
if(isset($_GET['order']) && in_array($_GET['order'], $orders)) { if(isset($_GET['order']) && in_array($_GET['order'], $orders)) {
$order = $_GET['order']; $order = $_GET['order'];
@ -92,7 +92,7 @@ class EventLog implements Extension {
private function add_to_log($user, $event, $entry) { private function add_to_log($user, $event, $entry) {
global $database; global $database;
$database->execute(" $database->execute("
INSERT INTO event_log (owner_id, owner_ip, date, event, entry) INSERT INTO event_log (owner_id, owner_ip, date, event, entry)
VALUES (?, ?, now(), ?, ?)", VALUES (?, ?, now(), ?, ?)",

View File

@ -5,7 +5,7 @@ class EventLogTheme extends Themelet {
$page->set_title("Event Log"); $page->set_title("Event Log");
$page->set_heading("Event Log"); $page->set_heading("Event Log");
$page->add_block(new NavBlock()); $page->add_block(new NavBlock());
$this->display_table($page, $events); $this->display_table($page, $events);
$this->display_controls($page); $this->display_controls($page);
} }

View File

@ -11,7 +11,7 @@ class Featured implements Extension {
public function receive_event(Event $event) { public function receive_event(Event $event) {
if(is_null($this->theme)) $this->theme = get_theme_object($this); if(is_null($this->theme)) $this->theme = get_theme_object($this);
if($event instanceof InitExtEvent) { if($event instanceof InitExtEvent) {
global $config; global $config;
$config->set_default_int('featured_id', 0); $config->set_default_int('featured_id', 0);

View File

@ -11,7 +11,7 @@ class ArchiveFileHandler implements Extension {
global $config; global $config;
$config->set_default_string('archive_extract_command', 'unzip -d "%d" "%f"'); $config->set_default_string('archive_extract_command', 'unzip -d "%d" "%f"');
} }
if($event instanceof SetupBuildingEvent) { if($event instanceof SetupBuildingEvent) {
$sb = new SetupBlock("Archive Handler Options"); $sb = new SetupBlock("Archive Handler Options");
$sb->add_text_option("archive_tmp_dir", "Temporary folder: "); $sb->add_text_option("archive_tmp_dir", "Temporary folder: ");
@ -60,13 +60,13 @@ class ArchiveFileHandler implements Extension {
// copied from bulk add extension // copied from bulk add extension
private function add_dir($base, $subdir="") { private function add_dir($base, $subdir="") {
global $page; global $page;
$list = ""; $list = "";
$dir = opendir("$base/$subdir"); $dir = opendir("$base/$subdir");
while($filename = readdir($dir)) { while($filename = readdir($dir)) {
$fullpath = "$base/$subdir/$filename"; $fullpath = "$base/$subdir/$filename";
if(is_link($fullpath)) { if(is_link($fullpath)) {
// ignore // ignore
} }

View File

@ -61,7 +61,7 @@ class FlashFileHandler implements Extension {
// } // }
// $image->width = $rect[1]; // $image->width = $rect[1];
// $image->height = $rect[3]; // $image->height = $rect[3];
if(!($info = getimagesize($filename))) return null; if(!($info = getimagesize($filename))) return null;
$image->width = $info[0]; $image->width = $info[0];
@ -89,7 +89,7 @@ class FlashFileHandler implements Extension {
} }
return $int; return $int;
} }
private function swf_get_bounds($filename) { private function swf_get_bounds($filename) {
$fp = fopen($filename, "r"); $fp = fopen($filename, "r");
$head = fread($fp, 3); $head = fread($fp, 3);

View File

@ -5,7 +5,7 @@ class FlashFileHandlerTheme extends Themelet {
$ilink = $image->get_image_link(); $ilink = $image->get_image_link();
// FIXME: object and embed have "height" and "width" // FIXME: object and embed have "height" and "width"
$html = " $html = "
<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' <object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'
codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0'
height='{$image->height}' height='{$image->height}'
width='{$image->width}' width='{$image->width}'

View File

@ -38,7 +38,7 @@ class IcoFileHandler implements Extension {
$image = Image::by_id($config, $database, $id); $image = Image::by_id($config, $database, $id);
$hash = $image->hash; $hash = $image->hash;
$ha = substr($hash, 0, 2); $ha = substr($hash, 0, 2);
$event->page->set_type("image/x-icon"); $event->page->set_type("image/x-icon");
$event->page->set_mode("data"); $event->page->set_mode("data");
$event->page->set_data(file_get_contents("images/$ha/$hash")); $event->page->set_data(file_get_contents("images/$ha/$hash"));
@ -49,7 +49,7 @@ class IcoFileHandler implements Extension {
$exts = array("ico", "ani", "cur"); $exts = array("ico", "ani", "cur");
return array_contains($exts, strtolower($ext)); return array_contains($exts, strtolower($ext));
} }
private function create_image_from_data($filename, $metadata) { private function create_image_from_data($filename, $metadata) {
global $config; global $config;
@ -61,10 +61,10 @@ class IcoFileHandler implements Extension {
$subheader = unpack("cwidth/cheight/ccolours/cnull/splanes/sbpp/lsize/loffset", fread($fp, 16)); $subheader = unpack("cwidth/cheight/ccolours/cnull/splanes/sbpp/lsize/loffset", fread($fp, 16));
fclose($fp); fclose($fp);
$image->width = $subheader['width']; $image->width = $subheader['width'];
$image->height = $subheader['height']; $image->height = $subheader['height'];
$image->filesize = $metadata['size']; $image->filesize = $metadata['size'];
$image->hash = $metadata['hash']; $image->hash = $metadata['hash'];
$image->filename = $metadata['filename']; $image->filename = $metadata['filename'];

View File

@ -48,7 +48,7 @@ class MP3FileHandler implements Extension {
// FIXME: need more flash format specs :| // FIXME: need more flash format specs :|
$image->width = 0; $image->width = 0;
$image->height = 0; $image->height = 0;
$image->filesize = $metadata['size']; $image->filesize = $metadata['size'];
$image->hash = $metadata['hash']; $image->hash = $metadata['hash'];
$image->filename = $metadata['filename']; $image->filename = $metadata['filename'];

View File

@ -5,7 +5,7 @@ class MP3FileHandlerTheme extends Themelet {
$data_href = get_base_href(); $data_href = get_base_href();
$ilink = $image->get_image_link(); $ilink = $image->get_image_link();
$html = " $html = "
<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' <object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'
codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0'
width='400' height='170'> width='400' height='170'>
<param name='movie' value='$data_href/ext/handle_mp3/xspf_player.swf?song_url=$ilink'/> <param name='movie' value='$data_href/ext/handle_mp3/xspf_player.swf?song_url=$ilink'/>

View File

@ -46,7 +46,7 @@ class SVGFileHandler implements Extension {
if(($event instanceof DisplayingImageEvent) && $this->supported_ext($event->image->ext)) { if(($event instanceof DisplayingImageEvent) && $this->supported_ext($event->image->ext)) {
$this->theme->display_image($event->page, $event->image); $this->theme->display_image($event->page, $event->image);
} }
if(($event instanceof PageRequestEvent) && $event->page_matches("get_svg")) { if(($event instanceof PageRequestEvent) && $event->page_matches("get_svg")) {
global $config; global $config;
global $database; global $database;
@ -54,7 +54,7 @@ class SVGFileHandler implements Extension {
$image = Image::by_id($config, $database, $id); $image = Image::by_id($config, $database, $id);
$hash = $image->hash; $hash = $image->hash;
$ha = substr($hash, 0, 2); $ha = substr($hash, 0, 2);
$event->page->set_type("image/svg+xml"); $event->page->set_type("image/svg+xml");
$event->page->set_mode("data"); $event->page->set_mode("data");
$event->page->set_data(file_get_contents("images/$ha/$hash")); $event->page->set_data(file_get_contents("images/$ha/$hash"));
@ -74,7 +74,7 @@ class SVGFileHandler implements Extension {
$msp = new MiniSVGParser($filename); $msp = new MiniSVGParser($filename);
$image->width = $msp->width; $image->width = $msp->width;
$image->height = $msp->height; $image->height = $msp->height;
$image->filesize = $metadata['size']; $image->filesize = $metadata['size'];
$image->hash = $metadata['hash']; $image->hash = $metadata['hash'];
$image->filename = $metadata['filename']; $image->filename = $metadata['filename'];
@ -87,7 +87,7 @@ class SVGFileHandler implements Extension {
private function check_contents($file) { private function check_contents($file) {
if(!file_exists($file)) return false; if(!file_exists($file)) return false;
$msp = new MiniSVGParser($file); $msp = new MiniSVGParser($file);
return $msp->valid; return $msp->valid;
} }

View File

@ -26,7 +26,7 @@ class Home implements Extension {
$name = str_replace("ext/home/counters/", "", $counter_dirname); $name = str_replace("ext/home/counters/", "", $counter_dirname);
$counters[ucfirst($name)] = $name; $counters[ucfirst($name)] = $name;
} }
$sb = new SetupBlock("Home Page"); $sb = new SetupBlock("Home Page");
$sb->add_label("Page Links - Example: [$"."base/index|Posts]"); $sb->add_label("Page Links - Example: [$"."base/index|Posts]");
$sb->add_longtext_option("home_links", "<br>"); $sb->add_longtext_option("home_links", "<br>");
@ -46,19 +46,19 @@ class Home implements Extension {
$sitename = $config->get_string('title'); $sitename = $config->get_string('title');
$contact_link = $config->get_string('contact_link'); $contact_link = $config->get_string('contact_link');
$counter_dir = $config->get_string('home_counter', 'default'); $counter_dir = $config->get_string('home_counter', 'default');
$total = ceil($database->db->GetOne("SELECT COUNT(*) FROM images")); $total = ceil($database->db->GetOne("SELECT COUNT(*) FROM images"));
$strtotal = "$total"; $strtotal = "$total";
$num_comma = number_format($total); $num_comma = number_format($total);
$counter_text = ""; $counter_text = "";
for($n=0; $n<strlen($strtotal); $n++) for($n=0; $n<strlen($strtotal); $n++)
{ {
$cur = $strtotal[$n]; $cur = $strtotal[$n];
$counter_text .= " <img alt='$cur' src='$data_href/ext/home/counters/$counter_dir/$cur.gif' /> "; $counter_text .= " <img alt='$cur' src='$data_href/ext/home/counters/$counter_dir/$cur.gif' /> ";
} }
// get the homelinks and process them // get the homelinks and process them
$main_links = $config->get_string('home_links'); $main_links = $config->get_string('home_links');
$main_links = str_replace('$base', $base_href, $main_links); $main_links = str_replace('$base', $base_href, $main_links);
@ -77,7 +77,7 @@ class Home implements Extension {
$data_href = get_base_href(); $data_href = get_base_href();
$sitename = $config->get_string('title'); $sitename = $config->get_string('title');
$theme_name = $config->get_string('theme'); $theme_name = $config->get_string('theme');
$body = $this->get_body(); $body = $this->get_body();
$this->theme->display_page($page, $sitename, $data_href, $theme_name, $body); $this->theme->display_page($page, $sitename, $data_href, $theme_name, $body);

View File

@ -43,7 +43,7 @@ EOD
<div style='font-size: 80%; margin-bottom: 2em;'> <div style='font-size: 80%; margin-bottom: 2em;'>
<a href='$contact_link'>contact</a> &ndash; Serving $num_comma posts <a href='$contact_link'>contact</a> &ndash; Serving $num_comma posts
</div> </div>
<div class='space'> <div class='space'>
Powered by <a href='http://trac.shishnet.org/shimmie2/'>Shimmie</a> Powered by <a href='http://trac.shishnet.org/shimmie2/'>Shimmie</a>
</div> </div>

View File

@ -9,7 +9,7 @@
* Version 0.1 * Version 0.1
* October 21, 2007 * October 21, 2007
*/ */
// RemoveImageHashBanEvent {{{ // RemoveImageHashBanEvent {{{
class RemoveImageHashBanEvent extends Event { class RemoveImageHashBanEvent extends Event {
var $hash; var $hash;
@ -20,7 +20,7 @@ class RemoveImageHashBanEvent extends Event {
} }
// }}} // }}}
// AddImageHashBanEvent {{{ // AddImageHashBanEvent {{{
class AddImageHashBanEvent extends Event { class AddImageHashBanEvent extends Event {
var $hash; var $hash;
var $reason; var $reason;

View File

@ -17,7 +17,7 @@ class RemoveIPBanEvent extends Event {
} }
// }}} // }}}
// AddIPBanEvent {{{ // AddIPBanEvent {{{
class AddIPBanEvent extends Event { class AddIPBanEvent extends Event {
var $ip; var $ip;
var $reason; var $reason;
var $end; var $end;
@ -41,7 +41,7 @@ class IPBan implements Extension {
if($config->get_int("ext_ipban_version") < 5) { if($config->get_int("ext_ipban_version") < 5) {
$this->install(); $this->install();
} }
$this->check_ip_ban(); $this->check_ip_ban();
} }
@ -95,7 +95,7 @@ class IPBan implements Extension {
protected function install() { protected function install() {
global $database; global $database;
global $config; global $config;
// shortcut to latest // shortcut to latest
if($config->get_int("ext_ipban_version") < 1) { if($config->get_int("ext_ipban_version") < 1) {
$database->execute(" $database->execute("

View File

@ -17,7 +17,7 @@ class IPBanTest extends WebTestCase {
$this->setField('reason', 'unit testing'); $this->setField('reason', 'unit testing');
$this->setField('end', '1 week'); $this->setField('end', '1 week');
$this->click("Ban"); $this->click("Ban");
$this->assertText("42.42.42.42"); $this->assertText("42.42.42.42");
$this->click("Remove"); // FIXME: remove which ban? :S $this->click("Remove"); // FIXME: remove which ban? :S
$this->assertNoText("42.42.42.42"); $this->assertNoText("42.42.42.42");

View File

@ -6,14 +6,14 @@
*/ */
class LinkImage implements Extension { class LinkImage implements Extension {
var $theme; var $theme;
public function receive_event(Event $event) { public function receive_event(Event $event) {
if(is_null($this->theme)) $this->theme = get_theme_object($this); if(is_null($this->theme)) $this->theme = get_theme_object($this);
if(($event instanceof DisplayingImageEvent)) { if(($event instanceof DisplayingImageEvent)) {
global $config; global $config;
$data_href = get_base_href(); $data_href = get_base_href();
$event->page->add_header("<link rel='stylesheet' href='$data_href/ext/link_image/_style.css' type='text/css'>",0); $event->page->add_header("<link rel='stylesheet' href='$data_href/ext/link_image/_style.css' type='text/css'>",0);
$this->theme->links_block($event->page,$this->data($event->image)); $this->theme->links_block($event->page,$this->data($event->image));
} }
if($event instanceof SetupBuildingEvent) { if($event instanceof SetupBuildingEvent) {
@ -30,10 +30,10 @@ class LinkImage implements Extension {
} }
private function data($image) { private function data($image) {
global $config; global $config;
$text_link = $image->parse_link_template($config->get_string("ext_link-img_text-link_format")); $text_link = $image->parse_link_template($config->get_string("ext_link-img_text-link_format"));
$text_link = $text_link==" "? null : $text_link; // null blank setting so the url gets filled in on the text links. $text_link = $text_link==" "? null : $text_link; // null blank setting so the url gets filled in on the text links.
return array( return array(
'thumb_src' => $image->get_thumb_link(), 'thumb_src' => $image->get_thumb_link(),
'image_src' => $image->get_image_link(), 'image_src' => $image->get_image_link(),

View File

@ -1,12 +1,12 @@
<?php <?php
class LinkImageTheme extends Themelet { class LinkImageTheme extends Themelet {
public function links_block($page,$data) { public function links_block($page,$data) {
$thumb_src = $data['thumb_src']; $thumb_src = $data['thumb_src'];
$image_src = $data['image_src']; $image_src = $data['image_src'];
$post_link = $data['post_link']; $post_link = $data['post_link'];
$text_link = $data['text_link']; $text_link = $data['text_link'];
$page->add_block( new Block( $page->add_block( new Block(
"Link to Image", "Link to Image",
"<fieldset>". "<fieldset>".
@ -15,14 +15,14 @@ class LinkImageTheme extends Themelet {
$this->link_code("Thumbnail Link",$this->url($post_link, $this->img($thumb_src,"ubb"),"ubb"),"ubb_thumb-link"). $this->link_code("Thumbnail Link",$this->url($post_link, $this->img($thumb_src,"ubb"),"ubb"),"ubb_thumb-link").
$this->link_code("Inline Image", $this->img($image_src,"ubb"), "ubb_full-img"). $this->link_code("Inline Image", $this->img($image_src,"ubb"), "ubb_full-img").
"</fieldset>". "</fieldset>".
"<fieldset>". "<fieldset>".
"<legend><a href='http://en.wikipedia.org/wiki/Html' target='_blank'>HTML</a></legend>". "<legend><a href='http://en.wikipedia.org/wiki/Html' target='_blank'>HTML</a></legend>".
$this->link_code("Text Link", $this->url($post_link, $text_link,"html"), "html_text-link"). $this->link_code("Text Link", $this->url($post_link, $text_link,"html"), "html_text-link").
$this->link_code("Thumbnail Link", $this->url($post_link,$this->img($thumb_src,"html"),"html"), "html_thumb-link"). $this->link_code("Thumbnail Link", $this->url($post_link,$this->img($thumb_src,"html"),"html"), "html_thumb-link").
$this->link_code("Inline Image", $this->img($image_src,"html"), "html_full-image"). $this->link_code("Inline Image", $this->img($image_src,"html"), "html_full-image").
"</fieldset>". "</fieldset>".
"<fieldset>". "<fieldset>".
"<legend>Plain Text</legend>". "<legend>Plain Text</legend>".
$this->link_code("Post URL",$post_link,"text_post-link"). $this->link_code("Post URL",$post_link,"text_post-link").
@ -32,10 +32,10 @@ class LinkImageTheme extends Themelet {
"main", "main",
50)); 50));
} }
protected function url ($url,$content,$type) { protected function url ($url,$content,$type) {
if ($content == NULL) {$content=$url;} if ($content == NULL) {$content=$url;}
switch ($type) { switch ($type) {
case "html": case "html":
$text = "<a href=\"".$url."\">".$content."</a>"; $text = "<a href=\"".$url."\">".$content."</a>";
@ -48,7 +48,7 @@ class LinkImageTheme extends Themelet {
} }
return $text; return $text;
} }
protected function img ($src,$type) { protected function img ($src,$type) {
switch ($type) { switch ($type) {
case "html": case "html":
@ -62,7 +62,7 @@ class LinkImageTheme extends Themelet {
} }
return $text; return $text;
} }
protected function link_code($label,$content,$id=NULL) { protected function link_code($label,$content,$id=NULL) {
return "<label for='".$id."' title='Click to select the textbox'>$label</label>\n". return "<label for='".$id."' title='Click to select the textbox'>$label</label>\n".
"<input type='text' readonly='readonly' id='".$id."' name='".$id."' value='".html_escape($content)."' onfocus='this.select();'></input>\n<br/>\n"; "<input type='text' readonly='readonly' id='".$id."' name='".$id."' value='".html_escape($content)."' onfocus='this.select();'></input>\n<br/>\n";

View File

@ -11,7 +11,7 @@ class News implements Extension {
public function receive_event(Event $event) { public function receive_event(Event $event) {
if(is_null($this->theme)) $this->theme = get_theme_object($this); if(is_null($this->theme)) $this->theme = get_theme_object($this);
if($event instanceof PostListBuildingEvent) { if($event instanceof PostListBuildingEvent) {
if(strlen($event->context->config->get_string("news_text")) > 0) { if(strlen($event->context->config->get_string("news_text")) > 0) {
$this->theme->display_news($event->page, $event->context->config->get_string("news_text")); $this->theme->display_news($event->page, $event->context->config->get_string("news_text"));

View File

@ -28,7 +28,7 @@ class NumericScore implements Extension {
$this->install(); $this->install();
} }
} }
if($event instanceof DisplayingImageEvent) { if($event instanceof DisplayingImageEvent) {
global $user; global $user;
if(!$user->is_anonymous()) { if(!$user->is_anonymous()) {
@ -36,7 +36,7 @@ class NumericScore implements Extension {
$event->page->add_block(new Block("Image Score", $html, "left", 20)); $event->page->add_block(new Block("Image Score", $html, "left", 20));
} }
} }
if(($event instanceof PageRequestEvent) && $event->page_matches("numeric_score_vote")) { if(($event instanceof PageRequestEvent) && $event->page_matches("numeric_score_vote")) {
if(!$event->user->is_anonymous()) { if(!$event->user->is_anonymous()) {
$image_id = int_escape($_POST['image_id']); $image_id = int_escape($_POST['image_id']);
@ -49,7 +49,7 @@ class NumericScore implements Extension {
$event->page->set_redirect(make_link("post/view/$image_id")); $event->page->set_redirect(make_link("post/view/$image_id"));
} }
} }
if($event instanceof ImageInfoSetEvent) { if($event instanceof ImageInfoSetEvent) {
global $user; global $user;
$char = $_POST['numeric_score']; $char = $_POST['numeric_score'];
@ -58,7 +58,7 @@ class NumericScore implements Extension {
else if($char == "d") $score = -1; else if($char == "d") $score = -1;
if($score != 0) send_event(new NumericScoreSetEvent($event->image_id, $user, $score)); if($score != 0) send_event(new NumericScoreSetEvent($event->image_id, $user, $score));
} }
if($event instanceof NumericScoreSetEvent) { if($event instanceof NumericScoreSetEvent) {
$this->add_vote($event->image_id, $event->user->id, $event->score); $this->add_vote($event->image_id, $event->user->id, $event->score);
} }

View File

@ -4,7 +4,7 @@ class NumericScoreTheme extends Themelet {
public function get_voter_html($image) { public function get_voter_html($image) {
$i_image_id = int_escape($image->id); $i_image_id = int_escape($image->id);
$i_score = int_escape($image->numeric_score); $i_score = int_escape($image->numeric_score);
$html = " $html = "
Current Score: $i_score Current Score: $i_score

View File

@ -12,9 +12,9 @@ class PicLens implements Extension {
} }
if($event instanceof PostListBuildingEvent) { if($event instanceof PostListBuildingEvent) {
$foo=' $foo='
<a href="javascript:PicLensLite.start();">Start Slideshow <a href="javascript:PicLensLite.start();">Start Slideshow
<img src="http://lite.piclens.com/images/PicLensButton.png" <img src="http://lite.piclens.com/images/PicLensButton.png"
alt="PicLens" width="16" height="12" border="0" alt="PicLens" width="16" height="12" border="0"
align="absmiddle"></a>'; align="absmiddle"></a>';
$event->page->add_block(new Block("PicLens", $foo, "left", 20)); $event->page->add_block(new Block("PicLens", $foo, "left", 20));
} }

View File

@ -114,7 +114,7 @@ class PM implements Extension {
protected function install(RequestContext $context) { protected function install(RequestContext $context) {
$database = $context->database; $database = $context->database;
$config = $context->config; $config = $context->config;
// shortcut to latest // shortcut to latest
if($config->get_int("pm_version") < 1) { if($config->get_int("pm_version") < 1) {
$database->execute(" $database->execute("

View File

@ -12,7 +12,7 @@ class RandomImage implements Extension {
if(($event instanceof PageRequestEvent) && $event->page_matches("random_image")) { if(($event instanceof PageRequestEvent) && $event->page_matches("random_image")) {
global $config; global $config;
global $database; global $database;
if($event->count_args() == 1) { if($event->count_args() == 1) {
$action = $event->get_arg(0); $action = $event->get_arg(0);
$search_terms = array(); $search_terms = array();

View File

@ -50,7 +50,7 @@ class Ratings implements Extension {
send_event(new RatingSetEvent($event->image_id, $user, $_POST['rating'])); send_event(new RatingSetEvent($event->image_id, $user, $_POST['rating']));
} }
} }
if($event instanceof SetupBuildingEvent) { if($event instanceof SetupBuildingEvent) {
$privs = array(); $privs = array();
$privs['Safe Only'] = 's'; $privs['Safe Only'] = 's';

View File

@ -8,7 +8,7 @@
* Version 0.3a - See changelog in main.php * Version 0.3a - See changelog in main.php
* November 06, 2007 * November 06, 2007
*/ */
class RemoveReportedImageEvent extends Event { class RemoveReportedImageEvent extends Event {
var $id; var $id;
@ -17,11 +17,11 @@ class RemoveReportedImageEvent extends Event {
} }
} }
class AddReportedImageEvent extends Event { class AddReportedImageEvent extends Event {
var $reporter_id; var $reporter_id;
var $image_id; var $image_id;
var $reason; var $reason;
public function AddReportedImageEvent($image_id, $reporter_id, $reason) { public function AddReportedImageEvent($image_id, $reporter_id, $reason) {
$this->reporter_id = $reporter_id; $this->reporter_id = $reporter_id;
$this->image_id = $image_id; $this->image_id = $image_id;
@ -31,20 +31,20 @@ class AddReportedImageEvent extends Event {
class ReportImage implements Extension { class ReportImage implements Extension {
var $theme; var $theme;
public function receive_event(Event $event) { public function receive_event(Event $event) {
if(is_null($this->theme)) $this->theme = get_theme_object($this); if(is_null($this->theme)) $this->theme = get_theme_object($this);
if($event instanceof InitExtEvent) { if($event instanceof InitExtEvent) {
global $config; global $config;
$config->set_default_bool('report_image_show_thumbs', true); $config->set_default_bool('report_image_show_thumbs', true);
if($config->get_int("ext_report_image_version") < 1) { if($config->get_int("ext_report_image_version") < 1) {
$this->install(); $this->install();
} }
} }
if(($event instanceof PageRequestEvent) && $event->page_matches("image_report")) { if(($event instanceof PageRequestEvent) && $event->page_matches("image_report")) {
global $user; global $user;
if($event->get_arg(0) == "add") { if($event->get_arg(0) == "add") {
@ -70,7 +70,7 @@ class ReportImage implements Extension {
} }
} }
} }
if($event instanceof AddReportedImageEvent) { if($event instanceof AddReportedImageEvent) {
global $database; global $database;
$database->Execute( $database->Execute(
@ -83,7 +83,7 @@ class ReportImage implements Extension {
global $database; global $database;
$database->Execute("DELETE FROM image_reports WHERE id = ?", array($event->id)); $database->Execute("DELETE FROM image_reports WHERE id = ?", array($event->id));
} }
if($event instanceof DisplayingImageEvent) { if($event instanceof DisplayingImageEvent) {
global $user; global $user;
global $config; global $config;
@ -98,7 +98,7 @@ class ReportImage implements Extension {
$sb->add_bool_option("report_image_show_thumbs", "<br>Show thumbnails in admin panel: "); $sb->add_bool_option("report_image_show_thumbs", "<br>Show thumbnails in admin panel: ");
$event->panel->add_block($sb); $event->panel->add_block($sb);
} }
if($event instanceof UserBlockBuildingEvent) { if($event instanceof UserBlockBuildingEvent) {
if($event->user->is_admin()) { if($event->user->is_admin()) {
$event->add_link("Reported Images", make_link("image_report/list")); $event->add_link("Reported Images", make_link("image_report/list"));
@ -110,7 +110,7 @@ class ReportImage implements Extension {
$database->Execute("DELETE FROM image_reports WHERE image_id = ?", array($event->image->id)); $database->Execute("DELETE FROM image_reports WHERE image_id = ?", array($event->image->id));
} }
} }
protected function install() { protected function install() {
global $database; global $database;
global $config; global $config;
@ -132,7 +132,7 @@ class ReportImage implements Extension {
FROM image_reports FROM image_reports
JOIN users ON reporter_id = users.id"); JOIN users ON reporter_id = users.id");
if(is_null($all_reports)) $all_reports = array(); if(is_null($all_reports)) $all_reports = array();
$reports = array(); $reports = array();
foreach($all_reports as $report) { foreach($all_reports as $report) {
global $database, $config; global $database, $config;

View File

@ -9,7 +9,7 @@
* Version 0.3a - See changelog in main.php * Version 0.3a - See changelog in main.php
* November 06, 2007 * November 06, 2007
*/ */
class ReportImageTheme extends Themelet { class ReportImageTheme extends Themelet {
public function display_reported_images($page, $reports) { public function display_reported_images($page, $reports) {
global $config; global $config;
@ -28,13 +28,13 @@ class ReportImageTheme extends Themelet {
$reporter_name = html_escape($report['reporter_name']); $reporter_name = html_escape($report['reporter_name']);
$userlink = "<a href='".make_link("user/$reporter_name")."'>$reporter_name</a>"; $userlink = "<a href='".make_link("user/$reporter_name")."'>$reporter_name</a>";
global $user; global $user;
$iabbe = new ImageAdminBlockBuildingEvent($image, $user); $iabbe = new ImageAdminBlockBuildingEvent($image, $user);
send_event($iabbe); send_event($iabbe);
ksort($iabbe->parts); ksort($iabbe->parts);
$actions = join("<br>", $iabbe->parts); $actions = join("<br>", $iabbe->parts);
$h_reportedimages .= " $h_reportedimages .= "
<tr> <tr>
<td>{$image_link}</td> <td>{$image_link}</td>
@ -50,7 +50,7 @@ class ReportImageTheme extends Themelet {
</tr> </tr>
"; ";
} }
$thumb_width = $config->get_int("thumb_width"); $thumb_width = $config->get_int("thumb_width");
$html = " $html = "
<style> <style>
@ -63,17 +63,17 @@ class ReportImageTheme extends Themelet {
$h_reportedimages $h_reportedimages
</table> </table>
"; ";
$page->set_title("Reported Images"); $page->set_title("Reported Images");
$page->set_heading("Reported Images"); $page->set_heading("Reported Images");
$page->add_block(new NavBlock()); $page->add_block(new NavBlock());
$page->add_block(new Block("Reported Images", $html)); $page->add_block(new Block("Reported Images", $html));
} }
public function display_image_banner($page, $image) { public function display_image_banner($page, $image) {
global $config; global $config;
$i_image = int_escape($image); $i_image = int_escape($image);
$html = " $html = "
<form action='".make_link("image_report/add")."' method='POST'> <form action='".make_link("image_report/add")."' method='POST'>

View File

@ -15,7 +15,7 @@ class ResolutionLimit implements Extension {
$max_h = $config->get_int("upload_max_height", -1); $max_h = $config->get_int("upload_max_height", -1);
$ratios = explode(" ", $config->get_string("upload_ratios", "")); $ratios = explode(" ", $config->get_string("upload_ratios", ""));
$ratios = array_filter($ratios, "strlen"); $ratios = array_filter($ratios, "strlen");
$image = $event->image; $image = $event->image;
if($min_w > 0 && $image->width < $min_w) throw new UploadException("Image too small"); if($min_w > 0 && $image->width < $min_w) throw new UploadException("Image too small");
@ -56,13 +56,13 @@ class ResolutionLimit implements Extension {
$sb->add_label(" x "); $sb->add_label(" x ");
$sb->add_int_option("upload_max_height"); $sb->add_int_option("upload_max_height");
$sb->add_label(" px"); $sb->add_label(" px");
$sb->add_label("<br>(-1 for no limit)"); $sb->add_label("<br>(-1 for no limit)");
$sb->add_label("<br>Ratios "); $sb->add_label("<br>Ratios ");
$sb->add_text_option("upload_ratios"); $sb->add_text_option("upload_ratios");
$sb->add_label("<br>(eg. '4:3 16:9', blank for no limit)"); $sb->add_label("<br>(eg. '4:3 16:9', blank for no limit)");
$event->panel->add_block($sb); $event->panel->add_block($sb);
} }
} }

View File

@ -53,7 +53,7 @@ class RSS_Comments implements Extension {
$posted = strftime("%a, %d %b %Y %T %Z", $comment['posted_timestamp']); $posted = strftime("%a, %d %b %Y %T %Z", $comment['posted_timestamp']);
$comment = html_escape($comment['comment']); $comment = html_escape($comment['comment']);
$content = html_escape("$owner: $comment"); $content = html_escape("$owner: $comment");
$data .= " $data .= "
<item> <item>
<title>$owner comments on $image_id</title> <title>$owner comments on $image_id</title>

View File

@ -69,7 +69,7 @@ class RSS_Images implements Extension {
"<p>" . Themelet::build_thumb_html($image) . "</p>" . "<p>" . Themelet::build_thumb_html($image) . "</p>" .
"<p>Uploaded by " . $owner->name . "</p>" "<p>Uploaded by " . $owner->name . "</p>"
); );
$data .= " $data .= "
<item> <item>
<title>{$image->id} - $tags</title> <title>{$image->id} - $tags</title>

View File

@ -33,7 +33,7 @@ class SCoreReporter extends HtmlReporter {
"</div>"; "</div>";
$this->page->add_block(new Block("Results", $html, "main", 40)); $this->page->add_block(new Block("Results", $html, "main", 40));
} }
function paintGroupStart($name, $size) { function paintGroupStart($name, $size) {
parent::paintGroupStart($name, $size); parent::paintGroupStart($name, $size);
$this->current_html = ""; $this->current_html = "";

View File

@ -11,7 +11,7 @@ class SVNUpdate implements Extension {
public function receive_event(Event $event) { public function receive_event(Event $event) {
if(is_null($this->theme)) $this->theme = get_theme_object($this); if(is_null($this->theme)) $this->theme = get_theme_object($this);
if(($event instanceof PageRequestEvent) && $event->page_matches("update")) { if(($event instanceof PageRequestEvent) && $event->page_matches("update")) {
if($event->user->is_admin()) { if($event->user->is_admin()) {
if($event->get_arg(0) == "view_changes") { if($event->get_arg(0) == "view_changes") {
@ -50,7 +50,7 @@ class SVNUpdate implements Extension {
// FIXME: MySQL specific // FIXME: MySQL specific
if(preg_match("#^mysql://([^:]+):([^@]+)@([^/]+)/([^\?]+)#", $database_dsn, $matches)) { if(preg_match("#^mysql://([^:]+):([^@]+)@([^/]+)/([^\?]+)#", $database_dsn, $matches)) {
$date = date("Ymd"); $date = date("Ymd");
return return
shell_exec("mysqldump -uUSER -pPASS -hHOST DATABASE | gzip > db-$date.sql.gz") . shell_exec("mysqldump -uUSER -pPASS -hHOST DATABASE | gzip > db-$date.sql.gz") .
"\n\nDatabase dump should now be sitting in db-$date.sql.gz in the shimmie folder"; "\n\nDatabase dump should now be sitting in db-$date.sql.gz in the shimmie folder";
} }

View File

@ -21,7 +21,7 @@ class Tag_HistoryTheme extends Themelet {
} }
$history_list .= "<li><input type='radio' name='revert' value='$current_id'>$current_tags (Set by $setter)</li>\n"; $history_list .= "<li><input type='radio' name='revert' value='$current_id'>$current_tags (Set by $setter)</li>\n";
} }
$end_string = " $end_string = "
</ul> </ul>
<input type='submit' value='Revert'> <input type='submit' value='Revert'>

View File

@ -8,14 +8,14 @@
class Tagger implements Extension { class Tagger implements Extension {
var $theme; var $theme;
public function receive_event(Event $event) { public function receive_event(Event $event) {
if(is_null($this->theme)) if(is_null($this->theme))
$this->theme = get_theme_object($this); $this->theme = get_theme_object($this);
if($event instanceof DisplayingImageEvent) { if($event instanceof DisplayingImageEvent) {
global $page, $config, $user; global $page, $config, $user;
if($config->get_bool("tag_edit_anon") if($config->get_bool("tag_edit_anon")
|| ($user->id != $config->get_int("anon_id")) || ($user->id != $config->get_int("anon_id"))
&& $config->get_bool("ext_tagger_enabled")) && $config->get_bool("ext_tagger_enabled"))
@ -45,7 +45,7 @@ class TaggerXML implements Extension {
public function receive_event(Event $event) { public function receive_event(Event $event) {
if(($event instanceof PageRequestEvent) && $event->page_matches("tagger/tags")) { if(($event instanceof PageRequestEvent) && $event->page_matches("tagger/tags")) {
global $page; global $page;
//$match_tags = null; //$match_tags = null;
//$image_tags = null; //$image_tags = null;
$tags=null; $tags=null;
@ -56,26 +56,26 @@ class TaggerXML implements Extension {
// return arg[1] AS image_id's tag list in XML form // return arg[1] AS image_id's tag list in XML form
$tags = $this->image_tag_list($event->get_arg(0)); $tags = $this->image_tag_list($event->get_arg(0));
} }
$xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n". $xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n".
"<tags>". "<tags>".
$tags. $tags.
"</tags>"; "</tags>";
$page->set_mode("data"); $page->set_mode("data");
$page->set_type("text/xml"); $page->set_type("text/xml");
$page->set_data($xml); $page->set_data($xml);
} }
} }
private function match_tag_list ($s) { private function match_tag_list ($s) {
global $database, $config, $event; global $database, $config, $event;
$max_rows = $config->get_int("ext_tagger_tag_max",30); $max_rows = $config->get_int("ext_tagger_tag_max",30);
$limit_rows = $config->get_int("ext_tagger_limit",30); $limit_rows = $config->get_int("ext_tagger_limit",30);
$values = array(); $values = array();
// Match // Match
$p = strlen($s) == 1? " ":"\_"; $p = strlen($s) == 1? " ":"\_";
$sq = "%".$p.mysql_real_escape_string($s)."%"; $sq = "%".$p.mysql_real_escape_string($s)."%";
@ -83,13 +83,13 @@ class TaggerXML implements Extension {
array_push($values,$p,$sq); array_push($values,$p,$sq);
// Exclude // Exclude
// $exclude = $event->get_arg(1)? "AND NOT IN ".$this->image_tags($event->get_arg(1)) : null; // $exclude = $event->get_arg(1)? "AND NOT IN ".$this->image_tags($event->get_arg(1)) : null;
// Hidden Tags // Hidden Tags
$hidden = $config->get_string('ext-tagger_show-hidden','N')=='N' ? $hidden = $config->get_string('ext-tagger_show-hidden','N')=='N' ?
"AND substring(tag,1,1) != '.'" : null; "AND substring(tag,1,1) != '.'" : null;
$q_where = "WHERE {$match} {$hidden} AND count > 0"; $q_where = "WHERE {$match} {$hidden} AND count > 0";
// FROM based on return count // FROM based on return count
$q_from = null; $q_from = null;
$count = $this->count($q_where,$values); $count = $this->count($q_where,$values);
@ -102,17 +102,17 @@ class TaggerXML implements Extension {
$q_from = "FROM `tags`"; $q_from = "FROM `tags`";
$count = null; $count = null;
} }
$tags = $database->Execute(" $tags = $database->Execute("
SELECT * SELECT *
{$q_from} {$q_from}
{$q_where} {$q_where}
ORDER BY tag", ORDER BY tag",
$values); $values);
return $this->list_to_xml($tags,"search",$s,$count); return $this->list_to_xml($tags,"search",$s,$count);
} }
private function image_tag_list ($image_id) { private function image_tag_list ($image_id) {
global $database; global $database;
$tags = $database->Execute(" $tags = $database->Execute("
@ -121,21 +121,21 @@ class TaggerXML implements Extension {
WHERE image_id=? ORDER BY tag", array($image_id)); WHERE image_id=? ORDER BY tag", array($image_id));
return $this->list_to_xml($tags,"image",$image_id); return $this->list_to_xml($tags,"image",$image_id);
} }
private function list_to_xml ($tags,$type,$query,$misc=null) { private function list_to_xml ($tags,$type,$query,$misc=null) {
$r = $tags->_numOfRows; $r = $tags->_numOfRows;
$s_misc = ""; $s_misc = "";
if(!is_null($misc)) if(!is_null($misc))
foreach($misc as $attr => $val) $s_misc .= " ".$attr."=\"".$val."\""; foreach($misc as $attr => $val) $s_misc .= " ".$attr."=\"".$val."\"";
$result = "<list id=\"$type\" query=\"$query\" rows=\"$r\"{$s_misc}>"; $result = "<list id=\"$type\" query=\"$query\" rows=\"$r\"{$s_misc}>";
foreach($tags as $tag) { foreach($tags as $tag) {
$result .= $this->tag_to_xml($tag); $result .= $this->tag_to_xml($tag);
} }
return $result."</list>"; return $result."</list>";
} }
private function tag_to_xml ($tag) { private function tag_to_xml ($tag) {
return return
"<tag ". "<tag ".
@ -144,13 +144,13 @@ class TaggerXML implements Extension {
html_escape($tag['tag']). html_escape($tag['tag']).
"</tag>"; "</tag>";
} }
private function count($query,$values) { private function count($query,$values) {
global $database; global $database;
return $database->Execute( return $database->Execute(
"SELECT COUNT(*) FROM `tags` $query",$values)->fields['COUNT(*)']; "SELECT COUNT(*) FROM `tags` $query",$values)->fields['COUNT(*)'];
} }
private function image_tags ($image_id) { private function image_tags ($image_id) {
global $database; global $database;
$list = "("; $list = "(";
@ -164,10 +164,10 @@ class TaggerXML implements Extension {
$list .= ","; $list .= ",";
$b = true; $b = true;
$list .= $tag['tag_id']; $list .= $tag['tag_id'];
} }
$list .= ")"; $list .= ")";
return $list; return $list;
} }
} add_event_listener( new taggerXML(),10); } add_event_listener( new taggerXML(),10);

View File

@ -15,7 +15,7 @@ class taggerTheme extends Themelet {
$page->add_block(new Block(null, $page->add_block(new Block(null,
"<script type='text/javascript'>Tagger.initialize(" "<script type='text/javascript'>Tagger.initialize("
.$event->get_image()->id.");</script>","main",1000)); .$event->get_image()->id.");</script>","main",1000));
// Tagger block // Tagger block
$page->add_block( new Block( $page->add_block( new Block(
null, null,
@ -27,16 +27,16 @@ class taggerTheme extends Themelet {
$i_image_id = int_escape($image->id); $i_image_id = int_escape($image->id);
$h_source = html_escape($image->source); $h_source = html_escape($image->source);
$h_query = isset($_GET['search'])? $h_query= "search=".url_escape($_GET['search']) : ""; $h_query = isset($_GET['search'])? $h_query= "search=".url_escape($_GET['search']) : "";
$delay = $config->get_string("ext_tagger_search_delay","250"); $delay = $config->get_string("ext_tagger_search_delay","250");
$url_form = make_link("tag_edit/set"); $url_form = make_link("tag_edit/set");
// TODO: option for initial Tagger window placement. // TODO: option for initial Tagger window placement.
$html = <<< EOD $html = <<< EOD
<div id="tagger_parent" style="display:none; top:25px; right:25px;"> <div id="tagger_parent" style="display:none; top:25px; right:25px;">
<div id="tagger_titlebar">Tagger</div> <div id="tagger_titlebar">Tagger</div>
<div id="tagger_toolbar"> <div id="tagger_toolbar">
<input type="text" value="" id="tagger_filter" onkeyup="Tagger.tag.search(this.value, $delay);"></input> <input type="text" value="" id="tagger_filter" onkeyup="Tagger.tag.search(this.value, $delay);"></input>
<input type="button" value="Add" onclick="Tagger.tag.create(byId('tagger_filter').value);"></input> <input type="button" value="Add" onclick="Tagger.tag.create(byId('tagger_filter').value);"></input>
@ -51,8 +51,8 @@ class taggerTheme extends Themelet {
<!--<ul id="tagger_p-menu"></ul> <!--<ul id="tagger_p-menu"></ul>
<br style="clear:both;"/>--> <br style="clear:both;"/>-->
</div> </div>
<div id="tagger_body"> <div id="tagger_body">
<div id="tagger_p-search" name="Searched Tags"></div> <div id="tagger_p-search" name="Searched Tags"></div>
<div id="tagger_p-applied" name="Applied Tags"></div> <div id="tagger_p-applied" name="Applied Tags"></div>
</div> </div>

View File

@ -29,7 +29,7 @@ class TextScore implements Extension {
} }
$config->set_default_bool("text_score_anon", true); $config->set_default_bool("text_score_anon", true);
} }
if(($event instanceof ImageInfoBoxBuildingEvent)) { if(($event instanceof ImageInfoBoxBuildingEvent)) {
global $user; global $user;
global $config; global $config;
@ -37,11 +37,11 @@ class TextScore implements Extension {
$event->add_part($this->theme->get_scorer_html($event->image)); $event->add_part($this->theme->get_scorer_html($event->image));
} }
} }
if($event instanceof ImageInfoSetEvent) { if($event instanceof ImageInfoSetEvent) {
global $user; global $user;
$i_score = int_escape($_POST['text_score__score']); $i_score = int_escape($_POST['text_score__score']);
if($i_score >= -2 || $i_score <= 2) { if($i_score >= -2 || $i_score <= 2) {
send_event(new TextScoreSetEvent($event->image_id, $user, $i_score)); send_event(new TextScoreSetEvent($event->image_id, $user, $i_score));
} }
@ -57,7 +57,7 @@ class TextScore implements Extension {
global $database; global $database;
$database->execute("DELETE FROM text_score_votes WHERE image_id=?", array($event->image->id)); $database->execute("DELETE FROM text_score_votes WHERE image_id=?", array($event->image->id));
} }
if(($event instanceof SetupBuildingEvent)) { if(($event instanceof SetupBuildingEvent)) {
$sb = new SetupBlock("Text Score"); $sb = new SetupBlock("Text Score");
$sb->add_bool_option("text_score_anon", "Allow anonymous votes: "); $sb->add_bool_option("text_score_anon", "Allow anonymous votes: ");

View File

@ -3,7 +3,7 @@
class TextScoreTheme extends Themelet { class TextScoreTheme extends Themelet {
public function get_scorer_html($image) { public function get_scorer_html($image) {
$i_image_id = int_escape($image->id); $i_image_id = int_escape($image->id);
$s_score = $this->score_to_name($image->text_score); $s_score = $this->score_to_name($image->text_score);
$html = " $html = "
Current score is \"$s_score\" Current score is \"$s_score\"

View File

@ -27,7 +27,7 @@ class WikiPage {
var $revision; var $revision;
var $locked; var $locked;
var $body; var $body;
public function WikiPage($row=null) { public function WikiPage($row=null) {
if(!is_null($row)) { if(!is_null($row)) {
$this->id = $row['id']; $this->id = $row['id'];
@ -69,7 +69,7 @@ class Wiki implements Extension {
else { else {
$title = $event->get_arg(0); $title = $event->get_arg(0);
} }
$content = $this->get_page($title); $content = $this->get_page($title);
if(isset($_GET['save']) && $_GET['save'] == "on") { if(isset($_GET['save']) && $_GET['save'] == "on") {
@ -77,7 +77,7 @@ class Wiki implements Extension {
$rev = int_escape($_POST['revision']); $rev = int_escape($_POST['revision']);
$body = $_POST['body']; $body = $_POST['body'];
$lock = isset($_POST['lock']) && ($_POST['lock'] == "on"); $lock = isset($_POST['lock']) && ($_POST['lock'] == "on");
global $user; global $user;
if($this->can_edit($user, $this->get_page($title))) { if($this->can_edit($user, $this->get_page($title))) {
$wikipage = new WikiPage(); $wikipage = new WikiPage();

View File

@ -13,7 +13,7 @@ class WikiTheme {
$nav_page = new WikiPage(); $nav_page = new WikiPage();
$nav_page->body = ""; $nav_page->body = "";
} }
$tfe = new TextFormattingEvent($nav_page->body); $tfe = new TextFormattingEvent($nav_page->body);
send_event($tfe); send_event($tfe);

View File

@ -19,7 +19,7 @@ class WordFilter implements Extension {
$event->panel->add_block($sb); $event->panel->add_block($sb);
} }
} }
private function filter($text) { private function filter($text) {
$map = $this->get_map(); $map = $this->get_map();
foreach($map as $search => $replace) { foreach($map as $search => $replace) {

View File

@ -16,7 +16,7 @@ class Zoom implements Extension {
global $config; global $config;
$this->theme->display_zoomer($event->page, $event->image, $config->get_bool("image_zoom", false)); $this->theme->display_zoomer($event->page, $event->image, $config->get_bool("image_zoom", false));
} }
if($event instanceof SetupBuildingEvent) { if($event instanceof SetupBuildingEvent) {
$sb = new SetupBlock("Image Zoom"); $sb = new SetupBlock("Image Zoom");
$sb->add_bool_option("image_zoom", "Zoom by default: "); $sb->add_bool_option("image_zoom", "Zoom by default: ");

View File

@ -4,7 +4,7 @@ class ZoomTheme extends Themelet {
public function display_zoomer($page, $image, $zoom_by_default) { public function display_zoomer($page, $image, $zoom_by_default) {
$page->add_block(new Block(null, $this->make_zoomer($image->width, $zoom_by_default))); $page->add_block(new Block(null, $this->make_zoomer($image->width, $zoom_by_default)));
} }
protected function make_zoomer($image_width, $zoom_by_default) { protected function make_zoomer($image_width, $zoom_by_default) {
global $config; global $config;
$default = $zoom_by_default ? "scale(img);" : ""; $default = $zoom_by_default ? "scale(img);" : "";

View File

@ -10,7 +10,7 @@ require_once "lib/adodb/adodb-exceptions.inc.php";
class Querylet { class Querylet {
var $sql; var $sql;
var $variables; var $variables;
public function Querylet($sql, $variables=array()) { public function Querylet($sql, $variables=array()) {
$this->sql = $sql; $this->sql = $sql;
$this->variables = $variables; $this->variables = $variables;
@ -193,14 +193,14 @@ class Database {
public function upgrade_schema($filename) { public function upgrade_schema($filename) {
$this->install_schema($filename); $this->install_schema($filename);
} }
public function install_schema($filename) { public function install_schema($filename) {
//print "<br>upgrading $filename"; //print "<br>upgrading $filename";
global $config; global $config;
if($config->get_bool("in_upgrade")) return; if($config->get_bool("in_upgrade")) return;
$config->set_bool("in_upgrade", true); $config->set_bool("in_upgrade", true);
require_once "lib/adodb/adodb-xmlschema03.inc.php"; require_once "lib/adodb/adodb-xmlschema03.inc.php";
$schema = new adoSchema($this->db); $schema = new adoSchema($this->db);
$sql = $schema->ParseSchema($filename); $sql = $schema->ParseSchema($filename);

View File

@ -43,7 +43,7 @@ class PageRequestEvent extends Event {
public function page_matches($name) { public function page_matches($name) {
$parts = explode("/", $name); $parts = explode("/", $name);
$this->part_count = count($parts); $this->part_count = count($parts);
if($this->part_count > $this->arg_count) { if($this->part_count > $this->arg_count) {
return false; return false;
} }

View File

@ -51,7 +51,7 @@ class Image {
$row = $database->get_row("SELECT * FROM images WHERE images.id=?", array($id)); $row = $database->get_row("SELECT * FROM images WHERE images.id=?", array($id));
return ($row ? new Image($row) : null); return ($row ? new Image($row) : null);
} }
public static function by_hash(Config $config, Database $database, $hash) { public static function by_hash(Config $config, Database $database, $hash) {
assert(is_string($hash)); assert(is_string($hash));
$image = null; $image = null;
@ -66,7 +66,7 @@ class Image {
if(count($set) > 0) return $set[0]; if(count($set) > 0) return $set[0];
else return null; else return null;
} }
public static function find_images(Config $config, Database $database, $start, $limit, $tags=array()) { public static function find_images(Config $config, Database $database, $start, $limit, $tags=array()) {
$images = array(); $images = array();
@ -74,11 +74,11 @@ class Image {
assert(is_numeric($limit)); assert(is_numeric($limit));
if($start < 0) $start = 0; if($start < 0) $start = 0;
if($limit < 1) $limit = 1; if($limit < 1) $limit = 1;
$querylet = Image::build_search_querylet($config, $database, $tags); $querylet = Image::build_search_querylet($config, $database, $tags);
$querylet->append(new Querylet("ORDER BY images.id DESC LIMIT ? OFFSET ?", array($limit, $start))); $querylet->append(new Querylet("ORDER BY images.id DESC LIMIT ? OFFSET ?", array($limit, $start)));
$result = $database->execute($querylet->sql, $querylet->variables); $result = $database->execute($querylet->sql, $querylet->variables);
while(!$result->EOF) { while(!$result->EOF) {
$images[] = new Image($result->fields); $images[] = new Image($result->fields);
$result->MoveNext(); $result->MoveNext();
@ -99,7 +99,7 @@ class Image {
return $result->RecordCount(); return $result->RecordCount();
} }
} }
public static function count_pages(Config $config, Database $database, $tags=array()) { public static function count_pages(Config $config, Database $database, $tags=array()) {
$images_per_page = $config->get_int('index_width') * $config->get_int('index_height'); $images_per_page = $config->get_int('index_width') * $config->get_int('index_height');
return ceil(Image::count_images($config, $database, $tags) / $images_per_page); return ceil(Image::count_images($config, $database, $tags) / $images_per_page);
@ -112,7 +112,7 @@ class Image {
public function get_next($tags=array(), $next=true) { public function get_next($tags=array(), $next=true) {
assert(is_array($tags)); assert(is_array($tags));
assert(is_bool($next)); assert(is_bool($next));
if($next) { if($next) {
$gtlt = "<"; $gtlt = "<";
$dir = "DESC"; $dir = "DESC";
@ -131,14 +131,14 @@ class Image {
$querylet->append_sql(" ORDER BY images.id $dir LIMIT 1"); $querylet->append_sql(" ORDER BY images.id $dir LIMIT 1");
$row = $this->database->db->GetRow($querylet->sql, $querylet->variables); $row = $this->database->db->GetRow($querylet->sql, $querylet->variables);
} }
return ($row ? new Image($row) : null); return ($row ? new Image($row) : null);
} }
public function get_prev($tags=array()) { public function get_prev($tags=array()) {
return $this->get_next($tags, false); return $this->get_next($tags, false);
} }
public function get_owner() { public function get_owner() {
return User::by_id($this->config, $this->database, $this->owner_id); return User::by_id($this->config, $this->database, $this->owner_id);
} }
@ -210,7 +210,7 @@ class Image {
public function get_filename() { public function get_filename() {
return $this->filename; return $this->filename;
} }
public function get_mime_type() { public function get_mime_type() {
return "image/".($this->ext); return "image/".($this->ext);
} }
@ -222,7 +222,7 @@ class Image {
public function get_source() { public function get_source() {
return $this->source; return $this->source;
} }
public function set_source($source) { public function set_source($source) {
if(empty($source)) $source = null; if(empty($source)) $source = null;
$this->database->execute("UPDATE images SET source=? WHERE id=?", array($source, $this->id)); $this->database->execute("UPDATE images SET source=? WHERE id=?", array($source, $this->id));
@ -244,7 +244,7 @@ class Image {
// delete old // delete old
$this->delete_tags_from_image(); $this->delete_tags_from_image();
// insert each new tag // insert each new tag
foreach($tags as $tag) { foreach($tags as $tag) {
$this->database->execute( $this->database->execute(
@ -266,7 +266,7 @@ class Image {
*/ */
public function delete() { public function delete() {
$this->database->execute("DELETE FROM images WHERE id=?", array($this->id)); $this->database->execute("DELETE FROM images WHERE id=?", array($this->id));
unlink($this->get_image_filename()); unlink($this->get_image_filename());
unlink($this->get_thumb_filename()); unlink($this->get_thumb_filename());
} }
@ -322,7 +322,7 @@ class Image {
$positive = false; $positive = false;
$term = substr($term, 1); $term = substr($term, 1);
} }
$term = Tag::resolve_alias($term); $term = Tag::resolve_alias($term);
$stpe = new SearchTermParseEvent($term, $terms); $stpe = new SearchTermParseEvent($term, $terms);
@ -498,7 +498,7 @@ class Tag {
function get_debug_info() { function get_debug_info() {
global $config, $_event_count; global $config, $_event_count;
if(function_exists('memory_get_usage')) { if(function_exists('memory_get_usage')) {
$i_mem = sprintf("%5.2f", ((memory_get_usage()+512)/1024)/1024); $i_mem = sprintf("%5.2f", ((memory_get_usage()+512)/1024)/1024);
} }
@ -530,11 +530,11 @@ function get_debug_info() {
// print_obj ($object, $title, $return) // print_obj ($object, $title, $return)
function print_obj($object,$title="Object Information", $return=false) { function print_obj($object,$title="Object Information", $return=false) {
global $user; global $user;
if(DEBUG && isset($_GET['debug']) && $user->is_admin()) { if(DEBUG && isset($_GET['debug']) && $user->is_admin()) {
$pr = print_r($object,true); $pr = print_r($object,true);
$count = substr_count($pr,"\n")<=25?substr_count($pr,"\n"):25; $count = substr_count($pr,"\n")<=25?substr_count($pr,"\n"):25;
$pr = "<textarea rows='".$count."' cols='80'>$pr</textarea>"; $pr = "<textarea rows='".$count."' cols='80'>$pr</textarea>";
if($return) { if($return) {
return $pr; return $pr;
} else { } else {
@ -545,23 +545,23 @@ function print_obj($object,$title="Object Information", $return=false) {
} }
} }
// preset tests. // preset tests.
// Prints the contents of $event->args, even though they are clearly visible in // Prints the contents of $event->args, even though they are clearly visible in
// the URL bar. // the URL bar.
function print_url_args() { function print_url_args() {
global $event; global $event;
print_obj($event->args,"URL Arguments"); print_obj($event->args,"URL Arguments");
} }
// Prints all the POST data. // Prints all the POST data.
function print_POST() { function print_POST() {
print_obj($_POST,"\$_POST"); print_obj($_POST,"\$_POST");
} }
// Prints GET, though this is also visible in the url ( url?var&var&var) // Prints GET, though this is also visible in the url ( url?var&var&var)
function print_GET() { function print_GET() {
print_obj($_GET,"\$_GET"); print_obj($_GET,"\$_GET");
} }

View File

@ -6,12 +6,12 @@ class GenericPage {
public function set_mode($mode) { public function set_mode($mode) {
$this->mode = $mode; $this->mode = $mode;
} }
public function set_type($type) { public function set_type($type) {
$this->type = $type; $this->type = $type;
} }
// ============================================== // ==============================================
// data // data
@ -21,7 +21,7 @@ class GenericPage {
public function set_data($data) { public function set_data($data) {
$this->data = $data; $this->data = $data;
} }
public function set_filename($filename) { public function set_filename($filename) {
$this->filename = $filename; $this->filename = $filename;
} }
@ -69,7 +69,7 @@ class GenericPage {
} }
// ============================================== // ==============================================
public function display($context) { public function display($context) {
header("Content-type: {$this->type}"); header("Content-type: {$this->type}");
header("X-Powered-By: SCore-".SCORE_VERSION); header("X-Powered-By: SCore-".SCORE_VERSION);

View File

@ -93,7 +93,7 @@ class User {
global $database; global $database;
return $database->db->GetOne("SELECT COUNT(*) AS count FROM images WHERE owner_id=?", array($this->id)); return $database->db->GetOne("SELECT COUNT(*) AS count FROM images WHERE owner_id=?", array($this->id));
} }
public function get_comment_count() { public function get_comment_count() {
global $database; global $database;
return $database->db->GetOne("SELECT COUNT(*) AS count FROM comments WHERE owner_id=?", array($this->id)); return $database->db->GetOne("SELECT COUNT(*) AS count FROM comments WHERE owner_id=?", array($this->id));

View File

@ -230,11 +230,11 @@ function array_remove($array, $to_remove) {
return $a2; return $a2;
} }
function array_add($array, $element) { function array_add($array, $element) {
$array[] = $element; $array[] = $element;
$array = array_unique($array); $array = array_unique($array);
return $array; return $array;
} }
function array_contains($array, $target) { function array_contains($array, $target) {
foreach($array as $element) { foreach($array as $element) {
@ -306,7 +306,7 @@ function full_copy($source, $target) {
continue; continue;
} }
$Entry = $source . '/' . $entry; $Entry = $source . '/' . $entry;
if(is_dir($Entry)) { if(is_dir($Entry)) {
full_copy($Entry, $target . '/' . $entry); full_copy($Entry, $target . '/' . $entry);
continue; continue;
@ -395,7 +395,7 @@ function _get_query_parts() {
else { else {
$path = ""; $path = "";
} }
while(strlen($path) > 0 && $path[0] == '/') { while(strlen($path) > 0 && $path[0] == '/') {
$path = substr($path, 1); $path = substr($path, 1);
} }
@ -413,7 +413,7 @@ function _get_page_request($context) {
if(count($args) == 0 || strlen($args[0]) == 0) { if(count($args) == 0 || strlen($args[0]) == 0) {
$args = split('/', $context->config->get_string('front_page')); $args = split('/', $context->config->get_string('front_page'));
} }
return new PageRequestEvent($context, $args); return new PageRequestEvent($context, $args);
} }

View File

@ -13,7 +13,7 @@ class AdminBuildingEvent extends Event {
class AdminPage implements Extension { class AdminPage implements Extension {
var $theme; var $theme;
public function receive_event(Event $event) { public function receive_event(Event $event) {
if(is_null($this->theme)) $this->theme = get_theme_object($this); if(is_null($this->theme)) $this->theme = get_theme_object($this);
@ -45,7 +45,7 @@ class AdminPage implements Extension {
if($event->user->is_admin()) { if($event->user->is_admin()) {
set_time_limit(0); set_time_limit(0);
$redirect = false; $redirect = false;
switch($_POST['action']) { switch($_POST['action']) {
case 'lowercase all tags': case 'lowercase all tags':
$this->lowercase_all_tags(); $this->lowercase_all_tags();
@ -121,7 +121,7 @@ class AdminPage implements Extension {
$cmd = "mysqldump -h$hostname -u$username -p$password $database"; $cmd = "mysqldump -h$hostname -u$username -p$password $database";
break; break;
} }
$page->set_mode("data"); $page->set_mode("data");
$page->set_type("application/x-unknown"); $page->set_type("application/x-unknown");
$page->set_filename('shimmie-'.date('Ymd').'.sql'); $page->set_filename('shimmie-'.date('Ymd').'.sql');

View File

@ -47,7 +47,7 @@ class AliasEditor implements Extension {
} }
else if($event->get_arg(0) == "list") { else if($event->get_arg(0) == "list") {
global $database; global $database;
$this->theme->display_aliases($event->page, $this->theme->display_aliases($event->page,
$database->db->GetAssoc("SELECT oldtag, newtag FROM aliases ORDER BY newtag"), $database->db->GetAssoc("SELECT oldtag, newtag FROM aliases ORDER BY newtag"),
$event->user->is_admin()); $event->user->is_admin());
} }
@ -88,7 +88,7 @@ class AliasEditor implements Extension {
$database->Execute("INSERT INTO aliases(oldtag, newtag) VALUES(?, ?)", $pair); $database->Execute("INSERT INTO aliases(oldtag, newtag) VALUES(?, ?)", $pair);
} }
} }
if($event instanceof UserBlockBuildingEvent) { if($event instanceof UserBlockBuildingEvent) {
if($event->user->is_admin()) { if($event->user->is_admin()) {
$event->add_link("Alias Editor", make_link("alias/list")); $event->add_link("Alias Editor", make_link("alias/list"));

View File

@ -24,7 +24,7 @@ class AliasEditorTheme extends Themelet {
$action = ""; $action = "";
$add = ""; $add = "";
} }
$h_aliases = ""; $h_aliases = "";
foreach($aliases as $old => $new) { foreach($aliases as $old => $new) {
$h_old = html_escape($old); $h_old = html_escape($old);
@ -55,7 +55,7 @@ class AliasEditorTheme extends Themelet {
<input type='submit' value='Upload List'> <input type='submit' value='Upload List'>
</form> </form>
"; ";
$page->set_title("Alias List"); $page->set_title("Alias List");
$page->set_heading("Alias List"); $page->set_heading("Alias List");
$page->add_block(new NavBlock()); $page->add_block(new NavBlock());

View File

@ -7,7 +7,7 @@ class BBCode implements Extension {
$event->stripped = $this->bbcode_to_text($event->stripped); $event->stripped = $this->bbcode_to_text($event->stripped);
} }
} }
private function bbcode_to_html($text) { private function bbcode_to_html($text) {
$text = preg_replace("/\[b\](.*?)\[\/b\]/s", "<b>\\1</b>", $text); $text = preg_replace("/\[b\](.*?)\[\/b\]/s", "<b>\\1</b>", $text);
$text = preg_replace("/\[i\](.*?)\[\/i\]/s", "<i>\\1</i>", $text); $text = preg_replace("/\[i\](.*?)\[\/i\]/s", "<i>\\1</i>", $text);
@ -76,7 +76,7 @@ class BBCode implements Extension {
while(true) { while(true) {
$start = strpos($text, "[spoiler]"); $start = strpos($text, "[spoiler]");
if($start === false) break; if($start === false) break;
$end = strpos($text, "[/spoiler]"); $end = strpos($text, "[/spoiler]");
if($end === false) break; if($end === false) break;

View File

@ -149,7 +149,7 @@ class CommentList implements Extension {
protected function install() { protected function install() {
global $database; global $database;
global $config; global $config;
// shortcut to latest // shortcut to latest
if($config->get_int("ext_comments_version") < 1) { if($config->get_int("ext_comments_version") < 1) {
$database->Execute("CREATE TABLE comments ( $database->Execute("CREATE TABLE comments (
@ -245,7 +245,7 @@ class CommentList implements Extension {
} }
return $comments; return $comments;
} }
private function get_comments($image_id) { private function get_comments($image_id) {
global $config; global $config;
global $database; global $database;

View File

@ -18,7 +18,7 @@ class CommentListTheme extends Themelet {
"<a href='".make_link("comment/list/$next")."'>Next</a>"; "<a href='".make_link("comment/list/$next")."'>Next</a>";
$nav = "$h_prev | $h_index | $h_next"; $nav = "$h_prev | $h_index | $h_next";
$page->set_title("Comments"); $page->set_title("Comments");
$page->set_heading("Comments"); $page->set_heading("Comments");
$page->add_block(new Block("Navigation", $nav, "left")); $page->add_block(new Block("Navigation", $nav, "left"));
@ -103,7 +103,7 @@ class CommentListTheme extends Themelet {
$h_userlink = "<a href='".make_link("user/$h_name")."'>$h_name</a>"; $h_userlink = "<a href='".make_link("user/$h_name")."'>$h_name</a>";
$stripped_nonl = str_replace("\n", "\\n", $tfe->stripped); $stripped_nonl = str_replace("\n", "\\n", $tfe->stripped);
$stripped_nonl = str_replace("\r", "\\r", $stripped_nonl); $stripped_nonl = str_replace("\r", "\\r", $stripped_nonl);
$h_dellink = $user->is_admin() ? $h_dellink = $user->is_admin() ?
"<br>($h_poster_ip, <a ". "<br>($h_poster_ip, <a ".
"onclick=\"return confirm('Delete comment by $h_name:\\n$stripped_nonl');\" ". "onclick=\"return confirm('Delete comment by $h_name:\\n$stripped_nonl');\" ".
"href='".make_link("comment/delete/$i_comment_id/$i_image_id")."'>Del</a>)" : ""; "href='".make_link("comment/delete/$i_comment_id/$i_image_id")."'>Del</a>)" : "";

View File

@ -58,7 +58,7 @@ class ExtManager implements Extension {
public function receive_event(Event $event) { public function receive_event(Event $event) {
if(is_null($this->theme)) $this->theme = get_theme_object($this); if(is_null($this->theme)) $this->theme = get_theme_object($this);
if(($event instanceof PageRequestEvent) && $event->page_matches("ext_manager")) { if(($event instanceof PageRequestEvent) && $event->page_matches("ext_manager")) {
if($event->user->is_admin()) { if($event->user->is_admin()) {
if($event->get_arg(0) == "set") { if($event->get_arg(0) == "set") {

View File

@ -18,7 +18,7 @@ class ExtManagerTheme extends Themelet {
$html .= " $html .= "
<tr> <tr>
" . ( " . (
empty($h_link) ? empty($h_link) ?
"<td>$h_name</td>" : "<td>$h_name</td>" :
"<td><a href='$h_link'>$h_name</a></td>" "<td><a href='$h_link'>$h_name</a></td>"
) . ( ) . (

View File

@ -38,7 +38,7 @@ class PixelFileHandler implements Extension {
$exts = array("jpg", "jpeg", "gif", "png"); $exts = array("jpg", "jpeg", "gif", "png");
return array_contains($exts, strtolower($ext)); return array_contains($exts, strtolower($ext));
} }
private function create_image_from_data($filename, $metadata) { private function create_image_from_data($filename, $metadata) {
global $config; global $config;
@ -49,7 +49,7 @@ class PixelFileHandler implements Extension {
$image->width = $info[0]; $image->width = $info[0];
$image->height = $info[1]; $image->height = $info[1];
$image->filesize = $metadata['size']; $image->filesize = $metadata['size'];
$image->hash = $metadata['hash']; $image->hash = $metadata['hash'];
$image->filename = $metadata['filename']; $image->filename = $metadata['filename'];
@ -74,9 +74,9 @@ class PixelFileHandler implements Extension {
$inname = "images/$ha/$hash"; $inname = "images/$ha/$hash";
$outname = "thumbs/$ha/$hash"; $outname = "thumbs/$ha/$hash";
global $config; global $config;
$ok = false; $ok = false;
switch($config->get_string("thumb_engine")) { switch($config->get_string("thumb_engine")) {
default: default:
case 'gd': case 'gd':
@ -131,7 +131,7 @@ class PixelFileHandler implements Extension {
$memory_use = (filesize($tmpname)*2) + ($width*$height*4) + (4*1024*1024); $memory_use = (filesize($tmpname)*2) + ($width*$height*4) + (4*1024*1024);
$memory_limit = get_memory_limit(); $memory_limit = get_memory_limit();
if($memory_use > $memory_limit) { if($memory_use > $memory_limit) {
$w = $config->get_int('thumb_width'); $w = $config->get_int('thumb_width');
$h = $config->get_int('thumb_height'); $h = $config->get_int('thumb_height');

View File

@ -83,7 +83,7 @@ class ImageIO implements Extension {
$config->set_default_int('thumb_height', 192); $config->set_default_int('thumb_height', 192);
$config->set_default_int('thumb_quality', 75); $config->set_default_int('thumb_quality', 75);
$config->set_default_int('thumb_mem_limit', parse_shorthand_int('8MB')); $config->set_default_int('thumb_mem_limit', parse_shorthand_int('8MB'));
$config->set_default_string('image_ilink', ''); $config->set_default_string('image_ilink', '');
$config->set_default_string('image_tlink', ''); $config->set_default_string('image_tlink', '');
$config->set_default_string('image_tip', '$tags // $size // $filesize'); $config->set_default_string('image_tip', '$tags // $size // $filesize');
@ -95,7 +95,7 @@ class ImageIO implements Extension {
$matches = array(); $matches = array();
if(!is_null($num) && preg_match("/(\d+)/", $num, $matches)) { if(!is_null($num) && preg_match("/(\d+)/", $num, $matches)) {
$num = $matches[1]; $num = $matches[1];
if($event->page_matches("image")) { if($event->page_matches("image")) {
$this->send_file($num, "image"); $this->send_file($num, "image");
} }
@ -113,7 +113,7 @@ class ImageIO implements Extension {
if($event instanceof ImageDeletionEvent) { if($event instanceof ImageDeletionEvent) {
$event->image->delete(); $event->image->delete();
} }
if($event instanceof SetupBuildingEvent) { if($event instanceof SetupBuildingEvent) {
$sb = new SetupBlock("Image Options"); $sb = new SetupBlock("Image Options");
$sb->position = 30; $sb->position = 30;
@ -215,7 +215,7 @@ class ImageIO implements Extension {
$page->set_type($image->get_mime_type()); $page->set_type($image->get_mime_type());
$file = $image->get_image_filename(); $file = $image->get_image_filename();
} }
$page->set_data(file_get_contents($file)); $page->set_data(file_get_contents($file));
if(isset($_SERVER["HTTP_IF_MODIFIED_SINCE"])) { if(isset($_SERVER["HTTP_IF_MODIFIED_SINCE"])) {

View File

@ -41,7 +41,7 @@ class Index implements Extension {
public function receive_event(Event $event) { public function receive_event(Event $event) {
if(is_null($this->theme)) $this->theme = get_theme_object($this); if(is_null($this->theme)) $this->theme = get_theme_object($this);
if($event instanceof InitExtEvent) { if($event instanceof InitExtEvent) {
global $config; global $config;
$config->set_default_int("index_width", 3); $config->set_default_int("index_width", 3);
@ -73,7 +73,7 @@ class Index implements Extension {
$search_terms = explode(' ', $event->get_arg(0)); $search_terms = explode(' ', $event->get_arg(0));
$page_number = int_escape($event->get_arg(1)); $page_number = int_escape($event->get_arg(1));
} }
if($page_number == 0) $page_number = 1; // invalid -> 0 if($page_number == 0) $page_number = 1; // invalid -> 0
global $config; global $config;
@ -84,7 +84,7 @@ class Index implements Extension {
$images = Image::find_images($config, $database, ($page_number-1)*$count, $count, $search_terms); $images = Image::find_images($config, $database, ($page_number-1)*$count, $count, $search_terms);
send_event(new PostListBuildingEvent($event->page, $search_terms)); send_event(new PostListBuildingEvent($event->page, $search_terms));
$this->theme->set_page($page_number, $total_pages, $search_terms); $this->theme->set_page($page_number, $total_pages, $search_terms);
$this->theme->display_page($event->page, $images); $this->theme->display_page($event->page, $images);
} }
@ -92,7 +92,7 @@ class Index implements Extension {
if($event instanceof SetupBuildingEvent) { if($event instanceof SetupBuildingEvent) {
$sb = new SetupBlock("Index Options"); $sb = new SetupBlock("Index Options");
$sb->position = 20; $sb->position = 20;
$sb->add_label("Index table size "); $sb->add_label("Index table size ");
$sb->add_int_option("index_width"); $sb->add_int_option("index_width");
$sb->add_label(" x "); $sb->add_label(" x ");

View File

@ -53,7 +53,7 @@ class IndexTheme extends Themelet {
$u_tags = url_escape(implode(" ", $search_terms)); $u_tags = url_escape(implode(" ", $search_terms));
$query = empty($u_tags) ? "" : "/$u_tags"; $query = empty($u_tags) ? "" : "/$u_tags";
$h_prev = ($page_number <= 1) ? "Prev" : "<a href='".make_link("post/list$query/$prev")."'>Prev</a>"; $h_prev = ($page_number <= 1) ? "Prev" : "<a href='".make_link("post/list$query/$prev")."'>Prev</a>";
$h_index = "<a href='".make_link()."'>Index</a>"; $h_index = "<a href='".make_link()."'>Index</a>";
$h_next = ($page_number >= $total_pages) ? "Next" : "<a href='".make_link("post/list$query/$next")."'>Next</a>"; $h_next = ($page_number >= $total_pages) ? "Next" : "<a href='".make_link("post/list$query/$next")."'>Next</a>";

View File

@ -117,7 +117,7 @@ class SetupBlock extends Block {
public function add_choice_option($name, $options, $label=null) { public function add_choice_option($name, $options, $label=null) {
global $config; global $config;
$current = $config->get_string($name); $current = $config->get_string($name);
if(!is_null($label)) { if(!is_null($label)) {
$this->body .= "<label for='$name'>$label</label>"; $this->body .= "<label for='$name'>$label</label>";
} }
@ -165,7 +165,7 @@ class Setup implements Extension {
global $config; global $config;
send_event(new ConfigSaveEvent($config)); send_event(new ConfigSaveEvent($config));
$config->save(); $config->save();
global $page; global $page;
$page->set_mode("redirect"); $page->set_mode("redirect");
$page->set_redirect(make_link("setup")); $page->set_redirect(make_link("setup"));

View File

@ -70,7 +70,7 @@ class TagEdit implements Extension {
$this->theme->display_error($event->page, "Error", "Anonymous tag editing is disabled"); $this->theme->display_error($event->page, "Error", "Anonymous tag editing is disabled");
} }
} }
if($event instanceof TagSetEvent) { if($event instanceof TagSetEvent) {
$event->image->set_tags($event->tags); $event->image->set_tags($event->tags);
} }

View File

@ -2,11 +2,11 @@
class TagList implements Extension { class TagList implements Extension {
var $theme = null; var $theme = null;
// event handling {{{ // event handling {{{
public function receive_event(Event $event) { public function receive_event(Event $event) {
if($this->theme == null) $this->theme = get_theme_object($this); if($this->theme == null) $this->theme = get_theme_object($this);
if($event instanceof InitExtEvent) { if($event instanceof InitExtEvent) {
global $config; global $config;
$config->set_default_int("tag_list_length", 15); $config->set_default_int("tag_list_length", 15);
@ -95,7 +95,7 @@ class TagList implements Extension {
$h_alphabetic = "<a href='".make_link("tags/alphabetic")."'>Alphabetic</a>"; $h_alphabetic = "<a href='".make_link("tags/alphabetic")."'>Alphabetic</a>";
$h_popularity = "<a href='".make_link("tags/popularity")."'>Popularity</a>"; $h_popularity = "<a href='".make_link("tags/popularity")."'>Popularity</a>";
$h_cats = "<a href='".make_link("tags/categories")."'>Categories</a>"; $h_cats = "<a href='".make_link("tags/categories")."'>Categories</a>";
return "$h_index<br>$h_map<br>$h_alphabetic<br>$h_popularity<br>$h_cats"; return "$h_index<br>$h_map<br>$h_alphabetic<br>$h_popularity<br>$h_cats";
} }
private function build_tag_map() { private function build_tag_map() {
@ -209,7 +209,7 @@ class TagList implements Extension {
global $config; global $config;
$query = " $query = "
SELECT COUNT(it3.image_id) as count, t3.tag AS tag SELECT COUNT(it3.image_id) as count, t3.tag AS tag
FROM FROM
image_tags AS it1, image_tags AS it1,
image_tags AS it2, image_tags AS it2,
@ -280,7 +280,7 @@ class TagList implements Extension {
$wild_tags = tag_explode($search); $wild_tags = tag_explode($search);
// $search_tags = array(); // $search_tags = array();
$tag_id_array = array(); $tag_id_array = array();
$tags_ok = true; $tags_ok = true;
foreach($wild_tags as $tag) { foreach($wild_tags as $tag) {
@ -303,12 +303,12 @@ class TagList implements Extension {
image_tags AS it2, image_tags AS it2,
tags AS t1, tags AS t1,
tags AS t2 tags AS t2
WHERE WHERE
t1.id IN($tag_id_list) t1.id IN($tag_id_list)
AND it1.image_id=it2.image_id AND it1.image_id=it2.image_id
AND it1.tag_id = t1.id AND it1.tag_id = t1.id
AND it2.tag_id = t2.id AND it2.tag_id = t2.id
GROUP BY t2.tag GROUP BY t2.tag
ORDER BY count ORDER BY count
DESC LIMIT ? DESC LIMIT ?
"; ";

View File

@ -3,7 +3,7 @@
class TagListTheme extends Themelet { class TagListTheme extends Themelet {
var $heading = ""; var $heading = "";
var $list = ""; var $list = "";
public function set_heading($text) { public function set_heading($text) {
$this->heading = $text; $this->heading = $text;
} }
@ -27,7 +27,7 @@ class TagListTheme extends Themelet {
/* /*
* $tag_infos = array( * $tag_infos = array(
* array('tag' => $tag, 'count' => $number_of_uses), * array('tag' => $tag, 'count' => $number_of_uses),
* ... * ...
* ) * )
*/ */
@ -59,7 +59,7 @@ class TagListTheme extends Themelet {
/* /*
* $tag_infos = array( * $tag_infos = array(
* array('tag' => $tag, 'count' => $number_of_uses), * array('tag' => $tag, 'count' => $number_of_uses),
* ... * ...
* ) * )
*/ */
@ -84,14 +84,14 @@ class TagListTheme extends Themelet {
$html .= " <span class='tag_count'>$count</span>"; $html .= " <span class='tag_count'>$count</span>";
} }
} }
$html .= "<p><a class='more' href='".make_link("tags")."'>Full List</a>\n"; $html .= "<p><a class='more' href='".make_link("tags")."'>Full List</a>\n";
$page->add_block(new Block("Popular Tags", $html, "left", 60)); $page->add_block(new Block("Popular Tags", $html, "left", 60));
} }
/* /*
* $tag_infos = array( * $tag_infos = array(
* array('tag' => $tag), * array('tag' => $tag),
* ... * ...
* ) * )
* $search = the current array of tags being searched for * $search = the current array of tags being searched for
@ -114,10 +114,10 @@ class TagListTheme extends Themelet {
$html .= " <a class='tag_name' href='$link'>$h_tag_no_underscores</a>"; $html .= " <a class='tag_name' href='$link'>$h_tag_no_underscores</a>";
$html .= $this->ars($tag, $search); $html .= $this->ars($tag, $search);
} }
$page->add_block(new Block("Refine Search", $html, "left", 60)); $page->add_block(new Block("Refine Search", $html, "left", 60));
} }
protected function ars($tag, $tags) { protected function ars($tag, $tags) {
// FIXME: a better fix would be to make sure the inputs are correct // FIXME: a better fix would be to make sure the inputs are correct
$tag = strtolower($tag); $tag = strtolower($tag);

View File

@ -14,7 +14,7 @@ class Upgrade implements Extension {
if(!is_numeric($config->get_string("db_version"))) { if(!is_numeric($config->get_string("db_version"))) {
$config->set_int("db_version", 2); $config->set_int("db_version", 2);
} }
if($config->get_int("db_version") < 6) { if($config->get_int("db_version") < 6) {
$database->upgrade_schema("ext/upgrade/schema.xml"); $database->upgrade_schema("ext/upgrade/schema.xml");
} }

View File

@ -33,7 +33,7 @@ class Upload implements Extension {
if(is_null($this->theme)) $this->theme = get_theme_object($this); if(is_null($this->theme)) $this->theme = get_theme_object($this);
$is_full = (disk_free_space(realpath("./images/")) < 100*1024*1024); $is_full = (disk_free_space(realpath("./images/")) < 100*1024*1024);
if($event instanceof InitExtEvent) { if($event instanceof InitExtEvent) {
global $config; global $config;
$config->set_default_int('upload_count', 3); $config->set_default_int('upload_count', 3);
@ -134,11 +134,11 @@ class Upload implements Extension {
private function try_upload($file, $tags, $source) { private function try_upload($file, $tags, $source) {
global $page; global $page;
global $config; global $config;
if(empty($source)) $source = null; if(empty($source)) $source = null;
$ok = true; $ok = true;
// blank file boxes cause empty uploads, no need for error message // blank file boxes cause empty uploads, no need for error message
if(file_exists($file['tmp_name'])) { if(file_exists($file['tmp_name'])) {
global $user; global $user;
@ -207,14 +207,14 @@ class Upload implements Extension {
curl_close($ch); curl_close($ch);
fclose($fp); fclose($fp);
} }
if($config->get_string("transload_engine") == "wget") { if($config->get_string("transload_engine") == "wget") {
$ua = "Shimmie-".VERSION; $ua = "Shimmie-".VERSION;
$s_url = escapeshellarg($url); $s_url = escapeshellarg($url);
$s_tmp = escapeshellarg($tmp_filename); $s_tmp = escapeshellarg($tmp_filename);
system("wget $s_url --output-document=$s_tmp --user-agent=$ua --referer=$s_url"); system("wget $s_url --output-document=$s_tmp --user-agent=$ua --referer=$s_url");
} }
if(filesize($tmp_filename) == 0) { if(filesize($tmp_filename) == 0) {
$this->theme->display_upload_error($page, "Error with ".html_escape($filename), $this->theme->display_upload_error($page, "Error with ".html_escape($filename),
"No data found -- perhaps the site has hotlink protection?"); "No data found -- perhaps the site has hotlink protection?");

View File

@ -12,7 +12,7 @@ class UploadTheme extends Themelet {
public function display_page($page) { public function display_page($page) {
global $config; global $config;
$tl_enabled = ($config->get_string("transload_engine", "none") != "none"); $tl_enabled = ($config->get_string("transload_engine", "none") != "none");
$upload_list = ""; $upload_list = "";
for($i=0; $i<$config->get_int('upload_count'); $i++) { for($i=0; $i<$config->get_int('upload_count'); $i++) {
$n = $i + 1; $n = $i + 1;

View File

@ -44,7 +44,7 @@ class UserPage implements Extension {
// event handling {{{ // event handling {{{
public function receive_event(Event $event) { public function receive_event(Event $event) {
if(is_null($this->theme)) $this->theme = get_theme_object($this); if(is_null($this->theme)) $this->theme = get_theme_object($this);
if($event instanceof InitExtEvent) { if($event instanceof InitExtEvent) {
$event->context->config->set_default_bool("login_signup_enabled", true); $event->context->config->set_default_bool("login_signup_enabled", true);
$event->context->config->set_default_int("login_memory", 365); $event->context->config->set_default_int("login_memory", 365);
@ -58,62 +58,64 @@ class UserPage implements Extension {
if($event->get_arg(0) == "login") { if($event->get_arg(0) == "login") {
if(isset($_POST['user']) && isset($_POST['pass'])) { if(isset($_POST['user']) && isset($_POST['pass'])) {
$this->login($event->page); $this->login($page);
} }
else { else {
$this->theme->display_login_page($event->page); $this->theme->display_login_page($page);
} }
} }
else if($event->get_arg(0) == "logout") { else if($event->get_arg(0) == "logout") {
setcookie("shm_session", "", time()+60*60*24*$config->get_int('login_memory'), "/"); setcookie("shm_session", "", time()+60*60*24*$config->get_int('login_memory'), "/");
$event->page->set_mode("redirect"); $page->set_mode("redirect");
$event->page->set_redirect(make_link()); $page->set_redirect(make_link());
} }
else if($event->get_arg(0) == "change_pass") { else if($event->get_arg(0) == "change_pass") {
$this->change_password_wrapper($event->page); $this->change_password_wrapper($page);
} }
else if($event->get_arg(0) == "create") { else if($event->get_arg(0) == "create") {
if(!$config->get_bool("login_signup_enabled")) { if(!$config->get_bool("login_signup_enabled")) {
$this->theme->display_signups_disabled($page); $this->theme->display_signups_disabled($page);
} }
else if(!isset($_POST['name'])) { else if(!isset($_POST['name'])) {
$this->theme->display_signup_page($event->page); $this->theme->display_signup_page($page);
} }
else if($_POST['pass1'] != $_POST['pass2']) { else if($_POST['pass1'] != $_POST['pass2']) {
$this->theme->display_error($event->page, "Password Mismatch", "Passwords don't match"); $this->theme->display_error($page, "Password Mismatch", "Passwords don't match");
} }
else { else {
try { try {
$uce = new UserCreationEvent($event->context, $_POST['name'], $_POST['pass1'], $_POST['email']); $uce = new UserCreationEvent($event->context, $_POST['name'], $_POST['pass1'], $_POST['email']);
send_event($uce); send_event($uce);
$this->set_login_cookie($uce->username, $uce->password); $this->set_login_cookie($uce->username, $uce->password);
$event->page->set_mode("redirect"); $page->set_mode("redirect");
$event->page->set_redirect(make_link("user")); $page->set_redirect(make_link("user"));
} }
catch(UserCreationException $ex) { catch(UserCreationException $ex) {
$this->theme->display_error($event->page, "User Creation Error", $ex->getMessage()); $this->theme->display_error($page, "User Creation Error", $ex->getMessage());
} }
} }
} }
else if($event->get_arg(0) == "set_more") { else if($event->get_arg(0) == "set_more") {
$this->set_more_wrapper($event->page); $this->set_more_wrapper($page);
} }
} }
if(($event instanceof PageRequestEvent) && $event->page_matches("user")) { if(($event instanceof PageRequestEvent) && $event->page_matches("user")) {
global $user; $user = $event->context->user;
global $config; $config = $event->context->config;
global $database; $database = $event->context->database;
$duser = ($event->count_args() == 0) ? $user : User::by_name($config, $database, $event->get_arg(0)); $page = $event->context->page;
if(!is_null($duser)) {
send_event(new UserPageBuildingEvent($event->context, $duser)); $display_user = ($event->count_args() == 0) ? $user : User::by_name($config, $database, $event->get_arg(0));
if(!is_null($display_user)) {
send_event(new UserPageBuildingEvent($event->context, $display_user));
} }
else { else {
$this->theme->display_error($event->page, "No Such User", $this->theme->display_error($page, "No Such User",
"If you typed the ID by hand, try again; if you came from a link on this ". "If you typed the ID by hand, try again; if you came from a link on this ".
"site, it might be bug report time..."); "site, it might be bug report time...");
} }
} }
if($event instanceof UserPageBuildingEvent) { if($event instanceof UserPageBuildingEvent) {
global $user; global $user;
global $config; global $config;
@ -144,7 +146,7 @@ class UserPage implements Extension {
$this->theme->display_user_block($page, $user, $ubbe->parts); $this->theme->display_user_block($page, $user, $ubbe->parts);
} }
} }
if($event instanceof SetupBuildingEvent) { if($event instanceof SetupBuildingEvent) {
$sb = new SetupBlock("User Options"); $sb = new SetupBlock("User Options");
$sb->add_bool_option("login_signup_enabled", "Allow new signups: "); $sb->add_bool_option("login_signup_enabled", "Allow new signups: ");
@ -234,7 +236,7 @@ class UserPage implements Extension {
"INSERT INTO users (name, pass, joindate, email) VALUES (?, ?, now(), ?)", "INSERT INTO users (name, pass, joindate, email) VALUES (?, ?, now(), ?)",
array($event->username, $hash, $email)); array($event->username, $hash, $email));
} }
private function set_login_cookie($name, $pass) { private function set_login_cookie($name, $pass) {
global $config; global $config;
@ -246,13 +248,13 @@ class UserPage implements Extension {
setcookie("shm_session", md5($hash.$addr), setcookie("shm_session", md5($hash.$addr),
time()+60*60*24*$config->get_int('login_memory'), '/'); time()+60*60*24*$config->get_int('login_memory'), '/');
} }
//}}} //}}}
// Things done *to* the user {{{ // Things done *to* the user {{{
private function change_password_wrapper($page) { private function change_password_wrapper($page) {
global $user; global $user;
global $config; global $config;
global $database; global $database;
$page->set_title("Error"); $page->set_title("Error");
$page->set_heading("Error"); $page->set_heading("Error");
$page->add_block(new NavBlock()); $page->add_block(new NavBlock());
@ -298,7 +300,7 @@ class UserPage implements Extension {
global $user; global $user;
global $config; global $config;
global $database; global $database;
$page->set_title("Error"); $page->set_title("Error");
$page->set_heading("Error"); $page->set_heading("Error");
$page->add_block(new NavBlock()); $page->add_block(new NavBlock());
@ -311,7 +313,7 @@ class UserPage implements Extension {
} }
else { else {
$admin = (isset($_POST['admin']) && ($_POST['admin'] == "on")); $admin = (isset($_POST['admin']) && ($_POST['admin'] == "on"));
$duser = User::by_id($config, $database, $_POST['id']); $duser = User::by_id($config, $database, $_POST['id']);
$duser->set_admin($admin); $duser->set_admin($admin);

View File

@ -1,7 +1,7 @@
<?php <?php
class UserPageTheme extends Themelet { class UserPageTheme extends Themelet {
public function display_login_page($page) { public function display_login_page(Page $page) {
$page->set_title("Login"); $page->set_title("Login");
$page->set_heading("Login"); $page->set_heading("Login");
$page->add_block(new NavBlock()); $page->add_block(new NavBlock());
@ -9,18 +9,18 @@ class UserPageTheme extends Themelet {
"There should be a login box to the left")); "There should be a login box to the left"));
} }
public function display_user_links($page, $user, $parts) { public function display_user_links(Page $page, User $user, $parts) {
# $page->add_block(new Block("User Links", join(", ", $parts), "main", 10)); # $page->add_block(new Block("User Links", join(", ", $parts), "main", 10));
} }
public function display_user_block($page, $user, $parts) { public function display_user_block(Page $page, User $user, $parts) {
$h_name = html_escape($user->name); $h_name = html_escape($user->name);
$html = "Logged in as $h_name<br>"; $html = "Logged in as $h_name<br>";
$html .= join("\n<br/>", $parts); $html .= join("\n<br/>", $parts);
$page->add_block(new Block("User Links", $html, "left", 90)); $page->add_block(new Block("User Links", $html, "left", 90));
} }
public function display_signup_page($page) { public function display_signup_page(Page $page) {
global $config; global $config;
$tac = $config->get_string("login_tac", ""); $tac = $config->get_string("login_tac", "");
@ -49,7 +49,7 @@ class UserPageTheme extends Themelet {
$page->add_block(new Block("Signup", $html)); $page->add_block(new Block("Signup", $html));
} }
public function display_signups_disabled($page) { public function display_signups_disabled(Page $page) {
$page->set_title("Signups Disabled"); $page->set_title("Signups Disabled");
$page->set_heading("Signups Disabled"); $page->set_heading("Signups Disabled");
$page->add_block(new NavBlock()); $page->add_block(new NavBlock());
@ -57,7 +57,7 @@ class UserPageTheme extends Themelet {
"The board admin has disabled the ability to create new accounts~")); "The board admin has disabled the ability to create new accounts~"));
} }
public function display_login_block($page) { public function display_login_block(Page $page) {
global $config; global $config;
$html = " $html = "
<form action='".make_link("user_admin/login")."' method='POST'> <form action='".make_link("user_admin/login")."' method='POST'>
@ -73,8 +73,8 @@ class UserPageTheme extends Themelet {
} }
$page->add_block(new Block("Login", $html, "left", 90)); $page->add_block(new Block("Login", $html, "left", 90));
} }
public function display_ip_list($page, $uploads, $comments) { public function display_ip_list(Page $page, $uploads, $comments) {
$html = "<table id='ip-history'>"; $html = "<table id='ip-history'>";
$html .= "<tr><td>Uploaded from: "; $html .= "<tr><td>Uploaded from: ";
$n = 0; $n = 0;
@ -102,7 +102,7 @@ class UserPageTheme extends Themelet {
$page->add_block(new Block("IPs", $html)); $page->add_block(new Block("IPs", $html));
} }
public function display_user_page($page, $duser, $user) { public function display_user_page(Page $page, User $duser, User $user) {
$page->set_title("{$duser->name}'s Page"); $page->set_title("{$duser->name}'s Page");
$page->set_heading("{$duser->name}'s Page"); $page->set_heading("{$duser->name}'s Page");
$page->add_block(new NavBlock()); $page->add_block(new NavBlock());

View File

@ -68,7 +68,7 @@ class ViewImage implements Extension {
if(($event instanceof PageRequestEvent) && $event->page_matches("post/view")) { if(($event instanceof PageRequestEvent) && $event->page_matches("post/view")) {
$image_id = int_escape($event->get_arg(0)); $image_id = int_escape($event->get_arg(0));
global $database; global $database;
global $config; global $config;
$image = Image::by_id($config, $database, $image_id); $image = Image::by_id($config, $database, $image_id);
@ -89,7 +89,7 @@ class ViewImage implements Extension {
$image_id = int_escape($_POST['image_id']); $image_id = int_escape($_POST['image_id']);
send_event(new ImageInfoSetEvent($image_id)); send_event(new ImageInfoSetEvent($image_id));
$query = $_POST['query']; $query = $_POST['query'];
$event->page->set_mode("redirect"); $event->page->set_mode("redirect");
$event->page->set_redirect(make_link("post/view/$image_id", $query)); $event->page->set_redirect(make_link("post/view/$image_id", $query));

View File

@ -36,7 +36,7 @@ class ViewImageTheme extends Themelet {
$search_terms = array(); $search_terms = array();
$query = null; $query = null;
} }
$next = $image->get_next($search_terms); $next = $image->get_next($search_terms);
$prev = $image->get_prev($search_terms); $prev = $image->get_prev($search_terms);