<? function ad_statistics($stats,$lastpost,$dbsize,$users,$bots) { ?>
<table class="innertable" cellspacing=1 width="100%"><tr><td class="tablehead" colspan=2>
<?=MSG_stats_forum;?>
<tr><td colspan=2 align=center>
<b><?=MSG_stats_common;?></b>
<tr><td width="50%">
<?=MSG_stats_title;?>:
<td>
<?=$GLOBALS['opt_title'];?>
<tr><td>
<?=MSG_stats_url;?>:
<td>
<?=$GLOBALS['opt_url'];?>
<tr><td>
<?=MSG_stats_dir;?>:
<td>
<?=$GLOBALS['opt_dir'];?>
<tr><td>
<?=MSG_stats_server;?>:
<td>
<?=$_SERVER['SERVER_SOFTWARE'];?>
<tr><td>
<?=MSG_stats_user;?>:
<td>
<? eval('echo get_current_user();');?> (<? eval('echo getmyuid();');?>)
<tr><td>
<?=MSG_backup_last;?>:
<td>
<? if ($GLOBALS['opt_last_backup']<(time()-7*24*60*60)) { ?>
<span style="color: #F00000"><?
  if ($GLOBALS['opt_last_backup']) { ?>
<?=long_date_out($GLOBALS['opt_last_backup']);?>
<? } else { ?><?=MSG_none;?><? } ?>
&nbsp; (<a href="admin/index.php?m=basic&a=backup"><?=MSG_backup_now;?></a>)
<? }
else { ?><?=long_date_out($GLOBALS['opt_last_backup']);?>
<? } ?>
<tr><td>
<?=MSG_stats_date;?>:
<td>
<?=long_date_out(time());?>
<tr><td colspan=2 align=center>
<b><?=MSG_stats_qualities;?></b>
<tr><td>
<?=MSG_stats_posts;?>:
<td>
<?=$stats['p_count'];?> (<?=$stats['p_nostats'];?>)
<tr><td>
<?=MSG_stats_premod;?>:
<td>
<?=$stats['premodcount'];?>
<tr><td>
<?=MSG_stats_topics;?>:
<td>
<?=$stats['t_count'];?> (<?=$stats['t_nostats'];?>)
<tr><td>
<?=MSG_stats_users;?>:
<td>
<?=$stats['u_count'];?> 
<tr><td>
<?=MSG_stats_dbsize;?>:
<td>
<?=ceil($dbsize/1024);?> Kb
<tr><td>
<?=MSG_stats_attachments;?>:
<td>
<?=intval($stats['files']);?> (<?=ceil($stats['size']/1024);?> Kb)
<tr><td colspan=2 align=center>
<b><?=MSG_stats_misc;?></b>
<tr><td>
<?=MSG_stats_admins;?>:
<td><?=$users;?>
<tr><td>
<?=MSG_stats_ppert;?>:
<td>
<?=$stats['p_per_t'];?>
<tr><td>
<?=MSG_stats_pperu;?>:
<td>
<?=$stats['p_per_u'];?>
<tr><td>
<?=MSG_stats_tperu;?>:
<td>
<?=$stats['t_per_u'];?>
<tr><td>
<?=MSG_stats_lastpost;?>:
<td>
<?=$lastpost['p_uname'].", \"".$lastpost['t_title']."\" ".long_date_out($lastpost['p__time'])."";?>
<tr><td>
<?=MSG_stats_lastuser;?>:
<td>
<?=$stats['u__name'];?> <?=MSG_u_regged;?> <?=long_date_out($stats['u__regdate'])."";?>
<tr><td>
<?=MSG_stats_dayly;?>:
<td>
<?=$stats['dayly'];?>
<tr><td>
<?=MSG_stats_weekly;?>:
<td>
<?=$stats['weekly'];?>
<tr><td colspan=2 align=center>
<b><?=MSG_stats_search;?></b>
<? foreach ($bots as $curbot) { ?>
  <tr><td><?=$curbot[0];?><td><? if ($curbot) { ?><?=long_date_out($curbot[2]);?><? }
  else { ?><?=MSG_none;?><? } 
 } ?>
</table>
<? }

