All pastes #42835 Raw Edit

Untitled

public text v1 · immutable
#42835 ·published 2006-02-22 23:21 UTC
rendered paste body
<?php 
/* 
  $Page ID: visitors.php,v2.2d, Dated: 14 August 2005 [Visitors File] Ian-San $
  http://www.gowebtools.com

  osCommerce, Open Source E-Commerce Solutions 
  http://www.oscommerce.com 

  Copyright (c) 2002 osCommerce 

  Released under the GNU General Public License 
*/ 
  
// Change following setting if you wish
  define('KEYWORD_DURATION', '90'); // Used to set duration of Keyword Report.
// Change above setting if you wish

  require('includes/application_top.php'); 
  
// Change following settings if you wish
  define('MAX_VISITOR_RESULTS', MIN(MAX_DISPLAY_SEARCH_RESULTS, 20)); // JavaScript chart may push out to right if Table size too big

  $gd_support = '1'; // Set Switch from '1' to '0' if GD Support or imagecreate() is not available or to simply switch off displaying Charts 
  $use_cookie = '1'; // Set to 0 to disable use of cookie
  $default_report = '2'; // Initial Chart to show
  $trace_days = '3'; // Time in days for Visitors Trace Data to be available
  $link_support = '1'; // Change to 0 if you do not want to link the Page Heading to the support site
// Change above settings if you wish

// Dont change anything below this line
// Clean-up Visitors Trace
   tep_db_query("DELETE FROM " . TABLE_VISITORS_TRACE . " where (TO_DAYS(now()) - TO_DAYS(date) > '" . $trace_days . "')"); 

// set the top level domain
  function visitor_get_top_level_domain($url) {
    if (strpos($url, '://')) {
      $url = parse_url($url);
      $url = $url['host'];
    }

    $domain_array = explode('.', $url);
    $domain_size = sizeof($domain_array);

    if ($domain_size > 1) {
      if (is_numeric($domain_array[$domain_size-2]) && is_numeric($domain_array[$domain_size-1])) {
        return false;
      } else {
        return $domain_array[$domain_size-2] . '.' . $domain_array[$domain_size-1];
      }
    } else {
      return false;
    }
  }
  
  $current_domain = visitor_get_top_level_domain(HTTP_SERVER);
  $cookie_path = '/'; // Could change if not using a top level path
  
  if ( ($HTTP_GET_VARS['display_robot'] && $HTTP_GET_VARS['display_robot'] == 'yes' ) || (!$HTTP_GET_VARS['display_robot'] && isset($HTTP_COOKIE_VARS["display_robot"]) && $HTTP_COOKIE_VARS["display_robot"] == 'yes') ) {
     $robot = "";
	 $display_robot = 'yes';
	 if ($use_cookie == '1') {
       setcookie('display_robot', 'yes', time()+ (365 * 5 * 24 * 3600), $cookie_path, $current_domain, ((getenv('HTTPS') == 'on') ? 1 : 0)); // set robot cookie
	 }
  } else {
     $robot = "AND SUBSTRING(browser_language,1,1) != '['";
	 $display_robot = 'no';
	 if ($use_cookie == '1') {
       setcookie('display_robot', 'no', time()+ (365 * 5 * 24 * 3600), $cookie_path, $current_domain, ((getenv('HTTPS') == 'on') ? 1 : 0)); // set robot cookie
	 }
  }  

 function visitor_get_country_language($country_code) {
   if (substr($country_code, 0, 1) == '[') {
	 $country_name = 'Network';
   } else {
 	$code1 = substr($country_code,0,2);
	$code2 = substr($country_code,3,2);
	$country_name = 'Unknown/LAN';

if ($code1 == "af") {$country_name = 'Afrikaans';}
if ($code1 == "ar") {
    $country_name = 'Arabic';
    if ($code2 == "ae") {$country_name = 'UAE';} 
    if ($code2 == "bh") {$country_name = 'Bahrain';} 
    if ($code2 == "eg") {$country_name = 'Egypt';} 
    if ($code2 == "dz") {$country_name = 'Algeria';} 
    if ($code2 == "iq") {$country_name = 'Iraq';} 
    if ($code2 == "jo") {$country_name = 'Jordan';} 
    if ($code2 == "kw") {$country_name = 'Kuwait';} 
    if ($code2 == "lb") {$country_name = 'Lebanon';} 
    if ($code2 == "ly") {$country_name = 'Libya';} 
    if ($code2 == "ma") {$country_name = 'Morocco';} 
    if ($code2 == "om") {$country_name = 'Oman';}
    if ($code2 == "qa") {$country_name = 'Qatar';} 
    if ($code2 == "sa") {$country_name = 'Saudi';} 
    if ($code2 == "sy") {$country_name = 'Syria';} 
    if ($code2 == "tn") {$country_name = 'Tunisia';} 
    if ($code2 == "ye") {$country_name = 'Yemen';}}
if ($code1 == "be") {$country_name = 'Belarusian';}
if ($code1 == "bg") {$country_name = 'Bulgarian';}
if ($code1 == "ca") {$country_name = 'Catalan';}
if ($code1 == "cs") {$country_name = 'Czech';}
if ($code1 == "da") {$country_name = 'Danish';}
if ($code1 == "de") {
    $country_name = 'Germany';
    if ($code2 == "at") {$country_name = 'Austria';}
    if ($code2 == "ch") {$country_name = 'Switzerland';}
    if ($code2 == "li") {$country_name = 'Liechtenstein';}
    if ($code2 == "lu") {$country_name = 'Luxembourg';}}
if ($code1 == "el") {$country_name = 'Greece';}
if ($code1 == "en") {
    $country_name = 'Other English';
    if ($code2 == "us") {$country_name = 'USA';}
    if ($code2 == "au") {$country_name = 'Australia';}
    if ($code2 == "bz") {$country_name = 'Belize';}
    if ($code2 == "ca") {$country_name = 'Canada';}
    if ($code2 == "gb") {$country_name = 'UK';}
    if ($code2 == "ie") {$country_name = 'Ireland';}
    if ($code2 == "jm") {$country_name = 'Jamaica';}
    if ($code2 == "nz") {$country_name = 'New Zealand';}
    if ($code2 == "tt") {$country_name = 'Trinidad';}
    if ($code2 == "za") {$country_name = 'South Africa';}}
if ($code1 == "es") {
    $country_name = 'Spain';
    if ($code2 == "ar") {$country_name = 'Argentina';}
    if ($code2 == "bo") {$country_name = 'Bolivia';}
    if ($code2 == "cl") {$country_name = 'Chile';}
    if ($code2 == "co") {$country_name = 'Colombia';}
    if ($code2 == "cr") {$country_name = 'Costa Rica';}
    if ($code2 == "do") {$country_name = 'Dominican';}
    if ($code2 == "ec") {$country_name = 'Ecuador';}
    if ($code2 == "gt") {$country_name = 'Guatemala';}
    if ($code2 == "hn") {$country_name = 'Honduras';}
    if ($code2 == "mx") {$country_name = 'Mexico';}
    if ($code2 == "ni") {$country_name = 'Nicaragua';}
    if ($code2 == "pa") {$country_name = 'Panama';}
    if ($code2 == "pe") {$country_name = 'Peru';}
    if ($code2 == "pr") {$country_name = 'Puerto Rico';}
    if ($code2 == "py") {$country_name = 'Paraguay';}
    if ($code2 == "sv") {$country_name = 'El Salvador';}
    if ($code2 == "uy") {$country_name = 'Uruguay';}
    if ($code2 == "ve") {$country_name = 'Venezuela';}}
if ($code1 == "et") {$country_name = 'Estonian';}
if ($code1 == "eu") {$country_name = 'Basque';}
if ($code1 == "fa") {$country_name = 'Farsi';}
if ($code1 == "fi") {$country_name = 'Finland';}
if ($code1 == "fo") {$country_name = 'Faeroes';}
if ($code1 == "fr") {
    $country_name = 'France';
    if ($code2 == "be") {$country_name = 'Belgium';}
    if ($code2 == "ca") {$country_name = 'Canada';}
    if ($code2 == "ch") {$country_name = 'Switzerland';}
    if ($code2 == "ca") {$country_name = 'Luxembourg';}}
if ($code1 == "gd") {
    $country_name = 'Scotland';
    if ($code2 == "ie") {$country_name = 'Ireland';}}
if ($code1 == "he") {$country_name = 'Hebrew';}
if ($code1 == "hi") {$country_name = 'Hindi';}
if ($code1 == "hr") {$country_name = 'Croatian';}
if ($code1 == "hu") {$country_name = 'Hungarian';}
if ($code1 == "in") {$country_name = 'Indonesian';}
if ($code1 == "is") {$country_name = 'Icelandic';}
if ($code1 == "he") {$country_name = 'Hebrew';}
if ($code1 == "it") {
    $country_name = 'Italy';
    if ($code2 == "ch") {$country_name = 'Switzerland';}}
if ($code1 == "ja") {$country_name = 'Japan';}
if ($code1 == "ji") {$country_name = 'Yiddish';}
if ($code1 == "ko") {$country_name = 'Korea';}
if ($code1 == "lt") {$country_name = 'Lithuania';}
if ($code1 == "lv") {$country_name = 'Latvian';}
if ($code1 == "mk") {$country_name = 'Macedonia';}
if ($code1 == "ms") {$country_name = 'Malaysia';}
if ($code1 == "mt") {$country_name = 'Malta';}
if ($code1 == "nl") {
    $country_name = 'Netherlands';
    if ($code2 == "be") {$country_name = 'Belgium';}}
if ($code1 == "no") {$country_name = 'Norway';}
if ($code1 == "pl") {$country_name = 'Poland';}
if ($code1 == "pt") {
    $country_name = 'Portugual';
    if ($code2 == "br") {$country_name = 'Brazil';}}
if ($code1 == "rm") {$country_name = 'Romania';}
if ($code1 == "ro") {$country_name = 'Romania';}
if ($code1 == "ru") {$country_name = 'Russia';}
if ($code1 == "sb") {$country_name = 'Sorbian';}
if ($code1 == "sk") {$country_name = 'Slovak';}
if ($code1 == "sl") {$country_name = 'Slovenian';}
if ($code1 == "sq") {$country_name = 'Albania';}
if ($code1 == "sr") {$country_name = 'Serbia';}
if ($code1 == "sv") {
    $country_name = 'Sweden';
    if ($code2 == "fi") {$country_name = 'Finland';}}
if ($code1 == "sx") {$country_name = 'Sutu';}
if ($code1 == "sz") {$country_name = 'Sami';}
if ($code1 == "tn") {$country_name = 'Tswana';}
if ($code1 == "tr") {$country_name = 'Turkey';}
if ($code1 == "ts") {$country_name = 'Tsonga';}
if ($code1 == "uk") {$country_name = 'Ukrainian';}
if ($code1 == "th") {$country_name = 'Thailand';}
if ($code1 == "ur") {$country_name = 'Urdu';}
if ($code1 == "ve") {$country_name = 'Venda';}
if ($code1 == "vi") {$country_name = 'Vietnam';}
if ($code1 == "xh") {$country_name = 'Xhosa';}
if ($code1 == "zh") {
    $country_name = 'China';
    if ($code2 == "cn") {$country_name = 'China';}
    if ($code2 == "hk") {$country_name = 'Hong Kong';}
    if ($code2 == "sg") {$country_name = 'Singapore';}
    if ($code2 == "tw") {$country_name = 'Taiwan';}}
if ($code1 == "zu") {$country_name = 'Zulu';}
  }
  return $country_name;	  
 }

  // check if the graphs directory exists 
     $show_charts = false; 
     if ( function_exists('imagecreate') ) { 
        if (is_dir(DIR_WS_IMAGES . 'graphs')) { 
          if (is_writeable(DIR_WS_IMAGES . 'graphs')) { 
            $show_charts = true; 
          } else { 
        $messageStack->add(ERROR_GRAPHS_DIRECTORY_NOT_WRITEABLE, 'error'); 
        } 
      } else { 
      $messageStack->add(ERROR_GRAPHS_DIRECTORY_DOES_NOT_EXIST, 'error'); 
      $show_charts = false; 
      } 
     } 

  if ( ($gd_support != '1') || (!function_exists('imagecreate')) ) { $show_charts = false; } 
  
  if ($show_charts == false) { 
    $report = '10'; 
  } else { 
    $report = $default_report; 
  } 

  if ( ($HTTP_GET_VARS['report']) && (tep_not_null($HTTP_GET_VARS['report'])) ) { 
    $report = $HTTP_GET_VARS['report']; 
  } 
  
	 $chart1 = 'menuBoxContentLink';
	 $chart2 = 'menuBoxContentLink';
 	 $chart3 = 'menuBoxContentLink';
	 $chart4 = 'menuBoxContentLink';
	 $chart5 = 'menuBoxContentLink';
 	 $chart6 = 'menuBoxContentLink';
 	 $chart7 = 'menuBoxContentLink';
	 $chart8 = 'menuBoxContentLink';
 	 $chart9 = 'menuBoxContentLink';
	 $chart10 = 'menuBoxContentLink';
	 $chart11 = 'menuBoxContentLink';
	 $chart12 = 'menuBoxContentLink';
	 $chart13 = 'menuBoxContentLink';
	 $chart20 = 'menuBoxContentLink';
	 $chart21 = 'menuBoxContentLink';
	 $chart22 = 'menuBoxContentLink';
 	 $chart23 = 'menuBoxContentLink';
	 $chart24 = 'menuBoxContentLink';
	 $chart25 = 'menuBoxContentLink';
	 $chart26 = 'menuBoxContentLink';
	 $chart27 = 'menuBoxContentLink';
	 $chart28 = 'menuBoxContentLink';
 	 $chart29 = 'menuBoxContentLink';
	 $chart30 = 'menuBoxContentLink';
	 $chart31 = 'menuBoxContentLink';
	 $chart32 = 'menuBoxContentLink';
	 $chart33 = 'menuBoxContentLink';
	 $chart34 = 'menuBoxContentLink';
 	 $chart35 = 'menuBoxContentLink';
	 $chart36 = 'menuBoxContentLink';
	 $chart37 = 'menuBoxContentLink';
	 $chart38 = 'menuBoxContentLink';
	 $chart39 = 'menuBoxContentLink';
	 $chart40 = 'menuBoxContentLink';
	 $chart41 = 'menuBoxContentLink';
	 $chart42 = 'menuBoxContentLink';
	 $chart43 = 'menuBoxContentLink';
	 $chart44 = 'menuBoxContentLink';
 	 $chart45 = 'menuBoxContentLink';

