merge pdo fixes
This commit is contained in:
commit
6f22207603
24
contrib/numeric_score/main.php
Normal file → Executable file
24
contrib/numeric_score/main.php
Normal file → Executable file
@ -185,7 +185,7 @@ class NumericScore implements Extension {
|
||||
}
|
||||
|
||||
if($event instanceof ImageDeletionEvent) {
|
||||
$database->execute("DELETE FROM numeric_score_votes WHERE image_id=?", array($event->image->id));
|
||||
$database->execute("DELETE FROM numeric_score_votes WHERE image_id=:id", array("id" => $event->image->id));
|
||||
}
|
||||
|
||||
if($event instanceof ParseLinkTemplateEvent) {
|
||||
@ -239,8 +239,8 @@ class NumericScore implements Extension {
|
||||
global $config;
|
||||
|
||||
if($config->get_int("ext_numeric_score_version") < 1) {
|
||||
$database->Execute("ALTER TABLE images ADD COLUMN numeric_score INTEGER NOT NULL DEFAULT 0");
|
||||
$database->Execute("CREATE INDEX images__numeric_score ON images(numeric_score)");
|
||||
$database->execute("ALTER TABLE images ADD COLUMN numeric_score INTEGER NOT NULL DEFAULT 0");
|
||||
$database->execute("CREATE INDEX images__numeric_score ON images(numeric_score)");
|
||||
$database->create_table("numeric_score_votes", "
|
||||
image_id INTEGER NOT NULL,
|
||||
user_id INTEGER NOT NULL,
|
||||
@ -253,24 +253,24 @@ class NumericScore implements Extension {
|
||||
$config->set_int("ext_numeric_score_version", 1);
|
||||
}
|
||||
if($config->get_int("ext_numeric_score_version") < 2) {
|
||||
$database->Execute("CREATE INDEX numeric_score_votes__user_votes ON numeric_score_votes(user_id, score)");
|
||||
$database->execute("CREATE INDEX numeric_score_votes__user_votes ON numeric_score_votes(user_id, score)");
|
||||
$config->set_int("ext_numeric_score_version", 2);
|
||||
}
|
||||
}
|
||||
|
||||
private function add_vote($image_id, $user_id, $score) {
|
||||
global $database;
|
||||
$database->Execute(
|
||||
"DELETE FROM numeric_score_votes WHERE image_id=? AND user_id=?",
|
||||
array($image_id, $user_id));
|
||||
$database->execute(
|
||||
"DELETE FROM numeric_score_votes WHERE image_id=:imageid AND user_id=:userid",
|
||||
array("imageid" => $image_id, "userid" => $user_id));
|
||||
if($score != 0) {
|
||||
$database->Execute(
|
||||
"INSERT INTO numeric_score_votes(image_id, user_id, score) VALUES(?, ?, ?)",
|
||||
array($image_id, $user_id, $score));
|
||||
$database->execute(
|
||||
"INSERT INTO numeric_score_votes(image_id, user_id, score) VALUES(:imageid, :userid, :score)",
|
||||
array("imageid" => $image_id, "userid" => $user_id, "score" => $score));
|
||||
}
|
||||
$database->Execute(
|
||||
"UPDATE images SET numeric_score=(SELECT SUM(score) FROM numeric_score_votes WHERE image_id=?) WHERE id=?",
|
||||
array($image_id, $image_id));
|
||||
"UPDATE images SET numeric_score=(SELECT SUM(score) FROM numeric_score_votes WHERE image_id=:imageid) WHERE id=:id",
|
||||
array("imageid" => $image_id, "id" => $image_id));
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
24
contrib/pm/main.php
Normal file → Executable file
24
contrib/pm/main.php
Normal file → Executable file
@ -93,13 +93,13 @@ class PrivMsg extends SimpleExtension {
|
||||
switch($event->get_arg(0)) {
|
||||
case "read":
|
||||
$pm_id = int_escape($event->get_arg(1));
|
||||
$pm = $database->get_row("SELECT * FROM private_message WHERE id = ?", array($pm_id));
|
||||
$pm = $database->get_row("SELECT * FROM private_message WHERE id = :id", array("id" => $pm_id));
|
||||
if(is_null($pm)) {
|
||||
$this->theme->display_error($page, "No such PM", "There is no PM #$pm_id");
|
||||
}
|
||||
else if(($pm["to_id"] == $user->id) || $user->is_admin()) {
|
||||
$from_user = User::by_id(int_escape($pm["from_id"]));
|
||||
$database->get_row("UPDATE private_message SET is_read='Y' WHERE id = ?", array($pm_id));
|
||||
$database->get_row("UPDATE private_message SET is_read='Y' WHERE id = :id", array("id" => $pm_id));
|
||||
$this->theme->display_message($page, $from_user, $user, new PM($pm));
|
||||
}
|
||||
else {
|
||||
@ -109,12 +109,12 @@ class PrivMsg extends SimpleExtension {
|
||||
case "delete":
|
||||
if($user->check_auth_token()) {
|
||||
$pm_id = int_escape($_POST["pm_id"]);
|
||||
$pm = $database->get_row("SELECT * FROM private_message WHERE id = ?", array($pm_id));
|
||||
$pm = $database->get_row("SELECT * FROM private_message WHERE id = :id", array("id" => $pm_id));
|
||||
if(is_null($pm)) {
|
||||
$this->theme->display_error($page, "No such PM", "There is no PM #$pm_id");
|
||||
}
|
||||
else if(($pm["to_id"] == $user->id) || $user->is_admin()) {
|
||||
$database->execute("DELETE FROM private_message WHERE id = ?", array($pm_id));
|
||||
$database->execute("DELETE FROM private_message WHERE id = :id", array("id" => $pm_id));
|
||||
log_info("pm", "Deleted PM #$pm_id");
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect($_SERVER["HTTP_REFERER"]);
|
||||
@ -146,9 +146,9 @@ class PrivMsg extends SimpleExtension {
|
||||
INSERT INTO private_message(
|
||||
from_id, from_ip, to_id,
|
||||
sent_date, subject, message)
|
||||
VALUES(?, ?, ?, now(), ?, ?)",
|
||||
array($event->pm->from_id, $event->pm->from_ip,
|
||||
$event->pm->to_id, $event->pm->subject, $event->pm->message)
|
||||
VALUES(:fromid, :fromip, :toid, now(), :subject, :message)",
|
||||
array("fromid" => $event->pm->from_id, "fromip" => $event->pm->from_ip,
|
||||
"toid" => $event->pm->to_id, "subject" => $event->pm->subject, "message" => $event->pm->message)
|
||||
);
|
||||
log_info("pm", "Sent PM to User #{$event->pm->to_id}");
|
||||
}
|
||||
@ -158,11 +158,11 @@ class PrivMsg extends SimpleExtension {
|
||||
global $database;
|
||||
|
||||
$arr = $database->get_all("
|
||||
SELECT private_message.*,user_from.name AS from_name
|
||||
FROM private_message
|
||||
JOIN users AS user_from ON user_from.id=from_id
|
||||
WHERE to_id = ?
|
||||
", array($user->id));
|
||||
SELECT private_message.*,user_from.name AS from_name
|
||||
FROM private_message
|
||||
JOIN users AS user_from ON user_from.id=from_id
|
||||
WHERE to_id = :toid",
|
||||
array("toid" => $user->id));
|
||||
$pms = array();
|
||||
foreach($arr as $pm) {
|
||||
$pms[] = new PM($pm);
|
||||
|
10
ext/alias_editor/main.php
Normal file → Executable file
10
ext/alias_editor/main.php
Normal file → Executable file
@ -45,7 +45,7 @@ class AliasEditor extends SimpleExtension {
|
||||
else if($event->get_arg(0) == "remove") {
|
||||
if($user->is_admin()) {
|
||||
if(isset($_POST['oldtag'])) {
|
||||
$database->Execute("DELETE FROM aliases WHERE oldtag=?", array($_POST['oldtag']));
|
||||
$database->execute("DELETE FROM aliases WHERE oldtag=:oldtag", array("oldtag" => $_POST['oldtag']));
|
||||
log_info("alias_editor", "Deleted alias for ".$_POST['oldtag']);
|
||||
|
||||
$page->set_mode("redirect");
|
||||
@ -103,12 +103,12 @@ class AliasEditor extends SimpleExtension {
|
||||
|
||||
public function onAddAlias(AddAliasEvent $event) {
|
||||
global $database;
|
||||
$pair = array($event->oldtag, $event->newtag);
|
||||
if($database->get_row("SELECT * FROM aliases WHERE oldtag=? AND lower(newtag)=lower(?)", $pair)) {
|
||||
$pair = array("oldtag" => $event->oldtag, "newtag" => $event->newtag);
|
||||
if($database->get_row("SELECT * FROM aliases WHERE oldtag=:oldtag AND lower(newtag)=lower(:newtag)", $pair)) {
|
||||
throw new AddAliasException("That alias already exists");
|
||||
}
|
||||
else {
|
||||
$database->Execute("INSERT INTO aliases(oldtag, newtag) VALUES(?, ?)", $pair);
|
||||
$database->execute("INSERT INTO aliases(oldtag, newtag) VALUES(:oldtag, :newtag)", $pair);
|
||||
log_info("alias_editor", "Added alias for {$event->oldtag} -> {$event->newtag}");
|
||||
}
|
||||
}
|
||||
@ -134,7 +134,7 @@ class AliasEditor extends SimpleExtension {
|
||||
foreach(explode("\n", $csv) as $line) {
|
||||
$parts = explode(",", $line);
|
||||
if(count($parts) == 2) {
|
||||
$database->execute("INSERT INTO aliases(oldtag, newtag) VALUES(?, ?)", $parts);
|
||||
$database->execute("INSERT INTO aliases(oldtag, newtag) VALUES(:oldtag, :newtag)", array("oldtag" => $parts[0], "newtag" => $parts[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user