<?php

/******************************************************
 * CjOverkill version 4.1.1
 * © Kaloyan Olegov Georgiev
 * http://www.icefire.org/
 * spam@icefire.org
 * 
 * Please read the lisence before you start editing this script.
 * 
********************************************************/

include ("../cj-conf.inc.php");
include ("../cj-functions.inc.php");   
cjoverkill_connect();
 
include ("security.inc.php");

$ip_limit="5000";

if (!isset($_GET["id"]) || $_GET["id"]=="") { 
    cjoverkill_print_error("You must select a trade for this"); 
}
$tid=$_GET["id"];
$order_by=$_GET["order_by"];
$sql=@mysql_query("SELECT domain FROM cjoverkill_trades WHERE trade_id=$tid") OR 
  cjoverkill_db_error(mysql_error());
$tmp=@mysql_fetch_array($sql);
extract($tmp);
switch ($order_by){
 case "raw":
    $sql=@mysql_query("SELECT c2code,uniqs,raws FROM cjoverkill_country_log_out WHERE trade_id=$tid 
			ORDER BY raws DESC,uniqs DESC,c2code ASC LIMIT 0,$ip_limit") OR
      cjoverkill_db_error(mysql_error());
    break;
 default:
    $sql=@mysql_query("SELECT c2code,uniqs,raws FROM cjoverkill_country_log_out WHERE trade_id=$tid
			ORDER BY raws DESC,uniqs DESC,c2code ASC LIMIT 0,$ip_limit") OR
      cjoverkill_db_error(mysql_error());
    break;
}


$tms="OUT Country Log for $domain";

echo ("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">
	<html>
	<head>
	<title>$tms</title>
	<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">
	<link href=\"../cj-style.css\" rel=\"stylesheet\" type=\"text/css\">
	</head>
	<body bgcolor=\"#FFFFFF\" text=\"#000000\" link=\"#000000\" vlink=\"#000000\" alink=\"#000000\">
	<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"1\" align=\"center\"> 
	  <tr>
	    <td colspan=\"5\" align=\"center\"><strong><font size=\"4\">$tms</font></strong></td>
	  </tr> 
	  <tr>
	    <td height=\"10\" colspan=\"3\">&nbsp;</td>
	  </tr>
	  <tr>
	    <td colspan=\"3\"><font size=\"1\"><b><font size=\"2\">Top $ip_limit Incoming Countries</font></b></font></td>
	  </tr>
	  <tr>
	    <td colspan=\"3\">&nbsp;</td> 
	  </tr> 
	<tr class=\"toprows\">
	<td width=\"20%\">Raw IN</td>
	<td width=\"20%\">Uniq IN</td>
	<td width=\"60%\">Country</td>
	</tr>
	<tr class=\"normalrows\">
	<td align=\"center\"><font size=\"2\"><a href=\"countrylog-out.php?id=$tid&order_by=raw\" target=\"_self\">Order</a></font></td>
	<td align=\"center\"><font size=\"2\"><a href=\"countrylog-out.php?id=$tid&order_by=ip\" target=\"_self\">Order</a></font></td>
	<td align=\"center\"><font size=\"2\">&nbsp</font></td>
	</tr>
	");

while ($tmp=@mysql_fetch_array($sql)) {
    extract ($tmp);
    if (isset($c2code) && $c2code!="00" && $c2code!=""){
	$sql2=@mysql_query("SELECT country FROM cjoverkill_filter_country WHERE c2code='$c2code' LIMIT 1") OR
	  cjoverkill_db_error(mysql_error());
	$tmp2=@mysql_fetch_array($sql2);
	extract($tmp2);
    }
    else {
	$country="UNKNOWN";
    }   
    echo ("<tr align=\"center\">
	    <td>$raws</td>
	    <td>$uniqs</td>
	    <td>$country</td>
	    </tr>");
}
echo ("<tr>
	<td colspan=\"3\">&nbsp;</td>
	</tr>
	<tr>
	<td colspan=\"3\" align=\"center\"><font size=\"2\"><a href=\"javascript:window.close()\">Close Window</a></font></td>
	</tr>
	</table>
	</body>
	</html>
	");
cjoverkill_disconnect(); 

?>
	