switch ($report) { 
    case '1': 
     $title = STATISTICS_TYPE_REPORT_A . ': ' . STATISTICS_TYPE_REPORT_1; 
	 $chart1 = 'messageStackSuccess';
    break; 
    case '3': 
     $title = STATISTICS_TYPE_REPORT_A . ': ' . STATISTICS_TYPE_REPORT_3; 
	 $chart3 = 'messageStackSuccess';
    break; 
    case '4': 
     $title = STATISTICS_TYPE_REPORT_A . ': ' . STATISTICS_TYPE_REPORT_4; 
	 $chart4 = 'messageStackSuccess';
    break; 
    case '5': 
     $title = STATISTICS_TYPE_REPORT_A . ': ' . STATISTICS_TYPE_REPORT_5; 
	 $chart5 = 'messageStackSuccess';
    break; 
    case '6': 
     $title = STATISTICS_TYPE_REPORT_A . ': ' . STATISTICS_TYPE_REPORT_6; 
	 $chart6 = 'messageStackSuccess';
    break; 
    case '7': 
     $title = STATISTICS_TYPE_REPORT_B . ': ' . STATISTICS_TYPE_REPORT_7; 
	 $chart7 = 'messageStackSuccess';
    break; 
    case '8': 
     $title = STATISTICS_TYPE_REPORT_B . ': ' . STATISTICS_TYPE_REPORT_8; 
	 $chart8 = 'messageStackSuccess';
    break; 
    case '9': 
     $title = STATISTICS_TYPE_REPORT_B . ': ' . STATISTICS_TYPE_REPORT_9; 
	 $chart9 = 'messageStackSuccess';
    break; 
    case '10': 
     $title = STATISTICS_TYPE_REPORT_10; 
	 $chart10 = 'messageStackSuccess';
    break; 
    case '11': 
     $title = STATISTICS_TYPE_REPORT_B . ': ' . STATISTICS_TYPE_REPORT_11; 
	 $chart11 = 'messageStackSuccess';
    break; 
    case '12': 
     $title = STATISTICS_TYPE_REPORT_A . ': ' . STATISTICS_TYPE_REPORT_12; 
	 $chart12 = 'messageStackSuccess';
    break; 
    case '13': 
     $title = STATISTICS_TYPE_REPORT_A . ': ' . STATISTICS_TYPE_REPORT_13; 
	 $chart13 = 'messageStackSuccess';
    break; 
    case '20': 
     $title = STATISTICS_TYPE_REPORT_A . ': ' . STATISTICS_TYPE_REPORT_20; 
	 $chart20 = 'messageStackSuccess';
    break; 
    case '21': 
     $title = STATISTICS_TYPE_REPORT_A . ': ' . STATISTICS_TYPE_REPORT_21; 
	 $chart21 = 'messageStackSuccess';
    break; 
    case '22': 
     $title = STATISTICS_TYPE_REPORT_A . ': ' . STATISTICS_TYPE_REPORT_22; 
	 $chart22 = 'messageStackSuccess';
    break; 
    case '23': 
     $title = STATISTICS_TYPE_REPORT_B . ': ' . STATISTICS_TYPE_REPORT_23; 
	 $chart23 = 'messageStackSuccess';
    break; 
    case '24': 
     $title = STATISTICS_TYPE_REPORT_B . ': ' . STATISTICS_TYPE_REPORT_24; 
	 $chart24 = 'messageStackSuccess';
    break; 
    case '25': 
     $title = STATISTICS_TYPE_REPORT_B . ': ' . STATISTICS_TYPE_REPORT_25; 
	 $chart25 = 'messageStackSuccess';
    break; 
    case '26': 
     $title = STATISTICS_TYPE_REPORT_B . ': ' . STATISTICS_TYPE_REPORT_26; 
	 $chart26 = 'messageStackSuccess';
    break; 
    case '27': 
     $title = STATISTICS_TYPE_REPORT_B . ': ' . STATISTICS_TYPE_REPORT_27; 
	 $chart27 = 'messageStackSuccess';
    break; 
    case '28': 
     $title = STATISTICS_TYPE_REPORT_B . ': ' . STATISTICS_TYPE_REPORT_28; 
	 $chart28 = 'messageStackSuccess';
    break; 
    case '29': 
     $title = STATISTICS_TYPE_REPORT_B . ': ' . STATISTICS_TYPE_REPORT_29; 
	 $chart29 = 'messageStackSuccess';
    break; 
    case '30': 
     $title = STATISTICS_TYPE_REPORT_B . ': ' . STATISTICS_TYPE_REPORT_30; 
	 $chart30 = 'messageStackSuccess';
    break; 
    case '31': 
     $title = STATISTICS_TYPE_REPORT_B . ': ' . STATISTICS_TYPE_REPORT_31; 
	 $chart31 = 'messageStackSuccess';
    break; 
    case '32': 
     $title = STATISTICS_TYPE_REPORT_A . ': ' . STATISTICS_TYPE_REPORT_32; 
	 $chart32 = 'messageStackSuccess';
    break; 
    case '33': 
     $title = STATISTICS_TYPE_REPORT_B . ': ' . STATISTICS_TYPE_REPORT_33; 
	 $chart33 = 'messageStackSuccess';
    break; 
    case '34': 
     $title = STATISTICS_TYPE_REPORT_A . ': ' . STATISTICS_TYPE_REPORT_34; 
	 $chart34 = 'messageStackSuccess';
    break; 
    case '35': 
     $title = STATISTICS_TYPE_REPORT_A . ': ' . STATISTICS_TYPE_REPORT_35; 
	 $chart35 = 'messageStackSuccess';
    break; 
    case '36': 
     $title = STATISTICS_TYPE_REPORT_B . ': ' . STATISTICS_TYPE_REPORT_36; 
	 $chart36 = 'messageStackSuccess';
    break; 
    case '37': 
     $title = STATISTICS_TYPE_REPORT_A . ': ' . STATISTICS_TYPE_REPORT_37; 
	 $chart37 = 'messageStackSuccess';
    break; 
    case '38': 
     $title = STATISTICS_TYPE_REPORT_B . ': ' . STATISTICS_TYPE_REPORT_38; 
	 $chart38 = 'messageStackSuccess';
    break; 
    case '39': 
     $title = STATISTICS_TYPE_REPORT_A . ': ' . STATISTICS_TYPE_REPORT_39; 
	 $chart39 = 'messageStackSuccess';
    break; 
    case '40': 
     $title = STATISTICS_TYPE_REPORT_B . ': ' . STATISTICS_TYPE_REPORT_40; 
	 $chart40 = 'messageStackSuccess';
    break; 
    case '41': 
     $title = STATISTICS_TYPE_REPORT_B . ': ' . STATISTICS_TYPE_REPORT_41; 
	 $chart41 = 'messageStackSuccess';
    break; 
    case '42': 
     $title = STATISTICS_TYPE_REPORT_A . ': ' . STATISTICS_TYPE_REPORT_42; 
	 $chart42 = 'messageStackSuccess';
    break; 
    case '43': 
     $title = STATISTICS_TYPE_REPORT_A . ': ' . STATISTICS_TYPE_REPORT_43; 
	 $chart43 = 'messageStackSuccess';
    break; 
    case '44': 
     $title = STATISTICS_TYPE_REPORT_B . ': ' . STATISTICS_TYPE_REPORT_44; 
	 $chart44 = 'messageStackSuccess';
    break; 
    case '45': 
     $title = STATISTICS_TYPE_REPORT_B . ': ' . STATISTICS_TYPE_REPORT_45; 
	 $chart45 = 'messageStackSuccess';
    break; 
    case '50': 
     $title = STATISTICS_TYPE_REPORT_50; 
	 $chart50 = 'messageStackSuccess';
    break; 
    default: 
     $title = STATISTICS_TYPE_REPORT_A . ': ' . STATISTICS_TYPE_REPORT_2; 
	 $chart2 = 'messageStackSuccess';
  } 
  
  $years_array = array(); 
  $years_query = tep_db_query("select distinct year(date) as visitor_year from " . TABLE_VISITORS . ""); 
  while ($years = tep_db_fetch_array($years_query)) { 
  $years_array[] = array('id' => $years['visitor_year'], 
                         'text' => $years['visitor_year']); 
  }
  
