This repository has been archived by the owner on Dec 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Site.php
181 lines (139 loc) · 4.45 KB
/
Site.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
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
<?php
class Site {
public static function action_index() {
require_once 'index_module.php';
}
public static function action_contacts_validate() {
header('Content-Type: application/json; charset=utf-8');
if(!array_key_exists('email',$_POST) || !preg_match('/^[^{}^%@\s]{0,50}@[^{}^%@\s.]{0,50}(.[^{}^%@\s]{0,50})+$/',$_POST['email'])){
echo json_encode(['error'=>'Вкажіть правильну електрнну адресу']);
die();
}
if(!array_key_exists('msg',$_POST) || strlen($_POST['msg']) == 0){
echo json_encode(['error'=>'Вкажіть повідомлення']);
die();
}
if(strlen($_POST['msg']) > 5000){
echo json_encode(['error'=>'Максимальна довжина повідомленння: 5000']);
die();
}
if(!array_key_exists('msg',$_POST) || strlen($_POST['msg']) == 0){
echo json_encode(['error'=>'Вкажіть повідомлення']);
die();
}
if(!array_key_exists('name',$_POST) || strlen($_POST['name']) == 0)
$name = '';
else if(strlen($_POST['name']) > 1000)
$name = substr($_POST['name'],0,1000);
else
$name = $_POST['name'];
$email = $_POST['email'];
$msg = $_POST['msg'];
mail(Config::_REAL_EMAIL_,'Нове запитання на сайті '.Config::_NAME_,'Нове запитання на сайті '.Config::_LINK_.'<br><br>Ім\'я: ' . $name . '<br>E-mail: ' . $email . '<br>Msg: ' . $msg,'From: ' . Config::_EMAIL_. "\r\n" .
'Reply-To: ' . Config::_EMAIL_ . "\r\n" .
"MIME-Version: 1.0\r\n".
"Content-Type: text/html; charset=UTF-8\r\n".
'X-Mailer: PHP/' . phpversion());
echo json_encode(['error' => '0']);
}
public static function use_min() {
if(!Config::_DEVELOPMENT_)
return '.min';
else
return '';
}
public static function action_robots() {
header('Content-Type: text/plain');
//TODO: fill in the urls
if(Config::_SEO_)
echo 'User-agent: *
Disallow:
';
else
echo 'User-agent: *
Disallow: /';
}
public static function action_manifest() {
header('Content-Type: application/json; charset=utf-8');
echo '{
"name": "' . Config::_TITLE_ . '",
"short_name": "' . Config::_NAME_ . '",
"theme_color": "' . Config::_BRAND_COLOR_ . '",
"background_color": "' . Config::_BACKGROUND_COLOR_ . '",
"display": "browser",
"Scope": "/",
"start_url": "/",
"icons": [
{
"src": "public/images/icons/android-icon-72x72.png",
"sizes": "72x72",
"type": "image/png"
},
{
"src": "public/images/icons/android-icon-96x96.png",
"sizes": "96x96",
"type": "image/png"
},
{
"src": "public/images/icons/android-icon-128x128.png",
"sizes": "128x128",
"type": "image/png"
},
{
"src": "public/images/icons/android-icon-144x144.png",
"sizes": "144x144",
"type": "image/png"
},
{
"src": "public/images/icons/apple-icon-152x152.png",
"sizes": "152x152",
"type": "image/png"
},
{
"src": "public/images/icons/android-icon-192x192.png",
"sizes": "192x192",
"type": "image/png"
}
],
"splash_pages": null
}';
}
public static function action_favicon() {
header('Content-Type: image/x-icon');
echo file_get_contents(Site::server_link('public/images/icons/favicon.ico'));
}
public static function server_link($path) {
return ROOT . $path;
}
public static function action_google_validation() {
header('Content-Type: text/html');
if($_SERVER['REQUEST_URI'] == '/' . Config::_GOOGLE_SITE_VERIFICATION_)
echo 'google-site-verification: ' . Config::_GOOGLE_SITE_VERIFICATION_;
else {
http_response_code(404);
die();
}
}
//PRIVATE
public static function action_browserconfig() {
//TODO: browserconfig.xml
header('Content-Type: application/xml; charset=utf-8');
echo '<?xml version = "1.0" encoding = "utf-8"?>
<browserconfig>
<msapplication>
<tile>
<square70x70logo src="/ms-icon-70x70.png" />
<square144x144logo src="/android-icon-144x144.png" />
<square150x150logo src="/ms-icon-150x150.png" />
<square310x310logo src="/ms-icon-310x310.png" />
<TileColor>' . Config::_BRAND_COLOR_ . '</TileColor>
</tile>
</msapplication>
</browserconfig>';
}
public static function action_serviceworker() {
//TODO:: serviceworker
header('Content-Type: application/javascript');
echo file_get_contents(Site::server_link('public/scripts/serviceworker' . self::use_min() . '.js'));
}
}