1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
| <?php
session_start();
include ("blocks/bd.php");
if (isset($_GET['id_got'])) {$id_got = $_GET['id_got'];
if ($id_got == '') {unset($id_got);}}
$result = mysql_query ("SELECT title, meta_d, meta_k, text FROM settings WHERE page='zakaz'", $db);
if (!$result)
{
echo "<p>Запрос на выборку данных из базы не прошел. Напишите об этом администратору support@sessiya-na-5.ru. <br>
<strong>Код ошибки: </strong> </p>";
exit (mysql_error());
}
if (mysql_num_rows($result)>0)
{
$myrow = mysql_fetch_array($result);
}
else
{
echo "<p>Информация по запросу не может быть извлечена в таблице нет записей</p>";
}
$admin = 'manager@sessiya-na-5.ru'; // майл-адрес, на который будут приходить письма
if ( isset( $_POST['sendMail'] ) ) {
$user = substr( $_POST['user'], 0, 64 );
$email = substr( $_POST['email'], 0, 64 );
$telk = substr( $_POST['telk'], 0, 64 );
$message = substr( $_POST['message'], 0, 250 );
// обработка ошибок
$error = '';
if ( empty( $user ) ) $error = $error.'<li>Не заполнено поле "Ваше Имя"</li>';
if ( empty( $email ) ) $error = $error.'<li>Не заполнено поле "E-mail"</li>';
if ( empty( $telk ) ) $error = $error.'<li>Не заполнено поле "Контактный телефон"</li>';
if ( !empty( $email ) and !preg_match( "#^[0-9a-z_\-\.]+@[0-9a-z\-\.]+\.[a-z]{2,6}$#i", $email ) )
$error = $error.'<li>поле "E-mail" должно соответствовать формату somebody@somewhere.ru</li>';
if ( !empty( $error ) ) {
$_SESSION['sendMailForm']['error'] = '<p>При заполнении формы были допущены ошибки:</p><ul>'.$error.'</ul>';
$_SESSION['sendMailForm']['user'] = $user;
$_SESSION['sendMailForm']['email'] = $email;
$_SESSION['sendMailForm']['telk'] = $telk;
$_SESSION['sendMailForm']['message'] = $message;
header( 'Location: '.$_SERVER['PHP_SELF'] ); // перенаправление в корневую страницу если есть ошибки
die();
}
// формирование письма
$body = "Id готовой работы:\r\n".$id_got."\r\n\r\n";
$body .= "Выше имя:\r\n".$user."\r\n\r\n";
$body .= "E-MAIL:\r\n".$email."\r\n\r\n";
$body .= "Контактный телефон:\r\n".$telk."\r\n\r\n";
$body .= "Комментарии и требования к работе:\r\n".$message;
$body = quoted_printable_encode( $body );
$theme = '=?windows-1251?B?'.base64_encode('Заполнена форма на сайте - новый заказ').'?=';
$headers = "From: ".$_SERVER['Sessiya-na-5.ru']." <".$email.">\r\n";
$headers = $headers."Return-path: <".$email.">\r\n";
$headers = $headers."Content-type: text/plain; charset=\"windows-1251\"\r\n";
$headers = $headers."Content-Transfer-Encoding: quoted-printable\r\n\r\n";
if ( mail($admin, $theme, $body, $headers) )
$_SESSION['success'] = true;
else
$_SESSION['success'] = false;
header( 'Location: '.$_SERVER['PHP_SELF'] );
die();
}
function quoted_printable_encode ( $string ) {
// rule #2, #3 (leaves space and tab characters in tact)
$string = preg_replace_callback (
'/[^\x21-\x3C\x3E-\x7E\x09\x20]/',
'quoted_printable_encode_character',
$string
);
$newline = "=\r\n"; // '=' + CRLF (rule #4)
// make sure the splitting of lines does not interfere with escaped characters
// (chunk_split fails here)
$string = preg_replace ( '/(.{73}[^=]{0,3})/', '$1'.$newline, $string);
return $string;
}
function quoted_printable_encode_character ( $matches ) {
$character = $matches[0];
return sprintf ( '=%02x', ord ( $character ) );
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta name="description" content="<?php echo $myrow['meta_d'];?>">
<meta name="keywords" content="<?php echo $myrow['meta_k'];?>">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<title><?php echo $myrow['title'];?></title>
<link href="style.css" rel="stylesheet" type="text/css">
<link rel="icon" href="/favicon.ico" type="image/x-icon">
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
</head>
<center>
<body>
<table class="table" border="0">
<tr>
<td colspan="2" class="header"></td>
</tr>
<tr>
<td colspan="2" class="menu"><?php include ("blocks/menu.php");?></td>
</tr>
<tr bordercolor="#00FF66">
<td class="td_left" valign="top" ><?php include ("blocks/leftblock.php");?></td>
<td class="td_right" valign="top">
<?php
if ( isset( $_SESSION['success'] ) ) {
if ( $_SESSION['success'] )
echo '<p>Заказ успешно отправлен</p>';
else
echo '<p>Ошибка при отправке заказа</p>';
unset( $_SESSION['success'] );
}
// если есть ошибки - выводим их
if ( isset( $_SESSION['sendMailForm'] ) ) {
echo $_SESSION['sendMailForm']['error'];
$user = htmlspecialchars ( $_SESSION['sendMailForm']['user'] );
$email = htmlspecialchars ( $_SESSION['sendMailForm']['email'] );
$telk = htmlspecialchars ( $_SESSION['sendMailForm']['telk'] );
$message = htmlspecialchars ( $_SESSION['sendMailForm']['message'] );
$pr ="";
unset( $_SESSION['sendMailForm'] );
} else {
$user = '';
$email = '';
$telk = '';
$message = '';
$pr = '';
}
$sum = mt_rand (1,10);
$result4 = mysql_query("SELECT * FROM value_img WHERE id='$sum'");
$myrow4 = mysql_fetch_array ($result4);
?>
<form name="zakaz" action="<?php echo $_SERVER['PHP_SELF'] ?>" method="POST">
<div class="job_post">
<div class='title_post_all'><strong>Форма заказа</strong></div>
<table width='800' border='0' class='info_post_all'>
<td width="400" colspan="2"><?php echo $myrow['text']; ?></td>
<tr>
<td width="167"></td>
<td width="189"></td>
<td width="400" rowspan="8" valign="top">Комментарий и требования к работе:<br>
<textarea name="message" rows="10" cols="25"><?php echo $message ?></textarea></td>
</tr>
<td>Имя:</td>
<td><input type="text" name="user" maxlength="64" value="<?php echo $user ?>" /></td></tr>
<tr>
<td>E-mail:</td>
<td><input type="text" name="email" maxlength="64" value="<?php echo $email ?>" /></td></tr>
<tr>
<td>Контактный телефон:</td>
<td><input type="text" name="telk" maxlength="64" value="<?php echo $telk ?>" /></td></tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td></td>
<td></td>
<td>
</td></tr>
</td>
</table>
<table width=800 align=center border=0 class='info_post_all'>
<tr><td><center> <?php echo '<img src='.$myrow4["img"].' width="80" height="35"><br>';
echo '<input name="pr" style="margin-bottom:5px;" type="text" size="5" maxlength="2" class="in1">';
echo '<input name="sum" type="hidden" value="'.$myrow4["sum"].'">';?></center></td></tr>
<tr><td><center><input type="submit" name="sendMail" value="Отправить" /></center></td></tr>
</table>
<div class='post_all'></div>
</div>
</form>
</td>
</tr>
<tr>
<td colspan="2" class="footer" valign="center";><?php include ("blocks/footer.php");?></td>
</tr>
<tr>
<td colspan="2" valign="center" align="center";><?php include ("blocks/chet.php");?>
<br>
</td>
</tr>
</table>
</center>
</html> |