// Something for an empty array
  if (sizeof($years_array) < 1) { $years_array = array(array('id' => date('Y'), 'text' => date('Y'))); }

  $months_array = array(); 
  for ($i=1; $i<13; $i++) { 
    $months_array[] = array('id' => $i, 
                            'text' => strftime('%B', mktime(0,0,0,$i,15))); 
  } 

  $type_array = array(array('id' => 'daily', 
                            'text' => HEADING_TYPE_DAILY), 
                      array('id' => 'monthly', 
                            'text' => HEADING_TYPE_MONTHLY), 
                      array('id' => 'yearly', 
                            'text' => HEADING_TYPE_YEARLY)); 

  if ($HTTP_GET_VARS['action']) {
    switch ($HTTP_GET_VARS['action']) {
      case 'emptyconfirm':
        tep_db_query("TRUNCATE " . TABLE_VISITORS);
        tep_redirect(tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'page', 'action')).'page=' . $HTTP_GET_VARS['page']));
	    break;
      case 'robotsconfirm':
        tep_db_query("DELETE FROM " . TABLE_VISITORS . " where SUBSTRING(browser_language,1,1) = '['");
        tep_redirect(tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'page', 'action')).'page=' . $HTTP_GET_VARS['page']));
        break;
      case 'guestsconfirm':
        tep_db_query("DELETE FROM " . TABLE_VISITORS . " where customers_id='0'");
        tep_redirect(tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'page', 'action')).'page=' . $HTTP_GET_VARS['page']));
        break;
      case 'datesconfirm':
        $delete_year = tep_db_prepare_input($HTTP_POST_VARS['delete_year']);
        $delete_month = tep_db_prepare_input($HTTP_POST_VARS['delete_month']);
        $delete_day = tep_db_prepare_input($HTTP_POST_VARS['delete_day']);
        tep_db_query("DELETE FROM " . TABLE_VISITORS . " where TO_DAYS(date) <= TO_DAYS('" . tep_db_input($delete_year) . "-" . tep_db_input($delete_month) . "-" . tep_db_input($delete_day) . "') - 1");
        tep_redirect(tep_href_link(FILENAME_VISITORS));
        break;
      case 'idconfirm':
        $delete_id = (int) tep_db_prepare_input($HTTP_POST_VARS['delete_id']);
        tep_db_query("delete from " . TABLE_VISITORS . " where browser_id = '$delete_id'");
        tep_redirect(tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'page', 'action')).'page=' . $HTTP_GET_VARS['page']));
	    break;
     }
   }
 ?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE .' ' . NAVBAR_TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
<SCRIPT LANGUAGE="JavaScript1.2" SRC="jsgraph/graph.js"></SCRIPT>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->
<!-- body //-->
<table border="0" width="100%" cellspacing="2" cellpadding="2"> 
<tr> 
  <td width="<?php echo BOX_WIDTH; ?>" valign="top" rowspan=99> 
    <table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">
      <!-- left_navigation //-->
      <?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
      <!-- left_navigation_eof //-->
    </table></td>
  <td class="pageHeading"><?php if ($link_support == '1') { echo '<a href="http://www.gowebtools.com/visitors/index.html?gwt_track=10145" target="_blank"><font class="pageHeading">' . HEADING_TITLE . '</font></a>'; } else {  echo HEADING_TITLE; } ?></td>
  <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT/2); ?></td>
</tr>
  <tr> 
    <td align="right"><table border="0" width="100%" cellspacing="0" cellpadding="0">
        <tr>
		  <?php echo tep_draw_form('search', FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'page')), 'get'); ?> 
          <?php echo tep_draw_hidden_field('year', $HTTP_GET_VARS['year']); ?> 
          <?php echo tep_draw_hidden_field('month', $HTTP_GET_VARS['month']); ?> 
          <?php echo tep_draw_hidden_field('listing', $HTTP_GET_VARS['listing']); ?> 
          <td class="smallText" align="right"><?php echo HEADING_TITLE_SEARCH . ' ' . tep_draw_input_field('search'); ?></td></form>
		  </tr>
      </table></td>
    <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
  </tr>
<?php
  if ( ($HTTP_GET_VARS['trace_pop_up']) && ($HTTP_GET_VARS['trace_pop_up'] == 'action') && ($HTTP_GET_VARS['trace_ip'] != $bFlag) ) {
    $trace_ip = $HTTP_GET_VARS['trace_ip'];
    $trace_date = date('Y-m-d' , $HTTP_GET_VARS['trace_date']);
	
    $trace_string = '<tr><td align="left"><font size="2"><b>' . TABLE_HEADING_TRACE_TIME . '</b></font></td>';
    $trace_string .= '<td align="left"><font size="2"><b>' . TABLE_HEADING_URI . '</b></font></td></tr>';
	
    $trace_query = tep_db_query("select date, uri from " . TABLE_VISITORS_TRACE . " where browser_ip = '" . $trace_ip . "' AND (TO_DAYS(date) = TO_DAYS('" . $trace_date . "')) order by date DESC");

    while ($trace = tep_db_fetch_array($trace_query)) {
      $trace_string .= '<tr><td nowrap width="10%"><font size="2">' . strrchr(tep_datetime_short($trace['date']), " ") . '</font></td>';

	  if($trace["uri"] == '/') {
	    $trace_string .= '<td><a href="' . HTTP_SERVER . '" target="_blank"><font size="2">' . TABLE_ROOT . '</font></a></td></tr>';
	  } else {
	    $trace_string .= '<td><a href="' . HTTP_SERVER . $trace['uri'] . '" target="_blank"><font size="2">' .  chunk_split($trace["uri"],80,"<br>") . '</font></a></td></tr>';
      }

    }
	
	echo '<script language="JAVASCRIPT" type="TEXT/JAVASCRIPT">';
    echo 'newWin = window.open(\'\',\'traceWindow\',\'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=600,height=300,screenX=150,screenY=150,top=150,left=150\');';

    echo 'newWin.document.write(\'<p><font size="2"><b>' . TABLE_HEADING_IP . '</b>:&nbsp;&nbsp;' . $trace_ip . '<br><b>' . TABLE_HEADING_HOST . '</b>:&nbsp;&nbsp;' . @gethostbyaddr($trace_ip) . '<br><b>' . TABLE_HEADING_TRACE_DATE . '</b>:&nbsp;&nbsp;' . date(DATE_FORMAT, $HTTP_GET_VARS['trace_date']+$this_time_zone * 3600) . '</font></p>\');';

    echo 'newWin.document.write(\'<table width="100%" cellspacing="2" cellpadding="2" border="2">' . $trace_string . '</td></tr></table>\');';
    echo 'newWin.document.write(\'<div align="right">' . POPUP_CLOSE . '</div><br>\');';
    echo 'newWin.focus();';
    echo '</script>';
	
    tep_session_register( 'bFlag' );
    tep_session_register( 'tFlag' );
	$bFlag = $trace_ip;
	$tFlag = $HTTP_GET_VARS['trace_date'];
  } else {
    tep_session_unregister( 'bFlag' );
    tep_session_unregister( 'tFlag' );
    $bFlag = '';
    $tFlag = '';
  }
