PDA

View Full Version : Webdesgn help!



Kalub
July 14th, 2009, 05:36 PM
Looking for a free gallery webapp that I can put on a buddies webpage. It would be nice if he could upload pictures, and the page would just update as he did it because he knows jack about html/php. It would also be cool if it had the lightbox effect, but I digress.


Thanks

klange
July 14th, 2009, 05:42 PM
I can offer you this script: http://hawaii.phpwnage.com/pictures/3400/

e: I can put Lightbox on this, too...

MetKiller Joe
July 14th, 2009, 05:47 PM
Roughly how many pictures is he planning to put on this site? If you have 5-10, I wouldn't bother getting gallery software unless they are high-res.

Is it a professional portfolio type site? I ask this because most lightweight galleries that I know of need some coding in there. I recommend LightBox because it requires only one phrase per picture.

legionaire45
July 15th, 2009, 09:35 AM
Lightbox 2 (http://www.huddletogether.com/projects/lightbox2/)
Other useful shit. (http://www.1stwebdesigner.com/tutorials/53-jquery-tutorials-resources-tips-and-tricks-ultimate-collection/)

www.delicious.com has a billion things on this topic and more.

Kalub
July 15th, 2009, 02:16 PM
Basically, there needs to be a form somewhere that I should be able to code (I'm not completely clueless) that will just upload to a directory somewhere. And on the main page there will be a script that just goes through the directory and loads the images in a nice format like Bacon's (Love that script) then when people click it tada lightbox prettiness and stuff.

:neckbeard:

klange
July 15th, 2009, 03:43 PM
Basically, there needs to be a form somewhere that I should be able to code (I'm not completely clueless) that will just upload to a directory somewhere. And on the main page there will be a script that just goes through the directory and loads the images in a nice format like Bacon's (Love that script) then when people click it tada lightbox prettiness and stuff.

:neckbeard:
You may want to just set your friend up with FTP and bookmark the directory w/ automatic login on Explorer. Would save time and not require any additional authentication.

I'll add Lightbox to Dv though...

Kalub
July 15th, 2009, 09:30 PM
I can try to do that, it would probably be the easiest. Anyways if you could add lightbox, and then pm the script or whatever that would be cool. :downs:

Kalub
July 16th, 2009, 10:56 PM
Bump, still waitin' for said script.

klange
July 16th, 2009, 11:06 PM
Bump, still waitin' for said script.
Tomorrow. Had to set up my new PC today, then "had" to do more Synapse-alpha testing. It's only a few extra lines of code to add for Lightbox, no worries.

Kalub
July 17th, 2009, 09:52 AM
Alright, it's cool no rush :)

klange
July 17th, 2009, 04:46 PM
<?php
/*
phpDV (PHP directory listing script)

Copyright 2008 Kevin Lange <klange@oasis-games.com>

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

*/
/* ********* README **********
Welcome to phpDV - the PHP Site Indexer. So you're probably wondering
how to set this thing up, 'eh? Well, it's fairly simple. Slap this file
in a directory that PHP can read from on your server. Then, create
a new index.php with the following:

<?php include "/path/to/phpdv.php"; ?>

and place it in all folders you want to index. Now, gather up some 32x32
icons for the following:
- Archives [archive.png]
- Audio files [audio.png]
- Directories [dir.png]
- Web files [html.png]
- Vector graphics [svg.png]
- Text files [txt.png]
- Video files [vid.png]
- Unknown files [unknown.png]
- "Up one" [up.png]
And place them in another directory PHP can access, then set the
$_THUMBPATH variable below to this directory (with trailing slash).

You may want to append or prepend some text to a directory listing.
To do this, create a file called `.index_prepend` for text you want
to place before the listing and `.index_append` for text you want
to place after the listing in the directories you want to display
the extra text for. Use HTML formatting in .index_ files.

*/

// XXX: Constants
// This needs to be an absolute path to the icon directory
$_THUMBPATH = "/path/to/other/thumbnails/";
$_ICONSIZE = 120; // Icon size

$TOTAL_WIDTH = 164;
$TOTAL_HEIGHT = $_ICONSIZE + 40;

error_reporting(E_NONE);
function byte_convert($bytes) {
$symbol = array('B', 'KiB', 'MiB', 'GiB', 'TiB',
'PiB', 'EiB', 'ZiB', 'YiB');

$exp = 0;
$converted_value = 0;
if( $bytes > 0 ) {
$exp = floor( log($bytes)/log(1024) );
$converted_value = ( $bytes/pow(1024,floor($exp)) );
}

return sprintf( '%.2f '.$symbol[$exp], $converted_value );
}

if (!isset($_GET['th'])) {
// XXX: Standard execution (display index)
if (file_exists("favicon.ico")) {
$tempmeta = getimagesize("favicon.ico");
$FAVMETA = "<link rel=\"icon\" type=\"" . $tempmeta['mime'] .
"\" href=\"favicon.ico\">";
} else {
$FAVMETA = "";
}
$dir_true = str_replace("index.php", "", $_SERVER['PHP_SELF']);
$dir_tree = explode("/",$dir_true);
array_pop($dir_tree);
$DIR_NAME = "";
$dir_path = "";
foreach ($dir_tree as $dir) {
$dir_path = $dir_path . $dir . "/";
$DIR_NAME = $DIR_NAME . "<a class=\"parent\" href=\"$dir_path\">$dir/</a>";
}
$DIR_INFO = $_SERVER['HTTP_HOST'] . "<br>powered by phpDV";
if (file_exists(".index_background")) {
$background = "background-image: url(\".index_background\");";
} else {
$background = "background-color: #dbeed6;";
}
print <<< END
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Index of $dir_path</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
<style type="text/css">
body {
font-family: Tahoma, sans-serif;
font-size: 12px;
$background
background-color: #dbeed6;
background-position: 50% 0;
}
h1 {
font-size: 18px;
font-weight: bold;
}
.file_block {
float: left;
padding: 4px;
margin: 4px;
width: {$TOTAL_WIDTH}px;
height: {$TOTAL_HEIGHT}px;
font-size: 16px;
vertical-align: middle;
text-align: center;
border: 1px solid #707070;
background-color: #FFFFFF;
-moz-border-radius: 8px;
-webkit-border-radius: 8px;
}
span.file_block:hover {
background-color: #888888;
color: #FFFFFF;
#font-weight: bold;
text-decoration: none;
}
.file_thumb {
margin: 2px;
}
.file_stat {
font-size: 12px;
}
.spacer {
width: 100%;
float: left;
}
.header {
padding: 4px;
display: block;
border: 1px solid #707070;
background-color: #FFFFFF;
-moz-border-radius: 8px;
-webkit-border-radius: 8px;
}
.footer {
padding: 4px;
margin-bottom: 4px;
display: block;
border: 1px solid #707070;
background-color: #FFFFFF;
-moz-border-radius: 8px;
-webkit-border-radius: 8px;
}
.dir_info {
float: right;
margin-right: 4px;
display: block;
color: #777777;
font-size: 12px;
text-align: right;
}
.fake_break {
font-size: 0px;
line-height: 0px;
}

.parent:link {color: #000000; text-decoration: none;}
.parent:visited {color: #000000; text-decoration: none;}
a.parent:hover {color: #FFF; text-decoration: none; background-color: #000;}

.subdirectory:link {color: #000000; text-decoration: none;}
.subdirectory:visited {color: #000000; text-decoration: none;}
a.subdirectory:hover {color: #888888; text-decoration: underline; }
a.subdirectory:link img, a.subdirectory:visited img { border-style: none }

.file_cont:link {color: #000000; text-decoration: none;}
.file_cont:visited {color: #000000; text-decoration: none;}
a.file_cont:hover {color: #000000; text-decoration: none; }
a.file_cont:link img, a.file_cont:visited img { border-style: none }



</style>
$FAVMETA
</head>
<body>
<div class="dir_info">$DIR_INFO</div>
<h1>Index of $DIR_NAME</h1>

END;

// Prepend
if (file_exists(".index_prepend")) {
print "<div class=\"spacer\"><div class=\"header\">\n";
print file_get_contents(".index_prepend");
print "</div></div>\n";
}
$myDirectory = opendir("./" . $gal);
while($entryName = readdir($myDirectory)) {
$dirArray[] = $entryName;
}
closedir($myDirectory);
sort($dirArray);
$indexCount = count($dirArray);
$directories[] = "..";
for($index=0; $index < $indexCount; $index++) {
if (is_dir("$dirArray[$index]") && (substr($dirArray[$index],0,1) != ".")) {
$value = $dirArray[$index];
$directories[] = $value;
unset($dirArray[$index]);
$dirArray = array_values($dirArray);
$index = $index - 1;
$indexCount = $indexCount - 1;
} elseif (substr($dirArray[$index], 0, 1) == ".") {
unset($dirArray[$index]);
$dirArray = array_values($dirArray);
$index = $index - 1;
$indexCount = $indexCount - 1;
}
}
$indexCount2 = count($directories);
for($index=0; $index < $indexCount2; $index++) {
$dir = $directories[$index];
if ($dir == "..") {
if ($dir_true == "/")
continue;
print "<a class=\"file_cont\" href=\"..\"><span class=\"file_block\">" .
"<span class=\"fake_break\"><br></span>" .
"<img src=\"?th=GOUP\" alt=\"Go Up\"><br>..<br>" .
"<span class=\"file_stat\">(Go up)</span></span></a>\n";
} else {
$pret = ucwords(str_replace("_", " ", $dir));
print "<a class=\"file_cont\" href=\"$dir\"><span class=\"file_block\">" .
"<span class=\"fake_break\"><br></span>" .
"<img src=\"?th=DIRECTORY\" alt=\"*\"><br>$pret<br>" .
"<span class=\"file_stat\">Directory - $dir</span></span></a>\n";
}
}
$actual_count = 0;
for($index=0; $index < $indexCount; $index++) {
$file = $dirArray[$index];
// Hide us.
if (strtolower($file) == "index.php")
continue;
$file_sub = substr($file,0,18);
if (strlen($file) > 18) {
$file_sub = $file_sub . "...";
}
$file_stat = "";
$size = filesize($file);
if ($size) {
$file_stat = $file_stat . byte_convert($size);
}
if (exif_read_data($file)) {
$exif = exif_read_data($file);
$file_stat = $file_stat . " " . date("M j g:i a",strtotime($exif['DateTime'])-21600);
} else {
$file_stat = $file_stat . " " . date("M j g:i a",filemtime($file)-21600); //mime_content_type($file);
}
if (file_exists(".thumbs/$file")) {
$thumb = ".thumbs/$file";
} else if (file_exists(".thumbs/$file.jpg")) {
$thumb = ".thumbs/$file.jpg";
} else {
$thumb = "?th=$file";
$exif_thumb = exif_thumbnail($file);
if (strlen($exif_thumb) > 0) {
if (isset($_GET['embed_new_exif']) && $_GET['embed_new_exif'] == "1") {
$thumb = "data:image/jpg;base64," . base64_encode(exif_thumbnail($file));
} else {
$thumb = ".thumbs/$file";
}
if (!is_dir(".thumbs")) {
mkdir(".thumbs");
}
file_put_contents(".thumbs/$file",$exif_thumb);
}
}
print "<a class=\"file_cont\" href=\"$file\"><span class=\"file_block\">" .
"<span class=\"fake_break\"><br></span>" .
"<img src=\"$thumb\" class=\"file_thumb\" alt=\"!\"><br>$file_sub<br>" .
"<span class=\"file_stat\">$file_stat</span></span></a>\n";
$actual_count++;
}
if ($actual_count == 0) {
print <<<END
<br /><br /><br /><br />
<div width="100%">
<p align="center" style="font-size: 16px; clear: left;">This directory is empty.</p>
</div>
END;
}
// Append
if (file_exists(".index_append")) {
print "<div class=\"spacer\"><div class=\"footer\">";
print file_get_contents(".index_append");
print "</div></div>";
}
print <<<END
</body>
</html>
END;
} else {
// XXX: Thumbnail request
$file = $_GET['th'];
$tmp = explode(".",$file);
$type = strtolower(array_pop($tmp));
header("Content-type: image/png");
header("Cache-control: public");
error_reporting(E_ERROR);
if ($file == "DIRECTORY") {
$im = imagecreatefrompng($_THUMBPATH . "dir.png");
} else if ($file == "GOUP") {
$im = imagecreatefrompng($_THUMBPATH . "up.png");
} else if ((file(".thumbs/" . $file)) and
(filemtime(".thumbs/" . $file) > filemtime($file))) {
$im = imagecreatefrompng(".thumbs/" . $file);
} else {
switch ($type) {
case "png":
$src = imagecreatefrompng($file);
break;
case "jpeg":
case "jpg":
$src = imagecreatefromjpeg($file);
break;
case "gif":
$src = imagecreatefromgif($file);
break;
case "txt":
$im = imagecreatefrompng($_THUMBPATH . "txt.png");
break;
case "svg":
$im = imagecreatefrompng($_THUMBPATH . "svg.png");
break;
case "avi":
case "mpg":
case "mpeg":
case "wmv":
case "ogg":
$im = imagecreatefrompng($_THUMBPATH . "vid.png");
break;
case "wav":
case "mp3":
case "wma":
$im = imagecreatefrompng($_THUMBPATH . "audio.png");
break;
case "tar":
case "gz":
case "bz2":
case "rar":
case "zip":
case "7z":
case "deb":
$im = imagecreatefrompng($_THUMBPATH . "archive.png");
break;
case "html":
case "htm":
case "php":
$im = imagecreatefrompng($_THUMBPATH . "html.png");
break;
default:
$im = imagecreatefrompng($_THUMBPATH . "unknown.png");
}
}
if (!isset($src)) {
imagesavealpha($im, true);
imagepng($im);
imagedestroy($im);
} else {
$im = imagecreatetruecolor($_ICONSIZE,$_ICONSIZE);
imagesavealpha($im, true);
$trans = imagecolorallocatealpha($im, 0, 0, 0, 127);
imagefill($im, 0, 0, $trans);
$wid = imagesx($src);
$hei = imagesy($src);
$_SIZE = $_ICONSIZE;
$ratio = $wid / $hei;
$ratio = $wid / $hei;
if ($ratio > 1) {
$newsize = $_SIZE / $ratio;
$offset = ($_SIZE - $newsize) / 2;
imagecopyresampled($im, $src, 0, $offset, 0, 0, $_SIZE,
$_SIZE / $ratio, $wid, $hei);
} else {
$newsize = $_SIZE * $ratio;
$offset = ($_SIZE - $newsize) / 2;
imagecopyresampled($im, $src, $offset, 0, 0, 0, $_SIZE * $ratio,
$_SIZE, $wid, $hei);
}
imagesavealpha($im, true);
if (!is_dir(".thumbs")) {
mkdir(".thumbs");
}
imagepng($im, ".thumbs/" . $file);
imagepng($im);
imagedestroy($im);
}
}


This is without Lightbox, I just wanted to make sure you got it at all. Adding lightbox should be simple...

Kalub
July 18th, 2009, 11:41 AM
Well... I copied and pasted that code into "gallery.php" and then I created an index.php and threw in the include code. I then created a gallery folder in my root directory (/var/html/www/gallery) I then uploaded the index.php and gallery.php. I tossed in a few pictures and it finds some and displays them, but it also indexes the gallery.php, how do I stop that.

klange
July 18th, 2009, 11:50 AM
It needs to be in index.php, the include line is for other directories. e: the other option is to find this:

// Hide us.
if (strtolower($file) == "index.php")
continue;

And add:


if (strotlower($file) == "gallery.php")
continue;

... after it.

Kalub
July 18th, 2009, 03:34 PM
Ah, I misread the directions then. Thanks Bacon :thumbsup: