<?php
// When the form is submitted
If($_POST['submit']==true) {
extract($_POST, EXTR_SKIP);
// Check the form for errors
If(trim($yourname)=="") {
$error.="<font size='2' face='Verdana' color='#ffffff'>Вы не ввели свое имя!</font><br />";
}
If(trim($yourphone)=="") {
$error.="<font size='2' face='Verdana' color='#ffffff'>Вы не ввели свой телефон!</font><br />";
}
If(trim($youremail)=="") {
$error.="<font size='2' face='Verdana' color='#ffffff'>Вы не ввели свой e-mail!</font><br />";
} Elseif(!preg_match("/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,})+$/", $youremail)) {
$error.="<font size='2' face='Verdana' color='#ffffff'>Неверный e-mail!</font><br />";
}
If(trim($emailsubject)=="") {
$emailsubject=$defaultsubject;
}
If(trim($yourmessage)=="") {
$error.="<font size='2' face='Verdana' color='#ffffff'>Вы не ввели свои пожелания!<br /></font>";
}
// Verify Attchment info
If($allowattach > 0) {
// Get the total size of all uploaded files
If((array_sum($_FILES['attachment']['size'])) > ($max_file_total*1024)) {
$error.="<font size='2' face='Verdana' color='#ffffff'>Максимальный размер загр. файла ".$max_file_total."КБ</font><br />";
} Else {
//Loop through each of the files
For($i=0; $i <= $allowattach-1; $i++) {
If($_FILES['attachment']['name'][$i]) {
//Check the size of each file
if(($_FILES['attachment']['size'][$i]) > ($max_file_size*1024)) {
$error.= "<font size='2' face='Verdana' color='#ffffff'>Ваш файл слишком большой!</file><br />";
} // If in_array
} // If Files
} // For
}
} // If Allowattach
If($error) {
$display_message=$error;
} Else {
If($use_subject_drop AND is_array($subjects) AND is_array($emails)) {
$subject_count=count($subjects);
$email_count=count($emails);
If($subject_count==$email_count) {
$myemail=$emails[$emailsubject];
$emailsubject=$subjects[$emailsubject];
} // If $subject_count
} // If $use_subject_drop
$boundary=md5(uniqid(time()));
//Headers
$headers="Return-Path: <".clean_msg($youremail).">\n";
$headers.="From: ".clean_msg($youremail)."\n";
$headers.="X-Mailer: PHP/".phpversion()."\n";
$headers.="X-Sender: ".$_SERVER['REMOTE_ADDR']."\n";
$headers.="X-Priority: ".$priority."\n";
$headers.="MIME-Version: 1.0\n";
$headers.="Content-Type: multipart/mixed; boundary=\"".$boundary."\"\n";
$headers.="This is a multi-part message in MIME format.\n";
//Message
$message = "--".$boundary."\n";
$message.="Content-Type: text/html; charset=\"utf-8\"\n";
$message.="Content-Transfer-Encoding: quoted-printable\n";
$message.="\n";
$message.=clean_msg(nl2br(strip_tags($yourname." (".$yourphone.") ".$youremail."\n ".$yourmessage)));
$message.="\n";
//Add attachments to message
If($allowattach > 0) {
For($i=0; $i <= $allowattach-1; $i++) {
If($_FILES['attachment']['tmp_name'][$i]) {
$message.=phattach($_FILES['attachment']['tmp_name'][$i], $_FILES['attachment']['name'][$i], $boundary);
} //If $_FILES['attachment']['name'][$i]
} //For
} // If
// End the message
$message.="--".$boundary."--\n";
// Send the completed message
If(!mail($myemail, clean_msg($emailsubject), $message, $headers)) {
Exit("<font size='2' face='Verdana' color='#ffffff'>Возникла ошибка с оправкой сообщения!</font>\n");
} Else {
$sent_mail=true;
}
} // Else
} // $_POST
?>
<script type="text/javascript">
var error="";
e_regex = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,})+$/;
function Checkit(theform) {
if(theform.yourname.value.length<3) {
error+="<font size='2' face='Verdana' color='#ffffff'>Вы не ввели своего имени</font>\n";
}
if(theform.yourphone.value.length<9&&theform.yourphone.value!="") {
error+="<font size='2' face='Verdana' color='#ffffff'>Вы не ввели своего телефона</font>\n";
}
if(theform.youremail.value=="") {
error+="<font size='2' face='Verdana' color='#ffffff'>Вы не ввели свой e-mail</font>\n";
} else if(!e_regex.test(theform.youremail.value)) {
error+="<font size='2' face='Verdana' color='#ffffff'>Неверный e-mail</font>\n";
}
if(error) {
alert('<font size='2' face='Verdana' color='#ffffff'>**Возникли следующие ошибки:**\n\n' + error + '</font>');
error="";
return false;
} else {
return true;
}
}
function valid_key_number(e){
e = (e) ? e : window.e;
w = (e.keyCode) ? e.keyCode : e.which;
if((w<48||w>57)&&w!=8) return false;
}
</script>
</head>
<body>
<?If($display_message) {?>
<div align="center" class="error_message"><font size='2' face='Verdana' color='#ffffff'><b><?=$display_message;?></b></font></div>
<br />
<?}?>
<?If($sent_mail!=true) {?>
<form method="post" action="form.php" enctype="multipart/form-data" name="phmailer" onsubmit="return Checkit(this)">
<table align="center" class="table">
<tr>
<td colspan="2" class="table_header" width="100%"><?=$websitename;?></td>
</tr>
<?If($allowattach > 0) {?>
<tr>
<td width="100%" class="attach_info" colspan="2"><br />
<font size='2' face='Verdana' color='#ffffff'><b>Максимальный размер файла:</b> <?=$max_file_size?>КБ.<br /></font>
</td>
</tr>
<?}?>
<tr>
<td width="30%" class="table_body"><font size='2' face='Verdana' color='#ffffff'>Ваше имя<span class="error_message">*</span>:</font></td>
<td width="70%" class="table_body"><input name="yourname" type="text" size="30" value="<?=stripslashes(htmlspecialchars($yourname));?>" /><span class="error_message">*</span></td>
</tr>
<tr>
<td width="30%" class="table_body"><font size='2' face='Verdana' color='#ffffff'>Ваш телефон<span class="error_message">*</span>:</font></td>
<td width="70%" class="table_body"><input name="yourphone" type="text" id="yourphone" onkeypress="return valid_key_number(event);" value="<?=stripslashes(htmlspecialchars($yourphone));?>" /><span class="error_message">*</span></td>
</tr>
<tr>
<td width="30%" class="table_body"><font size='2' face='Verdana' color='#ffffff'>Ваш e-mail<span class="error_message">*</span>:</font></td>
<td width="70%" class="table_body"><input name="youremail" type="text" size="30" value="<?=stripslashes(htmlspecialchars($youremail));?>" /><span class="error_message">*</span></td>
</tr>
<?For($i=1;$i <= $allowattach; $i++) {?>
<tr>
<td width="30%" class="table_body"><font size='2' face='Verdana' color='#ffffff'>Файл для отправки:</font></td>
<td width="70%" class="table_body"><input name="attachment[]" type="file" size="30" /></td>
</tr>
<?}?>
<tr>
<td colspan="2" width="100%" class="table_body"><font size='2' face='Verdana' color='#ffffff'>Ваши пожелания:</font><br />
<div align="center">
<textarea name="yourmessage" rows="8" cols="60"><?=stripslashes(htmlspecialchars($yourmessage));?></textarea>
</div>
</td>
</tr>
<tr>
<td colspan="2" width="100%" class="table_footer">
<input type="hidden" name="submit" value="true" />
<input type="submit" value="<?=$submitvalue;?>" />
<input type="reset" value="<?=$resetvalue;?>" />
</td>
</tr>
</table>
</form>
<?} Else {?>
<div align="center" class="thanks_message"><?=$thanksmessage;?></div>
<br />
<br />
<?} ?>
</tbody>
</table>
<br>
</form></td></tr>
</tbody></table> |