Re: Problem with script....

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Fabio Silva wrote:
Hi all, i have a problem with this script... could anybody help me??

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"];

First question to you is, what version of PHP are you using?



all the above should be in this format:

$list = array('user','oldpw','newpw1','newpw2');
foreach ( $list AS $value ) {
	$$value = false;
	if ( isset($_POST[]) ) {
		$$value = $_POST[$value];
	}
}


if (! strlen($user)) {

if ( isset($user) && !empty($user) ) {

   echo "Senha tem que ter no minimo 6 caracteres.<br>";
   echo "<form action=".$PHP_SELF." method=post><table><tr><td>";

The $PHP_SELF variable does not exist, try $_SERVER['PHP_SELF']

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 ) {

if ( isset($oldpw) ) {

   echo "<h3>Naoi fornecido a senha antiga!<br>";
   $abort=1;
   }

if (! $newpw1 ) {

if ( isset($newpw1) && isset($newpw2) ) {

   echo "<h3>Nao foi fornecido a nova senha!<br>";
   $abort=1;
   } else if (! $newpw1 == $oldpw ) {

} 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>




--
Enjoy,

Jim Lucas

Different eyes see different things. Different hearts beat on different strings. But there are times for you and me when all such things agree.

- Rush

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux