.
*/
include("./include/include.php");
if( $_SERVER['REQUEST_METHOD']=="GET" ) {
admin_header();
}else {
admin_header(true, true);
}
if( !in_array("export_maillist", $_SESSION['sess_functions']) ) {
echoln("You are not authorized to see this page.");
}else {
if( $_SERVER['REQUEST_METHOD']=="GET" ) {
echoln("
Mailing list export
");
echoln("Note: only people selected for this workshop will show up here, the choices made ");
echoln("by the participants do not influence this list. Also, the participant accepted status ");
echoln("must be either 'accepted' or 'arrived'.");
echoln("");
admin_footer();
}else {
$workshop = get_int('workshop');
$format = get_var('format');
if( $workshop<1 ) {
echoln("You did not select a workshop. Please select one.");
}elseif( $format!="nl" AND $format!="nlname" ) {
echoln("You did not select the output format. Please select it.");
}else {
$query="SELECT `FirstName`, `LastName`, `Email` FROM `persons`
WHERE (`Accepted`='yes' OR `Accepted`='confirmed' OR `Accepted`='arrived') AND (`WorkshopIDSlot1`=".addslashes($workshop)." OR `WorkshopIDSlot2`=".addslashes($workshop).")
ORDER BY `FirstName`, `LastName`";
if( @mysql_num_rows( $res=doquery($query) )>0 ) {
$data = "";
while( $row = mysql_fetch_array($res) ) {
switch( $format ) {
case "nl":
$data .= $row['Email']."\n";
break;
case "nlname":
$data .= $row['Email']." ".$row['FirstName']." ".$row['LastName']."\n";
break;
default:
}
}
$data .= "\n";
header("Last-Modified: " . gmdate("D, d M Y H:i ") . " GMT");
header('Pragma: no-cache');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header("Content-length: ".strlen($data));
header("Content-disposition: attachment; filename=\"workshop_".$workshop."-".$format.".txt\"");
header("Content-type: application/octet-stream");
header("Content-Transfer-Encoding: binary");
header('Pragma: public');
echo $data;
}else {
echoln("There are no people in the current selection. Nothing to download.");
}
}
}
}
?>