Changeset 17 for trunk/search.php
- Timestamp:
- May 25, 2003, 10:31:39 AM (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/search.php
r10 r17 24 24 if ( isset( $_POST['search'] ) ) 25 25 { 26 $i = 0; 27 if ( strlen( $_POST['search'] ) > 2 ) 26 $redirect = true; 27 $search = array(); 28 $words = preg_split( '/\s+/', $_POST['search'] ); 29 foreach ( $words as $i => $word ) { 30 if ( strlen( $word ) > 2 and !preg_match( '/[,;:\']/', $word ) ) 31 { 32 array_push( $search, $word ); 33 } 34 else 35 { 36 $redirect = false; 37 array_push( $error, $lang['invalid_search'] ); 38 break; 39 } 40 } 41 $search = array_unique( $search ); 42 $search = implode( ',', $search ); 43 if ( $redirect ) 28 44 { 29 $url = add_session_id( 'category.php?cat=search&search='.30 $_POST['search'], true );45 $url = 'category.php?cat=search&search='.$search.'&mode='.$_POST['mode']; 46 $url = add_session_id( $url, true ); 31 47 header( 'Request-URI: '.$url ); 32 48 header( 'Content-Location: '.$url ); 33 49 header( 'Location: '.$url ); 34 50 exit(); 35 }36 else37 {38 $error[$i++] = $lang['invalid_search'];39 51 } 40 52 } … … 68 80 $vtp->closeSession( $handle, 'errors' ); 69 81 } 70 //---------------------------------------------------------------- search field 82 //------------------------------------------------------------------------ form 83 // search field 71 84 $vtp->addSession( $handle, 'line' ); 72 85 $vtp->setVar( $handle, 'line.name', $lang['search_field_search'] ); … … 77 90 $vtp->closeSession( $handle, 'text' ); 78 91 $vtp->closeSession( $handle, 'line' ); 92 // mode of search : match all words or at least one of this words 93 $vtp->addSession( $handle, 'line' ); 94 $vtp->addSession( $handle, 'group' ); 95 96 $vtp->addSession( $handle, 'radio' ); 97 $vtp->setVar( $handle, 'radio.name', 'mode' ); 98 $vtp->setVar( $handle, 'radio.value', 'OR' ); 99 $vtp->setVar( $handle, 'radio.option', $lang['search_mode_or'] ); 100 if ( $_POST['mode'] == 'OR' or $_POST['mode'] == '' ) 101 { 102 $vtp->setVar( $handle, 'radio.checked', ' checked="checked"' ); 103 } 104 $vtp->closeSession( $handle, 'radio' ); 105 106 $vtp->addSession( $handle, 'radio' ); 107 $vtp->setVar( $handle, 'radio.name', 'mode' ); 108 $vtp->setVar( $handle, 'radio.value', 'AND' ); 109 $vtp->setVar( $handle, 'radio.option', $lang['search_mode_and'] ); 110 if ( $_POST['mode'] == 'AND' ) 111 { 112 $vtp->setVar( $handle, 'radio.checked', ' checked="checked"' ); 113 } 114 $vtp->closeSession( $handle, 'radio' ); 115 116 $vtp->closeSession( $handle, 'group' ); 117 $vtp->closeSession( $handle, 'line' ); 79 118 //---------------------------------------------------- return to main page link 80 119 $vtp->setGlobalVar( $handle, 'back_url', add_session_id( './category.php' ) ); … … 83 122 echo $code; 84 123 //------------------------------------------------------------ log informations 124 pwg_log( 'category', $page['title'] ); 125 mysql_close(); 85 126 $query = 'insert into '.PREFIX_TABLE.'history'; 86 127 $query.= '(date,login,IP,page) values';
Note: See TracChangeset
for help on using the changeset viewer.