%PDF- %PDF-
Direktori : /var/www/html/buggydubrovnik.com/buggy-booking/ |
Current File : /var/www/html/buggydubrovnik.com/buggy-booking/thankyou.php |
<?php define("TESTING", $_SERVER["REMOTE_ADDR"]=="141.136.252.252"); function insertRow($table, $data, $con) { $sql="INSERT INTO ".$table." ("; $keys=array_keys($data); for($i=0; $i<sizeof($data); $i++){ $sql.=$con->real_escape_string($keys[$i]); if($i<sizeof($data)-1) $sql.=", "; } $sql.=") VALUES ("; for($i=0; $i<sizeof($data); $i++) { $sql.="'".$con->real_escape_string($data[$keys[$i]])."'"; if($i<sizeof($data)-1) $sql.=", "; } $sql.=")"; $con->query($sql); if($con->error) die($con->error); return $con->insert_id; } function formatMoney($number, $cents = 1) { // cents: 0=never, 1=if needed, 2=always if (is_numeric($number)) { // a number if (!$number) { // zero $money = ($cents == 2 ? '0.00' : '0'); // output zero } else { // value if (floor($number) == $number) { // whole number $money = number_format($number, ($cents == 2 ? 2 : 0)); // format } else { // cents $money = number_format(round($number, 2), ($cents == 0 ? 0 : 2)); // format } // integer or decimal } // value $money = str_replace(",","[]", $money); $money = str_replace(".",",", $money); $money = str_replace("[]",".", $money); return $money; } // numeric } //pokupimo pay way podatke $idtemprezervacija=0; $idizlet=0; $tid=0; if(isset($_GET["pgw_order_id"])) { $idtemprezervacija=$_GET["pgw_order_id"]; } else die("Order ID is not set"); if(isset($_GET["pgw_transaction_id"])) { $tid=$_GET["pgw_transaction_id"]; } else die("Transaction ID not set."); $id=$idtemprezervacija; $servername = "localhost"; $username="buggydubrovnik_app_production"; $password="appr-17"; //$username="root"; //$password=""; $db="buggydubrovnik_app_production"; // Create connection $con = mysqli_connect($servername, $username, $password, $db); mysqli_query($con,"set names 'utf8'"); $sql="SELECT rt.*, d.naziv as drzava FROM rezervacija_temp rt JOIN drzava d ON d.id_drzava=rt.id_drzava WHERE id_rezervacija_temp=".$id; $data=$con->query($sql); if($data->num_rows!=1) die("Rezervacija ne postoji."); $row=$data->fetch_assoc(); if($row["placeno"]==0) { $row["placeno"]=1; $row["pgw_transaction_id"]=$tid; $insertData=$row; // var_dump($insertData); $termin=$con->query("SELECT * FROM izlet_termin t WHERE t.termin='$insertData[vrijeme_izleta]' AND t.id_izlet_tip=2 AND t.aktivan=1"); if($termin->num_rows) { $termin=$termin->fetch_assoc(); $termin=$termin["id_izlet_termin"]; } else { $terminData=["termin"=>$insertData["vrijeme_izleta"], "id_izlet_period"=>0, "id_izlet_tip"=>2, "online"=>1, "id_zaposlenik_izmjena"=>1, "datum_izmjena"=>date("Y-m-d H:i:s"), "aktivan"=>1]; $termin=insertRow("izlet_termin", $terminData, $con); } //echo"TERMIN ID:".$termin; $insertData["id_izlet_termin"]=$termin; $endTime=strtotime("+3 hour", strtotime($insertData["vrijeme_izleta"])); $insertData["datum_kupnja"]=date("Y-m-d H:i:s", $endTime); //var_dump($insertData); unset($insertData["vrijeme_izleta"]); unset($insertData["id_rezervacija_temp"]); unset($insertData["izlet_naziv"]); unset($insertData["promo_kod"]); unset($insertData["placeno"]); unset($insertData["promo_kod"]); $insertData["voucher"]=$insertData["broj_voucher"]; unset($insertData["broj_voucher"]); $insertData["id_tip_placanja"]=5; unset($insertData["drzava"]); $insertData["id_payway"]=$insertData["pgw_transaction_id"]; unset($insertData["pgw_transaction_id"]); $insertData["id_kosarica"]=$idtemprezervacija; $insertData["id_prodajno_mjesto"]=6; $insertData["id_izlet_tip"]=2; $insertData["id_vozilo_tip"]=4; $sumaLjudi=$insertData["odrasli"]+$insertData["djeca"]; if($sumaLjudi%2==1) $sumaLjudi++; $insertData["resurs"]=$insertData["djeca_besplatno"]; $posebni=($insertData["odrasli"]+$insertData["djeca"])==$insertData["djeca_besplatno"]&&(($insertData["cijena_odrasli"]+$insertData["cijena_djeca"])>300); $insertData["djeca_besplatno"]=0; insertRow("rezervacija", $insertData, $con); //TODO: REMOVE!!! //die("Test die."); $con->query("UPDATE rezervacija_temp SET placeno=1, id_payway='".$tid."' WHERE id_rezervacija_temp=".$id); //echo $con->error; /************************************************************ pgw_trace_ref – referenca provedenog procesa na PayWay-u - pgw_transaction_id – ID provedene transakcije na PayWay-u - pgw_order_id – ID narudžbe (zaprimljen u inicijalnoj poruci od dućana) - pgw_amount – iznos narudžbe (zaprimljen u inicijalnoj poruci od dućana) - pgw_installments – broj rata - pgw_card_type_id – id tipa kartice (CardTypeID) - pgw_signature – potpis parametara kako bi dućan mogao provjeriti autentičnost poruke ***********************************************/ $SecretKey="xIj78UUpQ0J78+eTHR]m|p6?p"; $testsignature= openssl_digest($_GET["pgw_trace_ref"].$SecretKey.$_GET["pgw_transaction_id"].$SecretKey.$_GET["pgw_order_id"].$SecretKey.$_GET["pgw_amount"].$SecretKey.$_GET["pgw_installments"].$SecretKey.$_GET["pgw_card_type_id"].$SecretKey, "SHA512"); //echo $testsignature; if($_GET["pgw_signature"]==$testsignature) { $con->query("UPDATE rezervacija_temp SET id_payway='".($tid."-DA")."' WHERE id_rezervacija_temp=".$id); } require($_SERVER["DOCUMENT_ROOT"]."/buggy-booking/voucher.php"); date_default_timezone_set('Etc/UTC'); require $_SERVER["DOCUMENT_ROOT"].'/PHPMailer_5.2.1/PHPMailerAutoload.php'; //Create a new PHPMailer instance $mail = new PHPMailer(); //Tell PHPMailer to use SMTP $mail->isSMTP(); $mail->CharSet = 'UTF-8'; //Enable SMTP debugging // 0 = off (for production use) // 1 = client messages // 2 = client and server messages $mail->SMTPDebug = 0; //Ask for HTML-friendly debug output $mail->Debugoutput = 'html'; //Set the hostname of the mail server $mail->Host = "mail.buggydubrovnik.com"; //Set the SMTP port number - 587 for authenticated TLS, a.k.a. RFC4409 SMTP submission $mail->Port = 465; //Set the encryption system to use - ssl (deprecated) or tls $mail->SMTPSecure = 'ssl'; //Whether to use SMTP authentication $mail->SMTPAuth = true; $mail->Username = "info@buggydubrovnik.com"; $mail->Password = "BuDuCo333!?"; //Set who the message is to be sent from $mail->SetFrom('info@buggydubrovnik.com', 'Buggy Safari'); $mail->AddReplyTo("info@buggydubrovnik.com","Buggy Safari"); $mail->Subject = 'Voucher('.$id.') - '.$row["izlet_naziv"]; $mail->MsgHTML($html); $address = $row["mail"]; $mail->AddAddress($address, $row["ime"].' '.$row["prezime"] ); $address = 'info@buggydubrovnik.com'; //$address="leo.staric@energit.biz"; $mail->AddAddress($address, 'Buggy Safari' ); //$mail->AddBcc("ivan.ivusic@energit.biz", 'Buggy Dubrovnik' ); //$mail->AddBcc("info@buggydubrovnik.com", 'Buggy Dubrovnik' ); $mail->AddBcc("ivan.grbavac@energit.biz", 'Buggy Dubrovnik' ); $mail->AddBcc("leo.staric@energit.biz", 'Leo' ); $mail->AddBcc("seo@mint-media.hr", 'SEO' ); $poruka=""; if(!$mail->Send()) { $mail = new PHPMailer(); $mail->isSMTP(); $mail->CharSet = 'UTF-8'; $mail->SMTPDebug = 0; $mail->Debugoutput = 'html'; $mail->Host = "mail.buggydubrovnik.com"; $mail->Port = 465; $mail->SMTPSecure = 'ssl'; $mail->SMTPAuth = true; $mail->Username = "info@buggydubrovnik.com"; $mail->Password = "BuDuCo333!?"; $mail->SetFrom('info@buggydubrovnik.com', 'Buggy Safari'); $mail->Subject = 'Voucher - '.$row["izlet_naziv"].'('.$row["odrasli"].'/'.$row["djeca"].')'; $mail->MsgHTML('<p style="font-size:16px; color:#F00"> VOUCHER NIJE POSLAN KUPCU, DOSLO JE DO NEKE GRESKE </p>'.$body); //TODO: VRATIT OFFICE!!! $address = 'info@buggydubrovnik.com'; $mail->AddAddress($address, 'Buggy Safari'); $mail->AddBcc('leo.staric@energit.biz', "Leo Starić"); $mail->Send(); } else { $poruka="Your request has been successfully sent! Thank you!"; } } ?> <!-- Google Code for Buggy Conversion Page --> <script type="text/javascript"> /* <![CDATA[ */ var google_conversion_id = 862843962; var google_conversion_language = "en"; var google_conversion_format = "3"; var google_conversion_color = "ffffff"; var google_conversion_label = "VvCLCJ-toHEQuui3mwM"; var google_remarketing_only = false; /* ]]> */ </script> <script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js"> </script> <noscript> <div style="display:inline;"> <img height="1" width="1" style="border-style:none;" alt="" src="//www.googleadservices.com/pagead/conversion/862843962/?label=VvCLCJ-toHEQuui3mwM&guid=ON&script=0"/> </div> </noscript>