Make drafts send with in-reply-to headers (fix regression from long ago)
[squirrelmail.git] / include / timezones / check.php
CommitLineData
2d3a630b 1<?php
4b4abf93 2
2d3a630b 3/**
4 * SquirrelMail time zone library - time zone validation script.
5 *
22387c8d 6 * @copyright 2005-2017 The SquirrelMail Project Team
4b4abf93 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
2d3a630b 8 * @version $Id$
9 * @package squirrelmail
10 * @subpackage timezones
11 */
12
13/** @ignore */
14define('SM_PATH','../../');
15
16/** Send http header */
17header('Content-Type: text/plain');
18
19/** Information about script */
20echo "--------------------------------------------\n"
21 ." SquirrelMail time zone library test script\n"
22 ."--------------------------------------------\n";
23
24/** load SM config */
25unset($time_zone_type);
26if (file_exists(SM_PATH.'config/config.php')) {
27 include(SM_PATH.'config/config.php');
28} else {
29 echo "SquirrelMail configuration file is missing.\n";
30 exit();
31}
32
33/**
34 * Script does not test, if standard time zone libraries are missing.
35 * If they are missing or corrupted - php can fail, scream and show
36 * finger or other parts of interpreter.
37 */
38
39/** load original reference */
40include(SM_PATH.'include/timezones/standard_orig.php');
41
42/** move timezones to different array */
43$aTimeZonesOrig = $aTimeZones;
44unset($aTimeZones);
45
46if (! isset($time_zone_type) || $time_zone_type == 0 || $time_zone_type == 1) {
47 /** load new time zone library */
48 include(SM_PATH.'include/timezones/standard.php');
49} elseif ($time_zone_type == 2 || $time_zone_type == 3) {
50 /** load custom time zone library */
51 $aTimeZones=array();
52 if (file_exists(SM_PATH . 'config/timezones.php')) {
53 include(SM_PATH.'config/timezones.php');
54 } else {
55 echo "ERROR: config/timezones.php is missing.\n";
56 exit();
57 }
58} else {
59 echo "ERROR: invalid value in time_zone_type configuration.\n";
60 exit();
61}
62
63if (! isset($aTimeZones) || ! is_array($aTimeZones) || empty($aTimeZones)) {
64 echo "ERROR: timezones array is missing or empty.\n";
65 exit();
66}
67
68$error = false;
69
70/** test backward compatibility */
71echo "Testing backward compatibility:\n"
72 ." Failed time zones:\n";
73foreach ($aTimeZonesOrig as $TzKey => $TzData) {
74 if (! isset($aTimeZones[$TzKey])) {
75 echo ' '.$TzKey."\n";
76 $error = true;
77 }
78}
79if (! $error) {
80 echo " none. Looking good.\n";
81} else {
82 // error is not fatal, but test should fail only with limited custom time zone sets
83}
84
85echo "\n";
86
87/** test forward compatibility */
88$error = false;
89echo "Testing forward compatibility:\n"
90 ." New time zones:\n";
91foreach ($aTimeZones as $TzKey => $TzData) {
92 if (! isset($aTimeZonesOrig[$TzKey])) {
93 echo ' '.$TzKey."\n";
94 $error = true;
95 }
96}
97if (! $error) {
98 echo " no new time zones.\n";
99} else {
100 // error is not fatal. test should show new time zones, that are not
101 // present in timezones.cfg
102}
103
104echo "\n";
105
106/** test links */
107$error = false;
108echo "Testing time zone links:\n"
109 ." Failed time zone links:\n";
110foreach ($aTimeZones as $TzKey => $TzData) {
111 if (isset($TzData['LINK']) && ! isset($aTimeZones[$TzData['LINK']]['TZ'])) {
112 echo ' '.$TzKey.' = '.$TzData['LINK']."\n";
113 $error = true;
114 }
115}
116if (! $error) {
117 echo " none. Looking good.\n";
118} else {
119 // error is fatal. 'LINK' should always reffer to existing 'TZ' entries
120}
121
122echo "\n";
123
124/** Test TZ subkeys */
125$error = false;
126echo "Testing time zone TZ subkeys:\n"
127 ." Failed time zone TZ subkeys:\n";
128foreach ($aTimeZones as $TzKey => $TzData) {
129 if (! isset($TzData['LINK']) && ! isset($TzData['TZ'])) {
130 echo ' '.$TzKey."\n";
131 $error = true;
132 }
133}
134if (! $error) {
135 echo " none. Looking good.\n";
136} else {
137 // LINK or TZ are required for strict time zones. Interface won't break, but
138 // any error means inconsistency in time zone array.
139}
140
141echo "\n";
142
143/** Test NAME subkeys */
144$error = false;
145echo "Testing time zone NAME subkeys:\n"
146 ." Time zones without NAME subkeys:\n";
147foreach ($aTimeZones as $TzKey => $TzData) {
148 if (isset($TzData['TZ']) && ! isset($TzData['NAME'])) {
149 echo ' '.$TzKey."\n";
150 $error = true;
151 }
152}
153if (! $error) {
154 echo " none.\n";
155} else {
156 // error is not fatal. It would be nice if all geographic locations
157 // use some human readable name
158}
159
160echo "\n";
161
f1e423b2 162/** Test NAME subkeys */
163$error = false;
164echo " Time zones with empty NAME subkeys:\n";
165foreach ($aTimeZones as $TzKey => $TzData) {
166 if (isset($TzData['NAME']) && empty($TzData['NAME'])) {
167 echo ' '.$TzKey."\n";
168 $error = true;
169 }
170}
171if (! $error) {
172 echo " none. Looking good\n";
173} else {
174 // error is fatal. NAME should not be empty string.
175}
176
177echo "\n";
178
2d3a630b 179/** Test TZ subkeys with UCT/UTC/GMT offsets */
180$error = false;
181echo "Testing TZ subkeys with UCT/UTC/GMT offsets:\n"
182 ." Time zones UCT/UTC/GMT offsets:\n";
183foreach ($aTimeZones as $TzKey => $TzData) {
184 if (isset($TzData['TZ']) && preg_match("/^(UCT)|(UTC)|(GMT).+/i",$TzData['TZ'])) {
185 echo ' '.$TzKey.' = '.$TzData['TZ']."\n";
186 $error = true;
187 }
188}
189if (! $error) {
190 echo " none.\n";
191} else {
192 // I think error is fatal for UCT with offsets. date('T',time()) is corrupted.
193}
194
195echo "\n";
196
197/** Test TZ subkeys with custom TZ values and no offsets */
198$error = false;
199echo "Testing TZ subkeys with custom TZ values and no offsets:\n"
200 ." Time zones with custom TZ values and no offsets:\n";
201foreach ($aTimeZones as $TzKey => $TzData) {
202 if (isset($TzData['TZ']) &&
203 ! preg_match("/^((UCT)|(UTC)|(GMT).+)|(GMT)$/i",$TzData['TZ']) &&
204 preg_match("/^[a-z]+$/i",$TzData['TZ'])) {
205 echo ' '.$TzKey.' = '.$TzData['TZ']."\n";
206 $error = true;
207 }
208}
209if (! $error) {
210 echo " none.\n";
211} else {
212 // I think error is fatal. Time zone formating requires time zone name and offset from GMT.
213}
214
215echo "\n";
216
217echo "Done!\n";