= 1)) { $search = str_replace(' ',' ',$search); } //remove multiple speech marks: while ((substr_count($search,'""') >= 1)) { $search = str_replace('""','"',$search); } //remove speech marks on start or end only if (($search[0] == '"') and ($search[(strlen($search) - 1)] <> '"') or ($search[0] <> '"') and ($search[(strlen($search) - 1)] == '"')) { $search = str_replace('"','',$search); } //define globals so they can be returned by functions $GLOBALS['highlight1'] = ''; $GLOBALS['highlight2'] = ''; $GLOBALS['result'] = ''; $GLOBALS['theurl'] = ''; $GLOBALS['thedate'] = ''; function highlight($thefield,$thefieldlow,$thesearch) { $fieldlength = strlen($thefield); $searchlength = strlen($thesearch); $pos = strpos($thefield, $thesearch); $stringend = $searchlength + $pos; $slice1 = substr($thefield, 0, $pos); $slice2 = substr($thefield, $pos, $searchlength); $slice3 = substr($thefield, $stringend); $GLOBALS['result'] = $slice1.$GLOBALS['highlight1'].$slice2.$GLOBALS['highlight2'].$slice3; //rebuild text with highlight } function getdetails($myurl,$folder,$demo_path,$demo_name,$demo_day,$demo_month,$demo_year) { $filetype_check = substr($demo_path,-4); if ($filetype_check <> '.php') { $filetype = '.html'; } if ($demo_name == 'Using Images To Show Link States') {$filetype = '.html#using';} switch ($folder) { case '': $folder = 'demos/'; break; case 'r': $folder = 'archives/'; break; case 'b': $folder = 'bugs/'; break; case 't': $folder = 'tips/'; break; case 'a': $folder = 'articles/'; break; case 'l': $folder = 'testlab/'; } if ($demo_day <> '') { $GLOBALS['thedate'] = date('jS F Y', mktime(0,0,0,$demo_month,$demo_day,($demo_year + 2000))); } else { $GLOBALS['thedate'] = 'Unknown date'; } $GLOBALS['theurl'] = $myurl.$folder.$demo_path.$filetype; } $title = 'Flat File Database Demo 6'; echo <<
ERROR: Unable to open database file!
');} $row = 0; while (!feof($fp)) { $col[$row] = fgets($fp,1024); //use 2048 if very long lines $row++; } fclose($fp); //Avoid sort below if you have numbers at the start of each line! //It puts all the lines beginning with 1 first, eg: 1, 10, 11, 12 etc. //sort($col); reset($col); $arrays = count($col) - 1; $GLOBALS['finds'] = ''; $loop = -1; $and = $once = $found = $found1 = $found2 = $bothfound = $search2also = 'no'; $count = 0; $speechmarks = ''; //test for AND but not two words that must be together (""): if ((strstr($search,' AND ')) and ($search[0] <> '"')) { $and = 'yes'; list ($word1, $word2, $word3) = explode (' ', $search); //remove AND $word1 = strtolower($word1); $word3 = strtolower($word3); if ($word1 == $word3) { $search = $word1; $and = 'no'; } else { $search1 = $word1; $search2 = $word3; while ($loop < $arrays) { $loop++; list($folder,$demo_path,$demo_name,$demo_notes,$demo_day,$demo_month,$demo_year) = explode('|',$col[$loop]); $field = $demo_name.'|'.$demo_notes; //preserve original text $fieldlow = strtolower($field); if ((strstr($fieldlow,$search1)) and (strstr($fieldlow,$search2))) { $found = $found1 = $found2 = $bothfound = 'yes'; getdetails($myurl,$folder,$demo_path,$demo_name,$demo_day,$demo_month,$demo_year); //word1 highlight($fieldlow,$field,$search1); //word2 $fieldlow = strtolower($GLOBALS['result']); //update field to include highlighted version from above highlight($fieldlow,$GLOBALS['result'],$search2); list($highlighted,$highlighted2) = explode('|',$GLOBALS['result']); if ($count >= $limit) { $hide = floor($count / $limit); $showpages = 'yes'; } $GLOBALS['finds'].='\''.$speechmarks.$search.$speechmarks.'\' found '.$count.' demo'.$plural.':
Page: 1'; $pinkfloyd = 1; while ($pinkfloyd < $pagecount) { $pinkfloyd++; // if ($pinkfloyd > $buttons) {echo ' Next '.$buttons.' > < Previous '.$buttons.' Last ('.$pagecount.')'; break;} echo ' '.$pinkfloyd.''; } echo '
'; } } else { echo '\''.$speechmarks.$search.$speechmarks.'\' was not found.
'; } echo '
By Chris Hester 7th February 2012 | Updated: '.date('jS F Y', getlastmod()).' | About The Demo | Comments