process_submission

[insert_php]
session_start();
$firstname = $_POST[‘firstname’];
$surname = $_POST[‘surname’];
$title = $_POST[‘title’];
$email = $_POST[’email’];
$phone = $_POST[‘phone’];
$authors = $_POST[‘authors’];
$affiliation = $_POST[‘affiliation’];
$uploadfile = $_FILES[‘uploadfile’][‘name’];

echo ““;
echo “Name: “. “” . ucfirst($firstname) . ” ” . strtoupper($surname) . “
“;
echo “Affiliation: “. “” . $affiliation . “
“;
echo “
“;
echo “Title of presentation: “. ““. ucwords($title) . “
“;
echo “Author(s): “. ““. $authors . “
“;
echo “
“;
echo “E-mail: “. ““. $email . “
“;
echo “Phone: “. ““. $phone . “
“;
echo “
“;
echo “Abstract file: “. ““. basename($uploadfile) . “
“;
echo “
“;
echo “
“;

$error_msg=”;

if(empty($_SESSION[‘6_letters_code’]) ||
strcasecmp($_SESSION[‘6_letters_code’], $_POST[‘6_letters_code’]) != 0)
{
//Note: the captcha code is compared case insensitively.
//if you want case sensitive match, update the check above to
// strcmp()

echo “Captcha code: “. $_SESSION[‘6_letters_code’] .”
“;
echo “Entered code: “. $_POST[‘6_letters_code’] .”
“;

$error_msg.= “The captcha code does not match!”;
}

if(trim($_POST[“firstname”])==”) {
$error_msg.=”First name, “;
}
if(trim($_POST[“surname”])==”) {
$error_msg.=”Surname, “;
}
if(trim($_POST[“email”])==”) {
$error_msg.=”E-mail, “;
}
if(trim($_POST[“title”])==”) {
$error_msg.=”Title of abstract, “;
}
if(trim($_POST[“authors”])==”) {
$error_msg.=”Author(s), “;
}
if(trim($_POST[“affiliation”])==”) {
$error_msg.=”Affiliation, “;
}

if(!($uploadfile==””||$uploadfile==”none”)){
$uploaddir = “SIG33/Abstracts/”;
$target_filename = ucfirst($firstname) . “_” . strtoupper($surname) . “_” . time() . “.pdf”;
$target_file = $uploaddir . $target_filename;
if(move_uploaded_file($_FILES[‘uploadfile’][‘tmp_name’], $target_file)) {
echo(“The abstract file has been stored as “. basename($target_file). “.
“);

$data=”

\n”;
$data .=”

“.ucfirst($firstname).”

\n”;
$data .=”

“.ucfirst($surname).”

\n”;
$data .=”

“.$email.”

\n”;
$data .=”

“.$affiliation.”

\n”;
$data .=”

“.$title.”

\n”;
$data .=”

“.$authors.”

\n”;
$data .=”

“.$phone.”

\n”;
$data .=”

\n”;
$style =”” .
“table, td, th{border:thin solid gray; font-family:sans-serif;border-collapse:collapse;font-size: 11px;}”.
“th{background-color:#CBE3F1;color:gray;font-weight:normal;}”.
“”;

$tableh=”

\n”;
$tableh .=”

\n”;
$tableh .=”

\n”;
$tableh .=”

\n”;
$tableh .=”

\n”;
$tableh .=”

\n”;
$tableh .=”

\n”;
$tableh .=”

\n”;
$tableh .=”

\n”;
$tableh .=”

\n”;

//echo $style . $tableh . $data . “

First name Surname E-mail Affiliation Title Authors Phone

” . “\n”;
/*
$filename=’data.txt’;
$current = file_get_contents($filename);
$current .= $data;
file_put_contents($filename, $current);
$table .=”\n” . $style . $tableh . $current . “

\n” . “\n”;
$filename=’list_abstract.html’;
file_put_contents($filename, $table);
*/
}
else
{
$error_msg.=”There was an error uploading the file, please try again!“;
}
}
else
{
$target_file=””;
}

// display error message if any, if not, proceed to other processing
if($error_msg==”){
$to=”sig33@mech.kth.se, ardeshir.hanifi@gmail.com”;
$subject=”Abstract submission for ERCOFTAC SIG33 Workshop by ” . $firstname . ” ” . $surname;

$message=”\n” . $style . $tableh . $data . “

\n”. “\n”;

$fileatt = $target_file;
$fileatttype = “application/pdf”;
$fileattname = $target_filename;
$semi_rand = md5( time() );
$mime_boundary = “{$semi_rand}x”;

$headers = “From: Registration@SIG33\r\n”;
$headers .= “Reply-To: sig33@mech.kth.se\r\n”;
$headers .= “MIME-Version: 1.0\r\n” .
“Content-Type: multipart/mixed;” .
“boundary=\”{$mime_boundary}\”\n”;

$message = “–{$mime_boundary}\n” .
// “Content-Type: text/html; charset=\”iso-8859-1\”\n” .
“Content-Type: text/html; charset=\”utf-8\”\n” .
“Content-Transfer-Encoding: 8bit\n\n” .
$message . “\n”;

$file = fopen( $fileatt, ‘rb’ );
$data = fread( $file, filesize( $fileatt ) );
fclose( $file );

$data = chunk_split( base64_encode( $data ) );

$message .= “–{$mime_boundary}\n” .
“Content-Type: {$fileatttype};” .
“name=\”{$fileattname}\”\n” .
“Content-Disposition: attachment;” .
“filename=\”{$fileattname}\”\n” .
“Content-Transfer-Encoding: base64\n\n” .
$data . “\n” .
“–{$mime_boundary}–\n”;

if (mail($to, $subject, $message, $headers)) {
echo(“

Thank you for your submission!

“);
} else {
echo(“

Submission did not succeed!
“);
echo(“Please send the file to sig33@mech.kth.se.

“);
}
} else {
echo “ The following necessary information are missing: $error_msg“;
}

[/insert_php]