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

// INITIALISE

$strTitle = '';

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

$bWithref=false;
if ( isset($oVIP) ) {
if ( count($oVIP->sections)>0 ) { $arrSections = QTarrget(GetSections($oVIP->role,-1,-1,'s.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);
  if ( $strTitle=='' ) $error = $L['Keywords'].' '.$L['E_invalid'];

  // read keys 

  $arrKeys = explode(' ',$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,'.') ) $error = $L['E_ref_search'];
      if ( strstr($strVal,',') ) $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 ) { $error = $L['H_Advanced']; $strTitle = $arrKeys[0]; }
  if ( $iNumber>0 && $iString>0 ) { $error = $L['H_Advanced']; $strTitle = $arrKeys[0]; }
  
  if ( empty($error) && $iNumber==1 ) $oHtml->Redirect('qti_find.php?a=ref&amp;k1='.$arrKeys[0],$L['Search']);
  if ( empty($error) && $iString>0 ) $oHtml->Redirect('qti_find.php?a=kw&amp;k1='.urlencode(implode('+',$arrKeys)).'&amp;k2=0&amp;k3=0',$L['Search']);
}

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

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

include('qti_p_header.php');
include('qti_search_inc.php');

// SIMPLE SEARCH

echo '<h2>',$L['Search'],'</h2>
<form method="post" id="s_search" action="',Href(),'">
<table class="data_s" cellspacing="0">
<tr class="data_s">
<td class="colhd colhdfirst colhdempty"></td>
<td class="colhd colhdempty"></td>
<td class="colhd colhdlastt 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 ico_s'),'</td>
<td class="colct"><input type="text" id="title" name="title" size="24" maxlength="32" value="',$strTitle,'" onkeyup="qtKeypress(event,\'ok\')" />&nbsp;<input type="submit" id="ok" name="ok" value="',$L['Ok'],'" />',($bWithref ? ' <span class="small">'.$L['H_Advanced'].'</span>' : ''),'</td>
<td class="colct" style="padding:7px; text-align:right"><a href="qti_search.php">',$L['Advanced_search'],'...</a></td>
</tr>
<tr class="colft">
<td class="colft colftfirst"></td>
<td class="colft"></td>
<td class="colft colflast"></td>
</tr>
</table>
</form>
';

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

// HTML END

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

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