<?php
// QuickTicket 2.3 build:20091102
// --------
// INITIALISE
// --------
$oVIP->output='print';
$s = -1; // section filter
$y = date('Y'); if ( intval(date('n'))<2 ) $y--; // year filter
$tag = ''; // tags filter
$tt = 'gt'; // tab: g=global, gt=globaltrend, d=detail, dt=detailtrend
$ch = array('m','b','a','a'); // chart parameters
// [0] blocktime: m=month, q=quarter, d=10days
// [1] graph type: b=bar, l=line, B=bar+variation, L=line+variation
// [2] graphics reals: a=actual, p=percent
// [3] trends reals: a=actual, p=percent
// --------
// SUBMITTED
// --------
if ( isset($_GET['y']) ) $y = intval($_GET['y']);
if ( isset($_GET['s']) ) $s = intval($_GET['s']);
if ( $s>=0 ) { $strSection = 'forum='.$s.' AND'; } else { $strSection=''; }
if ( isset($_GET['tag']) ) $tag = strip_tags($_GET['tag']);
$strTags = '';
if ( !empty($tag) )
{
if ( substr($tag,-1,1)==';' ) $tag = substr($tag,0,-1);
$arrTags = explode(';',$tag);
$str = '';
foreach($arrTags as $strTag)
{
if ( !empty($str) ) $str .= ' OR ';
$str .= 'UPPER(tags) LIKE "%'.strtoupper($strTag).'%"';
}
if ( !empty($str) ) $strTags = ' ('.$str.') AND';
}
if ( isset($_GET['tt']) ) $tt = strip_tags($_GET['tt']);
if ( isset($_GET['ch']) )
{
$str = strip_tags($_GET['ch']);
if ( str_len($str)>0 ) $ch['time'] = substr($str,0,1); // blocktime
if ( str_len($str)>1 ) $ch['type'] = substr($str,1,1); // graph type
if ( str_len($str)>2 ) $ch['value'] = substr($str,2,1); // value type
if ( str_len($str)>3 ) $ch['trend'] = substr($str,3,1); // trends value type
}
// ------
// OUTPUT
// ------
$arrYears = array($y-1,$y); // Normal is 1 year but for Trends analysis, 2 years
include('qti_stats_inc.php');
if ( $ch['time']=='q' ) { $intWidth=16; } else { $intWidth=11; }
$pdf=new PDF();
$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->SetTitle( PdfClean($L['Statistics']) );
$pdf->SetAuthor( PdfClean($_SESSION[QT]['site_name']) );
$pdf->SetSubject( PdfClean(PdfClean($L['H_Global_trends']) );
$pdf->SetFont('Arial','B',14);
$pdf->SetTextColor(150);
$pdf->Ln();
$pdf->Cell(0, 10, PdfClean($L['H_Global_trends']), 'T', 1, 'R');
$pdf->SetTextColor(0);
$pdf->SetFont('Arial','B',10);
$arr = QTarrget(GetSections($oVIP->role));
$pdf->Cell(0, 8, PdfClean(($y-1).' - '.$y.($s>=0 ? ' ('.$arr[$s].')' : '').(empty($tag) ? '' : ', '.$L['With_tag'].' '.str_replace(';',' '.$L['or'].' ',$tag))), '', 1);
// -----
foreach($arrYears as $y) {
// -----
$arrTable = array();
// Table header
$arrRow = array();
$oCell = new cPdfCell($y,28,5,'',true); $oCell->font=array('Arial','B',8); $arrRow[]=$oCell;
$oCell = new cPdfCell(' ',4, 5,'',true); $arrRow[]=$oCell;
switch($ch['time'])
{
case 'q': for ($i=1;$i<=$intMaxBt;$i++) { $oCell = new cPdfCell( 'Q'.$i, $intWidth,5,'C',true); $arrRow[]=$oCell; } break;
case 'm': for ($i=1;$i<=$intMaxBt;$i++) { $oCell = new cPdfCell( $L['dateMM'][$i], $intWidth,5,'C',true); $arrRow[]=$oCell; } break;
case 'd': for ($i=1;$i<=$intMaxBt;$i++) { $oCell = new cPdfCell( QTdatestr(DateAdd($strTendaysago,$i,'day'),'d/n',''),$intWidth,5,'C',true); $arrRow[]=$oCell; } break;
}
$oCell = new cPdfCell(($ch['time']=='d' ? '10 '.strtolower($L['Days']) : PdfClean($L['Year'])),$intWidth+3,5,'C',true); $arrRow[]=$oCell;
$arrTable[] = $arrRow;
// Table body topics
$arrRow = array();
$oCell = new cPdfCell($L['Topics'],28,5,'',true); $arrRow[]=$oCell;
$oCell = new cPdfCell(' ', 4, 5,'',true,array(0,0,102)); $arrRow[]=$oCell;
for ($intBt=1;$intBt<=$intMaxBt;$intBt++)
{
$oCell = new cPdfCell((isset($arrT[$y][$intBt]) ? $arrT[$y][$intBt] : '0'),$intWidth); $arrRow[]=$oCell;
}
$oCell = new cPdfCell($arrTs[$y],$intWidth+3,5,'C');$oCell->font=array('Arial','B',8); $arrRow[]=$oCell;
$arrTable[] = $arrRow;
// Table body messages
$arrRow = array();
$oCell = new cPdfCell($L['Replys'],28,5,'',true); $arrRow[]=$oCell;
$oCell = new cPdfCell(' ', 4, 5,'',true,array(153,0,153)); $arrRow[]=$oCell;
for ($intBt=1;$intBt<=$intMaxBt;$intBt++)
{
$oCell = new cPdfCell((isset($arrM[$y][$intBt]) ? $arrM[$y][$intBt] : '0'),$intWidth); $arrRow[]=$oCell;
}
$oCell = new cPdfCell($arrMs[$y],$intWidth+3,5,'C');$oCell->font=array('Arial','B',8); $arrRow[]=$oCell;
$arrTable[] = $arrRow;
// Table body users
$arrRow = array();
$oCell = new cPdfCell($L['Users'].'*',28,5,'',true); $arrRow[]=$oCell;
$oCell = new cPdfCell(' ', 4, 5,'',true,array(0,153,153)); $arrRow[]=$oCell;
for ($intBt=1;$intBt<=$intMaxBt;$intBt++)
{
$oCell = new cPdfCell((isset($arrU[$y][$intBt]) ? $arrU[$y][$intBt] : '0'),$intWidth); $arrRow[]=$oCell;
}
$oCell = new cPdfCell($arrUs[$y],$intWidth+3,5,'C');$oCell->font=array('Arial','B',8); $arrRow[]=$oCell;
$arrTable[] = $arrRow;
// Show table
$pdf->BasicTable($arrTable);
$pdf->Ln(1);
// -----
}
// -----
$arrTable = array();
// Table header
$arrRow = array();
$oCell = new cPdfCell($L['Trends'],28,5,'',true); $oCell->font=array('Arial','B',8); $arrRow[]=$oCell;
$oCell = new cPdfCell(' ',4, 5,'',true); $arrRow[]=$oCell;
switch($ch['time'])
{
case 'q': for ($i=1;$i<=$intMaxBt;$i++) { $oCell = new cPdfCell( 'Q'.$i, $intWidth,5,'C',true); $arrRow[]=$oCell; } break;
case 'm': for ($i=1;$i<=$intMaxBt;$i++) { $oCell = new cPdfCell( $L['dateMM'][$i], $intWidth,5,'C',true); $arrRow[]=$oCell; } break;
case 'd': for ($i=1;$i<=$intMaxBt;$i++) { $oCell = new cPdfCell( QTdatestr(DateAdd($strTendaysago,$i,'day'),'d/n',''),$intWidth,5,'C',true); $arrRow[]=$oCell; } break;
}
$oCell = new cPdfCell(($ch['time']=='d' ? '10 '.strtolower($L['Days']) : PdfClean($L['Year'])),$intWidth+3,5,'C',true); $arrRow[]=$oCell;
$arrTable[] = $arrRow;
// Table body topic
$arrRow = array();
$oCell = new cPdfCell($L['Topics'],28,5,'',true); $arrRow[]=$oCell;
$oCell = new cPdfCell(' ',4, 5,'',true,array(0,0,102)); $arrRow[]=$oCell;
for ($intBt=1;$intBt<=$intMaxBt;$intBt++)
{
$oCell = new cPdfCell('0',$intWidth);
$i = QTtrend((isset($arrT[$y][$intBt]) ? $arrT[$y][$intBt] : 0),(isset($arrT[$y-1][$intBt]) ? $arrT[$y-1][$intBt] : 0),$ch['trend']=='p');
if ( isset($i) )
{
$oCell->s = $i.($ch['trend']=='p' ? '%' : '');
if ( $i>0 ) { $oCell->color=array(255,0,0); $oCell->s = '+'.$oCell->s; }
if ( $i<0 ) { $oCell->color=array(0,255,0); $oCell->s = $oCell->s; }
}
else
{
$oCell->s = '.';
}
$arrRow[]=$oCell;
}
$oCell = new cPdfCell('0',$intWidth); $oCell->font=array('Arial','B',8);
$i = QTtrend($arrTs[$y],$arrTs[$y-1],$ch['trend']=='p');
if ( isset($i) )
{
$oCell->s = $i.($ch['trend']=='p' ? '%' : '');
if ( $i>0 ) { $oCell->color=array(255,0,0); $oCell->s = '+'.$oCell->s; }
if ( $i<0 ) { $oCell->color=array(0,255,0); $oCell->s = $oCell->s; }
}
else
{
$oCell->s = '.';
}
$arrRow[]=$oCell;
$arrTable[] = $arrRow;
// Table body messages
$arrRow = array();
$oCell = new cPdfCell($L['Replys'],28,5,'',true); $arrRow[]=$oCell;
$oCell = new cPdfCell(' ',4, 5,'',true,array(153,0,153)); $arrRow[]=$oCell;
for ($intBt=1;$intBt<=$intMaxBt;$intBt++)
{
$oCell = new cPdfCell('0',$intWidth);
$i = QTtrend((isset($arrM[$y][$intBt]) ? $arrM[$y][$intBt] : 0),(isset($arrM[$y-1][$intBt]) ? $arrM[$y-1][$intBt] : 0),$ch['trend']=='p');
if ( isset($i) )
{
$oCell->s = $i.($ch['trend']=='p' ? '%' : '');
if ( $i>0 ) { $oCell->color=array(255,0,0); $oCell->s = '+'.$oCell->s; }
if ( $i<0 ) { $oCell->color=array(0,255,0); $oCell->s = $oCell->s; }
}
else
{
$oCell->s = '.';
}
$arrRow[]=$oCell;
}
$oCell = new cPdfCell('0',$intWidth); $oCell->font=array('Arial','B',8);
$i = QTtrend($arrMs[$y],$arrMs[$y-1],$ch['trend']=='p');
if ( isset($i) )
{
$oCell->s = $i.($ch['trend']=='p' ? '%' : '');
if ( $i>0 ) { $oCell->color=array(255,0,0); $oCell->s = '+'.$oCell->s; }
if ( $i<0 ) { $oCell->color=array(0,255,0); $oCell->s = $oCell->s; }
}
else
{
$oCell->s = '.';
}
$arrRow[]=$oCell;
$arrTable[] = $arrRow;
// Table body users
$arrRow = array();
$oCell = new cPdfCell($L['Users'].'*',28,5,'',true); $arrRow[]=$oCell;
$oCell = new cPdfCell(' ',4, 5,'',true,array(0,153,153)); $arrRow[]=$oCell;
for ($intBt=1;$intBt<=$intMaxBt;$intBt++)
{
$oCell = new cPdfCell('0',$intWidth);
$i = QTtrend((isset($arrU[$y][$intBt]) ? $arrU[$y][$intBt] : 0),(isset($arrU[$y-1][$intBt]) ? $arrU[$y-1][$intBt] : 0),$ch['trend']=='p');
$i = QTtrend($arrU[$y][$intBt],$arrU[$y-1][$intBt],$ch['trend']=='p');
if ( isset($i) )
{
$oCell->s = $i.($ch['trend']=='p' ? '%' : '');
if ( $i>0 ) { $oCell->color=array(255,0,0); $oCell->s = '+'.$oCell->s; }
if ( $i<0 ) { $oCell->color=array(0,255,0); $oCell->s = $oCell->s; }
}
else
{
$oCell->s = '.';
}
$arrRow[]=$oCell;
}
$oCell = new cPdfCell('0',$intWidth); $oCell->font=array('Arial','B',8);
$i = QTtrend($arrUs[$y],$arrUs[$y-1],$ch['trend']=='p');
if ( isset($i) )
{
$oCell->s = $i.($ch['trend']=='p' ? '%' : '');
if ( $i>0 ) { $oCell->color=array(255,0,0); $oCell->s = '+'.$oCell->s; }
if ( $i<0 ) { $oCell->color=array(0,255,0); $oCell->s = $oCell->s; }
}
else
{
$oCell->s = '.';
}
$arrRow[]=$oCell;
$arrTable[] = $arrRow;
// End table
$pdf->BasicTable($arrTable);
$pdf->Ln(3);
$pdf->SetTextColor(0);
// After values display change the null values to zero to be able to make charts
foreach($arrYears as $y)
{
$arrT[$y] = QTarrayzero($arrT[$y]);
$arrM[$y] = QTarrayzero($arrM[$y]);
$arrU[$y] = QTarrayzero($arrU[$y]);
}
// GRAPH
if ( file_exists('bin/qt_lib_graph.php') && file_exists($_SESSION[QT]['skin_dir'].'/qti_main2.css') )
{
$y = $pdf->GetY();
$x = $pdf->GetX();
// TOPIC first serie
$intTopValue = QTroof( array(max($arrT[$y-1]),max($arrT[$y])) );
if ( $ch['value']=='a' )
{
$pdf = QTbarchartpdf($pdf,$arrT[$y-1],92,30,$intTopValue,2,true,$L['Topics_per_'.$bt].' '.($y-1),'','1');
}
else
{
$pdf = QTbarchartpdf($pdf,$arrT[$y-1],92,30,$intTopValue,2,'P',$L['Topics_per_'.$bt].' (%)'.' '.($y-1),'','1');
}
$pdf->SetXY($x+94,$y);
// TOPIC second serie
if ( $ch['value']=='a' )
{
$pdf = QTbarchartpdf($pdf,$arrT[$y],92,30,$intTopValue,2,true,$L['Topics_per_'.$bt].' '.$y,'','1');
}
else
{
$pdf = QTbarchartpdf($pdf,$arrT[$y],92,30,$intTopValue,2,'P',$L['Topics_per_'.$bt].' (%)'.' '.$y,'','1');
}
$pdf->SetXY($x,$y+47);
// MESSAGES first serie
$intTopValue = QTroof( array(max($arrM[$y-1]),max($arrM[$y])) );
if ( $ch['value']=='a' )
{
$pdf = QTbarchartpdf($pdf,$arrM[$y-1],92,30,$intTopValue,2,true,$L['Topics_per_'.$bt].' '.($y-1),'','2');
}
else
{
$pdf = QTbarchartpdf($pdf,$arrM[$y-1],92,30,$intTopValue,2,'P',$L['Topics_per_'.$bt].' (%)'.' '.($y-1),'','2');
}
$pdf->SetXY($x+94,$y+47);
// MESSAGES second serie
if ( $ch['value']=='a' )
{
$pdf = QTbarchartpdf($pdf,$arrM[$y],92,30,$intTopValue,2,true,$L['Messages_per_'.$bt].' '.$y,'','2');
}
else
{
$pdf = QTbarchartpdf($pdf,$arrM[$y],92,30,$intTopValue,2,'P',$L['Messages_per_'.$bt].' (%)'.' '.$y,'','2');
}
$pdf->SetXY($x,$y+94);
// USERS first serie
$intTopValue = QTroof( array(max($arrU[$y-1]),max($arrU[$y])) );
if ( $ch['value']=='a' )
{
$pdf = QTbarchartpdf($pdf,$arrU[$y-1],92,30,$intTopValue,2,true,$L['Users_per_'.$bt].' '.($y-1),'','3');
}
else
{
$pdf = QTbarchartpdf($pdf,$arrU[$y-1],92,30,$intTopValue,2,'P',$L['Users_per_'.$bt].' (%)'.' '.($y-1),'','3');
}
$pdf->SetXY($x+94,$y+94);
// USERS second serie
if ( $ch['value']=='a' )
{
$pdf = QTbarchartpdf($pdf,$arrU[$y],92,30,$intTopValue,2,true,$L['Users_per_'.$bt].' '.$y,'','3');
}
else
{
$pdf = QTbarchartpdf($pdf,$arrU[$y],92,30,$intTopValue,2,'P',$L['Users_per_'.$bt].' (%)'.' '.$y,'','3');
}
$pdf->SetXY($x,$y+138);
}
else
{
$pdf->SetFont('Arial','',8);
$pdf->Cell(0, 10, PdfClean('Graphs cannot be displayed because one of these files is missing: bin/qt_lib_graph.php, '.$_SESSION[QT]['skin_dir'].'/qti_main2.css'), 'T', 1);
}
// Note
$pdf->SetFont('Arial','',8);
$pdf->Cell(0, 10, '* '.PdfClean($L['Distinct_users']), '', 1);
// --------
// PDF END
// --------
$pdf->Output();
?>