$data = getAjaxData(); $result['valid'] = false; // We did not get any request data if ($data === null) { die; } // Validate the field value given if ($data['action'] === 'validate') { // It's valid if (validate($data['field'], $data['value'])) { $result['valid'] = true; } echo json_encode($result); // Submit the form } elseif ($data['action'] === 'submit') { // Bot check ;) if ($data['value']['bot'] === true) { die; } // Remove the bot field, as it is now useless unset($data['value']['bot']); // Validate all the fields if (validateAll($data['value'])) { // Send the email $result['valid'] = true; _sendEmail($data['value']); } echo json_encode($result); } } die;
$admin = $result->fetch_array(); if ($result->num_rows < 1) { $errors['inputEmail'] = $i18n->getMessage('sendpassword_admin_usernotfound'); } elseif ($admin['passwort_neu_angefordert'] > $now - 120 * 60) { $errors['inputEmail'] = $i18n->getMessage('sendpassword_admin_alreadysent'); } else { $newPassword = SecurityUtil::generatePassword(); $hashedPw = SecurityUtil::hashPassword($newPassword, $admin['passwort_salt']); // store new PW $columns = array('passwort_neu' => $hashedPw, 'passwort_neu_angefordert' => $now); $fromTable = $conf['db_prefix'] . '_admin'; $whereCondition = 'id = %d'; $parameter = $admin['id']; $db->queryUpdate($columns, $fromTable, $whereCondition, $parameter); try { _sendEmail($inputEmail, $newPassword, $website, $i18n); header('location: login.php?newpwd=1'); die; } catch (Exception $e) { $errors['inputEmail'] = $e->getMessage(); } } $result->free(); } } function _sendEmail($email, $password, $website, $i18n) { $tplparameters['newpassword'] = $password; EmailHelper::sendSystemEmailFromTemplate($website, $i18n, $email, $i18n->getMessage('sendpassword_admin_email_subject'), 'sendpassword_admin', $tplparameters); } ?>