ACC SHELL
<?php
class I18n
{
/**
* Get two-letter ISO code of browser’s preferred language
*
* @param string $default_language
* @return string
*/
public static function getBrowserLanguage($default_language = 'en') {
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) AND $_SERVER['HTTP_ACCEPT_LANGUAGE'])
{
$languages = array();
$all_accepted = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
foreach ($all_accepted as $accepted)
{
if (preg_match('/(.*);q=([0-1]{0,1}\.\d{0,4})/i', $accepted, $matches))
{
$languages[$matches[1]] = (float) $matches[2];
}
else {
$languages[$accepted] = 1.0;
}
}
arsort($languages);
foreach ($languages as $language => $priority)
{
$language = strtolower(substr($language, 0, 2));
if (($language === 'cs' OR $language === 'sk') AND $priority >= 0.7)
{
return 'cs';
}
}
}
return $default_language;
}
/**
* Get two-letter ISO 3166-1 alpha-2 country code from IP address
*
* @return null|string
*/
public static function getCountryFromIP()
{
$country = NULL;
try
{
$cURL = curl_init();
curl_setopt($cURL, CURLOPT_AUTOREFERER, TRUE);
curl_setopt($cURL, CURLOPT_FAILONERROR, TRUE);
curl_setopt($cURL, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($cURL, CURLOPT_HEADER, FALSE);
curl_setopt($cURL, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($cURL, CURLOPT_URL, 'http://www.telize.com/geoip'); // OR http://ip-api.com/json for non-commercial use
if ($data = curl_exec($cURL))
{
if ($data = json_decode($data, TRUE))
{
if (isset($data['country_code']))
{
return strtolower($data['country_code']);
}
}
}
curl_close($cURL);
}
catch (Exception $e)
{
// Silent, just in case
}
return $country;
}
}
$included_in_file = basename($_SERVER['SCRIPT_FILENAME']);
if (stripos($included_in_file, 'admin') === FALSE)
{
$browser_language = I18n::getBrowserLanguage();
// $country_from_ip = I18n::getCountryFromIP();
session_start();
if (isset($_GET['lang']))
{
if ($_SERVER['HTTP_HOST'] === 'cz.eqnx.co' AND $_GET['lang'] === 'en')
{
header('Location: http://www.eqnx.co'.$_SERVER['REQUEST_URI']);
}
if ($_SERVER['HTTP_HOST'] === 'www.eqnx.co' AND $_GET['lang'] === 'cs')
{
header('Location: http://cz.eqnx.co'.$_SERVER['REQUEST_URI']);
}
$_SESSION['lang'] = TRUE;
}
elseif (isset($_SESSION['lang']) AND $_SESSION['lang'])
{
// Do not redirect
}
else
{
if ($_SERVER['HTTP_HOST'] === 'cz.eqnx.co' AND $browser_language !== 'cs')
{
header('Location: http://www.eqnx.co'.$_SERVER['REQUEST_URI']);
}
if ($_SERVER['HTTP_HOST'] === 'www.eqnx.co' AND $browser_language === 'cs')
{
header('Location: http://cz.eqnx.co'.$_SERVER['REQUEST_URI']);
}
}
session_write_close();
}
$page = new Page;
$page->dbServer='localhost';
//$page->dbUser = 'root';
//$page->dbPassword = '';
//$page->dbName = 'eqnx_cz';
//$page->dbUser = 'eqnxcz';
//$page->dbPassword = 'Lert8877';
//$page->dbName = 'eqnxcz';
$page->dbUser = 'eqnx';
$page->dbPassword = 'Ekv85202+';
$page->dbName = 'eqnx';
ACC SHELL 2018