Location: PHPKode > projects > QuickTalk Forum > quicktalk/qtf_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   Forum
* @package    QuickTalk
* @author     Philippe Vandenberghe <hide@address.com>
* @copyright  2008-2012 The PHP Group
* @version    2.5 build:20100924
* @since      File available since Release 1.0.0
* @deprecated File deprecated in Release 3.0.0
*/

session_start();
require_once('bin/qtf_init.php');
if ( !$oVIP->CanView('V4') ) HtmlPage(11);

// INITIALISE

if ( !isset($_GET['y']) ) die('Missing parameter m');

$intYear = intval($_GET['y']);

$intMonth = 0;
if ( isset($_GET['m']) ) $intMonth = intval($_GET['m']);

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

$oVIP->selfurl = 'qtf_stat.php';
$oVIP->selfname = $L['Statistics'];
$oVIP->exiturl = 'qtf_stats.php';
$oVIP->exitname = $L['Statistics'];

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

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

include('qtf_p_header.php');

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 'db2':   $oDB->Query( 'SELECT DISTINCT userid, username FROM '.TABPOST.' WHERE '.$strSection.' SUBSTR(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="data_o" cellspacing="0" summary="statistics">',N;
echo '<tr class="data_o">',N;
echo '<td class="colhd colhdfirst" style="width:10px;">',S,'</td>',N;
echo '<td class="colhd" style="width:300px;">',$L['Username'],'</td>',N;
echo '<td class="colhd" style="width:250px;">',$L['Information'],'</td>',N;
echo '<td class="colhd colhdlast" style="width:10px;">',S,'</td>',N;
echo '</tr>',N;
echo '<tr class="data_o">',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="qtf_user.php?id=',$intId,'">',$strName,'</a>',$str;
  }
}
else
{
  echo $L['None'].'<br/>';
}

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

// --------
// HTML END
// --------

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

include('qtf_p_footer.php');

?>
Return current item: QuickTalk Forum