<?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.
*
* @package QuickTalk
* @author Philippe Vandenberghe <hide@address.com>
* @copyright 2008-2012 The PHP Group
* @version 2.5 build:20100924
*/
session_start();
require_once('bin/qtf_init.php');
if ( !$oVIP->CanView('V5') ) HtmlPage(11);
if ( !isset($_GET['a']) ) die('Missing parameter a');
$a = strip_tags($_GET['a']); // action search type: ref, kw, tst, user
include('bin/qtf_fn_sql.php');
// INITIALISE
$oVIP->selfname = $L['Search_result'];
include('qtf_find_inc.php');
$oVIP->selfurl = 'qtf_find.php';
$oVIP->exiturl = 'qtf_search.php?'.QTargimplode(QTargexplode());
$oVIP->exitname = $L['Search'];
$arrMe[] = array();
// --------
// HTML START
// --------
if ( $a=='tst' )
{
$strHeadScript = '
<script type="text/javascript" src="bin/qt_jquery.js"></script>
<script type="text/javascript">
<!--
$(document).ready(function() {
$(".tag").hover(function() {
var oTag = $(this);
$.post("qtf_j_tag.php",{s:oTag.attr("title"),val:oTag.html(),lang:"'.GetIso().'",na:"('.strtolower($L['E_no_desc']).')"}, function(data) { oTag.attr({title:data}); } );
});
});
-->
</script>
';
}
include('qtf_p_header.php');
echo '<table class="hidden" cellspacing="0" summary="quick search">',N;
echo '<tr class="hidden">',N;
echo '<td class="hidden"> </td>',N;
echo '<td class="button" style="width:25px">',AsImg($_SESSION[QT]['skin_dir'].'/ico_topic_t_0.gif','T',$L['Ico_topic_t_0'],'ico i_topic'),'</td>',N;
echo '<td class="button" style="width:120px"> <a href="qtf_find.php?a=last" class="button">',$L['Recent_messages'],'</a> </td>',N;
echo '<td class="hidden" style="width:10px"> </td>',N;
echo '<td class="button" style="width:25px">',AsImg($_SESSION[QT]['skin_dir'].'/ico_topic_a_0.gif','T',$L['Ico_topic_a_0'],'ico i_topic'),'</td>',N;
echo '<td class="button" style="width:120px"> <a href="qtf_find.php?a=news" class="button">',$L['All_news'],'</a> </td>',N;
if ($oVIP->role!='V')
{
echo '<td class="hidden" style="width:10px"> </td>',N;
echo '<td class="button" style="width:25px">',AsImg($_SESSION[QT]['skin_dir'].'/ico_user_p_1.gif','T',$L['Ico_user_p'],'ico i_user'),'</td>',N;
echo '<td class="button" style="width:120px"> <a href="qtf_find.php?a=user&k1=',$oVIP->id,'&k2=',urlencode($oVIP->username),'" class="button">',$L['All_my_topics'],'</a> </td>',N;
}
echo '</tr>',N;
echo '</table>',N;
echo '<h2>',$oVIP->selfname,'</h2>',N;
// COUNT
if ( isset($_GET['debug']) ) $oDB->debug=true;
$oDB->Query( $strCount );
$row = $oDB->Getrow();
$intCount = $row['countid'];
// FOUND
switch($a)
{
case 'ref':
$strSubtitle = $k1;
if ( $s>=0 ) $strSubtitle .= ' ('.$L['Section'].': '.(isset($_SESSION[QT]['sys_sections'][$s]) ? $_SESSION[QT]['sys_sections'][$s] : '').')';
$strSubtitle = $L['Ref'].': '.$strSubtitle.' · '.LangS('Result',$intCount);
break;
case 'kw':
$strSubtitle = $k1.' · '.LangS('Result',$intCount);
if ( $k2=='0' && count($arrKeys)>1 )
{
$strSubtitle .= ' · <a href="'.$oVIP->selfurl.'?a=kw&k1='.$k1.'&k2=1&s='.$s.'&k3='.$k3.'">'.$L['Search_by_words'].'</a>';
}
if ( $k2=='1' && count($arrKeys)>1 )
{
$strSubtitle .= ' · <a href="'.$oVIP->selfurl.'?a=kw&k1='.$k1.'&k2=0&s='.$s.'&k3='.$k3.'">'.$L['Search_exact_words'].'</a>';
}
$strOptions = '&k2='.$k2.'&k3='.$k3;
break;
case 'news':
$strSubtitle = $L['All_news'];
if ( $s>=0 ) $strSubtitle .= ' ('.$L['Section'].': '.(isset($_SESSION[QT]['sys_sections'][$s]) ? $_SESSION[QT]['sys_sections'][$s] : '').')';
$strSubtitle .= ' · '.LangS('Result',$intCount);
break;
case 'last':
$strSubtitle = $L['Recent_messages'];
if ( $s>=0 ) $strSubtitle .= ' ('.$L['Section'].': '.(isset($_SESSION[QT]['sys_sections'][$s]) ? $_SESSION[QT]['sys_sections'][$s] : '').')';
$strSubtitle .= ' · '.LangS('Result',$intCount);
break;
case 'user':
$strSubtitle = $L['Topics'].' '.strtolower($L['By']).' '.$k2;
if ( $s>=0 ) $strSubtitle .= ' ('.$L['Section'].': '.(isset($_SESSION[QT]['sys_sections'][$s]) ? $_SESSION[QT]['sys_sections'][$s] : '').')';
$strSubtitle .= ' · '.LangS('Result',$intCount);
$strOptions = '&k2='.urlencode($k2);
break;
case 'tst':
$strSubtitle='';
$arrStatuses = $oVIP->GetStatuses();
if ( $k1=='-1' ) { $strSubtitle = $L['Any_time']; }
elseif ( $k1=='w' ) { $strSubtitle = $L['This_week']; }
elseif ( $k1=='m' ) { $strSubtitle = $L['This_month']; }
elseif ( $k1=='y' ) { $strSubtitle = $L['This_year']; }
elseif ( is_numeric($k1) ) $strSubtitle = $L['dateMMM'][intval($k1)].' '.$intYear;
if ( $k2=='-1' )
{
$strSubtitle .= ', '.$L['Any_status'];
}
else
{
$strSubtitle .= ', '.$arrStatuses[$k2];
}
if ( count($arrTags)>0 ) $strSubtitle .= ', '.$L['With_tag'].' "'.implode('" '.$L['or'].' "',$arrTags).'"';
if ( $s>=0 ) $strSubtitle .= ' ('.$L['Section'].': '.(isset($_SESSION[QT]['sys_sections'][$s]) ? $_SESSION[QT]['sys_sections'][$s] : '').')';
$strSubtitle = '<p>'.$strSubtitle.' · '.LangS('Result',$intCount).'</p>';
$strOptions = '&k2='.$k2.'&k3='.$k3.'&y='.$intYear;
break;
}
// NO RESULT
if ($intCount==0)
{
echo '<p>',$strSubtitle,'</p>',N;
TableEmpty($L['E_no_topic'].'...');
echo '<p>« <a href="',Href($oVIP->exiturl),'">',$oVIP->exitname,'</a></p>';
include('qtf_p_footer.php');
exit;
}
// -----
// QUERY
// -----
// order
$strFullOrder = 't.'.$strOrder.' '.$strDir;
if ( $strOrder=='title' ) $strFullOrder='p.title'.' '.$strDir;
if ( $strOrder=='sectiontitle' ) $strFullOrder='s.title'.' '.$strDir;
// second order
if ( $strOrder!='lastpostdate' ) $strFullOrder .= ',t.lastpostdate DESC';
if ( QTF_LIST_ME && $oVIP->numpost>0 )
{
$oDB->Query( 'SELECT p.topic,p.issuedate FROM '.TABPOST.' p INNER JOIN '.TABSECTION.' s ON p.forum=s.id WHERE '.str_replace('t.forum','p.forum',$strSection).' AND p.type="R" AND p.userid='.$oVIP->id.' AND p.issuedate>"'.DateAdd(date('Ymd'),-2,'year').'" ORDER BY p.issuedate DESC' );
while($row=$oDB->Getrow()) { $i=intval($row['topic']); if ( !isset($arrMe[$i]) ) $arrMe[$i]=$row['issuedate']; if ( count($arrMe)>100 ) break; }
}
$oDB->Query( LimitSQL($strField.$strFrom.$strWhere,$strFullOrder,$intLimit,$_SESSION[QT]['topics_per_page'],$intCount) );
// --------
// DISPLAY
// --------
echo '<p>',$strSubtitle,'</p>',N;
// Button line and pager
$strPager = MakePager("$oVIP->selfurl?a=$a&k1=$k1&s=$s&page=1".$strOptions,$intCount,$_SESSION[QT]['topics_per_page'],$intPage);
if ($strPager!='') $strPager = $L['Page'].$strPager;
// -- Displays pager --
echo '<table class="hidden" cellspacing="0" summary="pages"><tr class="hidden"><td class="hidden" id="pager_zt"> ',$strPager,'</td></tr></table>';
// -- result --
echo '<table class="data_t" cellspacing="0" summary="subjects">',N;
echo '<tr class="data_t">',N;
// ========
$arrFLD = array();
$oFLD = new cFLD('icon','•','colhd colhdico colhdfirst','','colct colico colfirst'); $oFLD->uid='status'; $oFLD->sort='ASC'; $arrFLD['icon']=$oFLD;
$oFLD = new cFLD('numid',$L['Ref'],'colhd colref','','colct colref'); $oFLD->sort='DESC'; if ( $bAddRef ) $arrFLD['numid']=$oFLD;
$oFLD = new cFLD('smile',' ','colhd colsmi','','colct colsmi'); $arrFLD['smile']=$oFLD;
$oFLD = new cFLD('title',$L['Topics'],'colhd','','colct'); $oFLD->sort='DESC'; $arrFLD['title']=$oFLD;
$oFLD = new cFLD('you',' ','colhd center','width:10px','colct center'); if ( QTF_LIST_ME ) $arrFLD['you']=$oFLD;
$oFLD = new cFLD('sectiontitle',$L['Section'],'colhd','','colct'); $oFLD->sort='ASC'; $arrFLD['sectiontitle']=$oFLD;
$oFLD = new cFLD('firstpostname',$L['Author'],'colhd','width:140px','colct','','ASC'); $oFLD->sort='ASC'; $arrFLD['firstpostname']=$oFLD;
$oFLD = new cFLD('lastpostdate',$L['Last_message'],'colhd','width:135px','colct','','ASC'); $oFLD->sort='ASC'; $arrFLD['lastpostdate']=$oFLD;
if ( $a=='tst' && !empty($k3) )
{
$oFLD = new cFLD('tags',$L['Tags'],'colhd center colhdlast','width:80px','colct center collast'); $arrFLD['tags']=$oFLD;
}
else
{
$oFLD = new cFLD('replies',$L['Replys'],'colhd center colhdlast','width:70px','colct center collast','','DESC'); $oFLD->sort='DESC'; $arrFLD['replies']=$oFLD;
}
if ( isset($arrFLD['numid']) ) $arrFLD['numid']->class_dynamic=array('colbg_%s','status',array('0'=>'opened','1'=>'closed'));
// ========
TableHeader($arrFLD,$intCount,"qtf_find.php?a=$a&k1=$k1&s=$s&page=1".$strOptions,$strOrder,$strDir);
// ========
echo '</tr>',N;
// ========
$intWhile=0;
$strAlt='r1';
while($row=$oDB->Getrow())
{
TableRowShow($arrFLD,TableRowFormat($arrFLD,$row,true,null),'data_t'.$strAlt,$row);
if ( $strAlt=='r1' ) { $strAlt='r2'; } else { $strAlt='r1'; }
$intWhile++;
//odbcbreak
if ( $intWhile>=$_SESSION[QT]['topics_per_page'] ) break;
}
// ========
echo '<tr class="data_t">',N;
echo '<td class="colft colftfirst"></td>',N;
For ($i=0;$i<(count($arrFLD)-2);$i++)
{
echo '<td class="colft"></td>',N;
}
echo '<td class="colft colftlast"></td>',N;
echo '</tr>',N;
echo '</table>',N;
// -- no data --
if ( $intWhile==0 ) echo '<p>',$L['None'],'...</p>',N;
// -- Displays pager --
$strCsv = ($oVIP->role=='V' ? '' : HtmlCsvLink(Href('qtf_find_csv.php').'?a='.$a.'&k1='.$k1.'&s='.$s.$strOptions,$intCount,$intPage));
if ( !empty($strCsv) )
{
$strPager = $strCsv.' · '.$strPager;
if ( substr($strPager,-10,10)==' · ' ) $strPager = substr($strPager,0,-10);
}
echo '<table class="hidden" cellspacing="0"><tr class="hidden"><td class="hidden" id="pager_zb">',$strPager,'</td></tr></table>';
echo '<p>« <a href="',$oVIP->exiturl,'">',$oVIP->exitname,'</a></p>';
// --------
// HTML END
// --------
include('qtf_p_footer.php');
?>