Completed
Push — master ( d13b22...a2d243 )
by Justin
05:45
created
system/packages/com.jukusoft.cms.htmlpage/classes/error403page.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@
 block discarded – undo
27 27
 
28 28
 class Error403Page extends HTMLPage {
29 29
 
30
-	public function setCustomHeader () {
30
+	public function setCustomHeader() {
31 31
 		//set error 403 forbidden header
32 32
 		header('HTTP/1.0 403 Forbidden');
33 33
 	}
Please login to merge, or discard this patch.
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -27,26 +27,26 @@
 block discarded – undo
27 27
 
28 28
 class Error403Page extends HTMLPage {
29 29
 
30
-	public function setCustomHeader () {
31
-		//set error 403 forbidden header
32
-		header('HTTP/1.0 403 Forbidden');
33
-	}
34
-
35
-	public function getContent(): string {
36
-		//first check, if specific template exists
37
-		$current_style = Registry::singleton()->getSetting("current_style_name");
38
-		if (file_exists(STYLE_PATH . $current_style . "/pages/error403.tpl")) {
39
-			$template = new Template($this->getPage()->hasCustomTemplate() ? $this->getPage()->getCustomTemplate() : "pages/error403");
40
-
41
-			$template->assign("TITLE", $this->getPage()->getTitle());
42
-			$template->assign("CONTENT", parent::getContent());
43
-
44
-			$template->parse("main");
45
-			return $template->getCode();
46
-		} else {
47
-			return parent::getContent();
48
-		}
49
-	}
30
+    public function setCustomHeader () {
31
+        //set error 403 forbidden header
32
+        header('HTTP/1.0 403 Forbidden');
33
+    }
34
+
35
+    public function getContent(): string {
36
+        //first check, if specific template exists
37
+        $current_style = Registry::singleton()->getSetting("current_style_name");
38
+        if (file_exists(STYLE_PATH . $current_style . "/pages/error403.tpl")) {
39
+            $template = new Template($this->getPage()->hasCustomTemplate() ? $this->getPage()->getCustomTemplate() : "pages/error403");
40
+
41
+            $template->assign("TITLE", $this->getPage()->getTitle());
42
+            $template->assign("CONTENT", parent::getContent());
43
+
44
+            $template->parse("main");
45
+            return $template->getCode();
46
+        } else {
47
+            return parent::getContent();
48
+        }
49
+    }
50 50
 
51 51
 }
52 52
 
Please login to merge, or discard this patch.
system/packages/com.jukusoft.cms.style/classes/stylerules.php 2 patches
Indentation   +215 added lines, -215 removed lines patch added patch discarded remove patch
@@ -18,225 +18,225 @@
 block discarded – undo
18 18
 
19 19
 class StyleRules {
20 20
 
21
-	protected static $rules = array();
22
-	protected static $initialized = false;
23
-
24
-	protected static $allowed_types = array("DOMAIN", "FOLDER", "MEDIA", "LANGUAGE");
25
-
26
-	/**
27
-	 * default constructor
28
-	 */
29
-	public function __construct() {
30
-		//
31
-	}
32
-
33
-	public static function getStyle (Registry &$registry, string $default_style_name) : string {
34
-		//load all rules, if absent
35
-		self::initIfAbsent();
36
-
37
-		return self::applyRules(-1, $registry, $default_style_name);
38
-	}
39
-
40
-	protected static function applyRules (int $parentID, Registry &$registry, $default_value) : string {
41
-		if (!isset(self::$rules[$parentID])) {
42
-			//parentID isnt set in array
43
-			return $default_value;
44
-		}
45
-
46
-		//get all root rules
47
-		$root_rules = self::$rules[$parentID];
48
-
49
-		$style_name = $default_value;
50
-
51
-		//iterate through rules
52
-		foreach ($root_rules as $rule) {
53
-			$type = $rule['type'];
54
-			$expected_value = $rule['expected_value'];
55
-
56
-			//validate condition
57
-			if (self::checkCondition($type, $expected_value, $registry)) {
58
-				//set new default value
59
-				$style_name = $rule['style_name'];
60
-				$parentID = $rule['rule_id'];
61
-
62
-				//search for next rules
63
-				return self::applyRules($parentID, $registry, $style_name);
64
-
65
-				break;
66
-			}
67
-		}
68
-
69
-		return $style_name;
70
-	}
71
-
72
-	/**
73
-	 * check, if a condition is true
74
-	 *
75
-	 * @param $type condition type ("DOMAIN", "FOLDER", "MEDIA", "LANGUAGE")
76
-	 * @param $expected_value expected value
77
-	 * @param $registry instance of Registry
78
-	 *
79
-	 * @return true, if condition is true
80
-	 */
81
-	public static function checkCondition (string $type, string $expected_value, Registry &$registry) : bool {
82
-		$type = strtoupper($type);
83
-
84
-		//check, if condition type is allowed
85
-		if (!in_array($type, self::$allowed_types)) {
86
-			throw new IllegalArgumentException("condition type '" . $type . "' is unknown.");
87
-		}
88
-
89
-		//TODO: check condition
90
-		switch ($type) {
91
-			case "DOMAIN":
92
-				//get current domain
93
-				$current_domain = $registry->getSetting("domain_name");
94
-
95
-				//compare expected domain with
96
-				return strcmp($current_domain, $expected_value) === 0;
97
-
98
-				break;
99
-			case "FOLDER":
100
-				$page_folder = $registry->getSetting("folder");
101
-
102
-				return PHPUtils::startsWith($page_folder, $expected_value);
103
-
104
-				break;
105
-			case "MEDIA":
106
-				switch (strtoupper($expected_value)) {
107
-					case "MOBILE":
108
-						//mobile devices (mbile phone / tablet)
109
-						return $registry->getSetting("isMobile");
110
-
111
-						break;
112
-					case "MOBILE_PHONE":
113
-						//mobile phone (iOS / android phone)
114
-						return Browser::isMobilePhone();
115
-
116
-						break;
117
-					case "TABLET":
118
-						//tablet (iPad / android tablet)
119
-						return Browser::isTablet();
120
-
121
-						break;
122
-					case "DESKTOP":
123
-						//desktop browsers
124
-						return !$registry->getSetting("isMobile");
125
-
126
-						break;
127
-					case "ANDROID":
128
-						//android phones & tablets
129
-						return Browser::isAndroid();
130
-
131
-						break;
132
-					case "IOS":
133
-						//iPod / iPhone / iPad
134
-						return Browser::isAppleiOS();
135
-
136
-						break;
137
-					case "ALL":
138
-						//all devices
139
-						return true;
140
-
141
-						break;
142
-				}
143
-
144
-				break;
145
-			case "PREF_LANG":
146
-				//get prefered user language token
147
-				$lang_token = Lang::getPrefLangToken();
148
-
149
-				return strcmp($lang_token, strtolower($expected_value)) == 0;
150
-
151
-				break;
152
-			case "SUPPORTED_LANG":
153
-				//get current user language token
154
-				$lang_tokens = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
155
-
156
-				//check, if language is supported by browser
157
-				return stripos($lang_tokens, $expected_value) !== false;
158
-
159
-				break;
160
-			case "DEFAULT":
161
-				//default value, if all other conditions are false
162
-				return true;
163
-
164
-				break;
165
-			default:
166
-				throw new IllegalStateException("Unknown style rule type: " . $type);
167
-				break;
168
-		}
169
-	}
170
-
171
-	public static function loadAllRules () {
172
-		if (Cache::contains("style", "style-rules")) {
173
-			self::$rules = Cache::get("style", "style-rules");
174
-		} else {
175
-			//get all style rules from database
176
-			$rows = Database::getInstance()->listRows("SELECT * FROM `{praefix}style_rules` WHERE `activated` = '1' ORDER BY `order`; ");
177
-
178
-			$rules = array();
179
-
180
-			foreach ($rows as $row) {
181
-				$parentID = $row['parent'];
182
-
183
-				if (!isset($rules[$parentID])) {
184
-					$rules[$parentID] = array();
185
-				}
186
-
187
-				$rules[$parentID][] = $row;
188
-			}
189
-
190
-			if (!isset($rules[-1])) {
191
-				$rules[-1] = array();
192
-			}
193
-
194
-			self::$rules = $rules;
195
-
196
-			//cache array
197
-			Cache::put("style", "style-rules", self::$rules);
198
-		}
199
-
200
-		//set initialized flag
201
-		self::$initialized = true;
202
-	}
203
-
204
-	protected static function initIfAbsent () {
205
-		if (!self::$initialized) {
206
-			self::loadAllRules();
207
-		}
208
-	}
209
-
210
-	public static function createRuleWithPredefinedID (int $ruleID, string $type, string $expected_value, string $style_name, int $parent = -1, int $order = 10) {
211
-		$type = strtoupper($type);
212
-
213
-		if ($type !== "DOMAIN" && $type !== "FOLDER" && $type !== "MEDIA" && $type !== "PREF_LANG" && $type !== "SUPPORTED_LANG") {
214
-			throw new IllegalArgumentException("unknown style rule type '" , $type . "'!");
215
-		}
216
-
217
-		Database::getInstance()->execute("INSERT INTO `{praefix}style_rules` (
21
+    protected static $rules = array();
22
+    protected static $initialized = false;
23
+
24
+    protected static $allowed_types = array("DOMAIN", "FOLDER", "MEDIA", "LANGUAGE");
25
+
26
+    /**
27
+     * default constructor
28
+     */
29
+    public function __construct() {
30
+        //
31
+    }
32
+
33
+    public static function getStyle (Registry &$registry, string $default_style_name) : string {
34
+        //load all rules, if absent
35
+        self::initIfAbsent();
36
+
37
+        return self::applyRules(-1, $registry, $default_style_name);
38
+    }
39
+
40
+    protected static function applyRules (int $parentID, Registry &$registry, $default_value) : string {
41
+        if (!isset(self::$rules[$parentID])) {
42
+            //parentID isnt set in array
43
+            return $default_value;
44
+        }
45
+
46
+        //get all root rules
47
+        $root_rules = self::$rules[$parentID];
48
+
49
+        $style_name = $default_value;
50
+
51
+        //iterate through rules
52
+        foreach ($root_rules as $rule) {
53
+            $type = $rule['type'];
54
+            $expected_value = $rule['expected_value'];
55
+
56
+            //validate condition
57
+            if (self::checkCondition($type, $expected_value, $registry)) {
58
+                //set new default value
59
+                $style_name = $rule['style_name'];
60
+                $parentID = $rule['rule_id'];
61
+
62
+                //search for next rules
63
+                return self::applyRules($parentID, $registry, $style_name);
64
+
65
+                break;
66
+            }
67
+        }
68
+
69
+        return $style_name;
70
+    }
71
+
72
+    /**
73
+     * check, if a condition is true
74
+     *
75
+     * @param $type condition type ("DOMAIN", "FOLDER", "MEDIA", "LANGUAGE")
76
+     * @param $expected_value expected value
77
+     * @param $registry instance of Registry
78
+     *
79
+     * @return true, if condition is true
80
+     */
81
+    public static function checkCondition (string $type, string $expected_value, Registry &$registry) : bool {
82
+        $type = strtoupper($type);
83
+
84
+        //check, if condition type is allowed
85
+        if (!in_array($type, self::$allowed_types)) {
86
+            throw new IllegalArgumentException("condition type '" . $type . "' is unknown.");
87
+        }
88
+
89
+        //TODO: check condition
90
+        switch ($type) {
91
+            case "DOMAIN":
92
+                //get current domain
93
+                $current_domain = $registry->getSetting("domain_name");
94
+
95
+                //compare expected domain with
96
+                return strcmp($current_domain, $expected_value) === 0;
97
+
98
+                break;
99
+            case "FOLDER":
100
+                $page_folder = $registry->getSetting("folder");
101
+
102
+                return PHPUtils::startsWith($page_folder, $expected_value);
103
+
104
+                break;
105
+            case "MEDIA":
106
+                switch (strtoupper($expected_value)) {
107
+                    case "MOBILE":
108
+                        //mobile devices (mbile phone / tablet)
109
+                        return $registry->getSetting("isMobile");
110
+
111
+                        break;
112
+                    case "MOBILE_PHONE":
113
+                        //mobile phone (iOS / android phone)
114
+                        return Browser::isMobilePhone();
115
+
116
+                        break;
117
+                    case "TABLET":
118
+                        //tablet (iPad / android tablet)
119
+                        return Browser::isTablet();
120
+
121
+                        break;
122
+                    case "DESKTOP":
123
+                        //desktop browsers
124
+                        return !$registry->getSetting("isMobile");
125
+
126
+                        break;
127
+                    case "ANDROID":
128
+                        //android phones & tablets
129
+                        return Browser::isAndroid();
130
+
131
+                        break;
132
+                    case "IOS":
133
+                        //iPod / iPhone / iPad
134
+                        return Browser::isAppleiOS();
135
+
136
+                        break;
137
+                    case "ALL":
138
+                        //all devices
139
+                        return true;
140
+
141
+                        break;
142
+                }
143
+
144
+                break;
145
+            case "PREF_LANG":
146
+                //get prefered user language token
147
+                $lang_token = Lang::getPrefLangToken();
148
+
149
+                return strcmp($lang_token, strtolower($expected_value)) == 0;
150
+
151
+                break;
152
+            case "SUPPORTED_LANG":
153
+                //get current user language token
154
+                $lang_tokens = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
155
+
156
+                //check, if language is supported by browser
157
+                return stripos($lang_tokens, $expected_value) !== false;
158
+
159
+                break;
160
+            case "DEFAULT":
161
+                //default value, if all other conditions are false
162
+                return true;
163
+
164
+                break;
165
+            default:
166
+                throw new IllegalStateException("Unknown style rule type: " . $type);
167
+                break;
168
+        }
169
+    }
170
+
171
+    public static function loadAllRules () {
172
+        if (Cache::contains("style", "style-rules")) {
173
+            self::$rules = Cache::get("style", "style-rules");
174
+        } else {
175
+            //get all style rules from database
176
+            $rows = Database::getInstance()->listRows("SELECT * FROM `{praefix}style_rules` WHERE `activated` = '1' ORDER BY `order`; ");
177
+
178
+            $rules = array();
179
+
180
+            foreach ($rows as $row) {
181
+                $parentID = $row['parent'];
182
+
183
+                if (!isset($rules[$parentID])) {
184
+                    $rules[$parentID] = array();
185
+                }
186
+
187
+                $rules[$parentID][] = $row;
188
+            }
189
+
190
+            if (!isset($rules[-1])) {
191
+                $rules[-1] = array();
192
+            }
193
+
194
+            self::$rules = $rules;
195
+
196
+            //cache array
197
+            Cache::put("style", "style-rules", self::$rules);
198
+        }
199
+
200
+        //set initialized flag
201
+        self::$initialized = true;
202
+    }
203
+
204
+    protected static function initIfAbsent () {
205
+        if (!self::$initialized) {
206
+            self::loadAllRules();
207
+        }
208
+    }
209
+
210
+    public static function createRuleWithPredefinedID (int $ruleID, string $type, string $expected_value, string $style_name, int $parent = -1, int $order = 10) {
211
+        $type = strtoupper($type);
212
+
213
+        if ($type !== "DOMAIN" && $type !== "FOLDER" && $type !== "MEDIA" && $type !== "PREF_LANG" && $type !== "SUPPORTED_LANG") {
214
+            throw new IllegalArgumentException("unknown style rule type '" , $type . "'!");
215
+        }
216
+
217
+        Database::getInstance()->execute("INSERT INTO `{praefix}style_rules` (
218 218
 			`rule_id`, `type`, `expected_value`, `style_name`, `parent`, `order`, `activated`
219 219
 		) VALUES (
220 220
 			:ruleID, :type, :value, :style, :parent, :order, '1'
221 221
 		) ON DUPLICATE KEY UPDATE `order` = :order; ", array(
222
-			'ruleID' => $ruleID,
223
-			'type' => $type,
224
-			'value' => $expected_value,
225
-			'style' => $style_name,
226
-			'parent' => $parent,
227
-			'order' => $order
228
-		));
229
-
230
-		//clear cache
231
-		Cache::clear("style", "style-rules");
232
-	}
233
-
234
-	public static function deleteRule (int $ruleID) {
235
-		Database::getInstance()->execute("DELETE FROM `{praefix}style_rules` WHERE `rule_id` = :ruleID; ", array('ruleID' => $ruleID));
236
-
237
-		//clear cache
238
-		Cache::clear("style", "style-rules");
239
-	}
222
+            'ruleID' => $ruleID,
223
+            'type' => $type,
224
+            'value' => $expected_value,
225
+            'style' => $style_name,
226
+            'parent' => $parent,
227
+            'order' => $order
228
+        ));
229
+
230
+        //clear cache
231
+        Cache::clear("style", "style-rules");
232
+    }
233
+
234
+    public static function deleteRule (int $ruleID) {
235
+        Database::getInstance()->execute("DELETE FROM `{praefix}style_rules` WHERE `rule_id` = :ruleID; ", array('ruleID' => $ruleID));
236
+
237
+        //clear cache
238
+        Cache::clear("style", "style-rules");
239
+    }
240 240
 
