Issues (1210)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

class/iCal_parser.php (17 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/*
3
 * You may not change or alter any portion of this comment or credits
4
 * of supporting developers from this source code or any supporting source code
5
 * which is considered copyrighted (c) material of the original comment or credit authors.
6
 *
7
 * This program is distributed in the hope that it will be useful,
8
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
 */
11
12
/**
13
 * @copyright   {@link http://xoops.org/ XOOPS Project}
14
 * @license     {@link http://www.fsf.org/copyleft/gpl.html GNU public license}
15
 * @package
16
 * @since
17
 * @author       XOOPS Development Team,
18
 * @author       GIJ=CHECKMATE (PEAK Corp. http://www.peak.ne.jp/)
19
 * @author       Antiques Promotion (http://www.antiquespromotion.ca)
20
 */
21
22
// ORIGINAL: PHP iCalendar  (http://phapcalendar.sourceforge.net/)
23
// PROJECT ADMINS
24
// --------------
25
// Chad Little    <[email protected]>
26
// Jared Wangen   <[email protected]>
27
//
28
// DEVELOPERS
29
// ----------
30
// Patrick Berry  <[email protected]>
31
// Bill Fenner    <[email protected]>
32
// David Reindl   <[email protected]>
33
//
34
// CODE CONTRIBUTORS
35
// -----------------
36
// Greg Westin    <[email protected]>
37
// Blaine Cook    <[email protected]>
38
39
// mb_internal_encoding¤Î¥¨¥ß¥å¥ì¡¼¥È (¾ï¤ËASCII¤òÊÖ¤¹)
40
if (!function_exists('mb_internal_encoding')) {
41
    /**
42
     * @return string
43
     */
44
    function mb_internal_encoding()
45
    {
46
        return 'ASCII';
47
    }
48
}
49
50
/**
51
 * Class iCal_parser
52
 */
53
class iCal_parser
54
{
55
    public $week_start_day = 'Sunday';
56
    public $timezone       = '+0900';
57
    public $events         = array();
58
    public $language       = 'japanese';
59
60
    // From timezones.php
61
    public $tz_array = array(
62
        'GMT'                          => array('+0000', '+0000'),
63
        'Africa/Addis_Ababa'           => array('+0300', '+0300'),
64
        'Africa/Algiers'               => array('+0100', '+0100'),
65
        'Africa/Asmera'                => array('+0300', '+0300'),
66
        'Africa/Bangui'                => array('+0100', '+0100'),
67
        'Africa/Blantyre'              => array('+0200', '+0200'),
68
        'Africa/Brazzaville'           => array('+0100', '+0100'),
69
        'Africa/Bujumbura'             => array('+0200', '+0200'),
70
        'Africa/Cairo'                 => array('+0200', '+0300'),
71
        'Africa/Ceuta'                 => array('+0100', '+0200'),
72
        'Africa/Dar_es_Salaam'         => array('+0300', '+0300'),
73
        'Africa/Djibouti'              => array('+0300', '+0300'),
74
        'Africa/Douala'                => array('+0100', '+0100'),
75
        'Africa/Gaborone'              => array('+0200', '+0200'),
76
        'Africa/Harare'                => array('+0200', '+0200'),
77
        'Africa/Johannesburg'          => array('+0200', '+0200'),
78
        'Africa/Kampala'               => array('+0300', '+0300'),
79
        'Africa/Khartoum'              => array('+0300', '+0300'),
80
        'Africa/Kigali'                => array('+0200', '+0200'),
81
        'Africa/Kinshasa'              => array('+0100', '+0100'),
82
        'Africa/Lagos'                 => array('+0100', '+0100'),
83
        'Africa/Libreville'            => array('+0100', '+0100'),
84
        'Africa/Luanda'                => array('+0100', '+0100'),
85
        'Africa/Lubumbashi'            => array('+0200', '+0200'),
86
        'Africa/Lusaka'                => array('+0200', '+0200'),
87
        'Africa/Malabo'                => array('+0100', '+0100'),
88
        'Africa/Maputo'                => array('+0200', '+0200'),
89
        'Africa/Maseru'                => array('+0200', '+0200'),
90
        'Africa/Mbabane'               => array('+0200', '+0200'),
91
        'Africa/Mogadishu'             => array('+0300', '+0300'),
92
        'Africa/Nairobi'               => array('+0300', '+0300'),
93
        'Africa/Ndjamena'              => array('+0100', '+0100'),
94
        'Africa/Niamey'                => array('+0100', '+0100'),
95
        'Africa/Porto-Novo'            => array('+0100', '+0100'),
96
        'Africa/Tripoli'               => array('+0200', '+0200'),
97
        'Africa/Tunis'                 => array('+0100', '+0100'),
98
        'Africa/Windhoek'              => array('+0200', '+0100'),
99
        'America/Adak'                 => array('-1000', '-0900'),
100
        'America/Anchorage'            => array('-0900', '-0800'),
101
        'America/Anguilla'             => array('-0400', '-0400'),
102
        'America/Antigua'              => array('-0400', '-0400'),
103
        'America/Araguaina'            => array('-0200', '-0300'),
104
        'America/Aruba'                => array('-0400', '-0400'),
105
        'America/Asuncion'             => array('-0300', '-0400'),
106
        'America/Atka'                 => array('-1000', '-0900'),
107
        'America/Barbados'             => array('-0400', '-0400'),
108
        'America/Belem'                => array('-0300', '-0300'),
109
        'America/Belize'               => array('-0600', '-0600'),
110
        'America/Boa_Vista'            => array('-0400', '-0400'),
111
        'America/Bogota'               => array('-0500', '-0500'),
112
        'America/Boise'                => array('-0700', '-0600'),
113
        'America/Buenos_Aires'         => array('-0300', '-0300'),
114
        'America/Cambridge_Bay'        => array('-0700', '-0600'),
115
        'America/Cancun'               => array('-0600', '-0500'),
116
        'America/Caracas'              => array('-0400', '-0400'),
117
        'America/Catamarca'            => array('-0300', '-0300'),
118
        'America/Cayenne'              => array('-0300', '-0300'),
119
        'America/Cayman'               => array('-0500', '-0500'),
120
        'America/Chicago'              => array('-0600', '-0500'),
121
        'America/Chihuahua'            => array('-0700', '-0600'),
122
        'America/Cordoba'              => array('-0300', '-0300'),
123
        'America/Costa_Rica'           => array('-0600', '-0600'),
124
        'America/Cuiaba'               => array('-0300', '-0400'),
125
        'America/Curacao'              => array('-0400', '-0400'),
126
        'America/Dawson'               => array('-0800', '-0700'),
127
        'America/Dawson_Creek'         => array('-0700', '-0700'),
128
        'America/Denver'               => array('-0700', '-0600'),
129
        'America/Detroit'              => array('-0500', '-0400'),
130
        'America/Dominica'             => array('-0400', '-0400'),
131
        'America/Edmonton'             => array('-0700', '-0600'),
132
        'America/Eirunepe'             => array('-0500', '-0500'),
133
        'America/El_Salvador'          => array('-0600', '-0600'),
134
        'America/Ensenada'             => array('-0800', '-0700'),
135
        'America/Fort_Wayne'           => array('-0500', '-0500'),
136
        'America/Fortaleza'            => array('-0300', '-0300'),
137
        'America/Glace_Bay'            => array('-0400', '-0300'),
138
        'America/Godthab'              => array('-0300', '-0200'),
139
        'America/Goose_Bay'            => array('-0400', '-0300'),
140
        'America/Grand_Turk'           => array('-0500', '-0400'),
141
        'America/Grenada'              => array('-0400', '-0400'),
142
        'America/Guadeloupe'           => array('-0400', '-0400'),
143
        'America/Guatemala'            => array('-0600', '-0600'),
144
        'America/Guayaquil'            => array('-0500', '-0500'),
145
        'America/Guyana'               => array('-0400', '-0400'),
146
        'America/Halifax'              => array('-0400', '-0300'),
147
        'America/Havana'               => array('-0500', '-0400'),
148
        'America/Hermosillo'           => array('-0700', '-0700'),
149
        'America/Indiana/Indianapolis' => array('-0500', '-0500'),
150
        'America/Indiana/Knox'         => array('-0500', '-0500'),
151
        'America/Indiana/Marengo'      => array('-0500', '-0500'),
152
        'America/Indiana/Vevay'        => array('-0500', '-0500'),
153
        'America/Indianapolis'         => array('-0500', '-0500'),
154
        'America/Inuvik'               => array('-0700', '-0600'),
155
        'America/Iqaluit'              => array('-0500', '-0400'),
156
        'America/Jamaica'              => array('-0500', '-0500'),
157
        'America/Jujuy'                => array('-0300', '-0300'),
158
        'America/Juneau'               => array('-0900', '-0800'),
159
        'America/Kentucky/Louisville'  => array('-0500', '-0400'),
160
        'America/Kentucky/Monticello'  => array('-0500', '-0400'),
161
        'America/Knox_IN'              => array('-0500', '-0500'),
162
        'America/La_Paz'               => array('-0400', '-0400'),
163
        'America/Lima'                 => array('-0500', '-0500'),
164
        'America/Los_Angeles'          => array('-0800', '-0700'),
165
        'America/Louisville'           => array('-0500', '-0400'),
166
        'America/Maceio'               => array('-0300', '-0300'),
167
        'America/Managua'              => array('-0600', '-0600'),
168
        'America/Manaus'               => array('-0400', '-0400'),
169
        'America/Martinique'           => array('-0400', '-0400'),
170
        'America/Mazatlan'             => array('-0700', '-0600'),
171
        'America/Mendoza'              => array('-0300', '-0300'),
172
        'America/Menominee'            => array('-0600', '-0500'),
173
        'America/Merida'               => array('-0600', '-0500'),
174
        'America/Mexico_City'          => array('-0600', '-0500'),
175
        'America/Miquelon'             => array('-0300', '-0200'),
176
        'America/Monterrey'            => array('-0600', '-0500'),
177
        'America/Montevideo'           => array('-0300', '-0300'),
178
        'America/Montreal'             => array('-0500', '-0400'),
179
        'America/Montserrat'           => array('-0400', '-0400'),
180
        'America/Nassau'               => array('-0500', '-0400'),
181
        'America/New_York'             => array('-0500', '-0400'),
182
        'America/Nipigon'              => array('-0500', '-0400'),
183
        'America/Nome'                 => array('-0900', '-0800'),
184
        'America/Noronha'              => array('-0200', '-0200'),
185
        'America/Panama'               => array('-0500', '-0500'),
186
        'America/Pangnirtung'          => array('-0500', '-0400'),
187
        'America/Paramaribo'           => array('-0300', '-0300'),
188
        'America/Phoenix'              => array('-0700', '-0700'),
189
        'America/Port-au-Prince'       => array('-0500', '-0500'),
190
        'America/Port_of_Spain'        => array('-0400', '-0400'),
191
        'America/Porto_Acre'           => array('-0500', '-0500'),
192
        'America/Porto_Velho'          => array('-0400', '-0400'),
193
        'America/Puerto_Rico'          => array('-0400', '-0400'),
194
        'America/Rainy_River'          => array('-0600', '-0500'),
195
        'America/Rankin_Inlet'         => array('-0600', '-0500'),
196
        'America/Recife'               => array('-0300', '-0300'),
197
        'America/Regina'               => array('-0600', '-0600'),
198
        'America/Rio_Branco'           => array('-0500', '-0500'),
199
        'America/Rosario'              => array('-0300', '-0300'),
200
        'America/Santiago'             => array('-0300', '-0400'),
201
        'America/Santo_Domingo'        => array('-0400', '-0400'),
202
        'America/Sao_Paulo'            => array('-0200', '-0300'),
203
        'America/Scoresbysund'         => array('-0100', '+0000'),
204
        'America/Shiprock'             => array('-0700', '-0600'),
205
        'America/St_Johns'             => array('-031800', '-021800'),
206
        'America/St_Kitts'             => array('-0400', '-0400'),
207
        'America/St_Lucia'             => array('-0400', '-0400'),
208
        'America/St_Thomas'            => array('-0400', '-0400'),
209
        'America/St_Vincent'           => array('-0400', '-0400'),
210
        'America/Swift_Current'        => array('-0600', '-0600'),
211
        'America/Tegucigalpa'          => array('-0600', '-0600'),
212
        'America/Thule'                => array('-0400', '-0300'),
213
        'America/Thunder_Bay'          => array('-0500', '-0400'),
214
        'America/Tijuana'              => array('-0800', '-0700'),
215
        'America/Tortola'              => array('-0400', '-0400'),
216
        'America/Vancouver'            => array('-0800', '-0700'),
217
        'America/Virgin'               => array('-0400', '-0400'),
218
        'America/Whitehorse'           => array('-0800', '-0700'),
219
        'America/Winnipeg'             => array('-0600', '-0500'),
220
        'America/Yakutat'              => array('-0900', '-0800'),
221
        'America/Yellowknife'          => array('-0700', '-0600'),
222
        'Antarctica/Casey'             => array('+0800', '+0800'),
223
        'Antarctica/Davis'             => array('+0700', '+0700'),
224
        'Antarctica/DumontDUrville'    => array('+1000', '+1000'),
225
        'Antarctica/Mawson'            => array('+0600', '+0600'),
226
        'Antarctica/McMurdo'           => array('+1300', '+1200'),
227
        'Antarctica/Palmer'            => array('-0300', '-0400'),
228
        'Antarctica/South_Pole'        => array('+1300', '+1200'),
229
        'Antarctica/Syowa'             => array('+0300', '+0300'),
230
        'Antarctica/Vostok'            => array('+0600', '+0600'),
231
        'Arctic/Longyearbyen'          => array('+0100', '+0200'),
232
        'Asia/Aden'                    => array('+0300', '+0300'),
233
        'Asia/Almaty'                  => array('+0600', '+0700'),
234
        'Asia/Amman'                   => array('+0200', '+0300'),
235
        'Asia/Anadyr'                  => array('+1200', '+1300'),
236
        'Asia/Aqtau'                   => array('+0400', '+0500'),
237
        'Asia/Aqtobe'                  => array('+0500', '+0600'),
238
        'Asia/Ashgabat'                => array('+0500', '+0500'),
239
        'Asia/Ashkhabad'               => array('+0500', '+0500'),
240
        'Asia/Baghdad'                 => array('+0300', '+0400'),
241
        'Asia/Bahrain'                 => array('+0300', '+0300'),
242
        'Asia/Baku'                    => array('+0400', '+0500'),
243
        'Asia/Bangkok'                 => array('+0700', '+0700'),
244
        'Asia/Beirut'                  => array('+0200', '+0300'),
245
        'Asia/Bishkek'                 => array('+0500', '+0600'),
246
        'Asia/Brunei'                  => array('+0800', '+0800'),
247
        'Asia/Calcutta'                => array('+051800', '+051800'),
248
        'Asia/Chungking'               => array('+0800', '+0800'),
249
        'Asia/Colombo'                 => array('+0600', '+0600'),
250
        'Asia/Dacca'                   => array('+0600', '+0600'),
251
        'Asia/Damascus'                => array('+0200', '+0300'),
252
        'Asia/Dhaka'                   => array('+0600', '+0600'),
253
        'Asia/Dili'                    => array('+0900', '+0900'),
254
        'Asia/Dubai'                   => array('+0400', '+0400'),
255
        'Asia/Dushanbe'                => array('+0500', '+0500'),
256
        'Asia/Gaza'                    => array('+0200', '+0300'),
257
        'Asia/Harbin'                  => array('+0800', '+0800'),
258
        'Asia/Hong_Kong'               => array('+0800', '+0800'),
259
        'Asia/Hovd'                    => array('+0700', '+0700'),
260
        'Asia/Irkutsk'                 => array('+0800', '+0900'),
261
        'Asia/Istanbul'                => array('+0200', '+0300'),
262
        'Asia/Jakarta'                 => array('+0700', '+0700'),
263
        'Asia/Jayapura'                => array('+0900', '+0900'),
264
        'Asia/Jerusalem'               => array('+0200', '+0300'),
265
        'Asia/Kabul'                   => array('+041800', '+041800'),
266
        'Asia/Kamchatka'               => array('+1200', '+1300'),
267
        'Asia/Karachi'                 => array('+0500', '+0500'),
268
        'Asia/Kashgar'                 => array('+0800', '+0800'),
269
        'Asia/Katmandu'                => array('+052700', '+052700'),
270
        'Asia/Krasnoyarsk'             => array('+0700', '+0800'),
271
        'Asia/Kuala_Lumpur'            => array('+0800', '+0800'),
272
        'Asia/Kuching'                 => array('+0800', '+0800'),
273
        'Asia/Kuwait'                  => array('+0300', '+0300'),
274
        'Asia/Macao'                   => array('+0800', '+0800'),
275
        'Asia/Magadan'                 => array('+1100', '+1200'),
276
        'Asia/Manila'                  => array('+0800', '+0800'),
277
        'Asia/Muscat'                  => array('+0400', '+0400'),
278
        'Asia/Nicosia'                 => array('+0200', '+0300'),
279
        'Asia/Novosibirsk'             => array('+0600', '+0700'),
280
        'Asia/Omsk'                    => array('+0600', '+0700'),
281
        'Asia/Phnom_Penh'              => array('+0700', '+0700'),
282
        'Asia/Pyongyang'               => array('+0900', '+0900'),
283
        'Asia/Qatar'                   => array('+0300', '+0300'),
284
        'Asia/Rangoon'                 => array('+061800', '+061800'),
285
        'Asia/Riyadh'                  => array('+0300', '+0300'),
286
        'Asia/Riyadh87'                => array('+03424', '+03424'),
287
        'Asia/Riyadh88'                => array('+03424', '+03424'),
288
        'Asia/Riyadh89'                => array('+03424', '+03424'),
289
        'Asia/Saigon'                  => array('+0700', '+0700'),
290
        'Asia/Samarkand'               => array('+0500', '+0500'),
291
        'Asia/Seoul'                   => array('+0900', '+0900'),
292
        'Asia/Shanghai'                => array('+0800', '+0800'),
293
        'Asia/Singapore'               => array('+0800', '+0800'),
294
        'Asia/Taipei'                  => array('+0800', '+0800'),
295
        'Asia/Tashkent'                => array('+0500', '+0500'),
296
        'Asia/Tbilisi'                 => array('+0400', '+0500'),
297
        'Asia/Tehran'                  => array('+031800', '+041800'),
298
        'Asia/Tel_Aviv'                => array('+0200', '+0300'),
299
        'Asia/Thimbu'                  => array('+0600', '+0600'),
300
        'Asia/Thimphu'                 => array('+0600', '+0600'),
301
        'Asia/Tokyo'                   => array('+0900', '+0900'),
302
        'Asia/Ujung_Pandang'           => array('+0800', '+0800'),
303
        'Asia/Ulaanbaatar'             => array('+0800', '+0800'),
304
        'Asia/Ulan_Bator'              => array('+0800', '+0800'),
305
        'Asia/Urumqi'                  => array('+0800', '+0800'),
306
        'Asia/Vientiane'               => array('+0700', '+0700'),
307
        'Asia/Vladivostok'             => array('+1000', '+1100'),
308
        'Asia/Yakutsk'                 => array('+0900', '+1000'),
309
        'Asia/Yekaterinburg'           => array('+0500', '+0600'),
310
        'Asia/Yerevan'                 => array('+0400', '+0500'),
311
        'Atlantic/Azores'              => array('-0100', '+0000'),
312
        'Atlantic/Bermuda'             => array('-0400', '-0300'),
313
        'Atlantic/Canary'              => array('+0000', '+0100'),
314
        'Atlantic/Cape_Verde'          => array('-0100', '-0100'),
315
        'Atlantic/Faeroe'              => array('+0000', '+0100'),
316
        'Atlantic/Jan_Mayen'           => array('-0100', '-0100'),
317
        'Atlantic/Madeira'             => array('+0000', '+0100'),
318
        'Atlantic/South_Georgia'       => array('-0200', '-0200'),
319
        'Atlantic/Stanley'             => array('-0300', '-0400'),
320
        'Australia/ACT'                => array('+1100', '+1000'),
321
        'Australia/Adelaide'           => array('+101800', '+091800'),
322
        'Australia/Brisbane'           => array('+1000', '+1000'),
323
        'Australia/Broken_Hill'        => array('+101800', '+091800'),
324
        'Australia/Canberra'           => array('+1100', '+1000'),
325
        'Australia/Darwin'             => array('+091800', '+091800'),
326
        'Australia/Hobart'             => array('+1100', '+1000'),
327
        'Australia/LHI'                => array('+1100', '+101800'),
328
        'Australia/Lindeman'           => array('+1000', '+1000'),
329
        'Australia/Lord_Howe'          => array('+1100', '+101800'),
330
        'Australia/Melbourne'          => array('+1100', '+1000'),
331
        'Australia/NSW'                => array('+1100', '+1000'),
332
        'Australia/North'              => array('+091800', '+091800'),
333
        'Australia/Perth'              => array('+0800', '+0800'),
334
        'Australia/Queensland'         => array('+1000', '+1000'),
335
        'Australia/South'              => array('+101800', '+091800'),
336
        'Australia/Sydney'             => array('+1100', '+1000'),
337
        'Australia/Tasmania'           => array('+1100', '+1000'),
338
        'Australia/Victoria'           => array('+1100', '+1000'),
339
        'Australia/West'               => array('+0800', '+0800'),
340
        'Australia/Yancowinna'         => array('+101800', '+091800'),
341
        'Brazil/Acre'                  => array('-0500', '-0500'),
342
        'Brazil/DeNoronha'             => array('-0200', '-0200'),
343
        'Brazil/East'                  => array('-0200', '-0300'),
344
        'Brazil/West'                  => array('-0400', '-0400'),
345
        'CET'                          => array('+0100', '+0200'),
346
        'CST6CDT'                      => array('-0600', '-0500'),
347
        'Canada/Atlantic'              => array('-0400', '-0300'),
348
        'Canada/Central'               => array('-0600', '-0500'),
349
        'Canada/East-Saskatchewan'     => array('-0600', '-0600'),
350
        'Canada/Eastern'               => array('-0500', '-0400'),
351
        'Canada/Mountain'              => array('-0700', '-0600'),
352
        'Canada/Newfoundland'          => array('-031800', '-021800'),
353
        'Canada/Pacific'               => array('-0800', '-0700'),
354
        'Canada/Saskatchewan'          => array('-0600', '-0600'),
355
        'Canada/Yukon'                 => array('-0800', '-0700'),
356
        'Chile/Continental'            => array('-0300', '-0400'),
357
        'Chile/EasterIsland'           => array('-0500', '-0600'),
358
        'Cuba'                         => array('-0500', '-0400'),
359
        'EET'                          => array('+0200', '+0300'),
360
        'EST'                          => array('-0500', '-0500'),
361
        'EST5EDT'                      => array('-0500', '-0400'),
362
        'Egypt'                        => array('+0200', '+0300'),
363
        'Eire'                         => array('+0000', '+0100'),
364
        'Etc/GMT+1'                    => array('-0100', '-0100'),
365
        'Etc/GMT+10'                   => array('-1000', '-1000'),
366
        'Etc/GMT+11'                   => array('-1100', '-1100'),
367
        'Etc/GMT+12'                   => array('-1200', '-1200'),
368
        'Etc/GMT+2'                    => array('-0200', '-0200'),
369
        'Etc/GMT+3'                    => array('-0300', '-0300'),
370
        'Etc/GMT+4'                    => array('-0400', '-0400'),
371
        'Etc/GMT+5'                    => array('-0500', '-0500'),
372
        'Etc/GMT+6'                    => array('-0600', '-0600'),
373
        'Etc/GMT+7'                    => array('-0700', '-0700'),
374
        'Etc/GMT+8'                    => array('-0800', '-0800'),
375
        'Etc/GMT+9'                    => array('-0900', '-0900'),
376
        'Etc/GMT-1'                    => array('+0100', '+0100'),
377
        'Etc/GMT-10'                   => array('+1000', '+1000'),
378
        'Etc/GMT-11'                   => array('+1100', '+1100'),
379
        'Etc/GMT-12'                   => array('+1200', '+1200'),
380
        'Etc/GMT-13'                   => array('+1300', '+1300'),
381
        'Etc/GMT-14'                   => array('+1400', '+1400'),
382
        'Etc/GMT-2'                    => array('+0200', '+0200'),
383
        'Etc/GMT-3'                    => array('+0300', '+0300'),
384
        'Etc/GMT-4'                    => array('+0400', '+0400'),
385
        'Etc/GMT-5'                    => array('+0500', '+0500'),
386
        'Etc/GMT-6'                    => array('+0600', '+0600'),
387
        'Etc/GMT-7'                    => array('+0700', '+0700'),
388
        'Etc/GMT-8'                    => array('+0800', '+0800'),
389
        'Etc/GMT-9'                    => array('+0900', '+0900'),
390
        'Europe/Amsterdam'             => array('+0100', '+0200'),
391
        'Europe/Andorra'               => array('+0100', '+0200'),
392
        'Europe/Athens'                => array('+0200', '+0300'),
393
        'Europe/Belfast'               => array('+0000', '+0100'),
394
        'Europe/Belgrade'              => array('+0100', '+0200'),
395
        'Europe/Berlin'                => array('+0100', '+0200'),
396
        'Europe/Bratislava'            => array('+0100', '+0200'),
397
        'Europe/Brussels'              => array('+0100', '+0200'),
398
        'Europe/Bucharest'             => array('+0200', '+0300'),
399
        'Europe/Budapest'              => array('+0100', '+0200'),
400
        'Europe/Chisinau'              => array('+0200', '+0300'),
401
        'Europe/Copenhagen'            => array('+0100', '+0200'),
402
        'Europe/Dublin'                => array('+0000', '+0100'),
403
        'Europe/Gibraltar'             => array('+0100', '+0200'),
404
        'Europe/Helsinki'              => array('+0200', '+0300'),
405
        'Europe/Istanbul'              => array('+0200', '+0300'),
406
        'Europe/Kaliningrad'           => array('+0200', '+0300'),
407
        'Europe/Kiev'                  => array('+0200', '+0300'),
408
        'Europe/Lisbon'                => array('+0000', '+0100'),
409
        'Europe/Ljubljana'             => array('+0100', '+0200'),
410
        'Europe/London'                => array('+0000', '+0100'),
411
        'Europe/Luxembourg'            => array('+0100', '+0200'),
412
        'Europe/Madrid'                => array('+0100', '+0200'),
413
        'Europe/Malta'                 => array('+0100', '+0200'),
414
        'Europe/Minsk'                 => array('+0200', '+0300'),
415
        'Europe/Monaco'                => array('+0100', '+0200'),
416
        'Europe/Moscow'                => array('+0300', '+0400'),
417
        'Europe/Nicosia'               => array('+0200', '+0300'),
418
        'Europe/Oslo'                  => array('+0100', '+0200'),
419
        'Europe/Paris'                 => array('+0100', '+0200'),
420
        'Europe/Prague'                => array('+0100', '+0200'),
421
        'Europe/Riga'                  => array('+0200', '+0300'),
422
        'Europe/Rome'                  => array('+0100', '+0200'),
423
        'Europe/Samara'                => array('+0400', '+0500'),
424
        'Europe/San_Marino'            => array('+0100', '+0200'),
425
        'Europe/Sarajevo'              => array('+0100', '+0200'),
426
        'Europe/Simferopol'            => array('+0200', '+0300'),
427
        'Europe/Skopje'                => array('+0100', '+0200'),
428
        'Europe/Sofia'                 => array('+0200', '+0300'),
429
        'Europe/Stockholm'             => array('+0100', '+0200'),
430
        'Europe/Tallinn'               => array('+0200', '+0200'),
431
        'Europe/Tirane'                => array('+0100', '+0200'),
432
        'Europe/Tiraspol'              => array('+0200', '+0300'),
433
        'Europe/Uzhgorod'              => array('+0200', '+0300'),
434
        'Europe/Vaduz'                 => array('+0100', '+0200'),
435
        'Europe/Vatican'               => array('+0100', '+0200'),
436
        'Europe/Vienna'                => array('+0100', '+0200'),
437
        'Europe/Vilnius'               => array('+0200', '+0200'),
438
        'Europe/Warsaw'                => array('+0100', '+0200'),
439
        'Europe/Zagreb'                => array('+0100', '+0200'),
440
        'Europe/Zaporozhye'            => array('+0200', '+0300'),
441
        'Europe/Zurich'                => array('+0100', '+0200'),
442
        'GB'                           => array('+0000', '+0100'),
443
        'GB-Eire'                      => array('+0000', '+0100'),
444
        'HST'                          => array('-1000', '-1000'),
445
        'Hongkong'                     => array('+0800', '+0800'),
446
        'Indian/Antananarivo'          => array('+0300', '+0300'),
447
        'Indian/Chagos'                => array('+0500', '+0500'),
448
        'Indian/Christmas'             => array('+0700', '+0700'),
449
        'Indian/Cocos'                 => array('+061800', '+061800'),
450
        'Indian/Comoro'                => array('+0300', '+0300'),
451
        'Indian/Kerguelen'             => array('+0500', '+0500'),
452
        'Indian/Mahe'                  => array('+0400', '+0400'),
453
        'Indian/Maldives'              => array('+0500', '+0500'),
454
        'Indian/Mauritius'             => array('+0400', '+0400'),
455
        'Indian/Mayotte'               => array('+0300', '+0300'),
456
        'Indian/Reunion'               => array('+0400', '+0400'),
457
        'Iran'                         => array('+031800', '+041800'),
458
        'Israel'                       => array('+0200', '+0300'),
459
        'Jamaica'                      => array('-0500', '-0500'),
460
        'Japan'                        => array('+0900', '+0900'),
461
        'Kwajalein'                    => array('+1200', '+1200'),
462
        'Libya'                        => array('+0200', '+0200'),
463
        'MET'                          => array('+0100', '+0200'),
464
        'MST'                          => array('-0700', '-0700'),
465
        'MST7MDT'                      => array('-0700', '-0600'),
466
        'Mexico/BajaNorte'             => array('-0800', '-0700'),
467
        'Mexico/BajaSur'               => array('-0700', '-0600'),
468
        'Mexico/General'               => array('-0600', '-0500'),
469
        'Mideast/Riyadh87'             => array('+03424', '+03424'),
470
        'Mideast/Riyadh88'             => array('+03424', '+03424'),
471
        'Mideast/Riyadh89'             => array('+03424', '+03424'),
472
        'NZ'                           => array('+1300', '+1200'),
473
        'NZ-CHAT'                      => array('+132700', '+122700'),
474
        'Navajo'                       => array('-0700', '-0600'),
475
        'PRC'                          => array('+0800', '+0800'),
476
        'PST8PDT'                      => array('-0800', '-0700'),
477
        'Pacific/Apia'                 => array('-1100', '-1100'),
478
        'Pacific/Auckland'             => array('+1300', '+1200'),
479
        'Pacific/Chatham'              => array('+132700', '+122700'),
480
        'Pacific/Easter'               => array('-0500', '-0600'),
481
        'Pacific/Efate'                => array('+1100', '+1100'),
482
        'Pacific/Enderbury'            => array('+1300', '+1300'),
483
        'Pacific/Fakaofo'              => array('-1000', '-1000'),
484
        'Pacific/Fiji'                 => array('+1200', '+1200'),
485
        'Pacific/Funafuti'             => array('+1200', '+1200'),
486
        'Pacific/Galapagos'            => array('-0600', '-0600'),
487
        'Pacific/Gambier'              => array('-0900', '-0900'),
488
        'Pacific/Guadalcanal'          => array('+1100', '+1100'),
489
        'Pacific/Guam'                 => array('+1000', '+1000'),
490
        'Pacific/Honolulu'             => array('-1000', '-1000'),
491
        'Pacific/Johnston'             => array('-1000', '-1000'),
492
        'Pacific/Kiritimati'           => array('+1400', '+1400'),
493
        'Pacific/Kosrae'               => array('+1100', '+1100'),
494
        'Pacific/Kwajalein'            => array('+1200', '+1200'),
495
        'Pacific/Majuro'               => array('+1200', '+1200'),
496
        'Pacific/Marquesas'            => array('-091800', '-091800'),
497
        'Pacific/Midway'               => array('-1100', '-1100'),
498
        'Pacific/Nauru'                => array('+1200', '+1200'),
499
        'Pacific/Niue'                 => array('-1100', '-1100'),
500
        'Pacific/Norfolk'              => array('+111800', '+111800'),
501
        'Pacific/Noumea'               => array('+1100', '+1100'),
502
        'Pacific/Pago_Pago'            => array('-1100', '-1100'),
503
        'Pacific/Palau'                => array('+0900', '+0900'),
504
        'Pacific/Pitcairn'             => array('-0800', '-0800'),
505
        'Pacific/Ponape'               => array('+1100', '+1100'),
506
        'Pacific/Port_Moresby'         => array('+1000', '+1000'),
507
        'Pacific/Rarotonga'            => array('-1000', '-1000'),
508
        'Pacific/Saipan'               => array('+1000', '+1000'),
509
        'Pacific/Samoa'                => array('-1100', '-1100'),
510
        'Pacific/Tahiti'               => array('-1000', '-1000'),
511
        'Pacific/Tarawa'               => array('+1200', '+1200'),
512
        'Pacific/Tongatapu'            => array('+1300', '+1300'),
513
        'Pacific/Truk'                 => array('+1000', '+1000'),
514
        'Pacific/Wake'                 => array('+1200', '+1200'),
515
        'Pacific/Wallis'               => array('+1200', '+1200'),
516
        'Pacific/Yap'                  => array('+1000', '+1000'),
517
        'Poland'                       => array('+0100', '+0200'),
518
        'Portugal'                     => array('+0000', '+0100'),
519
        'ROC'                          => array('+0800', '+0800'),
520
        'ROK'                          => array('+0900', '+0900'),
521
        'Singapore'                    => array('+0800', '+0800'),
522
        'SystemV/AST4'                 => array('-0400', '-0400'),
523
        'SystemV/AST4ADT'              => array('-0400', '-0300'),
524
        'SystemV/CST6'                 => array('-0600', '-0600'),
525
        'SystemV/CST6CDT'              => array('-0600', '-0500'),
526
        'SystemV/EST5'                 => array('-0500', '-0500'),
527
        'SystemV/EST5EDT'              => array('-0500', '-0400'),
528
        'SystemV/HST10'                => array('-1000', '-1000'),
529
        'SystemV/MST7'                 => array('-0700', '-0700'),
530
        'SystemV/MST7MDT'              => array('-0700', '-0600'),
531
        'SystemV/PST8'                 => array('-0800', '-0800'),
532
        'SystemV/PST8PDT'              => array('-0800', '-0700'),
533
        'SystemV/YST9'                 => array('-0900', '-0900'),
534
        'SystemV/YST9YDT'              => array('-0900', '-0800'),
535
        'Turkey'                       => array('+0200', '+0300'),
536
        'US/Alaska'                    => array('-0900', '-0800'),
537
        'US/Aleutian'                  => array('-1000', '-0900'),
538
        'US/Arizona'                   => array('-0700', '-0700'),
539
        'US/Central'                   => array('-0600', '-0500'),
540
        'US/East-Indiana'              => array('-0500', '-0500'),
541
        'US/Eastern'                   => array('-0500', '-0400'),
542
        'US/Hawaii'                    => array('-1000', '-1000'),
543
        'US/Indiana-Starke'            => array('-0500', '-0500'),
544
        'US/Michigan'                  => array('-0500', '-0400'),
545
        'US/Mountain'                  => array('-0700', '-0600'),
546
        'US/Pacific'                   => array('-0800', '-0700'),
547
        'US/Samoa'                     => array('-1100', '-1100'),
548
        'W-SU'                         => array('+0300', '+0400'),
549
        'WET'                          => array('+0000', '+0100')
550
    );
551
552
    // From date_functions.php
553
554
    // takes iCalendar 2 day format and makes it into 3 characters
555
    // if $txt is true, it returns the 3 letters, otherwise it returns the
556
    // integer of that day; 0=Sun, 1=Mon, etc.
557
    /**
558
     * @param         $day
559
     * @param  bool   $txt
560
     * @return string
0 ignored issues
show
Should the return type not be string|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
561
     */
562
    public function two2threeCharDays($day, $txt = true)
563
    {
564
        switch ($day) {
565
            case 'SU':
566
                return ($txt ? 'sun' : '0');
567
            case 'MO':
568
                return ($txt ? 'mon' : '1');
569
            case 'TU':
570
                return ($txt ? 'tue' : '2');
571
            case 'WE':
572
                return ($txt ? 'wed' : '3');
573
            case 'TH':
574
                return ($txt ? 'thu' : '4');
575
            case 'FR':
576
                return ($txt ? 'fri' : '5');
577
            case 'SA':
578
                return ($txt ? 'sat' : '6');
579
        }
580
    }
581
582
    // dateOfWeek() takes a date in Ymd and a day of week in 3 letters or more
583
    // and returns the date of that day. (ie: "sun" or "sunday" would be acceptable values of $day but not "su")
584
    /**
585
     * @param $Ymd
586
     * @param $day
587
     * @return bool|string
588
     */
589
    public function dateOfWeek($Ymd, $day)
590
    {
591
        if (!isset($this->week_start_day)) {
592
            $this->week_start_day = 'Sunday';
593
        }
594
        $timestamp      = strtotime($Ymd);
595
        $num            = date('w', strtotime($this->week_start_day));
596
        $start_day_time = strtotime((date('w', $timestamp) == $num ? "$this->week_start_day" : "last $this->week_start_day"), $timestamp);
597
        $ret_unixtime   = strtotime($day, $start_day_time);
598
        $ret_unixtime   = strtotime('+12 hours', $ret_unixtime);
599
        $ret            = date('Ymd', $ret_unixtime);
600
601
        return $ret;
602
    }
603
604
    // function to compare to dates in Ymd and return the number of weeks
605
    // that differ between them. requires dateOfWeek()
606
    /**
607
     * @param $now
608
     * @param $then
609
     * @return float
610
     */
611
    public function weekCompare($now, $then)
612
    {
613
        $sun_now      = $this->dateOfWeek($now, $this->week_start_day);
614
        $sun_then     = $this->dateOfWeek($then, $this->week_start_day);
615
        $seconds_now  = strtotime($sun_now);
616
        $seconds_then = strtotime($sun_then);
617
        $diff_seconds = $seconds_now - $seconds_then;
618
        $diff_minutes = $diff_seconds / 60;
619
        $diff_hours   = $diff_minutes / 60;
620
        $diff_days    = round($diff_hours / 24);
621
        $diff_weeks   = $diff_days / 7;
622
623
        return $diff_weeks;
624
    }
625
626
    // function to compare to dates in Ymd and return the number of days
627
    // that differ between them.
628
    /**
629
     * @param $now
630
     * @param $then
631
     * @return float
632
     */
633
    public function dayCompare($now, $then)
634
    {
635
        $seconds_now  = strtotime($now);
636
        $seconds_then = strtotime($then);
637
        $diff_seconds = $seconds_now - $seconds_then;
638
        $diff_minutes = $diff_seconds / 60;
639
        $diff_hours   = $diff_minutes / 60;
640
        $diff_days    = round($diff_hours / 24);
641
642
        return $diff_days;
643
    }
644
645
    // function to compare to dates in Ymd and return the number of months
646
    // that differ between them.
647
    /**
648
     * @param $now
649
     * @param $then
650
     * @return int
0 ignored issues
show
Should the return type not be double?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
651
     */
652
    public function monthCompare($now, $then)
653
    {
654
        preg_match('/([0-9]{4})([0-9]{2})([0-9]{2})/', $now, $date_now);
655
        preg_match('/([0-9]{4})([0-9]{2})([0-9]{2})/', $then, $date_then);
656
        $diff_years  = $date_now[1] - $date_then[1];
657
        $diff_months = $date_now[2] - $date_then[2];
658
        if ($date_now[2] < $date_then[2]) {
659
            --$diff_years;
660
            $diff_months = ($diff_months + 12) % 12;
661
        }
662
        $diff_months = ($diff_years * 12) + $diff_months;
663
664
        return $diff_months;
665
    }
666
667
    /**
668
     * @param $now
669
     * @param $then
670
     * @return mixed
671
     */
672
    public function yearCompare($now, $then)
673
    {
674
        preg_match('/([0-9]{4})([0-9]{2})([0-9]{2})/', $now, $date_now);
675
        preg_match('/([0-9]{4})([0-9]{2})([0-9]{2})/', $then, $date_then);
676
        $diff_years = $date_now[1] - $date_then[1];
677
678
        return $diff_years;
679
    }
680
681
    // localizeDate() - similar to strftime but uses our preset arrays of localized
682
    // months and week days and only supports %A, %a, %B, %b, %e, and %Y
683
    // more can be added as needed but trying to keep it small while we can
684
    /*function localizeDate($format, $timestamp) {
685
        global $daysofweek_lang, $daysofweekshort_lang, $daysofweekreallyshort_lang, $monthsofyear_lang, $monthsofyear_lang, $monthsofyearshort_lang;
686
        $year = date("Y", $timestamp);
687
        $month = date("n", $timestamp)-1;
688
        $day = date("j", $timestamp);
689
        $dayofweek = date("w", $timestamp);
690
691
        $date = str_replace('%Y', $year, $format);
692
        $date = str_replace('%e', $day, $date);
693
        $date = str_replace('%B', $monthsofyear_lang[$month], $date);
694
        $date = str_replace('%b', $monthsofyearshort_lang[$month], $date);
695
        $date = str_replace('%A', $daysofweek_lang[$dayofweek], $date);
696
        $date = str_replace('%a', $daysofweekshort_lang[$dayofweek], $date);
697
698
        return $date;
699
700
    }*/
701
    // calcOffset takes an offset (ie, -0500) and returns it in the number of seconds
702
    /**
703
     * @param $offset_str
704
     * @return int
705
     */
706
    public function calcOffset($offset_str)
707
    {
708
        $sign  = substr($offset_str, 0, 1);
709
        $hours = substr($offset_str, 1, 2);
710
        $mins  = substr($offset_str, 3, 2);
711
        $secs  = ((int)$hours * 3600) + ((int)$mins * 60);
712
        if ($sign == '-') {
713
            $secs = 0 - $secs;
714
        }
715
716
        return $secs;
717
    }
718
719
    // calcTime calculates the unixtime of a new offset by comparing it to the current offset
720
    // $have is the current offset (ie, '-0500')
721
    // $want is the wanted offset (ie, '-0700')
722
    // $time is the unixtime relative to $have
723
    /**
724
     * @param $have
725
     * @param $want
726
     * @param $time
727
     * @return int
728
     */
729
    public function calcTime($have, $want, $time)
730
    {
731
        if ($have === 'none' || $want === 'none') {
732
            return $time;
733
        }
734
        $have_secs = $this->calcOffset($have);
735
        $want_secs = $this->calcOffset($want);
736
        $diff      = $want_secs - $have_secs;
737
        $time      += $diff;
738
739
        return $time;
740
    }
741
742
    /**
743
     * @param $time
744
     * @return string
745
     */
746
    public function chooseOffset($time)
0 ignored issues
show
The parameter $time is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
747
    {
748
        return $this->timezone;
749
        /* ¥µ¥Þ¡¼¥¿¥¤¥à¤Î½èÍý¤ò¤ä¤Ã¤Æ¤¤¤ë¤Î¤À¤í¤¦¤±¤É¡¢¤È¤ê¤¢¤¨¤º¥³¥á¥ó¥È¥¢¥¦¥È
750
            if (!isset($this->timezone)) $this->timezone = '';
751
            switch ($this->timezone) {
752
                case '':
753
                    $offset = 'none';
754
                    break;
755
                case 'Same as Server':
756
                    $offset = date('O', $time);
757
                    break;
758
                default:
759
                    if (is_array($this->tz_array) && array_key_exists($this->timezone, $this->tz_array)) {
760
                        $dlst = date('I', $time);
761
                        $offset = $this->tz_array[$this->timezone][$dlst];
762
                    } else {
763
                        $offset = '+0000';
764
                    }
765
            }
766
767
            return $offset;
768
        */
769
    }
770
771
    // ¥³¥ó¥¹¥È¥é¥¯¥¿
772
773
    /**
774
     * iCal_parser constructor.
775
     */
776
    public function __construct()
777
    {
778
    }
779
780
    // ¥Õ¥¡¥¤¥ë¤ò¥Ñ¡¼¥¹¤·¤Æ¡¢ÆâÉôÊÑ¿ô¤Ë¼è¤ê¹þ¤à
781
782
    /**
783
     * @param $filename
784
     * @param $calendar_name
785
     * @return string
786
     */
787
    public function parse($filename, $calendar_name)
788
    {
789
        $ifile = @fopen($filename, 'r');
790
        if ($ifile === false) {
791
            return "-1: File cannot open. filename: $filename";
792
        }
793
        $nextline = fgets($ifile, 1024);
794
        if (trim($nextline) !== 'BEGIN:VCALENDAR') {
795
            return "-2: This file is not iCalendar(RFC2445). filename: $filename";
796
        }
797
798
        // Set a value so we can check to make sure $master_array contains valid data
799
        // $master_array['-1'] = 'valid cal file';
800
801
        // Set default calendar name - can be overridden by X-WR-CALNAME
802
        // $calendar_name = $filename;
803
        // $master_array['calendar_name'] = $filename;
804
805
        // auxiliary array for determining overlaps of events
806
        //  $overlap_array = array ();
807
808
        // using $uid to set specific points in array, if $uid is not in the
809
        // .ics file, we need to have some unique place in the array
810
        $uid_counter = 0;
811
812
        // read file in line by line
813
        // XXX end line is skipped because of the 1-line readahead
814
        while (!feof($ifile)) {
815
            $line     = $nextline;
816
            $nextline = fgets($ifile, 1024);
817
            $nextline = preg_replace("/[\r\n]/", '', $nextline);
818
            while (substr($nextline, 0, 1) === ' ') {
819
                $line     .= substr($nextline, 1);
820
                $nextline = fgets($ifile, 1024);
821
                $nextline = preg_replace("/[\r\n]/", '', $nextline);
822
            }
823
            $line = trim($line);
824
            if ($line === 'BEGIN:VEVENT') {
825
                // each of these vars were being set to an empty string
826
                unset($start_time, $end_time, $start_date, $end_date, $summary, $allday_start, $allday_end, $start, $end, $the_duration, $beginning, $rrule, $start_of_vevent, $description, $status, $class, $categories, $contact, $location, $dtstamp, $sequence, $tz_dtstart, $tz_dtend, $event_tz, $valarm_description, $start_unixtime, $end_unixtime, $recurrence_id, $uid, $uid_valid);
827
828
                $except_dates   = array();
0 ignored issues
show
$except_dates is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
829
                $except_times   = array();
0 ignored issues
show
$except_times is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
830
                $first_duration = true;
0 ignored issues
show
$first_duration is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
831
                $count          = 1000000;
0 ignored issues
show
$count is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
832
                $valarm_set     = false;
0 ignored issues
show
$valarm_set is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
833
            } elseif ($line === 'END:VEVENT') {
834
                // make sure we have some value for $uid
835
                if (!isset($uid)) {
836
                    $uid = $uid_counter;
837
                    ++$uid_counter;
838
                    $uid_valid = false;
839
                } else {
840
                    $uid_valid = true;
841
                }
842
843
                if (empty($summary)) {
844
                    $summary = '';
845
                }
846
                if (empty($description)) {
847
                    $description = '';
848
                }
849
                if (empty($location)) {
850
                    $location = '';
851
                }
852
                if (empty($contact)) {
853
                    $contact = '';
854
                }
855
                if (empty($sequence)) {
856
                    $sequence = 0;
857
                }
858
                if (empty($rrule)) {
859
                    $rrule = '';
860
                }
861
862
                // Handling of the all day events¡ÊÁ´Æü¥¤¥Ù¥ó¥È¡Ë
863
                if (isset($allday_start) && $allday_start !== '') {
864
                    $start_unixtime = strtotime($allday_start);
865
                    if (isset($allday_end) && $allday_end !== '') {
866
                        $end_unixtime = strtotime($allday_end);
867
                        if ($start_unixtime == $end_unixtime) {
868
                            $end_unixtime = $start_unixtime + 86400;
869
                        }
870
                    } else {
871
                        // allday_end ¤Î»ØÄ꤬¤Ê¤±¤ì¤Ð°ìÆü¤Î¤ß¤È¸«¤Ê¤¹
872
                        $end_unixtime = $start_unixtime + 86400;
873
                    }
874
                }
875
876
                $this->events[$uid] = compact('start_unixtime', 'end_unixtime', 'summary', 'description', 'status', 'class', 'categories', 'contact', 'location', 'dtstamp', 'sequence', 'allday_start',
877
                                              'allday_end', 'tz_dtstart', 'tz_dtend', 'event_tz', 'rrule', 'uid_valid');    // GIJ added 03/05/27
878
879
                // Begin VTODO Support
880
                /*      } elseif ($line == 'END:VTODO') {
881
                            if ((!$vtodo_priority) && ($status == 'COMPLETED')) {
882
                                $vtodo_sort = 11;
883
                            } elseif (!$vtodo_priority) {
884
                                $vtodo_sort = 10;
885
                            } else {
886
                                $vtodo_sort = $vtodo_priority;
887
                            }
888
                            $master_array['-2']["$vtodo_sort"]["$uid"] = array ('start_date' => $start_date, 'start_time' => $start_time, 'vtodo_text' => $summary, 'due_date'=> $due_date, 'due_time'=> $due_time, 'completed_date' => $completed_date, 'completed_time' => $completed_time, 'priority' => $vtodo_priority, 'status' => $status, 'class' => $class, 'categories' => $vtodo_categories);
889
                            unset ($due_date, $due_time, $completed_date, $completed_time, $vtodo_priority, $status, $class, $vtodo_categories, $summary);
890
                            $vtodo_set = FALSE;
891
                        } elseif ($line == 'BEGIN:VTODO') {
892
                            $vtodo_set = TRUE;
893
                        } elseif ($line == 'BEGIN:VALARM') {
894
                            $valarm_set = TRUE;
895
                        } elseif ($line == 'END:VALARM') {
896
                            $valarm_set = FALSE;
897
                */
898
            } else {
899
                unset($field, $data, $prop_pos, $property);
900
                preg_match('(/[^:]+):(.*)/', $line, $line);
901
                $field = $line[1];
902
                $data  = $line[2];
903
904
                $property = $field;
905
                $prop_pos = strpos($property, ';');
906
                if ($prop_pos !== false) {
907
                    $property = substr($property, 0, $prop_pos);
908
                }
909
                $property = strtoupper($property);
910
911
                switch ($property) {
912
913
                    // Start VTODO Parsing
914
                    //
915
                    /*              case 'DUE':
916
                                        $zulu_time = false;
917
                                        if (substr($data,-1) == 'Z') $zulu_time = true;
918
                                        $data = preg_replace('/T/', '', $data);
919
                                        $data = preg_replace('/Z/', '', $data);
920
                                        if (preg_match("/^DUE;VALUE=DATE/i", $field)) {
921
                                            $allday_start = $data;
922
                                            $start_date = $allday_start;
923
                                        } else {
924
                                            if (preg_match("/^DUE;TZID=/i", $field)) {
925
                                                $tz_tmp = explode('=', $field);
926
                                                $tz_due = $tz_tmp[1];
927
                                                unset($tz_tmp);
928
                                            } elseif ($zulu_time) {
929
                                                $tz_due = 'GMT';
930
                                            }
931
932
                                            preg_match('/([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{0,2})([0-9]{0,2})/', $data, $regs);
933
                                            $start_date = $regs[1] . $regs[2] . $regs[3];
934
                                            $start_time = $regs[4] . $regs[5];
935
                                            $start_unixtime = mktime($regs[4], $regs[5], 0, $regs[2], $regs[3], $regs[1]);
936
937
                                            $dlst = date('I', $start_unixtime);
938
                                            $server_offset_tmp = $this->chooseOffset($start_unixtime);
939
                                            if (isset($tz_due)) {
940
                                                if (array_key_exists($tz_due, $this->tz_array)) {
941
                                                    $offset_tmp = $this->tz_array[$tz_due][$dlst];
942
                                                } else {
943
                                                    $offset_tmp = '+0000';
944
                                                }
945
                                            } elseif (isset($calendar_tz)) {
946
                                                if (array_key_exists($calendar_tz, $this->tz_array)) {
947
                                                    $offset_tmp = $this->tz_array[$calendar_tz][$dlst];
948
                                                } else {
949
                                                    $offset_tmp = '+0000';
950
                                                }
951
                                            } else {
952
                                                $offset_tmp = $server_offset_tmp;
953
                                            }
954
                                            $start_unixtime = $this->calcTime($offset_tmp, $server_offset_tmp, $start_unixtime);
955
                                            $due_date = date('Ymd', $start_unixtime);
956
                                            $due_time = date('Hi', $start_unixtime);
957
                                            unset($server_offset_tmp);
958
                                        }
959
                                        break;
960
                    */
961
                    /*              case 'COMPLETED':
962
                                        $zulu_time = false;
963
                                        if (substr($data,-1) == 'Z') $zulu_time = true;
964
                                        $data = ereg_replace('T', '', $data);
965
                                        $data = ereg_replace('Z', '', $data);
966
                                        if (preg_match("/^COMPLETED;VALUE=DATE/i", $field)) {
967
                                            $allday_start = $data;
968
                                            $start_date = $allday_start;
969
                                        } else {
970
                                            if (preg_match("/^COMPLETED;TZID=/i", $field)) {
971
                                                $tz_tmp = explode('=', $field);
972
                                                $tz_completed = $tz_tmp[1];
973
                                                unset($tz_tmp);
974
                                            } elseif ($zulu_time) {
975
                                                $tz_completed = 'GMT';
976
                                            }
977
978
                                            ereg ('([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{0,2})([0-9]{0,2})', $data, $regs);
979
                                            $start_date = $regs[1] . $regs[2] . $regs[3];
980
                                            $start_time = $regs[4] . $regs[5];
981
                                            $start_unixtime = mktime($regs[4], $regs[5], 0, $regs[2], $regs[3], $regs[1]);
982
983
                                            $dlst = date('I', $start_unixtime);
984
                                            $server_offset_tmp = $this->chooseOffset($start_unixtime);
985
                                            if (isset($tz_completed)) {
986
                                                if (array_key_exists($tz_completed, $this->tz_array)) {
987
                                                    $offset_tmp = $this->tz_array[$tz_completed][$dlst];
988
                                                } else {
989
                                                    $offset_tmp = '+0000';
990
                                                }
991
                                            } elseif (isset($calendar_tz)) {
992
                                                if (array_key_exists($calendar_tz, $this->tz_array)) {
993
                                                    $offset_tmp = $this->tz_array[$calendar_tz][$dlst];
994
                                                } else {
995
                                                    $offset_tmp = '+0000';
996
                                                }
997
                                            } else {
998
                                                $offset_tmp = $server_offset_tmp;
999
                                            }
1000
                                            $start_unixtime = $this->calcTime($offset_tmp, $server_offset_tmp, $start_unixtime);
1001
                                            $completed_date = date('Ymd', $start_unixtime);
1002
                                            $completed_time = date('Hi', $start_unixtime);
1003
                                            unset($server_offset_tmp);
1004
                                        }
1005
                                        break;
1006
1007
                                    case 'PRIORITY':
1008
                                        $vtodo_priority = "$data";
1009
                                        break;
1010
                    */
1011
                    case 'STATUS':
1012
                        // VEVENT: TENTATIVE, CONFIRMED, CANCELLED
1013
                        // VTODO: NEEDS-ACTION, COMPLETED, IN-PROCESS, CANCELLED
1014
                        $status = "$data";
1015
                        break;
1016
1017
                    case 'CLASS':
1018
                        // VEVENT, VTODO: PUBLIC, PRIVATE, CONFIDENTIAL
1019
                        $class = "$data";
1020
                        break;
1021
1022
                    case 'CATEGORIES':
1023
                        $categories = mb_convert_encoding($data, mb_internal_encoding(), 'UTF-8');
1024
                        break;
1025
                    //
1026
                    // End VTODO Parsing
1027
1028
                    case 'DTSTART':
1029
                        $zulu_time = false;
1030
                        if (substr($data, -1) === 'Z') {
1031
                            $zulu_time = true;
1032
                        }
1033
                        $data  = preg_replace('/T/', '', $data);
1034
                        $data  = preg_replace('/Z/', '', $data);
1035
                        $field = preg_replace('/;VALUE=DATE-TIME/', '', $field);
1036
                        if (preg_match('/^DTSTART;VALUE=DATE/i', $field)) {
1037
                            $allday_start = $data;
1038
                            $start_date   = $allday_start;
1039
                        } else {
1040 View Code Duplication
                            if (preg_match('/^DTSTART;TZID=/i', $field)) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1041
                                $tz_tmp     = explode('=', $field);
1042
                                $tz_dtstart = $tz_tmp[1];
1043
                                unset($tz_tmp);
1044
                            } elseif ($zulu_time) {
1045
                                $tz_dtstart = 'GMT';
1046
                            }
1047
1048
                            preg_match('/([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{0,2})([0-9]{0,2})/', $data, $regs);
1049
                            $start_date     = $regs[1] . $regs[2] . $regs[3];
0 ignored issues
show
$start_date is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
1050
                            $start_time     = $regs[4] . $regs[5];
0 ignored issues
show
$start_time is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
1051
                            $start_unixtime = mktime($regs[4], $regs[5], 0, $regs[2], $regs[3], $regs[1]);
1052
1053
                            $dlst              = date('I', $start_unixtime);
1054
                            $server_offset_tmp = $this->chooseOffset($start_unixtime);
1055
                            if (isset($tz_dtstart)) {
1056
                                if (array_key_exists($tz_dtstart, $this->tz_array)) {
1057
                                    $offset_tmp = $this->tz_array[$tz_dtstart][$dlst];
1058
                                } else {
1059
                                    $offset_tmp = '+0000';
1060
                                }
1061
                            } elseif (isset($calendar_tz)) {
1062
                                if (array_key_exists($calendar_tz, $this->tz_array)) {
1063
                                    $offset_tmp = $this->tz_array[$calendar_tz][$dlst];
1064
                                } else {
1065
                                    $offset_tmp = '+0000';
1066
                                }
1067
                                $tz_dtstart = $calendar_tz; // GIJ added
1068
                            } else {
1069
                                $offset_tmp = $server_offset_tmp;
1070
                            }
1071
                            $start_unixtime = $this->calcTime($offset_tmp, $server_offset_tmp, $start_unixtime);
1072
                            $event_tz       = $this->calcOffset($offset_tmp) / 3600;
1073
                            $start_date     = date('Ymd', $start_unixtime);
1074
                            $start_time     = date('Hi', $start_unixtime);
1075
                            unset($server_offset_tmp);
1076
                        }
1077
                        break;
1078
1079
                    case 'DTEND':
1080
                        $zulu_time = false;
1081
                        if (substr($data, -1) === 'Z') {
1082
                            $zulu_time = true;
1083
                        }
1084
                        $data  = preg_replace('/T/', '', $data);
1085
                        $data  = preg_replace('/Z/', '', $data);
1086
                        $field = preg_replace('/;VALUE=DATE-TIME/', '', $field);
1087
                        if (preg_match('/^DTEND;VALUE=DATE/i', $field)) {
1088
                            $allday_end = $data;
1089
                        } else {
1090 View Code Duplication
                            if (preg_match('/^DTEND;TZID=/i', $field)) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1091
                                $tz_tmp   = explode('=', $field);
1092
                                $tz_dtend = $tz_tmp[1];
1093
                                unset($tz_tmp);
1094
                            } elseif ($zulu_time) {
1095
                                $tz_dtend = 'GMT';
1096
                            }
1097
1098
                            preg_match('/([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{0,2})([0-9]{0,2})/', $data, $regs);
1099
                            $end_date     = $regs[1] . $regs[2] . $regs[3];
0 ignored issues
show
$end_date is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
1100
                            $end_time     = $regs[4] . $regs[5];
0 ignored issues
show
$end_time is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
1101
                            $end_unixtime = mktime($regs[4], $regs[5], 0, $regs[2], $regs[3], $regs[1]);
1102
1103
                            $dlst              = date('I', $end_unixtime);
1104
                            $server_offset_tmp = $this->chooseOffset($end_unixtime);
1105
                            if (isset($tz_dtend)) {
1106
                                $offset_tmp = $this->tz_array[$tz_dtend][$dlst];
1107
                            } elseif (isset($calendar_tz)) {
1108
                                $offset_tmp = $this->tz_array[$calendar_tz][$dlst];
1109
                                $tz_dtend   = $calendar_tz; // GIJ added
1110
                            } else {
1111
                                $offset_tmp = $server_offset_tmp;
1112
                            }
1113
                            $end_unixtime = $this->calcTime($offset_tmp, $server_offset_tmp, $end_unixtime);
1114
                            if (!isset($event_tz)) {
1115
                                $event_tz = $this->calcOffset($offset_tmp) / 3600;
1116
                            }
1117
                            $end_date = date('Ymd', $end_unixtime);
1118
                            $end_time = date('Hi', $end_unixtime);
1119
                            unset($server_offset_tmp);
1120
                        }
1121
                        break;
1122
1123
                    /*              case 'EXDATE':
1124
                                        $data = explode(",", $data);
1125
                                        foreach ($data as $exdata) {
1126
                                            $exdata = preg_replace('/T/', '', $exdata);
1127
                                            $exdata = preg_replace('/Z/', '', $exdata);
1128
                                            preg_match ('/([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{0,2})([0-9]{0,2})/', $exdata, $regs);
1129
                                            $except_dates[] = $regs[1] . $regs[2] . $regs[3];
1130
                                            $except_times[] = $regs[4] . $regs[5];
1131
                                        }
1132
                                        break;
1133
                    */
1134
                    case 'SUMMARY':
1135
                        $summary = mb_convert_encoding($data, mb_internal_encoding(), 'UTF-8');
1136
                        break;
1137
1138
                    case 'DESCRIPTION':
1139
                        $description = mb_convert_encoding($data, mb_internal_encoding(), 'UTF-8');
1140
                        break;
1141
1142
                    case 'CONTACT':
1143
                        // RFC2445 4.8.4.2  GIJ added
1144
                        $contact = mb_convert_encoding($data, mb_internal_encoding(), 'UTF-8');
1145
                        break;
1146
1147
                    case 'LOCATION':
1148
                        // RFC2445 4.8.1.7  GIJ added
1149
                        $location = mb_convert_encoding($data, mb_internal_encoding(), 'UTF-8');
1150
                        break;
1151
1152
                    case 'DTSTAMP':
1153
                        // RFC2445 4.8.7.2  GIJ added
1154
                        $data    = str_replace('T', '', $data);
1155
                        $dtstamp = str_replace('Z', '', $data);
1156
                        break;
1157
1158
                    case 'SEQUENCE':
1159
                        // RFC2445 4.8.7.4  GIJ added
1160
                        $sequence = (int)$data;
1161
                        break;
1162
1163
                    case 'UID':
1164
                        $uid = $data;
1165
                        break;
1166
1167
                    case 'X-WR-CALNAME':
1168
                        $calendar_name = mb_convert_encoding($data, mb_internal_encoding(), 'UTF-8');
1169
                        break;
1170
1171
                    case 'X-WR-TIMEZONE':
1172
                        $calendar_tz = $data;
1173
                        break;
1174
1175
                    /*              case 'DURATION':
1176
                                        if (($first_duration === true) && (!stristr($field, '=DURATION'))) {
1177
                                            preg_match('/^P([0-9]{1,2})?([W,D]{0,1}[T])?([0-9]{1,2}[H])?([0-9]{1,2}[M])?([0-9]{1,2}[S])?/', $data, $duration);
1178
                                            if ($duration[2] = 'W') {
1179
                                                $weeks = $duration[1];
1180
                                                $days = 0;
1181
                                            } else {
1182
                                                $days = $duration[1];
1183
                                                $weeks = 0;
1184
                                            }
1185
                                            $hours = preg_replace('/H/', '', $duration[3]);
1186
                                            $minutes = preg_replace('/M/', '', $duration[4]);
1187
                                            $seconds = preg_replace('/S/', '', $duration[5]);
1188
                                            $the_duration = ($weeks * 60 * 60 * 24 * 7) + ($days * 60 * 60 * 24) + ($hours * 60 * 60) + ($minutes * 60) + ($seconds);
1189
                                            $end_unixtime = $start_unixtime + $the_duration;
1190
                                            $end_time = date ('Hi', $end_unixtime);
1191
                                            $first_duration = FALSE;
1192
                                        }
1193
                                        break;
1194
                    */
1195
                    case 'RRULE':
1196
                        $rrule = strtoupper($data);
1197
                        break;
1198
1199
                    /*              case 'ATTENDEE':
1200
                                        $attendee = $data;
1201
                                        break;
1202
                    */
1203
                }
1204
            }
1205
        }
1206
1207
        //If you want to see the values in the arrays, uncomment below.
1208
        //print '<pre>';
1209
        //print_r($this->events);
1210
        //print_r($rrule);
1211
        //print '</pre>';
1212
        return "0: $calendar_name :";
1213
    }
