<?php
###############################################
#  by MaZaFaKa                                #
#  ICQ: 449-559                               #
#  E-mail: Dimonnet@inbox.ru                  #
#  Menghabiskan waktu: Sekitar 2 minggu         #
#  Translate by: jogerplay #
#  Situs: http://jogerwap.net #
###############################################

$id = (int) $_GET['id'];
$item = (isset($_GET['item'])) ? ($_GET['item']) : "index";

$sql = mysql_query("SELECT `status` FROM `".USERS."` WHERE `id` = ".$id.";");

   if(mysql_num_rows($sql) < 1)
   {   echo("User dengan ID = ".$id." tidak ditemukan di database.\n");
   $item = "default";
   }
   elseif(mysql_result($sql, 0) == "locked")
   {   echo("User dengan ID = ".$id." diblokir.\n");
   $item = "default";
   }

//ONLINE
$sql = mysql_query("SELECT COUNT(*) FROM `".ONLINE."` WHERE `user_id` = ".$id.";");
$is_online = mysql_result($sql, 0);

$sql = mysql_query("SELECT * FROM `".USERS."` WHERE `id` = ".$id.";");
$user = mysql_fetch_assoc($sql);

$user['url']=str_replace("http://","",$user['url']);


if(empty($_GET['item']))
{
$td_on = '<td style="color: #3366cc">&#149;</td><td><b>';
$b_off = '</b><td>';
}
else
{
$td_on = '<td> </td><td>';
}
//////
if($_GET['item']=='days')
{
$td_on2 = '<td style="color: #3366cc">&#149;</td><td><b>';
$b_off2 = '</b>';
}
else
{
$td_on2 = '<td> </td><td>';
}
//////
if($_GET['item']=='hours')
{
$td_on3 = '<td style="color: #3366cc">&#149;</td><td><b>';
$b_off3 = '</b>';
}
else
{
$td_on3 = '<td> </td><td>';
}
//////
if($_GET['item']=='online')
{
$td_on4 = '<td style="color: #3366cc">&#149;</td><td><b>';
$b_off4 = '</b>';
}
else
{
$td_on4 = '<td> </td><td>';
}
//////
if($_GET['item']=='operators')
{
$td_on5 = '<td style="color: #3366cc">&#149;</td><td><b>';
$b_off5 = '</b>';
}
else
{
$td_on5 = '<td> </td><td>';
}
//////
if($_GET['item']=='country')
{
$td_on6 = '<td style="color: #3366cc">&#149;</td><td><b>';
$b_off6 = '</b>';
}
else
{
$td_on6 = '<td> </td><td>';
}
//////
if($_GET['item']=='ip')
{
$td_on7 = '<td style="color: #3366cc">&#149;</td><td><b>';
$b_off7 = '</b>';
}
else
{
$td_on7 = '<td> </td><td>';
}
//////
if($_GET['item']=='brands')
{
$td_on8 = '<td style="color: #3366cc">&#149;</td><td><b>';
$b_off8 = '</b>';
}
else
{
$td_on8 = '<td> </td><td>';
}
//////
if($_GET['item']=='useragent')
{
$td_on9 = '<td style="color: #3366cc">&#149;</td><td><b>';
$b_off9 = '</b>';
}
else
{
$td_on9 = '<td> </td><td>';
}

