From 88fabace4349ccb77e468083d0148d2fc52ad728 Mon Sep 17 00:00:00 2001 From: icewing Date: Thu, 29 May 2008 14:40:49 +0000 Subject: Marcus Povey * Introducing callpath_gatekeeper git-svn-id: https://code.elgg.org/elgg/trunk@758 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/elgglib.php | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'engine/lib/elgglib.php') diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php index 3b48610c1..330ae30f9 100644 --- a/engine/lib/elgglib.php +++ b/engine/lib/elgglib.php @@ -1026,7 +1026,7 @@ return false; - // If file then check using reflection that this it is being called from this function + // If file then check that this it is being called from this function if ($file) { // Check file against function @@ -1041,8 +1041,11 @@ /** * This function checks to see if it is being called at somepoint by a function defined somewhere * on a given path (optionally including subdirectories). + * + * @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. */ - /*function callpath_gatekeeper($path, $include_subdirs = true) + function callpath_gatekeeper($path, $include_subdirs = true) { $path = sanitise_string($path); @@ -1052,13 +1055,22 @@ foreach ($callstack as $call) { - if + if ($include_subdirs) + { + if (strpos($call['file'], $path) === 0) + return true; + } + else + { + if (strcmp($path, $call['file'])==0) + return true; + } } } return false; } -*/ + // register privileged code block -- cgit v1.2.3