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

/**
* PHP versions 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.
*
* @package    QuickTicket
* @author     Philippe Vandenberghe <hide@address.com>
* @copyright  2008-2012 The PHP Group
* @version    2.5 build:20101222
*/

session_start();
require_once('bin/qti_init.php');
if ( !$oVIP->CanView('V4') ) HtmlPage(11);
if ( !isset($_GET['y']) ) die('Missing parameter y');
include(Translate('qti_stat.php'));

include('bin/qti_fn_sql.php');

// INITIALISE

$y = -1;
$m = -1;
$s = -1;
QThttpvar('y m s','int int int',true,true,false); // reject POST method

if ( $s>=0 )
{
$strSection = 'forum='.$s.' AND ';
$arrSectionTitle = QTarrget(GetSections('A'));
$strSectionTitle = '<br />'.$L['Section'].' '.$arrSectionTitle[$s].'';
}
else
{
$strSection='';
$strSectionTitle = '';
}

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

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

$oHtml->scripts = array();
$strHeadScript = '
<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:"'.GetLang().'",dir:"'.QTI_DIR_PIC.'"},
      function(data) { if ( data.length>0 ) document.getElementById("title_err").innerHTML=data; });
  });
});
-->
</script>
';

include('qti_p_header.php');

// USERS

if ( $m==0 )
{
  if ( substr($oDB->type,0,5)=='mysql' )
  {
  $oDB->Query( 'SELECT DISTINCT userid, username, count(id) as countid FROM '.TABPOST.' WHERE '.$strSection.SqlDateCondition($y,'issuedate').' GROUP BY userid,username' );
  }
  else
  {
  $oDB->Query( 'SELECT DISTINCT userid, username FROM '.TABPOST.' WHERE '.$strSection.SqlDateCondition($y,'issuedate') );
  }
}
else
{
  if ( substr($oDB->type,0,5)=='mysql' )
  {
  $oDB->Query( 'SELECT DISTINCT userid, username, count(id) as countid FROM '.TABPOST.' WHERE '.$strSection.SqlDateCondition(($y*100+$m),'issuedate',6).' GROUP BY userid,username' );
  }
  else
  {
  $oDB->Query( 'SELECT DISTINCT userid, username FROM '.TABPOST.' WHERE '.$strSection.SqlDateCondition(($y*100+$m),'issuedate',6) );
  }
}
$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['Users'],'*  ',( $m!=0 ? ' '.$L['dateMM'][$m] : ''),' ',$y,$strSectionTitle,'</h2>',N;
echo LangS('User',$intUsers).'<br /><br />';

echo '<table class="data_t" cellspacing="0">',N;
echo '<tr class="data_t">',N;
echo '<td class="colhd colhdfirst" style="width:10px;">&nbsp;</td>',N;
echo '<td class="colhd" style="width:300px">',$L['Username'],' (',strtolower($L['Messages']),')</td>',N;
echo '<td class="colhd" style="width:250px">',$L['Information'],'</td>',N;
echo '<td class="colhd colhdlast" style="width:10px;">&nbsp;</td>',N;
echo '</tr>',N;
echo '<tr class="data_t">',N;
echo '<td class="colct">&nbsp;</td>',N;
echo '<td class="colct" 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_user.php?id=',$intId,'">',$strName,'</a>',$str;
  }
}
else
{
  echo $L['None'].'<br />';
}

echo '</td>',N;
echo '<td class="colct td_t_inf" 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="colct td_t_inf">&nbsp;</td>
</tr>
<tr class="data_t">
<td class="colft colftfirst"></td>
<td class="colft"></td>
<td class="colft"></td>
<td class="colft colftlast"></td>
</tr>
</table>
';

echo '<p>*  <span class="small">',$L['Distinct_users'],'</span></p>
';

// HTML END

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

include('qti_p_footer.php');

?>
Return current item: QuickTicket