From 8e7cc01e756c93d0c2718f2075b3eb7cf8151ef7 Mon Sep 17 00:00:00 2001 From: Tyler Cosgrove Date: Mon, 11 Jul 2016 15:08:42 -0400 Subject: [PATCH 1/2] Add user to config (#913) --- system/src/Grav/Common/User/User.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/system/src/Grav/Common/User/User.php b/system/src/Grav/Common/User/User.php index 3582d0387..9d28aec80 100644 --- a/system/src/Grav/Common/User/User.php +++ b/system/src/Grav/Common/User/User.php @@ -29,7 +29,9 @@ class User extends Data */ public static function load($username) { - $locator = Grav::instance()['locator']; + $grav = Grav::instance(); + $locator = $grav['locator']; + $config = $grav['config']; // force lowercase of username $username = strtolower($username); @@ -48,6 +50,9 @@ class User extends Data $user = new User($content, $blueprint); $user->file($file); + // add user to config + $config->set("user", $user); + return $user; } From 29f6da675dbe91a2578ee1b6a3c44d1279255dd0 Mon Sep 17 00:00:00 2001 From: Flavio Copes Date: Mon, 11 Jul 2016 21:13:25 +0200 Subject: [PATCH 2/2] Cache images loaded from the route (when cache is enabled) (#905) * Cache images loaded from the route (when cache is enabled) * Use GMT instead of +0000 as used in DATE_RFC1123 format --- system/src/Grav/Common/Utils.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/system/src/Grav/Common/Utils.php b/system/src/Grav/Common/Utils.php index 683f17dab..85631966a 100644 --- a/system/src/Grav/Common/Utils.php +++ b/system/src/Grav/Common/Utils.php @@ -270,6 +270,25 @@ abstract class Utils } else { $new_length = $size; header("Content-Length: " . $size); + + if (Grav::instance()['config']->get('system.cache.enabled')) { + $expires = Grav::instance()['config']->get('system.pages.expires'); + if ($expires > 0) { + $expires_date = gmdate('D, d M Y H:i:s T', time() + $expires); + header('Cache-Control: max-age=' . $expires); + header('Expires: ' . $expires_date); + header('Pragma: cache'); + } + header('Last-Modified: ' . gmdate("D, d M Y H:i:s T", filemtime($file))); + + // Return 304 Not Modified if the file is already cached in the browser + if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && + strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) >= filemtime($file)) + { + header('HTTP/1.1 304 Not Modified'); + exit(); + } + } } /* output the file itself */