HEX
Server: Apache/2.4.65 (Debian)
System: Linux srv39710 6.1.0-41-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.158-1 (2025-11-09) x86_64
User: root (0)
PHP: 8.4.11
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
Upload Files
File: /var/www/www-root/data/www/mowik.click/tds/files/source.php
<?php
if(!defined("INDEX")){header('HTTP/1.1 403 Forbidden'); die('403 Forbidden');}
$se_label = 0;
if($q == 'sources' && empty($d)){
	$db = new SQLite3($folder_log.'/'.$g_id.'.db');
	$db->busyTimeout($timeout_2);
	$db->exec("PRAGMA journal_mode = WAL;");
	$date = date('Y-m-d', $table);
	if($db->querySingle("SELECT name FROM sqlite_master WHERE type = 'table' AND name = '$table'")){
		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">';
		echo '<table id="example" class="cell-border display compact responsive" width="100%" cellspacing="0">
<thead>
<tr>
<th data-priority="1"></th>';
		foreach($col_source 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_source as $name => $v){
			echo "<th>$name</th>\n";
		}
		echo '</tr>
</tfoot>
<tbody>';
		if(empty($s)){
			$res = $db->query("SELECT * FROM '$table' WHERE bot = '$empty';");
			$st = '';
		}
		else{
			$res = $db->query("SELECT * FROM '$table' WHERE nstream = '$s_name' AND bot = '$empty';");
			$st = "&s=$s";
		}
		$a = array();
		while($array = $res->fetchArray(SQLITE3_ASSOC)){
			$domain = trim($array['domain']);
			if(!in_array($domain, $a)){
				$a[] = $array['domain'];
			}
		}
		if(!empty($a)){
			asort($a);
			foreach($a as $domain){
				$sources_profit = 0;
				if(!empty($s)){
					$query = "SELECT COUNT (*) FROM '$table' WHERE domain = '$domain' AND nstream = '$s_name' AND bot = '$empty'";
				}
				else{
					$query = "SELECT COUNT (*) FROM '$table' WHERE domain = '$domain' AND bot = '$empty'";
				}
				if(!empty($s)){
					$query_pb = "SELECT * FROM '$table' WHERE domain = '$domain' AND nstream = '$s_name' AND bot = '$empty';";
				}
				else{
					$query_pb = "SELECT * FROM '$table' WHERE domain = '$domain' AND bot = '$empty';";
				}
				$res = $db->query("$query_pb;");
				while($array = $res->fetchArray(SQLITE3_ASSOC)){
					if($array['postback'] != $empty){
						$sources_profit = $sources_profit + $array['postback'];
					}
				}
				if($sources_profit == 0){
					$sources_profit = $empty;
				}
				$sources_visitors = $db->querySingle("$query;");
				if($sources_visitors == 0){
					$sources_visitors = $empty;
				}
				$sources_unique = $db->querySingle("$query AND uniq = 'yes';");
				if($sources_unique == 0){
					$sources_unique = $empty;
				}
				$sources_se = $db->querySingle("$query AND se != '$empty' AND uniq = 'yes';");
				if($sources_se == 0){
					$sources_se = $empty;
				}
				else{
					$se_label = 1;
				}
				$sources_computers = $db->querySingle("$query AND device = 'computer' AND uniq = 'yes';");
				if($sources_computers == 0){
					$sources_computers = $empty;
				}
				$sources_tablets = $db->querySingle("$query AND device = 'tablet' AND uniq = 'yes';");
				if($sources_tablets == 0){
					$sources_tablets = $empty;
				}
				$sources_phones = $db->querySingle("$query AND device = 'phone' AND uniq = 'yes';");
				if($sources_phones == 0){
					$sources_phones = $empty;
				}
				$sources_wap = $db->querySingle("$query AND operator != '$empty' AND uniq = 'yes';");
				if($sources_wap == 0){
					$sources_wap = $empty;
				}
				$td = '<td></td>
<td class="stdicon"><a class="sicon" title="View" target="_blank" href="//'.$domain.'">&#10003;</a><a class="sicon" title="Log" href="'.$admin_page.'?q=log&g='.$g_id.$st.'&col=domain&find='.$domain.'&t='.$table.'">&#9783;</a><a class="sicon" title="Postback" href="'.$admin_page.'?q=pb&range=12&from='.$date.'&to='.$date.'&g='.$g_id.$st.'&d='.$domain.'">&#36;</a><a class="sicon" title="Config" href="'.$admin_page.'?q=conf&g='.$g_id.$st.'&d='.$domain.'">&#9998;</a><a class="slink" href="'.$admin_page.'?q=sources&g='.$g_id.$st.'&d='.$domain.'&t='.$table.'">'.$domain.'</a></td>
<td>'.$sources_visitors.'</td>
<td>'.$sources_unique.'</td>
<td>'.$sources_se.'</td>
<td>'.$sources_wap.'</td>
<td>'.$sources_computers.'</td>
<td>'.$sources_tablets.'</td>
<td>'.$sources_phones.'</td>
<td>'.$sources_profit.'</td>';
				echo '<tr align="center">'.$td.'</tr>';
			}
		}
		echo '</tbody>
</table>';
	}
	$db->close();
	$sort = 3;
	if($se_label == 1){
		$sort = 4;
	}
	echo '<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, 200, 300, 500, 1000 -1], [50, 100, 200, 300, 500, 1000, "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>';
}
if($q == 'sources' && !empty($d)){
	$db = new SQLite3($folder_log.'/'.$g_id.'.db');
	$db->busyTimeout($timeout_2);
	$db->exec("PRAGMA journal_mode = WAL;");
	$dt = '';
	$lp = $period_log;
	while(true){
		$table_temp = strtotime(date("Y-m-d", strtotime('-'.$lp.' day')));
		if($db->querySingle("SELECT name FROM sqlite_master WHERE type = 'table' AND name = '$table_temp';")){
			$dt = date('Y-m-d', $table_temp);
			$dt = explode("-", $dt);
			if(!empty($dt[2])){
				$dt = $dt[2];
			}
			else{
				$dt = date("d", strtotime('-'.$lp.' day'));
			}
			if(!empty($s)){
				$query = "SELECT COUNT (*) FROM '$table_temp' WHERE domain = '$d' AND nstream = '$s_name' AND bot = '$empty'";
			}
			else{
				$query = "SELECT COUNT (*) FROM '$table_temp' WHERE domain = '$d' AND bot = '$empty'";
			}
			$ch_visitors = $db->querySingle("$query;");
			$ch_hosts = $db->querySingle("$query AND uniq = 'yes';");
			$ch_wap = $db->querySingle("$query AND operator != '$empty' AND uniq = 'yes';");
			if($chart_bots == 1){
				if(!empty($s)){
					$ch_bots = $db->querySingle("SELECT COUNT (*) FROM '$table_temp' WHERE domain = '$d' AND nstream = '$s_name' AND bot != '$empty' AND uniq = 'yes';");
				}
				else{
					$ch_bots = $db->querySingle("SELECT COUNT (*) FROM '$table_temp' WHERE domain = '$d' AND bot != '$empty' AND uniq = 'yes';");
				}
			}
			else{
				$ch_bots = 0;
			}
			if(empty($dg_stats)){
				$dg_stats = '[\''.$dt.'\','.$ch_visitors.','.$ch_hosts.','.$ch_wap.','.$ch_bots.']';
			}
			else{
				$dg_stats = $dg_stats.',[\''.$dt.'\','.$ch_visitors.','.$ch_hosts.','.$ch_wap.','.$ch_bots.']';
			}
			if($charts['se'] == 1){
				$ch_google = $db->querySingle("$query AND se = 'google' AND uniq = 'yes';");
				$ch_yandex = $db->querySingle("$query AND se = 'yandex' AND uniq = 'yes';");
				$ch_mail = $db->querySingle("$query AND se = 'mail' AND uniq = 'yes';");
				$ch_yahoo = $db->querySingle("$query AND se = 'yahoo' AND uniq = 'yes';");
				$ch_bing = $db->querySingle("$query AND se = 'bing' AND uniq = 'yes';");
				$ch_baidu = $db->querySingle("$query AND se = 'baidu' AND uniq = 'yes';");
				if($ch_google != 0 || $ch_yandex != 0 || $ch_mail != 0 || $ch_yahoo != 0 || $ch_bing != 0 || $ch_baidu != 0){
					$ch_se_view = 1;
				}
				if(empty($dg_se)){
					$dg_se = '[\''.$dt.'\','.$ch_google.','.$ch_yandex.','.$ch_mail.','.$ch_yahoo.','.$ch_bing.','.$ch_baidu.']';
				}
				else{
					$dg_se = $dg_se.',[\''.$dt.'\','.$ch_google.','.$ch_yandex.','.$ch_mail.','.$ch_yahoo.','.$ch_bing.','.$ch_baidu.']';
				}
			}
		}
		else{
			if(empty($dg_stats)){
				$dg_stats = '[\''.date("d", strtotime('-'.$lp.' day')).'\',0,0,0,0]';
			}
			else{
				$dg_stats = $dg_stats.',[\''.date("d", strtotime('-'.$lp.' day')).'\',0,0,0,0]';
			}
			if(empty($dg_se)){
				$dg_se = '[\''.date("d", strtotime('-'.$lp.' day')).'\',0,0,0,0,0,0]';
			}
			else{
				$dg_se = $dg_se.',[\''.date("d", strtotime('-'.$lp.' day')).'\',0,0,0,0,0,0]';
			}
		}
		if($lp == 0){
			break;
		}
		$lp--;
	}
	if($charts['unique'] == 1){
		if(!empty($_GET['t'])){
			$table = $_GET['t'];
		}
		else{
			$table = $db->querySingle("SELECT name FROM sqlite_master WHERE type = 'table' ORDER BY name DESC;");
		}
		$ch_today = array();
		$date_today = $ch_time = date('Y-m-d', $table);
		if($db->querySingle("SELECT name FROM sqlite_master WHERE type = 'table' AND name = '$table';")){
			$ch_start = $table;
			$ch_time = '';
			$query = "SELECT COUNT (*) FROM '$table' WHERE domain = '$d' AND bot = '$empty'";
			while($ch_time != '00'){
				$ch_end = $ch_start + 3600;
				$ch_time = date('H', $ch_end);
				$ch_hosts_today = $db->querySingle("$query AND uniq = 'yes' AND strtotime >= $ch_start AND strtotime < $ch_end;");
				$ch_today[$ch_time] = $ch_hosts_today;
				$ch_start = $ch_end;
				if($ch_hosts_today != 0){
					$ch_unique_view = 1;
				}
			}
		}
		$ch_yesterday = array();
		$table_yesterday = $table - 86400;
		$date_yesterday = $ch_time = date('Y-m-d', $table_yesterday);
		if($db->querySingle("SELECT name FROM sqlite_master WHERE type = 'table' AND name = '$table_yesterday';")){
			$ch_start = $table_yesterday;
			$ch_time = '';
			$query = "SELECT COUNT (*) FROM '$table_yesterday' WHERE domain = '$d' AND bot = '$empty'";
			while($ch_time != '00'){
				$ch_end = $ch_start + 3600;
				$ch_time = date('H', $ch_end);
				$ch_hosts_yesterday = $db->querySingle("$query AND uniq = 'yes' AND strtotime >= $ch_start AND strtotime < $ch_end;");
				$ch_yesterday[$ch_time] = $ch_hosts_yesterday;
				$ch_start = $ch_end;
				if($ch_hosts_yesterday != 0){
					$ch_unique_view = 1;
				}
			}
		}
		$ch_t = array('01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','00');
		$h = date('H');
		foreach($ch_t as $v){
			if(!empty($ch_today[$v]) || ($table != strtotime(date("Y-m-d")) && isset($ch_today[$v]))){
				$x = $ch_today[$v];
				$x = ",$x";
			}
			else{
				if($v == '00' || $h < $v){
					$x = ',null';
				}
				else{
					$x = ',0';
				}
			}
			if(!empty($ch_yesterday[$v])){
				$y = $ch_yesterday[$v];
				$y = ",$y";
			}
			else{
				$y = ',0';
			}
			if(empty($dg_unique)){
				$dg_unique = '[\''.$v.'\''.$y.$x.']';
			}
			else{
				$dg_unique = $dg_unique.',[\''.$v.'\''.$y.$x.']';
			}
		}
	}
	echo '<div class="align_center h_auto indt_10">';
	if(!empty($s_name)){
		echo '<div class="align_center bold indt_10">'.$trans['group']['g2'].': '.$g_name.' | '.$trans['stream']['s1'].': '.$s_name.' | Domain: '.$d.'</div>';
		$ch_se_view = 0;
	}
	else{
		echo '<div class="align_center bold indt_10">'.$trans['group']['g2'].': '.$g_name.' | Domain: '.$d.'</div>';
	}
	echo '<div id="curve_chart_stats" class="chart indt_20"></div>';
	if($charts['se'] == 1 && $ch_se_view == 1){
		echo '<div id="curve_chart_se" class="chart indt_10"></div>';
	}
	if($charts['unique'] == 1 && $ch_unique_view == 1){
		echo '<div id="curve_chart_unique" class="chart indt_20"></div>';
	}
	echo '<div class="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>';
	if(empty($s)){
		$res = $db->query("SELECT * FROM '$table' WHERE bot = '$empty' AND domain = '$d'");
	}
	else{
		$res = $db->query("SELECT * FROM '$table' WHERE nstream = '$s_name' AND bot = '$empty' AND domain = '$d'");
	}
	$a = array();
	while($array = $res->fetchArray(SQLITE3_ASSOC)){
		$country = trim($array['country']);
		if(!in_array($country, $a)){
			$a[] = $array['country'];
		}
	}
	if(!empty($a)){
		asort($a);
		foreach($a as $country){
			if(!empty($s)){
				$query = "SELECT COUNT (*) FROM '$table' WHERE country = '$country' AND nstream = '$s_name' AND bot = '$empty' AND domain = '$d'";
			}
			else{
				$query = "SELECT COUNT (*) FROM '$table' WHERE country = '$country' AND bot = '$empty' AND domain = '$d'";
			}
			$countries_visitors = $db->querySingle("$query;");
			if($countries_visitors == 0){
				$countries_visitors = $empty;
			}
			$countries_uniq = $db->querySingle("$query AND uniq = 'yes';");
			if($countries_uniq == 0){
				$countries_uniq = $empty;
			}
			$countries_se = $db->querySingle("$query AND se != '$empty' AND uniq = 'yes';");
			if($countries_se == 0){
				$countries_se = $empty;
			}
			else{
				$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>
</div>
<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>';
}
?>