Location: PHPKode > projects > QuickTalk Forum > quicktalk/qtf_search.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');
require_once('bin/qtf_fn_tags.php');
if ( !$oVIP->CanView('V5') ) HtmlPage(11);

// INITIALISE

$oVIP->selfurl = 'qtf_search.php';
$oVIP->selfname = $L['Search'];
$oVIP->exitname = $L['Search'];

$strAction = 'ref';
$s = -1;
$k1 = '';
$k2 = '-1';
$k3 = '';

if ( isset($_GET['a']) ) $strAction = strip_tags($_GET['a']);
if ( isset($_GET['s']) ) $s = intval($_GET['s']);
if ( isset($_POST['s']) ) $s = intval($_POST['s']);
if ( isset($_POST['s_ref']) ) $s = intval($_POST['s_ref']);
if ( isset($_POST['s_ti']) ) $s = intval($_POST['s_ti']);
if ( isset($_POST['s_kw']) ) $s = intval($_POST['s_kw']);

if ( isset($_GET['k1']) ) $k1 = strip_tags($_GET['k1']);
if ( isset($_POST['k1']) ) $k1 = strip_tags($_POST['k1']);
if ( isset($_GET['k2']) ) $k2 = strip_tags($_GET['k2']);
if ( isset($_POST['k2']) ) $k2 = strip_tags($_POST['k2']);
if ( isset($_GET['k3']) ) $k3 = strip_tags($_GET['k3']);
if ( isset($_POST['k3']) ) $k3 = strip_tags($_POST['k3']);

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

if ( isset($_POST['okref']) )
{
  if ( empty($k1) ) $error = $L['Ref'].' '.$L['E_invalid'];
  if ( empty($error) ) { $oVIP->exiturl = 'qtf_find.php?a=ref&amp;s='.$s.'&amp;k1='.$k1; $oVIP->EndMessage('0'); exit; }
}
if ( isset($_POST['oktst']) )
{
  if ( $k1=='-' || $k1=='--' || $k2=='-' ) $error = $L['Date'].' & '.$L['Status'].' '.$L['E_invalid'];
  if ( $k1=='-1' && $k2=='-1' && empty($k3) ) $error = $L['Date'].' & '.$L['Status'].' & Tag '.$L['E_invalid'];
  if ( $k3==';' ) $error = 'Tag '.$L['E_invalid'];
  if ( empty($error) ) { $oVIP->exiturl = 'qtf_find.php?a=tst&amp;s='.$s.'&amp;k1='.$k1.'&amp;y='.intval($_POST['y']).'&amp;k2='.$k2.'&amp;k3='.$k3; $oVIP->EndMessage('0'); exit; }
}
if ( isset($_POST['okkw']) )
{
  if ( empty($k1) ) $error = $L['Keywords'].' '.$L['E_invalid'];
  if ( empty($error) ) { $oVIP->exiturl = 'qtf_find.php?a=kw&amp;s='.$s.'&amp;k1='.$k1.'&amp;k2='.(isset($_POST['k2']) ? '1' : '0').'&amp;k3='.($k3=='1' ? '1' : '0'); $oVIP->EndMessage('0'); exit; }
}

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

$arrTags = cSection::GetTagsUsed(-1);
if ( count($arrTags)>0 ) $arrTags = TagsDesc($arrTags);
$str  = '';
foreach($arrTags as $strKey=>$strDesc) { $str .= '"'.$strKey.'",'; }
$str = substr($str,0,-1);

$strHeadScript = '
<link rel="stylesheet" type="text/css" href="bin/css/qt_jquery.css"/>
<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">
<!--
function ValidateForm(str)
{
  if (document.getElementById(str).value.length==0) { alert(qtHtmldecode("'.$L['E_mandatory'].'")); return false; }
  return true;
}
function SearchOption(strValue)
{
  if (document.getElementById("s_ref")) document.getElementById("s_ref").value=strValue;
  if (document.getElementById("s_ti")) document.getElementById("s_ti").value=strValue;
  if (document.getElementById("s_kw")) document.getElementById("s_kw").value=strValue;
  if (document.getElementById("s_tag")) document.getElementById("s_tag").value=strValue;
}
$(document).ready(function() {
  $("#tag").autocomplete(['.$str.'],{
    minChars:0,
    matchContains:1,
    width:200,
    multiple:true,
    multipleSeparator:";"
    });
});
-->
</script>
';  

