<?php

	// Hauptkonfigurationsdatei
	include_once("../../conf/config.inc.php");
	include_once(DATEIPFAD . "conf/db.inc.php");
	if(KUNDENGRUPPEN) {
		include_once(DATEIPFAD . "includes/functions.mod.kundengruppen.inc.php");
	} else {
		include_once(DATEIPFAD . "includes/functions.kundengruppen.inc.php");
	}
	include_once(DATEIPFAD . "includes/functions.artikel.inc.php");
	include_once(DATEIPFAD . "includes/functions.rabattstaffeln.inc.php");
	include_once(DATEIPFAD . "includes/functions.versandart.inc.php");
	include_once(DATEIPFAD . "includes/functions.zahlungsart.inc.php");
	include_once(DATEIPFAD . "includes/functions.kunden.inc.php");
	include_once(DATEIPFAD . "includes/functions.mail.inc.php");
	include_once(DATEIPFAD . "includes/functions.shopeinstellung.inc.php");
	include_once(DATEIPFAD . "includes/functions.warenkorb.inc.php");
	include_once(DATEIPFAD . "includes/functions.land.inc.php");
	include_once(DATEIPFAD . "includes/functions.waehrung.inc.php");
	include_once(DATEIPFAD . "includes/functions.kategorie.inc.php");
	if(RECHNUNGSWESEN) {
		include_once(DATEIPFAD . "includes/functions.mod.bestellungen.inc.php");
	} else {
		include_once(DATEIPFAD . "includes/functions.bestellungen.inc.php");
	}
	if(ARTIKELDOWNLOAD) {
		include_once(DATEIPFAD . "includes/functions.mod.download.inc.php");
	}
	include_once(DATEIPFAD . "includes/functions.global.inc.php");
	include_once(DATEIPFAD . "includes/crypt.inc.php");

	// Spracheninclude
	if (@fopen(DATEIPFAD . "includes/language/langu_" . $_SESSION["langu"] . ".inc.php",r)) {
		include_once(DATEIPFAD . "includes/language/langu_" . $_SESSION["langu"] . ".inc.php");
	} else {
		include_once(DATEIPFAD . "includes/language/langu_de.inc.php");
	}	

	// ********************************************************************************
	// ** Ueberpruefung der Bestellung
	// ********************************************************************************

	if ($_GET['function'] == "billing") {
	
		$SQLString = "SELECT ";
		$SQLString .= TABLE_BESTELLEN . ".id, ";
		$SQLString .= TABLE_BESTELLEN . ".zahlungsart_id, ";
		$SQLString .= TABLE_BESTELLEN . ".email ";
		$SQLString .= "FROM " . TABLE_BESTELLEN . " ";
		$SQLString .= "WHERE ";
		$SQLString .= "MD5(" . TABLE_BESTELLEN . ".session) = '" . $_GET["session"] . "' ";
		
		$BestellObject = mysql_fetch_object(errorlogged_mysql_query($SQLString));
		
		// Bestellung erfolgreich
		if ($BestellObject) {

			$ZahlungsartObject = GetZahlungsartDetail($BestellObject->zahlungsart_id, $BestellObject->email);
						
			$SQLString = "UPDATE " . TABLE_BESTELLEN . " SET ";
			$SQLString .= TABLE_BESTELLEN . ".status = '" . $ZahlungsartObject->bestellen_status_id . "' ";
			$SQLString .= "WHERE ";
			$SQLString .= TABLE_BESTELLEN . ".id = '" . $BestellObject->id . "' ";
			
			$MySQLQueryReference = errorlogged_mysql_query($SQLString);
			
			$mp_ebank2pay_status = "ok";
			$mp_ebank2pay_url = URLPFAD . "themes/bestellen/mp_ebank2pay_exit.php";
			$mp_ebank2pay_target = "_self";
			$mp_ebank2pay_forward = "1";
			
		} else {
			
			$mp_ebank2pay_status = "error";
			$mp_ebank2pay_url = URLPFAD . "themes/bestellen/mp_ebank2pay_exit.php";
			$mp_ebank2pay_target = "_self";
			$mp_ebank2pay_forward = "1";
			
		}

	}

	$mp_ebank2pay_response = 'status=' . $mp_ebank2pay_status . "\n";
	$mp_ebank2pay_response .= 'url=' . $mp_ebank2pay_url . "\n";
	$mp_ebank2pay_response .= 'target=' . $mp_ebank2pay_target . "\n";
	$mp_ebank2pay_response .= 'forward=' . $mp_ebank2pay_forward . "\n";

	echo $mp_ebank2pay_response;
	
?>