BaseName = substr($this->FileName, 0, strrpos($this->FileName, ".")); $this->Caption = $this->BaseName . ".caption"; $this->Thumbnail = $this->BaseName . ".thumb.jpg"; } function Photo($name, $caption="", $thumbnail="") { $this->Name = $name; $this->PathName = dirname($name); $this->FileName = basename($name); $this->caption = $caption; $this->thumbnail = $thumbnail; $this->FileDate = 0; if(($caption == "") && ($thumbnail == "")) $this->MakeNames(); } } function ShowAdminPanel($photo) { global $Config; if($Config["Action"] == "ShowChangeCaption") { ?>
"> Change the caption, then press the button.
"> "> "> "> ">

"> Delete this photo? Are you sure?
"> "> "> "> ">     
"> Move this photo to the "" album -- Are you sure?
"> "> "> "> "> ">     
"> "> "> "> "> ">
"> "> "> "> "> ">   Move  to:     
"> "> "> "> "> ">
"> "> "> "> "> "> "> \n"; echo ""; echo "\n"; echo "\n"; echo "\n"; echo "
Options:  
\n"; if(strtoupper(substr($Config["ShowAlbumList"],0,1) == "Y")) { echo "Show Albums:    \n"; } echo ""; echo "Show Pictures:   \n"; echo "
 "; echo "Show Link URLs:   \n"; echo "
 "; echo "Sort Photos By:   \n"; echo "
\n"; # end internal table echo "\n"; echo ""; echo "
\n"; } function DoCookieStuff() { global $Config, $ShowAlbums, $ShowPics, $ShowLinks, $LastVisit, $LV, $SortOrder, $HTTP_COOKIE_VARS, $HTTP_POST_VARS; $ShowAlbums = $HTTP_COOKIE_VARS["ShowAlbums"]; $ShowPics = $HTTP_COOKIE_VARS["ShowPics"]; $ShowLinks = $HTTP_COOKIE_VARS["ShowLinks"]; $SortOrder = $HTTP_COOKIE_VARS["SortOrder"]; $LastVisit = $HTTP_COOKIE_VARS["LastVisit"]; $NewShowAlbums = $HTTP_POST_VARS["NewShowAlbums"]; $NewShowPics = $HTTP_POST_VARS["NewShowPics"]; $NewShowLinks = $HTTP_POST_VARS["NewShowLinks"]; $NewSortOrder = $HTTP_POST_VARS["NewSortOrder"]; $MoveTarget = $HTTP_POST_VARS["MoveTarget"]; if(isset($NewShowAlbums)) $ShowAlbums = $NewShowAlbums; if(isset($NewShowPics)) $ShowPics = $NewShowPics; if(isset($NewShowLinks)) $ShowLinks = $NewShowLinks; if(isset($NewSortOrder)) $SortOrder = $NewSortOrder; // Anything that needs to persist across calls to this script // has to be in here... and this function has to be called // *BEFORE* any HTML is sent... $cookiedays = time()+60*60*24*90; // 90 days if(!isset($LV)) { if(isset($LastVisit)) $LV = $LastVisit; else $LV = 0; } if(!isset($LastVisit) || $LastVisit < time() - 7200) // if last visit time was more than two hours ago, { $LastVisit = time(); setcookie("LastVisit", time(), $cookiedays, "", $Config["Domain"]); } if($ShowAlbums <= "") $ShowAlbums = "pic"; setcookie("ShowAlbums", $ShowAlbums, $cookiedays, "", $Config["Domain"]); if($ShowPics <= "") $ShowPics = "all"; setcookie("ShowPics", $ShowPics, $cookiedays, "", $Config["Domain"]); if($ShowLinks <= "") $ShowLinks = "No"; setcookie("ShowLinks", $ShowLinks, $cookiedays, "", $Config["Domain"]); if($SortOrder <= "") $SortOrder = "D"; setcookie("SortOrder", $SortOrder, $cookiedays, "", $Config["Domain"]); $Config["ShowAlbums"] = $ShowAlbums; $Config["ShowPics"] = $ShowPics; $Config["ShowLinks"] = $ShowLinks; $Config["SortOrder"] = $SortOrder; } function GetConfig() { global $REMOTE_USER; global $Config; // we're creating this and loading it to make the script cleaner... include("config.php"); // reads the config variables... $REMOTE_USER = $_SERVER['REMOTE_USER']; // These are from config.php $Config["AdminOwner"] = $AdminOwner; $Config["AlbumBGColor"] = $AlbumBGColor; $Config["AlbumBGImage"] = $AlbumBGImage; $Config["AlbumDir"] = $albumdir; $Config["AlbumURL"] = $albumurl; $Config["BackgroundColor"] = $backgroundcolor; $Config["ByLines"] = $ShowByLines; $Config["CaptionFontColor"] = $CaptionFontColor; $Config["CaptionFontEndStyle"] = $CaptionFontEndStyle; $Config["CaptionFontStartStyle"] = $CaptionFontStartStyle; $Config["Domain"] = $Domain; $Config["FooterFile"] = $FooterFile; $Config["GenHeaders"] = $GenHeaders; $Config["HeaderFile"] = $HeaderFile; $Config["IndexButton"] = $indexbutton; $Config["NavBGColor"] = $NavBGColor; $Config["NavFontColor"] = $NavFontColor; $Config["NextButton"] = $nextbutton; $Config["NumCols"] = $numcols; $Config["NumRows"] = $numrows; $Config["NumThumbs"] = $numthumbs; $Config["PhotoHeight"] = $PhotoHeight; $Config["PrevButton"] = $prevbutton; $Config["PublicAlbums"] = split(":", $PublicAlbums); $Config["SanitizeInput"] = $SanitizeInput; $Config["SortOrder"] = $SortOrder; $Config["ScriptLocation"] = $scriptlocation; $Config["ShowAlbumList"] = $ShowAlbumList; $Config["ShowAnyway"] = 0; $Config["ShowLinks"] = $ShowLinks; $Config["ThumbBGColor"] = $ThumbBGColor; $Config["ThumbBGImage"] = $ThumbBGImage; $Config["ThumbFontColor"] = $ThumbFontColor; $Config["ThumbHeight"] = $ThumbHeight; $Config["ThumbsPerRow"] = $thumbsperrow; $Config["UserName"] = $REMOTE_USER; $Config["UsePHPScaling"] = $UsePHPScaling; if(strstr($_SERVER['REQUEST_URI'], "StartPic=")) $Config["ShowAnyway"] = 1; // if the URL specified a picture, show it even // if it would otherwise be filtered out. if($Config["UserName"] <= "") $Config["UserName"] = "!@%^%$$_login_info_not_available_%^^!#$@"; // These are from the last page viewed global $HTTP_POST_VARS; global $Album, $StartPic, $StartIndex, $ShowIndex, $NC, $NR, $Action, $JumpTo, $LV; global $ShowAlbums, $ShowLinks, $ShowPics, $SortOrder, $NewShowAlbums, $NewShowPics, $NewShowLinks, $NewSortOrder; // cookie variables that user can change global $MoveTarget; $Album = $HTTP_POST_VARS["Album"]; $StartPic = $HTTP_POST_VARS["StartPic"]; $StartIndex = $HTTP_POST_VARS["StartIndex"]; $ShowIndex = $HTTP_POST_VARS["ShowIndex"]; $NC = $HTTP_POST_VARS["NC"]; $NR = $HTTP_POST_VARS["NR"]; $Action = $HTTP_POST_VARS["Action"]; $JumpTo = $HTTP_POST_VARS["JumpTo"]; $LV = $HTTP_POST_VARS["LV"]; $ShowAlbums = $HTTP_COOKIE_VARS["ShowAlbums"]; $ShowLinks = $HTTP_COOKIE_VARS["ShowLinks"]; $ShowPics = $HTTP_COOKIE_VARS["ShowPics"]; $SortOrder = $HTTP_COOKIE_VARS["SortOrder"]; $NewShowAlbums = $HTTP_POST_VARS["NewShowAlbums"]; $NewShowPics = $HTTP_POST_VARS["NewShowPics"]; $NewShowLinks = $HTTP_POST_VARS["NewShowLinks"]; $NewSortOrder = $HTTP_POST_VARS["NewSortOrder"]; $MoveTarget = $HTTP_POST_VARS["MoveTarget"]; if(isset($NewShowAlbums)) $ShowAlbums = $NewShowAlbums; if(isset($NewShowPics)) $ShowPics = $NewShowPics; if(isset($NewShowLinks)) $ShowLinks = $NewShowLinks; if(isset($NewSortOrder)) $SortOrder = $NewSortOrder; DoCookieStuff(); if(!isset($Album) || $Album <= "") $Album = $DefaultAlbum; $Config["LastVisit"] = $LV; $Config["Action"] = $Action; $Config["JumpTo"] = $JumpTo; $Config["Album"] = stripslashes(urldecode($Album)); if(!isset($StartPic)) { $StartPic = ""; $StartIndex = 0; } $Config["StartPic"] = stripslashes(urldecode($StartPic)); $Config["StartIndex"] = urldecode($StartIndex); $Config["ShowIndex"] = urldecode($ShowIndex); $Config["MoveTarget"] = urldecode($MoveTarget); if($NC > 0) $Config["NumCols"] = $NC; if($NR > 0) $Config["NumRows"] = $NR; $dirpath = $Config["AlbumDir"]; if($dirpath > "") $dirpath = $dirpath . "/"; $dirpath = $dirpath . $Config["Album"] . "/"; $Config["DirPath"] = $dirpath; // now get any per-album overrides of these if(file_exists($dirpath . "config.php")) { include($dirpath . "config.php"); // override only those which are not blank in the per-album config... if($albumdir > "") $Config["AlbumDir"] = $albumdir; if($scriptlocation > "") $Config["ScriptLocation"] = $scriptlocation; if($numthumbs > "") $Config["NumThumbs"] = $numthumbs; if($numcols > "") $Config["NumCols"] = $numcols; if($numrows > "") $Config["NumRows"] = $numrows; if($prevbutton > "") $Config["PrevButton"] = $prevbutton; if($nextbutton > "") $Config["NextButton"] = $nextbutton; if($indexbutton > "") $Config["IndexButton"] = $indexbutton; if($thumbsperrow > "") $Config["ThumbsPerRow"] = $thumbsperrow; if($backgroundcolor > "") $Config["BackgroundColor"] = $backgroundcolor; if($albumurl > "") $Config["AlbumURL"] = $albumurl; if($ThumbFontColor > "") $Config["ThumbFontColor"] = $ThumbFontColor; if($AlbumBGColor > "") $Config["AlbumBGColor"] = $AlbumBGColor; if($ThumbBGColor > "") $Config["ThumbBGColor"] = $ThumbBGColor; if($AlbumBGImage > "") $Config["AlbumBGImage"] = $AlbumBGImage; if($ThumbBGImage > "") $Config["ThumbBGImage"] = $ThumbBGImage; if($CaptionFontColor > "") $Config["CaptionFontColor"] = $CaptionFontColor; if($CaptionFontStartStyle > "") $Config["CaptionFontStartStyle"] = $CaptionFontStartStyle; if($CaptionFontEndStyle > "") $Config["CaptionFontEndStyle"] = $CaptionFontEndStyle; if($GenHeaders > "") $Config["GenHeaders"] = $GenHeaders; if($HeaderFile > "") $Config["HeaderFile"] = $HeaderFile; if($FooterFile > "") $Config["FooterFile"] = $FooterFile; if($ShowAlbumList > "") $Config["ShowAlbumList"] = $ShowAlbumList; if($PhotoHeight > "") $Config["PhotoHeight"] = $PhotoHeight; if($ThumbHeight > "") $Config["ThumbHeight"] = $ThumbHeight; if($ShowLinks > "") $Config["ShowLinks"] = $ShowLinks; } if($Config["PhotoHeight"] == 0) $Config["PhotoHeight"] = 400; if($Config["ThumbHeight"] == 0) $Config["ThumbHeight"] = 100; if($Config["ThumbsPerRow"] == 0) $Config["ThumbsPerRow"] = 5; } function ComparePhotoTimes($first, $second) { if ($first->FileDate < $second->FileDate) return -1; else if ($first->FileDate == $second->FileDate) return 0; return 1; } # same as sort by date, but we want them in reverse order (newest first). function ComparePhotoTimesReverse($first, $second) { if ($first->FileDate < $second->FileDate) return 1; else if ($first->FileDate == $second->FileDate) return 0; return -1; } function ComparePhotoNames($first, $second) { if ($first->Name < $second->Name) return -1; else if ($first->Name == $second->Name) return 0; return 1; } function GetAlbum() { global $Config; $index = 0; // $album will be an array, this indexes the array. $ahandle = opendir($Config["DirPath"]); if($ahandle) { while($file = chop(readdir($ahandle))) { if(strstr($file, ".jpg") == ".jpg" && strstr($file, ".thumb.jpg") == "") { $useit = 1; if($Config["ShowPics"] != "all") { // check if it's new since the last visit $testfile = $Config["DirPath"] . $file; $stats = stat($testfile); if($stats && ($stats[9] < $Config["LastVisit"] || $stats[10] < $Config["LastVisit"])) $useit = 0; } if($Config["ShowAnyway"] && $file == $Config["StartPic"]) $useit = 1; if($useit) { $album[$index] = new Photo($file); if($album[$index]->FileName == $Config["StartPic"] && $Config["StartPic"] != "") $Config["StartIndex"] = $index; $statpath = $Config["DirPath"] . $file; $stats = stat($statpath); if($stats) $album[$index]->FileDate = $stats[9]; $index++; } } } closedir($ahandle); if(count($album)) { if($Config["SortOrder"] == "D") usort($album, "ComparePhotoTimes"); else if($Config["SortOrder"] == "R") usort($album, "ComparePhotoTimesReverse"); else usort($album, "ComparePhotoNames"); if($Config["StartPic"] == "") // first call to album? Set start at first pic. { $Config["StartPic"] = $album[$index]->FileName; $Config["StartIndex"] = 0; } else { // have to find where the image is in the current sort order for ($i = 0; $i < count($album); $i++ ) { if($album[$i]->FileName == $Config["StartPic"]) $Config["StartIndex"] = $i; } } } } return $album; } function GetOwnership() { global $Config; $Ownership = array(); $path = $Config["DirPath"] . "/ownership.txt"; if(file_exists($path)) { $fh = fopen($path, "r"); while(!feof($fh)) { $line = chop(fgets($fh, 2048)); $parts = split(":", $line); $Ownership[$parts[0]] = $parts[1]; } } return $Ownership; } function get_array_keys ($arr, $term="") { $t = array(); while (list($k,$v) = each($arr)) { if ($term && $v != $term) { continue; } $t[] = $k; } return $t; } function WriteOwnership($Ownership) { global $Config; $path = $Config["DirPath"] . "/ownership.txt"; $fh = fopen($path, "w"); $keys = get_array_keys($Ownership); for ($index=0; $index < count($keys); $index++) { $str = $keys[$index] . ":" . $Ownership[$keys[$index]] . "\n"; if($Ownership[$keys[$index]] > "") fputs($fh, $str); } fclose($fh); } function RemoveOwnership($file) { $Ownership = GetOwnership(); $Ownership[$file] = ""; WriteOwnership($Ownership); } function GetAlbumList($showalbums) { global $Config; $index = 0; // $AlbumList will be an array, this indexes the array. $ahandle = opendir($Config["AlbumDir"]); if($ahandle) { while($file = chop(readdir($ahandle))) { $test = $Config["AlbumDir"] . "/" . $file; if(is_dir($test) && $file != "." && $file != "..") { if($showalbums != "all") { // see if there are actually any photos in the directory... $num_found = 0; $checkhandle = opendir($test); if($checkhandle) { while($checkfile = chop(readdir($checkhandle))) { if(strstr($checkfile, ".jpg") == ".jpg" && strstr($checkfile, ".thumb.jpg") == "") { if($Config["ShowPics"] != "all") { // check if it's new since the last visit $testfile = $test . "/" . $checkfile; $stats = stat($testfile); if($stats[9] >= $Config["LastVisit"] || $stats[10] >= $Config["LastVisit"]) $num_found++; } else $num_found++; } } closedir($checkhandle); } // if found any files, OR this is the current user's album, show it. if($num_found > 0 || $Config["UserName"] == $file) { $AlbumList[$index] = $file; $index++; } } else { $AlbumList[$index] = $file; $index++; } } } closedir($ahandle); } if(count($AlbumList)) sort($AlbumList); return $AlbumList; } function ShowAlbumList() { global $Config; $AlbumList = GetAlbumList($Config["ShowAlbums"]); echo "
\n"; echo "\"" . $Config["Album"] . "\" Album
"; echo "Choose album: \n"; echo "\n"; echo "\n"; echo "\n"; echo "  \n"; echo "
\n"; } function ShowAddPhoto() { global $Config; if($Config["Action"] == "ShowAddPhoto") { ?>
" enctype="multipart/form-data"> "> "> "> "> "> Add photo to album ""
Photo to Add

 
Caption  
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "  \n"; echo "\n"; } } function DumpAlbum($album) { for ($index=0; $index < count($album); $index++) { echo "Photo:

\n"; } } function ShowPictures($album,$Ownership) { global $Config, $HTTP_HOST, $PHP_SELF; $ByLines = 0; if(in_array($Config["Album"], $Config["PublicAlbums"]) && (strtoupper(substr($Config["ByLines"],0,1) == "Y"))) $ByLines = 1; for($row = 0; $row < $Config["NumRows"]; $row++) { $picdex = $Config["StartIndex"] + ($Config["NumCols"] * $row); if($row > 0) { # don't open first row -- main routine already opens it. echo "\n"; } for($col = 0; $col < $Config["NumCols"]; $col++) { if($picdex < count($album)) { print "\n"; print "

\n"; $picurl = $Config["DirPath"] . $album[$picdex]->FileName; print "
\n"; if($Config["CaptionFontStartStyle"] > "") echo $Config["CaptionFontStartStyle"]; if(file_exists($Config["DirPath"] . $album[$picdex]->Caption)) readfile($Config["DirPath"] . $album[$picdex]->Caption); if($Config["CaptionFontEndStyle"] > "") echo $Config["CaptionFontEndStyle"]; if($ByLines) { echo "

Posted by " . $Ownership[$album[$picdex]->FileName] . "\n"; } if(strtoupper(substr($Config["ShowLinks"],0,1) == "Y")) { echo "

URL for this album page:
\n"; $url = "http://" . $HTTP_HOST . $PHP_SELF . "?Album=" . $Config["Album"] . "&StartPic=" . $Config["StartPic"]; $url = ereg_replace(" ", "%20", $url); echo "$url

\n"; } if(($Config["Album"] == $Config["UserName"]) || ($Ownership[$album[$picdex]->FileName] == $Config["UserName"]) || ($Config["AdminOwner"] == $Config["UserName"])) ShowAdminPanel($album[$picdex]); print "

\n"; print "\n"; } $picdex++; } if(($Config["NumRows"] > 1) && ($row == 0)) ShowThumbnails($album, "NEXT"); if($row < $Config["NumRows"] - 1) { # don't close last row, main script will close it. print "\n"; } } } function DisplayAlbum($album, $Ownership) { global $Config; echo " "") echo " bgcolor='" . $Config["AlbumBGColor"] . "'"; if($Config["AlbumBGImage"] > "") echo " background='" . $Config["AlbumBGImage"] . "'"; echo ">"; ShowThumbnails($album, "PRIOR"); ShowPictures($album, $Ownership); if($Config["NumRows"] == 1) // otherwise ShowPictures does this. ShowThumbnails($album, "NEXT"); $firstpic = $Config["StartIndex"] - ($Config["NumCols"] * $Config["NumRows"]); if($firstpic < 0) $firstpic = 0; $lastpic = $Config["StartIndex"] + ($Config["NumCols"] * $Config["NumRows"]); if($lastpic >= count($album)) $lastpic = count($album) - 1; echo""; echo "
"; ShowButtons($album, $firstpic, $lastpic); echo "
\n"; } function DisplayIndex($album) { global $Config; ?> 0) $Config["StartIndex"] = ($Config["JumpTo"] - 1) * $thumbsperpage; $totalpages = ceil(count($album) / $thumbsperpage); $indexpage = ceil($Config["StartIndex"] / $thumbsperpage) + 1; echo "

\n"; echo "\n"; echo "\n"; echo "
Index Page $indexpage of $totalpages      
\n"; echo ""; echo ""; echo ""; echo ""; echo ""; echo "Name) ."\">"; echo "Jump to page \n"; echo "
\n"; echo "
\n"; echo "\n"; # now just show the thumbnails. $maxpics = count($album); $picsrow = 0; $index = $Config["StartIndex"]; for($row = 0; $row < $Config["ThumbsPerRow"]; $row++) { echo "\n"; for($col = 0; $col < $Config["ThumbsPerRow"]; $col++) { echo "\n"; } echo "\n"; } $firstpic = $Config["StartIndex"] - $thumbsperpage + 1; if($firstpic < 0) $firstpic = 0; $lastpic = $Config["StartIndex"] + $thumbsperpage - 1; if($lastpic >= count($album)) $lastpic = count($album) - 1; echo""; echo "
\n"; if($index >= $maxpics) { echo " "; } else { echo "
\n"; echo ""; echo ""; echo ""; echo ""; echo "Name) ."\">"; echo "Thumbnail . "\">
\n"; $index++; } echo "
"; ShowButtons($album, $firstpic, $lastpic); echo "
\n"; } function ShowThumbnails($album, $whichway) { global $Config; $which = strtoupper(substr($whichway, 0, 1)); if($which == "P") $thumbstart = $Config["StartIndex"] - $Config["NumThumbs"]; else $thumbstart = $Config["StartIndex"] + $Config["NumRows"] * $Config["NumCols"] ; echo " "") echo " bgcolor=" . $Config["ThumbBGColor"]; if($Config["ThumbBGImage"] > "") echo " background=\"" . $Config["ThumbBGImage"] . "\""; echo ">\n"; echo "
"") echo " color=" . $Config["ThumbFontColor"]; if($which == "P") echo ">Previous Pages

