Location: PHPKode > projects > QuickTicket > quickticket/quickticket/qti_s_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   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);

// INITIALISE

$strTitle = '';

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

$bWithref=false;
if ( isset($_SESSION['qtiGoto']) ) {
if ( count($_SESSION['qtiGoto'])>0 ) { $arrSections = GetSectionTitles($oVIP->role,-1,-1,'numfield<>"N"');
if ( count($arrSections)>0 ) {
  $bWithref=true;
}}}

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

if ( isset($_POST['ok']) )
{

  // security check
  $strTitle = $_POST['title']; if ( get_magic_quotes_gpc() ) $strTitle = stripslashes($strTitle);
  $strTitle = strip_tags($strTitle);

    // read keys
    $arrKeys = split(' ',$strTitle);
    // convert stringnumber to int (if bWithref) and count the different types
    $iNumber = 0;
    $iString = 0;
    foreach ($arrKeys as $intKey => $strVal)
    {
      if ( is_numeric($strVal) && $bWithref )
      {
        if ( strstr($strVal,'.') ) $qti_error = $L['E_ref_search'];
        if ( strstr($strVal,',') ) $qti_error = $L['E_ref_search'];
        $arrKeys[$intKey]=intval($strVal);
        $iNumber++;
      }
      else
      {
        $iString++;
        if ( substr($strVal,0,1)=='"' && substr($strVal,-1,1)=='"' ) $arrKeys[$intKey]= substr($strVal,1,-1);
      }
    }
    // reject if different types exist
    if ( $iNumber>1 ) { $qti_error = $L['H_Advanced']; $strTitle = $arrKeys[0]; }
    if ( $iNumber>0 && $iString>0 ) { $qti_error = $L['H_Advanced']; $strTitle = $arrKeys[0]; }

    if ( empty($qti_error) && $iNumber==1 )
    {
      if ( headers_sent() )
      {
      echo '<a href="qti_search_id.php?ref=',$arrKeys[0],'">',$L['Search'],'</a><meta http-equiv="REFRESH" content="0;url=qti_search_id.php?ref=',$arrKeys[0],'">';
      }
      else
      {
      header('Location: qti_search_id.php?ref='.$arrKeys[0]);
      }
      exit;
    }
    if ( empty($qti_error) && $iString>0 )
    {
      if ( headers_sent() )
      {
      echo '<a href="qti_search_kw.php?title=',implode('+',$arrKeys),'">',$L['Search'],'</a><meta http-equiv="REFRESH" content="0;url=qti_search_kw.php?title=',implode('+',$arrKeys),'">';
      }
      else
      {
      header('Location: qti_search_kw.php?title='.implode('+',$arrKeys));
      }
      exit;
    }
}

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

include('qti_p_header.php');

// TOP BUTTONS

echo '<table class="ta_button" cellspacing="0">',N;
echo '<tr class="tr_button">',N;
echo '<td>&nbsp;</td>',N;
echo '<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>',N;
echo '<td style="width:120px" class="td_button">&nbsp;<a href="qti_search_ov.php?a=last" class="a_button">',$L['Recent_messages'],'</a>&nbsp;</td>',N;
echo '<td style="width:10px">&nbsp;</td>',N;
echo '<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>',N;
echo '<td style="width:120px" class="td_button">&nbsp;<a href="qti_search_ov.php?a=news" class="a_button">',$L['All_news'],'</a>&nbsp;</td>',N;
if ($oVIP->role!='V')
{
echo '<td style="width:10px">&nbsp;</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">&nbsp;<a href="qti_search_ov.php?a=user&amp;id=',$oVIP->id,'&amp;n=',urlencode($oVIP->username),'" class="a_button">',$L['All_my_topics'],'</a>&nbsp;</td>',N;
}
echo '</tr>',N;
echo '</table>',N;

echo '
<script type="text/javascript">
<!--
function ValidateForm(theForm)
{
  if (theForm.title.value.length==0) { alert(html_entity_decode("',$L['E_mandatory'],'")); return false; }
  return null;
}
-->
</script>
';

// SIMPLE SEARCH

echo '<h2>',$L['Search'],'</h2>
<form method="post" action="qti_s_search.php" onsubmit="return ValidateForm(this);">
<table class="ta ta_s" cellspacing="0">
<tr class="tr_t">
<th class="th_t th_t_first th_t_empty"></th>
<th class="th_t th_t_empty"></th>
<th class="th_t th_t_last th_t_empty"></th>
</tr>
<tr class="tr_t">
<td class="td_t" style="text-align:center; width:50px">',AsImg($_SESSION[QT]['skin_dir'].'/ico_section_search.gif','search',$L['Search'],'ico ico_s'),'</td>
<td class="td_t"><input type="text" id="title" name="title" size="24" maxlength="32" value="',$strTitle,'" onKeyUp="handle_keypress(event,\'ok\')"/>&nbsp;<input type="submit" id="ok" name="ok" value="',$L['Ok'],'"/>',($bWithref ? ' <span class="small">'.$L['H_Advanced'].'</span>' : ''),'</td>
<td class="td_t" style="padding:7px; text-align:right"><a href="qti_search.php">',$L['Advanced'],'</a></td>
</tr>
<tr class="tr_t">
<td class="tf_t tf_t_first"></td>
<td class="tf_t"></td>
<td class="tf_t tf_t_last"></td>
</tr>
</table>
</form>
';

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

// HTML END

echo '<script type="text/javascript">
<!--
document.getElementById("title").focus();
-->
</script>';

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