From 924f395a39eeccbcd54d540613e440cbedd6ba3d Mon Sep 17 00:00:00 2001
From: Arun Persaud <arun@nubati.net>
Date: Sat, 26 Apr 2008 13:01:41 -0700
Subject: CLEANUP: cleaned up index.php a bit more by introducing an 'action'
 variable

no more if, but one nice switch statement in index.php
Signed-off-by: Arun Persaud <arun@nubati.net>
---
 include/login.php | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
 create mode 100644 include/login.php

(limited to 'include/login.php')

diff --git a/include/login.php b/include/login.php
new file mode 100644
index 0000000..346c71e
--- /dev/null
+++ b/include/login.php
@@ -0,0 +1,33 @@
+<?php
+/* make sure that we are not called from outside the scripts, 
+ * use a variable defined in config.php to check this
+ */
+if(!isset($HOST))
+  exit;
+
+if(!myisset("email","password"))
+  {
+    "can't log you in";
+  }
+else
+  {
+    $email     = $_REQUEST["email"];
+    $password  = $_REQUEST["password"];
+
+    /* verify password and email */
+    if(strlen($password)!=32)
+      $password = md5($password);
+    
+    $ok  = 1;
+    $myid = DB_get_userid('email-password',$email,$password);
+    if(!$myid)
+      $ok = 0;
+    
+    if($ok)
+      {
+	/* user information is ok */
+	$myname = DB_get_name('email',$email);
+	$_SESSION["name"] = $myname;
+      }
+  }
+?>
\ No newline at end of file
-- 
cgit v1.2.3-18-g5258