Icy Bison
Contact Icy Bison
extensions = array(".jpg",".jpeg",".png",".gif",".doc",".docx",".xls",".xlsx",".pdf",".zip"); // specify the allowed extensions here
// $my_upload->extensions = "de"; // use this to switch the messages into an other language (translate first!!!)
$my_upload->max_length_filename = 100; // change this value to fit your field length in your database (standard 100)
$my_upload->rename_file = true;
function upload_file () {
extract($GLOBALS);
$my_upload->the_temp_file = $_FILES['upload']['tmp_name'];
$my_upload->the_file = $_FILES['upload']['name'];
$my_upload->http_error = $_FILES['upload']['error'];
$my_upload->replace = "n"; // because only a checked checkboxes is true
$my_upload->do_filename_check = "y"; // use this boolean to check for a valid filename
// $found = TRUE;
$my_upload->upload('');
// return $my_upload->show_error_string();
$GLOBALS['x'] = $my_upload->show_error_string();
// if (isset($info)) echo "
".nl2br($info)."
";
}
// check for whack kinput
foreach ($_POST as $j =>$value)
{
if (stristr($value,"Content-Type"))
{
header("HTTP/1.0 403 Forbidden");
echo "Sorry, there were one or more errors.";
exit();
}
}
// parameters
$u_em = stripslashes(isset($_POST['u_em']) ? $_POST['u_em'] : '');
$u_nam = stripslashes(isset($_POST['u_nam']) ? $_POST['u_nam'] : '');
$u_sub = stripslashes(isset($_POST['u_sub']) ? $_POST['u_sub'] : '');
$u_msg = stripslashes(isset($_POST['u_msg']) ? $_POST['u_msg'] : '');
$submit = stripslashes(isset($_POST['submit']) ? $_POST['submit'] : '');
$submitted = stripslashes(isset($_POST['submitted']) ? $_POST['submitted'] : '0');
$phpmailer_dir = 'includes/mailer/class.phpmailer.php';
$mail_host = 'localhost';
$spam = 0;
$error_num = array(TRUE,TRUE,TRUE,TRUE,TRUE);
// ##### function to define form errors ##### //
$errorin[0] = "Your need to enter at least your first name.";
$errorin[1] = "You must supply a valid email address.";
$errorin[2] = "You need to supply a subject.";
$errorin[3] = "The message you are sending can not be empty.";
$errorin[4] = "The information you entered is invalid. Please avoid using special characters when possible.";
// only process this if the form has been submitted
if ($submit)
{
// form referrer page
// if ( ($_SERVER['HTTP_REFERER'] != "http://www.cuphd.org/contact.html") ){
// echo ("Sorry, there was an error.");
// exit();
// }
// validate all user input
$error_num = array('','','','','');
validate_input();
$send = TRUE;
for ($j=0; $j<=4; $j++) {
if ($error_num[$j] == FALSE)
$send = FALSE;
}
if ($send == TRUE) {
upload_file (); // attatch file
if ($x)
$send = FALSE;
}
if ($error_num[4] == FALSE)
{
echo $errorin[4];
$u_em = "None";
$u_nam = "Website contact";
$u_sub = "Possible spam attempt!";
$sentTime = date('l F jS \a\t h:i:s a');
$user_ip = getenv('REMOTE_ADDR');
$u_msg = "Spammer's IP number is ".$user_ip."\n\nSent ".$sentTime."\n";
}
// if input is valid or error_num[4] == FALSE send email
if ($send == TRUE)
$submitted = send_email();
}
function send_email()
{
extract($GLOBALS);
$temp_name = $_FILES['upload']['tmp_name'];
$real_name = $_FILES['upload']['name'];
$user_ip = getenv('REMOTE_ADDR');
$submitted = 1;
// Build email message
$em_body = "This is an email message generated from the Icy Bison contact form.\n\nSenders name: ".$u_nam."\nSenders email: ".$u_em."\nSenders ip: $user_ip\n\nSubject: ".$u_sub."\n\nMessage: ".$u_msg;
$mail = new PHPMailer();
$mail->IsHTML(false);
// $mail->IsSMTP(); // telling the class to use SMTP
$mail->Host = $mail_host; // SMTP server
$mail->AddAttachment($temp_name, $real_name); // optional name
$mail->From = 'no-reply@icybison.com';
$mail->FromName = 'Icy Bison contact';
$mail->AddAddress("sbrunkow@icybison.com", "sb"); // email address
//$mail->AddAddress("dyates@cuphd.org", "dyates");
// A little clean-up - not sure if this should be done earlier
$mail->Subject = stripslashes($u_sub);
$mail->Body = stripslashes($em_body);
$mail->WordWrap = 0;
if(!$mail->Send())
{
echo "Message was not sent";
echo "Mailer Error: " . $mail->ErrorInfo;
}
else
{
if ($spam == FALSE)
{
echo '
';
echo '
Thank you
Your message has been submitted
';
// echo "Go back to web site.";
//exit();
echo '
';
}
}
return ($submitted);
}
// end send mail function
// end of form processing
function validate_input()
{
extract($GLOBALS);
global $errorin;
global $error_num;
// Validate email
$emailPattern = '/^[^@\s]+@([-a-z0-9]+\.)+[a-z]{2,}$/i';
if ($u_em == "")
$error_num[1] == FALSE;
else if (!preg_match($emailPattern, $u_em) )
{
$error_num[1] == FALSE;
$errorin[1] = "The email address you entered is invalid.";
}
else $error_num[1] = TRUE;
// Validate name
$textPattern = '/^[a-z0-9(),. \']{2,35}$/i';
if ($u_nam == "")
$error_num[0] == FALSE;
else if ( (!preg_match($textPattern, $u_nam) ) )
{
$error_num[0] == FALSE;
$errorin[0] = "The name you entered is invalid.";
}
else $error_num[0] = TRUE;
// Validate subject
$textPattern = '/^[a-z0-9()\/\'":\*+,.; \- !?$@]{2,75}$/i';
if ($u_sub == "")
$error_num[2] == FALSE;
else if ( (!preg_match($textPattern, $u_sub) ) )
{
$error_num[2] == FALSE;
$errorin[2] = "The subject you entered is invalid.";
}
else $error_num[2] = TRUE;
// Validate the message
$textPattern = '/^[a-z0-9()\/\'":\*+|,.; \- !?$@!\\r\\n]{2,500}$/i';
if ($u_msg == "")
$error_num[3] == FALSE;
else if (preg_match('/http:/', $u_msg) || preg_match('/\[url/', $u_msg) || preg_match('/\
show_error_string();
if ($submitted == 0 || $x || $send==FALSE) {
?>