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) {
|
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) {
|
if($event instanceof ParseLinkTemplateEvent) {
|
||||||
@ -239,8 +239,8 @@ class NumericScore implements Extension {
|
|||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
if($config->get_int("ext_numeric_score_version") < 1) {
|
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("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("CREATE INDEX images__numeric_score ON images(numeric_score)");
|
||||||
$database->create_table("numeric_score_votes", "
|
$database->create_table("numeric_score_votes", "
|
||||||
image_id INTEGER NOT NULL,
|
image_id INTEGER NOT NULL,
|
||||||
user_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);
|
$config->set_int("ext_numeric_score_version", 1);
|
||||||
}
|
}
|
||||||
if($config->get_int("ext_numeric_score_version") < 2) {
|
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);
|
$config->set_int("ext_numeric_score_version", 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function add_vote($image_id, $user_id, $score) {
|
private function add_vote($image_id, $user_id, $score) {
|
||||||
global $database;
|
global $database;
|
||||||
$database->Execute(
|
$database->execute(
|
||||||
"DELETE FROM numeric_score_votes WHERE image_id=? AND user_id=?",
|
"DELETE FROM numeric_score_votes WHERE image_id=:imageid AND user_id=:userid",
|
||||||
array($image_id, $user_id));
|
array("imageid" => $image_id, "userid" => $user_id));
|
||||||
if($score != 0) {
|
if($score != 0) {
|
||||||
$database->Execute(
|
$database->execute(
|
||||||
"INSERT INTO numeric_score_votes(image_id, user_id, score) VALUES(?, ?, ?)",
|
"INSERT INTO numeric_score_votes(image_id, user_id, score) VALUES(:imageid, :userid, :score)",
|
||||||
array($image_id, $user_id, $score));
|
array("imageid" => $image_id, "userid" => $user_id, "score" => $score));
|
||||||
}
|
}
|
||||||
$database->Execute(
|
$database->Execute(
|
||||||
"UPDATE images SET numeric_score=(SELECT SUM(score) FROM numeric_score_votes WHERE image_id=?) WHERE id=?",
|
"UPDATE images SET numeric_score=(SELECT SUM(score) FROM numeric_score_votes WHERE image_id=:imageid) WHERE id=:id",
|
||||||
array($image_id, $image_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)) {
|
switch($event->get_arg(0)) {
|
||||||
case "read":
|
case "read":
|
||||||
$pm_id = int_escape($event->get_arg(1));
|
$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)) {
|
if(is_null($pm)) {
|
||||||
$this->theme->display_error($page, "No such PM", "There is no PM #$pm_id");
|
$this->theme->display_error($page, "No such PM", "There is no PM #$pm_id");
|
||||||
}
|
}
|
||||||
else if(($pm["to_id"] == $user->id) || $user->is_admin()) {
|
else if(($pm["to_id"] == $user->id) || $user->is_admin()) {
|
||||||
$from_user = User::by_id(int_escape($pm["from_id"]));
|
$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));
|
$this->theme->display_message($page, $from_user, $user, new PM($pm));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -109,12 +109,12 @@ class PrivMsg extends SimpleExtension {
|
|||||||
case "delete":
|
case "delete":
|
||||||
if($user->check_auth_token()) {
|
if($user->check_auth_token()) {
|
||||||
$pm_id = int_escape($_POST["pm_id"]);
|
$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)) {
|
if(is_null($pm)) {
|
||||||
$this->theme->display_error($page, "No such PM", "There is no PM #$pm_id");
|
$this->theme->display_error($page, "No such PM", "There is no PM #$pm_id");
|
||||||
}
|
}
|
||||||
else if(($pm["to_id"] == $user->id) || $user->is_admin()) {
|
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");
|
log_info("pm", "Deleted PM #$pm_id");
|
||||||
$page->set_mode("redirect");
|
$page->set_mode("redirect");
|
||||||
$page->set_redirect($_SERVER["HTTP_REFERER"]);
|
$page->set_redirect($_SERVER["HTTP_REFERER"]);
|
||||||
@ -146,9 +146,9 @@ class PrivMsg extends SimpleExtension {
|
|||||||
INSERT INTO private_message(
|
INSERT INTO private_message(
|
||||||
from_id, from_ip, to_id,
|
from_id, from_ip, to_id,
|
||||||
sent_date, subject, message)
|
sent_date, subject, message)
|
||||||
VALUES(?, ?, ?, now(), ?, ?)",
|
VALUES(:fromid, :fromip, :toid, now(), :subject, :message)",
|
||||||
array($event->pm->from_id, $event->pm->from_ip,
|
array("fromid" => $event->pm->from_id, "fromip" => $event->pm->from_ip,
|
||||||
$event->pm->to_id, $event->pm->subject, $event->pm->message)
|
"toid" => $event->pm->to_id, "subject" => $event->pm->subject, "message" => $event->pm->message)
|
||||||
);
|
);
|
||||||
log_info("pm", "Sent PM to User #{$event->pm->to_id}");
|
log_info("pm", "Sent PM to User #{$event->pm->to_id}");
|
||||||
}
|
}
|
||||||
@ -158,11 +158,11 @@ class PrivMsg extends SimpleExtension {
|
|||||||
global $database;
|
global $database;
|
||||||
|
|
||||||
$arr = $database->get_all("
|
$arr = $database->get_all("
|
||||||
SELECT private_message.*,user_from.name AS from_name
|
SELECT private_message.*,user_from.name AS from_name
|
||||||
FROM private_message
|
FROM private_message
|
||||||
JOIN users AS user_from ON user_from.id=from_id
|
JOIN users AS user_from ON user_from.id=from_id
|
||||||
WHERE to_id = ?
|
WHERE to_id = :toid",
|
||||||
", array($user->id));
|
array("toid" => $user->id));
|
||||||
$pms = array();
|
$pms = array();
|
||||||
foreach($arr as $pm) {
|
foreach($arr as $pm) {
|
||||||
$pms[] = new PM($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") {
|
else if($event->get_arg(0) == "remove") {
|
||||||
if($user->is_admin()) {
|
if($user->is_admin()) {
|
||||||
if(isset($_POST['oldtag'])) {
|
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']);
|
log_info("alias_editor", "Deleted alias for ".$_POST['oldtag']);
|
||||||
|
|
||||||
$page->set_mode("redirect");
|
$page->set_mode("redirect");
|
||||||
@ -103,12 +103,12 @@ class AliasEditor extends SimpleExtension {
|
|||||||
|
|
||||||
public function onAddAlias(AddAliasEvent $event) {
|
public function onAddAlias(AddAliasEvent $event) {
|
||||||
global $database;
|
global $database;
|
||||||
$pair = array($event->oldtag, $event->newtag);
|
$pair = array("oldtag" => $event->oldtag, "newtag" => $event->newtag);
|
||||||
if($database->get_row("SELECT * FROM aliases WHERE oldtag=? AND lower(newtag)=lower(?)", $pair)) {
|
if($database->get_row("SELECT * FROM aliases WHERE oldtag=:oldtag AND lower(newtag)=lower(:newtag)", $pair)) {
|
||||||
throw new AddAliasException("That alias already exists");
|
throw new AddAliasException("That alias already exists");
|
||||||
}
|
}
|
||||||
else {
|
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}");
|
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) {
|
foreach(explode("\n", $csv) as $line) {
|
||||||
$parts = explode(",", $line);
|
$parts = explode(",", $line);
|
||||||
if(count($parts) == 2) {
|
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