?>
<tr> <td valign="top">
  <table border="0" cellpadding=2 cellspacing=0 width=100%>
    <tr> 
      <!-- body_text //-->
      <td class="main" align="left">
	    <?php echo tep_draw_form('year', FILENAME_VISITORS, '', 'get'); ?> 
        <?php echo tep_draw_hidden_field('year', $HTTP_GET_VARS['year']); ?>
		<?php echo tep_draw_hidden_field('month', $HTTP_GET_VARS['end_month']); ?> 
        <?php echo tep_draw_hidden_field('listing', $HTTP_GET_VARS['listing']); ?> 
        <?php echo tep_draw_hidden_field('display_robot', $HTTP_GET_VARS['display_robot']); ?> 
        <?php echo tep_draw_hidden_field('report', $HTTP_GET_VARS['report']); ?> 
        <?php echo TITLE_TYPE . ' ' . tep_draw_pull_down_menu('type', $type_array, (($HTTP_GET_VARS['type']) ? $HTTP_GET_VARS['type'] : 'daily'), 'onChange="this.form.submit();"'); ?> 
        <noscript>
        <input type="submit" value="<?php echo BUTTON_REFRESH; ?>">
        </noscript></td>
<?php
  switch ($HTTP_GET_VARS['type']) { 
    case 'yearly':
	  break; 
    case 'monthly': 
      echo '<td align="left">' . TITLE_YEAR . ' ' . tep_draw_pull_down_menu('year', $years_array, (($HTTP_GET_VARS['year']) ? $HTTP_GET_VARS['year'] : date('Y')), 'onChange="this.form.submit();"') . '<noscript><input type="submit" value="' . BUTTON_REFRESH . '"></noscript></td>'; 
	  break;
	default:
	  echo '<td align="left">' . TITLE_MONTH . ' ' . tep_draw_pull_down_menu('month', $months_array, (($HTTP_GET_VARS['month']) ? $HTTP_GET_VARS['month'] : date('n')), 'onChange="this.form.submit();"') . '<noscript><input type="submit" value="' . BUTTON_REFRESH . '"></noscript></td>';
	  echo '<td align="left">' . TITLE_YEAR . ' ' . tep_draw_pull_down_menu('year', $years_array, (($HTTP_GET_VARS['year']) ? $HTTP_GET_VARS['year'] : date('Y')), 'onChange="this.form.submit();"') . '<noscript><input type="submit" value="' . BUTTON_REFRESH . '"></noscript></td>';
	  break;
  }
?> 
    <td class="main" align="left"><input type="submit" value="<?php echo BUTTON_REFRESH; ?>"></td></form></tr>
  </table>
  <table border="0" width="100%" cellspacing="2" cellpadding="2">
    <tr> 
      <?php 
      $start_year = $years_array['0']['id'];
      $start_month = '1'; 
      $end_year = date('Y')+1; 
      $end_month = '1'; 
      $order =  " WHERE TO_DAYS(date) >= TO_DAYS('" . $start_year . "-" . $start_month . "-01') AND TO_DAYS(date) <= TO_DAYS('" . $end_year . "-" . $end_month . "-01') - 1 $robot order by "; 
      $order1 =  " WHERE TO_DAYS(date) >= TO_DAYS('" . $start_year . "-" . $start_month . "-01')  AND TO_DAYS(date) <= TO_DAYS('" . $end_year . "-" . $end_month . "-01') - 1 $robot"; 
    
  switch ($HTTP_GET_VARS['type']) { 
      case 'daily': 
         $start_year = $HTTP_GET_VARS['year']; 
         $start_month = $HTTP_GET_VARS['month']; 
         $end_year = $HTTP_GET_VARS['year']; 
         $end_month = $HTTP_GET_VARS['month']+1; 
         if ($end_month == '13') {$end_month = '1'; $end_year = $end_year +1;} 
         $order =  " WHERE TO_DAYS(date) >= TO_DAYS('" . $start_year . "-" . $start_month . "-01') AND TO_DAYS(date) <= TO_DAYS('" . $end_year . "-" . $end_month . "-01') - 1 $robot order by "; 
         $order1 =  " WHERE TO_DAYS(date) >= TO_DAYS('" . $start_year . "-" . $start_month . "-01')  AND TO_DAYS(date) <= TO_DAYS('" . $end_year . "-" . $end_month . "-01') - 1 $robot"; 
      break; 
      case 'monthly': 
         $start_year = $HTTP_GET_VARS['year']; 
         $start_month = '01'; 
         $end_year = $HTTP_GET_VARS['year'] + 1; 
         $end_month = '01'; 
         $order =  " WHERE TO_DAYS(date) >= TO_DAYS('" . $start_year . "-" . $start_month . "-01') AND TO_DAYS(date) <= TO_DAYS('" . $end_year . "-" . $end_month . "-01') - 1 $robot order by "; 
         $order1 =  " WHERE TO_DAYS(date) >= TO_DAYS('" . $start_year . "-" . $start_month . "-01')  AND TO_DAYS(date) <= TO_DAYS('" . $end_year . "-" . $end_month . "-01') - 1 $robot"; 
      break; 
      default: 
        $order = str_replace('AND', 'WHERE', $robot) . " order by ";
        break; 
  } 
          
  switch ($listing) { 
      case "id-asc": 
        $order .= "browser_id ASC"; 
      break; 
      case "id-desc": 
        $order .= "browser_id DESC"; 
      break; 
      case "counter-asc": 
        $order .= "counter ASC"; 
      break; 
      case "counter-desc": 
        $order .= "counter DESC"; 
      break;
      case "date-asc": 
        $order .= "date ASC"; 
      break; 
      case "date-desc": 
        $order .= "date DESC"; 
      break; 
      case "last-asc": 
        $order .= "online ASC"; 
      break; 
      case "last-desc": 
        $order .= "online DESC"; 
      break; 
      case "online-asc": 
        $order .= "(UNIX_TIMESTAMP(online) - UNIX_TIMESTAMP(date)) ASC"; 
      break; 
      case "online-desc": 
        $order .= "(UNIX_TIMESTAMP(online) - UNIX_TIMESTAMP(date)) DESC"; 
      break; 
      case "customer-asc": 
        $order .= "customers_id ASC"; 
      break; 
      case "customer-desc": 
        $order .= "customers_id DESC"; 
      break; 
      case "b-language-asc": 
        $order .= "browser_language ASC"; 
      break; 
      case "b-language-desc": 
        $order .= "browser_language DESC"; 
      break; 
      case "language-asc": 
        $order .= "language ASC"; 
      break; 
      case "language-desc": 
        $order .= "language DESC"; 
      break; 
      case "ip-asc": 
        $order .= "browser_ip ASC"; 
      break; 
      case "ip-desc": 
        $order .= "browser_ip DESC"; 
      break; 
      case "referer-asc": 
       $order .= "referer ASC"; 
      break; 
      case "referer-desc": 
       $order .= "referer DESC"; 
      break; 
      case "uri-asc": 
       $order .= "uri ASC"; 
      break; 
      case "uri-desc": 
       $order .= "uri DESC"; 
      break; 
      default: 
  	   $listing = "date-desc";
       $order .= "online DESC"; 
  } 

  ?>
      <td class="smallText" align="left"> <?php echo RANGE_FROM . ' ' . date(DATE_FORMAT, mktime(0,0,0,$start_month,1,$start_year)); ?>&nbsp;&nbsp;<?php echo RANGE_TO . ' ' . date(DATE_FORMAT, mktime(0,0,0,$end_month  ,0,$end_year)); ?> 
      </td>
      <td class="smallText" align="right"> 
        <?php if ($display_robot == 'yes') {
      echo '<font color="#008080">' . ROBOT_SWITCH_LIMITED . '</font>&nbsp;&nbsp;' . tep_image(DIR_WS_IMAGES . 'icon_status_green.gif', VISITOR_ICON_FULL_ACTIVE, 10, 10) . '&nbsp;&nbsp;<a href="' . tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'display_robot')).'display_robot=no') . '">' . tep_image(DIR_WS_IMAGES . 'icon_status_red_light.gif', VISITOR_ICON_LIMITED, 10, 10) . '</a>';
	} else {
      echo '<font color="#FF0000"><b>' . ROBOT_SWITCH_FULL . '</b></font>&nbsp;&nbsp;<a href="' . tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'display_robot')).'display_robot=yes') . '">' . tep_image(DIR_WS_IMAGES . 'icon_status_green_light.gif', VISITOR_ICON_FULL, 10, 10) . '</a>&nbsp;&nbsp;' . tep_image(DIR_WS_IMAGES . 'icon_status_red.gif', VISITOR_ICON_LIMITED_ACTIVE, 10, 10);
	}  ?>
      </td>
    </tr>
    <?php
  $counter_data_query = tep_db_query("select * from " . TABLE_VISITORS); 
  $heading = array();
  $contents = array();
  switch ($HTTP_GET_VARS['action']) {
    case 'empty':
      $heading[] = array('text' => '<b>' . TEXT_HEADING_EMPTY . '</b>');
      $contents = array('form' => tep_draw_form('status', FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'page', 'action')).'action=emptyconfirm', 'post', 'enctype="multipart/form-data"'));
      $contents[] = array('text' => TEXT_EDIT_EMPTY);
      $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_confirm.gif', IMAGE_CONFIRM) . ' <a href="' . tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'page', 'action')).'page=' . $HTTP_GET_VARS['page']) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a></form>');
	  break;
    case 'robots':
      $heading[] = array('text' => '<b>' . TEXT_HEADING_ROBOTS . '</b>');
      $contents = array('form' => tep_draw_form('status', FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'page', 'action')).'action=robotsconfirm', 'post', 'enctype="multipart/form-data"'));
      $contents[] = array('text' => TEXT_EDIT_ROBOTS);
      $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_confirm.gif', IMAGE_CONFIRM) . ' <a href="' . tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'page', 'action')).'page=' . $HTTP_GET_VARS['page']) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a></form>');
	  break;
    case 'guests':
      $heading[] = array('text' => '<b>' . TEXT_HEADING_GUESTS . '</b>');
      $contents = array('form' => tep_draw_form('status', FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'page', 'action')).'action=guestsconfirm', 'post', 'enctype="multipart/form-data"'));
      $contents[] = array('text' => TEXT_EDIT_GUESTS);
      $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_confirm.gif', IMAGE_CONFIRM) . ' <a href="' . tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'page', 'action')).'page=' . $HTTP_GET_VARS['page']) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a></form>');
	  break;
    case 'id':
      $heading[] = array('text' => '<b>' . TEXT_HEADING_BY_ID . '</b>');
      $contents = array('form' => tep_draw_form('status', FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'page', 'action')).'action=idconfirm', 'post', 'enctype="multipart/form-data"'));
	  $contents[] = array('text' => '<br>' . TEXT_EDIT_BY_ID . '<br>' . tep_draw_input_field('delete_id', '0', 'size=11'));
      $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_confirm.gif', IMAGE_CONFIRM) . ' <a href="' . tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'page', 'action')).'page=' . $HTTP_GET_VARS['page']) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a></form>');
	  break;
    case 'date':
	  $days_array = array(); 
      for ($i=1; $i<32; $i++) { 
        $days_array[] = array('id' => $i, 
                              'text' => ($i) ); 
      } 
      $heading[] = array('text' => '<b>' . TEXT_HEADING_DATE . '</b>');
      $contents = array('form' => tep_draw_form('status', FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'page', 'action')).'action=datesconfirm', 'post', 'enctype="multipart/form-data"'));
      $contents[] = array('text' => TEXT_EDIT_DATE);
      $contents[] = array('text' => '<br>' . TITLE_DAY . '&nbsp;' . tep_draw_pull_down_menu('delete_day', $days_array) . '&nbsp;&nbsp;&nbsp;' . TITLE_MONTH . '&nbsp;' . tep_draw_pull_down_menu('delete_month', $months_array) . '&nbsp;&nbsp;&nbsp;' . TITLE_YEAR . '&nbsp;' . tep_draw_pull_down_menu('delete_year', $years_array));
      $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_confirm.gif', IMAGE_CONFIRM) . ' <a href="' . tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'page', 'action')).'page=' . $HTTP_GET_VARS['page']) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a></form>');
	  break;
    default:
      $heading[] = array('text' => '<b>' . TEXT_HEADING_DELETE . '</b>');
  if( tep_db_num_rows($counter_data_query) ) {
      $contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'page', 'action')).'page=' . $HTTP_GET_VARS['page'] . '&action=guests') . '">' . tep_image_button('button_guests.gif', IMAGE_DELETE_GUESTS) . '</a>&nbsp;&nbsp;&nbsp;<a href="' . tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'page', 'action')).'page=' . $HTTP_GET_VARS['page'] . '&action=robots') . '">' . tep_image_button('button_robots.gif', IMAGE_DELETE_ROBOTS) . '</a>&nbsp;&nbsp;&nbsp;<a href="' . tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'page', 'action')).'page=' . $HTTP_GET_VARS['page'] . '&action=date') . '">' . tep_image_button('button_dates.gif', IMAGE_DELETE_DATE) . '</a>&nbsp;&nbsp;&nbsp;<a href="' . tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'page', 'action')).'page=' . $HTTP_GET_VARS['page'] . '&action=id') . '">' . tep_image_button('button_delete_id.gif', IMAGE_DELETE_BY_ID) . '</a>&nbsp;&nbsp;&nbsp;<a href="' . tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'page', 'action')).'page=' . $HTTP_GET_VARS['page'] . '&action=empty') . '">' . tep_image_button('button_empty.gif', IMAGE_EMPTY) . '</a>');
      $contents[] = array('align' => 'center', 'text' => '<b>' . TEXT_FOOTER_DELETE . '</b>');
  } else {
	  $contents[] = array('align' => 'center', 'text' => '<center><b>' . ERROR_NO_DATA . '</b></center>'); 
  }
      break;
  }

  if ( (tep_not_null($heading)) && (tep_not_null($contents)) ) {
    echo '            <tr><td colspan="3" width="100%" valign="top">' . "\n";

    $box = new box;
    echo $box->infoBox($heading, $contents);

    echo '            </td></tr>' . "\n";
  }
