Ejemplo n.º 1
0
function getGuid()
{
    $guid = KTUtil::getSystemIdentifier();
    if (PEAR::isError($guid)) {
        $guid = '-';
    }
    return $guid;
}
 function do_sendResetRequest()
 {
     $email = $_REQUEST['email'];
     $user = $_REQUEST['username'];
     // Check that the user and email match up in the database
     $sQuery = 'SELECT id FROM users WHERE username = ? AND email = ?';
     $aParams = array($user, $email);
     $id = DBUtil::getOneResultKey(array($sQuery, $aParams), 'id');
     if (!is_numeric($id) || $id < 1) {
         return _kt('Please check that you have entered a valid username and email address.');
     }
     // Generate a random key that expires after 24 hours
     $expiryDate = time() + 86400;
     $randomKey = rand(20000, 100000) . "_{$id}_" . KTUtil::getSystemIdentifier();
     KTUtil::setSystemSetting('password_reset_expire-' . $id, $expiryDate);
     KTUtil::setSystemSetting('password_reset_key-' . $id, $randomKey);
     // Create the link to reset the password
     $query = 'pword_reset=' . $randomKey;
     $url = KTUtil::addQueryStringSelf($query);
     //        $url = KTUtil::kt_url() . '/login.php?' . $query;
     $subject = APP_NAME . ': ' . _kt('password reset request');
     $body = '<dd><p>';
     $body .= _kt('You have requested to reset the password for your account. To confirm that the request was submitted by you
     click on the link below, you will then be able to reset your password.');
     $body .= "</p><p><a href = '{$url}'>" . _kt('Confirm password reset') . '</a></p></dd>';
     $oEmail = new Email();
     $res = $oEmail->send($email, $subject, $body);
     if ($res === true) {
         return _kt('A verification email has been sent to your email address.');
     }
     return _kt('An error occurred while sending the email, please try again or contact the System Administrator.');
 }