Re: [PHP] search.php
Where or what recursive function would I need to get all sub-directories? If not, can someone suggest another script? Much appreciated, John Taylor-Johnston - Université de Sherbrooke http://compcanlit.ca/ Mike Brum wrote: John, since you're looking to modify this script and not build your own or search for another, here's some tips on how one might go about doing this. 1) set $which_one to the directory you want to search. 2) create a recursive funtion (many on php.net) to get all subdirectories under it and build an array with their paths as the elements. 3) now, take that arrary and add a foreach before the line $directory = opendir($which_one); replacing $which_one with your foreach array element. This is the *easy* way that I can think to do this - just do it for each subdir in the array. It probably is far from the most elegant way, but offers the least amount of real editing/manipulation. I welcome any/all flaming for my suggestion :) -M -Original Message- From: John Taylor-Johnston [mailto:[EMAIL PROTECTED] Sent: Sunday, February 01, 2004 12:09 AM To: [EMAIL PROTECTED] Cc: John Taylor-Johnston Subject: [PHP] search.php I found this script. I would like to modify it so it searches in not just the current directory, but also any other subdirectories. There are maybe better scripts out there, but I like this one for its simplicity. Can anyone lend a hand please? John ?php $counter=1; $not_found=0; $which_one=.; // use a . to search in this directory, or type in the folder name $link = www.glquebec.org; // this is your base url //$search_for=Search for something here!!!; // comment this whole line out if you are using a form to search $search_for=nice word; $directory = opendir($which_one); while($file = readdir( $directory)){$file_ar[] = $file;} foreach( $file_ar as $file ) { $type= strrchr($file,'.'); $name=$which_one; $name.=/; $name.=$file; $file_name=fopen($name,r); $bleh =; #if ($type==.php || $type==.txt || $type==.html) #if ($type==.htm || $type==.txt || $type==.html) if ($type==.htm || $type==.html) { while ((!feof($file_name))) { $bleh .= fgets($file_name , 2); } $bleh = strtolower($bleh); $bleh = stripslashes($bleh); $bleh = str_replace(br, , $bleh); if (stristr($bleh,$search_for)) { echo $counter .) a href=$link.$name..$link.$name./abr; echo \...; $bingo = strstr($bleh, $search_for); $bingo = explode ( , $bingo); echo b$bingo[0]/b; for ($x=1;$x15;$x++) echo $bingo[$x] ; echo ...\brBr; $counter++; $not_found=2; } else{} } fclose($file_name); } if ($not_found==0) { echo Sorry... $search_for was not found!!!Br a href=javascript:history.go(-1)Search Again/a; } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] search.php
On Monday 02 February 2004 13:07, John Taylor-Johnston wrote: Can anyone give me a heads up on how to recurse for sub-directories please? What function can I use? I'm still kind of new at this, The user comments in the online manual for the chapter Directory functions should prove useful. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* Time and tide wait for no man. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] search.php
Hi John, This is the third or fourth thread on this topic that you have started. As jason has pointed out you need to start reading. While people in this list will be happy to help you overcome specific problems no one has the time to code for you. John Taylor-Johnston wrote: Can anyone give me a heads up on how to recurse for sub-directories please? What function can I use? I'm still kind of new at this, John 1) set $which_one to the directory you want to search. 2) create a recursive funtion (many on php.net) to get all subdirectories under it and build an array with their paths as the elements. 3) now, take that arrary and add a foreach before the line $directory = opendir($which_one); replacing $which_one with your foreach array element. -- Raditha Dissanayake. http://www.radinks.com/sftp/ | http://www.raditha.com/megaupload Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader Graphical User Inteface. Just 150 KB | with progress bar. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] search.php
Second actually. Thanks for the answer Jason, John Raditha Dissanayake wrote: Hi John, This is the third or fourth thread on this topic that you have started. As jason has pointed out you need to start reading. While people in this list will be happy to help you overcome specific problems no one has the time to code for you. John Taylor-Johnston wrote: Can anyone give me a heads up on how to recurse for sub-directories please? What function can I use? I'm still kind of new at this, John 1) set $which_one to the directory you want to search. 2) create a recursive funtion (many on php.net) to get all subdirectories under it and build an array with their paths as the elements. 3) now, take that arrary and add a foreach before the line $directory = opendir($which_one); replacing $which_one with your foreach array element. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] search.php
John, since you're looking to modify this script and not build your own or search for another, here's some tips on how one might go about doing this. 1) set $which_one to the directory you want to search. 2) create a recursive funtion (many on php.net) to get all subdirectories under it and build an array with their paths as the elements. 3) now, take that arrary and add a foreach before the line $directory = opendir($which_one); replacing $which_one with your foreach array element. This is the *easy* way that I can think to do this - just do it for each subdir in the array. It probably is far from the most elegant way, but offers the least amount of real editing/manipulation. I welcome any/all flaming for my suggestion :) -M -Original Message- From: John Taylor-Johnston [mailto:[EMAIL PROTECTED] Sent: Sunday, February 01, 2004 12:09 AM To: [EMAIL PROTECTED] Cc: John Taylor-Johnston Subject: [PHP] search.php I found this script. I would like to modify it so it searches in not just the current directory, but also any other subdirectories. There are maybe better scripts out there, but I like this one for its simplicity. Can anyone lend a hand please? John ?php $counter=1; $not_found=0; $which_one=.; // use a . to search in this directory, or type in the folder name $link = www.glquebec.org; // this is your base url //$search_for=Search for something here!!!; // comment this whole line out if you are using a form to search $search_for=nice word; $directory = opendir($which_one); while($file = readdir( $directory)){$file_ar[] = $file;} foreach( $file_ar as $file ) { $type= strrchr($file,'.'); $name=$which_one; $name.=/; $name.=$file; $file_name=fopen($name,r); $bleh =; #if ($type==.php || $type==.txt || $type==.html) #if ($type==.htm || $type==.txt || $type==.html) if ($type==.htm || $type==.html) { while ((!feof($file_name))) { $bleh .= fgets($file_name , 2); } $bleh = strtolower($bleh); $bleh = stripslashes($bleh); $bleh = str_replace(br, , $bleh); if (stristr($bleh,$search_for)) { echo $counter .) a href=$link.$name..$link.$name./abr; echo \...; $bingo = strstr($bleh, $search_for); $bingo = explode ( , $bingo); echo b$bingo[0]/b; for ($x=1;$x15;$x++) echo $bingo[$x] ; echo ...\brBr; $counter++; $not_found=2; } else{} } fclose($file_name); } if ($not_found==0) { echo Sorry... $search_for was not found!!!Br a href=javascript:history.go(-1)Search Again/a; } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] search.php
Mike, :) Could you show me how, or an example. This is why I went searching for one. I haven't the slighest where to start, but am willing to learn. I have toyed with $which_one, but it does not recurse sub-directories. Thanks, John John, since you're looking to modify this script and not build your own or search for another, here's some tips on how one might go about doing this. 1) set $which_one to the directory you want to search. 2) create a recursive funtion (many on php.net) to get all subdirectories under it and build an array with their paths as the elements. 3) now, take that arrary and add a foreach before the line $directory = opendir($which_one); replacing $which_one with your foreach array element. This is the *easy* way that I can think to do this - just do it for each subdir in the array. It probably is far from the most elegant way, but offers the least amount of real editing/manipulation. I welcome any/all flaming for my suggestion :) -M -Original Message- From: John Taylor-Johnston [mailto:[EMAIL PROTECTED] Sent: Sunday, February 01, 2004 12:09 AM To: [EMAIL PROTECTED] Cc: John Taylor-Johnston Subject: [PHP] search.php I found this script. I would like to modify it so it searches in not just the current directory, but also any other subdirectories. There are maybe better scripts out there, but I like this one for its simplicity. Can anyone lend a hand please? John ?php $counter=1; $not_found=0; $which_one=.; // use a . to search in this directory, or type in the folder name $link = www.glquebec.org; // this is your base url //$search_for=Search for something here!!!; // comment this whole line out if you are using a form to search $search_for=nice word; $directory = opendir($which_one); while($file = readdir( $directory)){$file_ar[] = $file;} foreach( $file_ar as $file ) { $type= strrchr($file,'.'); $name=$which_one; $name.=/; $name.=$file; $file_name=fopen($name,r); $bleh =; #if ($type==.php || $type==.txt || $type==.html) #if ($type==.htm || $type==.txt || $type==.html) if ($type==.htm || $type==.html) { while ((!feof($file_name))) { $bleh .= fgets($file_name , 2); } $bleh = strtolower($bleh); $bleh = stripslashes($bleh); $bleh = str_replace(br, , $bleh); if (stristr($bleh,$search_for)) { echo $counter .) a href=$link.$name..$link.$name./abr; echo \...; $bingo = strstr($bleh, $search_for); $bingo = explode ( , $bingo); echo b$bingo[0]/b; for ($x=1;$x15;$x++) echo $bingo[$x] ; echo ...\brBr; $counter++; $not_found=2; } else{} } fclose($file_name); } if ($not_found==0) { echo Sorry... $search_for was not found!!!Br a href=javascript:history.go(-1)Search Again/a; } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php