a little help with php directory function

nahsorhseda

Member
Messages
116
Reaction score
0
Points
16
i have a script which lists all files in the directory
but i want it to list only the image files to be more specific ......list only files ending with jpeg,jpg,png,gif

OR

i want the script to list all other files except the php files ill pay you 50 c -100c if you help me out

below is the script(its a modifeid wapbuddy script)



PHP:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<?
 extract($_REQUEST);
?>
<? include("../css.php"); ?>




<title>my personal pics</title><body>
<?php
include("../wapbuddy_settings.php");
if (!isset($_GET['page'])) $page =$_GET['page'];
$total = 0;

if(!($dp = opendir("./"))) die ("Cannot open ./");
$file_array = array(); 
while ($file = readdir ($dp))
{
if(substr($file,0,1) != '.' and $file != "index.php" and $file != "search.php")
{
$file_array[] = $file;
}
}
$file_count = count ($file_array);
sort ($file_array);
?>
</head>
<body bgcolor="#000000" text="#00FF00" link="#FFFFFF" vlink="#FF0000" alink="#FFFFFF">

<img src='http://c.wen.ru/256908.wbmp?Nahsorhsed' alt='Создай сайт! Create site!'/><br/>
<big>NAHSORHSEDA</big><br/>

<?php include("../menu.php"); ?><br/>

<?

echo "<small>";

echo "<b><u>my school days</u></b><br/>";

if ($file_count > 0)
{
$first_record = $page * $conf["items_per_page"];
$last_record = $first_record + $conf["items_per_page"];

while (list($fileIndexValue, $file_name) = each ($file_array))
{

if (($fileIndexValue >= $first_record) AND ($fileIndexValue < $last_record))
{

echo "<a href=\"$file_name\">$file_name</a> (". round(filesize($file_name)/1024,1) . "kb)<br/>------<br/>";
$total = $total + filesize($file_name);
}
}

if (($file_count > 0) AND ($page != 0))
{
// previous button
$prev_page = $page -1;
echo "<br/><a href=\"".$_SERVER["PHP_SELF"]."?page=$prev_page\">Prev Page</a><br/>";
}


if (($file_count > 0) AND ($last_record < $file_count))
{
// next button
$next_page = $page + 1;
echo "<br/><a href=\"".$_SERVER["PHP_SELF"]."?page=$next_page\">Next Page</a><br/>";
}
echo "<br/>Total Files:<br/>$file_count ";
if ($file_count == 1)
{echo "file";}
else
{echo "files";}

echo " (" . round($total/1024,1) . "kb)";
}
closedir($dp);
echo "</small>";
?>
<br/>
<?
echo '<form action="process.php" method="post">'
          .'search file: <input name="q" title="search:" size="5" maxlength="99999999999"/><br/>'
          .'<input type="submit" value="go"/></form>' ?>


<small>page:<? echo"$page"; ?></small><br/>
<?
echo '<form action="'.$_SERVER["PHP_SELF"].'" method="get">'
          .'Jump to Page: <input name="page" title="Jump to Page:" size="3" maxlength="3"/><br/>'
          .'<input type="submit" value="Jump"/></form>' ?>

<small><a href="http://nahsorhseda.wen9.com/Rock2.html">home</a></small>
</p>
</body>
</html>



thnks in advance
 
Top