Commit a161110a authored by Dries's avatar Dries

- Applied  Michael Caerwyn's "%s -> %d" patch.

- Changed all occurences of '%d' to %d as suggested on the mailing list.
parent 9a62873a
......@@ -38,7 +38,7 @@ function error_handler($errno, $message, $filename, $line, $variables) {
function watchdog($type, $message, $link = NULL) {
global $user;
db_query("INSERT INTO watchdog (uid, type, message, link, location, hostname, timestamp) VALUES ('%d', '%s', '%s', '%s', '%s', '%s', '%s')", $user->uid, $type, $message, $link, request_uri(), getenv("REMOTE_ADDR"), time());
db_query("INSERT INTO watchdog (uid, type, message, link, location, hostname, timestamp) VALUES (%d, '%s', '%s', '%s', '%s', '%s', %d)", $user->uid, $type, $message, $link, request_uri(), getenv("REMOTE_ADDR"), time());
}
function throttle($type, $rate) {
......@@ -659,7 +659,7 @@ function cache_clear_all($cid = NULL) {
db_query("DELETE FROM cache WHERE expire <> 0");
}
else {
db_query("DELETE FROM cache WHERE cid = '%d'", $cid);
db_query("DELETE FROM cache WHERE cid = %d", $cid);
}
}
......
......@@ -113,7 +113,7 @@ function db_next_id($name) {
db_query("LOCK TABLES sequences WRITE");
$id = db_result(db_query("SELECT id FROM sequences WHERE name = '%s'", $name)) + 1;
db_query("REPLACE INTO sequences VALUES ('%s', '%d')", $name, $id);
db_query("REPLACE INTO sequences VALUES ('%s', %d)", $name, $id);
db_query("UNLOCK TABLES");
return $id;
......
......@@ -181,7 +181,7 @@ function theme_init() {
function theme_blocks($region) {
global $user, $REQUEST_URI;
$result = db_query("SELECT * FROM blocks WHERE (status = '1' OR custom = '1') ". ($region != "all" ? "AND region = '%s' " : "") ."ORDER BY weight, module", $region == "left" ? 0 : 1);
$result = db_query("SELECT * FROM blocks WHERE (status = '1' OR custom = '1') ". ($region != "all" ? "AND region = %d " : "") ."ORDER BY weight, module", $region == "left" ? 0 : 1);
while ($result && ($block = db_fetch_object($result))) {
if ((($block->status && (!$user->uid || !$block->custom)) || ($block->custom && $user->block[$block->module][$block->delta])) && (!$block->path || preg_match('/'. str_replace('/', '\/', $block->path) .'/', request_uri()))) {
......
......@@ -359,7 +359,7 @@ function import_save_item($edit) {
db_query("DELETE FROM item WHERE iid = %d", $edit["iid"]);
}
else if ($edit["title"] && $edit["link"]) {
db_query("INSERT INTO item (fid, title, link, author, description, attributes, timestamp) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s')", $edit["fid"], $edit["title"], $edit["link"], $edit["author"], $edit["description"], $edit["attributes"], time());
db_query("INSERT INTO item (fid, title, link, author, description, attributes, timestamp) VALUES (%d, '%s', '%s', '%s', '%s', '%s', %d)", $edit["fid"], $edit["title"], $edit["link"], $edit["author"], $edit["description"], $edit["attributes"], time());
}
}
......@@ -417,7 +417,7 @@ function import_form_feed($edit = array()) {
function import_save_feed($edit) {
if ($edit["fid"] && $edit["title"]) {
db_query("UPDATE feed SET title = '%s', url = '%s', attributes = '%s', refresh = '%s' WHERE fid = %d", $edit["title"], $edit["url"], $edit["attributes"], $edit["refresh"], $edit["fid"]);
db_query("UPDATE feed SET title = '%s', url = '%s', attributes = '%s', refresh = %d WHERE fid = %d", $edit["title"], $edit["url"], $edit["attributes"], $edit["refresh"], $edit["fid"]);
db_query("DELETE FROM item WHERE fid = %d", $edit["fid"]);
}
else if ($edit["fid"]) {
......@@ -427,7 +427,7 @@ function import_save_feed($edit) {
else if ($edit["title"]) {
// a single unique id for bundles and feeds, to use in blocks
$next_id = db_next_id("feed_fid");
db_query("INSERT INTO feed (fid, title, url, attributes, refresh) VALUES (%d, '%s', '%s', '%s', '%s')", $next_id, $edit["title"], $edit["url"], $edit["attributes"], $edit["refresh"]);
db_query("INSERT INTO feed (fid, title, url, attributes, refresh) VALUES (%d, '%s', '%s', '%s', %d)", $next_id, $edit["title"], $edit["url"], $edit["attributes"], $edit["refresh"]);
}
}
......
......@@ -359,7 +359,7 @@ function import_save_item($edit) {
db_query("DELETE FROM item WHERE iid = %d", $edit["iid"]);
}
else if ($edit["title"] && $edit["link"]) {
db_query("INSERT INTO item (fid, title, link, author, description, attributes, timestamp) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s')", $edit["fid"], $edit["title"], $edit["link"], $edit["author"], $edit["description"], $edit["attributes"], time());
db_query("INSERT INTO item (fid, title, link, author, description, attributes, timestamp) VALUES (%d, '%s', '%s', '%s', '%s', '%s', %d)", $edit["fid"], $edit["title"], $edit["link"], $edit["author"], $edit["description"], $edit["attributes"], time());
}
}
......@@ -417,7 +417,7 @@ function import_form_feed($edit = array()) {
function import_save_feed($edit) {
if ($edit["fid"] && $edit["title"]) {
db_query("UPDATE feed SET title = '%s', url = '%s', attributes = '%s', refresh = '%s' WHERE fid = %d", $edit["title"], $edit["url"], $edit["attributes"], $edit["refresh"], $edit["fid"]);
db_query("UPDATE feed SET title = '%s', url = '%s', attributes = '%s', refresh = %d WHERE fid = %d", $edit["title"], $edit["url"], $edit["attributes"], $edit["refresh"], $edit["fid"]);
db_query("DELETE FROM item WHERE fid = %d", $edit["fid"]);
}
else if ($edit["fid"]) {
......@@ -427,7 +427,7 @@ function import_save_feed($edit) {
else if ($edit["title"]) {
// a single unique id for bundles and feeds, to use in blocks
$next_id = db_next_id("feed_fid");
db_query("INSERT INTO feed (fid, title, url, attributes, refresh) VALUES (%d, '%s', '%s', '%s', '%s')", $next_id, $edit["title"], $edit["url"], $edit["attributes"], $edit["refresh"]);
db_query("INSERT INTO feed (fid, title, url, attributes, refresh) VALUES (%d, '%s', '%s', '%s', %d)", $next_id, $edit["title"], $edit["url"], $edit["attributes"], $edit["refresh"]);
}
}
......
......@@ -67,7 +67,7 @@ function block_block($op = "list", $delta = 0) {
return $blocks;
}
else {
$block = db_fetch_object(db_query("SELECT * FROM boxes WHERE bid = '%d'", $delta));
$block = db_fetch_object(db_query("SELECT * FROM boxes WHERE bid = %d", $delta));
$data["subject"] = $block->title;
$data["content"] = ($block->type == 1) ? eval($block->body) : $block->body;
return $data;
......@@ -77,7 +77,7 @@ function block_block($op = "list", $delta = 0) {
function block_admin_save($edit) {
foreach ($edit as $module => $blocks) {
foreach ($blocks as $delta => $block) {
db_query("UPDATE blocks SET region = '%s', status = '%d', custom = '%d', path = '%s', weight = '%d' WHERE module = '%s' AND delta = '%s'",
db_query("UPDATE blocks SET region = %d, status = %d, custom = %d, path = '%s', weight = %d WHERE module = '%s' AND delta = '%s'",
$block["region"], $block["status"], $block["custom"], $block["path"], $block["weight"], $module, $delta);
}
}
......@@ -119,7 +119,7 @@ function _block_rehash($order_by = array("weight")) {
}
// reinsert blocks into table
db_query("INSERT INTO blocks (module, delta, status, weight, region, path, custom) VALUES ('%s', '%s', '%d', '%d', '%d', '%s', '%d')",
db_query("INSERT INTO blocks (module, delta, status, weight, region, path, custom) VALUES ('%s', '%s', %d, %d, %d, '%s', %d)",
$block["module"], $block["delta"], $block["status"], $block["weight"], $block["region"], $block["path"], $block["custom"]);
$blocks[] = $block;
......@@ -215,7 +215,7 @@ function block_admin_preview() {
}
function block_box_get($bid) {
return db_fetch_array(db_query("SELECT * FROM boxes WHERE bid = '%d'", $bid));
return db_fetch_array(db_query("SELECT * FROM boxes WHERE bid = %d", $bid));
}
function block_box_form($edit = array()) {
......@@ -243,18 +243,18 @@ function block_box_save($edit) {
}
if ($edit["bid"]) {
db_query("UPDATE boxes SET title = '%s', body = '%s', info = '%s', type = '%s' WHERE bid = '%d'", $edit["title"], $edit["body"], $edit["info"], $edit["type"], $edit["bid"]);
db_query("UPDATE boxes SET title = '%s', body = '%s', info = '%s', type = %d WHERE bid = %d", $edit["title"], $edit["body"], $edit["info"], $edit["type"], $edit["bid"]);
return t("the block has been updated.");
}
else {
db_query("INSERT INTO boxes (title, body, info, type) VALUES ('%s', '%s', '%s', '%s')", $edit["title"], $edit["body"], $edit["info"], $edit["type"]);
db_query("INSERT INTO boxes (title, body, info, type) VALUES ('%s', '%s', '%s', %d)", $edit["title"], $edit["body"], $edit["info"], $edit["type"]);
return t("the new block has been added.");
}
}
function block_box_delete($bid) {
if ($bid) {
db_query("DELETE FROM boxes WHERE bid = '%d'", $bid);
db_query("DELETE FROM boxes WHERE bid = %d", $bid);
return t("the block has been deleted.");
}
}
......@@ -304,7 +304,7 @@ function block_admin() {
function block_user($type, &$edit, &$user) {
switch ($type) {
case "register_form":
$result = db_query("SELECT * FROM blocks WHERE custom = '%d' ORDER BY module, delta", 1);
$result = db_query("SELECT * FROM blocks WHERE custom = %d ORDER BY module, delta", 1);
while ($block = db_fetch_object($result)) {
$form .= form_hidden("block][$block->module][$block->delta", $block->status);
......@@ -312,7 +312,7 @@ function block_user($type, &$edit, &$user) {
return $form;
case "edit_form":
$result = db_query("SELECT * FROM blocks WHERE custom = '%d' ORDER BY module, delta", 1);
$result = db_query("SELECT * FROM blocks WHERE custom = %d ORDER BY module, delta", 1);
while ($block = db_fetch_object($result)) {
$data = module_invoke($block->module, "block", "list");
......
......@@ -67,7 +67,7 @@ function block_block($op = "list", $delta = 0) {
return $blocks;
}
else {
$block = db_fetch_object(db_query("SELECT * FROM boxes WHERE bid = '%d'", $delta));
$block = db_fetch_object(db_query("SELECT * FROM boxes WHERE bid = %d", $delta));
$data["subject"] = $block->title;
$data["content"] = ($block->type == 1) ? eval($block->body) : $block->body;
return $data;
......@@ -77,7 +77,7 @@ function block_block($op = "list", $delta = 0) {
function block_admin_save($edit) {
foreach ($edit as $module => $blocks) {
foreach ($blocks as $delta => $block) {
db_query("UPDATE blocks SET region = '%s', status = '%d', custom = '%d', path = '%s', weight = '%d' WHERE module = '%s' AND delta = '%s'",
db_query("UPDATE blocks SET region = %d, status = %d, custom = %d, path = '%s', weight = %d WHERE module = '%s' AND delta = '%s'",
$block["region"], $block["status"], $block["custom"], $block["path"], $block["weight"], $module, $delta);
}
}
......@@ -119,7 +119,7 @@ function _block_rehash($order_by = array("weight")) {
}
// reinsert blocks into table
db_query("INSERT INTO blocks (module, delta, status, weight, region, path, custom) VALUES ('%s', '%s', '%d', '%d', '%d', '%s', '%d')",
db_query("INSERT INTO blocks (module, delta, status, weight, region, path, custom) VALUES ('%s', '%s', %d, %d, %d, '%s', %d)",
$block["module"], $block["delta"], $block["status"], $block["weight"], $block["region"], $block["path"], $block["custom"]);
$blocks[] = $block;
......@@ -215,7 +215,7 @@ function block_admin_preview() {
}
function block_box_get($bid) {
return db_fetch_array(db_query("SELECT * FROM boxes WHERE bid = '%d'", $bid));
return db_fetch_array(db_query("SELECT * FROM boxes WHERE bid = %d", $bid));
}
function block_box_form($edit = array()) {
......@@ -243,18 +243,18 @@ function block_box_save($edit) {
}
if ($edit["bid"]) {
db_query("UPDATE boxes SET title = '%s', body = '%s', info = '%s', type = '%s' WHERE bid = '%d'", $edit["title"], $edit["body"], $edit["info"], $edit["type"], $edit["bid"]);
db_query("UPDATE boxes SET title = '%s', body = '%s', info = '%s', type = %d WHERE bid = %d", $edit["title"], $edit["body"], $edit["info"], $edit["type"], $edit["bid"]);
return t("the block has been updated.");
}
else {
db_query("INSERT INTO boxes (title, body, info, type) VALUES ('%s', '%s', '%s', '%s')", $edit["title"], $edit["body"], $edit["info"], $edit["type"]);
db_query("INSERT INTO boxes (title, body, info, type) VALUES ('%s', '%s', '%s', %d)", $edit["title"], $edit["body"], $edit["info"], $edit["type"]);
return t("the new block has been added.");
}
}
function block_box_delete($bid) {
if ($bid) {
db_query("DELETE FROM boxes WHERE bid = '%d'", $bid);
db_query("DELETE FROM boxes WHERE bid = %d", $bid);
return t("the block has been deleted.");
}
}
......@@ -304,7 +304,7 @@ function block_admin() {
function block_user($type, &$edit, &$user) {
switch ($type) {
case "register_form":
$result = db_query("SELECT * FROM blocks WHERE custom = '%d' ORDER BY module, delta", 1);
$result = db_query("SELECT * FROM blocks WHERE custom = %d ORDER BY module, delta", 1);
while ($block = db_fetch_object($result)) {
$form .= form_hidden("block][$block->module][$block->delta", $block->status);
......@@ -312,7 +312,7 @@ function block_user($type, &$edit, &$user) {
return $form;
case "edit_form":
$result = db_query("SELECT * FROM blocks WHERE custom = '%d' ORDER BY module, delta", 1);
$result = db_query("SELECT * FROM blocks WHERE custom = %d ORDER BY module, delta", 1);
while ($block = db_fetch_object($result)) {
$data = module_invoke($block->module, "block", "list");
......
......@@ -88,7 +88,7 @@ function blog_feed_user($uid = 0) {
$account = $user;
}
$result = db_query_range("SELECT n.nid, n.title, n.teaser, n.created, u.name, u.uid FROM node n LEFT JOIN users u ON n.uid = u.uid WHERE n.type = 'blog' AND u.uid = '%d' AND n.status = 1 ORDER BY n.nid DESC", $uid, 0, 15);
$result = db_query_range("SELECT n.nid, n.title, n.teaser, n.created, u.name, u.uid FROM node n LEFT JOIN users u ON n.uid = u.uid WHERE n.type = 'blog' AND u.uid = %d AND n.status = 1 ORDER BY n.nid DESC", $uid, 0, 15);
$channel["title"] = $account->name. "'s blog";
$channel["link"] = url("blog/view/$uid");
$channel["description"] = $term->description;
......@@ -153,7 +153,7 @@ function blog_form(&$node, &$help, &$error) {
$node->body = "<i>". $blog->body ."</i> [". l($blog->name, "node/view/$nid") ."]";
}
if ($iid && $item = db_fetch_object(db_query("SELECT i.*, f.title as ftitle, f.link as flink FROM item i, feed f WHERE i.iid = '%d' AND i.fid = f.fid", $iid))) {
if ($iid && $item = db_fetch_object(db_query("SELECT i.*, f.title as ftitle, f.link as flink FROM item i, feed f WHERE i.iid = %d AND i.fid = f.fid", $iid))) {
$node->title = $item->title;
$node->body = "<a href=\"$item->link\">$item->title</a> - <i>". check_output($item->description) ."</i> [<a href=\"$item->flink\">$item->ftitle</a>]\n";
}
......
......@@ -88,7 +88,7 @@ function blog_feed_user($uid = 0) {
$account = $user;
}
$result = db_query_range("SELECT n.nid, n.title, n.teaser, n.created, u.name, u.uid FROM node n LEFT JOIN users u ON n.uid = u.uid WHERE n.type = 'blog' AND u.uid = '%d' AND n.status = 1 ORDER BY n.nid DESC", $uid, 0, 15);
$result = db_query_range("SELECT n.nid, n.title, n.teaser, n.created, u.name, u.uid FROM node n LEFT JOIN users u ON n.uid = u.uid WHERE n.type = 'blog' AND u.uid = %d AND n.status = 1 ORDER BY n.nid DESC", $uid, 0, 15);
$channel["title"] = $account->name. "'s blog";
$channel["link"] = url("blog/view/$uid");
$channel["description"] = $term->description;
......@@ -153,7 +153,7 @@ function blog_form(&$node, &$help, &$error) {
$node->body = "<i>". $blog->body ."</i> [". l($blog->name, "node/view/$nid") ."]";
}
if ($iid && $item = db_fetch_object(db_query("SELECT i.*, f.title as ftitle, f.link as flink FROM item i, feed f WHERE i.iid = '%d' AND i.fid = f.fid", $iid))) {
if ($iid && $item = db_fetch_object(db_query("SELECT i.*, f.title as ftitle, f.link as flink FROM item i, feed f WHERE i.iid = %d AND i.fid = f.fid", $iid))) {
$node->title = $item->title;
$node->body = "<a href=\"$item->link\">$item->title</a> - <i>". check_output($item->description) ."</i> [<a href=\"$item->flink\">$item->ftitle</a>]\n";
}
......
......@@ -267,7 +267,7 @@ function bloggerapi_node_recent($num) {
global $user;
if (($num == 0) or ($num > 100)) $num = 50;
$result = db_query_range("SELECT n.*, u.name FROM node n LEFT JOIN users u ON n.uid = u.uid WHERE n.uid = '%d' ORDER BY n.nid DESC", $user->uid, 0, $num);
$result = db_query_range("SELECT n.*, u.name FROM node n LEFT JOIN users u ON n.uid = u.uid WHERE n.uid = %d ORDER BY n.nid DESC", $user->uid, 0, $num);
if ($result) {
while ($blog = db_fetch_object($result)) {
$body = "<title>$blog->title</title>\n". $blog->body;
......
......@@ -96,7 +96,7 @@ function book_link($type, $node = 0, $main = 0) {
function book_load($node) {
global $user;
$book = db_fetch_object(db_query("SELECT format, parent, weight, log FROM book WHERE nid = '%d'", $node->nid));
$book = db_fetch_object(db_query("SELECT format, parent, weight, log FROM book WHERE nid = %d", $node->nid));
if (strstr(request_uri(), "node/edit")) {
......@@ -129,15 +129,15 @@ function book_load($node) {
}
function book_insert($node) {
db_query("INSERT INTO book (nid, format, parent, weight, log) VALUES ('%d', '%d', '%d', '%d', '%s')", $node->nid, $node->format, $node->parent, $node->weight, $node->log);
db_query("INSERT INTO book (nid, format, parent, weight, log) VALUES (%d, %d, %d, %d, '%s')", $node->nid, $node->format, $node->parent, $node->weight, $node->log);
}
function book_update($node) {
db_query("UPDATE book SET format = '%d', parent = '%d', weight = '%d', log = '%s' WHERE nid = '%d'", $node->format, $node->parent, $node->weight, $node->log, $node->nid);
db_query("UPDATE book SET format = %d, parent = %d, weight = %d, log = '%s' WHERE nid = %d", $node->format, $node->parent, $node->weight, $node->log, $node->nid);
}
function book_delete(&$node) {
db_query("DELETE FROM book WHERE nid = '%d'", $node->nid);
db_query("DELETE FROM book WHERE nid = %d", $node->nid);
}
function book_validate(&$node) {
......@@ -206,24 +206,24 @@ function book_node_link($node = 0) {
}
if ($op == t("Add to book outline")) {
db_query("INSERT INTO book (nid, parent, weight) VALUES ('%d', '%s', '%s')", $node->nid, $edit["parent"], $edit["weight"]);
db_query("INSERT INTO book (nid, parent, weight) VALUES (%d, %d, %d)", $node->nid, $edit["parent"], $edit["weight"]);
$output .= status(t("added the node to the book."));
}
if ($op == t("Update book outline")) {
db_query("UPDATE book SET parent = '%s', weight = '%s' WHERE nid = '%d'", $edit["parent"], $edit["weight"], $node->nid);
db_query("UPDATE book SET parent = %d, weight = %d WHERE nid = %d", $edit["parent"], $edit["weight"], $node->nid);
$output .= status(t("updated the book outline."));
}
if ($op == t("Remove from book outline")) {
db_query("DELETE FROM book WHERE nid = '%d'", $node->nid);
db_query("DELETE FROM book WHERE nid = %d", $node->nid);
$output .= status(t("removed the node form the book."));
}
$output .= "<h3>". t("Edit book outline for node <i>") . "$node->title</i></h3>";
if ($edit["nid"]) {
$page = db_fetch_object(db_query("SELECT * FROM book WHERE nid = '%d'", $node->nid));
$page = db_fetch_object(db_query("SELECT * FROM book WHERE nid = %d", $node->nid));
$output .= form_select(t("Parent"), "parent", $page->parent, book_toc(), t("The parent subject or category the page belongs in."));
$output .= form_weight(t("Weight"), "weight", $node->weight, 15, t("The heavier pages will sink and the lighter pages will be positioned nearer the top."));
......@@ -286,7 +286,7 @@ function book_revision_load($page, $conditions = array()) {
** Return the path (call stack) to a certain book page.
*/
function book_location($node, $nodes = array()) {
$parent = db_fetch_object(db_query("SELECT n.nid, n.title, b.parent FROM node n LEFT JOIN book b ON n.nid = b.nid WHERE n.nid = '%d'", $node->parent));
$parent = db_fetch_object(db_query("SELECT n.nid, n.title, b.parent FROM node n LEFT JOIN book b ON n.nid = b.nid WHERE n.nid = %d", $node->parent));
if ($parent->title) {
$nodes = book_location($parent, $nodes);
array_push($nodes, $parent);
......@@ -561,7 +561,7 @@ function book_page() {
}
function book_print($id = "", $depth = 1) {
$result = db_query("SELECT n.nid FROM node n LEFT JOIN book b ON n.nid = b.nid WHERE n.status = 1 AND n.nid = '%d' AND (n.moderate = 0 OR n.revisions IS NOT NULL) ORDER BY b.weight, n.title", $id);
$result = db_query("SELECT n.nid FROM node n LEFT JOIN book b ON n.nid = b.nid WHERE n.status = 1 AND n.nid = %d AND (n.moderate = 0 OR n.revisions IS NOT NULL) ORDER BY b.weight, n.title", $id);
while ($page = db_fetch_object($result)) {
// load the node:
......@@ -622,7 +622,7 @@ function book_admin_view_line($node, $depth = 0) {
}
function book_admin_view_book($nid, $depth = 1) {
$result = db_query("SELECT n.nid FROM node n LEFT JOIN book b ON n.nid = b.nid WHERE b.parent = '%d' ORDER BY b.weight, n.title", $nid);
$result = db_query("SELECT n.nid FROM node n LEFT JOIN book b ON n.nid = b.nid WHERE b.parent = %d ORDER BY b.weight, n.title", $nid);
while ($node = db_fetch_object($result)) {
$node = node_load(array("nid" => $node->nid));
......@@ -658,18 +658,18 @@ function book_admin_save($nid, $edit = array()) {
** Check to see whether the title needs updating:
*/
$title = db_result(db_query("SELECT title FROM node WHERE nid = '%d'", $nid));
$title = db_result(db_query("SELECT title FROM node WHERE nid = %d", $nid));
if ($title != $value["title"]) {
db_query("UPDATE node SET title = '%s' WHERE nid = '%d'", $value["title"], $nid);
db_query("UPDATE node SET title = '%s' WHERE nid = %d", $value["title"], $nid);
}
/*
** Check to see whether the weight needs updating:
*/
$weight = db_result(db_query("SELECT weight FROM book WHERE nid = '%d'", $nid));
$weight = db_result(db_query("SELECT weight FROM book WHERE nid = %d", $nid));
if ($weight != $value["weight"]) {
db_query("UPDATE book SET weight = '%d' WHERE nid = '%d'", $value["weight"], $nid);
db_query("UPDATE book SET weight = %d WHERE nid = %d", $value["weight"], $nid);
}
}
......
......@@ -96,7 +96,7 @@ function book_link($type, $node = 0, $main = 0) {
function book_load($node) {
global $user;
$book = db_fetch_object(db_query("SELECT format, parent, weight, log FROM book WHERE nid = '%d'", $node->nid));
$book = db_fetch_object(db_query("SELECT format, parent, weight, log FROM book WHERE nid = %d", $node->nid));
if (strstr(request_uri(), "node/edit")) {
......@@ -129,15 +129,15 @@ function book_load($node) {
}
function book_insert($node) {
db_query("INSERT INTO book (nid, format, parent, weight, log) VALUES ('%d', '%d', '%d', '%d', '%s')", $node->nid, $node->format, $node->parent, $node->weight, $node->log);
db_query("INSERT INTO book (nid, format, parent, weight, log) VALUES (%d, %d, %d, %d, '%s')", $node->nid, $node->format, $node->parent, $node->weight, $node->log);
}
function book_update($node) {
db_query("UPDATE book SET format = '%d', parent = '%d', weight = '%d', log = '%s' WHERE nid = '%d'", $node->format, $node->parent, $node->weight, $node->log, $node->nid);
db_query("UPDATE book SET format = %d, parent = %d, weight = %d, log = '%s' WHERE nid = %d", $node->format, $node->parent, $node->weight, $node->log, $node->nid);
}
function book_delete(&$node) {
db_query("DELETE FROM book WHERE nid = '%d'", $node->nid);
db_query("DELETE FROM book WHERE nid = %d", $node->nid);
}
function book_validate(&$node) {
......@@ -206,24 +206,24 @@ function book_node_link($node = 0) {
}
if ($op == t("Add to book outline")) {
db_query("INSERT INTO book (nid, parent, weight) VALUES ('%d', '%s', '%s')", $node->nid, $edit["parent"], $edit["weight"]);
db_query("INSERT INTO book (nid, parent, weight) VALUES (%d, %d, %d)", $node->nid, $edit["parent"], $edit["weight"]);
$output .= status(t("added the node to the book."));
}
if ($op == t("Update book outline")) {
db_query("UPDATE book SET parent = '%s', weight = '%s' WHERE nid = '%d'", $edit["parent"], $edit["weight"], $node->nid);
db_query("UPDATE book SET parent = %d, weight = %d WHERE nid = %d", $edit["parent"], $edit["weight"], $node->nid);
$output .= status(t("updated the book outline."));
}
if ($op == t("Remove from book outline")) {
db_query("DELETE FROM book WHERE nid = '%d'", $node->nid);
db_query("DELETE FROM book WHERE nid = %d", $node->nid);
$output .= status(t("removed the node form the book."));
}
$output .= "<h3>". t("Edit book outline for node <i>") . "$node->title</i></h3>";
if ($edit["nid"]) {
$page = db_fetch_object(db_query("SELECT * FROM book WHERE nid = '%d'", $node->nid));
$page = db_fetch_object(db_query("SELECT * FROM book WHERE nid = %d", $node->nid));
$output .= form_select(t("Parent"), "parent", $page->parent, book_toc(), t("The parent subject or category the page belongs in."));
$output .= form_weight(t("Weight"), "weight", $node->weight, 15, t("The heavier pages will sink and the lighter pages will be positioned nearer the top."));
......@@ -286,7 +286,7 @@ function book_revision_load($page, $conditions = array()) {
** Return the path (call stack) to a certain book page.
*/
function book_location($node, $nodes = array()) {
$parent = db_fetch_object(db_query("SELECT n.nid, n.title, b.parent FROM node n LEFT JOIN book b ON n.nid = b.nid WHERE n.nid = '%d'", $node->parent));
$parent = db_fetch_object(db_query("SELECT n.nid, n.title, b.parent FROM node n LEFT JOIN book b ON n.nid = b.nid WHERE n.nid = %d", $node->parent));
if ($parent->title) {
$nodes = book_location($parent, $nodes);
array_push($nodes, $parent);
......@@ -561,7 +561,7 @@ function book_page() {
}
function book_print($id = "", $depth = 1) {
$result = db_query("SELECT n.nid FROM node n LEFT JOIN book b ON n.nid = b.nid WHERE n.status = 1 AND n.nid = '%d' AND (n.moderate = 0 OR n.revisions IS NOT NULL) ORDER BY b.weight, n.title", $id);
$result = db_query("SELECT n.nid FROM node n LEFT JOIN book b ON n.nid = b.nid WHERE n.status = 1 AND n.nid = %d AND (n.moderate = 0 OR n.revisions IS NOT NULL) ORDER BY b.weight, n.title", $id);
while ($page = db_fetch_object($result)) {
// load the node:
......@@ -622,7 +622,7 @@ function book_admin_view_line($node, $depth = 0) {
}
function book_admin_view_book($nid, $depth = 1) {
$result = db_query("SELECT n.nid FROM node n LEFT JOIN book b ON n.nid = b.nid WHERE b.parent = '%d' ORDER BY b.weight, n.title", $nid);
$result = db_query("SELECT n.nid FROM node n LEFT JOIN book b ON n.nid = b.nid WHERE b.parent = %d ORDER BY b.weight, n.title", $nid);
while ($node = db_fetch_object($result)) {
$node = node_load(array("nid" => $node->nid));
......@@ -658,18 +658,18 @@ function book_admin_save($nid, $edit = array()) {
** Check to see whether the title needs updating:
*/
$title = db_result(db_query("SELECT title FROM node WHERE nid = '%d'", $nid));
$title = db_result(db_query("SELECT title FROM node WHERE nid = %d", $nid));
if ($title != $value["title"]) {
db_query("UPDATE node SET title = '%s' WHERE nid = '%d'", $value["title"], $nid);
db_query("UPDATE node SET title = '%s' WHERE nid = %d", $value["title"], $nid);
}
/*
** Check to see whether the weight needs updating:
*/
$weight = db_result(db_query("SELECT weight FROM book WHERE nid = '%d'", $nid));
$weight = db_result(db_query("SELECT weight FROM book WHERE nid = %d", $nid));
if ($weight != $value["weight"]) {
db_query("UPDATE book SET weight = '%d' WHERE nid = '%d'", $value["weight"], $nid);
db_query("UPDATE book SET weight = %d WHERE nid = %d", $value["weight"], $nid);
}
}
......
......@@ -109,18 +109,18 @@ function cloud_form($edit = array()) {
}
function cloud_get_site($sid) {
return db_fetch_array(db_query("SELECT * FROM site WHERE sid = '%d'", $sid));
return db_fetch_array(db_query("SELECT * FROM site WHERE sid = %d", $sid));
}
function cloud_save($edit) {
if ($edit["sid"] && $edit["name"]) {
db_query("UPDATE site SET name = '%s', link = '%s', feed = '%s', refresh = '%s', threshold = '%s' WHERE sid = '%d'", $edit["name"], $edit["link"], $edit["feed"], $edit["refresh"], $edit["threshold"], $edit["sid"]);
db_query("UPDATE site SET name = '%s', link = '%s', feed = '%s', refresh = %d, threshold = %d WHERE sid = %d", $edit["name"], $edit["link"], $edit["feed"], $edit["refresh"], $edit["threshold"], $edit["sid"]);
}
else if ($edit["sid"]) {
db_query("DELETE FROM site WHERE sid = '%d'", $edit["sid"]);
db_query("DELETE FROM site WHERE sid = %d", $edit["sid"]);
}
else {
db_query("INSERT INTO site (name, link, feed, refresh, threshold) VALUES ('%s', '%s', '%s', '%s', '%s')", $edit["name"], $edit["link"], $edit["feed"], $edit["refresh"], $edit["threshold"]);
db_query("INSERT INTO site (name, link, feed, refresh, threshold) VALUES ('%s', '%s', '%s', %d, %d)", $edit["name"], $edit["link"], $edit["feed"], $edit["refresh"], $edit["threshold"]);
}
}
......
......@@ -270,7 +270,7 @@ function comment_post($edit) {
$edit["cid"] = db_next_id("comments_cid");
db_query("INSERT INTO comments (cid, nid, pid, uid, subject, comment, hostname, timestamp, status, score, users) VALUES (%d, %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s')", $edit["cid"], $edit["nid"], $edit["pid"], $user->uid, $edit["subject"], $edit["comment"], getenv("REMOTE_ADDR"), time(), $status, $score, $users);
db_query("INSERT INTO comments (cid, nid, pid, uid, subject, comment, hostname, timestamp, status, score, users) VALUES (%d, %d, %d, %d, '%s', '%s', '%s', %d, %d, %d, '%s')", $edit["cid"], $edit["nid"], $edit["pid"], $user->uid, $edit["subject"], $edit["comment"], getenv("REMOTE_ADDR"), time(), $status, $score, $users);
/*
** Tell the other modules a new comment has been submitted:
......@@ -790,7 +790,7 @@ function comment_delete($edit) {
}
function comment_save($id, $edit) {
db_query("UPDATE comments SET subject = '%s', comment = '%s', status = '%s' WHERE cid = %d", filter($edit["subject"]), filter($edit["comment"]), $edit["status"], $id);
db_query("UPDATE comments SET subject = '%s', comment = '%s', status = %d WHERE cid = %d", filter($edit["subject"]), filter($edit["comment"]), $edit["status"], $id);
watchdog("special", "comment: modified '". $edit["subject"] ."'");
return "updated comment.";
}
......
......@@ -270,7 +270,7 @@ function comment_post($edit) {
$edit["cid"] = db_next_id("comments_cid");
db_query("INSERT INTO comments (cid, nid, pid, uid, subject, comment, hostname, timestamp, status, score, users) VALUES (%d, %d, %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s')", $edit["cid"], $edit["nid"], $edit["pid"], $user->uid, $edit["subject"], $edit["comment"], getenv("REMOTE_ADDR"), time(), $status, $score, $users);
db_query("INSERT INTO comments (cid, nid, pid, uid, subject, comment, hostname, timestamp, status, score, users) VALUES (%d, %d, %d, %d, '%s', '%s', '%s', %d, %d, %d, '%s')", $edit["cid"], $edit["nid"], $edit["pid"], $user->uid, $edit["subject"], $edit["comment"], getenv("REMOTE_ADDR"), time(), $status, $score, $users);
/*
** Tell the other modules a new comment has been submitted:
......@@ -790,7 +790,7 @@ function comment_delete($edit) {
}
function comment_save($id, $edit) {
db_query("UPDATE comments SET subject = '%s', comment = '%s', status = '%s' WHERE cid = %d", filter($edit["subject"]), filter($edit["comment"]), $edit["status"], $id);
db_query("UPDATE comments SET subject = '%s', comment = '%s', status = %d WHERE cid = %d", filter($edit["subject"]), filter($edit["comment"]), $edit["status"], $id);
watchdog("special", "comment: modified '". $edit["subject"] ."'");
return "updated comment.";
}
......
......@@ -72,7 +72,7 @@ function drupal_directory_ping($arguments) {
if ($link && $name && $mail && $slogan && $mission) {
db_query("DELETE FROM directory WHERE link = '%s' OR mail = '%s'", $link, $mail);
db_query("INSERT INTO directory (link, name, mail, slogan, mission, timestamp) VALUES ('%s', '%s', '%s', '%s', '%s', '%s')", $link, $name, $mail, $slogan, $mission, time());
db_query("INSERT INTO directory (link, name, mail, slogan, mission, timestamp) VALUES ('%s', '%s', '%s', '%s', '%s', %d)", $link, $name, $mail, $slogan, $mission, time());
watchdog("message", "directory: ping from '$name' ($link)");
......
......@@ -72,7 +72,7 @@ function drupal_directory_ping($arguments) {
if ($link && $name && $mail && $slogan && $mission) {
db_query("DELETE FROM directory WHERE link = '%s' OR mail = '%s'", $link, $mail);
db_query("INSERT INTO directory (link, name, mail, slogan, mission, timestamp) VALUES ('%s', '%s', '%s', '%s', '%s', '%s')", $link, $name, $mail, $slogan, $mission, time());
db_query("INSERT INTO directory (link, name, mail, slogan, mission, timestamp) VALUES ('%s', '%s', '%s', '%s', '%s', %d)", $link, $name, $mail, $slogan, $mission, time());
watchdog("message", "directory: ping from '$name' ($link)");
......
......@@ -70,7 +70,7 @@ function forum_taxonomy($op, $type, $object) {
}
function forum_load($node) {
$forum = db_fetch_object(db_query("SELECT * FROM forum WHERE nid = '%d'", $node->nid));
$forum = db_fetch_object(db_query("SELECT * FROM forum WHERE nid = %d", $node->nid));
return $forum;
}
......@@ -121,7 +121,7 @@ function forum_link($type, $node = 0, $main = 0) {
if (!$main && $type == "node" && $node->type == "forum") {
// get previous and next topic
$result = db_query("SELECT n.nid, title, body, GREATEST(n.created, MAX(c.timestamp)) AS date_sort, COUNT(c.nid) AS num_comments FROM node n, forum f LEFT JOIN comments c ON c.nid = n.nid WHERE n.nid = f.nid AND f.tid = '%d' AND n.status = 1 GROUP BY n.nid ORDER BY ". _forum_get_topic_order(isset($user->sortby) ? $user->sortby : variable_get("forum_order",1)), $node->tid);
$result = db_query("SELECT n.nid, title, body, GREATEST(n.created, MAX(c.timestamp)) AS date_sort, COUNT(c.nid) AS num_comments FROM node n, forum f LEFT JOIN comments c ON c.nid = n.nid WHERE n.nid = f.nid AND f.tid = %d AND n.status = 1 GROUP BY n.nid ORDER BY ". _forum_get_topic_order(isset($user->sortby) ? $user->sortby : variable_get("forum_order",1)), $node->tid);
while ($topic = db_fetch_object($result)) {
if ($stop == 1) {
......@@ -240,12 +240,12 @@ function forum_form(&$node, &$help, &$error) {
function forum_insert($node) {
$node->icon = _forum_decode_icon($node);
db_query("INSERT INTO forum (nid, icon, shadow, tid) VALUES ('%d', '%s', '%d', '%d')", $node->nid, $node->icon, $node->shadow, $node->tid[0]);
db_query("INSERT INTO forum (nid, icon, shadow, tid) VALUES (%d, '%s', %d, %d)", $node->nid, $node->icon, $node->shadow, $node->tid[0]);
}
function forum_update($node) {
$node->icon = _forum_decode_icon($node);
db_query("UPDATE forum SET icon = '%s', shadow = '%d', tid = '%d' WHERE nid = '%d'", $node->icon, $node->shadow, $node->tid[0], $node->nid);
db_query("UPDATE forum SET icon = '%s', shadow = %d, tid = %d WHERE nid = %d", $node->icon, $node->shadow, $node->tid[0], $node->nid);
}
function _forum_decode_icon($node) {
......@@ -265,21 +265,21 @@ function _forum_decode_icon($node) {
}
function forum_delete(&$node) {
db_query("DELETE FROM forum WHERE nid = '%d'", $node->nid);