<?php
$error = 0;
$email_type = addslashes(htmlspecialchars($_POST['email_type']));
$email = addslashes(htmlspecialchars($_POST['email']));
$order_type = addslashes(htmlspecialchars($_POST['order_type']));
$message = addslashes(htmlspecialchars($_POST['message']));
$notes = addslashes(htmlspecialchars($_POST['notes']));
$info = "Character name: " . addslashes(htmlspecialchars($_POST['info'])) . "\r\n";
$info .= "Server name: " . $_POST['server'] . "\r\n";
$info .= "IP Adress: " . $_SERVER['REMOTE_ADDR'] . "\r\n";
$info .= "-====================-" . "\r\n";
$info .= "About: " . $_POST['about'] . "\r\n";
$info .= "Message: " . $_POST['message'] . "\r\n";
$headers = "From: " . $_POST["info"] . " - " . $_POST["server"];
$headers .= "<" . $_POST["email"] . ">\r\n";
$headers .= "Reply-To: " . $_POST["email"] . "\r\n";
$headers .= "Return-Path: " . $_POST["email"];
$headers .= "Content-Type: text/plain; charset=cp1251";
$fileatt = $_FILES['fileatt']['tmp_name'];
$fileatt_type = $_FILES['fileatt']['type'];
$fileatt_name = $_FILES['fileatt']['name'];
if (is_uploaded_file($fileatt)) {
$file = fopen($fileatt,'rb');
$data = fread($file,filesize($fileatt));
fclose($file);
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
$headers .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"{$mime_boundary}\"";
$info .= "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" .
"Content-Type: text/plain; charset=\"windows-1251\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$info . "\n\n";
$data = chunk_split(base64_encode($data));
$info .= "--{$mime_boundary}\n" .
"Content-Type: {$fileatt_type};\n" .
" name=\"{$fileatt_name}\"\n" .
"Content-Disposition: attachment;\n" .
" filename=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"--{$mime_boundary}--\n";
}
if ($_POST['submit']) {
if (empty($_POST['info'])) {
echo '<div id="info">Моля попълнете вашето име!';
$error = 1;
}
elseif(!ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) {
echo '<div id="info">Моля попълнете валиден email !';
$error = 1;
}
elseif($email_type == 'none') {
echo '<div id="info">Моля изберете тема на съобщението!';
$error = 1;
}
elseif(empty($message)) {
echo '<div id="info">Моля попълнете вашето съобщение!';
$error = 1;
}
elseif ($_SESSION['security_code'] == $_POST['security_code'] && !empty($_SESSION['security_code'])) {
if(preg_match("/\.(rar|zip)$/i", $fileatt_name)){
mail('email@abv.bg',$email_type,$info,$headers);
echo '<div id="info">Вашият email беше изпратен успешно!';
unset($_SESSION['security_code']);
}
else {
echo '<div id="info">Невалиден формат на файла, който прикачате!</div>';
$error = 1;
}
}
else {
echo '<div id="info">Грешен код!</div>';
$error = 1;
}
}
?>
<form action="" method="POST">
*вашето име<br/> <input type="text" name="info" value="<? if ($error) {echo $_POST['info']; }?>"/><br/>
*email за обратна връзка<br/> <input type="text" name="email" value="<? if ($error) {echo $_POST['email']; }?>"/><br/><br/>
<select name="email_type">
<option value="none">--- *тема на съобщението ---</option>
<option value="Запитване">запитване</option>
<option value="друго">друго</option>
</select><br/>
*вашето съобщение<br/> <textarea name="message"><? if ($error) {echo $_POST['message']; }?></textarea><br/>
<div id="order">
забележки и упътвания<br/> <textarea name="notes"><? if ($error) {echo $_POST['notes']; }?></textarea><br/>
изпратете ни файлове<br/> (.rar с всички нужни файлове)<br/> <input type="file" name="fileatt"/>
</div>
<div id="code">*въведете кода<br/> <input id="security_code" name="security_code" type="text" maxlength="5"/></div>
<img src="CaptchaSecurityImages.php?width=90&height=30&characters=5" />
<div id="buttons">
<input type="reset" value="изчисти"/>
<input type="submit" value="изпрати" name="submit" />
</div>
</form>