Return to gallery page
<script language="php">
// Image Gallery by Tom Parker <palfrey@tevp.net>
// http://tevp.net/projects/
//
// Released under the GPL Version 2 (http://www.gnu.org/copyleft/gpl.html)
require 'substr.php';
if (!isset($show)) {
echo "Need a show code page!";
exit;
}
if (!isset($pictures)) {
echo "Need the pictures directory!";
exit;
}
if (!isset($comments)) {
$comments = 1;
}
$image = $_GET["image"];
$start = $_GET["start"];
$SCRIPT_FILENAME = $HTTP_SERVER_VARS["SCRIPT_FILENAME"];
if (!isset($image)) {
echo "Need an image!";
exit;
}
$image = preg_replace("|\\\'|","'",$image);
$image = $pictures.$image;
$dir = dirname($image);
$o_dir = opendir($dir);
$back = substr($dir,strlen($pictures));
$before = "";
$after = "";
$base_image = basename($image);
function write_comments($des, $index, $file)
{
fwrite($file, $des."\n");
}
if ($comments == 1)
{
$comment = $HTTP_GET_VARS["comment"];
if ($comment!="")
{
if (file_exists($dir."/tn/".$base_image.".txt"))
{
$des = file($dir."/tn/".$base_image.".txt");
}
else
{
$des = array();
}
array_push($des,$comment);
$com = fopen($dir."/tn/".$base_image.".txt",'w');
array_walk($des,'write_comments',$com);
fclose($com);
}
}
if (isset($header) && $header!="")
{
include $header;
}
if ($comments==1 && $comment!="")
{
print "Comment "".$comment."" added<br />";
}
while (($file = readdir($o_dir))!=false)
{
if ($file!='.' && $file!='..')
{
if (!is_dir($file) && ( preg_match("/\.png$/i",$file) || preg_match("/\.jpg$/i",$file) || preg_match("/\.flv$/i",$file) ) && $file != $base_image)
{
if (($before == "" && strnatcasecmp($base_image,$file)>0) || (strnatcasecmp($before,$file)<0 && strnatcasecmp($base_image,$file)>0))
$before = $file;
// else
// print $file." - ".strcmp($before,$file)." - ".strcmp($base_image,$file)."\n";
if (($after == "" && strnatcasecmp($base_image,$file)<0)|| (strnatcasecmp($after,$file)>0 && strnatcasecmp($base_image,$file)<0))
$after = $file;
}
}
}
closedir($o_dir);
$trans = array(" "=>"%20","&"=>"%26","'"=>"%27");
if (isset($start))
$s = "&start=".$start;
else
$s="";
$d_name = strtr(dirname(substr($image,strlen($pictures))),$trans);
$d_name = preg_replace("|\\\\|","",$d_name);
#print $d_name;
$back = preg_replace("|\\\\|","",strtr($back,$trans));
if ($before != "")
{
$before = strtr($before,$trans);
print "<a href=\"".preg_replace("/(.*)\/(.*)/","$2",$SCRIPT_FILENAME)."?image=".$d_name."/".$before."\"><<</a> ";
}
print "<a href=\"".$show."?sub_dir=".$back.$s."\">Back to gallery</a>";
if ($after != "")
{
$after = strtr($after,$trans);
print " <a href=\"".preg_replace("/(.*)\/(.*)/","$2",$SCRIPT_FILENAME)."?image=".$d_name."/".$after."\">>></a>";
}
print "<br />\n";
//print dirname($image)."/descriptions.txt";
if (file_exists($dir."/descriptions.txt")) {
$des = file($dir."/descriptions.txt");
$base = basename($image);
for ($i=0;$i<sizeof($des);$i++) {
//print "a:".$des".substr($des[$i],0,strlen($base));
if (strcmp(substr($des[$i],0,strlen($base)),$base)==0) {
$disp = substr($des[$i],strlen($base)+1);
$disp = trim($disp);
if (strlen($disp)>0)
{
print "<b>".$disp."</b><br />";
}
break;
}
}
//print $des[0];
}
if (substr_compare($image,".flv",-4)==0)
{
$preview = dirname($image)."/tn/tn_".substr(basename($image),0,-3)."jpg";
if (strcmp(basename($image),"1364_mvi.flv")==0)
{
$height = 640;
$width = 480;
}
else
{
$height = 480;
$width = 640;
}
print <<<ENDFLV
<script type="text/javascript" src="/images/ufo.js"></script>
<p id="player1"><a href="http://www.macromedia.com/go/getflashplayer">Get the Flash Player</a> to see this player.</p>
<script type="text/javascript">
var FO = { movie:"/images/flvplayer.swf",width:"$width",height:"$height",majorversion:"7",build:"0",bgcolor:"#FFFFFF",allowfullscreen:"true",
flashvars:"file=$image&image=$preview" };
UFO.create( FO, "player1");
</script>
ENDFLV;
}
else
{
print "<img src=\"".strtr($image,$trans)."\" /><br />";
}
if ($comments == 1)
{
if (file_exists($dir."/tn/".$base_image.".txt"))
{
print "<b><u>Captions:</u></b><br />";
$des = file($dir."/tn/".$base_image.".txt");
for ($i=0;$i<sizeof($des);$i++) {
$des[$i] = trim(stripslashes($des[$i]));
if ($des[$i]!="")
print "<b>".$des[$i]."</b><br />";
}
}
print "You can add your own captions to this photograph (be warned that you <b>can't</b> delete them afterwards!):<br />\n";
print "<form method=\"GET\" action=\"".preg_replace("/(.*)\/(.*)/","$2",$SCRIPT_FILENAME)."\">\n";
print "<input type=\"hidden\" name=\"image\" value=\"".substr($image,strlen($pictures))."\">\n";
if (isset($start))
print "<input type=\"hidden\" name=\"start\" value=\"".$start."\">\n";
print "<input type=\"text\" name=\"comment\" value=\"\">\n";
print "<input type=\"submit\" value=\"Add comment\">\n";
print "</form>";
}
</script>
Return to gallery page

