Commit 337b3c9d authored by Dries's avatar Dries

- Committed a slightly modified version of Slavica's table prefix patch.
parent 1c2fc43b
Drupal x.x.x, xxxx-xx-xx (to be released)
------------------------
- database backend:
* added support for database table prefxing.
Drupal 4.2.0, xxxx-xx-xx (to be released) Drupal 4.2.0, xxxx-xx-xx (to be released)
------------------------ ------------------------
...@@ -69,7 +75,7 @@ Drupal 4.0.0, 2002-06-15 ...@@ -69,7 +75,7 @@ Drupal 4.0.0, 2002-06-15
- themes: - themes:
* cleaned up the theme system. * cleaned up the theme system.
* moved themes that are not maintained to contributions CVS repository. * moved themes that are not maintained to contributions CVS repository.
- database abstraction: - database backend:
* changed to PEAR database abstraction layer. * changed to PEAR database abstraction layer.
* using ANSI SQL queries to be more portable. * using ANSI SQL queries to be more portable.
- rewrote the user system: - rewrote the user system:
......
...@@ -37,12 +37,12 @@ function error_handler($errno, $message, $filename, $line, $variables) { ...@@ -37,12 +37,12 @@ function error_handler($errno, $message, $filename, $line, $variables) {
function watchdog($type, $message, $link = NULL) { function watchdog($type, $message, $link = NULL) {
global $user; global $user;
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()); 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) { function throttle($type, $rate) {
if (!user_access("access administration pages")) { if (!user_access("access administration pages")) {
if ($throttle = db_fetch_object(db_query("SELECT * FROM watchdog WHERE type = '$type' AND hostname = '". getenv("REMOTE_ADDR") ."' AND ". time() ." - timestamp < $rate"))) { if ($throttle = db_fetch_object(db_query("SELECT * FROM {watchdog} WHERE type = '$type' AND hostname = '". getenv("REMOTE_ADDR") ."' AND ". time() ." - timestamp < $rate"))) {
watchdog("warning", "throttle: '". getenv("REMOTE_ADDR") ."' exceeded submission rate - $throttle->type"); watchdog("warning", "throttle: '". getenv("REMOTE_ADDR") ."' exceeded submission rate - $throttle->type");
die(message_throttle()); die(message_throttle());
} }
...@@ -169,7 +169,7 @@ function t($string, $args = 0) { ...@@ -169,7 +169,7 @@ function t($string, $args = 0) {
} }
function variable_init($conf = array()) { function variable_init($conf = array()) {
$result = db_query("SELECT * FROM variable"); $result = db_query("SELECT * FROM {variable} ");
while ($variable = db_fetch_object($result)) { while ($variable = db_fetch_object($result)) {
if (!isset($conf[$variable->name])) { if (!isset($conf[$variable->name])) {
$conf[$variable->name] = unserialize($variable->value); $conf[$variable->name] = unserialize($variable->value);
...@@ -188,8 +188,8 @@ function variable_get($name, $default) { ...@@ -188,8 +188,8 @@ function variable_get($name, $default) {
function variable_set($name, $value) { function variable_set($name, $value) {
global $conf; global $conf;
db_query("DELETE FROM variable WHERE name = '%s'", $name); db_query("DELETE FROM {variable} WHERE name = '%s'", $name);
db_query("INSERT INTO variable (name, value) VALUES ('%s', '%s')", $name, serialize($value)); db_query("INSERT INTO {variable} (name, value) VALUES ('%s', '%s')", $name, serialize($value));
$conf[$name] = $value; $conf[$name] = $value;
} }
...@@ -197,7 +197,7 @@ function variable_set($name, $value) { ...@@ -197,7 +197,7 @@ function variable_set($name, $value) {
function variable_del($name) { function variable_del($name) {
global $conf; global $conf;
db_query("DELETE FROM variable WHERE name = '%s'", $name); db_query("DELETE FROM {variable} WHERE name = '%s'", $name);
unset($conf[$name]); unset($conf[$name]);
} }
...@@ -490,7 +490,7 @@ function xss_check_input_data($data) { ...@@ -490,7 +490,7 @@ function xss_check_input_data($data) {
// check attributes: // check attributes:
$match += preg_match("/\W(dynsrc|datasrc|data|lowsrc|on[a-z]+)\s*=[^>]+?>/i", $data); $match += preg_match("/\W(dynsrc|datasrc|data|lowsrc|on[a-z]+)\s*=[^>]+?>/i", $data);
// check tags: // check tags:
$match += preg_match("/<\s*(applet|script|object|style|embed|form|blink|meta|html|frame|iframe|layer|ilayer|head|frameset|xml)/i", $data); $match += preg_match("/<\s*(applet|script|object|style|embed|form|blink|meta|html|frame|iframe|layer|ilayer|head|frameset|xml)/i", $data);
...@@ -703,25 +703,25 @@ function format_size($size) { ...@@ -703,25 +703,25 @@ function format_size($size) {
} }
function cache_get($key) { function cache_get($key) {
$cache = db_fetch_object(db_query("SELECT data, created FROM cache WHERE cid = '%s'", $key)); $cache = db_fetch_object(db_query("SELECT data, created FROM {cache} WHERE cid = '%s'", $key));
return $cache->data ? $cache : 0; return $cache->data ? $cache : 0;
} }
function cache_set($cid, $data, $expire = 0) { function cache_set($cid, $data, $expire = 0) {
if (db_fetch_object(db_query("SELECT cid FROM cache WHERE cid = '%s'", $cid))) { if (db_fetch_object(db_query("SELECT cid FROM {cache} WHERE cid = '%s'", $cid))) {
db_query("UPDATE cache SET data = '%s', created = %d, expire = %d WHERE cid = '%s'", $data, time(), $expire, $cid); db_query("UPDATE {cache} SET data = '%s', created = %d, expire = %d WHERE cid = '%s'", $data, time(), $expire, $cid);
} }
else { else {
db_query("INSERT INTO cache (cid, data, created, expire) VALUES('%s', '%s', %d, %d)", $cid, $data, time(), $expire); db_query("INSERT INTO {cache} (cid, data, created, expire) VALUES('%s', '%s', %d, %d)", $cid, $data, time(), $expire);
} }
} }
function cache_clear_all($cid = NULL) { function cache_clear_all($cid = NULL) {
if (empty($cid)) { if (empty($cid)) {
db_query("DELETE FROM cache WHERE expire <> 0"); db_query("DELETE FROM {cache} WHERE expire <> 0");
} }
else { else {
db_query("DELETE FROM cache WHERE cid = %d", $cid); db_query("DELETE FROM {cache} WHERE cid = %d", $cid);
} }
} }
......
...@@ -15,9 +15,14 @@ ...@@ -15,9 +15,14 @@
# $db_url = "mysql://user:password@hostname/database"; # $db_url = "mysql://user:password@hostname/database";
# $db_url = "pgsql://user:password@hostname/database"; # $db_url = "pgsql://user:password@hostname/database";
# $db_url = "mssql://user:password@hostname/database"; # $db_url = "mssql://user:password@hostname/database";
$db_url = "mysql://drupal:drupal@localhost/drupal"; $db_url = "mysql://drupal:drupal@localhost/drupal";
# If $db_prefix is specified all database table names will be
# prepended with this string. Be sure to use valid database
# characters only, usually alphanumeric and underscore. If no
# prefixes are desired, set to empty string "".
$db_prefix = "";
# #
# Base URL: # Base URL:
# #
......
<?php <?php
// $Id$
function db_prefix_tables($sql) {
global $db_prefix;
return strtr($sql, array("{" => $db_prefix, "}" => ""));
}
$db_type = substr($db_url, 0, strpos($db_url, "://")); $db_type = substr($db_url, 0, strpos($db_url, "://"));
...@@ -11,4 +18,4 @@ ...@@ -11,4 +18,4 @@
db_connect($db_url); db_connect($db_url);
?> ?>
\ No newline at end of file
...@@ -23,6 +23,7 @@ function db_connect($url) { ...@@ -23,6 +23,7 @@ function db_connect($url) {
function db_query($query) { function db_query($query) {
$args = func_get_args(); $args = func_get_args();
$query = db_prefix_tables($query);
if (count($args) > 1) { if (count($args) > 1) {
$args = array_map("check_query", $args); $args = array_map("check_query", $args);
$args[0] = $query; $args[0] = $query;
...@@ -36,6 +37,7 @@ function db_query($query) { ...@@ -36,6 +37,7 @@ function db_query($query) {
// debug version // debug version
function db_queryd($query) { function db_queryd($query) {
$args = func_get_args(); $args = func_get_args();
$query = db_prefix_tables($query);
if (count($args) > 1) { if (count($args) > 1) {
$args = array_map("check_query", $args); $args = array_map("check_query", $args);
$args[0] = $query; $args[0] = $query;
...@@ -111,9 +113,9 @@ function db_next_id($name) { ...@@ -111,9 +113,9 @@ function db_next_id($name) {
** when needed ** when needed
*/ */
db_query("LOCK TABLES sequences WRITE"); db_query("LOCK TABLES {sequences} WRITE");
$id = db_result(db_query("SELECT id FROM sequences WHERE name = '%s'", $name)) + 1; $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"); db_query("UNLOCK TABLES");
return $id; return $id;
...@@ -136,11 +138,13 @@ function db_query_range($query) { ...@@ -136,11 +138,13 @@ function db_query_range($query) {
$from = array_pop($args); $from = array_pop($args);
if (count(func_get_args()) > 3) { if (count(func_get_args()) > 3) {
$args = array_map("check_query", $args); $args = array_map("check_query", $args);
$query = db_prefix_tables($query);
$args[0] = $query; $args[0] = $query;
$query = call_user_func_array("sprintf", $args); $query = call_user_func_array("sprintf", $args);
} }
else { else {
$query = func_get_arg(0); $query = func_get_arg(0);
$query = db_prefix_tables($query);
} }
$query .= " LIMIT $from, $count"; $query .= " LIMIT $from, $count";
return _db_query($query); return _db_query($query);
......
...@@ -25,6 +25,7 @@ function db_connect($url) { ...@@ -25,6 +25,7 @@ function db_connect($url) {
function db_query($query) { function db_query($query) {
$args = func_get_args(); $args = func_get_args();
$query = db_prefix_tables($query);
if (count($args) > 1) { if (count($args) > 1) {
$args = array_map("check_query", $args); $args = array_map("check_query", $args);
$args[0] = $query; $args[0] = $query;
...@@ -38,6 +39,7 @@ function db_query($query) { ...@@ -38,6 +39,7 @@ function db_query($query) {
// debug version // debug version
function db_queryd($query) { function db_queryd($query) {
$args = func_get_args(); $args = func_get_args();
$query = db_prefix_tables($query);
if (count($args) > 1) { if (count($args) > 1) {
$args = array_map("check_query", $args); $args = array_map("check_query", $args);
$args[0] = $query; $args[0] = $query;
...@@ -147,11 +149,14 @@ function db_query_range($query) { ...@@ -147,11 +149,14 @@ function db_query_range($query) {
$from = array_pop($args); $from = array_pop($args);
if (count(func_get_args()) > 3) { if (count(func_get_args()) > 3) {
$args = array_map("check_query", $args); $args = array_map("check_query", $args);
$query = db_prefix_tables($query);
$args[0] = $query; $args[0] = $query;
$result = $db_handle->limitQuery(call_user_func_array("sprintf", $args), $from, $count); $result = $db_handle->limitQuery(call_user_func_array("sprintf", $args), $from, $count);
} }
else { else {
$result = $db_handle->limitQuery(func_get_arg(0), $from, $count); $query = func_get_arg(0);
$query = db_prefix_tables($query);
$result = $db_handle->limitQuery( $query, $from, $count);
} }
if (variable_get("dev_query", 0)) { if (variable_get("dev_query", 0)) {
......
...@@ -50,7 +50,7 @@ function module_list($refresh = 0) { ...@@ -50,7 +50,7 @@ function module_list($refresh = 0) {
if (!$list) { if (!$list) {
$list = array("admin" => "admin", "system" => "system", "user" => "user", "watchdog" => "watchdog"); $list = array("admin" => "admin", "system" => "system", "user" => "user", "watchdog" => "watchdog");
$result = db_query("SELECT name, filename FROM system WHERE type = 'module' AND status = '1' ORDER BY name"); $result = db_query("SELECT name, filename FROM {system} WHERE type = 'module' AND status = '1' ORDER BY name");
while ($module = db_fetch_object($result)) { while ($module = db_fetch_object($result)) {
if (file_exists($module->filename)) { if (file_exists($module->filename)) {
$list[$module->name] = $module->name; $list[$module->name] = $module->name;
......
...@@ -84,7 +84,7 @@ function footer() { ...@@ -84,7 +84,7 @@ function footer() {
print $output; print $output;
} }
} } // End of BaseTheme class //
function theme_mark() { function theme_mark() {
/* /*
...@@ -130,7 +130,7 @@ function theme_list($refresh = 0) { ...@@ -130,7 +130,7 @@ function theme_list($refresh = 0) {
if (!$list) { if (!$list) {
$list = array(); $list = array();
$result = db_query("SELECT * FROM system where type = 'theme' AND status = '1' ORDER BY name"); $result = db_query("SELECT * FROM {system} where type = 'theme' AND status = '1' ORDER BY name");
while ($theme = db_fetch_object($result)) { while ($theme = db_fetch_object($result)) {
if (file_exists($theme->filename)) { if (file_exists($theme->filename)) {
$list[$theme->name] = $theme; $list[$theme->name] = $theme;
...@@ -189,7 +189,7 @@ function theme_init() { ...@@ -189,7 +189,7 @@ function theme_init() {
function theme_blocks($region) { function theme_blocks($region) {
global $user; global $user;
$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); $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))) { 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($block->path, str_replace("?q=", "", request_uri())))) { if ((($block->status && (!$user->uid || !$block->custom)) || ($block->custom && $user->block[$block->module][$block->delta])) && (!$block->path || preg_match($block->path, str_replace("?q=", "", request_uri())))) {
......
...@@ -644,8 +644,9 @@ function parseResponse($data="") { ...@@ -644,8 +644,9 @@ function parseResponse($data="") {
$xmlrpc_value=new xmlrpcval; $xmlrpc_value=new xmlrpcval;
if ($this->debug) if ($this->debug)
print "<pre>---GOT---\n" . htmlspecialchars($data) . ##print "<pre>---GOT---\n" . htmlspecialchars($data) . "\n---END---\n</pre>";
"\n---END---\n</pre>"; ##print "<p>---GOT---\n" . nl2br(htmlspecialchars($data)) . "\n---END---\n</p>";
print "<p>---GOT---\n" . nl2br($data) . "\n---END---\n</p>";
if ($data=="") { if ($data=="") {
error_log("No response received from server."); error_log("No response received from server.");
$r=new xmlrpcresp(0, $xmlrpcerr["no_data"], $r=new xmlrpcresp(0, $xmlrpcerr["no_data"],
......
...@@ -95,14 +95,14 @@ function import_link($type) { ...@@ -95,14 +95,14 @@ function import_link($type) {
} }
function import_cron() { function import_cron() {
$result = db_query("SELECT * FROM feed WHERE timestamp + refresh < ". time()); $result = db_query("SELECT * FROM {feed} WHERE timestamp + refresh < ". time());
while ($feed = db_fetch_array($result)) { while ($feed = db_fetch_array($result)) {
import_refresh($feed); import_refresh($feed);
} }
} }
function import_update() { function import_update() {
$result = db_query("SELECT * FROM feed"); $result = db_query("SELECT * FROM {feed} ");
while ($feed = db_fetch_array($result)) { while ($feed = db_fetch_array($result)) {
import_refresh($feed); import_refresh($feed);
} }
...@@ -127,7 +127,7 @@ function import_bundle_block($attributes) { ...@@ -127,7 +127,7 @@ function import_bundle_block($attributes) {
$keys = explode(",", $attributes); $keys = explode(",", $attributes);
foreach ($keys as $key) $where[] = "attributes LIKE '%". trim($key) ."%'"; foreach ($keys as $key) $where[] = "attributes LIKE '%". trim($key) ."%'";
$result = db_query_range("SELECT * FROM item WHERE ". implode(" OR ", $where) ." ORDER BY iid DESC", 0, variable_get("import_block_limit", 15)); $result = db_query_range("SELECT * FROM {item} WHERE ". implode(" OR ", $where) ." ORDER BY iid DESC", 0, variable_get("import_block_limit", 15));
} }
$items = array(); $items = array();
...@@ -143,7 +143,7 @@ function import_bundle_block($attributes) { ...@@ -143,7 +143,7 @@ function import_bundle_block($attributes) {
} }
function import_feed_block($feed) { function import_feed_block($feed) {
$result = db_query_range("SELECT * FROM item WHERE fid = %d ORDER BY iid DESC ", $feed->fid, 0, variable_get("import_block_limit", 15)); $result = db_query_range("SELECT * FROM {item} WHERE fid = %d ORDER BY iid DESC ", $feed->fid, 0, variable_get("import_block_limit", 15));
$items = array(); $items = array();
while ($item = db_fetch_object($result)) { while ($item = db_fetch_object($result)) {
...@@ -159,12 +159,12 @@ function import_feed_block($feed) { ...@@ -159,12 +159,12 @@ function import_feed_block($feed) {
function import_block($op, $delta) { function import_block($op, $delta) {
if ($op == "list") { if ($op == "list") {
$result = db_query("SELECT * FROM bundle ORDER BY title"); $result = db_query("SELECT * FROM {bundle} ORDER BY title");
while ($bundle = db_fetch_object($result)) { while ($bundle = db_fetch_object($result)) {
$block["bundle:$bundle->bid"]["info"] = "$bundle->title bundle"; $block["bundle:$bundle->bid"]["info"] = "$bundle->title bundle";
} }
$result = db_query("SELECT * FROM feed ORDER BY fid"); $result = db_query("SELECT * FROM {feed} ORDER BY fid");
while ($feed = db_fetch_object($result)) { while ($feed = db_fetch_object($result)) {
$block["feed:$feed->fid"]["info"] = "$feed->title feed"; $block["feed:$feed->fid"]["info"] = "$feed->title feed";
} }
...@@ -175,13 +175,13 @@ function import_block($op, $delta) { ...@@ -175,13 +175,13 @@ function import_block($op, $delta) {
list($type, $id) = split(":", $delta); list($type, $id) = split(":", $delta);
switch ($type) { switch ($type) {
case "feed": case "feed":
$feed = db_fetch_object(db_query("SELECT * FROM feed WHERE fid = %d", $id)); $feed = db_fetch_object(db_query("SELECT * FROM {feed} WHERE fid = %d", $id));
$block["subject"] = $feed->title; $block["subject"] = $feed->title;
$block["content"] .= import_feed_block($feed) ."<div style=\"text-align: right;\">". l(t("more"), "import/feed/$feed->fid", array("title" => t("View this feed's recent news."))) ."</div>"; $block["content"] .= import_feed_block($feed) ."<div style=\"text-align: right;\">". l(t("more"), "import/feed/$feed->fid", array("title" => t("View this feed's recent news."))) ."</div>";
break; break;
case "bundle": case "bundle":
$bundle = db_fetch_object(db_query("SELECT * FROM bundle WHERE bid = %d", $id)); $bundle = db_fetch_object(db_query("SELECT * FROM {bundle} WHERE bid = %d", $id));
$block["subject"] = $bundle->title; $block["subject"] = $bundle->title;
$block["content"] .= import_bundle_block($bundle->attributes) ."<div style=\"text-align: right;\">". l(t("more"), "import/bundle/$bundle->bid", array("title" => t("View this bundle's recent news."))) ."</div>"; $block["content"] .= import_bundle_block($bundle->attributes) ."<div style=\"text-align: right;\">". l(t("more"), "import/bundle/$bundle->bid", array("title" => t("View this bundle's recent news."))) ."</div>";
break; break;
...@@ -195,7 +195,7 @@ function import_get_bundles($attributes = 0) { ...@@ -195,7 +195,7 @@ function import_get_bundles($attributes = 0) {
$block = array(); $block = array();
$result = db_query("SELECT * FROM bundle ORDER BY title"); $result = db_query("SELECT * FROM {bundle} ORDER BY title");
while ($bundle = db_fetch_object($result)) { while ($bundle = db_fetch_object($result)) {
$block["bundle:$bundle->bid"]["subject"] = $bundle->title; $block["bundle:$bundle->bid"]["subject"] = $bundle->title;
$block["bundle:$bundle->bid"]["content"] = import_bundle_block($bundle->attributes) ."<div style=\"text-align: right;\">". $block["bundle:$bundle->bid"]["content"] = import_bundle_block($bundle->attributes) ."<div style=\"text-align: right;\">".
...@@ -211,7 +211,7 @@ function import_get_feeds($attributes = 0) { ...@@ -211,7 +211,7 @@ function import_get_feeds($attributes = 0) {
$block = array(); $block = array();
$result = db_query("SELECT * FROM feed ORDER BY fid"); $result = db_query("SELECT * FROM {feed} ORDER BY fid");
while ($feed = db_fetch_object($result)) { while ($feed = db_fetch_object($result)) {
$block["feed:$feed->fid"]["subject"] = $feed->title; $block["feed:$feed->fid"]["subject"] = $feed->title;
$block["feed:$feed->fid"]["content"] = import_feed_block($feed) ."<div style=\"text-align: right;\">". $block["feed:$feed->fid"]["content"] = import_feed_block($feed) ."<div style=\"text-align: right;\">".
...@@ -224,7 +224,7 @@ function import_get_feeds($attributes = 0) { ...@@ -224,7 +224,7 @@ function import_get_feeds($attributes = 0) {
} }
function import_remove($feed) { function import_remove($feed) {
db_query("DELETE FROM item WHERE fid = %d", $feed["fid"]); db_query("DELETE FROM {item} WHERE fid = %d", $feed["fid"]);
return t("removed news items from '%site'.", array("%site" => $feed["title"])); return t("removed news items from '%site'.", array("%site" => $feed["title"]));
} }
...@@ -323,7 +323,7 @@ function import_refresh($feed) { ...@@ -323,7 +323,7 @@ function import_refresh($feed) {
$tt = array_flip(get_html_translation_table(HTML_ENTITIES)); $tt = array_flip(get_html_translation_table(HTML_ENTITIES));
$tt["&apos;"] = "'"; $tt["&apos;"] = "'";
db_query("UPDATE feed SET timestamp = %d, link = '%s', description = '%s' WHERE fid = %d", time(), $channel["LINK"], $channel["DESCRIPTION"], $feed["fid"]); db_query("UPDATE {feed} SET timestamp = %d, link = '%s', description = '%s' WHERE fid = %d", time(), $channel["LINK"], $channel["DESCRIPTION"], $feed["fid"]);
/* /*
** We reverse the array such that we store the first item last, ** We reverse the array such that we store the first item last,
...@@ -369,10 +369,10 @@ function import_refresh($feed) { ...@@ -369,10 +369,10 @@ function import_refresh($feed) {
*/ */
if ($link && $link != $feed["link"] && $link != $feed["url"]) { if ($link && $link != $feed["link"] && $link != $feed["url"]) {
$entry = db_fetch_object(db_query("SELECT iid FROM item WHERE fid = %d AND link = '%s'", $feed["fid"], $link)); $entry = db_fetch_object(db_query("SELECT iid FROM {item} WHERE fid = %d AND link = '%s'", $feed["fid"], $link));
} }
else { else {
$entry = db_fetch_object(db_query("SELECT iid FROM item WHERE fid = %d AND title = '%s'", $feed["fid"], $title)); $entry = db_fetch_object(db_query("SELECT iid FROM {item} WHERE fid = %d AND title = '%s'", $feed["fid"], $title));
} }
import_save_item(array(iid => $entry->iid, fid => $feed["fid"], title => $title, link => $link, author => $item["AUTHOR"], description => $item["DESCRIPTION"], attributes => $feed["attributes"])); import_save_item(array(iid => $entry->iid, fid => $feed["fid"], title => $title, link => $link, author => $item["AUTHOR"], description => $item["DESCRIPTION"], attributes => $feed["attributes"]));
...@@ -384,14 +384,14 @@ function import_refresh($feed) { ...@@ -384,14 +384,14 @@ function import_refresh($feed) {
unset($items); unset($items);
$result = db_query("SELECT iid FROM item WHERE fid = %d ORDER BY timestamp", $feed["fid"]); $result = db_query("SELECT iid FROM {item} WHERE fid = %d ORDER BY timestamp", $feed["fid"]);
while ($item = db_fetch_object($result)) { while ($item = db_fetch_object($result)) {
$items[] = "iid = '$item->iid'"; $items[] = "iid = '$item->iid'";
} }
if (sizeof($items) > 50) { if (sizeof($items) > 50) {
db_query("DELETE FROM item WHERE ". implode(" OR ", array_slice($items, 0, - 50))); db_query("DELETE FROM {item} WHERE ". implode(" OR ", array_slice($items, 0, - 50)));
} }
cache_clear_all(); cache_clear_all();
...@@ -405,13 +405,13 @@ function import_refresh($feed) { ...@@ -405,13 +405,13 @@ function import_refresh($feed) {
function import_save_item($edit) { function import_save_item($edit) {
if ($edit["iid"] && $edit["title"]) { if ($edit["iid"] && $edit["title"]) {
db_query("UPDATE item SET title = '%s', link = '%s', author = '%s', description = '%s', attributes = '%s' WHERE iid = %d", $edit["title"], $edit["link"], $edit["author"], $edit["description"], $edit["attributes"], $edit["iid"]); db_query("UPDATE {item} SET title = '%s', link = '%s', author = '%s', description = '%s', attributes = '%s' WHERE iid = %d", $edit["title"], $edit["lin