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)
------------------------
......@@ -69,7 +75,7 @@ Drupal 4.0.0, 2002-06-15
- themes:
* cleaned up the theme system.
* moved themes that are not maintained to contributions CVS repository.
- database abstraction:
- database backend:
* changed to PEAR database abstraction layer.
* using ANSI SQL queries to be more portable.
- rewrote the user system:
......
......@@ -37,12 +37,12 @@ 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', %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) {
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");
die(message_throttle());
}
......@@ -169,7 +169,7 @@ function t($string, $args = 0) {
}
function variable_init($conf = array()) {
$result = db_query("SELECT * FROM variable");
$result = db_query("SELECT * FROM {variable} ");
while ($variable = db_fetch_object($result)) {
if (!isset($conf[$variable->name])) {
$conf[$variable->name] = unserialize($variable->value);
......@@ -188,8 +188,8 @@ function variable_get($name, $default) {
function variable_set($name, $value) {
global $conf;
db_query("DELETE FROM variable WHERE name = '%s'", $name);
db_query("INSERT INTO variable (name, value) VALUES ('%s', '%s')", $name, serialize($value));
db_query("DELETE FROM {variable} WHERE name = '%s'", $name);
db_query("INSERT INTO {variable} (name, value) VALUES ('%s', '%s')", $name, serialize($value));
$conf[$name] = $value;
}
......@@ -197,7 +197,7 @@ function variable_set($name, $value) {
function variable_del($name) {
global $conf;
db_query("DELETE FROM variable WHERE name = '%s'", $name);
db_query("DELETE FROM {variable} WHERE name = '%s'", $name);
unset($conf[$name]);
}
......@@ -490,7 +490,7 @@ function xss_check_input_data($data) {
// check attributes:
$match += preg_match("/\W(dynsrc|datasrc|data|lowsrc|on[a-z]+)\s*=[^>]+?>/i", $data);
// check tags:
$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) {
}
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;
}
function cache_set($cid, $data, $expire = 0) {
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);
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);
}
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) {
if (empty($cid)) {
db_query("DELETE FROM cache WHERE expire <> 0");
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);
}
}
......
......@@ -15,9 +15,14 @@
# $db_url = "mysql://user:password@hostname/database";
# $db_url = "pgsql://user:password@hostname/database";
# $db_url = "mssql://user:password@hostname/database";
$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:
#
......
<?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, "://"));
......@@ -11,4 +18,4 @@
db_connect($db_url);
?>
\ No newline at end of file
?>
......@@ -23,6 +23,7 @@ function db_connect($url) {
function db_query($query) {
$args = func_get_args();
$query = db_prefix_tables($query);
if (count($args) > 1) {
$args = array_map("check_query", $args);
$args[0] = $query;
......@@ -36,6 +37,7 @@ function db_query($query) {
// debug version
function db_queryd($query) {
$args = func_get_args();
$query = db_prefix_tables($query);
if (count($args) > 1) {
$args = array_map("check_query", $args);
$args[0] = $query;
......@@ -111,9 +113,9 @@ function db_next_id($name) {
** when needed
*/
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("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("UNLOCK TABLES");
return $id;
......@@ -136,11 +138,13 @@ function db_query_range($query) {
$from = array_pop($args);
if (count(func_get_args()) > 3) {
$args = array_map("check_query", $args);
$query = db_prefix_tables($query);
$args[0] = $query;
$query = call_user_func_array("sprintf", $args);
}
else {
$query = func_get_arg(0);
$query = db_prefix_tables($query);
}
$query .= " LIMIT $from, $count";
return _db_query($query);
......
......@@ -25,6 +25,7 @@ function db_connect($url) {
function db_query($query) {
$args = func_get_args();
$query = db_prefix_tables($query);
if (count($args) > 1) {
$args = array_map("check_query", $args);
$args[0] = $query;
......@@ -38,6 +39,7 @@ function db_query($query) {
// debug version
function db_queryd($query) {
$args = func_get_args();
$query = db_prefix_tables($query);
if (count($args) > 1) {
$args = array_map("check_query", $args);
$args[0] = $query;
......@@ -147,11 +149,14 @@ function db_query_range($query) {
$from = array_pop($args);
if (count(func_get_args()) > 3) {
$args = array_map("check_query", $args);
$query = db_prefix_tables($query);
$args[0] = $query;
$result = $db_handle->limitQuery(call_user_func_array("sprintf", $args), $from, $count);
}
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)) {
......
......@@ -50,7 +50,7 @@ function module_list($refresh = 0) {
if (!$list) {
$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)) {
if (file_exists($module->filename)) {
$list[$module->name] = $module->name;
......
......@@ -84,7 +84,7 @@ function footer() {
print $output;
}
}
} // End of BaseTheme class //
function theme_mark() {
/*
......@@ -130,7 +130,7 @@ function theme_list($refresh = 0) {
if (!$list) {
$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)) {
if (file_exists($theme->filename)) {
$list[$theme->name] = $theme;
......@@ -189,7 +189,7 @@ function theme_init() {
function theme_blocks($region) {
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))) {
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="") {
$xmlrpc_value=new xmlrpcval;
if ($this->debug)
print "<pre>---GOT---\n" . htmlspecialchars($data) .
"\n---END---\n</pre>";
##print "<pre>---GOT---\n" . htmlspecialchars($data) . "\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=="") {
error_log("No response received from server.");
$r=new xmlrpcresp(0, $xmlrpcerr["no_data"],
......
......@@ -95,14 +95,14 @@ function import_link($type) {
}
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)) {
import_refresh($feed);
}
}
function import_update() {
$result = db_query("SELECT * FROM feed");
$result = db_query("SELECT * FROM {feed} ");
while ($feed = db_fetch_array($result)) {
import_refresh($feed);
}
......@@ -127,7 +127,7 @@ function import_bundle_block($attributes) {
$keys = explode(",", $attributes);
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();
......@@ -143,7 +143,7 @@ function import_bundle_block($attributes) {
}
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();
while ($item = db_fetch_object($result)) {
......@@ -159,12 +159,12 @@ function import_feed_block($feed) {
function import_block($op, $delta) {
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)) {
$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)) {
$block["feed:$feed->fid"]["info"] = "$feed->title feed";
}
......@@ -175,13 +175,13 @@ function import_block($op, $delta) {
list($type, $id) = split(":", $delta);
switch ($type) {
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["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;
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["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;
......@@ -195,7 +195,7 @@ function import_get_bundles($attributes = 0) {
$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)) {
$block["bundle:$bundle->bid"]["subject"] = $bundle->title;
$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) {
$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)) {
$block["feed:$feed->fid"]["subject"] = $feed->title;
$block["feed:$feed->fid"]["content"] = import_feed_block($feed) ."<div style=\"text-align: right;\">".
......@@ -224,7 +224,7 @@ function import_get_feeds($attributes = 0) {
}
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"]));
}
......@@ -323,7 +323,7 @@ function import_refresh($feed) {
$tt = array_flip(get_html_translation_table(HTML_ENTITIES));
$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,
......@@ -369,10 +369,10 @@ function import_refresh($feed) {
*/
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 {
$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"]));
......@@ -384,14 +384,14 @@ function import_refresh($feed) {
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)) {
$items[] = "iid = '$item->iid'";
}
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();
......@@ -405,13 +405,13 @@ function import_refresh($feed) {
function import_save_item($edit) {
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["link"], $edit["author"], $edit["description"], $edit["attributes"], $edit["iid"]);
}
else if ($edit["iid"]) {
db_query("DELETE FROM item WHERE iid = %d", $edit["iid"]);
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 (%d, '%s', '%s', '%s', '%s', '%s', %d)", $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());
}
}
......@@ -432,15 +432,15 @@ function import_form_bundle($edit = array()) {
function import_save_bundle($edit) {
if ($edit["bid"] && $edit["title"]) {
db_query("UPDATE bundle SET title = '%s', attributes = '%s' WHERE bid = %d", $edit["title"], $edit["attributes"], $edit["bid"]);
db_query("UPDATE {bundle} SET title = '%s', attributes = '%s' WHERE bid = %d", $edit["title"], $edit["attributes"], $edit["bid"]);
}
else if ($edit["bid"]) {
db_query("DELETE FROM bundle WHERE bid = %d", $edit["bid"]);
db_query("DELETE FROM {bundle} WHERE bid = %d", $edit["bid"]);
}
else if ($edit["title"]) {
// a single unique id for bundles and feeds, to use in blocks
$next_id = db_next_id("bundle_bid");
db_query("INSERT INTO bundle (bid, title, attributes) VALUES (%d, '%s', '%s')", $next_id, $edit["title"], $edit["attributes"]);
db_query("INSERT INTO {bundle} (bid, title, attributes) VALUES (%d, '%s', '%s')", $next_id, $edit["title"], $edit["attributes"]);
}
}
......@@ -469,37 +469,37 @@ 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 = %d WHERE fid = %d", $edit["title"], $edit["url"], $edit["attributes"], $edit["refresh"], $edit["fid"]);
db_query("DELETE FROM item WHERE fid = %d", $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"]) {
db_query("DELETE FROM feed WHERE fid = %d", $edit["fid"]);
db_query("DELETE FROM item WHERE fid = %d", $edit["fid"]);
db_query("DELETE FROM {feed} WHERE fid = %d", $edit["fid"]);
db_query("DELETE FROM {item} WHERE fid = %d", $edit["fid"]);
}
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', %d)", $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"]);
}
}
function import_save_attributes($edit) {
foreach ($edit as $iid => $value) {
db_query("UPDATE item SET attributes = '%s' WHERE iid = %d", $value, $iid);
db_query("UPDATE {item} SET attributes = '%s' WHERE iid = %d", $value, $iid);
}
return "attributes has been saved";
}
function import_get_feed($fid) {
return db_fetch_array(db_query("SELECT * FROM feed WHERE fid = %d", $fid));
return db_fetch_array(db_query("SELECT * FROM {feed} WHERE fid = %d", $fid));
}
function import_get_bundle($bid) {
return db_fetch_array(db_query("SELECT * FROM bundle WHERE bid = %d", $bid));
return db_fetch_array(db_query("SELECT * FROM {bundle} WHERE bid = %d", $bid));
}
function import_view() {
$result = db_query("SELECT f.*, COUNT(i.iid) AS items FROM feed f LEFT JOIN item i ON f.fid = i.fid GROUP BY f.fid, f.title, f.url, f.refresh, f.timestamp, f.attributes, f.link, f.description ORDER BY f.title");
$result = db_query("SELECT f.*, COUNT(i.iid) AS items FROM {feed} f LEFT JOIN {item} i ON f.fid = i.fid GROUP BY f.fid, f.title, f.url, f.refresh, f.timestamp, f.attributes, f.link, f.description ORDER BY f.title");
$output .= "<h3>Feed overview</h3>";
......@@ -510,7 +510,7 @@ function import_view() {
}
$output .= table($header, $rows);
$result = db_query("SELECT * FROM bundle ORDER BY title");
$result = db_query("SELECT * FROM {bundle} ORDER BY title");
$output .= "<h3>Bundle overview</h3>";
......@@ -526,7 +526,7 @@ function import_view() {
function import_tag() {
$result = db_query_range("SELECT i.*, f.title AS feed FROM item i LEFT JOIN feed f ON i.fid = f.fid ORDER BY i.iid DESC", 0, 50);
$result = db_query_range("SELECT i.*, f.title AS feed FROM {item} i LEFT JOIN {feed} f ON i.fid = f.fid ORDER BY i.iid DESC", 0, 50);
$header = array(t("date"), t("feed"), t("news item"));
while ($item = db_fetch_object($result)) {
......@@ -619,7 +619,7 @@ function import_page_info() {
function import_page_last() {
$result = db_query_range("SELECT i.*, f.title AS ftitle, f.link AS flink FROM item i LEFT JOIN feed f ON i.fid = f.fid ORDER BY i.iid DESC", 0, variable_get("import_page_limit", 75));
$result = db_query_range("SELECT i.*, f.title AS ftitle, f.link AS flink FROM {item} i LEFT JOIN {feed} f ON i.fid = f.fid ORDER BY i.iid DESC", 0, variable_get("import_page_limit", 75));
$output .= "<table border=\"0\" cellpadding=\"4\" cellspacing=\"2\">";
while ($item = db_fetch_object($result)) {
......@@ -649,13 +649,13 @@ function import_page_last() {
function import_page_feed($fid) {
$feed = db_fetch_object(db_query("SELECT * FROM feed WHERE fid = %d", $fid));
$feed = db_fetch_object(db_query("SELECT * FROM {feed} WHERE fid = %d", $fid));
$header .= "<p><b>". t("Website") .":</b><div style=\"margin-left: 20px;\"><a href=\"$feed->link\">$feed->link</a></div></p>";
$header .= "<p><b>". t("Description") .":</b><div style=\"margin-left: 20px;\">$feed->description</div></p>";
$header .= "<p><b>". t("Last update") .":</b><div style=\"margin-left: 20px; text-align: right;\">". format_interval(time() - $feed->timestamp) ." ". t("ago") ." <a href=\"$feed->url\"><img src=\"". theme("image", "xml.gif") ."\" width=\"36\" height=\"14\" style=\"border: 0px;\" alt=\"\" title=\"\" /></a><br /><br /></div></p>\n";
$result = db_query_range("SELECT * FROM item WHERE fid = %d ORDER BY iid DESC", $fid, 0, variable_get("import_page_limit", 75));
$result = db_query_range("SELECT * FROM {item} WHERE fid = %d ORDER BY iid DESC", $fid, 0, variable_get("import_page_limit", 75));
$output .= "<table border=\"0\" cellpadding=\"4\" cellspacing=\"2\">";
while ($item = db_fetch_object($result)) {
......@@ -685,14 +685,14 @@ function import_page_feed($fid) {
function import_page_bundle($bid) {
$bundle = db_fetch_object(db_query("SELECT * FROM bundle WHERE bid = %d", $bid));
$bundle = db_fetch_object(db_query("SELECT * FROM {bundle} WHERE bid = %d", $bid));
$header .= "<p><b>". t("Website") .":</b><div style=\"margin-left: 20px;\">". l($bundle->title, "import/bundle/$bundle->bid") ."</div></p>";
$header .= "<p><b>". t("Description") .":</b><div style=\"margin-left: 20px;\">". t("A composite news feed about") ." $bundle->attributes.</div></p>";
$keys = explode(",", $bundle->attributes);
foreach ($keys as $key) $where[] = "i.attributes LIKE '%". trim($key) ."%'";
$result = db_query_range("SELECT i.*, f.title AS ftitle, f.link AS flink FROM item i, feed f WHERE (". implode(" OR ", $where) .") AND i.fid = f.fid ORDER BY iid DESC", 0, variable_get("import_page_limit", 75));
$result = db_query_range("SELECT i.*, f.title AS ftitle, f.link AS flink FROM {item} i, {feed} f WHERE (". implode(" OR ", $where) .") AND i.fid = f.fid ORDER BY iid DESC", 0, variable_get("import_page_limit", 75));
$output .= "<table border=\"0\" cellpadding=\"4\" cellspacing=\"2\">";
while ($item = db_fetch_object($result)) {
......@@ -725,7 +725,7 @@ function import_page_bundle($bid) {
function import_page_sources() {
$result = db_query("SELECT * FROM feed ORDER BY title");
$result = db_query("SELECT * FROM {feed} ORDER BY title");
while ($feed = db_fetch_object($result)) {
$output .= l($feed->title, "import/feed/$feed->fid");
......@@ -742,7 +742,7 @@ function import_page_sources() {
function import_page_fd() {
$result = db_query("SELECT * FROM feed ORDER BY title");
$result = db_query("SELECT * FROM {feed} ORDER BY title");
$output .= "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n\n";
$output .= "<rssfeeds version=\"0.1\">\n\n";
......
......@@ -95,14 +95,14 @@ function import_link($type) {
}
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)) {
import_refresh($feed);
}
}
function import_update() {
$result = db_query("SELECT * FROM feed");
$result = db_query("SELECT * FROM {feed} ");
while ($feed = db_fetch_array($result)) {
import_refresh($feed);
}
......@@ -127,7 +127,7 @@ function import_bundle_block($attributes) {
$keys = explode(",", $attributes);
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();
......@@ -143,7 +143,7 @@ function import_bundle_block($attributes) {
}
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();
while ($item = db_fetch_object($result)) {
......@@ -159,12 +159,12 @@ function import_feed_block($feed) {
function import_block($op, $delta) {
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)) {
$block["bundle:$bundle->bid"]["info"] = "$bundle->title bundle";
}