%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /var/www_old/
Upload File :
Create Path :
Current File : //var/www_old/domaincount.php__b81eaf3

<?php 
error_reporting(0);

function cmp($a, $b)
{
	return $a->cnt < $b->cnt ? 1 : 0;
}
function fsize($size)
{
	$jedn = array("bytes", "Kbytes", "Mbytes", "Gbytes", "Tbytes", "Pbytes");
	//$size = filesize($name);
	$i = 0;
	while($size > 1023)
	{
		$size /= 1024;
		$i++;
	}
	return sprintf("%0.2f %s", $size, $jedn[$i]);
}

ob_start();
if(isset($_GET['today'])) 
{
/*	echo "<html><head><title>DomainCount</title></head><body>";
	passthru("time mysql --user=waritko --password=blade666 --database=\"waritko_utils\" -e \"select distinct vhost, count(1) cnt, sum(bytes_in)/(1024*1024) data_in, sum(bytes_out)/(1024*1024) data_out, (sum(bytes_in)+sum(bytes_out))/(1024*1024) data from httplog where date > '".date("Y-m-d", time() - 3600*4.5)." 04:30:00' group by vhost order by cnt desc\" -H -vvv | tidy -i -w 120 -q");
	passthru("time mysql --user=waritko --password=blade666 --database=\"waritko_utils\" -e \"select distinct cipher, count(1) cnt, sum(bytes_in)/(1024*1024) data_in, sum(bytes_out)/(1024*1024) data_out, (sum(bytes_in)+sum(bytes_out))/(1024*1024) data from httplog where date > '".date("Y-m-d", time() - 3600*4.5)." 04:30:00' group by cipher order by cnt desc\" -H -vvv | tidy -i -w 120 -q");
	echo "</body></html>";*/
	$f = popen("cat /var/log/nginx/access_main.log | cut -d ' ' -f 1,9,10", "r");
	$vh = array();

	while(!feof($f))
	{
		$line = fgets($f);
		list($host, $out, $in) = explode(" ", $line);
		if(!isset($vh[$host]))
		{
			$vh[$host] = new stdClass();
			$vh[$host]->in = $in;
			$vh[$host]->out = $out;
			$vh[$host]->cnt = 1;
			$vh[$host]->host = $host;
		}
		else
		{
			$vh[$host]->in += $in;
			$vh[$host]->out += $out;
			$vh[$host]->cnt += 1;
		}
	}
	pclose($f);
	usort($vh, 'cmp');
	//echo "<pre>"; print_r($vh); echo "</pre>";
?><table border="1">
	<tr>
		<th>Host</th>
		<th>Requests</th>
		<th>Sent</th>
		<th>Received</th>
	</tr>
	<?php foreach($vh as $v) { ?><tr>
		<td><?php echo $v->host; ?></td>
		<td><?php echo $v->cnt; ?></td>
		<td><?php echo fsize($v->out); ?></td>
		<td><?php echo fsize($v->in); ?></td>
	</tr><?php echo "\n"; } ?>
</table><?php
	echo "<hr><pre>"; passthru('cat /var/log/nginx/access_main.log | grep dns.varak.net | cut -d " " -f 16 | sort | uniq -c | sort -bnr'); echo "</pre>";
	echo "<hr><pre>";  passthru('cat /var/log/nginx/access_main.log | cut -f 1 -d " " | sort | uniq -c | sort -n | tac'); echo "</pre>";
}
else
{ ?>
<pre>
<?php
	passthru('cat /var/log/nginx/access_main.log.1 | cut -f 1 -d " " | sort | uniq -c | sort -n | tac');
?>
</pre>
<?php 
} 

$ret = ob_get_clean();

// Gzip/Deflate/Bzip2 compression
if(stristr($_SERVER["HTTP_ACCEPT_ENCODING"], "bzip2"))
{
    $ret = bzcompress($ret, 9);
    header("Content-Encoding: bzip2");
}
elseif(stristr($_SERVER["HTTP_ACCEPT_ENCODING"], "gzip"))
{
    $ret = gzencode($ret, 9);
    header("Content-Encoding: gzip");
}
elseif (stristr($_SERVER["HTTP_ACCEPT_ENCODING"], "deflate"))
{
    $ret = gzdeflate($ret, 9);
    header("Content-Encoding: deflate");
}

header("Content-length: ".strlen($ret));
echo $ret;
?>

Zerion Mini Shell 1.0