コード例 #1
0
 public function generatePassword(Request $request)
 {
     $data = 'POST' === $request->getMethod() ? $this->handleRequest($request) : $request->query->all();
     $generator = new \PWGen();
     $generator->setCapitalize((bool) $data['upper_case'])->setNumerals((bool) $data['numbers'])->setSecure((bool) $data['secure'])->setSymbols((bool) $data['symbols'])->setLength((int) $data['length']);
     return new JsonResponse(['password' => $generator->generate()], 200);
 }
コード例 #2
0
ファイル: main.queries.php プロジェクト: sleepy909/cpassman
     }
     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
         $mail = new PHPMailer();
         $mail->SetLanguage("en", "../includes/libraries/phpmailer/language/");
コード例 #3
0
ファイル: items.queries.php プロジェクト: sleepy909/cpassman
      */
 /*
  * CASE
  * Generate a password
  */
 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