index.php 0000754 0000764 0000060 00000017000 11546760106 012002 0 ustar marcl apache <
// |_|_| |_|\__,_|\___/_/\_\
//
// ==========================================================================
// A PHP utility to do a Macintosh style 'Light Box' display of a bunch of
// thumbnail photos, where clicking on a photo causes some Javascript magic
// to display a larger version of the photo nicly centered on the page with
// a small (X) in the upper right corner to close it. This is all done via
// configuration by a partner PHP file called config.php in this directory.
// H Marc Lewis -- March-2011
// ==========================================================================
ini_set('display_errors',1);
$version = "1.1";
// ---------------------------------------------------------
// If this utility isn't configured yet, go do that first...
// ---------------------------------------------------------
if (!file_exists("tools/CONFIGURED")) {
header("Location: config.php");
exit(0);
}
$body = "";
$Rotation = Array();
$Args = Array();
$x = file_get_contents("tools/CONFIGURED");
if (empty($x)) {
print "
File tools/CONFIGURED is empty — please delete it and reload
";
exit(0);
}
else {
$Args = unserialize($x);
//foreach ($Args as $key => $value)
//print "$key => '$value' \n";
$background = $Args['Background'];
$bodytext = $Args['BodyText'];
$border = $Args['Border'];
$copyright = $Args['Copyright'];
$fonts = $Args['Fonts'];
$fontsize = $Args['FontSize'];
$height = $Args['Height'];
$namecolor = $Args['NameColor'];
$pagecolor = $Args['PageColor'];
$quality = $Args['Quality'];
$repeatX = $Args['RepeatX'];
$repeatY = $Args['RepeatY'];
$spacing = $Args['Spacing'];
$showname = $Args['ShowName'];
$title = $Args['Title'];
$titlecolor = $Args['TitleColor'];
$titlefont = $Args['TitleFont'];
}
// ----------------------------------------------------------------
// Give user a button to quickly re-configure if still in test mode
// ----------------------------------------------------------------
if (!file_exists("tools/PUBLISHED")) {
$cButton = "
";
}
else
$cButton = "";
sendHeader($title,$bodytext,$fonts,$fontsize,$titlefont,$cButton,$background,
$pagecolor,$repeatX,$repeatY,$titlecolor,$border,$namecolor);
if ($image = opendir("thumb")) {
while ($name = readdir($image)) {
//print "$name ";
if ('.jpg' == strtolower(substr($name,-4))
or '.jpeg' == strtolower(substr($name,-5))
or '.png' == strtolower(substr($name,-4))
or '.gif' == strtolower(substr($name,-4))) {
$Rotation[] = $name;
}
}
}
if (count($Rotation)) {
asort($Rotation);
$first = $Rotation[0];
ini_set('display_errors',0); // lots of .TXT files won't be there
foreach ($Rotation as $name) {
//print "Rotation = $name ";
$body .= showThumb($name,$spacing,$showname);
}
}
print $body;
sendFooter($copyright,$version);
// ==================================================================
// Display a single thumbnail photo in a floating DIV so the images
// will fill whatever screen size the user has at the moment.
// ==================================================================
function showThumb($name,$spacing,$showname)
{
$html = preg_replace("/\.jpg|\.jpeg|\.png|\.gif$/i",".txt",$name);
$text = file_get_contents($html);
if (empty($text))
$title = ""; // to prevent validation errors
else
$title = "title='$text'";
if ($showname)
$filename = " $name";
else
$filename = "";
return <<$filename
RETURN;
}
// =========================
// Write the HTML 5 header
// =========================
function sendHeader($title,$text,$font,$size,$titlefont,$button,$background,
$pagecolor,$repeatx,$repeaty,$titlecolor,$border,$namecolor)
{
if (!empty($pagecolor))
$pagecolor = "background-color: $pagecolor;";
if (!empty($background)) {
$background = "background: url($background) ";
if (!empty($repeatx)) $background .= " repeat-x ";
if (!empty($repeaty)) $background .= " repeat-y ";
$background .= ";";
}
if (!empty($titlecolor))
$titlecolor = "color: $titlecolor;";
if ($border+0)
$imgborder = "img { border: ${border}px solid black; }";
else
$imgborder = "";
if (!empty($namecolor))
$namecolor = "color: $namecolor;";
print <<$title
$title
$button
$text
HEADER;
}
// =========================
// Write the HTML 5 footer
// =========================
function sendFooter($copyright,$version)
{
if (!empty($copyright))
$copyright .= " ";
print <<