Explorar el Código

Delete inline style for phpinfo

https://github.com/forkbb/forkbb/issues/2
Visman hace 4 años
padre
commit
3a9ebb5336
Se han modificado 2 ficheros con 30 adiciones y 1 borrados
  1. 6 0
      app/Controllers/Routing.php
  2. 24 1
      app/Models/Pages/Admin/Statistics.php

+ 6 - 0
app/Controllers/Routing.php

@@ -538,6 +538,12 @@ class Routing
                 'AdminStatistics:info',
                 'AdminInfo'
             );
+            $r->add(
+                $r::GET,
+                '/admin/statistics/info/{time:\d+}',
+                'AdminStatistics:infoCSS',
+                'AdminInfoCSS'
+            );
             $r->add(
                 $r::DUO,
                 '/admin/options',

+ 24 - 1
app/Models/Pages/Admin/Statistics.php

@@ -49,7 +49,12 @@ class Statistics extends Admin
                     },
                     $matches[1]
                 );
-                $this->pageHeader('phpinfo', 'style', [$style]);
+                $this->c->Cache->set('phpinfoCSS', $style);
+                $this->pageHeader('phpinfoStyle', 'link', [
+                    'rel'  => 'stylesheet',
+                    'type' => 'text/css',
+                    'href' => $this->c->Router->link('AdminInfoCSS', ['time' => \time()] ),
+                ]);
             }
         } else {
             $phpinfo = '- - -';
@@ -70,6 +75,24 @@ class Statistics extends Admin
         return $this;
     }
 
+    /**
+     * Возврат css из phpinfo() как файл
+     */
+    public function infoCSS(): Page
+    {
+        $this->c->DEBUG  = 0;
+
+        $this->nameTpl      = 'layouts/plain';
+        $this->plainText    = $this->c->Cache->get('phpinfoCSS', '');
+#        $this->onlinePos    = null;
+        $this->onlineDetail = false;
+        $this->onlineFilter = false;
+
+        $this->header('Content-type', 'text/css; charset=utf-8');
+
+        return $this;
+    }
+
     /**
      * Подготавливает данные для шаблона
      */