Commit 8674cf09 authored by Dries's avatar Dries

- Small updates
parent 441e2598
......@@ -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();
}
......
......@@ -63,7 +63,7 @@ function system_view_options() {
// layout settings:
$output .= "<H3>Layout settings</H3>\n";
foreach ($themes as $key=>$value) $options .= "<OPTION VALUE=\"$key\"". (variable_get("theme_default", key($themes)) == $key ? " SELECTED" : "") .">$key</OPTION>\n";
$output .= form_item(t("Default theme"), "<SELECT NAME=\"edit[theme_default]\">$options</SELECT>", t("The default theme as seen by new visitors and anonymous users."));
$output .= form_item(t("Default theme"), "<SELECT NAME=\"edit[theme_default]\">$options</SELECT>", t("The default theme as seen by visitors or anonymous users."));
$output .= "<HR>\n";
// development settings:
......
......@@ -63,7 +63,7 @@ function system_view_options() {
// layout settings:
$output .= "<H3>Layout settings</H3>\n";
foreach ($themes as $key=>$value) $options .= "<OPTION VALUE=\"$key\"". (variable_get("theme_default", key($themes)) == $key ? " SELECTED" : "") .">$key</OPTION>\n";
$output .= form_item(t("Default theme"), "<SELECT NAME=\"edit[theme_default]\">$options</SELECT>", t("The default theme as seen by new visitors and anonymous users."));
$output .= form_item(t("Default theme"), "<SELECT NAME=\"edit[theme_default]\">$options</SELECT>", t("The default theme as seen by visitors or anonymous users."));
$output .= "<HR>\n";
// development settings:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment