Re: Problem with script....
| From: | Tijnema ! | Date: | Thu, 08 Mar 2007 15:32:15 +0000 |
| Subject: | Re: Problem with script.... | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-250074@lists.php.net to get a copy of this message | ||
On 3/8/07, Fabio Silva <fssilva@gmail.com> wrote:
Hi all, i have a problem with this script... could anybody help me??What is your problem? you are only posting your code here and whe have to find the error? What error comes up? Tijnema Regards,
<title>Password change</title></head>
<body bgcolor="#ffffff">
<?php
//Written by Dave Edick on 6/22/99
// customize these variables for your install
$base_dn="ou=People";
$ldap_server="localhost";
error_reporting(E_ERROR);
$abort=0;
$user=$HTTP_POST_VARS["user"];
$oldpw=$HTTP_POST_VARS["oldpw"];
$newpw1=$HTTP_POST_VARS["newpw1"];
$newpw2=$HTTP_POST_VARS["newpw2"];
if (! strlen($user)) {
echo "Senha tem que ter no minimo 6 caracteres.<br>";
echo "<form action=".$PHP_SELF." method=post><table><tr><td>";
echo "<b>Username:</b></td><td><input type=text
name=user></td></tr><tr>";
echo "<td><b>Old Password:</b></td><td><input type=password
name=oldpw>";
echo "</td></tr><tr><td><b>New Password:</b></td><td>";
echo "<input type=password name=newpw1></td></tr>";
echo "<tr><td><b>New Password, again:</b></td><td>";
echo "<input type=password name=newpw2></td></tr>";
echo "<tr><td><input value=\"Change Password\" type=submit></td>";
echo "<td><input value=\"Clear Entries\" type=reset></td></tr>";
echo "</table></form></center>";
exit();
}
if (! $oldpw ) {
echo "<h3>Naoi fornecido a senha antiga!<br>";
$abort=1;
}
if (! $newpw1 ) {
echo "<h3>Nao foi fornecido a nova senha!<br>";
$abort=1;
} else
if (! $newpw1 == $oldpw ) {
if ($newpw1 != $newpw2) {
echo "<h3>Nova senha nao e igual!<br>";
$abort=1;
}
if (strlen($newpw1) < 6) {
echo "<h3>Nova senha e menor que 6 caracteres!<br>";
$abort=1;
}
}
$ldap_session=ldap_connect($ldap_server);
$anon_session=ldap_bind($ldap_session);
$anon_search=ldap_search($anon_session,$base_dn,"uid=$user");
$uid_data=ldap_get_entries($anon_session,$anon_search);
if( $uid_data["count"] != 1) {
echo "<h3>".$user." nao e valido!<br>";
$abort=1;
}
$dn=$uid_data[0]["dn"];
$auth_session=ldap_bind($ldap_session,$dn,$oldpw);
if (! $auth_session) {
echo "<h3>Senha antiga incorreto!<br>";
$abort=1;
}
if ($abort == 1) {
echo "<br>Favor clique em voltar e corriga o(s) problema(s)</h3>";
exit();
}
srand((double)microtime()*1000000);
$alphabet=array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o",
"p","q","r","s","t","u","v","w","x","y","z","A","B","C","D",
"E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S",
"T","U","V","W","X","Y","Z","2","3","4","5","6","7","8","9");
$salt=$alphabet[rand(0,58)].$alphabet[rand(0,58)];
$mod_data["userpassword"]="{crypt}".crypt($newpw1,$salt);
ldap_modify($auth_session,$dn,$mod_data);
ldap_unbind($ldap_session);
?>
<h3>Seu password foi alterado</h3><br>
<a href="http://www.terra.com.br">Pagin principal</a><br>
</body></html>
--
Fabio S. Silva
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php