1 (edited by 2004-12-25 06:24:30)

Topic: lost pass addon mod

*UPDATE*
now requires the following two (2) hacks:


fixed a misunderstanding in the mail path shizzle (delete any folders you created because of this hack in the past)
admin email now set in the config
cute mail function now used
make random password function now used (from functions instead of independantly)
shortened code in general - just made it quicker (hooray for milliseconds!)
updated email vs username checking to work better (CASE INSENSITIVE)


<?PHP
/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 lostpass.php - Build 002 - DO NOT EDIT
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
error_reporting (E_ALL ^E_NOTICE);
require_once("./inc/functions.inc.php");
require_once("./data/config.php");
require_once("./skins/${config_skin}.skin.php");
//$PHP_SELF = "";

if($action == "dosend")
{
    if($user == "" or $email == ""){ msg("error", "Error !!!", "All fields are required"); }
    $found = FALSE;
    $all_users = file("./data/users.db.php");
    foreach($all_users as $user_line){
        $user_arr = explode("|", $user_line);
        if(stristr("|".$user_arr[2]."|", "|".$user."|") && stristr("|".$user_arr[5]."|", "|".$email."|")){ $found = TRUE; break;}
    }
    if(!$found){ msg("error", "Error !!!", "The username/email you enter did not match in our users database"); }
    else{

        $new_pass = makeRandomPassword();
     $new_db = fopen("./data/users.db.php", "w");
     foreach($all_users as $all_users_line){
         $all_users_arr = explode("|", $all_users_line);
         if($user != $all_users_arr[2]){
          fwrite($new_db,"$all_users_line");
         }else{
          fwrite($new_db,"$all_users_arr[0]|$all_users_arr[1]|$all_users_arr[2]|".md5($new_pass)."|$all_users_arr[4]|$all_users_arr[5]|$all_users_arr[6]|$all_users_arr[7]|||\n");
         }
     }
     fclose($new_db);

        cute_mail("$email", "Your New Password", "Hello $user,\n Your new password for the ".$_SERVER['SERVER_NAME']." news system is $new_pass, please change this password after you login.");

        msg("info", "Password Sent", "The new password for [b]$user[/b] was sent to [b]$email[/b]");
    }
}
// ********************************************************************************
// LP Main Page
// ********************************************************************************
else{

    echoheader("user","Lost Password");

    echo"<form method=post action=\"$PHP_SELF\"><table border=0 cellpading=0 cellspacing=0 width=\"654\" height=\"59\" >
    <td width=\"18\" height=\"11\">
    <td width=\"71\" height=\"11\" align=\"left\">

    Username<td width=\"203\" height=\"11\" align=\"left\">
        <input type=text name=user seize=20>
    <td width=\"350\" height=\"26\" align=\"left\" rowspan=\"2\" valign=\"middle\">
        If the username and email match in our users database,
 the new password will be automatically mailed to you.
        <tr>
        <td width=\"18\" valign=\"top\" height=\"15\">
          <td width=\"71\" height=\"15\" align=\"left\">
          Email
          <td width=\"203\" height=\"15\" align=\"left\">

        <input type=text name=email size=\"20\">

        </tr>
        <tr>
          <td width=\"18\" valign=\"top\" height=\"15\">
          <td width=\"628\" height=\"15\" align=\"left\" colspan=\"3\">
           

        </tr>
        <tr>
          <td width=\"18\" valign=\"top\" height=\"15\">
          <td         width=\"628\" height=\"15\" align=\"left\" colspan=\"3\">
          <input type=submit value=\"Send me the password\">
        </tr>
        <input type=hidden name=action value=dosend>
        <input type=hidden name=mod value=lostpass>
        <tr>
        <td width=\"18\" height=\"27\">
        <td width=\"632\" height=\"27\" colspan=\"3\">
        </tr></table></form>";

    echofooter();
}

?>


as with the original just place in the cute news directory and link to it

difference between this mod and the original:
this one has better random password generation, better mail delivery, and better email vs username checking