| Server IP : 103.234.187.230 / Your IP : 216.73.216.216 Web Server : Apache System : Linux lserver42043-ind.megavelocity.net 3.10.0-1160.108.1.el7.x86_64 #1 SMP Thu Jan 25 16:17:31 UTC 2024 x86_64 User : apache ( 48) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/fetchcurrency/ |
Upload File : |
<?php
$DBArray = [
12416 => 'tripjackDB',
102411 => 'yutrp_db',
106039 => 'hongkongmacautour_db',
118296 => 'pmlholidays_db',
6135 => 'connectindia_DB',
48984 => 'megablueandaman_db',
119519 => 'lhtravels_db',
21 => 'helloGTXApi_DB',
137710 => 'helloGTXApi_DB',
];
$apiData = ["SecurityKey" => "asdsadsa67sdgsagdhsagdhsagdsad"];
try {
$curl = curl_init("https://globaltravelexchange.com/webservice/currency/get-rate");
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($apiData));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$curl_response = curl_exec($curl);
curl_close($curl);
$DBhost = "localhost";
$DBuser = "root";
$DBpassword = "At07Y#2zLWk@?mVP";
$DBname = "CommanDB";
$conn = mysqli_connect($DBhost, $DBuser, $DBpassword, $DBname);
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$response_array = json_decode($curl_response, true);
$selectQuery = "TRUNCATE TABLE tbl_currency_rate";
$resultQuery = mysqli_query($conn, $selectQuery) or die(mysqli_error($conn));
if (isset($response_array['RateList']) && !empty($response_array['RateList'])) {
foreach ($response_array['RateList'] as $key => $val) {
$FCurrencyType = (int) $val['FCurrencyType'];
$TCurrencyType = (int) $val['TCurrencyType'];
$Rate = $val['Rate'];
$insertQuery = 'INSERT INTO tbl_currency_rate (FCurrencyType, TCurrencyType,Rate) VALUES("' . $FCurrencyType . '","' . $TCurrencyType . '","' . $Rate . '")';
$query = mysqli_query($conn, $insertQuery) or die(mysqli_error($conn));
}
}
mysqli_close($conn);
} catch (Exception $error) {
echo $error->getMessage();
die;
}
foreach ($DBArray as $AgencySysId => $DbName) {
$DBhost = "localhost";
$DBuser = "root";
$DBpassword = "At07Y#2zLWk@?mVP";
$DBname = "CommanDB";
$conn1 = mysqli_connect($DBhost, $DBuser, $DBpassword, $DBname);
if (!$conn1) {
die("Connection failed: " . mysqli_connect_error());
}
$apiData = ["AgencySysId" => $AgencySysId];
$curl = curl_init("https://globaltravelexchange.com/webservice/currency/get-currency-markup");
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($apiData));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$curl_response = curl_exec($curl);
$response_array = json_decode($curl_response, true);
curl_close($curl);
if (isset($response_array['status']) && $response_array['status'] == true) {
$ExchangeRateMaarkup = (float) $response_array['ExchangeRateMaarkup'];
$match = 0;
$selectQuery = "SELECT agency_id FROM tbl_currency_markup WHERE agency_id = $AgencySysId";
$resultQuery = mysqli_query($conn1, $selectQuery) or die(mysqli_error($conn1));
while ($val1 = mysqli_fetch_array($resultQuery)) {
if ($val1['agency_id'] == $AgencySysId) {
$match = 1;
}
}
if ($match == 1) {
$updateQuery = "UPDATE tbl_currency_markup SET markup=$ExchangeRateMaarkup WHERE agency_id = $AgencySysId";
$query = mysqli_query($conn1, $updateQuery) or die(mysqli_error($conn1));
} else {
$insertQuery = 'INSERT INTO tbl_currency_markup (agency_id, markup) VALUES("' . $AgencySysId . '","' . $ExchangeRateMaarkup . '")';
$query = mysqli_query($conn1, $insertQuery) or die(mysqli_error($conn1));
}
}
mysqli_close($conn1);
}
echo "Done";
die;
?>