Parcourir la source

Add output of http headers from engine config

The default set is "common". In the admin panel, profile, registration and login - "secury".
Visman il y a 4 ans
Parent
commit
bb385ea147

+ 19 - 11
app/Models/Page.php

@@ -45,16 +45,17 @@ abstract class Page extends Model
         $formats[1]              = __($formats[1]);
         $container->TIME_FORMATS = $formats;
 
-        $this->fIndex       = 'index'; # string      Указатель на активный пункт навигации
-        $this->httpStatus   = 200;     # int         HTTP статус ответа для данной страницы
-#       $this->nameTpl      = null;    # null|string Имя шаблона
-#       $this->titles       = [];      # array       Массив титула страницы | setTitles()
-        $this->fIswev       = [];      # array       Массив info, success, warning, error, validation информации
-#       $this->onlinePos    = '';      # null|string Позиция для таблицы онлайн текущего пользователя
-        $this->onlineDetail = false;   # bool        Формировать данные по посетителям online или нет
-        $this->onlineFilter = true;    # bool        Посетители только по текущей странице или по всем
-#       $this->robots       = '';      # string      Переменная для meta name="robots"
-#       $this->canonical    = '';      # string      Переменная для link rel="canonical"
+        $this->fIndex       = 'index';  # string      Указатель на активный пункт навигации
+        $this->httpStatus   = 200;      # int         HTTP статус ответа для данной страницы
+#       $this->nameTpl      = null;     # null|string Имя шаблона
+#       $this->titles       = [];       # array       Массив титула страницы | setTitles()
+        $this->fIswev       = [];       # array       Массив info, success, warning, error, validation информации
+#       $this->onlinePos    = '';       # null|string Позиция для таблицы онлайн текущего пользователя
+        $this->onlineDetail = false;    # bool        Формировать данные по посетителям online или нет
+        $this->onlineFilter = true;     # bool        Посетители только по текущей странице или по всем
+#       $this->robots       = '';       # string      Переменная для meta name="robots"
+#       $this->canonical    = '';       # string      Переменная для link rel="canonical"
+        $this->hhsLevel     = 'common'; # string      Ключ для $c->HTTP_HEADERS (для вывода заголовков HTTP из конфига)
 
         $this->fTitle       = $container->config->o_board_title;
         $this->fDescription = $container->config->o_board_desc;
@@ -355,7 +356,10 @@ abstract class Page extends Model
 
         if (null === $value) {
             unset($this->httpHeaders[$key]);
-        } elseif (true === $replace || empty($this->httpHeaders[$key])) {
+        } elseif (
+            true === $replace
+            || empty($this->httpHeaders[$key])
+        ) {
             $this->httpHeaders[$key] = [
                 ["{$header} {$value}", $replace],
             ];
@@ -372,6 +376,10 @@ abstract class Page extends Model
      */
     protected function gethttpHeaders(): array
     {
+        foreach ($this->c->HTTP_HEADERS[$this->hhsLevel] as $header => $value) {
+            $this->header($header, $value);
+        }
+
         $this->httpStatus();
 
         return $this->httpHeaders;

+ 1 - 0
app/Models/Pages/Admin.php

@@ -29,6 +29,7 @@ class Admin extends Page
         $this->fIndex    = 'admin';
         $this->onlinePos = 'admin';
         $this->robots    = 'noindex, nofollow';
+        $this->hhsLevel  = 'secure';
 
         $container->Lang->load('admin');
     }

+ 3 - 0
app/Models/Pages/Auth.php

@@ -72,6 +72,7 @@ class Auth extends Page
 
         $ref = $this->c->Secury->replInvalidChars($_SERVER['HTTP_REFERER'] ?? '');
 
+        $this->hhsLevel   = 'secure';
         $this->fIndex     = 'login';
         $this->nameTpl    = 'login';
         $this->onlinePos  = 'login';
@@ -245,6 +246,7 @@ class Auth extends Page
             $this->fIswev = $v->getErrors();
         }
 
+        $this->hhsLevel   = 'secure';
         $this->fIndex     = 'login';
         $this->nameTpl    = 'passphrase_reset';
         $this->onlinePos  = 'passphrase_reset';
@@ -355,6 +357,7 @@ class Auth extends Page
             $this->fIswev = ['i', __('Account activated')];
         }
 
+        $this->hhsLevel   = 'secure';
         $this->fIndex     = 'login';
         $this->nameTpl    = 'change_passphrase';
         $this->onlinePos  = 'change_passphrase';

+ 1 - 0
app/Models/Pages/Profile.php

@@ -37,6 +37,7 @@ abstract class Profile extends Page
 
         $this->c->Lang->load('profile');
 
+        $this->hhsLevel  = 'secure';
         $this->rules     = $this->c->ProfileRules->setUser($this->curUser);
         $this->robots    = 'noindex';
         $this->fIndex    = $this->rules->my ? 'profile' : 'userlist';

+ 1 - 0
app/Models/Pages/Profile/View.php

@@ -25,6 +25,7 @@ class View extends Profile
             return $this->c->Message->message('Bad request');
         }
 
+        $this->hhsLevel   = 'common'; // для остальных страниц профиля уровень задан в initProfile()
         $this->canonical  = $this->curUser->link;
         $this->robots     = null;
         $this->crumbs     = $this->crumbs();

+ 1 - 0
app/Models/Pages/Register.php

@@ -64,6 +64,7 @@ class Register extends Page
             return $this->c->Message->message('Reg cancel', true, 403);
         }
 
+        $this->hhsLevel   = 'secure';
         $this->fIndex     = 'register';
         $this->nameTpl    = 'register';
         $this->onlinePos  = 'register';