summaryrefslogtreecommitdiff
path: root/includes/common.inc
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2001-07-01 11:27:10 +0000
committerDries Buytaert <dries@buytaert.net>2001-07-01 11:27:10 +0000
commit8674cf0953e3be8e0eacd17734bea65f729c33c3 (patch)
tree65e6915b997b88f4df41b6383eeef25409240b7d /includes/common.inc
parent441e2598883119365f63229f229ca2e1e60c0723 (diff)
downloadbrdo-8674cf0953e3be8e0eacd17734bea65f729c33c3.tar.gz
brdo-8674cf0953e3be8e0eacd17734bea65f729c33c3.tar.bz2
- Small updates
Diffstat (limited to 'includes/common.inc')
-rw-r--r--includes/common.inc29
1 files changed, 15 insertions, 14 deletions
diff --git a/includes/common.inc b/includes/common.inc
index c21036961..c8549b0f3 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -94,25 +94,26 @@ function cache_clear($interval = 0) {
function cache_get() {
global $user, $REQUEST_URI, $REQUEST_METHOD;
- if ($user->id || $REQUEST_METHOD != "GET") {
- return 0;
- }
-
- if ($cache = db_fetch_object(db_query("SELECT * FROM cache WHERE url = '". check_input($REQUEST_URI) ."'"))) {
- cache_clear(variable_get("cache_clear", 30));
-
- return $cache->data;
+ if (!$user->id && $REQUEST_METHOD == "GET") {
+ if ($cache = db_fetch_object(db_query("SELECT * FROM cache WHERE url = '". check_input($REQUEST_URI) ."'"))) {
+ cache_clear(variable_get("cache_clear", 30));
+ }
+ else {
+ ob_start();
+ }
}
- ob_start();
-
- return 0;
+ return $cache->data ? $cache->data : 0;
}
function cache_set() {
- global $REQUEST_URI;
+ global $user, $REQUEST_URI, $REQUEST_METHOD;
- db_query("INSERT INTO cache (url, data, timestamp) VALUES('". check_input($REQUEST_URI) ."', '". check_code(ob_get_contents()) ."', '". time() ."')");
+ if (!$user->id && $REQUEST_METHOD == "GET") {
+ if ($data = ob_get_contents()) {
+ db_query("INSERT INTO cache (url, data, timestamp) VALUES('". addslashes($REQUEST_URI) ."', '". addslashes($data) ."', '". time() ."')");
+ }
+ }
}
function format_interval($timestamp) {
@@ -286,7 +287,7 @@ function page_footer() {
if (variable_get("dev_timer", 0)) {
timer_print();
}
-
+
if (variable_get("cache", 0)) {
cache_set();
}