File:  [mozdev] / testo / email.html
Revision 1.1: download - view: text, annotated - select for diffs - revision graph
Tue Aug 28 07:17:41 2007 UTC (11 years, 5 months ago) by buckley
Branches: MAIN
CVS tags: HEAD
no message

<?php
extract($HTTP_GET_VARS);
$ediv = '</div>';
$ebody = '</body></html>';
$first = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en"><head>';
$head = '<link rel="stylesheet" type="text/css" href="css/css.css">
<link rel="stylesheet" type="text/css" href="css/email.css">
<script type="text/javascript" src="email.js"></script>
</head>
<body onload="file();">';
$body = '<h1>E-mail</h1>
<div id="e">
<div id="c">';
$thank = '<h2>Thank You</h2><p>Thank you ';
$thanks = ' for takeing the time to send me an e-mail. This page just confirms that it has been sent. I will reply as soon as I can.';
$error = '<h2>Error!</h2>
<p>
I am sorry but something went wrong when mailing this message. Please go to <a href="feedback.html">the Feed Back page</a> and try another way of sending your message. And tell me about this problem, no one should ever see this page. It is only for when things go real wrong on my end.';
$donate = '<h2>Donate</h2>
<p>If you are just writing to say thank you, why not <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&amp;business=michael%2ebuckley%40ozemail%2ecom%2eau&amp;item_name=Michael">Donate</a> instead?';
$form = '<h2>Contact Me</h2>
<p>
If you want to send and e-mail to me you have come to the right place. Please make sure you type your e-mail address correct, otherwise I can\'t reply.
<p>
Please make sure you have the latest version, each new version has bug fixes so your problem my be solved.
<p id="js">
If you want to be able to send a file (image, zip ect..) you need JavaScript enabled.
</p>';
$fileError = '<p id="boo">
The file you attempted to upload is too big, please chose a smaller file.
</p>';
$formError = '<p id="boo">
There were some errors in processing the e-mail please correct them.
</p>';
$form1 = '<form id="post" method="POST" enctype="multipart/form-data" action="email.html?id=send">
Email From:
<input ';
$form2 = 'type="text" class="mod" name="EmailFrom" value="';
$form3 ='">
Subject:
<input ';
$form4 = 'type="text" class="mod" name="Subject" value="';
$form5 = '">
Name:
<input ';
$form6 = 'type="text" class="mod" name="Name" value="';
$form7 = '">
<textarea ';
$form8 = ' rows="10" cols="40" name="Comments">';
$form9 = '</textarea>
<input id="g" type="submit" name="submit" value="Submit" onclick="submit();">
<input id="h" type="reset" name="reset" value="Reset">
<div id="hidden">
<div id="p">
<input type="hidden" name="MAX_FILE_SIZE" value="150000">
<input id="f" oninput="setValue(this);" onchange="setValue(this);" type="file" name="userfile">
</div>
<div class="n">
<input type="text" class="n" id="n" name="nothing" value="">
<button id="button">Browse...</button></div>
<div id="j">
This is optional, you don\'t have to send a file, but if you want to send a screen shot, zip file etc. you can.
</div>
</div>
</form>';
if($id=="success"){
	echo ($first.'<title>E-mail - Sent</title>'.$head);
	echo ($body.$thank.$_GET['name'].$thanks.$ediv);
	include("content/menu.php");
	echo ($ebody);
}
if($id=="error") {
	echo ($first.'<title>E-mail - Error</title>'.$head.$body.$error.$donate.$ediv);
	include("content/menu.php");
	echo ($ebody);
}
if($id=="") {
	echo ($first.'<title>E-mail</title>'.$head.$body.$form.$form1.$form2.$form3.$form4.$form5.$form6.$form7.$form8.$form9.$donate.$ediv);
	include("content/menu.php");
	echo ($ebody);
}

	$uri = 'http://';
	$uri .= $_SERVER['HTTP_HOST'];
