@@ -28,7 +28,7 @@ |
||
28 | 28 | /** |
29 | 29 | * @inheritdoc |
30 | 30 | * |
31 | - * @return array |
|
31 | + * @return string[] |
|
32 | 32 | * |
33 | 33 | * @throws SS_HTTPResponse_Exception |
34 | 34 | */ |
@@ -35,13 +35,13 @@ |
||
35 | 35 | function check() { |
36 | 36 | $response = Director::test($this->url); |
37 | 37 | |
38 | - if($response->getStatusCode() != 200) { |
|
38 | + if ($response->getStatusCode() != 200) { |
|
39 | 39 | return array( |
40 | 40 | EnvironmentCheck::ERROR, |
41 | 41 | sprintf('Error retrieving "%s" (Code: %d)', $this->url, $response->getStatusCode()) |
42 | 42 | ); |
43 | 43 | |
44 | - } else if($this->testString && (strpos($response->getBody(), $this->testString) === false)) { |
|
44 | + } else if ($this->testString && (strpos($response->getBody(), $this->testString) === false)) { |
|
45 | 45 | return array( |
46 | 46 | EnvironmentCheck::WARNING, |
47 | 47 | sprintf('Success retrieving "%s", but string "%s" not found', $this->url, $this->testString) |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | /** |
86 | 86 | * Run this test suite and return the result code of the worst result. |
87 | 87 | * |
88 | - * @return int |
|
88 | + * @return EnvironmentCheckSuiteResult |
|
89 | 89 | */ |
90 | 90 | public function run() { |
91 | 91 | $result = new EnvironmentCheckSuiteResult(); |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | /** |
166 | 166 | * Register a check against the named check suite. |
167 | 167 | * |
168 | - * @param string|array $names |
|
168 | + * @param string $names |
|
169 | 169 | * @param EnvironmentCheck $check |
170 | 170 | * @param string|array |
171 | 171 | */ |
@@ -264,6 +264,7 @@ discard block |
||
264 | 264 | /** |
265 | 265 | * Return a text version of a status code. |
266 | 266 | * |
267 | + * @param integer $status |
|
267 | 268 | * @return string |
268 | 269 | */ |
269 | 270 | protected function statusText($status) { |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | |
76 | 76 | // Existing named checks can be disabled by setting their 'state' to 'disabled'. |
77 | 77 | // This is handy for disabling checks mandated by modules. |
78 | - if (!empty($check['state']) && $check['state']==='disabled') continue; |
|
78 | + if (!empty($check['state']) && $check['state'] === 'disabled') continue; |
|
79 | 79 | |
80 | 80 | // Add the check to this suite. |
81 | 81 | $this->push($check['definition'], $check['title']); |
@@ -90,12 +90,12 @@ discard block |
||
90 | 90 | public function run() { |
91 | 91 | $result = new EnvironmentCheckSuiteResult(); |
92 | 92 | |
93 | - foreach($this->checkInstances() as $check) { |
|
93 | + foreach ($this->checkInstances() as $check) { |
|
94 | 94 | list($checkClass, $checkTitle) = $check; |
95 | 95 | try { |
96 | 96 | list($status, $message) = $checkClass->check(); |
97 | 97 | // If the check fails, register that as an error |
98 | - } catch(Exception $e) { |
|
98 | + } catch (Exception $e) { |
|
99 | 99 | $status = EnvironmentCheck::ERROR; |
100 | 100 | $message = $e->getMessage(); |
101 | 101 | } |
@@ -112,16 +112,16 @@ discard block |
||
112 | 112 | */ |
113 | 113 | protected function checkInstances() { |
114 | 114 | $output = array(); |
115 | - foreach($this->checks as $check) { |
|
115 | + foreach ($this->checks as $check) { |
|
116 | 116 | list($checkClass, $checkTitle) = $check; |
117 | - if(is_string($checkClass)) { |
|
117 | + if (is_string($checkClass)) { |
|
118 | 118 | $checkInst = Object::create_from_string($checkClass); |
119 | - if($checkInst instanceof EnvironmentCheck) { |
|
119 | + if ($checkInst instanceof EnvironmentCheck) { |
|
120 | 120 | $output[] = array($checkInst, $checkTitle); |
121 | 121 | } else { |
122 | 122 | throw new InvalidArgumentException("Bad EnvironmentCheck: '$checkClass' - the named class doesn't implement EnvironmentCheck"); |
123 | 123 | } |
124 | - } else if($checkClass instanceof EnvironmentCheck) { |
|
124 | + } else if ($checkClass instanceof EnvironmentCheck) { |
|
125 | 125 | $output[] = array($checkClass, $checkTitle); |
126 | 126 | } else { |
127 | 127 | throw new InvalidArgumentException("Bad EnvironmentCheck: " . var_export($check, true)); |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | * @param string $title |
138 | 138 | */ |
139 | 139 | public function push($check, $title = null) { |
140 | - if(!$title) { |
|
140 | + if (!$title) { |
|
141 | 141 | $title = is_string($check) ? $check : get_class($check); |
142 | 142 | } |
143 | 143 | $this->checks[] = array($check, $title); |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | * @return EnvironmentCheckSuite |
159 | 159 | */ |
160 | 160 | static function inst($name) { |
161 | - if(!isset(self::$instances[$name])) self::$instances[$name] = new EnvironmentCheckSuite($name); |
|
161 | + if (!isset(self::$instances[$name])) self::$instances[$name] = new EnvironmentCheckSuite($name); |
|
162 | 162 | return self::$instances[$name]; |
163 | 163 | } |
164 | 164 | |
@@ -170,8 +170,8 @@ discard block |
||
170 | 170 | * @param string|array |
171 | 171 | */ |
172 | 172 | static function register($names, $check, $title = null) { |
173 | - if(!is_array($names)) $names = array($names); |
|
174 | - foreach($names as $name) self::inst($name)->push($check, $title); |
|
173 | + if (!is_array($names)) $names = array($names); |
|
174 | + foreach ($names as $name) self::inst($name)->push($check, $title); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | /** |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | 'ShouldPass' => $this->ShouldPass(), |
256 | 256 | 'Checks' => array() |
257 | 257 | ); |
258 | - foreach($this->details as $detail) { |
|
258 | + foreach ($this->details as $detail) { |
|
259 | 259 | $result['Checks'][] = $detail->toMap(); |
260 | 260 | } |
261 | 261 | return json_encode($result); |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | * @return string |
268 | 268 | */ |
269 | 269 | protected function statusText($status) { |
270 | - switch($status) { |
|
270 | + switch ($status) { |
|
271 | 271 | case EnvironmentCheck::ERROR: return "ERROR"; |
272 | 272 | case EnvironmentCheck::WARNING: return "WARNING"; |
273 | 273 | case EnvironmentCheck::OK: return "OK"; |
@@ -75,7 +75,9 @@ discard block |
||
75 | 75 | |
76 | 76 | // Existing named checks can be disabled by setting their 'state' to 'disabled'. |
77 | 77 | // This is handy for disabling checks mandated by modules. |
78 | - if (!empty($check['state']) && $check['state']==='disabled') continue; |
|
78 | + if (!empty($check['state']) && $check['state']==='disabled') { |
|
79 | + continue; |
|
80 | + } |
|
79 | 81 | |
80 | 82 | // Add the check to this suite. |
81 | 83 | $this->push($check['definition'], $check['title']); |
@@ -158,7 +160,9 @@ discard block |
||
158 | 160 | * @return EnvironmentCheckSuite |
159 | 161 | */ |
160 | 162 | static function inst($name) { |
161 | - if(!isset(self::$instances[$name])) self::$instances[$name] = new EnvironmentCheckSuite($name); |
|
163 | + if(!isset(self::$instances[$name])) { |
|
164 | + self::$instances[$name] = new EnvironmentCheckSuite($name); |
|
165 | + } |
|
162 | 166 | return self::$instances[$name]; |
163 | 167 | } |
164 | 168 | |
@@ -170,8 +174,12 @@ discard block |
||
170 | 174 | * @param string|array |
171 | 175 | */ |
172 | 176 | static function register($names, $check, $title = null) { |
173 | - if(!is_array($names)) $names = array($names); |
|
174 | - foreach($names as $name) self::inst($name)->push($check, $title); |
|
177 | + if(!is_array($names)) { |
|
178 | + $names = array($names); |
|
179 | + } |
|
180 | + foreach($names as $name) { |
|
181 | + self::inst($name)->push($check, $title); |
|
182 | + } |
|
175 | 183 | } |
176 | 184 | |
177 | 185 | /** |
@@ -79,10 +79,10 @@ discard block |
||
79 | 79 | */ |
80 | 80 | function init($permission = 'ADMIN') { |
81 | 81 | // if the environment supports it, provide a basic auth challenge and see if it matches configured credentials |
82 | - if(defined('ENVCHECK_BASICAUTH_USERNAME') && defined('ENVCHECK_BASICAUTH_PASSWORD')) { |
|
83 | - if(isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) { |
|
82 | + if (defined('ENVCHECK_BASICAUTH_USERNAME') && defined('ENVCHECK_BASICAUTH_PASSWORD')) { |
|
83 | + if (isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) { |
|
84 | 84 | // authenticate the input user/pass with the configured credentials |
85 | - if( |
|
85 | + if ( |
|
86 | 86 | !( |
87 | 87 | $_SERVER['PHP_AUTH_USER'] == ENVCHECK_BASICAUTH_USERNAME |
88 | 88 | && $_SERVER['PHP_AUTH_PW'] == ENVCHECK_BASICAUTH_PASSWORD |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | throw $e; |
105 | 105 | } |
106 | 106 | } else { |
107 | - if(!$this->canAccess(null, $permission)) return $this->httpError(403); |
|
107 | + if (!$this->canAccess(null, $permission)) return $this->httpError(403); |
|
108 | 108 | } |
109 | 109 | } |
110 | 110 | |
@@ -117,17 +117,17 @@ discard block |
||
117 | 117 | * @throws SS_HTTPResponse_Exception |
118 | 118 | */ |
119 | 119 | function canAccess($member = null, $permission = "ADMIN") { |
120 | - if(!$member) { |
|
120 | + if (!$member) { |
|
121 | 121 | $member = Member::currentUser(); |
122 | 122 | } |
123 | 123 | |
124 | - if(!$member) { |
|
124 | + if (!$member) { |
|
125 | 125 | $member = BasicAuth::requireLogin('Environment Checker', $permission, false); |
126 | 126 | } |
127 | 127 | |
128 | 128 | // We allow access to this controller regardless of live-status or ADMIN permission only |
129 | 129 | // if on CLI. Access to this controller is always allowed in "dev-mode", or of the user is ADMIN. |
130 | - if( |
|
130 | + if ( |
|
131 | 131 | Director::isDev() |
132 | 132 | || Director::is_cli() |
133 | 133 | || empty($permission) |
@@ -140,8 +140,8 @@ discard block |
||
140 | 140 | // "Veto" style, return NULL to abstain vote. |
141 | 141 | $canExtended = null; |
142 | 142 | $results = $this->extend('canAccess', $member); |
143 | - if($results && is_array($results)) { |
|
144 | - if(!min($results)) return false; |
|
143 | + if ($results && is_array($results)) { |
|
144 | + if (!min($results)) return false; |
|
145 | 145 | else return true; |
146 | 146 | } |
147 | 147 | |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | $response = new SS_HTTPResponse; |
156 | 156 | $result = EnvironmentCheckSuite::inst($this->checkSuiteName)->run(); |
157 | 157 | |
158 | - if(!$result->ShouldPass()) { |
|
158 | + if (!$result->ShouldPass()) { |
|
159 | 159 | $response->setStatusCode($this->errorCode); |
160 | 160 | } |
161 | 161 | |
@@ -172,13 +172,13 @@ discard block |
||
172 | 172 | } |
173 | 173 | |
174 | 174 | // Optionally log errors and warnings individually |
175 | - foreach($result->Details() as $detail) { |
|
176 | - if($this->config()->log_results_warning && $detail->StatusCode == EnvironmentCheck::WARNING) { |
|
175 | + foreach ($result->Details() as $detail) { |
|
176 | + if ($this->config()->log_results_warning && $detail->StatusCode == EnvironmentCheck::WARNING) { |
|
177 | 177 | $this->log( |
178 | 178 | sprintf('EnvironmentChecker warning at "%s" check. Message: %s', $detail->Check, $detail->Message), |
179 | 179 | $this->config()->log_results_warning_level |
180 | 180 | ); |
181 | - } elseif($this->config()->log_results_error && $detail->StatusCode == EnvironmentCheck::ERROR) { |
|
181 | + } elseif ($this->config()->log_results_error && $detail->StatusCode == EnvironmentCheck::ERROR) { |
|
182 | 182 | $this->log( |
183 | 183 | sprintf('EnvironmentChecker error at "%s" check. Message: %s', $detail->Check, $detail->Message), |
184 | 184 | $this->config()->log_results_error_level |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | } |
188 | 188 | |
189 | 189 | // output the result as JSON if requested |
190 | - if( |
|
190 | + if ( |
|
191 | 191 | $this->getRequest()->getExtension() == 'json' |
192 | 192 | || strpos($this->getRequest()->getHeader('Accept'), 'application/json') !== false |
193 | 193 | ) { |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | */ |
243 | 243 | public static function set_to_email_address($to) { |
244 | 244 | Deprecation::notice('2.0', 'Use config API instead'); |
245 | - Config::inst()->update('EnvironmentChecker', 'to_email_address', $to); |
|
245 | + Config::inst()->update('EnvironmentChecker', 'to_email_address', $to); |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | /** |
@@ -104,7 +104,9 @@ discard block |
||
104 | 104 | throw $e; |
105 | 105 | } |
106 | 106 | } else { |
107 | - if(!$this->canAccess(null, $permission)) return $this->httpError(403); |
|
107 | + if(!$this->canAccess(null, $permission)) { |
|
108 | + return $this->httpError(403); |
|
109 | + } |
|
108 | 110 | } |
109 | 111 | } |
110 | 112 | |
@@ -141,8 +143,11 @@ discard block |
||
141 | 143 | $canExtended = null; |
142 | 144 | $results = $this->extend('canAccess', $member); |
143 | 145 | if($results && is_array($results)) { |
144 | - if(!min($results)) return false; |
|
145 | - else return true; |
|
146 | + if(!min($results)) { |
|
147 | + return false; |
|
148 | + } else { |
|
149 | + return true; |
|
150 | + } |
|
146 | 151 | } |
147 | 152 | |
148 | 153 | return false; |
@@ -22,13 +22,13 @@ |
||
22 | 22 | * @return array |
23 | 23 | */ |
24 | 24 | function check() { |
25 | - if(!DB::getConn()->hasTable($this->checkTable)) { |
|
25 | + if (!DB::getConn()->hasTable($this->checkTable)) { |
|
26 | 26 | return array(EnvironmentCheck::ERROR, "$this->checkTable not present in the database"); |
27 | 27 | } |
28 | 28 | |
29 | 29 | $count = DB::query("SELECT COUNT(*) FROM \"$this->checkTable\"")->value(); |
30 | 30 | |
31 | - if($count > 0) { |
|
31 | + if ($count > 0) { |
|
32 | 32 | return array(EnvironmentCheck::OK, ""); |
33 | 33 | } else { |
34 | 34 | return array(EnvironmentCheck::WARNING, "$this->checkTable queried ok but has no records"); |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * @param int $timeout |
25 | 25 | */ |
26 | 26 | function __construct($urls, $timeout = 15) { |
27 | - if($urls) $this->urls = explode(' ', $urls); |
|
27 | + if ($urls) $this->urls = explode(' ', $urls); |
|
28 | 28 | $this->timeout = $timeout; |
29 | 29 | } |
30 | 30 | |
@@ -37,14 +37,14 @@ discard block |
||
37 | 37 | $urls = $this->getURLs(); |
38 | 38 | |
39 | 39 | $chs = array(); |
40 | - foreach($urls as $url) { |
|
40 | + foreach ($urls as $url) { |
|
41 | 41 | $ch = curl_init(); |
42 | 42 | $chs[] = $ch; |
43 | 43 | curl_setopt_array($ch, $this->getCurlOpts($url)); |
44 | 44 | } |
45 | 45 | // Parallel execution for faster performance |
46 | 46 | $mh = curl_multi_init(); |
47 | - foreach($chs as $ch) curl_multi_add_handle($mh,$ch); |
|
47 | + foreach ($chs as $ch) curl_multi_add_handle($mh, $ch); |
|
48 | 48 | |
49 | 49 | $active = null; |
50 | 50 | // Execute the handles |
@@ -63,10 +63,10 @@ discard block |
||
63 | 63 | |
64 | 64 | $hasError = false; |
65 | 65 | $msgs = array(); |
66 | - foreach($chs as $ch) { |
|
66 | + foreach ($chs as $ch) { |
|
67 | 67 | $url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL); |
68 | 68 | $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
69 | - if(curl_errno($ch) || $code >= 400) { |
|
69 | + if (curl_errno($ch) || $code >= 400) { |
|
70 | 70 | $hasError = true; |
71 | 71 | $msgs[] = sprintf( |
72 | 72 | 'Error retrieving "%s": %s (Code: %s)', |
@@ -84,10 +84,10 @@ discard block |
||
84 | 84 | } |
85 | 85 | |
86 | 86 | // Close the handles |
87 | - foreach($chs as $ch) curl_multi_remove_handle($mh, $ch); |
|
87 | + foreach ($chs as $ch) curl_multi_remove_handle($mh, $ch); |
|
88 | 88 | curl_multi_close($mh); |
89 | 89 | |
90 | - if($hasError) { |
|
90 | + if ($hasError) { |
|
91 | 91 | return array(EnvironmentCheck::ERROR, implode(', ', $msgs)); |
92 | 92 | } else { |
93 | 93 | return array(EnvironmentCheck::OK, implode(', ', $msgs)); |
@@ -24,7 +24,9 @@ discard block |
||
24 | 24 | * @param int $timeout |
25 | 25 | */ |
26 | 26 | function __construct($urls, $timeout = 15) { |
27 | - if($urls) $this->urls = explode(' ', $urls); |
|
27 | + if($urls) { |
|
28 | + $this->urls = explode(' ', $urls); |
|
29 | + } |
|
28 | 30 | $this->timeout = $timeout; |
29 | 31 | } |
30 | 32 | |
@@ -44,7 +46,9 @@ discard block |
||
44 | 46 | } |
45 | 47 | // Parallel execution for faster performance |
46 | 48 | $mh = curl_multi_init(); |
47 | - foreach($chs as $ch) curl_multi_add_handle($mh,$ch); |
|
49 | + foreach($chs as $ch) { |
|
50 | + curl_multi_add_handle($mh,$ch); |
|
51 | + } |
|
48 | 52 | |
49 | 53 | $active = null; |
50 | 54 | // Execute the handles |
@@ -84,7 +88,9 @@ discard block |
||
84 | 88 | } |
85 | 89 | |
86 | 90 | // Close the handles |
87 | - foreach($chs as $ch) curl_multi_remove_handle($mh, $ch); |
|
91 | + foreach($chs as $ch) { |
|
92 | + curl_multi_remove_handle($mh, $ch); |
|
93 | + } |
|
88 | 94 | curl_multi_close($mh); |
89 | 95 | |
90 | 96 | if($hasError) { |
@@ -28,7 +28,7 @@ |
||
28 | 28 | /** |
29 | 29 | * @inheritdoc |
30 | 30 | * |
31 | - * @return array |
|
31 | + * @return string[] |
|
32 | 32 | * |
33 | 33 | * @throws SS_HTTPResponse_Exception |
34 | 34 | */ |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | */ |
59 | 59 | function __construct($path, $fileTypeValidateFunc = 'noVidation', $checkType = null) { |
60 | 60 | $this->path = $path; |
61 | - $this->fileTypeValidateFunc = ($fileTypeValidateFunc)? $fileTypeValidateFunc:'noVidation'; |
|
61 | + $this->fileTypeValidateFunc = ($fileTypeValidateFunc) ? $fileTypeValidateFunc : 'noVidation'; |
|
62 | 62 | $this->checkType = ($checkType) ? $checkType : self::CHECK_SINGLE; |
63 | 63 | } |
64 | 64 | |
@@ -72,32 +72,32 @@ discard block |
||
72 | 72 | Versioned::set_reading_mode('Live'); |
73 | 73 | |
74 | 74 | $files = $this->getFiles(); |
75 | - if($files){ |
|
75 | + if ($files) { |
|
76 | 76 | $fileTypeValidateFunc = $this->fileTypeValidateFunc; |
77 | - if(method_exists ($this, $fileTypeValidateFunc)){ |
|
77 | + if (method_exists($this, $fileTypeValidateFunc)) { |
|
78 | 78 | $invalidFiles = array(); |
79 | 79 | $validFiles = array(); |
80 | 80 | |
81 | - foreach($files as $file){ |
|
82 | - if($this->$fileTypeValidateFunc($file)){ |
|
81 | + foreach ($files as $file) { |
|
82 | + if ($this->$fileTypeValidateFunc($file)) { |
|
83 | 83 | $validFiles[] = $file; |
84 | - }else{ |
|
84 | + } else { |
|
85 | 85 | $invalidFiles[] = $file; |
86 | 86 | } |
87 | 87 | } |
88 | 88 | |
89 | 89 | // If at least one file was valid, count as passed |
90 | - if($this->checkType == self::CHECK_SINGLE && count($invalidFiles) < count($files)) { |
|
90 | + if ($this->checkType == self::CHECK_SINGLE && count($invalidFiles) < count($files)) { |
|
91 | 91 | $validFileList = "\n"; |
92 | - foreach($validFiles as $vf){ |
|
93 | - $validFileList .= $vf."\n"; |
|
92 | + foreach ($validFiles as $vf) { |
|
93 | + $validFileList .= $vf . "\n"; |
|
94 | 94 | } |
95 | - if($fileTypeValidateFunc == 'noVidation') { |
|
95 | + if ($fileTypeValidateFunc == 'noVidation') { |
|
96 | 96 | $checkReturn = array( |
97 | 97 | EnvironmentCheck::OK, |
98 | 98 | sprintf('At least these file(s) accessible: %s', $validFileList) |
99 | 99 | ); |
100 | - }else{ |
|
100 | + } else { |
|
101 | 101 | $checkReturn = array( |
102 | 102 | EnvironmentCheck::OK, |
103 | 103 | sprintf('At least these file(s) passed file type validate function "%s": %s', $fileTypeValidateFunc, $validFileList) |
@@ -107,16 +107,16 @@ discard block |
||
107 | 107 | if (count($invalidFiles) == 0) $checkReturn = array(EnvironmentCheck::OK, 'All files valideted'); |
108 | 108 | else { |
109 | 109 | $invalidFileList = "\n"; |
110 | - foreach($invalidFiles as $vf){ |
|
111 | - $invalidFileList .= $vf."\n"; |
|
110 | + foreach ($invalidFiles as $vf) { |
|
111 | + $invalidFileList .= $vf . "\n"; |
|
112 | 112 | } |
113 | 113 | |
114 | - if($fileTypeValidateFunc == 'noVidation'){ |
|
114 | + if ($fileTypeValidateFunc == 'noVidation') { |
|
115 | 115 | $checkReturn = array( |
116 | 116 | EnvironmentCheck::ERROR, |
117 | 117 | sprintf('File(s) not accessible: %s', $invalidFileList) |
118 | 118 | ); |
119 | - }else{ |
|
119 | + } else { |
|
120 | 120 | $checkReturn = array( |
121 | 121 | EnvironmentCheck::ERROR, |
122 | 122 | sprintf('File(s) not passing the file type validate function "%s": %s', $fileTypeValidateFunc, $invalidFileList) |
@@ -125,14 +125,14 @@ discard block |
||
125 | 125 | |
126 | 126 | } |
127 | 127 | } |
128 | - }else{ |
|
129 | - $checkReturn = array( |
|
128 | + } else { |
|
129 | + $checkReturn = array( |
|
130 | 130 | EnvironmentCheck::ERROR, |
131 | 131 | sprintf("Invalid file type validation method name passed: %s ", $fileTypeValidateFunc) |
132 | 132 | ); |
133 | 133 | } |
134 | 134 | |
135 | - }else{ |
|
135 | + } else { |
|
136 | 136 | $checkReturn = array( |
137 | 137 | EnvironmentCheck::ERROR, |
138 | 138 | sprintf("No files accessible at path %s", $this->path) |
@@ -149,11 +149,11 @@ discard block |
||
149 | 149 | * |
150 | 150 | * @return bool |
151 | 151 | */ |
152 | - private function jsonValidate($file){ |
|
152 | + private function jsonValidate($file) { |
|
153 | 153 | $json = json_decode(file_get_contents($file)); |
154 | - if(!$json) { |
|
154 | + if (!$json) { |
|
155 | 155 | return false; |
156 | - }else{ |
|
156 | + } else { |
|
157 | 157 | return true; |
158 | 158 | } |
159 | 159 | } |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | foreach($files as $file){ |
82 | 82 | if($this->$fileTypeValidateFunc($file)){ |
83 | 83 | $validFiles[] = $file; |
84 | - }else{ |
|
84 | + } else{ |
|
85 | 85 | $invalidFiles[] = $file; |
86 | 86 | } |
87 | 87 | } |
@@ -97,15 +97,16 @@ discard block |
||
97 | 97 | EnvironmentCheck::OK, |
98 | 98 | sprintf('At least these file(s) accessible: %s', $validFileList) |
99 | 99 | ); |
100 | - }else{ |
|
100 | + } else{ |
|
101 | 101 | $checkReturn = array( |
102 | 102 | EnvironmentCheck::OK, |
103 | 103 | sprintf('At least these file(s) passed file type validate function "%s": %s', $fileTypeValidateFunc, $validFileList) |
104 | 104 | ); |
105 | 105 | } |
106 | 106 | } else { |
107 | - if (count($invalidFiles) == 0) $checkReturn = array(EnvironmentCheck::OK, 'All files valideted'); |
|
108 | - else { |
|
107 | + if (count($invalidFiles) == 0) { |
|
108 | + $checkReturn = array(EnvironmentCheck::OK, 'All files valideted'); |
|
109 | + } else { |
|
109 | 110 | $invalidFileList = "\n"; |
110 | 111 | foreach($invalidFiles as $vf){ |
111 | 112 | $invalidFileList .= $vf."\n"; |
@@ -116,7 +117,7 @@ discard block |
||
116 | 117 | EnvironmentCheck::ERROR, |
117 | 118 | sprintf('File(s) not accessible: %s', $invalidFileList) |
118 | 119 | ); |
119 | - }else{ |
|
120 | + } else{ |
|
120 | 121 | $checkReturn = array( |
121 | 122 | EnvironmentCheck::ERROR, |
122 | 123 | sprintf('File(s) not passing the file type validate function "%s": %s', $fileTypeValidateFunc, $invalidFileList) |
@@ -125,14 +126,14 @@ discard block |
||
125 | 126 | |
126 | 127 | } |
127 | 128 | } |
128 | - }else{ |
|
129 | + } else{ |
|
129 | 130 | $checkReturn = array( |
130 | 131 | EnvironmentCheck::ERROR, |
131 | 132 | sprintf("Invalid file type validation method name passed: %s ", $fileTypeValidateFunc) |
132 | 133 | ); |
133 | 134 | } |
134 | 135 | |
135 | - }else{ |
|
136 | + } else{ |
|
136 | 137 | $checkReturn = array( |
137 | 138 | EnvironmentCheck::ERROR, |
138 | 139 | sprintf("No files accessible at path %s", $this->path) |
@@ -153,7 +154,7 @@ discard block |
||
153 | 154 | $json = json_decode(file_get_contents($file)); |
154 | 155 | if(!$json) { |
155 | 156 | return false; |
156 | - }else{ |
|
157 | + } else{ |
|
157 | 158 | return true; |
158 | 159 | } |
159 | 160 | } |
@@ -28,7 +28,7 @@ |
||
28 | 28 | /** |
29 | 29 | * @inheritdoc |
30 | 30 | * |
31 | - * @return array |
|
31 | + * @return string[] |
|
32 | 32 | * |
33 | 33 | * @throws SS_HTTPResponse_Exception |
34 | 34 | */ |
@@ -115,8 +115,8 @@ |
||
115 | 115 | if($this->checkType == self::CHECK_SINGLE && count($invalidFiles) < count($files)) { |
116 | 116 | return array(EnvironmentCheck::OK, ''); |
117 | 117 | } else { |
118 | - if (count($invalidFiles) == 0) return array(EnvironmentCheck::OK, ''); |
|
119 | - else return array( |
|
118 | + if (count($invalidFiles) == 0) return array(EnvironmentCheck::OK, ''); |
|
119 | + else return array( |
|
120 | 120 | EnvironmentCheck::ERROR, |
121 | 121 | sprintf('No files matched criteria (%s %s)', $this->compareOperand, date('c', $cutoffTime)) |
122 | 122 | ); |
@@ -86,20 +86,20 @@ discard block |
||
86 | 86 | * @return array |
87 | 87 | */ |
88 | 88 | function check() { |
89 | - $cutoffTime = strtotime($this->relativeAge, SS_Datetime::now()->Format('U')); |
|
89 | + $cutoffTime = strtotime($this->relativeAge, SS_Datetime::now()->Format('U')); |
|
90 | 90 | $files = $this->getFiles(); |
91 | 91 | $invalidFiles = array(); |
92 | 92 | $validFiles = array(); |
93 | 93 | $checkFn = $this->checkFn; |
94 | 94 | $allValid = true; |
95 | - if($files) foreach($files as $file) { |
|
95 | + if ($files) foreach ($files as $file) { |
|
96 | 96 | $fileTime = $checkFn($file); |
97 | 97 | $valid = ($this->compareOperand == '>') ? ($fileTime >= $cutoffTime) : ($fileTime <= $cutoffTime); |
98 | - if($valid) { |
|
98 | + if ($valid) { |
|
99 | 99 | $validFiles[] = $file; |
100 | 100 | } else { |
101 | 101 | $invalidFiles[] = $file; |
102 | - if($this->checkType == self::CHECK_ALL) { |
|
102 | + if ($this->checkType == self::CHECK_ALL) { |
|
103 | 103 | return array( |
104 | 104 | EnvironmentCheck::ERROR, |
105 | 105 | sprintf( |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | } |
113 | 113 | |
114 | 114 | // If at least one file was valid, count as passed |
115 | - if($this->checkType == self::CHECK_SINGLE && count($invalidFiles) < count($files)) { |
|
115 | + if ($this->checkType == self::CHECK_SINGLE && count($invalidFiles) < count($files)) { |
|
116 | 116 | return array(EnvironmentCheck::OK, ''); |
117 | 117 | } else { |
118 | 118 | if (count($invalidFiles) == 0) return array(EnvironmentCheck::OK, ''); |
@@ -92,8 +92,10 @@ discard block |
||
92 | 92 | $validFiles = array(); |
93 | 93 | $checkFn = $this->checkFn; |
94 | 94 | $allValid = true; |
95 | - if($files) foreach($files as $file) { |
|
95 | + if($files) { |
|
96 | + foreach($files as $file) { |
|
96 | 97 | $fileTime = $checkFn($file); |
98 | + } |
|
97 | 99 | $valid = ($this->compareOperand == '>') ? ($fileTime >= $cutoffTime) : ($fileTime <= $cutoffTime); |
98 | 100 | if($valid) { |
99 | 101 | $validFiles[] = $file; |
@@ -115,11 +117,14 @@ discard block |
||
115 | 117 | if($this->checkType == self::CHECK_SINGLE && count($invalidFiles) < count($files)) { |
116 | 118 | return array(EnvironmentCheck::OK, ''); |
117 | 119 | } else { |
118 | - if (count($invalidFiles) == 0) return array(EnvironmentCheck::OK, ''); |
|
119 | - else return array( |
|
120 | + if (count($invalidFiles) == 0) { |
|
121 | + return array(EnvironmentCheck::OK, ''); |
|
122 | + } else { |
|
123 | + return array( |
|
120 | 124 | EnvironmentCheck::ERROR, |
121 | 125 | sprintf('No files matched criteria (%s %s)', $this->compareOperand, date('c', $cutoffTime)) |
122 | 126 | ); |
127 | + } |
|
123 | 128 | } |
124 | 129 | |
125 | 130 | } |
@@ -28,7 +28,7 @@ |
||
28 | 28 | /** |
29 | 29 | * @inheritdoc |
30 | 30 | * |
31 | - * @return array |
|
31 | + * @return string[] |
|
32 | 32 | * |
33 | 33 | * @throws SS_HTTPResponse_Exception |
34 | 34 | */ |
@@ -22,34 +22,34 @@ discard block |
||
22 | 22 | * @return array |
23 | 23 | */ |
24 | 24 | function check() { |
25 | - if($this->path[0] == '/') $filename = $this->path; |
|
25 | + if ($this->path[0] == '/') $filename = $this->path; |
|
26 | 26 | else $filename = BASE_PATH . DIRECTORY_SEPARATOR . str_replace('/', DIRECTORY_SEPARATOR, $this->path); |
27 | 27 | |
28 | - if(file_exists($filename)) $isWriteable = is_writeable($filename); |
|
28 | + if (file_exists($filename)) $isWriteable = is_writeable($filename); |
|
29 | 29 | else $isWriteable = is_writeable(dirname($filename)); |
30 | 30 | |
31 | - if(!$isWriteable) { |
|
32 | - if(function_exists('posix_getgroups')) { |
|
31 | + if (!$isWriteable) { |
|
32 | + if (function_exists('posix_getgroups')) { |
|
33 | 33 | $userID = posix_geteuid(); |
34 | 34 | $user = posix_getpwuid($userID); |
35 | 35 | |
36 | - $currentOwnerID = fileowner(file_exists($filename) ? $filename : dirname($filename) ); |
|
36 | + $currentOwnerID = fileowner(file_exists($filename) ? $filename : dirname($filename)); |
|
37 | 37 | $currentOwner = posix_getpwuid($currentOwnerID); |
38 | 38 | |
39 | 39 | $message = "User '$user[name]' needs to be able to write to this file:\n$filename\n\nThe file is currently owned by '$currentOwner[name]'. "; |
40 | 40 | |
41 | - if($user['name'] == $currentOwner['name']) { |
|
41 | + if ($user['name'] == $currentOwner['name']) { |
|
42 | 42 | $message .= "We recommend that you make the file writeable."; |
43 | 43 | } else { |
44 | 44 | |
45 | 45 | $groups = posix_getgroups(); |
46 | 46 | $groupList = array(); |
47 | - foreach($groups as $group) { |
|
47 | + foreach ($groups as $group) { |
|
48 | 48 | $groupInfo = posix_getgrgid($group); |
49 | - if(in_array($currentOwner['name'], $groupInfo['members'])) $groupList[] = $groupInfo['name']; |
|
49 | + if (in_array($currentOwner['name'], $groupInfo['members'])) $groupList[] = $groupInfo['name']; |
|
50 | 50 | } |
51 | - if($groupList) { |
|
52 | - $message .= " We recommend that you make the file group-writeable and change the group to one of these groups:\n - ". implode("\n - ", $groupList) |
|
51 | + if ($groupList) { |
|
52 | + $message .= " We recommend that you make the file group-writeable and change the group to one of these groups:\n - " . implode("\n - ", $groupList) |
|
53 | 53 | . "\n\nFor example:\nchmod g+w $filename\nchgrp " . $groupList[0] . " $filename"; |
54 | 54 | } else { |
55 | 55 | $message .= " There is no user-group that contains both the web-server user and the owner of this file. Change the ownership of the file, create a new group, or temporarily make the file writeable by everyone during the install process."; |
@@ -63,6 +63,6 @@ discard block |
||
63 | 63 | return array(EnvironmentCheck::ERROR, $message); |
64 | 64 | } |
65 | 65 | |
66 | - return array(EnvironmentCheck::OK,''); |
|
66 | + return array(EnvironmentCheck::OK, ''); |
|
67 | 67 | } |
68 | 68 | } |
@@ -22,11 +22,17 @@ discard block |
||
22 | 22 | * @return array |
23 | 23 | */ |
24 | 24 | function check() { |
25 | - if($this->path[0] == '/') $filename = $this->path; |
|
26 | - else $filename = BASE_PATH . DIRECTORY_SEPARATOR . str_replace('/', DIRECTORY_SEPARATOR, $this->path); |
|
25 | + if($this->path[0] == '/') { |
|
26 | + $filename = $this->path; |
|
27 | + } else { |
|
28 | + $filename = BASE_PATH . DIRECTORY_SEPARATOR . str_replace('/', DIRECTORY_SEPARATOR, $this->path); |
|
29 | + } |
|
27 | 30 | |
28 | - if(file_exists($filename)) $isWriteable = is_writeable($filename); |
|
29 | - else $isWriteable = is_writeable(dirname($filename)); |
|
31 | + if(file_exists($filename)) { |
|
32 | + $isWriteable = is_writeable($filename); |
|
33 | + } else { |
|
34 | + $isWriteable = is_writeable(dirname($filename)); |
|
35 | + } |
|
30 | 36 | |
31 | 37 | if(!$isWriteable) { |
32 | 38 | if(function_exists('posix_getgroups')) { |
@@ -46,7 +52,9 @@ discard block |
||
46 | 52 | $groupList = array(); |
47 | 53 | foreach($groups as $group) { |
48 | 54 | $groupInfo = posix_getgrgid($group); |
49 | - if(in_array($currentOwner['name'], $groupInfo['members'])) $groupList[] = $groupInfo['name']; |
|
55 | + if(in_array($currentOwner['name'], $groupInfo['members'])) { |
|
56 | + $groupList[] = $groupInfo['name']; |
|
57 | + } |
|
50 | 58 | } |
51 | 59 | if($groupList) { |
52 | 60 | $message .= " We recommend that you make the file group-writeable and change the group to one of these groups:\n - ". implode("\n - ", $groupList) |
@@ -22,7 +22,7 @@ |
||
22 | 22 | * @return array |
23 | 23 | */ |
24 | 24 | function check() { |
25 | - if(class_exists($this->className)) return array(EnvironmentCheck::OK, 'Class ' . $this->className.' exists'); |
|
26 | - else return array(EnvironmentCheck::ERROR, 'Class ' . $this->className.' doesn\'t exist'); |
|
25 | + if (class_exists($this->className)) return array(EnvironmentCheck::OK, 'Class ' . $this->className . ' exists'); |
|
26 | + else return array(EnvironmentCheck::ERROR, 'Class ' . $this->className . ' doesn\'t exist'); |
|
27 | 27 | } |
28 | 28 | } |
@@ -22,7 +22,10 @@ |
||
22 | 22 | * @return array |
23 | 23 | */ |
24 | 24 | function check() { |
25 | - if(class_exists($this->className)) return array(EnvironmentCheck::OK, 'Class ' . $this->className.' exists'); |
|
26 | - else return array(EnvironmentCheck::ERROR, 'Class ' . $this->className.' doesn\'t exist'); |
|
25 | + if(class_exists($this->className)) { |
|
26 | + return array(EnvironmentCheck::OK, 'Class ' . $this->className.' exists'); |
|
27 | + } else { |
|
28 | + return array(EnvironmentCheck::ERROR, 'Class ' . $this->className.' doesn\'t exist'); |
|
29 | + } |
|
27 | 30 | } |
28 | 31 | } |
@@ -28,7 +28,7 @@ |
||
28 | 28 | /** |
29 | 29 | * @inheritdoc |
30 | 30 | * |
31 | - * @return array |
|
31 | + * @return string[] |
|
32 | 32 | * |
33 | 33 | * @throws SS_HTTPResponse_Exception |
34 | 34 | */ |