print
('
<span style="color:#666666"><b>'.$user['url'].':</b></span><br/>
<table width="100%" border="0" cellspacing="0" cellpadding="2">
<tr><td colspan="2" height="5px"></td></tr>
<tr bgcolor="#cccccc"><td> </td><td style="color: #666666; bgcolor">Kehadiran</td></tr>
<tr>'.$td_on.'<a href="'.PATH.'/'.VERSION.'/info/'.$id.'">Ringkasan statistik</a>'.$b_off.'</td></tr>
<tr>'.$td_on2.'<a href="'.PATH.'/'.VERSION.'/info/'.$id.'?item=days">Kehadiran Harian</a>'.$b_off2.'</td></tr>
<tr>'.$td_on3.'<a href="'.PATH.'/'.VERSION.'/info/'.$id.'?item=hours">Kehadiran jam</a>'.$b_off3.'</td></tr>
<tr>'.$td_on4.'<a href="'.PATH.'/'.VERSION.'/info/'.$id.'?item=online">Online users</a>'.$b_off4.'</td></tr>
<tr><td colspan="2" height="5px"></td></tr>
<tr bgcolor="#cccccc"><td> </td><td style="color: #666666; bgcolor">Operator</td></tr>
<tr>'.$td_on5.'<a href="'.PATH.'/'.VERSION.'/info/'.$id.'?item=operators">Mobile operator</a>'.$b_off5.'</td></tr>
<tr>'.$td_on6.'<a href="'.PATH.'/'.VERSION.'/info/'.$id.'?item=country">Operator menurut negara</a>'.$b_off6.'</td></tr>
<tr>'.$td_on7.'<a href="'.PATH.'/'.VERSION.'/info/'.$id.'?item=ip">Operator IP</a>'.$b_off7.'</td></tr>
<tr><td colspan="2" height="5px"></td></tr>
<tr bgcolor="#cccccc"><td> </td><td style="color: #666666; bgcolor">Telepon</td></tr>
<tr>'.$td_on8.'<a href="'.PATH.'/'.VERSION.'/info/'.$id.'?item=brands">Model Telepon</a>'.$b_off8.'</td></tr>
<tr>'.$td_on9.'<a href="'.PATH.'/'.VERSION.'/info/'.$id.'?item=useragent">Browser</a>'.$b_off9.'</td></tr>
</table>
</td>
<td rowspan="2"> </td>
<td rowspan="2" width="100%">
');

switch($item)
{default:

print
('
<table width="555px" border="0" cellspacing="0" cellpadding="2">
<tr><td style="color: #666666">Jadwal Enterprise, '.date("d-m-Y", time()).'</td></tr>
</table>
');

print
('
<img src="/graph/info.php?id='.$id.'&amp;v=h" alt="">
');
print
('
<img src="/graph/info.php?id='.$id.'&amp;v=o" alt="">
');

print
('
<table width="100%" border="0" cellspacing="0" cellpadding="2">
<tr>
<td style="color: #666666">
Ringkasan untuk &laquo;<a href="'.PATH.'/'.VERSION.'/out/'.$id.'">'.$user['url'].'</a>&raquo<br />
</td>
</tr>
</table>
');

print
('
<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td bgcolor="#ff6600">
<table width="100%" border="0" cellspacing="1" cellpadding="0"><tr><td bgcolor="#ffffff">
<table width="100%" border="0" cellspacing="1" cellpadding="4">
<tr bgcolor="#cccccc">
<td width="40%">Indeks</td>
<td width="15%">Hari ini</td>
<td width="15%">Kemarin</td>
<td width="15%">Bulan ini</td>
<td width="15%">Total</td>
</tr>
<tr>
<td>Host*</td>
<td>'.$user['hosts'].'</td>
<td>'.$user['yday_hosts'].'</td>
<td>'.$user['month_hosts'].'</td>
<td>'.$user['all_hosts'].'</td>
</tr>
<tr bgcolor="#eeeeee">
<td>Hits</td>
<td>'.$user['hits'].'</td>
<td>'.$user['yday_hits'].'</td>
<td>'.$user['month_hits'].'</td>
<td>'.$user['all_hits'].'</td>
</tr>
<tr>
<td>Arahan dari peringkat situs</td>
<td>'.$user['out'].'</td>
<td>-</td>
<td>-</td>
<td>'.$user['all_out'].'</td>
</tr>
<tr bgcolor="#eeeeee">
<td>Arahan dari situs peringkat</td>
<td>'.$user['in'].'</td>
<td>-</td>
<td>-</td>
<td>'.$user['all_in'].'</td>
</tr>
</table>
</td></tr></table>
</td></tr></table>
<span style="color: #666666">* jumlah host yang unik pada semua situs platform.</span><br/><br/>
</td>
</tr>
<tr>
');



break;
///////////////////////////////////////////////////////////////////////////////////////////
case 'online':
$sql = mysql_query("SELECT COUNT(*) FROM `".ONLINE."` WHERE `user_id` = ".$id.";");
$count = mysql_result($sql, 0);

$page = (isset($_GET['page'])) ? intval($_GET['page']) : "0";
if($page < 0 || $page > $count) $page = 0;




print
('
<table width="555px" border="0" cellspacing="0" cellpadding="2">
<tr>
<td style="color: #666666">Jadwal pengguna online</td>
<td align="right" style="color: #666666">Total: '.$count.'</td>
</tr>
</table>
');

print
('
<table width="555px" border="0" cellspacing="0" cellpadding="0"><tr><td bgcolor="#ff6600">
<table width="100%" border="0" cellspacing="1" cellpadding="0"><tr><td bgcolor="#ffffff">
<table width="100%" border="0" cellspacing="1" cellpadding="4">
<tr bgcolor="#cccccc" align="center">
<td width="5%" style="color:#666666" nowrap><b>#</b></td>
<td width="25%" style="color:#666666" nowrap><b>Alamat</b></td>
<td width="25%" style="color:#666666" nowrap><b>Ip</b></td>
</tr>
');


//SELECT
$sql = mysql_query("SELECT `user-agent`, INET_NTOA(`ip`) as `ip` FROM `".ONLINE."` WHERE `user_id` = ".$id." ORDER BY `date` DESC LIMIT ".$page.", ".BIGPAGE.";");

   if(mysql_num_rows($sql) > 0)
   {
   $c = 1;

      while($online = mysql_fetch_assoc($sql))
      {
              $d = $c / 2;
                $d1 = ceil($d);
                $d2 = $d1 - $d;
                $d3 = ceil($d2);
                if ($d3 == 0)
                {
               $trs = ("<tr align=\"center\"  bgcolor=\"#dddddd\">");
                }
                else
                {
               $trs = ("<tr align=\"center\" bgcolor=\"#eeeeee\">");
                }


      echo("".$trs."<td>".$c."</td> <td>".$online['user-agent']."</td> <td>".$online['ip']."</td></tr>\n");
      $c++;
      }

   if(($count > ($page + BIGPAGE)) || ($page > 0)) echo("---<br />\n");
   if($count > ($page + BIGPAGE)) echo("<a href='".PATH."/".VERSION."/info/".$id."/?item=online&amp;page=".($page + BIGPAGE)."'>Lebih lanjut</a><br />\n");
   if($page > 0) echo("<a href='".PATH."/".VERSION."/info/".$id."/?item=online&amp;page=".($page - BIGPAGE)."'>Kembali</a><br />\n");
   }
   else
   {
   echo("<tr align=\"center\"  bgcolor=\"#dddddd\"><td>No</td> <td>Baris kosong</td> <td>System</td></tr>\n");
   }
print
('
</tr></table>
</td></tr></table>
</td></tr></table>
<table width="555px" border="0" cellspacing="2" cellpadding="0">
<tr>
<td align="right" nowrap><span style="color: #666666">2 menit terakhir</span></td>
</tr>
</table>
</td>
</tr>
');

break;
///////////////////////////////////////////////////////////////////////////////////////////
case 'hours':

print
('
<table width="555px" border="0" cellspacing="0" cellpadding="2">
<tr><td style="color: #666666">Jadwal kehadiran jam, '.date("d-m-Y", time()).'</td></tr>
</table>
');

print
('
<img src="/graph/hours.php?id='.$id.'" alt="">
');

print
('
<table width="555px" border="0" cellspacing="0" cellpadding="2">
<tr><td style="color: #666666">Daftar kehadiran jam, '.date("d-m-Y", time()).'</td></tr>
</table>
<table width="555px" border="0" cellspacing="0" cellpadding="0"><tr><td bgcolor="#ff6600">
<table width="100%" border="0" cellspacing="1" cellpadding="0"><tr><td bgcolor="#ffffff">
<table width="100%" border="0" cellspacing="1" cellpadding="4">
<tr bgcolor="#cccccc" align="center">
<td rowspan="1" width="25%" style="color:#666666" nowrap><b>Jam</b></td>
<td colspan="2" width="100%" style="color:#666666" nowrap><b>hits</b></td>
</tr>
');

for($i = 0; $i < 24; $i++)
{
$sql = mysql_query("SELECT SUM(`count`) as `count` FROM `".SHOWS."` WHERE `date` BETWEEN ".mktime($i, 0, 0, date("m"), date("d"), date("Y"))." AND ".mktime(($i + 1), 0, 0, date("m"), date("d"), date("Y"))." AND `user_id` = ".$id.";");

if(strlen($i) == 1) $i = "0".$i;
if(strlen($i + 1) == 1) $j = "0".($i + 1);
else $j = $i + 1;

echo("<tr bgcolor=\"#eeeeee\"><td>C ".$i.":00 ? ".($j).":00</td><td><center>".intval(mysql_result($sql, 0))."</center></td></tr>\n");
}

print
('
</table>
</table>
</table>
<span style="color: #666666;">* dalam kolom &laquo;Sejak awal hari&raquo; menunjukkan meningkatnya jumlah penghuni dan hits.</span><br/>
</td>
');


break;
/////////////////////////////////////////////////////////////////////////////////////////////
case 'days':
//ARRAY
$array_month = array("1" => "Januari", "2" => "Februari", "3" => "Maret", "4" => "April", "5" => "Mei", "6" => "Juni", "7" => "Juli", "8" => "Agustus", "9" => "September", "10" => "Oktober", "11" => "November", "12" => "Desember");
$array_year = array("2007" => "2007", "2008" => "2008");
//MONTH
$month = (int) $_POST['month'];
if(empty($month) || $month < 1 || $month > 12) $month = date("m");
//YEAR
$year = (int) $_POST['year'];
if(empty($year) || $year < 2007 || $year > 2008) $year = 2008;
print
('
<table width="555px" border="0" cellspacing="0" cellpadding="0"><tr><td bgcolor="#ff6600">
<table width="100%" border="0" cellspacing="1" cellpadding="0"><tr><td bgcolor="#ffffff">
<table width="100%" border="0" cellspacing="1" cellpadding="1">
<tr bgcolor="#cccccc"><td align="center"> <span style="color:#333366">Periode Pengiriman Statistik</span></td><tr>
');
echo
(
"<tr><td><center><form action='".PATH."/".VERSION."/info/".$id."/?item=days&amp;".SESSION."' method='post'>\n".
"<select name='month'>\n");

   foreach($array_month as $key => $value)
   {
   if($key == $month) echo("<option value='".$key."' selected='selected'>".$value."</option>\n");
   else echo("<option value='".$key."'>".$value."</option>\n");
   }

echo
(
"</select>\n".
"<select name='year'>\n");

   foreach($array_year as $key => $value)
   {
   if($key == $year) echo("<option value='".$key."' selected='selected'>".$value."</option>\n");
   else echo("<option value='".$key."'>".$value."</option>\n");
   }

echo
(
"</select>\n".
"<input type='submit' value='Melihat' />\n".
"</form>\n".
"</table>\n".
"</td></tr></table>\n".
"</td></tr></table></center>\n");

print
('
<table width="555px" border="0" cellspacing="0" cellpadding="2">
<tr><td style="color: #666666">Kehadiran Harian,  '.$_POST['month'].'-'.$_POST['year'].'</td></tr>
</table>

<table width="555px" border="0" cellspacing="0" cellpadding="0"><tr><td bgcolor="#ff6600">
<table width="100%" border="0" cellspacing="1" cellpadding="0"><tr><td bgcolor="#ffffff">
<table width="100%" border="0" cellspacing="1" cellpadding="4">
<tr bgcolor="#cccccc" align="center">
<td rowspan="2" width="50%" style="color:#666666"><b>Tanggal</b></td>
<td colspan="2" style="color:#666666"><b>Kehadiran</b></td>
</tr>
<tr bgcolor="#cccccc" align="center">
<td width="25%" style="color:#666666"><b>Host</b></td>
<td width="25%" style="color:#666666"><b>Hits</b></td>
</tr>
');


if($year == 2007) $sql = mysql_query("SELECT `hosts`, `hits`, `date` FROM `".STATS_DAY."` WHERE `date` BETWEEN '2007-".$month."-1' AND '2007-".$month."-31' AND `id` = ".$id." ORDER BY `date`;");
else $sql = mysql_query("SELECT `hosts`, `hits`, `date` FROM `".STATS_DAY_2008."` WHERE `date` BETWEEN '2008-".$month."-1' AND '2008-".$month."-31' AND `id` = ".$id." ORDER BY `date`;");

   if(mysql_num_rows($sql) > 0)
   {
      while($st = mysql_fetch_assoc($sql))
      {
      $date = explode("-", $st['date']);
      $date = $date[2].".".$date[1];

                $d = $date[1] / 2;
                $d1 = ceil($d);
                $d2 = $d1 - $d;
                $d3 = ceil($d2);
                if ($d3 == 0)
                {
               $trs = ("<tr bgcolor=\"#dddddd\">");
                }
                else
                {
               $trs = ("<tr bgcolor=\"#eeeeee\">");
                }


      echo("".$trs."<td>".$date."</td><td>".$st['hosts']."</td><td>".$st['hits']."</td></tr>\n");
      }
   }
   else
   {
   echo("".$trs."<td>Statistik Belum ada !</td><td>-</td><td>-</td></tr>\n");
   }

print
('
</table>
</td></tr></table>
</td></tr></table>
</td>
</tr>
');

break;
//////////////////////////////////////////////////////////////////////////////////////////////
case 'ip':

print
('
<table width="555px" border="0" cellspacing="0" cellpadding="2">
<td width="100%" style="color: #666666">Mobile IP, '.date("d-m-Y", time()).'</span></td>
</table>
');

print
('
<table width="555px" border="0" cellspacing="0" cellpadding="0"><tr><td bgcolor="#ff6600">
<table width="100%" border="0" cellspacing="1" cellpadding="0"><tr><td bgcolor="#ffffff">
<table width="100%" border="0" cellspacing="1" cellpadding="4">
<tr bgcolor="#cccccc" align="center">
<td rowspan="1" style="color: #666666"> <b>Alamat IP</b> </td>
<td colspan="1" style="color: #666666"> <b>Proporsi hits, %</b> </td>
<td rowspan="1" style="color: #666666"> <b>Hits</b> </td>
');

$sql = mysql_query("SELECT SUM(`count`) FROM `".SHOWS."` WHERE `user_id` = ".$id.";");
$all = mysql_result($sql, 0);

$sql = mysql_query("SELECT COUNT(DISTINCT `ip`) FROM `".SHOWS."` WHERE `user_id` = ".$id.";");
$count = mysql_result($sql, 0);

$page = (isset($_GET['page'])) ? intval($_GET['page']) : "0";
if($page < 0 || $page > $count) $page = 0;

$sql = mysql_query("SELECT DISTINCT INET_NTOA(`ip`) as `ip`, SUM(`count`) AS `count` FROM `".SHOWS."` WHERE `user_id` = ".$id." GROUP BY `ip` ORDER BY 2 DESC LIMIT ".$page.", 30;");

   if(mysql_num_rows($sql) > 0)
   {
      while($stat = mysql_fetch_assoc($sql))
      {
                     $sk = ($stat['count'] / $all) * 100;

              $d = $c / 2;
                $d1 = ceil($d);
                $d2 = $d1 - $d;
                $d3 = ceil($d2);
                if ($d3 == 0)
                {
               $trs = ("<tr align=\"center\"  bgcolor=\"#dddddd\">");
                }
                else
                {
               $trs = ("<tr align=\"center\" bgcolor=\"#eeeeee\">");
                }


      echo("".$trs."<td>&nbsp ".$stat['ip']."</td><td>".round($sk, 2)."%</td><td>".$stat['count']."</td></tr>\n");
         $c++;
      }




   if($page > 0) echo("<td><a class=\"scr\" href='".PATH."/".VERSION."/info/".$id."/?item=ip&amp;page=".($page - BIGPAGE)."'>Kembali</a></td>\n");
   if($count > ($page + BIGPAGE)) echo("<td><a class=\"scr\" href='".PATH."/".VERSION."/info/".$id."/?item=ip&amp;page=".($page + BIGPAGE)."'>Lebih lanjut</a></td>\n");
   }
   else
   {
   echo("<tr align=\"center\"  bgcolor=\"#dddddd\"><td> IP tidak terdeteksi </td><td>Not</td><td>Not</td></tr>\n");
   }


print
('
</table>
</td></tr></table>
</td></tr></table>
</td>
</tr>
');

break;
///////////////////////////////////////////////////////////////////////////////////////////////////////////
case 'brands':
print
('
<table width="555px" border="0" cellspacing="0" cellpadding="2">
<td width="100%" style="color: #666666">Model Handset, '.date("d-m-Y", time()).'</span></td>
</table>
');

print
('
<table width="555px" border="0" cellspacing="0" cellpadding="0"><tr><td bgcolor="#ff6600">
<table width="100%" border="0" cellspacing="1" cellpadding="0"><tr><td bgcolor="#ffffff">
<table width="100%" border="0" cellspacing="1" cellpadding="4">
<tr bgcolor="#cccccc" align="center">
<td style="color: #666666"> <b>Modul<br/></b> </td>
<td style="color: #666666"> <b>Proporsi hits, %</b> </td>
<td style="color: #666666"> <b>Hits</b> </td>
</tr>
');

$array_ua = array
(
2 => "SonyEricsson",
3 => "Nokia",
4 => "Samsung",
5 => "Siemens",
6 => "Motorola",
7 => "Lg",
8 => "Sagem",
9 => "Opera",
10 => "Panasonic",
11 => "Fly",
12 => "Sharp",
13 => "Philips",
14 => "Alcatel",
15 => "Komputer",
1 => "Lainnya"
);

$sql = mysql_query("SELECT SUM(`count`) FROM `".SHOWS."` WHERE `user_id` = ".$id.";");
$all = mysql_result($sql, 0);

$sql = mysql_query("SELECT DISTINCT `brand`, SUM(`count`) AS `count` FROM `".SHOWS."` WHERE `user_id` = ".$id." GROUP BY `brand` ORDER BY 2 DESC;");

   if(mysql_num_rows($sql) > 0)
   {
      while($stat = mysql_fetch_assoc($sql))
      {


             $d = $c / 2;
                $d1 = ceil($d);
                $d2 = $d1 - $d;
                $d3 = ceil($d2);
                if ($d3 == 0)
                {
               $trs = ("<tr align=\"center\"  bgcolor=\"#dddddd\">");
                }
                else
                {
               $trs = ("<tr align=\"center\" bgcolor=\"#eeeeee\">");
                }


      $sk = ($stat['count'] / $all) * 100;
      echo("".$trs."<td>".$array_ua[$stat['brand']]."</td><td>".round($sk, 2)."%</td><td>".$stat['count']." </td></tr>\n");
         $c++;

      }
   }
   else
   {
   echo("<tr align=\"center\"  bgcolor=\"#dddddd\"><td> Model telepon tidak terdeteksi</td><td>Not</td><td>Not</td></tr>\n");
   }
print
('
</table>
</td></tr></table>
</td></tr></table>
</td>
</tr>
');

break;
////////////////////////////////////////////////////////////////////////////////////////////////////////////
case 'useragent':

print
('
<table width="555px" border="0" cellspacing="0" cellpadding="2">
<td width="100%" style="color: #666666"> model handset, '.date("d-m-Y", time()).'</span></td>
</table>
');

print
('
<table width="555px" border="0" cellspacing="0" cellpadding="0"><tr><td bgcolor="#ff6600">
<table width="100%" border="0" cellspacing="1" cellpadding="0"><tr><td bgcolor="#ffffff">
<table width="100%" border="0" cellspacing="1" cellpadding="4">
<tr bgcolor="#cccccc" align="center">
<td style="color: #666666"> <b>User-agent<br/></b> </td>
<td style="color: #666666"> <b>Proporsi hits, %</b> </td>
<td style="color: #666666"> <b>Hits</b> </td>
</tr>
');

$sql = mysql_query("SELECT SUM(`count`) FROM `".SHOWS."` WHERE `user_id` = ".$id.";");
$all = mysql_result($sql, 0);

$sql = mysql_query("SELECT COUNT(DISTINCT `user-agent`) FROM `".SHOWS."` WHERE `user_id` = ".$id.";");
$count = mysql_result($sql, 0);

$page = (isset($_GET['page'])) ? intval($_GET['page']) : "0";
if($page < 0 || $page > $count) $page = 0;

$sql = mysql_query("SELECT DISTINCT `user-agent`, SUM(`count`) AS `count` FROM `".SHOWS."` WHERE `user_id` = ".$id." GROUP BY `user-agent` ORDER BY 2 DESC LIMIT ".$page.", 30;");

   if(mysql_num_rows($sql) > 0)
   {
      while($stat = mysql_fetch_assoc($sql))
      {

             $d = $c / 2;
                $d1 = ceil($d);
                $d2 = $d1 - $d;
                $d3 = ceil($d2);
                if ($d3 == 0)
                {
               $trs = ("<tr align=\"center\"  bgcolor=\"#dddddd\">");
                }
                else
                {
               $trs = ("<tr align=\"center\" bgcolor=\"#eeeeee\">");
                }


      $sk = ($stat['count'] / $all) * 100;
      echo("".$trs."<td>".$stat['user-agent']."</td><td>".round($sk, 2)."%</td><td>".$stat['count']." </td></tr>\n");
         $c++;




      }

   if($page > 0) echo("<td><a class=\"scr\" href='".PATH."/".VERSION."/info/".$id."/?item=useragent&amp;page=".($page - BIGPAGE)."'>Kembali</a></td>\n");
   if($count > ($page + BIGPAGE)) echo("<td><a class=\"scr\" href='".PATH."/".VERSION."/info/".$id."/?item=useragent&amp;page=".($page + BIGPAGE)."'>Lebih lanjut</a></td>\n");
   }
   else
   {
   echo("<tr align=\"center\"  bgcolor=\"#dddddd\"><td> Statistik User-agent tidak ditemukan ! </td><td>Not</td><td>Not</td></tr>\n");
   }

print
('
</table>
</td></tr></table>
</td></tr></table>
</td>
</tr>
');

break;
//////////////////////////////////////////////////////////////////////////////////////////////////
case 'operators':

print
('
<table width="555px" border="0" cellspacing="0" cellpadding="2">
<td width="100%" style="color: #666666">Operator mobile, '.date("d-m-Y", time()).'</span></td>
<td nowrap align="right">Operator | <a href="'.PATH.'/'.VERSION.'/info/'.$id.'?item=country">negara</a></td>
</table>
');

print
('
<table width="555px" border="0" cellspacing="0" cellpadding="0"><tr><td bgcolor="#ff6600">
<table width="100%" border="0" cellspacing="1" cellpadding="0"><tr><td bgcolor="#ffffff">
<table width="100%" border="0" cellspacing="1" cellpadding="4">
<tr bgcolor="#cccccc" align="center">
<td rowspan="1" style="color: #666666"> <b>Operator / Negara</b> </td>
<td colspan="1" style="color: #666666"> <b>Proporsi hits, %</b> </td>
<td rowspan="1" style="color: #666666"> <b>Hits</b> </td>
');

$sql = mysql_query("SELECT SUM(`count`) FROM `".SHOWS."` WHERE `user_id` = ".$id.";");
$all = mysql_result($sql, 0);

$sql = mysql_query("SELECT DISTINCT `".SHOWS."`.`operator`, SUM(`".SHOWS."`.`count`) AS `count`, `".IP_NAME."`.`name` as `name` FROM `".SHOWS."`, `".IP_NAME."` WHERE `".SHOWS."`.`user_id` = ".$id." AND `".SHOWS."`.`operator` = `".IP_NAME."`.`id` GROUP BY `".SHOWS."`.`operator` ORDER BY 2 DESC;");

   if(mysql_num_rows($sql) > 0)
   {

      while($stat = mysql_fetch_assoc($sql))
      {

                $sk = ($stat['count'] / $all) * 100;

              $d = $c / 2;
                $d1 = ceil($d);
                $d2 = $d1 - $d;
                $d3 = ceil($d2);
                if ($d3 == 0)
                {
               $trs = ("<tr align=\"center\"  bgcolor=\"#dddddd\">");
                }
                else
                {
               $trs = ("<tr align=\"center\" bgcolor=\"#eeeeee\">");
                }


      echo("".$trs."<td>&nbsp ".$stat['name']."</td><td>".round($sk, 2)."%</td><td>".$stat['count']."</td></tr>\n");

          $c++;


      }


   }
   else
   {
   echo("<tr align=\"center\"  bgcolor=\"#dddddd\"><td> Operator tidak terdeteksi !</td><td>Not</td><td>Not</td></tr>\n");
   }

print
('
</table>
</td></tr></table>
</td></tr></table>
</td>
</tr>
');

break;

case 'country':
print
('
<table width="555px" border="0" cellspacing="0" cellpadding="2">
<td width="100%" style="color: #666666">Operator menurut negara, '.date("d-m-Y", time()).'</span></td>
<td nowrap align="right"><a href="'.PATH.'/'.VERSION.'/info/'.$id.'?item=operators">Operator</a> | negara</td>
</tr>
</table>
');

print
('
<table width="555px" border="0" cellspacing="0" cellpadding="0"><tr><td bgcolor="#ff6600">
<table width="100%" border="0" cellspacing="1" cellpadding="0"><tr><td bgcolor="#ffffff">
<table width="100%" border="0" cellspacing="1" cellpadding="4">
<tr bgcolor="#cccccc" align="center">
<td style="color: #666666"> <b>Negara</b> </td>
<td style="color: #666666"> <b>Proporsi hits, %</b> </td>
<td style="color: #666666"> <b>Hits</b> </td>
</tr>
');

$sql = mysql_query("SELECT SUM(`count`) FROM `".SHOWS."` WHERE `user_id` = ".$id.";");
$all = mysql_result($sql, 0);

$sql = mysql_query("SELECT DISTINCT `".IP_COUNTRY."`.`id`, SUM(`".SHOWS."`.`count`) AS `count`, `".IP_COUNTRY."`.`name` as `name` FROM `".SHOWS."`, `".IP_COUNTRY."`, `".IP_NAME."` WHERE `".SHOWS."`.`user_id` = ".$id." AND `".SHOWS."`.`operator` = `".IP_NAME."`.`id` AND `".IP_COUNTRY."`.`id` = `".IP_NAME."`.`country` GROUP BY `".IP_COUNTRY."`.`id` ORDER BY 2 DESC;") or print(mysql_error());

   if(mysql_num_rows($sql) > 0)
   {
      while($stat = mysql_fetch_assoc($sql))
      {


                $sk = ($stat['count'] / $all) * 100;

              $d = $c / 2;
                $d1 = ceil($d);
                $d2 = $d1 - $d;
                $d3 = ceil($d2);
                if ($d3 == 0)
                {
               $trs = ("<tr align=\"center\"  bgcolor=\"#dddddd\">");
                }
                else
                {
               $trs = ("<tr align=\"center\" bgcolor=\"#eeeeee\">");
                }


      echo("".$trs."<td>&nbsp ".$stat['name']."</td><td>".round($sk, 2)."%</td><td>".$stat['count']."</td></tr>\n");

          $c++;


      }
   }
   else
   {
   echo("<tr align=\"center\"  bgcolor=\"#dddddd\"><td> Statistik teridentifikasi !</td><td>Not</td><td>Not</td></tr>\n");
   }

print
('
</table>
</td></tr></table>
</td></tr></table>
</td>
</tr>
');

break;

case 'default':
//LOCKED OR NOT FOUND
break;
}
?>