for ($i = 0; $i < 16; $i++) { $new_serial .= rand(0, 9); } $data = array('serial' => $new_serial); $db->where('id', $result['id']); $db->update('user', $data); $_SESSION['admin'] = $new_serial; $_SESSION['grawlix_version'] = 'run_check'; // software update check $_SESSION['install_cleanup'] = 'run_check'; // check if firstrun is still present grlx_cookie(); header('location:' . $ref); die; } else { $view->alert_msg('Login failed.'); } } if ($username && $extra && !$result || $count == 0) { $view->alert_msg('Login failed.'); } } /* ! Build * * * * * * * */ $form = new GrlxForm(); $form->error_check(false); $form->no_div_wrap(); $form->hide_error(); $form->send_to($_SERVER['SCRIPT_NAME']); $form_output = $form->open_form(); $form->input_hidden('ref'); $form->value($ref);
* Updates */ // When the user submits a form if ($new_password && $s) { // Give the user a new serial number. for ($i = 0; $i < 16; $i++) { $new_serial .= rand(0, 9); } $new_hash = password_hash($new_password, PASSWORD_BCRYPT); if (password_verify($new_password, $new_hash)) { $data = array('serial' => $new_serial, 'password' => $new_hash, 'date_modified' => $db->now()); $db->where('serial', $s); $db->update('user', $data); $success = true; } else { $view->alert_msg('Password reset failed.'); } } /***** * Display logic */ if ($success) { $form_output = '<p>Your password has been reset.</p>'; $view->action('<div><a class="btn primary login" href="panl.login.php"><i></i>Login</a></div>'); $form_output .= $view->format_actions(); } else { $form_output = $form->open_form(); $form->input_hidden('s'); $form->value($s); $form_output .= $form->paint(); $form_output .= $form->new_password('new_password');
// Check if valid user $user = $db->where('email', $email)->getOne('user', 'count(*) AS count'); if ($user['count'] == 1) { // Give the user a new serial number. for ($i = 0; $i < 16; $i++) { $new_serial .= rand(0, 9); } $data = array('serial' => $new_serial, 'date_modified' => $db->now()); $db->where('email', $email); if ($db->update('user', $data)) { $email_message = 'Tap this to reset your Grawlix password: http://' . $_SERVER['HTTP_HOST'] . '/_admin/panl.password-reset.php?s=' . $new_serial; $headers = 'From: ' . $email . "\r\n" . 'Reply-To: ' . $email . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($email, 'Grawlix password reset', $email_message, $headers); $success = true; } else { $view->alert_msg('Database error.'); } } else { $view->alert_msg('Email not found.'); unset($_POST); } } /***** * Display logic */ if ($success) { $form_output = '<p>Email sent to <b>' . $email . '</b>.</p><p>Please check your inbox for instructions and a link to reset your password.</p>'; } else { $form_output = $form->open_form(); $form->input_email('email'); $form->label('Enter the email associated with your panel username');