View Full Version : Making An Image Gallery Script
sleepingdanny
10-18-2002, 09:11 AM
Is There A Way To Make A Script That If You Enter Inside The Script - Lets Say... http://www.site.com/img/ ... It Will Show You All The Images That This Folder Contains, Even If This Isn't Your Site ??
Just To See What Images They Have In A Chosen Folder..
Grizzly
10-18-2002, 11:31 AM
Thats not really possible. There's no way to determine what files are located in a directory on another server.
roninblade
10-18-2002, 11:26 PM
well, you can use php ftp functions if you have an account on the other server.
sleepingdanny
10-19-2002, 10:19 AM
Oh Ok... :-)
ChefNinja
10-19-2002, 07:58 PM
You could also stop capitalizing every letter of every word in your sentence. Otherwise, I'm adding you to my hitlist.
^BuGs^
10-20-2002, 10:13 AM
function vaildimgTypes($imgtype_test) {
$tempinc = 0;
$imgtpyearray = "jpg,gif,png";
$char = "/,/";
$section = preg_split($char,$imgtpyearray);
while ($section[$tempinc] != "") {
if ($section[$tempinc] == $imgtype_test) {
return "true";
} else {
return "false";
}
$tempinc++;
}
}
?>
<center>click on the picture thumbnail to view the larger photo. The captions are entered manaully and never needs to access a DB so it should go pretty fast.</center>
<?php
echo "<table align='center'>";
echo "<tr>";
if ($handle = opendir(".")) {
$tempinc = 0;
while (false !== ($file_list = readdir($handle))) {
if ($file_list != "." && $file_list != "..") {
if (!is_dir($file_list)) {
$img = vaildimgTypes(substr($file_list,strlen($file_list)-3,3));
//echo "<td>The return: $img_return</td>";
if ($img != "false") {
$total_images = $total_images+1;
if (!($insertbreak % 2)) {
echo "</tr><tr>";
}
/* retrive line of text that has the caption in it.
** look for the image filename.the caption and the file name
** are seperated by '####' so there is a distict difference
** if not found, set $caption_return = "none";
*/
echo "<td cellspacing=\"10\" cellspadding=\"5\" valign='top'>";
createimage_only("image " . $tempinc,$file_list,"1",captiontext($file_list),""); // change me here for sure!
echo "</td>";
$insertbreak = $insertbreak+1;
$tempinc++;
}
}
}
}
closedir($handle);
}
echo "</tr>"; // ended displaying all pics
echo "</table>"; // end table
Some of the code you might have to change, but it's the same princiable. Hope this helps and give me some creid ton your site! :D
iDxMan
10-20-2002, 10:25 AM
.. that is if you are viewing images stored on your site where the script resides on.
-r
sleepingdanny
10-20-2002, 02:20 PM
I Just Like To Write Like That... I Do That In Every Site :-)
sleepingdanny
10-20-2002, 02:26 PM
I Don't Know How To Work With This Script - I'm A PHP Beginner...
Thanks For The Try :-)
Strike
10-20-2002, 03:43 PM
Originally posted by sleepingdanny
I Just Like To Write Like That... I Do That In Every Site :-)
Okay, but just know that it is annoying to many of us.
roninblade
10-20-2002, 10:38 PM
Originally posted by sleepingdanny
I Just Like To Write Like That... I Do That In Every Site :-) yes, its a bit annoying and its a terrible habit, specially if you're going into programming; better practice by typing with lowercase characters.
sleepingdanny
10-21-2002, 11:44 AM
I can write like this, but usually when i enter to a forum i write like "This".
Uranium-235
10-21-2002, 05:19 PM
I made a nice little once a while ago
<?php
//image archive
//by Paul "Uranium-235" Linebarger
$do = explode("&", $HTTP_SERVER_VARS["QUERY_STRING"]);
$do = $do[0];
function head()
{
print("<body bgcolor=\"black\">\n");
}
function fsize($bytes)
{
$fix = 2;
if($bytes < 1024)
$prepend = "B";
if($bytes >= 1024 && $bytes < 1048576)
{
$bytes /= 1024;
$prepend = "KB";
}
if($bytes >= 1048576)
{
$bytes /= 1048576;
$prepend = "MB";
}
$rounded = round($bytes, $fix);
//round() has a bad habit of not showing the last 0 in like 2.3, when I want it 2.30
if(substr_count($rounded, "."))
{
for($i = 0; $i < $fix; $i++)
{
$num = explode(".", $rounded);
$num = $num[1];
if(strlen($num) <= 1)
{
$rounded .= "0";
}
}
}
return $rounded . $prepend;
}
switch($do)
{
default:
?>
<head>
<title>title</title>
</head>
<frameset cols="15%,85%">
<frame src="?list" name="list">
<frame src="?blah" NAME="rightpane">
</frameset>
<?php
break;
case "list":
head();
print("<center>\n");
if(!$dir = @opendir("."))
die("<center><font color=\"white\" face=Arial>Error Opening Directory</font></center>");
while (false !== ($file = readdir($dir)))
{
if(strtolower(substr($file, -4)) == ".jpg")
$image[] = $file;
}
sort($image);
$count = count($image);
for($i = 0; $i < $count; $i++)
print("<a href=\"?viewimage&image=" . urlencode($image[$i]) . "\" target=\"rightpane\">" . $image[$i] . "</a>
<font color=\"white\" size=2>(" . fsize(filesize($image[$i])) . ")</font>
\n");
closedir($dir);
print("</center>\n");
break;
case "viewimage":
head();
if(!is_file($image))
print("<center><font color=\"white\" face=Arial>Picture not found</font></center>\n");
else
{
print("<center>\n");
print("<img src=\"$image\">
\n");
print("<font color=\"white\" face=\"Arial\">$image</font>");
print("</center>\n");
}
break;
case "blah":
head();
print("<center>\n<font color=\"white\" size=3>Select image to the left :)</font>\n</center>\n");
break;
case "showsource":
show_source("index.php");
break;
}
?>
an example can be seen here:
http://www.paintbug.com/chipper
thiers another example I have, but I don't think it would be appropriate for the site :)
sleepingdanny
10-23-2002, 08:58 AM
Thanks, But It Not Exacly What I Wanted...
vBulletin® v3.7.0, Copyright ©2000-2009, Jelsoft Enterprises Ltd.