function stats_form() { ?>
<form action="admin/index.php" method=POST>
<table class="innertable" cellspacing=1 width="100%"><tr><td class="tablehead" colspan=2>
<?=MSG_stats_stats;?>
<tr><td width="40%"><?=MSG_stats_showfrom;?>:<td><?=build_date_field("start",mktime(0,0,0,1,1,2004));?>
<tr><td><?=MSG_stats_till;?>:<td><?=build_date_field("end",time());?>
<tr><td><?=MSG_stats_show;?>:<td>
<input type=checkbox name=hits value=1 checked><?=MSG_stats_hits;?><br>
<input type=checkbox name=truehits value=1 checked><?=MSG_stats_truehits;?><br>
<input type=checkbox name=sessions value=1 checked><?=MSG_stats_sessions;?><br>
<input type=checkbox name=hosts value=1 checked><?=MSG_stats_hosts;?><br>
<input type=checkbox name=users value=1 checked><?=MSG_stats_users;?><br>
<input type=checkbox name=topics value=1><?=MSG_stats_topics;?><br>
<input type=checkbox name=posts value=1><?=MSG_stats_posts;?><br>
<input type=checkbox name=searches value=1><?=MSG_stats_searches;?><br>
<input type=checkbox name=mainpage value=1><?=MSG_stats_mainpages;?><br>
<input type=checkbox name=fviews value=1><?=MSG_stats_forumviews;?><br>
<input type=checkbox name=tviews value=1><?=MSG_stats_topicviews;?><br>
<input type=checkbox name=hps value=1><?=MSG_stats_hpers;?><br>
<input type=checkbox name=spu value=1><?=MSG_stats_hperu;?><br>
<input type=checkbox name=hpu value=1><?=MSG_stats_speru;?>
<tr><td><?=MSG_stats_group;?>:<td>
<input type=radio name=period value=all checked><?=MSG_stats_alltime;?><br>
<input type=radio name=period value=days><?=MSG_stats_byday;?><br>
<input type=radio name=period value=wdays><?=MSG_stats_byweek;?><br>
<input type=radio name=period value=hours><?=MSG_stats_byhour;?>
<tr><td class="tablehead" colspan=2><input type=hidden name=m value=stats><input type=hidden name=a value=show_stats>
<input type=submit value="<?=MSG_show;?>">
</table></form>
<? }

function stat_start($count) { ?>
<table class="innertable" cellspacing=1 width="100%"><tr><td class="tablehead" colspan=<?=$count+1;?>>
<?=MSG_stats_from;?> <?=long_date_out(get_date_field("start"));?> <?=MSG_stats_till2;?> <?=long_date_out(get_date_field("end"));?>
<tr><td class="tablehead" width="25%"><?=MSG_stat_period;?>
<? if (getvar("hits")) { ?><td class="tablehead"><?=MSG_stat_hits;?><? }
if (getvar("truehits")) { ?><td class="tablehead"><?=MSG_stat_truehits;?><? }
if (getvar("sessions")) { ?><td class="tablehead"><?=MSG_stat_sessions;?><? }
if (getvar("hosts")) { ?><td class="tablehead"><?=MSG_stat_hosts;?><? }
if (getvar("users")) { ?><td class="tablehead"><?=MSG_stat_users;?><? }
if (getvar("topics")) { ?><td class="tablehead"><?=MSG_stat_topics;?><? }
if (getvar("posts")) { ?><td class="tablehead"><?=MSG_stat_posts;?><? }
if (getvar("searches")) { ?><td class="tablehead"><?=MSG_stat_searches;?><? }
if (getvar("mainpage")) { ?><td class="tablehead"><?=MSG_stat_mainpage;?><? }
if (getvar("fviews")) { ?><td class="tablehead"><?=MSG_stat_forumviews;?><? }
if (getvar("tviews")) { ?><td class="tablehead"><?=MSG_stat_topicviews;?><? }
if (getvar("hps")) { ?><td class="tablehead"><?=MSG_stat_hpers;?><? }
if (getvar("spu")) { ?><td class="tablehead"><?=MSG_stat_speru;?><? }
if (getvar("hpu")) { ?><td class="tablehead"><?=MSG_stat_hperu;?><? } ?>
<? }

function stat_entry($curout,$curnumber,&$hits,&$truehits,&$sessions,&$hosts,&$users,&$topics,&$posts,&$searches,&$mainpage,&$fviews,&$tviews,&$hps,&$spu,&$hpu) { ?>
<tr style="text-align: center"><td><?=$curout;?>
<? if (getvar("hits")) { ?><td><?=$hits[$curnumber];?><? }
if (getvar("truehits")) { ?><td><?=$truehits[$curnumber];?><? }
if (getvar("sessions")) { ?><td><?=$sessions[$curnumber];?><? }
if (getvar("hosts")) { ?><td><?=$hosts[$curnumber];?><? }
if (getvar("users")) { ?><td><?=$users[$curnumber];?><? }
if (getvar("topics")) { ?><td><?=$topics[$curnumber];?><? }
if (getvar("posts")) { ?><td><?=$posts[$curnumber];?><? }
if (getvar("searches")) { ?><td><?=$searches[$curnumber];?><? }
if (getvar("mainpage")) { ?><td><?=$mainpage[$curnumber];?><? }
if (getvar("fviews")) { ?><td><?=$fviews[$curnumber];?><? }
if (getvar("tviews")) { ?><td><?=$tviews[$curnumber];?><? }
if (getvar("hps")) { ?><td><?=$hps[$curnumber];?><? }
if (getvar("spu")) { ?><td><?=$spu[$curnumber];?><? }
if (getvar("hpu")) { ?><td><?=$hpu[$curnumber];?><? } ?>
<? }

