@@ -1060,8 +1060,9 @@ discard block |
||
1060 | 1060 | * @return array |
1061 | 1061 | */ |
1062 | 1062 | static public function GetFullTZ($phptimezone = false) { |
1063 | - if ($phptimezone === false) |
|
1064 | - $phptimezone = date_default_timezone_get(); |
|
1063 | + if ($phptimezone === false) { |
|
1064 | + $phptimezone = date_default_timezone_get(); |
|
1065 | + } |
|
1065 | 1066 | |
1066 | 1067 | ZLog::Write(LOGLEVEL_DEBUG, "TimezoneUtil::GetFullTZ() for ". $phptimezone); |
1067 | 1068 | |
@@ -1122,9 +1123,9 @@ discard block |
||
1122 | 1123 | */ |
1123 | 1124 | static public function FillTZNames($tz) { |
1124 | 1125 | ZLog::Write(LOGLEVEL_DEBUG, "TimezoneUtil::FillTZNames() filling up bias ". $tz["bias"]); |
1125 | - if (!isset($tz["bias"])) |
|
1126 | - ZLog::Write(LOGLEVEL_WARN, "TimezoneUtil::FillTZNames() submitted TZ array does not have a bias"); |
|
1127 | - else { |
|
1126 | + if (!isset($tz["bias"])) { |
|
1127 | + ZLog::Write(LOGLEVEL_WARN, "TimezoneUtil::FillTZNames() submitted TZ array does not have a bias"); |
|
1128 | + } else { |
|
1128 | 1129 | $tzname = self::guessTZNameFromOffset($tz); |
1129 | 1130 | $tz['tzname'] = $tz['tznamedst'] = self::encodeTZName(self::getMSTZnameFromTZName($tzname)); |
1130 | 1131 | } |
@@ -1146,14 +1147,16 @@ discard block |
||
1146 | 1147 | isset($offset["dstendmonth"]) && $offset["dstendmonth"] == $tzoffset[4] && |
1147 | 1148 | isset($offset["dstendday"]) && $offset["dstendday"] == $tzoffset[6] && |
1148 | 1149 | isset($offset["dststartmonth"]) && $offset["dststartmonth"] == $tzoffset[12] && |
1149 | - isset($offset["dststartday"]) && $offset["dststartday"] == $tzoffset[14]) |
|
1150 | - return $tzname; |
|
1150 | + isset($offset["dststartday"]) && $offset["dststartday"] == $tzoffset[14]) { |
|
1151 | + return $tzname; |
|
1152 | + } |
|
1151 | 1153 | } |
1152 | 1154 | |
1153 | 1155 | // try to find a bias match |
1154 | 1156 | foreach (self::$tzonesoffsets as $tzname => $tzoffset) { |
1155 | - if ($offset["bias"] == $tzoffset[0]) |
|
1156 | - return $tzname; |
|
1157 | + if ($offset["bias"] == $tzoffset[0]) { |
|
1158 | + return $tzname; |
|
1159 | + } |
|
1157 | 1160 | } |
1158 | 1161 | |
1159 | 1162 | // nothing found? return gmt |
@@ -1198,8 +1201,9 @@ discard block |
||
1198 | 1201 | } |
1199 | 1202 | |
1200 | 1203 | foreach (self::$mstzones as $mskey => $msdefs) { |
1201 | - if ($name == $msdefs[0]) |
|
1202 | - return $msdefs[1]; |
|
1204 | + if ($name == $msdefs[0]) { |
|
1205 | + return $msdefs[1]; |
|
1206 | + } |
|
1203 | 1207 | } |
1204 | 1208 | |
1205 | 1209 | // Not found? Then retrieve the correct TZName first and try again. |
@@ -1217,8 +1221,9 @@ discard block |
||
1217 | 1221 | } |
1218 | 1222 | if ($tzName != '') { |
1219 | 1223 | foreach (self::$mstzones as $mskey => $msdefs) { |
1220 | - if ($tzName == $msdefs[0]) |
|
1221 | - return $msdefs[1]; |
|
1224 | + if ($tzName == $msdefs[0]) { |
|
1225 | + return $msdefs[1]; |
|
1226 | + } |
|
1222 | 1227 | } |
1223 | 1228 | } |
1224 | 1229 | |
@@ -1247,8 +1252,9 @@ discard block |
||
1247 | 1252 | */ |
1248 | 1253 | static public function TZtest() { |
1249 | 1254 | foreach (self::$mstzones as $mskey => $msdefs) { |
1250 | - if (!array_key_exists($msdefs[0], self::$tzonesoffsets)) |
|
1251 | - echo "key '". $msdefs[0]. "' not found in tzonesoffsets\n"; |
|
1255 | + if (!array_key_exists($msdefs[0], self::$tzonesoffsets)) { |
|
1256 | + echo "key '". $msdefs[0]. "' not found in tzonesoffsets\n"; |
|
1257 | + } |
|
1252 | 1258 | } |
1253 | 1259 | |
1254 | 1260 | foreach (self::$tzonesoffsets as $tzname => $offset) { |
@@ -1259,8 +1265,9 @@ discard block |
||
1259 | 1265 | break; |
1260 | 1266 | } |
1261 | 1267 | } |
1262 | - if (!$found) |
|
1263 | - echo "key '$tzname' NOT FOUND\n"; |
|
1268 | + if (!$found) { |
|
1269 | + echo "key '$tzname' NOT FOUND\n"; |
|
1270 | + } |
|
1264 | 1271 | } |
1265 | 1272 | } |
1266 | 1273 | |
@@ -1274,8 +1281,9 @@ discard block |
||
1274 | 1281 | */ |
1275 | 1282 | static public function GetSyncBlobFromTZ($tz) { |
1276 | 1283 | // set the correct TZ name (done using the Bias) |
1277 | - if (!isset($tz["tzname"]) || !$tz["tzname"] || !isset($tz["tznamedst"]) || !$tz["tznamedst"]) |
|
1278 | - $tz = TimezoneUtil::FillTZNames($tz); |
|
1284 | + if (!isset($tz["tzname"]) || !$tz["tzname"] || !isset($tz["tznamedst"]) || !$tz["tznamedst"]) { |
|
1285 | + $tz = TimezoneUtil::FillTZNames($tz); |
|
1286 | + } |
|
1279 | 1287 | |
1280 | 1288 | $packed = pack("la64vvvvvvvv" . "la64vvvvvvvv" . "l", |
1281 | 1289 | $tz["bias"], $tz["tzname"], 0, $tz["dstendmonth"], $tz["dstendday"], $tz["dstendweek"], $tz["dstendhour"], $tz["dstendminute"], $tz["dstendsecond"], $tz["dstendmillis"], |
@@ -12,8 +12,9 @@ |
||
12 | 12 | protected $showLegal = false; |
13 | 13 | |
14 | 14 | public function __construct($message = "", $code = 0, $previous = NULL, $logLevel = false) { |
15 | - if ($code) |
|
16 | - $this->httpReturnCode = $code; |
|
15 | + if ($code) { |
|
16 | + $this->httpReturnCode = $code; |
|
17 | + } |
|
17 | 18 | parent::__construct($message, (int) $code, $previous, $logLevel); |
18 | 19 | } |
19 | 20 | } |
@@ -15,11 +15,13 @@ |
||
15 | 15 | protected $showLegal = true; |
16 | 16 | |
17 | 17 | public function __construct($message = "", $code = 0, $previous = NULL, $logLevel = false) { |
18 | - if (! $message) |
|
19 | - $message = $this->httpReturnMessage; |
|
18 | + if (! $message) { |
|
19 | + $message = $this->httpReturnMessage; |
|
20 | + } |
|
20 | 21 | |
21 | - if (!$logLevel) |
|
22 | - $logLevel = $this->defaultLogLevel; |
|
22 | + if (!$logLevel) { |
|
23 | + $logLevel = $this->defaultLogLevel; |
|
24 | + } |
|
23 | 25 | |
24 | 26 | parent::__construct($message, (int) $code); |
25 | 27 | ZLog::Write($logLevel, get_class($this) .': '. $message . ' - code: '.$code. ' - file: '. $this->getFile().':'.$this->getLine(), false); |
@@ -10,7 +10,9 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | require_once 'vendor/autoload.php'; |
13 | -if (!defined('ZPUSH_CONFIG')) define('ZPUSH_CONFIG', 'config.php'); |
|
13 | +if (!defined('ZPUSH_CONFIG')) { |
|
14 | + define('ZPUSH_CONFIG', 'config.php'); |
|
15 | +} |
|
14 | 16 | include_once(ZPUSH_CONFIG); |
15 | 17 | |
16 | 18 | /************************************************ |
@@ -20,16 +22,20 @@ discard block |
||
20 | 22 | define('BASE_PATH_CLI', dirname(__FILE__) ."/"); |
21 | 23 | set_include_path(get_include_path() . PATH_SEPARATOR . BASE_PATH_CLI); |
22 | 24 | |
23 | - if (!defined('ZPUSH_CONFIG')) define('ZPUSH_CONFIG', BASE_PATH_CLI . 'config.php'); |
|
25 | + if (!defined('ZPUSH_CONFIG')) { |
|
26 | + define('ZPUSH_CONFIG', BASE_PATH_CLI . 'config.php'); |
|
27 | + } |
|
24 | 28 | include_once(ZPUSH_CONFIG); |
25 | 29 | |
26 | 30 | try { |
27 | 31 | ZPush::CheckConfig(); |
28 | - if (!function_exists("pcntl_signal")) |
|
29 | - throw new FatalException("Function pcntl_signal() is not available. Please install package 'php5-pcntl' (or similar) on your system."); |
|
32 | + if (!function_exists("pcntl_signal")) { |
|
33 | + throw new FatalException("Function pcntl_signal() is not available. Please install package 'php5-pcntl' (or similar) on your system."); |
|
34 | + } |
|
30 | 35 | |
31 | - if (php_sapi_name() != "cli") |
|
32 | - throw new FatalException("This script can only be called from the CLI."); |
|
36 | + if (php_sapi_name() != "cli") { |
|
37 | + throw new FatalException("This script can only be called from the CLI."); |
|
38 | + } |
|
33 | 39 | |
34 | 40 | $zpt = new ZPushTop(); |
35 | 41 | |
@@ -44,11 +50,10 @@ discard block |
||
44 | 50 | $zpt->run(); |
45 | 51 | $zpt->scrClear(); |
46 | 52 | system("stty sane"); |
53 | + } else { |
|
54 | + echo "grommunio-sync interprocess communication (IPC) is not available or TopCollector is disabled.\n"; |
|
47 | 55 | } |
48 | - else |
|
49 | - echo "grommunio-sync interprocess communication (IPC) is not available or TopCollector is disabled.\n"; |
|
50 | - } |
|
51 | - catch (ZPushException $zpe) { |
|
56 | + } catch (ZPushException $zpe) { |
|
52 | 57 | fwrite(STDERR, get_class($zpe) . ": ". $zpe->getMessage() . "\n"); |
53 | 58 | exit(1); |
54 | 59 | } |
@@ -147,8 +152,9 @@ discard block |
||
147 | 152 | $this->currenttime = time(); |
148 | 153 | |
149 | 154 | // see if shared memory is active |
150 | - if (!$this->IsAvailable()) |
|
151 | - $this->terminate = true; |
|
155 | + if (!$this->IsAvailable()) { |
|
156 | + $this->terminate = true; |
|
157 | + } |
|
152 | 158 | |
153 | 159 | // active processes should continue sending data |
154 | 160 | $this->topCollector->CollectData(); |
@@ -164,10 +170,11 @@ discard block |
||
164 | 170 | // check if screen size changed |
165 | 171 | $s = $this->scrGetSize(); |
166 | 172 | if ($this->scrSize['width'] != $s['width']) { |
167 | - if ($s['width'] > 180) |
|
168 | - $this->wide = true; |
|
169 | - else |
|
170 | - $this->wide = false; |
|
173 | + if ($s['width'] > 180) { |
|
174 | + $this->wide = true; |
|
175 | + } else { |
|
176 | + $this->wide = false; |
|
177 | + } |
|
171 | 178 | } |
172 | 179 | $this->scrSize = $s; |
173 | 180 | |
@@ -212,14 +219,16 @@ discard block |
||
212 | 219 | $this->activeUsers = array(); |
213 | 220 | $this->activeDevices = array(); |
214 | 221 | |
215 | - if (!is_array($data)) |
|
216 | - return; |
|
222 | + if (!is_array($data)) { |
|
223 | + return; |
|
224 | + } |
|
217 | 225 | |
218 | 226 | foreach ($data as $devid=>$users) { |
219 | 227 | foreach ($users as $user=>$pids) { |
220 | 228 | foreach ($pids as $pid=>$line) { |
221 | - if (!is_array($line)) |
|
222 | - continue; |
|
229 | + if (!is_array($line)) { |
|
230 | + continue; |
|
231 | + } |
|
223 | 232 | |
224 | 233 | $line['command'] = Utils::GetCommandFromCode($line['command']); |
225 | 234 | |
@@ -230,37 +239,43 @@ discard block |
||
230 | 239 | $this->activeHosts[$line['ip']] = 1; |
231 | 240 | |
232 | 241 | $line["time"] = $this->currenttime - $line['start']; |
233 | - if ($line['push'] === true) $this->pushConn += 1; |
|
242 | + if ($line['push'] === true) { |
|
243 | + $this->pushConn += 1; |
|
244 | + } |
|
234 | 245 | |
235 | 246 | // ignore push connections |
236 | - if ($line['push'] === true && ! $this->showPush) |
|
237 | - continue; |
|
247 | + if ($line['push'] === true && ! $this->showPush) { |
|
248 | + continue; |
|
249 | + } |
|
238 | 250 | |
239 | 251 | if ($this->filter !== false) { |
240 | 252 | $f = $this->filter; |
241 | 253 | if (!($line["pid"] == $f || $line["ip"] == $f || strtolower($line['command']) == strtolower($f) || preg_match("/.*?$f.*?/i", $line['user']) || |
242 | - preg_match("/.*?$f.*?/i", $line['devagent']) || preg_match("/.*?$f.*?/i", $line['devid']) || preg_match("/.*?$f.*?/i", $line['addinfo']) )) |
|
243 | - continue; |
|
254 | + preg_match("/.*?$f.*?/i", $line['devagent']) || preg_match("/.*?$f.*?/i", $line['devid']) || preg_match("/.*?$f.*?/i", $line['addinfo']) )) { |
|
255 | + continue; |
|
256 | + } |
|
244 | 257 | } |
245 | 258 | |
246 | 259 | $lastUpdate = $this->currenttime - $line["update"]; |
247 | - if ($this->currenttime - $line["update"] < 2) |
|
248 | - $this->linesActive[$line["update"].$line["pid"]] = $line; |
|
249 | - else if (($line['push'] === true && $lastUpdate > ($this->pingInterval+2)) || ($line['push'] !== true && $lastUpdate > 4)) |
|
250 | - $this->linesUnknown[$line["update"].$line["pid"]] = $line; |
|
251 | - else |
|
252 | - $this->linesOpen[$line["update"].$line["pid"]] = $line; |
|
253 | - } |
|
254 | - else { |
|
260 | + if ($this->currenttime - $line["update"] < 2) { |
|
261 | + $this->linesActive[$line["update"].$line["pid"]] = $line; |
|
262 | + } else if (($line['push'] === true && $lastUpdate > ($this->pingInterval+2)) || ($line['push'] !== true && $lastUpdate > 4)) { |
|
263 | + $this->linesUnknown[$line["update"].$line["pid"]] = $line; |
|
264 | + } else { |
|
265 | + $this->linesOpen[$line["update"].$line["pid"]] = $line; |
|
266 | + } |
|
267 | + } else { |
|
255 | 268 | // do not show terminated + expired connections |
256 | - if ($line['ended'] + $this->showTermSec < $this->currenttime) |
|
257 | - continue; |
|
269 | + if ($line['ended'] + $this->showTermSec < $this->currenttime) { |
|
270 | + continue; |
|
271 | + } |
|
258 | 272 | |
259 | 273 | if ($this->filter !== false) { |
260 | 274 | $f = $this->filter; |
261 | 275 | if (!($line['pid'] == $f || $line['ip'] == $f || strtolower($line['command']) == strtolower($f) || preg_match("/.*?$f.*?/i", $line['user']) || |
262 | - preg_match("/.*?$f.*?/i", $line['devagent']) || preg_match("/.*?$f.*?/i", $line['devid']) || preg_match("/.*?$f.*?/i", $line['addinfo']) )) |
|
263 | - continue; |
|
276 | + preg_match("/.*?$f.*?/i", $line['devagent']) || preg_match("/.*?$f.*?/i", $line['devid']) || preg_match("/.*?$f.*?/i", $line['addinfo']) )) { |
|
277 | + continue; |
|
278 | + } |
|
264 | 279 | } |
265 | 280 | |
266 | 281 | $line['time'] = $line['ended'] - $line['start']; |
@@ -336,8 +351,9 @@ discard block |
||
336 | 351 | |
337 | 352 | $linesprinted = 0; |
338 | 353 | foreach ($this->linesActive as $time=>$l) { |
339 | - if ($linesprinted >= $toPrintActive) |
|
340 | - break; |
|
354 | + if ($linesprinted >= $toPrintActive) { |
|
355 | + break; |
|
356 | + } |
|
341 | 357 | |
342 | 358 | $this->scrPrintAt($lc,0, "\033[01m" . $this->getLine($l) ."\033[0m"); |
343 | 359 | $lc++; |
@@ -346,8 +362,9 @@ discard block |
||
346 | 362 | |
347 | 363 | $linesprinted = 0; |
348 | 364 | foreach ($this->linesOpen as $time=>$l) { |
349 | - if ($linesprinted >= $toPrintOpen) |
|
350 | - break; |
|
365 | + if ($linesprinted >= $toPrintOpen) { |
|
366 | + break; |
|
367 | + } |
|
351 | 368 | |
352 | 369 | $this->scrPrintAt($lc,0, $this->getLine($l)); |
353 | 370 | $lc++; |
@@ -356,24 +373,28 @@ discard block |
||
356 | 373 | |
357 | 374 | $linesprinted = 0; |
358 | 375 | foreach ($this->linesUnknown as $time=>$l) { |
359 | - if ($linesprinted >= $toPrintUnknown) |
|
360 | - break; |
|
376 | + if ($linesprinted >= $toPrintUnknown) { |
|
377 | + break; |
|
378 | + } |
|
361 | 379 | |
362 | 380 | $color = "0;31m"; |
363 | - if ($l['push'] == false && $time - $l["start"] > 30) |
|
364 | - $color = "1;31m"; |
|
381 | + if ($l['push'] == false && $time - $l["start"] > 30) { |
|
382 | + $color = "1;31m"; |
|
383 | + } |
|
365 | 384 | $this->scrPrintAt($lc,0, "\033[0". $color . $this->getLine($l) ."\033[0m"); |
366 | 385 | $lc++; |
367 | 386 | $linesprinted++; |
368 | 387 | } |
369 | 388 | |
370 | - if ($toPrintTerm > 0) |
|
371 | - $toPrintTerm = $linesAvail - $lc +6; |
|
389 | + if ($toPrintTerm > 0) { |
|
390 | + $toPrintTerm = $linesAvail - $lc +6; |
|
391 | + } |
|
372 | 392 | |
373 | 393 | $linesprinted = 0; |
374 | 394 | foreach ($this->linesTerm as $time=>$l){ |
375 | - if ($linesprinted >= $toPrintTerm) |
|
376 | - break; |
|
395 | + if ($linesprinted >= $toPrintTerm) { |
|
396 | + break; |
|
397 | + } |
|
377 | 398 | |
378 | 399 | $this->scrPrintAt($lc,0, "\033[01;30m" . $this->getLine($l) ."\033[0m"); |
379 | 400 | $lc++; |
@@ -386,8 +407,9 @@ discard block |
||
386 | 407 | $this->scrPrintAt($lc,0, "Colorscheme: \033[01mActive \033[0mOpen \033[01;31mUnknown \033[01;30mTerminated\033[0m"); |
387 | 408 | |
388 | 409 | // remove old status |
389 | - if ($this->statusexpire < $this->currenttime) |
|
390 | - $this->status = false; |
|
410 | + if ($this->statusexpire < $this->currenttime) { |
|
411 | + $this->status = false; |
|
412 | + } |
|
391 | 413 | |
392 | 414 | // show request information and help command |
393 | 415 | if ($this->starttime + 6 > $this->currenttime) { |
@@ -397,25 +419,31 @@ discard block |
||
397 | 419 | |
398 | 420 | |
399 | 421 | $str = ""; |
400 | - if (! $this->showPush) |
|
401 | - $str .= "\033[00;32mPush: \033[01;32mNo\033[0m "; |
|
422 | + if (! $this->showPush) { |
|
423 | + $str .= "\033[00;32mPush: \033[01;32mNo\033[0m "; |
|
424 | + } |
|
402 | 425 | |
403 | - if ($this->showOption == self::SHOW_ACTIVE_ONLY) |
|
404 | - $str .= "\033[01;32mActive only\033[0m "; |
|
426 | + if ($this->showOption == self::SHOW_ACTIVE_ONLY) { |
|
427 | + $str .= "\033[01;32mActive only\033[0m "; |
|
428 | + } |
|
405 | 429 | |
406 | - if ($this->showOption == self::SHOW_UNKNOWN_ONLY) |
|
407 | - $str .= "\033[01;32mUnknown only\033[0m "; |
|
430 | + if ($this->showOption == self::SHOW_UNKNOWN_ONLY) { |
|
431 | + $str .= "\033[01;32mUnknown only\033[0m "; |
|
432 | + } |
|
408 | 433 | |
409 | - if ($this->showTermSec != self::SHOW_TERM_DEFAULT_TIME) |
|
410 | - $str .= "\033[01;32mTerminated: ". $this->showTermSec. "s\033[0m "; |
|
434 | + if ($this->showTermSec != self::SHOW_TERM_DEFAULT_TIME) { |
|
435 | + $str .= "\033[01;32mTerminated: ". $this->showTermSec. "s\033[0m "; |
|
436 | + } |
|
411 | 437 | |
412 | 438 | if ($this->filter !== false || ($this->status !== false && $this->statusexpire > $this->currenttime)) { |
413 | 439 | // print filter in green |
414 | - if ($this->filter !== false) |
|
415 | - $str .= "\033[00;32mFilter: \033[01;32m$this->filter\033[0m "; |
|
440 | + if ($this->filter !== false) { |
|
441 | + $str .= "\033[00;32mFilter: \033[01;32m$this->filter\033[0m "; |
|
442 | + } |
|
416 | 443 | // print status in red |
417 | - if ($this->status !== false) |
|
418 | - $str .= "\033[00;31m$this->status\033[0m"; |
|
444 | + if ($this->status !== false) { |
|
445 | + $str .= "\033[00;31m$this->status\033[0m"; |
|
446 | + } |
|
419 | 447 | } |
420 | 448 | $this->scrPrintAt(5,0, $str); |
421 | 449 | |
@@ -447,47 +475,40 @@ discard block |
||
447 | 475 | $this->topCollector->ClearLatest(true); |
448 | 476 | |
449 | 477 | $this->terminate = true; |
450 | - } |
|
451 | - else if ($cmds[0] == "clear" ) { |
|
478 | + } else if ($cmds[0] == "clear" ) { |
|
452 | 479 | $this->topCollector->ClearLatest(true); |
453 | 480 | $this->topCollector->CollectData(true); |
454 | 481 | $this->topCollector->ReInitIPC(); |
455 | - } |
|
456 | - else if ($cmds[0] == "filter" || $cmds[0] == "f") { |
|
482 | + } else if ($cmds[0] == "filter" || $cmds[0] == "f") { |
|
457 | 483 | if (!isset($cmds[1]) || $cmds[1] == "") { |
458 | 484 | $this->filter = false; |
459 | 485 | $this->status = "No filter"; |
460 | 486 | $this->statusexpire = $this->currenttime+5; |
461 | - } |
|
462 | - else { |
|
487 | + } else { |
|
463 | 488 | $this->filter = $cmds[1]; |
464 | 489 | $this->status = false; |
465 | 490 | } |
466 | - } |
|
467 | - else if ($cmds[0] == "option" || $cmds[0] == "o") { |
|
491 | + } else if ($cmds[0] == "option" || $cmds[0] == "o") { |
|
468 | 492 | if (!isset($cmds[1]) || $cmds[1] == "") { |
469 | 493 | $this->status = "Option value needs to be specified. See 'help' or 'h' for instructions"; |
470 | 494 | $this->statusexpire = $this->currenttime+5; |
471 | - } |
|
472 | - else if ($cmds[1] == "p" || $cmds[1] == "push" || $cmds[1] == "ping") |
|
473 | - $this->showPush = !$this->showPush; |
|
474 | - else if ($cmds[1] == "a" || $cmds[1] == "active") |
|
475 | - $this->showOption = self::SHOW_ACTIVE_ONLY; |
|
476 | - else if ($cmds[1] == "u" || $cmds[1] == "unknown") |
|
477 | - $this->showOption = self::SHOW_UNKNOWN_ONLY; |
|
478 | - else if ($cmds[1] == "d" || $cmds[1] == "default") { |
|
495 | + } else if ($cmds[1] == "p" || $cmds[1] == "push" || $cmds[1] == "ping") { |
|
496 | + $this->showPush = !$this->showPush; |
|
497 | + } else if ($cmds[1] == "a" || $cmds[1] == "active") { |
|
498 | + $this->showOption = self::SHOW_ACTIVE_ONLY; |
|
499 | + } else if ($cmds[1] == "u" || $cmds[1] == "unknown") { |
|
500 | + $this->showOption = self::SHOW_UNKNOWN_ONLY; |
|
501 | + } else if ($cmds[1] == "d" || $cmds[1] == "default") { |
|
479 | 502 | $this->showOption = self::SHOW_DEFAULT; |
480 | 503 | $this->showTermSec = self::SHOW_TERM_DEFAULT_TIME; |
481 | 504 | $this->showPush = true; |
482 | - } |
|
483 | - else if (is_numeric($cmds[1])) |
|
484 | - $this->showTermSec = $cmds[1]; |
|
485 | - else { |
|
505 | + } else if (is_numeric($cmds[1])) { |
|
506 | + $this->showTermSec = $cmds[1]; |
|
507 | + } else { |
|
486 | 508 | $this->status = sprintf("Option '%s' unknown", $cmds[1]); |
487 | 509 | $this->statusexpire = $this->currenttime+5; |
488 | 510 | } |
489 | - } |
|
490 | - else if ($cmds[0] == "reset" || $cmds[0] == "r") { |
|
511 | + } else if ($cmds[0] == "reset" || $cmds[0] == "r") { |
|
491 | 512 | $this->filter = false; |
492 | 513 | $this->wide = false; |
493 | 514 | $this->helpexpire = 0; |
@@ -499,16 +520,14 @@ discard block |
||
499 | 520 | $this->wide = ! $this->wide; |
500 | 521 | $this->status = ($this->wide)?"w i d e view" : "normal view"; |
501 | 522 | $this->statusexpire = $this->currenttime+2; |
502 | - } |
|
503 | - else if ($cmds[0] == "help" || $cmds[0] == "h") { |
|
523 | + } else if ($cmds[0] == "help" || $cmds[0] == "h") { |
|
504 | 524 | $this->helpexpire = $this->currenttime+20; |
505 | 525 | } |
506 | 526 | // grep the log file |
507 | 527 | else if (($cmds[0] == "log" || $cmds[0] == "l") && isset($cmds[1]) ) { |
508 | 528 | if (!file_exists(LOGFILE)) { |
509 | 529 | $this->status = "Logfile can not be found: ". LOGFILE; |
510 | - } |
|
511 | - else { |
|
530 | + } else { |
|
512 | 531 | system('bash -c "fgrep -a '.escapeshellarg($cmds[1]).' '. LOGFILE .' | less +G" > `tty`'); |
513 | 532 | $this->status = "Returning from log, updating data"; |
514 | 533 | } |
@@ -518,13 +537,14 @@ discard block |
||
518 | 537 | else if (($cmds[0] == "tail" || $cmds[0] == "t")) { |
519 | 538 | if (!file_exists(LOGFILE)) { |
520 | 539 | $this->status = "Logfile can not be found: ". LOGFILE; |
521 | - } |
|
522 | - else { |
|
540 | + } else { |
|
523 | 541 | $this->doingTail = true; |
524 | 542 | $this->scrClear(); |
525 | 543 | $this->scrPrintAt(1,0,$this->scrAsBold("Press CTRL+C to return to grommunio-sync-top\n\n")); |
526 | 544 | $secondary = ""; |
527 | - if (isset($cmds[1])) $secondary = " -n 200 | grep ".escapeshellarg($cmds[1]); |
|
545 | + if (isset($cmds[1])) { |
|
546 | + $secondary = " -n 200 | grep ".escapeshellarg($cmds[1]); |
|
547 | + } |
|
528 | 548 | system('bash -c "tail -f '. LOGFILE . $secondary . '" > `tty`'); |
529 | 549 | $this->doingTail = false; |
530 | 550 | $this->status = "Returning from tail, updating data"; |
@@ -535,21 +555,20 @@ discard block |
||
535 | 555 | else if (($cmds[0] == "error" || $cmds[0] == "e")) { |
536 | 556 | if (!file_exists(LOGERRORFILE)) { |
537 | 557 | $this->status = "Error logfile can not be found: ". LOGERRORFILE; |
538 | - } |
|
539 | - else { |
|
558 | + } else { |
|
540 | 559 | $this->doingTail = true; |
541 | 560 | $this->scrClear(); |
542 | 561 | $this->scrPrintAt(1,0,$this->scrAsBold("Press CTRL+C to return to grommunio-sync-top\n\n")); |
543 | 562 | $secondary = ""; |
544 | - if (isset($cmds[1])) $secondary = " -n 200 | grep ".escapeshellarg($cmds[1]); |
|
563 | + if (isset($cmds[1])) { |
|
564 | + $secondary = " -n 200 | grep ".escapeshellarg($cmds[1]); |
|
565 | + } |
|
545 | 566 | system('bash -c "tail -f '. LOGERRORFILE . $secondary . '" > `tty`'); |
546 | 567 | $this->doingTail = false; |
547 | 568 | $this->status = "Returning from tail, updating data"; |
548 | 569 | } |
549 | 570 | $this->statusexpire = time()+5; // it might be much "later" now |
550 | - } |
|
551 | - |
|
552 | - else if ($cmds[0] != "") { |
|
571 | + } else if ($cmds[0] != "") { |
|
553 | 572 | $this->status = sprintf("Command '%s' unknown", $cmds[0]); |
554 | 573 | $this->statusexpire = $this->currenttime+8; |
555 | 574 | } |
@@ -646,10 +665,11 @@ discard block |
||
646 | 665 | * @return string |
647 | 666 | */ |
648 | 667 | private function getLine($l) { |
649 | - if ($this->wide === true) |
|
650 | - return sprintf("%s%s%s%s%s%s%s%s", $this->ptStr($l['pid'],6), $this->ptStr($l['ip'],16), $this->ptStr($l['user'],24), $this->ptStr($l['command'],16), $this->ptStr($this->sec2min($l['time']),8), $this->ptStr($l['devagent'],28), $this->ptStr($l['devid'],33, true), $l['addinfo']); |
|
651 | - else |
|
652 | - return sprintf("%s%s%s%s%s%s%s%s", $this->ptStr($l['pid'],6), $this->ptStr($l['ip'],16), $this->ptStr($l['user'],8), $this->ptStr($l['command'],8), $this->ptStr($this->sec2min($l['time']),6), $this->ptStr($l['devagent'],20), $this->ptStr($l['devid'],12, true), $l['addinfo']); |
|
668 | + if ($this->wide === true) { |
|
669 | + return sprintf("%s%s%s%s%s%s%s%s", $this->ptStr($l['pid'],6), $this->ptStr($l['ip'],16), $this->ptStr($l['user'],24), $this->ptStr($l['command'],16), $this->ptStr($this->sec2min($l['time']),8), $this->ptStr($l['devagent'],28), $this->ptStr($l['devid'],33, true), $l['addinfo']); |
|
670 | + } else { |
|
671 | + return sprintf("%s%s%s%s%s%s%s%s", $this->ptStr($l['pid'],6), $this->ptStr($l['ip'],16), $this->ptStr($l['user'],8), $this->ptStr($l['command'],8), $this->ptStr($this->sec2min($l['time']),6), $this->ptStr($l['devagent'],20), $this->ptStr($l['devid'],12, true), $l['addinfo']); |
|
672 | + } |
|
653 | 673 | } |
654 | 674 | |
655 | 675 | /** |
@@ -664,13 +684,12 @@ discard block |
||
664 | 684 | * @return string |
665 | 685 | */ |
666 | 686 | private function ptStr($str, $size, $cutmiddle = false) { |
667 | - if (strlen($str) < $size) |
|
668 | - return str_pad($str, $size); |
|
669 | - else if ($cutmiddle == true) { |
|
687 | + if (strlen($str) < $size) { |
|
688 | + return str_pad($str, $size); |
|
689 | + } else if ($cutmiddle == true) { |
|
670 | 690 | $cut = ($size-2)/2; |
671 | 691 | return $this->ptStr(substr($str,0,$cut) ."..". substr($str,(-1)*($cut-1)), $size); |
672 | - } |
|
673 | - else { |
|
692 | + } else { |
|
674 | 693 | return substr($str,0,$size-3).".. "; |
675 | 694 | } |
676 | 695 | } |
@@ -684,8 +703,9 @@ discard block |
||
684 | 703 | private function scrGetSize() { |
685 | 704 | $tty = strtolower(exec('stty -a | fgrep columns')); |
686 | 705 | if (preg_match_all("/rows.([0-9]+);.columns.([0-9]+);/", $tty, $output) || |
687 | - preg_match_all("/([0-9]+).rows;.([0-9]+).columns;/", $tty, $output)) |
|
688 | - return array('width' => $output[2][0], 'height' => $output[1][0]); |
|
706 | + preg_match_all("/([0-9]+).rows;.([0-9]+).columns;/", $tty, $output)) { |
|
707 | + return array('width' => $output[2][0], 'height' => $output[1][0]); |
|
708 | + } |
|
689 | 709 | |
690 | 710 | return array('width' => 80, 'height' => 24); |
691 | 711 | } |
@@ -709,8 +729,9 @@ discard block |
||
709 | 729 | * @return string |
710 | 730 | */ |
711 | 731 | private function sec2min($s) { |
712 | - if (!is_int($s)) |
|
713 | - return $s; |
|
732 | + if (!is_int($s)) { |
|
733 | + return $s; |
|
734 | + } |
|
714 | 735 | return sprintf("%02.2d:%02.2d", floor($s/60), $s%60); |
715 | 736 | } |
716 | 737 |
@@ -758,13 +758,19 @@ discard block |
||
758 | 758 | $store = $this->store; |
759 | 759 | } else { |
760 | 760 | $ab = mapi_openaddressbook($this->session); |
761 | - if(!$ab) return false; |
|
761 | + if(!$ab) { |
|
762 | + return false; |
|
763 | + } |
|
762 | 764 | |
763 | 765 | $mailuser = mapi_ab_openentry($ab, $ownerentryid); |
764 | - if(!$mailuser) return false; |
|
766 | + if(!$mailuser) { |
|
767 | + return false; |
|
768 | + } |
|
765 | 769 | |
766 | 770 | $mailuserprops = mapi_getprops($mailuser, array(PR_EMAIL_ADDRESS)); |
767 | - if(!isset($mailuserprops[PR_EMAIL_ADDRESS])) return false; |
|
771 | + if(!isset($mailuserprops[PR_EMAIL_ADDRESS])) { |
|
772 | + return false; |
|
773 | + } |
|
768 | 774 | |
769 | 775 | $storeid = mapi_msgstore_createentryid($this->store, $mailuserprops[PR_EMAIL_ADDRESS]); |
770 | 776 | |
@@ -783,8 +789,9 @@ discard block |
||
783 | 789 | |
784 | 790 | $inbox = mapi_msgstore_getreceivefolder($store); |
785 | 791 | $inboxprops = mapi_getprops($inbox, Array(PR_IPM_TASK_ENTRYID)); |
786 | - if(!isset($inboxprops[PR_IPM_TASK_ENTRYID])) |
|
787 | - return false; |
|
792 | + if(!isset($inboxprops[PR_IPM_TASK_ENTRYID])) { |
|
793 | + return false; |
|
794 | + } |
|
788 | 795 | |
789 | 796 | return mapi_msgstore_openentry($store, $inboxprops[PR_IPM_TASK_ENTRYID]); |
790 | 797 | } |
@@ -827,10 +834,14 @@ discard block |
||
827 | 834 | $storeprops = mapi_getprops($store, array(PR_IPM_OUTBOX_ENTRYID, PR_IPM_SENTMAIL_ENTRYID)); |
828 | 835 | |
829 | 836 | $outbox = mapi_msgstore_openentry($store, $storeprops[PR_IPM_OUTBOX_ENTRYID]); |
830 | - if(!$outbox) return false; |
|
837 | + if(!$outbox) { |
|
838 | + return false; |
|
839 | + } |
|
831 | 840 | |
832 | 841 | $outgoing = mapi_folder_createmessage($outbox); |
833 | - if(!$outgoing) return false; |
|
842 | + if(!$outgoing) { |
|
843 | + return false; |
|
844 | + } |
|
834 | 845 | |
835 | 846 | // Set SENT_REPRESENTING in case we're sending as a delegate |
836 | 847 | $ownerstore = $this->getTaskFolderStore(); |
@@ -920,8 +931,9 @@ discard block |
||
920 | 931 | $rows = mapi_table_queryallrows($table, array(PR_DEFAULT_STORE, PR_ENTRYID)); |
921 | 932 | |
922 | 933 | foreach($rows as $row) { |
923 | - if($row[PR_DEFAULT_STORE]) |
|
924 | - return mapi_openmsgstore($this->session, $row[PR_ENTRYID]); |
|
934 | + if($row[PR_DEFAULT_STORE]) { |
|
935 | + return mapi_openmsgstore($this->session, $row[PR_ENTRYID]); |
|
936 | + } |
|
925 | 937 | } |
926 | 938 | |
927 | 939 | return false; |
@@ -124,8 +124,9 @@ discard block |
||
124 | 124 | } |
125 | 125 | // Properties in the attachment are the properties of the base object, plus $exception_props plus the base date |
126 | 126 | foreach (array("subject", "location", "label", "reminder", "reminder_minutes", "alldayevent", "busystatus") as $propname) { |
127 | - if(isset($this->messageprops[$this->proptags[$propname]])) |
|
128 | - $props[$this->proptags[$propname]] = $this->messageprops[$this->proptags[$propname]]; |
|
127 | + if(isset($this->messageprops[$this->proptags[$propname]])) { |
|
128 | + $props[$this->proptags[$propname]] = $this->messageprops[$this->proptags[$propname]]; |
|
129 | + } |
|
129 | 130 | } |
130 | 131 | |
131 | 132 | $props[PR_MESSAGE_CLASS] = "IPM.OLE.CLASS.{00061055-0000-0000-C000-000000000046}"; |
@@ -220,12 +221,14 @@ discard block |
||
220 | 221 | $extomodify = false; |
221 | 222 | |
222 | 223 | for($i = 0, $len = count($this->recur["changed_occurences"]); $i < $len; $i++) { |
223 | - if($this->isSameDay($this->recur["changed_occurences"][$i]["basedate"], $baseday)) |
|
224 | - $extomodify = &$this->recur["changed_occurences"][$i]; |
|
224 | + if($this->isSameDay($this->recur["changed_occurences"][$i]["basedate"], $baseday)) { |
|
225 | + $extomodify = &$this->recur["changed_occurences"][$i]; |
|
226 | + } |
|
225 | 227 | } |
226 | 228 | |
227 | - if(!$extomodify) |
|
228 | - return false; |
|
229 | + if(!$extomodify) { |
|
230 | + return false; |
|
231 | + } |
|
229 | 232 | |
230 | 233 | // remove basedate property as we want to preserve the old value |
231 | 234 | // client will send basedate with time part as zero, so discard that value |
@@ -339,10 +342,11 @@ discard block |
||
339 | 342 | $startday = $this->dayStartOf($start); |
340 | 343 | |
341 | 344 | // Get all the occurrences on the days between the basedate (may be reversed) |
342 | - if($prevday < $startday) |
|
343 | - $items = $this->getItems($this->toGMT($this->tz, $prevday), $this->toGMT($this->tz, $startday + 24 * 60 * 60)); |
|
344 | - else |
|
345 | - $items = $this->getItems($this->toGMT($this->tz, $startday), $this->toGMT($this->tz, $prevday + 24 * 60 * 60)); |
|
345 | + if($prevday < $startday) { |
|
346 | + $items = $this->getItems($this->toGMT($this->tz, $prevday), $this->toGMT($this->tz, $startday + 24 * 60 * 60)); |
|
347 | + } else { |
|
348 | + $items = $this->getItems($this->toGMT($this->tz, $startday), $this->toGMT($this->tz, $prevday + 24 * 60 * 60)); |
|
349 | + } |
|
346 | 350 | |
347 | 351 | // There should now be exactly one item, namely the item that we are modifying. If there are any other items in the range, |
348 | 352 | // then we abort the change, since one of the rules has been violated. |
@@ -371,8 +375,9 @@ discard block |
||
371 | 375 | $previousitem_startdate = $occitems[count($occitems) - 1][$this->proptags["startdate"]]; |
372 | 376 | |
373 | 377 | // if our reminder is set before or equal to the beginning of the previous occurrence, then that's not allowed |
374 | - if($startdate - ($reminderminutes*60) <= $previousitem_startdate) |
|
375 | - return false; |
|
378 | + if($startdate - ($reminderminutes*60) <= $previousitem_startdate) { |
|
379 | + return false; |
|
380 | + } |
|
376 | 381 | } |
377 | 382 | |
378 | 383 | // Get the endtime of the current occurrence and find the next two occurrences (including the current occurrence) |
@@ -385,8 +390,9 @@ discard block |
||
385 | 390 | // Get reminder time of the next occurrence. |
386 | 391 | $nextOccReminderTime = $next[$this->proptags["startdate"]] - ($next[$this->proptags["reminder_minutes"]] * 60); |
387 | 392 | // If the reminder time of the next item is before the start of this item, then that's not allowed |
388 | - if($nextOccReminderTime <= $startdate) |
|
389 | - return false; |
|
393 | + if($nextOccReminderTime <= $startdate) { |
|
394 | + return false; |
|
395 | + } |
|
390 | 396 | } |
391 | 397 | |
392 | 398 | // All was ok |
@@ -396,16 +402,19 @@ discard block |
||
396 | 402 | function setRecurrence($tz, $recur) |
397 | 403 | { |
398 | 404 | // only reset timezone if specified |
399 | - if($tz) |
|
400 | - $this->tz = $tz; |
|
405 | + if($tz) { |
|
406 | + $this->tz = $tz; |
|
407 | + } |
|
401 | 408 | |
402 | 409 | $this->recur = $recur; |
403 | 410 | |
404 | - if(!isset($this->recur["changed_occurences"])) |
|
405 | - $this->recur["changed_occurences"] = Array(); |
|
411 | + if(!isset($this->recur["changed_occurences"])) { |
|
412 | + $this->recur["changed_occurences"] = Array(); |
|
413 | + } |
|
406 | 414 | |
407 | - if(!isset($this->recur["deleted_occurences"])) |
|
408 | - $this->recur["deleted_occurences"] = Array(); |
|
415 | + if(!isset($this->recur["deleted_occurences"])) { |
|
416 | + $this->recur["deleted_occurences"] = Array(); |
|
417 | + } |
|
409 | 418 | |
410 | 419 | $this->deleteAttachments(); |
411 | 420 | $this->saveRecurrence(); |
@@ -657,18 +666,20 @@ discard block |
||
657 | 666 | $new = Array(); |
658 | 667 | |
659 | 668 | foreach($this->recur["deleted_occurences"] as $entry) { |
660 | - if($entry != $base_date) |
|
661 | - $new[] = $entry; |
|
669 | + if($entry != $base_date) { |
|
670 | + $new[] = $entry; |
|
671 | + } |
|
662 | 672 | } |
663 | 673 | $this->recur["deleted_occurences"] = $new; |
664 | 674 | |
665 | 675 | $new = Array(); |
666 | 676 | |
667 | 677 | foreach($this->recur["changed_occurences"] as $entry) { |
668 | - if(!$this->isSameDay($entry["basedate"], $base_date)) |
|
669 | - $new[] = $entry; |
|
670 | - else |
|
671 | - $this->deleteExceptionAttachment($this->toGMT($this->tz, $base_date + $this->recur["startocc"] * 60)); |
|
678 | + if(!$this->isSameDay($entry["basedate"], $base_date)) { |
|
679 | + $new[] = $entry; |
|
680 | + } else { |
|
681 | + $this->deleteExceptionAttachment($this->toGMT($this->tz, $base_date + $this->recur["startocc"] * 60)); |
|
682 | + } |
|
672 | 683 | } |
673 | 684 | |
674 | 685 | $this->recur["changed_occurences"] = $new; |
@@ -833,7 +844,7 @@ discard block |
||
833 | 844 | $exception = $this->isException($basedate); |
834 | 845 | if($exception){ |
835 | 846 | return false; |
836 | - }else{ |
|
847 | + } else{ |
|
837 | 848 | $occstart = $basedate + $startocc * 60; |
838 | 849 | $occend = $basedate + $endocc * 60; |
839 | 850 | |
@@ -849,8 +860,9 @@ discard block |
||
849 | 860 | * starts at 00:00 and ends on 00:00. if it is so, then process |
850 | 861 | * the occurrence and send it in response. |
851 | 862 | */ |
852 | - if(($occstart >= $end || $occend <= $start) && !($occstart == $occend && $occstart == $start)) |
|
853 | - return; |
|
863 | + if(($occstart >= $end || $occend <= $start) && !($occstart == $occend && $occstart == $start)) { |
|
864 | + return; |
|
865 | + } |
|
854 | 866 | |
855 | 867 | // Properties for this occurrence are the same as the main object, |
856 | 868 | // With these properties overridden |
@@ -863,8 +875,9 @@ discard block |
||
863 | 875 | } |
864 | 876 | |
865 | 877 | // If reminderonly is set, only add reminders |
866 | - if($reminderonly && (!isset($newitem[$this->proptags["reminder"]]) || $newitem[$this->proptags["reminder"]] == false)) |
|
867 | - return; |
|
878 | + if($reminderonly && (!isset($newitem[$this->proptags["reminder"]]) || $newitem[$this->proptags["reminder"]] == false)) { |
|
879 | + return; |
|
880 | + } |
|
868 | 881 | |
869 | 882 | $items[] = $newitem; |
870 | 883 | } |
@@ -886,12 +899,14 @@ discard block |
||
886 | 899 | |
887 | 900 | // Check range criterium. Exact matches (eg when $occstart == $end), do NOT match since you cannot |
888 | 901 | // see any part of the appointment. Partial overlaps DO match. |
889 | - if($occstart >= $end || $occend <= $start) |
|
890 | - continue; |
|
902 | + if($occstart >= $end || $occend <= $start) { |
|
903 | + continue; |
|
904 | + } |
|
891 | 905 | |
892 | 906 | array_push($items, $this->getExceptionProperties($exception)); |
893 | - if((count($items) == $limit)) |
|
894 | - break; |
|
907 | + if((count($items) == $limit)) { |
|
908 | + break; |
|
909 | + } |
|
895 | 910 | } |
896 | 911 | } |
897 | 912 | |
@@ -902,11 +917,13 @@ discard block |
||
902 | 917 | */ |
903 | 918 | function isException($basedate) |
904 | 919 | { |
905 | - if($this->isDeleteException($basedate)) |
|
906 | - return true; |
|
920 | + if($this->isDeleteException($basedate)) { |
|
921 | + return true; |
|
922 | + } |
|
907 | 923 | |
908 | - if($this->getChangeException($basedate) != false) |
|
909 | - return true; |
|
924 | + if($this->getChangeException($basedate) != false) { |
|
925 | + return true; |
|
926 | + } |
|
910 | 927 | |
911 | 928 | return false; |
912 | 929 | } |
@@ -919,8 +936,9 @@ discard block |
||
919 | 936 | // Check if the occurrence is deleted on the specified date |
920 | 937 | foreach($this->recur["deleted_occurences"] as $deleted) |
921 | 938 | { |
922 | - if($this->isSameDay($deleted, $basedate)) |
|
923 | - return true; |
|
939 | + if($this->isSameDay($deleted, $basedate)) { |
|
940 | + return true; |
|
941 | + } |
|
924 | 942 | } |
925 | 943 | |
926 | 944 | return false; |
@@ -934,8 +952,9 @@ discard block |
||
934 | 952 | // Check if the occurrence is modified on the specified date |
935 | 953 | foreach($this->recur["changed_occurences"] as $changed) |
936 | 954 | { |
937 | - if($this->isSameDay($changed["basedate"], $basedate)) |
|
938 | - return $changed; |
|
955 | + if($this->isSameDay($changed["basedate"], $basedate)) { |
|
956 | + return $changed; |
|
957 | + } |
|
939 | 958 | } |
940 | 959 | |
941 | 960 | return false; |
@@ -1120,8 +1139,9 @@ discard block |
||
1120 | 1139 | foreach($recipientRows as $key => $recipient) { |
1121 | 1140 | $found = false; |
1122 | 1141 | foreach($exception_recips as $excep_recip) { |
1123 | - if (isset($recipient[PR_SEARCH_KEY], $excep_recip[PR_SEARCH_KEY]) && $recipient[PR_SEARCH_KEY] == $excep_recip[PR_SEARCH_KEY]) |
|
1124 | - $found = true; |
|
1142 | + if (isset($recipient[PR_SEARCH_KEY], $excep_recip[PR_SEARCH_KEY]) && $recipient[PR_SEARCH_KEY] == $excep_recip[PR_SEARCH_KEY]) { |
|
1143 | + $found = true; |
|
1144 | + } |
|
1125 | 1145 | } |
1126 | 1146 | |
1127 | 1147 | if (!$found) { |
@@ -5,8 +5,9 @@ |
||
5 | 5 | * SPDX-FileCopyrightText: Copyright 2020-2022 grommunio GmbH |
6 | 6 | */ |
7 | 7 | |
8 | -if (!function_exists("mapi_prop_tag")) |
|
8 | +if (!function_exists("mapi_prop_tag")) { |
|
9 | 9 | throw new FatalMisconfigurationException("PHP-MAPI extension is not available"); |
10 | +} |
|
10 | 11 | |
11 | 12 | define('PR_ACKNOWLEDGEMENT_MODE' ,mapi_prop_tag(PT_LONG, 0x0001)); |
12 | 13 | define('PR_ALTERNATE_RECIPIENT_ALLOWED' ,mapi_prop_tag(PT_BOOLEAN, 0x0002)); |
@@ -200,11 +200,13 @@ discard block |
||
200 | 200 | while(1) { |
201 | 201 | $rows = mapi_table_queryrows($contents, array_values($this->proptags), 0, 50); |
202 | 202 | |
203 | - if(!is_array($rows)) |
|
204 | - break; |
|
203 | + if(!is_array($rows)) { |
|
204 | + break; |
|
205 | + } |
|
205 | 206 | |
206 | - if(empty($rows)) |
|
207 | - break; |
|
207 | + if(empty($rows)) { |
|
208 | + break; |
|
209 | + } |
|
208 | 210 | |
209 | 211 | foreach ($rows as $row) { |
210 | 212 | $occurrences = Array(); |
@@ -260,9 +262,9 @@ discard block |
||
260 | 262 | |
261 | 263 | // We're finished |
262 | 264 | mapi_freebusysupport_close($fbsupport); |
265 | + } else { |
|
266 | + ZLog::Write(LOGLEVEL_WARN, "FreeBusyPublish is not available"); |
|
263 | 267 | } |
264 | - else |
|
265 | - ZLog::Write(LOGLEVEL_WARN, "FreeBusyPublish is not available"); |
|
266 | 268 | } |
267 | 269 | |
268 | 270 | /** |
@@ -271,10 +273,12 @@ discard block |
||
271 | 273 | function cmp($a, $b) |
272 | 274 | { |
273 | 275 | if ($a["time"] == $b["time"]) { |
274 | - if($a["type"] < $b["type"]) |
|
275 | - return 1; |
|
276 | - if($a["type"] > $b["type"]) |
|
277 | - return -1; |
|
276 | + if($a["type"] < $b["type"]) { |
|
277 | + return 1; |
|
278 | + } |
|
279 | + if($a["type"] > $b["type"]) { |
|
280 | + return -1; |
|
281 | + } |
|
278 | 282 | return 0; |
279 | 283 | } |
280 | 284 | return ($a["time"] > $b["time"] ? 1 : -1); |
@@ -322,8 +326,9 @@ discard block |
||
322 | 326 | $newitem["end"] = $ts["time"]; |
323 | 327 | $newitem["subject"] = join(",", $csubj); |
324 | 328 | $newitem["status"] = !empty($cbusy) ? max($cbusy) : 0; |
325 | - if($newitem["status"] > 0) |
|
326 | - $merged[] = $newitem; |
|
329 | + if($newitem["status"] > 0) { |
|
330 | + $merged[] = $newitem; |
|
331 | + } |
|
327 | 332 | } |
328 | 333 | |
329 | 334 | $level++; |
@@ -340,8 +345,9 @@ discard block |
||
340 | 345 | $newitem["end"] = $ts["time"]; |
341 | 346 | $newitem["subject"] = join(",", $csubj); |
342 | 347 | $newitem["status"] = !empty($cbusy) ? max($cbusy) : 0; |
343 | - if($newitem["status"] > 0) |
|
344 | - $merged[] = $newitem; |
|
348 | + if($newitem["status"] > 0) { |
|
349 | + $merged[] = $newitem; |
|
350 | + } |
|
345 | 351 | } |
346 | 352 | |
347 | 353 | $level--; |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | $guids[$split[1]] = makeguid($split[1]); |
104 | 104 | } |
105 | 105 | $guid = $guids[$split[1]]; |
106 | - }else{ |
|
106 | + } else{ |
|
107 | 107 | $guid = constant($split[1]); |
108 | 108 | } |
109 | 109 | |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | $ids["guid"][$num] = $guid; |
114 | 114 | $ids["type"][$num] = $split[0]; |
115 | 115 | $num++; |
116 | - }else{ |
|
116 | + } else{ |
|
117 | 117 | // not a named property |
118 | 118 | $props[$name] = $val; |
119 | 119 | } |