<?php
// 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;
$arrGraphT = array();
$arrGraphM = array();
$arrGraphU = array();
switch($bt)
{
case 'q': for ($i=1;$i<=$intMaxBt;$i++) { $arrGraphT['Q'.$i]=0; $arrGraphM['Q'.$i]=0; $arrGraphU['Q'.$i]=0; } break;
case 'm': for ($i=1;$i<=$intMaxBt;$i++) { $arrGraphT[$L['dateMM'][$i]]=0; $arrGraphM[$L['dateMM'][$i]]=0; $arrGraphU[$L['dateMM'][$i]]=0; } break;
case 'd': for ($i=1;$i<=$intMaxBt;$i++) { $arrGraphT[substr(DateAdd($strTendaysago,$i,'day'),-2,2)]=0; $arrGraphM[substr(DateAdd($strTendaysago,$i,'day'),-2,2)]=0; $arrGraphU[substr(DateAdd($strTendaysago,$i,'day'),-2,2)]=0; } break;
}
// Display title & option
echo '<table class="ta_hidden" cellspacing="0">';
echo '<tr class="tr_hidden" style="vertical-align:middle;">';
echo '<td class="td_hidden"><h2>',$intYear,S,($s>=0 ? '('.$arrSections[$s].')' : ''),'</h2></td>',N;
if ( !isset($bToPrint) ) echo '<td class="td_hidden small" style="text-align:right">',implode(' · ',$arrTimeblocks),'</td>';
echo '</tr></table>
';
// Display table header
echo '<table class="ta ta_t" cellspacing="0">
<tr class="tr_t">
<th class="th_o" style="width:85px"> </th>
<th class="th_o" style="width:14px"> </th>
';
switch($bt)
{
case 'q': for ($i=1;$i<=$intMaxBt;$i++) { echo '<th class="th_o" style="text-align:center;">Q',$i,'</th>'; } break;
case 'm': for ($i=1;$i<=$intMaxBt;$i++) { echo '<th class="th_o" style="text-align:center;">',$L['dateMM'][$i],'</th>'; } break;
case 'd': for ($i=1;$i<=$intMaxBt;$i++) { echo '<th class="th_o" style="text-align:center;">',str_replace(' ','<br/>',QTdate(DateAdd($strTendaysago,$i,'day'),array('n','date','d M'))),'</th>'; } break;
}
echo '<th class="th_o" style="text-align:center;"><b>',($bt=='d' ? '10 days' : $L['Year']),'</b></th>
</tr>';
// 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']);
if ( $bt=='m') $arrGraphT[$L['dateMM'][$intBt]] = $arrT[$intBt];
if ( $bt=='q') $arrGraphT['Q'.$intBt] = $arrT[$intBt];
if ( $bt=='d') $arrGraphT[substr(DateAdd($strTendaysago,$i,'day'),-2,2)] = $arrT[$intBt];
// Add link
if ( $arrT[$intBt]>0 && $bt=='m' ) $arrT[$intBt] = '<a href="qti_search_ti.php?y='.$intYear.'&ti='.$intBt.'&s='.$s.'&st=-1">'.$arrT[$intBt].'</a>';
}
// Add link
if ( $arrT[$intMaxBt+1]>0 && $bt=='m' ) $arrT[$intMaxBt+1] = '<a href="qti_search_ti.php?y='.$intYear.'&ti=y&s='.$s.'&st=-1">'.$arrT[$intMaxBt+1].'</a>';
// DISPLAY TOPICS
echo '<tr class="tr_t">',N;
echo '<th class="th_o">',$L['Topics'],'</th>',N;
echo '<th class="th_o"><div style="margin:0 auto;background-color:#000066;width:8px;height:10px"> </div></th>',N;
for ($intBt=1;$intBt<=$intMaxBt;$intBt++)
{
echo '<td class="td_o" style="text-align:center;">',(isset($arrT[$intBt]) ? $arrT[$intBt] : '·'),'</td>',N;
}
echo '<td class="td_o" style="text-align:center;padding:5px;"><b>',$arrT[$intMaxBt+1],'</b></td>',N;
echo '</tr>';
// 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']);
if ( $bt=='m') $arrGraphM[$L['dateMM'][$intBt]] = $arrM[$intBt];
if ( $bt=='q') $arrGraphM['Q'.$intBt] = $arrM[$intBt];
if ( $bt=='d') $arrGraphM[substr(DateAdd($strTendaysago,$i,'day'),-2,2)] = $arrM[$intBt];
}
// DISPLAY MESSAGES
echo '<tr class="tr_t">',N;
echo '<th class="th_o">',$L['Messages'],'</th>',N;
echo '<th class="th_o"><div style="margin:0 auto;background-color:#990099;width:8px;height:10px"> </div></th>',N;
for ($intBt=1;$intBt<=$intMaxBt;$intBt++)
{
echo '<td class="td_o" style="text-align:center;">',(isset($arrM[$intBt]) ? $arrM[$intBt] : '·'),'</td>',N;
}
echo '<td class="td_o" style="text-align:center;padding:5px;"><b>',$arrM[$intMaxBt+1],'</b></td>',N;
echo '</tr>';
// 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']);
if ( $bt=='m') $arrGraphU[$L['dateMM'][$intBt]] = $arrU[$intBt];
if ( $bt=='q') $arrGraphU['Q'.$intBt] = $arrU[$intBt];
if ( $bt=='d') $arrGraphU[substr(DateAdd($strTendaysago,$i,'day'),-2,2)] = $arrU[$intBt];
// Add link
if ( $arrU[$intBt]>0 && $bt=='m' ) $arrU[$intBt] = '<a href="qti_stat.php?y='.$intYear.'&m='.$intBt.'&s='.$s.'">'.$arrU[$intBt].'</a>';
}
// 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']);
// Add link
if ( $arrU[$intMaxBt+1]>0 && $bt=='m' ) $arrU[$intMaxBt+1] = '<a href="qti_stat.php?y='.$intYear.'&s='.$s.'">'.$arrU[$intMaxBt+1].'</a>';
// DISPLAY USERS
echo '<tr class="tr_t">',N;
echo '<th class="th_o">',$L['Users'],'*</th>',N;
echo '<th class="th_o"><div style="margin:0 auto;background-color:#009999;width:8px;height:10px"> </div></th>',N;
for ($intBt=1;$intBt<=$intMaxBt;$intBt++)
{
echo '<td class="td_o" style="text-align:center;">',(isset($arrU[$intBt]) ? $arrU[$intBt] : '·'),'</td>',N;
}
echo '<td class="td_o" style="text-align:center;padding:5px;"><b>',$arrU[$intMaxBt+1],'</b></td>',N;
echo '</tr></table>
';
// GRAPH
if ( file_exists('bin/qt_lib_graph.php') && file_exists($_SESSION[QT]['skin_dir'].'/qti_graph.css') )
{
include('bin/qt_lib_graph.php');
$arr = array();
$arr[] = ($gr=='a' ? $L['Per_a'] : '<a href="'.$oVIP->selfurl.'?s='.$s.'&year='.$intYear.'&tt='.$tt.'&bt='.$bt.'&gr=a" class="small">'.$L['Per_a'].'</a>');
$arr[] = ($gr=='p' ? $L['Per_p'] : '<a href="'.$oVIP->selfurl.'?s='.$s.'&year='.$intYear.'&tt='.$tt.'&bt='.$bt.'&gr=p" class="small">'.$L['Per_p'].'</a>');
if ( !isset($bToPrint) ) echo '<p class="small" style="text-align:right">',implode(' · ',$arr),'</p>';
// Topics
echo '<table class="ta ta_t" cellspacing="0">',N;
echo '<tr class="tr_t">',N;
echo '<td class="td_o" style="width:355px">',N;
$intTopValue = 5; $i = max($arrGraphT);
if ( $i>5 ) $intTopValue = 10;
if ( $i>10 ) $intTopValue = 20;
if ( $i>20 ) $intTopValue = 30;
if ( $i>30 ) $intTopValue = 50;
if ( $i>50 ) $intTopValue = $i;
if ( $gr=='a' )
{
QTsimplegraph($arrGraphT,false,320,100,$intTopValue,2,true,$L['Topics_per_'.$bt],'','1');
}
else
{
QTsimplegraph($arrGraphT,false,350,100,$intTopValue,2,'P',$L['Topics_per_'.$bt].' (%)','','1');
}
echo '</td>',N;
echo '<td class="td_o"> </td>',N;
echo '<td class="td_o" style="width:355px">',N;
$intTopValue = 5; $i = array_sum($arrGraphT);
if ( $i>5 ) $intTopValue = 10;
if ( $i>10 ) $intTopValue = 20;
if ( $i>20 ) $intTopValue = 30;
if ( $i>30 ) $intTopValue = 50;
if ( $i>50 ) $intTopValue = $i;
if ( $gr=='a' )
{
QTsimplegraph($arrGraphT,true,320,100,$intTopValue,2,true,$L['Topics_per_'.$bt.'_cumul'],'','1');
}
else
{
QTsimplegraph($arrGraphT,true,350,100,$intTopValue,2,'P',$L['Topics_per_'.$bt.'_cumul'].' (%)','','1');
}
echo '</td>',N;
echo '</tr></table>',N;
// Messages & Users
echo '<table class="ta ta_t" cellspacing="0">',N;
echo '<tr class="tr_t">',N;
echo '<td class="td_o" style="width:355px">',N;
$intTopValue = 5; $i = max($arrGraphM);
if ( $i>5 ) $intTopValue = 10;
if ( $i>10 ) $intTopValue = 20;
if ( $i>20 ) $intTopValue = 30;
if ( $i>30 ) $intTopValue = 50;
if ( $i>50 ) $intTopValue = $i;
if ( $gr=='a' )
{
QTsimplegraph($arrGraphM,false,320,100,$intTopValue,2,true,$L['Messages_per_'.$bt],'','2');
}
else
{
QTsimplegraph($arrGraphM,false,350,100,$intTopValue,2,'P',$L['Messages_per_'.$bt].' (%)','','2');
}
echo '</td>',N;
echo '<td class="td_o"> </td>',N;
echo '<td class="td_o" style="width:355px">',N;
$intTopValue = 5; $i = array_sum($arrGraphU);
if ( $i>5 ) $intTopValue = 10;
if ( $i>10 ) $intTopValue = 20;
if ( $i>20 ) $intTopValue = 30;
if ( $i>30 ) $intTopValue = 50;
if ( $i>50 ) $intTopValue = $i;
if ( $gr=='a' )
{
QTsimplegraph($arrGraphU,false,320,100,$intTopValue,2,true,$L['Users_per_'.$bt],'','3');
}
else
{
QTsimplegraph($arrGraphU,false,350,100,$intTopValue,2,'P',$L['Users_per_'.$bt].' (%)','','3');
}
echo '</td>',N;
echo '</tr></table>',N;
}
else
{
echo '<p class="small">Graphs cannot be displayed because one of these files is missing: bin/qt_lib_graph.php, ',$_SESSION[QT]['skin_dir'].'/qti_graph.css</p>';
}
// LEGEND
echo '<p>* <span class="small">',$L['Distinct_users'],'</span></p>
';
?>