.
*/
include("./include/include.php");
include("./include/Tar.php");
admin_header(true, true);
if( !in_array("application_photoexport", $_SESSION['sess_functions']) ) {
echoln("You are not authorized to see this page.");
}else {
$query = "SELECT `FirstName`, `LastName`, `Photo`, `Modified` FROM `persons` WHERE ".$_SESSION['sess_sel']." AND LENGTH(`Photo`)>64 ORDER BY `FirstName`, `LastName`";
if( @mysql_num_rows( $res=doquery($query) )>0 ) {
// First we create a .tar file with all photo's
$tar = new Tar();
while( $row=mysql_fetch_array($res) ) {
$t = $row['Modified'];
$timestamp = mktime(substr($t, 11, 2), substr($t, 14, 2), substr($t, 17, 2), substr($t, 5, 2), substr($t, 8, 2), substr($t, 0, 4));
$tar->add($row['Photo'], substr($row['FirstName']." ".$row['LastName'], 0, 95).".jpg", $timestamp);
}
$data = $tar->close();
$datacompressed = gzencode($data);
// Send the file to the user
header("Content-type: application/zip");
header("Content-type: application/octet-stream");
header("Content-disposition: attachment; filename=\"photos.tar.gz\"");
header("Content-Transfer-Encoding: binary");
header("Content-length: ".strlen($datacompressed));
echo $datacompressed;
}else {
echoln("No photo's found in selection.");
}
}
admin_footer(true, true);
?>