pdo compat
This commit is contained in:
parent
175ceac490
commit
9e00675900
@ -89,7 +89,7 @@ class IPBan implements Extension {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if($event instanceof RemoveIPBanEvent) {
|
if($event instanceof RemoveIPBanEvent) {
|
||||||
$database->Execute("DELETE FROM bans WHERE id = ?", array($event->id));
|
$database->Execute("DELETE FROM bans WHERE id = :id", array("id"=>$event->id));
|
||||||
$database->cache->delete("ip_bans");
|
$database->cache->delete("ip_bans");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -211,9 +211,9 @@ class IPBan implements Extension {
|
|||||||
SELECT bans.*, users.name as banner_name
|
SELECT bans.*, users.name as banner_name
|
||||||
FROM bans
|
FROM bans
|
||||||
JOIN users ON banner_id = users.id
|
JOIN users ON banner_id = users.id
|
||||||
WHERE (end_timestamp > ?) OR (end_timestamp IS NULL)
|
WHERE (end_timestamp > :end_timestamp) OR (end_timestamp IS NULL)
|
||||||
ORDER BY end_timestamp, bans.id
|
ORDER BY end_timestamp, bans.id
|
||||||
", array(time()));
|
", array("end_timestamp"=>time()));
|
||||||
|
|
||||||
$database->cache->set("ip_bans", $bans, 600);
|
$database->cache->set("ip_bans", $bans, 600);
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ class Comment {
|
|||||||
|
|
||||||
public static function count_comments_by_user($user) {
|
public static function count_comments_by_user($user) {
|
||||||
global $database;
|
global $database;
|
||||||
return $database->db->GetOne("SELECT COUNT(*) AS count FROM comments WHERE owner_id=?", array($user->id));
|
return $database->db->GetOne("SELECT COUNT(*) AS count FROM comments WHERE owner_id=:owner_id", array("owner_id"=>$user->id));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_owner() {
|
public function get_owner() {
|
||||||
@ -180,7 +180,7 @@ class CommentList extends SimpleExtension {
|
|||||||
public function onImageDeletion(ImageDeletionEvent $event) {
|
public function onImageDeletion(ImageDeletionEvent $event) {
|
||||||
global $database;
|
global $database;
|
||||||
$image_id = $event->image->id;
|
$image_id = $event->image->id;
|
||||||
$database->Execute("DELETE FROM comments WHERE image_id=?", array($image_id));
|
$database->Execute("DELETE FROM comments WHERE image_id=:image_id", array("image_id"=>$image_id));
|
||||||
log_info("comment", "Deleting all comments for Image #$image_id");
|
log_info("comment", "Deleting all comments for Image #$image_id");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,7 +191,7 @@ class CommentList extends SimpleExtension {
|
|||||||
|
|
||||||
public function onCommentDeletion(CommentDeletionEvent $event) {
|
public function onCommentDeletion(CommentDeletionEvent $event) {
|
||||||
global $database;
|
global $database;
|
||||||
$database->Execute("DELETE FROM comments WHERE id=?", array($event->comment_id));
|
$database->Execute("DELETE FROM comments WHERE id=:comment_id", array("comment_id"=>$event->comment_id));
|
||||||
log_info("comment", "Deleting Comment #{$event->comment_id}");
|
log_info("comment", "Deleting Comment #{$event->comment_id}");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -261,9 +261,9 @@ class CommentList extends SimpleExtension {
|
|||||||
FROM comments
|
FROM comments
|
||||||
GROUP BY image_id
|
GROUP BY image_id
|
||||||
ORDER BY latest DESC
|
ORDER BY latest DESC
|
||||||
LIMIT ? OFFSET ?
|
LIMIT :limit OFFSET :offset
|
||||||
";
|
";
|
||||||
$result = $database->Execute($get_threads, array($threads_per_page, $start));
|
$result = $database->Execute($get_threads, array("limit"=>$threads_per_page, "offset"=>$start));
|
||||||
|
|
||||||
$total_pages = (int)($database->db->GetOne("SELECT COUNT(c1) FROM (SELECT COUNT(image_id) AS c1 FROM comments GROUP BY image_id) AS s1") / 10);
|
$total_pages = (int)($database->db->GetOne("SELECT COUNT(c1) FROM (SELECT COUNT(image_id) AS c1 FROM comments GROUP BY image_id) AS s1") / 10);
|
||||||
|
|
||||||
@ -297,8 +297,8 @@ class CommentList extends SimpleExtension {
|
|||||||
FROM comments
|
FROM comments
|
||||||
LEFT JOIN users ON comments.owner_id=users.id
|
LEFT JOIN users ON comments.owner_id=users.id
|
||||||
ORDER BY comments.id DESC
|
ORDER BY comments.id DESC
|
||||||
LIMIT ?
|
LIMIT :limit
|
||||||
", array($config->get_int('comment_count')));
|
", array("limit"=>$config->get_int('comment_count')));
|
||||||
$comments = array();
|
$comments = array();
|
||||||
foreach($rows as $row) {
|
foreach($rows as $row) {
|
||||||
$comments[] = new Comment($row);
|
$comments[] = new Comment($row);
|
||||||
@ -318,9 +318,9 @@ class CommentList extends SimpleExtension {
|
|||||||
comments.posted as posted
|
comments.posted as posted
|
||||||
FROM comments
|
FROM comments
|
||||||
LEFT JOIN users ON comments.owner_id=users.id
|
LEFT JOIN users ON comments.owner_id=users.id
|
||||||
WHERE comments.image_id=?
|
WHERE comments.image_id=:image_id
|
||||||
ORDER BY comments.id ASC
|
ORDER BY comments.id ASC
|
||||||
", array($i_image_id));
|
", array("image_id"=>$i_image_id));
|
||||||
$comments = array();
|
$comments = array();
|
||||||
foreach($rows as $row) {
|
foreach($rows as $row) {
|
||||||
$comments[] = new Comment($row);
|
$comments[] = new Comment($row);
|
||||||
|
@ -46,8 +46,8 @@ class TagList implements Extension {
|
|||||||
|
|
||||||
if(($event instanceof PageRequestEvent) && $event->page_matches("api/internal/tag_list/complete")) {
|
if(($event instanceof PageRequestEvent) && $event->page_matches("api/internal/tag_list/complete")) {
|
||||||
$all = $database->get_all(
|
$all = $database->get_all(
|
||||||
"SELECT tag FROM tags WHERE tag LIKE ? AND count > 0 LIMIT 10",
|
"SELECT tag FROM tags WHERE tag LIKE :search AND count > 0 LIMIT 10",
|
||||||
array($_GET["s"]."%"));
|
array("search"=>$_GET["s"]."%"));
|
||||||
|
|
||||||
$res = array();
|
$res = array();
|
||||||
foreach($all as $row) {$res[] = $row["tag"];}
|
foreach($all as $row) {$res[] = $row["tag"];}
|
||||||
@ -130,11 +130,11 @@ class TagList implements Extension {
|
|||||||
$result = $database->execute("
|
$result = $database->execute("
|
||||||
SELECT
|
SELECT
|
||||||
tag,
|
tag,
|
||||||
FLOOR(LOG(2.7, LOG(2.7, count - ? + 1)+1)*1.5*100)/100 AS scaled
|
FLOOR(LOG(2.7, LOG(2.7, count - :tags_min + 1)+1)*1.5*100)/100 AS scaled
|
||||||
FROM tags
|
FROM tags
|
||||||
WHERE count >= ?
|
WHERE count >= :tags_min
|
||||||
ORDER BY tag
|
ORDER BY tag
|
||||||
", array($tags_min, $tags_min));
|
", array("tags_min"=>$tags_min));
|
||||||
$tag_data = $result->GetArray();
|
$tag_data = $result->GetArray();
|
||||||
|
|
||||||
$html = "";
|
$html = "";
|
||||||
@ -154,8 +154,8 @@ class TagList implements Extension {
|
|||||||
|
|
||||||
$tags_min = $this->get_tags_min();
|
$tags_min = $this->get_tags_min();
|
||||||
$result = $database->execute(
|
$result = $database->execute(
|
||||||
"SELECT tag,count FROM tags WHERE count >= ? ORDER BY tag",
|
"SELECT tag,count FROM tags WHERE count >= :tags_min ORDER BY tag",
|
||||||
array($tags_min));
|
array("tags_min"=>$tags_min));
|
||||||
$tag_data = $result->GetArray();
|
$tag_data = $result->GetArray();
|
||||||
|
|
||||||
$html = "";
|
$html = "";
|
||||||
@ -179,8 +179,8 @@ class TagList implements Extension {
|
|||||||
|
|
||||||
$tags_min = $this->get_tags_min();
|
$tags_min = $this->get_tags_min();
|
||||||
$result = $database->execute(
|
$result = $database->execute(
|
||||||
"SELECT tag,count,FLOOR(LOG(count)) AS scaled FROM tags WHERE count >= ? ORDER BY count DESC, tag ASC",
|
"SELECT tag,count,FLOOR(LOG(count)) AS scaled FROM tags WHERE count >= :tags_min ORDER BY count DESC, tag ASC",
|
||||||
array($tags_min));
|
array("tags_min"=>$tags_min));
|
||||||
$tag_data = $result->GetArray();
|
$tag_data = $result->GetArray();
|
||||||
|
|
||||||
$html = "Results grouped by log<sub>e</sub>(n)";
|
$html = "Results grouped by log<sub>e</sub>(n)";
|
||||||
@ -240,7 +240,7 @@ class TagList implements Extension {
|
|||||||
tags AS t1,
|
tags AS t1,
|
||||||
tags AS t3
|
tags AS t3
|
||||||
WHERE
|
WHERE
|
||||||
it1.image_id=?
|
it1.image_id=:image_id
|
||||||
AND it1.tag_id=it2.tag_id
|
AND it1.tag_id=it2.tag_id
|
||||||
AND it2.image_id=it3.image_id
|
AND it2.image_id=it3.image_id
|
||||||
AND t1.tag != 'tagme'
|
AND t1.tag != 'tagme'
|
||||||
@ -249,9 +249,9 @@ class TagList implements Extension {
|
|||||||
AND t3.id = it3.tag_id
|
AND t3.id = it3.tag_id
|
||||||
GROUP BY it3.tag_id
|
GROUP BY it3.tag_id
|
||||||
ORDER BY calc_count DESC
|
ORDER BY calc_count DESC
|
||||||
LIMIT ?
|
LIMIT :tag_list_length
|
||||||
";
|
";
|
||||||
$args = array($image->id, $config->get_int('tag_list_length'));
|
$args = array("image_id"=>$image->id, "tag_list_length"=>$config->get_int('tag_list_length'));
|
||||||
|
|
||||||
$tags = $database->get_all($query, $args);
|
$tags = $database->get_all($query, $args);
|
||||||
if(count($tags) > 0) {
|
if(count($tags) > 0) {
|
||||||
@ -267,11 +267,11 @@ class TagList implements Extension {
|
|||||||
SELECT tags.tag, tags.count as calc_count
|
SELECT tags.tag, tags.count as calc_count
|
||||||
FROM tags, image_tags
|
FROM tags, image_tags
|
||||||
WHERE tags.id = image_tags.tag_id
|
WHERE tags.id = image_tags.tag_id
|
||||||
AND image_tags.image_id = ?
|
AND image_tags.image_id = :image_id
|
||||||
ORDER BY calc_count DESC
|
ORDER BY calc_count DESC
|
||||||
LIMIT ?
|
LIMIT :tag_list_length
|
||||||
";
|
";
|
||||||
$args = array($image->id, $config->get_int('tag_list_length'));
|
$args = array("image_id"=>$image->id, "tag_list_length"=>$config->get_int('tag_list_length'));
|
||||||
|
|
||||||
$tags = $database->get_all($query, $args);
|
$tags = $database->get_all($query, $args);
|
||||||
if(count($tags) > 0) {
|
if(count($tags) > 0) {
|
||||||
@ -288,9 +288,9 @@ class TagList implements Extension {
|
|||||||
FROM tags
|
FROM tags
|
||||||
WHERE count > 0
|
WHERE count > 0
|
||||||
ORDER BY count DESC
|
ORDER BY count DESC
|
||||||
LIMIT ?
|
LIMIT :tag_list_length
|
||||||
";
|
";
|
||||||
$args = array($config->get_int('tag_list_length'));
|
$args = array("tag_list_length"=>$config->get_int('tag_list_length'));
|
||||||
|
|
||||||
$tags = $database->get_all($query, $args);
|
$tags = $database->get_all($query, $args);
|
||||||
if(count($tags) > 0) {
|
if(count($tags) > 0) {
|
||||||
@ -310,9 +310,9 @@ class TagList implements Extension {
|
|||||||
foreach($wild_tags as $tag) {
|
foreach($wild_tags as $tag) {
|
||||||
$tag = str_replace("*", "%", $tag);
|
$tag = str_replace("*", "%", $tag);
|
||||||
$tag = str_replace("?", "_", $tag);
|
$tag = str_replace("?", "_", $tag);
|
||||||
$tag_ids = $database->db->GetCol("SELECT id FROM tags WHERE tag LIKE ?", array($tag));
|
$tag_ids = $database->db->GetCol("SELECT id FROM tags WHERE tag LIKE :tag", array("tag"=>$tag));
|
||||||
// $search_tags = array_merge($search_tags,
|
// $search_tags = array_merge($search_tags,
|
||||||
// $database->db->GetCol("SELECT tag FROM tags WHERE tag LIKE ?", array($tag)));
|
// $database->db->GetCol("SELECT tag FROM tags WHERE tag LIKE :tag", array("tag"=>$tag)));
|
||||||
$tag_id_array = array_merge($tag_id_array, $tag_ids);
|
$tag_id_array = array_merge($tag_id_array, $tag_ids);
|
||||||
$tags_ok = count($tag_ids) > 0;
|
$tags_ok = count($tag_ids) > 0;
|
||||||
if(!$tags_ok) break;
|
if(!$tags_ok) break;
|
||||||
@ -334,9 +334,9 @@ class TagList implements Extension {
|
|||||||
AND it2.tag_id = t2.id
|
AND it2.tag_id = t2.id
|
||||||
GROUP BY t2.tag
|
GROUP BY t2.tag
|
||||||
ORDER BY calc_count
|
ORDER BY calc_count
|
||||||
DESC LIMIT ?
|
DESC LIMIT :limit
|
||||||
";
|
";
|
||||||
$args = array($config->get_int('tag_list_length'));
|
$args = array("limit"=>$config->get_int('tag_list_length'));
|
||||||
|
|
||||||
$related_tags = $database->get_all($query, $args);
|
$related_tags = $database->get_all($query, $args);
|
||||||
print $database->db->ErrorMsg();
|
print $database->db->ErrorMsg();
|
||||||
|
@ -136,6 +136,7 @@ try {
|
|||||||
catch(Exception $e) {
|
catch(Exception $e) {
|
||||||
$version = VERSION;
|
$version = VERSION;
|
||||||
$message = $e->getMessage();
|
$message = $e->getMessage();
|
||||||
|
$trace = var_dump($e->getTrace());
|
||||||
header("HTTP/1.0 500 Internal Error");
|
header("HTTP/1.0 500 Internal Error");
|
||||||
print <<<EOD
|
print <<<EOD
|
||||||
<html>
|
<html>
|
||||||
@ -145,6 +146,7 @@ catch(Exception $e) {
|
|||||||
<body>
|
<body>
|
||||||
<h1>Internal Error</h1>
|
<h1>Internal Error</h1>
|
||||||
<p>$message
|
<p>$message
|
||||||
|
<p>$trace
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
EOD;
|
EOD;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user