Passed
Branch master (ff9d34)
by Mike
09:14
created
lib/utils/stringstreamwrapper.php 3 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
         return $this->position;
105 105
     }
106 106
 
107
-   /**
107
+    /**
108 108
      * Indicates if 'end of file' is reached
109 109
      *
110 110
      * @access public
@@ -133,11 +133,11 @@  discard block
 block discarded – undo
133 133
     }
134 134
 
135 135
     /**
136
-    * Retrieves information about a stream
137
-    *
138
-    * @access public
139
-    * @return array
140
-    */
136
+     * Retrieves information about a stream
137
+     *
138
+     * @access public
139
+     * @return array
140
+     */
141 141
     public function stream_stat() {
142 142
         return array(
143 143
             7               => $this->stringlength,
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
         );
146 146
     }
147 147
 
148
-   /**
148
+    /**
149 149
      * Instantiates a StringStreamWrapper
150 150
      *
151 151
      * @param string    $string             The string to be wrapped
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
      * @access public
155 155
      * @return StringStreamWrapper
156 156
      */
157
-     static public function Open($string, $truncatehtmlsafe = false) {
157
+        static public function Open($string, $truncatehtmlsafe = false) {
158 158
         $context = stream_context_create(array(self::PROTOCOL => array('string' => &$string, 'truncatehtmlsafe' => $truncatehtmlsafe)));
159 159
         return fopen(self::PROTOCOL . "://",'r', false, $context);
160 160
     }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
         $this->truncateHtmlSafe = (isset($contextOptions[self::PROTOCOL]['truncatehtmlsafe'])) ? $contextOptions[self::PROTOCOL]['truncatehtmlsafe'] : false;
43 43
 
44 44
         $this->stringlength = strlen($this->stringstream);
45
-        ZLog::Write(LOGLEVEL_DEBUG, sprintf("StringStreamWrapper::stream_open(): initialized stream length: %d - HTML-safe-truncate: %s", $this->stringlength,  Utils::PrintAsString($this->truncateHtmlSafe)));
45
+        ZLog::Write(LOGLEVEL_DEBUG, sprintf("StringStreamWrapper::stream_open(): initialized stream length: %d - HTML-safe-truncate: %s", $this->stringlength, Utils::PrintAsString($this->truncateHtmlSafe)));
46 46
 
47 47
         return true;
48 48
     }
@@ -67,9 +67,9 @@  discard block
 block discarded – undo
67 67
      * @param string $data
68 68
      * @return int
69 69
      */
