Local drive (without webshare) file and folder search trough the webpage
I'm trying to find some solutions for my issue.
I wanted to made an local or external webpage on the webserver which is in fact file server, with the simple php web page with the search bar with the input, field and that page needs to output the search results in the text form or in any other form. I mean the goal is to get searched files or folders and where is their location.
I had couple of ideas, but I cant workaround any of them successfully, I would like to list all of my ideas and I would like that some of the pro users would tell me did they stumble across the similar codes or solutions or even complete projects or eventually the tools or application which have what I need.
The platform is the file server on ubuntu server or debian server or freebsd server
The best and easiest way would be if there is some php coding and connections toward Linux commands like "locate", slocate" or "rlocate", because those commands were connected to the indexed db of files and folders already, the best way would be with the rlocate because its in the fact the real-time, because of the kernel traps.
How could I make a php code, that would connect to the command like rlocate or locate,
I'm not sure how much secure would be to connect php with rlocate or is it even possible at all. I mean its important that system security is not compromised because the web server could have access to such system command as locate.
I've searched trough 7-8 pro php books and I cant find any connection to locate or slocate or rlocate with php. Are there any?
This is the first way, the second way would be to use some loadless "file and folder indexer", which could collect the folders structure to some database, and than the web server would connect to that db. I mean there would be an external web page with the search bar and output would be in textual form or in any shape I dont care, its important that I get advanced file and folder searcher which will produce at least load on the server.
Some people said to me that they know that there are some complete project but they cant remeber the names of those projects and tools.
The third and the worst way would be if I would use SPL file and folder handling within newest versions of PHP 5.3 and above
I mean its the worst solution which would make enormous load , and it would need a lot of time to search folder structure of 500.000 files in the mass number of folders and subfolders.
Here is rough code that I had in mind:
The question is could you post what you know about the fastest and the best way to do this matter.
$search_dir = "/home/incoming";
$search = $_POST['Editbox1'];
$found_files = array();
$it = new FilesystemIterator($search_dir);
foreach ($it as $file)
if(substr_count(($file_name = $file->getFilename()), $search))
$found_files = $file_name;
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
function FindObject(id, doc)
var child, elem;
if(doc.id==id || doc.name==id)
for(var i=0; i<child.length; i++)
for(var i=0; i<frm.length; i++)
for(var j=0; j<elems.length; j++)
if(elem) return elem;
function ShowObject(id, flag)
<body bgcolor="#FFFFFF" text="#000000">
<div id="wb_Image1" style="overflow:hidden;position:absolute;left:0px;top:131px;z-index:0" align="left">
<img src="images/201_1.jpg" id="Image1" alt="" align="top" border="0" style="width:1294px;height:405px;">
<input type="text" id="Editbox1" style="position:absolute;left:384;top:312;width:409px;font-family:Courier New;font-size:16px;z-index:1" name="Editbox1" value="<?php echo isset($_POST['Editbox1']) ? $_POST['Editbox1'] : '' ?>" title="Search 201">
<input type="submit" id="Button1" name="Button1" value="Search" style="position:absolute;left:794;top:312;width:84px;height:27px;background-color:#FFFFE0;font-family:Arial;font-size:13px;z-index:3">
foreach($found_files as $found_file)
echo $found_file.'<br />';
Thanks in advance.