clean($_REQUEST['orderid'],'encode'); $operator = '*'; $result = $db->select($table,$operator,$column,$value); if(isset($result)) { if($result[0]['order.token'] == $_REQUEST['paytoken']) { // Update database with a status of processing order. $table = '`shop.orders`'; $columns = ['order.status']; $values = ['mollie processing']; $db->update($table,$columns,$values,$result[0]['id']); // Mail the client. if(isset($result[0]['order.email'])) { $email = $result[0]['order.email']; $name = $result[0]['order.firstname']; $tpl = new \security\forms\SecureMail([]); $template_location = '../../inc/templates/order.html'; $template_pairs = [ "name" => $result[0]['order.firstname'], "shop" => $_SERVER['HTTP_HOST'] ]; $html = $tpl->parseTemplate($template_location,$template_pairs); $parameters = array( 'to' => $email, 'email' => $email, 'subject' => 'Order', 'body' => $html ); $checkForm = new \security\forms\SecureMail($parameters); $checkForm->sendmail(); } // Mail shop owner to notify new order. $settings = $db->query("SELECT * from `shop.settings`"); $email = $settings[0]['settings.email']; if(isset($email)) { $tpl = new \security\forms\SecureMail([]); $template_location = '../../inc/templates/shoporder.html'; $template_pairs = [ "link" => $db->clean(WEBSITE,'encode') . "dashboard/", "shop" => $_SERVER['HTTP_HOST'] ]; $html = $tpl->parseTemplate($template_location,$template_pairs); $parameters = array( 'to' => $email, 'email' => $email, 'subject' => 'Order', 'body' => $html ); $checkForm = new \security\forms\SecureMail($parameters); $checkForm->sendmail(); } } } // Empty session to prevent replay. unset($_SESSION['cartid']); unset($_SESSION['cart']); $_SESSION['cartid'] = []; $_SESSION['cart'] = []; session_destroy(); // redirect to shop again. header("Location: ../../"); exit; } } else { // redirect to shop again. header("Location: ../../"); exit; } ?>