aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--actions/login.php42
-rw-r--r--actions/logout.php34
-rw-r--r--engine/lib/users.php5
-rw-r--r--index.php128
-rw-r--r--views/default/css.php22
-rw-r--r--views/default/login.php23
-rw-r--r--views/default/pageshell.php1
-rw-r--r--views/default/welcome.php19
8 files changed, 209 insertions, 65 deletions
diff --git a/actions/login.php b/actions/login.php
new file mode 100644
index 000000000..2dc3371ad
--- /dev/null
+++ b/actions/login.php
@@ -0,0 +1,42 @@
+<?php
+
+ /**
+ * Elgg login action page
+ *
+ * @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/
+ */
+
+ // Get username and password
+ require_once('../engine/start.php');
+ global $CONFIG;
+
+ $username = get_input('username');
+ $password = get_input("password");
+ $persistent = get_input("persistent");
+
+ if (empty($passthru)) {
+ $passthru = $CONFIG->url;
+ }
+
+ // If all is present and correct, try to log in
+ if (!empty($username) && !empty($password)) {
+ $result = login($username, $password, $persistent);
+ }
+
+ // Set the system_message as appropriate
+
+ if ($result) {
+ system_message("You have been logged in.");
+ } else {
+ system_message("We couldn't log you in. Make sure your details are correct and please try again.");
+ }
+
+ header("Location: {$passthru}");
+ exit;
+
+?> \ No newline at end of file
diff --git a/actions/logout.php b/actions/logout.php
new file mode 100644
index 000000000..c75a7c30e
--- /dev/null
+++ b/actions/logout.php
@@ -0,0 +1,34 @@
+<?php
+
+ /**
+ * Elgg logout action page
+ *
+ * @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/
+ */
+
+ //delete this
+ require_once('../engine/start.php');
+ global $CONFIG;
+
+ // Log out
+ $result = logout();
+
+ // Set the system_message as appropriate
+
+ if ($result) {
+ system_message("You have been logged out.");
+ } else {
+ system_message("We couldn't log you out. We're not sure why, to be honest. Try again?");
+ }
+
+ //direct to frontpage
+ $url = $CONFIG->url;
+ header("Location: {$url}");
+ exit;
+
+?> \ No newline at end of file
diff --git a/engine/lib/users.php b/engine/lib/users.php
index 9ea66763e..bf72fbe91 100644
--- a/engine/lib/users.php
+++ b/engine/lib/users.php
@@ -546,5 +546,10 @@
}
register_event_handler("init","system","session_init");
+
+ //register actions *************************************************************
+
+ register_action("login",true);
+ register_action("logout");
?> \ No newline at end of file
diff --git a/index.php b/index.php
index e0b2774a3..d75ad8413 100644
--- a/index.php
+++ b/index.php
@@ -17,72 +17,72 @@
require_once(dirname(__FILE__) . "/engine/start.php");
/**
- * Load the front page
- */
- echo page_draw(null, elgg_view("homepage"));
+ * Check to see if user is logged in, if not display login form
+ **/
+ if ($_SESSION['id'] != -1){
+ //Load the sample welcome page
+ echo page_draw(null, elgg_view("welcome"));
+ } else {
+ //Load the front page
+ echo page_draw(null, elgg_view("login"));
+ }
+
+
+
+ // Testing ///////
+ if ($_SESSION['id']==-1) $_SESSION['id'] = 1;
+
+ // Create / load a site
+ $site = get_site(1);
+error_log("GETTIGN SITE " . print_r($site, true));
+
+ if (empty($site))
+ {
+ $site = new ElggSite();
+
+ $site->title = "Test title";
+ $site->description = "Test description";
+ $site->url = "http://dushka/~icewing/Workingdirectory/elggnew/";
+ $site->owner_id = 1;
+ $site->access_id = 0;
+
+ error_log("LOADED NEW SITE: Saving" . print_r($site,true));
+
+ $site->save();
+ }
+ else
+ {
+ $site = new ElggSite($site);
+
+ $site->title = "Test title " . time();
+ $site->save();
+
+ error_log("UPDATING SITE " . print_r($site, true));
+ }
+
+
+
+ // annotate site
+ $site->annotate("Test","TestValue");
+
+ // add meta data
+ $site->setMetadata("Metaname", "Value");
+
+
+
+
+ // change site metadata
+ $site->setMetadata("Metaname", "Value2");
- get_objects(3,"blog","mammals","are lovely", 7, 2, 1);
- $obj = new stdClass;
- $obj->id = 3;
-
-
-
-
- // Testing ///////
- if ($_SESSION['id']==-1) $_SESSION['id'] = 1;
-
- // Create / load a site
- $site = get_site(1);
-error_log("GETTIGN SITE " . print_r($site, true));
-
- if (empty($site))
- {
- $site = new ElggSite();
-
- $site->title = "Test title";
- $site->description = "Test description";
- $site->url = "http://dushka/~icewing/Workingdirectory/elggnew/";
- $site->owner_id = 1;
- $site->access_id = 0;
-
- error_log("LOADED NEW SITE: Saving" . print_r($site,true));
-
- $site->save();
- }
- else
- {
- $site = new ElggSite($site);
-
- $site->title = "Test title " . time();
- $site->save();
-
- error_log("UPDATING SITE " . print_r($site, true));
- }
-
-
-
- // annotate site
- $site->annotate("Test","TestValue");
-
- // add meta data
- $site->setMetadata("Metaname", "Value");
-
-
-
-
- // change site metadata
- $site->setMetadata("Metaname", "Value2");
-
-
-
-
- // get site annotations
- error_log("SITE Annotations : " . print_r($site->getAnnotations("Test"), true));
-
-
- // get site metadata
- error_log("SITE Metadata : " . print_r($site->getMetadata("Metaname"), true));
+
+
+ // get site annotations
+ error_log("SITE Annotations : " . print_r($site->getAnnotations("Test"), true));
+
+
+ // get site metadata
+ error_log("SITE Metadata : " . print_r($site->getMetadata("Metaname"), true));
?> \ No newline at end of file
diff --git a/views/default/css.php b/views/default/css.php
index 10eedcc9d..f81c7766d 100644
--- a/views/default/css.php
+++ b/views/default/css.php
@@ -14,4 +14,24 @@
* @uses $vars['wwwroot'] The site URL
*/
-?> \ No newline at end of file
+?>
+
+/*
+ Default Elgg CSS
+*/
+
+body {
+ background:#fff;
+ color:#000;
+ margin:20px center;
+ text-align:center;
+}
+
+#login-box {
+ text-align:left;
+ background:#555;
+ border:1px solid #ddd;
+ width:300px;
+ padding:10px;
+ margin:auto;
+} \ No newline at end of file
diff --git a/views/default/login.php b/views/default/login.php
new file mode 100644
index 000000000..a09a65705
--- /dev/null
+++ b/views/default/login.php
@@ -0,0 +1,23 @@
+<?php
+
+ /**
+ * Elgg login form
+ *
+ * @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/
+ */
+
+?>
+
+ <div id="login-box">
+ <form action="<?php echo $vars['url']; ?>actions/login.php" method="POST">
+ <label>Username<br /><input name="username" type="text" class="general-textarea" /></label>
+ <br />
+ <label>Password<br /><input name="password" type="password" class="general-textarea" /></label><br />
+ <input type="submit" name="submit" value="login" />
+ </form>
+ </div> \ No newline at end of file
diff --git a/views/default/pageshell.php b/views/default/pageshell.php
index f242335f8..06d427cb6 100644
--- a/views/default/pageshell.php
+++ b/views/default/pageshell.php
@@ -31,6 +31,7 @@
<html>
<head>
<title><?php echo $title; ?></title>
+ <link rel="stylesheet" href="<?php echo $vars['url']; ?>css/css.php" type="text/css" />
</head>
<body>
<h1><?php echo $title; ?></h1>
diff --git a/views/default/welcome.php b/views/default/welcome.php
new file mode 100644
index 000000000..be2d4582f
--- /dev/null
+++ b/views/default/welcome.php
@@ -0,0 +1,19 @@
+<?php
+
+ /**
+ * Elgg sample welcome page
+ *
+ * @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/
+ */
+
+ $user = $vars['name'];
+
+?>
+
+<p>Welcome <?php echo $user; ?></p>
+<p><a href="<?php echo $vars['url']; ?>actions/logout.php">[logout]</a></p> \ No newline at end of file