<?php
/********************************************************/
/* NukeSentinel(tm)                                     */
/* By: NukeScripts Network (webmaster@nukescripts.net)  */
/* http://www.nukescripts.net                           */
/* Copyright © 2000-2005 by NukeScripts Network         */
/********************************************************/
defined('MAXIMUS') or Header("Location: index.php");

$pagetitle = _AB_NUKESENTINEL.": "._AB_IP2CLISTING;
incoh();
title($pagetitle);
stmain_menu();
br('1');
Max_OpenTable();
$perpage = 50;
if ($perpage == 0) { $perpage = 25; }
if (!isset($min)) $min=0;
if (!isset($max)) $max=$min+$perpage;
if(!$column or $column=="") $column = "ip_lo";
if(!$direction or $direction=="") $direction = "asc";
$totalselected = $GLOBALS['db']->sql_numrows($GLOBALS['db']->sql_query("SELECT * FROM `".$prefix."_nsnst_ip2country`"));
if ($totalselected > 0) {
  echo "<table align='center' border='0' cellpadding='2' cellspacing='2' bgcolor='$bgcolor2' width='100%'>\n";
  // Page Sorting
  echo "<tr><form method='post' action='modules.php?name=$module_name'>\n";
  echo "<input type='hidden' name='op' value='STIP2C'>\n";
  echo "<input type='hidden' name='min' value='$min'>\n";
  echo "<td align='right' bgcolor='$bgcolor2' colspan='5'><b>"._AB_SORT.":</b> ";
  echo "<select name='column'>\n";
  if($column == "ip_lo") $selcolumn1 = "selected";
  echo "<option value='ip_lo' $selcolumn1>"._AB_IP2CRANGE."</option>\n";
  if($column == "c2c") $selcolumn2 = "selected";
  echo "<option value='c2c' $selcolumn2>"._AB_C2CODE."</option>\n";
  if($column == "country") $selcolumn3 = "selected";
  echo "<option value='country' $selcolumn3>"._AB_COUNTRY."</option>\n";
  if($column == "date") $selcolumn4 = "selected";
  echo "<option value='date' $selcolumn4>"._AB_DATE."</option>\n";
  echo "</select> ";
  echo "<select name='direction'>\n";
  if($direction == "asc") $seldirection1 = "selected";
  echo "<option value='asc' $seldirection1>"._AB_ASC."</option>\n";
  if($direction == "desc") $seldirection2 = "selected";
  echo "<option value='desc' $seldirection2>"._AB_DESC."</option>\n";
  echo "</select> ";
  echo "<input type='submit' value='"._AB_SORT."'>\n";
  echo "</td></form></tr>";
  // Page Sorting
  echo "<tr bgcolor='$bgcolor1'><td colspan='5'><img src='images/pix.gif' height='2' width='2'></td></tr>\n";
  echo "<tr bgcolor='$bgcolor2'>\n";
  echo "<td align='center' width='20%'><b>"._AB_IPLO."</b></td>\n";
  echo "<td align='center' width='20%'><b>"._AB_IPHI."</b></td>\n";
  echo "<td align='center' width='10%'><b>"._AB_C2CODE."</b></td>\n";
  echo "<td align='center' width='35%'><b>"._AB_COUNTRY."</b></td>\n";
  echo "<td align='center' width='15%'><b>"._AB_DATE."</b></td>\n";
  echo "</tr>\n";
  $result = $GLOBALS['db']->sql_query("SELECT * FROM `".$prefix."_nsnst_ip2country` ORDER BY $column $direction LIMIT $min,$perpage");
  while ($getIPs = $GLOBALS['db']->sql_fetchrow($result)) {
    $getIPs['ip_lo_ip'] = long2ip($getIPs['ip_lo']);
    $getIPs['ip_hi_ip'] = long2ip($getIPs['ip_hi']);
    $getIPs['c2c'] = strtoupper($getIPs['c2c']);
    echo "<tr onmouseover=\"this.style.backgroundColor='$bgcolor2'\" onmouseout=\"this.style.backgroundColor='$bgcolor1'\" bgcolor='$bgcolor1'>\n";
    echo "<td align='center'>".$getIPs['ip_lo_ip']."</td>\n";
    echo "<td align='center'>".$getIPs['ip_hi_ip']."</td>\n";
    echo "<td align='center'>".$getIPs['c2c']."</td>\n";
    echo "<td align='center'>".$getIPs['country']."</td>\n";
    echo "<td align='center'>".date("Y-m-d", $getIPs['date'])."</td>\n";
    echo "</tr>\n";
  }
  // Page Numbering
  $pagesint = ($totalselected / $perpage);
  $pageremainder = ($totalselected % $perpage);
  if ($pageremainder != 0) {
    $pages = ceil($pagesint);
    if ($totalselected < $perpage) { $pageremainder = 0; }
  } else {
    $pages = $pagesint;
  }
  if ($pages != 1 && $pages != 0) {
    echo "<tr bgcolor='$bgcolor1'><td colspan='5'><img src='images/pix.gif' height='2' width='2'></td></tr>\n";
    echo "<tr><form action='modules.php?name=$module_name' method='post'>\n";
    echo "<input type='hidden' name='op' value='STIP2C'>\n";
    echo "<td align='right' bgcolor='$bgcolor2' colspan='5'><b>"._AB_PAGE."</b> ";
    $counter = 1;
    $currentpage = ($max / $perpage);
    echo "<input type='hidden' name='column' value='$column'>\n";
    echo "<input type='hidden' name='direction' value='$direction'>\n";
    echo "<select name='min'>\n";
    while ($counter <= $pages ) {
      $cpage = $counter;
      $mintemp = ($perpage * $counter) - $perpage;
      if ($counter == $currentpage) {
        echo "<option selected>$counter</option>";
      } else {
        echo "<option value='$mintemp'>$counter</option>";
      }
      $counter++;
    }
    echo "</select> <b>"._AB_OF." $pages</b> <input type='submit' value='"._AB_GO."'></td>\n</form></tr>\n";
  }
  // Page Numbering
  echo "</table>\n";
} else {
  echo "<center><b>"._AB_NOIPS."</b></center>\n";
}
Max_CloseTable();
incof();