Location: PHPKode > scripts > Photoshoot > photoshoot/index.php
<?php 

/** 

Photoshoot Version 1.0.0 - PHP5
Copyright (c) 2010 JF Nutbroek <hide@address.com>

Permission to use, copy, modify, and/or distribute this software for any
purpose without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

*/

$email          = '';                            // The photographers email address, to receive portfolio's by email (leave empty to disable)
$tableformat    = '4x4';                         // Display format for amount of thumbnails (columns x rows)
$thumbwidth     = 140;                           // Display size for the thumbnails in px
$referralpage   = 'http://www.mywebmymail.com';  // Page to go to when visitor clicks 'exit' (should automatic detection not work)
$browsing       = true;                          // Allow browsing through the photos
$buttoncolor    = '#99CCFF';                     // Color of the browsing buttons

if (isset($_REQUEST['download'])) {
	$downloadphoto=dirname($_REQUEST['download']) . '/originals/' . basename($_REQUEST['download']);
	if (file_exists($downloadphoto)) {
		download($downloadphoto);
		exit;
	}
}

session_start();

include_once('inc/userdata.php');
include_once('inc/languages.php');

if(!isset($_SESSION['exitphotoshoot'])) {
        $_SESSION['exitphotoshoot']=$referralpage;
	if (isset($_SERVER['HTTP_REFERER'])) {
                $thispage=strtolower('http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']);
                if (substr(strtolower($_SERVER['HTTP_REFERER']),0,strlen($thispage))!=$thispage)
                        $_SESSION['exitphotoshoot']=$_SERVER['HTTP_REFERER'];     
        }
}

if (isset($_REQUEST['exit'])) {
        $url=$_SESSION['exitphotoshoot'];
        session_unset();
	session_destroy();
        header("Location: " . $url); 
}

if (isset($_REQUEST['logout'])) {
        unset($_SESSION['photoshoot_user']);
	unset($_SESSION['photoshoot_passw']);
	unset($_SESSION['menuphotoshoot']);
	unset($_SESSION['cartphotoshoot']);
	unset($_SESSION['albumphotoshoot']);
	unset($_SESSION['imagesphotoshoot']);
}

// Check for valid login
if (isset($_REQUEST['requirelogin'])) {
	if (isset($_REQUEST['new_user']) && isset($_REQUEST['new_password'])) {
		foreach($login as $user => $password) {
			if ($user==$_REQUEST['new_user'] && $password==$_REQUEST['new_password']) {
				$_SESSION['photoshoot_user']=$_REQUEST['new_user'];
				$_SESSION['photoshoot_passw']=$_REQUEST['new_password'];
				unset($_SESSION['menuphotoshoot']);
				unset($_SESSION['albumphotoshoot']);
				unset($_SESSION['imagesphotoshoot']);
			}
		}
		if (!isset($_SESSION['photoshoot_user'])) {
			$_REQUEST['login']=1;
			$_SESSION['albumphotoshoot']=-1;
		}
	} else {
		$_REQUEST['login']=1;
		$_SESSION['albumphotoshoot']=-1;
	}
}

if (isset($_REQUEST['album'])) {
        $_SESSION['albumphotoshoot']=intval($_REQUEST['album']);
	unset($_SESSION['imagesphotoshoot']);
}

if (isset($_REQUEST['checkout'])) {
        $_SESSION['albumphotoshoot']=-1;
}

if (isset($_REQUEST['portfolio'])) {
	if(!isset($_SESSION['cartphotoshoot'])) {$_SESSION['cartphotoshoot']=array();}
	if (file_exists($_REQUEST['portfolio'])) {
		if (!in_array($_REQUEST['portfolio'],$_SESSION['cartphotoshoot']))
			$_SESSION['cartphotoshoot'][]=$_REQUEST['portfolio'];
	}
}

if (isset($_REQUEST['delete']) && isset($_SESSION['cartphotoshoot'])) {
	foreach($_SESSION['cartphotoshoot'] as $key => $portfoliophoto) {
		if ($portfoliophoto==$_REQUEST['delete'])
			$_SESSION['cartphotoshoot'][$key]='';
	}
}

if (isset($_REQUEST['screenwidth'])) {
        $_SESSION['screenwidth'] = intval($_REQUEST['screenwidth']);
	if ($_SESSION['screenwidth']<1024) {$_SESSION['screenwidth']=1024;}
}

