diff options
Diffstat (limited to 'includes/variable.inc')
-rw-r--r-- | includes/variable.inc | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/includes/variable.inc b/includes/variable.inc new file mode 100644 index 000000000..20beb5efd --- /dev/null +++ b/includes/variable.inc @@ -0,0 +1,54 @@ +<?php + +function variable_init($conf = array()) { + $result = db_query("SELECT * FROM variable"); + while ($variable = db_fetch_object($result)) $conf[$variable->name] = $variable->value; + return $conf; +} + +function handler_post_threshold($node, $default) { + if ($node->type) { + $function = $node->type ."_post_threshold"; + return $function($node, $default); + } + else { + return $default; + } +} + +function handler_dump_threshold($node, $default) { + if ($node->type) { + $function = $node->type ."_dump_threshold"; + return $function($node, $default); + } + else { + return $default; + } +} + +function handler_timout_threshold($node, $default) { + if ($node->type) { + $function = $node->type ."_timout_threshold"; + return $function($node, $default); + } + else { + return $default; + } +} + +function variable_get($name, $default, $object = 0) { + global $conf; + + switch ($name) { + case "post_threshold": + return handler_post_threshold($object, $default); + case "dump_threshold": + return handler_dump_threshold($object, $default); + case "timout_threshold": + return handler_timout_threshold($object, $default); + default: + return ($conf[$name] ? $conf[$name] : $default); + } +} + +?>
\ No newline at end of file |