'mysql', // Db driver
'host' => first_all::$host,
'database' => first_all::$dbname,
'username' => first_all::$login,
'password' => first_all::$password,
'charset' => 'utf8', // Optional
'collation' => 'utf8_unicode_ci', // Optional
'options' => [ // PDO constructor options, optional
PDO::ATTR_TIMEOUT => 5,
PDO::ATTR_EMULATE_PREPARES => false,
],
];
$host = first_all::$host;
$db = first_all::$dbname;
$username = first_all::$login;
$password = first_all::$password;
$pdo = new PDO("mysql:host=$host;dbname=$db", $username, $password);
new \Pixie\Connection('mysql', $config, 'QB');
$remoteAddress = filter_input(INPUT_SERVER, 'REMOTE_ADDR', FILTER_SANITIZE_SPECIAL_CHARS);
$got_direct = $_GET["target"];
function getAmazonIdByCountryProductId($country) {
$id = array(
'US' => 'helptochoose-2-20',
'DE' => 'helptochoos08-21',
'GB' => 'helptochoose-21',
'ES' => 'helptochoos03-21',
'FR' => 'helptochoos0c-21',
'IT' => 'helptochoos05-21',
'CA' => 'helptochoose-20',
'AU' => 'helptochoose-22',
'NL' => 'helptochoos02-21'
);
return !empty($id[$country]) ? $id[$country] : $id['US'];
}
function getAmazonIdByCountrySearchPage($country) {
$id = array(
'US' => 'helptochoose-2-20',
'DE' => 'helptochoos08-21',
'GB' => 'helptochoose-21',
'ES' => 'helptochoos03-21',
'FR' => 'helptochoos0c-21',
'IT' => 'helptochoos05-21',
'CA' => 'helptochoose-20',
'AU' => 'helptochoose-22',
'NL' => 'helptochoos02-21'
);
return !empty($id[$country]) ? $id[$country] : $id['US'];
}
function getUserCountry($ip){
// Get Country Code Using IP
$userInfo = @json_decode(file_get_contents("http://www.geoplugin.net/json.gp?ip=" . $ip));
return $userInfo;
}
function googleShopping()
{
if (!empty($_GET['id'])) {
$product=QB::table('product')->where('asin','=',$_GET['id'])->first();
$GOOGLE_SHOP_TEMPLATE ="https://www.google.com/search?q=$product->title asin=$product->asin&tbm=shop";
header('Location: ' . $GOOGLE_SHOP_TEMPLATE, true, 302);
}
}
function amazonAffiliate(){
$user_info = getUserCountry($GLOBALS['remoteAddress']);
$countryCode = !empty($user_info) ? $user_info->geoplugin_countryCode : 'US';
if(!empty($amazon_locations[$user_info->geoplugin_countryCode]))
$AMAZON_DOMAIN = 'https://' . $amazon_locations[$user_info->geoplugin_countryCode];
else $AMAZON_DOMAIN = 'https://amazon.com';
if(!empty($_GET['id'])){
# For amazon product page
$AMAZON_ID = getAmazonIdByCountryProductId($countryCode);
$url = $AMAZON_DOMAIN.'/dp/' . $_GET['id'] . '/?tag=' . $AMAZON_ID;
}
else {
# For amazon search page
$AMAZON_ID = getAmazonIdByCountryProductId($countryCode);
$url = $AMAZON_DOMAIN .'/gp/search?ie=UTF8&keywords='.$_GET['keyword'].'&tag=' . $AMAZON_ID;
}
// walk-table-refactor.php
if (!empty($_GET['th']))
{
$url.=$_GET['th'];
}
header('Location: ' . $url, true, 302);
}
googleShopping();
?>