// Determine which album to show
if (count($_SESSION['menuphotoshoot'])==0 || isset($_REQUEST['login'])) {
	$album='portfolio/';
} else {
	if (isset($_SESSION['albumphotoshoot'])) {
		if (key_exists($_SESSION['albumphotoshoot'],$_SESSION['menuphotoshoot'])) {
			$albumurl=$_SESSION['menuphotoshoot'][$_SESSION['albumphotoshoot']];
			$album=$albumurl[1];
		}
	} else {
		$album='portfolio/';
	}
}

// Determine phototable columns x rows
if (isset($_REQUEST['checkout'])) {$tableformat='4x50';}
$table=explode('x',$tableformat);
$tablesize=$table[0]*$table[1];

if (isset($_REQUEST['tiltviewer'])) {
print <<<EOF
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>TiltViewer</title>
<script type="text/javascript" src="inc/tiltviewer/swfobject.js"></script>
<style type="text/css">	
html {
height: 100%;
overflow: hidden;
}
#flashcontent {
height: 100%;
}
body {
height: 100%;
margin: 0;
padding: 0;
background-color: #000000;
color:#ffffff;
font-family:sans-serif;
font-size:40;
}
a {	
color:#cccccc;
}
</style>
</head>
<body>
<div id="flashcontent">TiltViewer requires JavaScript and the latest Flash player. <a href="http://www.macromedia.com/go/getflashplayer/">Get Flash here.</a></div>
<script type="text/javascript">
var fo = new SWFObject("inc/tiltviewer/TiltViewer.swf", "viewer", "100%", "100%", "9.0.28", "#000000");				
fo.addVariable("useFlickr", "false");
EOF;
echo "fo.addVariable(\"xmlURL\", \"$album/gallery.xml\");\n";
echo "fo.addVariable(\"columns\", $table[0]);\n";
echo "fo.addVariable(\"rows\", $table[1]);\n";
print <<<EOF
fo.addVariable("useReloadButton", "false");
fo.addVariable("showFlipButton","false");
fo.addParam("allowFullScreen","true");
fo.write("flashcontent");			
</script>	
</body>
</html>
EOF;
exit;
}

// The page
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\"><html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"en\" xml:lang=\"en\">\n";
echo "<head><link rel=\"stylesheet\" type=\"text/css\" href=\"inc/photoshoot.css\" /><title>$lang_01</title>\n";
echo "<meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\" />\n";

// The page body
if(!isset($_SESSION['screenwidth'])) {
	echo "</head><body onload=\"location.href='index.php?screenwidth=' + screen.width;\">\n";
} else {
	echo "</head><body>\n";
}
echo "<form method=\"post\" action=\"index.php?requirelogin=1\" enctype=\"multipart/form-data\">\n";
echo "<table style=\"width : 100%;border : 0px;\" cellspacing=\"10px\" cellpadding=\"0px\"><tr><td style=\"width : 140px;vertical-align : top;\">\n";
topborder();

// Build the menu
if(!isset($_SESSION['menuphotoshoot'])) {
	$_SESSION['menuphotoshoot']=array();$homedir=getcwd() . '/portfolio/';
	if ($dir=@opendir($homedir)) {
		while ($dirname=@readdir($dir)) {
			if (substr($dirname,0,1)!='.' && $dirname!='thumbs' && $dirname!='originals') {
				$view=true;
				if (array_key_exists($dirname,$access)) {
					$view=false;
					foreach($access as $lockeddir => $privileges) {
						if ($lockeddir==$dirname) {
							$users=explode(",",$privileges);
							if (isset($_SESSION['photoshoot_user'])) {
								if (in_array($_SESSION['photoshoot_user'],$users)) {$view=true;}
							}
						}
					}
				}
				if ($view) {
					$_SESSION['menuphotoshoot'][]=array(str_replace('.','',$dirname), 'portfolio/' . $dirname);
					photoalbums($homedir.'/'.$dirname.'/');
				}
			}
		}
	}
}

// Print the menu
echo "<table class=\"contenttable\" style=\"width : 100%;\" cellspacing=\"0\" cellpadding=\"0\">\n";
foreach($_SESSION['menuphotoshoot'] as $key => $url) {
	if (substr($url[0],0,1)!='.') {echo "<tr><td style=\"text-align : left;\">";}
	if ($album!='portfolio/' && $_SESSION['albumphotoshoot']==$key)
		echo "<a href=\"index.php?album=$key\" style=\"text-decoration : underline;\">$url[0]</a>";
	else
		echo "<a href=\"index.php?album=$key\">$url[0]</a>";
	if (key_exists($key+1,$_SESSION['menuphotoshoot'])) {
		$nextmenuitem=$_SESSION['menuphotoshoot'][$key+1];
		if (substr($nextmenuitem[0],0,1)=='.') {echo "<br />";} else {echo "</td></tr><tr><td>&nbsp;</td></tr>\n";}
	} else {
		echo "</td></tr>\n"; 
	}
}
if (isset($_SESSION['cartphotoshoot'])) {
	if (count($_SESSION['cartphotoshoot'])>0)
		echo "<tr><td>&nbsp;</td></tr><tr><td style=\"text-align : left;font-weight : bold;\"><a href=\"index.php?checkout=1\">$lang_02</a></td></tr>\n";
}
if (isset($_SESSION['photoshoot_user'])) {
	echo "<tr><td>&nbsp;</td></tr><tr><td style=\"text-align : left;\"><a href=\"index.php?logout=1\">$lang_03</a></td></tr>\n";
} else {
	if ($login[1]!='password')
		echo "<tr><td>&nbsp;</td></tr><tr><td style=\"text-align : left;\"><a href=\"index.php?login=1\">$lang_04</a></td></tr>\n";
}
echo "<tr><td>&nbsp;</td></tr><tr><td style=\"text-align : left;\"><a href=\"index.php?exit=1\">$lang_05</a></td></tr>\n";
echo "</table>\n";
bottomborder();

// Start of main content
echo "</td><td style=\"vertical-align : top;\">\n";
topborder();

if (!isset($_SESSION['imagesphotoshoot'])) {
	$images=array();$newthumbs=array();
	// Read all image files in selected album
	if ($dir=@opendir($album)) {
		while ($filename=@readdir($dir)) {
			if (substr($dirname,0,1)!='.' && !is_dir($filename)) {
				$extension=strtolower(substr($filename,strrpos($filename,'.')+1,strlen($filename)));
				if ($extension=='jpg' || $extension=='jpeg' || $extension=='png' || $extension=='gif') {
					$images[]=$filename;
					if (!file_exists($album.'/thumbs/'.substr($filename,0,strrpos($filename,'.')).".jpg"))
						$newthumbs[]=$album.'/'.$filename;
				}
			}
		}
	}
	$_SESSION['imagesphotoshoot']=$images;
	// Save new thumbs if required
	if (count($newthumbs)>0) {
		include_once('inc/easyphpthumbnail.class.php');
		$thumb = new easyphpthumbnail;
		$thumb -> Thumblocation = $album . '/thumbs/';
		if (!file_exists($thumb->Thumblocation)) {@mkdir($thumb->Thumblocation);@chmod($thumb->Thumblocation,octdec($thumb->Chmodlevel));}
		$thumb -> Createthumb($newthumbs);
	}
}

// Select the portfolio photos
if (isset($_REQUEST['checkout'])) {
	unset($_SESSION['imagesphotoshoot']);
	foreach($_SESSION['cartphotoshoot'] as $portfoliophoto) {
		if ($portfoliophoto!='')
			$_SESSION['imagesphotoshoot'][]=$portfoliophoto;
	}
}

// The main table
 echo "<table class=\"contenttable\" style=\"width : 100%;\"><tr><td style=\"text-align : center;vertical-align : middle;\">\n";

// Display the thumbs, photo or list
$column=0;$portfolio='';
if (isset($_REQUEST['page'])) {$page=intval($_REQUEST['page']);} else {$page=1;}
if (isset($_REQUEST['photo'])) {$photo=basename($_REQUEST['photo']);} else {$photo='';}
echo "<table style=\"width : 100%;\">\n";
if ($photo=='') {
	// Display thumbnails
	if ((count($_SESSION['imagesphotoshoot'])>0 && count($_SESSION['imagesphotoshoot'])>=($page-1)*$tablesize) && !isset($_REQUEST['login'])) {
		foreach($_SESSION['imagesphotoshoot'] as $key => $image) {
			if ($key>=($tablesize*($page-1)) && $key<($tablesize*$page)) {
				if ($column==0) {echo "<tr>";}
				if (!isset($_REQUEST['checkout'])) {
					if (file_exists($album . '/thumbs/'.substr($image,0,strrpos($image,'.')+1) .'jpg')) {
						echo "<td><a href=\"index.php?page=$page&amp;photo=" . urlencode($image) . "\"><img src=\"" . $album . '/thumbs/'.substr($image,0,strrpos($image,'.')+1) .'jpg'. "\" style=\"border : 0px;\" alt=\"$image\" title=\"$lang_07\" /></a></td>";
					} else {
						$size=@getimagesize($album . "/$image");
						if ($size[0]>$size[1])
							$width=$thumbwidth.'px';
						else
							$width=ceil($size[0]/($size[1]/$thumbwidth)).'px';
						echo "<td><a href=\"index.php?page=$page&amp;photo=" . urlencode($image) . "\"><img src=\"" . $album . "/$image" . "\" style=\"border : 0px;width : $width;\" alt=\"$image\" title=\"$lang_07\" /></a></td>";
					}
				} else {
					if (isset($_REQUEST['submitportfolio'])) {
						if (($key+1)<10) {$filler='0';} else {$filler='';}
						$portfolio=$portfolio . $filler . ($key+1) . '. ' . trim($image,'portfolio/') . "\n";
					} else {
						$thumb=dirname($image) . '/thumbs/' . basename($image);
						if (file_exists($thumb)) {
							echo "<td><img src=\"$thumb\" style=\"border : 0px;\" alt=\"$thumb\" title=\"$lang_02\" /><a href=\"index.php?page=$page&amp;checkout=1&amp;delete=$image\"><img src=\"gfx/delete.gif\" style=\"border : 0px;\" alt=\"$lang_09\" title=\"$lang_08\" /></a></td>";
						} else {
							$size=@getimagesize($image);
							if ($size[0]>$size[1])
								$width=$thumbwidth.'px';
							else
								$width=ceil($size[0]/($size[1]/$thumbwidth)).'px';
							echo "<td><img src=\"$image\" style=\"border : 0px;width : $width;\" alt=\"$image\" title=\"$lang_02\" /><a href=\"index.php?page=$page&amp;checkout=1&amp;delete=$image\"><img src=\"gfx/delete.gif\" style=\"border : 0px;\" alt=\"$lang_09\" title=\"$lang_08\" /></a></td>";
						}	
					}
				}
				$column+=1;
				if ($column==$table[0]) {$column=0;echo "</tr>\n";}
			}
		}
		$lastpageimages=count($_SESSION['imagesphotoshoot'])-($tablesize*($page-1));
		if ($page==ceil(count($_SESSION['imagesphotoshoot'])/$tablesize) && $lastpageimages<$table[0]) {
			echo "</tr></table>\n";		
		} else if ($column<$table[0] && $column>0) {
			echo str_repeat('<td>&nbsp;</td>',$table[0]-$column) . "</tr>\n" . "</table>\n";
		} else {
			echo "</table>\n";
		}
	} else {
		// Show login screen
		if (isset($_REQUEST['login'])) {
			echo "<tr><td>&nbsp;</td></tr>\n";
			echo "<tr><td><input type=\"text\" name=\"new_user\" class=\"input\" onclick=\"if(this.value=='$lang_10')this.value='';\" value=\"$lang_10\" /></td></tr>\n";
			echo "<tr><td><input type=\"password\" name=\"new_password\" class=\"input\" onclick=\"this.value='';\" value=\"$lang_11\" /></td></tr>\n";
			echo "<tr><td>&nbsp;</td></tr>\n";
			echo "<tr><td><input type=\"submit\" name=\"Submit\" class=\"button\" value=\"$lang_04\" onmouseover=\"this.style.cursor='pointer'\" /></td></tr>\n";	
			echo "<tr><td>&nbsp;</td></tr></table>\n";			
			
		} else {
			echo "<tr><td>&nbsp;</td></tr><tr><td style=\"text-align : center;vertical-align : middle;\"><img src=\"gfx/photoshoot.jpg\" style=\"border : 0px;\" alt=\"no images found\" title=\"$lang_12\" /></td></tr><tr><td>&nbsp;</td></tr></table>\n";
		}
	}
} else {
	// Display large photo
	$photopath=$album.'/' . $photo;
	$downloadpath=$album.'/originals/' . $photo;
	$size=getimagesize($photopath);
	if ($size[0]>($_SESSION['screenwidth']-360)) {
		$width='width : ' . ($_SESSION['screenwidth']-360) .'px';
	} else {
		$width="width : $size[0]px";
	}	
	// Browsing
	$index=array_search($photo, $_SESSION['imagesphotoshoot']);
	if ($browsing && key_exists($index + 1, $_SESSION['imagesphotoshoot'])) {
		$nextf="onmouseover=\"this.bgColor='$buttoncolor';this.style.cursor='pointer';\" title=\"browse forward\" onclick=\"location.href=('index.php?page=$page&amp;photo="  .  urlencode($_SESSION['imagesphotoshoot'][$index + 1])  .  "');\"";
                $nextfs="style=\"width : 30px; border : 1px solid $buttoncolor;\"";
	} else {
		$nextf='';
		$nextfs='style="width : 30px; border : 0px;"';
	}
	if ($browsing && key_exists($index - 1, $_SESSION['imagesphotoshoot'])) {
		$nextb="onmouseover=\"this.bgColor='$buttoncolor';this.style.cursor='pointer';\" title=\"browse backward\" onclick=\"location.href=('index.php?page=$page&amp;photo="  .  urlencode($_SESSION['imagesphotoshoot'][$index - 1])  .  "');\"";
		$nextbs="style=\"width : 30px; border : 1px solid $buttoncolor;\"";
	} else {
		$nextb='';
		$nextbs='style="width : 30px; border : 0px;"';
	}
	// End browsing
	echo "<tr><td style=\"vertical-align : top; text-align : center;\">\n";
	echo "<table $nextbs ><tr><td style=\"height : 25px; text-align : center;\" $nextb onmouseout=\"this.bgColor='#FAFAFA';\">&nbsp;</td></tr></table>\n";
	echo "</td><td style=\"text-align : center;width : 100%;\">\n";
	if (strpos($album,'photoshoot')>0) {
		if (!in_array($photopath,$_SESSION['cartphotoshoot']))
			echo "<a href=\"index.php?page=$page\"><img src=\"" . $album . '/' . basename($photo) . "\" style=\"border : 0px; $width;\" alt=\"$photo\" title=\"$lang_13\" /></a><br /><br /><a href=\"index.php?page=$page&amp;photo=$photopath&amp;portfolio=$photopath\">$lang_14</a>\n";
		else
			echo "<a href=\"index.php?page=$page\"><img src=\"" . $album . '/' . basename($photo) . "\" style=\"border : 0px; $width;\" alt=\"$photo\" title=\"$lang_13\" /></a><br /><br /><a href=\"index.php?page=$page&amp;photo=$photopath&amp;delete=$photopath\">$lang_19</a>\n";
	} else {
		if (file_exists($downloadpath)) {
			echo "<a href=\"index.php?page=$page\"><img src=\"" . $album . '/' . basename($photo) . "\" style=\"border : 0px; $width;\" alt=\"$photo\" title=\"$lang_13\" /></a><br /><br /><a href=\"index.php?download=$photopath\">$lang_15</a>\n";
		} else {
			echo "<a href=\"index.php?page=$page\"><img src=\"" . $album . '/' . basename($photo) . "\" style=\"border : 0px; $width;\" alt=\"$photo\" title=\"$lang_13\" /></a>\n";
		}
	}
	echo "</td><td style=\"vertical-align : top; text-align : center;\">\n";
	echo "<table $nextfs ><tr><td style=\"height : 25px; text-align : center;\" $nextf onmouseout=\"this.bgColor='#FAFAFA';\">&nbsp;</td></tr></table>\n";
	echo "</td></tr></table>\n";
}

// Display the amount of pages
if ($tablesize<count($_SESSION['imagesphotoshoot']) && $photo=='' && !isset($_REQUEST['login']) && !isset($_REQUEST['checkout'])) {
	echo "<table style=\"width : 100%;\">\n";
	echo "<tr><td style=\"text-align : center;\">";
	if (isset($_REQUEST['checkout'])) {$checkout='&amp;checkout=1';} else {$checkout='';}
	for ($i=1;$i<=ceil(count($_SESSION['imagesphotoshoot'])/$tablesize);$i++) {
		if ($page==$i) {echo " <a href=\"index.php?page=$i$checkout\" style=\"text-decoration : underline;\">$i</a>";} else {echo " <a href=\"index.php?page=$i$checkout\">$i</a>";}
	}
	echo "</td></tr>\n";
	echo "</table>\n";
}

// Tiltviewer
if ($photo=='' && !isset($_REQUEST['login']) && file_exists($album.'/originals')) {
	echo "<table style=\"width : 100%;\">\n";
	echo "<tr><td style=\"text-align : right;font-size : 9px;\"><a href=\"index.php?tiltviewer=1\">View with TiltViewer</a></td></tr>\n";
	echo "</table>\n";
	// Create tiltviewer xml file
	if (!file_exists($album.'/gallery.xml')) 
		tiltviewer($album,$_SESSION['imagesphotoshoot']);
}

// Perform the 'checkout' and submit the list with photos for the portfolio
if (isset($_REQUEST['checkout'])) {
	echo "<table style=\"width : 100%;\">\n";
	if (isset($_REQUEST['submitportfolio'])) {
		if ($email!='' && isset($_SESSION['photoshoot_user']) && isset($_SESSION['photoshoot_passw'])) {
			if (mailportfolio($email,$email,'Portfolio request from: ' . $_SESSION['photoshoot_user'],$portfolio)) {
				echo "<tr><td style=\"text-align : center;\">$lang_18</td></tr>\n";
				echo "<tr><td>&nbsp;</td></tr>";
			} else {
				echo "<tr><td>$lang_06</td></tr>";
				echo "<tr><td>&nbsp;</td></tr>";
				echo "<tr><td style=\"text-align : center;\"><textarea rows=\"15\" cols=\"80\" class=\"portfolio\" >$portfolio</textarea></td></tr>\n";
				echo "<tr><td>&nbsp;</td></tr>";
				echo "<tr><td style=\"text-align : center;\">$lang_16</td></tr>\n";
			}
		} else {
			echo "<tr><td>$lang_06</td></tr>";
			echo "<tr><td>&nbsp;</td></tr>";
			echo "<tr><td style=\"text-align : center;\"><textarea rows=\"15\" cols=\"80\" class=\"portfolio\" >$portfolio</textarea></td></tr>\n";
			echo "<tr><td>&nbsp;</td></tr>";
			echo "<tr><td style=\"text-align : center;\">$lang_16</td></tr>\n";
		}
	} else {
		echo "<tr><td>&nbsp;</td></tr>";
		if ($email!='' && isset($_SESSION['photoshoot_user']) && isset($_SESSION['photoshoot_passw'])) {
			echo "<script language=\"JavaScript\">\n";
			echo "function submitportfolio() {\n";
			echo "try {\n";
			echo "if (confirm('$lang_20')) {\n";
			echo "location.href=('index.php?checkout=1&submitportfolio=1');\n";
			echo "}\n";
			echo "} catch (err) {}\n";
			echo "}\n";
			echo "</script>\n";
			echo "<tr><td style=\"text-align : center;\"><a href=\"#\" onclick=\"submitportfolio();\">$lang_17</a></td></tr>\n";	
		} else {
			echo "<tr><td style=\"text-align : center;\"><a href=\"index.php?checkout=1&amp;submitportfolio=1\">$lang_17</a></td></tr>\n";
		}
	}
	echo "</table>\n";
}

// Close the main table
echo "</td></tr></table>\n";
bottomborder();

// Footer
echo "<div class=\"footer\"><a href=\"http://www.mywebmymail.com\">&copy; 2010 Photoshoot</a> - hosted by " . trim($_ENV["SERVER_NAME"],'www.') . "</div>\n";

// End of content
echo "</td></tr></table>\n";

// Page end
echo "</form></body></html>\n";

// Functions
function photoalbums($path) {
	global $homedir;
	if ($dir=@opendir($path)) {
		while ($dirname=@readdir($dir)) {
			if (substr($dirname,0,1)!='.' && is_dir($path.$dirname) && $dirname!='thumbs' && $dirname!='originals') {
				$_SESSION['menuphotoshoot'][]=array(str_repeat('.',substr_count($path.$dirname,'/',strlen($homedir))-1).str_replace('.','',$dirname),'portfolio/'.substr($path,strlen($homedir)+1).$dirname);
				photoalbums($path.$dirname.'/');
			}
		}
	}  
}

