Location: PHPKode > projects > QuickTicket > quickticket/qti_topic.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('V3') ) HtmlPage(11);

// ---------
// PRE SETTINGS
// ---------

$t = -1;
$page = 1;
QThttpvar('t page','int int');

if ( $t<0 ) die('Missing topic id... (t)');
if ( $page<1 ) $page=1;

$oTopic = new cTopic($t,$oVIP->id); //provide userid to update stats
$s = $oTopic->parentid;

$intLimit = 0;
if ( $page>1 ) $intLimit = ($page-1)*$_SESSION[QT]['replies_per_page'];

require_once('bin/qti_fn_tags.php');
require_once('bin/qti_fn_sql.php');

// --------
// INITIALISE
// --------

$oSEC = new cSection($s);
$oTopic = new cTopic($t,$oVIP->id);

// exit according to section settings
if ( $oSEC->type!=0 && !$oVIP->IsStaff() )
{
$oVIP->selfname = $L['Section'];
$oVIP->exitname = ObjTrans('index','i',$_SESSION[QT]['index_name']);
if ( $oSEC->type==1 ) $oVIP->EndMessage(NULL,$L['R_staff'],$_SESSION[QT]['skin_dir'],0);
if ( $oSEC->type==2 && $oVIP->role=='V' ) $oVIP->EndMessage(NULL,$L['R_member'].'<br /><br /><a href="'.Href('qti_login.php').'?s='.$s.'&t='.$t.'">'.$L['Login'].'</a>',$_SESSION[QT]['skin_dir'],0);
if ( $oSEC->type==2 && $oVIP->role=='U' && $oTopic->firstpostuser!=$oVIP->id ) $oVIP->EndMessage(NULL,$L['E_topic_private']."<br />".$L['R_member'],$_SESSION[QT]['skin_dir'],0);
}

$strCoord='';
$strCommand = '';
if (isset($_GET['view'])) { $_SESSION[QT]['viewmode'] = $_GET['view']; }

$oVIP->selfurl = 'qti_topic.php';
$oVIP->exiturl = 'qti_topics.php?s='.$s;
$oVIP->selfname = $L['Messages'];

$strOrder = 'issuedate';
$strDirec = 'ASC';
if ( isset($_GET['order']) ) $strOrder = $_GET['order'];
if ( isset($_GET['dir']) ) $strDirec = $_GET['dir'];

if ( $oVIP->IsStaff() ) include('qti_p_staffmenu.php'); // define staff menu and process submitted staff actions

// ---------
// SUBMITTED
// ---------

if ( isset($_POST['addtag']) )
{
  $str = strip_tags(trim($_POST['tag']));
  if ( !empty($str) && $str!='*' ) $oTopic->TagsAdd($str,$oSEC);
}
if ( isset($_POST['deltag']) )
{
  $str = strip_tags($_POST['tag']);
  if ( !empty($str) ) $oTopic->TagsDel($str,$oSEC);
}

// MAP MODULE

if ( UseModule('map') ) { $strCheck=$s; include('qtim_map_ini.php'); } else { $bMap=false; }

// MAP DATA


