Ver Mensaje Individual
  #3 (permalink)  
Antiguo 19/10/2008, 16:56
timz
(Desactivado)
 
Fecha de Ingreso: octubre-2008
Ubicación: Lima
Mensajes: 190
Antigüedad: 15 años, 6 meses
Puntos: 3
Respuesta: envia el pass encriptado al usuario :S

aca posteo el script...

aca la tabla
login.sql

CREATE TABLE `login` (
`loginid` int(10) unsigned NOT NULL auto_increment,
`username` varchar(30) NOT NULL,
`password` varchar(50) NOT NULL,
`email` varchar(255) NOT NULL,
`actcode` varchar(45) NOT NULL,
`disabled` tinyint(1) NOT NULL default '0',
`activated` tinyint(1) NOT NULL default '0',
PRIMARY KEY (`loginid`)
);




activate.php

Cita:
<?php

require_once "header.php";

$uid = (int)htmlentities(strip_tags($_GET['uid']));
$actcode = htmlentities(strip_tags($_GET['actcode']));

if (activateUser($uid, $actcode) == true)
{
echo "Thank you for activating your account, You can now login.
<a href='./index.php'>Click here to login.</a>";
} else
{
echo "Activation failed! Please try again.";
echo "If problem presists please contact the webmaster.";
}

require_once "footer.php";
?>

changepassword.php


<?php

require_once "header.php";

if (isLoggedIn() == true)
{

if (isset($_POST['change']))
{

if (changePassword($_POST['username'], $_POST['oldpassword'], $_POST['password'],
$_POST['password2']))
{
echo "Your password has been changed ! <br /> <a href='./index.php'>Return to homepage</a>";

} else
{
echo "Password change failed! Please try again.";
show_changepassword_form();
}

} else
{
show_changepassword_form();
}

} else {
// user is not loggedin
show_loginform();
}

require_once "footer.php";

?>


db_connect.inc.php


<?php
// Database settings
// database hostname or IP. default:localhost
// localhost will be correct for 99% of times
define("HOST", "localhost");
// Database user
define("DBUSER", "user");
// Database password
define("PASS", "pass");
// Database name
define("DB", "basedatos");

############## Make the mysql connection ###########
$conn = mysql_connect(HOST, DBUSER, PASS) or die('Could not connect !<br />Please contact the site\'s administrator.');

$db = mysql_select_db(DB) or die('Could not connect to database !<br />Please contact the site\'s administrator.');

?>


display.functions.inc.php

<?php

#### Display Functions ####

function show_userbox()
{
// retrieve the session information
$u = $_SESSION['username'];
$uid = $_SESSION['loginid'];
// display the user box
echo "<div id='userbox'>
Welcome $u
<ul>
<li><a href='./changepassword.php'>Change Password</a></li>
<li><a href='./logout.php'>Logout</a></li>
</ul>
</div>";
}

function show_changepassword_form(){

echo '<form action="./changepassword.php" method="post">
<fieldset>
<legend>Change Password</legend>
<input type="hidden" value="'.$_SESSION['username'].'" name="username">
<dl>
<dt>
<label for="oldpassword">Current Password:</label>
</dt>
<dd>
<input name="oldpassword" type="password" id="oldpassword" maxlength="15">
</dd>
</dl>
<dl>
<dt>
<label for="password">New Password:</label>
</dt>
<dd>
<input name="password" type="password" id="password" maxlength="15">
</dd>
</dl>
<dl>
<dt>
<label for="password2">Re-type new password:</label>
</dt>
<dd>
<input name="password2" type="password" id="password2" maxlength="15">
</dd>
</dl>
<p>
<input name="reset" type="reset" value="Reset">
<input name="change" type="submit" value="Reset Password">
</p>
</fieldset>
</form>
';
}