1214
1215
    // ¥Ñ¡¼¥¹¤·¤¿iCalendar¥Ç¡¼¥¿¤«¤é¡¢INSERT,UPDATEÍѤÎSETʸÇÛÎó¤òÀ¸À®¤¹¤ë´Ø¿ô
1216
1217
    /**
1218
     * @return array
1219
     */
1220
    public function output_setsqls()
1221
    {
1222
        $rets = array();
1223
1224
        foreach ($this->events as $uid => $event) {
1225
            $ret = '';
1226
1227
            // $event[] ¤ò¥í¡¼¥«¥ëÊÑ¿ô¤ËŸ³«
1228
            unset($start_unixtime, $end_unixtime, $summary, $description, $status, $class, $categories, $contact, $location, $dtstamp, $sequence, $allday_start, $allday_end, $tz_dtstart, $tz_dtend, $event_tz, $uid_valid);
1229
            extract($event);
1230
1231
            // Unique-ID (¼«Æ°ÉÕ²ÃÈÖ¹æ¤Î¾ì¹ç¤Ï¡¢¤½¤ì¤Ã¤Ý¤¯À¸À®¤¹¤ë)
1232
            if (!$uid_valid) {
1233
                $unique_id = 'apcal060-' . md5("{$_SERVER['HTTP_HOST']}{$_SERVER['PHP_SELF']}") . "-$uid";
1234
            } else {
1235
                $unique_id = $uid;
1236
            }
1237
            $ret .= "unique_id='" . addslashes($unique_id) . "',";
1238
1239
            // DTEND¤Îµ­½Ò¤¬¤Ê¤¤¥Ç¡¼¥¿¤Ø¤ÎÂкö
1240
            if (!isset($end_unixtime)) {
1241
                $end_unixtime = $start_unixtime + 300;
1242
            }
1243
1244
            // start¤Èend¤¬È¿Å¾¤·¤Æ¤¤¤ë¥Ç¡¼¥¿¤Ø¤ÎÂкö
1245
            if ($start_unixtime > $end_unixtime) {
1246
                list($start_unixtime, $end_unixtime) = array($end_unixtime, $start_unixtime);
1247
            }
1248
1249
            // 5ʬñ°Ì¤Ë·¤¨¤ë
1250
            $start_unixtime = (int)($start_unixtime / 300) * 300;
1251
            $end_unixtime   = (int)($end_unixtime / 300) * 300;
1252
1253
            // »þ´Ö¤Î¥»¥Ã¥È
1254
            $ret .= "start='$start_unixtime',end='$end_unixtime',";
1255
            if (isset($allday_start) && $allday_start !== '') {
1256
                // Á´Æü¥¤¥Ù¥ó¥È
1257
                $ret .= "allday='1',";
1258
            } else {
1259
                // Ä̾磻¥Ù¥ó¥È
1260
                $ret .= "allday='0',";
1261
            }
1262
1263
            // tzid ¤Îµ­Ï¿¡Ê°ì±þ¡Ë
1264
            if (isset($tz_dtstart) && $tz_dtstart !== '') {
1265
                $ret .= "tzid='$tz_dtstart',";
1266
            } elseif (isset($tz_dtend) && $tz_dtend !== '') {
1267
                $ret .= "tzid='$tz_dtend',";
1268
            }
1269
1270
            // event_tz ¤Îµ­Ï¿
1271
            if (isset($event_tz)) {
1272
                $ret .= "event_tz='$event_tz',";
1273
            }
1274
1275
            // summary¤Î¥Á¥§¥Ã¥¯¡Ê̤µ­Æþ¤Ê¤é¤½¤Î»Ý¤òÄɲáË
1276
            if (empty($summary) || $summary === '') {
1277
                $event['summary'] = '¡Ê·ï̾¤Ê¤·¡Ë';
1278
            }
1279
1280
            // ¤½¤Î¾¤Î¥«¥é¥à (dtstamp ¤Ï¤¢¤¨¤Æ³°¤¹)
1281
            $cols = array(
1282
                'summary'     => '255:J:1',
1283
                'location'    => '255:J:0',
1284
                'contact'     => '255:J:0',
1285
                'categories'  => '255:J:0',
1286
                'rrule'       => '255:E:0', /* "dtstamp" => "14:E:0" ,*/
1287
                'sequence'    => 'I:N:0',
1288
                'description' => 'A:J:0'
1289
            );
1290
            $ret  .= $this->get_sql_set($event, $cols);
1291
1292
            $rets[] = $ret;
1293
        }
1294
1295
        return $rets;
1296
    }