if ( $bMap ) {
if ( !empty($oTopic->y) && !empty($oTopic->x) ) {

  $y = floatval($oTopic->y);
  $x = floatval($oTopic->x);
  $strPname = ( $oSEC->numfield=='N' ? '' : sprintf($oSEC->numfield,$oTopic->numid) );
  $strPlink = '<a class="small" href="http://maps.google.com?q='.$y.','.$x.'+('.urlencode($strPname).')&z='.$_SESSION[QT]['m_map_gzoom'].'" title="'.$L['map']['In_google'].'" target="_blank">[G]</a>';
  if ( $_SESSION[QT]['viewmode']=='C' )
  {
  $strPinfo = '<span class="small bold">Lat: '.QTdd2dms($y).' <br />Lon: '.QTdd2dms($x).'</span><br /><span class="small">DD: '.round($oTopic->y,8).', '.round($oTopic->x,8).'</span><br />'.$strPlink;
  }
  else
  {
  $strPinfo = '<span class="bold">Lat: '.QTdd2dms($y).' <br />Lon: '.QTdd2dms($x).'</span><br /><span class="small">DD: '.round($oTopic->y,8).', '.round($oTopic->x,8).'</span><br /><br />'.$strPlink;
  }
  if ( $oTopic->firstpostuser==$oVIP->id || $oVIP->IsStaff() ) $strPinfo .= ' &middot; <a class="small" href="'.Href('qti_form_edit.php').'?s='.$s.'&amp;t='.$t.'&amp;p='.$oTopic->firstpostid.'&amp;a=ed">'.$L['Edit'].'</a>';
  $oMapPoint = new cMapPoint($y,$x,$strPname,$strPinfo);
  if ( isset($_SESSION[QT]['m_map'][$s]['icon']) )        $oMapPoint->icon        = $_SESSION[QT]['m_map'][$s]['icon'];
  if ( isset($_SESSION[QT]['m_map'][$s]['shadow']) )      $oMapPoint->shadow      = $_SESSION[QT]['m_map'][$s]['shadow'];
  if ( isset($_SESSION[QT]['m_map'][$s]['printicon']) )   $oMapPoint->printicon   = $_SESSION[QT]['m_map'][$s]['printicon'];
  if ( isset($_SESSION[QT]['m_map'][$s]['printshadow']) ) $oMapPoint->printshadow = $_SESSION[QT]['m_map'][$s]['printshadow'];
  $arrExtData = array($oMapPoint);
  $strCoord = '<a href="javascript:void(0)"'.($bMapGoogle && !$_SESSION[QT]['m_map_hidelist'] ? ' onclick="map.setCenter(new GLatLng('.$y.','.$x.')); return false;"' : '').' title="'.$L['Coord'].': '.round($y,8).','.round($x,8).'"><img class="ico" src="'.$_SESSION[QT]['skin_dir'].'/ico_user_m_1.gif" alt="G" title="'.$L['Coord_latlon'].' '.QTdd2dms($y).','.QTdd2dms($x).'" /></a>';
  $strPcoord = 'Lat,Lon: '.QTdd2dms($y).', '.QTdd2dms($x).' DD: '.round($oTopic->y,8).', '.round($oTopic->x,8);

}}

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

$strHeadScript = '';

if ( $_SESSION[QT]['show_quick_reply']!='0' && $_SESSION[QT]['bbc']=='1' )
{
  $oHtml->scripts[] = '<script type="text/javascript" src="bin/qti_bbc.js"></script>';
  $oHtml->links[] = '<link rel="stylesheet" type="text/css" href="bin/css/qti_bbc.css" />';
  $intBbc=1; // buttons for quick reply
}

if ( $_SESSION[QT]['tags']!='0' )
{
  $oHtml->links[] = '<link rel="stylesheet" type="text/css" href="bin/css/qt_jquery.css" />';

  $arr1 = TagsRead(GetIso(),$s);
  $arr2 = TagsRead(GetIso(),'*');
  $arrTags = array_merge($arr1,$arr2);
  if ( count($arrTags)<100 )
  {
    $arr1 = cSection::GetTagsUsed($oSEC->id);
    foreach($arr1 as $strKey=>$strDesc) { if ( !isset($arrTags[$strKey]) ) $arrTags[$strKey]=$strDesc; }
  }
  $str = '';
  foreach($arrTags as $strKey=>$strDesc) { $str .= '{n:"'.$strKey.'",d:"'.($strKey==$strDesc ? ' ' : substr($strDesc,0,64)).'"},'; }
  $str = substr($str,0,-1);

  $strHeadScript .= '
  <script type="text/javascript" src="bin/qt_jquery.js"></script>
  <script type="text/javascript" src="bin/qt_jquery_auto.js"></script>
  <script type="text/javascript">
  <!--
  $(document).ready(function() {
    $("#tag").autocomplete(['.$str.'],{
      minChars:0,
      width:250,
      matchContains:1,
      multiple:true,
      multipleSeparator:";",
      formatItem: function(row) { return (row.d==" ") ? row.n : (row.n+"<span class=small> - " + row.d + "</span>"); },
      formatResult: function(row) { return row.n; }
      });
    $(".tag").hover(function() {
      var oTag = $(this);
      $.post("qti_j_tag.php",{s:"'.$s.'",val:oTag.html(),lang:"'.GetIso().'",na:"..."}, function(data) { oTag.attr({title:data}); } );
      });
    });
  -->
  </script>
  ';
}