function stat_end() { ?>
</table>
<? }

function stat_browser_start() { ?>
<table class="innertable" cellspacing=1 width="100%"><tr><td class="tablehead" colspan=3>
<?=MSG_stats_perbrowser;?>
<tr><td class="tablehead" width="50%"><?=MSG_stats_browser;?><td class="tablehead" width="25%"><?=MSG_stats_percent;?>
<td class="tablehead"><?=MSG_stats_percent_active;?>
<? }

function stat_browser_entry($browser,$count1,$count2,$sum1,$sum2) { ?>
<tr><td><?=$browser;?><td><?=floor($count2/$sum2*100);?>% (<?=$count2;?>/<?=$sum2;?>)
<td><?=floor($count1/$sum1*100);?>% (<?=$count1;?>/<?=$sum1;?>)
<? }

function stat_browser_end() { ?>
</table>
<? }

function stat_select_form($startdate,$enddate,$mode) { ?>
<form action="admin/index.php" method=POST>
<table class="innertable" cellspacing=1 width="100%"><tr><td class="tablehead" colspan=2>
<?=MSG_stats_views;?>
<tr><td width="40%"><?=MSG_stats_showfrom;?>:<td><?=build_date_field("start",$startdate);?>
<tr><td><?=MSG_stats_till;?>:<td><?=build_date_field("end",$enddate);?>
<tr><td><?=MSG_stats_show;?>:<td>
<input type=radio name=mode value="forum_only" <?=check($mode=="forum_only");?>><?=MSG_stats_forum;?><br>
<input type=radio name=mode value="forum" <?=check($mode=="forum");?>><?=MSG_stats_forumtopic;?><br>
<input type=radio name=mode value="topic" <?=check($mode=="topic");?>><?=MSG_stats_topic;?>
<tr><td><?=MSG_stats_perpage;?>:<td>
<input type=text name=perpage size=3 value="10">
<tr><td class="tablehead" colspan=2><input type=hidden name=m value=stats>
<input type=hidden name=a value=stat_process><input type=submit value="<?=MSG_show;?>">
</table></form>
<? }

function stat_process_start($pages) { ?>
<table class="innertable" cellspacing=1 width="100%"><tr><td class="tablehead" colspan=2>
<?=MSG_stats_views;?>
<tr><td class="tablehead" colspan=2><?=$pages;?>
<? }

function stat_process_entry($lnk,$msg,$count) { ?>
<tr><td width="80%"><a href="<?=$lnk;?>"><?=$msg;?></a>
<td align=center><?=$count;?>
<? }

function stat_process_end() { ?>
</table>
<? }

function stat_detail_form() { ?>
<form action="admin/index.php" method=POST>
<table class="innertable" cellspacing=1 width="100%"><tr><td class="tablehead" colspan=2>
<?=MSG_stats_detailed;?>
<tr><td width="40%"><?=MSG_stats_showfrom;?>:<td><?=build_date_field("start",time()-7*24*60*60);?>
<tr><td><?=MSG_stats_till;?>:<td><?=build_date_field("end",time());?>
<tr><td class="tablehead" colspan=2><input type=hidden name=m value=stats><input type=hidden name=a value=stat_show_detail>
<input type=submit value="<?=MSG_show;?>">
</table></form>
<? }

function stat_detail_start($starttime,$endtime) { ?>
<table class="innertable" cellspacing=1 width="100%"><tr><td class="tablehead" colspan=3>
<?=MSG_stats_detailedfrom;?> <?=short_date_out($starttime);?> <?=MSG_stats_till;?> <?=short_date_out($endtime);?>
<? }

function online_entry($udata,$comment) { ?>
<tr><td width="30%"><b><?=$udata['u__name'];?></b><br><?=numtoip($udata['uo_ip']);?><br><?=long_date_out($udata['uo_time']);?>
<td align=center><?=$comment;?>
<? }

function stat_detail_end() { ?>
</table>
<? }
