Super Sonic Search Engine Script for your website and webfiles.
Hi! again!.This is the fastest of the search engine php scripts and uses less resources than the full version and around the same as preg but this is faster. Its a scaled down modified version of the strpos super search but it still retains all the same features and output like a preg match search. You can lean it up a bit more and remove the seperate results and just highlight any keywords in the snippet description.
What makes this script great as always you have options for directory read or array list for files and html content rip feature and more. You can compare the speed and check memory usage as well to the other search scripts.
How? Well I will give you a run down on this version.
Keywords: we explode multiple words into array and merge the combined with multiples and reverse to match exact first.
Features:Limit amount of words, filter for word length and duplicate words.
File Contents: Strpos is used and checks strlen and for a space at end of string for word exact match.
Features: Can get files from directory or array list.
Displays the total of search words count per page.
Lists files by word count score and removes duplicate file arrays.
Search process: Emimated the explode and count keys to get the lead and trailing result text. With this method we just strpos the text and grab the snippets by substring position or strpos!!
Features: Outputs search word match count and
link to file and well as the meta description snippet.
You can set the amout of leading and trailing words to display.
Its a lite version of the Strpos super search but faster and just as precise.
Made for static sites or directory read and load content or content loaded from flat file db content but you can easily modify it for file line read or i can do it for you for 3 dollar donation. Check it out the demo and give it a try on this site!
You can download it for free below. Please donate a dollar for me.
Its works great and its very efficient and versatile. I hope you can find it useful. Check it out below. If you have a comment stop at the forum!
1: <!doctype html>
2: <html lang="en">
3: <head>
4: <title>CMXads Strpos Super Sonic Search</title>
5: <meta charset="utf-8">
6: <meta name="robots" content="noindex">
7: <meta name="description" content="Strpos super sonic search engine free php script The speed and efficiency of a strpos search. Made for large number of files and you need precise exact results and output just like preg match and uses low resources and is the fastest and best search engine script there is. A lean version of the many cmxads search scripts. Demo and download.">
8: <style type="text/css">
9: body, html {
10: margin:10px 10px;
11: font-size:14px;
12: height:100%;
13:
14: font-family: Tahoma, Arial;
15: background:#E0E0E0;
16: background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#FFFFFF), to(#E0E0E0 ));*/
17: background: -moz-linear-gradient(top, #FFFFFF 0%, #E0E0E0 100%);*/
18: background: -o-linear-gradient(top, #FFFFFF 0%, #E0E0E0 100%);*/
19: background: linear-gradient(top, #FFFFFF 0%, #E0E0E0 100%);*/
20: }
21: #wrapper {
22: padding:10px;
23: width:600px;
24:
25: min-height:100%;
26: background-color: #ffffff;
27: border: 2px solid #333;
28: /* curved border radius */
29: -moz-border-radius:20px;
30: -webkit-border-radius:20px;
31: -o-border-radius:20px;
32: border-radius:20px;
33: }
34:
35: </style>
36:
37: </head>
38:
39: <body>
40: <div id="wrapper">
41:
42: <h3>CMXads Strpos Super Sonic Search</h3>
43: <form name='searchform' id='searchform' action='<?php echo $_SERVER['PHP_SELF']; ?>' method='get'>
44: <input type='text' name='keyword' id='keyword' value='<?php echo @$_GET['keyword']; ?>'><br>
45: <input type='submit' value='submit'>
46: </form>
47: <hr>
48:
49: <?php
50: //makes link title from file name
51: function Title($filename) {
52: $title = substr($filename, 0, strlen($filename) - 4);
53: $title = str_replace('-', ' ', $title);
54: $title = ucwords($title);
55: return $title;
56: }
57: //cuts our result page description text
58: function snippet($text,$length,$tail='...') {
59: $text = trim($text);
60: $txtl = strlen($text);
61: if($txtl > $length) {
62: for($i=1;$text[$length-$i]!=" ";$i++) {
63: if($i == $length) {
64: return substr($text,0,$length) . $tail;
65: }
66: }
67: $text = substr($text,0,$length-$i+1) . $tail;
68: }
69: return $text;
70: }
71: function snippet_needle($text,$length) {
72: $text = trim($text);
73: $txtl = strlen($text);
74: if($txtl > $length) {
75: for($i=1;$text[$length-$i]!=" ";$i++) {
76: if($i == $length) {
77: return substr($text,0,$length).'..';
78: }
79: }
80: $text = substr($text,0,$length-$i+1);
81: }
82: return $text.'..';
83: }
84: function snippet_pre_needle($text,$length,$end=' ') {
85: $text = strrev(trim($text));
86: $txtl = strlen($text);
87: if($txtl > $length) {
88: for($i=1;$text[$length-$i]!=' ';$i++) {
89: if($i == $length) {
90: return '..' . strrev(substr($text,0,$length)).$end;
91: }
92: }
93: $text = substr($text,0,$length-$i+1);
94: }
95: return '..' . strrev($text).$end;
96: }
97: //utf lock and get file
98: function flock_utf8_contents($filename){
99: $return = FALSE;
100: if(file_exists($filename) and is_readable($filename)){
101: if($handle = @fopen($filename, 'r')){
102: while(!$return){
103: if(flock($handle, LOCK_SH)){
104: if($return = file_get_contents($filename)){
105: flock($handle, LOCK_UN);
106: }}}
107: fclose($handle);
108: }}
109: return mb_convert_encoding($return, 'UTF-8',
110: mb_detect_encoding($return, 'UTF-8, ISO-8859-1', true));
111: }
112:
113: if(isset($_GET['keyword']) && !empty($_GET['keyword'])){
114: $starttime = microtime();
115: $startarray = explode(" ", $starttime);
116: $starttime = $startarray[1] + $startarray[0];
117: if(strlen($_GET['keyword'])<3){
118: echo 'Search term must be at least 3 characters.<br>';
119: echo '<form><input type="button" value="back" onclick="history.go(-1);return true;"></form>';
120: echo '</div><br>';
121: echo '<p><a href="http://www.cmxads.com/super-sonic-search.php">Super Sonic Strpos Search Script</a></p>';
122: echo '</body>';
123: echo '</html>';
124: exit;
125: }
126:
127:
128:
129: $keywords=$_GET['keyword'];
130:
131: //set domain for link optional. no end/
132: $domain='';
133: //set for break trigger on exact match
134: $matched='';
135: //if ripping html tag content for string set to 1. else ''
136: $rip_html='1';
137: //if not ripping html and want alpha numeric only set to 1. else ''
138: $clean_string='1';
139: //limit total keywords. number of words
140: $word_count='4';
141: //set amount of characters rounded to words for result page description pulled from search string
142: $length='155';
143: //set amount of leading and trailing letters rounded to words for each matched result
144: $prewords='30';
145: //use file list array 1 empty use glob set folder below
146: $file_list='1';
147: //example get files using glob
148: // ./ is root or folder/ set ext
149: $folder='./';
150: //set ext php or htm etc
151: $ext='php';
152: if(empty($file_list) and is_dir($folder)){
153: $files = glob("$folder*.$ext");
154: }
155:
156: if($file_list){
157: //set files array to search method
158: $pages=array(
159: 'strpos-super-search-engine-script.php',
160: 'substr-super-search-engine.php',
161: 'html-tags-content-made-easy.php',
162: 'webpage-search-engine-script.php',
163: 'top20phperrors.php',
164: 'sessionsscanandban.php',
165: 'services.php',
166: 'scriptsntips.php',
167: 'safelist-script.php',
168: 'privacy.php',
169: 'policy.php',
170: 'onepagehostingmanagerscript.php',
171: 'new-style-captcha-contact-form.php',
172: 'mailing-list-script.php',
173: 'index.php',
174: 'image-file-upload-manager-script.php',
175: 'home.php',
176: 'greathorizontaldropdownmenu.php',
177: 'freeflatfileforumscript.php',
178: 'free-chat-shout-textdb-php-script.php',
179: 'flatfile-users-bots-online.php',
180: 'ezmail.php',
181: 'editable-encrypted-paypal-secure-button.php',
182: 'editable-dynamic-secure-paypal-buy-now-button.php',
183: 'edit-webpage-html-table-pure-php.php',
184: 'directory-tree-dropdown-menu-example-website.php',
185: 'datascanandban.php',
186: 'curltofile.php',
187: 'csvtodbscript.php',
188: 'contact.php',
189: 'cheap-webdesign-with-hosting.php',
190: 'better-than-sql-flatfile-db-cms-website-script-example.php',
191: 'bestjquerydropdownmenus.php',
192: 'anti_injection_php_script.php',
193: 'anti-injection-php-script.php',
194: 'anonoblog.php',
195: 'adverts.php',
196: 'advertising.php',
197: 'about.php',);
198: }
199:
200:
201:
202: //set content to rip in order
203: //to get all page content just use the main content div name or p etc inside main content
204: //set exactly start and end
205: $tags=array(
206: '<title>' => '</title>',
207: '<meta name="description" content="' => '.">',
208: '<section id="content">' => '</section>',
209: );
210:
211:
212:
213:
214: //remove extra spaces and trim keywords
215: $needle=preg_replace('/(\s)\s+/', ' ',$keywords);
216: $needle=trim(strtolower(preg_replace('#[^A-Za-z0-9\s]#', '',$needle)));
217: //explode into array
218: $needles=explode(' ',$needle);
219: //remove words less than 3 characters long
220: $needles = array_filter($needles, function($x) { return strlen($x) >= 3; });
221: //remove duplicate keywords
222: $needles=$needles3=array_unique($needles);
223: //slice array to keywords limit
224: if(count($needles)>$word_count){
225: $needles=$needles3=array_slice($needles,0,$word_count);
226: }
227:
228: if(count($needles)>1){
229: $merge=trim(implode(' ',$needles));
230: $needles=array_reverse(array_merge($needles, array($merge)));
231: }
232: //count final keywords total after filter
233: $cnt=count($needles);
234: //less than 1 after filter error
235: if($cnt<1){
236: echo 'Search term invalid.<br>';
237: echo '<form><input type="button" value="back" onclick="history.go(-1);return true;"></form>';
238: echo '</div><br>';
239: echo '<p><a href="http://www.cmxads.com/super-sonic-search.php">Super Sonic Strpos Search Script</a></p>';
240: echo '</body>';
241: echo '</html>';
242: exit;
243:
244: }
245:
246: //alpha numeric only
247: function string_clean($c1)
248: {
249: $c1=trim(preg_replace('/(\s)\s+/', ' ', $c1));
250: return trim(preg_replace("/[^A-Za-z0-9\s]/", "",$c1));
251: }
252:
253:
254: function rip_tags($text){
255: global $tags;
256: global $clean_string;
257: $result=array();
258: foreach($tags as $start =>$end){
259: $r = explode($start, $text);
260: if (isset($r[1])){
261: $r = explode($end, $r[1]);
262: if($clean_string){
263: $result[]=string_clean(trim(strip_tags($r[0])));
264: }else{
265: $result[]=preg_replace('/(\s)\s+/', ' ',trim(strip_tags($r[0])));
266: }
267: }else{
268: return false;
269: }
270: }
271: return implode(' ',$result);
272: }
273: //var_dump($needles);
274:
275: //no result flag
276: $results='';
277: //set page result number
278: $nm=1;
279:
280: //get file contents build array with total search words count
281: //file name and search string
282: $file=array();
283: foreach($pages as $page){
284: if(!empty($rip_html)){
285: $cs=rip_tags(flock_utf8_contents($page));
286: $text[$page]=$cs;
287: }else{
288: $text[$page]=flock_utf8_contents($page);
289: }
290: }
291: $end='';
292: foreach ($text as $name=>$string){
293: //$string=trim(preg_replace('/(\s)\s+/', ' ',$string));
294: if(!empty($clean_string) && !empty($rip_tags)){
295: $string=string_clean($string);
296: }
297: $end = strlen($string);
298: $f=0;
299: foreach ($needles as $needle){
300: //if(strpos($string, $needle) !== FALSE){
301: if($pos=strpos($string, $needle)){
302: //echo substr($string,$pos+strlen($needle),1);
303: if(substr($string,$pos+strlen($needle),1)==' ' || $pos+strlen($needle)==$end ){
304: $results='1';
305: $t[$f]= substr_count($string,$needle);
306: //build array get total of all keywords count
307: $file[]=array('wc'=>array_sum($t),'name'=>$name,'text'=>$string);
308: $f++;
309: }
310: }
311: }
312: }
313: //remove duplicate file name arrays
314: $newArr = array();
315: foreach ($file as $val) {
316: $newArr[$val['name']] = $val;
317: }
318: $array = array_values($newArr);
319: //sort by keyword count. high on top
320: ksort($array);
321: arsort($array);
322: //print_r($res);
323: $rn=1;
324: foreach($array as $key => $subArray){
325: // echo $subArray['wc']. $subArray['name'].$subArray['text'].'<br><br>';
326: echo '<strong>Result#'.$rn.' - Term found '.$subArray['wc'].'(x) in </strong>';
327: //echo 'page found in '.$subArray['name'].'<br>';
328: echo "<a href=".$domain."/".$subArray['name'].">".Title($subArray['name'])."</a>";
329: $desc=$subArray['text'];
330: echo '<p>'.ucwords(snippet($desc,$length)).'</p>';
331: //$item=explode(' ',$subArray['text']);
332: $i=0;
333: foreach ($needles as $needle){
334: // while($i<$cnt){
335: if($pos=strpos($desc, $needle)){
336: //echo '..';
337: echo '<i>'.snippet_pre_needle(substr($desc, 0 ,$pos-1),$prewords). '</i> ';
338: echo "<span style=\"font-weight:bold;color:darkgreen;\">$needle </span>";
339: echo snippet_needle(substr($desc, $pos+strlen($needle),$prewords+strlen($needle)),$prewords);
340: //echo '..';
341: }
342: $i++;
343: //}
344: }
345: echo '<hr>';
346: $rn++;
347: }
348: //var_dump($files);
349: if(empty($results)){
350: $keyword=implode(' ',$needles3);
351: echo "<p style=\"color:darkred;\">No results found for <strong>$keyword</strong>. Modify search term.<br>";
352: echo "Enter a single word search term for general search or multiple words for a wider search.</p><hr>";
353: }
354:
355: // Calculates the end time of the page loading and deductes the time taken to load page
356: $endtime = microtime();
357: $endarray = explode(" ", $endtime);
358: $endtime = $endarray[1] + $endarray[0];
359: $totaltime = $endtime - $starttime;
360: $totaltime = round($totaltime,4);
361: echo "<div id='timetaken'><p>This search took $totaltime seconds to complete.";
362:
363:
364: //memory usage
365: function convert($size)
366: {
367: $unit=array('b','kb','mb','gb','tb','pb');
368: return @round($size/pow(1024,($i=floor(log($size,1024)))),2).' '.$unit[$i];
369: }
370:
371: echo ' Memory usage ' . convert(memory_get_usage(true)) . '</p></div>'; // 123 kb
372:
373: }//end nc
374:
375: echo '</div><br>';
376: echo '<p><a href="www.cmxads.com">Strpos Super Search Script</a></p>';
377: echo '</body>';
378: echo '</html>';
379:
380: exit;
381: ?>
Please help me I am handicapped and support myself
Donate With PayPal
Donate Bitcoin
Please donate and help the handicapped.
1Ev8n7R63yqkKsFTrztufvuVah44MCbzpNThis worked out great I sent you 19 cents.
name:Tosha Date:06.10.23 @ 12:14pm Country:
Tyvm.
name:Shantelle Date:03.22.23 @ 04:08am Country:
I will give it a try. thanks.