summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2001-04-07 15:02:28 +0000
committerDries Buytaert <dries@buytaert.net>2001-04-07 15:02:28 +0000
commit38806b4a39a6bdfc9d4a09f86b7bbaf0173c298d (patch)
treea445eab5750bd259731134cd31412305b55b8acb /includes
parent8213f5b2627a6b63db9f84b572918bd7e3254dff (diff)
downloadbrdo-38806b4a39a6bdfc9d4a09f86b7bbaf0173c298d.tar.gz
brdo-38806b4a39a6bdfc9d4a09f86b7bbaf0173c298d.tar.bz2
- fixed bug in common.inc: throttle()
- streamlined method invocation in node.inc - added node_status() function to modules - added NEW (mostly static) page module - added NEW settings module
Diffstat (limited to 'includes')
-rw-r--r--includes/common.inc1
-rw-r--r--includes/node.inc22
2 files changed, 15 insertions, 8 deletions
diff --git a/includes/common.inc b/includes/common.inc
index 81127c22c..53f1aa4d0 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -16,6 +16,7 @@ function watchdog($type, $message) {
}
function throttle($type, $rate) {
+ global $user;
if (!(user_access($user, "watchdog") || user_access($user, "comment") || user_access($user, "node"))) {
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");
diff --git a/includes/node.inc b/includes/node.inc
index 75b1fdc8c..fa2ca7d92 100644
--- a/includes/node.inc
+++ b/includes/node.inc
@@ -1,6 +1,7 @@
<?php
$status = array(dumped => 0, expired => 1, queued => 2, posted => 3);
+$rstatus = array(0 => dumped, 1 => expired, 2 => queued, 3 => posted);
function _node_get($field, $value) {
$result = db_query("SELECT lid, type FROM node WHERE $field = '$value'");
@@ -119,18 +120,23 @@ function node_save($node) {
}
+
+function node_invoke($node, $name, $arg = 0) {
+ if ($node[type]) $function = $node[type] ."_$name";
+ if ($node->type) $function = $node->type ."_$name";
+ if ($function) return ($arg ? $function($node) : $function($node, $arg));
+}
+
function node_view($node, $page) {
- if ($node->type) {
- $function = $node->type ."_view";
- return $function($node, $page);
- }
+ return node_invoke($node, "view", $page);
}
function node_form($node) {
- if ($node[type]) {
- $function = $node[type] ."_form";
- return $function($node);
- }
+ return node_invoke($node, "form");
+}
+
+function node_status($node) {
+ return node_invoke($node, "status");
}
function node_control($node) {