line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTTP::ProxyPAC::Functions; |
2
|
3
|
|
|
3
|
|
16
|
use strict; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
98
|
|
3
|
3
|
|
|
3
|
|
2706
|
use IO::Socket; # inet_aton, inet_ntoa |
|
3
|
|
|
|
|
84456
|
|
|
3
|
|
|
|
|
17
|
|
4
|
3
|
|
|
3
|
|
4927
|
use Sys::Hostname; |
|
3
|
|
|
|
|
3937
|
|
|
3
|
|
|
|
|
1476
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our @PACFunctions = qw( |
7
|
|
|
|
|
|
|
isPlainHostName |
8
|
|
|
|
|
|
|
dnsDomainIs |
9
|
|
|
|
|
|
|
localHostOrDomainIs |
10
|
|
|
|
|
|
|
isResolvable |
11
|
|
|
|
|
|
|
isInNet |
12
|
|
|
|
|
|
|
dnsResolve |
13
|
|
|
|
|
|
|
myIpAddress |
14
|
|
|
|
|
|
|
dnsDomainLevels |
15
|
|
|
|
|
|
|
shExpMatch |
16
|
|
|
|
|
|
|
weekDayRange |
17
|
|
|
|
|
|
|
dateRange |
18
|
|
|
|
|
|
|
timeRange |
19
|
|
|
|
|
|
|
); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
############################################################################## |
22
|
|
|
|
|
|
|
# |
23
|
|
|
|
|
|
|
# isPlainHostName - PAC command that tells if this is a plain host name |
24
|
|
|
|
|
|
|
# (no dots) |
25
|
|
|
|
|
|
|
# |
26
|
|
|
|
|
|
|
############################################################################## |
27
|
|
|
|
|
|
|
sub isPlainHostName { |
28
|
0
|
|
|
0
|
0
|
0
|
my ($host) = @_; |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
0
|
return $host !~ /\./; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
############################################################################## |
34
|
|
|
|
|
|
|
# |
35
|
|
|
|
|
|
|
# dnsDomainIs - PAC command to tell if the host is in the domain. |
36
|
|
|
|
|
|
|
# |
37
|
|
|
|
|
|
|
############################################################################## |
38
|
|
|
|
|
|
|
sub dnsDomainIs { |
39
|
7
|
|
|
7
|
0
|
17
|
my ($host, $domain) = @_; |
40
|
|
|
|
|
|
|
|
41
|
7
|
|
|
|
|
27
|
my $lh = length($host); |
42
|
7
|
|
|
|
|
673
|
my $ld = length($domain); |
43
|
7
|
|
66
|
|
|
446
|
return $lh >= $ld |
44
|
|
|
|
|
|
|
&& substr($host, $lh - $ld) eq $domain; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
############################################################################## |
48
|
|
|
|
|
|
|
# |
49
|
|
|
|
|
|
|
# localHostOrDomainIs - PAC command to tell if the host matches, or if it is |
50
|
|
|
|
|
|
|
# unqualified and in the domain. |
51
|
|
|
|
|
|
|
# |
52
|
|
|
|
|
|
|
############################################################################## |
53
|
|
|
|
|
|
|
sub localHostOrDomainIs { |
54
|
0
|
|
|
0
|
0
|
0
|
my ($host, $hostdom) = @_; |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
0
|
|
|
0
|
return $host eq $hostdom |
57
|
|
|
|
|
|
|
|| rindex($hostdom, "$host.") == 0; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
############################################################################## |
61
|
|
|
|
|
|
|
# |
62
|
|
|
|
|
|
|
# isResolvable - PAC command to see if the host can be resolved via DNS. |
63
|
|
|
|
|
|
|
# |
64
|
|
|
|
|
|
|
############################################################################## |
65
|
|
|
|
|
|
|
sub isResolvable { |
66
|
0
|
|
|
0
|
0
|
0
|
return defined(gethostbyname($_[0])); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
############################################################################## |
70
|
|
|
|
|
|
|
# |
71
|
|
|
|
|
|
|
# isInNet - PAC command to see if the IP address is in this network based on |
72
|
|
|
|
|
|
|
# the mask and pattern. |
73
|
|
|
|
|
|
|
# |
74
|
|
|
|
|
|
|
############################################################################## |
75
|
|
|
|
|
|
|
sub isInNet { |
76
|
8
|
|
|
8
|
0
|
19
|
my ($ipaddr, $pattern, $maskstr) = @_; |
77
|
|
|
|
|
|
|
|
78
|
8
|
100
|
|
|
|
32
|
if (!validIP($ipaddr)) { |
79
|
5
|
|
|
|
|
122
|
$ipaddr = dnsResolve($ipaddr); |
80
|
5
|
50
|
|
|
|
27
|
if (!$ipaddr) {return ''} |
|
0
|
|
|
|
|
0
|
|
81
|
|
|
|
|
|
|
} |
82
|
8
|
50
|
33
|
|
|
163
|
if (!validIP($pattern) || !validIP($maskstr)) {return ''} |
|
0
|
|
|
|
|
0
|
|
83
|
|
|
|
|
|
|
|
84
|
8
|
|
|
|
|
278
|
my $host = inet_aton($ipaddr); |
85
|
8
|
|
|
|
|
50
|
my $pat = inet_aton($pattern); |
86
|
8
|
|
|
|
|
73
|
my $mask = inet_aton($maskstr); |
87
|
8
|
|
|
|
|
97
|
return ($host & $mask) eq ($pat & $mask); |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
############################################################################## |
91
|
|
|
|
|
|
|
# |
92
|
|
|
|
|
|
|
# dnsResolve - PAC command to get the IP from the host name. |
93
|
|
|
|
|
|
|
# |
94
|
|
|
|
|
|
|
############################################################################## |
95
|
|
|
|
|
|
|
sub dnsResolve { |
96
|
10
|
|
|
10
|
0
|
70
|
my $ipad = inet_aton($_[0]); |
97
|
10
|
50
|
|
|
|
96228
|
if ($ipad) {return inet_ntoa($ipad)} |
|
10
|
|
|
|
|
192
|
|
98
|
0
|
|
|
|
|
0
|
return; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
############################################################################## |
102
|
|
|
|
|
|
|
# |
103
|
|
|
|
|
|
|
# myIpAddress - PAC command to get your IP. |
104
|
|
|
|
|
|
|
# |
105
|
|
|
|
|
|
|
############################################################################## |
106
|
|
|
|
|
|
|
my $myIpAddress; |
107
|
|
|
|
|
|
|
BEGIN { |
108
|
3
|
|
|
3
|
|
13
|
my $hostname = hostname(); |
109
|
3
|
|
|
|
|
2232
|
my $ipad = inet_aton($hostname); |
110
|
3
|
50
|
|
|
|
6296
|
$myIpAddress = $ipad ? inet_ntoa($ipad) : '127.0.0.1'; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
sub myIpAddress { |
113
|
0
|
|
|
0
|
0
|
0
|
return $myIpAddress; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
############################################################################## |
117
|
|
|
|
|
|
|
# |
118
|
|
|
|
|
|
|
# dnsDomainLevels - PAC command to tell how many domain levels there are in |
119
|
|
|
|
|
|
|
# the host name (number of dots). |
120
|
|
|
|
|
|
|
# |
121
|
|
|
|
|
|
|
############################################################################## |
122
|
|
|
|
|
|
|
sub dnsDomainLevels { |
123
|
0
|
|
|
0
|
0
|
0
|
my @parts = split /\./, $_[0]; |
124
|
0
|
|
|
|
|
0
|
return @parts-1; |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
############################################################################## |
128
|
|
|
|
|
|
|
# |
129
|
|
|
|
|
|
|
# shExpMatch - PAC command to see if a URL/path matches the shell expression. |
130
|
|
|
|
|
|
|
# Shell expressions are like */foo/* or http://*. |
131
|
|
|
|
|
|
|
# |
132
|
|
|
|
|
|
|
############################################################################## |
133
|
|
|
|
|
|
|
sub shExpMatch { |
134
|
7
|
|
|
7
|
0
|
16
|
my ($str, $shellExp) = @_; |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
# this escapes the perl regexp characters that need it except ? and * |
137
|
|
|
|
|
|
|
# it also escapes / |
138
|
7
|
|
|
|
|
26
|
$shellExp =~ s#([\\|\x28\x29\x5B\x7B^\$+./])#\\$1#g; |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
# there are two wildcards in "shell expressions": * and ? |
141
|
7
|
|
|
|
|
226
|
$shellExp =~ s/\?/./g; |
142
|
7
|
|
|
|
|
38
|
$shellExp =~ s/\*/.*?/g; |
143
|
|
|
|
|
|
|
|
144
|
7
|
|
|
|
|
194
|
return $str =~ /^$shellExp$/; |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
############################################################################## |
148
|
|
|
|
|
|
|
# |
149
|
|
|
|
|
|
|
# weekDayRange - PAC command to see if the current weekday falls within a |
150
|
|
|
|
|
|
|
# range. |
151
|
|
|
|
|
|
|
# |
152
|
|
|
|
|
|
|
############################################################################## |
153
|
|
|
|
|
|
|
sub weekDayRange { |
154
|
0
|
|
|
0
|
0
|
0
|
my $wd1 = shift; |
155
|
0
|
|
|
|
|
0
|
my $wd2 = ""; |
156
|
0
|
0
|
|
|
|
0
|
$wd2 = shift if ($_[0] ne "GMT"); |
157
|
0
|
|
|
|
|
0
|
my $gmt = ""; |
158
|
0
|
0
|
|
|
|
0
|
$gmt = shift if ($_[0] eq "GMT"); |
159
|
|
|
|
|
|
|
|
160
|
0
|
|
|
|
|
0
|
my %wd = ( SUN=>0, MON=>1, TUE=>2, WED=>3, THU=>4, FRI=>5, SAT=>6); |
161
|
0
|
0
|
|
|
|
0
|
my $dow = (($gmt eq "GMT") ? (gmtime)[6] : (localtime)[6]); |
162
|
|
|
|
|
|
|
|
163
|
0
|
0
|
|
|
|
0
|
if ($wd2 eq "") { |
164
|
0
|
|
|
|
|
0
|
return $dow eq $wd{$wd1}; |
165
|
|
|
|
|
|
|
} else { |
166
|
0
|
|
|
|
|
0
|
my @range; |
167
|
0
|
0
|
|
|
|
0
|
if ($wd{$wd1} < $wd{$wd2}) { |
168
|
0
|
|
|
|
|
0
|
@range = ($wd{$wd1}..$wd{$wd2}); |
169
|
|
|
|
|
|
|
} else { |
170
|
0
|
|
|
|
|
0
|
@range = ($wd{$wd1}..6,0..$wd{$wd2}); |
171
|
|
|
|
|
|
|
} |
172
|
0
|
|
|
|
|
0
|
foreach my $tdow (@range) { |
173
|
0
|
|
|
|
|
0
|
return $dow eq $tdow; |
174
|
|
|
|
|
|
|
} } |
175
|
0
|
|
|
|
|
0
|
return ''; |
176
|
|
|
|
|
|
|
} |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
############################################################################## |
179
|
|
|
|
|
|
|
# |
180
|
|
|
|
|
|
|
# dateRange - PAC command to see if the current date falls within a range. |
181
|
|
|
|
|
|
|
# |
182
|
|
|
|
|
|
|
############################################################################## |
183
|
|
|
|
|
|
|
sub dateRange { |
184
|
0
|
|
|
0
|
0
|
0
|
my %mon = ( JAN=>0,FEB=>1,MAR=>2,APR=>3,MAY=>4,JUN=>5,JUL=>6,AUG=>7,SEP=>8,OCT=>9,NOV=>10,DEC=>11); |
185
|
|
|
|
|
|
|
|
186
|
0
|
|
|
|
|
0
|
my %args; |
187
|
0
|
|
|
|
|
0
|
my $dayCount = 1; |
188
|
0
|
|
|
|
|
0
|
my $monCount = 1; |
189
|
0
|
|
|
|
|
0
|
my $yearCount = 1; |
190
|
|
|
|
|
|
|
|
191
|
0
|
|
|
|
|
0
|
while ($#_ > -1) { |
192
|
0
|
0
|
|
|
|
0
|
if ($_[0] eq "GMT") { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
193
|
0
|
|
|
|
|
0
|
$args{gmt} = shift; |
194
|
|
|
|
|
|
|
} elsif (exists($mon{$_[0]})) { |
195
|
0
|
|
|
|
|
0
|
my $month = shift; |
196
|
0
|
|
|
|
|
0
|
$args{"mon$monCount"} = $mon{$month}; |
197
|
0
|
|
|
|
|
0
|
$monCount++; |
198
|
|
|
|
|
|
|
} elsif ($_[0] > 31) { |
199
|
0
|
|
|
|
|
0
|
$args{"year$yearCount"} = shift; |
200
|
0
|
|
|
|
|
0
|
$yearCount++; |
201
|
|
|
|
|
|
|
} else { |
202
|
0
|
|
|
|
|
0
|
$args{"day$dayCount"} = shift; |
203
|
0
|
|
|
|
|
0
|
$dayCount++; |
204
|
|
|
|
|
|
|
} |
205
|
|
|
|
|
|
|
} |
206
|
|
|
|
|
|
|
|
207
|
0
|
0
|
|
|
|
0
|
my $mday = (exists($args{gmt}) ? (gmtime)[3] : (localtime)[3]); |
208
|
0
|
0
|
|
|
|
0
|
my $mon = (exists($args{gmt}) ? (gmtime)[4] : (localtime)[4]); |
209
|
0
|
0
|
|
|
|
0
|
my $year = 1900+(exists($args{gmt}) ? (gmtime)[5] : (localtime)[5]); |
210
|
|
|
|
|
|
|
|
211
|
0
|
0
|
0
|
|
|
0
|
if (exists($args{day1}) && exists($args{mon1}) && exists($args{year1}) && |
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
212
|
|
|
|
|
|
|
exists($args{day2}) && exists($args{mon2}) && exists($args{year2})) { |
213
|
|
|
|
|
|
|
|
214
|
0
|
0
|
0
|
|
|
0
|
if (($args{year1} < $year) && ($args{year2} > $year)) { |
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
215
|
0
|
|
|
|
|
0
|
return 1; |
216
|
|
|
|
|
|
|
} elsif (($args{year1} == $year) && ($args{mon1} <= $mon)) { |
217
|
0
|
|
|
|
|
0
|
return 1; |
218
|
|
|
|
|
|
|
} elsif (($args{year2} == $year) && ($args{mon2} >= $mon)) { |
219
|
0
|
|
|
|
|
0
|
return 1; |
220
|
|
|
|
|
|
|
} |
221
|
0
|
|
|
|
|
0
|
return 0; |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
} elsif (exists($args{mon1}) && exists($args{year1}) && |
224
|
|
|
|
|
|
|
exists($args{mon2}) && exists($args{year2})) { |
225
|
0
|
0
|
0
|
|
|
0
|
if (($args{year1} < $year) && ($args{year2} > $year)) { |
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
226
|
0
|
|
|
|
|
0
|
return 1; |
227
|
|
|
|
|
|
|
} elsif (($args{year1} == $year) && ($args{mon1} < $mon)) { |
228
|
0
|
|
|
|
|
0
|
return 1; |
229
|
|
|
|
|
|
|
} elsif (($args{year2} == $year) && ($args{mon2} > $mon)) { |
230
|
0
|
|
|
|
|
0
|
return 1; |
231
|
|
|
|
|
|
|
} elsif (($args{year1} == $year) && ($args{mon1} == $mon) && |
232
|
|
|
|
|
|
|
($args{day1} <= $mday)) { |
233
|
0
|
|
|
|
|
0
|
return 1; |
234
|
|
|
|
|
|
|
} elsif (($args{year2} == $year) && ($args{mon2} == $mon) && |
235
|
|
|
|
|
|
|
($args{day2} >= $mday)) { |
236
|
0
|
|
|
|
|
0
|
return 1; |
237
|
|
|
|
|
|
|
} |
238
|
0
|
|
|
|
|
0
|
return 0; |
239
|
|
|
|
|
|
|
} elsif (exists($args{day1}) && exists($args{mon1}) && |
240
|
|
|
|
|
|
|
exists($args{day2}) && exists($args{mon2})) { |
241
|
0
|
0
|
0
|
|
|
0
|
if (($args{mon1} < $mon) && ($args{mon2} > $mon)) { |
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
242
|
0
|
|
|
|
|
0
|
return 1; |
243
|
|
|
|
|
|
|
} elsif (($args{mon1} == $mon) && ($args{day1} <= $mday)) { |
244
|
0
|
|
|
|
|
0
|
return 1; |
245
|
|
|
|
|
|
|
} elsif (($args{mon2} == $mon) && ($args{day2} >= $mday)) { |
246
|
0
|
|
|
|
|
0
|
return 1; |
247
|
|
|
|
|
|
|
} |
248
|
0
|
|
|
|
|
0
|
return 0; |
249
|
|
|
|
|
|
|
} elsif (exists($args{year1}) && exists($args{year2})) { |
250
|
0
|
|
|
|
|
0
|
foreach my $tyear ($args{year1}..$args{year2}) { |
251
|
0
|
0
|
|
|
|
0
|
return 1 if ($tyear == $year); |
252
|
|
|
|
|
|
|
} |
253
|
0
|
|
|
|
|
0
|
return 0; |
254
|
|
|
|
|
|
|
} elsif (exists($args{mon1}) && exists($args{mon2})) { |
255
|
0
|
|
|
|
|
0
|
foreach my $tmon ($args{mon1}..$args{mon2}) { |
256
|
0
|
0
|
|
|
|
0
|
return 1 if ($tmon == $mon); |
257
|
|
|
|
|
|
|
} |
258
|
0
|
|
|
|
|
0
|
return 0; |
259
|
|
|
|
|
|
|
} elsif (exists($args{day1}) && exists($args{day2})) { |
260
|
0
|
|
|
|
|
0
|
foreach my $tmday ($args{day1}..$args{day2}) { |
261
|
0
|
0
|
|
|
|
0
|
return 1 if ($tmday == $mday); |
262
|
|
|
|
|
|
|
} |
263
|
0
|
|
|
|
|
0
|
return 0; |
264
|
|
|
|
|
|
|
} elsif (exists($args{year1})) { |
265
|
0
|
0
|
|
|
|
0
|
return (($args{year1} == $year) ? 1 : 0); |
266
|
|
|
|
|
|
|
} elsif (exists($args{mon1})) { |
267
|
0
|
0
|
|
|
|
0
|
return (($args{mon1} == $mon) ? 1 : 0); |
268
|
|
|
|
|
|
|
} elsif (exists($args{day1})) { |
269
|
0
|
0
|
|
|
|
0
|
return (($args{day1} == $mday) ? 1 : 0); |
270
|
|
|
|
|
|
|
} |
271
|
0
|
|
|
|
|
0
|
return 0; |
272
|
|
|
|
|
|
|
} |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
############################################################################## |
275
|
|
|
|
|
|
|
# |
276
|
|
|
|
|
|
|
# timeRange - PAC command to see if the current time falls within a range. |
277
|
|
|
|
|
|
|
# |
278
|
|
|
|
|
|
|
############################################################################## |
279
|
|
|
|
|
|
|
sub timeRange { |
280
|
0
|
|
|
0
|
0
|
0
|
my %args; |
281
|
0
|
|
|
|
|
0
|
my $dayCount = 1; |
282
|
0
|
|
|
|
|
0
|
my $monCount = 1; |
283
|
0
|
|
|
|
|
0
|
my $yearCount = 1; |
284
|
|
|
|
|
|
|
|
285
|
0
|
0
|
|
|
|
0
|
$args{gmt} = pop(@_) if ($_[$#_] eq "GMT"); |
286
|
|
|
|
|
|
|
|
287
|
0
|
0
|
|
|
|
0
|
if ($#_ == 0) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
288
|
0
|
|
|
|
|
0
|
$args{hour1} = shift; |
289
|
|
|
|
|
|
|
} elsif ($#_ == 1) { |
290
|
0
|
|
|
|
|
0
|
$args{hour1} = shift; |
291
|
0
|
|
|
|
|
0
|
$args{hour2} = shift; |
292
|
|
|
|
|
|
|
} elsif ($#_ == 3) { |
293
|
0
|
|
|
|
|
0
|
$args{hour1} = shift; |
294
|
0
|
|
|
|
|
0
|
$args{min1} = shift; |
295
|
0
|
|
|
|
|
0
|
$args{hour2} = shift; |
296
|
0
|
|
|
|
|
0
|
$args{min2} = shift; |
297
|
|
|
|
|
|
|
} elsif ($#_ == 5) { |
298
|
0
|
|
|
|
|
0
|
$args{hour1} = shift; |
299
|
0
|
|
|
|
|
0
|
$args{min1} = shift; |
300
|
0
|
|
|
|
|
0
|
$args{sec1} = shift; |
301
|
0
|
|
|
|
|
0
|
$args{hour2} = shift; |
302
|
0
|
|
|
|
|
0
|
$args{min2} = shift; |
303
|
0
|
|
|
|
|
0
|
$args{sec2} = shift; |
304
|
|
|
|
|
|
|
} |
305
|
|
|
|
|
|
|
|
306
|
0
|
0
|
|
|
|
0
|
my $sec = (exists($args{gmt}) ? (gmtime)[0] : (localtime)[0]); |
307
|
0
|
0
|
|
|
|
0
|
my $min = (exists($args{gmt}) ? (gmtime)[1] : (localtime)[1]); |
308
|
0
|
0
|
|
|
|
0
|
my $hour = (exists($args{gmt}) ? (gmtime)[2] : (localtime)[2]); |
309
|
|
|
|
|
|
|
|
310
|
0
|
0
|
0
|
|
|
0
|
if (exists($args{sec1}) && exists($args{min1}) && exists($args{hour1}) && |
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
311
|
|
|
|
|
|
|
exists($args{sec2}) && exists($args{min2}) && exists($args{hour2})) { |
312
|
|
|
|
|
|
|
|
313
|
0
|
0
|
0
|
|
|
0
|
if (($args{hour1} < $hour) && ($args{hour2} > $hour)) { |
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
314
|
0
|
|
|
|
|
0
|
return 1; |
315
|
|
|
|
|
|
|
} elsif (($args{hour1} == $hour) && ($args{min1} <= $min)) { |
316
|
0
|
|
|
|
|
0
|
return 1; |
317
|
|
|
|
|
|
|
} elsif (($args{hour2} == $hour) && ($args{min2} >= $min)) { |
318
|
0
|
|
|
|
|
0
|
return 1; |
319
|
|
|
|
|
|
|
} |
320
|
0
|
|
|
|
|
0
|
return 0; |
321
|
|
|
|
|
|
|
|
322
|
|
|
|
|
|
|
} elsif (exists($args{min1}) && exists($args{hour1}) && |
323
|
|
|
|
|
|
|
exists($args{min2}) && exists($args{hour2})) { |
324
|
0
|
0
|
0
|
|
|
0
|
if (($args{hour1} < $hour) && ($args{hour2} > $hour)) { |
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
325
|
0
|
|
|
|
|
0
|
return 1; |
326
|
|
|
|
|
|
|
} elsif (($args{hour1} == $hour) && ($args{min1} < $min)) { |
327
|
0
|
|
|
|
|
0
|
return 1; |
328
|
|
|
|
|
|
|
} elsif (($args{hour2} == $hour) && ($args{min2} > $min)) { |
329
|
0
|
|
|
|
|
0
|
return 1; |
330
|
|
|
|
|
|
|
} elsif (($args{hour1} == $hour) && ($args{min1} == $min) && |
331
|
|
|
|
|
|
|
($args{sec1} <= $sec)) { |
332
|
0
|
|
|
|
|
0
|
return 1; |
333
|
|
|
|
|
|
|
} elsif (($args{hour2} == $hour) && ($args{min2} == $min) && |
334
|
|
|
|
|
|
|
($args{sec2} >= $sec)) { |
335
|
0
|
|
|
|
|
0
|
return 1; |
336
|
|
|
|
|
|
|
} |
337
|
0
|
|
|
|
|
0
|
return 0; |
338
|
|
|
|
|
|
|
} elsif (exists($args{sec1}) && exists($args{min1}) && |
339
|
|
|
|
|
|
|
exists($args{sec2}) && exists($args{min2})) { |
340
|
0
|
0
|
0
|
|
|
0
|
if (($args{min1} < $min) && ($args{min2} > $min)) { |
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
341
|
0
|
|
|
|
|
0
|
return 1; |
342
|
|
|
|
|
|
|
} elsif (($args{min1} == $min) && ($args{sec1} <= $sec)) { |
343
|
0
|
|
|
|
|
0
|
return 1; |
344
|
|
|
|
|
|
|
} elsif (($args{min2} == $min) && ($args{sec2} >= $sec)) { |
345
|
0
|
|
|
|
|
0
|
return 1; |
346
|
|
|
|
|
|
|
} |
347
|
0
|
|
|
|
|
0
|
return 0; |
348
|
|
|
|
|
|
|
} elsif (exists($args{hour1}) && exists($args{hour2})) { |
349
|
0
|
|
|
|
|
0
|
foreach my $thour ($args{hour1}..$args{hour2}) { |
350
|
0
|
0
|
|
|
|
0
|
return 1 if ($thour == $hour); |
351
|
|
|
|
|
|
|
} |
352
|
0
|
|
|
|
|
0
|
return 0; |
353
|
|
|
|
|
|
|
} elsif (exists($args{min1}) && exists($args{min2})) { |
354
|
0
|
|
|
|
|
0
|
foreach my $tmin ($args{min1}..$args{min2}) { |
355
|
0
|
0
|
|
|
|
0
|
return 1 if ($tmin == $min); |
356
|
|
|
|
|
|
|
} |
357
|
0
|
|
|
|
|
0
|
return 0; |
358
|
|
|
|
|
|
|
} elsif (exists($args{sec1}) && exists($args{sec2})) { |
359
|
0
|
|
|
|
|
0
|
foreach my $tsec ($args{sec1}..$args{sec2}) { |
360
|
0
|
0
|
|
|
|
0
|
return 1 if ($tsec == $sec); |
361
|
|
|
|
|
|
|
} |
362
|
0
|
|
|
|
|
0
|
return 0; |
363
|
|
|
|
|
|
|
} elsif (exists($args{hour1})) { |
364
|
0
|
0
|
|
|
|
0
|
return (($args{hour1} == $hour) ? 1 : 0); |
365
|
|
|
|
|
|
|
} elsif (exists($args{min1})) { |
366
|
0
|
0
|
|
|
|
0
|
return (($args{min1} == $min) ? 1 : 0); |
367
|
|
|
|
|
|
|
} elsif (exists($args{sec1})) { |
368
|
0
|
0
|
|
|
|
0
|
return (($args{sec1} == $sec) ? 1 : 0); |
369
|
|
|
|
|
|
|
} |
370
|
0
|
|
|
|
|
0
|
return 0; |
371
|
|
|
|
|
|
|
} |
372
|
|
|
|
|
|
|
|
373
|
|
|
|
|
|
|
# new (vice changed) stuff |
374
|
|
|
|
|
|
|
our @baseFunctions = qw( |
375
|
|
|
|
|
|
|
dnsResolve |
376
|
|
|
|
|
|
|
myIpAddress |
377
|
|
|
|
|
|
|
); |
378
|
|
|
|
|
|
|
|
379
|
|
|
|
|
|
|
sub validIP { |
380
|
24
|
|
33
|
24
|
0
|
1374
|
return $_[0] =~ /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/ |
381
|
|
|
|
|
|
|
&& $1 <= 255 && $2 <= 255 && $3 <= 255 && $4 <= 255; |
382
|
|
|
|
|
|
|
} |
383
|
|
|
|
|
|
|
|
384
|
|
|
|
|
|
|
#/* The following comments headed the file nsProxyAutoConfig.js used |
385
|
|
|
|
|
|
|
# by various NetScape and Mozilla browsers. Since HTTP::ProxyPAC |
386
|
|
|
|
|
|
|
# is also licensed under the GPL, this use is OK. */ |
387
|
|
|
|
|
|
|
# |
388
|
|
|
|
|
|
|
#/* ***** BEGIN LICENSE BLOCK ***** |
389
|
|
|
|
|
|
|
# * Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
390
|
|
|
|
|
|
|
# * |
391
|
|
|
|
|
|
|
# * The contents of this file are subject to the Mozilla Public License Version |
392
|
|
|
|
|
|
|
# * 1.1 (the "License"); you may not use this file except in compliance with |
393
|
|
|
|
|
|
|
# * the License. You may obtain a copy of the License at |
394
|
|
|
|
|
|
|
# * http://www.mozilla.org/MPL/ |
395
|
|
|
|
|
|
|
# * |
396
|
|
|
|
|
|
|
# * Software distributed under the License is distributed on an "AS IS" basis, |
397
|
|
|
|
|
|
|
# * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License |
398
|
|
|
|
|
|
|
# * for the specific language governing rights and limitations under the |
399
|
|
|
|
|
|
|
# * License. |
400
|
|
|
|
|
|
|
# * |
401
|
|
|
|
|
|
|
# * The Original Code is mozilla.org code. |
402
|
|
|
|
|
|
|
# * |
403
|
|
|
|
|
|
|
# * The Initial Developer of the Original Code is |
404
|
|
|
|
|
|
|
# * Netscape Communications Corporation. |
405
|
|
|
|
|
|
|
# * Portions created by the Initial Developer are Copyright (C) 1998 |
406
|
|
|
|
|
|
|
# * the Initial Developer. All Rights Reserved. |
407
|
|
|
|
|
|
|
# * |
408
|
|
|
|
|
|
|
# * Contributor(s): |
409
|
|
|
|
|
|
|
# * Akhil Arora |
410
|
|
|
|
|
|
|
# * Tomi Leppikangas |
411
|
|
|
|
|
|
|
# * Darin Fisher |
412
|
|
|
|
|
|
|
# * |
413
|
|
|
|
|
|
|
# * Alternatively, the contents of this file may be used under the terms of |
414
|
|
|
|
|
|
|
# * either the GNU General Public License Version 2 or later (the "GPL"), or |
415
|
|
|
|
|
|
|
# * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), |
416
|
|
|
|
|
|
|
# * in which case the provisions of the GPL or the LGPL are applicable instead |
417
|
|
|
|
|
|
|
# * of those above. If you wish to allow use of your version of this file only |
418
|
|
|
|
|
|
|
# * under the terms of either the GPL or the LGPL, and not to allow others to |
419
|
|
|
|
|
|
|
# * use your version of this file under the terms of the MPL, indicate your |
420
|
|
|
|
|
|
|
# * decision by deleting the provisions above and replace them with the notice |
421
|
|
|
|
|
|
|
# * and other provisions required by the GPL or the LGPL. If you do not delete |
422
|
|
|
|
|
|
|
# * the provisions above, a recipient may use your version of this file under |
423
|
|
|
|
|
|
|
# * the terms of any one of the MPL, the GPL or the LGPL. |
424
|
|
|
|
|
|
|
# * |
425
|
|
|
|
|
|
|
# * ***** END LICENSE BLOCK ***** */ |
426
|
|
|
|
|
|
|
|
427
|
|
|
|
|
|
|
sub nsProxyAutoConfig { |
428
|
5
|
|
|
5
|
0
|
107
|
<
|
429
|
|
|
|
|
|
|
/* |
430
|
|
|
|
|
|
|
Script for Proxy Auto Config in the new world order. |
431
|
|
|
|
|
|
|
- Gagan Saksena 04/24/00 |
432
|
|
|
|
|
|
|
*/ |
433
|
|
|
|
|
|
|
|
434
|
|
|
|
|
|
|
/*** code for installing the following code into a browser |
435
|
|
|
|
|
|
|
removed 2010 by cmac for HTTP::ProxyPAC version 0.2 ***/ |
436
|
|
|
|
|
|
|
|
437
|
|
|
|
|
|
|
function dnsDomainIs(host, domain) { |
438
|
|
|
|
|
|
|
return (host.length >= domain.length && |
439
|
|
|
|
|
|
|
host.substring(host.length - domain.length) == domain); |
440
|
|
|
|
|
|
|
} |
441
|
|
|
|
|
|
|
function dnsDomainLevels(host) { |
442
|
|
|
|
|
|
|
return host.split('.').length-1; |
443
|
|
|
|
|
|
|
} |
444
|
|
|
|
|
|
|
function convert_addr(ipchars) { |
445
|
|
|
|
|
|
|
var bytes = ipchars.split('.'); |
446
|
|
|
|
|
|
|
var result = ((bytes[0] & 0xff) << 24) | |
447
|
|
|
|
|
|
|
((bytes[1] & 0xff) << 16) | |
448
|
|
|
|
|
|
|
((bytes[2] & 0xff) << 8) | |
449
|
|
|
|
|
|
|
(bytes[3] & 0xff); |
450
|
|
|
|
|
|
|
return result; |
451
|
|
|
|
|
|
|
} |
452
|
|
|
|
|
|
|
function isInNet(ipaddr, pattern, maskstr) { |
453
|
|
|
|
|
|
|
var test = /^(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\$/.exec(ipaddr); |
454
|
|
|
|
|
|
|
if (test == null) { |
455
|
|
|
|
|
|
|
ipaddr = dnsResolve(ipaddr); |
456
|
|
|
|
|
|
|
if (ipaddr == null) |
457
|
|
|
|
|
|
|
return false; |
458
|
|
|
|
|
|
|
} else if (test[1] > 255 || test[2] > 255 || |
459
|
|
|
|
|
|
|
test[3] > 255 || test[4] > 255) { |
460
|
|
|
|
|
|
|
return false; // not an IP address |
461
|
|
|
|
|
|
|
} |
462
|
|
|
|
|
|
|
var host = convert_addr(ipaddr); |
463
|
|
|
|
|
|
|
var pat = convert_addr(pattern); |
464
|
|
|
|
|
|
|
var mask = convert_addr(maskstr); |
465
|
|
|
|
|
|
|
return ((host & mask) == (pat & mask)); |
466
|
|
|
|
|
|
|
|
467
|
|
|
|
|
|
|
} |
468
|
|
|
|
|
|
|
function isPlainHostName(host) { |
469
|
|
|
|
|
|
|
return (host.search('\\\\.') == -1); |
470
|
|
|
|
|
|
|
} |
471
|
|
|
|
|
|
|
function isResolvable(host) { |
472
|
|
|
|
|
|
|
var ip = dnsResolve(host); |
473
|
|
|
|
|
|
|
return (ip != null); |
474
|
|
|
|
|
|
|
} |
475
|
|
|
|
|
|
|
function localHostOrDomainIs(host, hostdom) { |
476
|
|
|
|
|
|
|
return (host == hostdom) || |
477
|
|
|
|
|
|
|
(hostdom.lastIndexOf(host + '.', 0) == 0); |
478
|
|
|
|
|
|
|
} |
479
|
|
|
|
|
|
|
function shExpMatch(url, pattern) { |
480
|
|
|
|
|
|
|
pattern = pattern.replace(/\\./g, '\\\\.'); |
481
|
|
|
|
|
|
|
pattern = pattern.replace(/\\*/g, '.*'); |
482
|
|
|
|
|
|
|
pattern = pattern.replace(/\\?/g, '.'); |
483
|
|
|
|
|
|
|
var newRe = new RegExp('^'+pattern+'\$'); |
484
|
|
|
|
|
|
|
return newRe.test(url); |
485
|
|
|
|
|
|
|
} |
486
|
|
|
|
|
|
|
|
487
|
|
|
|
|
|
|
var wdays = {SUN: 0, MON: 1, TUE: 2, WED: 3, THU: 4, FRI: 5, SAT: 6}; |
488
|
|
|
|
|
|
|
var months = {JAN: 0, FEB: 1, MAR: 2, APR: 3, MAY: 4, JUN: 5, |
489
|
|
|
|
|
|
|
JUL: 6, AUG: 7, SEP: 8, OCT: 9, NOV: 10, DEC: 11}; |
490
|
|
|
|
|
|
|
|
491
|
|
|
|
|
|
|
function weekdayRange() { |
492
|
|
|
|
|
|
|
function getDay(weekday) { |
493
|
|
|
|
|
|
|
if (weekday in wdays) { |
494
|
|
|
|
|
|
|
return wdays[weekday]; |
495
|
|
|
|
|
|
|
} |
496
|
|
|
|
|
|
|
return -1; |
497
|
|
|
|
|
|
|
} |
498
|
|
|
|
|
|
|
var date = new Date(); |
499
|
|
|
|
|
|
|
var argc = arguments.length; |
500
|
|
|
|
|
|
|
var wday; |
501
|
|
|
|
|
|
|
if (argc < 1) |
502
|
|
|
|
|
|
|
return false; |
503
|
|
|
|
|
|
|
if (arguments[argc - 1] == 'GMT') { |
504
|
|
|
|
|
|
|
argc--; |
505
|
|
|
|
|
|
|
wday = date.getUTCDay(); |
506
|
|
|
|
|
|
|
} else { |
507
|
|
|
|
|
|
|
wday = date.getDay(); |
508
|
|
|
|
|
|
|
} |
509
|
|
|
|
|
|
|
var wd1 = getDay(arguments[0]); |
510
|
|
|
|
|
|
|
var wd2 = (argc == 2) ? getDay(arguments[1]) : wd1; |
511
|
|
|
|
|
|
|
return (wd1 == -1 || wd2 == -1) ? false |
512
|
|
|
|
|
|
|
: (wd1 <= wday && wday <= wd2); |
513
|
|
|
|
|
|
|
} |
514
|
|
|
|
|
|
|
function dateRange() { |
515
|
|
|
|
|
|
|
function getMonth(name) { |
516
|
|
|
|
|
|
|
if (name in months) { |
517
|
|
|
|
|
|
|
return months[name]; |
518
|
|
|
|
|
|
|
} |
519
|
|
|
|
|
|
|
return -1; |
520
|
|
|
|
|
|
|
} |
521
|
|
|
|
|
|
|
var date = new Date(); |
522
|
|
|
|
|
|
|
var argc = arguments.length; |
523
|
|
|
|
|
|
|
if (argc < 1) { |
524
|
|
|
|
|
|
|
return false; |
525
|
|
|
|
|
|
|
} |
526
|
|
|
|
|
|
|
var isGMT = (arguments[argc - 1] == 'GMT'); |
527
|
|
|
|
|
|
|
|
528
|
|
|
|
|
|
|
if (isGMT) { |
529
|
|
|
|
|
|
|
argc--; |
530
|
|
|
|
|
|
|
} |
531
|
|
|
|
|
|
|
// function will work even without explict handling of this case |
532
|
|
|
|
|
|
|
if (argc == 1) { |
533
|
|
|
|
|
|
|
var tmp = parseInt(arguments[0]); |
534
|
|
|
|
|
|
|
if (isNaN(tmp)) { |
535
|
|
|
|
|
|
|
return ((isGMT ? date.getUTCMonth() |
536
|
|
|
|
|
|
|
: date.getMonth()) == getMonth(arguments[0])); |
537
|
|
|
|
|
|
|
} else if (tmp < 32) { |
538
|
|
|
|
|
|
|
return ((isGMT ? date.getUTCDate() |
539
|
|
|
|
|
|
|
: date.getDate()) == tmp); |
540
|
|
|
|
|
|
|
} else { |
541
|
|
|
|
|
|
|
return ((isGMT ? date.getUTCFullYear() |
542
|
|
|
|
|
|
|
: date.getFullYear()) == tmp); |
543
|
|
|
|
|
|
|
} |
544
|
|
|
|
|
|
|
} |
545
|
|
|
|
|
|
|
var year = date.getFullYear(); |
546
|
|
|
|
|
|
|
var date1, date2; |
547
|
|
|
|
|
|
|
date1 = new Date(year, 0, 1, 0, 0, 0); |
548
|
|
|
|
|
|
|
date2 = new Date(year, 11, 31, 23, 59, 59); |
549
|
|
|
|
|
|
|
var adjustMonth = false; |
550
|
|
|
|
|
|
|
for (var i = 0; i < (argc >> 1); i++) { |
551
|
|
|
|
|
|
|
var tmp = parseInt(arguments[i]); |
552
|
|
|
|
|
|
|
if (isNaN(tmp)) { |
553
|
|
|
|
|
|
|
var mon = getMonth(arguments[i]); |
554
|
|
|
|
|
|
|
date1.setMonth(mon); |
555
|
|
|
|
|
|
|
} else if (tmp < 32) { |
556
|
|
|
|
|
|
|
adjustMonth = (argc <= 2); |
557
|
|
|
|
|
|
|
date1.setDate(tmp); |
558
|
|
|
|
|
|
|
} else { |
559
|
|
|
|
|
|
|
date1.setFullYear(tmp); |
560
|
|
|
|
|
|
|
} |
561
|
|
|
|
|
|
|
} |
562
|
|
|
|
|
|
|
for (var i = (argc >> 1); i < argc; i++) { |
563
|
|
|
|
|
|
|
var tmp = parseInt(arguments[i]); |
564
|
|
|
|
|
|
|
if (isNaN(tmp)) { |
565
|
|
|
|
|
|
|
var mon = getMonth(arguments[i]); |
566
|
|
|
|
|
|
|
date2.setMonth(mon); |
567
|
|
|
|
|
|
|
} else if (tmp < 32) { |
568
|
|
|
|
|
|
|
date2.setDate(tmp); |
569
|
|
|
|
|
|
|
} else { |
570
|
|
|
|
|
|
|
date2.setFullYear(tmp); |
571
|
|
|
|
|
|
|
} |
572
|
|
|
|
|
|
|
} |
573
|
|
|
|
|
|
|
if (adjustMonth) { |
574
|
|
|
|
|
|
|
date1.setMonth(date.getMonth()); |
575
|
|
|
|
|
|
|
date2.setMonth(date.getMonth()); |
576
|
|
|
|
|
|
|
} |
577
|
|
|
|
|
|
|
if (isGMT) { |
578
|
|
|
|
|
|
|
var tmp = date; |
579
|
|
|
|
|
|
|
tmp.setFullYear(date.getUTCFullYear()); |
580
|
|
|
|
|
|
|
tmp.setMonth(date.getUTCMonth()); |
581
|
|
|
|
|
|
|
tmp.setDate(date.getUTCDate()); |
582
|
|
|
|
|
|
|
tmp.setHours(date.getUTCHours()); |
583
|
|
|
|
|
|
|
tmp.setMinutes(date.getUTCMinutes()); |
584
|
|
|
|
|
|
|
tmp.setSeconds(date.getUTCSeconds()); |
585
|
|
|
|
|
|
|
date = tmp; |
586
|
|
|
|
|
|
|
} |
587
|
|
|
|
|
|
|
return ((date1 <= date) && (date <= date2)); |
588
|
|
|
|
|
|
|
} |
589
|
|
|
|
|
|
|
function timeRange() { |
590
|
|
|
|
|
|
|
var argc = arguments.length; |
591
|
|
|
|
|
|
|
var date = new Date(); |
592
|
|
|
|
|
|
|
var isGMT= false; |
593
|
|
|
|
|
|
|
|
594
|
|
|
|
|
|
|
if (argc < 1) { |
595
|
|
|
|
|
|
|
return false; |
596
|
|
|
|
|
|
|
} |
597
|
|
|
|
|
|
|
if (arguments[argc - 1] == 'GMT') { |
598
|
|
|
|
|
|
|
isGMT = true; |
599
|
|
|
|
|
|
|
argc--; |
600
|
|
|
|
|
|
|
} |
601
|
|
|
|
|
|
|
|
602
|
|
|
|
|
|
|
var hour = isGMT ? date.getUTCHours() : date.getHours(); |
603
|
|
|
|
|
|
|
var date1, date2; |
604
|
|
|
|
|
|
|
date1 = new Date(); |
605
|
|
|
|
|
|
|
date2 = new Date(); |
606
|
|
|
|
|
|
|
|
607
|
|
|
|
|
|
|
if (argc == 1) { |
608
|
|
|
|
|
|
|
return (hour == arguments[0]); |
609
|
|
|
|
|
|
|
} else if (argc == 2) { |
610
|
|
|
|
|
|
|
return ((arguments[0] <= hour) && (hour <= arguments[1])); |
611
|
|
|
|
|
|
|
} else { |
612
|
|
|
|
|
|
|
switch (argc) { |
613
|
|
|
|
|
|
|
case 6: |
614
|
|
|
|
|
|
|
date1.setSeconds(arguments[2]); |
615
|
|
|
|
|
|
|
date2.setSeconds(arguments[5]); |
616
|
|
|
|
|
|
|
case 4: |
617
|
|
|
|
|
|
|
var middle = argc >> 1; |
618
|
|
|
|
|
|
|
date1.setHours(arguments[0]); |
619
|
|
|
|
|
|
|
date1.setMinutes(arguments[1]); |
620
|
|
|
|
|
|
|
date2.setHours(arguments[middle]); |
621
|
|
|
|
|
|
|
date2.setMinutes(arguments[middle + 1]); |
622
|
|
|
|
|
|
|
if (middle == 2) { |
623
|
|
|
|
|
|
|
date2.setSeconds(59); |
624
|
|
|
|
|
|
|
} |
625
|
|
|
|
|
|
|
break; |
626
|
|
|
|
|
|
|
default: |
627
|
|
|
|
|
|
|
throw 'timeRange: bad number of arguments' |
628
|
|
|
|
|
|
|
} |
629
|
|
|
|
|
|
|
} |
630
|
|
|
|
|
|
|
if (isGMT) { |
631
|
|
|
|
|
|
|
date.setFullYear(date.getUTCFullYear()); |
632
|
|
|
|
|
|
|
date.setMonth(date.getUTCMonth()); |
633
|
|
|
|
|
|
|
date.setDate(date.getUTCDate()); |
634
|
|
|
|
|
|
|
date.setHours(date.getUTCHours()); |
635
|
|
|
|
|
|
|
date.setMinutes(date.getUTCMinutes()); |
636
|
|
|
|
|
|
|
date.setSeconds(date.getUTCSeconds()); |
637
|
|
|
|
|
|
|
} |
638
|
|
|
|
|
|
|
return ((date1 <= date) && (date <= date2)); |
639
|
|
|
|
|
|
|
} |
640
|
|
|
|
|
|
|
ZZZZ |
641
|
|
|
|
|
|
|
} |
642
|
|
|
|
|
|
|
1; |