15 $uri = preg_replace(
'#[/]+$#',
'',
$request);
16 $uri = preg_replace(
'#[/]{2,}#',
'/', $uri);
18 if ($QUERY_STRING = parse_url(
$_SERVER[
'REQUEST_URI'], PHP_URL_QUERY)) {
19 $uri .=
'?' . $QUERY_STRING;
21 header(
"HTTP/1.1 301 Moved Permanently");
22 header(
"Location: $uri");
27 $uri = preg_replace(
'#[/]+$#',
'',
$request);
28 if (file_exists(
$_SERVER[
'DOCUMENT_ROOT'] . $uri)) {
30 require
$_SERVER[
'DOCUMENT_ROOT'] .
'/docs/index.html';
33 require
$_SERVER[
'DOCUMENT_ROOT'] .
'/page/404.php';
36 if ($QUERY_STRING = parse_url(
$_SERVER[
'REQUEST_URI'], PHP_URL_QUERY)) {
37 $uri .=
'?' . $QUERY_STRING;
39 header(
"HTTP/1.1 301 Moved Permanently");
40 header(
"Location: $uri");
44 if (preg_match(
'#index\.(php|html)$#',
$request)) {
45 header(
"HTTP/1.1 301 Moved Permanently");
46 header(
"Location: " . dirname(
$request));
50 if (Wrong\Start\Env::$e->SYSTEM_CLOSED &&
$user->main_group_id != 1) {
54 if (preg_match(
'#^/api/(modal|action|select)/[a-z0-9\-]+#',
$request, $matches)) {
55 if (
$arr = Wrong\Database\Controller::all(
$request,
'request', $matches[1] .
's')) {
58 return $user->access()->read($row);
64 foreach (
$arr as $row) {
65 if (file_exists(
$_SERVER[
'DOCUMENT_ROOT'] . $row->file)) {
66 header(
"X-Robots-Tag: noindex");
69 if (strpos(
$request,
'/api/select') !==
false && $row->cache_time) {
74 register_shutdown_function(
function (
$mem, $timeout) {
75 $mem->set(
$_SERVER[
'REQUEST_URI'], ob_get_contents(), $timeout);
76 },
$mem, $row->cache_time);
79 require
$_SERVER[
'DOCUMENT_ROOT'] . $row->file;
87 if (isset($_GET[
'FROM_UID'])) {
90 if (
$user->access()->page(
'/system')) {
91 header(
"Location: /system");
93 header(
"Location: /");
99 header(
"Location: $user->request");
103 if (preg_match(
'#^/remind/([0-9]+)/([a-z0-9]+)#i',
$request, $matches) && Wrong\Auth\User::is_remind($matches[1], $matches[2])) {
104 header(
"X-Robots-Tag: noindex");
106 _modal("#sign-remind", null, "user_id=' . $matches[1] .
'&md5=' . $matches[2] .
'");
107 history.pushState(null, null, "/");
108 ', 0,
'sign-remind');
112 if (preg_match(
'#^/email-confirm/([0-9]+)/([a-z0-9]+)#i',
$request, $matches) && Wrong\Auth\User::is_confirm($matches[1], $matches[2]) && !
$user->email_confirmed) {
113 header(
"X-Robots-Tag: noindex");
114 Wrong\Task\Stackjs::add(
'history.pushState(null, null, "/");setTimeout(()=>{successToast("Почта успешно подтверждена");},100)', 0,
'email-confirm');
115 $user->set_confirm(1);
116 if (
$user->access()->page(
'/system')) {
117 header(
"Location: /system");
119 header(
"Location: /");
124 if (Wrong\Start\Env::$e->EMAIL_CONFIRMATION &&
$user->id && !
$user->email_confirmed) {
132 return $user->access()->read($row);
138 foreach (
$arr as $row) {
139 if (file_exists(
$_SERVER[
'DOCUMENT_ROOT'] . $row->file)) {
141 ($template = Wrong\Models\Templates::find($row->template_id)) &&
142 $user->access()->read($template) &&
143 file_exists(
$_SERVER[
'DOCUMENT_ROOT'] . $template->file)
145 if ($row->cache_time) {
150 register_shutdown_function(
function (
$mem, $timeout) {
151 $mem->set(
$_SERVER[
'REQUEST_URI'], ob_get_contents(), $timeout);
152 },
$mem, $row->cache_time);
155 if ($template->cache_time) {
160 register_shutdown_function(
function (
$mem, $timeout) {
161 $mem->set(
$_SERVER[
'REQUEST_URI'], ob_get_contents(), $timeout);
162 },
$mem, $template->cache_time);
165 require
$_SERVER[
'DOCUMENT_ROOT'] . $template->file;
166 }
else if (
$request !=
'/forbidden') {
225 require
$_SERVER[
'DOCUMENT_ROOT'] .
'/page/404.php';
User отвечает за работу с данными пользователя
Cache класс, отвечающий за кеширование
static add($code, $timeout=0, $key='')
setcookie('FROM_UID', $uid, [ 'expires'=> time()+31536000, 'path'=> '/', 'domain'=> $_SERVER['HTTP_HOST'], 'secure'=> Wrong\Start\Env::$e->IS_SECURE, 'httponly'=> false, 'samesite'=> Wrong\Start\Env::$e->IS_SECURE ? 'None' :'Lax']) or setcookie('FROM_UID' $_SERVER['HTTP_HOST']
if(($dbh=Connect::getInstance(true) ->dbh) && $dbh->query("SHOW TABLES") ->fetchAll() && $dbh->query("SELECT COUNT(*) FROM `users`") ->fetchColumn()) if(!empty($_POST)) exit
catch(\Throwable $th) $request