Merge branch 'master' of github.com:shish/shimmie2
This commit is contained in:
		
						commit
						9ebe425520
					
				| @ -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"; | ||||||
|  | |||||||
| @ -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,9 +403,14 @@ 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) { | ||||||
|  | 		if($this->engine->name == "pgsql") { | ||||||
|  | 			return $this->db->lastInsertId($seq); | ||||||
|  | 		} | ||||||
|  | 		else { | ||||||
| 			return $this->db->lastInsertId(); | 			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})"); | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -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)); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user