?>
    <tr> 
      <td valign="top" colspan="2"> <table border="0" width="100%" cellspacing="0" cellpadding="2" class="VisitorTableBox">
          <tr class="dataTableHeadingRow"> 
            <td nowrap valign="top" class="VisitorTableHeadingContent" align="center"><center>
                <a href="<?php echo tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'listing')).'listing=id-asc'); ?>"><img src="images/<?php if ($listing == 'id-asc') { echo 'ic_up_on.gif'; } else { echo 'ic_up.gif'; } ?>" width="11" height="12" alt="<?php echo SORT_UP; ?>" border="0" align=""></a><?php echo tep_draw_separator('pixel_blue.gif', '11', '8'); ?><a href="<?php echo tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'listing')).'listing=id-desc'); ?>"><img src="images/<?php if ($listing == 'id-desc') { echo 'ic_down_on.gif'; } else { echo 'ic_down.gif'; } ?>" width="11" height="12" alt="<?php echo SORT_DOWN; ?>" border="0" align=""></a> 
              </center>
              <?php echo TABLE_HEADING_NUMBER; ?></td>
            <td nowrap valign="top" class="VisitorTableHeadingContent" align="center"><center>
                <a href="<?php echo tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'listing')).'listing=ip-asc'); ?>"><img src="images/<?php if ($listing == 'ip-asc') { echo 'ip_up_on.gif'; } else { echo 'ic_up.gif'; } ?>" width="11" height="12" alt="<?php echo SORT_UP; ?>" border="0" align=""></a><?php echo tep_draw_separator('pixel_blue.gif', '11', '8'); ?><a href="<?php echo tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'listing')).'listing=ip-desc'); ?>"><img src="images/<?php if ($listing == 'ip-desc') { echo 'ic_down_on.gif'; } else { echo 'ic_down.gif'; } ?>" width="11" height="12" alt="<?php echo SORT_DOWN; ?>" border="0" align=""></a> 
              </center>
              <?php echo TABLE_HEADING_IP; ?></td>
            <td nowrap valign="top" class="VisitorTableHeadingContent" align="center"><center>
                <a href="<?php echo tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'listing')).'listing=date-asc'); ?>"><img src="images/<?php if ($listing == 'date-asc') { echo 'ic_up_on.gif'; } else { echo 'ic_up.gif'; } ?>" width="11" height="12" alt="<?php echo SORT_UP; ?>" border="0" align=""></a><?php echo tep_draw_separator('pixel_blue.gif', '11', '8'); ?><a href="<?php echo tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'listing')).'listing=date-desc'); ?>"><img src="images/<?php if ($listing == 'date-desc') { echo 'ic_down_on.gif'; } else { echo 'ic_down.gif'; } ?>" width="11" height="12" alt="<?php echo SORT_DOWN; ?>" border="0" align=""></a> 
              </center>
              <?php echo TABLE_HEADING_DATE; ?></td>
            <td nowrap valign="top" class="VisitorTableHeadingContent" align="center"><center>
                <a href="<?php echo tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'listing')).'listing=last-asc'); ?>"><img src="images/<?php if ($listing == 'last-asc') { echo 'ic_up_on.gif'; } else { echo 'ic_up.gif'; } ?>" width="11" height="12" alt="<?php echo SORT_UP; ?>" border="0" align=""></a><?php echo tep_draw_separator('pixel_blue.gif', '11', '8'); ?><a href="<?php echo tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'listing')).'listing=last-desc'); ?>"><img src="images/<?php if ($listing == 'last-desc') { echo 'ic_down_on.gif'; } else { echo 'ic_down.gif'; } ?>" width="11" height="12" alt="<?php echo SORT_DOWN; ?>" border="0" align=""></a>
              </center>
              <?php echo TABLE_HEADING_LAST; ?></td>
            <td valign="top" class="VisitorTableHeadingContent" align="center"><center>
                <a href="<?php echo tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'listing')).'listing=counter-asc'); ?>"><img src="images/<?php if ($listing == 'counter-asc') { echo 'ic_up_on.gif'; } else { echo 'ic_up.gif'; } ?>" width="11" height="12" alt="<?php echo SORT_UP; ?>" border="0" align=""></a><?php echo tep_draw_separator('pixel_blue.gif', '11', '8'); ?><a href="<?php echo tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'listing')).'listing=counter-desc'); ?>"><img src="images/<?php if ($listing == 'counter-desc') { echo 'ic_down_on.gif'; } else { echo 'ic_down.gif'; } ?>" width="11" height="12" alt="<?php echo SORT_DOWN; ?>" border="0" align=""></a> 
              </center>
              <?php echo TABLE_HEADING_COUNTER; ?></td>
            <td valign="top" class="VisitorTableHeadingContent" align="center"><center>
                <a href="<?php echo tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'listing')).'listing=online-asc'); ?>"><img src="images/<?php if ($listing == 'online-asc') { echo 'ic_up_on.gif'; } else { echo 'ic_up.gif'; } ?>" width="11" height="12" alt="<?php echo SORT_UP; ?>" border="0" align=""></a><?php echo tep_draw_separator('pixel_blue.gif', '11', '8'); ?><a href="<?php echo tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'listing')).'listing=online-desc'); ?>"><img src="images/<?php if ($listing == 'online-desc') { echo 'ic_down_on.gif'; } else { echo 'ic_down.gif'; } ?>" width="11" height="12" alt="<?php echo SORT_DOWN; ?>" border="0" align=""></a> 
              </center>
              <?php echo TABLE_HEADING_ONLINE; ?></td>
            <td valign="top" class="VisitorTableHeadingContent" align="center"><center>
                <a href="<?php echo tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'listing')).'listing=customer-asc'); ?>"><img src="images/<?php if ($listing == 'customer-asc') { echo 'ic_up_on.gif'; } else { echo 'ic_up.gif'; } ?>" width="11" height="12" alt="<?php echo SORT_UP; ?>" border="0" align=""></a><?php echo tep_draw_separator('pixel_blue.gif', '11', '8'); ?><a href="<?php echo tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'listing')).'listing=customer-desc'); ?>"><img src="images/<?php if ($listing == 'customer-desc') { echo 'ic_down_on.gif'; } else { echo 'ic_down.gif'; } ?>" width="11" height="12" alt="<?php echo SORT_DOWN; ?>" border="0" align=""></a> 
              </center>
              <?php echo TABLE_HEADING_CUSTOMER; ?></td>
            <td valign="top" class="VisitorTableHeadingContent" align="center"><center>
                <a href="<?php echo tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'listing')).'listing=b-language-asc'); ?>"><img src="images/<?php if ($listing == 'b-language-asc') { echo 'ic_up_on.gif'; } else { echo 'ic_up.gif'; } ?>" width="11" height="12" alt="<?php echo SORT_UP; ?>" border="0" align=""></a><?php echo tep_draw_separator('pixel_blue.gif', '11', '8'); ?><a href="<?php echo tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'listing')).'listing=b-language-desc'); ?>"><img src="images/<?php if ($listing == 'b-language-desc') { echo 'ic_down_on.gif'; } else { echo 'ic_down.gif'; } ?>" width="11" height="12" alt="<?php echo SORT_DOWN; ?>" border="0" align=""></a> 
              </center>
              <?php echo TABLE_HEADING_BLANGUAGE; ?></td>
            <td valign="top" class="VisitorTableHeadingContent" align="center"><center>
                <a href="<?php echo tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'listing')).'listing=language-asc'); ?>"><img src="images/<?php if ($listing == 'language-asc') { echo 'ic_up_on.gif'; } else { echo 'ic_up.gif'; } ?>" width="11" height="12" alt="<?php echo SORT_UP; ?>" border="0" align=""></a><?php echo tep_draw_separator('pixel_blue.gif', '11', '8'); ?><a href="<?php echo tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'listing')).'listing=language-desc'); ?>"><img src="images/<?php if ($listing == 'language-desc') { echo 'ic_down_on.gif'; } else { echo 'ic_down.gif'; } ?>" width="11" height="12" alt="<?php echo SORT_DOWN; ?>" border="0" align=""></a> 
              </center>
              <?php echo TABLE_HEADING_LANGUAGE; ?></td>
            <td nowrap valign="top" class="VisitorTableHeadingContent" align="center"><center>
                <a href="<?php echo tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'listing')).'listing=referer-asc'); ?>"><img src="images/<?php if ($listing == 'referer-asc') { echo 'ic_up_on.gif'; } else { echo 'ic_up.gif'; } ?>" width="11" height="12" alt="<?php echo SORT_UP; ?>" border="0" align=""></a><?php echo tep_draw_separator('pixel_blue.gif', '11', '8'); ?><a href="<?php echo tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'listing')).'listing=referer-desc'); ?>"><img src="images/<?php if ($listing == 'referer-desc') { echo 'ic_down_on.gif'; } else { echo 'ic_down.gif'; } ?>" width="11" height="12" alt="<?php echo SORT_DOWN; ?>" border="0" align=""></a> 
              </center>
              <?php echo TABLE_HEADING_REFERER; ?></td>
            <td nowrap valign="top" class="VisitorTableHeadingContent" align="center"><center>
                <a href="<?php echo tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'listing')).'listing=uri-asc'); ?>"><img src="images/<?php if ($listing == 'uri-asc') { echo 'ic_up_on.gif'; } else { echo 'ic_up.gif'; } ?>" width="11" height="12" alt="<?php echo SORT_UP; ?>" border="0" align=""></a><?php echo tep_draw_separator('pixel_blue.gif', '11', '8'); ?><a href="<?php echo tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'listing')).'listing=uri-desc'); ?>"><img src="images/<?php if ($listing == 'uri-desc') { echo 'ic_down_on.gif'; } else { echo 'ic_down.gif'; } ?>" width="11" height="12" alt="<?php echo SORT_DOWN; ?>" border="0" align=""></a> 
              </center>
              <?php echo TABLE_HEADING_URI; ?></td>
          </tr>
          <?php
  $search = '';
  if ( ($HTTP_GET_VARS['search']) && (tep_not_null($HTTP_GET_VARS['search'])) ) {
      $keywords = tep_db_input(tep_db_prepare_input($HTTP_GET_VARS['search']));
      $search = "where (browser_id like '%" . $keywords . "%' or browser_language like '%" . $keywords . "%' or referer like '%" . $keywords . "%' or browser_ip like '%" . $keywords . "%' or uri like '%" . $keywords . "')";
      $order = str_replace('WHERE', 'AND', $order);
      $order1 = str_replace('WHERE', 'AND', $order1);
      $visitors_query_raw = "SELECT * from " . TABLE_VISITORS . " $search $order"; 
      $visitors_count_raw = "SELECT sum(counter) AS counter from " . TABLE_VISITORS . " $search $order1"; 
   } else {
      $visitors_query_raw = "SELECT * from " . TABLE_VISITORS . " $order"; 
      $visitors_count_raw = "SELECT sum(counter) AS counter from " . TABLE_VISITORS . " $order1"; 
    }
		  
  $visitors_count = tep_db_query($visitors_count_raw); 
  $case_count = tep_db_fetch_array($visitors_count); 
  
  $visitors_split = new splitPageResults($HTTP_GET_VARS['page'], MAX_VISITOR_RESULTS, $visitors_query_raw, $visitors_query_numrows); 
  $visitors_query = tep_db_query($visitors_query_raw); 
  $bgcolor = 'FFFFFF'; 
  $max_entry = '1';

  while ($visitors = tep_db_fetch_array($visitors_query)) { 

  $stats_table[] = array($visitors["browser_id"], $visitors["counter"]);
  $max_entry = MAX($visitors["counter"], $max_entry);

  if ($visitors['customers_id'] != '0'){
    $cResult = tep_db_query("select customers_firstname, customers_lastname from " . TABLE_CUSTOMERS . " where customers_id = '" . $visitors['customers_id'] . "'");
    $cName = tep_db_fetch_array($cResult);
    
	$visitor_query_string = "SELECT o.orders_id FROM " . TABLE_ORDERS . " o, " . TABLE_VISITORS . " v WHERE o.customers_id = v.customers_id AND o.customers_id = '" . $visitors['customers_id'] . "' AND (to_days(o.date_purchased) - to_days(v.date)) = 0 order by o.orders_id desc";
    $visitors_order_query = tep_db_query($visitor_query_string);
    
	if (tep_db_num_rows($visitors_order_query)){
      $visitors_order = tep_db_fetch_array($visitors_order_query);
      $customer_info_string = '<a href="' . tep_href_link(FILENAME_CUSTOMERS, 'selected_box=customers&search=' . $cName["customers_lastname"]) . '"><font color="#0000F">' . $cName["customers_firstname"] . '<br>' . $cName["customers_lastname"] . '</font></a><br><a href="' . tep_href_link(FILENAME_ORDERS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'oID', 'action')) . 'selected_box=customers&oID=' . $visitors_order['orders_id'] . '&action=edit') . '">' . tep_image_button('button_orders.gif', IMAGE_ORDERS) . '</a>';
    } else {
	 $customer_info_string = '<a href="' . tep_href_link(FILENAME_CUSTOMERS, 'selected_box=customers&search=' . $cName["customers_lastname"]) . '"><font color="#0000F">' . $cName["customers_firstname"] . '<br>' . $cName["customers_lastname"] . '</font></a>';
    }
  } else {
    $customer_info_string = '<font color="#808080">' . GUEST . '</font>';
  }
