From 269c58d56242a9c4bf4cac067efdbc6774424a32 Mon Sep 17 00:00:00 2001 From: ben Date: Thu, 14 Feb 2008 16:32:36 +0000 Subject: Actions, .htaccess, and the database schema git-svn-id: https://code.elgg.org/elgg/trunk@31 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/actions.php | 88 +++++++++++ engine/lib/elgglib.php | 7 + engine/schema/mysql.sql | 177 +++++++++++++++++++++++ engine/settings.example.php | 87 +++++++++++ index.php | 23 --- views/default/messages/sanitisation/htaccess.php | 18 +++ 6 files changed, 377 insertions(+), 23 deletions(-) create mode 100644 engine/lib/actions.php create mode 100644 engine/schema/mysql.sql delete mode 100644 index.php create mode 100644 views/default/messages/sanitisation/htaccess.php 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 @@ +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; diff --git a/engine/schema/mysql.sql b/engine/schema/mysql.sql new file mode 100644 index 000000000..9b8304b80 --- /dev/null +++ b/engine/schema/mysql.sql @@ -0,0 +1,177 @@ +-- +-- Main Elgg database +-- +-- @link http://elgg.org/ +-- @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/ +-- + +-- -------------------------------------------------------- + +-- +-- Table structure for table `access_groups` +-- + +CREATE TABLE `access_groups` ( + `id` int(11) NOT NULL, + `name` varchar(16) NOT NULL, + PRIMARY KEY (`id`), + KEY `name` (`name`) +) ENGINE=MyISAM ; + +-- +-- Dumping data for table `access_groups` +-- + +INSERT INTO `access_groups` (`id`, `name`) VALUES +(0, 'PRIVATE'), +(1, 'LOGGED_IN'), +(2, 'PUBLIC'); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `access_group_membership` +-- + +CREATE TABLE `access_group_membership` ( + `user_id` int(11) NOT NULL, + `access_group_id` int(11) NOT NULL, + PRIMARY KEY (`user_id`,`access_group_id`) +) ENGINE=MyISAM ; + + +-- -------------------------------------------------------- + +-- +-- Table structure for table `configuration` +-- + +CREATE TABLE `configuration` ( + `id` int(11) NOT NULL, + `name` varchar(32) NOT NULL, + `value` text NOT NULL, + PRIMARY KEY (`id`), + KEY `name` (`name`) +) ENGINE=MyISAM ; + + +-- -------------------------------------------------------- + +-- +-- Table structure for table `metadata_type` +-- + +CREATE TABLE `metadata_type` ( + `id` int(11) NOT NULL auto_increment, + `name` varchar(32) NOT NULL, + PRIMARY KEY (`id`), + KEY `name` (`name`) +) ENGINE=MyISAM ; + + +-- -------------------------------------------------------- + +-- +-- Table structure for table `metadata_value` +-- + +CREATE TABLE `metadata_value` ( + `id` int(11) NOT NULL auto_increment, + `value` text NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=MyISAM ; + + +-- -------------------------------------------------------- + +-- +-- Table structure for table `objects` +-- + +CREATE TABLE `objects` ( + `id` int(11) NOT NULL auto_increment, + `owner_id` int(11) NOT NULL, + `site_id` int(11) NOT NULL, + `type_id` int(11) NOT NULL, + `title` text NOT NULL, + `description` text NOT NULL, + `time_created` int(11) NOT NULL, + `time_updated` int(11) NOT NULL, + PRIMARY KEY (`id`), + KEY `time_created` (`time_created`,`time_updated`) +) ENGINE=MyISAM ; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `object_metadata` +-- + +CREATE TABLE `object_metadata` ( + `id` int(11) NOT NULL auto_increment, + `object_id` int(11) NOT NULL, + `metadata_type_id` int(11) NOT NULL, + `value_id` int(11) NOT NULL, + `access_id` int(11) NOT NULL, + PRIMARY KEY (`id`), + KEY `object_id` (`object_id`,`metadata_type_id`,`value_id`), + KEY `access_id` (`access_id`) +) ENGINE=MyISAM ; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `object_types` +-- + +CREATE TABLE `object_types` ( + `id` int(11) NOT NULL auto_increment, + `name` varchar(16) NOT NULL, + PRIMARY KEY (`id`), + KEY `name` (`name`) +) ENGINE=MyISAM ; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `users` +-- + +CREATE TABLE `users` ( + `id` int(11) NOT NULL auto_increment, + `name` text NOT NULL, + `username` varchar(12) NOT NULL default '', + `password` varchar(32) NOT NULL default '', + `email` text NOT NULL, + `code` varchar(32) NOT NULL default '', + `last_updated` int(11) NOT NULL default '0', + `registered` int(11) NOT NULL default '0', + `enabled` enum('yes','no') NOT NULL default 'no', + `last_action` int(11) NOT NULL default '0', + `prev_last_action` int(11) NOT NULL default '0', + `last_login` int(11) NOT NULL default '0', + `prev_last_login` int(11) NOT NULL default '0', + PRIMARY KEY (`id`), + KEY `password` (`password`), + FULLTEXT KEY `name` (`name`) +) ENGINE=MyISAM ; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `user_metadata` +-- + +CREATE TABLE `user_metadata` ( + `id` int(11) NOT NULL auto_increment, + `user_id` int(11) NOT NULL, + `metadata_type_id` int(11) NOT NULL, + `value_id` int(11) NOT NULL, + `access_id` int(11) NOT NULL, + PRIMARY KEY (`id`), + KEY `user_id` (`user_id`,`metadata_type_id`,`value_id`), + KEY `access_id` (`access_id`) +) ENGINE=MyISAM ; diff --git a/engine/settings.example.php b/engine/settings.example.php index 0165eb215..7c8b5019f 100644 --- a/engine/settings.example.php +++ b/engine/settings.example.php @@ -1,3 +1,90 @@ dbuser = ""; + + // Database password + $CONFIG->dbpass = ""; + + // Database name + $CONFIG->dbname = ""; + + // Database server + // (For most configurations, you can leave this as 'localhost') + $CONFIG->dbhost = "localhost"; + + /* + * Multiple database connections + * + * Here you can set up multiple connections for reads and writes. To do this, uncomment out + * the lines below. + */ + + /* + + // Yes! We want to split reads and writes + $CONFIG->db->split = true; + + // READS + // Database username + $CONFIG->db['read']->dbuser = ""; + + // Database password + $CONFIG->db['read']->dbpass = ""; + + // Database name + $CONFIG->db['read']->dbname = ""; + + // Database server + // (For most configurations, you can leave this as 'localhost') + $CONFIG->db['read']->dbhost = "localhost"; + + // WRITES + // Database username + $CONFIG->db['write']->dbuser = ""; + + // Database password + $CONFIG->db['write']->dbpass = ""; + + // Database name + $CONFIG->db['write']->dbname = ""; + + // Database server + // (For most configurations, you can leave this as 'localhost') + $CONFIG->db['write']->dbhost = "localhost"; + + + */ + + /* + * For extra connections for both reads and writes, you can turn both + * $CONFIG->db['read'] and $CONFIG->db['write'] into an array, eg: + * + * $CONFIG->db['read'][0]->dbhost = "localhost"; + * + * Note that the array keys must be numeric and consecutive, i.e., they start + * at 0, the next one must be at 1, etc. + */ + ?> \ No newline at end of file diff --git a/index.php b/index.php deleted file mode 100644 index fa0a0f41b..000000000 --- a/index.php +++ /dev/null @@ -1,23 +0,0 @@ - \ No newline at end of file diff --git a/views/default/messages/sanitisation/htaccess.php b/views/default/messages/sanitisation/htaccess.php new file mode 100644 index 000000000..31423e3b3 --- /dev/null +++ b/views/default/messages/sanitisation/htaccess.php @@ -0,0 +1,18 @@ + +Elgg requires a file called .htaccess to be set in the root directory of its installation. We tried to create it for you, but Elgg doesn't have permission to write to that directory. + +Creating this is easy. Just take the htaccess_dist file in the root directory and rename it to .htaccess. (On Windows systems, you will need to open htaccess_dist in Notepad and save it as .htaccess from there.) \ No newline at end of file -- cgit v1.2.3