<?php
// QuickTicket 1.9.0.3 build:20081001
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
$strCSV = '';
$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 = 'section='.$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);
// DETAIL STATISTICS
switch($bt)
{
case 'q': $intMaxBt=4; break;
case 'd': $intMaxBt=10; break;
case 'm': $intMaxBt=12; break;
default: die('Invalid blocktime');
}
// Initialise array values. When a value is missing the display will show ·
$intCurrentYear = $intYear;
$strCurrentTendaysago = $strTendaysago;
$arrN = array();
$arrC = array();
$arrN[$intYear] = array(); $arrN[$intYear-1] = array();
$arrC[$intYear] = array(); $arrC[$intYear-1] = array();
$arrN[$intYear][$intMaxBt+1] = 0; $arrN[$intYear-1][$intMaxBt+1] = 0;
$arrC[$intYear][$intMaxBt+1] = 0; $arrC[$intYear-1][$intMaxBt+1] = 0;
// COUNT
// -----
foreach (array($intCurrentYear-1,$intCurrentYear) as $intYear) {
// -----
if ( $intCurrentYear==$intYear ) { $strTendaysago = $strCurrentTendaysago; } else { $strTendaysago = DateAdd(substr($strTendaysago,0,8),-1,'year'); }
// COUNT NEW TOPICS
for ($intBt=1;$intBt<=$intMaxBt;$intBt++)
{
// check limits (startdate/enddate)
if ( $intYear<$intStartyear ) continue;
if ( $intYear==$intStartyear )
{
if ( $bt=='m' ) {
if ( $intBt<$intStartmonth ) {
continue;
}}
if ( $bt=='q' ) {
if ( ($intBt==1 && $intStartmonth>3) || ($intBt==2 && $intStartmonth>6) || ($intBt==3 && $intStartmonth>9) ) {
continue;
}}
}
if ( $intYear>=$intEndyear )
{
if ( $bt=='m' ) {
if ( $intBt>$intEndmonth ) {
continue;
}}
if ( $bt=='q' ) {
if ( ($intBt==2 && $intEndmonth<4) || ($intBt==3 && $intEndmonth<8) || ($intBt==4 && $intEndmonth<12) ) {
continue;
}}
}
// compute per blocktime
switch(substr($oDB->type,0,5))
{
case 'mysql':
if ( $bt=='m') $oDB->Query( 'SELECT count(id) as countid FROM '.TABTOPIC.' WHERE '.$strSection.' LEFT(firstpostdate,6)="'.($intYear*100+$intBt).'"' );
if ( $bt=='q') $oDB->Query( 'SELECT count(id) as countid FROM '.TABTOPIC.' WHERE '.$strSection.' LEFT(firstpostdate,6)>"'.($intYear*100+($intBt-1)*3).'" AND LEFT(firstpostdate,6)<="'.($intYear*100+($intBt*3)).'"' );
if ( $bt=='d') $oDB->Query( 'SELECT count(id) as countid FROM '.TABTOPIC.' WHERE '.$strSection.' LEFT(firstpostdate,8)="'.(DateAdd($strTendaysago,$intBt,'day')).'"' );
break;
case 'mssql':
if ( $bt=='m') $oDB->Query( 'SELECT count(id) as countid FROM '.TABTOPIC.' WHERE '.$strSection.' LEFT(firstpostdate,6)="'.($intYear*100+$intBt).'"' );
if ( $bt=='q') $oDB->Query( 'SELECT count(id) as countid FROM '.TABTOPIC.' WHERE '.$strSection.' LEFT(firstpostdate,6)>"'.($intYear*100+($intBt-1)*3).'" AND LEFT(firstpostdate,6)<="'.($intYear*100+($intBt*3)).'"' );
if ( $bt=='d') $oDB->Query( 'SELECT count(id) as countid FROM '.TABTOPIC.' WHERE '.$strSection.' LEFT(firstpostdate,8)="'.(DateAdd($strTendaysago,$intBt,'day')).'"' );
break;
case 'pg':
if ( $bt=='m') $oDB->Query( 'SELECT count(id) as countid FROM '.TABTOPIC.' WHERE '.$strSection.' SUBSTRING(firstpostdate,1,6)="'.($intYear*100+$intBt).'"' );
if ( $bt=='q') $oDB->Query( 'SELECT count(id) as countid FROM '.TABTOPIC.' WHERE '.$strSection.' SUBSTRING(firstpostdate,1,6)>"'.($intYear*100+($intBt-1)*3).'" AND SUBSTRING(firstpostdate,1,6)<="'.($intYear*100+($intBt*3)).'"' );
if ( $bt=='d') $oDB->Query( 'SELECT count(id) as countid FROM '.TABTOPIC.' WHERE '.$strSection.' SUBSTRING(firstpostdate,1,8)="'.(DateAdd($strTendaysago,$intBt,'day')).'"' );
break;
case 'ibase':
if ( $bt=='m') $oDB->Query( 'SELECT count(id) as countid FROM '.TABTOPIC.' WHERE '.$strSection.' SUBSTRING(firstpostdate FROM 1 FOR 6)="'.($intYear*100+$intBt).'"' );
if ( $bt=='q') $oDB->Query( 'SELECT count(id) as countid FROM '.TABTOPIC.' WHERE '.$strSection.' SUBSTRING(firstpostdate FROM 1 FOR 6)>"'.($intYear*100+($intBt-1)*3).'" AND SUBSTRING(firstpostdate FROM 1 FOR 6)<="'.($intYear*100+($intBt*3)).'"' );
if ( $bt=='d') $oDB->Query( 'SELECT count(id) as countid FROM '.TABTOPIC.' WHERE '.$strSection.' SUBSTRING(firstpostdate FROM 1 FOR 8)="'.(DateAdd($strTendaysago,$intBt,'day')).'"' );
break;
case 'sqlit':
if ( $bt=='m') $oDB->Query( 'SELECT count(id) as countid FROM '.TABTOPIC.' WHERE '.$strSection.' SUBSTR(firstpostdate,1,6)="'.($intYear*100+$intBt).'"' );
if ( $bt=='q') $oDB->Query( 'SELECT count(id) as countid FROM '.TABTOPIC.' WHERE '.$strSection.' SUBSTR(firstpostdate,1,6)>"'.($intYear*100+($intBt-1)*3).'" AND SUBSTR(firstpostdate,1,6)<="'.($intYear*100+($intBt*3)).'"' );
if ( $bt=='d') $oDB->Query( 'SELECT count(id) as countid FROM '.TABTOPIC.' WHERE '.$strSection.' SUBSTR(firstpostdate,1,8)="'.(DateAdd($strTendaysago,$intBt,'day')).'"' );
break;
case 'acces':
if ( $bt=='m') $oDB->Query( 'SELECT count(id) as countid FROM '.TABTOPIC.' WHERE '.$strSection.' LEFT(firstpostdate,6)="'.($intYear*100+$intBt).'"' );
if ( $bt=='q') $oDB->Query( 'SELECT count(id) as countid FROM '.TABTOPIC.' WHERE '.$strSection.' LEFT(firstpostdate,6)>"'.($intYear*100+($intBt-1)*3).'" AND LEFT(firstpostdate,6)<="'.($intYear*100+($intBt*3)).'"' );
if ( $bt=='d') $oDB->Query( 'SELECT count(id) as countid FROM '.TABTOPIC.' WHERE '.$strSection.' LEFT(firstpostdate,8)="'.(DateAdd($strTendaysago,$intBt,'day')).'"' );
break;
case 'db2':
if ( $bt=='m') $oDB->Query( 'SELECT count(id) as countid FROM '.TABTOPIC.' WHERE '.$strSection.' SUBSTR(firstpostdate,1,6)="'.($intYear*100+$intBt).'"' );
if ( $bt=='q') $oDB->Query( 'SELECT count(id) as countid FROM '.TABTOPIC.' WHERE '.$strSection.' SUBSTR(firstpostdate,1,6)>"'.($intYear*100+($intBt-1)*3).'" AND SUBSTR(firstpostdate,1,6)<="'.($intYear*100+($intBt*3)).'"' );
if ( $bt=='d') $oDB->Query( 'SELECT count(id) as countid FROM '.TABTOPIC.' WHERE '.$strSection.' SUBSTR(firstpostdate,1,8)="'.(DateAdd($strTendaysago,$intBt,'day')).'"' );
break;
case 'ifx':
if ( $bt=='m') $oDB->Query( 'SELECT count(id) as countid FROM '.TABTOPIC.' WHERE '.$strSection.' SUBSTRING(firstpostdate,1,6)="'.($intYear*100+$intBt).'"' );
if ( $bt=='q') $oDB->Query( 'SELECT count(id) as countid FROM '.TABTOPIC.' WHERE '.$strSection.' SUBSTRING(firstpostdate,1,6)>"'.($intYear*100+($intBt-1)*3).'" AND SUBSTRING(firstpostdate,1,6)<="'.($intYear*100+($intBt*3)).'"' );
if ( $bt=='d') $oDB->Query( 'SELECT count(id) as countid FROM '.TABTOPIC.' WHERE '.$strSection.' SUBSTRING(firstpostdate,1,8)="'.(DateAdd($strTendaysago,$intBt,'day')).'"' );
break;
case 'oci':
if ( $bt=='m') $oDB->Query( 'SELECT count(id) as countid FROM '.TABTOPIC.' WHERE '.$strSection.' SUBSTR(firstpostdate,1,6)="'.($intYear*100+$intBt).'"' );
if ( $bt=='q') $oDB->Query( 'SELECT count(id) as countid FROM '.TABTOPIC.' WHERE '.$strSection.' SUBSTR(firstpostdate,1,6)>"'.($intYear*100+($intBt-1)*3).'" AND SUBSTR(firstpostdate,1,6)<="'.($intYear*100+($intBt*3)).'"' );
if ( $bt=='d') $oDB->Query( 'SELECT count(id) as countid FROM '.TABTOPIC.' WHERE '.$strSection.' SUBSTR(firstpostdate,1,8)="'.(DateAdd($strTendaysago,$intBt,'day')).'"' );
break;
default: die('Unknown db type '.$oDB->type);
}
$row = $oDB->Getrow();
$arrN[$intYear][$intBt] = intval($row['countid']);
$arrN[$intYear][$intMaxBt+1] += $arrN[$intYear][$intBt]; // total
}
// COUNT CLOSED TOPICS
for ($intBt=1;$intBt<=$intMaxBt;$intBt++)
{
// check limits (startdate/enddate)
if ( $intYear<$intStartyear ) continue;
if ( $intYear==$intStartyear )
{
if ( $bt=='m' ) {
if ( $intBt<$intStartmonth ) {
continue;
}}
if ( $bt=='q' ) {
if ( ($intBt==1 && $intStartmonth>3) || ($intBt==2 && $intStartmonth>6) || ($intBt==3 && $intStartmonth>9) ) {
continue;
}}
}
if ( $intYear>=$intEndyear )
{
if ( $bt=='m' ) {
if ( $intBt>$intEndmonth ) {
continue;
}}
if ( $bt=='q' ) {
if ( ($intBt==2 && $intEndmonth<4) || ($intBt==3 && $intEndmonth<8) || ($intBt==4 && $intEndmonth<12) ) {
continue;
}}
}
// compute per blocktime
switch(substr($oDB->type,0,5))
{
case 'mysql':
if ( $bt=='m') $oDB->Query( 'SELECT count(id) as countid FROM '.TABTOPIC.' WHERE '.$strSection.' status="Z" AND LEFT(lastpostdate,6)="'.($intYear*100+$intBt).'"' );
if ( $bt=='q') $oDB->Query( 'SELECT count(id) as countid FROM '.TABTOPIC.' WHERE '.$strSection.' status="Z" AND LEFT(lastpostdate,6)>"'.($intYear*100+($intBt-1)*3).'" AND LEFT(lastpostdate,6)<="'.($intYear*100+($intBt*3)).'"' );
if ( $bt=='d') $oDB->Query( 'SELECT count(id) as countid FROM '.TABTOPIC.' WHERE '.$strSection.' status="Z" AND LEFT(lastpostdate,8)="'.(DateAdd($strTendaysago,$intBt,'day')).'"' );
break;
case 'mssql':
if ( $bt=='m') $oDB->Query( 'SELECT count(id) as countid FROM '.TABTOPIC.' WHERE '.$strSection.' status="Z" AND LEFT(lastpostdate,6)="'.($intYear*100+$intBt).'"' );
if ( $bt=='q') $oDB->Query( 'SELECT count(id) as countid FROM '.TABTOPIC.' WHERE '.$strSection.' status="Z" AND LEFT(lastpostdate,6)>"'.($intYear*100+($intBt-1)*3).'" AND LEFT(lastpostdate,6)<="'.($intYear*100+($intBt*3)).'"' );
if ( $bt=='d') $oDB->Query( 'SELECT count(id) as countid FROM '.TABTOPIC.' WHERE '.$strSection.' status="Z" AND LEFT(lastpostdate,8)="'.(DateAdd($strTendaysago,$intBt,'day')).'"' );
break;
case 'pg':
if ( $bt=='m') $oDB->Query( 'SELECT count(id) as countid FROM '.TABTOPIC.' WHERE '.$strSection.' status="Z" AND SUBSTRING(lastpostdate,1,6)="'.($intYear*100+$intBt).'"' );
if ( $bt=='q') $oDB->Query( 'SELECT count(id) as countid FROM '.TABTOPIC.' WHERE '.$strSection.' status="Z" AND SUBSTRING(lastpostdate,1,6)>"'.($intYear*100+($intBt-1)*3).'" AND SUBSTRING(lastpostdate,1,6)<="'.($intYear*100+($intBt*3)).'"' );
if ( $bt=='d') $oDB->Query( 'SELECT count(id) as countid FROM '.TABTOPIC.' WHERE '.$strSection.' status="Z" AND SUBSTRING(lastpostdate,1,8)="'.(DateAdd($strTendaysago,$intBt,'day')).'"' );
break;
case 'ibase':
if ( $bt=='m') $oDB->Query( 'SELECT count(id) as countid FROM '.TABTOPIC.' WHERE '.$strSection.' status="Z" AND SUBSTRING(lastpostdate FROM 1 FOR 6)="'.($intYear*100+$intBt).'"' );
if ( $bt=='q') $oDB->Query( 'SELECT count(id) as countid FROM '.TABTOPIC.' WHERE '.$strSection.' status="Z" AND SUBSTRING(lastpostdate FROM 1 FOR 6)>"'.($intYear*100+($intBt-1)*3).'" AND SUBSTRING(lastpostdate FROM 1 FOR 6)<="'.($intYear*100+($intBt*3)).'"' );
if ( $bt=='d') $oDB->Query( 'SELECT count(id) as countid FROM '.TABTOPIC.' WHERE '.$strSection.' status="Z" AND SUBSTRING(lastpostdate FROM 1 FOR 8)="'.(DateAdd($strTendaysago,$intBt,'day')).'"' );
break;
case 'sqlit':
if ( $bt=='m') $oDB->Query( 'SELECT count(id) as countid FROM '.TABTOPIC.' WHERE '.$strSection.' status="Z" AND SUBSTR(lastpostdate,1,6)="'.($intYear*100+$intBt).'"' );
if ( $bt=='q') $oDB->Query( 'SELECT count(id) as countid FROM '.TABTOPIC.' WHERE '.$strSection.' status="Z" AND SUBSTR(lastpostdate,1,6)>"'.($intYear*100+($intBt-1)*3).'" AND SUBSTR(lastpostdate,1,6)<="'.($intYear*100+($intBt*3)).'"' );
if ( $bt=='d') $oDB->Query( 'SELECT count(id) as countid FROM '.TABTOPIC.' WHERE '.$strSection.' status="Z" AND SUBSTR(lastpostdate,1,8)="'.(DateAdd($strTendaysago,$intBt,'day')).'"' );
break;
case 'acces':
if ( $bt=='m') $oDB->Query( 'SELECT count(id) as countid FROM '.TABTOPIC.' WHERE '.$strSection.' status="Z" AND LEFT(lastpostdate,6)="'.($intYear*100+$intBt).'"' );
if ( $bt=='q') $oDB->Query( 'SELECT count(id) as countid FROM '.TABTOPIC.' WHERE '.$strSection.' status="Z" AND LEFT(lastpostdate,6)>"'.($intYear*100+($intBt-1)*3).'" AND LEFT(lastpostdate,6)<="'.($intYear*100+($intBt*3)).'"' );
if ( $bt=='d') $oDB->Query( 'SELECT count(id) as countid FROM '.TABTOPIC.' WHERE '.$strSection.' status="Z" AND LEFT(lastpostdate,8)="'.(DateAdd($strTendaysago,$intBt,'day')).'"' );
break;
case 'db2':
if ( $bt=='m') $oDB->Query( 'SELECT count(id) as countid FROM '.TABTOPIC.' WHERE '.$strSection.' status="Z" AND SUBSTR(lastpostdate,1,6)="'.($intYear*100+$intBt).'"' );
if ( $bt=='q') $oDB->Query( 'SELECT count(id) as countid FROM '.TABTOPIC.' WHERE '.$strSection.' status="Z" AND SUBSTR(lastpostdate,1,6)>"'.($intYear*100+($intBt-1)*3).'" AND SUBSTR(lastpostdate,1,6)<="'.($intYear*100+($intBt*3)).'"' );
if ( $bt=='d') $oDB->Query( 'SELECT count(id) as countid FROM '.TABTOPIC.' WHERE '.$strSection.' status="Z" AND SUBSTR(lastpostdate,1,8)="'.(DateAdd($strTendaysago,$intBt,'day')).'"' );
break;
case 'ifx':
if ( $bt=='m') $oDB->Query( 'SELECT count(id) as countid FROM '.TABTOPIC.' WHERE '.$strSection.' status="Z" AND SUBSTRING(lastpostdate,1,6)="'.($intYear*100+$intBt).'"' );
if ( $bt=='q') $oDB->Query( 'SELECT count(id) as countid FROM '.TABTOPIC.' WHERE '.$strSection.' status="Z" AND SUBSTRING(lastpostdate,1,6)>"'.($intYear*100+($intBt-1)*3).'" AND SUBSTRING(lastpostdate,1,6)<="'.($intYear*100+($intBt*3)).'"' );
if ( $bt=='d') $oDB->Query( 'SELECT count(id) as countid FROM '.TABTOPIC.' WHERE '.$strSection.' status="Z" AND SUBSTRING(lastpostdate,1,8)="'.(DateAdd($strTendaysago,$intBt,'day')).'"' );
break;
case 'oci':
if ( $bt=='m') $oDB->Query( 'SELECT count(id) as countid FROM '.TABTOPIC.' WHERE '.$strSection.' status="Z" AND SUBSTR(lastpostdate,1,6)="'.($intYear*100+$intBt).'"' );
if ( $bt=='q') $oDB->Query( 'SELECT count(id) as countid FROM '.TABTOPIC.' WHERE '.$strSection.' status="Z" AND SUBSTR(lastpostdate,1,6)>"'.($intYear*100+($intBt-1)*3).'" AND SUBSTR(lastpostdate,1,6)<="'.($intYear*100+($intBt*3)).'"' );
if ( $bt=='d') $oDB->Query( 'SELECT count(id) as countid FROM '.TABTOPIC.' WHERE '.$strSection.' status="Z" AND SUBSTR(lastpostdate,1,8)="'.(DateAdd($strTendaysago,$intBt,'day')).'"' );
break;
default: die('Unknown db type '.$oDB->type);
}
$row = $oDB->Getrow();
$arrC[$intYear][$intBt] = intval($row['countid']);
$arrC[$intYear][$intMaxBt+1] += $arrC[$intYear][$intBt]; // total
}
// -----
}
// -----
// OUTPUT
// -----
foreach (array($intCurrentYear-1,$intCurrentYear) as $intYear) {
// -----
// Table header
$strCSV .= '"'.$intYear.'";';
switch($bt)
{
case 'q': for ($i=1;$i<=$intMaxBt;$i++) { $strCSV .= '"Q'.$i.'";'; } break;
case 'm': for ($i=1;$i<=$intMaxBt;$i++) { $strCSV .= '"'.$L['dateMM'][$i].'";'; } break;
case 'd': for ($i=1;$i<=$intMaxBt;$i++) { $strCSV .= '"'.QTdate( DateAdd($strTendaysago,$i,'day'),array('n','date','d M') ).'";'; } break;
}
$strCSV .= '"'.($bt=='d' ? '10 days' : $L['Year']).'"<br/>';
$strCSV .= '"'.$L['New_topics'].'";';
for ($intBt=1;$intBt<=$intMaxBt;$intBt++) { $strCSV .= (isset($arrN[$intYear][$intBt]) ? $arrN[$intYear][$intBt] : '0').';'; }
$strCSV .= $arrN[$intYear][$intMaxBt+1].'<br/>';
$strCSV .= '"'.$L['Closed_topics'].'";';
for ($intBt=1;$intBt<=$intMaxBt;$intBt++) { $strCSV .= (isset($arrC[$intYear][$intBt]) ? $arrC[$intYear][$intBt] : '0').';'; }
$strCSV .= $arrC[$intYear][$intMaxBt+1].'<br/><br/>';
// -----
}
// -----
// DISPLAY TRENDS
// Table header
$strCSV .= '"'.$L['Trends'].'";';
switch($bt)
{
case 'q': for ($i=1;$i<=$intMaxBt;$i++) { $strCSV .= '"Q'.$i.'";'; } break;
case 'm': for ($i=1;$i<=$intMaxBt;$i++) { $strCSV .= '"'.$L['dateMM'][$i].'";'; } break;
case 'd': for ($i=1;$i<=$intMaxBt;$i++) { $strCSV .= '"'.QTdate( DateAdd($strTendaysago,$i,'day'),array('n','date','d M') ).'";'; } break;
}
$strCSV .= '"'.($bt=='d' ? '10 days' : $L['Year']).'"<br/>';
// New_topics trends
$strCSV .= $L['New_topics'].';';
for ($intBt=1;$intBt<=$intMaxBt;$intBt++)
{
$i = 0;
if ( isset($arrN[$intCurrentYear][$intBt]) && isset($arrN[$intCurrentYear-1][$intBt]) )
{
$i = $arrN[$intCurrentYear][$intBt]-$arrN[$intCurrentYear-1][$intBt];
if ( $tr=='p' && $i!=0 )
{
if ( $arrN[$intCurrentYear-1][$intBt]==0 ) $arrN[$intCurrentYear-1][$intBt]=1;
$i = intval(($i/$arrN[$intCurrentYear-1][$intBt])*100);
}
}
$strCSV .= $i.';';
}
$i = 0;
if ( isset($arrN[$intCurrentYear][$intMaxBt+1]) && isset($arrN[$intCurrentYear-1][$intMaxBt+1]) )
{
$i = $arrN[$intCurrentYear][$intMaxBt+1]-$arrN[$intCurrentYear-1][$intMaxBt+1];
if ( $tr=='p' && $i!=0 )
{
if ( $arrN[$intCurrentYear-1][$intMaxBt+1]==0 ) $arrN[$intCurrentYear-1][$intMaxBt+1]=1;
$i = intval(($i/$arrN[$intCurrentYear-1][$intMaxBt+1])*100);
}
}
$strCSV .= $i.'<br/>';
// Closed_topics trends
$strCSV .= $L['Closed_topics'].';';
for ($intBt=1;$intBt<=$intMaxBt;$intBt++)
{
$i = 0;
if ( isset($arrC[$intCurrentYear][$intBt]) && isset($arrC[$intCurrentYear-1][$intBt]) )
{
$i = $arrC[$intCurrentYear][$intBt]-$arrC[$intCurrentYear-1][$intBt];
if ( $tr=='p' && $i!=0 )
{
if ( $arrC[$intCurrentYear-1][$intBt]==0 ) $arrC[$intCurrentYear-1][$intBt]=1;
$i = intval(($i/$arrC[$intCurrentYear-1][$intBt])*100);
}
}
$strCSV .= $i.';';
}
$i = 0;
if ( isset($arrC[$intCurrentYear][$intMaxBt+1]) && isset($arrC[$intCurrentYear-1][$intMaxBt+1]) )
{
$i = $arrC[$intCurrentYear][$intMaxBt+1]-$arrC[$intCurrentYear-1][$intMaxBt+1];
if ( $tr=='p' && $i!=0 )
{
if ( $arrC[$intCurrentYear-1][$intMaxBt+1]==0 ) $arrC[$intCurrentYear-1][$intMaxBt+1]=1;
$i = intval(($i/$arrC[$intCurrentYear-1][$intMaxBt+1])*100);
}
}
$strCSV .= $i.'<br/>';
if (!headers_sent())
{
$strCSV = str_replace('<br/>',"\r\n",$strCSV);
header('Content-Type: text/csv; charset='.QTI_HTML_CHAR);
header('Content-Disposition: attachment; filename="global_stat_'.$intYear.'.csv"');
}
echo $strCSV;
?>