Merge branch 'master' of github.com:shish/shimmie2
This commit is contained in:
commit
e35c1dca74
14 changed files with 57 additions and 31 deletions
|
@ -47,7 +47,7 @@ class ImageBan extends Extension {
|
||||||
global $database;
|
global $database;
|
||||||
$row = $database->get_row("SELECT * FROM image_bans WHERE hash = :hash", array("hash"=>$event->hash));
|
$row = $database->get_row("SELECT * FROM image_bans WHERE hash = :hash", array("hash"=>$event->hash));
|
||||||
if($row) {
|
if($row) {
|
||||||
log_info("image_hash_ban", "Blocked image ({$event->hash})");
|
log_info("image_hash_ban", "Attempted to upload a blocked image ({$event->hash} - {$row['reason']})");
|
||||||
throw new UploadException("Image ".html_escape($row["hash"])." has been banned, reason: ".format_text($row["reason"]));
|
throw new UploadException("Image ".html_escape($row["hash"])." has been banned, reason: ".format_text($row["reason"]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,16 +60,20 @@ class LogDatabase extends Extension {
|
||||||
if(!empty($_GET["user"])) {
|
if(!empty($_GET["user"])) {
|
||||||
if($database->engine->name == "pgsql") {
|
if($database->engine->name == "pgsql") {
|
||||||
if(preg_match("#\d+\.\d+\.\d+\.\d+(/\d+)?#", $_GET["user"])) {
|
if(preg_match("#\d+\.\d+\.\d+\.\d+(/\d+)?#", $_GET["user"])) {
|
||||||
$wheres[] = "(username = :user OR address << :user)";
|
$wheres[] = "(username = :user1 OR text(address) = :user2)";
|
||||||
|
$args["user1"] = $_GET["user"];
|
||||||
|
$args["user2"] = $_GET["user"] . "/32";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$wheres[] = "lower(username) = lower(:user)";
|
$wheres[] = "lower(username) = lower(:user)";
|
||||||
|
$args["user"] = $_GET["user"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$wheres[] = "(username = :user OR address = :user)";
|
$wheres[] = "(username = :user1 OR address = :user2)";
|
||||||
|
$args["user1"] = $_GET["user"];
|
||||||
|
$args["user2"] = $_GET["user"];
|
||||||
}
|
}
|
||||||
$args["user"] = $_GET["user"];
|
|
||||||
}
|
}
|
||||||
if(!empty($_GET["priority"])) {
|
if(!empty($_GET["priority"])) {
|
||||||
$wheres[] = "priority >= :priority";
|
$wheres[] = "priority >= :priority";
|
||||||
|
|
|
@ -12,8 +12,9 @@ class LogNet extends Extension {
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
if($event->priority > 10) {
|
if($event->priority > 10) {
|
||||||
|
// TODO: colour based on event->priority
|
||||||
$username = ($user && $user->name) ? $user->name : "Anonymous";
|
$username = ($user && $user->name) ? $user->name : "Anonymous";
|
||||||
$str = sprintf("%2d %15s (%s): %s - %s", $event->priority, $_SERVER['REMOTE_ADDR'], $username, $event->section, $event->message);
|
$str = sprintf("%-15s %-10s: %s", $_SERVER['REMOTE_ADDR'], $username, $event->message);
|
||||||
system("echo ".escapeshellarg($str)." | nc -q 0 localhost 5000");
|
system("echo ".escapeshellarg($str)." | nc -q 0 localhost 5000");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -340,7 +340,7 @@ class Pools extends Extension {
|
||||||
VALUES (:uid, :public, :title, :desc, now())",
|
VALUES (:uid, :public, :title, :desc, now())",
|
||||||
array("uid"=>$user->id, "public"=>$public, "title"=>$_POST["title"], "desc"=>$_POST["description"]));
|
array("uid"=>$user->id, "public"=>$public, "title"=>$_POST["title"], "desc"=>$_POST["description"]));
|
||||||
|
|
||||||
$result['poolID'] = $database->get_last_insert_id();
|
$result['poolID'] = $database->get_last_insert_id('pools_id_seq');
|
||||||
|
|
||||||
log_info("pools", "Pool {$result["poolID"]} created by {$user->name}");
|
log_info("pools", "Pool {$result["poolID"]} created by {$user->name}");
|
||||||
|
|
||||||
|
|
|
@ -403,8 +403,13 @@ class Database {
|
||||||
/**
|
/**
|
||||||
* get the ID of the last inserted row
|
* get the ID of the last inserted row
|
||||||
*/
|
*/
|
||||||
public function get_last_insert_id() {
|
public function get_last_insert_id($seq) {
|
||||||
return $this->db->lastInsertId();
|
if($this->engine->name == "pgsql") {
|
||||||
|
return $this->db->lastInsertId($seq);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return $this->db->lastInsertId();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -419,7 +419,7 @@ class Image {
|
||||||
$sln = $database->engine->scoreql_to_sql('SCORE_BOOL_'.$ln);
|
$sln = $database->engine->scoreql_to_sql('SCORE_BOOL_'.$ln);
|
||||||
$sln = str_replace("'", "", $sln);
|
$sln = str_replace("'", "", $sln);
|
||||||
$sln = str_replace('"', "", $sln);
|
$sln = str_replace('"', "", $sln);
|
||||||
if($sln != $this->locked) {
|
if(undb_bool($sln) !== $this->locked) {
|
||||||
$database->execute("UPDATE images SET locked=:yn WHERE id=:id", array("yn"=>$sln, "id"=>$this->id));
|
$database->execute("UPDATE images SET locked=:yn WHERE id=:id", array("yn"=>$sln, "id"=>$this->id));
|
||||||
log_info("core-image", "Setting Image #{$this->id} lock to: $ln");
|
log_info("core-image", "Setting Image #{$this->id} lock to: $ln");
|
||||||
}
|
}
|
||||||
|
|
|
@ -500,8 +500,11 @@ class CommentList extends Extension {
|
||||||
"INSERT INTO comments(image_id, owner_id, owner_ip, posted, comment) ".
|
"INSERT INTO comments(image_id, owner_id, owner_ip, posted, comment) ".
|
||||||
"VALUES(:image_id, :user_id, :remote_addr, now(), :comment)",
|
"VALUES(:image_id, :user_id, :remote_addr, now(), :comment)",
|
||||||
array("image_id"=>$image_id, "user_id"=>$user->id, "remote_addr"=>$_SERVER['REMOTE_ADDR'], "comment"=>$comment));
|
array("image_id"=>$image_id, "user_id"=>$user->id, "remote_addr"=>$_SERVER['REMOTE_ADDR'], "comment"=>$comment));
|
||||||
$cid = $database->get_last_insert_id();
|
$cid = $database->get_last_insert_id('comments_id_seq');
|
||||||
log_info("comment", "Comment #$cid added to Image #$image_id");
|
$snippet = substr($comment, 0, 100);
|
||||||
|
$snippet = str_replace("\n", " ", $snippet);
|
||||||
|
$snippet = str_replace("\r", " ", $snippet);
|
||||||
|
log_info("comment", "Comment #$cid added to Image #$image_id: $snippet");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// }}}
|
// }}}
|
||||||
|
|
|
@ -328,13 +328,7 @@ class ImageIO extends Extension {
|
||||||
"hash"=>$image->hash, "ext"=>$image->ext, "width"=>$image->width, "height"=>$image->height, "source"=>$image->source
|
"hash"=>$image->hash, "ext"=>$image->ext, "width"=>$image->width, "height"=>$image->height, "source"=>$image->source
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
//$database->Execute("UPDATE users SET image_count = image_count+1 WHERE id = :id ", array("id"=>$user->id));
|
$image->id = $database->get_last_insert_id('images_id_seq');
|
||||||
if($database->engine->name == "pgsql") {
|
|
||||||
$image->id = $database->get_one("SELECT id FROM images WHERE hash=:hash", array("hash"=>$image->hash));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$image->id = $database->get_last_insert_id();
|
|
||||||
}
|
|
||||||
|
|
||||||
log_info("image", "Uploaded Image #{$image->id} ({$image->hash})");
|
log_info("image", "Uploaded Image #{$image->id} ({$image->hash})");
|
||||||
|
|
||||||
|
|
|
@ -112,7 +112,6 @@ class Upload extends Extension {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// event handling {{{
|
|
||||||
public function onPageRequest($event) {
|
public function onPageRequest($event) {
|
||||||
global $config, $page, $user;
|
global $config, $page, $user;
|
||||||
|
|
||||||
|
@ -187,16 +186,15 @@ class Upload extends Extension {
|
||||||
else {
|
else {
|
||||||
/* Regular Upload Image */
|
/* Regular Upload Image */
|
||||||
if(count($_FILES) + count($_POST) > 0) {
|
if(count($_FILES) + count($_POST) > 0) {
|
||||||
$tags = Tag::explode($_POST['tags']);
|
|
||||||
$source = isset($_POST['source']) ? $_POST['source'] : null;
|
$source = isset($_POST['source']) ? $_POST['source'] : null;
|
||||||
$ok = true;
|
$ok = true;
|
||||||
foreach($_FILES as $file) {
|
foreach($_FILES as $name => $file) {
|
||||||
reset($_FILES); // rewind to first element in array.
|
$tags = $this->tags_for_upload_slot(int_escape(substr($name, 4)));
|
||||||
$ok = $ok & $this->try_upload($file, $tags, $source);
|
$ok = $ok & $this->try_upload($file, $tags, $source);
|
||||||
}
|
}
|
||||||
foreach($_POST as $name => $value) {
|
foreach($_POST as $name => $value) {
|
||||||
reset($_POST); // rewind to first element in array.
|
|
||||||
if(substr($name, 0, 3) == "url" && strlen($value) > 0) {
|
if(substr($name, 0, 3) == "url" && strlen($value) > 0) {
|
||||||
|
$tags = $this->tags_for_upload_slot(int_escape(substr($name, 3)));
|
||||||
$ok = $ok & $this->try_transload($value, $tags, $source);
|
$ok = $ok & $this->try_transload($value, $tags, $source);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -223,7 +221,17 @@ class Upload extends Extension {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// }}}
|
|
||||||
|
private function tags_for_upload_slot($id) {
|
||||||
|
if(isset($_POST["tags$id"])) {
|
||||||
|
$tags = array_merge(Tag::explode($_POST['tags']), Tag::explode($_POST["tags$id"]));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$tags = Tag::explode($_POST['tags']);
|
||||||
|
}
|
||||||
|
return $tags;
|
||||||
|
}
|
||||||
|
|
||||||
// do things {{{
|
// do things {{{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -20,9 +20,9 @@ class UploadTheme extends Themelet {
|
||||||
".make_form(make_link("upload"), "POST", $multipart=True, 'file_upload')."
|
".make_form(make_link("upload"), "POST", $multipart=True, 'file_upload')."
|
||||||
<table id='large_upload_form' class='vert'>
|
<table id='large_upload_form' class='vert'>
|
||||||
$upload_list
|
$upload_list
|
||||||
<tr><td width='20'>Tags<td colspan='3'><input name='tags' type='text' placeholder='tagme' class='autocomplete_tags'></td></tr>
|
<tr><td width='20'>Tags<td colspan='5'><input name='tags' type='text' placeholder='tagme' class='autocomplete_tags'></td></tr>
|
||||||
<tr><td>Source</td><td colspan='3'><input name='source' type='text'></td></tr>
|
<tr><td>Source</td><td colspan='5'><input name='source' type='text'></td></tr>
|
||||||
<tr><td colspan='4'><input id='uploadbutton' type='submit' value='Post'></td></tr>
|
<tr><td colspan='6'><input id='uploadbutton' type='submit' value='Post'></td></tr>
|
||||||
</table>
|
</table>
|
||||||
</form>
|
</form>
|
||||||
<small>(Max file size is $max_kb)</small>
|
<small>(Max file size is $max_kb)</small>
|
||||||
|
@ -48,6 +48,7 @@ class UploadTheme extends Themelet {
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan='2'>Files</td>
|
<td colspan='2'>Files</td>
|
||||||
<td colspan='2'>URLs</td>
|
<td colspan='2'>URLs</td>
|
||||||
|
<td colspan='2'>Image-Specific Tags</td>
|
||||||
</tr>
|
</tr>
|
||||||
";
|
";
|
||||||
|
|
||||||
|
@ -56,15 +57,24 @@ class UploadTheme extends Themelet {
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan='2'><input type='file' name='data$i'></td>
|
<td colspan='2'><input type='file' name='data$i'></td>
|
||||||
<td colspan='2'><input type='text' name='url$i'</td>
|
<td colspan='2'><input type='text' name='url$i'</td>
|
||||||
|
<td colspan='2'><input type='text' name='tags$i'></td>
|
||||||
</tr>
|
</tr>
|
||||||
";
|
";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
$upload_list .= "
|
||||||
|
<tr>
|
||||||
|
<td colspan='4'>Files</td>
|
||||||
|
<td colspan='2'>Image-Specific Tags</td>
|
||||||
|
</tr>
|
||||||
|
";
|
||||||
|
|
||||||
for($i=0; $i<$upload_count; $i++) {
|
for($i=0; $i<$upload_count; $i++) {
|
||||||
$upload_list .= "
|
$upload_list .= "
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan='4'><input type='file' name='data$i'></td>
|
<td colspan='4'><input type='file' name='data$i'></td>
|
||||||
|
<td colspan='2'><input type='text' name='tags$i'></td>
|
||||||
</tr>
|
</tr>
|
||||||
";
|
";
|
||||||
}
|
}
|
||||||
|
|
|
@ -339,7 +339,7 @@ class UserPage extends Extension {
|
||||||
$database->Execute(
|
$database->Execute(
|
||||||
"INSERT INTO users (name, pass, joindate, email, class) VALUES (:username, :hash, now(), :email, :class)",
|
"INSERT INTO users (name, pass, joindate, email, class) VALUES (:username, :hash, now(), :email, :class)",
|
||||||
array("username"=>$event->username, "hash"=>$hash, "email"=>$email, "class"=>$class));
|
array("username"=>$event->username, "hash"=>$hash, "email"=>$email, "class"=>$class));
|
||||||
$uid = $database->get_last_insert_id();
|
$uid = $database->get_last_insert_id('users_id_seq');
|
||||||
log_info("user", "Created User #$uid ({$event->username})");
|
log_info("user", "Created User #$uid ({$event->username})");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
2
install.php
Executable file → Normal file
2
install.php
Executable file → Normal file
|
@ -354,7 +354,7 @@ function insert_defaults() { // {{{
|
||||||
$db = new Database();
|
$db = new Database();
|
||||||
|
|
||||||
$db->execute("INSERT INTO users(name, pass, joindate, class) VALUES(:name, :pass, now(), :class)", Array("name" => 'Anonymous', "pass" => null, "class" => 'anonymous'));
|
$db->execute("INSERT INTO users(name, pass, joindate, class) VALUES(:name, :pass, now(), :class)", Array("name" => 'Anonymous', "pass" => null, "class" => 'anonymous'));
|
||||||
$db->execute("INSERT INTO config(name, value) VALUES(:name, :value)", Array("name" => 'anon_id', "value" => $db->get_last_insert_id()));
|
$db->execute("INSERT INTO config(name, value) VALUES(:name, :value)", Array("name" => 'anon_id', "value" => $db->get_last_insert_id('users_id_seq')));
|
||||||
|
|
||||||
if(check_im_version() > 0) {
|
if(check_im_version() > 0) {
|
||||||
$db->execute("INSERT INTO config(name, value) VALUES(:name, :value)", Array("name" => 'thumb_engine', "value" => 'convert'));
|
$db->execute("INSERT INTO config(name, value) VALUES(:name, :value)", Array("name" => 'thumb_engine', "value" => 'convert'));
|
||||||
|
|
2
lib/jquery.timeago-0.10.0.min.js
vendored
2
lib/jquery.timeago-0.10.0.min.js
vendored
|
@ -1 +1 @@
|
||||||
(function(d){d.timeago=function(g){if(g instanceof Date){return a(g)}else{if(typeof g==="string"){return a(d.timeago.parse(g))}else{return a(d.timeago.datetime(g))}}};var f=d.timeago;d.extend(d.timeago,{settings:{refreshMillis:60000,allowFuture:false,strings:{prefixAgo:null,prefixFromNow:null,suffixAgo:"ago",suffixFromNow:"from now",seconds:"less than a minute",minute:"about a minute",minutes:"%d minutes",hour:"about an hour",hours:"about %d hours",day:"a day",days:"%d days",month:"about a month",months:"%d months",year:"about a year",years:"%d years",numbers:[]}},inWords:function(l){var m=this.settings.strings;var i=m.prefixAgo;var q=m.suffixAgo;if(this.settings.allowFuture){if(l<0){i=m.prefixFromNow;q=m.suffixFromNow}}var o=Math.abs(l)/1000;var g=o/60;var n=g/60;var p=n/24;var j=p/365;function h(r,t){var s=d.isFunction(r)?r(t,l):r;var u=(m.numbers&&m.numbers[t])||t;return s.replace(/%d/i,u)}var k=o<45&&h(m.seconds,Math.round(o))||o<90&&h(m.minute,1)||g<45&&h(m.minutes,Math.round(g))||g<90&&h(m.hour,1)||n<24&&h(m.hours,Math.round(n))||n<48&&h(m.day,1)||p<30&&h(m.days,Math.floor(p))||p<60&&h(m.month,1)||p<365&&h(m.months,Math.floor(p/30))||j<2&&h(m.year,1)||h(m.years,Math.floor(j));return d.trim([i,k,q].join(" "))},parse:function(h){var g=d.trim(h);g=g.replace(/\.\d\d\d+/,"");g=g.replace(/-/,"/").replace(/-/,"/");g=g.replace(/T/," ").replace(/Z/," UTC");g=g.replace(/([\+\-]\d\d)\:?(\d\d)/," $1$2");return new Date(g)},datetime:function(h){var i=d(h).get(0).tagName.toLowerCase()==="time";var g=i?d(h).attr("datetime"):d(h).attr("title");return f.parse(g)}});d.fn.timeago=function(){var h=this;h.each(c);var g=f.settings;if(g.refreshMillis>0){setInterval(function(){h.each(c)},g.refreshMillis)}return h};function c(){var g=b(this);if(!isNaN(g.datetime)){d(this).text(a(g.datetime))}return this}function b(g){g=d(g);if(!g.data("timeago")){g.data("timeago",{datetime:f.datetime(g)});var h=d.trim(g.text());if(h.length>0){g.attr("title",h)}}return g.data("timeago")}function a(g){return f.inWords(e(g))}function e(g){return(new Date().getTime()-g.getTime())}document.createElement("abbr");document.createElement("time")}(jQuery));
|
(function(d){d.timeago=function(g){if(g instanceof Date){return a(g)}else{if(typeof g==="string"){return a(d.timeago.parse(g))}else{return a(d.timeago.datetime(g))}}};var f=d.timeago;d.extend(d.timeago,{settings:{refreshMillis:60000,allowFuture:false,strings:{prefixAgo:null,prefixFromNow:null,suffixAgo:"ago",suffixFromNow:"from now",seconds:"less than a minute",minute:"a minute",minutes:"%d minutes",hour:"an hour",hours:"%d hours",day:"a day",days:"%d days",month:"a month",months:"%d months",year:"a year",years:"%d years",numbers:[]}},inWords:function(l){var m=this.settings.strings;var i=m.prefixAgo;var q=m.suffixAgo;if(this.settings.allowFuture){if(l<0){i=m.prefixFromNow;q=m.suffixFromNow}}var o=Math.abs(l)/1000;var g=o/60;var n=g/60;var p=n/24;var j=p/365;function h(r,t){var s=d.isFunction(r)?r(t,l):r;var u=(m.numbers&&m.numbers[t])||t;return s.replace(/%d/i,u)}var k=o<45&&h(m.seconds,Math.round(o))||o<90&&h(m.minute,1)||g<45&&h(m.minutes,Math.round(g))||g<90&&h(m.hour,1)||n<24&&h(m.hours,Math.round(n))||n<48&&h(m.day,1)||p<30&&h(m.days,Math.floor(p))||p<60&&h(m.month,1)||p<365&&h(m.months,Math.floor(p/30))||j<2&&h(m.year,1)||h(m.years,Math.floor(j));return d.trim([i,k,q].join(" "))},parse:function(h){var g=d.trim(h);g=g.replace(/\.\d\d\d+/,"");g=g.replace(/-/,"/").replace(/-/,"/");g=g.replace(/T/," ").replace(/Z/," UTC");g=g.replace(/([\+\-]\d\d)\:?(\d\d)/," $1$2");return new Date(g)},datetime:function(h){var i=d(h).get(0).tagName.toLowerCase()==="time";var g=i?d(h).attr("datetime"):d(h).attr("title");return f.parse(g)}});d.fn.timeago=function(){var h=this;h.each(c);var g=f.settings;if(g.refreshMillis>0){setInterval(function(){h.each(c)},g.refreshMillis)}return h};function c(){var g=b(this);if(!isNaN(g.datetime)){d(this).text(a(g.datetime))}return this}function b(g){g=d(g);if(!g.data("timeago")){g.data("timeago",{datetime:f.datetime(g)});var h=d.trim(g.text());if(h.length>0){g.attr("title",h)}}return g.data("timeago")}function a(g){return f.inWords(e(g))}function e(g){return(new Date().getTime()-g.getTime())}document.createElement("abbr");document.createElement("time")}(jQuery));
|
||||||
|
|
|
@ -91,8 +91,9 @@ EOD;
|
||||||
$b = $block->body;
|
$b = $block->body;
|
||||||
$html = "";
|
$html = "";
|
||||||
$i = str_replace(' ', '_', $h) . $salt;
|
$i = str_replace(' ', '_', $h) . $salt;
|
||||||
|
$h_toggler = $hidable ? " shm-toggler" : "";
|
||||||
if(!is_null($h)) $html .= "
|
if(!is_null($h)) $html .= "
|
||||||
<h3 data-toggle-id='$i' class='hrr shm-toggler'>$h</h3>
|
<h3 data-toggle-id='$i' class='hrr$h_toggler'>$h</h3>
|
||||||
";
|
";
|
||||||
if(!is_null($b)) {
|
if(!is_null($b)) {
|
||||||
if(strpos($b, "<!-- cancel border -->") === FALSE) {
|
if(strpos($b, "<!-- cancel border -->") === FALSE) {
|
||||||
|
|
Reference in a new issue