include('qti_p_header.php');

// COUNT REPLIES

$oDB->Query( 'SELECT count(id) as countid FROM '.TABPOST.' WHERE type<>"P" AND topic='.$oTopic->id );
$row = $oDB->Getrow();
$intReplies = intval($row['countid']);

// PAGER

$strPager = MakePager("$oVIP->selfurl?s={$oSEC->id}&amp;t={$oTopic->id}",$intReplies,$_SESSION[QT]['topics_per_page'],$page);
if ($strPager!='') $strPager = $L['Page'].$strPager;

// BUTTONS

if ( $oSEC->status==1 )
{
  $strCommand = '<td class="button" style="width:120px"><span class="button_off">&nbsp;'.$L['E_section_closed'].'&nbsp;</span></td>';
}
else
{
  $strCommand = '<td class="button" style="width:120px">&nbsp;<a class="button" href="'.Href('qti_form_edit.php').'?s='.$oSEC->id.'&amp;t='.$oTopic->id.'&amp;a=re">'.$L['Post_reply'].'</a>&nbsp;</td>';
  if ( $oTopic->status=='Z' || $oTopic->status=='0' ) $strCommand = '<td class="button" style="width:120px"><span class="button_off">&nbsp;'.$L['Topic_closed'].'&nbsp;</span></td>';

  if ( ($oVIP->role=='V') && ($_SESSION[QT]['visitor_right']<6) )
  {
  $strCommand = '<td class="button" style="width:120px"><span class="button_off">&nbsp;'.$L['Post_reply'].'&nbsp;</span></td>';
  }
}

$strCommand = ( QTI_BACKBUTTON ? '<td class="button" style="width:20px"><a href="'.Href($oVIP->exiturl).'" class="button">'.QTI_BACKBUTTON.'</a></td>'.N : '').$strCommand;

// Moderator action

if ( isset($strStaffMenu) ) echo $strStaffMenu;

// TOPIC DESCRIPTION AND MAP

$strDescr = '';
$strLocation = '';
// topic description
if ($_SESSION[QT]['section_desc']=='1')
{
  if ( $oTopic->numid >= 0 && $oSEC->numfield!='N' )
  {
  $strDescr .= '<p id="topic_reference">'.sprintf($oSEC->numfield,$oTopic->numid).($oTopic->type=='T' ? '<br />'.$oVIP->statuses[$oTopic->status]['statusname'] : '').'</p>';
  }
}
// map module
if ( $bMap )
{
  if ( !empty($oTopic->y) && !empty($oTopic->x) )
  {
  if ( $_SESSION[QT]['viewmode']=='C' )
  {
  $strLocation .= '
  <div class="gmap" style="margin:0 0 0 auto;width:375px;"><div id="map_canvas" style="width:100%; height:180px;"></div>'.(($oTopic->firstpostuser==$oVIP->id || $oVIP->IsStaff()) ? '<p class="gmap mapscreenfooter" style="margin:4px 0 0 0">'.$L['map']['editmove'].'</p>' : '' ).(isset($strPcoord) ? '<p class="gmap mapprintfooter" style="margin:4px 0 0 0">'.$strPcoord.'</p>' : '').'</div>
  ';
  }
  else
  {
  $strLocation .= '
  <div class="gmap" style="margin:0;"><div id="map_canvas" style="width:100%; height:350px;"></div>'.(($oTopic->firstpostuser==$oVIP->id || $oVIP->IsStaff()) ? '<p class="gmap mapscreenfooter" style="margin:4px 0 0 0;display:screen">'.$L['map']['editmove'].'</p>' : '' ).(isset($strPcoord) ? '<p class="gmap mapprintfooter" style="margin:4px 0 0 0">'.$strPcoord.'</p>' : '').'</div>
  ';
  }
  }
  else
  {
  $strLocation .= '<p class="gmap">'.$L['map']['E_noposition'].'</p>'.N;
  }
}

