Jump to content

Index listing(i think..)


DeathStar

Recommended Posts

You should be able to get the same result from that, you just have to go into the next directory and check for image files or php files. If there is a .jpg or .gif extension than use this image if not and there is .php use this image.

 

The problem arises when you have a .php in an image directory, which one to display??? =)

Link to comment
https://forums.phpfreaks.com/topic/43567-index-listingi-think/#findComment-211683
Share on other sites

Ok i got that part but failing miserably!

 

Here is my script:

<?php
$dict = $_SERVER['DOCUMENT_ROOT'];
$d = dir($dict);
echo "Path to this dictinary: " . $d->path . "<br />";
while (false !== ($entry = $d->read())) {
$ext = strrchr($entry, '');
if ($ext == ""){
echo "<font color=red>$ext$entry</font>";}
elseif ($ext == "php"){
echo "<font color=green>$ext$entry</font>";}
elseif ($ext == "html"){
echo "<font color=blue>$ext$entry</font>";}
elseif ($ext == "txt"){
echo "<font color=yellow>$ext$entry</font>";}
else{
   echo "$ext$entry<br />";}
}
$d->close();
?>

 

Any help?

 

There is more than one result so it must be on seprate line!

 

Link to comment
https://forums.phpfreaks.com/topic/43567-index-listingi-think/#findComment-212361
Share on other sites

ok thanks.

But the result im getting is:

Path to this dictinary: /home/deathsta/public_html
..
...
.PNGeditor.PNG
.phpbuton1.php.phpglobal_func.php.phpmenu.phpds1.phpstaff.php.shtml404.shtml
proxys.phpinex.php.phphead.phpe107ds.phpviemember.php.phplogin.phpformcgi-binds2profilesiteb.phpbuton.php.exeDeathStarviewer.exe
.htaccess.htaccess

 

and not on seperate liness

Link to comment
https://forums.phpfreaks.com/topic/43567-index-listingi-think/#findComment-212601
Share on other sites

and remove $ext..

Now i get it right but for link's i dont ?!?

 

<?php
$dict = $_SERVER['DOCUMENT_ROOT'];
$d = dir($dict);
echo "Path to this dictinary: " . $d->path . "<br />";
while (false !== ($entry = $d->read())) {
$ext = strrchr($entry, ".");

if ($ext == ""){

echo "
<style>
ahref1. { a:link {color: red; }; }
ahref2. { a:link {color: green; }; }
ahref3. { a:link {color: blue; }; }
ahref4. { a:link {color: yellow; }; }
ahref5. { a:link {color: black; }; }
</style> ";

echo "<br><a href='$entry' class='ahref1'>$entry</a>";}
elseif ($ext == ".php"){
echo "<br><a href='$entry' class='ahref2'>$entry</a>";}
elseif ($ext == ".html"){
echo "<br><a href='$entry' class='ahref3'>$entry</a>";}
elseif ($ext == ".txt"){
echo "<br><a href='$entry' class='ahref4'>$entry</a>";}
else{
   echo "<br><a href='$entry' class='ahref5'>$entry</a>";}
}

$d->close();
?>

 

Realy cannot understand this  ???

Link to comment
https://forums.phpfreaks.com/topic/43567-index-listingi-think/#findComment-212686
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.