Call us Toll-Free:
1-800-218-1525
Live ChatEmail us

 Sponsors

Searching Extensions by MBK

Code Wizard, 12-30-2006

This recursive script will let you search the server's HD for files with a certain extension.
It outputs the dir/filename and makes it a link, for download.
Also useful if you want to make a page with all your mp3 files in it, for other people to download.
For any questions email mbk@cable.a2000.nl.

<html><head>
<title>Search Extensions By MBK</title>
</head>
<body bgcolor="#cccccc">
<br><br><br>
<?


/*

This recursive script will let you search the server's HD for files with a certain extension.
It outputs the dir/filename and makes it a link, for download.
Also useful if you want to make a page with all your mp3 files in it, for other people to download.
For any questions email mbk@cable.a2000.nl.



*/

if ($extensi) {
echo "<a href='$PHP_SELF'>Search Again</a><br><br>";
echo "Searching extension: $extensi<br>
";
}

// This function checks if the file has the extension you are looking for.
function extens($input, $extensio) {
$bestand = explode(".", "$input");
if (end($bestand) != $bestand[0]) {
$extens = end($bestand);
$extens = strtolower ($extens);
if ($extens == $extensio) { return true; }
else { return false; }
}
else {
return false;
}
}

$count = 0;
$dire = ".."; // Enter the starting directory here.

if (isset($extensi)) {
explore($dire, $extensi);
}
function explore($dir, $extension){
$d = dir("$dir");
while($entry=$d->read()) {
$bestand = explode(".", "$entry");

if (end($bestand) != $bestand[0]) {
$extens = end($bestand);
$extens = strtolower ($extens);
}
elseif ($entry != "." && $entry != "..") {
explore("$dir/$entry", $extension); // recursive
}
if (extens($entry, $extension)) {
echo "<a href="$dir/$entry">";
echo "$dir/$entry </a><br>
";
global $count;
$count++;
}
}
$d->close();
}
echo "<br>Found $count files with the extension $extensi";

if (!isset($extensi)) {
echo "<center><form method='post' action='searchext.php'>
Search for extension: <input type='text' name='extensi' width='4'>
<br><input type='submit' value='Search'></form></center>";
}


?>

</body>
</html>
Enjoyed this post?

Subscribe Now to receive new posts via Email as soon as they come out.

 Comments
Post your comments












Note: No link spamming! If your message contains link/s, it will NOT be published on the site before manually approved by one of our moderators.



About Us  |  Contact us  |  Privacy Policy  |  Terms & Conditions