diff --git a/contrib/ipban/main.php b/contrib/ipban/main.php
index 679678d4..0df30dbf 100644
--- a/contrib/ipban/main.php
+++ b/contrib/ipban/main.php
@@ -89,7 +89,7 @@ class IPBan implements Extension {
}
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");
}
}
@@ -211,9 +211,9 @@ class IPBan implements Extension {
SELECT bans.*, users.name as banner_name
FROM bans
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
- ", array(time()));
+ ", array("end_timestamp"=>time()));
$database->cache->set("ip_bans", $bans, 600);
diff --git a/ext/comment/main.php b/ext/comment/main.php
index f98ba3c7..19c2d516 100644
--- a/ext/comment/main.php
+++ b/ext/comment/main.php
@@ -51,7 +51,7 @@ class Comment {
public static function count_comments_by_user($user) {
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() {
@@ -180,7 +180,7 @@ class CommentList extends SimpleExtension {
public function onImageDeletion(ImageDeletionEvent $event) {
global $database;
$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");
}
@@ -191,7 +191,7 @@ class CommentList extends SimpleExtension {
public function onCommentDeletion(CommentDeletionEvent $event) {
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}");
}
@@ -261,9 +261,9 @@ class CommentList extends SimpleExtension {
FROM comments
GROUP BY image_id
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);
@@ -297,8 +297,8 @@ class CommentList extends SimpleExtension {
FROM comments
LEFT JOIN users ON comments.owner_id=users.id
ORDER BY comments.id DESC
- LIMIT ?
- ", array($config->get_int('comment_count')));
+ LIMIT :limit
+ ", array("limit"=>$config->get_int('comment_count')));
$comments = array();
foreach($rows as $row) {
$comments[] = new Comment($row);
@@ -318,9 +318,9 @@ class CommentList extends SimpleExtension {
comments.posted as posted
FROM comments
LEFT JOIN users ON comments.owner_id=users.id
- WHERE comments.image_id=?
+ WHERE comments.image_id=:image_id
ORDER BY comments.id ASC
- ", array($i_image_id));
+ ", array("image_id"=>$i_image_id));
$comments = array();
foreach($rows as $row) {
$comments[] = new Comment($row);
diff --git a/ext/tag_list/main.php b/ext/tag_list/main.php
index 32000351..541a1696 100644
--- a/ext/tag_list/main.php
+++ b/ext/tag_list/main.php
@@ -46,8 +46,8 @@ class TagList implements Extension {
if(($event instanceof PageRequestEvent) && $event->page_matches("api/internal/tag_list/complete")) {
$all = $database->get_all(
- "SELECT tag FROM tags WHERE tag LIKE ? AND count > 0 LIMIT 10",
- array($_GET["s"]."%"));
+ "SELECT tag FROM tags WHERE tag LIKE :search AND count > 0 LIMIT 10",
+ array("search"=>$_GET["s"]."%"));
$res = array();
foreach($all as $row) {$res[] = $row["tag"];}
@@ -130,11 +130,11 @@ class TagList implements Extension {
$result = $database->execute("
SELECT
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
- WHERE count >= ?
+ WHERE count >= :tags_min
ORDER BY tag
- ", array($tags_min, $tags_min));
+ ", array("tags_min"=>$tags_min));
$tag_data = $result->GetArray();
$html = "";
@@ -154,8 +154,8 @@ class TagList implements Extension {
$tags_min = $this->get_tags_min();
$result = $database->execute(
- "SELECT tag,count FROM tags WHERE count >= ? ORDER BY tag",
- array($tags_min));
+ "SELECT tag,count FROM tags WHERE count >= :tags_min ORDER BY tag",
+ array("tags_min"=>$tags_min));
$tag_data = $result->GetArray();
$html = "";
@@ -179,8 +179,8 @@ class TagList implements Extension {
$tags_min = $this->get_tags_min();
$result = $database->execute(
- "SELECT tag,count,FLOOR(LOG(count)) AS scaled FROM tags WHERE count >= ? ORDER BY count DESC, tag ASC",
- array($tags_min));
+ "SELECT tag,count,FLOOR(LOG(count)) AS scaled FROM tags WHERE count >= :tags_min ORDER BY count DESC, tag ASC",
+ array("tags_min"=>$tags_min));
$tag_data = $result->GetArray();
$html = "Results grouped by loge(n)";
@@ -240,7 +240,7 @@ class TagList implements Extension {
tags AS t1,
tags AS t3
WHERE
- it1.image_id=?
+ it1.image_id=:image_id
AND it1.tag_id=it2.tag_id
AND it2.image_id=it3.image_id
AND t1.tag != 'tagme'
@@ -249,9 +249,9 @@ class TagList implements Extension {
AND t3.id = it3.tag_id
GROUP BY it3.tag_id
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);
if(count($tags) > 0) {
@@ -267,11 +267,11 @@ class TagList implements Extension {
SELECT tags.tag, tags.count as calc_count
FROM tags, image_tags
WHERE tags.id = image_tags.tag_id
- AND image_tags.image_id = ?
+ AND image_tags.image_id = :image_id
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);
if(count($tags) > 0) {
@@ -288,9 +288,9 @@ class TagList implements Extension {
FROM tags
WHERE count > 0
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);
if(count($tags) > 0) {
@@ -310,9 +310,9 @@ class TagList implements Extension {
foreach($wild_tags as $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,
- // $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);
$tags_ok = count($tag_ids) > 0;
if(!$tags_ok) break;
@@ -334,9 +334,9 @@ class TagList implements Extension {
AND it2.tag_id = t2.id
GROUP BY t2.tag
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);
print $database->db->ErrorMsg();
diff --git a/index.php b/index.php
index f488a113..4b04ef0f 100644
--- a/index.php
+++ b/index.php
@@ -136,6 +136,7 @@ try {
catch(Exception $e) {
$version = VERSION;
$message = $e->getMessage();
+ $trace = var_dump($e->getTrace());
header("HTTP/1.0 500 Internal Error");
print <<
@@ -145,6 +146,7 @@ catch(Exception $e) {
Internal Error
$message
+
$trace