-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpost.php
56 lines (52 loc) · 1.79 KB
/
post.php
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
<?php
$admin_email = "[email protected]";
$admin_email = "[email protected]";
$result = array('success' => false);
if(isset($_POST) && isset($_POST['reg_type'])) {
$post = $_POST;
$errors = array();
if(!isset($post['dob']) or !$post['dob']) {
$errors['dob'] = 'Укажите дату рождения';
}
if(!isset($post['email']) or !$post['email']) {
$errors['email'] = 'Укажите email адрес';
}
if(!isset($post['region']) or !$post['region']) {
$errors['region'] = 'Укажите область';
}
switch(@$post['reg_type']) {
case "anonymous":
$body = "email: $post[email]\n region: $post[region]";
break;
case "id_offline":
if(!isset($post['hash']) or !$post['hash']) {
$errors['hash'] = 'Неверно указан один из параметров';
}
$link = mysql_connect('localhost', 'www-data', '') or die('Could not connect to server.');
mysql_select_db('liquid_feedback', $link) or die('Could not select database.');
if (get_magic_quotes_gpc()) {
$hash = stripslashes($post['hash']);
}
$query = mysql_query("SELECT COUNT(*) as count FROM member WHERE identification='".$hash."'");
if($query) while ($row = mysql_fetch_object($query)) {
$result = $row;
}
if($result && $result->count > 0) {
$errors['hash'] = 'Пользователь существует';
}
$body = "email: $post[email]\n region: $post[region]\n hash: $post[hash]";
break;
default:
case "id_online":
$errors['reg_type'] = "Временно не доступно";
break;
}
if(count($errors) > 0) {
$result['errors'] = $errors;
} else {
$result['message'] = $body;
$result['success'] = mail($admin_email, 'LiquidFeedbackUA Registration', $body);
}
}
die(json_encode($result));
?>