From e201c260f2bd78cee762461ef41e508790edc299 Mon Sep 17 00:00:00 2001
From: real_nowhereman
Date: Fri, 28 Mar 2008 12:25:43 +0000
Subject: [PATCH] made login session-less
---
fp-interface/sharedtpls/login.tpl | 10 ++----
login.php | 51 ++++++++++++++++++++-----------
2 files changed, 36 insertions(+), 25 deletions(-)
diff --git a/fp-interface/sharedtpls/login.tpl b/fp-interface/sharedtpls/login.tpl
index 236601d..1e2a918 100755
--- a/fp-interface/sharedtpls/login.tpl
+++ b/fp-interface/sharedtpls/login.tpl
@@ -1,15 +1,11 @@
-{validate id="userid" message=$lang.login.error.user append="error"}
-{validate id="pwd" message=$lang.login.error.pass append="error"}
-{validate id="password" message=$lang.login.error.match append="error"}
-
{include file=shared:errorlist.tpl}
-
-
+
diff --git a/login.php b/login.php
index 23beaa9..7554b43 100755
--- a/login.php
+++ b/login.php
@@ -8,6 +8,36 @@
$tpl = 'default.tpl';
+
+ function login_validate() {
+ global $smarty, $lang;
+
+ $user = trim(@$_POST['user']);
+ $pass = trim(@$_POST['pass']);
+
+ $error = array();
+ $lerr =& $lang['login']['error'];
+
+ if (!$user) {
+ $error['user'] = $lerr['user'];
+ }
+
+ if (!$pass) {
+ $error['pass'] = $lerr['pass'];
+ }
+
+ if (!$error && !user_login($user, $pass)) {
+ $error['match'] = $lerr['match'];
+ }
+
+ if ($error) {
+ $smarty->assign('error', $error);
+ return 0;
+ }
+
+ return 1;
+
+ }
function main() {
global $lang, $smarty;
@@ -54,26 +84,11 @@
} elseif(empty($_POST)) {
-
- // new form, we (re)set the session data
- SmartyValidate::connect($smarty, true);
- // register our validators
- SmartyValidate::register_validator('userid', 'user', 'notEmpty', false, false, 'trim');
- SmartyValidate::register_validator('pwd', 'pass', 'notEmpty', false, false, 'trim');
- SmartyValidate::register_validator('password', 'user:pass', 'isValidPassword', false, false);
-
- // display form
- $content = (SHARED_TPLS . 'login.tpl');
+ $content = (SHARED_TPLS . 'login.tpl');
} else {
// validate after a POST
- SmartyValidate::connect($smarty);
- if(SmartyValidate::is_valid($_POST)) {
- SmartyValidate::disconnect();
-
- // sess_add('login_do', true);
- // utils_redirect();
+ if(login_validate()) {
utils_redirect('login.php');
-
} else {
$smarty->assign($_POST);
$content = (SHARED_TPLS . 'login.tpl');
@@ -112,4 +127,4 @@
$smarty->display('default.tpl');
-?>
\ No newline at end of file
+?>