Im merging directories/file names into a database (indexing)
now this is working very nicly. Now I have a viewer that will post all the contents from the database, so all you do is click on a link and it takes you to that item, like a image
now this script is really only to display images only
how does one filter out everything but, .jpg, .gif, .png, .tiff, .bmp
now there are some files with .zip, .doc and other things
now I know about using
if ($string != "." {
but that cannot do somthing like *.doc / or can it?
here is the code im using
<?
require('cfg.php');
// Get Url Strings ----Start----
$stripit = $_REQUEST[location];
$limitonset = $_REQUEST[onset];
$limitoffset = $_REQUEST[offset];
// Get Url Strings ----End----
// Next Prev Setup -----Start-----
if ($limitoffset == "" and $limitonset == "") {
$limitoffset = "24";
$limitonset = "0";
}
//Calc offset onset for the next button
$offset2 = $limitoffset + 24;
$onset2 = $limitoffset - 24;
if ($onset2 < 0) {
$onset2 = "0";
}
if ($offset2 < 0) {
$offset2 = "0";
}
// Next prev Setup -----End-----
echo "From Url: $limitonset/$limitoffset<br>Script: $onset2/$offset2";
//Get Url Stings, strip it, explode it then echo ifor debugging and place into database string
//$blowup = explode("\\", $stripit);
//$URLstr = "$blowup[0]\\$blowup[1]\\$blowup[2]";
//$test3 = addslashes("Alberto Martinez\\2002 Digital photos\\Eastvale Line E 5-1-2002");
//$test2 = "Alberto Martinez\2002 Digital photos\Eastvale Line E 5-1-2002";
// Database Conenction String ------Start------
$connect = mysql_connect("localhost", "root", "") or die ("Couldnt connect");
$db = mysql_select_db("Photos", $connect) or die ("Couldnt open Database");
$sql = "select * from photos WHERE PhotoLocation = '$stripit' Order by Photoid ASC LIMIT $onset2,24";
$sql_result = mysql_query($sql, $connect) or die ("Access Denied!");
$count = mysql_num_rows($sql_result);
// Database Connection String -------End-------
//Start the Echo out from databse records to html output -----Start------
$half = ceil($count*0.5);
$striplocaton = stripslashes($stripit);
echo "<center><br>Location: $striplocaton <br>$test</center><br>";
?>
<table width="640" border=0 align="center" cellpadding="0" cellspacing="6">
<?
//Start loop for more than column out put
$i = 1;
?>
<tr>
<?
// Loop for database connection, lets get the records
while ($row = mysql_fetch_array($sql_result)){
$rs_fld1 = $row["PhotoName"];
$rs_fld2 = $row["PhotoLocation"];
$rs_fld3 = $row["PhotoThumbnail"];
// How many columns on output (Default set to 7)
if ($i == 7) {
$i = 1;
?>
</tr><tr>
<?
}
?>
<td align="center" valign="middle" width="100%">
<?
$filesize = filesize("$script_location$rs_fld2\\$rs_fld1");
if ($file_size >= 1073741824) {
$filesize = number_format(($filesize / 1073741824),2) . " GB";
} elseif ($filesize >= 1048576) {
$filesize = number_format(($filesize / 1048576),2) . " MB";
} elseif ($filesize >= 1024) {
$filesize = number_format(($filesize / 1024),2) . " KB";
} elseif ($file_size >= 0) {
$filesize = $filesize . " bytes";
} else {
$filesize = "0 bytes";
}
// Check for zip files
if ($rs_fld1 == "HomeLand.zip" or $rs_fld1 == "Homeland MDP 1.zip" or $rs_fld1 == "Homeland MDP 2.zip") {
echo "<a href='$rs_fld2\\$rs_fld1'><img src='../common/zipfile.jpg' width='100' height='100'><br><font size='2'>$rs_fld1</font></a>";
echo "<br><font size='2'>".$filesize."</font>";
} else {
echo "<a href='$rs_fld2\\$rs_fld1'><img src='$rs_fld3' width='100' height='100'><br><font size='2'>$rs_fld1</font></a>";
echo "<br><font size='2'>".$filesize."</font>";
}
?>
</td>
<?
// loop
$i++;
}
?>
</tr></table>
<?
//Start the Echo out from databse records to html output -----End------
// Check to see if there is anymore data, if not then remove Next/Prev
if ($rs_fld1 == "") {
echo "No more Data<br><a href='index.php'>Home</a><br>";
} else {
$stripit2 = stripslashes($stripit);
?>
<A HREF="view.php?&location=<? echo $stripit2 ?>&onset=<? echo "$onset2"; ?>&offset=<? echo "$offset2"; ?>">Next</A> <A href='index.php'>Home</A>
<?
}
//End
?>
using code do to the double \
-Thanx