Copyright (c) 2002 - 2003 osCommerce

   Released under the GNU General Public License
   ---------------------------------------------------------------------------*/
require 'includes/application_top.php';
// include needed functions
require_once DIR_FS_INC . 'olc_image_button.inc.php';
require_once DIR_FS_INC . 'olc_draw_input_field.inc.php';
// include the mailer-class
require_once DIR_WS_CLASSES . 'class.phpmailer.php';
if (isset($_GET['action']) && $_GET['action'] == 'process') {
    $check_affiliate_query = olc_db_query("select affiliate_firstname, affiliate_lastname, affiliate_password, affiliate_id from " . TABLE_AFFILIATE . " where affiliate_email_address = '" . $_POST['email_address'] . APOS);
    if (olc_db_num_rows($check_affiliate_query)) {
        $check_affiliate = olc_db_fetch_array($check_affiliate_query);
        // Crypted password mods - create a new password, update the database and mail it to them
        $newpass = olc_create_random_value(ENTRY_PASSWORD_MIN_LENGTH);
        $crypted_password = olc_encrypt_password($newpass);
        olc_db_query(SQL_UPDATE . TABLE_AFFILIATE . " set affiliate_password = '******' where affiliate_id = '" . $check_affiliate['affiliate_id'] . APOS);
        olc_php_mail(AFFILIATE_EMAIL_ADDRESS, STORE_OWNER, $_POST['email_address'], $check_affiliate['affiliate_firstname'] . BLANK . $check_affiliate['affiliate_lastname'], '', AFFILIATE_EMAIL_ADDRESS, STORE_OWNER, '', '', EMAIL_PASSWORD_REMINDER_SUBJECT, nl2br(sprintf(EMAIL_PASSWORD_REMINDER_BODY, $newpass)), nl2br(sprintf(EMAIL_PASSWORD_REMINDER_BODY, $newpass)));
        if (!isset($mail_error)) {
            olc_redirect(olc_href_link(FILENAME_AFFILIATE, 'info_message=' . urlencode(TEXT_PASSWORD_SENT), SSL, true, false));
        } else {
            echo $mail_error;
        }
    } else {
        olc_redirect(olc_href_link(FILENAME_AFFILIATE_PASSWORD_FORGOTTEN, 'email=nonexistent', SSL));
    }
} else {
    $breadcrumb->add(NAVBAR_TITLE, olc_href_link(FILENAME_AFFILIATE, '', SSL));
    $breadcrumb->add(NAVBAR_TITLE_PASSWORD_FORGOTTEN, olc_href_link(FILENAME_AFFILIATE_PASSWORD_FORGOTTEN, '', SSL));
    require DIR_WS_INCLUDES . 'header.php';
 function generate_cart_id($length = 5)
 {
     return olc_create_random_value($length, 'digits');
 }
 function generate_trid()
 {
     do {
         $trid = olc_create_random_value(16, "mixed");
         $result = olc_db_query("SELECT mb_TRID FROM " . TABLE_PAYMENT_MONEYBOOKERS . "  WHERE mb_TRID = '{$trid}'");
     } while (olc_db_num_rows($result));
     return $trid;
 }