lookupCountryCode($_SERVER['REMOTE_ADDR']); if(isset($_GET['country_override'])) $cc = $_GET['country_override']; $aname = trim(pg_escape_string($_GET['aname'])); $zone_id = trim(pg_escape_string($_GET['zone_id'])); $prod_id = trim(pg_escape_string($_GET['prod_id'])); $referrer = pg_escape_string((isset($_GET['ref'])?urldecode($_GET['ref']):$_SERVER['HTTP_REFERER'])); $dyn_id = preg_replace('#([^0-9a-z\_\\-\.]+)#', '', strtolower(pg_escape_string($_GET['dyn_id']))); $lang = preg_replace('#([^0-9a-z\_\\-\.]+)#', '', strtolower(pg_escape_string($_GET['cg']))); $countryOverrides = array( 'RU' => array('.og-communication.com', 'http://www.og-communication.com/index.cgi') ); $cd = '.redkings.com'; if(isset($countryOverrides[$cc])) { $cd = $countryOverrides[$cc][0]; if(!isset($_GET['r'])) { if($referrer) $_GET['ref'] = urlencode($referrer); $_GET['r'] = '1'; header("Location: ".$countryOverrides[$cc][1]."?".http_build_query($_GET), TRUE, 302); exit; } } else { if(!isset($_GET['r'])) { if($referrer) $_GET['ref'] = urlencode($referrer); $_GET['r'] = '1'; header("Location: http://poker.redkings.com/index.cgi?".http_build_query($_GET), TRUE, 302); exit; } } if ($_GET['aname'] == 'mavrodi') { header("Location: http://poker.redkings.com/aff_error/index.html",TRUE,302); exit(); } function writehitlog($aname, $zone_id, $cc) { global $cd; $log[] = $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; $log[] = $loc; $log[] = $loc; $log[] = 'rk'; $log[] = 'rkmain'; $log[] = $zone_id; $log[] = $cc; $log[] = $_SERVER['HTTP_USER_AGENT']; $log[] = $_SERVER['HTTP_REFERER']; $log[] = $_SERVER['REMOTE_ADDR']; $log[] = '(null)'; //language? $log[] = $aname; foreach ($log as $k => $v) { if (!$v) $log[$k] = '(null)'; } $pLog = implode("\t", $log); $a = getdate(); $year = $a['year']; $month = $a['mon']; $day = $a['mday']; $dir_name = "$year-$month-$day"; $log_dir_path = '/project/routing_service_admin/routing_service_reports/logfiles/'; check_dir($log_dir_path, $dir_name); $unixtime = time(); $fr = fopen("{$log_dir_path}{$dir_name}/$unixtime" . "_" . mt_rand() . ".txt", 'a+'); fputs($fr, $pLog); fclose($fr); require_once('/project/rk/widgets/chk_unq.php'); chk_unq($cd); } function check_dir($log_dir_path, $dir_name) { if (!file_exists("{$log_dir_path}{$dir_name}")) mkdir("{$log_dir_path}{$dir_name}", 0777) or die($php_errormsg); return; } function prod_direct($prod_id = null) { if (!$prod_id) return; elseif ($prod_id == 'rkdownload') { header("Location: http://download.ongamepoker.com/games/249/V9YB/RedKingsSetup.exe",TRUE,302); exit(); } elseif ($prod_id == 'macdownload') { header("Location: http://download.ongamepoker.com/games/249/V9CC/RedKings.dmg",TRUE,302); exit(); } elseif ($prod_id == 'rkblog') { header("Location: http://blogs.redkings.com/",TRUE,302); exit(); } elseif ($prod_id == 'rkteam') { header("Location: http://poker.redkings.com/Team-RedKings.html",TRUE,302); exit(); } } if(!$aname && $cc == 'KZ') { $aname = 'kzsport1'; } if (!$aname) $aname = 'house_rk'.date('my'); writehitlog($aname, $zone_id, $cc); @setcookie("Referer", $referrer, time() + 3600 * 24 * 90, "/", $cd); if ($aname) { $cok1 = "aname=$aname"; @setcookie("Operation", '=' . "aname=$aname zone_id=$zone_id", time() + 3600 * 3, "/", $cd); prod_direct($prod_id); if ($dyn_id) { @setcookie("dyn_id", $dyn_id, time() + 3600 * 3, "/", $cd); } $cond[] = " lower('$aname')=lower(aname) "; $cond[] = " prod_id='rkmain' "; if ($zone_id) { $cond[] = " lower('$zone_id')=lower(zone_id) "; $cok1 = $cok1 . " zone_id=$zone_id"; } else { $cond[] = " zone_id='0' "; } $cond[] = " country='$cc' "; } if($aname && !$zone_id) @setcookie("tracker", "aname={$aname}", strtotime('+6 months'), "/", $cd); if($aname && $zone_id) @setcookie("tracker", "aname={$aname}*zone_id={$zone_id}", strtotime('+6 months'), "/", $cd); @setcookie("Operation", "$cok1", time() + 3600 * 3, "/", $cd); if (!$prod_id) { $cond2 = implode(" and ", $cond); if ($cond2) $cond2 = ' where ' . $cond2; $qry = "select destination_url_definition from bg_routing_rules_view $cond2 limit 1"; $loc = svq($qry); if (!$loc) { $cond = array(); $cond[] = " lower('$aname')=lower(aname) "; $cond[] = " prod_id='rkmain' "; $cond = array(); $cond[] = " lower('$aname')=lower(aname) "; $cond[] = " prod_id='rkmain' "; if ($zone_id) { $cond[] = " lower('$zone_id')=lower(zone_id) "; $cok1 = $cok1 . " zone_id=$zone_id"; } else { $cond[] = " zone_id='0' "; } $cond[] = " country='0' "; $cond2 = implode(" and ", $cond); if ($cond2) $cond2 = ' where ' . $cond2; $qry = "select destination_url_definition from bg_routing_rules_view $cond2 limit 1"; $loc = svq($qry); if (!$loc) { $loc = svq("select destination_url_definition from bg_routing_rules_view where prod_id='rkmain' and aname='$aname' and zone_id='0' and country='$cc'"); if (!$loc) { $loc = svq("select destination_url_definition from bg_routing_rules_view where prod_id='rkmain' and aname='$aname' and zone_id='0' "); } if (!$loc) { $cond = array(); $cond[] = " lower('$aname')=lower(aname) "; $cond[] = " prod_id='rkmain' "; $cond = array(); $cond[] = " lower('$aname')=lower(aname) "; $cond[] = " prod_id='rkmain' "; if ($zone_id) { $cond[] = " lower('$zone_id')=lower(zone_id) "; $cok1 = $cok1 . " zone_id=$zone_id"; } else { $cond[] = " zone_id='0' "; } $cond[] = " country='0' "; $cond2 = implode(" and ", $cond); if ($cond2) $cond2 = ' where ' . $cond2; $qry = "select destination_url_definition from bg_routing_rules_view $cond2 limit 1"; $loc = svq($qry); if (!$loc) { if ($lang) { $loc = svq("select destination_url_definition from routing_rules where countries_group='$lang' and sub_application='rkmain' and broker_login='0' and sub_broker_login='0'"); } if (!$loc) { $loc = svq("select destination_url_definition from bg_routing_rules_view where aname ='0' and country='$cc' and prod_id='rkmain'"); } if (!$loc) $loc = 'http://poker.redkings.com'; } } } } if ($cc == 'IT' && !preg_match('#italia13#', $loc)) $loc = 'http://italia13.redkings.com/it'; header("Location: $loc",TRUE,302); } else { header("Location: http://download.ongamepoker.com/games/249/V9YB/RedKingsSetup.exe",TRUE,302); } // else download the client. ?>