aboutsummaryrefslogtreecommitdiff
path: root/engine/lib
diff options
context:
space:
mode:
authorben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-02-14 16:32:36 +0000
committerben <ben@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-02-14 16:32:36 +0000
commit269c58d56242a9c4bf4cac067efdbc6774424a32 (patch)
tree971369045067f5a7180b70939368eafee21e9a31 /engine/lib
parent5b373ca622653dcdea04f7f2ce73b6ee22495f43 (diff)
downloadelgg-269c58d56242a9c4bf4cac067efdbc6774424a32.tar.gz
elgg-269c58d56242a9c4bf4cac067efdbc6774424a32.tar.bz2
Actions, .htaccess, and the database schema
git-svn-id: https://code.elgg.org/elgg/trunk@31 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'engine/lib')
-rw-r--r--engine/lib/actions.php88
-rw-r--r--engine/lib/elgglib.php7
2 files changed, 95 insertions, 0 deletions
diff --git a/engine/lib/actions.php b/engine/lib/actions.php
new file mode 100644
index 000000000..e24659df1
--- /dev/null
+++ b/engine/lib/actions.php
@@ -0,0 +1,88 @@
+<?php
+
+ /**
+ * Elgg actions
+ * Allows system modules to specify actions
+ *
+ * @package Elgg
+ * @subpackage Core
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd
+ * @copyright Curverider Ltd 2008
+ * @link http://elgg.org/
+ */
+
+ // Action setting and run *************************************************
+
+ /**
+ * Loads an action script, if it exists, then forwards elsewhere
+ *
+ * @param string $action The requested action
+ * @param string $forwarder Optionally, the location to forward to
+ */
+
+ function action($action, $forwarder = "") {
+
+ global $CONFIG;
+
+ $forwarder = str_replace($CONFIG->url, "", $forwarder);
+ $forwarder = str_replace("http://", "", $forwarder);
+ $forwarder = str_replace("@", "", $forwarder);
+
+ if (substr($forwarder,0,1) == "/") {
+ $forwarder = substr($forwarder,1);
+ }
+
+ if (isset($CONFIG->actions[$action])) {
+ if ($CONFIG->actions[$action]['public'] || $_SESSION['id'] != -1) {
+ if (@include($CONFIG->actions[$action]['file'])) {
+ } else {
+ register_error("The requested action was not defined in the system.");
+ }
+ } else {
+ register_error("Sorry, you cannot perform this action while logged out.");
+ }
+ }
+ forward($CONFIG->url . $forwarder);
+
+ }
+
+ /**
+ * Registers a particular action in memory
+ *
+ * @param string $action The name of the action (eg "register", "account/settings/save")
+ * @param boolean $public Can this action be accessed by people not logged into the system?
+ * @param string $filename Optionally, the filename where this action is located
+ */
+
+ function register_action($action, $public = false, $filename = "") {
+ global $CONFIG;
+
+ if (!isset($CONFIG->actions)) {
+ $CONFIG->actions = array();
+ }
+
+ if (empty($filename)) {
+ $filename = $CONFIG->path . "actions/" . $action . ".php";
+ }
+
+ $CONFIG->actions[$action] = array('file' => $filename, 'public' => $public);
+ }
+
+ /**
+ * Actions to perform on initialisation
+ *
+ * @param string $event Events API required parameters
+ * @param string $object_type Events API required parameters
+ * @param string $object Events API required parameters
+ */
+
+ function actions_init($event, $object_type, $object) {
+ register_action("error");
+ }
+
+ // Register some actions ***************************************************
+
+ register_event_handler("init","system","actions_init");
+
+?> \ No newline at end of file
diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php
index ab0bf8877..53771f896 100644
--- a/engine/lib/elgglib.php
+++ b/engine/lib/elgglib.php
@@ -170,6 +170,13 @@
register_error(elgg_view("messages/sanitisation/settings"));
$sanitised = false;
}
+
+ if (!file_exists(dirname(dirname(dirname(__FILE__)))) . "/.htaccess") {
+ if (!copy(dirname(dirname(dirname(__FILE__))) . "/htaccess_dist", dirname(dirname(dirname(__FILE__))) . "/.htaccess")) {
+ register_error(elgg_view("messages/sanitisation/htaccess"));
+ $sanitised = false;
+ }
+ }
return $sanitised;