<?php
/************************************************************************/
/* Maximus CMS: Web Portal System                                       */
/* ==============================                                       */
/*                                                                      */
/* Copyright (c) 2002 - 2006                                            */
/* http://www.php-maximus.fr                                            */
/* dev@php-maximus.org                                                  */
/*                                                                      */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/************************************************************************/
/* Based on PHP-NUKE: Web Portal System                                 */
/************************************************************************/
/********************************************************/
/* NukeSentinel(tm)                                     */
/* By: NukeScripts Network (webmaster@nukescripts.net)  */
/* http://www.nukescripts.net                           */
/* Copyright © 2000-2005 by NukeScripts Network         */
/********************************************************/

if (!defined('ADMIN_ALLOW') && !defined('ADMIN_MAX')) {
	die ("Access Denied");
}

$pagetitle = _AB_NUKESENTINEL.": "._AB_COUNTRYLISTING;
incoh();
title($pagetitle);
Max_OpenTable();
OpenMenu();
ipbanmenu();
CarryMenu();
ip2cmenu();
CloseMenu();
Max_CloseTable();
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 = "country";
if(!$direction or $direction=="") $direction = "asc";
$totalselected = $db->sql_numrows($db->sql_query("SELECT * FROM `".$prefix."_nsnst_countries`"));
if ($totalselected > 0) {
  echo "<table align='center' border='0' cellpadding='2' cellspacing='2' bgcolor='$bgcolor2' width='100%'>\n";
  // Page Sorting
  echo "<tr><td colspan='5'><table width='100%' cellpadding='0' cellspacing='0' border='0'>\n";
  echo "<tr><form method='post' action='".$admin_file.".php?op=ABCountryList'>\n";
  echo "<input type='hidden' name='min' value='$min'>\n";
  echo "<td bgcolor='$bgcolor2' width='100%'><b>"._AB_SORT.":</b> ";
  echo "<select name='column'>\n";
  if($column == "c2c") $selcolumn1 = "selected";
  echo "<option value='c2c' $selcolumn1>"._AB_C2CODE."</option>\n";
  if($column == "country") $selcolumn2 = "selected";
  echo "<option value='country' $selcolumn2>"._AB_COUNTRY."</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>";
  // Page Sorting
  echo "</tr>\n";
  echo "</td></tr></table>\n";
  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='10%'><b>"._AB_FLAG."</b></td>\n";
  echo "<td align='center' width='10%'><b>"._AB_C2CODE."</b></td>\n";
  echo "<td width='80%'><b>"._AB_COUNTRY."</b></td>\n";
  echo "</tr>\n";
  $result = $db->sql_query("SELECT * FROM `".$prefix."_nsnst_countries` ORDER BY $column $direction LIMIT $min,$perpage");
  while ($getIPs = $db->sql_fetchrow($result)) {
    $getIPs['flag'] = flag_img($getIPs['c2c']);
    $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['flag']."</td>\n";
    echo "<td align='center'>".$getIPs['c2c']."</td>\n";
    echo "<td>".$getIPs['country']."</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='".$admin_file.".php?op=ABCountryList' method='post'>\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_NOCOUNTRIES."</b></center>\n";
}
Max_CloseTable();
incof();