aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/elgglib.php
diff options
context:
space:
mode:
authoricewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-05-30 08:26:40 +0000
committericewing <icewing@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-05-30 08:26:40 +0000
commit09b84bd3cea65020b021e096783780bf1e98be8c (patch)
tree562cecc6b4112f776f0fe1da20ba54266d1a0a0d /engine/lib/elgglib.php
parent9b7b557ab8ef0612af433cb4ab32d5782cd2f207 (diff)
downloadelgg-09b84bd3cea65020b021e096783780bf1e98be8c.tar.gz
elgg-09b84bd3cea65020b021e096783780bf1e98be8c.tar.bz2
Marcus Povey <marcus@dushka.co.uk>
* Improved callpath_gatekeeper git-svn-id: https://code.elgg.org/elgg/trunk@763 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib/elgglib.php')
-rw-r--r--engine/lib/elgglib.php22
1 files changed, 18 insertions, 4 deletions
diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php
index 92d76d84b..9c287fdb7 100644
--- a/engine/lib/elgglib.php
+++ b/engine/lib/elgglib.php
@@ -1050,30 +1050,44 @@
*
* @param string $path The full path and filename that this function must have in its call stack
* @param bool $include_subdirs Are subdirectories of the path ok, or must you specify an absolute path and filename.
+ * @param bool $limited_mode If true then the calling method or function must be directly called by something on $path, if false the whole call stack is searched.
*/
- function callpath_gatekeeper($path, $include_subdirs = true)
+ function callpath_gatekeeper($path, $include_subdirs = true, $limited_mode = false)
{
+ global $CONFIG;
+
$path = sanitise_string($path);
if ($path)
{
$callstack = debug_backtrace();
-
+
foreach ($callstack as $call)
{
if ($include_subdirs)
{
if (strpos($call['file'], $path) === 0)
- return true;
+ if ($limited_mode) {
+ if ($callstack[2] === $call) return true;
+ }
+ else
+ return true;
}
else
{
if (strcmp($path, $call['file'])==0)
- return true;
+ if ($limited_mode) {
+ if ($callstack[2] === $call) return true;
+ } else
+ return true;
}
+
}
}
+ if ($CONFIG->debug)
+ system_message("Gatekeeper'd function called from {$callstack[2]['file']}:{$callstack[2]['line']}\n\nStack trace:\n\n" . print_r($callstack, true));
+
return false;
}