70
-    public function stream_write($data){
70
+    public function stream_write($data) {
71 71
         $l = strlen($data);
72
-        $this->stringstream = substr($this->stringstream, 0, $this->position) . $data . substr($this->stringstream, $this->position += $l);
72
+        $this->stringstream = substr($this->stringstream, 0, $this->position).$data.substr($this->stringstream, $this->position += $l);
73 73
         $this->stringlength = strlen($this->stringstream);
74 74
         return $l;
75 75
     }
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
      * @param int $new_size
121 121
      * @return boolean
122 122
      */
123
-    public function stream_truncate ($new_size) {
123
+    public function stream_truncate($new_size) {
124 124
         // cut the string!
125 125
         $this->stringstream = Utils::Utf8_truncate($this->stringstream, $new_size, $this->truncateHtmlSafe);
126 126
         $this->stringlength = strlen($this->stringstream);
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
      */
157 157
      static public function Open($string, $truncatehtmlsafe = false) {
158 158
         $context = stream_context_create(array(self::PROTOCOL => array('string' => &$string, 'truncatehtmlsafe' => $truncatehtmlsafe)));
159
-        return fopen(self::PROTOCOL . "://",'r', false, $context);
159
+        return fopen(self::PROTOCOL."://", 'r', false, $context);
160 160
     }
161 161
 }
162 162
 
Please login to merge, or discard this patch.
Braces   +5 added lines, -6 removed lines patch added patch discarded remove patch
@@ -32,8 +32,9 @@  discard block
 block discarded – undo
32 32
      */
33 33
     public function stream_open($path, $mode, $options, &$opened_path) {
34 34
         $contextOptions = stream_context_get_options($this->context);
35
-        if (!isset($contextOptions[self::PROTOCOL]['string']))
36
-            return false;
35
+        if (!isset($contextOptions[self::PROTOCOL]['string'])) {
36
+                    return false;
37
+        }
37 38
 
38 39
         $this->position = 0;
39 40
 
@@ -84,11 +85,9 @@  discard block
 block discarded – undo
84 85
     public function stream_seek($offset, $whence = SEEK_SET) {
85 86
         if ($whence == SEEK_CUR) {
86 87
             $this->position += $offset;
87
-        }
88
-        else if ($whence == SEEK_END) {
88
+        } else if ($whence == SEEK_END) {
89 89
             $this->position = $this->stringlength + $offset;
90
-        }
91
-        else {
90
+        } else {
92 91
             $this->position = $offset;
93 92
         }
94 93
         return true;
Please login to merge, or discard this patch.
lib/utils/g_RFC822.php 4 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -136,9 +136,9 @@  discard block
 block discarded – undo
136 136
     var $mailRFC822 = true;
137 137
 
138 138
     /**
139
-    * A limit after which processing stops
140
-    * @var int $limit
141
-    */
139
+     * A limit after which processing stops
140
+     * @var int $limit
141
+     */
142 142
     var $limit = null;
143 143
 
144 144
     /**
@@ -272,9 +272,9 @@  discard block
 block discarded – undo
272 272
         // $string now contains the first full address/group.
273 273
         // Add to the addresses array.
274 274
         $this->addresses[] = array(
275
-                                   'address' => trim($string),
276
-                                   'group'   => $is_group
277
-                                   );
275
+                                    'address' => trim($string),
276
+                                    'group'   => $is_group
277
+                                    );
278 278
 
279 279
         // Remove the now stored address from the initial line, the +1
280 280
         // is to account for the explode character.
Please login to merge, or discard this patch.
Switch Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -369,19 +369,19 @@
 block discarded – undo
369 369
 
370 370
         for (; $i < $iMax; ++$i) {
371 371
             switch ($string[$i]) {
372
-            case '\\':
373
-                ++$slashes;
374
-                break;
375
-
376
-            case '"':
377
-                if ($slashes % 2 == 0) {
378
-                    $in_quote = !$in_quote;
379
-                }
380
-                // Fall through to default action below.
381
-
382
-            default:
383
-                $slashes = 0;
384
-                break;
372
+                case '\\':
373
+                    ++$slashes;
374
+                    break;
375
+
376
+                case '"':
377
+                    if ($slashes % 2 == 0) {
378
+                        $in_quote = !$in_quote;
379
+                    }
380
+                    // Fall through to default action below.
381
+
382
+                default:
383
+                    $slashes = 0;
384
+                    break;
385 385
             }
386 386
         }
387 387
 
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 
257 257
             // First check there's a colon at all:
258 258
             if (strpos($string, ':') === false) {
259
-                $this->error = 'Invalid address: ' . $string;
259
+                $this->error = 'Invalid address: '.$string;
260 260
                 return false;
261 261
             }
262 262
 
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
         // If the next char is a comma and this was a group, then
284 284
         // there are more addresses, otherwise, if there are any more
285 285
         // chars, then there is another address.
286
-        if ($is_group && substr($address, 0, 1) == ','){
286
+        if ($is_group && substr($address, 0, 1) == ',') {
287 287
             $address = trim(substr($address, 1));
288 288
             return $address;
289 289
 
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
                 || $this->_hasUnclosedBrackets($string, '()')
340 340
                 || substr($string, -1) == '\\') {
341 341
                 if (isset($parts[$i + 1])) {
342
-                    $string = $string . $char . $parts[$i + 1];
342
+                    $string = $string.$char.$parts[$i + 1];
343 343
                 } else {
344 344
                     $this->error = 'Invalid address spec. Unclosed bracket or quotes';
345 345
                     return false;
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
         $this->_hasUnclosedBracketsSub($string, $num_angle_end, $chars[1]);
406 406
 
407 407
         if ($num_angle_start < $num_angle_end) {
408
-            $this->error = 'Invalid address spec. Unmatched quote or bracket (' . $chars . ')';
408
+            $this->error = 'Invalid address spec. Unmatched quote or bracket ('.$chars.')';
409 409
             return false;
410 410
         } else {
411 411
             return ($num_angle_start > $num_angle_end);
@@ -423,11 +423,11 @@  discard block
 block discarded – undo
423 423
     protected function _hasUnclosedBracketsSub($string, &$num, $char)
424 424
     {
425 425
         $parts = explode($char, $string);
426
-        for ($i = 0; $i < count($parts); $i++){
426
+        for ($i = 0; $i < count($parts); $i++) {
427 427
             if (substr($parts[$i], -1) == '\\' || $this->_hasUnclosedQuotes($parts[$i]))
428 428
                 $num--;
429 429
             if (isset($parts[$i + 1]))
430
-                $parts[$i + 1] = $parts[$i] . $char . $parts[$i + 1];
430
+                $parts[$i + 1] = $parts[$i].$char.$parts[$i + 1];
431 431
         }
432 432
 
433 433
         return $num;
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
             $structure = array();
454 454
 
455 455
             // And validate the group part of the name.
456
-            if (!$this->_validatePhrase($groupname)){
456
+            if (!$this->_validatePhrase($groupname)) {
457 457
                 $this->error = 'Group name did not validate.';
458 458
                 return false;
459 459
             } else {
@@ -465,7 +465,7 @@  discard block
 block discarded – undo
465 465
                 }
466 466
             }
467 467
 
468
-            $address['address'] = ltrim(substr($address['address'], strlen($groupname . ':')));
468
+            $address['address'] = ltrim(substr($address['address'], strlen($groupname.':')));
469 469
         }
470 470
 
471 471
         // If a group then split on comma and put into an array.
@@ -474,7 +474,7 @@  discard block
 block discarded – undo
474 474
             while (strlen($address['address']) > 0) {
475 475
                 $parts       = explode(',', $address['address']);
476 476
                 $addresses[] = $this->_splitCheck($parts, ',');
477
-                $address['address'] = trim(substr($address['address'], strlen(end($addresses) . ',')));
477
+                $address['address'] = trim(substr($address['address'], strlen(end($addresses).',')));
478 478
             }
479 479
         } else {
480 480
             $addresses[] = $address['address'];
@@ -491,7 +491,7 @@  discard block
 block discarded – undo
491 491
         for ($i = 0; $i < count($addresses); $i++) {
492 492
             if (!$this->validateMailbox($addresses[$i])) {
493 493
                 if (empty($this->error)) {
494
-                    $this->error = 'Validation failed for: ' . $addresses[$i];
494
+                    $this->error = 'Validation failed for: '.$addresses[$i];
495 495
                 }
496 496
                 return false;
497 497
             }
@@ -529,7 +529,7 @@  discard block
 block discarded – undo
529 529
         $parts = preg_split('/[ \\x09]+/', $phrase, -1, PREG_SPLIT_NO_EMPTY);
530 530
 
531 531
         $phrase_parts = array();
532
-        while (count($parts) > 0){
532
+        while (count($parts) > 0) {
533 533
             $phrase_parts[] = $this->_splitCheck($parts, ' ');
534 534
             for ($i = 0; $i < $this->index + 1; $i++)
535 535
                 array_shift($parts);
@@ -632,7 +632,7 @@  discard block
 block discarded – undo
632 632
                 $comments[] = $comment;
633 633
 
634 634
                 // +2 is for the brackets
635
-                $_mailbox = substr($_mailbox, strpos($_mailbox, '('.$comment)+strlen($comment)+2);
635
+                $_mailbox = substr($_mailbox, strpos($_mailbox, '('.$comment) + strlen($comment) + 2);
636 636
             } else {
637 637
                 break;
638 638
             }
@@ -717,7 +717,7 @@  discard block
 block discarded – undo
717 717
 
718 718
         // If $route is same as $route_addr then the colon was in
719 719
         // quotes or brackets or, of course, non existent.
720
-        if ($route === $route_addr){
720
+        if ($route === $route_addr) {
721 721
             unset($route);
722 722
             $addr_spec = $route_addr;
723 723
             if (($addr_spec = $this->_validateAddrSpec($addr_spec)) === false) {
@@ -729,7 +729,7 @@  discard block
 block discarded – undo
729 729
                 return false;
730 730
             }
731 731
 
732
-            $addr_spec = substr($route_addr, strlen($route . ':'));
732
+            $addr_spec = substr($route_addr, strlen($route.':'));
733 733
 
734 734
             // Validate addr-spec part.
735 735
             if (($addr_spec = $this->_validateAddrSpec($addr_spec)) === false) {
@@ -805,7 +805,7 @@  discard block
 block discarded – undo
805 805
      */
806 806
     protected function _validateSubdomain($subdomain)
807 807
     {
808
-        if (preg_match('|^\[(.*)]$|', $subdomain, $arr)){
808
+        if (preg_match('|^\[(.*)]$|', $subdomain, $arr)) {
809 809
             if (!$this->_validateDliteral($arr[1])) return false;
810 810
         } else {
811 811
             if (!$this->_validateAtom($subdomain)) return false;
@@ -824,7 +824,7 @@  discard block
 block discarded – undo
824 824
      */
825 825
     protected function _validateDliteral($dliteral)
826 826
     {
827
-        return !preg_match('/(.)[][\x0D\\\\]/', $dliteral, $matches) && ((! isset($matches[1])) || $matches[1] != '\\');
827
+        return !preg_match('/(.)[][\x0D\\\\]/', $dliteral, $matches) && ((!isset($matches[1])) || $matches[1] != '\\');
828 828
     }
829 829
 
830 830
     /**
@@ -843,7 +843,7 @@  discard block
 block discarded – undo
843 843
         if (strpos($addr_spec, '@') !== false) {
844 844
             $parts      = explode('@', $addr_spec);
845 845
             $local_part = $this->_splitCheck($parts, '@');
846
-            $domain     = substr($addr_spec, strlen($local_part . '@'));
846
+            $domain     = substr($addr_spec, strlen($local_part.'@'));
847 847
 
848 848
         // No @ sign so assume the default domain.
849 849
         } else {
@@ -943,7 +943,7 @@  discard block
 block discarded – undo
943 943
      * @access private
944 944
      */
945 945
     function raiseError($message) {
946
-        ZLog::Write(LOGLEVEL_ERROR, "z_RFC822 error: ". $message);
946
+        ZLog::Write(LOGLEVEL_ERROR, "z_RFC822 error: ".$message);
947 947
         return false;
948 948
     }
949 949
 }
Please login to merge, or discard this patch.
Braces   +69 added lines, -28 removed lines patch added patch discarded remove patch
@@ -154,11 +154,21 @@  discard block
 block discarded – undo
154 154
      */
155 155
     public function __construct($address = null, $default_domain = null, $nest_groups = null, $validate = null, $limit = null)
156 156
     {
157
-        if (isset($address))        $this->address        = $address;
158
-        if (isset($default_domain)) $this->default_domain = $default_domain;
159
-        if (isset($nest_groups))    $this->nestGroups     = $nest_groups;
160
-        if (isset($validate))       $this->validate       = $validate;
161
-        if (isset($limit))          $this->limit          = $limit;
157
+        if (isset($address)) {
158
+            $this->address        = $address;
159
+        }
160
+        if (isset($default_domain)) {
161
+            $this->default_domain = $default_domain;
162
+        }
163
+        if (isset($nest_groups)) {
164
+            $this->nestGroups     = $nest_groups;
165
+        }
166
+        if (isset($validate)) {
167
+            $this->validate       = $validate;
168
+        }
169
+        if (isset($limit)) {
170
+            $this->limit          = $limit;
171
+        }
162 172
     }
163 173
 
164 174
     /**
@@ -179,13 +189,25 @@  discard block
 block discarded – undo
179 189
             return $obj->parseAddressList();
180 190
         }
181 191
 
182
-        if (isset($address))        $this->address        = $address;
192
+        if (isset($address)) {
193
+            $this->address        = $address;
194
+        }
183 195
         // grommunio-sync addition
184
-        if (strlen(trim($this->address)) == 0) return array();
185
-        if (isset($default_domain)) $this->default_domain = $default_domain;
186
-        if (isset($nest_groups))    $this->nestGroups     = $nest_groups;
187
-        if (isset($validate))       $this->validate       = $validate;
188
-        if (isset($limit))          $this->limit          = $limit;
196
+        if (strlen(trim($this->address)) == 0) {
197
+            return array();
198
+        }
199
+        if (isset($default_domain)) {
200
+            $this->default_domain = $default_domain;
201
+        }
202
+        if (isset($nest_groups)) {
203
+            $this->nestGroups     = $nest_groups;
204
+        }
205
+        if (isset($validate)) {
206
+            $this->validate       = $validate;
207
+        }
208
+        if (isset($limit)) {
209
+            $this->limit          = $limit;
210
+        }
189 211
 
190 212
         $this->structure  = array();
191 213
         $this->addresses  = array();
@@ -424,10 +446,12 @@  discard block
 block discarded – undo
424 446
     {
425 447
         $parts = explode($char, $string);
426 448
         for ($i = 0; $i < count($parts); $i++){
427
-            if (substr($parts[$i], -1) == '\\' || $this->_hasUnclosedQuotes($parts[$i]))
428
-                $num--;
429
-            if (isset($parts[$i + 1]))
430
-                $parts[$i + 1] = $parts[$i] . $char . $parts[$i + 1];
449
+            if (substr($parts[$i], -1) == '\\' || $this->_hasUnclosedQuotes($parts[$i])) {
450
+                            $num--;
451
+            }
452
+            if (isset($parts[$i + 1])) {
453
+                            $parts[$i + 1] = $parts[$i] . $char . $parts[$i + 1];
454
+            }
431 455
         }
432 456
 
433 457
         return $num;
@@ -531,8 +555,9 @@  discard block
 block discarded – undo
531 555
         $phrase_parts = array();
532 556
         while (count($parts) > 0){
533 557
             $phrase_parts[] = $this->_splitCheck($parts, ' ');
534
-            for ($i = 0; $i < $this->index + 1; $i++)
535
-                array_shift($parts);
558
+            for ($i = 0; $i < $this->index + 1; $i++) {
559
+                            array_shift($parts);
560
+            }
536 561
         }
537 562
 
538 563
         foreach ($phrase_parts as $part) {
@@ -545,7 +570,9 @@  discard block
 block discarded – undo
545 570
             }
546 571
 
547 572
             // Otherwise it's an atom:
548
-            if (!$this->_validateAtom($part)) return false;
573
+            if (!$this->_validateAtom($part)) {
574
+                return false;
575
+            }
549 576
         }
550 577
 
551 578
         return true;
@@ -761,7 +788,9 @@  discard block
 block discarded – undo
761 788
 
762 789
         foreach ($domains as $domain) {
763 790
             $domain = str_replace('@', '', trim($domain));
764
-            if (!$this->_validateDomain($domain)) return false;
791
+            if (!$this->_validateDomain($domain)) {
792
+                return false;
793
+            }
765 794
         }
766 795
 
767 796
         return $route;
@@ -783,13 +812,15 @@  discard block
 block discarded – undo
783 812
 
784 813
         while (count($subdomains) > 0) {
785 814
             $sub_domains[] = $this->_splitCheck($subdomains, '.');
786
-            for ($i = 0; $i < $this->index + 1; $i++)
787
-                array_shift($subdomains);
815
+            for ($i = 0; $i < $this->index + 1; $i++) {
816
+                            array_shift($subdomains);
817
+            }
788 818
         }
789 819
 
790 820
         foreach ($sub_domains as $sub_domain) {
791
-            if (!$this->_validateSubdomain(trim($sub_domain)))
792
-                return false;
821
+            if (!$this->_validateSubdomain(trim($sub_domain))) {
822
+                            return false;
823
+            }
793 824
         }
794 825
 
795 826
         // Managed to get here, so return input.
@@ -806,9 +837,13 @@  discard block
 block discarded – undo
806 837
     protected function _validateSubdomain($subdomain)
807 838
     {
808 839
         if (preg_match('|^\[(.*)]$|', $subdomain, $arr)){
809
-            if (!$this->_validateDliteral($arr[1])) return false;
840
+            if (!$this->_validateDliteral($arr[1])) {
841
+                return false;
842
+            }
810 843
         } else {
811
-            if (!$this->_validateAtom($subdomain)) return false;
844
+            if (!$this->_validateAtom($subdomain)) {
845
+                return false;
846
+            }
812 847
         }
813 848
 
814 849
         // Got here, so return successful.
@@ -851,8 +886,12 @@  discard block
 block discarded – undo
851 886
             $domain     = $this->default_domain;
852 887
         }
853 888
 
854
-        if (($local_part = $this->_validateLocalPart($local_part)) === false) return false;
855
-        if (($domain     = $this->_validateDomain($domain)) === false) return false;
889
+        if (($local_part = $this->_validateLocalPart($local_part)) === false) {
890
+            return false;
891
+        }
892
+        if (($domain     = $this->_validateDomain($domain)) === false) {
893
+            return false;
894
+        }
856 895
 
857 896
         // Got here so return successful.
858 897
         return array('local_part' => $local_part, 'domain' => $domain);
@@ -890,7 +929,9 @@  discard block
 block discarded – undo
890 929
                 return false;
891 930
             }
892 931
 
893
-            if ($this->_validatePhrase(trim($word)) === false) return false;
932
+            if ($this->_validatePhrase(trim($word)) === false) {
933
+                return false;
934
+            }
894 935
         }
895 936
 
896 937
         // Managed to get here, so return the input.
Please login to merge, or discard this patch.
lib/utils/compat.php 3 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -9,11 +9,11 @@
 block discarded – undo
9 9
 
10 10
 if (!function_exists('apache_request_headers')) {
11 11
     /**
12
-      * When using other webservers or using php as cgi in apache
13
-      * the function apache_request_headers() is not available.
14
-      * This function parses the environment variables to extract
15
-      * the necessary headers for grommunio-sync
16
-      */
12
+     * When using other webservers or using php as cgi in apache
13
+     * the function apache_request_headers() is not available.
14
+     * This function parses the environment variables to extract
15
+     * the necessary headers for grommunio-sync
16
+     */
17 17
     function apache_request_headers() {
18 18
         $headers = array();
19 19
         foreach ($_SERVER as $key => $value)
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -84,12 +84,12 @@
 block discarded – undo
84 84
                 case 504: $text = 'Gateway Time-out'; break;
85 85
                 case 505: $text = 'HTTP Version not supported'; break;
86 86
                 default:
87
-                    exit('Unknown http status code "' . htmlentities($code) . '"');
87
+                    exit('Unknown http status code "'.htmlentities($code).'"');
88 88
                     break;
89 89
             }
90 90
 
91 91
             $protocol = (isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0');
92
-            header($protocol . ' ' . $code . ' ' . $text);
92
+            header($protocol.' '.$code.' '.$text);
93 93
 
94 94
             $GLOBALS['http_response_code'] = $code;
95 95
         } else {
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,9 +16,10 @@
 block discarded – undo
16 16
       */
17 17
     function apache_request_headers() {
18 18
         $headers = array();
19
-        foreach ($_SERVER as $key => $value)
20
-            if (substr($key, 0, 5) == 'HTTP_')
19
+        foreach ($_SERVER as $key => $value) {
20
+                    if (substr($key, 0, 5) == 'HTTP_')
21 21
                 $headers[strtr(substr($key, 5), '_', '-')] = $value;
22
+        }
22 23
 
23 24
         return $headers;
24 25
     }
Please login to merge, or discard this patch.
lib/utils/utils.php 3 patches
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
      * @return string
18 18
      */
19 19
     static public function PrintAsString($var) {
20
-       return ($var)?(($var===true)?'true':$var):(($var===false)?'false':(($var==='')?'empty':(($var === null) ? 'null':$var)));
20
+        return ($var)?(($var===true)?'true':$var):(($var===false)?'false':(($var==='')?'empty':(($var === null) ? 'null':$var)));
21 21
     }
22 22
 
23 23
     /**
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
             return hex2bin("040000008200E00074C5B7101A82E0080000000000000000000000000000000000000000". bin2hex($OLUid). "00");
240 240
         }
241 241
         else
242
-           return hex2bin($icalUid);
242
+            return hex2bin($icalUid);
243 243
     }
244 244
 
245 245
     /**
@@ -546,18 +546,18 @@  discard block
 block discarded – undo
546 546
     }
547 547
 
548 548
 
549
-   /**
550
-    * Get charset name from a codepage
551
-    *
552
-    * @see http://msdn.microsoft.com/en-us/library/dd317756(VS.85).aspx
553
-    *
554
-    * Table taken from common/codepage.cpp
555
-    *
556
-    * @param integer codepage Codepage
557
-    *
558
-    * @access public
559
-    * @return string iconv-compatible charset name
560
-    */
549
+    /**
550
+     * Get charset name from a codepage
551
+     *
552
+     * @see http://msdn.microsoft.com/en-us/library/dd317756(VS.85).aspx
553
+     *
554
+     * Table taken from common/codepage.cpp
555
+     *
556
+     * @param integer codepage Codepage
557
+     *
558
+     * @access public
559
+     * @return string iconv-compatible charset name
560
+     */
561 561
     public static function GetCodepageCharset($codepage) {
562 562
         $codepages = array(
563 563
             20106 => "DIN_66003",
@@ -696,8 +696,8 @@  discard block
 block discarded – undo
696 696
      */
697 697
     public static function FixFileOwner($file) {
698 698
         if (!function_exists('posix_getuid')) {
699
-           ZLog::Write(LOGLEVEL_DEBUG, "Utils::FixeFileOwner(): Posix subsystem not available, skipping.");
700
-           return false;
699
+            ZLog::Write(LOGLEVEL_DEBUG, "Utils::FixeFileOwner(): Posix subsystem not available, skipping.");
700
+            return false;
701 701
         }
702 702
         if (posix_getuid() == 0 && is_file($file)) {
703 703
             $dir = dirname($file);
Please login to merge, or discard this patch.
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
      * @return string
18 18
      */
19 19
     static public function PrintAsString($var) {
20
-       return ($var)?(($var===true)?'true':$var):(($var===false)?'false':(($var==='')?'empty':(($var === null) ? 'null':$var)));
20
+       return ($var) ? (($var === true) ? 'true' : $var) : (($var === false) ? 'false' : (($var === '') ? 'empty' : (($var === null) ? 'null' : $var)));
21 21
     }
22 22
 
23 23
     /**
@@ -31,13 +31,13 @@  discard block
 block discarded – undo
31 31
      */
32 32
     static public function SplitDomainUser($domainuser) {
33 33
         $pos = strrpos($domainuser, '\\');
34
-        if($pos === false){
34
+        if ($pos === false) {
35 35
             $user = $domainuser;
36 36
             $domain = '';
37 37
         }
38
-        else{
39
-            $domain = substr($domainuser,0,$pos);
40
-            $user = substr($domainuser,$pos+1);
38
+        else {
39
+            $domain = substr($domainuser, 0, $pos);
40
+            $user = substr($domainuser, $pos + 1);
41 41
         }
42 42
         return array($user, $domain);
43 43
     }
@@ -61,13 +61,13 @@  discard block
 block discarded – undo
61 61
 
62 62
         $zcs = "";
63 63
         if (isset($zip) && $zip != "") $zcs = $zip;
64
-        if (isset($city) && $city != "") $zcs .= (($zcs)?" ":"") . $city;
65
-        if (isset($state) && $state != "") $zcs .= (($zcs)?" ":"") . $state;
66
-        if ($zcs) $out = $zcs . "\r\n" . $out;
64
+        if (isset($city) && $city != "") $zcs .= (($zcs) ? " " : "").$city;
65
+        if (isset($state) && $state != "") $zcs .= (($zcs) ? " " : "").$state;
66
+        if ($zcs) $out = $zcs."\r\n".$out;
67 67
 
68
-        if (isset($street) && $street != "") $out = $street . (($out)?"\r\n\r\n". $out: "") ;
68
+        if (isset($street) && $street != "") $out = $street.(($out) ? "\r\n\r\n".$out : "");
69 69
 
70
-        return ($out)?$out:null;
70
+        return ($out) ? $out : null;
71 71
     }
72 72
 
73 73
     /**
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
     static public function BuildFileAs($lastname = "", $firstname = "", $middlename = "", $company = "") {
85 85
         if (defined('FILEAS_ORDER')) {
86 86
             $fileas = $lastfirst = $firstlast = "";
87
-            $names = trim ($firstname . " " . $middlename);
87
+            $names = trim($firstname." ".$middlename);
88 88
             $lastname = trim($lastname);
89 89
             $company = trim($company);
90 90
 
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
             // firstlast is "firstname middlename lastname"
93 93
             if (strlen($lastname) > 0) {
94 94
                 $lastfirst = $lastname;
95
-                if (strlen($names) > 0){
95
+                if (strlen($names) > 0) {
96 96
                     $lastfirst .= ", $names";
97 97
                     $firstlast = "$names $lastname";
98 98
                 }
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
             $vs = preg_split('/-/', phpversion("mapi"));
193 193
             return ($version <= $vs[1]);
194 194
         }
195
-        if (version_compare(phpversion("mapi"), $version) == -1){
195
+        if (version_compare(phpversion("mapi"), $version) == -1) {
196 196
             return false;
197 197
         }
198 198
 
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
      * @access public
208 208
      * @return string   the vCal-Uid if available in the olUid, else the original olUid as HEX
209 209
      */
210
-    static public function GetICalUidFromOLUid($olUid){
210
+    static public function GetICalUidFromOLUid($olUid) {
211 211
         //check if "vCal-Uid" is somewhere in outlookid case-insensitive
212 212
         $icalUid = stristr($olUid, "vCal-Uid");
213 213
         if ($icalUid !== false) {
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
             $OLUid .= "vCal-Uid";
237 237
             $OLUid .= pack("V", 1);
238 238
             $OLUid .= $icalUid;
239
-            return hex2bin("040000008200E00074C5B7101A82E0080000000000000000000000000000000000000000". bin2hex($OLUid). "00");
239
+            return hex2bin("040000008200E00074C5B7101A82E0080000000000000000000000000000000000000000".bin2hex($OLUid)."00");
240 240
         }
241 241
         else
242 242
            return hex2bin($icalUid);
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
      */
297 297
     static public function GetFiltertypeInterval($filtertype) {
298 298
         $back = false;
299
-        switch($filtertype) {
299
+        switch ($filtertype) {
300 300
             case SYNC_FILTERTYPE_1DAY:
301 301
                 $back = 60 * 60 * 24;
302 302
                 break;
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
      * @return long
333 333
      */
334 334
     static public function GetTruncSize($truncation) {
335
-        switch($truncation) {
335
+        switch ($truncation) {
336 336
             case SYNC_TRUNCATION_HEADERS:
337 337
                 return 0;
338 338
             case SYNC_TRUNCATION_512B:
@@ -340,19 +340,19 @@  discard block
 block discarded – undo
340 340
             case SYNC_TRUNCATION_1K:
341 341
                 return 1024;
342 342
             case SYNC_TRUNCATION_2K:
343
-                return 2*1024;
343
+                return 2 * 1024;
344 344
             case SYNC_TRUNCATION_5K:
345
-                return 5*1024;
345
+                return 5 * 1024;
346 346
             case SYNC_TRUNCATION_10K:
347
-                return 10*1024;
347
+                return 10 * 1024;
348 348
             case SYNC_TRUNCATION_20K:
349
-                return 20*1024;
349
+                return 20 * 1024;
350 350
             case SYNC_TRUNCATION_50K:
351
-                return 50*1024;
351
+                return 50 * 1024;
352 352
             case SYNC_TRUNCATION_100K:
353
-                return 100*1024;
353
+                return 100 * 1024;
354 354
             case SYNC_TRUNCATION_ALL:
355
-                return 1024*1024; // We'll limit to 1MB anyway
355
+                return 1024 * 1024; // We'll limit to 1MB anyway
356 356
             default:
357 357
                 return 1024; // Default to 1Kb
358 358
         }
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
             }
389 389
         }
390 390
 
391
-        while($length >= 0) {
391
+        while ($length >= 0) {
392 392
             if ((ord($string[$length]) < 0x80) || (ord($string[$length]) >= 0xC0)) {
393 393
                 return substr($string, 0, $length);
394 394
             }
@@ -434,7 +434,7 @@  discard block
 block discarded – undo
434 434
      * @return boolean
435 435
      */
436 436
     static public function IsBase64String($string) {
437
-        return (bool) preg_match("#^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{2}==|[A-Za-z0-9+\/]{3}=|[A-Za-z0-9+/]{4})?$#", $string);
437
+        return (bool)preg_match("#^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{2}==|[A-Za-z0-9+\/]{3}=|[A-Za-z0-9+/]{4})?$#", $string);
438 438
     }
439 439
 
440 440
     /**
@@ -607,7 +607,7 @@  discard block
 block discarded – undo
607 607
             20127 => "us-ascii"
608 608
         );
609 609
 
610
-        if(isset($codepages[$codepage])) {
610
+        if (isset($codepages[$codepage])) {
611 611
             return $codepages[$codepage];
612 612
         } else {
613 613
             // Defaulting to iso-8859-15 since it is more likely for someone to make a mistake in the codepage
@@ -709,7 +709,7 @@  discard block
 block discarded – undo
709 709
                 throw new FatalException("FixFileOwner: $dir must be owned by the nginx/apache/php user instead of root for debian based systems and by root:grosync for RHEL-based systems");
710 710
             }
711 711
 
712
-            if($perm_dir['uid'] !== $perm_file['uid'] || $perm_dir['gid'] !== $perm_file['gid']) {
712
+            if ($perm_dir['uid'] !== $perm_file['uid'] || $perm_dir['gid'] !== $perm_file['gid']) {
713 713
                 chown($file, $perm_dir['uid']);
714 714
                 chgrp($file, $perm_dir['gid']);
715 715
                 chmod($file, 0664);
@@ -764,10 +764,10 @@  discard block
 block discarded – undo
764 764
         if ($bytes <= 0) return '0 B';
765 765
 
766 766
         $units = array('B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB');
767
-        $base = log ($bytes, 1024);
767
+        $base = log($bytes, 1024);
768 768
         $fBase = floor($base);
769 769
         $pow = pow(1024, $base - $fBase);
770
-        return sprintf ("%.{$precision}f %s", $pow, $units[$fBase]);
770
+        return sprintf("%.{$precision}f %s", $pow, $units[$fBase]);
771 771
     }
772 772
 
773 773
     /**
@@ -866,9 +866,9 @@  discard block
 block discarded – undo
866 866
     //if the store supports unicode return the string without converting it
867 867
     if (!$force_convert && defined('STORE_SUPPORTS_UNICODE') && STORE_SUPPORTS_UNICODE == true) return $string;
868 868
 
869
-    if (function_exists("iconv")){
870
-        return @iconv("UTF-8", "Windows-1252" . $option, $string);
871
-    }else{
869
+    if (function_exists("iconv")) {
870
+        return @iconv("UTF-8", "Windows-1252".$option, $string);
871
+    } else {
872 872
         return utf8_decode($string); // no euro support here
873 873
     }
874 874
 }
@@ -877,9 +877,9 @@  discard block
 block discarded – undo
877 877
     //if the store supports unicode return the string without converting it
878 878
     if (!$force_convert && defined('STORE_SUPPORTS_UNICODE') && STORE_SUPPORTS_UNICODE == true) return $string;
879 879
 
880
-    if (function_exists("iconv")){
881
-        return @iconv("Windows-1252", "UTF-8" . $option, $string);
882
-    }else{
880
+    if (function_exists("iconv")) {
881
+        return @iconv("Windows-1252", "UTF-8".$option, $string);
882
+    } else {
883 883
         return utf8_encode($string); // no euro support here
884 884
     }
885 885
 }
Please login to merge, or discard this patch.
Braces   +70 added lines, -48 removed lines patch added patch discarded remove patch
@@ -34,8 +34,7 @@  discard block
 block discarded – undo
34 34
         if($pos === false){
35 35
             $user = $domainuser;
36 36
             $domain = '';
37
-        }
38
-        else{
37
+        } else{
39 38
             $domain = substr($domainuser,0,$pos);
40 39
             $user = substr($domainuser,$pos+1);
41 40
         }
@@ -57,15 +56,27 @@  discard block
 block discarded – undo
57 56
     static public function BuildAddressString($street, $zip, $city, $state, $country) {
58 57
         $out = "";
59 58
 
60
-        if (isset($country) && $street != "") $out = $country;
59
+        if (isset($country) && $street != "") {
60
+            $out = $country;
61
+        }
61 62
 
62 63
         $zcs = "";
63
-        if (isset($zip) && $zip != "") $zcs = $zip;
64
-        if (isset($city) && $city != "") $zcs .= (($zcs)?" ":"") . $city;
65
-        if (isset($state) && $state != "") $zcs .= (($zcs)?" ":"") . $state;
66
-        if ($zcs) $out = $zcs . "\r\n" . $out;
64
+        if (isset($zip) && $zip != "") {
65
+            $zcs = $zip;
66
+        }
67
+        if (isset($city) && $city != "") {
68
+            $zcs .= (($zcs)?" ":"") . $city;
69
+        }
70
+        if (isset($state) && $state != "") {
71
+            $zcs .= (($zcs)?" ":"") . $state;
72
+        }
73
+        if ($zcs) {
74
+            $out = $zcs . "\r\n" . $out;
75
+        }
67 76
 
68
-        if (isset($street) && $street != "") $out = $street . (($out)?"\r\n\r\n". $out: "") ;
77
+        if (isset($street) && $street != "") {
78
+            $out = $street . (($out)?"\r\n\r\n". $out: "") ;
79
+        }
69 80
 
70 81
         return ($out)?$out:null;
71 82
     }
@@ -95,12 +106,10 @@  discard block
 block discarded – undo
95 106
                 if (strlen($names) > 0){
96 107
                     $lastfirst .= ", $names";
97 108
                     $firstlast = "$names $lastname";
98
-                }
99
-                else {
109
+                } else {
100 110
                     $firstlast = $lastname;
101 111
                 }
102
-            }
103
-            elseif (strlen($names) > 0) {
112
+            } elseif (strlen($names) > 0) {
104 113
                 $lastfirst = $firstlast = $names;
105 114
             }
106 115
 
@@ -112,18 +121,19 @@  discard block
 block discarded – undo
112 121
                 case SYNC_FILEAS_COMPANYONLY:
113 122
                     if (strlen($company) > 0) {
114 123
                         $fileas = $company;
124
+                    } elseif (strlen($firstlast) > 0) {
125
+                                            $fileas = $lastfirst;
115 126
                     }
116
-                    elseif (strlen($firstlast) > 0)
117
-                        $fileas = $lastfirst;
118 127
                     break;
119 128
                 case SYNC_FILEAS_COMPANYLAST:
120 129
                     if (strlen($company) > 0) {
121 130
                         $fileas = $company;
122
-                        if (strlen($lastfirst) > 0)
123
-                            $fileas .= "($lastfirst)";
131
+                        if (strlen($lastfirst) > 0) {
132
+                                                    $fileas .= "($lastfirst)";
133
+                        }
134
+                    } elseif (strlen($lastfirst) > 0) {
135
+                                            $fileas = $lastfirst;
124 136
                     }
125
-                    elseif (strlen($lastfirst) > 0)
126
-                        $fileas = $lastfirst;
127 137
                     break;
128 138
                 case SYNC_FILEAS_COMPANYFIRST:
129 139
                     if (strlen($company) > 0) {
@@ -131,8 +141,7 @@  discard block
 block discarded – undo
131 141
                         if (strlen($firstlast) > 0) {
132 142
                             $fileas .= " ($firstlast)";
133 143
                         }
134
-                    }
135
-                    elseif (strlen($firstlast) > 0) {
144
+                    } elseif (strlen($firstlast) > 0) {
136 145
                         $fileas = $firstlast;
137 146
                     }
138 147
                     break;
@@ -142,8 +151,7 @@  discard block
 block discarded – undo
142 151
                         if (strlen($company) > 0) {
143 152
                             $fileas .= " ($company)";
144 153
                         }
145
-                    }
146
-                    elseif (strlen($company) > 0) {
154
+                    } elseif (strlen($company) > 0) {
147 155
                         $fileas = $company;
148 156
                     }
149 157
                     break;
@@ -153,8 +161,7 @@  discard block
 block discarded – undo
153 161
                         if (strlen($company) > 0) {
154 162
                             $fileas .= " ($company)";
155 163
                         }
156
-                    }
157
-                    elseif (strlen($company) > 0) {
164
+                    } elseif (strlen($company) > 0) {
158 165
                         $fileas = $company;
159 166
                     }
160 167
                     break;
@@ -167,8 +174,9 @@  discard block
 block discarded – undo
167 174
                     $fileas = $firstlast;
168 175
                     break;
169 176
             }
170
-            if (strlen($fileas) == 0)
171
-                ZLog::Write(LOGLEVEL_DEBUG, "Fileas is empty.");
177
+            if (strlen($fileas) == 0) {
178
+                            ZLog::Write(LOGLEVEL_DEBUG, "Fileas is empty.");
179
+            }
172 180
             return $fileas;
173 181
         }
174 182
         ZLog::Write(LOGLEVEL_DEBUG, "FILEAS_ORDER not defined. Add it to your config.php.");
@@ -237,9 +245,9 @@  discard block
 block discarded – undo
237 245
             $OLUid .= pack("V", 1);
238 246
             $OLUid .= $icalUid;
239 247
             return hex2bin("040000008200E00074C5B7101A82E0080000000000000000000000000000000000000000". bin2hex($OLUid). "00");
248
+        } else {
249
+                   return hex2bin($icalUid);
240 250
         }
241
-        else
242
-           return hex2bin($icalUid);
243 251
     }
244 252
 
245 253
     /**
@@ -263,9 +271,9 @@  discard block
 block discarded – undo
263 271
             $s = $recurStartTime - $h * 4096 - $m * 64;
264 272
 
265 273
             return gmmktime($h, $m, $s, $month, $day, $year);
274
+        } else {
275
+                    return false;
266 276
         }
267
-        else
268
-            return false;
269 277
     }
270 278
 
271 279
     /**
@@ -539,10 +547,11 @@  discard block
 block discarded – undo
539 547
      * @return string
540 548
      */
541 549
     public static function GetFormattedTime($timestamp = false) {
542
-        if (!$timestamp)
543
-            return @strftime("%d/%m/%Y %H:%M:%S");
544
-        else
545
-            return @strftime("%d/%m/%Y %H:%M:%S", $timestamp);
550
+        if (!$timestamp) {
551
+                    return @strftime("%d/%m/%Y %H:%M:%S");
552
+        } else {
553
+                    return @strftime("%d/%m/%Y %H:%M:%S", $timestamp);
554
+        }
546 555
     }
547 556
 
548 557
 
@@ -630,9 +639,9 @@  discard block
 block discarded – undo
630 639
         if (function_exists("iconv")) {
631 640
             $charset = self::GetCodepageCharset($codepage);
632 641
             return iconv($charset, "utf-8", $string);
642
+        } else {
643
+                    ZLog::Write(LOGLEVEL_WARN, "Utils::ConvertCodepageStringToUtf8() 'iconv' is not available. Charset conversion skipped.");
633 644
         }
634
-        else
635
-            ZLog::Write(LOGLEVEL_WARN, "Utils::ConvertCodepageStringToUtf8() 'iconv' is not available. Charset conversion skipped.");
636 645
 
637 646
         return $string;
638 647
     }
@@ -649,16 +658,17 @@  discard block
 block discarded – undo
649 658
      */
650 659
     public static function ConvertCodepage($in, $out, $string) {
651 660
         // do nothing if both charsets are the same
652
-        if ($in == $out)
653
-            return $string;
661
+        if ($in == $out) {
662
+                    return $string;
663
+        }
654 664
 
655 665
         if (function_exists("iconv")) {
656 666
             $inCharset = self::GetCodepageCharset($in);
657 667
             $outCharset = self::GetCodepageCharset($out);
658 668
             return iconv($inCharset, $outCharset, $string);
669
+        } else {
670
+                    ZLog::Write(LOGLEVEL_WARN, "Utils::ConvertCodepage() 'iconv' is not available. Charset conversion skipped.");
659 671
         }
660
-        else
661
-            ZLog::Write(LOGLEVEL_WARN, "Utils::ConvertCodepage() 'iconv' is not available. Charset conversion skipped.");
662 672
 
663 673
         return $string;
664 674
     }
@@ -677,9 +687,15 @@  discard block
 block discarded – undo
677 687
         }
678 688
         // The best choice is RTF, then HTML and then MIME in order to save bandwidth
679 689
         // because MIME is a complete message including the headers and attachments
680
-        if (in_array(SYNC_BODYPREFERENCE_RTF, $bpTypes))  return SYNC_BODYPREFERENCE_RTF;
681
-        if (in_array(SYNC_BODYPREFERENCE_HTML, $bpTypes)) return SYNC_BODYPREFERENCE_HTML;
682
-        if (in_array(SYNC_BODYPREFERENCE_MIME, $bpTypes)) return SYNC_BODYPREFERENCE_MIME;
690
+        if (in_array(SYNC_BODYPREFERENCE_RTF, $bpTypes)) {
691
+            return SYNC_BODYPREFERENCE_RTF;
692
+        }
693
+        if (in_array(SYNC_BODYPREFERENCE_HTML, $bpTypes)) {
694
+            return SYNC_BODYPREFERENCE_HTML;
695
+        }
696
+        if (in_array(SYNC_BODYPREFERENCE_MIME, $bpTypes)) {
697
+            return SYNC_BODYPREFERENCE_MIME;
698
+        }
683 699
         return SYNC_BODYPREFERENCE_PLAIN;
684 700
     }
685 701
 
@@ -761,7 +777,9 @@  discard block
 block discarded – undo
761 777
      * @return void|string
762 778
      */
763 779
     public static function FormatBytes($bytes, $precision = 2) {
764
-        if ($bytes <= 0) return '0 B';
780
+        if ($bytes <= 0) {
781
+            return '0 B';
782
+        }
765 783
 
766 784
         $units = array('B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB');
767 785
         $base = log ($bytes, 1024);
@@ -864,22 +882,26 @@  discard block
 block discarded – undo
864 882
 //for other backends.
865 883
 function utf8_to_windows1252($string, $option = "", $force_convert = false) {
866 884
     //if the store supports unicode return the string without converting it
867
-    if (!$force_convert && defined('STORE_SUPPORTS_UNICODE') && STORE_SUPPORTS_UNICODE == true) return $string;
885
+    if (!$force_convert && defined('STORE_SUPPORTS_UNICODE') && STORE_SUPPORTS_UNICODE == true) {
886
+        return $string;
887
+    }
868 888
 
869 889
     if (function_exists("iconv")){
870 890
         return @iconv("UTF-8", "Windows-1252" . $option, $string);
871
-    }else{
891
+    } else{
872 892
         return utf8_decode($string); // no euro support here
873 893
     }
874 894
 }
875 895
 
876 896
 function windows1252_to_utf8($string, $option = "", $force_convert = false) {
877 897
     //if the store supports unicode return the string without converting it
878
-    if (!$force_convert && defined('STORE_SUPPORTS_UNICODE') && STORE_SUPPORTS_UNICODE == true) return $string;
898
+    if (!$force_convert && defined('STORE_SUPPORTS_UNICODE') && STORE_SUPPORTS_UNICODE == true) {
899
+        return $string;
900
+    }
879 901
 
880 902
     if (function_exists("iconv")){
881 903
         return @iconv("Windows-1252", "UTF-8" . $option, $string);
882
-    }else{
904
+    } else{
883 905
         return utf8_encode($string); // no euro support here
884 906
     }
885 907
 }
Please login to merge, or discard this patch.
lib/utils/timezoneutil.php 3 patches
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
             // -720 min
239 239
             "Dateline Standard Time" => array(
240 240
                         "Etc/GMT+12",
241
-                 ),
241
+                    ),
242 242
 
243 243
             // -660 min
244 244
             "Samoa Standard Time" => array(
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
                         "Pacific/Pago_Pago",
249 249
                         "Pacific/Samoa",
250 250
                         "US/Samoa",
251
-                 ),
251
+                    ),
252 252
 
253 253
             // -600 min
254 254
             "Hawaiian Standard Time" => array(
@@ -262,12 +262,12 @@  discard block
 block discarded – undo
262 262
                         "Pacific/Tahiti",
263 263
                         "US/Aleutian",
264 264
                         "US/Hawaii",
265
-                 ),
265
+                    ),
266 266
 
267 267
             // -570 min
268 268
             "-570" => array(
269 269
                         "Pacific/Marquesas",
270
-                 ),
270
+                    ),
271 271
 
272 272
             // -540 min
273 273
             "Alaskan Standard Time" => array(
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
                         "Etc/GMT+9",
280 280
                         "Pacific/Gambier",
281 281
                         "US/Alaska",
282
-                 ),
282
+                    ),
283 283
 
284 284
             // -480 min
285 285
             "Pacific Standard Time" => array(
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
                         "PST8PDT",
300 300
                         "US/Pacific",
301 301
                         "US/Pacific-New",
302
-                 ),
302
+                    ),
303 303
 
304 304
             // -420 min
305 305
             "US Mountain Standard Time" => array(
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
                         "Navajo",
326 326
                         "US/Arizona",
327 327
                         "US/Mountain",
328
-                 ),
328
+                    ),
329 329
 
330 330
             // -360 min
331 331
             "Central Standard Time" => array(
@@ -347,17 +347,17 @@  discard block
 block discarded – undo
347 347
                         "US/Indiana-Starke",
348 348
                         "CST6CDT",
349 349
                         "Etc/GMT+6",
350
-                 ),
350
+                    ),
351 351
             "Canada Central Standard Time" => array(
352 352
                         "Canada/Central",
353 353
                         "Canada/East-Saskatchewan",
354 354
                         "Canada/Saskatchewan",
355
-                 ),
355
+                    ),
356 356
             "Mexico Standard Time" => array(
357 357
                         "America/Mexico_City",
358 358
                         "America/Monterrey",
359 359
                         "Mexico/General",
360
-                 ),
360
+                    ),
361 361
             "Central America Standard Time" => array(
362 362
                         "America/Bahia_Banderas",
363 363
                         "America/Belize",
@@ -372,7 +372,7 @@  discard block
 block discarded – undo
372 372
                         "Chile/EasterIsland",
373 373
                         "Pacific/Easter",
374 374
                         "Pacific/Galapagos",
375
-                 ),
375
+                    ),
376 376
 
377 377
             // -300 min
378 378
             "US Eastern Standard Time" => array(
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
                         "US/East-Indiana",
404 404
                         "US/Eastern",
405 405
                         "US/Michigan",
406
-                 ),
406
+                    ),
407 407
             "SA Pacific Standard Time" => array(
408 408
                         "America/Atikokan",
409 409
                         "America/Bogota",
@@ -418,12 +418,12 @@  discard block
 block discarded – undo
418 418
                         "America/Panama",
419 419
                         "America/Pangnirtung",
420 420
                         "America/Port-au-Prince",
421
-                 ),
421
+                    ),
422 422
 
423 423
             // -270 min
424 424
             "Venezuela Standard Time" => array(
425 425
                         "America/Caracas",
426
-                 ),
426
+                    ),
427 427
             // -240 min
428 428
             "Atlantic Standard Time" => array(
429 429
                         "America/Barbados",
@@ -443,7 +443,7 @@  discard block
 block discarded – undo
443 443
                         "Atlantic/Bermuda",
444 444
                         "Canada/Atlantic",
445 445
                         "Etc/GMT+4",
446
-                 ),
446
+                    ),
447 447
             "SA Western Standard Time" => array(
448 448
                         "America/Anguilla",
449 449
                         "America/Antigua",
@@ -472,19 +472,19 @@  discard block
 block discarded – undo
472 472
                         "America/Rio_Branco",
473 473
                         "Brazil/Acre",
474 474
                         "Brazil/West",
475
-                 ),
475
+                    ),
476 476
             "Pacific SA Standard Time" => array(
477 477
                         "America/Santiago",
478 478
                         "America/Santo_Domingo",
479 479
                         "Antarctica/Palmer",
480 480
                         "Chile/Continental",
481
-                 ),
481
+                    ),
482 482
 