// display topic descripition and map
if ( !empty($strDescr) || !empty($strLocation) )
{
echo '
<table class="hidden" cellspacing="0">
<colgroup span="2"><col width="180"></col><col></col></colgroup>
<tr class="hidden"><td class="hidden">',$strDescr,'</td><td class="hidden">',$strLocation,'</td></tr>
</table>
';
}

// --------
// TOPIC MESSAGE
// --------

echo '
<table class="button button_top" cellspacing="0">
<tr class="button">',$strCommand,'<td id="pager_zt">&nbsp;',($oTopic->type=='I' ? '' : $strPager),'</td></tr>
</table>
';

/* ====== */
$oDB->Query( 'SELECT p.*, u.role, u.location, u.photo, u.signature FROM '.TABPOST.' p, '.TABUSER.' u WHERE p.userid = u.id AND p.type="P" AND p.topic='.$oTopic->id );
$iMsgNum = $intLimit;
$intWhile= 0;
$strAlt  = 'r1';
$strSep  = '<div class="post_sep_'.($_SESSION[QT]['viewmode']=='N' ? 'n' : 'c').'"></div>'.N;
/* ====== */

$row=$oDB->Getrow();
$iMsgNum = $iMsgNum+1;
$oPost = new cPost($row);
if ( $_SESSION[QT]['viewmode']=='C' ) $oPost->text = QTcompact($oPost->text,0);
$strButton = '';
if ( $oVIP->auth )
{
  if ( !$oTopic->status && !$oSEC->status )
  {
  $strButton .= '<td class="buttonsmall" style="width:50px">&nbsp;<a href="'.Href('qti_form_edit.php').'?s='.$oSEC->id.'&amp;t='.$oTopic->id.'&amp;a=qu&amp;p='.$oPost->id.'" class="buttonsmall">'.$L['Quote'].'</a>&nbsp;</td>'.N;
  }
  if ( $oPost->CanEdit() )
  {
  $strButton .= '<td class="buttonsmall" style="width:50px">&nbsp;<a href="'.Href('qti_form_edit.php').'?s='.$oSEC->id.'&amp;t='.$oTopic->id.'&amp;p='.$oPost->id.'&amp;a=ed" class="buttonsmall">'.$L['Edit'].'</a>&nbsp;</td>'.N;
  $strButton .= '<td class="buttonsmall" style="width:50px">&nbsp;<a href="'.Href('qti_change.php').'?a=topicdelete&amp;s='.$oSEC->id.'&amp;t='.$oTopic->id.'" class="buttonsmall">'.$L['Delete'].'</a>&nbsp;</td>'.N;
  if ( $oPost->type=='P' && !empty($oTopic->options) )$strButton .= '<td class="buttonsmall" style="width:50px">&nbsp;<a href="'.Href('qti_change.php').'?s='.$oSEC->id.'&amp;t='.$oTopic->id.'&amp;p='.$oPost->id.'&amp;a=topicparam" class="buttonsmall">'.L('Parameters').'</a>&nbsp;</td>'.N;
  }
}
if ( !empty($oPost->modifuser) ) $strButton .= '<td class="post_modif"><span class="small">&nbsp;'.$L['Modified_by'].' <a href="'.Href('qti_user.php').'?id='.$oPost->modifuser.'" class="small">'.$oPost->modifname.'</a> ('.QTdatestr($oPost->modifdate,'$','$',true).')</span></td>'.N;
if ( !empty($strButton) ) $strButton .= '<td class="hidden">&nbsp;</td>'.N;
if ( !empty($strButton) ) $strButton = '<table class="hidden" cellspacing="0" style="margin:10px 0 1px 0;"><tr>'.$strButton.'</tr></table>'.N;

// SHOW FIRST MESSAGE

