<?php
// QT-registrations 2.4 build:20100313
session_start();
require_once('bin/qtr_init.php');
if ( !$oVIP->CanView('V4') ) HtmlPage(11);
// --------
// INITIALISE
// --------
$oVIP->output='print';
$strCSV = '';
$s = -1; // section filter
$y = date('Y'); if ( intval(date('n'))<2 ) $y--; // year filter
$type = ''; // type filter
$tag = ''; // tags filter
$tt = 'g'; // tab: g=global, gt=globaltrend, d=detail, dt=detailtrend
$ch = array('time'=>'m','type'=>'b','value'=>'a','trend'=>'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
// --------
QThttpvar('y s type tag tt','int int str str str',true,true,false);
if ( $s>=0 ) { $strSection = 'section='.$s.' AND '; } else { $strSection=''; }
if ( !empty($type) ) { $strType='type="'.strtoupper(substr($type,0,1)).'" AND '; } else { $strType=''; }
$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['ch']) )
{
$str = strip_tags($_GET['ch']);
if ( strlen($str)>0 ) $ch['time'] = substr($str,0,1); // blocktime
if ( strlen($str)>1 ) $ch['type'] = substr($str,1,1); // graph type
if ( strlen($str)>2 ) $ch['value'] = substr($str,2,1); // value type
if ( strlen($str)>3 ) $ch['trend'] = substr($str,3,1); // trends value type
}
// ------
// OUTPUT
// ------
$arrYears = array($y);
include('qtr_stats_inc_g.php');
// Table header
$arr = QTarrget(GetSections($oVIP->role));
$strCSV .= '"'.$y.($s>=0 ? ' '.$arr[$s] : '').(empty($tag) ? '' : ', '.$L['With_tag'].' '.str_replace(';',' '.$L['or'].' ',$tag)).'"<br/>';
$strCSV .= '" ";';
switch($ch['time'])
{
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 .= '"'.QTdatestr( DateAdd($strTendaysago,$i,'day'),'d M','' ).'";'; } break;
}
$strCSV .= '"'.($ch['time']=='d' ? '10 '.strtolower($L['Days']) : $L['Year']).'"<br/>';
// Table body
$strCSV .= '"'.$L['Topics'].'";';
for ($intBt=1;$intBt<=$intMaxBt;$intBt++) { $strCSV .= (isset($arrT[$y][$intBt]) ? $arrT[$y][$intBt] : '0').';'; }
$strCSV .= $arrTs[$y].'<br/>';
$strCSV .= '"'.$L['Replys'].'";';
for ($intBt=1;$intBt<=$intMaxBt;$intBt++) { $strCSV .= (isset($arrM[$y][$intBt]) ? $arrM[$y][$intBt] : '0').';'; }
$strCSV .= $arrMs[$y].'<br/>';
$strCSV .= '"'.$L['Users'].'";';
for ($intBt=1;$intBt<=$intMaxBt;$intBt++) { $strCSV .= (isset($arrU[$y][$intBt]) ? $arrU[$y][$intBt] : '0').';'; }
$strCSV .= $arrUs[$y].'<br/>';
// Export
if ( !headers_sent() )
{
$strCSV = str_replace('<br/>',"\r\n",$strCSV);
header('Content-Type: text/csv; charset='.QTR_HTML_CHAR);
header('Content-Disposition: attachment; filename="global_stat_'.$y.'.csv"');
}
echo $strCSV;
?>