?>
          <tr bgcolor="<?php echo $bgcolor; ?>"> 
            <td class="VisitorTableContent" valign=\"top\"><?php echo $visitors["browser_id"]; ?></td>
              <td class="VisitorTableContent" valign=\"top\"> 
                <?php if(substr_count($visitors["browser_ip"], '.') != '3') { echo 'Invalid'; } else { echo '<a href="http://www.showmyip.com/?ip=' . $visitors["browser_ip"] . '" target="_blank"><font color="#0000FF">' . $visitors["browser_ip"] . '</font></a>'; } ?>
              </td>
            <td class="VisitorTableContent" align="center" valign=\"top\"> 
              <?php if ( (time() - strtotime($visitors["date"]) < 86400) ) { echo '<font color="#FF0000">' . tep_datetime_short($visitors["date"]) . '</font>';} else {echo tep_date_short($visitors["date"]);} ?>
            </td>
            <td class="VisitorTableContent" align="center" valign=\"top\"> 
              <?php if ( (time() - strtotime($visitors["online"]) < 86400) ) { echo '<font color="#FF0000">' . tep_datetime_short($visitors["online"]) . '</font>';} else {echo tep_date_short($visitors["online"]);} ?>
            </td>
            <td class="VisitorTableContent" align="center" valign=\"top\">
			<?php if ( (time() - strtotime($visitors["date"]) < 86400 * $trace_days) ) { 
			  echo '<font color="#0000FF">' . number_format($visitors["counter"]) . '</font><img src="images/pixel_trans.gif" width="10" height="25" alt="' . BOX_TITLE_TRACE . '" border="0" align="top">'; ?><?php if ( ($bFlag != $visitors["browser_ip"]) || ($tFlag != strtotime($visitors["date"])) ) { echo '<a href="' . tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip')).'trace_pop_up=action&trace_ip=' . $visitors["browser_ip"]) . '&trace_date=' . strtotime($visitors["date"]) . '">>>></a>'; } else { echo '<font color="#FF0000">>>></font>'; } '</td>';
			} else {
			  echo number_format($visitors["counter"]) . '</a></td>';
			} ?>
            <td class="VisitorTableContent" valign=\"center\"> 
              <?php if (strtotime($visitors["online"]) > strtotime($visitors["date"])) { echo date("H:i:s", mktime(0,0,(strtotime($visitors["online"]) - strtotime($visitors["date"])))); } else { echo '00:00:00'; }?>
            </td>
            <td class="VisitorTableContent" align="center" valign=\"top\"><?php echo $customer_info_string; ?></td>
            <td class="VisitorTableContent" valign=\"top\"><a href="javascript:void(0)" onMouseOver="window.status='<?php echo visitor_get_country_language($visitors["browser_language"]); ?>'; return true" onMouseOut="window.status=' '"><?php echo chunk_split($visitors["browser_language"],15,"<br>"); ?></a></td>
            <td class="VisitorTableContent" valign=\"top\"><?php echo $visitors["language"]; ?></td>
            <td class="VisitorTableContent" valign=\"top\"> 
              <?php if(substr($visitors["referer"],0,7) != 'http://') { echo TABLE_DIRECT; } else {echo '<a href="' . $visitors["referer"]; ?>
              " target="_blank"><font color="#0000FF"><?php echo chunk_split($visitors["referer"],26,"<br>"); ?></font></a> 
              <?php } ?>
            </td>
            <td class="VisitorTableContent" valign=\"top\"><?php echo '<a href="' . $visitors["uri"];?>" 
              target="_blank"><font color="#0000FF"> 
              <?php if($visitors["uri"] == '/') { echo TABLE_ROOT; } else { echo chunk_split($visitors["uri"],26,"<br>"); } ?></a> 
            </td>
          </tr>
          <?php 
    if ($bgcolor == 'FFFFFF'){$bgcolor = '99CCFF';} 
    else {$bgcolor = 'FFFFFF';} 
  } 
