<?php
/*
* PHP versions 4 and 5
*
* LICENSE: This source file is subject to version 3.0 of the PHP license
* that is available through the world-wide-web at the following URI:
* http://www.php.net/license. If you did not receive a copy of
* the PHP License and are unable to obtain it through the web, please
* send a note to hide@address.com so we can mail you a copy immediately.
*
* @category Troubleticket
* @package QuickTicket
* @author Philippe Vandenberghe <hide@address.com>
* @copyright 2008-2012 The PHP Group
* @license http://www.php.net/license PHP License 3.0
* @version 1.9.0.3 build:20081001
* @link http://www.qt-cute.org/doc/package/qti
* @since File available since Release 1.0.0
* @deprecated File deprecated in Release 2.0.0
*
*/
session_start();
require_once('bin/qti_init.php');
if ( !$oVIP->CanAccess('MUV',4) ) $oVIP->EndMessage('!',$L['R_member'],$_SESSION[QT]['skin_dir'],0);
include(Translate('qti_lang_stat.inc'));
// INITIALISE
$intYear = date('Y');
if ( intval(date('n'))<2 ) $inthYear--;
if ( isset($_GET['year']) ) $intYear = intval($_GET['year']);
$arrYears = array($intYear-1=>$intYear-1,$intYear=>$intYear);
$s = -1; if ( isset($_GET['s']) ) $s = intval($_GET['s']);
if ( $s>=0 ) { $strSection = 'forum='.$s.' AND'; } else { $strSection=''; }
$tt = 'g';
if ( isset($_GET['tt']) ) $tt = strip_tags($_GET['tt']);
if ( isset($_POST['tt']) ) $tt = strip_tags($_POST['tt']);
$bt = 'm';
if ( isset($_GET['bt']) ) $bt = strip_tags($_GET['bt']);
if ( isset($_POST['bt']) ) $bt = strip_tags($_POST['bt']);
$gr = 'a';
if ( isset($_GET['gr']) ) $gr = strip_tags($_GET['gr']);
if ( isset($_POST['gr']) ) $gr = strip_tags($_POST['gr']);
$tr = 'a';
if ( isset($_GET['tr']) ) $tr = strip_tags($_GET['tr']);
if ( isset($_POST['gr']) ) $tr = strip_tags($_POST['tr']);
// FIRST/LAST DATE
$query = 'SELECT min(firstpostdate) as startdate, max(firstpostdate) as lastdate FROM '.TABTOPIC;
$oDB->Query($query);
$row = $oDB->Getrow();
if ( empty($row['startdate']) ) $row['startdate']=strval($intYear-1).'0101';
if ( empty($row['lastdate']) ) $row['lastdate']=strval($intYear).'1231';
$strFirstdate = QTdate($row['startdate'],$arrQTdate);
$strLastdate = QTdate($row['lastdate'],$arrQTdate);
$strLastdaysago = substr($row['lastdate'],0,8);
$strTendaysago = DateAdd($strLastdaysago,-10,'day');
$intStartyear = intval(date('Y',strtotime($row['startdate'])));
$intStartmonth = intval(date('n',strtotime($row['startdate'])));
$intEndyear = intval(date('Y'));
$intEndmonth = intval(date('n'));
$arrAllYears = array();
for ($i=$intStartyear;$i<=$intEndyear;$i++)
{
$arrAllYears[$i]=$i;
}
$arrYears = array($intEndyear-1=>$intEndyear-1,$intEndyear=>$intEndyear);
$oVIP->selfurl = 'qti_stats.php?s='.$s.'&year='.$intYear;
$oVIP->selfname = $L['Statistics'];
// --------
// HTML START
// --------
$bToPrint = true;
$arrCss = array('qti_graph.css','qti_legend.css');
$arrJava = array('com'=>false);
include('qti_p_header.php');
$arrSections = GetSectionTitles($oVIP->role);
// USERS
$query = 'SELECT count(id) as countid FROM '.TABUSER;
$oDB->Query($query);
$row = $oDB->Getrow();
$intUsers = $row['countid'];
$iTotalPost = 0;
// TOPICS PER DAY
$intTPD = 0;
$oDB->Query('SELECT count(id) as countid, max(firstpostdate) as lastdate, min(firstpostdate) as firstdate FROM '.TABTOPIC);
if ( $row=$oDB->Getrow() )
{
if ( $row['countid']!=0 && $row['lastdate']!=$row['firstdate'] )
{
$intDif = (strtotime($row['lastdate']) - strtotime($row['firstdate']))/86400;
if ( $intDif>1 )
{
$intTPD = $row['countid'] / $intDif ;
$intTPD = round($intTPD, 1);
}
}
}
// MESSAGE PER DAY
$intMPD = 0;
$oDB->Query('SELECT count(id) as countid,max(issuedate) as lastdate, min(issuedate) as firstdate FROM '.TABPOST);
if ( $row=$oDB->Getrow() ) {
if ( $row['countid']!=0 && $row['lastdate']!=$row['firstdate'] ) {
$intDif = (strtotime($row['lastdate']) - strtotime($row['firstdate']))/86400;
if ( $intDif>1 )
{
$intMPD = $row['countid'] / $intDif ;
$intMPD = round($intMPD, 1);
}
}
}
echo '
<table class="ta_hidden" cellspacing="0">
<tr class="tr_hidden" style="vertical-align:top;">
<td class="td_hidden"><h1>',$L['Statistics'],'</h1></td>
<td class="td_hidden"> </td>
</tr>
</table>
';
// --------
// STATISTIC TABS
// --------
$arrTabs = array();
$arrTabs['g'] = array('tabname'=>$L['Global'],'tabdesc'=>$L['H_Global']);
$arrTabs['gt'] = array('tabname'=>$L['Global_trends'],'tabdesc'=>$L['H_Global_trends']);
$arrTabs['d'] = array('tabname'=>$L['Details'],'tabdesc'=>$L['H_Details']);
$arrTabs['dt'] = array('tabname'=>$L['Details_trends'],'tabdesc'=>$L['H_Details_trends']);
$arrTimeblocks = array();
$arrTimeblocks[] = ($bt=='q' ? $L['Per_q'] : '<a href="'.$oVIP->selfurl.'?s='.$s.'&year='.$intYear.'&tt='.$tt.'&bt=q&gr='.$gr.'" class="small">'.$L['Per_q'].'</a>');
$arrTimeblocks[] = ($bt=='m' ? $L['Per_m'] : '<a href="'.$oVIP->selfurl.'?s='.$s.'&year='.$intYear.'&tt='.$tt.'&bt=m&gr='.$gr.'" class="small">'.$L['Per_m'].'</a>');
$arrTimeblocks[] = ($bt=='d' ? $L['Per_d'] : '<a href="'.$oVIP->selfurl.'?s='.$s.'&year='.$intYear.'&tt='.$tt.'&bt=d&gr='.$gr.'" class="small">'.$L['Per_d'].'</a>');
$arrTrendtypes = array();
$arrTrendtypes[] = ($tr=='a' ? $L['Per_a'] : '<a href="'.$oVIP->selfurl.'?s='.$s.'&year='.$intYear.'&tt='.$tt.'&bt='.$bt.'&tr=a&gr='.$gr.'" class="small">'.$L['Per_a'].'</a>');
$arrTrendtypes[] = ($tr=='p' ? $L['Per_p'] : '<a href="'.$oVIP->selfurl.'?s='.$s.'&year='.$intYear.'&tt='.$tt.'&bt='.$bt.'&tr=p&gr='.$gr.'" class="small">'.$L['Per_p'].'</a>');
echo '<table class="ta_pan" cellspacing="0">
<tr class="tr_pan">
<td class="td_pan">
<div class="div_pan_top">',$arrTabs[$tt]['tabdesc'],'</div>
';
switch($tt)
{
case 'g': include('qti_stats_g.php'); break;
case 'gt': include('qti_stats_gt.php'); break;
case 'd': include('qti_stats_d.php'); break;
case 'dt': include('qti_stats_dt.php'); break;
default: die('Invalid tab');
}
echo '
</td>
</tr>
</table>
';
// HTML END
include('qti_p_footer.php');
?>