483 483
             // -210 min
484 484
             "Newfoundland and Labrador Standard Time" => array(
485 485
                         "America/St_Johns",
486 486
                         "Canada/Newfoundland",
487
-                 ),
487
+                    ),
488 488
 
489 489
             // -180 min
490 490
             "E South America Standard Time" => array(
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
                         "America/Sao_Paulo",
498 498
                         "Brazil/East",
499 499
                         "Etc/GMT+3",
500
-                 ),
500
+                    ),
501 501
             "SA Eastern Standard Time" => array(
502 502
                         "America/Argentina/Buenos_Aires",
503 503
                         "America/Argentina/Catamarca",
@@ -524,11 +524,11 @@  discard block
 block discarded – undo
524 524
                         "America/Paramaribo",
525 525
                         "America/Rosario",
526 526
                         "America/Santarem",
527
-                 ),
527
+                    ),
528 528
             "Greenland Standard Time" => array(
529 529
                         "Antarctica/Rothera",
530 530
                         "Atlantic/Stanley",
531
-                 ),
531
+                    ),
532 532
 
533 533
             // -120 min
534 534
             "Mid-Atlantic Standard Time" => array(
@@ -536,17 +536,17 @@  discard block
 block discarded – undo
536 536
                         "Atlantic/South_Georgia",
537 537
                         "Brazil/DeNoronha",
538 538
                         "Etc/GMT+2",
539
-                 ),
539
+                    ),
540 540
 
541 541
             // -60 min
542 542
             "Azores Standard Time" => array(
543 543
                         "Atlantic/Azores",
544 544
                         "Etc/GMT+1",
545
-                 ),
545
+                    ),
546 546
             "Cape Verde Standard Time" => array(
547 547
                         "America/Scoresbysund",
548 548
                         "Atlantic/Cape_Verde",
549
-                 ),
549
+                    ),
550 550
 
551 551
             // 0 min
552 552
             "GMT Standard Time" => array(
@@ -580,7 +580,7 @@  discard block
 block discarded – undo
580 580
                         "UCT",
581 581
                         "Universal",
582 582
                         "UTC",
583
-                 ),
583
+                    ),
584 584
             "Greenwich Standard Time" => array(
585 585
                         "Africa/Abidjan",
586 586
                         "Africa/Accra",
@@ -606,7 +606,7 @@  discard block
 block discarded – undo
606 606
                         "Atlantic/Reykjavik",
607 607
                         "Atlantic/St_Helena",
608 608
                         "Zulu",
609
-                 ),
609
+                    ),
610 610
 
611 611
             // +60 min
