forked from Cavemanon/cavepaintings
more pdo compat
This commit is contained in:
@@ -67,12 +67,12 @@ class AliasEditor extends SimpleExtension {
|
||||
|
||||
$alias_per_page = $config->get_int('alias_items_per_page', 30);
|
||||
|
||||
$query = "SELECT oldtag, newtag FROM aliases ORDER BY newtag ASC LIMIT ? OFFSET ?";
|
||||
$alias = $database->db->GetAssoc($query,
|
||||
array($alias_per_page, $page_number * $alias_per_page)
|
||||
$query = "SELECT oldtag, newtag FROM aliases ORDER BY newtag ASC LIMIT :limit OFFSET :offset";
|
||||
$alias = $database->get_pairs($query,
|
||||
array("limit"=>$alias_per_page, "offset"=>$page_number * $alias_per_page)
|
||||
);
|
||||
|
||||
$total_pages = ceil($database->db->GetOne("SELECT COUNT(*) FROM aliases") / $alias_per_page);
|
||||
$total_pages = ceil($database->get_one("SELECT COUNT(*) FROM aliases") / $alias_per_page);
|
||||
|
||||
$this->theme->display_aliases($page, $alias, $user->is_admin(), $page_number + 1, $total_pages);
|
||||
}
|
||||
@@ -104,7 +104,7 @@ class AliasEditor extends SimpleExtension {
|
||||
public function onAddAlias(AddAliasEvent $event) {
|
||||
global $database;
|
||||
$pair = array($event->oldtag, $event->newtag);
|
||||
if($database->db->GetRow("SELECT * FROM aliases WHERE oldtag=? AND lower(newtag)=lower(?)", $pair)) {
|
||||
if($database->get_row("SELECT * FROM aliases WHERE oldtag=? AND lower(newtag)=lower(?)", $pair)) {
|
||||
throw new AddAliasException("That alias already exists");
|
||||
}
|
||||
else {
|
||||
|
@@ -397,7 +397,7 @@ class CommentList extends SimpleExtension {
|
||||
|
||||
private function is_dupe($image_id, $comment) {
|
||||
global $database;
|
||||
return ($database->db->GetRow("SELECT * FROM comments WHERE image_id=? AND comment=?", array($image_id, $comment)));
|
||||
return ($database->get_row("SELECT * FROM comments WHERE image_id=? AND comment=?", array($image_id, $comment)));
|
||||
}
|
||||
|
||||
private function add_comment_wrapper($image_id, $user, $comment, $event) {
|
||||
|
@@ -234,13 +234,20 @@ class ImageIO extends SimpleExtension {
|
||||
$database->Execute(
|
||||
"INSERT INTO images(
|
||||
owner_id, owner_ip, filename, filesize,
|
||||
hash, ext, width, height, posted, source)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, now(), ?)",
|
||||
array($user->id, $_SERVER['REMOTE_ADDR'], $image->filename, $image->filesize,
|
||||
$image->hash, $image->ext, $image->width, $image->height, $image->source));
|
||||
hash, ext, width, height, posted, source
|
||||
)
|
||||
VALUES (
|
||||
:owner_id, :owner_ip, :filename, :filesize,
|
||||
:hash, :ext, :width, :height, now(), :source
|
||||
)",
|
||||
array(
|
||||
"owner_id"=>$user->id, "owner_ip"=>$_SERVER['REMOTE_ADDR'], "filename"=>$image->filename, "filesize"=>$image->filesize,
|
||||
"hash"=>$image->hash, "ext"=>$image->ext, "width"=>$image->width, "height"=>$image->height, "source"=>$image->source
|
||||
)
|
||||
);
|
||||
if($database->engine->name == "pgsql") {
|
||||
$database->Execute("UPDATE users SET image_count = image_count+1 WHERE id = ? ", array($user->id));
|
||||
$image->id = $database->db->GetOne("SELECT id FROM images WHERE hash=?", array($image->hash));
|
||||
$image->id = $database->get_one("SELECT id FROM images WHERE hash=?", array($image->hash));
|
||||
}
|
||||
else {
|
||||
$image->id = $database->db->lastInsertId();
|
||||
|
@@ -286,7 +286,7 @@ class UserPage extends SimpleExtension {
|
||||
"Username contains invalid characters. Allowed characters are ".
|
||||
"letters, numbers, dash, and underscore");
|
||||
}
|
||||
else if($database->db->GetRow("SELECT * FROM users WHERE name = ?", array($name))) {
|
||||
else if($database->get_row("SELECT * FROM users WHERE name = ?", array($name))) {
|
||||
throw new UserCreationException("That username is already taken");
|
||||
}
|
||||
}
|
||||
@@ -298,7 +298,7 @@ class UserPage extends SimpleExtension {
|
||||
$email = (!empty($event->email)) ? $event->email : null;
|
||||
|
||||
// if there are currently no admins, the new user should be one
|
||||
$need_admin = ($database->db->GetOne("SELECT COUNT(*) FROM users WHERE admin IN ('Y', 't', '1')") == 0);
|
||||
$need_admin = ($database->get_one("SELECT COUNT(*) FROM users WHERE admin IN ('Y', 't', '1')") == 0);
|
||||
$admin = $need_admin ? 'Y' : 'N';
|
||||
|
||||
$database->Execute(
|
||||
@@ -427,28 +427,28 @@ class UserPage extends SimpleExtension {
|
||||
// ips {{{
|
||||
private function count_upload_ips($duser) {
|
||||
global $database;
|
||||
$rows = $database->db->GetAssoc("
|
||||
$rows = $database->get_pairs("
|
||||
SELECT
|
||||
owner_ip,
|
||||
COUNT(images.id) AS count,
|
||||
MAX(posted) AS most_recent
|
||||
FROM images
|
||||
WHERE owner_id=?
|
||||
WHERE owner_id=:id
|
||||
GROUP BY owner_ip
|
||||
ORDER BY most_recent DESC", array($duser->id), false, true);
|
||||
ORDER BY most_recent DESC", array("id"=>$duser->id));
|
||||
return $rows;
|
||||
}
|
||||
private function count_comment_ips($duser) {
|
||||
global $database;
|
||||
$rows = $database->db->GetAssoc("
|
||||
$rows = $database->get_pairs("
|
||||
SELECT
|
||||
owner_ip,
|
||||
COUNT(comments.id) AS count,
|
||||
MAX(posted) AS most_recent
|
||||
FROM comments
|
||||
WHERE owner_id=?
|
||||
WHERE owner_id=:id
|
||||
GROUP BY owner_ip
|
||||
ORDER BY most_recent DESC", array($duser->id), false, true);
|
||||
ORDER BY most_recent DESC", array("id"=>$duser->id));
|
||||
return $rows;
|
||||
}
|
||||
// }}}
|
||||
|
Reference in New Issue
Block a user