HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/molennooitgedagtbudel.nl/wwwroot/paymentCheck.php
<?php

require_once 'initializeMollie.php';
include("all_kms_con.inc.php");
require_once 'css-js/phpmailer/class.phpmailer.php';

session_start();

if (isset($_GET['order_id'])) {
	
	$order_id = $_GET['order_id'];

	$q_payment_id = sprintf("SELECT kms_orders.transactie_id FROM kms_orders WHERE kms_orders.order_id = '%s'", $order_id);
	$r_payment_id = mysql_query($q_payment_id);
	$rec_payment_id = mysql_fetch_assoc($r_payment_id);

	$payment_id = $rec_payment_id['transactie_id'];
	$payment    = $mollie->payments->get($payment_id);

	/*
	 * The order ID saved in the payment can be used to load the order and update it's status
	 */
	$order_id = $payment->metadata->order_id;
	$betaalstatus = $payment->status;
	
	if ($payment->isPaid())
	{
	
		$q_order_prijs = sprintf("SELECT kms_orders.totaalprijs, kms_orders.verzendwijze, kms_orders.status FROM kms_orders WHERE kms_orders.order_id = '%s'", $order_id);
			$r_order_prijs = mysql_query($q_order_prijs);
			$rec_order_prijs = mysql_fetch_assoc($r_order_prijs);
	
			$betaald = "yes";
	
			if($rec_order_prijs['status'] != "voltooid"){
	
				if($rec_order_prijs['verzendwijze'] == "ophalen"){
					$status = "nog op te halen";
				}else{
					$status = "wacht op verzending";
				}
	
				$q_set_betaald = sprintf("UPDATE kms_orders SET betaald = '%s', status = '%s', betaalstatus = '%s' WHERE kms_orders.order_id='%s'", $betaald, $status, $betaalstatus, $order_id);
				$r_set_betaald = mysql_query($q_set_betaald);
			}
	
	}
	elseif (! $payment->isOpen())
	{
		/*
		 * The payment isn't paid and isn't open anymore. We can assume it was aborted.
		 */
	}


    $q_order_data = sprintf("SELECT kms_orders.order_id, kms_orders.betaald, kms_orders.ordernummer, kms_orders.bedrijfsnaam, kms_orders.voornaam, kms_orders.tussenvoegsel, kms_orders.achternaam, kms_orders.geslacht, kms_orders.emailadres, kms_orders.telefoonnummer, kms_orders.straatnaam, kms_orders.huisnummer, kms_orders.toevoeging, kms_orders.postcode, kms_orders.woonplaats, kms_orders.land, kms_orders.bezorgadresWijktAf, kms_orders.bedrijfsnaamBezorg, kms_orders.voornaamBezorg, kms_orders.tussenvoegselBezorg, kms_orders.achternaamBezorg, kms_orders.geslachtBezorg, kms_orders.straatnaamBezorg, kms_orders.huisnummerBezorg, kms_orders.toevoegingBezorg, kms_orders.postcodeBezorg, kms_orders.woonplaatsBezorg, kms_orders.landBezorg, kms_orders.subtotaalprijs, kms_orders.verzendkosten, kms_orders.totaalprijs, kms_orders.verzendwijze FROM kms_orders WHERE kms_orders.order_id = '%s'", $order_id);
    $r_order_data = mysql_query($q_order_data);
    $rec_order_data = mysql_fetch_assoc($r_order_data);

    if($rec_order_data['geslacht'] == "man"){
        $aanhef = "heer";
    }else{
        $aanhef = "mevrouw";
    }
    if(empty($rec_order_data['tussenvoegsel'])){
        $achternaam_volledig = ucfirst($rec_order_data['tussenvoegsel'])." ".$rec_order_data['achternaam'];
    }else{
        $achternaam_volledig = $rec_order_data['achternaam'];
    }
    $achternaam_volledig = stripslashes(html_entity_decode($achternaam_volledig));

    $naamEnAanhef = $aanhef." ".$achternaam_volledig;

    $ordernummer = $rec_order_data['ordernummer'];

    $_SESSION['naamEnAanhef'] = $naamEnAanhef;
    $_SESSION['winkelwagenBevestigd'] = true;
    $_SESSION['ordernummer'] = $ordernummer;
    $_SESSION['emailadres'] = $rec_order_data['emailadres'];


    if(empty($tussenvoegsel)){
        $naam = $rec_order_data['voornaam']." ".$rec_order_data['achternaam'];
    }else{
        $naam = $rec_order_data['voornaam']." ".$rec_order_data['tussenvoegsel']." ".$rec_order_data['achternaam'];
    }
    $naam = stripslashes(html_entity_decode($naam, ENT_QUOTES));

    if($rec_order_data['geslacht'] == "man"){
        $aanhef = "heer";
    }else{
        $aanhef = "mevrouw";
    }
    if(!empty($rec_order_data['tussenvoegsel'])){
        $achternaam_volledig = ucfirst($rec_order_data['tussenvoegsel'])." ".$rec_order_data['achternaam'];
        $achternaam_smallCap = $rec_order_data['tussenvoegsel']." ".$rec_order_data['achternaam'];
        $achternaam_smallCapBezorg = $rec_order_data['tussenvoegselBezorg']." ".$rec_order_data['achternaamBezorg'];
    }else{
        $achternaam_volledig = $rec_order_data['achternaam'];
        $achternaam_smallCap = $rec_order_data['achternaam'];
        $achternaam_smallCapBezorg = $rec_order_data['achternaamBezorg'];
    }
    $achternaam_volledig = stripslashes(html_entity_decode($achternaam_volledig));
    $achternaam_smallCap = stripslashes(html_entity_decode($achternaam_smallCap));
    $achternaam_smallCapBezorg = stripslashes(html_entity_decode($achternaam_smallCapBezorg));

    $bedrijfsnaam = stripslashes(html_entity_decode($rec_order_data['bedrijfsnaam']));
    $voornaam = stripslashes(html_entity_decode($rec_order_data['voornaam']));
    $tussenvoegsel = stripslashes(html_entity_decode($rec_order_data['tussenvoegsel']));
    $achternaam = stripslashes(html_entity_decode($rec_order_data['achternaam']));
    $geslacht = $rec_order_data['geslacht'];
    $emailadres = $rec_order_data['emailadres'];
    $bevestigingEmail = $emailadres;
    $telefoonnummer = stripslashes($rec_order_data['telefoonnummer']);
    $straatnaam = stripslashes(html_entity_decode($rec_order_data['straatnaam']));
    $huisnummer = stripslashes(html_entity_decode($rec_order_data['huisnummer']));
    $toevoeging = stripslashes(html_entity_decode($rec_order_data['toevoeging']));
    $postcode = stripslashes(html_entity_decode($rec_order_data['postcode']));
    $woonplaats = stripslashes(html_entity_decode($rec_order_data['woonplaats']));
    $land = stripslashes(html_entity_decode($rec_order_data['land']));
    $bedrijfsnaamBezorg = stripslashes(html_entity_decode($rec_order_data['bedrijfsnaamBezorg']));
    $voornaamBezorg = stripslashes(html_entity_decode($rec_order_data['voornaamBezorg']));
    $tussenvoegselBezorg = stripslashes(html_entity_decode($rec_order_data['tussenvoegselBezorg']));
    $achternaamBezorg = stripslashes(html_entity_decode($rec_order_data['achternaamBezorg']));
    $geslachtBezorg = $rec_order_data['geslachtBezorg'];
    $straatnaamBezorg = stripslashes(html_entity_decode($rec_order_data['straatnaamBezorg']));
    $huisnummerBezorg = stripslashes(html_entity_decode($rec_order_data['huisnummerBezorg']));
    $toevoegingBezorg = stripslashes(html_entity_decode($rec_order_data['toevoegingBezorg']));
    $postcodeBezorg = stripslashes(html_entity_decode($rec_order_data['postcodeBezorg']));
    $woonplaatsBezorg = stripslashes(html_entity_decode($rec_order_data['woonplaatsBezorg']));
    $landBezorg = stripslashes(html_entity_decode($rec_order_data['landBezorg']));
    $bezorgadresWijktAf = $rec_order_data['bezorgadresWijktAf'];


    $q_items_data = sprintf("SELECT kms_orders_articles.article_id, kms_orders_articles.order_aantal FROM kms_orders_articles WHERE kms_orders_articles.order_id = '%s'", $rec_order_data['order_id']);
    $r_items_data = mysql_query($q_items_data);
    $array_index = 0;
    $winkelwagenArray;

    while($rec_items_data = mysql_fetch_assoc($r_items_data)){
        $winkelwagenArray['artikelen'][$array_index] = $rec_items_data['article_id'];
        $winkelwagenArray['aantallen'][$array_index] = $rec_items_data['order_aantal'];
        $array_index = $array_index + 1;
    }

    if($rec_order_data['betaald'] == "yes"){

        $_SESSION['goedgekeurd'] = true;

        include("emailTemplatePhp.inc.php");

        $send_message = false;

        $from = "info@molennooitgedagtbudel.nl";
        $from_naam = "Molen Nooit Gedagt Budel";
        $onderwerp_besteller = "Bevestiging van uw bestelling ".$ordernummer;
        $onderwerp_os = "Bestelling ".$ordernummer;

        $mail = new PHPMailer(true); //defaults to using php "mail()"; the true param means it will throw exceptions on errors, which we need to catch

        try {
            $mail->AddReplyTo($from , $from_naam);
            $mail->AddAddress($emailadres, $naam);
            $mail->SetFrom($from, $from_naam);
            $mail->AddReplyTo($from, $from_naam);
            $mail->Subject = $onderwerp_besteller;
            $mail->MsgHTML($bericht_html);
            $mail->Send();
            $send_message = true;
        } catch (phpmailerException $e) {
            $send_message = false;
            $foutmeldingEmailBesteller = $e->errorMessage(); //Pretty error messages from PHPMailer
        } catch (Exception $e) {
            $send_message = false;
            $foutmeldingEmailBesteller = $e->getMessage(); //Boring error messages from anything else!
        }

        //mail naar oude spulletjes
        $mail_klant = new PHPMailer(true); //defaults to using php "mail()"; the true param means it will throw exceptions on errors, which we need to catch

        try {
            $mail_klant->AddReplyTo($from , $from_naam);
            $mail_klant->AddAddress($from, $from_naam);
            $mail_klant->SetFrom($from, $from_naam);
            $mail_klant->AddReplyTo($from , $from_naam);
            $mail_klant->Subject = $onderwerp_os;
            $mail_klant->MsgHTML($bericht_os);
            $mail_klant->Send();
            $mail_klant_send = true;
        } catch (phpmailerException $e) {
            $mail_klant_send = false;
            $foutmeldingEmailKlant = $e->errorMessage(); //Pretty error messages from PHPMailer
        } catch (Exception $e) {
            $mail_klant_send = false;
            $foutmeldingEmailKlant = $e->getMessage(); //Boring error messages from anything else!
        }

        $_SESSION['mailNaarBesteller'] = $send_message;
        $_SESSION['mailNaarMolenNooitGedagt'] = $mail_klant_send;


        header("Location: /winkelwagen/stap6/succes");
        exit;

    }else{
        $_SESSION['goedgekeurd'] = false;

        include("emailFoutBestellingPhp.inc.php");

        $send_message = false;

        $from = "info@molennooitgedagtbudel.nl";
        $from_naam = "Molen Nooit Gedagt Budel";
        $komma_mail = "stef@komma.pro";
        $komma_naam = "Komma Mediadesign";
        $onderwerp_besteller = "Fout tijdens bestelling ".$ordernummer;
        $onderwerp_os = "Fout tijdens bestelling ".$ordernummer;


        $mail = new PHPMailer(true); //defaults to using php "mail()"; the true param means it will throw exceptions on errors, which we need to catch

        try {
            $mail->AddReplyTo($from , $from_naam);
            $mail->AddAddress($emailadres, $naam);
            $mail->SetFrom($from, $from_naam);
            $mail->AddReplyTo($from, $from_naam);
            $mail->Subject = $onderwerp_besteller;
            $mail->MsgHTML($bericht_html);
            $mail->Send();
            $send_message = true;
        } catch (phpmailerException $e) {
            $send_message = false;
            $foutmeldingEmailBesteller = $e->errorMessage(); //Pretty error messages from PHPMailer
        } catch (Exception $e) {
            $send_message = false;
            $foutmeldingEmailBesteller = $e->getMessage(); //Boring error messages from anything else!
        }

        //mail naar oude spulletjes
        $mail_klant = new PHPMailer(true); //defaults to using php "mail()"; the true param means it will throw exceptions on errors, which we need to catch

        try {
            $mail_klant->AddReplyTo($from , $from_naam);
            $mail_klant->AddAddress($from, $from_naam);
			$mail_klant->AddAddress($komma_mail, $komma_naam);
            $mail_klant->SetFrom($from, $from_naam);
            $mail_klant->Subject = $onderwerp_os;
            $mail_klant->MsgHTML($bericht_os);
            $mail_klant->Send();
            $mail_klant_send = true;
        } catch (phpmailerException $e) {
            $mail_klant_send = false;
            $foutmeldingEmailKlant = $e->errorMessage(); //Pretty error messages from PHPMailer
        } catch (Exception $e) {
            $mail_klant_send = false;
            $foutmeldingEmailKlant = $e->getMessage(); //Boring error messages from anything else!
        }

        $_SESSION['mailNaarBesteller'] = $send_message;
        $_SESSION['mailNaarMolenNooitGedagt'] = $mail_klant_send;

        header("Location: /winkelwagen/stap6/error");
        exit;
    }

}
else {
    echo 'Er is geen order_id meegegeven.';
}

?>