$oAvatar=true;
if ( $oTopic->type=='I' ) $oAvatar = AsImgBox('','picboxmsg','',($_SESSION[QT]['viewmode']=='C' ? '' : L('Score').'<br /><span class="small">('.L('I_v_'.$oTopic->ReadOptions('Istat')).')</span><br />').ValueScalebar($oTopic->z,$oTopic->ReadOptions('Ilevel')).'<br />'.ValueName($oTopic->z,$oTopic->ReadOptions('Ilevel')) );

$oPost->Show($oSEC,$oTopic,$oAvatar,$strButton,$strSep,$_SESSION[QT]['skin_dir'],$strAlt);
if ( $strAlt=='r1' ) { $strAlt='r2'; } else { $strAlt='r1'; }
$intWhile++;

// SHOW TAGS

if ( $oPost->type=='P' && $_SESSION[QT]['tags']!='0' )
{
  $arrTags=explode(';',$oTopic->tags);

  if ( $oVIP->role<=$_SESSION[QT]['tags'] && $oTopic->status!='1' )
  {
    echo '<div class="tags small" style="text-align:right">',$L['Tags'],' ';
    foreach($arrTags as $strTag)
    {
      if ( !empty($strTag) ) echo '<span class="tagline tag" title="" onclick="document.getElementById(\'tag\').value=this.innerHTML;">',$strTag,'</span> ';
    }
    echo (count($arrTags)>5 ? '</div><div class="tags small" style="text-align:right">' : ''),'<form method="post" action="',Href(),'?s=',$s,'&amp;t=',$t,'">',N;
    echo '<input type="hidden" name="s" value="',$s,'" />';
    echo '<input type="hidden" name="t" value="',$t,'" />';
    echo '<input type="text" class="small" size="20" id="tag" name="tag" maxlength="24" value="" />';
    echo '<input type="submit" class="small" name="addtag" id="addtag" title="',$L['Add'],'" value="+" onclick="if (document.getElementById(\'tag\').value==\'\') {return false;} else { return null;}" />';
    echo '<input type="submit" class="small" name="deltag" id="deltag" title="',$L['Delete_tags'],'" value="-"  onclick="if (document.getElementById(\'tag\').value==\'\') {return false;} else { return null;}" />';
    echo '</form>',N;
    echo '</div>';
  }
  else
  {
    if ( !empty($oTopic->tags) ) 
    {
    echo '<div class="tags small" style="text-align:right">',$L['Tags'],'&nbsp;';
    foreach($arrTags as $strTag)
    {
      echo '<span class="tagline">',$strTag,'</span> ';
    }  
    echo '</div>';
    }
  }
}

// END

if ( $intReplies>0 ) echo $strSep;

// --------
// REPLIES
// --------

// ======
$oDB->Query( LimitSQL(
'p.*, u.role, u.location, u.photo, u.signature FROM '.TABPOST.' p, '.TABUSER.' u WHERE p.userid = u.id AND p.type<>"P" AND p.topic='.$oTopic->id,
'p.'.$strOrder.' '.$strDirec.($strOrder!='issuedate' ? ',p.issuedate DESC' : ''),
$intLimit,
$_SESSION[QT]['replies_per_page'],
$intReplies
));
// ======
$iMsgNum = $intLimit;
$intWhile= 0;
$strAlt  = 'r1';
$strSep  = '<div class="post_sep_'.($_SESSION[QT]['viewmode']=='N' ? 'n' : 'c').'"></div>'.N;
// ======

