";
+ //TODO how will notes be edited? On edit artist? (should there be an editartist?) or on a editnotes?
+ //same question for deletion
+ $html .= "
+
";
+
+ $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 = "
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 -->
+ *- 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 .= "