241 241
 }
242 242
 
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -30,14 +30,14 @@  discard block
 block discarded – undo
30 30
 		//
31 31
 	}
32 32
 
33
-	public static function getStyle (Registry &$registry, string $default_style_name) : string {
33
+	public static function getStyle(Registry &$registry, string $default_style_name) : string {
34 34
 		//load all rules, if absent
35 35
 		self::initIfAbsent();
36 36
 
37 37
 		return self::applyRules(-1, $registry, $default_style_name);
38 38
 	}
39 39
 
40
-	protected static function applyRules (int $parentID, Registry &$registry, $default_value) : string {
40
+	protected static function applyRules(int $parentID, Registry &$registry, $default_value) : string {
41 41
 		if (!isset(self::$rules[$parentID])) {
42 42
 			//parentID isnt set in array
43 43
 			return $default_value;
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	 *
79 79
 	 * @return true, if condition is true
80 80
 	 */
81
-	public static function checkCondition (string $type, string $expected_value, Registry &$registry) : bool {
81
+	public static function checkCondition(string $type, string $expected_value, Registry &$registry) : bool {
82 82
 		$type = strtoupper($type);
83 83
 
84 84
 		//check, if condition type is allowed
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 		}
169 169
 	}
170 170
 
171
-	public static function loadAllRules () {
171
+	public static function loadAllRules() {
172 172
 		if (Cache::contains("style", "style-rules")) {
173 173
 			self::$rules = Cache::get("style", "style-rules");
174 174
 		} else {
@@ -201,17 +201,17 @@  discard block
 block discarded – undo
201 201
 		self::$initialized = true;
202 202
 	}
203 203
 
204
-	protected static function initIfAbsent () {
204
+	protected static function initIfAbsent() {
205 205
 		if (!self::$initialized) {
206 206
 			self::loadAllRules();
207 207
 		}
208 208
 	}
209 209
 
210
-	public static function createRuleWithPredefinedID (int $ruleID, string $type, string $expected_value, string $style_name, int $parent = -1, int $order = 10) {
210
+	public static function createRuleWithPredefinedID(int $ruleID, string $type, string $expected_value, string $style_name, int $parent = -1, int $order = 10) {
211 211
 		$type = strtoupper($type);
212 212
 
213 213
 		if ($type !== "DOMAIN" && $type !== "FOLDER" && $type !== "MEDIA" && $type !== "PREF_LANG" && $type !== "SUPPORTED_LANG") {
214
-			throw new IllegalArgumentException("unknown style rule type '" , $type . "'!");
214
+			throw new IllegalArgumentException("unknown style rule type '", $type . "'!");
215 215
 		}
216 216
 
217 217
 		Database::getInstance()->execute("INSERT INTO `{praefix}style_rules` (
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 		Cache::clear("style", "style-rules");
232 232
 	}
233 233
 
234
-	public static function deleteRule (int $ruleID) {
234
+	public static function deleteRule(int $ruleID) {
235 235
 		Database::getInstance()->execute("DELETE FROM `{praefix}style_rules` WHERE `rule_id` = :ruleID; ", array('ruleID' => $ruleID));
236 236
 
237 237
 		//clear cache
Please login to merge, or discard this patch.
css.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 
100 100
 //http://blog.franky.ws/php-und-das-caching-via-http-header-etag/
101 101
 
102
-$cache_strategy = Settings::get("css_cache_strategy", "expires_header");//etag / expires
102
+$cache_strategy = Settings::get("css_cache_strategy", "expires_header"); //etag / expires
103 103
 
104 104
 //intelligent caching
105 105
 if (file_exists($css_cache_path)) {
@@ -114,19 +114,19 @@  discard block
 block discarded – undo
114 114
 		header("Cache-Control: max-age=" . $seconds_to_cache);
115 115
 	} else if ($cache_strategy === "etag_header") {
116 116
 		//get the last-modified-date of this very file
117
-		$lastModified=filemtime($css_cache_path);
117
+		$lastModified = filemtime($css_cache_path);
118 118
 
119 119
 		//get a unique hash of this file (etag)
120 120
 		$etagFile = md5_file($css_cache_path);
121 121
 
122 122
 		//get the HTTP_IF_MODIFIED_SINCE header if set
123
-		$ifModifiedSince=(isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? $_SERVER['HTTP_IF_MODIFIED_SINCE'] : false);
123
+		$ifModifiedSince = (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? $_SERVER['HTTP_IF_MODIFIED_SINCE'] : false);
124 124
 
125 125
 		//get the HTTP_IF_NONE_MATCH header if set (etag: unique file hash)
126
-		$etagHeader=(isset($_SERVER['HTTP_IF_NONE_MATCH']) ? trim($_SERVER['HTTP_IF_NONE_MATCH']) : false);
126
+		$etagHeader = (isset($_SERVER['HTTP_IF_NONE_MATCH']) ? trim($_SERVER['HTTP_IF_NONE_MATCH']) : false);
127 127
 
128 128
 		//set last-modified header
129
-		header("Last-Modified: ".gmdate("D, d M Y H:i:s", $lastModified)." GMT");
129
+		header("Last-Modified: " . gmdate("D, d M Y H:i:s", $lastModified) . " GMT");
130 130
 
131 131
 		//set etag-header
132 132
 		header("Etag: $etagFile");
Please login to merge, or discard this patch.
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -35,9 +35,9 @@  discard block
 block discarded – undo
35 35
 
36 36
 //reset OpCache in debug mode
37 37
 if (CLEAR_OP_CACHE) {
38
-	//http://php.net/manual/en/function.opcache-reset.php
39
-	//http://php.net/manual/en/function.opcache-invalidate.php
40
-	opcache_reset();
38
+    //http://php.net/manual/en/function.opcache-reset.php
39
+    //http://php.net/manual/en/function.opcache-invalidate.php
40
+    opcache_reset();
41 41
 }
42 42
 
43 43
 ob_start("ob_gzhandler");
@@ -53,8 +53,8 @@  discard block
 block discarded – undo
53 53
 
54 54
 //get required style
55 55
 if (!isset($_REQUEST['style']) || empty($_REQUEST['style'])) {
56
-	echo "No style set. Use css.php?style=your-style-name .";
57
-	exit;
56
+    echo "No style set. Use css.php?style=your-style-name .";
57
+    exit;
58 58
 }
59 59
 
60 60
 $style = $_REQUEST['style'];
@@ -65,34 +65,34 @@  discard block
 block discarded – undo
65 65
 $validator = new Validator_Filename();
66 66
 
67 67
 if (!$validator->isValide($style)) {
68
-	echo "Invalide style name '" . htmlentities($style) . "' (only allowed characters: a-z, A-Z and 0-9)!";
69
-	exit;
68
+    echo "Invalide style name '" . htmlentities($style) . "' (only allowed characters: a-z, A-Z and 0-9)!";
69
+    exit;
70 70
 }
71 71
 
72 72
 $style = $validator->validate($style);
73 73
 
74 74
 //check, if style exists
75 75
 if (!file_exists(STYLE_PATH . $style)) {
76
-	echo "Style '" . $style . "' doesnt exists!";
77
-	exit;
76
+    echo "Style '" . $style . "' doesnt exists!";
77
+    exit;
78 78
 }
79 79
 
80 80
 if (isset($_REQUEST['media']) && !empty($_REQUEST['media'])) {
81
-	if (!$validator->isValide($_REQUEST['media'])) {
82
-		echo "Invalide media '" . htmlentities($_REQUEST['media']) . "'!";
83
-		exit;
84
-	}
81
+    if (!$validator->isValide($_REQUEST['media'])) {
82
+        echo "Invalide media '" . htmlentities($_REQUEST['media']) . "'!";
83
+        exit;
84
+    }
85 85
 
86
-	$media = $validator->validate($_REQUEST['media']);
86
+    $media = $validator->validate($_REQUEST['media']);
87 87
 }
88 88
 
89 89
 if (isset($_REQUEST['position']) && !empty($_REQUEST['position'])) {
90
-	if (!$validator->isValide($_REQUEST['position'])) {
91
-		echo "Invalide position '" . htmlentities($_REQUEST['position']) . "'!";
92
-		exit;
93
-	}
90
+    if (!$validator->isValide($_REQUEST['position'])) {
91
+        echo "Invalide position '" . htmlentities($_REQUEST['position']) . "'!";
92
+        exit;
93
+    }
94 94
 
95
-	$position = $validator->validate($_REQUEST['position']);
95
+    $position = $validator->validate($_REQUEST['position']);
96 96
 }
97 97
 
98 98
 //create css builder
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 
104 104
 //generate css file, if neccessary
105 105
 if (!$css_builder->existsCache($style, $media, $position)) {
106
-	$css_builder->generateCSS($style, $media, $position);
106
+    $css_builder->generateCSS($style, $media, $position);
107 107
 }
108 108
 
109 109
 //http://blog.franky.ws/php-und-das-caching-via-http-header-etag/
@@ -112,48 +112,48 @@  discard block
 block discarded – undo
112 112
 
113 113
 //intelligent caching
114 114
 if (file_exists($css_cache_path)) {
115
-	if ($cache_strategy === "expires_header") {
116
-		//https://www.electrictoolbox.com/php-caching-headers/
117
-
118
-		//set expires header, so browser can cache this css file
119
-		$seconds_to_cache = (int) Settings::get("css_cache_expires_header_ttl", "31536000");
120
-		$ts = gmdate("D, d M Y H:i:s", time() + $seconds_to_cache) . " GMT";
121
-		header("Expires: " . $ts);
122
-		header("Pragma: cache");
123
-		header("Cache-Control: max-age=" . $seconds_to_cache);
124
-	} else if ($cache_strategy === "etag_header") {
125
-		//get the last-modified-date of this very file
126
-		$lastModified=filemtime($css_cache_path);
127
-
128
-		//get a unique hash of this file (etag)
129
-		$etagFile = md5_file($css_cache_path);
130
-
131
-		//get the HTTP_IF_MODIFIED_SINCE header if set
132
-		$ifModifiedSince=(isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? $_SERVER['HTTP_IF_MODIFIED_SINCE'] : false);
133
-
134
-		//get the HTTP_IF_NONE_MATCH header if set (etag: unique file hash)
135
-		$etagHeader=(isset($_SERVER['HTTP_IF_NONE_MATCH']) ? trim($_SERVER['HTTP_IF_NONE_MATCH']) : false);
136
-
137
-		//set last-modified header
138
-		header("Last-Modified: ".gmdate("D, d M Y H:i:s", $lastModified)." GMT");
139
-
140
-		//set etag-header
141
-		header("Etag: $etagFile");
142
-
143
-		//make sure caching is turned on
144
-		header('Cache-Control: public');
145
-
146
-		//check if page has changed. If not, send 304 and exit
147
-		if (@strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == $lastModified || $etagHeader == $etagFile) {
148
-			header("HTTP/1.1 304 Not Modified");
149
-			exit;
150
-		}
151
-	} else if ($cache_strategy === "none") {
152
-		//dont set browser cache header
153
-	} else {
154
-		echo "Unknown css_cache_strategy '" . $cache_strategy . "'!";
155
-		exit;
156
-	}
115
+    if ($cache_strategy === "expires_header") {
116
+        //https://www.electrictoolbox.com/php-caching-headers/
117
+
118
+        //set expires header, so browser can cache this css file
119
+        $seconds_to_cache = (int) Settings::get("css_cache_expires_header_ttl", "31536000");
120
+        $ts = gmdate("D, d M Y H:i:s", time() + $seconds_to_cache) . " GMT";
121
+        header("Expires: " . $ts);
122
+        header("Pragma: cache");
123
+        header("Cache-Control: max-age=" . $seconds_to_cache);
124
+    } else if ($cache_strategy === "etag_header") {
125
+        //get the last-modified-date of this very file
126
+        $lastModified=filemtime($css_cache_path);
127
+
128
+        //get a unique hash of this file (etag)
129
+        $etagFile = md5_file($css_cache_path);
130
+
131
+        //get the HTTP_IF_MODIFIED_SINCE header if set
132
+        $ifModifiedSince=(isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? $_SERVER['HTTP_IF_MODIFIED_SINCE'] : false);
133
+
134
+        //get the HTTP_IF_NONE_MATCH header if set (etag: unique file hash)
135
+        $etagHeader=(isset($_SERVER['HTTP_IF_NONE_MATCH']) ? trim($_SERVER['HTTP_IF_NONE_MATCH']) : false);
136
+
137
+        //set last-modified header
138
+        header("Last-Modified: ".gmdate("D, d M Y H:i:s", $lastModified)." GMT");
139
+
140
+        //set etag-header
141
+        header("Etag: $etagFile");
142
+
143
+        //make sure caching is turned on
144
+        header('Cache-Control: public');
145
+
146
+        //check if page has changed. If not, send 304 and exit
147
+        if (@strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == $lastModified || $etagHeader == $etagFile) {
148
+            header("HTTP/1.1 304 Not Modified");
149
+            exit;
150
+        }
151
+    } else if ($cache_strategy === "none") {
152
+        //dont set browser cache header
153
+    } else {
154
+        echo "Unknown css_cache_strategy '" . $cache_strategy . "'!";
155
+        exit;
156
+    }
157 157
 }
158 158
 
159 159
 //load css builder
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 
168 168
 //send logs to server
169 169
 if (LOGGING_ENABLED) {
170
-	Logger::send();
170
+    Logger::send();
171 171
 }
172 172
 
173 173
 Events::throwEvent("after_show_css");
Please login to merge, or discard this patch.
config/mysql.example.php 1 patch
Indentation   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -6,74 +6,74 @@
 block discarded – undo
6 6
 
7 7
 //allow including of mysql.cfg only once (for security reasons)
8 8
 if (defined('MYSQL_CONFIG_INCLUDED')) {
9
-	echo "Error! Cannot include mysql.cfg again (because for security reasons).";
10
-	exit;
9
+    echo "Error! Cannot include mysql.cfg again (because for security reasons).";
10
+    exit;
11 11
 }
12 12
 
13 13
 define('MYSQL_CONFIG_INCLUDED', true);
14 14
 
15 15
 $mysql_settings = array(
16
-	/**
17
-	 * MySQL Host
18
-	 *
19
-	 * For example "localhost" or the ip of your mysql server
20
-	 */
21
-	'host' => "localhost",
16
+    /**
17
+     * MySQL Host
18
+     *
19
+     * For example "localhost" or the ip of your mysql server
20
+     */
21
+    'host' => "localhost",
22 22
 
23
-	/**
24
-	 * MySQL Port
25
-	 *
26
-	 * by default 3306
27
-	 */
28
-	'port' => 3306,
23
+    /**
24
+     * MySQL Port
25
+     *
26
+     * by default 3306
27
+     */
28
+    'port' => 3306,
29 29
 
30
-	/**
31
-	 * MySQL database user
32
-	 *
33
-	 * If you have an choice: Dont use "root" !
34
-	 */
35
-	'username' => "root",
30
+    /**
31
+     * MySQL database user
32
+     *
33
+     * If you have an choice: Dont use "root" !
34
+     */
35
+    'username' => "root",
36 36
 
37
-	/**
38
-	 * MySQL database password
39
-	 */
40
-	'password' => "<Insert your password here>",
37
+    /**
38
+     * MySQL database password
39
+     */
40
+    'password' => "<Insert your password here>",
41 41
 
42
-	/**
43
-	 * MySQL database name
44
-	 */
45
-	'database' => "pscf",
42
+    /**
43
+     * MySQL database name
44
+     */
45
+    'database' => "pscf",
46 46
 
47
-	/**
48
-	 * MySQL table praefix (praefix before table name, for example "prefix_<Table Name>")
49
-	 *
50
-	 * Also "" is allowed
51
-	 */
52
-	'praefix' => "pscf_",
47
+    /**
48
+     * MySQL table praefix (praefix before table name, for example "prefix_<Table Name>")
49
+     *
50
+     * Also "" is allowed
51
+     */
52
+    'praefix' => "pscf_",
53 53
 
54
-	/**
55
-	 * optional PhpMyAdmin configuration to show PhpMyAdmin menu or other thinks in administration panel
56
-	 */
57
-	'phpmyadmin' => array(
58
-		'enabled' => false,
59
-		'link' => "<Insert your PhpMyAdmin Link here (optional)>",
54
+    /**
55
+     * optional PhpMyAdmin configuration to show PhpMyAdmin menu or other thinks in administration panel
56
+     */
57
+    'phpmyadmin' => array(
58
+        'enabled' => false,
59
+        'link' => "<Insert your PhpMyAdmin Link here (optional)>",
60 60
 
61
-		/**
62
-		 * should phpMyAdmin shown in administration panel?
63
-		 *
64
-		 * true / false
65
-		 */
66
-		'admin_access' => true
67
-	),
61
+        /**
62
+         * should phpMyAdmin shown in administration panel?
63
+         *
64
+         * true / false
65
+         */
66
+        'admin_access' => true
67
+    ),
68 68
 
69
-	'options' => array(
70
-		/**
71
-		 * use connection pooling, dont create an new connection on every request, use connection caching
72
-		 *
73
-		 * @link http://php.net/manual/de/pdo.connections.php
74
-		 */
75
-		PDO::ATTR_PERSISTENT => true
76
-	)
69
+    'options' => array(
70
+        /**
71
+         * use connection pooling, dont create an new connection on every request, use connection caching
72
+         *
73
+         * @link http://php.net/manual/de/pdo.connections.php
74
+         */
75
+        PDO::ATTR_PERSISTENT => true
76
+    )
77 77
 );
78 78
 
79 79
 ?>
Please login to merge, or discard this patch.
config/config.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@
 block discarded – undo
27 27
 error_reporting(E_ALL);
28 28
 
29 29
 $config = array(
30
-	'PHP_BENCHMARK' => true
30
+    'PHP_BENCHMARK' => true
31 31
 );
32 32
 
33 33
 ?>
Please login to merge, or discard this patch.
twig_performance/xtpl_cached.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@
 block discarded – undo
36 36
 require(ROOT_PATH . "system/packages/com.jukusoft.cms.xtpl/xtpl/caching_xtemplate.class.php");
37 37
 
38 38
 if (!file_exists(ROOT_PATH . "/twig_performance/cache/")) {
39
-	mkdir(ROOT_PATH . "/twig_performance/cache/");
39
+    mkdir(ROOT_PATH . "/twig_performance/cache/");
40 40
 }
41 41
 
42 42
 $template = new CachingXTemplate(dirname(__FILLE__) . "/index.tpl");
Please login to merge, or discard this patch.
store/autoloader/autoloader.php 1 patch
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -21,30 +21,30 @@
 block discarded – undo
21 21
  */
22 22
 
23 23
 $autoloader_classes = array(
24
-	"system/core/exception/classloaderexception.php",
25
-	"system/core/classes/dbdriver.php",
26
-	"system/core/driver/mysqldriver.php",
27
-	"system/core/classes/database.php",
28
-	"system/core/classes/security.php",
29
-	"system/core/classes/icache.php",
30
-	"system/core/classes/cache.php",
31
-	"system/core/classes/phputils.php",
32
-	"system/core/driver/filecache.php",
33
-	"system/core/classes/events.php",
34
-	"system/packages/com.jukusoft.cms.settings/classes/settings.php",
35
-	"system/packages/com.jukusoft.cms.xtpl/classes/template.php",
36
-	"system/packages/com.jukusoft.cms.xtpl/xtpl/xtemplate.class.php",
37
-	"system/packages/com.jukusoft.cms.xtpl/xtpl/caching_xtemplate.class.php",
38
-	"system/packages/com.jukusoft.cms.browser/classes/browser.php",
39
-	"system/packages/com.jukusoft.cms.lang/classes/lang.php",
40
-	"system/packages/com.jukusoft.cms.style/classes/stylerules.php",
41
-	"system/packages/com.jukusoft.cms.style/classes/stylecontroller.php",
42
-	"system/packages/com.jukusoft.cms.page/classes/page.php",
43
-	"system/packages/com.jukusoft.cms.page/classes/pagetype.php",
44
-	"system/packages/com.jukusoft.cms.htmlpage/classes/htmlpage.php",
45
-	"system/packages/com.jukusoft.cms.user/classes/user.php",
46
-	"system/packages/com.jukusoft.cms.cssbuilder/classes/cssbuilder.php",
47
-	"system/packages/com.jukusoft.cms.jsbuilder/classes/jsbuilder.php"
24
+    "system/core/exception/classloaderexception.php",
25
+    "system/core/classes/dbdriver.php",
26
+    "system/core/driver/mysqldriver.php",
27
+    "system/core/classes/database.php",
28
+    "system/core/classes/security.php",
29
+    "system/core/classes/icache.php",
30
+    "system/core/classes/cache.php",
31
+    "system/core/classes/phputils.php",
32
+    "system/core/driver/filecache.php",
33
+    "system/core/classes/events.php",
34
+    "system/packages/com.jukusoft.cms.settings/classes/settings.php",
35
+    "system/packages/com.jukusoft.cms.xtpl/classes/template.php",
36
+    "system/packages/com.jukusoft.cms.xtpl/xtpl/xtemplate.class.php",
37
+    "system/packages/com.jukusoft.cms.xtpl/xtpl/caching_xtemplate.class.php",
38
+    "system/packages/com.jukusoft.cms.browser/classes/browser.php",
39
+    "system/packages/com.jukusoft.cms.lang/classes/lang.php",
40
+    "system/packages/com.jukusoft.cms.style/classes/stylerules.php",
41
+    "system/packages/com.jukusoft.cms.style/classes/stylecontroller.php",
42
+    "system/packages/com.jukusoft.cms.page/classes/page.php",
43
+    "system/packages/com.jukusoft.cms.page/classes/pagetype.php",
44
+    "system/packages/com.jukusoft.cms.htmlpage/classes/htmlpage.php",
45
+    "system/packages/com.jukusoft.cms.user/classes/user.php",
46
+    "system/packages/com.jukusoft.cms.cssbuilder/classes/cssbuilder.php",
47
+    "system/packages/com.jukusoft.cms.jsbuilder/classes/jsbuilder.php"
48 48
 );
49 49
 
50 50
 ?>
Please login to merge, or discard this patch.
index.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@
 block discarded – undo
33 33
 		header("HTTP/1.1 302 Found");
34 34
 	}
35 35
 
36
-	header("Location: " + $domain->getRedirectUrl());
36
+	header("Location: " +$domain->getRedirectUrl());
37 37
 	header("Connection: close");
38 38
 
39 39
 	exit;
Please login to merge, or discard this patch.
Indentation   +91 added lines, -91 removed lines patch added patch discarded remove patch
@@ -11,9 +11,9 @@  discard block
 block discarded – undo
11 11
 
12 12
 //reset OpCache in debug mode
13 13
 if (CLEAR_OP_CACHE) {
14
-	//http://php.net/manual/en/function.opcache-reset.php
15
-	//http://php.net/manual/en/function.opcache-invalidate.php
16
-	opcache_reset();
14
+    //http://php.net/manual/en/function.opcache-reset.php
15
+    //http://php.net/manual/en/function.opcache-invalidate.php
16
+    opcache_reset();
17 17
 }
18 18
 
19 19
 //throw event
@@ -24,38 +24,38 @@  discard block
 block discarded – undo
24 24
 
25 25
 //check, if redirect is enabled
26 26
 if ($domain->isRedirectUrl()) {
27
-	if ($domain->getRedirectCode() == 301) {
28
-		header("HTTP/1.1 301 Moved Permanently");
29
-	} else if ($domain->getRedirectCode() == 302) {
30
-		header("HTTP/1.1 302 Found");
31
-	}
27
+    if ($domain->getRedirectCode() == 301) {
28
+        header("HTTP/1.1 301 Moved Permanently");
29
+    } else if ($domain->getRedirectCode() == 302) {
30
+        header("HTTP/1.1 302 Found");
31
+    }
32 32
 
33
-	header("Location: " + $domain->getRedirectUrl());
34
-	header("Connection: close");
33
+    header("Location: " + $domain->getRedirectUrl());
34
+    header("Connection: close");
35 35
 
36
-	exit;
36
+    exit;
37 37
 }
38 38
 
39 39
 //check, if gzip compression is enabled
40 40
 if (Settings::get("gzip_compression", false)) {
41
-	//use gzip compression
42
-	ob_start();
41
+    //use gzip compression
42
+    ob_start();
43 43
 }
44 44
 
45 45
 //TODO: remove this code in production
46 46
 if (isset($_REQUEST['clear_cache'])) {
47
-	//clear cache
48
-	Cache::clear();
47
+    //clear cache
48
+    Cache::clear();
49 49
 
50
-	//clear gettext cache
51
-	PHPUtils::clearGetTextCache();
50
+    //clear gettext cache
51
+    PHPUtils::clearGetTextCache();
52 52
 
53
-	echo "Clear cache!<br />";
53
+    echo "Clear cache!<br />";
54 54
 }
55 55
 
56 56
 //TODO: remove this code later
57 57
 if (isset($_REQUEST['generate_csrf_token'])) {
58
-	Security::generateNewCSRFToken();
58
+    Security::generateNewCSRFToken();
59 59
 }
60 60
 
61 61
 //create new instance of registry
@@ -106,8 +106,8 @@  discard block
 block discarded – undo
106 106
 
107 107
 //check, if user has folder permissions
108 108
 if (!$folder->checkPermissions(PermissionChecker::current())) {
109
-	//user dont has permissions to access folder
110
-	$page->load("error403");
109
+    //user dont has permissions to access folder
110
+    $page->load("error403");
111 111
 }
112 112
 
113 113
 //set folder
@@ -119,12 +119,12 @@  discard block
 block discarded – undo
119 119
 
120 120
 //check, if user has page permissions
121 121
 if (!$page_type->checkPermissions(PermissionChecker::current())) {
122
-	//user dont has custom permissions to access page
123
-	$page->load("error403");
122
+    //user dont has custom permissions to access page
123
+    $page->load("error403");
124 124
 
125
-	//create page type
126
-	$page_type = PageLoader::loadInstance($page->getPageType());
127
-	$page_type->setPage($page);
125
+    //create page type
126
+    $page_type = PageLoader::loadInstance($page->getPageType());
127
+    $page_type->setPage($page);
128 128
 }
129 129
 
130 130
 //check page rights
@@ -136,29 +136,29 @@  discard block
 block discarded – undo
136 136
 
137 137
 //check, if page is not published
138 138
 if (!$page->isPublished()) {
139
-	//another permission is required, because page is not published yet
140
-	if (isset($_REQUEST['preview']) && $_REQUEST['preview'] == "true") {
141
-		//show preview
142
-
143
-		//check permissions
144
-		if (PermissionChecker::current()->hasRight("can_edit_all_pages") || (PermissionChecker::current()->hasRight("can_edit_own_pages") && $page->getAuthorID() == User::current()->getID())) {
145
-			//editor's can see previews of this page, also if they aren't published yet
146
-			$page_permission = "see";
147
-		} else {
148
-			$page_permission = "see_draft";
149
-		}
150
-	} else {
151
-		$page_permission = "see_draft";
152
-	}
139
+    //another permission is required, because page is not published yet
140
+    if (isset($_REQUEST['preview']) && $_REQUEST['preview'] == "true") {
141
+        //show preview
142
+
143
+        //check permissions
144
+        if (PermissionChecker::current()->hasRight("can_edit_all_pages") || (PermissionChecker::current()->hasRight("can_edit_own_pages") && $page->getAuthorID() == User::current()->getID())) {
145
+            //editor's can see previews of this page, also if they aren't published yet
146
+            $page_permission = "see";
147
+        } else {
148
+            $page_permission = "see_draft";
149
+        }
150
+    } else {
151
+        $page_permission = "see_draft";
152
+    }
153 153
 }
154 154
 
155 155
 if (!$page_rights->checkRights($user->getID(), $groups->listGroupIDs(), $page_permission)) {
156
-	//user dont has custom permissions to access page
157
-	$page->load("error403");
156
+    //user dont has custom permissions to access page
157
+    $page->load("error403");
158 158
 
159
-	//create page type
160
-	$page_type = PageLoader::loadInstance($page->getPageType());
161
-	$page_type->setPage($page);
159
+    //create page type
160
+    $page_type = PageLoader::loadInstance($page->getPageType());
161
+    $page_type->setPage($page);
162 162
 }
163 163
 
164 164
 $registry->storeObject("page", $page);
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 $redirect_url = urlencode(DomainUtils::getURL());
180 180
 
181 181
 if (isset($_REQUEST['redirect_url']) && !empty($_REQUEST['redirect_url'])) {
182
-	$redirect_url = $_REQUEST['redirect_url'];
182
+    $redirect_url = $_REQUEST['redirect_url'];
183 183
 }
184 184
 
185 185
 $registry->setSetting("login_url", DomainUtils::getBaseURL() . "/" . Settings::get("login_page", "login") . "?action=login&redirect_url=" . $redirect_url);
@@ -210,60 +210,60 @@  discard block
 block discarded – undo
210 210
 $registry->setSetting("footer", "");
211 211
 
212 212
 Events::throwEvent("Show page", array(
213
-	'registry' => &$registry
213
+    'registry' => &$registry
214 214
 ));
215 215
 
216 216
 //show page here
217 217
 if ($page_type->showDesign()) {
218
-	//show page with design
219
-	StyleController::showPage($registry, $page, $page_type);
218
+    //show page with design
219
+    StyleController::showPage($registry, $page, $page_type);
220 220
 } else {
221
-	//only show content
222
-	echo $page_type->getContent();
221
+    //only show content
222
+    echo $page_type->getContent();
223 223
 
224
-	if ($page_type->exitAfterOutput()) {
225
-		//flush gzip cache
226
-		ob_end_flush();
224
+    if ($page_type->exitAfterOutput()) {
225
+        //flush gzip cache
226
+        ob_end_flush();
227 227
 
228
-		exit;
229
-	}
228
+        exit;
229
+    }
230 230
 }
231 231
 
232 232
 $end_time = microtime(true);
233 233
 $exec_time = $end_time - $start_time;
234 234
 
235 235
 if ($page_type->showHTMLComments()) {
236
-	//benchmark code
237
-	if (ACTIVATE_BENCHMARK) {
238
-		echo "<!-- page was generated in " . $exec_time . " seconds -->\n";
239
-		echo "<!-- mobile detection executed in " . $mobile_detection_exec_time . " seconds, isMobile: " . ($registry->getSetting("isMobile") ? "true" : "false") . " -->\n";
240
-
241
-		//benchmark dwoo template engine
242
-		foreach (DwooTemplate::listFileBenchmark() as $file=>$exec_time) {
243
-			echo "<!-- Dwoo benchmark file '" . $file . "': " . $exec_time . " seconds -->\n";
244
-		}
245
-
246
-		foreach (CSSBuilder::listBenchmarks() as $key=>$exec_time) {
247
-			echo "<!-- css generation of file '" . $key . "': " . $exec_time . " seconds -->\n";
248
-		}
249
-
250
-		foreach (JSBuilder::listBenchmarks() as $key=>$exec_time) {
251
-			echo "<!-- js generation of file '" . $key . "': " . $exec_time . " seconds -->\n";
252
-		}
253
-	}
254
-
255
-	if (DEBUG_MODE) {
256
-		echo "<!-- userID: " . User::current()->getID() . ", username: " . User::current()->getUsername() . " -->\n";
257
-		echo "<!-- " . Database::getInstance()->countQueries() . " sql queries executed -->\n";
258
-		echo "<!-- pref_lang: " . $registry->getSetting("pref_lang") . " -->\n";
259
-		echo "<!-- lang_token: " . $registry->getSetting("lang_token") . " -->\n";
260
-
261
-		if (DEBUG_SQL_QUERIES) {
262
-			foreach (Database::getInstance()->listQueryHistory() as $query_array) {
263
-				echo "<!-- query: " . $query_array['query'] . " -->\n";
264
-			}
265
-		}
266
-	}
236
+    //benchmark code
237
+    if (ACTIVATE_BENCHMARK) {
238
+        echo "<!-- page was generated in " . $exec_time . " seconds -->\n";
239
+        echo "<!-- mobile detection executed in " . $mobile_detection_exec_time . " seconds, isMobile: " . ($registry->getSetting("isMobile") ? "true" : "false") . " -->\n";
240
+
241
+        //benchmark dwoo template engine
242
+        foreach (DwooTemplate::listFileBenchmark() as $file=>$exec_time) {
243
+            echo "<!-- Dwoo benchmark file '" . $file . "': " . $exec_time . " seconds -->\n";
244
+        }
245
+
246
+        foreach (CSSBuilder::listBenchmarks() as $key=>$exec_time) {
247
+            echo "<!-- css generation of file '" . $key . "': " . $exec_time . " seconds -->\n";
248
+        }
249
+
250
+        foreach (JSBuilder::listBenchmarks() as $key=>$exec_time) {
251
+            echo "<!-- js generation of file '" . $key . "': " . $exec_time . " seconds -->\n";
252
+        }
253
+    }
254
+
255
+    if (DEBUG_MODE) {
256
+        echo "<!-- userID: " . User::current()->getID() . ", username: " . User::current()->getUsername() . " -->\n";
257
+        echo "<!-- " . Database::getInstance()->countQueries() . " sql queries executed -->\n";
258
+        echo "<!-- pref_lang: " . $registry->getSetting("pref_lang") . " -->\n";
259
+        echo "<!-- lang_token: " . $registry->getSetting("lang_token") . " -->\n";
260
+
261
+        if (DEBUG_SQL_QUERIES) {
262
+            foreach (Database::getInstance()->listQueryHistory() as $query_array) {
263
+                echo "<!-- query: " . $query_array['query'] . " -->\n";
264
+            }
265
+        }
266
+    }
267 267
 }
268 268
 
269 269
 //flush gzip cache
@@ -274,8 +274,8 @@  discard block
 block discarded – undo
274 274
 
275 275
 //clear cache
276 276
 if ($registry->getSetting("clear_cache") == true) {
277
-	//clear cache
278
-	Cache::clear();
277
+    //clear cache
278
+    Cache::clear();
279 279
 }
280 280
 
281 281
 //update online list
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 
287 287
 //execute tasks
288 288
 if (!Settings::get("cronjon_enabled", true)) {
289
-	Tasks::schedule(Settings::get("max_tasks_on_site", 3));
289
+    Tasks::schedule(Settings::get("max_tasks_on_site", 3));
290 290
 }
291 291
 
292 292
 //save changed settings into database
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
 
295 295
 //send logs to server
296 296
 if (LOGGING_ENABLED) {
297
-	Logger::send();
297
+    Logger::send();
298 298
 }
299 299
 
300 300
 ob_end_flush();
Please login to merge, or discard this patch.
js.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 	$js_builder->generateJS($style, $media, $position);
107 107
 }
108 108
 
109
-$cache_strategy = Settings::get("js_cache_strategy", "expires_header");//etag / expires
109
+$cache_strategy = Settings::get("js_cache_strategy", "expires_header"); //etag / expires
110 110
 
111 111
 //intelligent caching
112 112
 if (file_exists($js_cache_path)) {
@@ -121,19 +121,19 @@  discard block
 block discarded – undo
121 121
 		header("Cache-Control: max-age=" . $seconds_to_cache);
122 122
 	} else if ($cache_strategy === "etag_header") {
123 123
 		//get the last-modified-date of this very file
124
-		$lastModified=filemtime($js_cache_path);
124
+		$lastModified = filemtime($js_cache_path);
125 125
 
126 126
 		//get a unique hash of this file (etag)
127 127
 		$etagFile = md5_file($js_cache_path);
128 128
 
129 129
 		//get the HTTP_IF_MODIFIED_SINCE header if set
130
-		$ifModifiedSince=(isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? $_SERVER['HTTP_IF_MODIFIED_SINCE'] : false);
130
+		$ifModifiedSince = (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? $_SERVER['HTTP_IF_MODIFIED_SINCE'] : false);
131 131
 
132 132
 		//get the HTTP_IF_NONE_MATCH header if set (etag: unique file hash)
133
-		$etagHeader=(isset($_SERVER['HTTP_IF_NONE_MATCH']) ? trim($_SERVER['HTTP_IF_NONE_MATCH']) : false);
133
+		$etagHeader = (isset($_SERVER['HTTP_IF_NONE_MATCH']) ? trim($_SERVER['HTTP_IF_NONE_MATCH']) : false);
134 134
 
135 135
 		//set last-modified header
136
-		header("Last-Modified: ".gmdate("D, d M Y H:i:s", $lastModified)." GMT");
136
+		header("Last-Modified: " . gmdate("D, d M Y H:i:s", $lastModified) . " GMT");
137 137
 
138 138
 		//set etag-header
139 139
 		header("Etag: $etagFile");
Please login to merge, or discard this patch.
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -34,9 +34,9 @@  discard block
 block discarded – undo
34 34
 
35 35
 //reset OpCache in debug mode
36 36
 if (CLEAR_OP_CACHE) {
37
-	//http://php.net/manual/en/function.opcache-reset.php
38
-	//http://php.net/manual/en/function.opcache-invalidate.php
39
-	opcache_reset();
37
+    //http://php.net/manual/en/function.opcache-reset.php
38
+    //http://php.net/manual/en/function.opcache-invalidate.php
39
+    opcache_reset();
40 40
 }
41 41
 
42 42
 ob_start("ob_gzhandler");
@@ -52,8 +52,8 @@  discard block
 block discarded – undo
52 52
 
53 53
 //get required style
54 54
 if (!isset($_REQUEST['style']) || empty($_REQUEST['style'])) {
55
-	echo "No style set. Use js.php?style=your-style-name&amp;position=your-position .";
56
-	exit;
55
+    echo "No style set. Use js.php?style=your-style-name&amp;position=your-position .";
56
+    exit;
57 57
 }
58 58
 
59 59
 $style = $_REQUEST['style'];
@@ -64,34 +64,34 @@  discard block
 block discarded – undo
64 64
 $validator = new Validator_Filename();
65 65
 
66 66
 if (!$validator->isValide($style)) {
67
-	echo "Invalide style name '" . htmlentities($style) . "' (only allowed characters: a-z, A-Z and 0-9)!";
68
-	exit;
67
+    echo "Invalide style name '" . htmlentities($style) . "' (only allowed characters: a-z, A-Z and 0-9)!";
68
+    exit;
69 69
 }
70 70
 
71 71
 $style = $validator->validate($style);
72 72
 
73 73
 //check, if style exists
74 74
 if (!file_exists(STYLE_PATH . $style)) {
75
-	echo "Style '" . $style . "' doesnt exists!";
76
-	exit;
75
+    echo "Style '" . $style . "' doesnt exists!";
76
+    exit;
77 77
 }
78 78
 
79 79
 if (isset($_REQUEST['media']) && !empty($_REQUEST['media'])) {
80
-	if (!$validator->isValide($_REQUEST['media'])) {
81
-		echo "Invalide media '" . htmlentities($_REQUEST['media']) . "'!";
82
-		exit;
83
-	}
80
+    if (!$validator->isValide($_REQUEST['media'])) {
81
+        echo "Invalide media '" . htmlentities($_REQUEST['media']) . "'!";
82
+        exit;
83
+    }
84 84
 
85
-	$media = $validator->validate($_REQUEST['media']);
85
+    $media = $validator->validate($_REQUEST['media']);
86 86
 }
87 87
 
88 88
 if (isset($_REQUEST['position']) && !empty($_REQUEST['position'])) {
89
-	if (!$validator->isValide($_REQUEST['position'])) {
90
-		echo "Invalide position '" . htmlentities($_REQUEST['position']) . "'!";
91
-		exit;
92
-	}
89
+    if (!$validator->isValide($_REQUEST['position'])) {
90
+        echo "Invalide position '" . htmlentities($_REQUEST['position']) . "'!";
91
+        exit;
92
+    }
93 93
 
94
-	$position = $validator->validate($_REQUEST['position']);
94
+    $position = $validator->validate($_REQUEST['position']);
95 95
 }
96 96
 
97 97
 //create js builder
@@ -102,55 +102,55 @@  discard block
 block discarded – undo
102 102
 
103 103
 //generate js file, if neccessary
104 104
 if (!$js_builder->existsCache($style, $media, $position)) {
105
-	$js_builder->generateJS($style, $media, $position);
105
+    $js_builder->generateJS($style, $media, $position);
106 106
 }
107 107
 
108 108
 $cache_strategy = Settings::get("js_cache_strategy", "expires_header");//etag / expires
109 109
 
110 110
 //intelligent caching
111 111
 if (file_exists($js_cache_path)) {
112
-	if ($cache_strategy === "expires_header") {
113
-		//https://www.electrictoolbox.com/php-caching-headers/
114
-
115
-		//set expires header, so browser can cache this js file
116
-		$seconds_to_cache = (int) Settings::get("js_cache_expires_header_ttl", "31536000");
117
-		$ts = gmdate("D, d M Y H:i:s", time() + $seconds_to_cache) . " GMT";
118
-		header("Expires: " . $ts);
119
-		header("Pragma: cache");
120
-		header("Cache-Control: max-age=" . $seconds_to_cache);
121
-	} else if ($cache_strategy === "etag_header") {
122
-		//get the last-modified-date of this very file
123
-		$lastModified=filemtime($js_cache_path);
124
-
125
-		//get a unique hash of this file (etag)
126
-		$etagFile = md5_file($js_cache_path);
127
-
128
-		//get the HTTP_IF_MODIFIED_SINCE header if set
129
-		$ifModifiedSince=(isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? $_SERVER['HTTP_IF_MODIFIED_SINCE'] : false);
130
-
131
-		//get the HTTP_IF_NONE_MATCH header if set (etag: unique file hash)
132
-		$etagHeader=(isset($_SERVER['HTTP_IF_NONE_MATCH']) ? trim($_SERVER['HTTP_IF_NONE_MATCH']) : false);
133
-
134
-		//set last-modified header
135
-		header("Last-Modified: ".gmdate("D, d M Y H:i:s", $lastModified)." GMT");
136
-
137
-		//set etag-header
138
-		header("Etag: $etagFile");
139
-
140
-		//make sure caching is turned on
141
-		header('Cache-Control: public');
142
-
143
-		//check if page has changed. If not, send 304 and exit
144
-		if (@strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == $lastModified || $etagHeader == $etagFile) {
145
-			header("HTTP/1.1 304 Not Modified");
146
-			exit;
147
-		}
148
-	} else if ($cache_strategy === "none") {
149
-		//dont set browser cache header
150
-	} else {
151
-		echo "Unknown js_cache_strategy '" . $cache_strategy . "'!";
152
-		exit;
153
-	}
112
+    if ($cache_strategy === "expires_header") {
113
+        //https://www.electrictoolbox.com/php-caching-headers/
114
+
115
+        //set expires header, so browser can cache this js file
116
+        $seconds_to_cache = (int) Settings::get("js_cache_expires_header_ttl", "31536000");
117
+        $ts = gmdate("D, d M Y H:i:s", time() + $seconds_to_cache) . " GMT";
118
+        header("Expires: " . $ts);
119
+        header("Pragma: cache");
120
+        header("Cache-Control: max-age=" . $seconds_to_cache);
121
+    } else if ($cache_strategy === "etag_header") {
122
+        //get the last-modified-date of this very file
123
+        $lastModified=filemtime($js_cache_path);
124
+
125
+        //get a unique hash of this file (etag)
126
+        $etagFile = md5_file($js_cache_path);
127
+
128
+        //get the HTTP_IF_MODIFIED_SINCE header if set
129
+        $ifModifiedSince=(isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? $_SERVER['HTTP_IF_MODIFIED_SINCE'] : false);
130
+
131
+        //get the HTTP_IF_NONE_MATCH header if set (etag: unique file hash)
132
+        $etagHeader=(isset($_SERVER['HTTP_IF_NONE_MATCH']) ? trim($_SERVER['HTTP_IF_NONE_MATCH']) : false);
133
+
134
+        //set last-modified header
135
+        header("Last-Modified: ".gmdate("D, d M Y H:i:s", $lastModified)." GMT");
136
+
137
+        //set etag-header
138
+        header("Etag: $etagFile");
139
+
140
+        //make sure caching is turned on
141
+        header('Cache-Control: public');
142
+
143
+        //check if page has changed. If not, send 304 and exit
144
+        if (@strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == $lastModified || $etagHeader == $etagFile) {
145
+            header("HTTP/1.1 304 Not Modified");
146
+            exit;
147
+        }
148
+    } else if ($cache_strategy === "none") {
149
+        //dont set browser cache header
150
+    } else {
151
+        echo "Unknown js_cache_strategy '" . $cache_strategy . "'!";
152
+        exit;
153
+    }
154 154
 }
155 155
 
156 156
 //load js builder
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 
165 165
 //send logs to server
166 166
 if (LOGGING_ENABLED) {
167
-	Logger::send();
167
+    Logger::send();
168 168
 }
169 169
 
170 170
 Events::throwEvent("after_show_js");
Please login to merge, or discard this patch.