include('qtf_p_header.php');

// TOP BUTTONS

echo '<table class="hidden" cellspacing="0" summary="quick search">',N;
echo '<tr class="hidden">',N;
echo '<td class="hidden">&nbsp;</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">&nbsp;<a href="qtf_find.php?a=last" class="button">',$L['Recent_messages'],'</a>&nbsp;</td>',N;
echo '<td class="hidden" style="width:10px">&nbsp;</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">&nbsp;<a href="qtf_find.php?a=news" class="button">',$L['All_news'],'</a>&nbsp;</td>',N;
if ($oVIP->role!='V')
{
echo '<td class="hidden" style="width:10px">&nbsp;</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">&nbsp;<a href="qtf_find.php?a=user&amp;k1=',$oVIP->id,'&amp;k2=',urlencode($oVIP->username),'" class="button">',$L['All_my_topics'],'</a>&nbsp;</td>',N;
}
echo '</tr>',N;
echo '</table>',N;

// SEARCH OPTION

echo '<h2>',$L['Search_option'],'</h2>
<form method="post" action="',$oVIP->selfurl,'">
<table class="data_s" cellspacing="0" style="width:500px" summary="search options">
<tr class="data_s">
<td class="colhd colhdempty colhdfirst"></td>
<td class="colhd colhdempty"></td>
<td class="colhd colhdempty colhdlast"></td>
</tr>
<tr class="data_s">
<td class="colct colico colfirst">',AsImg($_SESSION[QT]['skin_dir'].'/ico_section_option.gif','search',$L['Search'],'ico i_sec'),'</td>
<td class="colct">',$L['Search'],' <select id="s" name="s" size="1" onchange="SearchOption(this.value);">
<option value="-1"',($s=='-1' ? QSEL : ''),'>',$L['In_all_sections'],'</option>';
if ( isset($oVIP) ) {
if ( count($_SESSION[QT]['sys_sections'])>0 ) {
  echo Gotolist($s);
}}
echo '
</select>
<input type="submit" id="o_ok" name="o_ok" value="',$L['Ok'],'"/>
</td>
<td class="colct"></td>
</tr>
<tr class="data_s">
<td class="colft colftfirst"></td>
<td class="colft"></td>
<td class="colft colftlast"></td>
</tr>
</table>
</form>
<br/>
';

echo '
<h2>',$L['Search_criteria'],'</h2>
';

// ERROR MESSAGE

if ( !empty($error) ) echo '<p class="error">',$error,'</p>';

// SEARCH BY REF

if ( isset($oVIP) ) {
if ( count($_SESSION[QT]['sys_sections'])>0 ) { $arrSections = QTarrget(GetSections($oVIP->role,-1,-1,'s.numfield<>"N"'));
if ( count($arrSections)>0 ) {
echo '<form method="post" action="',$oVIP->selfurl,'" onsubmit="return ValidateForm(\'ref\');">
<table class="data_s" cellspacing="0" summary="search criteria">
<tr class="data_s">
<td class="colhd colhdempty colhdfirst"></td>
<td class="colhd colhdempty"></td>
<td class="colhd colhdempty colhdlast"></td>
</tr>
<tr class="data_s">
<td class="colct colico colfirst">',AsImg($_SESSION[QT]['skin_dir'].'/ico_section_search.gif','search',$L['Search'],'ico i_sec'),'</td>
<td class="colct">',$L['Ref'],' <input type="text" id="ref" name="k1" size="5" maxlength="10" value="'.($strAction=='ref' ? $k1 : '').'"/>&nbsp;<label for="title">',$L['H_Reference'],'</label></td>
<td class="colct" style="padding:7px; text-align:right">
<input type="hidden" id="s_ref" name="s_ref" value="',$s,'"/>
<input type="submit" id="okref" name="okref" value="',$L['Search'],'" onclick="return ValidateForm(\'ref\');"/>
</td>
</tr>
<tr class="data_s">
<td class="colft colftfirst"></td>
<td class="colft"></td>
<td class="colft colftlast"></td>
</tr>
</table>
</form>
<br/>
';
}}}

