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;
$banned = $config->get_string("banned_words");
$comment = strtolower($event->comment);
foreach(explode("\n", $banned) as $word) {
$word = trim(strtolower($word));
if(strlen($word) == 0) {

View file

@ -10,16 +10,16 @@
* October 26, 2007
*
*/
class BrowserSearch implements Extension {
public function receive_event(Event $event) {
global $page;
global $config;
if($event instanceof InitExtEvent) {
$config->set_default_string("search_suggestions_results_order", 'a');
}
// Add in header code to let the browser know that the search plugin exists
if($event instanceof PageRequestEvent) {
// We need to build the data for the header
@ -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');
$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
if(($event instanceof PageRequestEvent) && $event->page_matches("browser_search/please_dont_use_this_tag_as_it_would_break_stuff__search.xml")) {
// First, we need to build all the variables we'll need
$search_title = $config->get_string('title');
//$search_form_url = $config->get_string('base_href'); //make_link('post/list');
$search_form_url = make_link('post/list/{searchTerms}');
$suggenton_url = make_link('browser_search/')."{searchTerms}";
// Now for the XML
$xml = "
<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: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>
<SearchForm>$search_form_url</SearchForm>
<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'/>
</SearchPlugin>
";
// And now to send it to the browser
$page->set_mode("data");
$page->set_type("text/xml");
$page->set_data($xml);
}
else if(($event instanceof PageRequestEvent) && (
$event->page_matches("browser_search") &&
!$config->get_bool("disable_search_suggestions")
)) {
global $database;
// We have to build some json stuff
$tag_search = $event->get_arg(0);
// Now to get DB results
if($config->get_string("search_suggestions_results_order") == "a") {
if($config->get_string("search_suggestions_results_order") == "a") {
$tags = $database->execute("SELECT tag FROM tags WHERE tag LIKE ? AND count > 0 ORDER BY tag ASC LIMIT 30",array($tag_search."%"));
} else {
$tags = $database->execute("SELECT tag FROM tags WHERE tag LIKE ? AND count > 0 ORDER BY count DESC LIMIT 30",array($tag_search."%"));
}
// And to do stuff with it. We want our output to look like:
// ["shimmie",["shimmies","shimmy","shimmie","21 shimmies","hip shimmies","skea shimmies"],[],[]]
$json_tag_list = "";
$tags_array = array();
foreach($tags as $tag) {
array_push($tags_array,$tag['tag']);
}
$json_tag_list .= implode("\",\"", $tags_array);
// $json_tag_list = implode($tags_array,", ");
// $json_tag_list = "\"".implode($tags_array,"\", \"")."\"";
// And now for the final output
$json_string = "[\"$tag_search\",[\"$json_tag_list\"],[],[]]";
$page->set_mode("data");
$page->set_data($json_string);
}
if($event instanceof SetupBuildingEvent) {
$sort_by = array();
$sort_by['Alphabetical'] = 'a';
$sort_by['Tag Count'] = 't';
$sb = new SetupBlock("Browser Search");
$sb->add_bool_option("disable_search_suggestions", "Disable search suggestions when using browser-based search: ");
$sb->add_label("<br>");

View file

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

View file

@ -26,7 +26,7 @@ class BulkAddTheme extends Themelet {
used as tags for the images within.
<br>Note: this is the folder as seen by the server -- you need to
upload via FTP or something first.
<p><form action='".make_link("bulk_add")."' method='POST'>
Directory to add: <input type='text' name='dir' size='40'>
<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.
19-OCT-07 4:46PM CST - JJS
Add compatibility with danbooru api v1.8.1 style urls
for find_posts and add_post. NOTE: This does not implement
the changes to the parameter names, it is simply a
workaround for the latest danbooruup firefox extension.
Add compatibility with danbooru api v1.8.1 style urls
for find_posts and add_post. NOTE: This does not implement
the changes to the parameter names, it is simply a
workaround for the latest danbooruup firefox extension.
Completely compatibility will probably involve a rewrite with a different URL
*/
class DanbooruApi implements Extension
class DanbooruApi implements Extension
{
// Receive the event
public function receive_event(Event $event)
public function receive_event(Event $event)
{
// 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
$this->api_danbooru($event);
@ -65,7 +65,7 @@ class DanbooruApi implements Extension
}
}
}
// Danbooru API
private function api_danbooru($event)
{
@ -77,31 +77,31 @@ class DanbooruApi implements Extension
$page->set_type("application/xml");
//debug
//$page->set_type("text/plain");
$results = array();
/*
add_post()
Adds a post to the database.
Parameters
Adds a post to the database.
Parameters
* login: login
* password: password
* file: file as a multipart form
* source: source url
* password: password
* file: file as a multipart form
* source: source url
* title: title **IGNORED**
* tags: list of tags as a string, delimited by whitespace
* md5: MD5 hash of upload in hexadecimal format
* tags: list of tags as a string, delimited by whitespace
* md5: MD5 hash of upload in hexadecimal format
* rating: rating of the post. can be explicit, questionable, or safe. **IGNORED**
Notes
* 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 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.
Response
The response depends on the method used:
Post
* X-Danbooru-Location set to the URL for newly uploaded post.
Get
Notes
* 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 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.
Response
The response depends on the method used:
Post
* X-Danbooru-Location set to the URL for newly uploaded post.
Get
* Redirected to the newly uploaded post.
*/
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']))
{
$source = $_REQUEST['post']['source'];
} else
} else
{
$source = null;
}
@ -146,19 +146,19 @@ class DanbooruApi implements Extension
$url = isset($_REQUEST['source']) ? $_REQUEST['source'] : $_REQUEST['post']['source'];
$source = $url;
$tmp_filename = tempnam("/tmp", "shimmie_transload");
// 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");
if(!$fp) {
header("HTTP/1.0 409 Conflict");
header("X-Danbooru-Errors: fopen read error");
}
$data = "";
$length = 0;
while(!feof($fp) && $length <= $config->get_int('upload_size'))
while(!feof($fp) && $length <= $config->get_int('upload_size'))
{
$data .= fread($fp, 8192);
$length = strlen($data);
@ -170,7 +170,7 @@ class DanbooruApi implements Extension
fclose($fp);
}
if($config->get_string("transload_engine") == "curl")
if($config->get_string("transload_engine") == "curl")
{
$ch = curl_init($url);
$fp = fopen($tmp_filename, "w");
@ -184,13 +184,13 @@ class DanbooruApi implements Extension
}
$file = $tmp_filename;
$filename = basename($url);
} else
} else
{ // Nothing was specified at all
header("HTTP/1.0 409 Conflict");
header("X-Danbooru-Errors: no input files");
return;
}
// Get tags out of url
$posttags = tag_explode(isset($_REQUEST['tags']) ? $_REQUEST['tags'] : $_REQUEST['post']['tags']);
$hash = md5_file($file);
@ -206,7 +206,7 @@ class DanbooruApi implements 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?)
// Does it exist already?
$existing = Image::by_hash($config, $database, $hash);
if(!is_null($existing)) {
@ -222,7 +222,7 @@ class DanbooruApi implements Extension
$metadata['extension'] = $fileinfo['extension'];
$metadata['tags'] = $posttags;
$metadata['source'] = $source;
try {
$nevent = new DataUploadEvent($user, $file, $metadata);
send_event($nevent);
@ -243,23 +243,23 @@ class DanbooruApi implements Extension
header("X-Danbooru-Errors: ". $ex->getMessage());
return;
}
} else
} else
{
header("HTTP/1.0 409 Conflict");
header("X-Danbooru-Errors: authentication error");
return;
}
}
/*
find_posts()
Find all posts that match the search criteria. Posts will be ordered by id descending.
Parameters
* md5: md5 hash to search for (comma delimited)
* id: id to search for (comma delimited)
* tags: what tags to search for
* limit: limit
* offset: offset
find_posts()
Find all posts that match the search criteria. Posts will be ordered by id descending.
Parameters
* md5: md5 hash to search for (comma delimited)
* id: id to search for (comma delimited)
* tags: what tags to search for
* limit: limit
* offset: offset
* 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')))
@ -285,7 +285,7 @@ class DanbooruApi implements Extension
$tags = isset($_GET['tags']) ? tag_explode($_GET['tags']) : array();
$results = Image::find_images($config,$database,$start,$limit,$tags);
}
// Now we have the array $results filled with Image objects
// Let's display them
$xml = "<posts>\n";
@ -302,13 +302,13 @@ class DanbooruApi implements Extension
$xml .= "</posts>";
$page->set_data($xml);
}
/*
find_tags() Find all tags that match the search criteria.
Parameters
* id: A comma delimited list of tag id numbers.
* name: A comma delimited list of tag names.
* tags: any typical tag query. See Tag#parse_query for details.
find_tags() Find all tags that match the search criteria.
Parameters
* id: A comma delimited list of tag id numbers.
* name: A comma delimited list of tag names.
* 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
*/
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']);
}
}
}
}
/* Currently disabled to maintain identical functionality to danbooru 1.0's own "broken" find_tags
elseif(isset($_GET['tags']))
{
$start = isset($_GET['after_id']) ? int_escape($_GET['offset']) : 0;
$tags = tag_explode($_GET['tags']);
}
*/
else
else
{
$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));
@ -354,7 +354,7 @@ class DanbooruApi implements Extension
$sqlresult->MoveNext();
}
}
// Tag results collected, build XML output
$xml = "<tags>\n";
foreach($results as $tag)
@ -364,7 +364,7 @@ class DanbooruApi implements Extension
$xml .= "</tags>";
$page->set_data($xml);
}
// Hackery for danbooruup 0.3.2 providing the wrong view url. This simply redirects to the proper
// Shimmie view page
// Example: danbooruup says the url is http://shimmie/api/danbooru/post/show/123
@ -375,7 +375,7 @@ class DanbooruApi implements Extension
header("Location: $fixedlocation");
}
}
// 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
// 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
// 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));
}