if($id=="send") {
$EmailFrom = Trim(stripslashes($_POST['EmailFrom']));
$EmailTo = "michael.buckley@ozemail.com.au";
$Subject = Trim(stripslashes($_POST['Subject']));
$Name = Trim(stripslashes($_POST['Name']));
$Comments = Trim(stripslashes($_POST['Comments']));
$Radio = Trim(stripslashes($_POST['Radio']));
$letter = $_FILES['userfile']['name'];
$fType = $_FILES['userfile']['type'];
$fSize = $_FILES['userfile']['size'];
$f_name = $_FILES['userfile']['tmp_name'];
if($fSize < 150000) {
	echo ($first.'<title>E-mail</title>'.$head.$body.$form.$fileError.$form1.$form2.$EmailFrom.$form3.$form4.$Subject.$form5.$form6.$Name.$form7.$form8.$Comments.$form9.$donate.$ediv);
	include("content/menu.php");
	echo ($ebody);
	exit;
}
$validationOK="true";
if (Trim($EmailFrom)==""){$from="false"; $validationOK='false';}
if (Trim($Subject)=="") {$subject="false"; $validationOK='false';}
if (Trim($Name)=="") {$name="false"; $validationOK='false';}
if (Trim($Comments)=="") {$com="false"; $validationOK='false';}
$handle=fopen($f_name, 'rb');
$f_contents=fread($handle, filesize($f_name));
$f_contents=chunk_split(base64_encode($f_contents));
$f_type=filetype($f_name);
fclose($handle);
if ($validationOK == 'false') {
	if($from == "false") $class1 = ' wrong="true" ';
	if($subject == "false") $class2 = ' wrong="true" ';
	if($name == "false") $class3 = ' wrong="true" ';
	if($com == "false") $class4 = ' wrong="true" ';
	echo ($first.'<title>E-mail</title>'.$head.$body.$form.$formError.$form1.$class1.$form2.$EmailFrom.$form3.$class2.$form4.$Subject.$form5.$class3.$form6.$Name.$form7.$class4.$form8.$Comments.$form9.$donate.$ediv);
	include("content/menu.php");
	echo ($ebody);
	exit;
}
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "Comments: ";
$Body .= $Comments;
$headers .= "From: <". $EmailFrom .">\n".$eol;
$headers .= "Message-ID: <".$now." TheSystem@".$_SERVER['SERVER_NAME'].">\n".$eol;
$headers .= "X-Mailer: PHP v".phpversion()."\n".$eol;
$mime_boundary=md5(time());
$headers .= 'MIME-Version: 1.0'."\n".$eol;
$headers .= "Content-Type: multipart/mixed; boundary=\"".$mime_boundary."\""."\n".$eol;
$msg = "";

$msg .= "This is a multi-part message in MIME format.\n".$eol;
$msg .= "--".$mime_boundary."\n".$eol;
$msg .= "Content-Type: text/plain; charset=iso-8859-1;"."\n".$eol;
$msg .= "Content-Transfer-Encoding: 7bit"."\n".$eol;
$msg .= "Content-Disposition: inline;"."\n"."\n".$eol;
$msg .= $Body."\n".$eol.$eol;

$msg .= "--".$mime_boundary."\n".$eol;
$msg .= "Content-Type: ".$fType."; name=\"".$letter."\""."\n".$eol;
$msg .= "Content-Transfer-Encoding: base64"."\n".$eol;
$msg .= "Content-Disposition: inline; filename=\"".$letter."\""."\n"."\n".$eol.$eol;
$msg .= $f_contents."\n".$eol.$eol;
# Setup for text OR html
$msg .= "Content-Type: multipart/alternative"."\n".$eol;

$msg .= "--".$mime_boundary."--"."\n".$eol.$eol;
$success = mail($EmailTo, $Subject, $msg, $headers);
if ($success){header('Location: '.$uri.'/email.html?id=success');}
else{header('Location: '.$uri.'/email.html?id=error');}
} ?>

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>