?>
        </table></td>
    </tr>
    <tr> 
      <td colspan="2"> <table border="0" width="100%" cellspacing="0" cellpadding="2">
          <tr> 
            <td class="smallText" valign="top"><?php echo $visitors_split->display_count($visitors_query_numrows, MAX_VISITOR_RESULTS, $HTTP_GET_VARS['page'], TEXT_DISPLAY_NUMBER_OF_ENTRIES); ?></td>
            <td align=left class="smallText"><?php echo TABLE_HEADING_FOOTER_COUNT . ' ' . number_format($case_count["counter"]); ?></td>
            <td class="smallText" align="right"><?php echo $visitors_split->display_links($visitors_query_numrows, MAX_VISITOR_RESULTS, MAX_DISPLAY_PAGE_LINKS, $HTTP_GET_VARS['page'], tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'page'))); ?></td>
          </tr>
        </table></td>
    </tr>
  </table></td>
</tr>
<tr> 
  <td colspan="2"><SCRIPT LANGUAGE="JavaScript1.2">
var g = new Graph(600,200);
g.addRow("<?php for ($i = 0; $i < MAX_VISITOR_RESULTS; $i++) {
  if ($stats_table[$i][1] == ""){
	echo '0","';
  } else {
	  echo $stats_table[$i][1] . '","';
  }
}
	echo '");';
?>
g.scale=<?php echo $max_entry/4; ?>;
g.setXScaleValues("<?php for ($i = 0; $i < MAX_VISITOR_RESULTS; $i++) {
  echo $stats_table[$i][0] . '","';
}
	echo '");';
?>
g.title = "<?php echo CHART_TITLE; ?>";
g.xLabel = "<?php echo CHART_X; ?>";
g.yLabel = "<?php echo CHART_Y; ?>";
g.setLegend("<?php echo TABLE_HEADING_TABLE; ?>");
g.build();
</SCRIPT> </td>
</tr>
<tr> 
  <td colspan="2" class="smallText"><div align="center"><a href="<?php echo tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip')).'selected_box=reports', 'NONSSL'); ?>#top"><font color="#0000FF"><?php echo TOP; ?></font></a></div></td>
</tr>
<tr> 
  <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '5', '5'); ?></td>
