";
foreach ($items as $item)
{
//turn the description back into an array so it can be output on separate lines.
$description = explode(" | ",$item->description);
$itemlist .= "
\n
$item->title
\n";
$itemlist.= "
url\">view
";
//split the description into separate lines
foreach ($description as $field)
{
$itemlist .= $field . "
\n";
}
$itemlist .= "
\n
\n";
}//end foreach
$html .= $itemlist . "
\n\n";
return $html;
}//end function
function ProcessFiles($directory,$thumbnails)
{
/*
* str $directory: the directory to process
* bool $thumbnails: whether thumbnails should be generated
*/
// comment out the next two statements if you want to permit access to
// files "above" the directory where the script resides. This is NOT recommended.
// You should adjust your openbasedir setting in php.ini instead so you aren't vulnerable.
if (strpos($directory,"/")===0)
die ("Access to that directory not allowed");
if (strpos($directory,".")===0)
die ("Access to that directory not allowed");
//if no dir specified, set to dir where script resides
if (!$directory)
$directory = ".";
$realpath = realpath($directory);
//make sure the directory exists
if (!is_dir($directory))
die("No directory at $directory.");
//the next statement requires PHP5.
//See below for PHP4 equivalent.
$files = scandir($realpath);
/*
PHP4 rough equivalent to scandir. (Untested)
code from: http://tinyurl.com/5ovps
$dh = opendir($realpath);
while (false !== ($filename = readdir($dh))) {
$files[] = $filename;
}
*/
if (!is_array($files))
{
$error = "No files to process in this directory.";
die ($error);
}
foreach ($files as $file)
{
//check if it's a file and a jpeg
$realfile = $realpath . "/" . $file;
if (is_file($realfile) && (exif_imagetype($realfile)==2) && (strpos($realfile,ASIF_SUFFIX)===false))
{
$exif = exif_read_data($realfile, 0, true);
$pic = new Picture();
//edit the path so it renders into a proper url when appended to the domain name.
//yuck -- got to be a better way to do this
if ($directory===".")
{ $htmldirectory = "/"; }
else
{ $htmldirectory = "/" . $directory . "/"; }
$pic->filename = $file;
$pic->filepath = dirname($_SERVER["SCRIPT_URI"]) . $htmldirectory . $file;
$pic->exif = $exif;
$pictures[] = $pic;
//create thumbnails if necessary
if ($thumbnails == "yes")
ResizeImage($realfile);
} //end if jpegs
}//end foreach file
if (is_array($pictures))
{return $pictures;}
else
{
$error = "No images to process in this directory.";
die ($error);
}
}//end function
$photos = ProcessFiles(clean($_GET["directory"],ASIF_PATH_LENGTH_LIMIT),clean($_GET["thumbnails"],3));
switch (clean($_GET["format"],4))
{
case "rss":
$feeditems = PrepareItems($photos,clean($_GET["thumbnails"],3),clean($_GET["alldata"],3));
$feeddata = PrepareMetaData("RSS");
$output = BuildRSSFeed
(
$feeddata["commenttext"],
$feeddata["feedtitle"],
$feeddata["feedurl"],
$feeddata["feedtagline"],
$feeddata["feedauthorname"],
ASIF_TIMEZONE_ENGLISH,
$feeditems
);
header('Content-Type: text/xml');
echo $output;
break;
case "atom":
$feeditems = PrepareItems($photos,clean($_GET["thumbnails"],3),clean($_GET["alldata"],3));
$feeddata = PrepareMetaData("Atom");
$output = BuildAtomFeed
(
$feeddata["commenttext"],
$feeddata["feedtitle"],
$feeddata["feedurl"],
$feeddata["feedtagline"],
$feeddata["feedid"],
$feeddata["feedauthorname"],
ASIF_TIMEZONE_NUMERIC,
$feeditems
);
header('Content-Type: text/xml');
echo $output;
break;
default:
//output as HTML
$feeditems = PrepareItems($photos,clean($_GET["thumbnails"],3),clean($_GET["alldata"],3));
$feeddata = PrepareMetaData("html");
$output = BuildHTML
(
$feeddata["commenttext"],
$feeddata["feedtitle"],
$feeddata["feedurl"],
$feeddata["feedtagline"],
$feeddata["feedauthorname"],
ASIF_TIMEZONE_ENGLISH,
$feeditems,
clean($_GET["thumbnails"],3)
);
echo $output;
}
?>