612 612
             "Central Europe Standard Time" => array(
@@ -616,7 +616,7 @@  discard block
 block discarded – undo
616 616
                         "Europe/Ljubljana",
617 617
                         "Europe/Prague",
618 618
                         "Europe/Vaduz",
619
-                 ),
619
+                    ),
620 620
             "Central European Standard Time" => array(
621 621
                         "Europe/Sarajevo",
622 622
                         "Europe/Skopje",
@@ -624,7 +624,7 @@  discard block
 block discarded – undo
624 624
                         "Europe/Zagreb",
625 625
                         "MET",
626 626
                         "Poland",
627
-                 ),
627
+                    ),
628 628
             "Romance Standard Time" => array(
629 629
                         "Europe/Andorra",
630 630
                         "Europe/Brussels",
@@ -637,7 +637,7 @@  discard block
 block discarded – undo
637 637
                         "Europe/Podgorica",
638 638
                         "Europe/San_Marino",
639 639
                         "Europe/Tirane",
640
-                 ),
640
+                    ),
641 641
             "W Europe Standard Time" => array(
642 642
                         "Europe/Amsterdam",
643 643
                         "Europe/Berlin",
@@ -652,7 +652,7 @@  discard block
 block discarded – undo
652 652
                         "WET",
653 653
                         "CET",
654 654
                         "Etc/GMT-1",
655
-                 ),
655
+                    ),
656 656
             "W Central Africa Standard Time" => array(
657 657
                         "Africa/Algiers",
658 658
                         "Africa/Bangui",
@@ -670,7 +670,7 @@  discard block
 block discarded – undo
670 670
                         "Africa/Tunis",
671 671
                         "Africa/Windhoek",
672 672
                         "Atlantic/Jan_Mayen",
673
-                 ),
673
+                    ),
674 674
 
675 675
             // +120 min
676 676
             "E Europe Standard Time" => array(
@@ -684,13 +684,13 @@  discard block
 block discarded – undo
684 684
                         "Europe/Tiraspol",
685 685
                         "Europe/Uzhgorod",
686 686
                         "Europe/Zaporozhye",
687
-                 ),
687
+                    ),
688 688
             "Egypt Standard Time" => array(
689 689
                         "Africa/Cairo",
690 690
                         "Africa/Tripoli",
691 691
                         "Egypt",
692 692
                         "Libya",
693
-                 ),
693
+                    ),
694 694
             "FLE Standard Time" => array(
695 695
                         "Europe/Helsinki",
696 696
                         "Europe/Kiev",
@@ -698,13 +698,13 @@  discard block
 block discarded – undo
698 698
                         "Europe/Sofia",
699 699
                         "Europe/Tallinn",
700 700
                         "Europe/Vilnius",
701
-                 ),
701
+                    ),
702 702
             "GTB Standard Time" => array(
703 703
                         "Asia/Istanbul",
704 704
                         "Europe/Athens",
705 705
                         "Europe/Istanbul",
706 706
                         "Turkey",
707
-                 ),
707
+                    ),
708 708
             "Israel Standard Time" => array(
709 709
                         "Asia/Amman",
710 710
                         "Asia/Beirut",
@@ -715,7 +715,7 @@  discard block
 block discarded – undo
715 715
                         "Asia/Tel_Aviv",
716 716
                         "Asia/Jerusalem",
717 717
                         "Israel",
718
-                 ),
718
+                    ),
719 719
             "South Africa Standard Time" => array(
720 720
                         "Africa/Blantyre",
721 721
                         "Africa/Bujumbura",
@@ -728,7 +728,7 @@  discard block
 block discarded – undo
728 728
                         "Africa/Maputo",
729 729
                         "Africa/Maseru",
730 730
                         "Africa/Mbabane",
731
-                 ),
731
+                    ),
732 732
 
733 733
             // +180 min
734 734
             "Russian Standard Time" => array(
@@ -736,12 +736,12 @@  discard block
 block discarded – undo
736 736
                         "Europe/Kaliningrad",
737 737
                         "Europe/Minsk",
738 738
                         "Etc/GMT-3",
739
-                 ),
739
+                    ),
740 740
             "Arab Standard Time" => array(
741 741
                         "Asia/Qatar",
742 742
                         "Asia/Kuwait",
743 743
                         "Asia/Riyadh",
744
-                 ),
744
+                    ),
745 745
             "E Africa Standard Time" => array(
746 746
                         "Africa/Addis_Ababa",
747 747
                         "Africa/Asmara",
@@ -753,7 +753,7 @@  discard block
 block discarded – undo
753 753
                         "Africa/Khartoum",
754 754
                         "Africa/Mogadishu",
755 755
                         "Africa/Nairobi",
756
-                 ),
756
+                    ),
757 757
             "Arabic Standard Time" => array(
758 758
                         "Asia/Aden",
759 759
                         "Asia/Baghdad",
@@ -761,13 +761,13 @@  discard block
 block discarded – undo
761 761
                         "Indian/Antananarivo",
762 762
                         "Indian/Comoro",
763 763
                         "Indian/Mayotte",
764
-                 ),
764
+                    ),
765 765
 
766 766
             // +210 min
767 767
             "Iran Standard Time" => array(
768 768
                         "Asia/Tehran",
769 769
                         "Iran",
770
-                 ),
770
+                    ),
771 771
 
772 772
             // +240 min
773 773
             "Arabian Standard Time" => array(
@@ -776,7 +776,7 @@  discard block
 block discarded – undo
776 776
                         "Indian/Mahe",
777 777
                         "Indian/Mauritius",
778 778
                         "Indian/Reunion",
779
-                 ),
779
+                    ),
780 780
             "Caucasus Standard Time" => array(
781 781
                         "Asia/Baku",
782 782
                         "Asia/Tbilisi",
@@ -786,17 +786,17 @@  discard block
 block discarded – undo
786 786
                         "Europe/Samara",
787 787
                         "Europe/Volgograd",
788 788
                         "W-SU",
789
-                 ),
789
+                    ),
790 790
 
791 791
             // +270 min
792 792
             "Transitional Islamic State of Afghanistan Standard Time" => array(
793 793
                         "Asia/Kabul",
794
-                 ),
794
+                    ),
795 795
 
796 796
             // +300 min
797 797
             "Ekaterinburg Standard Time" => array(
798 798
                         "Antarctica/Mawson",
799
-                 ),
799
+                    ),
800 800
             "West Asia Standard Time" => array(
801 801
                         "Asia/Aqtau",
802 802
                         "Asia/Aqtobe",
@@ -810,29 +810,29 @@  discard block
 block discarded – undo
810 810
                         "Etc/GMT-5",
811 811
                         "Indian/Kerguelen",
812 812
                         "Indian/Maldives",
813
-                 ),
813
+                    ),
814 814
 
815 815
             // +330 min
816 816
             "India Standard Time" => array(
817 817
                         "Asia/Calcutta",
818 818
                         "Asia/Colombo",
819 819
                         "Asia/Kolkata",
820
-                 ),
820
+                    ),
821 821
 
822 822
             // +345 min
823 823
             "Nepal Standard Time" => array(
824 824
                         "Asia/Kathmandu",
825 825
                         "Asia/Katmandu",
826
-                 ),
826
+                    ),
827 827
 
828 828
             // +360 min
829 829
             "Central Asia Standard Time" => array(
830 830
                         "Asia/Dacca",
831 831
                         "Asia/Dhaka",
832
-                 ),
832
+                    ),
833 833
             "Sri Lanka Standard Time" => array(
834 834
                         "Indian/Chagos",
835
-                 ),
835
+                    ),
836 836
             "N Central Asia Standard Time" => array(
837 837
                         "Antarctica/Vostok",
838 838
                         "Asia/Almaty",
@@ -842,13 +842,13 @@  discard block
 block discarded – undo
842 842
                         "Asia/Thimphu",
843 843
                         "Asia/Yekaterinburg",
844 844
                         "Etc/GMT-6",
845
-                 ),
845
+                    ),
846 846
 
847 847
             // +390 min
848 848
             "Myanmar Standard Time" => array(
849 849
                         "Asia/Rangoon",
850 850
                         "Indian/Cocos",
851
-                 ),
851
+                    ),
852 852
 
853 853
             // +420 min
854 854
             "SE Asia Standard Time" => array(
@@ -859,7 +859,7 @@  discard block
 block discarded – undo
859 859
                         "Asia/Phnom_Penh",
860 860
                         "Asia/Saigon",
861 861
                         "Indian/Christmas",
862
-                 ),
862
+                    ),
863 863
             "North Asia Standard Time" => array(
864 864
                         "Antarctica/Davis",
865 865
                         "Asia/Novokuznetsk",
@@ -868,7 +868,7 @@  discard block
 block discarded – undo
868 868
                         "Asia/Pontianak",
869 869
                         "Asia/Vientiane",
870 870
                         "Etc/GMT-7",
871
-                 ),
871
+                    ),
872 872
 
873 873
             // +480 min
874 874
             "China Standard Time" => array(
@@ -884,19 +884,19 @@  discard block
 block discarded – undo
884 884
                         "Hongkong",
885 885
                         "PRC",
886 886
                         "ROC",
887
-                 ),
887
+                    ),
888 888
             "Singapore Standard Time" => array(
889 889
                         "Singapore",
890 890
                         "Asia/Singapore",
891 891
                         "Asia/Kuala_Lumpur",
892
-                 ),
892
+                    ),
893 893
             "Taipei Standard Time" => array(
894 894
                         "Asia/Taipei",
895
-                 ),
895
+                    ),
896 896
             "W Australia Standard Time" => array(
897 897
                         "Australia/Perth",
898 898
                         "Australia/West",
899
-                 ),
899
+                    ),
900 900
             "North Asia East Standard Time" => array(
901 901
                         "Antarctica/Casey",
902 902
                         "Asia/Kashgar",
@@ -909,43 +909,43 @@  discard block
 block discarded – undo
909 909
                         "Etc/GMT-8",
910 910
                         "Asia/Ulaanbaatar",
911 911
                         "Asia/Ulan_Bator",
912
-                 ),
912
+                    ),
913 913
 
914 914
             // +525 min
915 915
             "525" => array(
916 916
                         "Australia/Eucla",
917
-                 ),
917
+                    ),
918 918
 
919 919
             // +540 min
920 920
             "Korea Standard Time" => array(
921 921
                         "Asia/Seoul",
922 922
                         "Asia/Pyongyang",
923 923
                         "ROK",
924
-                 ),
924
+                    ),
925 925
             "Tokyo Standard Time" => array(
926 926
                         "Asia/Tokyo",
927 927
                         "Japan",
928 928
                         "Etc/GMT-9",
929
-                 ),
929
+                    ),
930 930
             "Yakutsk Standard Time" => array(
931 931
                         "Asia/Dili",
932 932
                         "Asia/Irkutsk",
933 933
                         "Asia/Jayapura",
934 934
                         "Pacific/Palau",
935
-                 ),
935
+                    ),
936 936
 
937 937
             // +570 min
938 938
             "AUS Central Standard Time" => array(
939 939
                         "Australia/Darwin",
940 940
                         "Australia/North",
941
-                 ),
942
-             // DST
941
+                    ),
942
+                // DST
943 943
             "Cen Australia Standard Time" => array(
944 944
                         "Australia/Adelaide",
945 945
                         "Australia/Broken_Hill",
946 946
                         "Australia/South",
947 947
                         "Australia/Yancowinna",
948
-                 ),
948
+                    ),
949 949
 
950 950
             // +600 min
951 951
             "AUS Eastern Standard Time" => array(
@@ -956,20 +956,20 @@  discard block
 block discarded – undo
956 956
                         "Australia/ACT",
957 957
                         "Australia/NSW",
958 958
                         "Australia/Victoria",
959
-                 ),
959
+                    ),
960 960
             "E Australia Standard Time" => array(
961 961
                         "Etc/GMT-10",
962 962
                         "Australia/Brisbane",
963 963
                         "Australia/Queensland",
964 964
                         "Australia/Lindeman",
965
-                 ),
965
+                    ),
966 966
             "Tasmania Standard Time" => array(
967 967
                         "Australia/Hobart",
968 968
                         "Australia/Tasmania",
969
-                 ),
969
+                    ),
970 970
             "Vladivostok Standard Time" => array(
971 971
                         "Antarctica/DumontDUrville",
972
-                 ),
972
+                    ),
973 973
             "West Pacific Standard Time" => array(
974 974
                         "Asia/Yakutsk",
975 975
                         "Pacific/Chuuk",
@@ -978,13 +978,13 @@  discard block
 block discarded – undo
978 978
                         "Pacific/Saipan",
979 979
                         "Pacific/Truk",
980 980
                         "Pacific/Yap",
981
-                 ),
981
+                    ),
982 982
 
983 983
             // +630 min
984 984
             "630" => array(
985 985
                         "Australia/LHI",
986 986
                         "Australia/Lord_Howe",
987
-                 ),
987
+                    ),
988 988
 
989 989
             // +660 min
990 990
             "Central Pacific Standard Time" => array(
@@ -998,12 +998,12 @@  discard block
 block discarded – undo
998 998
                         "Pacific/Noumea",
999 999
                         "Pacific/Pohnpei",
1000 1000
                         "Pacific/Ponape",
1001
-                 ),
1001
+                    ),
1002 1002
 
1003 1003
             // 690 min
1004 1004
             "690" => array(
1005 1005
                         "Pacific/Norfolk",
1006
-                 ),
1006
+                    ),
1007 1007
 
1008 1008
             // +720 min
1009 1009
             "Fiji Islands Standard Time" => array(
@@ -1011,7 +1011,7 @@  discard block
 block discarded – undo
1011 1011
                         "Asia/Kamchatka",
1012 1012
                         "Asia/Magadan",
1013 1013
                         "Kwajalein",
1014
-                 ),
1014
+                    ),
1015 1015
             "New Zealand Standard Time" => array(
1016 1016
                         "Antarctica/McMurdo",
1017 1017
                         "Antarctica/South_Pole",
@@ -1026,13 +1026,13 @@  discard block
 block discarded – undo
1026 1026
                         "Pacific/Tarawa",
1027 1027
                         "Pacific/Wake",
1028 1028
                         "Pacific/Wallis",
1029
-                 ),
1029
+                    ),
1030 1030
 
1031 1031
             // +765 min
1032 1032
             "765" => array(
1033 1033
                         "NZ-CHAT",
1034 1034
                         "Pacific/Chatham",
1035
-                 ),
1035
+                    ),
1036 1036
 
1037 1037
             // +780 min
1038 1038
             "Tonga Standard Time" => array(
@@ -1040,14 +1040,14 @@  discard block
 block discarded – undo
1040 1040
                         "Pacific/Apia",
1041 1041
                         "Pacific/Enderbury",
1042 1042
                         "Pacific/Tongatapu",
1043
-                 ),
1043
+                    ),
1044 1044
 
1045 1045
             // +840 min
1046 1046
             "840" => array(
1047 1047
                         "Etc/GMT-14",
1048 1048
                         "Pacific/Fakaofo",
1049 1049
                         "Pacific/Kiritimati",
1050
-                 ),
1050
+                    ),
1051 1051
             );
1052 1052
 
1053 1053
     /**
Please login to merge, or discard this patch.
Spacing   +165 added lines, -165 removed lines patch added patch discarded remove patch
@@ -18,83 +18,83 @@  discard block
 block discarded – undo
18 18
      * Updated at: 01.06.2012
19 19
      */
