From ede84e2cb88371867b2db8b36adb625bbca0e25f Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Sat, 18 Nov 2017 23:54:44 +0100 Subject: [PATCH] fixed problem with hashbang crawling, set expire headers correctly --- api/api_default.php | 6 +++--- files/files.php | 1 + security/security.php | 1 + system/HEADER.php | 12 ++++++------ 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/api/api_default.php b/api/api_default.php index 3bce477..f0ac462 100644 --- a/api/api_default.php +++ b/api/api_default.php @@ -53,7 +53,7 @@ abstract class api_default extends api_system implements api_default_interface { public static function static__escaped_fragment_($_escaped_fragment_){ \libxml_use_internal_errors(true); $html = new \DOMDocument(); - $html->loadHTML(static::default_page($_escaped_fragment_ ? $_escaped_fragment_ : true)); + $html->loadHTML(static::default_page($_escaped_fragment_ ? $_escaped_fragment_ : true),LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); if($error = \libxml_get_last_error()){ //new \SYSTEM\LOG\ERROR('Parse Error: '.$error->message.' line:'.$error->line.' html: '.$html->saveHTML()); \libxml_clear_errors();} @@ -63,7 +63,7 @@ abstract class api_default extends api_system implements api_default_interface { parse_str(\parse_url($row['url'],PHP_URL_QUERY), $params); $class = static::get_class(); if($class){ - $frag->loadHTML(mb_convert_encoding(\SYSTEM\API\api::run('\SYSTEM\API\verify', $class, $params, static::get_apigroup(), true, false),'HTML-ENTITIES', 'UTF-8')); + $frag->loadHTML(mb_convert_encoding(\SYSTEM\API\api::run('\SYSTEM\API\verify', $class, $params, static::get_apigroup(), true, false),'HTML-ENTITIES', 'UTF-8'),LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); if($error = \libxml_get_last_error()){ //new \SYSTEM\LOG\ERROR('Parse Error: '.$error->message.' line:'.$error->line.' html: '.$frag->saveHTML()); \libxml_clear_errors();} @@ -71,7 +71,7 @@ abstract class api_default extends api_system implements api_default_interface { //Load subpage css foreach($row['css'] as $css){ $css_frag = new \DOMDocument(); - $css_frag->loadHTML(''); + $css_frag->loadHTML('',LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); $html->getElementsByTagName('head')[0]->appendChild($html->importNode($css_frag->documentElement,true)); } } diff --git a/files/files.php b/files/files.php index 8a59562..0fa0986 100644 --- a/files/files.php +++ b/files/files.php @@ -56,6 +56,7 @@ class files { call_user_func('\SYSTEM\HEADER::'.$ext); }else{ \SYSTEM\HEADER::FILE($id);} + \session_cache_limiter('private_no_expire'); header("Last-Modified: " . gmdate('D, d M Y H:i:s \G\M\T', filemtime(self::$folders[$cat].$id))); //Allow Caching for all files diff --git a/security/security.php b/security/security.php index 52463ea..55d3de8 100644 --- a/security/security.php +++ b/security/security.php @@ -356,6 +356,7 @@ class security { */ protected static function startSession(){ if(!isset($_SESSION) && !headers_sent()){ + //\session_cache_limiter('private_no_expire'); \session_start();} //respect locale from db if not set(right place here?) if( isset($_SESSION[\SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_PATH_BASEURL)]) && diff --git a/system/HEADER.php b/system/HEADER.php index 42940ab..c86c865 100644 --- a/system/HEADER.php +++ b/system/HEADER.php @@ -56,7 +56,7 @@ class HEADER { */ public static function PNG(){ if(self::checkHeader()){ - header('Expires: '.gmdate('D, d M Y H:i:s \G\M\T', time() + (60 * 60 * 24 * 7))); // 1 week + //header('Expires: '.gmdate('D, d M Y H:i:s \G\M\T', time() + (60 * 60 * 24 * 7*4*52))); // 1 week header('content-type:image/png');}} /** * Send JPG Headers, if Header was not sent yet @@ -65,7 +65,7 @@ class HEADER { */ public static function JPG(){ if(self::checkHeader()){ - header('Expires: '.gmdate('D, d M Y H:i:s \G\M\T', time() + (60 * 60 * 24 * 7))); // 1 week + //header('Expires: '.gmdate('D, d M Y H:i:s \G\M\T', time() + (60 * 60 * 24 * 7))); // 1 week header('content-type:image/jpeg');}} /** * Send JPEG Headers, if Header was not sent yet @@ -74,7 +74,7 @@ class HEADER { */ public static function JPEG(){ if(self::checkHeader()){ - header('Expires: '.gmdate('D, d M Y H:i:s \G\M\T', time() + (60 * 60 * 24 * 7))); // 1 week + //header('Expires: '.gmdate('D, d M Y H:i:s \G\M\T', time() + (60 * 60 * 24 * 7))); // 1 week header('content-type:image/jpeg');}} /** * Send GIF Headers, if Header was not sent yet @@ -83,7 +83,7 @@ class HEADER { */ public static function GIF(){ if(self::checkHeader()){ - header('Expires: '.gmdate('D, d M Y H:i:s \G\M\T', time() + (60 * 60 * 24 * 7))); // 1 week + //header('Expires: '.gmdate('D, d M Y H:i:s \G\M\T', time() + (60 * 60 * 24 * 7))); // 1 week header('content-type:image/gif');}} /** * Send JS Headers, if Header was not sent yet @@ -92,7 +92,7 @@ class HEADER { */ public static function JS(){ if(self::checkHeader()){ - header('Expires: '.gmdate('D, d M Y H:i:s \G\M\T', time() + (60 * 60 * 24 * 7))); // 1 week + //header('Expires: '.gmdate('D, d M Y H:i:s \G\M\T', time() + (60 * 60 * 24 * 7))); // 1 week header('content-type:application/javascript');}} /** * Send CSS Headers, if Header was not sent yet @@ -101,7 +101,7 @@ class HEADER { */ public static function CSS(){ if(self::checkHeader()){ - header('Expires: '.gmdate('D, d M Y H:i:s \G\M\T', time() + (60 * 60 * 24 * 7))); // 1 week + //header('Expires: '.gmdate('D, d M Y H:i:s \G\M\T', time() + (60 * 60 * 24 * 7))); // 1 week header('content-type:text/css');}} /** * Send LESS Headers, if Header was not sent yet