function topborder() {
        echo "<table style=\"border : 0px;width : 100%;\" cellspacing=\"0\" cellpadding=\"0\"><tr>\n";
        echo "<td style=\"width : 39px;height : 39px;background-image : url('gfx/lt.gif');\">&nbsp;</td>\n";
        echo "<td style=\"background-image : url('gfx/tabletop.gif');\">&nbsp;</td>\n";
        echo "<td style=\"width : 39px;background-image : url('gfx/rt.gif');\">&nbsp;</td></tr>\n";
        echo "<tr><td style=\"background-image : url('gfx/tableleft.gif');\">&nbsp;</td>\n";
        echo "<td style=\"text-align : center;\">\n";           
}

function bottomborder() {
        echo "</td><td style=\"background-image : url('gfx/tableright.gif');\">&nbsp;</td></tr>\n";
        echo "<tr><td style=\"height : 39px;background-image : url('gfx/lb.gif');\">&nbsp;</td>\n";
        echo "<td style=\"background-image : url('gfx/tablebottom.gif');\">&nbsp;</td>\n";
        echo "<td style=\"background-image : url('gfx/rb.gif');\">&nbsp;</td>\n";
        echo "</tr></table>\n";        
}

function download($image) {
	$size=filesize($image);
	header("Pragma: public");
	header("Expires: 0");
	header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); 
	header("Cache-Control: public");
	header("Content-Type: application/octet-stream");
	header("Content-Disposition: attachment; filename=\"" . basename($image) . "\";");
	header("Content-Transfer-Encoding: binary");
	header("Content-Length: ".$size);	
	$fp=@fopen($image,"rb");
	if ($fp) {
		while(!feof($fp)) {
			print(fread($fp,1024*8));
			flush();
			if (connection_status()!=0) {
				@fclose($fp);
				die();
			}
		}
		@fclose($fp);
	}
}

function tiltviewer($album,$images) {
	if ($fp=@fopen($album.'/gallery.xml','wb')) {
		fwrite($fp,"<tiltviewergallery>\n");
		fwrite($fp,"<photos>\n");
		foreach($images as $image) {
			fwrite($fp,"<photo imageurl=\"$album/$image\"></photo>\n");
		}
		fwrite($fp,"</photos>\n");
		fwrite($fp,"</tiltviewergallery>\n");
		fclose($fp);
	}
}

function mailportfolio($mailto,$mailfrom,$subject,$portfolio) {
	$headers="From: $mailfrom\r\n";
	$headers.="Reply-to: $mailfrom\r\n";
	$bound_text=md5(uniqid(time()));
	$headers.="MIME-Version: 1.0\r\n" . "Content-Type: multipart/alternative; boundary=\"$bound_text\"\r\n";
	$message="--$bound_text\r\n"
		."Content-Type: text/plain; charset=\"UTF-8\"\r\n"
		."Content-Transfer-Encoding: 7bit\r\n\r\n"	
		."$emailmessage\r\n"
		." \r\n\r\n"
		."--$bound_text\r\n"	
		."Content-Type: text/html; charset=\"UTF-8\"\r\n"
		."Content-Transfer-Encoding: 7bit\r\n\r\n"	
		."<html><head><title></title></head><body style=\"background-color : #D0DEEE;\">"
		."<table  border=\"0\" width=\"630\" cellpadding=\"0\" cellspacing=\"0\" style=\"max-width:630px; margin: 0 auto;\"><tr><td>"
                ."<table style=\"border : 0px;width : 100%;\" cellspacing=\"0\" cellpadding=\"0\"><tr><td style=\"width : 39px;height : 39px;\">&nbsp;</td><td>&nbsp;</td>"
                ."<td style=\"width : 39px;\">&nbsp;</td></tr><tr><td>&nbsp;</td><td style=\"background-color : #FAFAFA;\">"
		."<table><tr><td style=\"font-family: Verdana, Helvetica, Arial, sans-serif; padding-left : 20px;font-size : 12px; color: #555555;\">" . nl2br($portfolio) . "</td></tr></table>"
                ."</td><td>&nbsp;</td></tr><tr><td style=\"height : 39px;\">&nbsp;</td>"
                ."<td>&nbsp;</td><td>&nbsp;</td></tr></table>"        
                ."</td></tr></table></body></html>\r\n\r\n"							
		."--$bound_text--\r\n\r\n";
	return mail($mailto,$subject,wordwrap($message,70),$headers);
}

?>
Return current item: Photoshoot