View file

@ -31,7 +31,7 @@ class Downtime implements Extension {
$user = $event->context->user;
$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)) {
$msg = $config->get_string("downtime_message");
$this->theme->display_message($msg);

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -5,7 +5,7 @@ class FlashFileHandlerTheme extends Themelet {
$ilink = $image->get_image_link();
// FIXME: object and embed have "height" and "width"
$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'
height='{$image->height}'
width='{$image->width}'

View file

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

View file

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

View file

@ -5,7 +5,7 @@ class MP3FileHandlerTheme extends Themelet {
$data_href = get_base_href();
$ilink = $image->get_image_link();
$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'
width='400' height='170'>
<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)) {
$this->theme->display_image($event->page, $event->image);
}
if(($event instanceof PageRequestEvent) && $event->page_matches("get_svg")) {
global $config;
global $database;
@ -54,7 +54,7 @@ class SVGFileHandler implements Extension {
$image = Image::by_id($config, $database, $id);
$hash = $image->hash;
$ha = substr($hash, 0, 2);
$event->page->set_type("image/svg+xml");
$event->page->set_mode("data");
$event->page->set_data(file_get_contents("images/$ha/$hash"));
@ -74,7 +74,7 @@ class SVGFileHandler implements Extension {
$msp = new MiniSVGParser($filename);
$image->width = $msp->width;
$image->height = $msp->height;
$image->filesize = $metadata['size'];
$image->hash = $metadata['hash'];
$image->filename = $metadata['filename'];
@ -87,7 +87,7 @@ class SVGFileHandler implements Extension {
private function check_contents($file) {
if(!file_exists($file)) return false;
$msp = new MiniSVGParser($file);
return $msp->valid;
}

View file

@ -26,7 +26,7 @@ class Home implements Extension {
$name = str_replace("ext/home/counters/", "", $counter_dirname);
$counters[ucfirst($name)] = $name;
}
$sb = new SetupBlock("Home Page");
$sb->add_label("Page Links - Example: [$"."base/index|Posts]");
$sb->add_longtext_option("home_links", "<br>");
@ -46,19 +46,19 @@ class Home implements Extension {
$sitename = $config->get_string('title');
$contact_link = $config->get_string('contact_link');
$counter_dir = $config->get_string('home_counter', 'default');
$total = ceil($database->db->GetOne("SELECT COUNT(*) FROM images"));
$strtotal = "$total";
$num_comma = number_format($total);
$counter_text = "";
for($n=0; $n<strlen($strtotal); $n++)
{
$cur = $strtotal[$n];
$counter_text .= " <img alt='$cur' src='$data_href/ext/home/counters/$counter_dir/$cur.gif' /> ";
}
// get the homelinks and process them
$main_links = $config->get_string('home_links');
$main_links = str_replace('$base', $base_href, $main_links);
@ -77,7 +77,7 @@ class Home implements Extension {
$data_href = get_base_href();
$sitename = $config->get_string('title');
$theme_name = $config->get_string('theme');
$body = $this->get_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;'>
<a href='$contact_link'>contact</a> &ndash; Serving $num_comma posts
</div>
<div class='space'>
Powered by <a href='http://trac.shishnet.org/shimmie2/'>Shimmie</a>
</div>

View file

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

View file

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

View file

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

View file

@ -6,14 +6,14 @@
*/
class LinkImage implements Extension {
var $theme;
public function receive_event(Event $event) {
if(is_null($this->theme)) $this->theme = get_theme_object($this);
if(($event instanceof DisplayingImageEvent)) {
global $config;
$data_href = get_base_href();
$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));
}
if($event instanceof SetupBuildingEvent) {
@ -30,10 +30,10 @@ class LinkImage implements Extension {
}
private function data($image) {
global $config;
$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.
return array(
'thumb_src' => $image->get_thumb_link(),
'image_src' => $image->get_image_link(),

View file

@ -1,12 +1,12 @@
<?php
class LinkImageTheme extends Themelet {
public function links_block($page,$data) {
$thumb_src = $data['thumb_src'];
$image_src = $data['image_src'];
$post_link = $data['post_link'];
$text_link = $data['text_link'];
$page->add_block( new Block(
"Link to Image",
"<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("Inline Image", $this->img($image_src,"ubb"), "ubb_full-img").
"</fieldset>".
"<fieldset>".
"<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("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").
"</fieldset>".
"<fieldset>".
"<legend>Plain Text</legend>".
$this->link_code("Post URL",$post_link,"text_post-link").
@ -32,10 +32,10 @@ class LinkImageTheme extends Themelet {
"main",
50));
}
protected function url ($url,$content,$type) {
if ($content == NULL) {$content=$url;}
switch ($type) {
case "html":
$text = "<a href=\"".$url."\">".$content."</a>";
@ -48,7 +48,7 @@ class LinkImageTheme extends Themelet {
}
return $text;
}
protected function img ($src,$type) {
switch ($type) {
case "html":
@ -62,7 +62,7 @@ class LinkImageTheme extends Themelet {
}
return $text;
}
protected function link_code($label,$content,$id=NULL) {
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";

View file

@ -11,7 +11,7 @@ class News implements Extension {
public function receive_event(Event $event) {
if(is_null($this->theme)) $this->theme = get_theme_object($this);
if($event instanceof PostListBuildingEvent) {
if(strlen($event->context->config->get_string("news_text")) > 0) {
$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();
}
}
if($event instanceof DisplayingImageEvent) {
global $user;
if(!$user->is_anonymous()) {
@ -36,7 +36,7 @@ class NumericScore implements Extension {
$event->page->add_block(new Block("Image Score", $html, "left", 20));
}
}
if(($event instanceof PageRequestEvent) && $event->page_matches("numeric_score_vote")) {
if(!$event->user->is_anonymous()) {
$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"));
}
}
if($event instanceof ImageInfoSetEvent) {
global $user;
$char = $_POST['numeric_score'];
@ -58,7 +58,7 @@ class NumericScore implements Extension {
else if($char == "d") $score = -1;
if($score != 0) send_event(new NumericScoreSetEvent($event->image_id, $user, $score));
}
if($event instanceof NumericScoreSetEvent) {
$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) {
$i_image_id = int_escape($image->id);
$i_score = int_escape($image->numeric_score);
$html = "
Current Score: $i_score

View file

@ -12,9 +12,9 @@ class PicLens implements Extension {
}
if($event instanceof PostListBuildingEvent) {
$foo='
<a href="javascript:PicLensLite.start();">Start Slideshow
<img src="http://lite.piclens.com/images/PicLensButton.png"
alt="PicLens" width="16" height="12" border="0"
<a href="javascript:PicLensLite.start();">Start Slideshow
<img src="http://lite.piclens.com/images/PicLensButton.png"
alt="PicLens" width="16" height="12" border="0"
align="absmiddle"></a>';
$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) {
$database = $context->database;
$config = $context->config;
// shortcut to latest
if($config->get_int("pm_version") < 1) {
$database->execute("

View file

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

View file

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

View file

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

View file

@ -9,7 +9,7 @@
* Version 0.3a - See changelog in main.php
* November 06, 2007
*/
class ReportImageTheme extends Themelet {
public function display_reported_images($page, $reports) {
global $config;
@ -28,13 +28,13 @@ class ReportImageTheme extends Themelet {
$reporter_name = html_escape($report['reporter_name']);
$userlink = "<a href='".make_link("user/$reporter_name")."'>$reporter_name</a>";
global $user;
$iabbe = new ImageAdminBlockBuildingEvent($image, $user);
send_event($iabbe);
ksort($iabbe->parts);
$actions = join("<br>", $iabbe->parts);
$h_reportedimages .= "
<tr>
<td>{$image_link}</td>
@ -50,7 +50,7 @@ class ReportImageTheme extends Themelet {
</tr>
";
}
$thumb_width = $config->get_int("thumb_width");
$html = "
<style>
@ -63,17 +63,17 @@ class ReportImageTheme extends Themelet {
$h_reportedimages
</table>
";
$page->set_title("Reported Images");
$page->set_heading("Reported Images");
$page->add_block(new NavBlock());
$page->add_block(new Block("Reported Images", $html));
}
public function display_image_banner($page, $image) {
global $config;
$i_image = int_escape($image);
$html = "
<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);
$ratios = explode(" ", $config->get_string("upload_ratios", ""));
$ratios = array_filter($ratios, "strlen");
$image = $event->image;
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_int_option("upload_max_height");
$sb->add_label(" px");
$sb->add_label("<br>(-1 for no limit)");
$sb->add_label("<br>Ratios ");
$sb->add_text_option("upload_ratios");
$sb->add_label("<br>(eg. '4:3 16:9', blank for no limit)");
$event->panel->add_block($sb);
}
}

View file

@ -53,7 +53,7 @@ class RSS_Comments implements Extension {
$posted = strftime("%a, %d %b %Y %T %Z", $comment['posted_timestamp']);
$comment = html_escape($comment['comment']);
$content = html_escape("$owner: $comment");
$data .= "
<item>
<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>Uploaded by " . $owner->name . "</p>"
);
$data .= "
<item>
<title>{$image->id} - $tags</title>

View file

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

View file

@ -11,7 +11,7 @@ class SVNUpdate implements Extension {
public function receive_event(Event $event) {
if(is_null($this->theme)) $this->theme = get_theme_object($this);
if(($event instanceof PageRequestEvent) && $event->page_matches("update")) {
if($event->user->is_admin()) {
if($event->get_arg(0) == "view_changes") {
@ -50,7 +50,7 @@ class SVNUpdate implements Extension {
// FIXME: MySQL specific
if(preg_match("#^mysql://([^:]+):([^@]+)@([^/]+)/([^\?]+)#", $database_dsn, $matches)) {
$date = date("Ymd");
return
return
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";
}

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";
}
$end_string = "
</ul>
<input type='submit' value='Revert'>

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -16,7 +16,7 @@ class Zoom implements Extension {
global $config;
$this->theme->display_zoomer($event->page, $event->image, $config->get_bool("image_zoom", false));
}
if($event instanceof SetupBuildingEvent) {
$sb = new SetupBlock("Image Zoom");
$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) {
$page->add_block(new Block(null, $this->make_zoomer($image->width, $zoom_by_default)));
}
protected function make_zoomer($image_width, $zoom_by_default) {
global $config;
$default = $zoom_by_default ? "scale(img);" : "";

View file

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

View file

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

View file

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

View file

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

View file

@ -93,7 +93,7 @@ class User {
global $database;
return $database->db->GetOne("SELECT COUNT(*) AS count FROM images WHERE owner_id=?", array($this->id));
}
public function get_comment_count() {
global $database;
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;
}
function array_add($array, $element) {
$array[] = $element;
$array = array_unique($array);
return $array;
}
function array_add($array, $element) {
$array[] = $element;
$array = array_unique($array);
return $array;
}
function array_contains($array, $target) {
foreach($array as $element) {
@ -306,7 +306,7 @@ function full_copy($source, $target) {
continue;
}
$Entry = $source . '/' . $entry;
$Entry = $source . '/' . $entry;
if(is_dir($Entry)) {
full_copy($Entry, $target . '/' . $entry);
continue;
@ -395,7 +395,7 @@ function _get_query_parts() {
else {
$path = "";
}
while(strlen($path) > 0 && $path[0] == '/') {
$path = substr($path, 1);
}
@ -413,7 +413,7 @@ function _get_page_request($context) {
if(count($args) == 0 || strlen($args[0]) == 0) {
$args = split('/', $context->config->get_string('front_page'));
}
return new PageRequestEvent($context, $args);
}

View file

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

View file

@ -47,7 +47,7 @@ class AliasEditor implements Extension {
}
else if($event->get_arg(0) == "list") {
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"),
$event->user->is_admin());
}
@ -88,7 +88,7 @@ class AliasEditor implements Extension {
$database->Execute("INSERT INTO aliases(oldtag, newtag) VALUES(?, ?)", $pair);
}
}
if($event instanceof UserBlockBuildingEvent) {
if($event->user->is_admin()) {
$event->add_link("Alias Editor", make_link("alias/list"));

View file

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

View file

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

View file

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

View file

@ -18,7 +18,7 @@ class CommentListTheme extends Themelet {
"<a href='".make_link("comment/list/$next")."'>Next</a>";
$nav = "$h_prev | $h_index | $h_next";
$page->set_title("Comments");
$page->set_heading("Comments");
$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>";
$stripped_nonl = str_replace("\n", "\\n", $tfe->stripped);
$stripped_nonl = str_replace("\r", "\\r", $stripped_nonl);
$h_dellink = $user->is_admin() ?
$h_dellink = $user->is_admin() ?
"<br>($h_poster_ip, <a ".
"onclick=\"return confirm('Delete comment by $h_name:\\n$stripped_nonl');\" ".
"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) {
if(is_null($this->theme)) $this->theme = get_theme_object($this);
if(($event instanceof PageRequestEvent) && $event->page_matches("ext_manager")) {
if($event->user->is_admin()) {
if($event->get_arg(0) == "set") {

View file

@ -18,7 +18,7 @@ class ExtManagerTheme extends Themelet {
$html .= "
<tr>
" . (
empty($h_link) ?
empty($h_link) ?
"<td>$h_name</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");
return array_contains($exts, strtolower($ext));
}
private function create_image_from_data($filename, $metadata) {
global $config;
@ -49,7 +49,7 @@ class PixelFileHandler implements Extension {
$image->width = $info[0];
$image->height = $info[1];
$image->filesize = $metadata['size'];
$image->hash = $metadata['hash'];
$image->filename = $metadata['filename'];
@ -74,9 +74,9 @@ class PixelFileHandler implements Extension {
$inname = "images/$ha/$hash";
$outname = "thumbs/$ha/$hash";
global $config;
$ok = false;
switch($config->get_string("thumb_engine")) {
default:
case 'gd':
@ -131,7 +131,7 @@ class PixelFileHandler implements Extension {
$memory_use = (filesize($tmpname)*2) + ($width*$height*4) + (4*1024*1024);
$memory_limit = get_memory_limit();
if($memory_use > $memory_limit) {
$w = $config->get_int('thumb_width');
$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_quality', 75);
$config->set_default_int('thumb_mem_limit', parse_shorthand_int('8MB'));
$config->set_default_string('image_ilink', '');
$config->set_default_string('image_tlink', '');
$config->set_default_string('image_tip', '$tags // $size // $filesize');
@ -95,7 +95,7 @@ class ImageIO implements Extension {
$matches = array();
if(!is_null($num) && preg_match("/(\d+)/", $num, $matches)) {
$num = $matches[1];
if($event->page_matches("image")) {
$this->send_file($num, "image");
}
@ -113,7 +113,7 @@ class ImageIO implements Extension {
if($event instanceof ImageDeletionEvent) {
$event->image->delete();
}
if($event instanceof SetupBuildingEvent) {
$sb = new SetupBlock("Image Options");
$sb->position = 30;
@ -215,7 +215,7 @@ class ImageIO implements Extension {
$page->set_type($image->get_mime_type());
$file = $image->get_image_filename();
}
$page->set_data(file_get_contents($file));
if(isset($_SERVER["HTTP_IF_MODIFIED_SINCE"])) {

View file

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

View file

@ -53,7 +53,7 @@ class IndexTheme extends Themelet {
$u_tags = url_escape(implode(" ", $search_terms));
$query = empty($u_tags) ? "" : "/$u_tags";
$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_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) {
global $config;
$current = $config->get_string($name);
if(!is_null($label)) {
$this->body .= "<label for='$name'>$label</label>";
}
@ -165,7 +165,7 @@ class Setup implements Extension {
global $config;
send_event(new ConfigSaveEvent($config));
$config->save();
global $page;
$page->set_mode("redirect");
$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");
}
}
if($event instanceof TagSetEvent) {
$event->image->set_tags($event->tags);
}

View file

@ -2,11 +2,11 @@
class TagList implements Extension {
var $theme = null;
// event handling {{{
public function receive_event(Event $event) {
if($this->theme == null) $this->theme = get_theme_object($this);
if($event instanceof InitExtEvent) {
global $config;
$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_popularity = "<a href='".make_link("tags/popularity")."'>Popularity</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() {
@ -209,7 +209,7 @@ class TagList implements Extension {
global $config;
$query = "
SELECT COUNT(it3.image_id) as count, t3.tag AS tag
SELECT COUNT(it3.image_id) as count, t3.tag AS tag
FROM
image_tags AS it1,
image_tags AS it2,
@ -280,7 +280,7 @@ class TagList implements Extension {
$wild_tags = tag_explode($search);
// $search_tags = array();
$tag_id_array = array();
$tags_ok = true;
foreach($wild_tags as $tag) {
@ -303,12 +303,12 @@ class TagList implements Extension {
image_tags AS it2,
tags AS t1,
tags AS t2
WHERE
WHERE
t1.id IN($tag_id_list)
AND it1.image_id=it2.image_id
AND it1.tag_id = t1.id
AND it2.tag_id = t2.id
GROUP BY t2.tag
GROUP BY t2.tag
ORDER BY count
DESC LIMIT ?
";

View file

@ -3,7 +3,7 @@
class TagListTheme extends Themelet {
var $heading = "";
var $list = "";
public function set_heading($text) {
$this->heading = $text;
}
@ -27,7 +27,7 @@ class TagListTheme extends Themelet {
/*
* $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(
* 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 .= "<p><a class='more' href='".make_link("tags")."'>Full List</a>\n";
$page->add_block(new Block("Popular Tags", $html, "left", 60));
}
/*
* $tag_infos = array(
* array('tag' => $tag),
* array('tag' => $tag),
* ...
* )
* $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 .= $this->ars($tag, $search);
}
$page->add_block(new Block("Refine Search", $html, "left", 60));
}
protected function ars($tag, $tags) {
// FIXME: a better fix would be to make sure the inputs are correct
$tag = strtolower($tag);

View file

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

View file

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

View file

@ -44,7 +44,7 @@ class UserPage implements Extension {
// event handling {{{
public function receive_event(Event $event) {
if(is_null($this->theme)) $this->theme = get_theme_object($this);
if($event instanceof InitExtEvent) {
$event->context->config->set_default_bool("login_signup_enabled", true);
$event->context->config->set_default_int("login_memory", 365);
@ -58,62 +58,64 @@ class UserPage implements Extension {
if($event->get_arg(0) == "login") {
if(isset($_POST['user']) && isset($_POST['pass'])) {
$this->login($event->page);
$this->login($page);
}
else {
$this->theme->display_login_page($event->page);
$this->theme->display_login_page($page);
}
}
else if($event->get_arg(0) == "logout") {
setcookie("shm_session", "", time()+60*60*24*$config->get_int('login_memory'), "/");
$event->page->set_mode("redirect");
$event->page->set_redirect(make_link());
$page->set_mode("redirect");
$page->set_redirect(make_link());
}
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") {
if(!$config->get_bool("login_signup_enabled")) {
$this->theme->display_signups_disabled($page);
}
else if(!isset($_POST['name'])) {
$this->theme->display_signup_page($event->page);
$this->theme->display_signup_page($page);
}
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 {
try {
$uce = new UserCreationEvent($event->context, $_POST['name'], $_POST['pass1'], $_POST['email']);
send_event($uce);
$this->set_login_cookie($uce->username, $uce->password);
$event->page->set_mode("redirect");
$event->page->set_redirect(make_link("user"));
$page->set_mode("redirect");
$page->set_redirect(make_link("user"));
}
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") {
$this->set_more_wrapper($event->page);
$this->set_more_wrapper($page);
}
}
if(($event instanceof PageRequestEvent) && $event->page_matches("user")) {
global $user;
global $config;
global $database;
$duser = ($event->count_args() == 0) ? $user : User::by_name($config, $database, $event->get_arg(0));
if(!is_null($duser)) {
send_event(new UserPageBuildingEvent($event->context, $duser));
$user = $event->context->user;
$config = $event->context->config;
$database = $event->context->database;
$page = $event->context->page;
$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 {
$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 ".
"site, it might be bug report time...");
}
}
if($event instanceof UserPageBuildingEvent) {
global $user;
global $config;
@ -144,7 +146,7 @@ class UserPage implements Extension {
$this->theme->display_user_block($page, $user, $ubbe->parts);
}
}
if($event instanceof SetupBuildingEvent) {
$sb = new SetupBlock("User Options");
$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(), ?)",
array($event->username, $hash, $email));
}
private function set_login_cookie($name, $pass) {
global $config;
@ -246,13 +248,13 @@ class UserPage implements Extension {
setcookie("shm_session", md5($hash.$addr),
time()+60*60*24*$config->get_int('login_memory'), '/');
}
//}}}
//}}}
// Things done *to* the user {{{
private function change_password_wrapper($page) {
global $user;
global $config;
global $database;
$page->set_title("Error");
$page->set_heading("Error");
$page->add_block(new NavBlock());
@ -298,7 +300,7 @@ class UserPage implements Extension {
global $user;
global $config;
global $database;
$page->set_title("Error");
$page->set_heading("Error");
$page->add_block(new NavBlock());
@ -311,7 +313,7 @@ class UserPage implements Extension {
}
else {
$admin = (isset($_POST['admin']) && ($_POST['admin'] == "on"));
$duser = User::by_id($config, $database, $_POST['id']);
$duser->set_admin($admin);

View file

@ -1,7 +1,7 @@
<?php
class UserPageTheme extends Themelet {
public function display_login_page($page) {
public function display_login_page(Page $page) {
$page->set_title("Login");
$page->set_heading("Login");
$page->add_block(new NavBlock());
@ -9,18 +9,18 @@ class UserPageTheme extends Themelet {
"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));
}
public function display_user_block($page, $user, $parts) {
public function display_user_block(Page $page, User $user, $parts) {
$h_name = html_escape($user->name);
$html = "Logged in as $h_name<br>";
$html .= join("\n<br/>", $parts);
$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;
$tac = $config->get_string("login_tac", "");
@ -49,7 +49,7 @@ class UserPageTheme extends Themelet {
$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_heading("Signups Disabled");
$page->add_block(new NavBlock());
@ -57,7 +57,7 @@ class UserPageTheme extends Themelet {
"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;
$html = "
<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));
}
public function display_ip_list($page, $uploads, $comments) {
public function display_ip_list(Page $page, $uploads, $comments) {
$html = "<table id='ip-history'>";
$html .= "<tr><td>Uploaded from: ";
$n = 0;
@ -102,7 +102,7 @@ class UserPageTheme extends Themelet {
$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_heading("{$duser->name}'s Page");
$page->add_block(new NavBlock());

View file

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

View file

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