//no one has this email ... alert echo '[{"error":"error_email" , "message":"' . $txt['forgot_my_pw_error_email_not_exist'] . '"}]'; } break; //Send to user his new pw if key is conform //Send to user his new pw if key is conform case "generate_new_password": //check if key is okay $data = $db->fetch_row("SELECT valeur FROM " . $pre . "misc WHERE intitule = '" . $_POST['login'] . "' AND type = 'password_recovery'"); if ($_POST['key'] == $data[0]) { //Generate and change pw $new_pw = ""; include '../includes/libraries/pwgen/pwgen.class.php'; $pwgen = new PWGen(); $pwgen->setLength(10); $pwgen->setSecure(true); $pwgen->setSymbols(false); $pwgen->setCapitalize(true); $pwgen->setNumerals(true); $new_pw_not_crypted = $pwgen->generate(); $new_pw = encrypt(string_utf8_decode($new_pw_not_crypted)); //update DB $db->query_update("users", array('pw' => $new_pw), "login = '******'login'] . "'"); //Delete recovery in DB $db->query_delete("misc", array('type' => 'password_recovery', 'intitule' => $_POST['login'], 'valeur' => $key)); //Get email $data_user = $db->query_first("SELECT email FROM " . $pre . "users WHERE login = '******'login'] . "'"); $_SESSION['validite_pw'] = false; //load library require_once "../includes/libraries/phpmailer/class.phpmailer.php"; //send to user
case "pw_generate": $key = ""; //call class include '../includes/libraries/pwgen/pwgen.class.php'; $pwgen = new PWGen(); // Set pw size $pwgen->setLength($_POST['size']); // Include at least one number in the password $pwgen->setNumerals($_POST['num'] == "true" ? true : false); // Include at least one capital letter in the password $pwgen->setCapitalize($_POST['maj'] == "true" ? true : false); // Include at least one symbol in the password $pwgen->setSymbols($_POST['symb'] == "true" ? true : false); // Complete random, hard to memorize password if (isset($_POST['secure']) && $_POST['secure'] == "true") { $pwgen->setSecure(true); $pwgen->setSymbols(true); $pwgen->setCapitalize(true); $pwgen->setNumerals(true); } else { $pwgen->setSecure(false); } echo json_encode(array("key" => $pwgen->generate()), JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP); break; /* * CASE * Delete an item */ /* * CASE * Delete an item