aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/deprecated-1.8.php
diff options
context:
space:
mode:
authorcash <cash.costello@gmail.com>2011-11-04 22:40:06 -0400
committercash <cash.costello@gmail.com>2011-11-04 22:40:06 -0400
commit54773892f88f53231b85d08d86d11557121d9609 (patch)
treefcc3738cf8104caf4d65ca261a973458363d19f8 /engine/lib/deprecated-1.8.php
parent61a7e2e9e138ec166227794e2de96bdd8a268957 (diff)
downloadelgg-54773892f88f53231b85d08d86d11557121d9609.tar.gz
elgg-54773892f88f53231b85d08d86d11557121d9609.tar.bz2
Fixes #4059 page handlers all return nothing
Diffstat (limited to 'engine/lib/deprecated-1.8.php')
-rw-r--r--engine/lib/deprecated-1.8.php37
1 files changed, 37 insertions, 0 deletions
diff --git a/engine/lib/deprecated-1.8.php b/engine/lib/deprecated-1.8.php
index beba7d2b7..e1866498b 100644
--- a/engine/lib/deprecated-1.8.php
+++ b/engine/lib/deprecated-1.8.php
@@ -4735,3 +4735,40 @@ function remove_from_river_by_id($id) {
return elgg_delete_river(array('id' => $id));
}
+
+/**
+ * A default page handler
+ * Tries to locate a suitable file to include. Only works for core pages, not plugins.
+ *
+ * @param array $page The page URL elements
+ * @param string $handler The base handler
+ *
+ * @return true|false Depending on success
+ * @deprecated 1.8
+ */
+function default_page_handler($page, $handler) {
+ global $CONFIG;
+
+ elgg_deprecated_notice("default_page_handler is deprecated", "1.8");
+
+ $page = implode('/', $page);
+
+ // protect against including arbitary files
+ $page = str_replace("..", "", $page);
+
+ $callpath = $CONFIG->path . $handler . "/" . $page;
+ if (is_dir($callpath)) {
+ $callpath = sanitise_filepath($callpath);
+ $callpath .= "index.php";
+ if (file_exists($callpath)) {
+ if (include($callpath)) {
+ return TRUE;
+ }
+ }
+ } else if (file_exists($callpath)) {
+ include($callpath);
+ return TRUE;
+ }
+
+ return FALSE;
+}