<?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);
// 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);
// GLOBAL 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 ·
$arrT = array();
$arrM = array();
$arrU = array();
$arrT[$intMaxBt+1] = 0;
$arrM[$intMaxBt+1] = 0;
$arrU[$intMaxBt+1] = 0;
// 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/>';
// COUNT 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 '.TABPOST.' WHERE '.$strSection.' type="P" AND LEFT(issuedate,6)="'.($intYear*100+$intBt).'"' );
if ( $bt=='q') $oDB->Query( 'SELECT count(id) as countid FROM '.TABPOST.' WHERE '.$strSection.' type="P" AND LEFT(issuedate,6)>"'.($intYear*100+($intBt-1)*3).'" AND LEFT(issuedate,6)<="'.($intYear*100+($intBt*3)).'"' );
if ( $bt=='d') $oDB->Query( 'SELECT count(id) as countid FROM '.TABPOST.' WHERE '.$strSection.' type="P" AND LEFT(issuedate,8)="'.(DateAdd($strTendaysago,$intBt,'day')).'"' );
break;
case 'mssql':
if ( $bt=='m') $oDB->Query( 'SELECT count(id) as countid FROM '.TABPOST.' WHERE '.$strSection.' type="P" AND LEFT(issuedate,6)="'.($intYear*100+$intBt).'"' );
if ( $bt=='q') $oDB->Query( 'SELECT count(id) as countid FROM '.TABPOST.' WHERE '.$strSection.' type="P" AND LEFT(issuedate,6)>"'.($intYear*100+($intBt-1)*3).'" AND LEFT(issuedate,6)<="'.($intYear*100+($intBt*3)).'"' );
if ( $bt=='d') $oDB->Query( 'SELECT count(id) as countid FROM '.TABPOST.' WHERE '.$strSection.' type="P" AND LEFT(issuedate,8)="'.(DateAdd($strTendaysago,$intBt,'day')).'"' );
break;
case 'pg':
if ( $bt=='m') $oDB->Query( 'SELECT count(id) as countid FROM '.TABPOST.' WHERE '.$strSection.' type="P" AND SUBSTRING(issuedate,1,6)="'.($intYear*100+$intBt).'"' );
if ( $bt=='q') $oDB->Query( 'SELECT count(id) as countid FROM '.TABPOST.' WHERE '.$strSection.' type="P" AND SUBSTRING(issuedate,1,6)>"'.($intYear*100+($intBt-1)*3).'" AND SUBSTRING(issuedate,1,6)<="'.($intYear*100+($intBt*3)).'"' );
if ( $bt=='d') $oDB->Query( 'SELECT count(id) as countid FROM '.TABPOST.' WHERE '.$strSection.' type="P" AND SUBSTRING(issuedate,1,8)="'.(DateAdd($strTendaysago,$intBt,'day')).'"' );
break;
case 'ibase':
if ( $bt=='m') $oDB->Query( 'SELECT count(id) as countid FROM '.TABPOST.' WHERE '.$strSection.' type="P" AND SUBSTRING(issuedate FROM 1 FOR 6)="'.($intYear*100+$intBt).'"' );
if ( $bt=='q') $oDB->Query( 'SELECT count(id) as countid FROM '.TABPOST.' WHERE '.$strSection.' type="P" AND SUBSTRING(issuedate FROM 1 FOR 6)>"'.($intYear*100+($intBt-1)*3).'" AND SUBSTRING(issuedate FROM 1 FOR 6)<="'.($intYear*100+($intBt*3)).'"' );
if ( $bt=='d') $oDB->Query( 'SELECT count(id) as countid FROM '.TABPOST.' WHERE '.$strSection.' type="P" AND SUBSTRING(issuedate FROM 1 FOR 8)="'.(DateAdd($strTendaysago,$intBt,'day')).'"' );
break;
case 'sqlit':
if ( $bt=='m') $oDB->Query( 'SELECT count(id) as countid FROM '.TABPOST.' WHERE '.$strSection.' type="P" AND SUBSTR(issuedate,1,6)="'.($intYear*100+$intBt).'"' );
if ( $bt=='q') $oDB->Query( 'SELECT count(id) as countid FROM '.TABPOST.' WHERE '.$strSection.' type="P" AND SUBSTR(issuedate,1,6)>"'.($intYear*100+($intBt-1)*3).'" AND SUBSTR(issuedate,1,6)<="'.($intYear*100+($intBt*3)).'"' );
if ( $bt=='d') $oDB->Query( 'SELECT count(id) as countid FROM '.TABPOST.' WHERE '.$strSection.' type="P" AND SUBSTR(issuedate,1,8)="'.(DateAdd($strTendaysago,$intBt,'day')).'"' );
break;
case 'acces':
if ( $bt=='m') $oDB->Query( 'SELECT count(id) as countid FROM '.TABPOST.' WHERE '.$strSection.' type="P" AND LEFT(issuedate,6)="'.($intYear*100+$intBt).'"' );
if ( $bt=='q') $oDB->Query( 'SELECT count(id) as countid FROM '.TABPOST.' WHERE '.$strSection.' type="P" AND LEFT(issuedate,6)>"'.($intYear*100+($intBt-1)*3).'" AND LEFT(issuedate,6)<="'.($intYear*100+($intBt*3)).'"' );
if ( $bt=='d') $oDB->Query( 'SELECT count(id) as countid FROM '.TABPOST.' WHERE '.$strSection.' type="P" AND LEFT(issuedate,8)="'.(DateAdd($strTendaysago,$intBt,'day')).'"' );
break;
case 'db2':
if ( $bt=='m') $oDB->Query( 'SELECT count(id) as countid FROM '.TABPOST.' WHERE '.$strSection.' type="P" AND SUBSTR(issuedate,1,6)="'.($intYear*100+$intBt).'"' );
if ( $bt=='q') $oDB->Query( 'SELECT count(id) as countid FROM '.TABPOST.' WHERE '.$strSection.' type="P" AND SUBSTR(issuedate,1,6)>"'.($intYear*100+($intBt-1)*3).'" AND SUBSTR(issuedate,1,6)<="'.($intYear*100+($intBt*3)).'"' );
if ( $bt=='d') $oDB->Query( 'SELECT count(id) as countid FROM '.TABPOST.' WHERE '.$strSection.' type="P" AND SUBSTR(issuedate,1,8)="'.(DateAdd($strTendaysago,$intBt,'day')).'"' );
break;
case 'ifx':
if ( $bt=='m') $oDB->Query( 'SELECT count(id) as countid FROM '.TABPOST.' WHERE '.$strSection.' type="P" AND SUBSTRING(issuedate,1,6)="'.($intYear*100+$intBt).'"' );
if ( $bt=='q') $oDB->Query( 'SELECT count(id) as countid FROM '.TABPOST.' WHERE '.$strSection.' type="P" AND SUBSTRING(issuedate,1,6)>"'.($intYear*100+($intBt-1)*3).'" AND SUBSTRING(issuedate,1,6)<="'.($intYear*100+($intBt*3)).'"' );
if ( $bt=='d') $oDB->Query( 'SELECT count(id) as countid FROM '.TABPOST.' WHERE '.$strSection.' type="P" AND SUBSTRING(issuedate,1,8)="'.(DateAdd($strTendaysago,$intBt,'day')).'"' );
break;
case 'oci':
if ( $bt=='m') $oDB->Query( 'SELECT count(id) as countid FROM '.TABPOST.' WHERE '.$strSection.' type="P" AND SUBSTR(issuedate,1,6)="'.($intYear*100+$intBt).'"' );
if ( $bt=='q') $oDB->Query( 'SELECT count(id) as countid FROM '.TABPOST.' WHERE '.$strSection.' type="P" AND SUBSTR(issuedate,1,6)>"'.($intYear*100+($intBt-1)*3).'" AND SUBSTR(issuedate,1,6)<="'.($intYear*100+($intBt*3)).'"' );
if ( $bt=='d') $oDB->Query( 'SELECT count(id) as countid FROM '.TABPOST.' WHERE '.$strSection.' type="P" AND SUBSTR(issuedate,1,8)="'.(DateAdd($strTendaysago,$intBt,'day')).'"' );
break;
default: die('Unknown db type '.$oDB->type);
}
$row = $oDB->Getrow();
$arrT[$intBt] = intval($row['countid']);
$arrT[$intMaxBt+1] += intval($row['countid']);
}
// COUNT POST
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 '.TABPOST.' WHERE '.$strSection.' LEFT(issuedate,6)="'.($intYear*100+$intBt).'"' );
if ( $bt=='q') $oDB->Query( 'SELECT count(id) as countid FROM '.TABPOST.' WHERE '.$strSection.' LEFT(issuedate,6)>"'.($intYear*100+($intBt-1)*3).'" AND LEFT(issuedate,6)<="'.($intYear*100+($intBt*3)).'"' );
if ( $bt=='d') $oDB->Query( 'SELECT count(id) as countid FROM '.TABPOST.' WHERE '.$strSection.' LEFT(issuedate,8)="'.(DateAdd($strTendaysago,$intBt,'day')).'"' );
break;
case 'mssql':
if ( $bt=='m') $oDB->Query( 'SELECT count(id) as countid FROM '.TABPOST.' WHERE '.$strSection.' LEFT(issuedate,6)="'.($intYear*100+$intBt).'"' );
if ( $bt=='q') $oDB->Query( 'SELECT count(id) as countid FROM '.TABPOST.' WHERE '.$strSection.' LEFT(issuedate,6)>"'.($intYear*100+($intBt-1)*3).'" AND LEFT(issuedate,6)<="'.($intYear*100+($intBt*3)).'"' );
if ( $bt=='d') $oDB->Query( 'SELECT count(id) as countid FROM '.TABPOST.' WHERE '.$strSection.' LEFT(issuedate,8)="'.(DateAdd($strTendaysago,$intBt,'day')).'"' );
break;
case 'pg':
if ( $bt=='m') $oDB->Query( 'SELECT count(id) as countid FROM '.TABPOST.' WHERE '.$strSection.' SUBSTRING(issuedate,1,6)="'.($intYear*100+$intBt).'"' );
if ( $bt=='q') $oDB->Query( 'SELECT count(id) as countid FROM '.TABPOST.' WHERE '.$strSection.' SUBSTRING(issuedate,1,6)>"'.($intYear*100+($intBt-1)*3).'" AND SUBSTRING(issuedate,1,6)<="'.($intYear*100+($intBt*3)).'"' );
if ( $bt=='d') $oDB->Query( 'SELECT count(id) as countid FROM '.TABPOST.' WHERE '.$strSection.' SUBSTRING(issuedate,1,8)="'.(DateAdd($strTendaysago,$intBt,'day')).'"' );
break;
case 'ibase':
if ( $bt=='m') $oDB->Query( 'SELECT count(id) as countid FROM '.TABPOST.' WHERE '.$strSection.' SUBSTRING(issuedate FROM 1 FOR 6)="'.($intYear*100+$intBt).'"' );
if ( $bt=='q') $oDB->Query( 'SELECT count(id) as countid FROM '.TABPOST.' WHERE '.$strSection.' SUBSTRING(issuedate FROM 1 FOR 6)>"'.($intYear*100+($intBt-1)*3).'" AND SUBSTRING(issuedate FROM 1 FOR 6)<="'.($intYear*100+($intBt*3)).'"' );
if ( $bt=='d') $oDB->Query( 'SELECT count(id) as countid FROM '.TABPOST.' WHERE '.$strSection.' SUBSTRING(issuedate FROM 1 FOR 8)="'.(DateAdd($strTendaysago,$intBt,'day')).'"' );
break;
case 'sqlit':
if ( $bt=='m') $oDB->Query( 'SELECT count(id) as countid FROM '.TABPOST.' WHERE '.$strSection.' SUBSTR(issuedate,1,6)="'.($intYear*100+$intBt).'"' );
if ( $bt=='q') $oDB->Query( 'SELECT count(id) as countid FROM '.TABPOST.' WHERE '.$strSection.' SUBSTR(issuedate,1,6)>"'.($intYear*100+($intBt-1)*3).'" AND SUBSTR(issuedate,1,6)<="'.($intYear*100+($intBt*3)).'"' );
if ( $bt=='d') $oDB->Query( 'SELECT count(id) as countid FROM '.TABPOST.' WHERE '.$strSection.' SUBSTR(issuedate,1,8)="'.(DateAdd($strTendaysago,$intBt,'day')).'"' );
break;
case 'acces':
if ( $bt=='m') $oDB->Query( 'SELECT count(id) as countid FROM '.TABPOST.' WHERE '.$strSection.' LEFT(issuedate,6)="'.($intYear*100+$intBt).'"' );
if ( $bt=='q') $oDB->Query( 'SELECT count(id) as countid FROM '.TABPOST.' WHERE '.$strSection.' LEFT(issuedate,6)>"'.($intYear*100+($intBt-1)*3).'" AND LEFT(issuedate,6)<="'.($intYear*100+($intBt*3)).'"' );
if ( $bt=='d') $oDB->Query( 'SELECT count(id) as countid FROM '.TABPOST.' WHERE '.$strSection.' LEFT(issuedate,8)="'.(DateAdd($strTendaysago,$intBt,'day')).'"' );
break;
case 'db2':
if ( $bt=='m') $oDB->Query( 'SELECT count(id) as countid FROM '.TABPOST.' WHERE '.$strSection.' SUBSTR(issuedate,1,6)="'.($intYear*100+$intBt).'"' );
if ( $bt=='q') $oDB->Query( 'SELECT count(id) as countid FROM '.TABPOST.' WHERE '.$strSection.' SUBSTR(issuedate,1,6)>"'.($intYear*100+($intBt-1)*3).'" AND SUBSTR(issuedate,1,6)<="'.($intYear*100+($intBt*3)).'"' );
if ( $bt=='d') $oDB->Query( 'SELECT count(id) as countid FROM '.TABPOST.' WHERE '.$strSection.' SUBSTR(issuedate,1,8)="'.(DateAdd($strTendaysago,$intBt,'day')).'"' );
break;
case 'ifx':
if ( $bt=='m') $oDB->Query( 'SELECT count(id) as countid FROM '.TABPOST.' WHERE '.$strSection.' SUBSTRING(issuedate,1,6)="'.($intYear*100+$intBt).'"' );
if ( $bt=='q') $oDB->Query( 'SELECT count(id) as countid FROM '.TABPOST.' WHERE '.$strSection.' SUBSTRING(issuedate,1,6)>"'.($intYear*100+($intBt-1)*3).'" AND SUBSTRING(issuedate,1,6)<="'.($intYear*100+($intBt*3)).'"' );
if ( $bt=='d') $oDB->Query( 'SELECT count(id) as countid FROM '.TABPOST.' WHERE '.$strSection.' SUBSTRING(issuedate,1,8)="'.(DateAdd($strTendaysago,$intBt,'day')).'"' );
break;
case 'oci':
if ( $bt=='m') $oDB->Query( 'SELECT count(id) as countid FROM '.TABPOST.' WHERE '.$strSection.' SUBSTR(issuedate,1,6)="'.($intYear*100+$intBt).'"' );
if ( $bt=='q') $oDB->Query( 'SELECT count(id) as countid FROM '.TABPOST.' WHERE '.$strSection.' SUBSTR(issuedate,1,6)>"'.($intYear*100+($intBt-1)*3).'" AND SUBSTR(issuedate,1,6)<="'.($intYear*100+($intBt*3)).'"' );
if ( $bt=='d') $oDB->Query( 'SELECT count(id) as countid FROM '.TABPOST.' WHERE '.$strSection.' SUBSTR(issuedate,1,8)="'.(DateAdd($strTendaysago,$intBt,'day')).'"' );
break;
default: die('Unknown db type '.$oDB->type);
}
$row = $oDB->Getrow();
$arrM[$intBt] = intval($row['countid']);
$arrM[$intMaxBt+1] += intval($row['countid']);
}
// COUNT USERS
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(DISTINCT userid) as countid FROM '.TABPOST.' WHERE '.$strSection.' LEFT(issuedate,6)="'.($intYear*100+$intBt).'"' );
if ( $bt=='q') $oDB->Query( 'SELECT COUNT(DISTINCT userid) as countid FROM '.TABPOST.' WHERE '.$strSection.' LEFT(issuedate,6)>"'.($intYear*100+($intBt-1)*3).'" AND LEFT(issuedate,6)<="'.($intYear*100+($intBt*3)).'"' );
if ( $bt=='d') $oDB->Query( 'SELECT COUNT(DISTINCT userid) as countid FROM '.TABPOST.' WHERE '.$strSection.' LEFT(issuedate,8)="'.(DateAdd($strTendaysago,$intBt,'day')).'"' );
break;
case 'mssql':
if ( $bt=='m') $oDB->Query( 'SELECT COUNT(DISTINCT userid) as countid FROM '.TABPOST.' WHERE '.$strSection.' LEFT(issuedate,6)="'.($intYear*100+$intBt).'"' );
if ( $bt=='q') $oDB->Query( 'SELECT COUNT(DISTINCT userid) as countid FROM '.TABPOST.' WHERE '.$strSection.' LEFT(issuedate,6)>"'.($intYear*100+($intBt-1)*3).'" AND LEFT(issuedate,6)<="'.($intYear*100+($intBt*3)).'"' );
if ( $bt=='d') $oDB->Query( 'SELECT COUNT(DISTINCT userid) as countid FROM '.TABPOST.' WHERE '.$strSection.' LEFT(issuedate,8)="'.(DateAdd($strTendaysago,$intBt,'day')).'"' );
break;
case 'pg':
if ( $bt=='m') $oDB->Query( 'SELECT COUNT(DISTINCT userid) as countid FROM '.TABPOST.' WHERE '.$strSection.' SUBSTRING(issuedate,1,6)="'.($intYear*100+$intBt).'"' );
if ( $bt=='q') $oDB->Query( 'SELECT COUNT(DISTINCT userid) as countid FROM '.TABPOST.' WHERE '.$strSection.' SUBSTRING(issuedate,1,6)>"'.($intYear*100+($intBt-1)*3).'" AND SUBSTRING(issuedate,1,6)<="'.($intYear*100+($intBt*3)).'"' );
if ( $bt=='d') $oDB->Query( 'SELECT COUNT(DISTINCT userid) as countid FROM '.TABPOST.' WHERE '.$strSection.' SUBSTRING(issuedate,1,8)="'.(DateAdd($strTendaysago,$intBt,'day')).'"' );
break;
case 'ibase':
if ( $bt=='m') $oDB->Query( 'SELECT COUNT(DISTINCT userid) as countid FROM '.TABPOST.' WHERE '.$strSection.' SUBSTRING(issuedate FROM 1 FOR 6)="'.($intYear*100+$intBt).'"' );
if ( $bt=='q') $oDB->Query( 'SELECT COUNT(DISTINCT userid) as countid FROM '.TABPOST.' WHERE '.$strSection.' SUBSTRING(issuedate FROM 1 FOR 6)>"'.($intYear*100+($intBt-1)*3).'" AND SUBSTRING(issuedate FROM 1 FOR 6)<="'.($intYear*100+($intBt*3)).'"' );
if ( $bt=='d') $oDB->Query( 'SELECT COUNT(DISTINCT userid) as countid FROM '.TABPOST.' WHERE '.$strSection.' SUBSTRING(issuedate FROM 1 FOR 8)="'.(DateAdd($strTendaysago,$intBt,'day')).'"' );
break;
case 'sqlit':
if ( $bt=='m') $oDB->Query( 'SELECT COUNT(*) as countid FROM (SELECT DISTINCT userid FROM '.TABPOST.' WHERE '.$strSection.' SUBSTR(issuedate,1,6)="'.($intYear*100+$intBt).'")' );
if ( $bt=='q') $oDB->Query( 'SELECT COUNT(*) as countid FROM (SELECT DISTINCT userid FROM '.TABPOST.' WHERE '.$strSection.' SUBSTR(issuedate,1,6)>"'.($intYear*100+($intBt-1)*3).'" AND SUBSTR(issuedate,1,6)<="'.($intYear*100+($intBt*3)).'")' );
if ( $bt=='d') $oDB->Query( 'SELECT COUNT(*) as countid FROM (SELECT DISTINCT userid FROM '.TABPOST.' WHERE '.$strSection.' SUBSTR(issuedate,1,8)="'.(DateAdd($strTendaysago,$intBt,'day')).'")' );
break;
case 'acces':
if ( $bt=='m') $oDB->Query( 'SELECT COUNT(*) as countid FROM (SELECT DISTINCT userid FROM '.TABPOST.' WHERE '.$strSection.' LEFT(issuedate,6)="'.($intYear*100+$intBt).'")' );
if ( $bt=='q') $oDB->Query( 'SELECT COUNT(*) as countid FROM (SELECT DISTINCT userid FROM '.TABPOST.' WHERE '.$strSection.' LEFT(issuedate,6)>"'.($intYear*100+($intBt-1)*3).'" AND LEFT(issuedate,6)<="'.($intYear*100+($intBt*3)).'")' );
if ( $bt=='d') $oDB->Query( 'SELECT COUNT(*) as countid FROM (SELECT DISTINCT userid FROM '.TABPOST.' WHERE '.$strSection.' LEFT(issuedate,8)="'.(DateAdd($strTendaysago,$intBt,'day')).'")' );
break;
case 'db2':
if ( $bt=='m') $oDB->Query( 'SELECT COUNT(*) as countid FROM (SELECT DISTINCT userid FROM '.TABPOST.' WHERE '.$strSection.' SUBSTR(issuedate,1,6)="'.($intYear*100+$intBt).'")' );
if ( $bt=='q') $oDB->Query( 'SELECT COUNT(*) as countid FROM (SELECT DISTINCT userid FROM '.TABPOST.' WHERE '.$strSection.' SUBSTR(issuedate,1,6)>"'.($intYear*100+($intBt-1)*3).'" AND SUBSTR(issuedate,1,6)<="'.($intYear*100+($intBt*3)).'")' );
if ( $bt=='d') $oDB->Query( 'SELECT COUNT(*) as countid FROM (SELECT DISTINCT userid FROM '.TABPOST.' WHERE '.$strSection.' SUBSTR(issuedate,1,8)="'.(DateAdd($strTendaysago,$intBt,'day')).'")' );
break;
case 'ifx':
if ( $bt=='m') $oDB->Query( 'SELECT COUNT(*) as countid FROM (SELECT DISTINCT userid FROM '.TABPOST.' WHERE '.$strSection.' SUBSTRING(issuedate,1,6)="'.($intYear*100+$intBt).'")' );
if ( $bt=='q') $oDB->Query( 'SELECT COUNT(*) as countid FROM (SELECT DISTINCT userid FROM '.TABPOST.' WHERE '.$strSection.' SUBSTRING(issuedate,1,6)>"'.($intYear*100+($intBt-1)*3).'" AND SUBSTRING(issuedate,1,6)<="'.($intYear*100+($intBt*3)).'")' );
if ( $bt=='d') $oDB->Query( 'SELECT COUNT(*) as countid FROM (SELECT DISTINCT userid FROM '.TABPOST.' WHERE '.$strSection.' SUBSTRING(issuedate,1,8)="'.(DateAdd($strTendaysago,$intBt,'day')).'")' );
break;
case 'oci':
if ( $bt=='m') $oDB->Query( 'SELECT COUNT(*) as countid FROM (SELECT DISTINCT userid FROM '.TABPOST.' WHERE '.$strSection.' SUBSTR(issuedate,1,6)="'.($intYear*100+$intBt).'")' );
if ( $bt=='q') $oDB->Query( 'SELECT COUNT(*) as countid FROM (SELECT DISTINCT userid FROM '.TABPOST.' WHERE '.$strSection.' SUBSTR(issuedate,1,6)>"'.($intYear*100+($intBt-1)*3).'" AND SUBSTR(issuedate,1,6)<="'.($intYear*100+($intBt*3)).'")' );
if ( $bt=='d') $oDB->Query( 'SELECT COUNT(*) as countid FROM (SELECT DISTINCT userid FROM '.TABPOST.' WHERE '.$strSection.' SUBSTR(issuedate,1,8)="'.(DateAdd($strTendaysago,$intBt,'day')).'")' );
break;
default: die('Unknown db type '.$oDB->type);
}
$row = $oDB->Getrow();
$arrU[$intBt] = intval($row['countid']);
}
// compute total
switch(substr($oDB->type,0,5))
{
case 'mysql':
if ( $bt=='m') $oDB->Query( 'SELECT COUNT(DISTINCT userid) as countid FROM '.TABPOST.' WHERE '.$strSection.' LEFT(issuedate,4)="'.$intYear.'"' );
if ( $bt=='q') $oDB->Query( 'SELECT COUNT(DISTINCT userid) as countid FROM '.TABPOST.' WHERE '.$strSection.' LEFT(issuedate,4)="'.$intYear.'"' );
if ( $bt=='d') $oDB->Query( 'SELECT COUNT(DISTINCT userid) as countid FROM '.TABPOST.' WHERE '.$strSection.' LEFT(issuedate,8)>"'.$strTendaysago.'" AND LEFT(issuedate,8)<="'.$strLastdaysago.'"' );
break;
case 'mssql':
if ( $bt=='m') $oDB->Query( 'SELECT COUNT(DISTINCT userid) as countid FROM '.TABPOST.' WHERE '.$strSection.' LEFT(issuedate,4)="'.$intYear.'"' );
if ( $bt=='q') $oDB->Query( 'SELECT COUNT(DISTINCT userid) as countid FROM '.TABPOST.' WHERE '.$strSection.' LEFT(issuedate,4)="'.$intYear.'"' );
if ( $bt=='d') $oDB->Query( 'SELECT COUNT(DISTINCT userid) as countid FROM '.TABPOST.' WHERE '.$strSection.' LEFT(issuedate,8)>"'.$strTendaysago.'" AND LEFT(issuedate,8)<="'.$strLastdaysago.'"' );
break;
case 'pg':
if ( $bt=='m') $oDB->Query( 'SELECT COUNT(DISTINCT userid) as countid FROM '.TABPOST.' WHERE '.$strSection.' SUBSTRING(issuedate,1,4)="'.$intYear.'"' );
if ( $bt=='q') $oDB->Query( 'SELECT COUNT(DISTINCT userid) as countid FROM '.TABPOST.' WHERE '.$strSection.' SUBSTRING(issuedate,1,4)="'.$intYear.'"' );
if ( $bt=='d') $oDB->Query( 'SELECT COUNT(DISTINCT userid) as countid FROM '.TABPOST.' WHERE '.$strSection.' SUBSTRING(issuedate,1,8)>"'.$strTendaysago.'" AND SUBSTRING(issuedate,1,8)<="'.$strLastdaysago.'"' );
break;
case 'ibase':
if ( $bt=='m') $oDB->Query( 'SELECT COUNT(DISTINCT userid) as countid FROM '.TABPOST.' WHERE '.$strSection.' SUBSTRING(issuedate FROM 1 FOR 4)="'.$intYear.'"' );
if ( $bt=='q') $oDB->Query( 'SELECT COUNT(DISTINCT userid) as countid FROM '.TABPOST.' WHERE '.$strSection.' SUBSTRING(issuedate FROM 1 FOR 4)="'.$intYear.'"' );
if ( $bt=='d') $oDB->Query( 'SELECT COUNT(DISTINCT userid) as countid FROM '.TABPOST.' WHERE '.$strSection.' SUBSTRING(issuedate FROM 1 FOR 8)>"'.$strTendaysago.'" AND SUBSTRING(issuedate FROM 1 FOR 8)<="'.$strLastdaysago.'"' );
break;
case 'sqlit':
if ( $bt=='m') $oDB->Query( 'SELECT COUNT(*) as countid FROM (SELECT DISTINCT userid FROM '.TABPOST.' WHERE '.$strSection.' SUBSTR(issuedate,1,4)="'.$intYear.'")' );
if ( $bt=='q') $oDB->Query( 'SELECT COUNT(*) as countid FROM (SELECT DISTINCT userid FROM '.TABPOST.' WHERE '.$strSection.' SUBSTR(issuedate,1,4)="'.$intYear.'")' );
if ( $bt=='d') $oDB->Query( 'SELECT COUNT(*) as countid FROM (SELECT DISTINCT userid FROM '.TABPOST.' WHERE '.$strSection.' SUBSTR(issuedate,1,8)>"'.$strTendaysago.'" AND SUBSTR(issuedate,1,8)<="'.$strLastdaysago.'")' );
break;
case 'acces':
if ( $bt=='m') $oDB->Query( 'SELECT COUNT(*) as countid FROM (SELECT DISTINCT userid FROM '.TABPOST.' WHERE '.$strSection.' LEFT(issuedate,4)="'.$intYear.'")' );
if ( $bt=='q') $oDB->Query( 'SELECT COUNT(*) as countid FROM (SELECT DISTINCT userid FROM '.TABPOST.' WHERE '.$strSection.' LEFT(issuedate,4)="'.$intYear.'")' );
if ( $bt=='d') $oDB->Query( 'SELECT COUNT(*) as countid FROM (SELECT DISTINCT userid FROM '.TABPOST.' WHERE '.$strSection.' LEFT(issuedate,8)>"'.$strTendaysago.'" AND LEFT(issuedate,8)<="'.$strLastdaysago.'")' );
break;
case 'db2':
if ( $bt=='m') $oDB->Query( 'SELECT COUNT(*) as countid FROM (SELECT DISTINCT userid FROM '.TABPOST.' WHERE '.$strSection.' SUBSTR(issuedate,1,4)="'.$intYear.'")' );
if ( $bt=='q') $oDB->Query( 'SELECT COUNT(*) as countid FROM (SELECT DISTINCT userid FROM '.TABPOST.' WHERE '.$strSection.' SUBSTR(issuedate,1,4)="'.$intYear.'")' );
if ( $bt=='d') $oDB->Query( 'SELECT COUNT(*) as countid FROM (SELECT DISTINCT userid FROM '.TABPOST.' WHERE '.$strSection.' SUBSTR(issuedate,1,8)>"'.$strTendaysago.'" AND SUBSTR(issuedate,1,8)<="'.$strLastdaysago.'")' );
break;
case 'ifx':
if ( $bt=='m') $oDB->Query( 'SELECT COUNT(*) as countid FROM (SELECT DISTINCT userid FROM '.TABPOST.' WHERE '.$strSection.' SUBSTRING(issuedate,1,4)="'.$intYear.'")' );
if ( $bt=='q') $oDB->Query( 'SELECT COUNT(*) as countid FROM (SELECT DISTINCT userid FROM '.TABPOST.' WHERE '.$strSection.' SUBSTRING(issuedate,1,4)="'.$intYear.'")' );
if ( $bt=='d') $oDB->Query( 'SELECT COUNT(*) as countid FROM (SELECT DISTINCT userid FROM '.TABPOST.' WHERE '.$strSection.' SUBSTRING(issuedate,1,8)>"'.$strTendaysago.'" AND SUBSTRING(issuedate,1,8)<="'.$strLastdaysago.'")' );
break;
case 'oci':
if ( $bt=='m') $oDB->Query( 'SELECT COUNT(*) as countid FROM (SELECT DISTINCT userid FROM '.TABPOST.' WHERE '.$strSection.' SUBSTR(issuedate,1,4)="'.$intYear.'")' );
if ( $bt=='q') $oDB->Query( 'SELECT COUNT(*) as countid FROM (SELECT DISTINCT userid FROM '.TABPOST.' WHERE '.$strSection.' SUBSTR(issuedate,1,4)="'.$intYear.'")' );
if ( $bt=='d') $oDB->Query( 'SELECT COUNT(*) as countid FROM (SELECT DISTINCT userid FROM '.TABPOST.' WHERE '.$strSection.' SUBSTR(issuedate,1,8)>"'.$strTendaysago.'" AND SUBSTR(issuedate,1,8)<="'.$strLastdaysago.'")' );
break;
default: die('Unknown db type '.$oDB->type);
}
$row = $oDB->Getrow();
$arrU[$intMaxBt+1] = intval($row['countid']);
// OUTPUT
$strCSV .= '"'.$L['Topics'].'";';
for ($intBt=1;$intBt<=$intMaxBt;$intBt++) { $strCSV .= (isset($arrT[$intBt]) ? $arrT[$intBt] : '0').';'; }
$strCSV .= $arrT[$intMaxBt+1].'<br/>';
$strCSV .= '"'.$L['Messages'].'";';
for ($intBt=1;$intBt<=$intMaxBt;$intBt++) { $strCSV .= (isset($arrM[$intBt]) ? $arrM[$intBt] : '0').';'; }
$strCSV .= $arrM[$intMaxBt+1].'<br/>';
$strCSV .= '"'.$L['Users'].'";';
for ($intBt=1;$intBt<=$intMaxBt;$intBt++) { $strCSV .= (isset($arrU[$intBt]) ? $arrU[$intBt] : '0').';'; }
$strCSV .= $arrU[$intMaxBt+1].'<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;
?>