2020-10-27 16:32:23 +01:00
< ? php
2022-12-31 10:19:09 +01:00
if ( ! defined ( 'N' )) {
echo ( 'You probably meant <a href="' . preg_replace ( '/\.php$/' , '' , $_SERVER [ 'REQUEST_URI' ]) . '">this</a>.' );
exit ( 0 );
}
2023-12-28 14:52:00 +01:00
$lc = localeconv ();
2023-12-26 11:17:54 +01:00
require '../lib/fnum.php' ;
2023-12-28 14:52:00 +01:00
require '../lib/realfloat.php' ;
2023-12-26 11:17:54 +01:00
require '../lib/supplangs.php' ;
2022-11-21 11:24:34 +01:00
2020-10-27 16:32:23 +01:00
echo ( ' </ nav >
2020-10-26 16:05:59 +01:00
< div class = " scrwide " >
< div class = " scrwidein " >
< section class = " sectcontm " >
2023-11-02 23:37:34 +01:00
< h3 > '._(' Statistics for the last 30 days ').' </ h3 >
2020-10-26 16:05:59 +01:00
< 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' );
$now = time ();
$tdstart = gmmktime ( 0 , 0 , 0 , gmdate ( 'n' , $now ), gmdate ( 'j' , $now ), gmdate ( 'Y' , $now ));
$limit = $tdstart - ( 30 * 24 * 60 * 60 );
2023-11-02 23:37:34 +01:00
$res = mysqli_query ( $link , 'SELECT MAX(Visits) AS MaxVisits, MAX(Hits) AS MaxHits FROM ZStats WHERE TS >= ' . $limit ) or muorimeglio ( __LINE__ . ': ' . mysqli_error ( $link ), true );
$row = mysqli_fetch_assoc ( $res );
$maxvisits = $row [ 'MaxVisits' ];
$maxhits = $row [ 'MaxHits' ];
2020-10-26 16:05:59 +01:00
$res = mysqli_query ( $link , 'SELECT * FROM ZStats WHERE TS >= ' . $limit . ' ORDER BY TS DESC' ) or muorimeglio ( __LINE__ . ': ' . mysqli_error ( $link ), true );
2020-10-31 06:57:34 +01:00
$hpmap = array (
'home' => _ ( 'Guide' ),
'instances' => _ ( 'Instances' ),
2022-12-31 07:25:42 +01:00
'users' => _ ( 'Users' ),
2023-07-01 20:26:36 +02:00
'links' => _ ( 'Links' ),
2020-10-31 06:57:34 +01:00
'about' => _ ( 'About' ),
2020-10-31 07:21:59 +01:00
'stats' => _ ( 'Statistics' ),
2020-10-31 06:57:34 +01:00
'contribute' => _ ( 'Contribute' ),
'404' => '404'
);
2020-10-26 16:05:59 +01:00
while ( $row = mysqli_fetch_assoc ( $res )) {
2020-10-31 06:57:34 +01:00
$hl = explode ( ';' , $row [ 'HitsLang' ]);
$buf = array ();
foreach ( $hl as $key => $val ) {
$val = explode ( ':' , $val );
2023-11-02 09:38:28 +01:00
if ( array_key_exists ( $val [ 0 ], $supplangs )) // needed when you (temporarily) subtract a lang code from $supplangs in lib/supplangs.php
$buf [ $supplangs [ $val [ 0 ]][ 'trname' ]] = $val [ 1 ];
2020-10-31 06:57:34 +01:00
}
2020-10-26 16:05:59 +01:00
arsort ( $buf );
2020-10-31 06:57:34 +01:00
$hl = '' ;
2023-12-28 14:52:00 +01:00
foreach ( $buf as $key => $val ) $hl .= $key . ': ' . fnum ( $val , $lc , 0 ) . '; ' ;
2020-10-31 06:57:34 +01:00
$hl = _ ( 'Hits per language' ) . ': ' . substr ( $hl , 0 , - 2 );
$hp = explode ( ';' , $row [ 'HitsPage' ]);
$buf = array ();
foreach ( $hp as $key => $val ) {
$val = explode ( ':' , $val );
$buf [ $hpmap [ $val [ 0 ]]] = $val [ 1 ];
}
2020-10-26 16:05:59 +01:00
arsort ( $buf );
2020-10-31 06:57:34 +01:00
$hp = '' ;
2023-12-28 14:52:00 +01:00
foreach ( $buf as $key => $val ) $hp .= $key . ': ' . fnum ( $val , $lc , 0 ) . '; ' ;
2020-10-31 06:57:34 +01:00
$hp = _ ( 'Hits per page' ) . ': ' . substr ( $hp , 0 , - 2 );
2023-12-28 14:52:00 +01:00
echo ( '<div class="info1st">' . gmdate ( 'd/m/Y' , $row [ 'TS' ]) . ': ' . fnum ( $row [ 'Visits' ], $lc , 0 ) . ' <span class="visitslab">' . sp ( $row [ 'Visits' ], _ ( 'visit' ), _ ( 'visits' )) . '</span>, ' . fnum ( $row [ 'Hits' ], $lc , 0 ) . ' <span class="hitslab">' . sp ( $row [ 'Hits' ], _ ( 'hit' ), _ ( 'hits' )) . '</span></div>' . N );
2020-10-31 06:57:34 +01:00
echo ( '<div class="info">' . $hl . '</div>' . N );
echo ( '<div class="info">' . $hp . '</div>' . N );
2023-12-28 14:52:00 +01:00
echo ( '<div class="visits" style="width:' . rf ( $row [ 'Visits' ] * 100 / $maxvisits ) . '%"></div>' . N );
echo ( '<div class="hits" style="width:' . rf ( $row [ 'Hits' ] * 100 / $maxhits ) . '%"></div>' . N );
2020-10-26 16:05:59 +01:00
}
mysqli_close ( $link );
2023-11-02 23:37:34 +01:00
echo ( ' </ section >
2020-10-26 16:05:59 +01:00
</ div >
2020-10-27 16:32:23 +01:00
</ div > ' . N );
?>