// ::::::::
if ( $oTopic->type=='I' ) {
// ::::::::

// start result table

// DISPLAY PAGER

echo '<table class="hidden" cellspacing="0"><tr class="hidden"><td id="pager_zt">&nbsp;',$strPager,'</td></tr></table>
';

echo '
<table class="data_t" cellspacing="0">
<colgroup span="6"><col style="width:25px"></col><col style="width:150px"></col><col style="width:150px"></col><col></col><col></col><col></col></colgroup>
<tr class="data_t">
';
// ========
$arrFLD = array();
$oFLD = new cFLD('icon','&nbsp;','colhd colhdico colhdfirst','','colct colico colfirst'); $oFLD->uid='status'; $arrFLD['icon']=$oFLD;
$oFLD = new cFLD('issuedate',$L['Date'],'colhd','','colct'); $oFLD->sort='DESC'; $arrFLD['issuedate']=$oFLD;
$oFLD = new cFLD('title',L('Score'),'colhd','','colct'); $oFLD->sort='DESC'; $arrFLD['title']=$oFLD;
$oFLD = new cFLD('textmsg',$L['Message'],'colhd','','colct'); $oFLD->sort='DESC'; $arrFLD['textmsg']=$oFLD;
$oFLD = new cFLD('author',$L['Author'],'colhd','','colct'); $oFLD->sort='ASC'; $arrFLD['author']=$oFLD;
$oFLD = new cFLD('action','&nbsp;','colhd colhdico colhdlast','','colct colico collast'); $arrFLD['action']=$oFLD;
// ========
TableHeader($arrFLD,$intReplies,"$oVIP->selfurl?s=$oSEC->id&amp;t=$oTopic->id&amp;page=1",$strOrder,$strDirec);
// ========
echo '</tr>
';

// results rows

while ( $row=$oDB->Getrow() )
{
  $oPost = new cPost($row);

  // compact long message
  $oPost->text = QTcompact($oPost->text,200);
  if ( strlen($oPost->text)>65 && $_SESSION[QT]['viewmode']=='C' ) $oPost->text = substr($oPost->text,0,60).'<a class="small" href="'.Href('qti_change.php').'?a=post&amp;s='.$s.'&amp;t='.$t.'&amp;p='.$oPost->id.'">[...]</a>';
  if ( strlen($oPost->text)>160 ) $oPost->text = substr($oPost->text,0,150).'<a class="small" href="'.Href('qti_change.php').'?a=post&amp;s='.$s.'&amp;t='.$t.'&amp;p='.$oPost->id.'">[...]</a>';

  //if ( $intMax>1 && strlen($str)>$intMax ) return substr($str,0,$intMax).$strTrunc;

  if ( $oPost->icon!='00' ) $oPost->text = AsImg($_SESSION[QT]['skin_dir'].'/ico_prefix_'.$oSEC->prefix.'_'.$oPost->icon.'.gif','[o]',$L['Ico_prefix'][$oSEC->prefix.'_'.$oPost->icon],'ico ico_prefix').' '.$oPost->text;
  $strButton = '';
  if ( $oVIP->auth )
  {
    if ( !$oTopic->status && !$oSEC->status )
    {
    $strButton .= '<td class="buttonsmall" style="width:50px">&nbsp;<a href="'.Href('qti_form_edit.php').'?s='.$oSEC->id.'&amp;t='.$oTopic->id.'&amp;a=qu&amp;p='.$oPost->id.'" class="buttonsmall">'.$L['Quote'].'</a>&nbsp;</td>'.N;
    }
    if ( $oPost->CanEdit() )
    {
    $strButton .= '<td class="buttonsmall" style="width:50px">&nbsp;<a href="'.Href('qti_form_edit.php').'?s='.$oSEC->id.'&amp;t='.$oTopic->id.'&amp;p='.$oPost->id.'&amp;a=ed" class="buttonsmall">'.$L['Edit'].'</a>&nbsp;</td>'.N;
    $strButton .= '<td class="buttonsmall" style="width:50px">&nbsp;<a href="'.Href('qti_form_del.php').'?s='.$oSEC->id.'&amp;t='.$oTopic->id.'&amp;p='.$oPost->id.'&amp;a=de" class="buttonsmall">'.$L['Delete'].'</a>&nbsp;</td>'.N;
    }
  }
  if ( !empty($oPost->modifuser) ) $strButton .= '<td class="post_modif"><span class="small">&nbsp;'.$L['Modified_by'].' <a href="'.Href('qti_user.php').'?id='.$oPost->modifuser.'" class="small">'.$oPost->modifname.'</a> ('.QTdatestr($oPost->modifdate,'$','$',true).')</span></td>'.N;
  if ( !empty($strButton) ) $strButton .= '<td class="hidden">&nbsp;</td>'.N;
  if ( !empty($strButton) ) $strButton = '<table class="hidden" cellspacing="0" style="margin:10px 0 1px 0;"><tr>'.$strButton.'</tr></table>'.N;

  // Show row
  echo '<tr class="data_t">';
  echo '<td class="colct" style="text-align:center">'.AsImg($_SESSION[QT]['skin_dir'].'/ico_post_'.strtolower($oPost->type).'.gif','P',L('Ico_post_'.strtolower($oPost->type)),'ico ico_p').'</td>';
  echo '<td class="colct">'.QTdatestr($oPost->issuedate,'$','$',true).'</td>';
  echo '<td class="colct small">'.$oPost->GetScoreImage($oTopic).'</td>';  
  echo '<td class="colct small">'.$oPost->text.(empty($oPost->text) ? '&nbsp;' : '').'</td>';
  echo '<td class="colct"><a class="small" href="',Href('qti_user.php'),'?id=',$oPost->userid,'">',$oPost->username,'</a></td>';
  echo '<td class="colct">';
  if ( $oVIP->auth && $oPost->CanEdit() )
  {
  echo '<a class="small" href="',Href('qti_form_edit.php'),'?a=ed&amp;s=',$oPost->section,'&amp;t=',$oPost->topic,'&amp;p=',$oPost->id,'">',$L['Edit'],'</a>&nbsp;&middot;&nbsp;<a class="small" href="',Href('qti_form_del.php'),'?a=de&amp;s=',$oPost->section,'&amp;t=',$oPost->topic,'&amp;p=',$oPost->id,'">',$L['Delete'],'</a>';
  }
  else
  {
  echo S;
  }
  echo '</td>';
  echo '</tr>',N;

  $intWhile++;  
}

if ( $intWhile===0 ) echo '<tr class="data_t"><td class="colct" colspan="6">(0 '.$L['Reply'].')</td></tr>
';

echo '<tr class="colft">';
echo '<td class="colft colftfirst"></td>';
For ($i=0;$i<(count($arrFLD)-2);$i++)
{
echo '<td class="colft"></td>';
}
echo '<td class="colft colftlast"></td>
</tr>
</table>
';

echo '
<!-- Button and pager -->
<table class="hidden" cellspacing="0">
<tr class="hidden">
<td id="pager_zb">',(empty($strPager) ? '&nbsp;' : $strPager),'</td>
</tr>
</table>
';

// ::::::::
}
else
{
// ::::::::

while($row=$oDB->Getrow())
{
  $iMsgNum = $iMsgNum+1;
  $oPost = new cPost($row,$iMsgNum);
  if ( $_SESSION[QT]['viewmode']=='C' ) $oPost->text = QTcompact($oPost->text,0);
  $strButton = '';
  if ( $oVIP->auth )
  {
    if ( !$oTopic->status && !$oSEC->status )
    {
    $strButton .= '<td class="buttonsmall" style="width:50px">&nbsp;<a href="'.Href('qti_form_edit.php').'?s='.$oSEC->id.'&amp;t='.$oTopic->id.'&amp;a=qu&amp;p='.$oPost->id.'" class="buttonsmall">'.$L['Quote'].'</a>&nbsp;</td>'.N;
    }
    if ( $oPost->userid==$oVIP->id || $oVIP->IsStaff() )
    {
    $strButton .= '<td class="buttonsmall" style="width:50px">&nbsp;<a href="'.Href('qti_form_edit.php').'?s='.$oSEC->id.'&amp;t='.$oTopic->id.'&amp;p='.$oPost->id.'&amp;a=ed" class="buttonsmall">'.$L['Edit'].'</a>&nbsp;</td>'.N;
    $strButton .= '<td class="buttonsmall" style="width:50px">&nbsp;<a href="'.Href('qti_form_del.php').'?s='.$oSEC->id.'&amp;t='.$oTopic->id.'&amp;p='.$oPost->id.'&amp;a=de" class="buttonsmall">'.$L['Delete'].'</a>&nbsp;</td>'.N;
    if ( $oPost->type=='P' && !empty($oTopic->options) )$strButton .= '<td class="buttonsmall" style="width:50px">&nbsp;<a href="'.Href('qti_change.php').'?s='.$oSEC->id.'&amp;t='.$oTopic->id.'&amp;p='.$oPost->id.'&amp;a=topicparam" class="buttonsmall">'.L('Parameters').'</a>&nbsp;</td>'.N;
    }
  }
  if ( !empty($oPost->modifuser) ) $strButton .= '<td class="post_modif"><span class="small">&nbsp;'.$L['Modified_by'].' <a href="'.Href('qti_user.php').'?id='.$oPost->modifuser.'" class="small">'.$oPost->modifname.'</a> ('.QTdatestr($oPost->modifdate,'$','$',true).')</span></td>'.N;
  if ( !empty($strButton) ) $strButton .= '<td class="hidden">&nbsp;</td>'.N;
  if ( !empty($strButton) ) $strButton = '<table class="hidden" cellspacing="0" style="margin:10px 0 1px 0;"><tr>'.$strButton.'</tr></table>'.N;

  // SHOW MESSAGE

  $oPost->Show($oSEC,$oTopic,true,$strButton,$strSep,$_SESSION[QT]['skin_dir'],$strAlt);
  if ( $strAlt=='r1' ) { $strAlt='r2'; } else { $strAlt='r1'; }
  $intWhile++;

  // SHOW TAGS
  
  if ( $oPost->type=='P' && $_SESSION[QT]['tags']!='0' )
  {
    $arrTags=explode(';',$oTopic->tags);
    
    if ( $oVIP->role<=$_SESSION[QT]['tags'] && $oTopic->status!='1' )
    {
      echo '<div class="tags small" style="text-align:right">',$L['Tags'],' ';
      foreach($arrTags as $strTag)
      {
        if ( !empty($strTag) ) echo '<span class="tagline tag" title="" onclick="document.getElementById(\'tag\').value=this.innerHTML;">',$strTag,'</span> ';
      }  
      echo (count($arrTags)>5 ? '</div><div class="tags small" style="text-align:right">' : ''),'<form method="post" action="',Href(),'?s=',$s,'&amp;t=',$t,'">',N;
      echo '<input type="hidden" name="s" value="',$s,'" />';
      echo '<input type="hidden" name="t" value="',$t,'" />';
      echo '<input type="text" class="small" size="20" id="tag" name="tag" maxlength="24" value="" />';
      echo '<input type="submit" class="small" name="addtag" id="addtag" title="',$L['Add'],'" value="+" onclick="if (document.getElementById(\'tag\').value==\'\') {return false;} else { return null;}" />';
      echo '<input type="submit" class="small" name="deltag" id="deltag" title="',$L['Delete_tags'],'" value="-"  onclick="if (document.getElementById(\'tag\').value==\'\') {return false;} else { return null;}" />';
      echo '</form>',N;
      echo '</div>';
    }
    else
    {
      if ( !empty($oTopic->tags) ) 
      {
      echo '<div class="tags small" style="text-align:right">',$L['Tags'],'&nbsp;';
      foreach($arrTags as $strTag) echo '<span class="tagline">',$strTag,'</span> ';
      echo '</div>';
      }
    }
  }

  // END

  if ( $intWhile<$intReplies ) echo $strSep;

  }

// ::::::::
}
// ::::::::

// BUTTON LINE AND PAGER
if ( $oTopic->type!='I' && $intReplies>2 )
{
echo '
<!-- Button and pager -->
<table class="button button_bot" cellspacing="0">
<tr class="button">
',$strCommand,'
<td id="pager_zb">',(empty($strPager) ? '&nbsp;' : $strPager),'</td>
</tr>
</table>
';
}

// --------
// QUICK REPLY
// --------

if ( $_SESSION[QT]['show_quick_reply']=='1' ) include('qti_topic_inc_qr.php');

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

// MAP MODULE

if ( $bMap )
{
  if ( count($arrExtData)>0 ) { $bSmallMap=($_SESSION[QT]['viewmode']=='C'); include('qtim_map_load.php'); } else { echo '<script type="text/javascript">function GUnload() { return true; }</script>'; }
}

include('qti_p_footer.php');
Return current item: QuickTicket