<?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',5,true) ) $oVIP->EndMessage('!',$L['R_member'],$_SESSION[QT]['skin_dir'],0);
if ( !isset($_GET['a']) ) die('Missing parameter a');
// INITIALISE
$bMap = UseModule('map');
if ( $bMap ) { if ( empty($_SESSION[QT]['m_map_gkey']) ) $bMap=false; }
if ( $bMap ) { require_once('qtim_map_lib.php'); if ( !QTgcanmap('S',$oVIP->role) ) $bMap=false; }
if ( $bMap ) include(Translate('qtim_map.inc'));
$strAction = 'last';
$strOrder = 'lastpostdate';
$strDirec = 'DESC';
$intLimit = 0;
$intPage = 1;
// security check 1
if ( isset($_GET['a']) ) $strAction = strip_tags($_GET['a']);
if ( isset($_GET['order']) ) $strOrder = strip_tags($_GET['order']);
if ( isset($_GET['dir']) ) $strDirec = strip_tags($_GET['dir']);
if ( isset($_GET['page']) ) $intPage = intval(strip_tags($_GET['page']));
if ( isset($_GET['view']) ) $_SESSION[QT]['viewmode'] = strip_tags($_GET['view']);
if ( isset($_GET['n']) ) $_GET['n'] = urldecode($_GET['n']);
// security check 2 (no long argument)
if ( strlen($strAction)>5 ) die('Invalid argument #a');
if ( strlen($strOrder)>12 ) die('Invalid argument #order');
if ( strlen($strDirec)>4 ) die('Invalid argument #dir');
$intLimit = ($intPage-1)*$_SESSION[QT]['topics_per_page'];
if ($oVIP->numpost>0)
{
$oDB2 = new cDB($qti_dbsystem,$qti_host,$qti_database,$qti_user,$qti_pwd,$qti_port,$qti_dsn);
}
$oVIP->selfurl = 'qti_search_ov.php';
$oVIP->selfname = $L['Search_result'];
$oVIP->exiturl = 'qti_search.php';
$oVIP->exitname = $L['Search'];
include('bin/qti_fn_limitsql.php');
// --------
// HTML START
// --------
if ( $bMap )
{
$arrMapPoints = array();
$strHeaderAddScript = QTgmapheader('http://gmaps-utility-library.googlecode.com/svn/trunk/markermanager/release/src/markermanager.js');
$strBodyAddOnunload='GUnload()';
}
$arrJava = array('com'=>false);
include('qti_p_header.php');
echo '<table class="ta_button" cellspacing="0">
<tr class="tr_button">
<td> </td>
<td style="width:25px" class="td_button">',AsImg($_SESSION[QT]['skin_dir'].'/ico_topic_t_0.gif','T',$L['Ico_topic_t_0'],'ico ico_t'),'</td>
<td style="width:120px" class="td_button"> <a href="qti_search_ov.php?a=last" class="a_button">',$L['Recent_messages'],'</a> </td>
<td style="width:10px"> </td>
<td style="width:25px" class="td_button">',AsImg($_SESSION[QT]['skin_dir'].'/ico_topic_a_0.gif','T',$L['Ico_topic_a_0'],'ico ico_t'),'</td>
<td style="width:120px" class="td_button"> <a href="qti_search_ov.php?a=news" class="a_button">'.$L['All_news'].'</a> </td>
';
if ($oVIP->role!='V')
{
echo '<td style="width:10px"> </td>',N;
echo '<td style="width:25px" class="td_button">',AsImg($_SESSION[QT]['skin_dir'].'/ico_user_p_1.gif','T',$L['Ico_user_p_1'],'ico ico_user'),'</td>',N;
echo '<td style="width:120px" class="td_button"> <a href="qti_search_ov.php?a=user&id=',$oVIP->id,'&n=',urlencode($oVIP->username),'" class="a_button">'.$L['All_my_topics'].'</a> </td>',N;
}
echo '</tr>
</table>
';
echo '<h2>',$oVIP->selfname,'</h2>
';
// check request
$strSelect = 't.*, f.title as sectiontitle, f.numfield, f.prefix, p.icon, p.title, p.textmsg ';
$strFrom = 'FROM '.TABTOPIC.' t INNER JOIN '.TABSECTION.' f ON t.forum = f.id INNER JOIN '.TABPOST.' p ON t.firstpostid = p.id ';
$extraparam = '';
// order
$strFullOrder = 't.'.$strOrder.' '.$strDirec;
if ( $strOrder=='title' ) $strFullOrder='p.title '.$strDirec;
if ( $strOrder=='sectiontitle' ) $strFullOrder='f.title '.$strDirec;
if ( $strOrder!='lastpostdate' ) $strFullOrder .= ',t.lastpostdate DESC'; // second order
if ( $strAction=='last' )
{
$overview = $L['Recent_messages'];
// get the lastpost date
$oDB->Query('SELECT max(t.lastpostdate) as f1 FROM '.TABTOPIC.' t ');
$row = $oDB->Getrow();
$intDate = strtotime($row['f1']);
$strY = date('Y',$intDate);
$strM = date('n',$intDate);
$strD = date('j',$intDate);
// query post of this day
switch(substr($oDB->type,0,5))
{
case 'mysql': $strWhere = "WHERE LEFT(t.lastpostdate,8)='".($strY*10000+$strM*100+$strD)."'"; break;
case 'mssql': $strWhere = "WHERE LEFT(t.lastpostdate,8)='".($strY*10000+$strM*100+$strD)."'"; break;
case 'pg': $strWhere = "WHERE SUBSTRING(t.lastpostdate,1,8)='".($strY*10000+$strM*100+$strD)."'"; break;
case 'ibase': $strWhere = "WHERE SUBSTRING(t.lastpostdate FROM 1 FOR 8)='".($strY*10000+$strM*100+$strD)."'"; break;
case 'sqlit': $strWhere = "WHERE SUBSTR(t.lastpostdate,1,8)='".($strY*10000+$strM*100+$strD)."'"; break;
case 'acces': $strWhere = "WHERE LEFT(t.lastpostdate,8)='".($strY*10000+$strM*100+$strD)."'"; break;
case 'db2': $strWhere = "WHERE SUBSTR(t.lastpostdate,1,8)='".($strY*10000+$strM*100+$strD)."'"; break;
case 'ifx': $strWhere = "WHERE SUBSTRING(t.lastpostdate,1,8)='".($strY*10000+$strM*100+$strD)."'"; break;
case 'oci': $strWhere = "WHERE SUBSTR(t.lastpostdate,1,8)='".($strY*10000+$strM*100+$strD)."'"; break;
default: die('Unknown db type '.$oDB->type);
}
$oDB->Query('SELECT count(t.id) as countid FROM '.TABTOPIC.' t '.$strWhere);
$row = $oDB->Getrow();
$intCount = $row['countid'];
$strQ = LimitSQL($strSelect.$strFrom.$strWhere,$strFullOrder,$intLimit,$_SESSION[QT]['topics_per_page']);
}
if ( $strAction=='news' )
{
$overview = $L['All_news'];
$oDB->Query( 'SELECT count(id) as countid FROM '.TABTOPIC.' WHERE type="A"' );
$row = $oDB->Getrow();
$intCount = $row['countid'];
$strWhere = 'WHERE t.type="A"';
$strQ = LimitSQL($strSelect.$strFrom.$strWhere,$strFullOrder,$intLimit,$_SESSION[QT]['topics_per_page']);
}
if ( $strAction=='user' )
{
$overview = $L['Topics'].' '.strtolower($L['By']).' '.$_GET['n'];
$extraparam = '&id='.$_GET['id'].'&n='.$_GET['n'];
$oDB->Query( 'SELECT count(id) as countid FROM '.TABTOPIC.' WHERE firstpostuser='.intval($_GET['id']) );
$row = $oDB->Getrow();
$intCount = $row['countid'];
$strWhere = 'WHERE t.firstpostuser='.intval($_GET['id']);
$strQ = LimitSQL($strSelect.$strFrom.$strWhere,$strFullOrder,$intLimit,$_SESSION[QT]['topics_per_page']);
}
if ( $strAction=='actor' )
{
$overview = $L['Topics_handled'].' '.strtolower($L['By']).' '.$_GET['n'];
$extraparam = '&id='.$_GET['id'].'&n='.$_GET['n'];
$oDB->Query( 'SELECT count(id) as countid FROM '.TABTOPIC.' WHERE actorid='.intval($_GET['id']) );
$row = $oDB->Getrow();
$intCount = $row['countid'];
$strWhere = 'WHERE t.actorid='.intval($_GET['id']);
$strQ = LimitSQL($strSelect.$strFrom.$strWhere,$strFullOrder,$intLimit,$_SESSION[QT]['topics_per_page']);
}
echo $overview,' · ',LangS('Result',$intCount),'<br/>';
if ($intCount==0)
{
echo '<p>« <a href="',$oVIP->exiturl,'">',$oVIP->exitname,'</a></p>';
include('qti_p_footer.php');
exit;
}
// -----
// Query
// -----
$oDB->Query($strQ);
// -- pager --
if ($intCount>($_SESSION[QT]['topics_per_page']*5))
{
$pager = $L['Page'];
// firstpage
if ($intPage == 1)
{
$strFirstpage = ' «';
}else{
$strFirstpage = ' <a href="'.$oVIP->selfurl.'?a='.$_GET['a'].'&page=1'.$extraparam.'" title="'.$L['First'].'">«</a>';
}
// lastpage
$il = ceil($intCount/$_SESSION[QT]['topics_per_page']);
if ($intPage == $il)
{
$strLastpage = ' »';
}else{
$strLastpage = ' <a href="'.$oVIP->selfurl.'?a='.$_GET['a'].'&page='.$il.$extraparam.'" title="'.$L['Last'].'">»</a>';
}
// 3 pages
if ($intPage==1)
{
$strThesepages = ' <b>'.$intPage.'</b> <a href="'.$oVIP->selfurl.'?a='.$_GET['a'].'&page='.($intPage+1).$extraparam.'" title="'.$L['Next'].'">'.($intPage+1).'</a> <a href="'.$oVIP->selfurl.'?a='.$_GET['a'].'&page='.($intPage+2).$extraparam.'" title="'.$L['Next'].'">'.($intPage+2).'</a>';
}
elseif ($intPage==$il)
{
$strThesepages = ' <a href="'.$oVIP->selfurl.'?a='.$_GET['a'].'&page='.($intPage-2).$extraparam.'" title="'.$L['Previous'].'">'.($intPage-2).'</a> <a href="'.$oVIP->selfurl.'?a='.$_GET['a'].'&page='.($intPage-1).$extraparam.'" title="'.$L['Previous'].'">'.($intPage-1).'</a> <b>'.$intPage.'</b> ';
}
else
{
$strThesepages = ' <a href="'.$oVIP->selfurl.'?a='.$_GET['a'].'&page='.($intPage-1).$extraparam.'" title="'.$L['Previous'].'">'.($intPage-1).'</a> <b>'.$intPage.'</b> <a href="'.$oVIP->selfurl.'?a='.$_GET['a'].'&page='.($intPage+1).$extraparam.'" title="'.$L['Next'].'">'.($intPage+1).'</a>';
}
// finish
$pager .= $strFirstpage.$strThesepages.$strLastpage;
}
elseif ($intCount>$_SESSION[QT]['topics_per_page'])
{
$pager = $L['Page'];
for ($i=0; $i<$intCount; $i+=$_SESSION[QT]['topics_per_page'])
{
$page = $i/$_SESSION[QT]['topics_per_page']+1;
if ($intPage==$page)
{
$pager .= ' <b>'.$page.'</b>';
}
else
{
$pager .= ' <a href="'.$oVIP->selfurl.'?a='.$_GET['a'].'&page='.$page.$extraparam.'">'.$page.'</a>';
}
}
}
else
{
$pager=S;
}
$strCommand = $pager;
// -- Displays Button line and pager --
echo '<table class="ta_button" cellspacing="0"><tr class="tr_button"><td> </td><td id="zone_pager_top">',$strCommand,'</td></tr></table>',N,N;
// --------
// Post content
// --------
echo '<table class="ta ta_t" cellspacing="0">',N;
echo '<tr class="tr_t tr_t0">',N;
/* ======== */
$arrFields = array(); // SORT LABEL CLASS STYLE
if ( $_GET['a']=='news' )
{
$arrFields['status'] = array(FALSE,S, 'th_t th_t_ico th_t_first', 'width:25px');
}
else
{
$arrFields['status'] = array(TRUE, '-', 'th_t th_t_ico th_t_first', 'width:25px');
$arrFields['numid'] = array(TRUE, $L['Ref'], 'th_t th_t_ref', 'width:50px');
}
$arrFields['smile'] = array(FALSE, S, 'th_t th_t_inf', 'width:20px');
$arrFields['title'] = array(TRUE, $L['Topics'], 'th_t th_t_tit', '');
$arrFields['you'] = array(FALSE, S, 'th_t th_t_inf', 'width:10px');
$arrFields['sectiontitle'] = array(TRUE, $L['Section'], 'th_t th_t_inf', '');
$arrFields['firstpostname'] = array(TRUE, $L['Topic_starter'], 'th_t th_t_inf', 'width:125px');
$arrFields['lastpostdate'] = array(TRUE, $L['Last_message'], 'th_t th_t_inf', 'width:125px');
$arrFields['replies'] = array(TRUE, $L['Last_column_label']['replies'], 'th_t th_t_inf th_t_last', 'width:70px;text-align:center');
/* ======== */
TableHeader($arrFields,$intCount,"$oVIP->selfurl?a={$_GET['a']}&page=1$extraparam",$strOrder,$strDirec);
/* ======== */
echo '</tr>',N;
/* ======== */
$bAddPrefix = true;
$bAddSection = true;
$bAddRef = true; if ( $_GET['a']=='news' ) $bAddRef = false;
$strExtra='replies';
include('qti_topics_inc.php');
/* ======== */
// -- no data --
if ( $intWhile==0 ) echo '<tr><td class="td_t td_t_tit1" colspan="6">',$L['None'],'...</td></tr>',N;
echo '<tr class="tr_t tr_t9">',N;
echo '<td class="tf_t tf_t_first"></td>',N;
For ($i=0;$i<(count($arrFields)-2);$i++)
{
echo '<td class="tf_t"></td>',N;
}
echo '<td class="tf_t tf_t_last"></td>',N;
echo '</tr>',N;
echo '</table>',N;
// MAP MODULE
if ( $bMap )
{
if ( count($arrMapPoints)==0 )
{
echo '<p class="p_gmap">'.$L['map']['E_noposition'].'</p>';
}
else
{
//select zoomto (maximum 15 items in the list)
if ( count($arrMapPoints)>1 )
{
$str = '<p class="p_gmap" style="margin:0 0 4px 0"><a class="a_gmap" href="javascript:void(0)" onclick="zoomToFullExtend(); return false;">'.$L['map']['zoomtoall'].'</a> | '.$L['Goto'].' <select class="gmap" id="zoomto" name="zoomto" size="1" onchange="map.setCenter(eval(this.value));">';
$str .= '<option class="gmap" value="new GLatLng('.QTgety($_SESSION[QT]['m_map_gcenter']).','.QTgetx($_SESSION[QT]['m_map_gcenter']).')"> </option>';
$i=0;
foreach ( $arrMapPoints as $intKey => $arrMapPoint )
{
$str .= '<option class="gmap" value="new GLatLng('.$arrMapPoint['y'].','.$arrMapPoint['x'].')">'.$arrMapPoint['title'].'</option>';
$i++; if ( $i>15 ) break;
}
$str .= '</select></p>';
}
echo '
<table class="ta_hidden" style="margin-top:5px;">
<tr class="tr_hidden">
<td class="div_gmap">
',( count($arrMapPoints)>1 ? $str :'' ),'
<div id="map_canvas" style="width:100%; height:350px;"></div>
<p class="p_gmap" style="margin:4px 0 0 0">',sprintf($L['map']['items'],strtolower( LangS('Topic',count($arrMapPoints))),strtolower(LangS('Topic',$intCount)) ),'</p>
</td>
</tr>
</table>
';
}
}
// --------
// Button line and pager
// --------
echo '<table class="ta_button" cellspacing="0"><tr class="tr_button"><td> </td><td id="zone_pager_bot">',$strCommand,'</td></tr></table>',N,N;
echo '<p>« <a href="',$oVIP->exiturl,'">',$oVIP->exitname,'</a></p>';
// --------
// HTML END
// --------
if ( $bMap ) {
if ( count($arrMapPoints)>0 ) {
$x = QTgetx($_SESSION[QT]['m_map_gcenter']);
$y = QTgety($_SESSION[QT]['m_map_gcenter']);
// center on the first ticket
foreach ($arrMapPoints as $intKey => $oMapPoint)
{
if ( !empty($oMapPoint->y) && !empty($oMapPoint->x) )
{
$y = $oMapPoint->y;
$x = $oMapPoint->x;
break;
}
}
// override symbol
if ( $_SESSION[QT]['m_map']['S']['icon']!='S' ) $arrMapPoints = QTgoverridesymbol($arrMapPoints,$_SESSION[QT]['m_map']['S']['icon']);
$strFooterAddScript = QTgmappoints($L['map'],$y,$x,'click',$arrMapPoints).N.'mapload();';
}}
include('qti_p_footer.php');