20 20
     private static $mstzones = array(
21
-                        "000" => array("Dateline Standard Time",                    "(GMT-12:00) International Date Line West"),
22
-                        "001" => array("Samoa Standard Time",                       "(GMT-11:00) Midway Island, Samoa"),
23
-                        "002" => array("Hawaiian Standard Time",                    "(GMT-10:00) Hawaii"),
24
-                        "003" => array("Alaskan Standard Time",                     "(GMT-09:00) Alaska"),
25
-                        "004" => array("Pacific Standard Time",                     "(GMT-08:00) Pacific Time (US and Canada); Tijuana"),
26
-                        "010" => array("Mountain Standard Time",                    "(GMT-07:00) Mountain Time (US and Canada)"),
27
-                        "013" => array("Mexico Standard Time 2",                    "(GMT-07:00) Chihuahua, La Paz, Mazatlan"),
28
-                        "015" => array("US Mountain Standard Time",                 "(GMT-07:00) Arizona"),
29
-                        "020" => array("Central Standard Time",                     "(GMT-06:00) Central Time (US and Canada"),
30
-                        "025" => array("Canada Central Standard Time",              "(GMT-06:00) Saskatchewan"),
31
-                        "030" => array("Mexico Standard Time",                      "(GMT-06:00) Guadalajara, Mexico City, Monterrey"),
32
-                        "033" => array("Central America Standard Time",             "(GMT-06:00) Central America"),
33
-                        "035" => array("Eastern Standard Time",                     "(GMT-05:00) Eastern Time (US and Canada)"),
34
-                        "040" => array("US Eastern Standard Time",                  "(GMT-05:00) Indiana (East)"),
35
-                        "045" => array("SA Pacific Standard Time",                  "(GMT-05:00) Bogota, Lima, Quito"),
36
-                        "uk1" => array("Venezuela Standard Time",                   "(GMT-04:30) Caracas"),                     // added
37
-                        "050" => array("Atlantic Standard Time",                    "(GMT-04:00) Atlantic Time (Canada)"),
38
-                        "055" => array("SA Western Standard Time",                  "(GMT-04:00) Caracas, La Paz"),
39
-                        "056" => array("Pacific SA Standard Time",                  "(GMT-04:00) Santiago"),
40
-                        "060" => array("Newfoundland and Labrador Standard Time",   "(GMT-03:30) Newfoundland and Labrador"),
41
-                        "065" => array("E South America Standard Time" ,            "(GMT-03:00) Brasilia"),
42
-                        "070" => array("SA Eastern Standard Time",                  "(GMT-03:00) Buenos Aires, Georgetown"),
43
-                        "073" => array("Greenland Standard Time",                   "(GMT-03:00) Greenland"),
44
-                        "075" => array("Mid-Atlantic Standard Time",                "(GMT-02:00) Mid-Atlantic"),
45
-                        "080" => array("Azores Standard Time",                      "(GMT-01:00) Azores"),
46
-                        "083" => array("Cape Verde Standard Time",                  "(GMT-01:00) Cape Verde Islands"),
47
-                        "085" => array("GMT Standard Time",                         "(GMT) Greenwich Mean Time: Dublin, Edinburgh, Lisbon, London"),
48
-                        "090" => array("Greenwich Standard Time",                   "(GMT) Casablanca, Monrovia"),
49
-                        "095" => array("Central Europe Standard Time",              "(GMT+01:00) Belgrade, Bratislava, Budapest, Ljubljana, Prague"),
50
-                        "100" => array("Central European Standard Time",            "(GMT+01:00) Sarajevo, Skopje, Warsaw, Zagreb"),
51
-                        "105" => array("Romance Standard Time",                     "(GMT+01:00) Brussels, Copenhagen, Madrid, Paris"),
52
-                        "110" => array("W Europe Standard Time",                    "(GMT+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna"),
53
-                        "111" => array("W. Europe Standard Time",                   "(GMT+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna"),
54
-                        "113" => array("W Central Africa Standard Time",            "(GMT+01:00) West Central Africa"),
55
-                        "115" => array("E Europe Standard Time",                    "(GMT+02:00) Bucharest"),
56
-                        "120" => array("Egypt Standard Time",                       "(GMT+02:00) Cairo"),
57
-                        "125" => array("FLE Standard Time",                         "(GMT+02:00) Helsinki, Kiev, Riga, Sofia, Tallinn, Vilnius"),
58
-                        "130" => array("GTB Standard Time",                         "(GMT+02:00) Athens, Istanbul, Minsk"),
59
-                        "135" => array("Israel Standard Time",                      "(GMT+02:00) Jerusalem"),
60
-                        "140" => array("South Africa Standard Time",                "(GMT+02:00) Harare, Pretoria"),
61
-                        "145" => array("Russian Standard Time",                     "(GMT+03:00) Moscow, St. Petersburg, Volgograd"),
62
-                        "150" => array("Arab Standard Time",                        "(GMT+03:00) Kuwait, Riyadh"),
63
-                        "155" => array("E Africa Standard Time",                    "(GMT+03:00) Nairobi"),
64
-                        "158" => array("Arabic Standard Time",                      "(GMT+03:00) Baghdad"),
65
-                        "160" => array("Iran Standard Time",                        "(GMT+03:30) Tehran"),
66
-                        "165" => array("Arabian Standard Time",                     "(GMT+04:00) Abu Dhabi, Muscat"),
67
-                        "170" => array("Caucasus Standard Time",                    "(GMT+04:00) Baku, Tbilisi, Yerevan"),
68
-                        "175" => array("Transitional Islamic State of Afghanistan Standard Time","(GMT+04:30) Kabul"),
69
-                        "180" => array("Ekaterinburg Standard Time",                "(GMT+05:00) Ekaterinburg"),
70
-                        "185" => array("West Asia Standard Time",                   "(GMT+05:00) Islamabad, Karachi, Tashkent"),
71
-                        "190" => array("India Standard Time",                       "(GMT+05:30) Chennai, Kolkata, Mumbai, New Delhi"),
72
-                        "193" => array("Nepal Standard Time",                       "(GMT+05:45) Kathmandu"),
73
-                        "195" => array("Central Asia Standard Time",                "(GMT+06:00) Astana, Dhaka"),
74
-                        "200" => array("Sri Lanka Standard Time",                   "(GMT+06:00) Sri Jayawardenepura"),
75
-                        "201" => array("N Central Asia Standard Time",              "(GMT+06:00) Almaty, Novosibirsk"),
76
-                        "203" => array("Myanmar Standard Time",                     "(GMT+06:30) Yangon Rangoon"),
77
-                        "205" => array("SE Asia Standard Time",                     "(GMT+07:00) Bangkok, Hanoi, Jakarta"),
78
-                        "207" => array("North Asia Standard Time",                  "(GMT+07:00) Krasnoyarsk"),
79
-                        "210" => array("China Standard Time",                       "(GMT+08:00) Beijing, Chongqing, Hong Kong SAR, Urumqi"),
80
-                        "215" => array("Singapore Standard Time",                   "(GMT+08:00) Kuala Lumpur, Singapore"),
81
-                        "220" => array("Taipei Standard Time",                      "(GMT+08:00) Taipei"),
82
-                        "225" => array("W Australia Standard Time",                 "(GMT+08:00) Perth"),
83
-                        "227" => array("North Asia East Standard Time",             "(GMT+08:00) Irkutsk, Ulaanbaatar"),
84
-                        "230" => array("Korea Standard Time",                       "(GMT+09:00) Seoul"),
85
-                        "235" => array("Tokyo Standard Time",                       "(GMT+09:00) Osaka, Sapporo, Tokyo"),
86
-                        "240" => array("Yakutsk Standard Time",                     "(GMT+09:00) Yakutsk"),
87
-                        "245" => array("AUS Central Standard Time",                 "(GMT+09:30) Darwin"),
88
-                        "250" => array("Cen Australia Standard Time",               "(GMT+09:30) Adelaide"),
89
-                        "255" => array("AUS Eastern Standard Time",                 "(GMT+10:00) Canberra, Melbourne, Sydney"),
90
-                        "260" => array("E Australia Standard Time",                 "(GMT+10:00) Brisbane"),
91
-                        "265" => array("Tasmania Standard Time",                    "(GMT+10:00) Hobart"),
92
-                        "270" => array("Vladivostok Standard Time",                 "(GMT+10:00) Vladivostok"),
93
-                        "275" => array("West Pacific Standard Time",                "(GMT+10:00) Guam, Port Moresby"),
94
-                        "280" => array("Central Pacific Standard Time",             "(GMT+11:00) Magadan, Solomon Islands, New Caledonia"),
95
-                        "285" => array("Fiji Islands Standard Time",                "(GMT+12:00) Fiji Islands, Kamchatka, Marshall Islands"),
96
-                        "290" => array("New Zealand Standard Time",                 "(GMT+12:00) Auckland, Wellington"),
97
-                        "300" => array("Tonga Standard Time",                       "(GMT+13:00) Nuku'alofa"),
21
+                        "000" => array("Dateline Standard Time", "(GMT-12:00) International Date Line West"),
22
+                        "001" => array("Samoa Standard Time", "(GMT-11:00) Midway Island, Samoa"),
23
+                        "002" => array("Hawaiian Standard Time", "(GMT-10:00) Hawaii"),
24
+                        "003" => array("Alaskan Standard Time", "(GMT-09:00) Alaska"),
25
+                        "004" => array("Pacific Standard Time", "(GMT-08:00) Pacific Time (US and Canada); Tijuana"),
26
+                        "010" => array("Mountain Standard Time", "(GMT-07:00) Mountain Time (US and Canada)"),
27
+                        "013" => array("Mexico Standard Time 2", "(GMT-07:00) Chihuahua, La Paz, Mazatlan"),
28
+                        "015" => array("US Mountain Standard Time", "(GMT-07:00) Arizona"),
29
+                        "020" => array("Central Standard Time", "(GMT-06:00) Central Time (US and Canada"),
30
+                        "025" => array("Canada Central Standard Time", "(GMT-06:00) Saskatchewan"),
31
+                        "030" => array("Mexico Standard Time", "(GMT-06:00) Guadalajara, Mexico City, Monterrey"),
32
+                        "033" => array("Central America Standard Time", "(GMT-06:00) Central America"),
33
+                        "035" => array("Eastern Standard Time", "(GMT-05:00) Eastern Time (US and Canada)"),
34
+                        "040" => array("US Eastern Standard Time", "(GMT-05:00) Indiana (East)"),
35
+                        "045" => array("SA Pacific Standard Time", "(GMT-05:00) Bogota, Lima, Quito"),
36
+                        "uk1" => array("Venezuela Standard Time", "(GMT-04:30) Caracas"), // added
37
+                        "050" => array("Atlantic Standard Time", "(GMT-04:00) Atlantic Time (Canada)"),
38
+                        "055" => array("SA Western Standard Time", "(GMT-04:00) Caracas, La Paz"),
39
+                        "056" => array("Pacific SA Standard Time", "(GMT-04:00) Santiago"),
40
+                        "060" => array("Newfoundland and Labrador Standard Time", "(GMT-03:30) Newfoundland and Labrador"),
41
+                        "065" => array("E South America Standard Time", "(GMT-03:00) Brasilia"),
42
+                        "070" => array("SA Eastern Standard Time", "(GMT-03:00) Buenos Aires, Georgetown"),
43
+                        "073" => array("Greenland Standard Time", "(GMT-03:00) Greenland"),
44
+                        "075" => array("Mid-Atlantic Standard Time", "(GMT-02:00) Mid-Atlantic"),
45
+                        "080" => array("Azores Standard Time", "(GMT-01:00) Azores"),
46
+                        "083" => array("Cape Verde Standard Time", "(GMT-01:00) Cape Verde Islands"),
47
+                        "085" => array("GMT Standard Time", "(GMT) Greenwich Mean Time: Dublin, Edinburgh, Lisbon, London"),
48
+                        "090" => array("Greenwich Standard Time", "(GMT) Casablanca, Monrovia"),
49
+                        "095" => array("Central Europe Standard Time", "(GMT+01:00) Belgrade, Bratislava, Budapest, Ljubljana, Prague"),
50
+                        "100" => array("Central European Standard Time", "(GMT+01:00) Sarajevo, Skopje, Warsaw, Zagreb"),
51
+                        "105" => array("Romance Standard Time", "(GMT+01:00) Brussels, Copenhagen, Madrid, Paris"),
52
+                        "110" => array("W Europe Standard Time", "(GMT+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna"),
53
+                        "111" => array("W. Europe Standard Time", "(GMT+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna"),
54
+                        "113" => array("W Central Africa Standard Time", "(GMT+01:00) West Central Africa"),
55
+                        "115" => array("E Europe Standard Time", "(GMT+02:00) Bucharest"),
56
+                        "120" => array("Egypt Standard Time", "(GMT+02:00) Cairo"),
57
+                        "125" => array("FLE Standard Time", "(GMT+02:00) Helsinki, Kiev, Riga, Sofia, Tallinn, Vilnius"),
58
+                        "130" => array("GTB Standard Time", "(GMT+02:00) Athens, Istanbul, Minsk"),
59
+                        "135" => array("Israel Standard Time", "(GMT+02:00) Jerusalem"),
60
+                        "140" => array("South Africa Standard Time", "(GMT+02:00) Harare, Pretoria"),
61
+                        "145" => array("Russian Standard Time", "(GMT+03:00) Moscow, St. Petersburg, Volgograd"),
62
+                        "150" => array("Arab Standard Time", "(GMT+03:00) Kuwait, Riyadh"),
63
+                        "155" => array("E Africa Standard Time", "(GMT+03:00) Nairobi"),
64
+                        "158" => array("Arabic Standard Time", "(GMT+03:00) Baghdad"),
65
+                        "160" => array("Iran Standard Time", "(GMT+03:30) Tehran"),
66
+                        "165" => array("Arabian Standard Time", "(GMT+04:00) Abu Dhabi, Muscat"),
67
+                        "170" => array("Caucasus Standard Time", "(GMT+04:00) Baku, Tbilisi, Yerevan"),
68
+                        "175" => array("Transitional Islamic State of Afghanistan Standard Time", "(GMT+04:30) Kabul"),
69
+                        "180" => array("Ekaterinburg Standard Time", "(GMT+05:00) Ekaterinburg"),
70
+                        "185" => array("West Asia Standard Time", "(GMT+05:00) Islamabad, Karachi, Tashkent"),
71
+                        "190" => array("India Standard Time", "(GMT+05:30) Chennai, Kolkata, Mumbai, New Delhi"),
72
+                        "193" => array("Nepal Standard Time", "(GMT+05:45) Kathmandu"),
73
+                        "195" => array("Central Asia Standard Time", "(GMT+06:00) Astana, Dhaka"),
74
+                        "200" => array("Sri Lanka Standard Time", "(GMT+06:00) Sri Jayawardenepura"),
75
+                        "201" => array("N Central Asia Standard Time", "(GMT+06:00) Almaty, Novosibirsk"),
76
+                        "203" => array("Myanmar Standard Time", "(GMT+06:30) Yangon Rangoon"),
77
+                        "205" => array("SE Asia Standard Time", "(GMT+07:00) Bangkok, Hanoi, Jakarta"),
78
+                        "207" => array("North Asia Standard Time", "(GMT+07:00) Krasnoyarsk"),
79
+                        "210" => array("China Standard Time", "(GMT+08:00) Beijing, Chongqing, Hong Kong SAR, Urumqi"),
80
+                        "215" => array("Singapore Standard Time", "(GMT+08:00) Kuala Lumpur, Singapore"),
81
+                        "220" => array("Taipei Standard Time", "(GMT+08:00) Taipei"),
82
+                        "225" => array("W Australia Standard Time", "(GMT+08:00) Perth"),
83
+                        "227" => array("North Asia East Standard Time", "(GMT+08:00) Irkutsk, Ulaanbaatar"),
84
+                        "230" => array("Korea Standard Time", "(GMT+09:00) Seoul"),
85
+                        "235" => array("Tokyo Standard Time", "(GMT+09:00) Osaka, Sapporo, Tokyo"),
86
+                        "240" => array("Yakutsk Standard Time", "(GMT+09:00) Yakutsk"),
87
+                        "245" => array("AUS Central Standard Time", "(GMT+09:30) Darwin"),
88
+                        "250" => array("Cen Australia Standard Time", "(GMT+09:30) Adelaide"),
89
+                        "255" => array("AUS Eastern Standard Time", "(GMT+10:00) Canberra, Melbourne, Sydney"),
90
+                        "260" => array("E Australia Standard Time", "(GMT+10:00) Brisbane"),
91
+                        "265" => array("Tasmania Standard Time", "(GMT+10:00) Hobart"),
92
+                        "270" => array("Vladivostok Standard Time", "(GMT+10:00) Vladivostok"),
93
+                        "275" => array("West Pacific Standard Time", "(GMT+10:00) Guam, Port Moresby"),
94
+                        "280" => array("Central Pacific Standard Time", "(GMT+11:00) Magadan, Solomon Islands, New Caledonia"),
95
+                        "285" => array("Fiji Islands Standard Time", "(GMT+12:00) Fiji Islands, Kamchatka, Marshall Islands"),
96
+                        "290" => array("New Zealand Standard Time", "(GMT+12:00) Auckland, Wellington"),
97
+                        "300" => array("Tonga Standard Time", "(GMT+13:00) Nuku'alofa"),
98 98
                 );
99 99
 
100 100
     /**
@@ -129,104 +129,104 @@  discard block
 block discarded – undo
129 129
      */