\n"; else echo ">Upcoming Pages

\n"; # now loop through the picture array, inserting the required number of # thumbnails, and linking them to a new album page. for($picdex=0; $picdex < $Config["NumThumbs"]; $picdex++) { $target = $thumbstart + $picdex; if($target >= 0 && (($which == "P" && $target <= $Config["StartIndex"]) || ($which == "N" && $target < count($album)))) { echo "

"; echo ""; echo ""; echo ""; echo ""; echo "Name) ."\">"; echo "Thumbnail; echo "\">
\n"; } } echo "\n"; } function ShowButtons($album, $firstpic, $lastpic) { global $Config; echo"\n"; echo"\n"; if(count($album) == 0) { echo "\n"; } else { // Previous echo "\n"; // Index echo ""; // Next echo "\n"; } echo "
"; echo "There are no "; if($Config["ShowPics"] == "new") echo "new "; echo "photos
in this album
"; if ($Config["StartIndex"] == 0) { echo " "; } else { echo "
"; echo ""; echo ""; echo ""; echo ""; echo ""; echo "FileName) ."\">"; echo "
\n"; echo "Previous Page"; } echo "
"; echo "
"; echo ""; echo ""; echo ""; echo ""; echo "FileName) ."\">"; echo ""; echo "
\n"; echo "Index
"; if($Config["StartIndex"] >= count($album) - ($Config["NumRows"] * $Config["NumCols"])) { echo " "; } else if($Config["ShowIndex"] == "Yes" && $lastpic >= count($album) - 1) { echo " "; } else { echo "
"; echo ""; echo ""; echo ""; echo ""; echo ""; echo "FileName) ."\">"; echo "
\n"; echo "Next Page"; } echo "
"; } function HTMLHeader() { global $Config; if(strtolower($Config["GenHeaders"]) == "yes") { $backgroundcolor = $Config["AlbumBGColor"]; echo "\n"; echo " "") echo " BGCOLOR='$backgroundcolor'\n"; echo ">\n"; } if(file_exists($Config["DirPath"] . $Config["HeaderFile"])) readfile($Config["DirPath"] . $Config["HeaderFile"]); } function HTMLFooter() { global $Config; if(file_exists($Config["DirPath"] . $Config["FooterFile"])) readfile($Config["DirPath"] . $Config["FooterFile"]); if(strtolower($Config["GenHeaders"]) == "yes") { echo "\n"; echo "\n"; } } function ShowAlbum() { global $Config; HTMLHeader(); if(strtoupper(substr($Config["ShowAlbumList"],0,1) == "Y")) ShowAlbumList(); if($Config["ErrorMessage"] > "") echo "

" . $Config["ErrorMessage"] . "

\n"; if(($Config["Album"] == $Config["UserName"]) || (in_array($Config["Album"], $Config["PublicAlbums"]))) if(strtolower($Config["UserName"]) != "guest") ShowAddPhoto(); $album = GetAlbum(); if(strtoupper(substr($Config["ShowIndex"],0,1) == "Y")) DisplayIndex($album); else { $Ownership = GetOwnership(); DisplayAlbum($album, $Ownership); } ShowOptionsPanel(); HTMLFooter(); } function SanitizeInput($userinput) { global $Config; $userinput = urldecode($userinput); $val = $userinput; if($Config["SanitizeInput"] == "Yes") { $allowed = array('b' => array(), 'i' => array(), 'center' => array(), 'hr' => array('width' => array('minlen' => 1, 'maxlen' => 4), 'size' => array('minval' => 0, 'maxval' => 10)), 'a' => array('href' => array('minlen' => 3, 'maxlen' => 80), 'title' => array('valueless' => 'n')), 'p' => array('align' => 1, 'dummy' => array('valueless' => 'y')), 'font' => array('size' => array('minval' => 4, 'maxval' => 20), 'color' => array('minlen' => 3, 'maxlen' => 30)), 'br' => array(), 'table' => array('width' => array('minlen' => 1, 'maxlen' => 4), 'align' => 1, 'valign' => 1, 'border' => 1, 'bgcolor' => array()), 'tr' => array('align' => 1, 'valign' => 1, 'bgcolor' => array()), 'td' => array('align' => 1, 'valign' => 1), 'bgcolor' => array()); if (get_magic_quotes_gpc()) $userinput = stripslashes($userinput); $val = kses($userinput, $allowed); } return $val; } function ChangeCaption() { global $Config, $HTTP_POST_VARS; $Photo = $HTTP_POST_VARS["Photo"]; $NewCaption = $HTTP_POST_VARS["NewCaption"]; $Photo = urldecode($Photo); $album = GetAlbum(); for($count=0;$count < count($album); $count++) { if($album[$count]->Name == $Photo) { $fh = fopen($Config["DirPath"] . $album[$count]->Caption, "w"); if($fh) { fwrite($fh, SanitizeInput($NewCaption)); fclose($fh); } break; } } } function DeletePhoto() { global $Config, $Photo, $HTTP_POST_VARS; $Photo = $HTTP_POST_VARS["Photo"]; $Photo = urldecode($Photo); $album = GetAlbum(); for($count=0;$count < count($album); $count++) { if($album[$count]->Name == $Photo) { $filepath = $Config["DirPath"] . $album[$count]->FileName; $cappath = $Config["DirPath"] . $album[$count]->Caption; $thumbpath = $Config["DirPath"] . $album[$count]->Thumbnail; unlink($filepath); unlink($cappath); unlink($thumbpath); RemoveOwnership($Photo); break; } } } function MovePhoto() { global $Config, $Photo, $HTTP_POST_VARS; $Photo = $HTTP_POST_VARS["Photo"]; $Photo = urldecode($Photo); $album = GetAlbum(); for($count=0;$count < count($album); $count++) { if($album[$count]->Name == $Photo) { $oldfilepath = $Config["DirPath"] . $album[$count]->FileName; $oldcappath = $Config["DirPath"] . $album[$count]->Caption; $oldthumbpath = $Config["DirPath"] . $album[$count]->Thumbnail; $newfilepath = $Config["MoveTarget"] . "/" . $album[$count]->Name; $newcappath = $Config["MoveTarget"] . "/" . $album[$count]->Caption; $newthumbpath = $Config["MoveTarget"] . "/" . $album[$count]->Thumbnail; if(copy($oldthumbpath, $newthumbpath)) if(copy($oldcappath, $newcappath)) if(copy($oldfilepath, $newfilepath)) { unlink($oldfilepath); unlink($oldcappath); unlink($oldthumbpath); // read existing ownership info, then remove it $heldpath = $Config["DirPath"]; $oldownership = GetOwnership(); RemoveOwnership($Photo); // then swap directory path and write it to ownership file $Config["DirPath"] = $Config["MoveTarget"]; $ownership = GetOwnership(); $Ownership[$Photo] = $oldownership[$Photo]; WriteOwnership($ownership); $Config["DirPath"] = $heldpath; } break; } } } function UploadPhoto() { global $Config, $Photo, $FileName, $HTTP_POST_VARS, $HTTP_POST_FILES, $_FILES; $Photo = $HTTP_POST_VARS["Photo"]; $FileName = $HTTP_POST_VARS["FileName"]; $FileName = strtolower(urldecode($_FILES['FileName']['name'])); if(strstr($FileName, ".jpg") != ".jpg") { $Config["ErrorMessage"] = "Sorry, only jpeg files are allowed."; return; } $FileName = ereg_replace("\#", "num", $FileName); $FileName = ereg_replace("\?", "qes", $FileName); $FileName = ereg_replace("\&", "amp", $FileName); $ThumbName = ereg_replace(".jpg", ".thumb.jpg", $FileName); $CaptionName = ereg_replace(".jpg", ".caption", $FileName); $FilePath = $Config["DirPath"] . $FileName; $ThumbPath = $Config["DirPath"] . $ThumbName; $CaptionPath = $Config["DirPath"] . $CaptionName; if(file_exists($FilePath)) { echo "

File Already Exists!! Upload Cancelled!

\n"; } else { if($Config["UsePHPScaling"] == "Yes") { $incoming = imagecreatefromjpeg($_FILES['FileName']['tmp_name']); $destheight = $Config["PhotoHeight"]; $srcheight = imagesy($incoming); $srcwidth = imagesx($incoming); # scale the image down, is necessary, but not up. if($srcheight > $destheight) $destwidth = $srcwidth * ($destheight / $srcheight); else $destwidth = $srcwidth; $outimage = imagecreate($destwidth, $destheight); imagecopyresampled ($outimage, $incoming, 0, 0, 0, 0, $destwidth, $destheight, $srcwidth, $srcheight); imagejpeg($outimage, $FilePath); $thumbheight = $Config["ThumbHeight"]; $thumbwidth = $srcwidth * ($thumbheight / $srcheight); $thumbimage = imagecreate($thumbwidth, $thumbheight); imagecopyresampled ($thumbimage, $incoming, 0, 0, 0, 0, $thumbwidth, $thumbheight, $srcwidth, $srcheight); imagejpeg($thumbimage, $ThumbPath); } else { if(file_exists("./makethumb")) { $cmd = "./makethumb " . escapeshellarg($_FILES['FileName']['tmp_name']) . " " . escapeshellarg($FilePath) . " " . $Config["PhotoHeight"]; system($cmd); $cmd = "./makethumb " . escapeshellarg($_FILES['FileName']['tmp_name']) . " " . escapeshellarg($ThumbPath) . " " . $Config["ThumbHeight"]; system($cmd); } } $Photo = $FileName; // for ChangeCaption $HTTP_POST_VARS["Photo"] = $Photo; ChangeCaption(); $Ownership = GetOwnership(); $Ownership[$Photo] = $Config["UserName"]; WriteOwnership($Ownership); $Config["StartPic"] = $Photo; } } GetConfig(); $Action = $HTTP_POST_VARS["Action"]; if($Action == "Change Caption") ChangeCaption(); else if($Action == "Delete Photo") DeletePhoto(); else if($Action == "Move Photo") MovePhoto(); else if($Action == "Upload!") UploadPhoto(); ShowAlbum(); ?>