</tr>
<tr> 
  <td align=center class="menuBoxHeading"><hr> 
    <?php 
    echo '<table width=100% border="1"><tr><td align="center">';
    if ($show_charts == true) {
    echo '<table width=100% border="1">';

    echo '<tr bgcolor="FFFFFF"><td align="left"><a name="chart"></a><font color="#808080" size="1">&nbsp;</font></td>';
    echo '<td colspan=4><center><font color="#808080" size="1">' . STATISTICS_HEADING_X . '</font></center></td></tr>';

    echo '<tr bgcolor="99CCFF"><td align="left"><font color="#808080" size="1">' . STATISTICS_HEADING_Y . '</font></td>';
	echo '<td align="left"><font color="#808080" size="1">' . STATISTICS_HEADING_HOURS . '</font></td>';
	echo '<td align="left"><font color="#808080" size="1">' . STATISTICS_HEADING_DAYS . '</font></td>';
	echo '<td align="left"><font color="#808080" size="1">' . STATISTICS_HEADING_OTHER_DATE . '</font></td>';
	echo '<td align="left"><font color="#808080" size="1">' . STATISTICS_HEADING_OTHER_VALUE . '</font></td></tr>';
	
    echo '<tr bgcolor="FFFFFF"><td align="left"><font color="#808080" size="1">' . STATISTICS_TYPE_REPORT_A . '</font></td>';
    echo '<td><a href="' . tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'report')).'report=1', 'NONSSL') . '#chart" class="' . $chart1 . '"><font color="#0000FF">' . STATISTICS_TYPE_REPORT_1 .'</font></a></td>';
    echo '<td><a href="' . tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'report')).'report=2', 'NONSSL') . '#chart" class="' . $chart2 . '"><font color="#0000FF"><b>' . STATISTICS_TYPE_REPORT_2 .'</b></font></a></td>';
    echo '<td><a href="' . tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'report')).'report=3', 'NONSSL') . '#chart" class="' . $chart3 . '"><font color="#0000FF">' . STATISTICS_TYPE_REPORT_3 . '</font></a></td>';
    echo '<td><a href="' . tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'report')).'report=12', 'NONSSL') . '#chart" class="' . $chart12 . '"><font color="#008000">' . STATISTICS_TYPE_REPORT_12 . '</font></a></td></tr>';
	
    echo '<tr bgcolor="99CCFF"><td align="left"><font color="#808080" size="1">' . STATISTICS_TYPE_REPORT_B . '</font></td>';
	echo '<td><a href="' . tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'report')).'report=23', 'NONSSL') . '#chart" class="' . $chart23 . '"><font color="#0000FF">' . STATISTICS_TYPE_REPORT_23 .'</font></a></td>';
    echo '<td><a href="' . tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'report')).'report=24', 'NONSSL') . '#chart" class="' . $chart24 . '"><font color="#0000FF">' . STATISTICS_TYPE_REPORT_24 .'</font></a></td>';
    echo '<td><a href="' . tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'report')).'report=25', 'NONSSL') . '#chart" class="' . $chart25 . '"><font color="#0000FF">' . STATISTICS_TYPE_REPORT_25 . '</font></a></td>';
    echo '<td><a href="' . tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'report')).'report=8', 'NONSSL') . '#chart" class="' . $chart8 . '"><font color="#008000">' . STATISTICS_TYPE_REPORT_8 . '</font></a></td></tr>';

    echo '<tr bgcolor="FFFFFF"><td align="left"><font color="#808080" size="1">' . STATISTICS_TYPE_REPORT_A . '</font></td>';
	echo '<td><a href="' . tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'report')).'report=20', 'NONSSL') . '#chart" class="' . $chart20 . '"><font color="#0000FF">' . STATISTICS_TYPE_REPORT_20 .'</font></a></td>';
    echo '<td><a href="' . tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'report')).'report=43', 'NONSSL') . '#chart" class="' . $chart43 . '"><font color="#0000FF">' . STATISTICS_TYPE_REPORT_43 .'</font></a></td>';
    echo '<td><a href="' . tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'report')).'report=42', 'NONSSL') . '#chart" class="' . $chart42 . '"><font color="#0000FF">' . STATISTICS_TYPE_REPORT_42 . '</font></a></td>';
    echo '<td><a href="' . tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'report')).'report=13', 'NONSSL') . '#chart" class="' . $chart13 . '"><font color="#008000">' . STATISTICS_TYPE_REPORT_13 . '</font></a></td></tr>';

    echo '<tr bgcolor="99CCFF"><td align="left"><font color="#808080" size="1">' . STATISTICS_TYPE_REPORT_B . '</font></td>';
	echo '<td><a href="' . tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'report')).'report=29', 'NONSSL') . '#chart" class="' . $chart29 . '"><font color="#0000FF">' . STATISTICS_TYPE_REPORT_29 .'</font></a></td>';
    echo '<td><a href="' . tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'report')).'report=44', 'NONSSL') . '#chart" class="' . $chart44 . '"><font color="#0000FF">' . STATISTICS_TYPE_REPORT_44 .'</font></a></td>';
    echo '<td><a href="' . tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'report')).'report=45', 'NONSSL') . '#chart" class="' . $chart45 . '"><font color="#0000FF">' . STATISTICS_TYPE_REPORT_45 . '</font></a></td>';
    echo '<td><a href="' . tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'report')).'report=11', 'NONSSL') . '#chart" class="' . $chart11 . '"><font color="#008000">' . STATISTICS_TYPE_REPORT_11 . '</font></a></td></tr>';

	echo '<tr bgcolor="FFFFFF"><td align="left"><font color="#808080" size="1">' . STATISTICS_TYPE_REPORT_A . '</font></td>';
    echo '<td><a href="' . tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'report')).'report=21', 'NONSSL') . '#chart" class="' . $chart21 . '"><font color="#0000FF">' . STATISTICS_TYPE_REPORT_21 . '</font></a></td>';
    echo '<td><a href="' . tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'report')).'report=22', 'NONSSL') . '#chart" class="' . $chart22 . '"><font color="#0000FF">' . STATISTICS_TYPE_REPORT_22 .'</font></a></td>';
    echo '<td><a href="' . tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'report')).'report=37', 'NONSSL') . '#chart" class="' . $chart37 . '"><font color="#0000FF">' . STATISTICS_TYPE_REPORT_37 . '</font></a></td>';
    echo '<td><a href="' . tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'report')).'report=34', 'NONSSL') . '#chart" class="' . $chart34 . '"><font color="#008000">' . STATISTICS_TYPE_REPORT_34 . '</font></a></td></tr>';

	echo '<tr bgcolor="99CCFF"><td align="left"><font color="#808080" size="1">' . STATISTICS_TYPE_REPORT_B . '</font></td>';
    echo '<td><a href="' . tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'report')).'report=30', 'NONSSL') . '#chart" class="' . $chart30 . '"><font color="#0000FF">' . STATISTICS_TYPE_REPORT_30 . '</font></a></td>';
    echo '<td><a href="' . tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'report')).'report=31', 'NONSSL') . '#chart" class="' . $chart31 . '"><font color="#0000FF">' . STATISTICS_TYPE_REPORT_31 .'</font></a></td>';
	echo '<td><a href="' . tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'report')).'report=38', 'NONSSL') . '#chart" class="' . $chart38 . '"><font color="#0000FF">' . STATISTICS_TYPE_REPORT_38 .'</font></a></td>';
    echo '<td><a href="' . tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'report')).'report=9', 'NONSSL') . '#chart" class="' . $chart9 . '"><font color="#008000">' . STATISTICS_TYPE_REPORT_9 . '</font></a></td></tr>';

    echo '<tr bgcolor="FFFFFF"><td align="left"><font color="#808080" size="1">' . STATISTICS_TYPE_REPORT_A . '</font></td>';
    echo '<td><a href="' . tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'report')).'report=5', 'NONSSL') . '#chart" class="' . $chart5 . '"><font color="#FF0000">' . STATISTICS_TYPE_REPORT_5 . '</font></a></td>';
    echo '<td><a href="' . tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'report')).'report=35', 'NONSSL') . '#chart" class="' . $chart35 . '"><font color="#FF0000">' . STATISTICS_TYPE_REPORT_35 . '</font></a></td>';
    echo '<td><a href="' . tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'report')).'report=39', 'NONSSL') . '#chart" class="' . $chart39 . '"><font color="#FF0000">' . STATISTICS_TYPE_REPORT_39 . '</font></a></td>';
    echo '<td><a href="' . tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'report')).'report=32', 'NONSSL') . '#chart" class="' . $chart32 . '"><font color="#FF0000">' . STATISTICS_TYPE_REPORT_32 . '</font></a></td></tr>';

    echo '<tr bgcolor="99CCFF"><td align="left"><font color="#808080" size="1">' . STATISTICS_TYPE_REPORT_B . '</font></td>';
    echo '<td><a href="' . tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'report')).'report=27', 'NONSSL') . '#chart" class="' . $chart27 . '"><font color="#FF0000">' . STATISTICS_TYPE_REPORT_27 . '</font></a></td>';
	echo '<td><a href="' . tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'report')).'report=36', 'NONSSL') . '#chart" class="' . $chart36 . '"><font color="#FF0000">' . STATISTICS_TYPE_REPORT_36 .'</font></a></td>';
    echo '<td><a href="' . tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'report')).'report=40', 'NONSSL') . '#chart" class="' . $chart40 . '"><font color="#FF0000">' . STATISTICS_TYPE_REPORT_40 . '</font></a></td>';
    echo '<td><a href="' . tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'report')).'report=33', 'NONSSL') . '#chart" class="' . $chart33 . '"><font color="#FF0000">' . STATISTICS_TYPE_REPORT_33 . '</font></a></td></tr>';

    echo '<tr bgcolor="FFFFFF"><td align="left"><font color="#808080" size="1">' . STATISTICS_TYPE_REPORT_A . '</font></td>';
	echo '<td bgcolor="#CCCCCC">&nbsp;</td>';
    echo '<td><a href="' . tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'report')).'report=6', 'NONSSL') . '#chart" class="' . $chart6 . '"><font color="#FF0000">' . STATISTICS_TYPE_REPORT_6 .'</font></a></td>';
    echo '<td><a href="' . tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'report')).'report=4', 'NONSSL') . '#chart" class="' . $chart4 . '"><font color="#FF0000">' . STATISTICS_TYPE_REPORT_4 . '</font></a></td>';
    echo '<td><a href="' . tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'report')).'report=10', 'NONSSL') . '#chart" class="' . $chart10 . '"><font color="#FF0000">' . STATISTICS_TYPE_REPORT_10 . '</font></a></td></tr>';

    echo '<tr bgcolor="99CCFF"><td align="left"><font color="#808080" size="1">' . STATISTICS_TYPE_REPORT_B . '</font></td>';
	echo '<td><a href="' . tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'report')).'report=41', 'NONSSL') . '#chart" class="' . $chart41 . '"><font color="#FF0000">' . STATISTICS_TYPE_REPORT_41 .'</font></a></td>';
    echo '<td><a href="' . tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'report')).'report=28', 'NONSSL') . '#chart" class="' . $chart28 . '"><font color="#FF0000">' . STATISTICS_TYPE_REPORT_28 .'</font></a></td>';
    echo '<td><a href="' . tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'report')).'report=26', 'NONSSL') . '#chart" class="' . $chart26 . '"><font color="#FF0000">' . STATISTICS_TYPE_REPORT_26 . '</font></a></td>';
	echo '<td><a href="' . tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'report')).'report=7', 'NONSSL') . '#chart" class="' . $chart7 . '"><b><font color="#FFA500">' . STATISTICS_TYPE_REPORT_7 .'</font></b></a></td></tr></table>'; 
    } else {
    echo '<table width=100% border="1">';
    echo '<tr bgcolor="FFFFFF"><td align="left"><a href="' . tep_href_link(FILENAME_VISITORS, tep_get_all_get_params(array('trace_pop_up', 'trace_date', 'trace_ip', 'report')).'report=10', 'NONSSL') . '#chart" class="' . $chart10 . '"><font color="#FF0000">' . STATISTICS_TYPE_REPORT_10 . '</font></a></td></tr></table>'; 
	}
	?>
  </td>
</tr>
<tr> 
  <td> <SCRIPT LANGUAGE="JavaScript">
<!-- Begin
document.write('<form><input type=button value="<?php echo BUTTON_REFRESH_CHART; ?>" onClick="history.go()">&nbsp;&nbsp;&nbsp;<?php echo BUTTON_REFRESH_TEXT; ?></form>')
//  End -->
</script> </td>
</tr>
<tr> 
  <?php 
    if (($show_charts == true) || ($report > '9')){ 
     $heading = array(); 
      $contents = array(); 
      include(DIR_WS_INCLUDES . 'graphs/visitor_infobox.php'); 
     if ($report != '10') { 
         $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image(DIR_WS_IMAGES . 'graphs/visitor_infobox-' . $report . '.png')); 
     } 
     echo '            <td width="100%" valign="top">' . "\n"; 
      $box = new box; 
     $heading[] = array('align' => 'left', 'text' => CHART_BOX_TITLE); 
     echo $box->infoBox($heading, $contents); 
     if ($report == '10') { 
     $bgcolor = '99CCFF'; 
     ?><div align="center"><table border="0" width="50%" cellspacing="2" cellpadding="2">
  <tr> 
    <td width="75%" class="pageHeading"><center>
        <?php echo $title; ?></center></td>
    <td width="25%" class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
  </tr><tr>
  <td><table border="1" width="100%" cellspacing="0" cellpadding="2" class="VisitorTableBox">
      <tr class="dataTableHeadingRow"> 
        <td class="VisitorTableHeadingContent"><?php echo TABLE_HEADING_KEYWORD_NAME; ?></td>
        <td class="VisitorTableHeadingContent"><?php echo TABLE_HEADING_KEYWORD_NUMBER; ?></td>
      </tr>
      <?php for ($row = 0; $row < 50; $row++) { 
          echo '<tr bgcolor="#' . $bgcolor . '">'; 
          echo '<td class="VisitorTableContent">' . $terms_grouped[$row][0] . '&nbsp;</td>';  
          echo '<td class="VisitorTableContent">' . $terms_grouped[$row][1] . '&nbsp;</td>';  
          echo '</tr>'; 
          if ($bgcolor == 'FFFFFF'){$bgcolor = '99CCFF';} 
            else {$bgcolor = 'FFFFFF';} 
          } 
         echo '</table></td></tr></table></div>'; 
     } 
      echo '            </td>' . "\n"; 
    } 
    if ($show_charts == false){ 
      echo '            </tr><tr><td><br><div align="center"><font color="#FF0000"><b>Sorry, I am unable to draw the other Charts as imagecreate() is not available in your version of php (check to see if you have gd support) or you switched off chart display</b></font></div><br><br></td>' . "\n"; 
    } 
  ?></tr>
    </table>
    <!-- body_eof //-->
    <!-- footer //-->
    <?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
    <!-- footer_eof //-->
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>