130 130
     private static $tzonesoffsets = array(
131 131
                         "Transitional Islamic State of Afghanistan Standard Time"
132
-                                                                    => array(-270, 0, -60,  0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0),
133
-                        "Alaskan Standard Time"                     => array(540, 0, -60,  0, 11, 0, 1, 2, 0, 0, 0,  0, 3, 0, 2, 2, 0, 0, 0),
134
-                        "Arab Standard Time"                        => array(-180, 0, -60,  0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0),
135
-                        "Arabian Standard Time"                     => array(-240, 0, -60,  0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0),
136
-                        "Arabic Standard Time"                      => array(-180, 0, -60,  0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0),
132
+                                                                    => array(-270, 0, -60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
133
+                        "Alaskan Standard Time"                     => array(540, 0, -60, 0, 11, 0, 1, 2, 0, 0, 0, 0, 3, 0, 2, 2, 0, 0, 0),
134
+                        "Arab Standard Time"                        => array(-180, 0, -60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
135
+                        "Arabian Standard Time"                     => array(-240, 0, -60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
136
+                        "Arabic Standard Time"                      => array(-180, 0, -60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
137 137
                         //"Argentina Standard Time"                   => array(180, 0, -60,  0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0),
138
-                        "Atlantic Standard Time"                    => array(240, 0, -60,  0, 11, 0, 1, 2, 0, 0, 0,  0, 3, 0, 2, 2, 0, 0, 0),
139
-                        "AUS Central Standard Time"                 => array(-570, 0, -60,  0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0),
140
-                        "AUS Eastern Standard Time"                 => array(-600, 0, -60,  0, 4, 0, 1, 3, 0, 0, 0,  0, 10, 0, 1, 2, 0, 0, 0),
138
+                        "Atlantic Standard Time"                    => array(240, 0, -60, 0, 11, 0, 1, 2, 0, 0, 0, 0, 3, 0, 2, 2, 0, 0, 0),
139
+                        "AUS Central Standard Time"                 => array(-570, 0, -60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
140
+                        "AUS Eastern Standard Time"                 => array(-600, 0, -60, 0, 4, 0, 1, 3, 0, 0, 0, 0, 10, 0, 1, 2, 0, 0, 0),
141 141
                         //"Azerbaijan Standard Time"                  => array(-240, 0, -60,  0, 10, 0, 5, 5, 0, 0, 0,  0, 3, 0, 5, 4, 0, 0, 0),
142
-                        "Azores Standard Time"                      => array(60, 0, -60,  0, 10, 0, 5, 3, 0, 0, 0,  0, 3, 0, 5, 2, 0, 0, 0),
142
+                        "Azores Standard Time"                      => array(60, 0, -60, 0, 10, 0, 5, 3, 0, 0, 0, 0, 3, 0, 5, 2, 0, 0, 0),
143 143
                         //"Bangladesh Standard Time"                  => array(-360, 0, -60,  0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0),
144
-                        "Canada Central Standard Time"              => array(360, 0, -60,  0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0),
145
-                        "Cape Verde Standard Time"                  => array(60, 0, -60,  0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0),
146
-                        "Caucasus Standard Time"                    => array(-240, 0, -60,  0, 10, 0, 5, 3, 0, 0, 0,  0, 3, 0, 5, 2, 0, 0, 0),
147
-                        "Cen Australia Standard Time"               => array(-570, 0, -60,  0, 4, 0, 1, 3, 0, 0, 0,  0, 10, 0, 1, 2, 0, 0, 0),
148
-                        "Central America Standard Time"             => array(360, 0, -60,  0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0),
149
-                        "Central Asia Standard Time"                => array(-360, 0, -60,  0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0),
144
+                        "Canada Central Standard Time"              => array(360, 0, -60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
145
+                        "Cape Verde Standard Time"                  => array(60, 0, -60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
146
+                        "Caucasus Standard Time"                    => array(-240, 0, -60, 0, 10, 0, 5, 3, 0, 0, 0, 0, 3, 0, 5, 2, 0, 0, 0),
147
+                        "Cen Australia Standard Time"               => array(-570, 0, -60, 0, 4, 0, 1, 3, 0, 0, 0, 0, 10, 0, 1, 2, 0, 0, 0),
148
+                        "Central America Standard Time"             => array(360, 0, -60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
149
+                        "Central Asia Standard Time"                => array(-360, 0, -60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
150 150
                         //"Central Brazilian Standard Time"           => array(240, 0, -60,  0, 2, 6, 4, 23, 59, 59, 999,  0, 10, 6, 3, 23, 59, 59, 999),
151
-                        "Central Europe Standard Time"              => array(-60, 0, -60,  0, 10, 0, 5, 3, 0, 0, 0,  0, 3, 0, 5, 2, 0, 0, 0),
152
-                        "Central European Standard Time"            => array(-60, 0, -60,  0, 10, 0, 5, 3, 0, 0, 0,  0, 3, 0, 5, 2, 0, 0, 0),
153
-                        "Central Pacific Standard Time"             => array(-660, 0, -60,  0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0),
154
-                        "Central Standard Time"                     => array(360, 0, -60,  0, 11, 0, 1, 2, 0, 0, 0,  0, 3, 0, 2, 2, 0, 0, 0),
155
-                        "Mexico Standard Time"                      => array(360, 0, -60,  0, 10, 0, 5, 2, 0, 0, 0,  0, 4, 0, 1, 2, 0, 0, 0),
156
-                        "China Standard Time"                       => array(-480, 0, -60,  0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0),
157
-                        "Dateline Standard Time"                    => array(720, 0, -60,  0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0),
158
-                        "E Africa Standard Time"                    => array(-180, 0, -60,  0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0),
159
-                        "E Australia Standard Time"                 => array(-600, 0, -60,  0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0),
160
-                        "E Europe Standard Time"                    => array(-120, 0, -60,  0, 10, 0, 5, 3, 0, 0, 0,  0, 3, 0, 5, 2, 0, 0, 0),
161
-                        "E South America Standard Time"             => array(180, 0, -60,  0, 2, 6, 4, 23, 59, 59, 999,  0, 10, 6, 3, 23, 59, 59, 999),
162
-                        "Eastern Standard Time"                     => array(300, 0, -60,  0, 11, 0, 1, 2, 0, 0, 0,  0, 3, 0, 2, 2, 0, 0, 0),
163
-                        "Egypt Standard Time"                       => array(-120, 0, -60,  0, 9, 4, 5, 23, 59, 59, 999,  0, 4, 4, 5, 23, 59, 59, 999),
164
-                        "Ekaterinburg Standard Time"                => array(-300, 0, -60,  0, 10, 0, 5, 3, 0, 0, 0,  0, 3, 0, 5, 2, 0, 0, 0),
165
-                        "Fiji Islands Standard Time"                => array(-720, 0, -60,  0, 3, 0, 5, 3, 0, 0, 0,  0, 10, 0, 4, 2, 0, 0, 0),
166
-                        "FLE Standard Time"                         => array(-120, 0, -60,  0, 10, 0, 5, 4, 0, 0, 0,  0, 3, 0, 5, 3, 0, 0, 0),
151
+                        "Central Europe Standard Time"              => array(-60, 0, -60, 0, 10, 0, 5, 3, 0, 0, 0, 0, 3, 0, 5, 2, 0, 0, 0),
152
+                        "Central European Standard Time"            => array(-60, 0, -60, 0, 10, 0, 5, 3, 0, 0, 0, 0, 3, 0, 5, 2, 0, 0, 0),
153
+                        "Central Pacific Standard Time"             => array(-660, 0, -60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
154
+                        "Central Standard Time"                     => array(360, 0, -60, 0, 11, 0, 1, 2, 0, 0, 0, 0, 3, 0, 2, 2, 0, 0, 0),
155
+                        "Mexico Standard Time"                      => array(360, 0, -60, 0, 10, 0, 5, 2, 0, 0, 0, 0, 4, 0, 1, 2, 0, 0, 0),
156
+                        "China Standard Time"                       => array(-480, 0, -60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
157
+                        "Dateline Standard Time"                    => array(720, 0, -60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
158
+                        "E Africa Standard Time"                    => array(-180, 0, -60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
159
+                        "E Australia Standard Time"                 => array(-600, 0, -60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
160
+                        "E Europe Standard Time"                    => array(-120, 0, -60, 0, 10, 0, 5, 3, 0, 0, 0, 0, 3, 0, 5, 2, 0, 0, 0),
161
+                        "E South America Standard Time"             => array(180, 0, -60, 0, 2, 6, 4, 23, 59, 59, 999, 0, 10, 6, 3, 23, 59, 59, 999),
162
+                        "Eastern Standard Time"                     => array(300, 0, -60, 0, 11, 0, 1, 2, 0, 0, 0, 0, 3, 0, 2, 2, 0, 0, 0),
163
+                        "Egypt Standard Time"                       => array(-120, 0, -60, 0, 9, 4, 5, 23, 59, 59, 999, 0, 4, 4, 5, 23, 59, 59, 999),
164
+                        "Ekaterinburg Standard Time"                => array(-300, 0, -60, 0, 10, 0, 5, 3, 0, 0, 0, 0, 3, 0, 5, 2, 0, 0, 0),
165
+                        "Fiji Islands Standard Time"                => array(-720, 0, -60, 0, 3, 0, 5, 3, 0, 0, 0, 0, 10, 0, 4, 2, 0, 0, 0),
166
+                        "FLE Standard Time"                         => array(-120, 0, -60, 0, 10, 0, 5, 4, 0, 0, 0, 0, 3, 0, 5, 3, 0, 0, 0),
167 167
                         //"Georgian Standard Time"                    => array(-240, 0, -60,  0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0),
168
-                        "GMT Standard Time"                         => array(0, 0, -60,  0, 10, 0, 5, 2, 0, 0, 0,  0, 3, 0, 5, 1, 0, 0, 0),
169
-                        "Greenland Standard Time"                   => array(180, 0, -60,  0, 10, 6, 5, 23, 0, 0, 0,  0, 3, 6, 4, 22, 0, 0, 0),
170
-                        "Greenwich Standard Time"                   => array(0, 0, -60,  0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0),
171
-                        "GTB Standard Time"                         => array(-120, 0, -60,  0, 10, 0, 5, 4, 0, 0, 0,  0, 3, 0, 5, 3, 0, 0, 0),
172
-                        "Hawaiian Standard Time"                    => array(600, 0, -60,  0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0),
173
-                        "India Standard Time"                       => array(-330, 0, -60,  0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0),
174
-                        "Iran Standard Time"                        => array(-210, 0, -60,  0, 9, 1, 3, 23, 59, 59, 999,  0, 3, 6, 3, 23, 59, 59, 999),
175
-                        "Israel Standard Time"                      => array(-120, 0, -60,  0, 9, 0, 4, 2, 0, 0, 0,  0, 3, 5, 5, 2, 0, 0, 0),
168
+                        "GMT Standard Time"                         => array(0, 0, -60, 0, 10, 0, 5, 2, 0, 0, 0, 0, 3, 0, 5, 1, 0, 0, 0),
169
+                        "Greenland Standard Time"                   => array(180, 0, -60, 0, 10, 6, 5, 23, 0, 0, 0, 0, 3, 6, 4, 22, 0, 0, 0),
170
+                        "Greenwich Standard Time"                   => array(0, 0, -60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
171
+                        "GTB Standard Time"                         => array(-120, 0, -60, 0, 10, 0, 5, 4, 0, 0, 0, 0, 3, 0, 5, 3, 0, 0, 0),
172
+                        "Hawaiian Standard Time"                    => array(600, 0, -60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
173
+                        "India Standard Time"                       => array(-330, 0, -60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
174
+                        "Iran Standard Time"                        => array(-210, 0, -60, 0, 9, 1, 3, 23, 59, 59, 999, 0, 3, 6, 3, 23, 59, 59, 999),
175
+                        "Israel Standard Time"                      => array(-120, 0, -60, 0, 9, 0, 4, 2, 0, 0, 0, 0, 3, 5, 5, 2, 0, 0, 0),
176 176
                         //"Jordan Standard Time"                      => array(-120, 0, -60,  0, 10, 5, 5, 1, 0, 0, 0,  0, 3, 4, 5, 23, 59, 59, 999),
177 177
                         //"Kamchatka Standard Time"                   => array(-720, 0, -60,  0, 10, 0, 5, 3, 0, 0, 0,  0, 3, 0, 5, 2, 0, 0, 0),
178
-                        "Korea Standard Time"                       => array(-540, 0, -60,  0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0),
178
+                        "Korea Standard Time"                       => array(-540, 0, -60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
179 179
                         //"Magadan Standard Time"                     => array(-660, 0, -60,  0, 10, 0, 5, 3, 0, 0, 0,  0, 3, 0, 5, 2, 0, 0, 0),
180 180
                         //"Mauritius Standard Time"                   => array(-240, 0, -60,  0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0),
181
-                        "Mid-Atlantic Standard Time"                => array(120, 0, -60,  0, 9, 0, 5, 2, 0, 0, 0,  0, 3, 0, 5, 2, 0, 0, 0),
181
+                        "Mid-Atlantic Standard Time"                => array(120, 0, -60, 0, 9, 0, 5, 2, 0, 0, 0, 0, 3, 0, 5, 2, 0, 0, 0),
182 182
                         //"Middle East Standard Time"                 => array(-120, 0, -60,  0, 10, 6, 5, 23, 59, 59, 999,  0, 3, 6, 4, 23, 59, 59, 999),
183 183
                         //"Montevideo Standard Time"                  => array(180, 0, -60,  0, 3, 0, 2, 2, 0, 0, 0,  0, 10, 0, 1, 2, 0, 0, 0),
184 184
                         //"Morocco Standard Time"                     => array(0, 0, -60,  0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0),
185
-                        "Mountain Standard Time"                    => array(420, 0, -60,  0, 11, 0, 1, 2, 0, 0, 0,  0, 3, 0, 2, 2, 0, 0, 0),
186
-                        "Mexico Standard Time 2"                    => array(420, 0, -60,  0, 10, 0, 5, 2, 0, 0, 0,  0, 4, 0, 1, 2, 0, 0, 0),
187
-                        "Myanmar Standard Time"                     => array(-390, 0, -60,  0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0),
188
-                        "N Central Asia Standard Time"              => array(-360, 0, -60,  0, 10, 0, 5, 3, 0, 0, 0,  0, 3, 0, 5, 2, 0, 0, 0),
185
+                        "Mountain Standard Time"                    => array(420, 0, -60, 0, 11, 0, 1, 2, 0, 0, 0, 0, 3, 0, 2, 2, 0, 0, 0),
186
+                        "Mexico Standard Time 2"                    => array(420, 0, -60, 0, 10, 0, 5, 2, 0, 0, 0, 0, 4, 0, 1, 2, 0, 0, 0),
187
+                        "Myanmar Standard Time"                     => array(-390, 0, -60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
188
+                        "N Central Asia Standard Time"              => array(-360, 0, -60, 0, 10, 0, 5, 3, 0, 0, 0, 0, 3, 0, 5, 2, 0, 0, 0),
189 189
                         //"Namibia Standard Time"                     => array(-60, 0, -60,  0, 4, 0, 1, 2, 0, 0, 0,  0, 9, 0, 1, 2, 0, 0, 0),
190
-                        "Nepal Standard Time"                       => array(-345, 0, -60,  0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0),
191
-                        "New Zealand Standard Time"                 => array(-720, 0, -60,  0, 4, 0, 1, 3, 0, 0, 0,  0, 9, 0, 5, 2, 0, 0, 0),
192
-                        "Newfoundland and Labrador Standard Time"   => array(210, 0, -60,  0, 11, 0, 1, 0, 1, 0, 0,  0, 3, 0, 2, 0, 1, 0, 0),
193
-                        "North Asia East Standard Time"             => array(-480, 0, -60,  0, 10, 0, 5, 3, 0, 0, 0,  0, 3, 0, 5, 2, 0, 0, 0),
194
-                        "North Asia Standard Time"                  => array(-420, 0, -60,  0, 10, 0, 5, 3, 0, 0, 0,  0, 3, 0, 5, 2, 0, 0, 0),
195
-                        "Pacific SA Standard Time"                  => array(240, 0, -60,  0, 3, 6, 2, 23, 59, 59, 999,  0, 10, 6, 2, 23, 59, 59, 999),
196
-                        "Pacific Standard Time"                     => array(480, 0, -60,  0, 11, 0, 1, 2, 0, 0, 0,  0, 3, 0, 2, 2, 0, 0, 0),
190
+                        "Nepal Standard Time"                       => array(-345, 0, -60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
191
+                        "New Zealand Standard Time"                 => array(-720, 0, -60, 0, 4, 0, 1, 3, 0, 0, 0, 0, 9, 0, 5, 2, 0, 0, 0),
192
+                        "Newfoundland and Labrador Standard Time"   => array(210, 0, -60, 0, 11, 0, 1, 0, 1, 0, 0, 0, 3, 0, 2, 0, 1, 0, 0),
193
+                        "North Asia East Standard Time"             => array(-480, 0, -60, 0, 10, 0, 5, 3, 0, 0, 0, 0, 3, 0, 5, 2, 0, 0, 0),
194
+                        "North Asia Standard Time"                  => array(-420, 0, -60, 0, 10, 0, 5, 3, 0, 0, 0, 0, 3, 0, 5, 2, 0, 0, 0),
195
+                        "Pacific SA Standard Time"                  => array(240, 0, -60, 0, 3, 6, 2, 23, 59, 59, 999, 0, 10, 6, 2, 23, 59, 59, 999),
196
+                        "Pacific Standard Time"                     => array(480, 0, -60, 0, 11, 0, 1, 2, 0, 0, 0, 0, 3, 0, 2, 2, 0, 0, 0),
197 197
                         //"Pacific Standard Time (Mexico)"            => array(480, 0, -60,  0, 10, 0, 5, 2, 0, 0, 0,  0, 4, 0, 1, 2, 0, 0, 0),
198 198
                         //"Pakistan Standard Time"                    => array(-300, 0, -60,  0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0),
199 199
                         //"Paraguay Standard Time"                    => array(240, 0, -60,  0, 4, 6, 1, 23, 59, 59, 999,  0, 10, 6, 1, 23, 59, 59, 999),
200
-                        "Romance Standard Time"                     => array(-60, 0, -60,  0, 10, 0, 5, 3, 0, 0, 0,  0, 3, 0, 5, 2, 0, 0, 0),
201
-                        "Russian Standard Time"                     => array(-180, 0, -60,  0, 10, 0, 5, 3, 0, 0, 0,  0, 3, 0, 5, 2, 0, 0, 0),
202
-                        "SA Eastern Standard Time"                  => array(180, 0, -60,  0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0),
203
-                        "SA Pacific Standard Time"                  => array(300, 0, -60,  0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0),
204
-                        "SA Western Standard Time"                  => array(240, 0, -60,  0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0),
205
-                        "Samoa Standard Time"                       => array(660, 0, -60,  0, 3, 6, 5, 23, 59, 59, 999,  0, 9, 6, 5, 23, 59, 59, 999),
206
-                        "SE Asia Standard Time"                     => array(-420, 0, -60,  0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0),
207
-                        "Singapore Standard Time"                   => array(-480, 0, -60,  0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0),
208
-                        "South Africa Standard Time"                => array(-120, 0, -60,  0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0),
209
-                        "Sri Lanka Standard Time"                   => array(-330, 0, -60,  0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0),
200
+                        "Romance Standard Time"                     => array(-60, 0, -60, 0, 10, 0, 5, 3, 0, 0, 0, 0, 3, 0, 5, 2, 0, 0, 0),
201
+                        "Russian Standard Time"                     => array(-180, 0, -60, 0, 10, 0, 5, 3, 0, 0, 0, 0, 3, 0, 5, 2, 0, 0, 0),
202
+                        "SA Eastern Standard Time"                  => array(180, 0, -60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
203
+                        "SA Pacific Standard Time"                  => array(300, 0, -60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
204
+                        "SA Western Standard Time"                  => array(240, 0, -60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
205
+                        "Samoa Standard Time"                       => array(660, 0, -60, 0, 3, 6, 5, 23, 59, 59, 999, 0, 9, 6, 5, 23, 59, 59, 999),
206
+                        "SE Asia Standard Time"                     => array(-420, 0, -60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
207
+                        "Singapore Standard Time"                   => array(-480, 0, -60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
208
+                        "South Africa Standard Time"                => array(-120, 0, -60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
209
+                        "Sri Lanka Standard Time"                   => array(-330, 0, -60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
210 210
                         //"Syria Standard Time"                       => array(-120, 0, -60,  0, 10, 4, 5, 23, 59, 59, 999,  0, 4, 4, 1, 23, 59, 59, 999),
211
-                        "Taipei Standard Time"                      => array(-480, 0, -60,  0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0),
212
-                        "Tasmania Standard Time"                    => array(-600, 0, -60,  0, 4, 0, 1, 3, 0, 0, 0,  0, 10, 0, 1, 2, 0, 0, 0),
213
-                        "Tokyo Standard Time"                       => array(-540, 0, -60,  0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0),
214
-                        "Tonga Standard Time"                       => array(-780, 0, -60,  0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0),
211
+                        "Taipei Standard Time"                      => array(-480, 0, -60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
212
+                        "Tasmania Standard Time"                    => array(-600, 0, -60, 0, 4, 0, 1, 3, 0, 0, 0, 0, 10, 0, 1, 2, 0, 0, 0),
213
+                        "Tokyo Standard Time"                       => array(-540, 0, -60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
214
+                        "Tonga Standard Time"                       => array(-780, 0, -60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
215 215
                         //"Ulaanbaatar Standard Time"                 => array(-480, 0, -60,  0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0),
216
-                        "US Eastern Standard Time"                  => array(300, 0, -60,  0, 11, 0, 1, 2, 0, 0, 0,  0, 3, 0, 2, 2, 0, 0, 0),
217
-                        "US Mountain Standard Time"                 => array(420, 0, -60,  0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0),
216
+                        "US Eastern Standard Time"                  => array(300, 0, -60, 0, 11, 0, 1, 2, 0, 0, 0, 0, 3, 0, 2, 2, 0, 0, 0),
217
+                        "US Mountain Standard Time"                 => array(420, 0, -60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
218 218
                         //"UTC"                                       => array(0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0),
219 219
                         //"UTC+12"                                    => array(-720, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0),
220 220
                         //"UTC-02"                                    => array(120, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0),
221 221
                         //"UTC-11"                                    => array(660, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0),
222
-                        "Venezuela Standard Time"                   => array(270, 0, -60,  0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0),
223
-                        "Vladivostok Standard Time"                 => array(-600, 0, -60,  0, 10, 0, 5, 3, 0, 0, 0,  0, 3, 0, 5, 2, 0, 0, 0),
224
-                        "W Australia Standard Time"                 => array(-480, 0, -60,  0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0),
225
-                        "W Central Africa Standard Time"            => array(-60, 0, -60,  0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0),
226
-                        "W Europe Standard Time"                    => array(-60, 0, -60,  0, 10, 0, 5, 3, 0, 0, 0,  0, 3, 0, 5, 2, 0, 0, 0),
227
-                        "West Asia Standard Time"                   => array(-300, 0, -60,  0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0),
228
-                        "West Pacific Standard Time"                => array(-600, 0, -60,  0, 0, 0, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 0, 0, 0),
229
-                        "Yakutsk Standard Time"                     => array(-540, 0, -60,  0, 10, 0, 5, 3, 0, 0, 0,  0, 3, 0, 5, 2, 0, 0, 0),
222
+                        "Venezuela Standard Time"                   => array(270, 0, -60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
223
+                        "Vladivostok Standard Time"                 => array(-600, 0, -60, 0, 10, 0, 5, 3, 0, 0, 0, 0, 3, 0, 5, 2, 0, 0, 0),
224
+                        "W Australia Standard Time"                 => array(-480, 0, -60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
225
+                        "W Central Africa Standard Time"            => array(-60, 0, -60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
226
+                        "W Europe Standard Time"                    => array(-60, 0, -60, 0, 10, 0, 5, 3, 0, 0, 0, 0, 3, 0, 5, 2, 0, 0, 0),
227
+                        "West Asia Standard Time"                   => array(-300, 0, -60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
228
+                        "West Pacific Standard Time"                => array(-600, 0, -60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
229
+                        "Yakutsk Standard Time"                     => array(-540, 0, -60, 0, 10, 0, 5, 3, 0, 0, 0, 0, 3, 0, 5, 2, 0, 0, 0),
230 230
                 );
231 231
 
232 232
     /**
@@ -1063,7 +1063,7 @@  discard block
 block discarded – undo
1063 1063
         if ($phptimezone === false)
1064 1064
             $phptimezone = date_default_timezone_get();
1065 1065
 
1066
-        ZLog::Write(LOGLEVEL_DEBUG, "TimezoneUtil::GetFullTZ() for ". $phptimezone);
1066
+        ZLog::Write(LOGLEVEL_DEBUG, "TimezoneUtil::GetFullTZ() for ".$phptimezone);
1067 1067
 
1068 1068
         $servertzname = self::guessTZNameFromPHPName($phptimezone);
1069 1069
         return self::GetFullTZFromTZName($servertzname);
@@ -1121,7 +1121,7 @@  discard block
 block discarded – undo
1121 1121
      * @return array
1122 1122
      */
1123 1123
     static public function FillTZNames($tz) {
1124
-        ZLog::Write(LOGLEVEL_DEBUG, "TimezoneUtil::FillTZNames() filling up bias ". $tz["bias"]);
1124
+        ZLog::Write(LOGLEVEL_DEBUG, "TimezoneUtil::FillTZNames() filling up bias ".$tz["bias"]);
1125 1125
         if (!isset($tz["bias"]))
1126 1126
             ZLog::Write(LOGLEVEL_WARN, "TimezoneUtil::FillTZNames() submitted TZ array does not have a bias");
1127 1127
         else {
@@ -1143,10 +1143,10 @@  discard block
 block discarded – undo
1143 1143
         // try to find a quite exact match
1144 1144
         foreach (self::$tzonesoffsets as $tzname => $tzoffset) {
1145 1145
             if ($offset["bias"] == $tzoffset[0] &&
1146
-                isset($offset["dstendmonth"])   && $offset["dstendmonth"] == $tzoffset[4] &&
1147
-                isset($offset["dstendday"])     && $offset["dstendday"] == $tzoffset[6] &&
1146
+                isset($offset["dstendmonth"]) && $offset["dstendmonth"] == $tzoffset[4] &&
1147
+                isset($offset["dstendday"]) && $offset["dstendday"] == $tzoffset[6] &&
1148 1148
                 isset($offset["dststartmonth"]) && $offset["dststartmonth"] == $tzoffset[12] &&
1149
-                isset($offset["dststartday"])   && $offset["dststartday"] == $tzoffset[14])
1149
+                isset($offset["dststartday"]) && $offset["dststartday"] == $tzoffset[14])
1150 1150
                 return $tzname;
1151 1151
         }
1152 1152
 
@@ -1235,7 +1235,7 @@  discard block
 block discarded – undo
1235 1235
      * @return string
1236 1236
      */
1237 1237
     static private function encodeTZName($name) {
1238
-        return substr(iconv('UTF-8', 'UTF-16', $name),2,-1);
1238
+        return substr(iconv('UTF-8', 'UTF-16', $name), 2, -1);
1239 1239
     }
1240 1240
 
1241 1241
     /**
@@ -1248,7 +1248,7 @@  discard block
 block discarded – undo
1248 1248
     static public function TZtest() {
1249 1249
         foreach (self::$mstzones as $mskey => $msdefs) {
1250 1250
             if (!array_key_exists($msdefs[0], self::$tzonesoffsets))
1251
-                echo "key   '". $msdefs[0]. "'   not found in tzonesoffsets\n";
1251
+                echo "key   '".$msdefs[0]."'   not found in tzonesoffsets\n";
1252 1252
         }
1253 1253
 
1254 1254
         foreach (self::$tzonesoffsets as $tzname => $offset) {
@@ -1277,7 +1277,7 @@  discard block
 block discarded – undo
1277 1277
         if (!isset($tz["tzname"]) || !$tz["tzname"] || !isset($tz["tznamedst"]) || !$tz["tznamedst"])
1278 1278
             $tz = TimezoneUtil::FillTZNames($tz);
1279 1279
 
1280
-        $packed = pack("la64vvvvvvvv" . "la64vvvvvvvv" . "l",
1280
+        $packed = pack("la64vvvvvvvv"."la64vvvvvvvv"."l",
1281 1281
                 $tz["bias"], $tz["tzname"], 0, $tz["dstendmonth"], $tz["dstendday"], $tz["dstendweek"], $tz["dstendhour"], $tz["dstendminute"], $tz["dstendsecond"], $tz["dstendmillis"],
1282 1282
                 $tz["stdbias"], $tz["tznamedst"], 0, $tz["dststartmonth"], $tz["dststartday"], $tz["dststartweek"], $tz["dststarthour"], $tz["dststartminute"], $tz["dststartsecond"], $tz["dststartmillis"],
1283 1283
                 $tz["dstbias"]);
@@ -1311,7 +1311,7 @@  discard block
 block discarded – undo
1311 1311
         }
1312 1312
         if (!$date) {
1313 1313
             //20110930 (Append T000000Z to the date, so it starts at midnight)
1314
-            $date = date_create_from_format('Ymd\THis\Z', $value . "T000000Z", $tz);
1314
+            $date = date_create_from_format('Ymd\THis\Z', $value."T000000Z", $tz);
1315 1315
         }
1316 1316
         return date_timestamp_get($date);
1317 1317
     }
@@ -1328,15 +1328,15 @@  discard block
 block discarded – undo
1328 1328
     public static function ParseTimezone($timezone) {
1329 1329
         //(GMT+01.00) Amsterdam / Berlin / Bern / Rome / Stockholm / Vienna
1330 1330
         if (preg_match('/GMT(\\+|\\-)0(\d)/', $timezone, $matches)) {
1331
-            return "Etc/GMT" . $matches[1] . $matches[2];
1331
+            return "Etc/GMT".$matches[1].$matches[2];
1332 1332
         }
1333 1333
         //(GMT+10.00) XXX / XXX / XXX / XXX
1334 1334
         if (preg_match('/GMT(\\+|\\-)1(\d)/', $timezone, $matches)) {
1335
-            return "Etc/GMT" . $matches[1] . "1" . $matches[2];
1335
+            return "Etc/GMT".$matches[1]."1".$matches[2];
1336 1336
         }
1337 1337
         ///inverse.ca/20101018_1/Europe/Amsterdam or /inverse.ca/20101018_1/America/Argentina/Buenos_Aires
1338 1338
         if (preg_match('/\/[.[:word:]]+\/\w+\/(\w+)\/([\w\/]+)/', $timezone, $matches)) {
1339
-            return $matches[1] . "/" . $matches[2];
1339
+            return $matches[1]."/".$matches[2];
1340 1340
         }
1341 1341
         return self::getMSTZnameFromTZName(trim($timezone, '"'));
1342 1342
     }
Please login to merge, or discard this patch.
Braces   +27 added lines, -19 removed lines patch added patch discarded remove patch
@@ -1060,8 +1060,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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"],
Please login to merge, or discard this patch.
lib/exceptions/httpreturncodeexception.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,6 +14,6 @@
 block discarded – undo
14 14
     public function __construct($message = "", $code = 0, $previous = NULL, $logLevel = false) {
15 15
         if ($code)
16 16
             $this->httpReturnCode = $code;
17
-        parent::__construct($message, (int) $code, $previous, $logLevel);
17
+        parent::__construct($message, (int)$code, $previous, $logLevel);
18 18
     }
19 19
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,8 +12,9 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
lib/exceptions/zpushexception.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -15,18 +15,18 @@
 block discarded – undo
15 15
     protected $showLegal = true;
16 16
 
17 17
     public function __construct($message = "", $code = 0, $previous = NULL, $logLevel = false) {
18
-        if (! $message)
18
+        if (!$message)
19 19
             $message = $this->httpReturnMessage;
20 20
 
21 21
         if (!$logLevel)
22 22
             $logLevel = $this->defaultLogLevel;
23 23
 
24
-        parent::__construct($message, (int) $code);
25
-        ZLog::Write($logLevel, get_class($this) .': '. $message . ' - code: '.$code. ' - file: '. $this->getFile().':'.$this->getLine(), false);
24
+        parent::__construct($message, (int)$code);
25
+        ZLog::Write($logLevel, get_class($this).': '.$message.' - code: '.$code.' - file: '.$this->getFile().':'.$this->getLine(), false);
26 26
     }
27 27
 
28 28
     public function getHTTPCodeString() {
29
-        return $this->httpReturnCode . " ". $this->httpReturnMessage;
29
+        return $this->httpReturnCode." ".$this->httpReturnMessage;
30 30
     }
31 31
 
32 32
     public function getHTTPHeaders() {
Please login to merge, or discard this patch.
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -15,11 +15,13 @@
 block discarded – undo
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);
Please login to merge, or discard this patch.
lib/exceptions/serviceunavailableexception.php 2 patches
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -8,16 +8,16 @@
 block discarded – undo
8 8
  */
9 9
 
10 10
 class ServiceUnavailableException extends HTTPReturnCodeException {
11
-	protected $defaultLogLevel = LOGLEVEL_INFO;
12
-	protected $httpReturnCode = HTTP_CODE_503;
13
-	protected $httpReturnMessage = "Service Unavailable";
14
-	protected $httpHeaders = array();
15
-	protected $showLegal = false;
11
+    protected $defaultLogLevel = LOGLEVEL_INFO;
12
+    protected $httpReturnCode = HTTP_CODE_503;
13
+    protected $httpReturnMessage = "Service Unavailable";
14
+    protected $httpHeaders = array();
15
+    protected $showLegal = false;
16 16
 
17
-	public function __construct($message = "", $code = 0, $previous = NULL, $logLevel = false) {
18
-		parent::__construct($message, $code, $previous, $logLevel);
19
-		if (RETRY_AFTER_DELAY !== false) {
20
-			$this->httpHeaders[] = 'Retry-After: ' . RETRY_AFTER_DELAY;
21
-		}
22
-	}
17
+    public function __construct($message = "", $code = 0, $previous = NULL, $logLevel = false) {
18
+        parent::__construct($message, $code, $previous, $logLevel);
19
+        if (RETRY_AFTER_DELAY !== false) {
20
+            $this->httpHeaders[] = 'Retry-After: ' . RETRY_AFTER_DELAY;
21
+        }
22
+    }
23 23
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@
 block discarded – undo
17 17
 	public function __construct($message = "", $code = 0, $previous = NULL, $logLevel = false) {
18 18
 		parent::__construct($message, $code, $previous, $logLevel);
19 19
 		if (RETRY_AFTER_DELAY !== false) {
20
-			$this->httpHeaders[] = 'Retry-After: ' . RETRY_AFTER_DELAY;
20
+			$this->httpHeaders[] = 'Retry-After: '.RETRY_AFTER_DELAY;
21 21
 		}
22 22
 	}
23 23
 }
Please login to merge, or discard this patch.
grommunio-sync-top.php 2 patches
Spacing   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -16,11 +16,11 @@  discard block
 block discarded – undo
16 16
 /************************************************
17 17
  * MAIN
18 18
  */
19
-    declare(ticks = 1);
20
-    define('BASE_PATH_CLI',  dirname(__FILE__) ."/");
21
-    set_include_path(get_include_path() . PATH_SEPARATOR . BASE_PATH_CLI);
19
+    declare(ticks=1);
20
+    define('BASE_PATH_CLI', dirname(__FILE__)."/");
21
+    set_include_path(get_include_path().PATH_SEPARATOR.BASE_PATH_CLI);
22 22
 
23
-    if (!defined('ZPUSH_CONFIG')) define('ZPUSH_CONFIG', BASE_PATH_CLI . 'config.php');
23
+    if (!defined('ZPUSH_CONFIG')) define('ZPUSH_CONFIG', BASE_PATH_CLI.'config.php');
24 24
     include_once(ZPUSH_CONFIG);
25 25
 
26 26
     try {
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
             echo "grommunio-sync interprocess communication (IPC) is not available or TopCollector is disabled.\n";
50 50
     }
51 51
     catch (ZPushException $zpe) {
52
-        fwrite(STDERR, get_class($zpe) . ": ". $zpe->getMessage() . "\n");
52
+        fwrite(STDERR, get_class($zpe).": ".$zpe->getMessage()."\n");
53 53
         exit(1);
54 54
     }
55 55
 
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
             // wait for user input
178 178
             $this->readLineProcess();
179 179
         }
180
-        while($this->terminate != true);
180
+        while ($this->terminate != true);
181 181
     }
182 182
 
183 183
     /**
@@ -233,20 +233,20 @@  discard block
 block discarded – undo
233 233
                         if ($line['push'] === true) $this->pushConn += 1;
234 234
 
235 235
                         // ignore push connections
236
-                        if ($line['push'] === true && ! $this->showPush)
236
+                        if ($line['push'] === true && !$this->showPush)
237 237
                             continue;
238 238
 
239 239
                         if ($this->filter !== false) {
240 240
                             $f = $this->filter;
241 241
                             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']) ))
242
+                                preg_match("/.*?$f.*?/i", $line['devagent']) || preg_match("/.*?$f.*?/i", $line['devid']) || preg_match("/.*?$f.*?/i", $line['addinfo'])))
243 243
                                 continue;
244 244
                         }
245 245
 
246 246
                         $lastUpdate = $this->currenttime - $line["update"];
247 247
                         if ($this->currenttime - $line["update"] < 2)
248 248
                             $this->linesActive[$line["update"].$line["pid"]] = $line;
249
-                        else if (($line['push'] === true  && $lastUpdate > ($this->pingInterval+2)) || ($line['push'] !== true  && $lastUpdate > 4))
249
+                        else if (($line['push'] === true && $lastUpdate > ($this->pingInterval + 2)) || ($line['push'] !== true && $lastUpdate > 4))
250 250
                             $this->linesUnknown[$line["update"].$line["pid"]] = $line;
251 251
                         else
252 252
                             $this->linesOpen[$line["update"].$line["pid"]] = $line;
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
                         if ($this->filter !== false) {
260 260
                             $f = $this->filter;
261 261
                             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']) ))
262
+                                preg_match("/.*?$f.*?/i", $line['devagent']) || preg_match("/.*?$f.*?/i", $line['devid']) || preg_match("/.*?$f.*?/i", $line['addinfo'])))
263 263
                                 continue;
264 264
                         }
265 265
 
@@ -286,23 +286,23 @@  discard block
 block discarded – undo
286 286
     private function scrOverview() {
287 287
         $linesAvail = $this->scrSize['height'] - 8;
288 288
         $lc = 1;
289
-        $this->scrPrintAt($lc,0, "\033[1mgrommunio-sync-top live statistics\033[0m\t\t\t\t\t". @strftime("%d/%m/%Y %T")."\n"); $lc++;
289
+        $this->scrPrintAt($lc, 0, "\033[1mgrommunio-sync-top live statistics\033[0m\t\t\t\t\t".@strftime("%d/%m/%Y %T")."\n"); $lc++;
290 290
 
291
-        $this->scrPrintAt($lc,0, sprintf("Open connections: %d\t\t\t\tUsers:\t %d\tgrommunio-sync:   %s ",count($this->activeConn),count($this->activeUsers), $this->getVersion())); $lc++;
292
-        $this->scrPrintAt($lc,0, sprintf("Push connections: %d\t\t\t\tDevices: %d\tPHP-MAPI: %s", $this->pushConn, count($this->activeDevices),phpversion("mapi"))); $lc++;
293
-        $this->scrPrintAt($lc,0, sprintf("                                                Hosts:\t %d", count($this->activeHosts))); $lc++;
291
+        $this->scrPrintAt($lc, 0, sprintf("Open connections: %d\t\t\t\tUsers:\t %d\tgrommunio-sync:   %s ", count($this->activeConn), count($this->activeUsers), $this->getVersion())); $lc++;
292
+        $this->scrPrintAt($lc, 0, sprintf("Push connections: %d\t\t\t\tDevices: %d\tPHP-MAPI: %s", $this->pushConn, count($this->activeDevices), phpversion("mapi"))); $lc++;
293
+        $this->scrPrintAt($lc, 0, sprintf("                                                Hosts:\t %d", count($this->activeHosts))); $lc++;
294 294
         $lc++;
295 295
 
296
-        $this->scrPrintAt($lc,0, "\033[4m". $this->getLine(array('pid'=>'PID', 'ip'=>'IP', 'user'=>'USER', 'command'=>'COMMAND', 'time'=>'TIME', 'devagent'=>'AGENT', 'devid'=>'DEVID', 'addinfo'=>'Additional Information')). str_repeat(" ",20)."\033[0m"); $lc++;
296
+        $this->scrPrintAt($lc, 0, "\033[4m".$this->getLine(array('pid'=>'PID', 'ip'=>'IP', 'user'=>'USER', 'command'=>'COMMAND', 'time'=>'TIME', 'devagent'=>'AGENT', 'devid'=>'DEVID', 'addinfo'=>'Additional Information')).str_repeat(" ", 20)."\033[0m"); $lc++;
297 297
 
298 298
         // print help text if requested
299 299
         $hl = 0;
300 300
         if ($this->helpexpire > $this->currenttime) {
301 301
             $help = $this->scrHelp();
302 302
             $linesAvail -= count($help);
303
-            $hl = $this->scrSize['height'] - count($help) -1;
303
+            $hl = $this->scrSize['height'] - count($help) - 1;
304 304
             foreach ($help as $h) {
305
-                $this->scrPrintAt($hl,0, $h);
305
+                $this->scrPrintAt($hl, 0, $h);
306 306
                 $hl++;
307 307
             }
308 308
         }
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
         if (count($this->linesActive) + count($this->linesOpen) + count($this->linesUnknown) > $linesAvail) {
317 317
             $toPrintUnknown = count($this->linesUnknown);
318 318
             $toPrintActive = count($this->linesActive);
319
-            $toPrintOpen = $linesAvail-$toPrintUnknown-$toPrintActive;
319
+            $toPrintOpen = $linesAvail - $toPrintUnknown - $toPrintActive;
320 320
             $toPrintTerm = 0;
321 321
         }
322 322
 
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
             if ($linesprinted >= $toPrintActive)
340 340
                 break;
341 341
 
342
-            $this->scrPrintAt($lc,0, "\033[01m" . $this->getLine($l)  ."\033[0m");
342
+            $this->scrPrintAt($lc, 0, "\033[01m".$this->getLine($l)."\033[0m");
343 343
             $lc++;
344 344
             $linesprinted++;
345 345
         }
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
             if ($linesprinted >= $toPrintOpen)
350 350
                 break;
351 351
 
352
-            $this->scrPrintAt($lc,0, $this->getLine($l));
352
+            $this->scrPrintAt($lc, 0, $this->getLine($l));
353 353
             $lc++;
354 354
             $linesprinted++;
355 355
         }
@@ -362,28 +362,28 @@  discard block
 block discarded – undo
362 362
             $color = "0;31m";
363 363
             if ($l['push'] == false && $time - $l["start"] > 30)
364 364
                 $color = "1;31m";
365
-            $this->scrPrintAt($lc,0, "\033[0". $color . $this->getLine($l)  ."\033[0m");
365
+            $this->scrPrintAt($lc, 0, "\033[0".$color.$this->getLine($l)."\033[0m");
366 366
             $lc++;
367 367
             $linesprinted++;
368 368
         }
369 369
 
370 370
         if ($toPrintTerm > 0)
371
-            $toPrintTerm = $linesAvail - $lc +6;
371
+            $toPrintTerm = $linesAvail - $lc + 6;
372 372
 
373 373
         $linesprinted = 0;
374
-        foreach ($this->linesTerm as $time=>$l){
374
+        foreach ($this->linesTerm as $time=>$l) {
375 375
             if ($linesprinted >= $toPrintTerm)
376 376
                 break;
377 377
 
378
-            $this->scrPrintAt($lc,0, "\033[01;30m" . $this->getLine($l)  ."\033[0m");
378
+            $this->scrPrintAt($lc, 0, "\033[01;30m".$this->getLine($l)."\033[0m");
379 379
             $lc++;
380 380
             $linesprinted++;
381 381
         }
382 382
 
383 383
         // add the lines used when displaying the help text
384 384
         $lc += $hl;
385
-        $this->scrPrintAt($lc,0, "\033[K"); $lc++;
386
-        $this->scrPrintAt($lc,0, "Colorscheme: \033[01mActive  \033[0mOpen  \033[01;31mUnknown  \033[01;30mTerminated\033[0m");
385
+        $this->scrPrintAt($lc, 0, "\033[K"); $lc++;
386
+        $this->scrPrintAt($lc, 0, "Colorscheme: \033[01mActive  \033[0mOpen  \033[01;31mUnknown  \033[01;30mTerminated\033[0m");
387 387
 
388 388
         // remove old status
389 389
         if ($this->statusexpire < $this->currenttime)
@@ -391,13 +391,13 @@  discard block
 block discarded – undo
391 391
 
392 392
         // show request information and help command
393 393
         if ($this->starttime + 6 > $this->currenttime) {
394
-            $this->status = sprintf("Requesting information (takes up to %dsecs)", $this->pingInterval). str_repeat(".", ($this->currenttime-$this->starttime)) . "  type \033[01;31mh\033[00;31m or \033[01;31mhelp\033[00;31m for usage instructions";
395
-            $this->statusexpire = $this->currenttime+1;
394
+            $this->status = sprintf("Requesting information (takes up to %dsecs)", $this->pingInterval).str_repeat(".", ($this->currenttime - $this->starttime))."  type \033[01;31mh\033[00;31m or \033[01;31mhelp\033[00;31m for usage instructions";
395
+            $this->statusexpire = $this->currenttime + 1;
396 396
         }
397 397
 
398 398
 
399 399
         $str = "";
400
-        if (! $this->showPush)
400
+        if (!$this->showPush)
401 401
             $str .= "\033[00;32mPush: \033[01;32mNo\033[0m   ";
402 402
 
403 403
         if ($this->showOption == self::SHOW_ACTIVE_ONLY)
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
             $str .= "\033[01;32mUnknown only\033[0m   ";
408 408
 
409 409
         if ($this->showTermSec != self::SHOW_TERM_DEFAULT_TIME)
410
-            $str .= "\033[01;32mTerminated: ". $this->showTermSec. "s\033[0m   ";
410
+            $str .= "\033[01;32mTerminated: ".$this->showTermSec."s\033[0m   ";
411 411
 
412 412
         if ($this->filter !== false || ($this->status !== false && $this->statusexpire > $this->currenttime)) {
413 413
             // print filter in green
@@ -417,9 +417,9 @@  discard block
 block discarded – undo
417 417
             if ($this->status !== false)
418 418
                 $str .= "\033[00;31m$this->status\033[0m";
419 419
         }
420
-        $this->scrPrintAt(5,0, $str);
420
+        $this->scrPrintAt(5, 0, $str);
421 421
 
422
-        $this->scrPrintAt(4,0,"Action: \033[01m".$this->action . "\033[0m");
422
+        $this->scrPrintAt(4, 0, "Action: \033[01m".$this->action."\033[0m");
423 423
     }
424 424
 
425 425
     /**
@@ -433,14 +433,14 @@  discard block
 block discarded – undo
433 433
 
434 434
         if ($ans[0] < 128) {
435 435
             if (isset($ans[1]) && bin2hex(trim($ans[1])) == "7f") {
436
-                $this->action = substr($this->action,0,-1);
436
+                $this->action = substr($this->action, 0, -1);
437 437
             }
438 438
 
439
-            if (isset($ans[1]) && $ans[1] != "" ){
440
-                $this->action .= trim(preg_replace("/[^A-Za-z0-9:]/","",$ans[1]));
439
+            if (isset($ans[1]) && $ans[1] != "") {
440
+                $this->action .= trim(preg_replace("/[^A-Za-z0-9:]/", "", $ans[1]));
441 441
             }
442 442
 
443
-            if (bin2hex($ans[0]) == "30" && bin2hex($ans[1]) == "0a")  {
443
+            if (bin2hex($ans[0]) == "30" && bin2hex($ans[1]) == "0a") {
444 444
                 $cmds = explode(':', $this->action);
445 445
                 if ($cmds[0] == "quit" || $cmds[0] == "q" || (isset($cmds[1]) && $cmds[0] == "" && $cmds[1] == "q")) {
446 446
                     $this->topCollector->CollectData(true);
@@ -448,7 +448,7 @@  discard block
 block discarded – undo
448 448
 
449 449
                     $this->terminate = true;
450 450
                 }
451
-                else if ($cmds[0] == "clear" ) {
451
+                else if ($cmds[0] == "clear") {
452 452
                     $this->topCollector->ClearLatest(true);
453 453
                     $this->topCollector->CollectData(true);
454 454
                     $this->topCollector->ReInitIPC();
@@ -457,7 +457,7 @@  discard block
 block discarded – undo
457 457
                     if (!isset($cmds[1]) || $cmds[1] == "") {
458 458
                         $this->filter = false;
459 459
                         $this->status = "No filter";
460
-                        $this->statusexpire = $this->currenttime+5;
460
+                        $this->statusexpire = $this->currenttime + 5;
461 461
                     }
462 462
                     else {
463 463
                         $this->filter = $cmds[1];
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
                 else if ($cmds[0] == "option" || $cmds[0] == "o") {
468 468
                     if (!isset($cmds[1]) || $cmds[1] == "") {
469 469
                         $this->status = "Option value needs to be specified. See 'help' or 'h' for instructions";
470
-                        $this->statusexpire = $this->currenttime+5;
470
+                        $this->statusexpire = $this->currenttime + 5;
471 471
                     }
472 472
                     else if ($cmds[1] == "p" || $cmds[1] == "push" || $cmds[1] == "ping")
473 473
                         $this->showPush = !$this->showPush;
@@ -484,7 +484,7 @@  discard block
 block discarded – undo
484 484
                         $this->showTermSec = $cmds[1];
485 485
                     else {
486 486
                         $this->status = sprintf("Option '%s' unknown", $cmds[1]);
487
-                        $this->statusexpire = $this->currenttime+5;
487
+                        $this->statusexpire = $this->currenttime + 5;
488 488
                     }
489 489
                 }
490 490
                 else if ($cmds[0] == "reset" || $cmds[0] == "r") {
@@ -492,66 +492,66 @@  discard block
 block discarded – undo
492 492
                     $this->wide = false;
493 493
                     $this->helpexpire = 0;
494 494
                     $this->status = "reset";
495
-                    $this->statusexpire = $this->currenttime+2;
495
+                    $this->statusexpire = $this->currenttime + 2;
496 496
                 }
497 497
                 // enable/disable wide view
498 498
                 else if ($cmds[0] == "wide" || $cmds[0] == "w") {
499
-                    $this->wide = ! $this->wide;
500
-                    $this->status = ($this->wide)?"w i d e  view" : "normal view";
501
-                    $this->statusexpire = $this->currenttime+2;
499
+                    $this->wide = !$this->wide;
500
+                    $this->status = ($this->wide) ? "w i d e  view" : "normal view";
501
+                    $this->statusexpire = $this->currenttime + 2;
502 502
                 }
503 503
                 else if ($cmds[0] == "help" || $cmds[0] == "h") {
504
-                    $this->helpexpire = $this->currenttime+20;
504
+                    $this->helpexpire = $this->currenttime + 20;
505 505
                 }
506 506
                 // grep the log file
507
-                else if (($cmds[0] == "log" || $cmds[0] == "l") && isset($cmds[1]) ) {
507
+                else if (($cmds[0] == "log" || $cmds[0] == "l") && isset($cmds[1])) {
508 508
                     if (!file_exists(LOGFILE)) {
509
-                        $this->status = "Logfile can not be found: ". LOGFILE;
509
+                        $this->status = "Logfile can not be found: ".LOGFILE;
510 510
                     }
511 511
                     else {
512
-                        system('bash -c "fgrep -a '.escapeshellarg($cmds[1]).' '. LOGFILE .' | less +G" > `tty`');
512
+                        system('bash -c "fgrep -a '.escapeshellarg($cmds[1]).' '.LOGFILE.' | less +G" > `tty`');
513 513
                         $this->status = "Returning from log, updating data";
514 514
                     }
515
-                    $this->statusexpire = time()+5; // it might be much "later" now
515
+                    $this->statusexpire = time() + 5; // it might be much "later" now
516 516
                 }
517 517
                 // tail the log file
518 518
                 else if (($cmds[0] == "tail" || $cmds[0] == "t")) {
519 519
                     if (!file_exists(LOGFILE)) {
520
-                        $this->status = "Logfile can not be found: ". LOGFILE;
520
+                        $this->status = "Logfile can not be found: ".LOGFILE;
521 521
                     }
522 522
                     else {
523 523
                         $this->doingTail = true;
524 524
                         $this->scrClear();
525
-                        $this->scrPrintAt(1,0,$this->scrAsBold("Press CTRL+C to return to grommunio-sync-top\n\n"));
525
+                        $this->scrPrintAt(1, 0, $this->scrAsBold("Press CTRL+C to return to grommunio-sync-top\n\n"));
526 526
                         $secondary = "";
527
-                        if (isset($cmds[1])) $secondary =  " -n 200 | grep ".escapeshellarg($cmds[1]);
528
-                        system('bash -c "tail -f '. LOGFILE . $secondary . '" > `tty`');
527
+                        if (isset($cmds[1])) $secondary = " -n 200 | grep ".escapeshellarg($cmds[1]);
528
+                        system('bash -c "tail -f '.LOGFILE.$secondary.'" > `tty`');
529 529
                         $this->doingTail = false;
530 530
                         $this->status = "Returning from tail, updating data";
531 531
                     }
532
-                    $this->statusexpire = time()+5; // it might be much "later" now
532
+                    $this->statusexpire = time() + 5; // it might be much "later" now
533 533
                 }
534 534
                 // tail the error log file
535 535
                 else if (($cmds[0] == "error" || $cmds[0] == "e")) {
536 536
                     if (!file_exists(LOGERRORFILE)) {
537
-                        $this->status = "Error logfile can not be found: ". LOGERRORFILE;
537
+                        $this->status = "Error logfile can not be found: ".LOGERRORFILE;
538 538
                     }
539 539
                     else {
540 540
                         $this->doingTail = true;
541 541
                         $this->scrClear();
542
-                        $this->scrPrintAt(1,0,$this->scrAsBold("Press CTRL+C to return to grommunio-sync-top\n\n"));
542
+                        $this->scrPrintAt(1, 0, $this->scrAsBold("Press CTRL+C to return to grommunio-sync-top\n\n"));
543 543
                         $secondary = "";
544
-                        if (isset($cmds[1])) $secondary =  " -n 200 | grep ".escapeshellarg($cmds[1]);
545
-                        system('bash -c "tail -f '. LOGERRORFILE . $secondary . '" > `tty`');
544
+                        if (isset($cmds[1])) $secondary = " -n 200 | grep ".escapeshellarg($cmds[1]);
545
+                        system('bash -c "tail -f '.LOGERRORFILE.$secondary.'" > `tty`');
546 546
                         $this->doingTail = false;
547 547
                         $this->status = "Returning from tail, updating data";
548 548
                     }
549
-                    $this->statusexpire = time()+5; // it might be much "later" now
549
+                    $this->statusexpire = time() + 5; // it might be much "later" now
550 550
                 }
551 551
 
552 552
                 else if ($cmds[0] != "") {
553 553
                     $this->status = sprintf("Command '%s' unknown", $cmds[0]);
554
-                    $this->statusexpire = $this->currenttime+8;
554
+                    $this->statusexpire = $this->currenttime + 8;
555 555
                 }
556 556
                 $this->action = "";
557 557
             }
@@ -582,7 +582,7 @@  discard block
 block discarded – undo
582 582
      * @access public
583 583
      */
584 584
     public function UsageInstructions() {
585
-        $help = "Usage:\n\tgrommunio-sync-top.php\n\n" .
585
+        $help = "Usage:\n\tgrommunio-sync-top.php\n\n".
586 586
                 "  grommunio-sync-top is a live top-like overview of what grommunio-sync is doing. It does not have specific command line options.\n\n".
587 587
                 "  When grommunio-sync-top is running you can specify certain actions and options which can be executed (listed below).\n".
588 588
                 "  This help information can also be shown inside grommunio-sync-top by hitting 'help' or 'h'.\n\n";
@@ -634,7 +634,7 @@  discard block
 block discarded – undo
634 634
      * @return string       same text as bold
635 635
      */
636 636
     private function scrAsBold($text) {
637
-        return "\033[01m" . $text  ."\033[0m";
637
+        return "\033[01m".$text."\033[0m";
638 638
     }
639 639
 
640 640
     /**
@@ -647,9 +647,9 @@  discard block
 block discarded – undo
647 647
      */
648 648
     private function getLine($l) {
649 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']);
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 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']);
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']);
653 653
     }
654 654
 
655 655
     /**
@@ -667,11 +667,11 @@  discard block
 block discarded – undo
667 667
         if (strlen($str) < $size)
668 668
             return str_pad($str, $size);
669 669
         else if ($cutmiddle == true) {
670
-            $cut = ($size-2)/2;
671
-            return $this->ptStr(substr($str,0,$cut) ."..". substr($str,(-1)*($cut-1)), $size);
670
+            $cut = ($size - 2) / 2;
671
+            return $this->ptStr(substr($str, 0, $cut)."..".substr($str, (-1) * ($cut - 1)), $size);
672 672
         }
673 673
         else {
674
-            return substr($str,0,$size-3).".. ";
674
+            return substr($str, 0, $size - 3).".. ";
675 675
         }
676 676
     }
677 677
 
@@ -711,7 +711,7 @@  discard block
 block discarded – undo
711 711
     private function sec2min($s) {
712 712
         if (!is_int($s))
713 713
             return $s;
714
-        return sprintf("%02.2d:%02.2d", floor($s/60), $s%60);
714
+        return sprintf("%02.2d:%02.2d", floor($s / 60), $s % 60);
715 715
     }
716 716
 
717 717
     /**
@@ -746,7 +746,7 @@  discard block
 block discarded – undo
746 746
      * @access private
747 747
      * @return
748 748
      */
749
-    private function scrPrintAt($row, $col, $text="") {
749
+    private function scrPrintAt($row, $col, $text = "") {
750 750
         echo "\033[".$row.";".$col."H".$text;
751 751
     }
752 752
 
Please login to merge, or discard this patch.
Braces   +132 added lines, -111 removed lines patch added patch discarded remove patch
@@ -10,7 +10,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.