// SEARCH BY KEY

echo '<form method="post" action="',$oVIP->selfurl,'" onsubmit="return ValidateForm(\'kw\');">
<table class="data_s" cellspacing="0" summary="search criteria">
<tr class="data_s">
<td class="colhd colhdempty colhdfirst"></td>
<td class="colhd colhdempty"></td>
<td class="colhd colhdempty colhdlast"></td>
</tr>
<tr class="data_s">
<td class="colct colico colfirst">',AsImg($_SESSION[QT]['skin_dir'].'/ico_section_search.gif','search',$L['Search'],'ico i_sec'),'</td>
<td class="colct">',$L['Keywords'],' <input type="text" id="kw" name="k1" size="40" maxlength="64" value="'.($strAction=='kw' ? $k1 : '').'"/>&nbsp;<input type="checkbox" id="to" name="k3"',(empty($k3) ? '' : QCHE),' value="1"/> <label for="to">',$L['In_title_only'],'</label>
</td>
<td class="colct" style="padding:7px; text-align:right">
<input type="hidden" id="s_kw" name="s_kw" value="',$s,'"/>
<input type="submit" id="okkw" name="okkw" value="',$L['Search'],'" onclick="return ValidateForm(\'kw\');"/>
</td>
</tr>
<tr class="data_s">
<td class="colft colftfirst"></td>
<td class="colft"></td>
<td class="colft colftlast"></td>
</tr>
</table>
</form>
<br/>
';

// SEARCH BY DATE & STATUS & TAGS

echo '<form method="post" action="',$oVIP->selfurl,'">
<table class="data_s" cellspacing="0" summary="search criteria">
<tr class="data_s">
<td class="colhd colhdfirst colhdempty"></td>
<td class="colhd colhdempty"></td>
<td class="colhd colhdlast colhdempty"></td>
</tr>
<tr class="data_s">
<td class="colct colico colfirst">',AsImg($_SESSION[QT]['skin_dir'].'/ico_section_search.gif','search',$L['Search'],'ico i_sec'),'</td>
<td class="colct">',$L['Date'],' <select id="ti" name="k1" size="1" class="small">
<option value="w"',($k1=='w' ? QSEL : ''),'>',$L['This_week'],'</option>
<option value="m"',($k1=='m' ? QSEL : ''),'>',$L['This_month'],'</option>
<option value="y"',($k1=='y' ? QSEL : ''),'>',$L['This_year'],'</option>
<option value="-" disabled="disabled">-----------</option>
<option value="-1"',($k1=='-1' ? QSEL : ''),'>',$L['Any_time'],'</option>
<option value="--" disabled="disabled">-----------</option>
',QTasTag($L['dateMMM'],$k1),'
</select><input type="hidden" name="y" value="',date('Y'),'"/>
',$L['Status'],' <select id="st" name="k2" size="1" class="small">
<option value="-1"',($k2=='-1' ? QSEL : ''),'>',$L['Any_status'],'</option>
<option value="-" disabled="disabled">-----------</option>
 ',QTasTag($oVIP->GetStatuses(),$k2),'
</select>
 ';
if ( $_SESSION[QT]['tags']!='0' ) echo $L['With_tag'],' <input type="text" id="tag" name="k3" size="30" value="'.($strAction=='tst' ? $k3 : '').'" class="small"/>*';
echo '</td>
<td class="colct" style="padding:7px; text-align:right">
<input type="hidden" id="s_tst" name="s_tst" value="',$s,'"/>
<input type="submit" id="oktst" name="oktst" value="',$L['Search'],'"/>
</td>
</tr>
<tr class="data_s">
<td class="colft colftfirst"></td>
<td class="colft"></td>
<td class="colft colftlast"></td>
</tr>
</table>
</form>
';
if ( $_SESSION[QT]['tags']!='0' ) echo '<p class="small">* ',$L['H_Tag_input'],'</p>';

// HTML END

echo '<script type="text/javascript">
<!--
document.getElementById("o_ok").style.visibility="hidden";
document.getElementById("kw").focus();
-->
</script>
';

include('qtf_p_footer.php');

?>
Return current item: QuickTalk Forum