Location: PHPKode > projects > QuickTicket > quickticket/quickticket/qti_stat.php
<?php

/*
 * PHP versions 4 and 5
 *
 * LICENSE: This source file is subject to version 3.0 of the PHP license
 * that is available through the world-wide-web at the following URI:
 * http://www.php.net/license. If you did not receive a copy of
 * the PHP License and are unable to obtain it through the web, please
 * send a note to hide@address.com so we can mail you a copy immediately.
 *
 * @category   Troubleticket
 * @package    QuickTicket
 * @author     Philippe Vandenberghe <hide@address.com>
 * @copyright  2008-2012 The PHP Group
 * @license    http://www.php.net/license  PHP License 3.0
 * @version    1.9.0.3 build:20081001
 * @link       http://www.qt-cute.org/doc/package/qti
 * @since      File available since Release 1.0.0
 * @deprecated File deprecated in Release 2.0.0
 *
 */

session_start();
require_once('bin/qti_init.php');
if ( !$oVIP->CanAccess('MUV',4) ) $oVIP->EndMessage('!',$L['R_member'],$_SESSION[QT]['skin_dir'],0);
if ( !isset($_GET['y']) ) die('Missing parameter y');

// INITIALISE

$intYear = intval(strip_tags($_GET['y']));
$intMonth = 0;
$s = -1;
if ( isset($_GET['m']) ) $intMonth = intval(strip_tags($_GET['m']));
if ( isset($_GET['s']) ) $s = intval(strip_tags($_GET['s']));

if ( $s>=0 )
{
$strSection = 'forum='.$s.' AND';
$arrSectionTitle = GetSectionTitles('A',-1,-1,'',true);
$strSectionTitle = '<br/>'.$L['Section'].S.$arrSectionTitle[$s].'';
}
else
{
$strSection='';
$strSectionTitle = '';
}

$oVIP->selfurl = 'qti_stat.php';
$oVIP->selfname = $L['Statistics'];
$oVIP->exiturl = 'qti_stats.php';
$oVIP->exitname = '&laquo;'.S.$L['Statistics'];

// --------
// HTML START
// --------

$arrJava = array('com'=>false);

$strHeaderAddScript = '
<script type="text/javascript" src="bin/qt_jquery.js"></script>
<script type="text/javascript">
<!--
$(function() {
  $(".ajaxmouseover").mouseover(function() {
    $.post("qti_j_user.php",
      {id:this.id,lang:"'.$_SESSION[QT]['language'].'"},
      function(data) { if ( data.length>0 ) document.getElementById("title_err").innerHTML=data; });
  });
});
-->
</script>
';

include('qti_p_header.php');

// USERS

switch(substr($oDB->type,0,5))
{
case 'mysql': $oDB->Query( 'SELECT DISTINCT userid, username, count(id) as countid FROM '.TABPOST.' WHERE '.$strSection.' LEFT(issuedate,6)="'.($intYear*100+$intMonth).'" GROUP BY userid,username' ); break;
case 'mssql': $oDB->Query( 'SELECT DISTINCT userid, username FROM '.TABPOST.' WHERE '.$strSection.' LEFT(issuedate,6)="'.($intYear*100+$intMonth).'"' ); break;
case 'pg':    $oDB->Query( 'SELECT DISTINCT userid, username FROM '.TABPOST.' WHERE '.$strSection.' SUBSTRING(issuedate,1,6)="'.($intYear*100+$intMonth).'"' ); break;
case 'ibase': $oDB->Query( 'SELECT DISTINCT userid, username FROM '.TABPOST.' WHERE '.$strSection.' SUBSTRING(issuedate FROM 1 FOR 6)="'.($intYear*100+$intMonth).'"' ); break;
case 'sqlit': $oDB->Query( 'SELECT DISTINCT userid, username FROM '.TABPOST.' WHERE '.$strSection.' SUBSTR(issuedate,1,6)="'.($intYear*100+$intMonth).'"' ); break;
case 'acces': $oDB->Query( 'SELECT DISTINCT userid, username FROM '.TABPOST.' WHERE '.$strSection.' LEFT(issuedate,6)="'.($intYear*100+$intMonth).'"' ); break;
case 'db2':   $oDB->Query( 'SELECT DISTINCT userid, username FROM '.TABPOST.' WHERE '.$strSection.' SUBSTR(issuedate,1,6)="'.($intYear*100+$intMonth).'"' ); break;
case 'ifx':   $oDB->Query( 'SELECT DISTINCT userid, username FROM '.TABPOST.' WHERE '.$strSection.' SUBSTRING(issuedate,1,6)="'.($intYear*100+$intMonth).'"' ); break;
case 'oci':   $oDB->Query( 'SELECT DISTINCT userid, username FROM '.TABPOST.' WHERE '.$strSection.' SUBSTR(issuedate,1,6)="'.($intYear*100+$intMonth).'"' ); break;
default: die('Unknown db type '.$oDB->type);
}
$arrUsers = array();
while($row=$oDB->Getrow())
{
  $arrUsers[$row['userid']]=$row['username'].(isset($row['countid']) ? ' ('.$row['countid'].')' : '');
}
$intUsers = count($arrUsers);
asort($arrUsers);

echo '<h1>',$L['Statistics'],'</h1>',N;

echo '<h2>',$L['Distinct_users'],( $intMonth!=0 ? ' '.$L['dateMM'][$intMonth] : ''),' ',$intYear,$strSectionTitle,'</h2>',N;
echo LangS('User',$intUsers).'<br/><br/>';

echo '<table class="ta ta_o" cellspacing="0">',N;
echo '<tr class="tr_t">',N;
echo '<th class="th_t th_t_inf th_t_first" style="width:10px;">',S,'</th>',N;
echo '<th class="th_t th_t_inf" style="width:300px;">',$L['Username'],' (',strtolower($L['Messages']),')</th>',N;
echo '<th class="th_t th_t_inf" style="width:250px;">',$L['Information'],'</th>',N;
echo '<th class="th_t th_t_inf th_t_last" style="width:10px;">',S,'</th>',N;
echo '</tr>',N;
echo '<tr class="tr_t">',N;
echo '<td class="td_t td_t_inf1">&nbsp;</td>',N;
echo '<td class="td_t td_t_inf1" style="vertical-align:top">',N;

if ( $intUsers>0 )
{
  $str = '<br/>'; if ($intUsers>50) $str = ', ';
  foreach($arrUsers as $intId => $strName)
  {
  echo '<a class="ajaxmouseover" id="u',$intId,'" href="qti_usr.php?id=',$intId,'">',$strName,'</a>',$str;
  }
}
else
{
  echo $L['None'].'<br/>';
}

echo '</td>',N;
echo '<td class="td_t td_t_inf1" style="vertical-align:top">',N;

  // DISPLAY Preview
  echo '<script type="text/javascript"></script><noscript>Your browser does not support JavaScript</noscript>';
  echo '<div id="title_err"></div>',N;

// preview
echo '</td>
<td class="td_t td_t_inf1">&nbsp;</td>
</tr>
<tr class="tr_t">
<td class="tf_t tf_t_first"></td>
<td class="tf_t"></td>
<td class="tf_t"></td>
<td class="tf_t tf_t_last"></td>
</tr>
</table>
';

// HTML END

echo '<p><a href="',$oVIP->exiturl,'">',$oVIP->exitname,'</a></p>',N;

include('qti_p_footer.php');

?>
Return current item: QuickTicket