1297
1298
    // Ï¢ÁÛÇÛÎó¤ò°ú¿ô¤Ë¼è¤ê¡¢$event¤«¤éINSERT,UPDATEÍѤÎSETʸ¤òÀ¸À®¤¹¤ë¥¯¥é¥¹´Ø¿ô
1299
1300
    /**
1301
     * @param $event
1302
     * @param $cols
1303
     * @return string
1304
     */
1305
    public function get_sql_set($event, $cols)
1306
    {
1307
        $ret = '';
1308
1309
        foreach ($cols as $col => $types) {
1310
            list($field, $lang, $essential) = explode(':', $types);
0 ignored issues
show
The assignment to $essential is unused. Consider omitting it like so list($first,,$third).

This checks looks for assignemnts to variables using the list(...) function, where not all assigned variables are subsequently used.

Consider the following code example.

<?php

function returnThreeValues() {
    return array('a', 'b', 'c');
}

list($a, $b, $c) = returnThreeValues();

print $a . " - " . $c;

Only the variables $a and $c are used. There was no need to assign $b.

Instead, the list call could have been.

list($a,, $c) = returnThreeValues();
Loading history...
1311
1312
            $data = empty($event[$col]) ? '' : $event[$col];
1313
1314
            // ¸À¸ì¡¦¿ô»ú¤Ê¤É¤ÎÊ̤ˤè¤ë½èÍý
1315 View Code Duplication
            switch ($lang) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1316
                case 'N':    // ¿ôÃÍ (·å¼è¤ê¤Î , ¤ò¼è¤ë)
1317
                    $data = str_replace(',', '', $data);
1318
                    break;
1319
                case 'J':    // ÆüËÜ¸ì¥Æ¥­¥¹¥È (Ⱦ³Ñ¥«¥Ê¢ªÁ´³Ñ¤«¤Ê)
1320
                    $data = $this->mb_convert_kana($data, 'KV');
1321
                    break;
1322
                case 'E':    // Ⱦ³Ñ±Ñ¿ô»ú¤Î¤ß (Á´³Ñ±Ñ¿ô¢ªÈ¾³Ñ±Ñ¿ô)
1323
                    $data = $this->mb_convert_kana($data, 'as');
1324
                    break;
1325
            }
1326
1327
            // ¥Õ¥£¡¼¥ë¥É¤Î·¿¤Ë¤è¤ë½èÍý
1328
            switch ($field) {
1329
                case 'A':    // textarea
1330
                    $data = $this->textarea_sanitizer_for_sql($data);
1331
                    break;
1332
                case 'I':    // integer
1333
                    $data = (int)$data;
1334
                    break;
1335
                default:    // varchar(¥Ç¥Õ¥©¥ë¥È)¤Ï¿ôÃͤˤè¤ëʸ»ú¿ô»ØÄê
1336
                    $data = $this->text_sanitizer_for_sql($data);
1337
                    if ($field < 1) {
1338
                        $field = 255;
1339
                    }
1340
                    $data = mb_strcut($data, 0, $field);
1341
            }
1342
1343
            // ºÇ¸å¤Ëaddslashes
1344
            $data = addslashes($data);
1345
1346
            $ret .= "$col='$data',";
1347
        }
