/trunk/init.php |
---|
44,4 → 44,6 |
$theme = new Theme; |
$auth = new Auth; |
session_start(); |
?> |
/trunk/libs/theme.php |
---|
20,7 → 20,8 |
if ($ID===0) { |
$return = "<div id='yousign'><a href='sign.php?action=signup'>"._("Signup")."</a>"; |
$return .= "• <form action='process.php' method='post'>"; |
$return .= _("Login:")." <input type='text' name='login'> "; |
$return .= "<input type='hidden' name='action' value='signin'>"; |
$return .= _("E-mail:")." <input type='text' name='login'> "; |
$return .= _("Password:")." <input type='password' name='passwd'>"; |
$return .= "<input type='submit' value='"._("Enter")."'></form></div>"; |
} else { |
29,6 → 30,18 |
} |
return $return; |
} |
function showSignupForm() { |
$return = "<form action='process.php' method='post'>"; |
$return .= "<fieldset><input type='hidden' name='action' value='signup'>"; |
$return .= _("E-mail:")." <input type='text' name='login'><br>"; |
$return .= _("Password:")." <input type='password' name='passwd'><br>"; |
$return .= _("Password (again):")." <input type='password' name='passwdag'><br>"; |
$return .= _("Real name:")." <input type='text' name='realname'><br>"; |
$return .= "<input type='submit' value='"._("Register")."'></fieldset></form>"; |
return $return; |
} |
} |
?> |
/trunk/process.php |
---|
12,4 → 12,32 |
require_once dirname(__FILE__)."/init.php"; |
$action = $_POST["action"]; |
switch($action) { |
case 'signin': |
$login = mysql_real_escape_string($_POST["login"]); |
$passw = $_POST["passwd"]; |
$hash = $auth->encPass($passw); |
$ID = $auth->getUserID($login, $hash); |
if ($ID!=0) { |
$user = $auth->getUserInfo($ID); |
$_SESSION["sign"] = $user["login"]; |
$_SESSION["hash"] = $hash; |
} |
break; |
case 'signup': |
$login = mysql_real_escape_string($_POST["login"]); |
$pass1 = $_POST["passwd"]; |
$pass2 = $_POST["passwdag"]; |
$rname = mysql_real_escape_string($_POST["realname"]); |
$status = 1; |
if ($pass1 == $pass2) { |
$pass = $auth->encPass($pass1); |
$register = $auth->registerUser($login, $pass, $rname, $status); |
} |
break; |
} |
?> |
/trunk/sign.php |
---|
Новый файл |
0,0 → 1,32 |
<?php |
/** |
* KBase |
* http://alex-w.org.ru/p/kbase/ |
* |
* Copyright (c) 2009 Alexander Wolf |
* Dual licensed under the MIT and GNU LGPL licenses. |
* http://alex-w.org.ru/p/kbase/license |
* |
*/ |
require_once dirname(__FILE__)."/init.php"; |
if(!empty($_GET["action"])) { |
$action = $_GET["action"]; |
} else { |
$action = "empty"; |
} |
switch ($action) { |
case 'empty': |
break; |
case 'signup': |
$theme->showSignupForm(); |
break; |
case 'exit': |
session_unset(); |
break; |
} |
?> |