<?php
/*
###################################################################################
  Bigware Shop 2.3
  Release Datum: 23.08.2015
  
  Bigware Shop
  http://www.bigware.de

  Copyright (c) 2015 Bigware LTD
  (c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
  (c) 2015	Bigware LTD

  Copyrightvermerke duerfen nicht entfernt werden.
  ------------------------------------------------------------------------
  Dieses Programm ist freie Software. Sie koennen es unter den Bedingungen
  der GNU General Public License, wie von der Free Software Foundation
  veroeffentlicht, weitergeben und/oder modifizieren, entweder gemaess Version 2 
  der Lizenz oder (nach Ihrer Option) jeder spaeteren Version.
  Die Veroeffentlichung dieses Programms erfolgt in der Hoffnung, dass es Ihnen
  von Nutzen sein wird, aber OHNE IRGENDEINE GARANTIE, sogar ohne die
  implizite Garantie der MARKTREIFE oder der VERWENDBARKEIT FUER EINEN
  BESTIMMTEN ZWECK. Details finden Sie in der GNU General Public License.
  
  Sie sollten eine Kopie der GNU General Public License zusammen mit diesem
  Programm erhalten haben. Falls nicht, schreiben Sie an die Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.

  Infos:
  ------------------------------------------------------------------------
  Der Bigware Shop wurde vor vielen Jahren bereits aus dem bekannten Shopsystem osCommerce
  weiter- und neuentwickelt.
  Der Bigware Shop legt im hohen Masse Wert auf Bedienerfreundlichkeit, beinhaltet eine leichte
  Installation, viele neue professionelle Werkzeuge und zeichnet sich aus durch eine grosse 
  Community, die bei Problemen weiterhelfen kann.
  
  Der Bigware Shop ist auf jedem System lauffaehig, welches eine PHP Umgebung
  (ab PHP 4.1.3) und mySQL zur Verfuegung stellt und auf Linux basiert.
 
  Hilfe erhalten Sie im Forum auf www.bigware.de 
  
  -----------------------------------------------------------------------
  
 ##################################################################################




*/
?>
<?php
  require('load_this/load_bigware_11.php');
  require(FOLDER_RELATIV_LANGUAGES . $language . '/' . NAME_OF_FILE_LOGIN);
  
  if (isset($_GET['action']) && ($_GET['action'] == 'process')) {
    $email_address = go_db_producing_input($_POST['email_address']);
    $firstname = go_db_producing_input($_POST['firstname']);
    $log_times = $_POST['log_times']+1;
    if ($log_times >= 4) {
      go_session_register('password_forgotten');
    } 
    $check_former_query = go_db_query("select former_id as check_id, former_firstname as check_firstname, former_lastname as check_lastname, former_email_address as check_email_address from " . DB_TBL_FORMER . " where former_email_address = '" . go_db_input($email_address) . "'");
    if (!go_db_num_rows($check_former_query)) {
      $_GET['login'] = 'fail';
    } else {
      $check_former = go_db_fetch_array($check_former_query);
      if ($check_former['check_firstname'] != $firstname) {
        $_GET['login'] = 'fail';
      } else {
        $_GET['login'] = 'success';
        
        function randomize() {
          $salt = "ABCDEFGHIJKLMNOPQRSTUVWXWZabchefghjkmnpqrstuvwxyz0123456789";
          srand((double)microtime()*1000000); 
          $i = 0;
    
          while ($i <= 7) {
            $num = rand() % 33;
    	    $tmp = substr($salt, $num, 1);
    	    $pass = $pass . $tmp;
    	    $i++;
  	  }
  	  return $pass;
        }
        $makePassword = randomize();
      
        go_mail($check_former['check_firstname'] . ' ' . $check_former['former_lastname'], $check_former['check_email_address'], FORMER_EMAIL_SUBJECT, sprintf(FORMER_EMAIL_TEXT, $check_former['check_firstname'], HTTP_SERVER . FOLDER_RELATIV_FORMER, $check_former['check_email_address'], $makePassword, SHOP_OWNER), SHOP_OWNER, SHOP_OWNER_EMAIL_ADDRESS);            
        go_db_query("update " . DB_TBL_FORMER . " set former_password = '" . go_encrypt_password($makePassword) . "' where former_id = '" . $check_former['check_id'] . "'");
      }
    }
  }
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<style type="text/css"><!--
a { color:#080381; text-decoration:none; }
a:hover { color:#aabbdd; text-decoration:underline; }
a.text:link, a.text:visited { color: #ffffff; text-decoration: none; }
a:text:hover { color: #000000; text-decoration: underline; }
a.sub:link, a.sub:visited { color: #dddddd; text-decoration: none; }
A.sub:hover { color: #dddddd; text-decoration: underline; }
.sub { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; font-weight: bold; line-height: 1.5; color: #dddddd; }
.text { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; font-weight: bold; color: #000000; }
.smallText { font-family: Verdana, Arial, sans-serif; font-size: 10px; }
.login_heading { font-family: Verdana, Arial, sans-serif; font-size: 12px; color: #ffffff;}
.login { font-family: Verdana, Arial, sans-serif; font-size: 12px; color: #000000;}
//--></style>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">
<?php 
$passwort_vergessen_ja = "764-hk&%(&%?!lsjdhfHFHF8990870987gkgRTT=))/%$/&%$$&/(%))=&=/&//&%($54";
require(FOLDER_RELATIV_INCLUDES . 'load_bigware_9.php'); 
?>
<!-- form -->
 <?php echo go_fetch_form('login', NAME_OF_FILE_PASSWORD_FORGOTTEN, 'action=process'); ?>
 <div align="center">
  <center>
                            <table width="280" border="0" cellspacing="0" cellpadding="2">
                              <tr>
                                <td class="login_heading" valign="top">&nbsp;<b><?php echo ABOVE_PASSWORD_FORGOTTEN; ?></b></td>
                              </tr>
                              <tr>
                                <td height="100%" width="100%" valign="top" align="center">
                                <table border="0" height="100%" width="100%" cellspacing="0" cellpadding="1" bgcolor="#666666">
                                  <tr><td><table border="0" width="100%" height="100%" cellspacing="3" cellpadding="2" bgcolor="#F0F0FF">
<?php
  if ($_GET['login'] == 'success') {
    $success_message = TEXT_FORGOTTEN_SUCCESS;
  } elseif ($_GET['login'] == 'fail') {
    $info_message = TEXT_FORGOTTEN_ERROR;
  }
  if (go_session_is_registered('password_forgotten')) {
?>
                                    <tr>
                                      <td class="smallText"><?php echo TEXT_FORGOTTEN_FAIL; ?></td>
                                    </tr>
                                    <tr>
                                      <td align="center" valign="top"><?php echo '<a href="' . go_href_link(NAME_OF_FILE_LOGIN, '' , 'SSL') . '">' . go_picture_button('button_back.gif', PICTURE_BACK) . '</a>'; ?></td>
                                    </tr>
<?php
  } elseif (isset($success_message)) {
?>
                                    <tr>
                                      <td class="smallText"><?php echo $success_message; ?></td>
                                    </tr>
                                    <tr>
                                      <td align="center" valign="top"><?php echo '<a href="' . go_href_link(NAME_OF_FILE_LOGIN, '' , 'SSL') . '">' . go_picture_button('button_back.gif', PICTURE_BACK) . '</a>'; ?></td>
                                    </tr>
<?php
  } else {
    if (isset($info_message)) {
?>
                                    <tr>
                                      <td colspan="2" class="smallText" align="center"><?php echo $info_message; ?><?php echo go_fetch_hidden_field('log_times', $log_times); ?></td>
                                    </tr>
<?php
    } else {
?>
                                    <tr>
                                      <td colspan="2"><?php echo go_fetch_dividing_up('tranparentes.gif', '100%', '10'); ?><?php echo go_fetch_hidden_field('log_times', '0'); ?></td>
                                    </tr>
<?php
    }
?>                                    
                                    <tr>
                                      <td class="login"><?php echo TYPE_IN_FIRSTNAME; ?></td>
                                      <td class="login"><?php echo go_fetch_inputfeld('firstname'); ?></td>
                                    </tr>
                                    <tr>
                                      <td class="login"><?php echo TYPE_IN_EMAIL_ADDRESS; ?></td>
                                      <td class="login"><?php echo go_fetch_inputfeld('email_address'); ?></td>
                                    </tr>
                                    <tr>
                                      <td colspan="2" align="right" valign="top"><?php echo '<a href="' . go_href_link(NAME_OF_FILE_LOGIN, '' , 'SSL') . '">' . go_picture_button('button_back.gif', PICTURE_BACK) . '</a> ' . go_picture_submit('button_confirm.gif', PICTURE_BUTTON_LOGIN); ?>&nbsp;</td>
                                    </tr>
<?php
  }
?>   
                                  </table></td></tr>
                                </table>
                                </td>
                              </tr>
                            </table>
                          </form>
<!-- form -->
  </center>
</div>
<?php require(FOLDER_RELATIV_INCLUDES . 'load_bigware_7.php'); ?> 
</body>
</html>