function show_loginform($disabled = false)
{

echo '<form name="login-form" id="login-form" method="post" action="./index.php">
<fieldset>
<legend>Please login</legend>
<dl>
<dt><label title="Username">Username: </label></dt>
<dd><input tabindex="1" accesskey="u" name="username" type="text" maxlength="30" id="username" /></dd>
</dl>
<dl>
<dt><label title="Password">Password: </label></dt>
<dd><input tabindex="2" accesskey="p" name="password" type="password" maxlength="15" id="password" /></dd>
</dl>
<ul>
<li><a href="./register.php" title="Register">Register</a></li>
<li><a href="./lostpassword.php" title="Lost Password">Lost password?</a></li>
</ul>
<p><input tabindex="3" accesskey="l" type="submit" name="cmdlogin" value="Login" ';
if ($disabled == true)
{
echo 'disabled="disabled"';
}
echo ' /></p></fieldset></form>';


}

function show_lostpassword_form(){

echo '<form action="./lostpassword.php" method="post">
<fieldset><legend>Reset Password</legend>
<dl>
<dt><label for="username">Username:</label></dt>
<dd><input name="username" type="text" id="username" maxlength="30">
</dd>
</dl>
<dl>
<dt><label for="email">email:</label></dt>
<dd><input name="email" type="text" id="email" maxlength="255">
</dd>
</dl>
<p>
<input name="reset" type="reset" value="Reset">
<input name="lostpass" type="submit" value="Reset Password">
</p>
</fieldset>
</form>';

}

function show_registration_form(){

echo '<form action="./register.php" method="post">
<fieldset><legend>Register</legend>
<dl>
<dt><label for="username">Username:</label></dt>
<dd><input name="username" type="text" id="username" maxlength="30">
</dd>
</dl>
<dl>
<dt><label for="password">Password:</label></dt>
<dd><input name="password" type="password" id="password" maxlength="15">
</dd>
</dl>
<dl>
<dt><label for="password2">Re-type password:</label></dt>
<dd><input name="password2" type="password" id="password2" maxlength="15">
</dd>
</dl>
<dl>
<dt><label for="email">email:</label></dt>
<dd><input name="email" type="text" id="email" maxlength="255">
</dd>
</dl>
<p>
<input name="reset" type="reset" value="Reset">
<input name="register" type="submit" value="Register">
</p>
</fieldset>
</form>';

}
?>


footer.php


<hr>
<div id='footer'>Copyright 2007-2008 &copy; <?php echo $domain; ?></div>
</body>
</html>



functions.inc.php

<?php

require_once("mail.functions.inc.php");
require_once("user.functions.inc.php");
require_once("display.functions.inc.php");
require_once("login.functions.inc.php");
require_once("validation.functions.inc.php");


function generate_code($length = 10)
{

if ($length <= 0)
{
return false;
}

$code = "";
$chars = "abcdefghijklmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXY Z123456789";
srand((double)microtime() * 1000000);
for ($i = 0; $i < $length; $i++)
{
$code = $code . substr($chars, rand() % strlen($chars), 1);
}
return $code;

}

?>


header.php

<?php
error_reporting(0); // we don't want to see errors on screen
// Start a session
session_start();
require_once ('db_connect.inc.php'); // include the database connection
require_once ("functions.inc.php"); // include all the functions
$seed="0dAfghRqSTgx"; // the seed for the passwords
$domain = "sonidof.com"; // the domain name without http://www.

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Complete Member Login / System tutorial - <?php echo $domain; ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>


index.php


<?php

require_once "header.php";
//content
include "login.php";
// more content
require_once "footer.php";

?>


login.php


<?php
if (!isLoggedIn())
{
// user is not logged in.
if (isset($_POST['cmdlogin']))
{
// retrieve the username and password sent from login form & check the login.
if (checkLogin($_POST['username'], $_POST['password']))
{
show_userbox();
} else
{
echo "Incorrect Login information !";
show_loginform();
}
} else
{
// User is not logged in and has not pressed the login button
// so we show him the loginform
show_loginform();
}

} else
{
// The user is already loggedin, so we show the userbox.
show_userbox();
}
?>