1348
1349
        // ºÇ¸å¤Î , ¤òºï½ü
1350
        $ret = substr($ret, 0, -1);
1351
1352
        return $ret;
1353
    }
1354
1355
    // mb_convert_kana¤Î½èÍý
1356
1357
    /**
1358
     * @param $str
1359
     * @param $option
1360
     * @return string
1361
     */
1362 View Code Duplication
    public function mb_convert_kana($str, $option)
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1363
    {
1364
        // convert_kana ¤Î½èÍý¤Ï¡¢ÆüËܸì¤Ç¤Î¤ß¹Ô¤¦
1365
        if ($this->language !== 'japanese' || !function_exists('mb_convert_kana')) {
1366
            return $str;
1367
        } else {
1368
            return mb_convert_kana($str, $option);
1369
        }
1370
    }
1371
1372
    // ¥µ¥Ë¥¿¥¤¥º´ØÏ¢¤Î´Ø¿ô (¥µ¥Ö¥¯¥é¥¹¤òºîÀ®¤¹¤ë»þ¤ÎOverrideÂоÝ)
1373
1374
    /**
1375
     * @param $data
1376
     * @return string
1377
     */
1378
    public function textarea_sanitizer_for_sql($data)
1379
    {
1380
        // '\n' ¤ò "\n" ¤Ë¤¹¤ë
1381
        $data = str_replace('\n', "\n", $data);
1382
1383
        if (class_exists('MyTextSanitizer')) {
1384
            // XOOPS¤Î¥µ¥Ë¥¿¥¤¥¶¥¯¥é¥¹¤¬¤¢¤ì¤Ð¡¢¸ÄÊ̤Ëbb code¥¿¥°¤Ø¤ÎÊÑ´¹¤ò¤·¤Æ¤ß¤ë
1385
            $search  = array(
1386
                "/mailto:(\S+)(\s)/i",
1387
                "/http:\/\/(\S+)(\s)/i"
1388
            );
1389
            $replace = array(
1390
                "[email]\\1[/email]\\2",
1391
                "[url=\\1]\\1[/url]\\2"
1392
            );
1393
            $data    = preg_replace($search, $replace, $data);
1394
1395
            return strip_tags($data);
1396
        } else {
1397
            // ¤Ê¤±¤ì¤Ð¡¢Ã±¤ËÁ´¥¿¥°¤ò̵¸ú¤È¤¹¤ë
1398
            return strip_tags($data);
1399
        }
1400
    }
1401
1402
    /**
1403
     * @param $data
1404
     * @return string
1405
     */
1406
    public function text_sanitizer_for_sql($data)
1407
    {
1408
        // Á´¥¿¥°¤ò̵¸ú¤È¤¹¤ësanitize
1409
        // ¼ÂºÝ¤Ë¤Ï¡¢Outlook¤Ê¤É¤Ç¤Ï¥¿¥°¤òľ½ñ¤­¤¹¤ë¤Î¤Ç¡¢²èÌ̽ÐÎϤΥµ¥Ë¥¿¥¤¥º¤µ¤¨
1410
        // ¤­¤Á¤ó¤È¹Ô¤ï¤ì¤Æ¤¤¤ë¤Î¤Ç¤¢¤ì¤Ð¡¢¤³¤³¤Ç¤Îstrip_tags ¤Ï¾Ã¤·¤Æ¤âÎɤ¤¤Ï¤º
1411
        return strip_tags($data);
1412
    }
1413
1414
    // The End of Class
1415
}
1416