| Current Path : /home/seto/tdsbs.com/v9/files/ |
| Current File : /home/seto/tdsbs.com/v9/files/country.php |
<?php
if(!defined('INDEX')){header('HTTP/1.1 403 Forbidden'); die('403 Forbidden');}
if($q == 'countries' && !empty($g_id) && file_exists($folder_log.'/'.$g_id.'.db')){
$db = new SQLite3($folder_log.'/'.$g_id.'.db');
$db->busyTimeout($timeout_2);
$db->exec('PRAGMA journal_mode = WAL;');
$se_label = 0;
if(!empty($s_name)){
echo '<div class="align_center bold indt_10">'.$trans['group']['g2'].': '.$g_name.' | '.$trans['stream']['s1'].': '.$s_name.'</div>';
}
else{
echo '<div class="align_center bold indt_10">'.$trans['group']['g2'].': '.$g_name.'</div>';
}
echo '<div class="align_center h_auto indt_20 indb_10">
<table id="example" class="cell-border display compact responsive" width="100%" cellspacing="0">
<thead>
<tr>
<th data-priority="1"></th>';
foreach($col_country as $name => $v){
$v_ex = explode(':', $v);
if($v_ex[0] == 0){
$dtclass = ' class="none"';
}
if($v_ex[0] == 1){
$dtclass = '';
}
$dp = 'data-priority="'.$v_ex[1].'"';
echo "<th $dp$dtclass>$name</th>\n";
}
echo '</tr>
</thead>
<tfoot>
<tr>
<th data-priority="1"></th>';
foreach($col_country as $name => $v){
echo "<th>$name</th>\n";
}
echo '</tr>
</tfoot>
<tbody>';
$country_res = array();
foreach($country_arr as $country){
$country_res[$country] = array(0,0,0);
}
foreach($all_tables as $table_temp){
foreach($country_arr as $country){
if(!empty($s)){
$query = "SELECT COUNT (*) FROM '$table_temp' WHERE country = '$country' AND nstream = '$s_name' AND bot = '$empty'";
}
else{
$query = "SELECT COUNT (*) FROM '$table_temp' WHERE country = '$country' AND bot = '$empty'";
}
$visitors = $db->querySingle("$query;");
$uniq = $db->querySingle("$query AND uniq = 'yes';");
$se = $db->querySingle("$query AND se != '$empty' AND uniq = 'yes';");
$country_res[$country][0] = $country_res[$country][0] + $visitors;
$country_res[$country][1] = $country_res[$country][1] + $uniq;
$country_res[$country][2] = $country_res[$country][2] + $se;
}
}
foreach($country_res as $country => $v){
if(!empty($v[0]) || !empty($v[1]) || !empty($v[2])){
if($v[0] == 0){
$countries_visitors = $empty;
}
else{
$countries_visitors = $v[0];
}
if($v[1] == 0){
$countries_uniq = $empty;
}
else{
$countries_uniq = $v[1];
}
if($v[2] == 0){
$countries_se = $empty;
}
else{
$countries_se = $v[2];
$se_label = 1;
}
country_names($country);
if($country != $empty){
$country = '<span class="flag"><img src="files/img/flags/'.$country.'.png"></span><span class="flag"> '.strtoupper($country).'</span>';
}
$td = '<td></td>
<td title="'.$cn.'">'.$country.'</td>
<td>'.$countries_visitors.'</td>
<td>'.$countries_uniq.'</td>
<td>'.$countries_se.'</td>';
echo '<tr align="center">'.$td.'</tr>';
}
}
$db->close();
$sort = 3;
if($se_label == 1){
$sort = 4;
}
echo '</tbody>
</table>
<script type="text/javascript" class="init">
$(document).ready(function(){
var t = $("#example").DataTable({
"paging":true,
"searching":false,
"info":false,
"ordering":true,
"order":[['.$sort.', "desc"]],
"lengthMenu":[[50, 100, -1], [50, 100, "All"]],
"pageLength":50,
"language":{
"thousands":"",
"paginate":{
"first":"First",
"last":"Last",
"next":"Next",
"previous":"Prev"
},
},
},
{
"columnDefs":[{
"searchable":false,
"orderable":false,
"targets":0
}],
"order":[[1, "asc"]]
});
t.on("order.dt search.dt", function(){
t.column(0, {search:"applied", order:"applied"}).nodes().each(function(cell, i){
cell.innerHTML = i+1;
});
}).draw();
});
</script>
</div>';
}
?>