diff --git a/.gitignore b/.gitignore index 081e8f06..8fd2cf81 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,88 @@ data images thumbs !lib/images + + +# Created by http://www.gitignore.io + +### Windows ### +# Windows image file caches +Thumbs.db +ehthumbs.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msm +*.msp + + +### OSX ### +.DS_Store +.AppleDouble +.LSOverride + +# Icon must ends with two \r. +Icon + + +# Thumbnails +._* + +# Files that might appear on external disk +.Spotlight-V100 +.Trashes + + +### Linux ### +*~ + +# KDE directory preferences +.directory + + +### vim ### +[._]*.s[a-w][a-z] +[._]s[a-w][a-z] *.un~ +Session.vim +.netrwhist +*~ + + +### PhpStorm ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm + +## Directory-based project format +.idea/ +# if you remove the above rule, at least ignore user-specific stuff: +# .idea/workspace.xml +# .idea/tasks.xml +# and these sensitive or high-churn files: +# .idea/dataSources.ids +# .idea/dataSources.xml +# .idea/sqlDataSources.xml +# .idea/dynamic.xml + +## File-based project format +*.ipr +*.iws +*.iml + +## Additional for IntelliJ +out/ + +# generated by mpeltonen/sbt-idea plugin +.idea_modules/ + +# generated by JIRA plugin +atlassian-ide-plugin.xml + +# generated by Crashlytics plugin (for Android Studio and Intellij) +com_crashlytics_export_strings.xml diff --git a/.scrutinizer.yml b/.scrutinizer.yml new file mode 100644 index 00000000..f1eef101 --- /dev/null +++ b/.scrutinizer.yml @@ -0,0 +1,6 @@ +imports: + - javascript + - php + +filter: + excluded_paths: [lib/*,ext/chatbox/js/jquery.js] diff --git a/core/basethemelet.class.php b/core/basethemelet.class.php index 06fadc20..94cfc159 100644 --- a/core/basethemelet.class.php +++ b/core/basethemelet.class.php @@ -39,19 +39,19 @@ class BaseThemelet { */ public function build_thumb_html(Image $image) { global $config; + $i_id = (int) $image->id; $h_view_link = make_link('post/view/'.$i_id); $h_thumb_link = $image->get_thumb_link(); $h_tip = html_escape($image->get_tooltip()); $h_tags = strtolower($image->get_tag_list()); - $ext = strtolower($image->ext); - - // If the file doesn't support thumbnail generation, show it at max size. - if($ext === 'swf' || $ext === 'svg' || $ext === 'mp4' || $ext === 'ogv' || $ext === 'webm' || $ext === 'flv'){ - $tsize = get_thumbnail_size($config->get_int('thumb_width'), $config->get_int('thumb_height')); - } - else{ + + $extArr = array_flip(array('swf', 'svg', 'mp4', 'ogv', 'webm', 'flv')); //List of thumbless filetypes + if(!isset($extArr[$image->ext])){ $tsize = get_thumbnail_size($image->width, $image->height); + }else{ + //Use max thumbnail size if using thumbless filetype + $tsize = get_thumbnail_size($config->get_int('thumb_width'), $config->get_int('thumb_height')); } $custom_classes = ""; diff --git a/core/config.class.php b/core/config.class.php index 538dd496..96e6e156 100644 --- a/core/config.class.php +++ b/core/config.class.php @@ -181,7 +181,7 @@ class DatabaseConfig extends BaseConfig { /* * Load the config table from a database */ - public function DatabaseConfig(Database $database) { + public function __construct(Database $database) { $this->database = $database; $cached = $this->database->cache->get("config"); diff --git a/core/database.class.php b/core/database.class.php index bd3032a9..eb00e1ab 100644 --- a/core/database.class.php +++ b/core/database.class.php @@ -5,7 +5,7 @@ class Querylet { var $sql; var $variables; - public function Querylet($sql, $variables=array()) { + public function __construct($sql, $variables=array()) { $this->sql = $sql; $this->variables = $variables; } @@ -28,7 +28,7 @@ class TagQuerylet { var $tag; var $positive; - public function TagQuerylet($tag, $positive) { + public function __construct($tag, $positive) { $this->tag = $tag; $this->positive = $positive; } @@ -37,7 +37,7 @@ class ImgQuerylet { var $qlet; var $positive; - public function ImgQuerylet($qlet, $positive) { + public function __construct($qlet, $positive) { $this->qlet = $qlet; $this->positive = $positive; } @@ -271,11 +271,13 @@ class Database { /** * Meta info about the database engine + * @var DBEngine */ private $engine = null; /** * The currently active cache engine + * @var CacheEngine */ public $cache = null; @@ -290,7 +292,7 @@ class Database { * need it. There are some pages where all the data is in cache, so the * DB connection is on-demand. */ - public function Database() { + public function __construct() { $this->connect_cache(); } diff --git a/core/extension.class.php b/core/extension.class.php index b288e91f..9d881c80 100644 --- a/core/extension.class.php +++ b/core/extension.class.php @@ -140,9 +140,9 @@ abstract class FormatterExtension extends Extension { */ abstract class DataHandlerExtension extends Extension { public function onDataUpload(DataUploadEvent $event) { - global $user; - - if(($supported_ext = $this->supported_ext($event->type)) && ($check_contents = $this->check_contents($event->tmpname))) { + $supported_ext = $this->supported_ext($event->type); + $check_contents = $this->check_contents($event->tmpname); + if($supported_ext && $check_contents) { if(!move_upload_to_archive($event)) return; send_event(new ThumbnailGenerationEvent($event->hash, $event->type)); diff --git a/core/imageboard.pack.php b/core/imageboard.pack.php index d87a6f4a..8e21de8b 100644 --- a/core/imageboard.pack.php +++ b/core/imageboard.pack.php @@ -49,7 +49,7 @@ class Image { * One will very rarely construct an image directly, more common * would be to use Image::by_id, Image::by_hash, etc */ - public function Image($row=null) { + public function __construct($row=null) { if(!is_null($row)) { foreach($row as $name => $value) { // some databases use table.name rather than name @@ -73,7 +73,6 @@ class Image { public static function by_id(/*int*/ $id) { assert(is_numeric($id)); global $database; - $image = null; $row = $database->get_row("SELECT * FROM images WHERE images.id=:id", array("id"=>$id)); return ($row ? new Image($row) : null); } @@ -86,7 +85,6 @@ class Image { public static function by_hash(/*string*/ $hash) { assert(is_string($hash)); global $database; - $image = null; $row = $database->get_row("SELECT images.* FROM images WHERE hash=:hash", array("hash"=>$hash)); return ($row ? new Image($row) : null); } @@ -124,12 +122,12 @@ class Image { if(SPEED_HAX) { if(!$user->can("big_search") and count($tags) > 3) { - die("Anonymous users may only search for up to 3 tags at a time"); // FIXME: throw an exception? + throw new SCoreException("Anonymous users may only search for up to 3 tags at a time"); } } $querylet = Image::build_search_querylet($tags); - $querylet->append(new Querylet(" ORDER BY images.".($order_sql ?: $config->get_string("index_order")))); + $querylet->append(new Querylet(" ORDER BY ".($order_sql ?: "images.".$config->get_string("index_order")))); $querylet->append(new Querylet(" LIMIT :limit OFFSET :offset", array("limit"=>$limit, "offset"=>$start))); #var_dump($querylet->sql); var_dump($querylet->variables); $result = $database->execute($querylet->sql, $querylet->variables); @@ -646,7 +644,7 @@ class Image { * images table. Yes, MySQL does suck this much. */ private static function build_accurate_search_querylet($terms) { - global $config, $database; + global $database; $tag_querylets = array(); $img_querylets = array(); @@ -806,7 +804,7 @@ class Image { * build_accurate_search_querylet() for a full explanation */ private static function build_ugly_search_querylet($terms) { - global $config, $database; + global $database; $tag_querylets = array(); $img_querylets = array(); @@ -912,9 +910,6 @@ class Image { // more than one positive tag, or more than zero negative tags else { - $s_tag_array = array_map("sql_escape", $tag_search->variables); - $s_tag_list = join(', ', $s_tag_array); - $tag_id_array = array(); $tags_ok = true; foreach($tag_search->variables as $tag) { @@ -1058,7 +1053,7 @@ class Tag { else { global $database; $db_wild_tag = str_replace("%", "\%", $tag); - $db_wild_tag = str_replace("*", "%", $tag); + $db_wild_tag = str_replace("*", "%", $db_wild_tag); $newtags = $database->get_col($database->scoreql_to_sql("SELECT tag FROM tags WHERE SCORE_STRNORM(tag) LIKE SCORE_STRNORM(?)"), array($db_wild_tag)); if(count($newtags) > 0) { $resolved = $newtags; @@ -1116,7 +1111,6 @@ function move_upload_to_archive(DataUploadEvent $event) { if(!@copy($event->tmpname, $target)) { $errors = error_get_last(); // note: requires php 5.2 throw new UploadException("Failed to copy file from uploads ({$event->tmpname}) to archive ($target): {$errors['type']} / {$errors['message']}"); - return false; } return true; } diff --git a/core/user.class.php b/core/user.class.php index cb99bf79..3adceadc 100644 --- a/core/user.class.php +++ b/core/user.class.php @@ -15,6 +15,9 @@ class User { var $name; var $email; var $join_date; + var $passhash; + + /* @var UserClass */ var $class; /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * @@ -30,7 +33,7 @@ class User { * One will very rarely construct a user directly, more common * would be to use User::by_id, User::by_session, etc */ - public function User($row) { + public function __construct($row) { global $_user_classes; $this->id = int_escape($row['id']); diff --git a/core/util.inc.php b/core/util.inc.php index f77b36b5..587f66a0 100644 --- a/core/util.inc.php +++ b/core/util.inc.php @@ -385,7 +385,13 @@ function make_http(/*string*/ $link) { /** * Make a form tag with relevant auth token and stuff * - * @retval string + * @param target string + * @param method string + * @param multipart boolean + * @param form_id string + * @param onsubmit string + * + * @return string */ function make_form($target, $method="POST", $multipart=False, $form_id="", $onsubmit="") { global $user; @@ -451,7 +457,7 @@ function captcha_get_html() { } else { session_start(); - $securimg = new Securimage(); + //$securimg = new Securimage(); $base = get_base_href(); $captcha = "
". "
CAPTCHA: "; @@ -1276,6 +1282,7 @@ function _sanitise_environment() { } function _get_themelet_files($_theme) { + $base_themelets = array(); if(file_exists('themes/'.$_theme.'/custompage.class.php')) $base_themelets[] = 'themes/'.$_theme.'/custompage.class.php'; $base_themelets[] = 'themes/'.$_theme.'/layout.class.php'; $base_themelets[] = 'themes/'.$_theme.'/themelet.class.php'; @@ -1406,7 +1413,7 @@ function _decaret($str) { } function _get_user() { - global $config, $database; + global $config; $user = null; if(get_prefixed_cookie("user") && get_prefixed_cookie("session")) { $tmp_user = User::by_session(get_prefixed_cookie("user"), get_prefixed_cookie("session")); diff --git a/ext/admin/main.php b/ext/admin/main.php index 2f83e63a..68273195 100644 --- a/ext/admin/main.php +++ b/ext/admin/main.php @@ -25,7 +25,7 @@ */ class AdminBuildingEvent extends Event { var $page; - public function AdminBuildingEvent(Page $page) { + public function __construct(Page $page) { $this->page = $page; } } @@ -182,14 +182,18 @@ class AdminPage extends Extension { case 'sqlite': $cmd = "sqlite3 $database .dump"; break; + default: + $cmd = false; } //FIXME: .SQL dump is empty if cmd doesn't exist - $page->set_mode("data"); - $page->set_type("application/x-unknown"); - $page->set_filename('shimmie-'.date('Ymd').'.sql'); - $page->set_data(shell_exec($cmd)); + if($cmd) { + $page->set_mode("data"); + $page->set_type("application/x-unknown"); + $page->set_filename('shimmie-'.date('Ymd').'.sql'); + $page->set_data(shell_exec($cmd)); + } return false; } diff --git a/ext/admin/theme.php b/ext/admin/theme.php index 64c18d2f..3eefdb11 100644 --- a/ext/admin/theme.php +++ b/ext/admin/theme.php @@ -14,9 +14,9 @@ class AdminPageTheme extends Themelet { protected function button(/*string*/ $name, /*string*/ $action, /*boolean*/ $protected=false) { $c_protected = $protected ? " protected" : ""; - $html = make_form(make_link("admin/$action"), "POST", false, false, false, "admin$c_protected"); + $html = make_form(make_link("admin/$action"), "POST", false, null, null, "admin$c_protected"); if($protected) { - $html .= ""; + $html .= ""; $html .= ""; } else { diff --git a/ext/alias_editor/main.php b/ext/alias_editor/main.php index fb52ce2e..54015ab9 100644 --- a/ext/alias_editor/main.php +++ b/ext/alias_editor/main.php @@ -14,7 +14,7 @@ class AddAliasEvent extends Event { var $oldtag; var $newtag; - public function AddAliasEvent($oldtag, $newtag) { + public function __construct($oldtag, $newtag) { $this->oldtag = trim($oldtag); $this->newtag = trim($newtag); } diff --git a/ext/alias_editor/theme.php b/ext/alias_editor/theme.php index d206a916..173f7bd2 100644 --- a/ext/alias_editor/theme.php +++ b/ext/alias_editor/theme.php @@ -29,7 +29,6 @@ class AliasEditorTheme extends Themelet { } $h_aliases = ""; - $n = 0; foreach($aliases as $old => $new) { $h_old = html_escape($old); $h_new = "".html_escape($new).""; diff --git a/ext/artists/main.php b/ext/artists/main.php index e0fbe3d5..7aea77ad 100644 --- a/ext/artists/main.php +++ b/ext/artists/main.php @@ -11,7 +11,7 @@ class AuthorSetEvent extends Event { var $image, $user, $author; - public function AuthorSetEvent(Image $image, User $user, /*string*/ $author) + public function __construct(Image $image, User $user, /*string*/ $author) { $this->image = $image; $this->user = $user; @@ -59,8 +59,8 @@ class Artists extends Extension { id SCORE_AIPK, user_id INTEGER NOT NULL, name VARCHAR(255) NOT NULL, - created DATETIME NOT NULL, - updated DATETIME NOT NULL, + created SCORE_DATETIME NOT NULL, + updated SCORE_DATETIME NOT NULL, notes TEXT, FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE "); @@ -70,8 +70,8 @@ class Artists extends Extension { artist_id INTEGER NOT NULL, user_id INTEGER NOT NULL, name VARCHAR(255) NOT NULL, - created DATETIME NOT NULL, - updated DATETIME NOT NULL, + created SCORE_DATETIME NOT NULL, + updated SCORE_DATETIME NOT NULL, FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE, FOREIGN KEY (artist_id) REFERENCES artists (id) ON UPDATE CASCADE ON DELETE CASCADE "); @@ -79,8 +79,8 @@ class Artists extends Extension { id SCORE_AIPK, artist_id INTEGER NOT NULL, user_id INTEGER NOT NULL, - created DATETIME, - updated DATETIME, + created SCORE_DATETIME, + updated SCORE_DATETIME, alias VARCHAR(255), FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE, FOREIGN KEY (artist_id) REFERENCES artists (id) ON UPDATE CASCADE ON DELETE CASCADE @@ -89,8 +89,8 @@ class Artists extends Extension { id SCORE_AIPK, artist_id INTEGER NOT NULL, user_id INTEGER NOT NULL, - created DATETIME NOT NULL, - updated DATETIME NOT NULL, + created SCORE_DATETIME NOT NULL, + updated SCORE_DATETIME NOT NULL, url VARCHAR(1000) NOT NULL, FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE, FOREIGN KEY (artist_id) REFERENCES artists (id) ON UPDATE CASCADE ON DELETE CASCADE @@ -143,7 +143,7 @@ class Artists extends Extension { } public function handle_commands($event) { - global $config, $page, $user; + global $page, $user; if($event->page_matches("artist")) { diff --git a/ext/artists/theme.php b/ext/artists/theme.php index b1acd803..c6d957a3 100644 --- a/ext/artists/theme.php +++ b/ext/artists/theme.php @@ -14,19 +14,11 @@ class ArtistsTheme extends Themelet { "; } - public function display_artists(){ - global $page; - - $page->set_title("Artists"); - $page->set_heading("Artists"); - $page->add_block(new Block("Artists", $html, "main", 10)); - - //$this->display_paginator($page, "artist/list", null, $pageNumber, $totalPages); - } - public function sidebar_options(/*string*/ $mode, $artistID=NULL, $is_admin=FALSE){ - global $page; - + global $page, $user; + + $html = ""; + if($mode == "neutral"){ $html = "
".$user->get_auth_html()." @@ -72,49 +64,52 @@ class ArtistsTheme extends Themelet {
"; } - $page->add_block(new Block("Manage Artists", $html, "left", 10)); + + if($html) $page->add_block(new Block("Manage Artists", $html, "left", 10)); } - public function show_artist_editor($artist, $aliases, $members, $urls) - { - $artistName = $artist['name']; - $artistNotes = $artist['notes']; - $artistID = $artist['id']; + public function show_artist_editor($artist, $aliases, $members, $urls) + { + global $user; - // aliases - $aliasesString = ""; - $aliasesIDsString = ""; - foreach ($aliases as $alias) - { - $aliasesString .= $alias["alias_name"]." "; - $aliasesIDsString .= $alias["alias_id"]." "; - } - $aliasesString = rtrim($aliasesString); - $aliasesIDsString = rtrim($aliasesIDsString); + $artistName = $artist['name']; + $artistNotes = $artist['notes']; + $artistID = $artist['id']; - // members - $membersString = ""; - $membersIDsString = ""; - foreach ($members as $member) - { - $membersString .= $member["name"]." "; - $membersIDsString .= $member["id"]." "; - } - $membersString = rtrim($membersString); - $membersIDsString = rtrim($membersIDsString); + // aliases + $aliasesString = ""; + $aliasesIDsString = ""; + foreach ($aliases as $alias) + { + $aliasesString .= $alias["alias_name"]." "; + $aliasesIDsString .= $alias["alias_id"]." "; + } + $aliasesString = rtrim($aliasesString); + $aliasesIDsString = rtrim($aliasesIDsString); - // urls - $urlsString = ""; - $urlsIDsString = ""; - foreach ($urls as $url) - { - $urlsString .= $url["url"]."\n"; - $urlsIDsString .= $url["id"]." "; - } - $urlsString = substr($urlsString, 0, strlen($urlsString) -1); - $urlsIDsString = rtrim($urlsIDsString); + // members + $membersString = ""; + $membersIDsString = ""; + foreach ($members as $member) + { + $membersString .= $member["name"]." "; + $membersIDsString .= $member["id"]." "; + } + $membersString = rtrim($membersString); + $membersIDsString = rtrim($membersIDsString); - $html = + // urls + $urlsString = ""; + $urlsIDsString = ""; + foreach ($urls as $url) + { + $urlsString .= $url["url"]."\n"; + $urlsIDsString .= $url["id"]." "; + } + $urlsString = substr($urlsString, 0, strlen($urlsString) -1); + $urlsIDsString = rtrim($urlsIDsString); + + $html = '
'.$user->get_auth_html().' @@ -131,112 +126,113 @@ class ArtistsTheme extends Themelet {
- + '; - global $page; - $page->add_block(new Block("Edit artist", $html, "main", 10)); - } + global $page; + $page->add_block(new Block("Edit artist", $html, "main", 10)); + } public function new_artist_composer() - { - global $page; + { + global $page, $user; - $html = "
+ $html = " ".$user->get_auth_html()." - - - - - +
Name:
Aliases:
Members:
URLs:
+ + + + - -
Name:
Aliases:
Members:
URLs:
Notes:
- "; + + + "; - $page->set_title("Artists"); - $page->set_heading("Artists"); - $page->add_block(new Block("Artists", $html, "main", 10)); + $page->set_title("Artists"); + $page->set_heading("Artists"); + $page->add_block(new Block("Artists", $html, "main", 10)); } public function list_artists($artists, $pageNumber, $totalPages) - { - global $user, $page; + { + global $user, $page; - $html = "". - "". - "". - "". - "". - ""; + $html = "
NameTypeLast updaterPosts
". + "". + "". + "". + "". + ""; - if(!$user->is_anonymous()) $html .= ""; // space for edit link - - $html .= ""; + if(!$user->is_anonymous()) $html .= ""; // space for edit link + + $html .= ""; - $n = 0; - $deletionLinkActionArray = - array('artist' => 'artist/nuke/' - , 'alias' => 'artist/alias/delete/' - , 'member' => 'artist/member/delete/' - ); + $deletionLinkActionArray = + array('artist' => 'artist/nuke/' + , 'alias' => 'artist/alias/delete/' + , 'member' => 'artist/member/delete/' + ); - $editionLinkActionArray = - array('artist' => 'artist/edit/' - , 'alias' => 'artist/alias/edit/' - , 'member' => 'artist/member/edit/' - ); + $editionLinkActionArray = + array('artist' => 'artist/edit/' + , 'alias' => 'artist/alias/edit/' + , 'member' => 'artist/member/edit/' + ); - $typeTextArray = - array('artist' => 'Artist' - , 'alias' => 'Alias' - , 'member' => 'Member' - ); + $typeTextArray = + array('artist' => 'Artist' + , 'alias' => 'Alias' + , 'member' => 'Member' + ); - foreach ($artists as $artist) { - if ($artist['type'] != 'artist') - $artist['name'] = str_replace("_", " ", $artist['name']); + foreach ($artists as $artist) { + if ($artist['type'] != 'artist') + $artist['name'] = str_replace("_", " ", $artist['name']); - $elementLink = "".str_replace("_", " ", $artist['name']).""; - $artist_link = "".str_replace("_", " ", $artist['artist_name']).""; - $user_link = "".$artist['user_name'].""; - $edit_link = "Edit"; - $del_link = "Delete"; + $elementLink = "".str_replace("_", " ", $artist['name']).""; + //$artist_link = "".str_replace("_", " ", $artist['artist_name']).""; + $user_link = "".$artist['user_name'].""; + $edit_link = "Edit"; + $del_link = "Delete"; - $html .= "". - "". + "". - "". - "". - ""; + $html .= "". + "". + "". + ""; - if(!$user->is_anonymous()) $html .= ""; - if($user->is_admin()) $html .= ""; + if(!$user->is_anonymous()) $html .= ""; + if($user->is_admin()) $html .= ""; - $html .= ""; - } + $html .= ""; + } - $html .= "
NameTypeLast updaterPostsAction
Action
".$elementLink; + $html .= "
".$elementLink; - //if ($artist['type'] == 'member') - // $html .= " (member of ".$artist_link.")"; + //if ($artist['type'] == 'member') + // $html .= " (member of ".$artist_link.")"; - //if ($artist['type'] == 'alias') - // $html .= " (alias for ".$artist_link.")"; + //if ($artist['type'] == 'alias') + // $html .= " (alias for ".$artist_link.")"; - $html .= "".$typeTextArray[$artist['type']]."".$user_link."".$artist['posts']."".$typeTextArray[$artist['type']]."".$user_link."".$artist['posts']."".$edit_link."".$del_link."".$edit_link."".$del_link."
"; + $html .= ""; - $page->set_title("Artists"); - $page->set_heading("Artists"); - $page->add_block(new Block("Artists", $html, "main", 10)); + $page->set_title("Artists"); + $page->set_heading("Artists"); + $page->add_block(new Block("Artists", $html, "main", 10)); - $this->display_paginator($page, "artist/list", null, $pageNumber, $totalPages); + $this->display_paginator($page, "artist/list", null, $pageNumber, $totalPages); } - public function show_new_alias_composer($artistID) - { - $html = - ' + public function show_new_alias_composer($artistID) + { + global $user; + + $html = + ' '.$user->get_auth_html().'
Alias: @@ -244,258 +240,265 @@ class ArtistsTheme extends Themelet {
- '; + '; - global $page; - $page->add_block(new Block("Artist Aliases", $html, "main", 20)); - } - public function show_new_member_composer($artistID) - { - $html = - '
+ global $page; + $page->add_block(new Block("Artist Aliases", $html, "main", 20)); + } + public function show_new_member_composer($artistID) + { + global $user; + + $html = + ' '.$user->get_auth_html().'
Members:
-
- '; + + '; - global $page; - $page->add_block(new Block("Artist members", $html, "main", 30)); - } + global $page; + $page->add_block(new Block("Artist members", $html, "main", 30)); + } - public function show_new_url_composer($artistID) - { - $html = - '
+ public function show_new_url_composer($artistID) + { + global $user; + + $html = + ' '.$user->get_auth_html().'
URL:
-
- '; + + '; - global $page; - $page->add_block(new Block("Artist URLs", $html, "main", 40)); - } + global $page; + $page->add_block(new Block("Artist URLs", $html, "main", 40)); + } - public function show_alias_editor($alias) - { - $html = - ' -
+ public function show_alias_editor($alias) + { + global $user; + + $html = + ' + '.$user->get_auth_html().' - - - - -
- '; + + + + + + '; - global $page; - $page->add_block(new Block("Edit Alias", $html, "main", 10)); - } + global $page; + $page->add_block(new Block("Edit Alias", $html, "main", 10)); + } - public function show_url_editor($url) - { - $html = - ' -
+ public function show_url_editor($url) + { + global $user; + + $html = + ' + '.$user->get_auth_html().' - - - - -
- '; + + + + + + '; - global $page; - $page->add_block(new Block("Edit URL", $html, "main", 10)); - } + global $page; + $page->add_block(new Block("Edit URL", $html, "main", 10)); + } - public function show_member_editor($member) - { - $html = - ' -
+ public function show_member_editor($member) + { + global $user; + + $html = + ' + '.$user->get_auth_html().' - - - - -
- '; + + + + + + '; - global $page; - $page->add_block(new Block("Edit Member", $html, "main", 10)); - } + global $page; + $page->add_block(new Block("Edit Member", $html, "main", 10)); + } public function show_artist($artist, $aliases, $members, $urls, $images, $userIsLogged, $userIsAdmin) - { - global $user, $event, $page; + { + global $page; - $artist_link = "".str_replace("_", " ", $artist['name']).""; + $artist_link = "".str_replace("_", " ", $artist['name']).""; - $n = 0; - - $html = " - - - - "; - - if ($userIsLogged) - $html .= ""; - - if ($userIsAdmin) - $html .= ""; - - $html .= " - - - - - "; - if ($userIsLogged) $html .= ""; - if ($userIsAdmin) $html .= ""; - $html .= ""; - - if (count($aliases) > 0) - { - $aliasViewLink = str_replace("_", " ", $aliases[0]['alias_name']); // no link anymore - $aliasEditLink = "Edit"; - $aliasDeleteLink = "Delete"; - - $html .= " - - "; - - if ($userIsLogged) - $html .= ""; - - if ($userIsAdmin) - $html .= ""; - - $html .= ""; - - if (count($aliases) > 1) - { - for ($i = 1; $i < count($aliases); $i++) - { - $aliasViewLink = str_replace("_", " ", $aliases[$i]['alias_name']); // no link anymore - $aliasEditLink = "Edit"; - $aliasDeleteLink = "Delete"; - - $html .= " - - "; - if ($userIsLogged) - $html .= ""; - if ($userIsAdmin) - $html .= ""; - - $html .= ""; - } - } - } - - if (count($members) > 0) - { - $memberViewLink = str_replace("_", " ", $members[0]['name']); // no link anymore - $memberEditLink = "Edit"; - $memberDeleteLink = "Delete"; - - $html .= " - - "; - if ($userIsLogged) - $html .= ""; - if ($userIsAdmin) - $html .= ""; - - $html .= ""; - - if (count($members) > 1) - { - for ($i = 1; $i < count($members); $i++) - { - $memberViewLink = str_replace("_", " ", $members[$i]['name']); // no link anymore - $memberEditLink = "Edit"; - $memberDeleteLink = "Delete"; - - $html .= " - - "; - if ($userIsLogged) - $html .= ""; - if ($userIsAdmin) - $html .= ""; - - $html .= ""; - } - } - } - - if (count($urls) > 0) - { - $urlViewLink = "".str_replace("_", " ", $urls[0]['url']).""; - $urlEditLink = "Edit"; - $urlDeleteLink = "Delete"; - - $html .= " - - "; - - if ($userIsLogged) - $html .= ""; - - if ($userIsAdmin) - $html .= ""; - - $html .= ""; - - if (count($urls) > 1) - { - for ($i = 1; $i < count($urls); $i++) - { - $urlViewLink = "".str_replace("_", " ", $urls[$i]['url']).""; - $urlEditLink = "Edit"; - $urlDeleteLink = "Delete"; - - $html .= " - - "; - if ($userIsLogged) - $html .= ""; - - if ($userIsAdmin) - $html .= ""; - - $html .= ""; - } - } - } - - $html .= - " - - "; - if ($userIsLogged) $html .= ""; - if ($userIsAdmin) $html .= ""; - //TODO how will notes be edited? On edit artist? (should there be an editartist?) or on a editnotes? - //same question for deletion - $html .= " -
Name:".$artist_link."
Aliases:".$aliasViewLink."".$aliasEditLink."".$aliasDeleteLink."
 ".$aliasViewLink."".$aliasEditLink."".$aliasDeleteLink."
Members:".$memberViewLink."".$memberEditLink."".$memberDeleteLink."
 ".$memberViewLink."".$memberEditLink."".$memberDeleteLink."
URLs:".$urlViewLink."".$urlEditLink."".$urlDeleteLink."
 ".$urlViewLink."".$urlEditLink."".$urlDeleteLink."
Notes:".$artist["notes"]."
"; - - $page->set_title("Artist"); - $page->set_heading("Artist"); - $page->add_block(new Block("Artist", $html, "main", 10)); - + $html = " + + + + "; + if ($userIsLogged) + $html .= ""; + + if ($userIsAdmin) + $html .= ""; + + $html .= " + + + + + "; + if ($userIsLogged) $html .= ""; + if ($userIsAdmin) $html .= ""; + $html .= ""; + + if (count($aliases) > 0) + { + $aliasViewLink = str_replace("_", " ", $aliases[0]['alias_name']); // no link anymore + $aliasEditLink = "Edit"; + $aliasDeleteLink = "Delete"; + + $html .= " + + "; + + if ($userIsLogged) + $html .= ""; + + if ($userIsAdmin) + $html .= ""; + + $html .= ""; + + if (count($aliases) > 1) + { + for ($i = 1; $i < count($aliases); $i++) + { + $aliasViewLink = str_replace("_", " ", $aliases[$i]['alias_name']); // no link anymore + $aliasEditLink = "Edit"; + $aliasDeleteLink = "Delete"; + + $html .= " + + "; + if ($userIsLogged) + $html .= ""; + if ($userIsAdmin) + $html .= ""; + + $html .= ""; + } + } + } + + if (count($members) > 0) + { + $memberViewLink = str_replace("_", " ", $members[0]['name']); // no link anymore + $memberEditLink = "Edit"; + $memberDeleteLink = "Delete"; + + $html .= " + + "; + if ($userIsLogged) + $html .= ""; + if ($userIsAdmin) + $html .= ""; + + $html .= ""; + + if (count($members) > 1) + { + for ($i = 1; $i < count($members); $i++) + { + $memberViewLink = str_replace("_", " ", $members[$i]['name']); // no link anymore + $memberEditLink = "Edit"; + $memberDeleteLink = "Delete"; + + $html .= " + + "; + if ($userIsLogged) + $html .= ""; + if ($userIsAdmin) + $html .= ""; + + $html .= ""; + } + } + } + + if (count($urls) > 0) + { + $urlViewLink = "".str_replace("_", " ", $urls[0]['url']).""; + $urlEditLink = "Edit"; + $urlDeleteLink = "Delete"; + + $html .= " + + "; + + if ($userIsLogged) + $html .= ""; + + if ($userIsAdmin) + $html .= ""; + + $html .= ""; + + if (count($urls) > 1) + { + for ($i = 1; $i < count($urls); $i++) + { + $urlViewLink = "".str_replace("_", " ", $urls[$i]['url']).""; + $urlEditLink = "Edit"; + $urlDeleteLink = "Delete"; + + $html .= " + + "; + if ($userIsLogged) + $html .= ""; + + if ($userIsAdmin) + $html .= ""; + + $html .= ""; + } + } + } + + $html .= + " + + "; + if ($userIsLogged) $html .= ""; + if ($userIsAdmin) $html .= ""; + //TODO how will notes be edited? On edit artist? (should there be an editartist?) or on a editnotes? + //same question for deletion + $html .= " +
Name:".$artist_link."
Aliases:".$aliasViewLink."".$aliasEditLink."".$aliasDeleteLink."
 ".$aliasViewLink."".$aliasEditLink."".$aliasDeleteLink."
Members:".$memberViewLink."".$memberEditLink."".$memberDeleteLink."
 ".$memberViewLink."".$memberEditLink."".$memberDeleteLink."
URLs:".$urlViewLink."".$urlEditLink."".$urlDeleteLink."
 ".$urlViewLink."".$urlEditLink."".$urlDeleteLink."
Notes:".$artist["notes"]."
"; + + $page->set_title("Artist"); + $page->set_heading("Artist"); + $page->add_block(new Block("Artist", $html, "main", 10)); + //we show the images for the artist $artist_images = ""; foreach($images as $image) { diff --git a/ext/blotter/theme.php b/ext/blotter/theme.php index 9fe9dd79..872f550a 100644 --- a/ext/blotter/theme.php +++ b/ext/blotter/theme.php @@ -31,7 +31,6 @@ class BlotterTheme extends Themelet { * Long function name, but at least I won't confuse it with something else ^_^ */ - $html = ""; // Add_new stuff goes here. $table_header = " @@ -134,7 +133,7 @@ class BlotterTheme extends Themelet { // Reset variables: $i_open = ""; $i_close = ""; - $id = $entries[$i]['id']; + //$id = $entries[$i]['id']; $messy_date = $entries[$i]['entry_date']; $clean_date = date("m/d/y", strtotime($messy_date)); $entry_text = $entries[$i]['entry_text']; @@ -145,8 +144,6 @@ class BlotterTheme extends Themelet { $entries_list .= "
  • {$i_open}{$clean_date} - {$entry_text}{$i_close}
  • "; } - $out_text = ""; - $in_text = ""; $pos_break = ""; $pos_align = "text-align: right; position: absolute; right: 0px;"; diff --git a/ext/bulk_add/main.php b/ext/bulk_add/main.php index 2cab0f46..cf58e4a3 100644 --- a/ext/bulk_add/main.php +++ b/ext/bulk_add/main.php @@ -30,7 +30,7 @@ class BulkAdd extends Extension { public function onCommand(CommandEvent $event) { if($event->cmd == "help") { print " bulk-add [directory]\n"; - print " Import this directory\n\n"; + print " Import this directory\n\n"; } if($event->cmd == "bulk-add") { if(count($event->args) == 1) { @@ -53,6 +53,7 @@ class BulkAdd extends Extension { if(!array_key_exists('extension', $pathinfo)) { throw new UploadException("File has no extension"); } + $metadata = array(); $metadata['filename'] = $pathinfo['basename']; $metadata['extension'] = $pathinfo['extension']; $metadata['tags'] = $tags; @@ -65,8 +66,6 @@ class BulkAdd extends Extension { } private function add_dir(/*string*/ $base, $subdir="") { - global $page; - if(!is_dir($base)) { $this->theme->add_status("Error", "$base is not a directory"); return; diff --git a/ext/bulk_add_csv/main.php b/ext/bulk_add_csv/main.php index fd177846..4ff15773 100644 --- a/ext/bulk_add_csv/main.php +++ b/ext/bulk_add_csv/main.php @@ -33,7 +33,7 @@ class BulkAddCSV extends Extension { public function onCommand(CommandEvent $event) { if($event->cmd == "help") { print " bulk-add-csv [/path/to.csv]\n"; - print " Import this .csv file (refer to documentation)\n\n"; + print " Import this .csv file (refer to documentation)\n\n"; } if($event->cmd == "bulk-add-csv") { global $user; @@ -62,6 +62,7 @@ class BulkAddCSV extends Extension { if(!array_key_exists('extension', $pathinfo)) { throw new UploadException("File has no extension"); } + $metadata = array(); $metadata['filename'] = $pathinfo['basename']; $metadata['extension'] = $pathinfo['extension']; $metadata['tags'] = $tags; @@ -82,8 +83,6 @@ class BulkAddCSV extends Extension { } private function add_csv(/*string*/ $csvfile) { - global $page; - if(!file_exists($csvfile)) { $this->theme->add_status("Error", "$csvfile not found"); return; diff --git a/ext/bulk_remove/main.php b/ext/bulk_remove/main.php index 73bcbb8e..2e609386 100644 --- a/ext/bulk_remove/main.php +++ b/ext/bulk_remove/main.php @@ -12,7 +12,7 @@ class BulkRemove extends Extension { public function onPageRequest(PageRequestEvent $event) { - global $page, $user; + global $user; if($event->page_matches("bulk_remove") && $user->is_admin() && $user->check_auth_token()) { if ($event->get_arg(0) == "confirm") $this->do_bulk_remove(); else $this->show_confirm(); @@ -20,7 +20,7 @@ class BulkRemove extends Extension { } public function onAdminBuilding(AdminBuildingEvent $event) { - global $page, $user; + global $page; $html = "Be extremely careful when using this!
    Once an image is removed there is no way to recover it so it is recommended that you first take when removing a large amount of images.
    @@ -83,10 +83,10 @@ class BulkRemove extends Extension { // if no images were found with the given info - if (count($images_for_removal) == 0 && $html == "") + if (count($images_for_removal) == 0) $error = "No images selected for removal"; - var_dump($tags_arr); + //var_dump($tags_arr); return array( "error" => $error, "images_for_removal" => $images_for_removal); @@ -119,6 +119,7 @@ class BulkRemove extends Extension { private function do_bulk_remove() { + global $page; // display error if user didn't go through admin board if (!isset($_POST["bulk_remove_images"])) { $page->add_block(new Block("Bulk Remove Error", diff --git a/ext/chatbox/main.php b/ext/chatbox/main.php index 9c48ce40..fc48cac1 100644 --- a/ext/chatbox/main.php +++ b/ext/chatbox/main.php @@ -13,7 +13,7 @@ class Chatbox extends Extension { global $page, $user; // Adds header to enable chatbox - $root = make_http(); + $root = get_base_href(); $yPath = "$root/ext/chatbox/"; $page->add_html_header(" diff --git a/ext/comment/main.php b/ext/comment/main.php index 3b97f597..e6132807 100644 --- a/ext/comment/main.php +++ b/ext/comment/main.php @@ -14,7 +14,7 @@ require_once "lib/akismet.class.php"; class CommentPostingEvent extends Event { var $image_id, $user, $comment; - public function CommentPostingEvent($image_id, $user, $comment) { + public function __construct($image_id, $user, $comment) { $this->image_id = $image_id; $this->user = $user; $this->comment = $comment; @@ -29,7 +29,7 @@ class CommentPostingEvent extends Event { class CommentDeletionEvent extends Event { var $comment_id; - public function CommentDeletionEvent($comment_id) { + public function __construct($comment_id) { $this->comment_id = $comment_id; } } @@ -37,7 +37,11 @@ class CommentDeletionEvent extends Event { class CommentPostingException extends SCoreException {} class Comment { - public function Comment($row) { + var $owner, $owner_id, $owner_name, $owner_email, $owner_class; + var $comment, $comment_id; + var $image_id, $poster_ip, $posted; + + public function __construct($row) { $this->owner = null; $this->owner_id = $row['user_id']; $this->owner_name = $row['user_name']; diff --git a/ext/comment/theme.php b/ext/comment/theme.php index ba4d12b4..7821b68c 100644 --- a/ext/comment/theme.php +++ b/ext/comment/theme.php @@ -244,7 +244,7 @@ class CommentListTheme extends Themelet { $hb = ($comment->owner_class == "hellbanned" ? "hb" : ""); if($trim) { - return " + $html = "
    $h_userlink: $h_comment >>> @@ -263,7 +263,7 @@ class CommentListTheme extends Themelet { $h_del = $user->can("delete_comment") ? ' - Del' : ''; - return " + $html = "
    $h_avatar @@ -273,7 +273,7 @@ class CommentListTheme extends Themelet {
    "; } - return ""; + return $html; } protected function build_postbox(/*int*/ $image_id) { diff --git a/ext/cron_uploader/main.php b/ext/cron_uploader/main.php index 49180ca8..24c62c55 100644 --- a/ext/cron_uploader/main.php +++ b/ext/cron_uploader/main.php @@ -206,7 +206,7 @@ class CronUploader extends Extension { /** * Returns amount of files & total size of dir. - * @param unknown $path + * @param $path string * @return multitype:number */ function scan_dir($path){ @@ -227,7 +227,7 @@ class CronUploader extends Extension { /** * Uploads the image & handles everything - * @param number $upload_count to upload a non-config amount of imgs + * @param $upload_count int to upload a non-config amount of imgs * @return boolean returns true if the upload was successful */ public function process_upload($upload_count = 0) { @@ -254,11 +254,11 @@ class CronUploader extends Extension { try { $this->add_image($img[0], $img[1], $img[2]); - $newPath = $this->move_uploaded($img[0], $img[1], false); + $this->move_uploaded($img[0], $img[1], false); } catch (Exception $e) { - $newPath = $this->move_uploaded($img[0], $img[1], true); + $this->move_uploaded($img[0], $img[1], true); } // Remove img from queue array @@ -295,37 +295,17 @@ class CronUploader extends Extension { $this->add_upload_info($info . "Image \"$filename\" moved from queue to \"$newPath\"."); } - /** - * moves a directory up or gets the directory of a file - * - * @param string $path Path to modify - * @param int $depth Amount of directories to go up - * @return unknown Path to correct Directory - */ - private function move_directory_up($path, $depth=1) - { - $path = str_replace("//", "/", $path); - $array = explode("/", $path); - - for ($i = 0; $i < $depth; $i++) { - $to_remove = count($array) -1; // Gets number of element to remove - unset($array[$to_remove]); - } - - return implode("/", $array); - } - /** * Generate the necessary DataUploadEvent for a given image and tags. */ private function add_image($tmpname, $filename, $tags) { - global $user, $image; assert ( file_exists ( $tmpname ) ); $pathinfo = pathinfo ( $filename ); if (! array_key_exists ( 'extension', $pathinfo )) { throw new UploadException ( "File has no extension" ); } + $metadata = array(); $metadata ['filename'] = $pathinfo ['basename']; $metadata ['extension'] = $pathinfo ['extension']; $metadata ['tags'] = ""; // = $tags; doesn't work when not logged in here @@ -343,12 +323,9 @@ class CronUploader extends Extension { // Set tags $img = Image::by_id($event->image_id); $img->set_tags($tags); - } private function generate_image_queue($base = "", $subdir = "") { - global $config; - if ($base == "") $base = $this->root_dir . "/queue"; @@ -391,8 +368,9 @@ class CronUploader extends Extension { /** * Adds a message to the info being published at the end - * @param string $text - * @param int $addon Enter a value to modify an existing value (enter value number) + * @param $text string + * @param $addon int Enter a value to modify an existing value (enter value number) + * @return int */ private function add_upload_info($text, $addon = 0) { $info = $this->upload_info; @@ -409,7 +387,7 @@ class CronUploader extends Extension { // else if addon function is used, select the line & modify it $lines = substr($info, "\n"); // Seperate the string to array in lines - $lines[$addon] = "$line[$addon] $text"; // Add the content to the line + $lines[$addon] = "$lines[$addon] $text"; // Add the content to the line $this->upload_info = implode("\n", $lines); // Put string back together & update return $addon; // Return line number @@ -419,7 +397,7 @@ class CronUploader extends Extension { * This is run at the end to display & save the log. */ private function handle_log() { - global $page, $config; + global $page; // Display message $page->set_mode("data"); @@ -437,4 +415,4 @@ class CronUploader extends Extension { file_put_contents ($log_path, $content); } } -?> \ No newline at end of file +?> diff --git a/ext/danbooru_api/main.php b/ext/danbooru_api/main.php index 2ba1b82d..987ee8c4 100644 --- a/ext/danbooru_api/main.php +++ b/ext/danbooru_api/main.php @@ -106,9 +106,6 @@ class DanbooruApi extends Extension { if($user->can("create_image")) { - $file = null; - $filename = ""; - $source = ""; if(isset($_FILES['file'])) { // A file was POST'd in $file = $_FILES['file']['tmp_name']; diff --git a/ext/ext_manager/main.php b/ext/ext_manager/main.php index 4d4dd645..fdd59c4e 100644 --- a/ext/ext_manager/main.php +++ b/ext/ext_manager/main.php @@ -21,8 +21,9 @@ function __extman_extcmp(ExtensionInfo $a, ExtensionInfo $b) { class ExtensionInfo { var $ext_name, $name, $link, $author, $email; var $description, $documentation, $version, $visibility; + var $enabled; - function ExtensionInfo($main) { + function __construct($main) { $matches = array(); $lines = file($main); $number_of_lines = count($lines); @@ -131,7 +132,7 @@ class ExtManager extends Extension { public function onCommand(CommandEvent $event) { if($event->cmd == "help") { print " disable-all-ext\n"; - print " disable all extensions\n\n"; + print " disable all extensions\n\n"; } if($event->cmd == "disable-all-ext") { $this->write_config(array()); @@ -167,6 +168,7 @@ class ExtManager extends Extension { private function set_things($settings) { $core = explode(",", CORE_EXTS); + $extras = array(); foreach(glob("ext/*/main.php") as $main) { $matches = array(); diff --git a/ext/ext_manager/theme.php b/ext/ext_manager/theme.php index 599acf85..0b9cb270 100644 --- a/ext/ext_manager/theme.php +++ b/ext/ext_manager/theme.php @@ -17,7 +17,6 @@ class ExtManagerTheme extends Themelet { "; - $n = 0; foreach($extensions as $extension) { if(!$editable && $extension->visibility == "admin") continue; @@ -53,7 +52,6 @@ class ExtManagerTheme extends Themelet { /* public function display_blocks(Page $page, $extensions) { global $user; - $n = 0; $col_1 = ""; $col_2 = ""; foreach($extensions as $extension) { diff --git a/ext/favorites/main.php b/ext/favorites/main.php index d5f78616..10242e53 100644 --- a/ext/favorites/main.php +++ b/ext/favorites/main.php @@ -16,7 +16,7 @@ class FavoriteSetEvent extends Event { var $image_id, $user, $do_set; - public function FavoriteSetEvent(/*int*/ $image_id, User $user, /*boolean*/ $do_set) { + public function __construct(/*int*/ $image_id, User $user, /*boolean*/ $do_set) { assert(is_numeric($image_id)); assert(is_bool($do_set)); @@ -35,7 +35,7 @@ class Favorites extends Extension { } public function onImageAdminBlockBuilding(ImageAdminBlockBuildingEvent $event) { - global $database, $page, $user; + global $database, $user; if(!$user->is_anonymous()) { $user_id = $user->id; $image_id = $event->image->id; @@ -51,7 +51,7 @@ class Favorites extends Extension { public function onDisplayingImage(DisplayingImageEvent $event) { $people = $this->list_persons_who_have_favorited($event->image); if(count($people) > 0) { - $html = $this->theme->display_people($people); + $this->theme->display_people($people); } } @@ -88,7 +88,7 @@ class Favorites extends Extension { in_array('favorite_action', $_POST) && (($_POST['favorite_action'] == "set") || ($_POST['favorite_action'] == "unset")) ) { - send_event(new FavoriteSetEvent($event->image_id, $user, ($_POST['favorite_action'] == "set"))); + send_event(new FavoriteSetEvent($event->image->id, $user, ($_POST['favorite_action'] == "set"))); } } @@ -148,16 +148,14 @@ class Favorites extends Extension { if($config->get_int("ext_favorites_version") < 1) { $database->Execute("ALTER TABLE images ADD COLUMN favorites INTEGER NOT NULL DEFAULT 0"); $database->Execute("CREATE INDEX images__favorites ON images(favorites)"); - $database->Execute(" - CREATE TABLE user_favorites ( + $database->create_table("user_favorites", " image_id INTEGER NOT NULL, user_id INTEGER NOT NULL, - created_at DATETIME NOT NULL, + created_at SCORE_DATETIME NOT NULL, UNIQUE(image_id, user_id), FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE, FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE - ) - "); + "); $database->execute("CREATE INDEX user_favorites_image_id_idx ON user_favorites(image_id)", array()); $config->set_int("ext_favorites_version", 1); } diff --git a/ext/forum/main.php b/ext/forum/main.php index 0e18c9f3..62951e4f 100644 --- a/ext/forum/main.php +++ b/ext/forum/main.php @@ -27,8 +27,8 @@ class Forum extends Extension { sticky SCORE_BOOL NOT NULL DEFAULT SCORE_BOOL_N, title VARCHAR(255) NOT NULL, user_id INTEGER NOT NULL, - date DATETIME NOT NULL, - uptodate DATETIME NOT NULL, + date SCORE_DATETIME NOT NULL, + uptodate SCORE_DATETIME NOT NULL, FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE RESTRICT "); $database->execute("CREATE INDEX forum_threads_date_idx ON forum_threads(date)", array()); @@ -37,7 +37,7 @@ class Forum extends Extension { id SCORE_AIPK, thread_id INTEGER NOT NULL, user_id INTEGER NOT NULL, - date DATETIME NOT NULL, + date SCORE_DATETIME NOT NULL, message TEXT, FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE RESTRICT, FOREIGN KEY (thread_id) REFERENCES forum_threads (id) ON UPDATE CASCADE ON DELETE CASCADE @@ -330,7 +330,7 @@ class Forum extends Extension { private function save_new_thread($user) { $title = html_escape($_POST["title"]); - $sticky = html_escape($_POST["sticky"]); + $sticky = !empty($_POST["sticky"]) ? html_escape($_POST["sticky"]) : "N"; if($sticky == ""){ $sticky = "N"; @@ -344,11 +344,11 @@ class Forum extends Extension { (?, ?, ?, now(), now())", array($title, $sticky, $user->id)); - $result = $database->get_row("SELECT LAST_INSERT_ID() AS threadID", array()); + $threadID = $database->get_last_insert_id("forum_threads_id_seq"); - log_info("forum", "Thread {$result["threadID"]} created by {$user->name}"); + log_info("forum", "Thread {$threadID} created by {$user->name}"); - return $result["threadID"]; + return $threadID; } private function save_new_post($threadID, $user) @@ -367,9 +367,9 @@ class Forum extends Extension { (?, ?, now(), ?)" , array($threadID, $userID, $message)); - $result = $database->get_row("SELECT LAST_INSERT_ID() AS postID", array()); + $postID = $database->get_last_insert_id("forum_posts_id_seq"); - log_info("forum", "Post {$result["postID"]} created by {$user->name}"); + log_info("forum", "Post {$postID} created by {$user->name}"); $database->execute("UPDATE forum_threads SET uptodate=now() WHERE id=?", array ($threadID)); } diff --git a/ext/forum/theme.php b/ext/forum/theme.php index 101ff5a4..78c06261 100644 --- a/ext/forum/theme.php +++ b/ext/forum/theme.php @@ -83,9 +83,7 @@ class ForumTheme extends Themelet { global $config, $page/*, $user*/; $posts_per_page = $config->get_int('forumPostsPerPage'); - $theme_name = $config->get_string('theme'); - $html = ""; $current_post = 0; $html = diff --git a/ext/handle_archive/main.php b/ext/handle_archive/main.php index a01589f8..f4dfe3dc 100644 --- a/ext/handle_archive/main.php +++ b/ext/handle_archive/main.php @@ -50,11 +50,11 @@ class ArchiveFileHandler extends Extension { assert(file_exists($tmpname)); try { - global $user; $pathinfo = pathinfo($filename); if(!array_key_exists('extension', $pathinfo)) { throw new UploadException("File has no extension"); } + $metadata = array(); $metadata['filename'] = $pathinfo['basename']; $metadata['extension'] = $pathinfo['extension']; $metadata['tags'] = $tags; @@ -69,8 +69,6 @@ class ArchiveFileHandler extends Extension { // copied from bulk add extension private function add_dir($base, $subdir="") { - global $page; - $list = ""; $dir = opendir("$base/$subdir"); diff --git a/ext/handle_flash/main.php b/ext/handle_flash/main.php index e59b8892..88becce7 100644 --- a/ext/handle_flash/main.php +++ b/ext/handle_flash/main.php @@ -17,26 +17,17 @@ class FlashFileHandler extends DataHandlerExtension { } protected function create_image_from_data(/*string*/ $filename, /*array*/ $metadata) { - global $config; - $image = new Image(); $image->filesize = $metadata['size']; - $image->hash = $metadata['hash']; + $image->hash = $metadata['hash']; $image->filename = $metadata['filename']; $image->ext = $metadata['extension']; $image->tag_array = Tag::explode($metadata['tags']); $image->source = $metadata['source']; - // redundant, since getimagesize() works on SWF o_O -// $rect = $this->swf_get_bounds($filename); -// if(is_null($rect)) { -// return $null; -// } -// $image->width = $rect[1]; -// $image->height = $rect[3]; - - if(!($info = getimagesize($filename))) return null; + $info = getimagesize($filename); + if(!$info) return null; $image->width = $info[0]; $image->height = $info[1]; @@ -45,61 +36,14 @@ class FlashFileHandler extends DataHandlerExtension { } protected function check_contents(/*string*/ $file) { - if(!file_exists($file)) return false; + if (!file_exists($file)) return false; $fp = fopen($file, "r"); $head = fread($fp, 3); fclose($fp); - if(!in_array($head, array("CWS", "FWS"))) return false; + if (!in_array($head, array("CWS", "FWS"))) return false; return true; } - - private function str_to_binarray(/*string*/ $string) { - $binary = array(); - $length = strlen($string); - for($j=0; $j<$length; $j++) { - $c = ord($string[$j]); - for($i=7; $i>=0; $i--) { - $binary[] = ($c >> $i) & 0x01; - } - } - return $binary; - } - - private function binarray_to_int($binarray, $start=0, $length=32) { - $int = 0; - for($i=$start; $i<$start + $length; $i++) { - $int = $int << 1; - $int = $int + ($binarray[$i] == "1" ? 1 : 0); - } - return $int; - } - - private function swf_get_bounds(/*string*/ $filename) { - $fp = fopen($filename, "r"); - $head = fread($fp, 3); - $version = fread($fp, 1); - $length = fread($fp, 4); - - if($head == "FWS") { - $data = fread($fp, 16); - } - else if($head == "CWS") { - $data = fread($fp, 128*1024); - $data = gzuncompress($data); - $data = substr($data, 0, 16); - } - - $bounds = array(); - $rect_bin = $this->str_to_binarray($data); - $nbits = $this->binarray_to_int($rect_bin, 0, 5); - $bounds[] = $this->binarray_to_int($rect_bin, 5 + 0 * $nbits, $nbits) / 20; - $bounds[] = $this->binarray_to_int($rect_bin, 5 + 1 * $nbits, $nbits) / 20; - $bounds[] = $this->binarray_to_int($rect_bin, 5 + 2 * $nbits, $nbits) / 20; - $bounds[] = $this->binarray_to_int($rect_bin, 5 + 3 * $nbits, $nbits) / 20; - - return $bounds; - } } ?> diff --git a/ext/handle_ico/main.php b/ext/handle_ico/main.php index 518f1a47..07fa97ec 100644 --- a/ext/handle_ico/main.php +++ b/ext/handle_ico/main.php @@ -36,7 +36,7 @@ class IcoFileHandler extends Extension { } public function onPageRequest(PageRequestEvent $event) { - global $config, $database, $page; + global $page; if($event->page_matches("get_ico")) { $id = int_escape($event->get_arg(0)); $image = Image::by_id($id); @@ -56,11 +56,8 @@ class IcoFileHandler extends Extension { } private function create_image_from_data($filename, $metadata) { - global $config; - $image = new Image(); - $info = ""; $fp = fopen($filename, "r"); $header = unpack("snull/stype/scount", fread($fp, 6)); diff --git a/ext/handle_ico/test.php b/ext/handle_ico/test.php index 956ad322..dd362055 100644 --- a/ext/handle_ico/test.php +++ b/ext/handle_ico/test.php @@ -6,8 +6,8 @@ class IcoHandlerTest extends ShimmieWebTestCase { $this->assert_response(302); $this->log_out(); - $raw = $this->get_page("post/view/$image_id"); // test for no crash - $raw = $this->get_page("get_ico/$image_id"); // test for no crash + $this->get_page("post/view/$image_id"); // test for no crash + $this->get_page("get_ico/$image_id"); // test for no crash $this->log_in_as_admin(); $this->delete_image($image_id); diff --git a/ext/handle_pixel/main.php b/ext/handle_pixel/main.php index 2dadfc34..0ee4ca69 100644 --- a/ext/handle_pixel/main.php +++ b/ext/handle_pixel/main.php @@ -14,22 +14,20 @@ class PixelFileHandler extends DataHandlerExtension { } protected function create_image_from_data(/*string*/ $filename, /*array*/ $metadata) { - global $config; - $image = new Image(); - $info = ""; - if(!($info = getimagesize($filename))) return null; + $info = getimagesize($filename); + if(!$info) return null; $image->width = $info[0]; $image->height = $info[1]; $image->filesize = $metadata['size']; - $image->hash = $metadata['hash']; + $image->hash = $metadata['hash']; $image->filename = (($pos = strpos($metadata['filename'],'?')) !== false) ? substr($metadata['filename'],0,$pos) : $metadata['filename']; - $image->ext = (($pos = strpos($metadata['extension'],'?')) !== false) ? substr($metadata['extension'],0,$pos) : $metadata['extension']; + $image->ext = (($pos = strpos($metadata['extension'],'?')) !== false) ? substr($metadata['extension'],0,$pos) : $metadata['extension']; $image->tag_array = Tag::explode($metadata['tags']); - $image->source = $metadata['source']; + $image->source = $metadata['source']; return $image; } @@ -52,9 +50,10 @@ class PixelFileHandler extends DataHandlerExtension { } protected function create_thumb_force(/*string*/ $hash) { + global $config; + $inname = warehouse_path("images", $hash); $outname = warehouse_path("thumbs", $hash); - global $config; $ok = false; @@ -165,7 +164,7 @@ class PixelFileHandler extends DataHandlerExtension { if($width > $height*5) $width = $height*5; if($height > $width*5) $height = $width*5; - $image = imagecreatefromstring($this->read_file($tmpname)); + $image = imagecreatefromstring(file_get_contents($tmpname)); $tsize = get_thumbnail_size($width, $height); $thumb = imagecreatetruecolor($tsize[0], $tsize[1]); @@ -176,16 +175,6 @@ class PixelFileHandler extends DataHandlerExtension { return $thumb; } } - - private function read_file(/*string*/ $fname) { - $fp = fopen($fname, "r"); - if(!$fp) return false; - - $data = fread($fp, filesize($fname)); - fclose($fp); - - return $data; - } // }}} } ?> diff --git a/ext/handle_pixel/script.js b/ext/handle_pixel/script.js index aa83fa16..8c3a50dd 100644 --- a/ext/handle_pixel/script.js +++ b/ext/handle_pixel/script.js @@ -15,26 +15,26 @@ $(function() { } }); -function zoom(zoom) { +function zoom(zoom_type) { var img = $('.shm-main-image'); - if(zoom == "full") { + if(zoom_type == "full") { img.css('max-width', img.data('width') + 'px'); img.css('max-height', img.data('height') + 'px'); } - if(zoom == "width") { + if(zoom_type == "width") { img.css('max-width', '95%'); img.css('max-height', img.data('height') + 'px'); } - if(zoom == "height") { + if(zoom_type == "height") { img.css('max-width', img.data('width') + 'px'); img.css('max-height', (window.innerHeight * 0.95) + 'px'); } - if(zoom == "both") { + if(zoom_type == "both") { img.css('max-width', '95%'); img.css('max-height', (window.innerHeight * 0.95) + 'px'); } - $(".shm-zoomer").val(zoom); + $(".shm-zoomer").val(zoom_type); - $.cookie("ui-image-zoom", zoom, {path: '/', expires: 365}); + $.cookie("ui-image-zoom", zoom_type, {path: '/', expires: 365}); } diff --git a/ext/handle_svg/main.php b/ext/handle_svg/main.php index 25f47015..76b9a18d 100644 --- a/ext/handle_svg/main.php +++ b/ext/handle_svg/main.php @@ -10,7 +10,6 @@ class SVGFileHandler extends Extension { public function onDataUpload(DataUploadEvent $event) { if($this->supported_ext($event->type) && $this->check_contents($event->tmpname)) { $hash = $event->hash; - $ha = substr($hash, 0, 2); if(!move_upload_to_archive($event)) return; send_event(new ThumbnailGenerationEvent($event->hash, $event->type)); $image = $this->create_image_from_data(warehouse_path("images", $hash), $event->metadata); @@ -27,7 +26,6 @@ class SVGFileHandler extends Extension { global $config; if($this->supported_ext($event->type)) { $hash = $event->hash; - $ha = substr($hash, 0, 2); copy("ext/handle_svg/thumb.jpg", warehouse_path("thumbs", $hash)); } @@ -88,7 +86,7 @@ class SVGFileHandler extends Extension { class MiniSVGParser { var $valid=false, $width=0, $height=0; - function MiniSVGParser($file) { + function __construct($file) { $xml_parser = xml_parser_create(); xml_set_element_handler($xml_parser, array($this, "startElement"), array($this, "endElement")); $this->valid = xml_parse($xml_parser, file_get_contents($file), true); diff --git a/ext/handle_video/theme.php b/ext/handle_video/theme.php index c58dd6e5..3e584ce3 100644 --- a/ext/handle_video/theme.php +++ b/ext/handle_video/theme.php @@ -31,6 +31,9 @@ else { "; } + else { + $html = "Video type '$ext' not recognised"; + } $page->add_block(new Block("Video", $html, "main", 10)); } } diff --git a/ext/image/main.php b/ext/image/main.php index d2553606..32d1bf97 100644 --- a/ext/image/main.php +++ b/ext/image/main.php @@ -20,9 +20,9 @@ class ImageAdditionEvent extends Event { * this new image. * * @sa TagSetEvent - * @param $image The new image to add. + * @param $image Image The new image to add. */ - public function ImageAdditionEvent(Image $image) { + public function __construct(Image $image) { $this->image = $image; } } @@ -46,9 +46,9 @@ class ImageDeletionEvent extends Event { * Used by things like tags and comments handlers to * clean out related rows in their tables. * - * @param $image The image being deleted + * @param $image Image The image being deleted */ - public function ImageDeletionEvent(Image $image) { + public function __construct(Image $image) { $this->image = $image; } } @@ -70,7 +70,7 @@ class ImageReplaceEvent extends Event { * @param $image * The image object of the new image to use */ - public function ImageReplaceEvent(/*int*/ $id, Image $image) { + public function __construct(/*int*/ $id, Image $image) { $this->id = $id; $this->image = $image; } @@ -93,10 +93,11 @@ class ThumbnailGenerationEvent extends Event { /** * Request a thumbnail be made for an image object * - * @param $hash The unique hash of the image - * @param $type The type of the image + * @param $hash string The unique hash of the image + * @param $type string The type of the image + * @param $force boolean Regenerate the thumbnail even if one already exists */ - public function ThumbnailGenerationEvent($hash, $type, $force=false) { + public function __construct($hash, $type, $force=false) { $this->hash = $hash; $this->type = $type; $this->force = $force; @@ -113,7 +114,7 @@ class ThumbnailGenerationEvent extends Event { class ParseLinkTemplateEvent extends Event { var $link, $original, $image; - public function ParseLinkTemplateEvent($link, Image $image) { + public function __construct($link, Image $image) { $this->link = $link; $this->original = $link; $this->image = $image; @@ -223,9 +224,6 @@ class ImageIO extends Extension { } public function onUserPageBuilding(UserPageBuildingEvent $event) { - global $user; - global $config; - $u_id = url_escape($event->display_user->id); $i_image_count = Image::count_images(array("user_id={$event->display_user->id}")); $i_days_old = ((time() - strtotime($event->display_user->join_date)) / 86400) + 1; @@ -279,7 +277,7 @@ class ImageIO extends Extension { // add image {{{ - private function add_image($image) { + private function add_image(Image $image) { global $page, $user, $database, $config; /* @@ -325,7 +323,7 @@ class ImageIO extends Extension { )", array( "owner_id"=>$user->id, "owner_ip"=>$_SERVER['REMOTE_ADDR'], "filename"=>substr($image->filename, 0, 60), "filesize"=>$image->filesize, - "hash"=>$image->hash, "ext"=>$image->ext, "width"=>$image->width, "height"=>$image->height, "source"=>$image->source + "hash"=>$image->hash, "ext"=>strtolower($image->ext), "width"=>$image->width, "height"=>$image->height, "source"=>$image->source ) ); $image->id = $database->get_last_insert_id('images_id_seq'); @@ -401,11 +399,8 @@ class ImageIO extends Extension { // replace image {{{ private function replace_image($id, $image) { - global $page; - global $user; global $database; - global $config; - + /* Check to make sure the image exists. */ $existing = Image::by_id($id); @@ -435,7 +430,7 @@ class ImageIO extends Extension { ", array( "filename"=>$image->filename, "filesize"=>$image->filesize, "hash"=>$image->hash, - "ext"=>$image->ext, "width"=>$image->width, "height"=>$image->height, "source"=>$image->source, + "ext"=>strtolower($image->ext), "width"=>$image->width, "height"=>$image->height, "source"=>$image->source, "id"=>$id ) ); diff --git a/ext/image_hash_ban/main.php b/ext/image_hash_ban/main.php index 513ee1cc..410f0b41 100644 --- a/ext/image_hash_ban/main.php +++ b/ext/image_hash_ban/main.php @@ -13,7 +13,7 @@ class RemoveImageHashBanEvent extends Event { var $hash; - public function RemoveImageHashBanEvent($hash) { + public function __construct($hash) { $this->hash = $hash; } } @@ -23,7 +23,7 @@ class AddImageHashBanEvent extends Event { var $hash; var $reason; - public function AddImageHashBanEvent($hash, $reason) { + public function __construct($hash, $reason) { $this->hash = $hash; $this->reason = $reason; } @@ -36,7 +36,7 @@ class ImageBan extends Extension { $database->create_table("image_bans", " id SCORE_AIPK, hash CHAR(32) NOT NULL, - date DATETIME DEFAULT SCORE_NOW, + date SCORE_DATETIME DEFAULT SCORE_NOW, reason TEXT NOT NULL "); $config->set_int("ext_imageban_version", 1); diff --git a/ext/image_hash_ban/theme.php b/ext/image_hash_ban/theme.php index 5afd92b1..87c70cb1 100644 --- a/ext/image_hash_ban/theme.php +++ b/ext/image_hash_ban/theme.php @@ -22,7 +22,6 @@ class ImageBanTheme extends Themelet { */ public function display_image_hash_bans(Page $page, $page_number, $page_count, $bans) { $h_bans = ""; - $n = 0; foreach($bans as $ban) { $h_bans .= " diff --git a/ext/index/main.php b/ext/index/main.php index a251f484..e2664883 100644 --- a/ext/index/main.php +++ b/ext/index/main.php @@ -94,6 +94,10 @@ *
  • order=width -- find all images sorted from highest > lowest width *
  • order=filesize_asc -- find all images sorted from lowest > highest filesize * + *
  • order=random_####, eg + *
      + *
    • order=random_8547 -- find all images sorted randomly using 8547 as a seed + *
    * *

    Search items can be combined to search for images which match both, * or you can stick "-" in front of an item to search for things that don't @@ -159,7 +163,7 @@ class SearchTermParseEvent extends Event { var $context = null; var $querylets = array(); - public function SearchTermParseEvent($term, $context) { + public function __construct($term, $context) { $this->term = $term; $this->context = $context; } @@ -362,7 +366,15 @@ class Index extends Extension { $ord = strtolower($matches[1]); $default_order_for_column = preg_match("/^(id|filename)$/", $matches[1]) ? "ASC" : "DESC"; $sort = isset($matches[2]) ? strtoupper($matches[2]) : $default_order_for_column; - $order_sql = "$ord $sort"; + $order_sql = "images.$ord $sort"; + $event->add_querylet(new Querylet("1=1")); //small hack to avoid metatag being treated as normal tag + } + else if(preg_match("/^order[=|:]random[_]([0-9]{1,4})$/i", $event->term, $matches)){ + global $order_sql; + //order[=|:]random requires a seed to avoid duplicates + //since the tag can't be changed during the parseevent, we instead generate the seed during submit using js + $seed = $matches[1]; + $order_sql = "RAND($seed)"; $event->add_querylet(new Querylet("1=1")); //small hack to avoid metatag being treated as normal tag } diff --git a/ext/index/script.js b/ext/index/script.js index f90bc95e..6842ef34 100644 --- a/ext/index/script.js +++ b/ext/index/script.js @@ -17,6 +17,18 @@ $(function() { function() {$('.shm-image-list').show();} ); } + + //Generate a random seed when using order:random + $('form > input[placeholder="Search"]').parent().submit(function(e){ + var input = $('form > input[placeholder="Search"]'); + var tagArr = input.val().split(" "); + + var rand = (($.inArray("order:random", tagArr) + 1) || ($.inArray("order=random", tagArr) + 1)) - 1; + if(rand !== -1){ + tagArr[rand] = "order:random_"+Math.floor((Math.random()*9999)+1); + input.val(tagArr.join(" ")); + } + }); }); function select_blocked_tags() { diff --git a/ext/index/theme.php b/ext/index/theme.php index 0b7f5ee5..7c04910b 100644 --- a/ext/index/theme.php +++ b/ext/index/theme.php @@ -1,6 +1,8 @@ page_number = $page_number; $this->total_pages = $total_pages; diff --git a/ext/ipban/main.php b/ext/ipban/main.php index ec4aa693..c566f47a 100644 --- a/ext/ipban/main.php +++ b/ext/ipban/main.php @@ -16,7 +16,7 @@ class RemoveIPBanEvent extends Event { var $id; - public function RemoveIPBanEvent($id) { + public function __construct($id) { $this->id = $id; } } @@ -27,7 +27,7 @@ class AddIPBanEvent extends Event { var $reason; var $end; - public function AddIPBanEvent(/*string(ip)*/ $ip, /*string*/ $reason, /*string*/ $end) { + public function __construct(/*string(ip)*/ $ip, /*string*/ $reason, /*string*/ $end) { $this->ip = trim($ip); $this->reason = trim($reason); $this->end = trim($end); @@ -130,8 +130,8 @@ class IPBan extends Extension { $database->Execute("CREATE TABLE bans ( id int(11) NOT NULL auto_increment, ip char(15) default NULL, - date datetime default NULL, - end datetime default NULL, + date SCORE_DATETIME default NULL, + end SCORE_DATETIME default NULL, reason varchar(255) default NULL, PRIMARY KEY (id) )"); diff --git a/ext/ipban/theme.php b/ext/ipban/theme.php index b6f46b16..e9e927b6 100644 --- a/ext/ipban/theme.php +++ b/ext/ipban/theme.php @@ -14,7 +14,6 @@ class IPBanTheme extends Themelet { public function display_bans(Page $page, $bans) { global $database, $user; $h_bans = ""; - $n = 0; $prefix = ($database->get_driver_name() == "sqlite" ? "bans." : ""); $prefix2 = ($database->get_driver_name() == "sqlite" ? "users." : ""); foreach($bans as $ban) { diff --git a/ext/link_image/theme.php b/ext/link_image/theme.php index 1e5d2196..24de94dc 100644 --- a/ext/link_image/theme.php +++ b/ext/link_image/theme.php @@ -62,7 +62,7 @@ class LinkImageTheme extends Themelet { $text = "[url=".$url."]".$content."[/url]"; break; default: - $text = $link." - ".$content; + $text = $url." - ".$content; } return $text; } diff --git a/ext/livefeed/main.php b/ext/livefeed/main.php index 3ce78f83..804b57e6 100644 --- a/ext/livefeed/main.php +++ b/ext/livefeed/main.php @@ -63,6 +63,7 @@ class LiveFeed extends Extension { fwrite($fp, "$data\n"); fclose($fp); } catch (Exception $e) { + /* logging errors shouldn't break everything */ } } } diff --git a/ext/log_db/theme.php b/ext/log_db/theme.php index a10dd838..77705826 100644 --- a/ext/log_db/theme.php +++ b/ext/log_db/theme.php @@ -40,7 +40,6 @@ class LogDatabaseTheme extends Themelet { \n"; - $n = 0; reset($events); // rewind to first element in array. foreach($events as $event) { diff --git a/ext/log_net/main.php b/ext/log_net/main.php index 56ee4c9e..f82d01d3 100644 --- a/ext/log_net/main.php +++ b/ext/log_net/main.php @@ -42,6 +42,7 @@ class LogNet extends Extension { fwrite($fp, "$data\n"); fclose($fp); } catch (Exception $e) { + /* logging errors shouldn't break everything */ } } } diff --git a/ext/mass_tagger/main.php b/ext/mass_tagger/main.php index 03a08c50..2216699b 100644 --- a/ext/mass_tagger/main.php +++ b/ext/mass_tagger/main.php @@ -53,6 +53,7 @@ class MassTagger extends Extension { } $page->set_mode("redirect"); + if(!isset($_SERVER['HTTP_REFERER'])) $_SERVER['HTTP_REFERER'] = make_link(); $page->set_redirect($_SERVER['HTTP_REFERER']); } } diff --git a/ext/not_a_tag/main.php b/ext/not_a_tag/main.php index 0aa72f19..5dcb41fc 100644 --- a/ext/not_a_tag/main.php +++ b/ext/not_a_tag/main.php @@ -29,7 +29,7 @@ class NotATag extends Extension { } private function scan(/*array*/ $tags_mixed) { - global $config, $database; + global $database; $tags = array(); foreach($tags_mixed as $tag) $tags[] = strtolower($tag); @@ -53,12 +53,12 @@ class NotATag extends Extension { } public function onPageRequest(PageRequestEvent $event) { - global $config, $database, $page, $user; + global $database, $page, $user; if($event->page_matches("untag")) { if($user->can("ban_image")) { if($event->get_arg(0) == "add") { - $tag = isset($_POST["tag"]) ? $_POST["tag"] : $image->tag; + $tag = $_POST["tag"]; $redirect = isset($_POST['redirect']) ? $_POST['redirect'] : "DNP"; $database->Execute( diff --git a/ext/not_a_tag/theme.php b/ext/not_a_tag/theme.php index 993bd0dc..543af6f5 100644 --- a/ext/not_a_tag/theme.php +++ b/ext/not_a_tag/theme.php @@ -2,7 +2,6 @@ class NotATagTheme extends Themelet { public function display_untags(Page $page, $page_number, $page_count, $bans) { $h_bans = ""; - $n = 0; foreach($bans as $ban) { $h_bans .= " diff --git a/ext/notes/main.php b/ext/notes/main.php index 9f73dce4..cfbb6259 100644 --- a/ext/notes/main.php +++ b/ext/notes/main.php @@ -20,7 +20,7 @@ class Notes extends Extension { image_id INTEGER NOT NULL, user_id INTEGER NOT NULL, user_ip CHAR(15) NOT NULL, - date DATETIME NOT NULL, + date SCORE_DATETIME NOT NULL, x1 INTEGER NOT NULL, y1 INTEGER NOT NULL, height INTEGER NOT NULL, @@ -35,7 +35,7 @@ class Notes extends Extension { id SCORE_AIPK, image_id INTEGER NOT NULL, user_id INTEGER NOT NULL, - date DATETIME NOT NULL, + date SCORE_DATETIME NOT NULL, FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE, FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE "); @@ -49,7 +49,7 @@ class Notes extends Extension { image_id INTEGER NOT NULL, user_id INTEGER NOT NULL, user_ip CHAR(15) NOT NULL, - date DATETIME NOT NULL, + date SCORE_DATETIME NOT NULL, x1 INTEGER NOT NULL, y1 INTEGER NOT NULL, height INTEGER NOT NULL, @@ -363,6 +363,8 @@ class Notes extends Extension { */ private function delete_note() { + global $user; + $imageID = int_escape($_POST["image_id"]); $noteID = int_escape($_POST["note_id"]); @@ -388,7 +390,7 @@ class Notes extends Extension { * HERE WE DELETE ALL NOTES FROM IMAGE */ private function nuke_notes() { - global $database; + global $database, $user; $image_id = int_escape($_POST["image_id"]); $database->execute("DELETE FROM notes WHERE image_id = ?", array($image_id)); log_info("notes", "Notes deleted from {$image_id} by {$user->name}"); @@ -400,7 +402,7 @@ class Notes extends Extension { * HERE WE DELETE ALL REQUESTS FOR IMAGE */ private function nuke_requests() { - global $database; + global $database, $user; $image_id = int_escape($_POST["image_id"]); $database->execute("DELETE FROM note_request WHERE image_id = ?", array($image_id)); @@ -588,7 +590,6 @@ class Notes extends Extension { $noteEnable = $history['note_enable']; $noteID = $history['note_id']; $imageID = $history['image_id']; - $userID = $user->id; $noteX1 = $history['x1']; $noteY1 = $history['y1']; $noteHeight = $history['height']; diff --git a/ext/notes/theme.php b/ext/notes/theme.php index c958c1e3..99359b92 100644 --- a/ext/notes/theme.php +++ b/ext/notes/theme.php @@ -1,6 +1,6 @@ Add a note -->

    @@ -39,32 +39,32 @@ class NotesTheme extends Themelet { $page->set_title(html_escape("Search Note")); $page->set_heading(html_escape("Search Note")); - $page->add_block(new Block("Search Note", $html, "main", 10)); + $page->add_block(new Block("Search Note", $html, "main", 10)); } - // check action POST on form + // check action POST on form public function display_note_system(Page $page, $image_id, $recovered_notes, $adminOptions) { $to_json = array(); - foreach($recovered_notes as $note) - { - $parsedNote = $note["note"]; - $parsedNote = str_replace("\n", "\\n", $parsedNote); - $parsedNote = str_replace("\r", "\\r", $parsedNote); + foreach($recovered_notes as $note) + { + $parsedNote = $note["note"]; + $parsedNote = str_replace("\n", "\\n", $parsedNote); + $parsedNote = str_replace("\r", "\\r", $parsedNote); - $to_json[] = array( + $to_json[] = array( 'x1' => $note["x1"], - 'y1' => $note["y1"], - 'height' => $note["height"], - 'width' => $note["width"], - 'note' => $parsedNote, - 'note_id' => $note["id"], + 'y1' => $note["y1"], + 'height' => $note["height"], + 'width' => $note["width"], + 'note' => $parsedNote, + 'note_id' => $note["id"], ); - } + } $html = " + $html .= "
    ".make_form(make_link("note/add_note"))." @@ -88,41 +88,41 @@ class NotesTheme extends Themelet {
    -
    +
    ".make_form(make_link("note/edit_note"))." - - - - - - - - - - - - - - -
    - -
    - "; + + + + + + + + + + + + + + +
    + +
    + "; - if($adminOptions) - $html .= " + if($adminOptions) + $html .= " ".make_form(make_link("note/delete_note"))." - - - - - - -
    - + + + + + + +
    + "; - $html .= "
    "; + $html .= "
    "; $page->add_block(new Block(null, $html, "main", 1)); } @@ -169,101 +169,71 @@ class NotesTheme extends Themelet { $page->set_heading("Note Requests"); $page->add_block(new Block("Note Requests", $pool_images, "main", 20)); } - - public function display_histories($histories, $pageNumber, $totalPages) { - global $user, $page; - + + private function get_history($histories) { + global $user; + $html = "". - "". - "". - "". - "". - "". - ""; - - + "". + "". + "". + "". + "". + ""; + if(!$user->is_anonymous()){ $html .= ""; } - + $html .= "". - ""; - - $n = 0; + ""; + foreach($histories as $history) { $image_link = "".$history['image_id'].""; $history_link = "".$history['note_id'].".".$history['review_id'].""; $user_link = "".$history['user_name'].""; $revert_link = "Revert"; - + $html .= "". - "". - "". - "". - "". - ""; - + "". + "". + "". + "". + ""; + if(!$user->is_anonymous()){ $html .= ""; } - + } - + $html .= "
    ImageNoteBodyUpdaterDate
    ImageNoteBodyUpdaterDateAction
    ".$image_link."".$history_link."".$history['note']."".$user_link."".autodate($history['date'])."".$image_link."".$history_link."".$history['note']."".$user_link."".autodate($history['date'])."".$revert_link."
    "; - + + return $html; + } + + public function display_histories($histories, $pageNumber, $totalPages) { + global $page; + + $html = $this->get_history($histories); + $page->set_title("Note Updates"); $page->set_heading("Note Updates"); $page->add_block(new Block("Note Updates", $html, "main", 10)); - + $this->display_paginator($page, "note/updated", null, $pageNumber, $totalPages); } public function display_history($histories, $pageNumber, $totalPages) { - global $user, $page; - - $html = "". - "". - "". - "". - "". - "". - ""; - - - if(!$user->is_anonymous()){ - $html .= ""; - } - - $html .= "". - ""; - - $n = 0; - foreach($histories as $history) { - $image_link = "".$history['image_id'].""; - $history_link = "".$history['note_id'].".".$history['review_id'].""; - $user_link = "".$history['user_name'].""; - $revert_link = "Revert"; - - $html .= "". - "". - "". - "". - "". - ""; - - if(!$user->is_anonymous()){ - $html .= ""; - } - - } - - $html .= "
    ImageNoteBodyUpdaterDateAction
    ".$image_link."".$history_link."".$history['note']."".$user_link."".autodate($history['date'])."".$revert_link."
    "; - + global $page; + + $html = $this->get_history($histories); + $page->set_title("Note History"); $page->set_heading("Note History"); $page->add_block(new Block("Note History", $html, "main", 10)); $this->display_paginator($page, "note/updated", null, $pageNumber, $totalPages); } -} +} ?> diff --git a/ext/numeric_score/main.php b/ext/numeric_score/main.php index 8f8cc980..e9a471f5 100644 --- a/ext/numeric_score/main.php +++ b/ext/numeric_score/main.php @@ -13,7 +13,7 @@ class NumericScoreSetEvent extends Event { var $image_id, $user, $score; - public function NumericScoreSetEvent(/*int*/ $image_id, User $user, /*int*/ $score) { + public function __construct(/*int*/ $image_id, User $user, /*int*/ $score) { $this->image_id = $image_id; $this->user = $user; $this->score = $score; @@ -237,7 +237,7 @@ class NumericScore extends Extension { global $order_sql; $default_order_for_column = "DESC"; $sort = isset($matches[3]) ? strtoupper($matches[3]) : $default_order_for_column; - $order_sql = "numeric_score $sort"; + $order_sql = "images.numeric_score $sort"; $event->add_querylet(new Querylet("1=1")); //small hack to avoid metatag being treated as normal tag } } diff --git a/ext/oekaki/main.php b/ext/oekaki/main.php index 42d06e10..6c114537 100644 --- a/ext/oekaki/main.php +++ b/ext/oekaki/main.php @@ -28,6 +28,7 @@ class Oekaki extends Extension { throw new UploadException("File has no extension"); } log_info("oekaki", "Processing file [{$pathinfo['filename']}]"); + $metadata = array(); $metadata['filename'] = 'oekaki.png'; $metadata['extension'] = $pathinfo['extension']; $metadata['tags'] = 'oekaki tagme'; diff --git a/ext/oekaki/theme.php b/ext/oekaki/theme.php index fccad46a..468c0bdb 100644 --- a/ext/oekaki/theme.php +++ b/ext/oekaki/theme.php @@ -9,7 +9,6 @@ class OekakiTheme extends Themelet { global $config, $page; $base_href = get_base_href(); - $http_base = make_http($base_href); $oekW = $config->get_int("oekaki_width", 400); $oekH = $config->get_int("oekaki_height", 400); diff --git a/ext/ouroboros_api/main.php b/ext/ouroboros_api/main.php index cbfb38ae..fa9ef5da 100644 --- a/ext/ouroboros_api/main.php +++ b/ext/ouroboros_api/main.php @@ -387,9 +387,11 @@ class OuroborosAPI extends Extension // @TODO Should move the validation logic into OuroborosPost instead? if ($user->can("create_image")) { $post = array( - 'tags' => !empty($_REQUEST['post']['tags']) ? filter_var( - urldecode($_REQUEST['post']['tags']), - FILTER_SANITIZE_STRING + 'tags' => !empty($_REQUEST['post']['tags']) ? Tag::implode( + array_map( + array('Tag', 'sanitise'), + Tag::explode(urldecode($_REQUEST['post']['tags'])) + ) ) : 'tagme', 'file' => !empty($_REQUEST['post']['file']) ? filter_var( $_REQUEST['post']['file'], diff --git a/ext/pm/main.php b/ext/pm/main.php index b18e0121..9cd781e7 100644 --- a/ext/pm/main.php +++ b/ext/pm/main.php @@ -11,12 +11,16 @@ */ class SendPMEvent extends Event { + var $pm; + public function __construct(PM $pm) { $this->pm = $pm; } } class PM { + var $id, $from_id, $from_ip, $to_id, $sent_date, $subject, $message, $is_read; + public function __construct($from_id=0, $from_ip="0.0.0.0", $to_id=0, $subject="A Message", $message="Some Text", $read=False) { # PHP: the P stands for "really", the H stands for "awful" and the other P stands for "language" if(is_array($from_id)) { @@ -53,7 +57,7 @@ class PrivMsg extends Extension { from_id INTEGER NOT NULL, from_ip SCORE_INET NOT NULL, to_id INTEGER NOT NULL, - sent_date DATETIME NOT NULL, + sent_date SCORE_DATETIME NOT NULL, subject VARCHAR(64) NOT NULL, message TEXT NOT NULL, is_read SCORE_BOOL NOT NULL DEFAULT SCORE_BOOL_N, diff --git a/ext/pm/theme.php b/ext/pm/theme.php index bf30302b..7b0f5be1 100644 --- a/ext/pm/theme.php +++ b/ext/pm/theme.php @@ -8,7 +8,6 @@ class PrivMsgTheme extends Themelet { "; - $n = 0; foreach($pms as $pm) { $h_subject = html_escape($pm->subject); if(strlen(trim($h_subject)) == 0) $h_subject = "(No subject)"; diff --git a/ext/pools/main.php b/ext/pools/main.php index dcd1b13c..9d8fa386 100644 --- a/ext/pools/main.php +++ b/ext/pools/main.php @@ -33,7 +33,7 @@ class Pools extends Extension { public SCORE_BOOL NOT NULL DEFAULT SCORE_BOOL_N, title VARCHAR(255) NOT NULL, description TEXT, - date DATETIME NOT NULL, + date SCORE_DATETIME NOT NULL, posts INTEGER NOT NULL DEFAULT 0, FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE "); @@ -51,7 +51,7 @@ class Pools extends Extension { action INTEGER NOT NULL, images TEXT, count INTEGER NOT NULL DEFAULT 0, - date DATETIME NOT NULL, + date SCORE_DATETIME NOT NULL, FOREIGN KEY (pool_id) REFERENCES pools(id) ON UPDATE CASCADE ON DELETE CASCADE, FOREIGN KEY (user_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE CASCADE "); diff --git a/ext/pools/theme.php b/ext/pools/theme.php index b31be49e..fd25d431 100644 --- a/ext/pools/theme.php +++ b/ext/pools/theme.php @@ -12,7 +12,6 @@ class PoolsTheme extends Themelet { } public function get_adder_html(Image $image, /*array*/ $pools) { - $editor = ""; $h = ""; foreach($pools as $pool) { $h .= ""; @@ -43,8 +42,6 @@ class PoolsTheme extends Themelet { '; - $n = 0; - // Build up the list of pools. foreach($pools as $pool) { $pool_link = ''.html_escape($pool['title']).""; @@ -133,7 +130,6 @@ class PoolsTheme extends Themelet { '; - $n = 0; foreach($pools as $pool) { $pool_info .= "". "". @@ -303,15 +299,15 @@ class PoolsTheme extends Themelet { $this->display_top($pools, "Sorting Pool"); $pool_images = "\n"; - $n = 0; + $i = 0; foreach($images as $pair) { $image = $pair[0]; $thumb_html = $this->build_thumb_html($image); $pool_images .= ''."\n".$thumb_html."\n". - '
    '. - ''. + '
    '. + ''. '
    '; - $n++; + $i++; } $pool_images .= "
    ". @@ -382,7 +378,6 @@ class PoolsTheme extends Themelet { '; - $n = 0; foreach($histories as $history) { $pool_link = "".html_escape($history['title']).""; $user_link = "".html_escape($history['user_name']).""; diff --git a/ext/rating/main.php b/ext/rating/main.php index 1b41b89f..eda01145 100644 --- a/ext/rating/main.php +++ b/ext/rating/main.php @@ -22,7 +22,7 @@ class RatingSetEvent extends Event { var $image, $rating; - public function RatingSetEvent(Image $image, /*char*/ $rating) { + public function __construct(Image $image, /*char*/ $rating) { assert(in_array($rating, array("s", "q", "e", "u"))); $this->image = $image; $this->rating = $rating; diff --git a/ext/rating/theme.php b/ext/rating/theme.php index bc95ea70..3e9437a6 100644 --- a/ext/rating/theme.php +++ b/ext/rating/theme.php @@ -2,7 +2,6 @@ class RatingsTheme extends Themelet { public function get_rater_html(/*int*/ $image_id, /*string*/ $rating) { - $i_image_id = int_escape($image_id); $s_checked = $rating == 's' ? " checked" : ""; $q_checked = $rating == 'q' ? " checked" : ""; $e_checked = $rating == 'e' ? " checked" : ""; diff --git a/ext/report_image/main.php b/ext/report_image/main.php index 16980169..a21a0581 100644 --- a/ext/report_image/main.php +++ b/ext/report_image/main.php @@ -12,7 +12,7 @@ class RemoveReportedImageEvent extends Event { var $id; - public function RemoveReportedImageEvent($id) { + public function __construct($id) { $this->id = $id; } } @@ -22,7 +22,7 @@ class AddReportedImageEvent extends Event { var $image_id; var $reason; - public function AddReportedImageEvent($image_id, $reporter_id, $reason) { + public function __construct($image_id, $reporter_id, $reason) { $this->reporter_id = $reporter_id; $this->image_id = $image_id; $this->reason = $reason; diff --git a/ext/report_image/theme.php b/ext/report_image/theme.php index 4e3afb9c..b62fd02a 100644 --- a/ext/report_image/theme.php +++ b/ext/report_image/theme.php @@ -15,7 +15,6 @@ class ReportImageTheme extends Themelet { global $config; $h_reportedimages = ""; - $n = 0; foreach($reports as $report) { $image = $report['image']; $h_reason = format_text($report['reason']); diff --git a/ext/resize/main.php b/ext/resize/main.php index 1bd7e146..705980eb 100644 --- a/ext/resize/main.php +++ b/ext/resize/main.php @@ -84,7 +84,7 @@ class ResizeImage extends Extension { } if($isanigif == 0){ try { - $this->resize_image($event->image_id, $width, $height); + $this->resize_image($image_obj, $width, $height); } catch (ImageResizeException $e) { $this->theme->display_resize_error($page, "Error Resizing", $e->error); } @@ -107,7 +107,7 @@ class ResizeImage extends Extension { // Try to get the image ID $image_id = int_escape($event->get_arg(0)); if (empty($image_id)) { - $image_id = isset($_POST['image_id']) ? $_POST['image_id'] : null; + $image_id = isset($_POST['image_id']) ? int_escape($_POST['image_id']) : null; } if (empty($image_id)) { throw new ImageResizeException("Can not resize Image: No valid Image ID given."); @@ -134,7 +134,7 @@ class ResizeImage extends Extension { /* Attempt to resize the image */ try { - $this->resize_image($image_id, $width, $height); + $this->resize_image($image, $width, $height); //$this->theme->display_resize_page($page, $image_id); @@ -157,19 +157,14 @@ class ResizeImage extends Extension { This function could be made much smaller by using the ImageReplaceEvent ie: Pretend that we are replacing the image with a resized copy. */ - private function resize_image(/*int*/ $image_id, /*int*/ $width, /*int*/ $height) { + private function resize_image(Image $image_obj, /*int*/ $width, /*int*/ $height) { global $config, $user, $page, $database; if ( ($height <= 0) && ($width <= 0) ) { throw new ImageResizeException("Invalid options for height and width. ($width x $height)"); } - $image_obj = Image::by_id($image_id); $hash = $image_obj->hash; - if (is_null($hash)) { - throw new ImageResizeException("Image does not have a hash associated with it."); - } - $image_filename = warehouse_path("images", $hash); $info = getimagesize($image_filename); /* Get the image file type */ @@ -177,7 +172,7 @@ class ResizeImage extends Extension { $filetype = strtolower($pathinfo['extension']); if (($image_obj->width != $info[0] ) || ($image_obj->height != $info[1])) { - throw new ImageResizeException("The image size does not match what is in the database! - Aborting Resize."); + throw new ImageResizeException("The current image size does not match what is set in the database! - Aborting Resize."); } /* @@ -192,7 +187,18 @@ class ResizeImage extends Extension { The factor of 2.5 is simply a rough guideline. http://stackoverflow.com/questions/527532/reasonable-php-memory-limit-for-image-resize */ - $memory_use = ($info[0] * $info[1] * ($info['bits'] / 8) * $info['channels'] * 2.5) / 1024; + + if (isset($info['bits']) && isset($info['channels'])) + { + $memory_use = ($info[0] * $info[1] * ($info['bits'] / 8) * $info['channels'] * 2.5) / 1024; + } else { + // + // If we don't have bits and channel info from the image then assume default values + // of 8 bits per color and 4 channels (R,G,B,A) -- ie: regular 24-bit color + // + $memory_use = ($info[0] * $info[1] * 1 * 4 * 2.5) / 1024; + } + $memory_limit = get_memory_limit(); if ($memory_use > $memory_limit) { @@ -219,28 +225,41 @@ class ResizeImage extends Extension { case IMAGETYPE_JPEG: $image = imagecreatefromjpeg($image_filename); break; case IMAGETYPE_PNG: $image = imagecreatefrompng($image_filename); break; default: - throw new ImageResizeException("Unsupported image type."); + throw new ImageResizeException("Unsupported image type (Only GIF, JPEG, and PNG are supported)."); } - /* Resize and resample the image */ + // Handle transparent images + $image_resized = imagecreatetruecolor( $new_width, $new_height ); - if ( ($info[2] == IMAGETYPE_GIF) || ($info[2] == IMAGETYPE_PNG) ) { - $transparency = imagecolortransparent($image); + if ($info[2] == IMAGETYPE_GIF) { + $transparency = imagecolortransparent($image); - if ($transparency >= 0) { - $transparent_color = imagecolorsforindex($image, $trnprt_indx); - $transparency = imagecolorallocate($image_resized, $trnprt_color['red'], $trnprt_color['green'], $trnprt_color['blue']); - imagefill($image_resized, 0, 0, $transparency); - imagecolortransparent($image_resized, $transparency); - } - elseif ($info[2] == IMAGETYPE_PNG) { + // If we have a specific transparent color + if ($transparency >= 0) { + // Get the original image's transparent color's RGB values + $transparent_color = imagecolorsforindex($image, $transparency); + + // Allocate the same color in the new image resource + $transparency = imagecolorallocate($image_resized, $transparent_color['red'], $transparent_color['green'], $transparent_color['blue']); + + // Completely fill the background of the new image with allocated color. + imagefill($image_resized, 0, 0, $transparency); + + // Set the background color for new image to transparent + imagecolortransparent($image_resized, $transparency); + } + } elseif ($info[2] == IMAGETYPE_PNG) { + // + // More info here: http://stackoverflow.com/questions/279236/how-do-i-resize-pngs-with-transparency-in-php + // imagealphablending($image_resized, false); - $color = imagecolorallocatealpha($image_resized, 0, 0, 0, 127); - imagefill($image_resized, 0, 0, $color); imagesavealpha($image_resized, true); - } + $transparent_color = imagecolorallocatealpha($image_resized, 255, 255, 255, 127); + imagefilledrectangle($image_resized, 0, 0, $new_width, $new_height, $transparent_color); } + + // Actually resize the image. imagecopyresampled($image_resized, $image, 0, 0, 0, 0, $new_width, $new_height, $image_obj->width, $image_obj->height); /* Temp storage while we resize */ @@ -255,7 +274,7 @@ class ResizeImage extends Extension { case IMAGETYPE_JPEG: imagejpeg($image_resized, $tmp_filename); break; case IMAGETYPE_PNG: imagepng($image_resized, $tmp_filename); break; default: - throw new ImageResizeException("Unsupported image type."); + throw new ImageResizeException("Failed to save the new image - Unsupported image type."); } /* Move the new image into the main storage location */ @@ -286,11 +305,11 @@ class ResizeImage extends Extension { ", array( "filename"=>$new_filename, "filesize"=>$new_size, "hash"=>$new_hash, - "width"=>$new_width, "height"=>$new_height, "id"=>$image_id + "width"=>$new_width, "height"=>$new_height, "id"=>$image_obj->id ) ); - log_info("resize", "Resized Image #{$image_id} - New hash: {$new_hash}"); + log_info("resize", "Resized Image #{$image_obj->id} - New hash: {$new_hash}"); } } ?> diff --git a/ext/resize/theme.php b/ext/resize/theme.php index 2dfa11c2..e19a8e32 100644 --- a/ext/resize/theme.php +++ b/ext/resize/theme.php @@ -7,7 +7,6 @@ class ResizeImageTheme extends Themelet { public function get_resize_html(Image $image) { global $user, $config; - $i_image_id = int_escape($image->id); $default_width = $config->get_int('resize_default_width'); $default_height = $config->get_int('resize_default_height'); diff --git a/ext/rotate/theme.php b/ext/rotate/theme.php index d29bb172..ddef58c7 100644 --- a/ext/rotate/theme.php +++ b/ext/rotate/theme.php @@ -7,8 +7,6 @@ class RotateImageTheme extends Themelet { public function get_rotate_html(/*int*/ $image_id) { global $user, $config; - $i_image_id = int_escape($image_id); - $html = " ".make_form(make_link('rotate/'.$image_id), 'POST')." diff --git a/ext/setup/main.php b/ext/setup/main.php index e9fc3249..d6c0cd45 100644 --- a/ext/setup/main.php +++ b/ext/setup/main.php @@ -14,7 +14,7 @@ class ConfigSaveEvent extends Event { var $config; - public function ConfigSaveEvent(Config $config) { + public function __construct(Config $config) { $this->config = $config; } } @@ -26,7 +26,7 @@ class ConfigSaveEvent extends Event { class SetupBuildingEvent extends Event { var $panel; - public function SetupBuildingEvent(SetupPanel $panel) { + public function __construct(SetupPanel $panel) { $this->panel = $panel; } } @@ -49,10 +49,11 @@ class SetupBlock extends Block { var $header; var $body; - public function SetupBlock($title) { + public function __construct($title) { $this->header = $title; $this->section = "main"; $this->position = 50; + $this->body = ""; } public function add_label($text) { diff --git a/ext/setup/theme.php b/ext/setup/theme.php index 6d67d1de..3bad7007 100644 --- a/ext/setup/theme.php +++ b/ext/setup/theme.php @@ -23,7 +23,6 @@ class SetupTheme extends Themelet { */ $setupblock_html = ""; foreach($panel->blocks as $block) { - $html = $this->sb_to_html($block); $setupblock_html .= $this->sb_to_html($block); } @@ -44,12 +43,10 @@ class SetupTheme extends Themelet { global $user; $h_rows = ""; - $n = 0; ksort($options); foreach($options as $name => $value) { $h_name = html_escape($name); $h_value = html_escape($value); - $len = strlen($h_value); $h_box = ""; if(strpos($value, "\n") > 0) { diff --git a/ext/simpletest/main.php b/ext/simpletest/main.php index 116a7ff7..523204cb 100644 --- a/ext/simpletest/main.php +++ b/ext/simpletest/main.php @@ -207,7 +207,7 @@ class ShimmieWebTestCase extends SCoreWebTestCase { /** @private */ class TestFinder extends TestSuite { - function TestFinder($hint) { + function __construct($hint) { if(strpos($hint, "..") !== FALSE) return; // Select the test cases for "All" extensions. diff --git a/ext/simpletest/theme.php b/ext/simpletest/theme.php index de1573ea..4ed982d9 100644 --- a/ext/simpletest/theme.php +++ b/ext/simpletest/theme.php @@ -10,7 +10,7 @@ class SCoreWebReporter extends HtmlReporter { var $fails; var $exceptions; - public function SCoreReporter(Page $page) { + public function __construct(Page $page) { $this->page = $page; $this->fails = 0; $this->exceptions = 0; diff --git a/ext/sitemap/main.php b/ext/sitemap/main.php index 33e7e566..3044ffe7 100644 --- a/ext/sitemap/main.php +++ b/ext/sitemap/main.php @@ -63,7 +63,7 @@ class XMLSitemap extends Extension { { global $database, $config; // add index - $index[0] = $base_href = $config->get_string("front_page"); + $index[0] = $config->get_string("front_page"); $this->add_sitemap_queue($index, "weekly", "1"); /* --- Add 20 most used tags --- */ @@ -162,4 +162,4 @@ class XMLSitemap extends Extension { $page->set_data($xml); } } -?> \ No newline at end of file +?> diff --git a/ext/source_history/main.php b/ext/source_history/main.php index cc4debfd..366ea7cf 100644 --- a/ext/source_history/main.php +++ b/ext/source_history/main.php @@ -93,7 +93,7 @@ class Source_History extends Extension { user_id INTEGER NOT NULL, user_ip SCORE_INET NOT NULL, source TEXT NOT NULL, - date_set DATETIME NOT NULL, + date_set SCORE_DATETIME NOT NULL, FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE, FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE "); @@ -351,7 +351,7 @@ class Source_History extends Extension { } // add a history entry - $row = $database->execute(" + $database->execute(" INSERT INTO source_histories(image_id, source, user_id, user_ip, date_set) VALUES (?, ?, ?, ?, now())", array($image->id, $new_source, $user->id, $_SERVER['REMOTE_ADDR'])); diff --git a/ext/tag_categories/main.php b/ext/tag_categories/main.php index 4a5dcffa..80f62e88 100644 --- a/ext/tag_categories/main.php +++ b/ext/tag_categories/main.php @@ -48,6 +48,30 @@ class TagCategories extends Extension { } } + public function onSearchTermParse(SearchTermParseEvent $event) { + $matches = array(); + + if(preg_match("/^(.+)tags([:]?<|[:]?>|[:]?<=|[:]?>=|[:|=])([0-9]+)$/i", $event->term, $matches)) { + global $database; + $type = $matches[1]; + $cmp = ltrim($matches[2], ":") ?: "="; + $count = $matches[3]; + + $types = $database->get_col('SELECT category FROM image_tag_categories'); + if(in_array($type, $types)) { + $event->add_querylet( + new Querylet("EXISTS ( + SELECT 1 + FROM image_tags it + LEFT JOIN tags t ON it.tag_id = t.id + WHERE images.id = it.image_id + GROUP BY image_id + HAVING SUM(CASE WHEN t.tag LIKE '$type:%' THEN 1 ELSE 0 END) $cmp $count + )")); + } + } + } + public function getDict() { global $database; diff --git a/ext/tag_edit/main.php b/ext/tag_edit/main.php index 30867f84..eb58efe3 100644 --- a/ext/tag_edit/main.php +++ b/ext/tag_edit/main.php @@ -43,7 +43,7 @@ class OwnerSetEvent extends Event { var $image; var $owner; - public function OwnerSetEvent(Image $image, User $owner) { + public function __construct(Image $image, User $owner) { $this->image = $image; $this->owner = $owner; } @@ -60,7 +60,7 @@ class SourceSetEvent extends Event { var $image; var $source; - public function SourceSetEvent(Image $image, $source) { + public function __construct(Image $image, $source) { $this->image = $image; $this->source = $source; } @@ -77,7 +77,7 @@ class TagSetEvent extends Event { var $image; var $tags; - public function TagSetEvent(Image $image, $tags) { + public function __construct(Image $image, $tags) { $this->image = $image; $this->tags = Tag::explode($tags); } @@ -93,7 +93,7 @@ class LockSetEvent extends Event { var $image; var $locked; - public function LockSetEvent(Image $image, $locked) { + public function __construct(Image $image, $locked) { assert(is_bool($locked)); $this->image = $image; $this->locked = $locked; @@ -109,7 +109,7 @@ class TagTermParseEvent extends Event { var $id = null; var $metatag = false; - public function TagTermParseEvent($term, $id) { + public function __construct($term, $id) { $this->term = $term; $this->id = $id; } @@ -243,8 +243,8 @@ class TagEdit extends Extension { global $database; global $config; - $search_set = Tag::explode(strtolower($search)); - $replace_set = Tag::explode(strtolower($replace)); + $search_set = Tag::explode(strtolower($search), false); + $replace_set = Tag::explode(strtolower($replace), false); log_info("tag_edit", "Mass editing tags: '$search' -> '$replace'"); @@ -266,17 +266,19 @@ class TagEdit extends Extension { // search returns high-ids first, so we want to look // at images with lower IDs than the previous. $search_forward = $search_set; - if($last_id >= 0) $search_forward[] = "id<$last_id"; + $search_forward[] = "order=id_desc"; //Default order can be changed, so make sure we order high > low ID + if($last_id >= 0){ + $search_forward[] = "id<$last_id"; + } $images = Image::find_images(0, 100, $search_forward); if(count($images) == 0) break; foreach($images as $image) { // remove the search'ed tags - $before = $image->get_tag_array(); + $before = array_map('strtolower', $image->get_tag_array()); $after = array(); foreach($before as $tag) { - $tag = strtolower($tag); if(!in_array($tag, $search_set)) { $after[] = $tag; } diff --git a/ext/tag_editcloud/main.php b/ext/tag_editcloud/main.php index 4d2dacea..d74e061e 100644 --- a/ext/tag_editcloud/main.php +++ b/ext/tag_editcloud/main.php @@ -83,8 +83,9 @@ class TagEditCloud extends Extension { array("tag_min1" => $tags_min, "tag_min2" => $tags_min, "limit" => $max_count)); break; case 'r': - $relevant_tags = implode(",",array_map(array($database,"escape"),array_diff($image->get_tag_array(),$ignore_tags))); + $relevant_tags = array_diff($image->get_tag_array(),$ignore_tags); if(count($relevant_tags) > 0) { + $relevant_tags = implode(",",array_map(array($database,"escape"),$relevant_tags)); $tag_data = $database->get_all("SELECT t2.tag AS tag, COUNT(image_id) AS count, FLOOR(LN(LN(COUNT(image_id) - :tag_min1 + 1)+1)*150)/200 AS scaled FROM image_tags it1 JOIN image_tags it2 USING(image_id) JOIN tags t1 ON it1.tag_id = t1.id JOIN tags t2 ON it2.tag_id = t2.id WHERE t1.count >= :tag_min2 AND t1.tag IN($relevant_tags) GROUP BY t2.tag ORDER BY count DESC LIMIT :limit", diff --git a/ext/tag_history/main.php b/ext/tag_history/main.php index fd62a41a..9550215f 100644 --- a/ext/tag_history/main.php +++ b/ext/tag_history/main.php @@ -93,7 +93,7 @@ class Tag_History extends Extension { user_id INTEGER NOT NULL, user_ip SCORE_INET NOT NULL, tags TEXT NOT NULL, - date_set DATETIME NOT NULL, + date_set SCORE_DATETIME NOT NULL, FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE, FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE "); @@ -103,7 +103,7 @@ class Tag_History extends Extension { if($config->get_int("ext_tag_history_version") == 1) { $database->Execute("ALTER TABLE tag_histories ADD COLUMN user_id INTEGER NOT NULL"); - $database->Execute("ALTER TABLE tag_histories ADD COLUMN date_set DATETIME NOT NULL"); + $database->Execute($database->scoreql_to_sql("ALTER TABLE tag_histories ADD COLUMN date_set SCORE_DATETIME NOT NULL")); $config->set_int("ext_tag_history_version", 2); } diff --git a/ext/tag_list/main.php b/ext/tag_list/main.php index 3dc3b92d..bb4c39fb 100644 --- a/ext/tag_list/main.php +++ b/ext/tag_list/main.php @@ -45,16 +45,19 @@ class TagList extends Extension { } $this->theme->display_page($page); } - - if($event->page_matches("api/internal/tag_list/complete")) { + else if($event->page_matches("api/internal/tag_list/complete")) { if(!isset($_GET["s"])) return; - $all = $database->get_all( - "SELECT tag FROM tags WHERE tag LIKE :search AND count > 0 LIMIT 10", - array("search"=>$_GET["s"]."%")); + $limit = 0; + $limitSQL = ""; + $SQLarr = array("search"=>$_GET["s"]."%"); + if(isset($_GET["limit"]) && $_GET["limit"] !== 0){ + $limitSQL = "LIMIT :limit"; + $SQLarr['limit'] = $_GET["limit"]; + } - $res = array(); - foreach($all as $row) {$res[] = $row["tag"];} + $res = $database->get_col( + "SELECT tag FROM tags WHERE tag LIKE :search AND count > 0 $limitSQL", $SQLarr); $page->set_mode("data"); $page->set_type("text/plain"); diff --git a/ext/tagger/main.php b/ext/tagger/main.php index 6165b810..4df81ee8 100644 --- a/ext/tagger/main.php +++ b/ext/tagger/main.php @@ -80,7 +80,6 @@ class TaggerXML extends Extension { $q_where = "WHERE {$match} {$hidden} AND count > 0"; // FROM based on return count - $q_from = null; $count = $this->count($q_where,$values); if ($count > $max_rows) { $q_from = "FROM (SELECT * FROM `tags` {$q_where} ". @@ -139,25 +138,5 @@ class TaggerXML extends Extension { return $database->Execute( "SELECT COUNT(*) FROM `tags` $query",$values)->fields['COUNT(*)']; } - - private function image_tags ($image_id) { - global $database; - $list = "("; - $i_tags = $database->Execute( - "SELECT tag_id FROM `image_tags` WHERE image_id=?", - array($image_id)); - - $b = false; - foreach($i_tags as $tag) { - if($b) - $list .= ","; - $b = true; - $list .= $tag['tag_id']; - - } - $list .= ")"; - - return $list; - } } ?> diff --git a/ext/tips/theme.php b/ext/tips/theme.php index 3c86b53e..2f4b84ba 100644 --- a/ext/tips/theme.php +++ b/ext/tips/theme.php @@ -65,7 +65,6 @@ class TipsTheme extends Themelet { $html .= ""; - $n = 0; foreach ($tips as $tip) { $tip_enable = ($tip['enable'] == "Y") ? "Yes" : "No"; $set_link = "".$tip_enable.""; diff --git a/ext/upgrade/main.php b/ext/upgrade/main.php index a87aa150..d7967754 100644 --- a/ext/upgrade/main.php +++ b/ext/upgrade/main.php @@ -75,6 +75,22 @@ class Upgrade extends Extension { log_info("upgrade", "Database at version 11"); $config->set_bool("in_upgrade", false); } + + if($config->get_int("db_version") < 12) { + $config->set_bool("in_upgrade", true); + $config->set_int("db_version", 12); + + if($database->get_driver_name() == 'pgsql') { + log_info("upgrade", "Changing ext column to VARCHAR"); + $database->execute("ALTER TABLE images ALTER COLUMN ext SET DATA TYPE VARCHAR(4)"); + } + + log_info("upgrade", "Lowering case of all exts"); + $database->execute("UPDATE images SET ext = LOWER(ext)"); + + log_info("upgrade", "Database at version 12"); + $config->set_bool("in_upgrade", false); + } } public function get_priority() {return 5;} diff --git a/ext/upload/main.php b/ext/upload/main.php index b92fc479..d876f2df 100644 --- a/ext/upload/main.php +++ b/ext/upload/main.php @@ -19,7 +19,7 @@ class DataUploadEvent extends Event { * @param $tmpname The temporary file used for upload. * @param $metadata Info about the file, should contain at least "filename", "extension", "tags" and "source". */ - public function DataUploadEvent(/*string*/ $tmpname, /*array*/ $metadata) { + public function __construct(/*string*/ $tmpname, /*array*/ $metadata) { assert(file_exists($tmpname)); $this->tmpname = $tmpname; @@ -49,6 +49,7 @@ class Upload extends Extension { global $config; $config->set_default_int('upload_count', 3); $config->set_default_int('upload_size', '1MB'); + $config->set_default_bool('upload_tlsource', TRUE); // SHIT: fucking PHP "security" measures -_-;;; $free_num = @disk_free_space(realpath("./images/")); @@ -90,6 +91,7 @@ class Upload extends Extension { $sb->add_shorthand_int_option("upload_size", "
    Max size per file: "); $sb->add_label("PHP Limit = ".ini_get('upload_max_filesize').""); $sb->add_choice_option("transload_engine", $tes, "
    Transload: "); + $sb->add_bool_option("upload_tlsource", "
    Use transloaded URL as source if none is provided: "); $event->panel->add_block($sb); } @@ -350,7 +352,7 @@ class Upload extends Extension { $metadata['filename'] = $filename; $metadata['extension'] = getExtension($headers['Content-Type']) ?: $pathinfo['extension']; $metadata['tags'] = $tags; - $metadata['source'] = $source; + $metadata['source'] = (($url == $source) && !$config->get_bool('upload_tlsource') ? "" : $source); /* check for locked > adds to metadata if it has */ if(!empty($locked)){ diff --git a/ext/view/main.php b/ext/view/main.php index 2a1911c9..c97e0592 100644 --- a/ext/view/main.php +++ b/ext/view/main.php @@ -31,7 +31,7 @@ class ImageInfoBoxBuildingEvent extends Event { var $image; var $user; - public function ImageInfoBoxBuildingEvent(Image $image, User $user) { + public function __construct(Image $image, User $user) { $this->image = $image; $this->user = $user; } @@ -45,7 +45,7 @@ class ImageInfoBoxBuildingEvent extends Event { class ImageInfoSetEvent extends Event { var $image; - public function ImageInfoSetEvent(Image $image) { + public function __construct(Image $image) { $this->image = $image; } } @@ -55,7 +55,7 @@ class ImageAdminBlockBuildingEvent extends Event { var $image = null; var $user = null; - public function ImageAdminBlockBuildingEvent(Image $image, User $user) { + public function __construct(Image $image, User $user) { $this->image = $image; $this->user = $user; } @@ -70,11 +70,7 @@ class ViewImage extends Extension { public function onPageRequest(PageRequestEvent $event) { global $page, $user; - if( - $event->page_matches("post/prev") || - $event->page_matches("post/next") - ) { - + if($event->page_matches("post/prev") || $event->page_matches("post/next")) { $image_id = int_escape($event->get_arg(0)); if(isset($_GET['search'])) { @@ -107,8 +103,7 @@ class ViewImage extends Extension { $page->set_mode("redirect"); $page->set_redirect(make_link("post/view/{$image->id}", $query)); } - - if($event->page_matches("post/view")) { + else if($event->page_matches("post/view")) { $image_id = int_escape($event->get_arg(0)); $image = Image::by_id($image_id); @@ -124,8 +119,7 @@ class ViewImage extends Extension { $this->theme->display_error(404, "Image not found", "No image in the database has the ID #$image_id"); } } - - if($event->page_matches("post/set")) { + else if($event->page_matches("post/set")) { if(!isset($_POST['image_id'])) return; $image_id = int_escape($_POST['image_id']); diff --git a/ext/wiki/main.php b/ext/wiki/main.php index 4026c2bd..94f9fb0f 100644 --- a/ext/wiki/main.php +++ b/ext/wiki/main.php @@ -12,7 +12,7 @@ class WikiUpdateEvent extends Event { var $user; var $wikipage; - public function WikiUpdateEvent(User $user, WikiPage $wikipage) { + public function __construct(User $user, WikiPage $wikipage) { $this->user = $user; $this->wikipage = $wikipage; } @@ -31,7 +31,7 @@ class WikiPage { var $locked; var $body; - public function WikiPage($row) { + public function __construct($row) { assert(!empty($row)); $this->id = $row['id']; @@ -63,7 +63,7 @@ class Wiki extends Extension { id SCORE_AIPK, owner_id INTEGER NOT NULL, owner_ip SCORE_INET NOT NULL, - date DATETIME DEFAULT NULL, + date SCORE_DATETIME DEFAULT NULL, title VARCHAR(255) NOT NULL, revision INTEGER NOT NULL DEFAULT 1, locked SCORE_BOOL NOT NULL DEFAULT SCORE_BOOL_N, @@ -157,7 +157,7 @@ class Wiki extends Extension { global $database; $wpage = $event->wikipage; try { - $row = $database->Execute(" + $database->Execute(" INSERT INTO wiki_pages(owner_id, owner_ip, date, title, revision, locked, body) VALUES (?, ?, now(), ?, ?, ?, ?)", array($event->user->id, $_SERVER['REMOTE_ADDR'], $wpage->title, $wpage->rev, $wpage->locked?'Y':'N', $wpage->body)); diff --git a/ext/wiki/theme.php b/ext/wiki/theme.php index 45b7bee4..54e7338d 100644 --- a/ext/wiki/theme.php +++ b/ext/wiki/theme.php @@ -39,7 +39,6 @@ class WikiTheme extends Themelet { protected function create_edit_html(WikiPage $page) { $h_title = html_escape($page->title); - $u_title = url_escape($page->title); $i_revision = int_escape($page->revision) + 1; global $user; diff --git a/lib/shimmie.js b/lib/shimmie.js index 1814570b..2a1f09ed 100644 --- a/lib/shimmie.js +++ b/lib/shimmie.js @@ -8,17 +8,20 @@ $(document).ready(function() { //TODO: Possibly move to using TextExtJS for autocomplete? - http://textextjs.com/ // Also use autocomplete in tag box? $('.autocomplete_tags').autocomplete(base_href + '/api/internal/tag_list/complete', { - width: 320, - max: 15, - highlight: false, - multiple: true, - multipleSeparator: ' ', - scroll: true, - scrollHeight: 300, - selectFirst: false, + //extraParams: {limit: 10}, queryParamName: 's', - delay: 150, - minChars: 1 + minChars: 1, + delay: 0, + useCache: true, + maxCacheLength: 10, + matchInside: false, + selectFirst: true, + selectOnly: false, + preventDefaultReturn: 1, + preventDefaultTab: 1, + useDelimiter: true, + delimiterChar : " ", + delimiterKeyCode : 48 }); $("TABLE.sortable").tablesorter(); diff --git a/themes/danbooru/layout.class.php b/themes/danbooru/layout.class.php index 611d8df6..4598f66b 100644 --- a/themes/danbooru/layout.class.php +++ b/themes/danbooru/layout.class.php @@ -231,8 +231,8 @@ $header_html Images © their respective owners, Shimmie © Shish & - The Team - 2007-2012, + The Team + 2007-2014, based on the Danbooru concept. $debug $contact diff --git a/themes/danbooru/themelet.class.php b/themes/danbooru/themelet.class.php index a6c5be6a..b69c5288 100644 --- a/themes/danbooru/themelet.class.php +++ b/themes/danbooru/themelet.class.php @@ -21,7 +21,6 @@ class Themelet extends BaseThemelet { private function build_paginator($current_page, $total_pages, $base_url, $query) { $next = $current_page + 1; $prev = $current_page - 1; - $rand = mt_rand(1, $total_pages); $at_start = ($current_page <= 3 || $total_pages <= 3); $at_end = ($current_page >= $total_pages -2); diff --git a/themes/danbooru/user.theme.php b/themes/danbooru/user.theme.php index ca62caa8..fba58e8d 100644 --- a/themes/danbooru/user.theme.php +++ b/themes/danbooru/user.theme.php @@ -35,7 +35,6 @@ class CustomUserPageTheme extends UserPageTheme { } public function display_user_block(Page $page, User $user, $parts) { - $h_name = html_escape($user->name); $html = ""; $blocked = array("Pools", "Pool Changes", "Alias Editor", "My Profile"); foreach($parts as $part) { diff --git a/themes/danbooru2/layout.class.php b/themes/danbooru2/layout.class.php index c0405e75..728af1cd 100644 --- a/themes/danbooru2/layout.class.php +++ b/themes/danbooru2/layout.class.php @@ -254,11 +254,11 @@ $header_html
    Running Shimmie – - Images © their respective owners – + Images © their respective owners, Shimmie © Shish & - The Team - 2007-2012, + The Team + 2007-2014, based on the Danbooru concept
    $debug $contact diff --git a/themes/danbooru2/themelet.class.php b/themes/danbooru2/themelet.class.php index a6c5be6a..b69c5288 100644 --- a/themes/danbooru2/themelet.class.php +++ b/themes/danbooru2/themelet.class.php @@ -21,7 +21,6 @@ class Themelet extends BaseThemelet { private function build_paginator($current_page, $total_pages, $base_url, $query) { $next = $current_page + 1; $prev = $current_page - 1; - $rand = mt_rand(1, $total_pages); $at_start = ($current_page <= 3 || $total_pages <= 3); $at_end = ($current_page >= $total_pages -2); diff --git a/themes/danbooru2/user.theme.php b/themes/danbooru2/user.theme.php index ca62caa8..fba58e8d 100644 --- a/themes/danbooru2/user.theme.php +++ b/themes/danbooru2/user.theme.php @@ -35,7 +35,6 @@ class CustomUserPageTheme extends UserPageTheme { } public function display_user_block(Page $page, User $user, $parts) { - $h_name = html_escape($user->name); $html = ""; $blocked = array("Pools", "Pool Changes", "Alias Editor", "My Profile"); foreach($parts as $part) { diff --git a/themes/default/layout.class.php b/themes/default/layout.class.php index 289854d1..078e143f 100644 --- a/themes/default/layout.class.php +++ b/themes/default/layout.class.php @@ -83,8 +83,8 @@ $header_html Images © their respective owners, Shimmie © Shish & - The Team - 2007-2012, + The Team + 2007-2014, based on the Danbooru concept. $debug $contact diff --git a/themes/futaba/comment.theme.php b/themes/futaba/comment.theme.php index 33a55ea0..f65b0b14 100644 --- a/themes/futaba/comment.theme.php +++ b/themes/futaba/comment.theme.php @@ -56,7 +56,7 @@ class CustomCommentListTheme extends CommentListTheme { } - protected function comment_to_html(Comment $comment, $trim=false) { + protected function comment_to_html($comment, $trim=false) { $inner_id = $this->inner_id; // because custom themes can't add params, because PHP global $user; diff --git a/themes/futaba/layout.class.php b/themes/futaba/layout.class.php index c98fe71f..b42c9ad2 100644 --- a/themes/futaba/layout.class.php +++ b/themes/futaba/layout.class.php @@ -1,7 +1,7 @@ get_string('theme', 'default'); @@ -90,8 +90,8 @@ $header_html Images © their respective owners, Shimmie © Shish & - The Team - 2007-2012, + The Team + 2007-2014, based on the Danbooru concept.
    Futaba theme based on 4chan's layout and CSS :3 $debug diff --git a/themes/lite/layout.class.php b/themes/lite/layout.class.php index 0f631b32..3cf8e9d9 100644 --- a/themes/lite/layout.class.php +++ b/themes/lite/layout.class.php @@ -75,7 +75,6 @@ class Layout { } $custom_sublinks = "
    "; - $cs = null; // hack global $user; $username = url_escape($user->name); @@ -190,8 +189,8 @@ class Layout { Images © their respective owners, Shimmie © Shish & - The Team - 2007-2012, + The Team + 2007-2014, based on the Danbooru concept.
    Lite Theme by Zach $debug diff --git a/themes/lite/user.theme.php b/themes/lite/user.theme.php index 9aa476ab..f3b11a8d 100644 --- a/themes/lite/user.theme.php +++ b/themes/lite/user.theme.php @@ -1,7 +1,7 @@ set_title("Login"); $page->set_heading("Login"); @@ -27,14 +27,14 @@ class CustomUserPageTheme extends UserPageTheme { $page->add_block(new Block("Login", $html, "main", 90)); } - public function display_user_links($page, $user, $parts) { + public function display_user_links(Page $page, User $user, $parts) { // no block in this theme } public function display_login_block(Page $page) { // no block in this theme } - 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 = ""; $blocked = array("Pools", "Pool Changes", "Alias Editor", "My Profile"); @@ -45,7 +45,7 @@ class CustomUserPageTheme extends UserPageTheme { $page->add_block(new Block("User Links", $html, "user", 90)); } - public function display_signup_page($page) { + public function display_signup_page(Page $page) { global $config; $tac = $config->get_string("login_tac", ""); @@ -74,7 +74,7 @@ class CustomUserPageTheme extends UserPageTheme { $page->add_block(new Block("Signup", $html)); } - public function display_ip_list($page, $uploads, $comments) { + public function display_ip_list(Page $page, $uploads, $comments) { $html = "
    R?SubjectFromDateAction
    Public
    Description
    ".html_escape($pool['title'])."
    Action
    "; $html .= "
    Uploaded from: "; foreach($uploads as $ip => $count) { diff --git a/themes/lite/view.theme.php b/themes/lite/view.theme.php index c86ceb92..419b3571 100644 --- a/themes/lite/view.theme.php +++ b/themes/lite/view.theme.php @@ -1,7 +1,7 @@ get_tag_list())); $page->set_title("Image {$image->id}: ".html_escape($image->get_tag_list())); @@ -17,7 +17,7 @@ class CustomViewImageTheme extends ViewImageTheme { $page->add_block(new Block(null, $this->build_pin($image), "main", 11)); } - private function build_stats($image) { + private function build_stats(Image $image) { $h_owner = html_escape($image->get_owner()->name); $h_ownerlink = "$h_owner"; $h_ip = html_escape($image->owner_ip); diff --git a/themes/warm/layout.class.php b/themes/warm/layout.class.php index d5f70eb6..afac42b0 100644 --- a/themes/warm/layout.class.php +++ b/themes/warm/layout.class.php @@ -97,8 +97,8 @@ $header_html Images © their respective owners, Shimmie © Shish & - The Team - 2007-2012, + The Team + 2007-2014, based on the Danbooru concept. $debug $contact