66 lines
3.3 KiB
PHP
66 lines
3.3 KiB
PHP
<?php
|
||
|
||
echo('</nav>
|
||
<div class="scrwide">
|
||
<div class="scrwidein">
|
||
<section class="sectcontm">
|
||
<h3>'._('Statistics').'</h3>
|
||
<link rel="stylesheet" type="text/css" href="'.$prepath.'stats.css?v='.$cjrand.'">
|
||
<script language="JavaScript">
|
||
</script>
|
||
'.N);
|
||
|
||
function sp($num,$sing,$plur) {
|
||
if ($num==1)
|
||
return($sing);
|
||
else
|
||
return($plur);
|
||
}
|
||
|
||
$link=mysqli_connect($conf['db_host'],$conf['db_user_name'],$conf['db_user_password'],$conf['db_name'],$conf['db_port'],$conf['db_socket']) or muorimeglio(_('Couldn’t connect to database: ').mysqli_connect_error().' ['.mysqli_connect_errno().']',false);
|
||
mysqli_set_charset($link,'utf8mb4');
|
||
|
||
$res=mysqli_query($link,'SELECT MAX(Visits) AS MaxVisits, MAX(Hits) AS MaxHits FROM ZStats') or muorimeglio(__LINE__.': '.mysqli_error($link),true);
|
||
$row=mysqli_fetch_assoc($res);
|
||
$maxvisits=$row['MaxVisits'];
|
||
$maxhits=$row['MaxHits'];
|
||
|
||
echo('<p>'._('Statistics for the last 30 days.').'</p>'.N);
|
||
$now=time();
|
||
$tdstart=gmmktime(0,0,0,gmdate('n',$now),gmdate('j',$now),gmdate('Y',$now));
|
||
$limit=$tdstart-(30*24*60*60);
|
||
$res=mysqli_query($link,'SELECT * FROM ZStats WHERE TS >= '.$limit.' ORDER BY TS DESC') or muorimeglio(__LINE__.': '.mysqli_error($link),true);
|
||
while ($row=mysqli_fetch_assoc($res)) {
|
||
$buf=array(_('Catalan')=>$row['HitsCa'], _('English')=>$row['HitsEn'], _('Spanish')=>$row['HitsEs'], _('French')=>$row['HitsFr'], _('Italian')=>$row['HitsIt']);
|
||
arsort($buf);
|
||
$langs='';
|
||
foreach ($buf as $key=>$val) $langs.=$key.': '.$val.', ';
|
||
$langs=_('Hits per language').': '.substr($langs,0,-2);
|
||
$buf=array(_('Guide')=>$row['HitsHome'], _('Instances')=>$row['HitsInst'], _('About')=>$row['HitsAbout'], _('Stats')=>$row['HitsStats'], _('Contribute')=>$row['HitsContrib'], '404'=>$row['Hits404']);
|
||
arsort($buf);
|
||
$pages='';
|
||
foreach ($buf as $key=>$val) $pages.=$key.': '.$val.', ';
|
||
$pages=_('Hits per page').': '.substr($pages,0,-2);
|
||
echo('<div class="info">'.gmdate('d/m/Y',$row['TS']).': '.$row['Visits'].' <span class="visitslab">'.sp($row['Visits'],_('visit'),_('visits')).'</span>, '.$row['Hits'].' <span class="hitslab">'.sp($row['Hits'],_('hit'),_('hits')).'</span></div>'.N);
|
||
echo('<div class="info">'.$langs.'</div>'.N);
|
||
echo('<div class="info">'.$pages.'</div>'.N);
|
||
echo('<div class="visits" style="width:'.(100/$maxvisits*$row['Visits']).'%"></div>'.N);
|
||
echo('<div class="hits" style="width:'.(100/$maxhits*$row['Hits']).'%"></div>'.N);
|
||
echo('<div class="sep"></div>'.N);
|
||
}
|
||
|
||
mysqli_close($link);
|
||
|
||
echo('</section>
|
||
</div>
|
||
</div>'.N);
|
||
|
||
$tradnotes=array(
|
||
'ca'=>'Translation of this page to catalan language is missing, please click <a href="/contribute/ca">here</a> if you’d like to help, or <span class="transc" onclick="document.getElementById(\'transd\').style.display=\'none\'">here</span> to close this message',
|
||
'es'=>'Translation of this page to spanish language is missing, please click <a href="/contribute/es">here</a> if you’d like to help, or <span class="transc" onclick="document.getElementById(\'transd\').style.display=\'none\'">here</span> to close this message',
|
||
'fr'=>'Translation of this page to french language is missing, please click <a href="/contribute/fr">here</a> if you’d like to help, or <span class="transc" onclick="document.getElementById(\'transd\').style.display=\'none\'">here</span> to close this message'
|
||
);
|
||
if (array_key_exists($dlang,$tradnotes))
|
||
echo('<div id="transd">'.$tradnotes[$dlang].'</div>'.N);
|
||
|
||
?>
|