This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
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 | if (!class_exists('APCal')) { |
||
23 | define('APCAL_EVENT_TABLE', 'apcal_event'); |
||
24 | define('APCAL_CAT_TABLE', 'apcal_cat'); |
||
25 | // require_once __DIR__ . '/../../../include/cp_header.php'; |
||
26 | require_once XOOPS_ROOT_PATH . '/modules/apcal/include/ro_contacthandler.php'; // added by goffy convert name(s) in field contact in a links to member account |
||
27 | require_once XOOPS_ROOT_PATH . '/modules/apcal/class/thumb.php'; |
||
28 | |||
29 | /** |
||
30 | * Class APCal |
||
31 | */ |
||
32 | class APCal |
||
33 | { |
||
34 | // SKELTON (they will be defined in language files) |
||
35 | public $holidays = array(); |
||
36 | public $date_short_names = array(); |
||
37 | public $date_long_names = array(); |
||
38 | public $week_numbers = array(); |
||
39 | public $week_short_names = array(); |
||
40 | public $week_middle_names = array(); |
||
41 | public $week_long_names = array(); |
||
42 | public $month_short_names = array(); |
||
43 | public $month_middle_names = array(); |
||
44 | public $month_long_names = array(); |
||
45 | public $byday2langday_w = array(); |
||
46 | public $byday2langday_m = array(); |
||
47 | |||
48 | // LOCALES |
||
49 | public $locale = ''; // locale for APCal original |
||
50 | public $locale4system = ''; // locale for UNIX systems (deprecated) |
||
51 | |||
52 | // COLORS/STYLES public |
||
53 | public $holiday_color = '#CC0000'; |
||
54 | public $holiday_bgcolor = '#FFEEEE'; |
||
55 | public $sunday_color = '#CC0000'; |
||
56 | public $sunday_bgcolor = '#FFEEEE'; |
||
57 | public $saturday_color = '#0000FF'; |
||
58 | public $saturday_bgcolor = '#EEF7FF'; |
||
59 | public $weekday_color = '#000099'; |
||
60 | public $weekday_bgcolor = '#FFFFFF'; |
||
61 | public $targetday_bgcolor = '#CCFF99'; |
||
62 | public $calhead_color = '#009900'; |
||
63 | public $calhead_bgcolor = '#CCFFCC'; |
||
64 | public $frame_css = '#000000'; |
||
65 | public $allcats_color = '#5555AA'; |
||
66 | public $event_color = '#000000'; |
||
67 | public $event_bgcolor = '#EEEEEE'; |
||
68 | |||
69 | // GOOGLE MAPS |
||
70 | public $gmlat = 0; |
||
71 | public $gmlng = 0; |
||
72 | public $gmzoom = 12; |
||
73 | public $gmheight = 350; |
||
74 | public $gmPoints = array(); |
||
75 | |||
76 | // PICTURES |
||
77 | public $picWidth = 150; |
||
78 | public $picHeight = 150; |
||
79 | public $nbPictures = 5; |
||
80 | |||
81 | public $showPicMonthly = 1; |
||
82 | public $showPicWeekly = 1; |
||
83 | public $showPicDaily = 1; |
||
84 | public $showPicList = 1; |
||
85 | |||
86 | public $widerDays = array('Saturday', 'Sunday'); |
||
87 | |||
88 | public $useurlrewrite = 0; |
||
89 | public $enablecalmap = 1; |
||
90 | public $enableeventmap = 1; |
||
91 | public $enablesharing = 1; |
||
92 | public $eventNavEnabled = 1; |
||
93 | public $displayCatTitle = 1; |
||
94 | public $enablesocial = false; |
||
95 | public $enabletellafriend = false; |
||
96 | public $enableprint = false; |
||
97 | |||
98 | public $default_view = 'Monthly'; |
||
99 | |||
100 | // TIMEZONES |
||
101 | public $server_TZ = 9; // Server's Timezone Offset (hour) |
||
102 | public $user_TZ = 9; // User's Timezone Offset (hour) |
||
103 | public $use_server_TZ = false; // if 'caldate' is generated in Server's time |
||
104 | public $displayTimezone = 1; |
||
105 | |||
106 | // AUTHORITIES |
||
107 | public $insertable = true; // can insert a new event |
||
108 | public $editable = true; // can update an event he posted |
||
109 | public $superedit = false; // can update all event |
||
110 | public $deletable = true; // can delete an event he posted |
||
111 | public $user_id = -1; // User's ID |
||
112 | public $isadmin = false; // Is admin or not |
||
113 | |||
114 | // ANOTHER public properties |
||
115 | public $conn; // MySQL�Ȥ���³�ϥ�ɥ� (ͽ������򤹤�����å�) |
||
116 | public $table = 'apcal_event'; // table name for events |
||
117 | public $cat_table = 'apcal_cat'; // table name for categories |
||
118 | public $pic_table = 'apcal_pictures'; // table name for pictures |
||
119 | public $plugin_table = 'apcal_plugin'; // table name for plugins |
||
120 | public $base_url = ''; |
||
121 | public $base_path = ''; |
||
122 | public $images_url = '/include/apcal/images'; // ���Υե������ spacer.gif, arrow*.gif ����֤��Ƥ��� |
||
123 | public $images_path = 'include/apcal/images'; |
||
124 | public $jscalendar = 'jscalendar'; // DHTML Date/Time Selector |
||
125 | public $jscalendar_lang_file = 'calendar-jp.js'; // language file of the jscalh |
||
126 | public $can_output_ics = true; // ics�ե�������Ϥ���Ĥ��뤫�ɤ��� |
||
127 | public $ics_new_cal = true; |
||
128 | public $connection = 'http'; // http �� https �� |
||
129 | public $max_rrule_extract = 100; // rrule ��Ÿ���ξ�¿�(COUNT) |
||
130 | public $week_start = 0; // ��������� 0������ 1������ |
||
131 | public $week_numbering = 0; // ���ο����� 0�ʤ��� 1�ʤ�ǯ���̻� |
||
132 | public $day_start = 0; // ���դζ���������ñ�̡� |
||
133 | public $use24 = true; // 24�������ʤ�true��12�������ʤ�false |
||
134 | public $now_cid = 0; // ���ƥ������ |
||
135 | public $categories = array(); // ����������ǽ�ʥ��ƥ��ꥪ�֥�������Ϣ������ |
||
136 | public $canbemain_cats = array(); |
||
137 | public $groups = array(); // PRIVATE���������ǽ�ʥ��롼�פ�Ϣ������ |
||
138 | public $nameoruname = 'name'; // ��ƼԤ�ɽ���ʥ?����̾���ϥ�ɥ�̾���� |
||
139 | public $proxysettings = ''; // Proxy setting |
||
140 | public $last_summary = ''; // ���������̾�򻲾Ȥ��뤿��Υץ�ѥƥ� |
||
141 | public $plugins_path_monthly = 'plugins/monthly'; |
||
142 | public $plugins_path_weekly = 'plugins/weekly'; |
||
143 | public $plugins_path_daily = 'plugins/daily'; |
||
144 | |||
145 | // private members |
||
146 | public $year; |
||
147 | public $month; |
||
148 | public $date; |
||
149 | public $day; // 0:Sunday ... 6:Saturday |
||
150 | public $daytype; // 0:weekdays 1:saturday 2:sunday 3:holiday |
||
151 | public $caldate; // everytime 'Y-n-j' formatted |
||
152 | public $unixtime; |
||
153 | public $long_event_legends = array(); |
||
154 | public $language = 'japanese'; |
||
155 | |||
156 | // ����դ������ѥ��� |
||
157 | public $original_id; // $_GET['event_id']�����ľ��˻��Ȳ�ǽ |
||
158 | |||
159 | // added by goffy: vars for online registration |
||
160 | public $table_ro_members = '_apcal_ro_members'; // table for eventmembers |
||
161 | public $table_ro_events = '_apcal_ro_events'; // table for events, where online registration is possible (max registration, email notify in case off add/remove eventmembers |
||
162 | public $table_ro_notify = '_apcal_ro_notify'; // table for persons, which should be informed about registrations by email |
||
163 | public $redirecturl = ''; // variable für redirect |
||
164 | public $registered = 0; // var whether user is already regristrated for this event or not |
||
165 | public $regonline = 0; // var, whether online registration is activated or not |
||
166 | public $roimage = 0; // var for image to mark events with online registration |
||
167 | public $eventmembers = ''; // first var for show additional info |
||
168 | public $eventmembersall = ''; // second var for show additional info |
||
169 | public $enableregistration = 1; |
||
170 | var $enablecontact = 0; // use contacthandler |
||
171 | var $ro_showtip = 0; // show tip for online registration |
||
172 | var $ro_mail_sender = "[email protected]"; // e-mail of sender for notify registered person |
||
173 | var $ro_mail_sendername = "Calendar of APCal"; // name of sender for notify registered person |
||
174 | var $ro_mail_signature = "Your Team of APCal"; // signature for notify registered person |
||
175 | var $ro_showlist = 0; // show list of registered persons |
||
176 | // var $ro_superedit = 0; // user can edit/delete registration of other persons |
||
177 | // var $ro_image_available = ""; // path to image showing availability of the event |
||
178 | // var $ro_use_waiting_list = ""; // a waiting list will be used for an event |
||
179 | // var $ro_need_confirm = ""; // each online registration must be confirm by event owner |
||
180 | var $ro_extrainfo1 = ''; // define extrainfo1 |
||
181 | var $ro_extrainfo2 = ''; // define extrainfo2 |
||
182 | var $ro_extrainfo3 = ''; // define extrainfo3 |
||
183 | var $ro_extrainfo4 = ''; // define extrainfo4 |
||
184 | var $ro_extrainfo5 = ''; // define extrainfo5 |
||
185 | var $ro_extrainfo1_obl = 0; // define whether extrainfo1 is obligatory or on voluntary base |
||
186 | var $ro_extrainfo2_obl = 0; // define whether extrainfo1 is obligatory or on voluntary base |
||
187 | var $ro_extrainfo3_obl = 0; // define whether extrainfo1 is obligatory or on voluntary base |
||
188 | var $ro_extrainfo4_obl = 0; // define whether extrainfo1 is obligatory or on voluntary base |
||
189 | var $ro_extrainfo5_obl = 0; // define whether extrainfo1 is obligatory or on voluntary base |
||
190 | // end goffy |
||
191 | |||
192 | /*******************************************************************/ |
||
193 | /* CONSTRUCTOR etc. */ |
||
194 | /*******************************************************************/ |
||
195 | |||
196 | // Constructor |
||
197 | /** |
||
198 | * APCal constructor. |
||
199 | * @param string $target_date |
||
200 | * @param string $language |
||
201 | * @param bool $reload |
||
202 | */ |
||
203 | public function __construct($target_date = '', $language = 'japanese', $reload = false) |
||
204 | { |
||
205 | // ���դΥ��å� |
||
206 | if ($target_date) { |
||
207 | $this->set_date($target_date); |
||
208 | } elseif (isset($_GET['caldate'])) { |
||
209 | $this->set_date($_GET['caldate']); |
||
210 | } elseif (isset($_POST['apcal_jumpcaldate']) && isset($_POST['apcal_year'])) { |
||
211 | if (empty($_POST['apcal_month'])) { |
||
212 | // ǯ�Τߤ�POST���줿��� |
||
213 | $month = 1; |
||
214 | $date = 1; |
||
215 | } elseif (empty($_POST['apcal_date'])) { |
||
216 | // ǯ���POST���줿��� |
||
217 | $month = (int)$_POST['apcal_month']; |
||
218 | $date = 1; |
||
219 | } else { |
||
220 | // ǯ�����POST���줿��� |
||
221 | $month = (int)$_POST['apcal_month']; |
||
222 | $date = (int)$_POST['apcal_date']; |
||
223 | } |
||
224 | $year = (int)$_POST['apcal_year']; |
||
225 | $this->set_date("$year-$month-$date"); |
||
226 | $caldate_posted = true; |
||
227 | } else { |
||
228 | $this->set_date(date('Y-n-j')); |
||
229 | $this->use_server_TZ = true; |
||
230 | } |
||
231 | |||
232 | // SSL��Í̵��$_SERVER['HTTPS'] �ˤ�Ƚ�� |
||
233 | if (defined('XOOPS_URL')) { |
||
234 | $this->connection = substr(XOOPS_URL, 0, 8) === 'https://' ? 'https' : 'http'; |
||
235 | } elseif (!empty($_SERVER['HTTPS'])) { |
||
236 | $this->connection = 'https'; |
||
237 | } else { |
||
238 | $this->connection = 'http'; |
||
239 | } |
||
240 | |||
241 | // ���ƥ��꡼����μ��� |
||
242 | $this->now_cid = !empty($_GET['cid']) ? (int)$_GET['cid'] : 0; |
||
243 | |||
244 | // POST�ǥХ�Х�����դ��������줿��硢���꤬����Х�?�ɤ�Ԥ� |
||
245 | if (!empty($caldate_posted) && $reload && !headers_sent()) { |
||
246 | $reload_str = "Location: $this->connection://{$_SERVER['HTTP_HOST']}{$_SERVER['PHP_SELF']}?caldate=$this->caldate&{$_SERVER['QUERY_STRING']}"; |
||
247 | $needed_post_vars = array('op', 'order', 'cid', 'num', 'txt'); |
||
248 | foreach ($needed_post_vars as $post) { |
||
249 | if (isset($_POST[$post])) { |
||
250 | $reload_str .= "&$post=" . urlencode($_POST[$post]); |
||
251 | } |
||
252 | } |
||
253 | $reload_str4header = strtr($reload_str, "\r\n\0", ' '); |
||
254 | header($reload_str4header); |
||
255 | exit; |
||
256 | } |
||
257 | |||
258 | // APCal.php �ե������¸�ߤ���ǥ��쥯�ȥ�ΰ�ľ��١����Ȥ��� |
||
259 | $this->base_path = dirname(__DIR__); |
||
260 | |||
261 | // ����ե�������ɤ߹��� |
||
262 | if (file_exists("$this->base_path/language/$language/apcal_vars.phtml")) { |
||
263 | include "$this->base_path/language/$language/apcal_vars.phtml"; |
||
264 | require_once "$this->base_path/language/$language/apcal_constants.php"; |
||
265 | $this->language = $language; |
||
266 | $this->jscalendar_lang_file = _APCAL_JS_CALENDAR; |
||
267 | } elseif (file_exists("$this->base_path/language/english/apcal_vars.phtml")) { |
||
268 | include "$this->base_path/language/english/apcal_vars.phtml"; |
||
269 | require_once "$this->base_path/language/english/apcal_constants.php"; |
||
270 | $this->language = 'english'; |
||
271 | $this->jscalendar_lang_file = 'calendar-en.js'; |
||
272 | } |
||
273 | |||
274 | // �?����ե�������ɹ� |
||
275 | if (!empty($this->locale)) { |
||
276 | $this->read_locale(); |
||
277 | } |
||
278 | } |
||
279 | |||
280 | /** |
||
281 | * @param string $get_target |
||
282 | * @param string $smode |
||
283 | * @param int $cid |
||
284 | * @param string $caldate |
||
285 | * @return string |
||
286 | */ |
||
287 | public function make_cal_link($get_target = '', $smode = 'Monthly', $cid = 0, $caldate = '') |
||
288 | { |
||
289 | global $xoopsModule; |
||
290 | |||
291 | if ($cid < 0) { |
||
292 | $cid = $this->now_cid; |
||
293 | } |
||
294 | if ($caldate === '') { |
||
295 | $caldate = $this->caldate; |
||
296 | } |
||
297 | if ($smode === '') { |
||
298 | $smode = $this->default_view; |
||
299 | } |
||
300 | |||
301 | $isAllCat = $cid == 0; |
||
302 | $isDefaultView = $smode == $this->default_view; |
||
303 | $isToday = date('Y-n-j') == $caldate; |
||
304 | |||
305 | if ($this->conn) { |
||
306 | $cat = $GLOBALS['xoopsDB']->query("SELECT cat_shorttitle FROM $this->cat_table WHERE cid=$cid LIMIT 0,1"); |
||
307 | } else { |
||
308 | $cat = false; |
||
309 | } |
||
310 | |||
311 | if ($cat && $GLOBALS['xoopsDB']->getRowsNum($cat)) { |
||
312 | $cat = $GLOBALS['xoopsDB']->fetchObject($cat); |
||
313 | $cat = urlencode(urlencode($cat->cat_shorttitle)); |
||
314 | } else { |
||
315 | $cat = isset($xoopsModule) |
||
316 | && !empty($xoopsModule) ? urlencode(urlencode($xoopsModule->getVar('name'))) : 0; |
||
317 | } |
||
318 | |||
319 | if ($this->useurlrewrite) { |
||
320 | if (!$isAllCat && !$isDefaultView && !$isToday) { |
||
321 | $link = XOOPS_URL . "/modules/apcal/$cat-$smode-$caldate"; |
||
322 | View Code Duplication | } elseif (!$isAllCat && !$isDefaultView && $isToday) { |
|
0 ignored issues
–
show
|
|||
323 | $link = XOOPS_URL . "/modules/apcal/$cat-$smode"; |
||
324 | } elseif (!$isAllCat && $isDefaultView && !$isToday) { |
||
325 | $link = XOOPS_URL . "/modules/apcal/$cat-$caldate"; |
||
326 | } elseif (!$isAllCat && $isDefaultView && $isToday) { |
||
327 | $link = XOOPS_URL . "/modules/apcal/$cat"; |
||
328 | View Code Duplication | } elseif ($isAllCat && !$isDefaultView && !$isToday) { |
|
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. ![]() |
|||
329 | $link = XOOPS_URL . "/modules/apcal/$smode-$caldate"; |
||
330 | } elseif ($isAllCat && !$isDefaultView && $isToday) { |
||
331 | $link = XOOPS_URL . "/modules/apcal/$smode"; |
||
332 | } elseif ($isAllCat && $isDefaultView && !$isToday) { |
||
333 | $link = XOOPS_URL . "/modules/apcal/$caldate"; |
||
334 | } else { |
||
335 | $link = XOOPS_URL . '/modules/apcal/'; |
||
336 | } |
||
337 | |||
338 | return $link; |
||
339 | } else { |
||
340 | return ($get_target === '' ? XOOPS_URL . '/modules/apcal/' : $get_target) . "?cid=$cid&smode=$smode&caldate=$caldate"; |
||
341 | } |
||
342 | } |
||
343 | |||
344 | /** |
||
345 | * @param $event_id |
||
346 | * @param string $get_target |
||
347 | * @param string $caldate |
||
348 | * @return string |
||
349 | */ |
||
350 | public function make_event_link($event_id, $get_target = '', $caldate = '') |
||
351 | { |
||
352 | if ($caldate === '') { |
||
353 | $caldate = $this->caldate; |
||
354 | } |
||
355 | |||
356 | $event = $GLOBALS['xoopsDB']->query("SELECT shortsummary, start FROM $this->table WHERE id=$event_id LIMIT 0,1"); |
||
357 | |||
358 | if ($event && $GLOBALS['xoopsDB']->getRowsNum($event)) { |
||
359 | $event = $GLOBALS['xoopsDB']->fetchObject($event); |
||
360 | $date = date('j-n-Y', $event->start); |
||
361 | $event = urlencode(urlencode($event->shortsummary)); |
||
362 | } else { |
||
363 | $event = $event_id; |
||
364 | $date = $caldate !== '' ? date('j-n-Y', strtotime($caldate)) : date('j-n-Y'); |
||
365 | } |
||
366 | |||
367 | if ($this->useurlrewrite) { |
||
368 | return XOOPS_URL . "/modules/apcal/$event-$date"; |
||
369 | } else { |
||
370 | return ($get_target === '' ? XOOPS_URL . '/modules/apcal/' : $get_target) . "?event_id=$event_id&action=View&caldate=$caldate"; |
||
371 | } |
||
372 | } |
||
373 | |||
374 | /** |
||
375 | * @param $str |
||
376 | * @return mixed |
||
377 | */ |
||
378 | public function urlencode($str) |
||
379 | { |
||
380 | $str = urlencode($str); |
||
381 | |||
382 | return str_replace(array('%26', '3D'), array('&', '='), $str); |
||
383 | } |
||
384 | |||
385 | /** |
||
386 | * @param $str |
||
387 | * @return mixed |
||
388 | */ |
||
389 | public function makeShort($str) |
||
390 | { |
||
391 | $replacements = array( |
||
392 | 'Ä' => 'Ae', |
||
393 | 'Ü' => 'Ue', |
||
394 | 'Ö' => 'Oe', |
||
395 | 'ä' => 'ae', |
||
396 | 'ö' => 'oe', |
||
397 | 'ü' => 'ue', |
||
398 | 'ß' => 'sz', |
||
399 | 'Å ' => 'S', |
||
400 | 'Å¡' => 's', |
||
401 | 'Ž' => 'Z', |
||
402 | 'ž' => 'z', |
||
403 | 'À' => 'A', |
||
404 | '�' => 'A', |
||
405 | 'Â' => 'A', |
||
406 | 'Ã' => 'A', |
||
407 | 'Ä' => 'A', |
||
408 | 'Ã…' => 'A', |
||
409 | 'Æ' => 'A', |
||
410 | 'Ç' => 'C', |
||
411 | 'È' => 'E', |
||
412 | 'É' => 'E', |
||
413 | 'Ê' => 'E', |
||
414 | 'Ë' => 'E', |
||
415 | 'Ì' => 'I', |
||
416 | '�' => 'I', |
||
417 | 'ÃŽ' => 'I', |
||
418 | '�' => 'I', |
||
419 | 'Ñ' => 'N', |
||
420 | 'Ã’' => 'O', |
||
421 | 'Ó' => 'O', |
||
422 | 'Ô' => 'O', |
||
423 | 'Õ' => 'O', |
||
424 | 'Ö' => 'O', |
||
425 | 'Ø' => 'O', |
||
426 | 'Ù' => 'U', |
||
427 | 'Ú' => 'U', |
||
428 | 'Û' => 'U', |
||
429 | 'Ü' => 'U', |
||
430 | '�' => 'Y', |
||
431 | 'Þ' => 'B', |
||
432 | 'ß' => 'Ss', |
||
433 | 'Ã ' => 'a', |
||
434 | 'á' => 'a', |
||
435 | 'â' => 'a', |
||
436 | 'ã' => 'a', |
||
437 | 'ä' => 'a', |
||
438 | 'Ã¥' => 'a', |
||
439 | 'æ' => 'a', |
||
440 | 'ç' => 'c', |
||
441 | 'è' => 'e', |
||
442 | 'é' => 'e', |
||
443 | 'ê' => 'e', |
||
444 | 'ë' => 'e', |
||
445 | 'ì' => 'i', |
||
446 | 'Ã' => 'i', |
||
447 | 'î' => 'i', |
||
448 | 'ï' => 'i', |
||
449 | 'ð' => 'o', |
||
450 | 'ñ' => 'n', |
||
451 | 'ò' => 'o', |
||
452 | 'ó' => 'o', |
||
453 | 'ô' => 'o', |
||
454 | 'õ' => 'o', |
||
455 | 'ö' => 'o', |
||
456 | 'ø' => 'o', |
||
457 | 'ù' => 'u', |
||
458 | 'ú' => 'u', |
||
459 | 'û' => 'u', |
||
460 | 'ý' => 'y', |
||
461 | 'ý' => 'y', |
||
462 | 'þ' => 'b', |
||
463 | 'ÿ' => 'y' |
||
464 | ); |
||
465 | |||
466 | $str = utf8_encode(strtr($str, $replacements)); |
||
467 | $str = strip_tags($str); |
||
468 | |||
469 | return str_replace(array(' ', '-', '/', "\\", "'", '"', "\r", "\n", '&', '?', '!', '%', ',', '.'), '', $str); |
||
470 | } |
||
471 | |||
472 | // APCal���ѥ?����ե�������ɤ߹��� |
||
473 | public function read_locale() |
||
474 | { |
||
475 | if (file_exists("$this->base_path/locales/{$this->locale}.php")) { |
||
476 | include "$this->base_path/locales/{$this->locale}.php"; |
||
477 | } |
||
478 | } |
||
479 | |||
480 | // year,month,day,caldate,unixtime �򥻥åȤ��� |
||
481 | |||
482 | /** |
||
483 | * @param $setdate |
||
484 | */ |
||
485 | public function set_date($setdate) |
||
486 | { |
||
487 | if (!(preg_match("/^([0-9][0-9]+)[-.\/]?([0-1]?[0-9])[-.\/]?([0-3]?[0-9])$/", $setdate, $regs) |
||
488 | && checkdate($regs[2], $regs[3], $regs[1])) |
||
489 | ) { |
||
490 | preg_match('/^([0-9]{4})-([0-9]{2})-([0-9]{2})$/', date('Y-m-d'), $regs); |
||
491 | $this->use_server_TZ = true; |
||
492 | } |
||
493 | $this->year = $year = (int)$regs[1]; |
||
494 | $this->month = $month = (int)$regs[2]; |
||
495 | $this->date = $date = (int)$regs[3]; |
||
496 | $this->caldate = "$year-$month-$date"; |
||
497 | $this->unixtime = mktime(0, 0, 0, $month, $date, $year); |
||
498 | |||
499 | // ��������ե����פΥ��å� |
||
500 | // �ĥ��顼�θ� |
||
501 | if ($month <= 2) { |
||
502 | $year--; |
||
503 | $month += 12; |
||
504 | } |
||
505 | $day = ($year + floor($year / 4) - floor($year / 100) + floor($year / 400) + floor(2.6 * $month + 1.6) + $date) % 7; |
||
506 | |||
507 | $this->day = $day; |
||
508 | if ($day == 0) { |
||
509 | $this->daytype = 2; |
||
510 | } elseif ($day == 6) { |
||
511 | $this->daytype = 1; |
||
512 | } else { |
||
513 | $this->daytype = 0; |
||
514 | } |
||
515 | |||
516 | if (isset($this->holidays[$this->caldate])) { |
||
517 | $this->daytype = 3; |
||
518 | } |
||
519 | } |
||
520 | |||
521 | // �������μ��फ���طʿ���ʸ������� |
||
522 | |||
523 | /** |
||
524 | * @param $daytype |
||
525 | * @return array |
||
526 | */ |
||
527 | public function daytype_to_colors($daytype) |
||
528 | { |
||
529 | switch ($daytype) { |
||
530 | case 3: |
||
531 | // Holiday |
||
532 | return array($this->holiday_bgcolor, $this->holiday_color); |
||
533 | case 2: |
||
534 | // Sunday |
||
535 | return array($this->sunday_bgcolor, $this->sunday_color); |
||
536 | case 1: |
||
537 | // Saturday |
||
538 | return array($this->saturday_bgcolor, $this->saturday_color); |
||
539 | case 0: |
||
540 | default: |
||
541 | // Weekday |
||
542 | return array($this->weekday_bgcolor, $this->weekday_color); |
||
543 | } |
||
544 | } |
||
545 | |||
546 | // SQL���������դ��顢�������μ������륯�饹�ؿ� |
||
547 | |||
548 | /** |
||
549 | * @param $date |
||
550 | * @return int |
||
551 | */ |
||
552 | public function get_daytype($date) |
||
553 | { |
||
554 | preg_match("/^([0-9][0-9]+)[-.\/]?([0-1]?[0-9])[-.\/]?([0-3]?[0-9])$/", $date, $regs); |
||
555 | $year = (int)$regs[1]; |
||
556 | $month = (int)$regs[2]; |
||
557 | $date = (int)$regs[3]; |
||
558 | |||
559 | // �����3 |
||
560 | if (isset($this->holidays["$year-$month-$date"])) { |
||
561 | return 3; |
||
562 | } |
||
563 | |||
564 | // �ĥ��顼�θ� |
||
565 | if ($month <= 2) { |
||
566 | $year--; |
||
567 | $month += 12; |
||
568 | } |
||
569 | $day = ($year + floor($year / 4) - floor($year / 100) + floor($year / 400) + floor(2.6 * $month + 1.6) + $date) % 7; |
||
570 | |||
571 | if ($day == 0) { |
||
572 | return 2; |
||
573 | } elseif ($day == 6) { |
||
574 | return 1; |
||
575 | } else { |
||
576 | return 0; |
||
577 | } |
||
578 | } |
||
579 | |||
580 | /*******************************************************************/ |
||
581 | /* �֥�å���ɽ���ؿ� */ |
||
582 | /*******************************************************************/ |
||
583 | |||
584 | // $this->caldate���ͽ�� ���֤� |
||
585 | /** |
||
586 | * @param string $get_target |
||
587 | * @return string |
||
588 | */ |
||
589 | public function get_date_schedule($get_target = '') |
||
590 | { |
||
591 | // if( $get_target == '' ) $get_target = $_SERVER['SCRIPT_NAME'] ; |
||
592 | |||
593 | $ret = ''; |
||
594 | |||
595 | // ������׻����Ĥġ�WHERE��δ�֤˴ؤ��������� |
||
596 | $tzoffset = ($this->user_TZ - $this->server_TZ) * 3600; |
||
597 | if ($tzoffset == 0) { |
||
598 | // �������ʤ���� ��MySQL����٤򤫤������ʤ����ᡢ�����Ǿ��ʬ�����Ȥ�) |
||
599 | $whr_term = "start<'" . ($this->unixtime + 86400) . "' AND end>'$this->unixtime'"; |
||
600 | } else { |
||
601 | // ������������ϡ�allday�ˤ�äƾ��ʬ�� |
||
602 | $whr_term = "( allday AND start<='$this->unixtime' AND end>'$this->unixtime') || ( ! allday AND start<'" . ($this->unixtime + 86400 - $tzoffset) . "' AND end>'" . ($this->unixtime |
||
603 | - $tzoffset) . "')"; |
||
604 | } |
||
605 | |||
606 | // ���ƥ��꡼��Ϣ��WHERE������ |
||
607 | $whr_categories = $this->get_where_about_categories(); |
||
608 | |||
609 | // CLASS��Ϣ��WHERE������ |
||
610 | $whr_class = $this->get_where_about_class(); |
||
611 | |||
612 | // ����Υ������塼����� |
||
613 | $yrs = $GLOBALS['xoopsDB']->query("SELECT start,end,summary,id,allday FROM $this->table WHERE admission>0 AND ($whr_term) AND ($whr_categories) AND ($whr_class) ORDER BY start,end"); |
||
614 | $num_rows = $GLOBALS['xoopsDB']->getRowsNum($yrs); |
||
615 | |||
616 | if ($num_rows == 0) { |
||
617 | $ret .= _APCAL_MB_NOEVENT . "\n"; |
||
618 | } else { |
||
619 | while ($event = $GLOBALS['xoopsDB']->fetchObject($yrs)) { |
||
620 | $summary = $this->text_sanitizer_for_show($event->summary); |
||
621 | |||
622 | if ($event->allday) { |
||
623 | // ����٥�� |
||
624 | $ret .= " |
||
625 | <table border='0' cellpadding='0' cellspacing='0' width='100%'> |
||
626 | <tr> |
||
627 | <td><img border='0' src='$this->images_url/dot_allday.gif' /> </td> |
||
628 | <td><span style='font-size: x-small; '><a href='$get_target?cid=$this->now_cid&smode=Daily&action=View&event_id=$event->id&caldate=$this->caldate' class='calsummary_allday'>$summary</a></span></td> |
||
629 | </tr> |
||
630 | </table>\n"; |
||
631 | } else { |
||
632 | // �̾磻�٥�� |
||
633 | $event->start += $tzoffset; |
||
634 | $event->end += $tzoffset; |
||
635 | $ret .= " |
||
636 | <dl> |
||
637 | <dt> |
||
638 | <span style='font-size: x-small; '>" . $this->get_todays_time_description($event->start, $event->end, $this->caldate, false, true) . "</span> |
||
639 | </dt> |
||
640 | <dd> |
||
641 | <span style='font-size: x-small; '><a href='$get_target?cid=$this->now_cid&smode=Daily&action=View&event_id=$event->id&caldate=$this->caldate' class='calsummary'>$summary</a></span> |
||
642 | </dd> |
||
643 | </dl>\n"; |
||
644 | } |
||
645 | } |
||
646 | } |
||
647 | |||
648 | // ͽ����ɲáʱ�ɮ��������� |
||
649 | View Code Duplication | if ($this->insertable) { |
|
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. ![]() |
|||
650 | $ret .= " |
||
651 | <dl> |
||
652 | <dt> |
||
653 | <span style='font-size: x-small; '><a href='$get_target?smode=Daily&action=Edit&caldate=$this->caldate'><img src='$this->images_url/addevent.gif' border='0' width='14' height='12' />" |
||
654 | . _APCAL_MB_ADDEVENT |
||
655 | . "</a></span> |
||
656 | </dt> |
||
657 | </dl>\n"; |
||
658 | } |
||
659 | |||
660 | return $ret; |
||
661 | } |
||
662 | |||
663 | // $this->caldate�ʹߤ�ͽ�� ����� $num ���֤� |
||
664 | |||
665 | /** |
||
666 | * @param string $get_target |
||
667 | * @param int $num |
||
668 | * @return string |
||
669 | */ |
||
670 | public function get_coming_schedule($get_target = '', $num = 5) |
||
671 | { |
||
672 | // if( $get_target == '' ) $get_target = $_SERVER['SCRIPT_NAME'] ; |
||
673 | |||
674 | $ret = ''; |
||
675 | |||
676 | // ������׻����Ĥġ�WHERE��δ�֤˴ؤ��������� |
||
677 | $tzoffset = ($this->user_TZ - $this->server_TZ) * 3600; |
||
678 | if ($tzoffset == 0) { |
||
679 | // �������ʤ���� ��MySQL����٤򤫤������ʤ����ᡢ�����Ǿ��ʬ�����Ȥ�) |
||
680 | $whr_term = "end>'$this->unixtime'"; |
||
681 | } else { |
||
682 | // ������������ϡ�allday�ˤ�äƾ��ʬ�� |
||
683 | $whr_term = "(allday AND end>'$this->unixtime') || ( ! allday AND end>'" . ($this->unixtime - $tzoffset) . "')"; |
||
684 | } |
||
685 | |||
686 | // ���ƥ��꡼��Ϣ��WHERE������ |
||
687 | $whr_categories = $this->get_where_about_categories(); |
||
688 | |||
689 | // CLASS��Ϣ��WHERE������ |
||
690 | $whr_class = $this->get_where_about_class(); |
||
691 | |||
692 | // ����ʹߤΥ������塼����� |
||
693 | $yrs = $GLOBALS['xoopsDB']->query("SELECT start,end,summary,id,allday FROM $this->table WHERE admission>0 AND ($whr_term) AND ($whr_categories) AND ($whr_class) ORDER BY start"); |
||
694 | $num_rows = $GLOBALS['xoopsDB']->getRowsNum($yrs); |
||
695 | |||
696 | if ($num_rows == 0) { |
||
697 | $ret .= _APCAL_MB_NOEVENT . "\n"; |
||
698 | } else { |
||
699 | for ($i = 0; $i < $num; ++$i) { |
||
700 | $event = $GLOBALS['xoopsDB']->fetchObject($yrs); |
||
701 | if ($event === false) { |
||
702 | break; |
||
703 | } |
||
704 | $summary = $this->text_sanitizer_for_show($event->summary); |
||
705 | |||
706 | if ($event->allday) { |
||
707 | // ����٥�� |
||
708 | $ret .= " |
||
709 | <dl> |
||
710 | <dt> |
||
711 | <span style='font-size: x-small; '><img border='0' src='$this->images_url/dot_allday.gif' /> " . $this->get_middle_md($event->start) . "</span> |
||
712 | </dt> |
||
713 | <dd> |
||
714 | <span style='font-size: x-small; '><a href='$get_target?cid=$this->now_cid&smode=Daily&action=View&event_id=$event->id&caldate=$this->caldate' class='calsummary_allday'>$summary</a></span> |
||
715 | </dd> |
||
716 | </dl>\n"; |
||
717 | } else { |
||
718 | // �̾磻�٥�� |
||
719 | $event->start += $tzoffset; |
||
720 | $event->end += $tzoffset; |
||
721 | $ret .= " |
||
722 | <dl> |
||
723 | <dt> |
||
724 | <span style='font-size: x-small; '>" . $this->get_coming_time_description($event->start, $this->unixtime) . "</span> |
||
725 | </dt> |
||
726 | <dd> |
||
727 | <span style='font-size: x-small; '><a href='$get_target?cid=$this->now_cid&smode=Daily&action=View&event_id=$event->id&caldate=$this->caldate' class='calsummary'>$summary</a></span> |
||
728 | </dd> |
||
729 | </dl>\n"; |
||
730 | } |
||
731 | } |
||
732 | } |
||
733 | |||
734 | // �Ĥ�����ɽ�� |
||
735 | if ($num_rows > $num) { |
||
736 | $ret .= " |
||
737 | <table border='0' cellspacing='0' cellpadding='0' width='100%'> |
||
738 | <tr> |
||
739 | <td align='right'><small>" . _APCAL_MB_RESTEVENT_PRE . ($num_rows - $num) . _APCAL_MB_RESTEVENT_SUF . "</small></td> |
||
740 | </tr> |
||
741 | </table>\n"; |
||
742 | } |
||
743 | |||
744 | // ͽ����ɲáʱ�ɮ��������� |
||
745 | View Code Duplication | if ($this->insertable) { |
|
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. ![]() |
|||
746 | $ret .= " |
||
747 | <dl> |
||
748 | <dt> |
||
749 | <span style='font-size: x-small; '><a href='$get_target?smode=Daily&action=Edit&caldate=$this->caldate'><img src='$this->images_url/addevent.gif' border='0' width='14' height='12' />" |
||
750 | . _APCAL_MB_ADDEVENT |
||
751 | . "</a></span> |
||
752 | </dt> |
||
753 | </dl>\n"; |
||
754 | } |
||
755 | |||
756 | return $ret; |
||
757 | } |
||
758 | |||
759 | // �ߥ˥��������ѥ��٥�ȼ����ؿ� |
||
760 | |||
761 | /** |
||
762 | * @param $range_start_s |
||
763 | * @param $range_end_s |
||
764 | * @param string $mode |
||
765 | * @return mixed |
||
766 | */ |
||
767 | public function get_flags_date_has_events($range_start_s, $range_end_s, $mode = '') |
||
768 | { |
||
769 | // ���餫����������������Ƥ��� |
||
770 | /* for ($time = $start ; $time < $end ; $time += 86400) { |
||
771 | $ret[ date( 'j' , $time ) ] = 0 ; |
||
772 | } */ |
||
773 | for ($i = 0; $i <= 31; ++$i) { |
||
774 | $ret[$i] = 0; |
||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
$ret was never initialized. Although not strictly required by PHP, it is generally a good practice to add $ret = array(); before regardless.
Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code. Let’s take a look at an example: foreach ($collection as $item) {
$myArray['foo'] = $item->getFoo();
if ($item->hasBar()) {
$myArray['bar'] = $item->getBar();
}
// do something with $myArray
}
As you can see in this example, the array This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop. ![]() |
|||
775 | } |
||
776 | |||
777 | // add margin -86400 and +86400 |
||
778 | $range_start_s -= 86400; |
||
779 | $range_end_s += 86400; |
||
780 | |||
781 | // �����׻� |
||
782 | $tzoffset_s2u = (int)(($this->user_TZ - $this->server_TZ) * 3600); |
||
783 | //$gmtoffset = (int)( $this->server_TZ * 3600 ) ; |
||
784 | |||
785 | // ���ƥ��꡼��Ϣ��WHERE������ |
||
786 | $whr_categories = $this->get_where_about_categories(); |
||
787 | |||
788 | // CLASS��Ϣ��WHERE������ |
||
789 | $whr_class = $this->get_where_about_class(); |
||
790 | |||
791 | /* $yrs = mysqli_query( "SELECT start,end,allday FROM $this->table WHERE admission > 0 AND start < ".($end + 86400)." AND end > ".($start - 86400)." AND ($whr_categories) AND ($whr_class)" , $this->conn ) ; |
||
792 | while ( $event = $xoopsDB->fetchObject( $yrs ) ) { |
||
793 | $time = $event->start > $start ? $event->start : $start ; |
||
794 | if (! $event->allday) { |
||
795 | $time += $tzoffset ; |
||
796 | $event->end += $tzoffset ; |
||
797 | } |
||
798 | $time -= ( $time + $gmtoffset ) % 86400 ; |
||
799 | while ($time < $end && $time < $event->end) { |
||
800 | $ret[ date( 'j' , $time ) ] = 1 ; |
||
801 | $time += 86400 ; |
||
802 | } |
||
803 | }*/ |
||
804 | |||
805 | // ����٥�Ȱʳ��ν��� |
||
806 | $result = $GLOBALS['xoopsDB']->query("SELECT summary,id,start,location,contact,gmlat,gmlong FROM $this->table WHERE admission > 0 AND start >= $range_start_s AND start < $range_end_s AND ($whr_categories) AND ($whr_class) AND allday <= 0"); |
||
807 | while (list($title, $id, $server_time, $location, $contact, $gmlat, $gmlong) = $GLOBALS['xoopsDB']->fetchRow($result)) { |
||
808 | View Code Duplication | if ($mode === 'NO_YEAR' && ($gmlat > 0 || $gmlong > 0)) { |
|
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. ![]() |
|||
809 | $this->gmPoints[] = array( |
||
810 | 'summary' => $title, |
||
811 | 'gmlat' => $gmlat, |
||
812 | 'gmlong' => $gmlong, |
||
813 | 'location' => $location, |
||
814 | 'contact' => $contact, |
||
815 | 'startDate' => date('j', $server_time), |
||
816 | 'event_id' => $id |
||
817 | ); |
||
818 | } |
||
819 | $user_time = $server_time + $tzoffset_s2u; |
||
820 | if (date('n', $user_time) != $this->month) { |
||
821 | continue; |
||
822 | } |
||
823 | $ret[date('j', $user_time)] = 1; |
||
0 ignored issues
–
show
The variable
$ret does not seem to be defined for all execution paths leading up to this point.
If you define a variable conditionally, it can happen that it is not defined for all execution paths. Let’s take a look at an example: function myFunction($a) {
switch ($a) {
case 'foo':
$x = 1;
break;
case 'bar':
$x = 2;
break;
}
// $x is potentially undefined here.
echo $x;
}
In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined. Available Fixes
![]() |
|||
824 | } |
||
825 | |||
826 | // ����٥�����Ѥν��� |
||
827 | $result = $GLOBALS['xoopsDB']->query("SELECT summary,id,start,end,location,contact,gmlat,gmlong FROM $this->table WHERE admission > 0 AND start >= $range_start_s AND start < $range_end_s AND ($whr_categories) AND ($whr_class) AND allday > 0"); |
||
828 | |||
829 | while (list($title, $id, $start_s, $end_s, $location, $contact, $gmlat, $gmlong) = $GLOBALS['xoopsDB']->fetchRow($result)) { |
||
830 | if ($start_s < $range_start_s) { |
||
831 | $start_s = $range_start_s; |
||
832 | } |
||
833 | if ($end_s > $range_end_s) { |
||
834 | $end_s = $range_end_s; |
||
835 | } |
||
836 | |||
837 | while ($start_s < $end_s) { |
||
838 | $user_time = $start_s + $tzoffset_s2u; |
||
839 | if (date('n', $user_time) == $this->month) { |
||
840 | View Code Duplication | if ($mode === 'NO_YEAR' && ($gmlat > 0 || $gmlong > 0)) { |
|
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. ![]() |
|||
841 | $this->gmPoints[] = array( |
||
842 | 'summary' => $title, |
||
843 | 'gmlat' => $gmlat, |
||
844 | 'gmlong' => $gmlong, |
||
845 | 'location' => $location, |
||
846 | 'contact' => $contact, |
||
847 | 'startDate' => date('j', $user_time), |
||
848 | 'event_id' => $id |
||
849 | ); |
||
850 | } |
||
851 | $ret[date('j', $user_time)] = 1; |
||
852 | } |
||
853 | $start_s += 86400; |
||
854 | } |
||
855 | } |
||
856 | |||
857 | return $ret; |
||
858 | } |
||
859 | |||
860 | // �ߥ˥�������ɽ����ʸ������֤� |
||
861 | |||
862 | /** |
||
863 | * @param string $get_target |
||
864 | * @param string $query_string |
||
865 | * @param string $mode |
||
866 | * @return string |
||
867 | */ |
||
868 | public function get_mini_calendar_html($get_target = '', $query_string = '', $mode = '') |
||
869 | { |
||
870 | // �¹Ի��ַ�¬�������� |
||
871 | // list( $usec , $sec ) = explode( " " , microtime() ) ; |
||
872 | // $apcalstarttime = $sec + $usec ; |
||
873 | |||
874 | // $PHP_SELF = $_SERVER['SCRIPT_NAME'] ; |
||
875 | // if( $get_target == '' ) $get_target = $PHP_SELF ; |
||
876 | |||
877 | require_once "$this->base_path/include/patTemplate.php"; |
||
878 | $tmpl = new PatTemplate(); |
||
879 | $tmpl->setBasedir("$this->images_path"); |
||
880 | |||
881 | // ɽ���⡼�ɤ˱����ơ��ƥ�ץ졼�ȥե�����򿶤�ʬ�� |
||
882 | switch ($mode) { |
||
883 | case 'NO_YEAR': |
||
884 | // ǯ��ɽ���� |
||
885 | $tmpl->readTemplatesFromFile('minical_for_yearly.tmpl.html'); |
||
886 | $target_highlight_flag = false; |
||
887 | break; |
||
888 | case 'NO_NAVIGATE': |
||
889 | // ��֤β��������� |
||
890 | $tmpl->readTemplatesFromFile('minical_for_monthly.tmpl.html'); |
||
891 | $target_highlight_flag = false; |
||
892 | break; |
||
893 | default: |
||
894 | // �̾�Υߥ˥��������֥�å��� |
||
895 | $tmpl->readTemplatesFromFile('minical.tmpl.html'); |
||
896 | $target_highlight_flag = true; |
||
897 | break; |
||
898 | } |
||
899 | |||
900 | // ����γ���٥�Ȥ��äƤ��뤫�ɤ�������� |
||
901 | $event_dates = $this->get_flags_date_has_events(mktime(0, 0, 0, $this->month, 1, $this->year), mktime(0, 0, 0, $this->month + 1, 1, $this->year), $mode); |
||
902 | |||
903 | // ����Ϸ��������Ϸ��Ȥ��� |
||
904 | $prev_month = date('Y-n-j', mktime(0, 0, 0, $this->month, 0, $this->year)); |
||
905 | $next_month = date('Y-n-j', mktime(0, 0, 0, $this->month + 1, 1, $this->year)); |
||
906 | |||
907 | // $tmpl->addVar( "WholeBoard" , "PHP_SELF" , '' ) ; |
||
908 | $tmpl->addVar('WholeBoard', 'DAY_URL', substr($this->make_cal_link($get_target, 'Monthly', $this->now_cid, ' '), 0, -1)); |
||
909 | $tmpl->addVar('WholeBoard', 'GET_TARGET', $get_target); |
||
910 | $tmpl->addVar('WholeBoard', 'QUERY_STRING', $query_string); |
||
911 | |||
912 | $tmpl->addVar('WholeBoard', 'MB_PREV_MONTH', _APCAL_MB_PREV_MONTH); |
||
913 | $tmpl->addVar('WholeBoard', 'MB_NEXT_MONTH', _APCAL_MB_NEXT_MONTH); |
||
914 | $tmpl->addVar('WholeBoard', 'MB_LINKTODAY', _APCAL_MB_LINKTODAY); |
||
915 | |||
916 | $tmpl->addVar('WholeBoard', 'SKINPATH', $this->images_url); |
||
917 | $tmpl->addVar('WholeBoard', 'FRAME_CSS', $this->frame_css); |
||
918 | // $tmpl->addVar( "WholeBoard" , "YEAR" , $this->year ) ; |
||
919 | // $tmpl->addVar( "WholeBoard" , "MONTH" , $this->month ) ; |
||
920 | $tmpl->addVar('WholeBoard', 'MONTH_NAME', $this->month_middle_names[$this->month]); |
||
921 | $tmpl->addVar('WholeBoard', 'YEAR_MONTH_TITLE', sprintf(_APCAL_FMT_YEAR_MONTH, $this->year, $this->month_middle_names[$this->month])); |
||
922 | $tmpl->addVar('WholeBoard', 'PREV_MONTH', $prev_month); |
||
923 | $tmpl->addVar('WholeBoard', 'NEXT_MONTH', $next_month); |
||
924 | |||
925 | $tmpl->addVar('WholeBoard', 'CALHEAD_BGCOLOR', $this->calhead_bgcolor); |
||
926 | $tmpl->addVar('WholeBoard', 'CALHEAD_COLOR', $this->calhead_color); |
||
927 | |||
928 | $first_date = getdate(mktime(0, 0, 0, $this->month, 1, $this->year)); |
||
929 | $date = (-$first_date['wday'] + $this->week_start - 7) % 7; |
||
930 | $wday_end = 7 + $this->week_start; |
||
931 | |||
932 | // ����̾�롼�� |
||
933 | $rows = array(); |
||
934 | View Code Duplication | for ($wday = $this->week_start; $wday < $wday_end; ++$wday) { |
|
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. ![]() |
|||
935 | if ($wday % 7 == 0) { |
||
936 | // Sunday |
||
937 | $bgcolor = $this->sunday_bgcolor; |
||
938 | $color = $this->sunday_color; |
||
939 | } elseif ($wday == 6) { |
||
940 | // Saturday |
||
941 | $bgcolor = $this->saturday_bgcolor; |
||
942 | $color = $this->saturday_color; |
||
943 | } else { |
||
944 | // Weekday |
||
945 | $bgcolor = $this->weekday_bgcolor; |
||
946 | $color = $this->weekday_color; |
||
947 | } |
||
948 | |||
949 | // �ƥ�ץ졼��������ؤΥǡ������å� |
||
950 | array_push($rows, array( |
||
951 | 'BGCOLOR' => $bgcolor, |
||
952 | 'COLOR' => $color, |
||
953 | 'DAYNAME' => $this->week_short_names[$wday % 7] |
||
954 | )); |
||
955 | } |
||
956 | |||
957 | // �ƥ�ץ졼�Ȥ˥ǡ����������� |
||
958 | $tmpl->addRows('DayNameLoop', $rows); |
||
959 | $tmpl->parseTemplate('DayNameLoop', 'w'); |
||
960 | |||
961 | // �� (row) �롼�� |
||
962 | for ($week = 0; $week < 6; ++$week) { |
||
963 | $rows = array(); |
||
964 | |||
965 | // �� (col) �롼�� |
||
966 | for ($wday = $this->week_start; $wday < $wday_end; ++$wday) { |
||
967 | ++$date; |
||
968 | if (!checkdate($this->month, $date, $this->year)) { |
||
969 | // ����ϰϳ� |
||
970 | array_push($rows, array( |
||
971 | 'GET_TARGET' => $get_target, |
||
972 | 'QUERY_STRING' => $query_string, |
||
973 | 'SKINPATH' => $this->images_url, |
||
974 | 'DATE' => date('j', mktime(0, 0, 0, $this->month, $date, $this->year)), |
||
975 | 'DATE_TYPE' => 0 |
||
976 | )); |
||
977 | continue; |
||
978 | } |
||
979 | |||
980 | $link = "$this->year-$this->month-$date"; |
||
981 | |||
982 | // ����פˤ�����迧����ʬ�� |
||
983 | View Code Duplication | if (isset($this->holidays[$link])) { |
|
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. ![]() |
|||
984 | // Holiday |
||
985 | $bgcolor = $this->holiday_bgcolor; |
||
986 | $color = $this->holiday_color; |
||
987 | } elseif ($wday % 7 == 0) { |
||
988 | // Sunday |
||
989 | $bgcolor = $this->sunday_bgcolor; |
||
990 | $color = $this->sunday_color; |
||
991 | } elseif ($wday == 6) { |
||
992 | // Saturday |
||
993 | $bgcolor = $this->saturday_bgcolor; |
||
994 | $color = $this->saturday_color; |
||
995 | } else { |
||
996 | // Weekday |
||
997 | $bgcolor = $this->weekday_bgcolor; |
||
998 | $color = $this->weekday_color; |
||
999 | } |
||
1000 | |||
1001 | // ��������طʿ��ϥ��饤�Ƚ��� |
||
1002 | if ($date == $this->date && $target_highlight_flag) { |
||
1003 | $bgcolor = $this->targetday_bgcolor; |
||
1004 | } |
||
1005 | |||
1006 | // �ƥ�ץ졼��������ؤΥǡ������å� |
||
1007 | array_push($rows, array( |
||
1008 | 'GET_TARGET' => $get_target, |
||
1009 | 'QUERY_STRING' => $query_string, |
||
1010 | 'DAY_URL' => substr($this->make_cal_link($get_target, ($mode === 'NO_YEAR' ? 'Daily' : 'Monthly'), $this->now_cid, ' '), 0, -1), |
||
1011 | |||
1012 | 'BGCOLOR' => $bgcolor, |
||
1013 | 'COLOR' => $color, |
||
1014 | 'LINK' => $link, |
||
1015 | 'DATE' => $date, |
||
1016 | 'DATE_TYPE' => $event_dates[$date] + 1 |
||
1017 | )); |
||
1018 | } |
||
1019 | // �ƥ�ץ졼�Ȥ˥ǡ����������� |
||
1020 | $tmpl->addRows('DailyLoop', $rows); |
||
1021 | $tmpl->parseTemplate('DailyLoop', 'w'); |
||
1022 | $tmpl->parseTemplate('WeekLoop', 'a'); |
||
1023 | } |
||
1024 | |||
1025 | $ret = $tmpl->getParsedTemplate(); |
||
1026 | |||
1027 | // �¹Ի��ֵ�Ͽ |
||
1028 | // list( $usec , $sec ) = explode( " " , microtime() ) ; |
||
1029 | // error_log( "MiniCalendar " . ( $sec + $usec - $apcalstarttime ) . "sec." , 0 ) ; |
||
1030 | return $ret; |
||
1031 | } |
||
1032 | |||
1033 | /*******************************************************************/ |
||
1034 | /* �ᥤ����ɽ���ؿ� */ |
||
1035 | /*******************************************************************/ |
||
1036 | |||
1037 | // ǯ�֥����������Τ�ɽ����patTemplate����) |
||
1038 | /** |
||
1039 | * @param string $get_target |
||
1040 | * @param string $query_string |
||
1041 | * @param bool $for_print |
||
1042 | * @return string |
||
1043 | */ |
||
1044 | public function get_yearly($get_target = '', $query_string = '', $for_print = false) |
||
1045 | { |
||
1046 | // $PHP_SELF = $_SERVER['SCRIPT_NAME'] ; |
||
1047 | // if( $get_target == '' ) $get_target = $PHP_SELF ; |
||
1048 | |||
1049 | require_once "$this->base_path/include/patTemplate.php"; |
||
1050 | $tmpl = new PatTemplate(); |
||
1051 | $tmpl->readTemplatesFromFile("$this->images_path/yearly.tmpl.html"); |
||
1052 | |||
1053 | // setting skin folder |
||
1054 | $tmpl->addVar('WholeBoard', 'SKINPATH', $this->images_url); |
||
1055 | |||
1056 | // Static parameter for the request |
||
1057 | $tmpl->addVar('WholeBoard', 'GET_TARGET', $get_target); |
||
1058 | $tmpl->addVar('WholeBoard', 'QUERY_STRING', $query_string); |
||
1059 | $tmpl->addVar('WholeBoard', 'PRINT_LINK', "$this->base_url/print.php?cid=$this->now_cid&smode=Yearly&caldate=$this->caldate"); |
||
1060 | $tmpl->addVar('WholeBoard', 'LANG_PRINT', _APCAL_BTN_PRINT); |
||
1061 | if ($for_print) { |
||
1062 | $tmpl->addVar('WholeBoard', 'PRINT_ATTRIB', "width='0' height='0'"); |
||
1063 | } |
||
1064 | |||
1065 | $jumpScript = "<script type='text/javascript'>\n"; |
||
1066 | $jumpScript .= "function submitCat(cid, smode, caldate)\n"; |
||
1067 | $jumpScript .= "{\n"; |
||
1068 | if ($this->useurlrewrite) { |
||
1069 | $jumpScript .= "document.selectDate.action = '" . XOOPS_URL . "/' + cid + '/' + smode + '/' + caldate;\n"; |
||
1070 | $jumpScript .= "document.selectDate.method = 'POST';\n"; |
||
1071 | } |
||
1072 | $jumpScript .= "return true;\n"; |
||
1073 | $jumpScript .= "}\n"; |
||
1074 | $jumpScript .= "</script>\n"; |
||
1075 | |||
1076 | $prevYear = date('Y-n-j', mktime(0, 0, 0, $this->month, $this->date, $this->year - 1)); |
||
1077 | $nextYear = date('Y-n-j', mktime(0, 0, 0, $this->month, $this->date, $this->year + 1)); |
||
1078 | $tmpl->addVar('WholeBoard', 'JUMPLINK', $this->make_cal_link($get_target, 'Yearly', $this->now_cid, date('Y-n-j'))); |
||
1079 | $tmpl->addVar('WholeBoard', 'TODAYLINK', $this->make_cal_link($get_target, 'Yearly', $this->now_cid, date('Y-n-j'))); |
||
1080 | $tmpl->addVar('WholeBoard', 'PREVIOUSYEARLINK', $this->make_cal_link($get_target, 'Yearly', $this->now_cid, $prevYear)); |
||
1081 | $tmpl->addVar('WholeBoard', 'NEXTYEARLINK', $this->make_cal_link($get_target, 'Yearly', $this->now_cid, $nextYear)); |
||
1082 | $tmpl->addVar('WholeBoard', 'MONTHLYVIEW', $this->make_cal_link($get_target, 'Monthly', $this->now_cid, $this->caldate)); |
||
1083 | $tmpl->addVar('WholeBoard', 'WEEKLYVIEW', $this->make_cal_link($get_target, 'Weekly', $this->now_cid, $this->caldate)); |
||
1084 | $tmpl->addVar('WholeBoard', 'DAILYVIEW', $this->make_cal_link($get_target, 'Daily', $this->now_cid, $this->caldate)); |
||
1085 | $tmpl->addVar('WholeBoard', 'LISTVIEW', $this->make_cal_link($get_target, 'List', $this->now_cid, $this->caldate)); |
||
1086 | |||
1087 | // ���ƥ��꡼����ܥå��� |
||
1088 | $tmpl->addVar('WholeBoard', 'CATEGORIES_SELFORM', $this->get_categories_selform($get_target)); |
||
1089 | $tmpl->addVar('WholeBoard', 'CID', $this->now_cid); |
||
1090 | |||
1091 | // Variables required in header part etc. |
||
1092 | $tmpl->addVars('WholeBoard', $this->get_calendar_information('Y')); |
||
1093 | |||
1094 | $tmpl->addVar('WholeBoard', 'LANG_JUMP', _APCAL_BTN_JUMP); |
||
1095 | |||
1096 | // �Ʒ�Υߥ˥������� |
||
1097 | // $this->caldate �ΥХå����å� |
||
1098 | $backuped_caldate = $this->caldate; |
||
1099 | |||
1100 | // 12����ʬ�Υߥ˥������������롼�� |
||
1101 | for ($m = 1; $m <= 12; ++$m) { |
||
1102 | $this->set_date(date('Y-n-j', mktime(0, 0, 0, $m, 1, $this->year))); |
||
1103 | $tmpl->addVar('WholeBoard', "MINICAL$m", $this->get_mini_calendar_html($get_target, $query_string, 'NO_YEAR')); |
||
1104 | } |
||
1105 | |||
1106 | // $this->caldate �Υꥹ�ȥ� |
||
1107 | $this->set_date($backuped_caldate); |
||
1108 | |||
1109 | // content generated from PatTemplate |
||
1110 | $ret = $tmpl->getParsedTemplate('WholeBoard'); |
||
1111 | |||
1112 | return $ret; |
||
1113 | } |
||
1114 | |||
1115 | // ��֥����������Τ�ɽ����patTemplate����) |
||
1116 | |||
1117 | /** |
||
1118 | * @param string $get_target |
||
1119 | * @param string $query_string |
||
1120 | * @param bool $for_print |
||
1121 | * @return string |
||
1122 | */ |
||
1123 | public function get_monthly($get_target = '', $query_string = '', $for_print = false) |
||
1124 | { |
||
1125 | // $PHP_SELF = $_SERVER['SCRIPT_NAME'] ; |
||
1126 | // if( $get_target == '' ) $get_target = $PHP_SELF ; |
||
1127 | |||
1128 | if (isset($_POST['startDate'])) { |
||
1129 | $date = explode('-', $_POST['startDate']); |
||
1130 | $this->year = $date[0]; |
||
1131 | $this->month = $date[1]; |
||
1132 | $this->day = $date[2]; |
||
1133 | $this->caldate = $_POST['startDate']; |
||
1134 | } |
||
1135 | |||
1136 | require_once "$this->base_path/include/patTemplate.php"; |
||
1137 | $tmpl = new PatTemplate(); |
||
1138 | $tmpl->readTemplatesFromFile("$this->images_path/monthly.tmpl.html"); |
||
1139 | |||
1140 | // setting skin folder |
||
1141 | $tmpl->addVar('WholeBoard', 'SKINPATH', $this->images_url); |
||
1142 | |||
1143 | // Static parameter for the request |
||
1144 | $tmpl->addVar('WholeBoard', 'GET_TARGET', $get_target); |
||
1145 | $tmpl->addVar('WholeBoard', 'QUERY_STRING', $query_string); |
||
1146 | $tmpl->addVar('WholeBoard', 'YEAR_MONTH_TITLE', sprintf(_APCAL_FMT_YEAR_MONTH, $this->year, $this->month_middle_names[$this->month])); |
||
1147 | $tmpl->addVar('WholeBoard', 'PRINT_LINK', "$this->base_url/print.php?cid=$this->now_cid&smode=Monthly&caldate=$this->caldate"); |
||
1148 | $tmpl->addVar('WholeBoard', 'LANG_PRINT', _APCAL_BTN_PRINT); |
||
1149 | if ($for_print) { |
||
1150 | $tmpl->addVar('WholeBoard', 'PRINT_ATTRIB', "width='0' height='0'"); |
||
1151 | } |
||
1152 | |||
1153 | $prevYear = date('Y-n-j', mktime(0, 0, 0, $this->month, $this->date, $this->year - 1)); |
||
1154 | $nextYear = date('Y-n-j', mktime(0, 0, 0, $this->month, $this->date, $this->year + 1)); |
||
1155 | $prevMonth = date('Y-n-j', mktime(0, 0, 0, $this->month, 0, $this->year)); |
||
1156 | $nextMonth = date('Y-n-j', mktime(0, 0, 0, $this->month + 1, 1, $this->year)); |
||
1157 | $tmpl->addVar('WholeBoard', 'TODAYLINK', $this->make_cal_link($get_target, 'Monthly', $this->now_cid, date('Y-n-j'))); |
||
1158 | $tmpl->addVar('WholeBoard', 'PREVIOUSYEARLINK', $this->make_cal_link($get_target, 'Monthly', $this->now_cid, $prevYear)); |
||
1159 | $tmpl->addVar('WholeBoard', 'PREVIOUSMONTHLINK', $this->make_cal_link($get_target, 'Monthly', $this->now_cid, $prevMonth)); |
||
1160 | $tmpl->addVar('WholeBoard', 'NEXTYEARLINK', $this->make_cal_link($get_target, 'Monthly', $this->now_cid, $nextYear)); |
||
1161 | $tmpl->addVar('WholeBoard', 'NEXTMONTHLINK', $this->make_cal_link($get_target, 'Monthly', $this->now_cid, $nextMonth)); |
||
1162 | $tmpl->addVar('WholeBoard', 'YEARLYVIEW', $this->make_cal_link($get_target, 'Yearly', $this->now_cid, $this->caldate)); |
||
1163 | $tmpl->addVar('WholeBoard', 'WEEKLYVIEW', $this->make_cal_link($get_target, 'Weekly', $this->now_cid, $this->caldate)); |
||
1164 | $tmpl->addVar('WholeBoard', 'DAILYVIEW', $this->make_cal_link($get_target, 'Daily', $this->now_cid, $this->caldate)); |
||
1165 | $tmpl->addVar('WholeBoard', 'LISTVIEW', $this->make_cal_link($get_target, 'List', $this->now_cid, $this->caldate)); |
||
1166 | |||
1167 | // ���ƥ��꡼����ܥå��� |
||
1168 | $tmpl->addVar('WholeBoard', 'CATEGORIES_SELFORM', $this->get_categories_selform($get_target)); |
||
1169 | $tmpl->addVar('WholeBoard', 'CID', $this->now_cid); |
||
1170 | |||
1171 | // Variables required in header part etc. |
||
1172 | $tmpl->addVars('WholeBoard', $this->get_calendar_information('M')); |
||
1173 | |||
1174 | $tmpl->addVar('WholeBoard', 'LANG_JUMP', _APCAL_BTN_JUMP); |
||
1175 | |||
1176 | // BODY of the calendar |
||
1177 | $tmpl->addVar('WholeBoard', 'CALENDAR_BODY', $this->get_monthly_html($get_target, $query_string, $for_print)); |
||
1178 | |||
1179 | // legends of long events |
||
1180 | View Code Duplication | foreach ($this->long_event_legends as $bit => $legend) { |
|
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. ![]() |
|||
1181 | $tmpl->addVar('LongEventLegends', 'BIT_MASK', 1 << ($bit - 1)); |
||
1182 | $tmpl->addVar('LongEventLegends', 'LEGEND_ALT', _APCAL_MB_ALLDAY_EVENT . " $bit"); |
||
1183 | $tmpl->addVar('LongEventLegends', 'LEGEND', $legend); |
||
1184 | $tmpl->addVar('LongEventLegends', 'SKINPATH', $this->images_url); |
||
1185 | $tmpl->parseTemplate('LongEventLegends', 'a'); |
||
1186 | } |
||
1187 | |||
1188 | // �����Υߥ˥������� |
||
1189 | // $this->caldate �ΥХå����å� |
||
1190 | $backuped_caldate = $this->caldate; |
||
1191 | // �����������դ򥻥åȤ�������Υߥ˥��������򥻥å� |
||
1192 | $this->set_date(date('Y-n-j', mktime(0, 0, 0, $this->month, 0, $this->year))); |
||
1193 | $tmpl->addVar('WholeBoard', 'PREV_MINICAL', $this->get_mini_calendar_html($get_target, $query_string, 'NO_NAVIGATE')); |
||
1194 | // ���Ϥ����դ򥻥åȤ����ߥ˥���������ɽ�� |
||
1195 | $this->set_date(date('Y-n-j', mktime(0, 0, 0, $this->month + 2, 1, $this->year))); |
||
1196 | $tmpl->addVar('WholeBoard', 'NEXT_MINICAL', $this->get_mini_calendar_html($get_target, $query_string, 'NO_NAVIGATE')); |
||
1197 | // $this->caldate �Υꥹ�ȥ� |
||
1198 | $this->set_date($backuped_caldate); |
||
1199 | |||
1200 | // content generated from PatTemplate |
||
1201 | $ret = $tmpl->getParsedTemplate('WholeBoard'); |
||
1202 | |||
1203 | return $ret; |
||
1204 | } |
||
1205 | |||
1206 | // ���֥����������Τ�ɽ����patTemplate����) |
||
1207 | |||
1208 | /** |
||
1209 | * @param string $get_target |
||
1210 | * @param string $query_string |
||
1211 | * @param bool $for_print |
||
1212 | * @return string |
||
1213 | */ |
||
1214 | View Code Duplication | public function get_weekly($get_target = '', $query_string = '', $for_print = false) |
|
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. ![]() |
|||
1215 | { |
||
1216 | // $PHP_SELF = $_SERVER['SCRIPT_NAME'] ; |
||
1217 | // if( $get_target == '' ) $get_target = $PHP_SELF ; |
||
1218 | |||
1219 | require_once "$this->base_path/include/patTemplate.php"; |
||
1220 | $tmpl = new PatTemplate(); |
||
1221 | $tmpl->readTemplatesFromFile("$this->images_path/weekly.tmpl.html"); |
||
1222 | |||
1223 | // setting skin folder |
||
1224 | $tmpl->addVar('WholeBoard', 'SKINPATH', $this->images_url); |
||
1225 | |||
1226 | // Static parameter for the request |
||
1227 | $tmpl->addVar('WholeBoard', 'GET_TARGET', $get_target); |
||
1228 | $tmpl->addVar('WholeBoard', 'QUERY_STRING', $query_string); |
||
1229 | $tmpl->addVar('WholeBoard', 'PRINT_LINK', "$this->base_url/print.php?cid=$this->now_cid&smode=Weekly&caldate=$this->caldate"); |
||
1230 | $tmpl->addVar('WholeBoard', 'LANG_PRINT', _APCAL_BTN_PRINT); |
||
1231 | if ($for_print) { |
||
1232 | $tmpl->addVar('WholeBoard', 'PRINT_ATTRIB', "width='0' height='0'"); |
||
1233 | } |
||
1234 | |||
1235 | $prevMonth = date('Y-n-j', mktime(0, 0, 0, $this->month, 0, $this->year)); |
||
1236 | $nextMonth = date('Y-n-j', mktime(0, 0, 0, $this->month + 1, 1, $this->year)); |
||
1237 | $prevWeek = date('Y-n-j', mktime(0, 0, 0, $this->month, $this->date - 7, $this->year)); |
||
1238 | $nextWeek = date('Y-n-j', mktime(0, 0, 0, $this->month, $this->date + 7, $this->year)); |
||
1239 | $tmpl->addVar('WholeBoard', 'TODAYLINK', $this->make_cal_link($get_target, 'Weekly', $this->now_cid, date('Y-n-j'))); |
||
1240 | $tmpl->addVar('WholeBoard', 'PREVIOUSMONTHLINK', $this->make_cal_link($get_target, 'Weekly', $this->now_cid, $prevMonth)); |
||
1241 | $tmpl->addVar('WholeBoard', 'PREVIOUSWEEKLINK', $this->make_cal_link($get_target, 'Weekly', $this->now_cid, $prevWeek)); |
||
1242 | $tmpl->addVar('WholeBoard', 'NEXTWEEKLINK', $this->make_cal_link($get_target, 'Weekly', $this->now_cid, $nextWeek)); |
||
1243 | $tmpl->addVar('WholeBoard', 'NEXTMONTHLINK', $this->make_cal_link($get_target, 'Weekly', $this->now_cid, $nextMonth)); |
||
1244 | $tmpl->addVar('WholeBoard', 'YEARLYVIEW', $this->make_cal_link($get_target, 'Yearly', $this->now_cid, $this->caldate)); |
||
1245 | $tmpl->addVar('WholeBoard', 'MONTHLYVIEW', $this->make_cal_link($get_target, 'Monthly', $this->now_cid, $this->caldate)); |
||
1246 | $tmpl->addVar('WholeBoard', 'DAILYVIEW', $this->make_cal_link($get_target, 'Daily', $this->now_cid, $this->caldate)); |
||
1247 | $tmpl->addVar('WholeBoard', 'LISTVIEW', $this->make_cal_link($get_target, 'List', $this->now_cid, $this->caldate)); |
||
1248 | |||
1249 | // ���ƥ��꡼����ܥå��� |
||
1250 | $tmpl->addVar('WholeBoard', 'CATEGORIES_SELFORM', $this->get_categories_selform($get_target)); |
||
1251 | $tmpl->addVar('WholeBoard', 'CID', $this->now_cid); |
||
1252 | |||
1253 | // Variables required in header part etc. |
||
1254 | $tmpl->addVars('WholeBoard', $this->get_calendar_information('W')); |
||
1255 | |||
1256 | $tmpl->addVar('WholeBoard', 'LANG_JUMP', _APCAL_BTN_JUMP); |
||
1257 | |||
1258 | // BODY of the calendar |
||
1259 | $tmpl->addVar('WholeBoard', 'CALENDAR_BODY', $this->get_weekly_html($get_target, $query_string)); |
||
0 ignored issues
–
show
The call to
APCal::get_weekly_html() has too many arguments starting with $query_string .
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. In this case you can add the ![]() |
|||
1260 | |||
1261 | // content generated from PatTemplate |
||
1262 | $ret = $tmpl->getParsedTemplate('WholeBoard'); |
||
1263 | |||
1264 | return $ret; |
||
1265 | } |
||
1266 | |||
1267 | // ������������Τ�ɽ����patTemplate����) |
||
1268 | |||
1269 | /** |
||
1270 | * @param string $get_target |
||
1271 | * @param string $query_string |
||
1272 | * @param bool $for_print |
||
1273 | * @return string |
||
1274 | */ |
||
1275 | View Code Duplication | public function get_daily($get_target = '', $query_string = '', $for_print = false) |
|
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. ![]() |
|||
1276 | { |
||
1277 | // $PHP_SELF = $_SERVER['SCRIPT_NAME'] ; |
||
1278 | // if( $get_target == '' ) $get_target = $PHP_SELF ; |
||
1279 | |||
1280 | require_once "$this->base_path/include/patTemplate.php"; |
||
1281 | $tmpl = new PatTemplate(); |
||
1282 | $tmpl->readTemplatesFromFile("$this->images_path/daily.tmpl.html"); |
||
1283 | |||
1284 | // setting skin folder |
||
1285 | $tmpl->addVar('WholeBoard', 'SKINPATH', $this->images_url); |
||
1286 | |||
1287 | // Static parameter for the request |
||
1288 | $tmpl->addVar('WholeBoard', 'GET_TARGET', $get_target); |
||
1289 | $tmpl->addVar('WholeBoard', 'QUERY_STRING', $query_string); |
||
1290 | $tmpl->addVar('WholeBoard', 'PRINT_LINK', "$this->base_url/print.php?cid=$this->now_cid&smode=Daily&caldate=$this->caldate"); |
||
1291 | $tmpl->addVar('WholeBoard', 'LANG_PRINT', _APCAL_BTN_PRINT); |
||
1292 | if ($for_print) { |
||
1293 | $tmpl->addVar('WholeBoard', 'PRINT_ATTRIB', "width='0' height='0'"); |
||
1294 | } |
||
1295 | |||
1296 | $prevMonth = date('Y-n-j', mktime(0, 0, 0, $this->month, 0, $this->year)); |
||
1297 | $nextMonth = date('Y-n-j', mktime(0, 0, 0, $this->month + 1, 1, $this->year)); |
||
1298 | $prevDay = date('Y-n-j', mktime(0, 0, 0, $this->month, $this->date - 1, $this->year)); |
||
1299 | $nextDay = date('Y-n-j', mktime(0, 0, 0, $this->month, $this->date + 1, $this->year)); |
||
1300 | $tmpl->addVar('WholeBoard', 'TODAYLINK', $this->make_cal_link($get_target, 'Daily', $this->now_cid, date('Y-n-j'))); |
||
1301 | $tmpl->addVar('WholeBoard', 'PREVIOUSMONTHLINK', $this->make_cal_link($get_target, 'Daily', $this->now_cid, $prevMonth)); |
||
1302 | $tmpl->addVar('WholeBoard', 'PREVIOUSDAYLINK', $this->make_cal_link($get_target, 'Daily', $this->now_cid, $prevDay)); |
||
1303 | $tmpl->addVar('WholeBoard', 'NEXTDAYLINK', $this->make_cal_link($get_target, 'Daily', $this->now_cid, $nextDay)); |
||
1304 | $tmpl->addVar('WholeBoard', 'NEXTMONTHLINK', $this->make_cal_link($get_target, 'Daily', $this->now_cid, $nextMonth)); |
||
1305 | $tmpl->addVar('WholeBoard', 'YEARLYVIEW', $this->make_cal_link($get_target, 'Yearly', $this->now_cid, $this->caldate)); |
||
1306 | $tmpl->addVar('WholeBoard', 'MONTHLYVIEW', $this->make_cal_link($get_target, 'Monthly', $this->now_cid, $this->caldate)); |
||
1307 | $tmpl->addVar('WholeBoard', 'WEEKLYVIEW', $this->make_cal_link($get_target, 'Weekly', $this->now_cid, $this->caldate)); |
||
1308 | $tmpl->addVar('WholeBoard', 'LISTVIEW', $this->make_cal_link($get_target, 'List', $this->now_cid, $this->caldate)); |
||
1309 | |||
1310 | // ���ƥ��꡼����ܥå��� |
||
1311 | $tmpl->addVar('WholeBoard', 'CATEGORIES_SELFORM', $this->get_categories_selform($get_target)); |
||
1312 | $tmpl->addVar('WholeBoard', 'CID', $this->now_cid); |
||
1313 | |||
1314 | // Variables required in header part etc. |
||
1315 | $tmpl->addVars('WholeBoard', $this->get_calendar_information('D')); |
||
1316 | |||
1317 | $tmpl->addVar('WholeBoard', 'LANG_JUMP', _APCAL_BTN_JUMP); |
||
1318 | |||
1319 | // BODY of the calendar |
||
1320 | $tmpl->addVar('WholeBoard', 'CALENDAR_BODY', $this->get_daily_html($get_target, $query_string)); |
||
0 ignored issues
–
show
The call to
APCal::get_daily_html() has too many arguments starting with $query_string .
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. In this case you can add the ![]() |
|||
1321 | |||
1322 | // content generated from PatTemplate |
||
1323 | $ret = $tmpl->getParsedTemplate('WholeBoard'); |
||
1324 | |||
1325 | return $ret; |
||
1326 | } |
||
1327 | |||
1328 | // ���������Υإå������ɬ�פʾ����Ϣ��������֤��ʷ�֡����֡������̡� |
||
1329 | |||
1330 | /** |
||
1331 | * @param string $mode |
||
1332 | * @return array |
||
1333 | */ |
||
1334 | public function get_calendar_information($mode = 'M') |
||
1335 | { |
||
1336 | $ret = array(); |
||
1337 | |||
1338 | // ���ܾ��� |
||
1339 | $ret['TODAY'] = date('Y-n-j'); // GIJ TODO �׼�ľ���ʻȤ�ʤ����� |
||
1340 | $ret['CALDATE'] = $this->caldate; |
||
1341 | $ret['DISP_YEAR'] = sprintf(_APCAL_FMT_YEAR, $this->year); |
||
1342 | $ret['DISP_MONTH'] = $this->month_middle_names[$this->month]; |
||
1343 | $ret['DISP_DATE'] = $this->date_long_names[$this->date]; |
||
1344 | $ret['DISP_DAY'] = "({$this->week_middle_names[ $this->day ]})"; |
||
1345 | list($bgcolor, $color) = $this->daytype_to_colors($this->daytype); |
||
0 ignored issues
–
show
The assignment to
$bgcolor is unused. Consider omitting it like so list($first,,$third) .
This checks looks for assignemnts to variables using the Consider the following code example. <?php
function returnThreeValues() {
return array('a', 'b', 'c');
}
list($a, $b, $c) = returnThreeValues();
print $a . " - " . $c;
Only the variables Instead, the list call could have been. list($a,, $c) = returnThreeValues();
![]() |
|||
1346 | $ret['DISP_DAY_COLOR'] = $color; |
||
1347 | $ret['COPYRIGHT'] = _MD_APCAL_COPYRIGHT; |
||
1348 | |||
1349 | // �إå������Υ��顼 |
||
1350 | $ret['CALHEAD_BGCOLOR'] = $this->calhead_bgcolor; |
||
1351 | $ret['CALHEAD_COLOR'] = $this->calhead_color; |
||
1352 | |||
1353 | // ���������alt(title) |
||
1354 | $ret['ICON_LIST'] = _APCAL_ICON_LIST; |
||
1355 | $ret['ICON_DAILY'] = _APCAL_ICON_DAILY; |
||
1356 | $ret['ICON_WEEKLY'] = _APCAL_ICON_WEEKLY; |
||
1357 | $ret['ICON_MONTHLY'] = _APCAL_ICON_MONTHLY; |
||
1358 | $ret['ICON_YEARLY'] = _APCAL_ICON_YEARLY; |
||
1359 | |||
1360 | // ��å������֥�å� |
||
1361 | $ret['MB_PREV_YEAR'] = _APCAL_MB_PREV_YEAR; |
||
1362 | $ret['MB_NEXT_YEAR'] = _APCAL_MB_NEXT_YEAR; |
||
1363 | $ret['MB_PREV_MONTH'] = _APCAL_MB_PREV_MONTH; |
||
1364 | $ret['MB_NEXT_MONTH'] = _APCAL_MB_NEXT_MONTH; |
||
1365 | $ret['MB_PREV_WEEK'] = _APCAL_MB_PREV_WEEK; |
||
1366 | $ret['MB_NEXT_WEEK'] = _APCAL_MB_NEXT_WEEK; |
||
1367 | $ret['MB_PREV_DATE'] = _APCAL_MB_PREV_DATE; |
||
1368 | $ret['MB_NEXT_DATE'] = _APCAL_MB_NEXT_DATE; |
||
1369 | $ret['MB_LINKTODAY'] = _APCAL_MB_LINKTODAY; |
||
1370 | |||
1371 | // �����ؤΥ�� |
||
1372 | $ret['PREV_YEAR'] = date('Y-n-j', mktime(0, 0, 0, $this->month, $this->date, $this->year - 1)); |
||
1373 | $ret['NEXT_YEAR'] = date('Y-n-j', mktime(0, 0, 0, $this->month, $this->date, $this->year + 1)); |
||
1374 | $ret['PREV_MONTH'] = date('Y-n-j', mktime(0, 0, 0, $this->month, 0, $this->year)); |
||
1375 | $ret['NEXT_MONTH'] = date('Y-n-j', mktime(0, 0, 0, $this->month + 1, 1, $this->year)); |
||
1376 | $ret['PREV_WEEK'] = date('Y-n-j', mktime(0, 0, 0, $this->month, $this->date - 7, $this->year)); |
||
1377 | $ret['NEXT_WEEK'] = date('Y-n-j', mktime(0, 0, 0, $this->month, $this->date + 7, $this->year)); |
||
1378 | $ret['PREV_DATE'] = date('Y-n-j', mktime(0, 0, 0, $this->month, $this->date - 1, $this->year)); |
||
1379 | $ret['NEXT_DATE'] = date('Y-n-j', mktime(0, 0, 0, $this->month, $this->date + 1, $this->year)); |
||
1380 | |||
1381 | // ���ե������ѥե�����γƥ���ȥ?�� |
||
1382 | // ǯ�������ν���� |
||
1383 | if (empty($_POST['apcal_year'])) { |
||
1384 | $year = $this->year; |
||
1385 | } else { |
||
1386 | $year = (int)$_POST['apcal_year']; |
||
1387 | } |
||
1388 | if (empty($_POST['apcal_month'])) { |
||
1389 | $month = $this->month; |
||
1390 | } else { |
||
1391 | $month = (int)$_POST['apcal_month']; |
||
1392 | } |
||
1393 | if (empty($_POST['apcal_date'])) { |
||
1394 | $date = $this->date; |
||
1395 | } else { |
||
1396 | $date = (int)$_POST['apcal_date']; |
||
1397 | } |
||
1398 | |||
1399 | // ǯ�������(2001��2020 �Ȥ���) |
||
1400 | $year_options = ''; |
||
1401 | View Code Duplication | for ($y = 2001; $y <= 2020; ++$y) { |
|
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. ![]() |
|||
1402 | if ($y == $year) { |
||
1403 | $year_options .= "\t\t\t<option value='$y' selected>" . sprintf(strip_tags(_APCAL_FMT_YEAR), $y) . "</option>\n"; |
||
1404 | } else { |
||
1405 | $year_options .= "\t\t\t<option value='$y'>" . sprintf(strip_tags(_APCAL_FMT_YEAR), $y) . "</option>\n"; |
||
1406 | } |
||
1407 | } |
||
1408 | $ret['YEAR_OPTIONS'] = $year_options; |
||
1409 | |||
1410 | // �������� |
||
1411 | $month_options = ''; |
||
1412 | View Code Duplication | for ($m = 1; $m <= 12; ++$m) { |
|
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. ![]() |
|||
1413 | if ($m == $month) { |
||
1414 | $month_options .= "\t\t\t<option value='$m' selected>{$this->month_short_names[$m]}</option>\n"; |
||
1415 | } else { |
||
1416 | $month_options .= "\t\t\t<option value='$m'>{$this->month_short_names[$m]}</option>\n"; |
||
1417 | } |
||
1418 | } |
||
1419 | $ret['MONTH_OPTIONS'] = $month_options; |
||
1420 | |||
1421 | // �������� |
||
1422 | if ($mode === 'W' || $mode === 'D') { |
||
1423 | $date_options = ''; |
||
1424 | View Code Duplication | for ($d = 1; $d <= 31; ++$d) { |
|
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. ![]() |
|||
1425 | if ($d == $date) { |
||
1426 | $date_options .= "\t\t\t<option value='$d' selected>{$this->date_short_names[$d]}</option>\n"; |
||
1427 | } else { |
||
1428 | $date_options .= "\t\t\t<option value='$d'>{$this->date_short_names[$d]}</option>\n"; |
||
1429 | } |
||
1430 | } |
||
1431 | |||
1432 | $ret['YMD_SELECTS'] = sprintf(_APCAL_FMT_YMD, "<select name='apcal_year'>{$ret['YEAR_OPTIONS']}</select> ", |
||
1433 | "<select name='apcal_month'>{$ret['MONTH_OPTIONS']}</select> ", "<select name='apcal_date'>$date_options</select> "); |
||
1434 | if ($this->week_numbering) { |
||
1435 | if ($this->day == 0 && !$this->week_start) { |
||
1436 | $weekno = date('W', $this->unixtime + 86400); |
||
1437 | } else { |
||
1438 | $weekno = date('W', $this->unixtime); |
||
1439 | } |
||
1440 | $ret['YMW_TITLE'] = sprintf(_APCAL_FMT_YW, $this->year, $weekno); |
||
1441 | } else { |
||
1442 | $week_number = floor(($this->date - ($this->day - $this->week_start + 7) % 7 + 12) / 7); |
||
1443 | $ret['YMW_TITLE'] = sprintf(_APCAL_FMT_YMW, $this->year, $this->month_middle_names[$this->month], $this->week_numbers[$week_number]); |
||
1444 | } |
||
1445 | $ret['YMD_TITLE'] = sprintf(_APCAL_FMT_YMD, $this->year, $this->month_middle_names[$this->month], $this->date_long_names[$date]); |
||
1446 | } |
||
1447 | |||
1448 | return $ret; |
||
1449 | } |
||
1450 | |||
1451 | /** |
||
1452 | * @param string $get_target |
||
1453 | * @param string $query_string |
||
1454 | * @param bool $for_print |
||
1455 | * @return mixed|string| |
||
1456 | */ |
||
1457 | public function get_monthly_html($get_target = '', $query_string = '', $for_print = false) |
||
0 ignored issues
–
show
|
|||
1458 | { |
||
1459 | $tpl = new XoopsTpl(); |
||
1460 | |||
1461 | // Set days width |
||
1462 | $this->widerDays = unserialize($this->widerDays); |
||
1463 | $total = 0; |
||
1464 | $widths = array( |
||
1465 | 'Monday' => 1, |
||
1466 | 'Tuesday' => 1, |
||
1467 | 'Wednesday' => 1, |
||
1468 | 'Thursday' => 1, |
||
1469 | 'Friday' => 1, |
||
1470 | 'Saturday' => 1, |
||
1471 | 'Sunday' => 1 |
||
1472 | ); |
||
1473 | foreach ($this->widerDays as $day) { |
||
1474 | $widths[$day] = 1.5; |
||
1475 | } |
||
1476 | foreach ($widths as $width) { |
||
1477 | $total += $width; |
||
1478 | } |
||
1479 | foreach ($widths as $day => $width) { |
||
1480 | $widths[$day] = (100 * $width / $total) . '%'; |
||
1481 | } |
||
1482 | |||
1483 | // Where clause - Start / End |
||
1484 | $mtop_unixtime = mktime(0, 0, 0, $this->month, 1, $this->year); |
||
1485 | $mtop_weekno = date('W', $mtop_unixtime); |
||
1486 | if ($mtop_weekno >= 52) { |
||
1487 | $mtop_weekno = 1; |
||
1488 | } |
||
1489 | $first_date = getdate($mtop_unixtime); |
||
1490 | $date = (-$first_date['wday'] + $this->week_start - 7) % 7; |
||
1491 | $wday_end = 7 + $this->week_start; |
||
1492 | $last_date = date('t', $this->unixtime); |
||
1493 | $mlast_unixtime = mktime(0, 0, 0, $this->month + 1, 1, $this->year); |
||
1494 | |||
1495 | $tzoffset = (int)(($this->user_TZ - $this->server_TZ) * 3600); |
||
1496 | if ($tzoffset == 0) { |
||
1497 | $whr_term = "start<='$mlast_unixtime' AND end>'$mtop_unixtime'"; |
||
1498 | } else { |
||
1499 | $whr_term = "(allday AND start<='" |
||
1500 | . ($mlast_unixtime - $tzoffset) |
||
1501 | . "' AND end>'" |
||
1502 | . ($mtop_unixtime - $tzoffset) |
||
1503 | . "') || (!allday AND start<='" |
||
1504 | . ($mlast_unixtime - $tzoffset) |
||
1505 | . "' AND end>'" |
||
1506 | . ($mtop_unixtime - $tzoffset) |
||
1507 | . "')"; |
||
1508 | } |
||
1509 | |||
1510 | // Where clause - Categories |
||
1511 | $whr_categories = $this->get_where_about_categories(); |
||
1512 | |||
1513 | // Where clause - Class |
||
1514 | $whr_class = $this->get_where_about_class(); |
||
1515 | |||
1516 | // WHERE clause - Admittance |
||
1517 | $whr_admit = $this->isadmin ? '' : 'AND admission=1'; |
||
1518 | |||
1519 | // ??? |
||
1520 | $rs = $GLOBALS['xoopsDB']->query("SELECT DISTINCT unique_id FROM $this->table WHERE ($whr_term) AND ($whr_categories) AND ($whr_class) AND (allday & 2) LIMIT 4"); |
||
1521 | $long_event_ids = array(); |
||
1522 | $bit = 1; |
||
1523 | while ($event = $GLOBALS['xoopsDB']->fetchObject($rs)) { |
||
1524 | $long_event_ids[$bit] = $event->unique_id; |
||
1525 | ++$bit; |
||
1526 | } |
||
1527 | |||
1528 | $cats_color['00000'] = $this->allcats_color; |
||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
$cats_color was never initialized. Although not strictly required by PHP, it is generally a good practice to add $cats_color = array(); before regardless.
Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code. Let’s take a look at an example: foreach ($collection as $item) {
$myArray['foo'] = $item->getFoo();
if ($item->hasBar()) {
$myArray['bar'] = $item->getBar();
}
// do something with $myArray
}
As you can see in this example, the array This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop. ![]() |
|||
1529 | foreach ($this->canbemain_cats as $i => $cat) { |
||
1530 | $cats_color[$cat->cid] = $cat->color; |
||
1531 | $this->canbemain_cats[$i]->link = $this->make_cal_link($get_target, 'Monthly', $cat->cid, $this->caldate); |
||
1532 | } |
||
1533 | |||
1534 | // Get all events in the month in the category with the class |
||
1535 | $yrs = $GLOBALS['xoopsDB']->query("SELECT id,start,end,summary,location,contact,id,allday,admission,uid,unique_id,mainCategory,categories,gmlat,gmlong,extkey0 FROM $this->table WHERE ({$whr_term}) AND ({$whr_categories}) AND ({$whr_class}) {$whr_admit} ORDER BY start"); |
||
1536 | $numrows_yrs = $GLOBALS['xoopsDB']->getRowsNum($yrs); |
||
1537 | $events = array(); |
||
1538 | $eventsids = array(); |
||
1539 | $slots = 0; |
||
1540 | if ($numrows_yrs) { |
||
1541 | $lastDay = date('t', mktime(0, 0, 0, $this->month, 1, $this->year)); |
||
1542 | |||
1543 | while ($event = $GLOBALS['xoopsDB']->fetchObject($yrs)) { |
||
1544 | $event->start += $tzoffset; |
||
1545 | $event->end += $tzoffset; |
||
1546 | |||
1547 | $startDay = date('j', $event->start); |
||
1548 | $endDay = date('j', $event->end); |
||
1549 | $endHour = date('H:i:s', $event->end); |
||
1550 | |||
1551 | $startDay = $event->start < mktime(0, 0, 0, $this->month, 1, $this->year) ? 1 : $startDay; |
||
1552 | //$endDay = $endDay != $startDay && $endHour == '00:00:00' ? $endDay - 1 : $endDay; |
||
1553 | $endDay = $event->end > mktime(0, 0, 0, $this->month, $lastDay, $this->year) ? $lastDay : $endDay; |
||
1554 | $week_end = $this->week_start + 6; |
||
1555 | |||
1556 | // Get picture |
||
1557 | $pic = $GLOBALS['xoopsDB']->fetchObject($GLOBALS['xoopsDB']->query("SELECT picture FROM {$this->pic_table} WHERE event_id={$event->id} AND main_pic=1 LIMIT 0,1")); |
||
1558 | |||
1559 | if ($event->admission) { |
||
1560 | // Put markers on map |
||
1561 | if ($event->gmlat > 0 || $event->gmlong > 0) { |
||
1562 | $this->gmPoints[$event->id] = array( |
||
1563 | 'summary' => $event->summary, |
||
1564 | 'gmlat' => $event->gmlat, |
||
1565 | 'gmlong' => $event->gmlong, |
||
1566 | 'location' => $event->location, |
||
1567 | 'contact' => $event->contact, |
||
1568 | 'startDate' => $startDay, |
||
1569 | 'event_id' => $event->id |
||
1570 | ); |
||
1571 | if ($endDay != $startDay && $endHour !== '00:00:00') { |
||
1572 | $nbDays = date('j', $event->end) - $startDay; |
||
1573 | for ($i = 1; $i <= $nbDays; ++$i) { |
||
1574 | $this->gmPoints[$event->id . ($startDay + $i)] = array( |
||
1575 | 'summary' => $event->summary, |
||
1576 | 'gmlat' => $event->gmlat, |
||
1577 | 'gmlong' => $event->gmlong, |
||
1578 | 'location' => $event->location, |
||
1579 | 'contact' => $event->contact, |
||
1580 | 'startDate' => $startDay + $i, |
||
1581 | 'event_id' => $event->id |
||
1582 | ); |
||
1583 | } |
||
1584 | } |
||
1585 | } |
||
1586 | |||
1587 | // Categories |
||
1588 | $categories = explode(',', $event->categories); |
||
0 ignored issues
–
show
$categories 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 ![]() |
|||
1589 | //$e['cat'] = $this->text_sanitizer_for_show($this->categories[(int)($categories[0])]->cat_title); |
||
1590 | // Summary |
||
1591 | $event->summary = $this->text_sanitizer_for_show($event->summary); |
||
1592 | $summary = /*mb_strcut(*/ |
||
1593 | $event->summary/*, 0, 44)*/ |
||
1594 | ; |
||
1595 | /*if($summary != $event->summary) $summary .= "..";*/ |
||
1596 | // Event ID |
||
1597 | $event_id = $event->id; |
||
1598 | //$e['week'] = date('W', $event->start) - date('W', mktime(0, 0, 0, $this->month, 1, $this->year)); |
||
1599 | // Events array |
||
1600 | $events[$event_id]['summary'] = $summary; |
||
1601 | $events[$event_id]['extkey0'] = (int)$event->extkey0; //added by goffy |
||
1602 | } elseif ($this->isadmin || ($this->user_id > 0 && $this->user_id == $event->uid)) { |
||
1603 | $event_id = $event->id; |
||
1604 | $events[$event_id]['summary'] = sprintf(_APCAL_NTC_NUMBEROFNEEDADMIT, ''); |
||
1605 | } |
||
1606 | $events[$event_id]['link'] = $this->make_event_link($event->id, $get_target); |
||
0 ignored issues
–
show
The variable
$event_id does not seem to be defined for all execution paths leading up to this point.
If you define a variable conditionally, it can happen that it is not defined for all execution paths. Let’s take a look at an example: function myFunction($a) {
switch ($a) {
case 'foo':
$x = 1;
break;
case 'bar':
$x = 2;
break;
}
// $x is potentially undefined here.
echo $x;
}
In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined. Available Fixes
![]() |
|||
1607 | $events[$event_id]['location'] = $this->text_sanitizer_for_show($event->location); |
||
1608 | $events[$event_id]['start'] = $this->get_middle_md($event->start /*+ $tzoffset*/) . ' ' . ($event->allday < 1 ? $this->get_middle_hi($event->start /*+ $tzoffset*/) : ''); |
||
1609 | $events[$event_id]['end'] = /*($event->allday != 1 ? */ |
||
1610 | $this->get_middle_md($event->end /*+ $tzoffset*/) /*: $this->get_middle_md($event->end - 3600))*/ . ' ' . ($event->allday |
||
1611 | < 1 ? $this->get_middle_hi($event->end/* + $tzoffset*/) : ''); |
||
1612 | $events[$event_id]['cat'] = ($event->mainCategory |
||
1613 | && array_key_exists($event->mainCategory, $cats_color)) ? $event->mainCategory : '00000'; |
||
1614 | $events[$event_id]['duration'] = $endDay - $startDay + 1; |
||
1615 | $events[$event_id]['picture'] = $pic && $this->showPicMonthly ? XOOPS_UPLOAD_URL . "/apcal/{$pic->picture}" : ''; |
||
1616 | |||
1617 | // Find the best slot for the event |
||
1618 | $i = 0; |
||
1619 | $ok = false; |
||
1620 | while (!$ok) { |
||
1621 | $ok = true; |
||
1622 | for ($d = $startDay; $d <= $endDay; ++$d) { |
||
1623 | if (isset($eventsids[$d][$i])) { |
||
1624 | $ok = false; |
||
1625 | } |
||
1626 | } |
||
1627 | if (!$ok) { |
||
1628 | ++$i; |
||
1629 | } |
||
1630 | } |
||
1631 | |||
1632 | // Assign event to day |
||
1633 | for ($d = $startDay; $d <= $endDay; ++$d) { |
||
1634 | $wday = date('w', mktime(0, 0, 0, $this->month, $d, $this->year)); |
||
1635 | |||
1636 | if ($d == $startDay) { |
||
1637 | $wday_left = $week_end == 7 && $wday == 0 ? 0 : $week_end - $wday; |
||
1638 | $duration = min($events[$event_id]['duration'], $wday_left + 1); |
||
1639 | $eventsids[$d][$i] = array('id' => $event_id, 'first' => 1, 'duration' => $duration); |
||
1640 | } elseif ($wday == $this->week_start) { |
||
1641 | $duration = min($endDay - $d + 1, 7); |
||
1642 | $eventsids[$d][$i] = array('id' => $event_id, 'first' => 1, 'duration' => $duration); |
||
1643 | } else { |
||
1644 | $eventsids[$d][$i] = array('id' => $event_id, 'first' => 0); |
||
1645 | } |
||
1646 | |||
1647 | $slots = max($slots, count($eventsids[$d])); |
||
1648 | } |
||
1649 | } |
||
1650 | } |
||
1651 | $roimage = XOOPS_URL . '/modules/apcal/assets/images/regonline/regonline.png'; // added by goffy: general comments for online registration |
||
1652 | |||
1653 | // Header |
||
1654 | $tpl->assign('images_url', $this->images_url); |
||
1655 | $tpl->assign('widths', $widths); |
||
1656 | $tpl->assign('week_start', $this->week_start); |
||
1657 | $tpl->assign('week_middle_names', $this->week_middle_names); |
||
1658 | |||
1659 | // Colors |
||
1660 | $tpl->assign('colors', array( |
||
1661 | $this->sunday_color, |
||
1662 | $this->weekday_color, |
||
1663 | $this->weekday_color, |
||
1664 | $this->weekday_color, |
||
1665 | $this->weekday_color, |
||
1666 | $this->weekday_color, |
||
1667 | $this->saturday_color, |
||
1668 | $this->sunday_color |
||
1669 | )); |
||
1670 | $tpl->assign('bgcolors', array( |
||
1671 | $this->sunday_bgcolor, |
||
1672 | $this->weekday_bgcolor, |
||
1673 | $this->weekday_bgcolor, |
||
1674 | $this->weekday_bgcolor, |
||
1675 | $this->weekday_bgcolor, |
||
1676 | $this->weekday_bgcolor, |
||
1677 | $this->saturday_bgcolor, |
||
1678 | $this->sunday_bgcolor |
||
1679 | )); |
||
1680 | $tpl->assign('frame_css', $this->frame_css); |
||
1681 | $tpl->assign('holiday_color', $this->holiday_color); |
||
1682 | $tpl->assign('holiday_bgcolor', $this->holiday_bgcolor); |
||
1683 | $tpl->assign('targetday_bgcolor', $this->targetday_bgcolor); |
||
1684 | $tpl->assign('event_color', $this->event_color); |
||
1685 | $tpl->assign('event_bgcolor', $this->event_bgcolor); |
||
1686 | |||
1687 | $tpl->assign('categories', $this->canbemain_cats); |
||
1688 | $tpl->assign('cats_color', $cats_color); |
||
1689 | |||
1690 | // Loops |
||
1691 | $tpl->assign('week_start', $this->week_start); |
||
1692 | $tpl->assign('week_end', $wday_end); |
||
1693 | $tpl->assign('day', $date); |
||
1694 | $tpl->assign('last_day', $last_date); |
||
1695 | $tpl->assign('week_numbering', $this->week_numbering); |
||
1696 | $tpl->assign('weekno', $mtop_weekno); |
||
1697 | $tpl->assign('selectedday', (int)$this->date); |
||
1698 | $tpl->assign('holidays', $this->holidays); |
||
1699 | |||
1700 | // Days |
||
1701 | $tpl->assign('insertable', $this->insertable); |
||
1702 | $tpl->assign('days', array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday')); |
||
1703 | |||
1704 | // Links |
||
1705 | $tpl->assign('cid', $this->now_cid); |
||
1706 | $tpl->assign('year', $this->year); |
||
1707 | $tpl->assign('month', $this->month); |
||
1708 | $tpl->assign('cal_date', $this->caldate); |
||
1709 | |||
1710 | // Events |
||
1711 | $tpl->assign('slots', $slots); |
||
1712 | $tpl->assign('events', $events); |
||
1713 | $tpl->assign('e', $eventsids); |
||
1714 | |||
1715 | $tpl->assign('for_print', $for_print); |
||
1716 | |||
1717 | $tpl->assign('cal', $this); |
||
1718 | |||
1719 | //added by goffy: registration online |
||
1720 | $tpl->assign('ro_image', $roimage); |
||
1721 | |||
1722 | return $tpl->fetch(XOOPS_ROOT_PATH . '/modules/apcal/templates/apcal_monthly.tpl'); |
||
1723 | } |
||
1724 | |||
1725 | // HTML output for weekly view |
||
1726 | |||
1727 | /** |
||
1728 | * @param string $get_target |
||
1729 | * @return string |
||
1730 | */ |
||
1731 | public function get_weekly_html($get_target = '') |
||
1732 | { |
||
1733 | $roimage = XOOPS_URL . '/modules/apcal/assets/images/regonline/regonline.png'; // added by goffy: image for online registration |
||
1734 | $ret = " |
||
1735 | <table border='0' cellspacing='0' cellpadding='0' width='100%' style='border-collapse:collapse;margin:0px;'> |
||
1736 | <tr> |
||
1737 | <td><img src='$this->images_url/spacer.gif' alt='' width='10' height='10' /></td> |
||
1738 | <td><img src='$this->images_url/spacer.gif' alt='' width='80' height='10' /></td> |
||
1739 | <td><img src='$this->images_url/spacer.gif' alt='' width='80' height='10' /></td> |
||
1740 | <td><img src='$this->images_url/spacer.gif' alt='' width='80' height='10' /></td> |
||
1741 | <td><img src='$this->images_url/spacer.gif' alt='' width='80' height='10' /></td> |
||
1742 | <td><img src='$this->images_url/spacer.gif' alt='' width='80' height='10' /></td> |
||
1743 | <td><img src='$this->images_url/spacer.gif' alt='' width='80' height='10' /></td> |
||
1744 | <td><img src='$this->images_url/spacer.gif' alt='' width='80' height='10' /></td> |
||
1745 | </tr>\n"; |
||
1746 | |||
1747 | $wtop_date = $this->date - ($this->day - $this->week_start + 7) % 7; |
||
1748 | $wtop_unixtime = mktime(0, 0, 0, $this->month, $wtop_date, $this->year); |
||
1749 | $wlast_unixtime = mktime(0, 0, 0, $this->month, $wtop_date + 7, $this->year); |
||
1750 | |||
1751 | // get the result of plugins |
||
1752 | $plugin_returns = array(); |
||
1753 | if (strtolower(get_class($this)) === 'apcal_xoops') { |
||
1754 | $db = XoopsDatabaseFactory::getDatabaseConnection(); |
||
1755 | $myts = MyTextSanitizer::getInstance(); |
||
1756 | $now = time(); |
||
1757 | $just1gif = 0; |
||
1758 | |||
1759 | $tzoffset_s2u = (int)(($this->user_TZ - $this->server_TZ) * 3600); |
||
1760 | $plugins = $this->get_plugins('weekly'); |
||
0 ignored issues
–
show
It seems like you code against a specific sub-type and not the parent class
APCal as the method get_plugins() does only exist in the following sub-classes of APCal : APCal_xoops . Maybe you want to instanceof check for one of these explicitly?
Let’s take a look at an example: abstract class User
{
/** @return string */
abstract public function getPassword();
}
class MyUser extends User
{
public function getPassword()
{
// return something
}
public function getDisplayName()
{
// return some name.
}
}
class AuthSystem
{
public function authenticate(User $user)
{
$this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
// do something.
}
}
In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break. Available Fixes
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types
inside the if block in such a case.
![]() |
|||
1761 | foreach ($plugins as $plugin) { |
||
1762 | $include_ret = @include $this->base_path . '/' . $this->plugins_path_weekly . '/' . $plugin['file']; |
||
1763 | if ($include_ret === false) { |
||
1764 | // weekly emulator by monthly plugin |
||
1765 | $wtop_month = date('n', $wtop_unixtime); |
||
1766 | $wlast_month = date('n', $wlast_unixtime - 86400); |
||
1767 | $year_backup = $this->year; |
||
1768 | $month_backup = $this->month; |
||
1769 | if ($wtop_month == $wlast_month) { |
||
1770 | @include $this->base_path . '/' . $this->plugins_path_monthly . '/' . $plugin['file']; |
||
0 ignored issues
–
show
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.
If you suppress an error, we recommend checking for the error condition explicitly: // For example instead of
@mkdir($dir);
// Better use
if (@mkdir($dir) === false) {
throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
![]() |
|||
1771 | } else { |
||
1772 | $plugin_returns_backup = $plugin_returns; |
||
1773 | $this->year = date('Y', $wtop_unixtime); |
||
1774 | $this->month = $wtop_month; |
||
1775 | @include $this->base_path . '/' . $this->plugins_path_monthly . '/' . $plugin['file']; |
||
0 ignored issues
–
show
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.
If you suppress an error, we recommend checking for the error condition explicitly: // For example instead of
@mkdir($dir);
// Better use
if (@mkdir($dir) === false) {
throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
![]() |
|||
1776 | View Code Duplication | for ($d = 1; $d < 21; ++$d) { |
|
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. ![]() |
|||
1777 | $plugin_returns[$d] = @$plugin_returns_backup[$d]; |
||
1778 | } |
||
1779 | $plugin_returns_backup = $plugin_returns; |
||
1780 | $this->year = date('Y', $wlast_unixtime); |
||
1781 | $this->month = $wlast_month; |
||
1782 | @include $this->base_path . '/' . $this->plugins_path_monthly . '/' . $plugin['file']; |
||
0 ignored issues
–
show
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.
If you suppress an error, we recommend checking for the error condition explicitly: // For example instead of
@mkdir($dir);
// Better use
if (@mkdir($dir) === false) {
throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
![]() |
|||
1783 | View Code Duplication | for ($d = 8; $d < 32; ++$d) { |
|
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. ![]() |
|||
1784 | $plugin_returns[$d] = @$plugin_returns_backup[$d]; |
||
1785 | } |
||
1786 | $this->year = $year_backup; |
||
1787 | $this->month = $month_backup; |
||
1788 | } |
||
1789 | } |
||
1790 | } |
||
1791 | } |
||
1792 | |||
1793 | $tzoffset = (int)(($this->user_TZ - $this->server_TZ) * 3600); |
||
1794 | if ($tzoffset == 0) { |
||
1795 | $whr_term = "start<='$wlast_unixtime' AND end>'$wtop_unixtime'"; |
||
1796 | } else { |
||
1797 | $whr_term = "(allday AND start<='$wlast_unixtime' AND end>'$wtop_unixtime') || ( ! allday AND start<='" |
||
1798 | . ($wlast_unixtime - $tzoffset) |
||
1799 | . "' AND end>'" |
||
1800 | . ($wtop_unixtime - $tzoffset) |
||
1801 | . "')"; |
||
1802 | } |
||
1803 | |||
1804 | $whr_categories = $this->get_where_about_categories(); |
||
1805 | $whr_class = $this->get_where_about_class(); |
||
1806 | |||
1807 | $ars = $GLOBALS['xoopsDB']->query("SELECT * FROM $this->table WHERE admission>0 AND ($whr_term) AND ($whr_categories) AND ($whr_class) ORDER BY start"); |
||
1808 | $numrows_ars = $GLOBALS['xoopsDB']->getRowsNum($ars); |
||
1809 | $wrs = $GLOBALS['xoopsDB']->query("SELECT * FROM $this->table WHERE admission=0 AND ($whr_term) AND ($whr_categories) AND ($whr_class) ORDER BY start"); |
||
1810 | $numrows_wrs = $GLOBALS['xoopsDB']->getRowsNum($wrs); |
||
1811 | |||
1812 | $now_date = $wtop_date; |
||
1813 | $wday_end = 7 + $this->week_start; |
||
1814 | for ($wday = $this->week_start; $wday < $wday_end; ++$wday, ++$now_date) { |
||
1815 | $now_unixtime = mktime(0, 0, 0, $this->month, $now_date, $this->year); |
||
1816 | $toptime_of_day = $now_unixtime + $this->day_start - $tzoffset; |
||
1817 | $bottomtime_of_day = $toptime_of_day + 86400; |
||
1818 | $link = date('Y-n-j', $now_unixtime); |
||
1819 | $date = date('j', $now_unixtime); |
||
1820 | $disp = $this->get_middle_md($now_unixtime); |
||
1821 | $disp .= "<br>({$this->week_middle_names[$wday]})"; |
||
1822 | $date_part_append = ''; |
||
1823 | $event_str = " |
||
1824 | <table cellpadding='0' cellspacing='2' style='margin:0px;'> |
||
1825 | <tr> |
||
1826 | <td><img src='$this->images_url/spacer.gif' alt='' border='0' width='120' height='4' /></td> |
||
1827 | <td><img src='$this->images_url/spacer.gif' alt='' border='0' width='360' height='4' /></td> |
||
1828 | </tr> |
||
1829 | \n"; |
||
1830 | |||
1831 | if ($numrows_ars > 0) { |
||
1832 | mysqli_data_seek($ars, 0); |
||
1833 | } |
||
1834 | while ($event = $GLOBALS['xoopsDB']->fetchObject($ars)) { |
||
1835 | if ($event->allday & 4) { |
||
1836 | $event->end += 86400; |
||
1837 | } |
||
1838 | View Code Duplication | if ($event->gmlat > 0 || $event->gmlong > 0) { |
|
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. ![]() |
|||
1839 | $this->gmPoints[] = array( |
||
1840 | 'summary' => $event->summary, |
||
1841 | 'gmlat' => $event->gmlat, |
||
1842 | 'gmlong' => $event->gmlong, |
||
1843 | 'location' => $event->location, |
||
1844 | 'contact' => $event->contact, |
||
1845 | 'startDate' => date('j', $event->start + $tzoffset), |
||
1846 | 'event_id' => $event->id |
||
1847 | ); |
||
1848 | } |
||
1849 | |||
1850 | View Code Duplication | if ($event->allday) { |
|
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. ![]() |
|||
1851 | if ($event->start + $tzoffset >= $now_unixtime + 86400 |
||
1852 | || $event->end + $tzoffset <= $now_unixtime |
||
1853 | ) { |
||
1854 | continue; |
||
1855 | } |
||
1856 | } else { |
||
1857 | if ($event->start + $tzoffset >= $bottomtime_of_day |
||
1858 | || $event->start + $tzoffset != $toptime_of_day |
||
1859 | && $event->end + $tzoffset <= $toptime_of_day |
||
1860 | ) { |
||
1861 | continue; |
||
1862 | } |
||
1863 | |||
1864 | $event->is_start_date = $event->start + $tzoffset >= $toptime_of_day; |
||
1865 | $event->is_end_date = $event->end + $tzoffset <= $bottomtime_of_day; |
||
1866 | } |
||
1867 | |||
1868 | $summary = $this->text_sanitizer_for_show($event->summary); |
||
1869 | |||
1870 | // Get picture |
||
1871 | $pic = $GLOBALS['xoopsDB']->fetchObject($GLOBALS['xoopsDB']->query("SELECT picture FROM {$this->pic_table} WHERE event_id={$event->id} AND main_pic=1 LIMIT 0,1")); |
||
1872 | $picture = $pic && $this->showPicWeekly ? "<img src='" . XOOPS_UPLOAD_URL . "/apcal/{$pic->picture}' alt='{$summary}' height='50' style='vertical-align: middle;' />" : ''; |
||
1873 | |||
1874 | if ($event->allday) { |
||
1875 | if ($event->allday & 4) { |
||
1876 | $date_part_append .= "<span style='font-size: x-small; '><a href='{$this->make_event_link($event->id, $get_target)}' class='cal_summary_specialday'><font color='$this->holiday_color'>$summary</a></span>"; |
||
1877 | View Code Duplication | if ($event->extkey0 == 1) { |
|
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. ![]() |
|||
1878 | $event_str .= " <img src='{$roimage}' height='15px' alt='" . _APCAL_RO_ONLINE_POSS . "' title='" . _APCAL_RO_ONLINE_POSS . "' />"; |
||
1879 | } // added by goffy: mark this event, that online registration is active |
||
1880 | $event_str .= "</a></font><br>\n"; |
||
1881 | continue; |
||
1882 | } else { |
||
1883 | $time_part = " <img border='0' src='$this->images_url/dot_allday.gif' />"; |
||
1884 | $summary_class = 'calsummary_allday'; |
||
1885 | } |
||
1886 | View Code Duplication | } else { |
|
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. ![]() |
|||
1887 | $time_part = $this->get_time_desc_for_a_day($event, $tzoffset, $bottomtime_of_day - $this->day_start, true, true); |
||
1888 | $summary_class = 'calsummary'; |
||
1889 | } |
||
1890 | |||
1891 | $event_str .= " |
||
1892 | <tr> |
||
1893 | <td valign='top' align='center'> |
||
1894 | <pre style='margin:0px;'><span style='font-size: x-small; '>$time_part</span></pre> |
||
1895 | </td> |
||
1896 | <td valign='top'> |
||
1897 | $picture |
||
1898 | <span style='font-size: x-small; '><a href='{$this->make_event_link($event->id, $get_target)}' class='$summary_class'>$summary</a></span>"; |
||
1899 | View Code Duplication | if ($event->extkey0 == 1) { |
|
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. ![]() |
|||
1900 | $event_str .= " <img src='{$roimage}' height='15px' alt='" . _APCAL_RO_ONLINE_POSS . "' title='" . _APCAL_RO_ONLINE_POSS . "' />"; |
||
1901 | } // added by goffy: mark this event, that online registration is active |
||
1902 | $event_str .= " |
||
1903 | </td> |
||
1904 | </tr> |
||
1905 | \n"; |
||
1906 | } |
||
1907 | |||
1908 | if ($this->isadmin || $this->user_id > 0) { |
||
1909 | if ($numrows_wrs > 0) { |
||
1910 | mysqli_data_seek($wrs, 0); |
||
1911 | } |
||
1912 | while ($event = $GLOBALS['xoopsDB']->fetchObject($wrs)) { |
||
1913 | View Code Duplication | if ($event->allday) { |
|
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. ![]() |
|||
1914 | if ($event->start + $tzoffset >= $now_unixtime + 86400 |
||
1915 | || $event->end + $tzoffset <= $now_unixtime |
||
1916 | ) { |
||
1917 | continue; |
||
1918 | } |
||
1919 | } else { |
||
1920 | if ($event->start + $tzoffset >= $bottomtime_of_day |
||
1921 | || $event->start + $tzoffset != $toptime_of_day |
||
1922 | && $event->end + $tzoffset <= $toptime_of_day |
||
1923 | ) { |
||
1924 | continue; |
||
1925 | } |
||
1926 | $event->is_start_date = $event->start + $tzoffset >= $toptime_of_day; |
||
1927 | $event->is_end_date = $event->end + $tzoffset <= $bottomtime_of_day; |
||
1928 | } |
||
1929 | |||
1930 | $summary = $this->text_sanitizer_for_show($event->summary); |
||
1931 | |||
1932 | // Get picture |
||
1933 | $pic = $GLOBALS['xoopsDB']->fetchObject($GLOBALS['xoopsDB']->query("SELECT picture FROM {$this->pic_table} WHERE event_id={$event->id} AND main_pic=1 LIMIT 0,1")); |
||
1934 | $picture = $pic && $this->showPicWeekly ? "<img src='" . XOOPS_UPLOAD_URL . "/apcal/{$pic->picture}' alt='{$summary}' height='50' style='vertical-align: middle;' />" : ''; |
||
1935 | |||
1936 | if ($event->allday) { |
||
1937 | $time_part = " <img border='0' src='$this->images_url/dot_notadmit.gif' />"; |
||
1938 | $summary_class = 'calsummary_allday'; |
||
1939 | View Code Duplication | } else { |
|
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. ![]() |
|||
1940 | $time_part = $this->get_time_desc_for_a_day($event, $tzoffset, $bottomtime_of_day - $this->day_start, true, false); |
||
1941 | $summary_class = 'calsummary'; |
||
1942 | } |
||
1943 | |||
1944 | $event_str .= " |
||
1945 | <tr> |
||
1946 | <td valign='top' align='center'> |
||
1947 | <pre style='margin:0px;'><span style='font-size: x-small; '>$time_part</span></pre> |
||
1948 | </td> |
||
1949 | <td valign='top'> |
||
1950 | $picture |
||
1951 | <span style='font-size: x-small; '><a href='{$this->make_event_link($event->id, $get_target)}' class='$summary_class'><font color='#00FF00'>$summary(" |
||
1952 | . _APCAL_MB_EVENT_NEEDADMIT |
||
1953 | . ')</a></span>'; |
||
1954 | View Code Duplication | if ($event->extkey0 == 1) { |
|
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. ![]() |
|||
1955 | $event_str .= " <img src='{$roimage}' height='15px' alt='" . _APCAL_RO_ONLINE_POSS . "' title='" . _APCAL_RO_ONLINE_POSS . "' />"; |
||
1956 | } // added by goffy: mark this event, that online registration is active |
||
1957 | $event_str .= " |
||
1958 | </td> |
||
1959 | </tr> |
||
1960 | \n"; |
||
1961 | } |
||
1962 | } |
||
1963 | |||
1964 | // drawing the result of plugins |
||
1965 | if (!empty($plugin_returns[$date])) { |
||
1966 | View Code Duplication | foreach ($plugin_returns[$date] as $item) { |
|
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. ![]() |
|||
1967 | $event_str .= " |
||
1968 | <tr> |
||
1969 | <td></td> |
||
1970 | <td valign='top'> |
||
1971 | <span style='font-size: x-small; '><a href='{$item['link']}' class='$summary_class'><img src='$this->images_url/{$item['dotgif']}' alt='{$item['title']}>' />{$item['title']}</a></span> |
||
0 ignored issues
–
show
The variable
$summary_class does not seem to be defined for all execution paths leading up to this point.
If you define a variable conditionally, it can happen that it is not defined for all execution paths. Let’s take a look at an example: function myFunction($a) {
switch ($a) {
case 'foo':
$x = 1;
break;
case 'bar':
$x = 2;
break;
}
// $x is potentially undefined here.
echo $x;
}
In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined. Available Fixes
![]() |
|||
1972 | </td> |
||
1973 | </tr>\n"; |
||
1974 | } |
||
1975 | } |
||
1976 | |||
1977 | if ($this->insertable) { |
||
1978 | $event_str .= " |
||
1979 | <tr> |
||
1980 | <td valign='bottom' colspan='2'> |
||
1981 | <span style='font-size: x-small; '><a href='$get_target?cid=$this->now_cid&smode=Weekly&action=Edit&caldate=$link'><img src='$this->images_url/addevent.gif' border='0' width='14' height='12' />" |
||
1982 | . _APCAL_MB_ADDEVENT |
||
1983 | . "</a></span> |
||
1984 | </td> |
||
1985 | </tr> |
||
1986 | \n"; |
||
1987 | } |
||
1988 | |||
1989 | $event_str .= "\t\t\t\t</table>\n"; |
||
1990 | |||
1991 | if (isset($this->holidays[$link])) { |
||
1992 | // Holiday |
||
1993 | $bgcolor = $this->holiday_bgcolor; |
||
1994 | $color = $this->holiday_color; |
||
1995 | if ($this->holidays[$link] != 1) { |
||
1996 | $date_part_append .= "<span color='$this->holiday_color'>{$this->holidays[ $link ]}</span>\n"; |
||
1997 | } |
||
1998 | } elseif ($wday % 7 == 0) { |
||
1999 | // Sunday |
||
2000 | $bgcolor = $this->sunday_bgcolor; |
||
2001 | $color = $this->sunday_color; |
||
2002 | } elseif ($wday == 6) { |
||
2003 | // Saturday |
||
2004 | $bgcolor = $this->saturday_bgcolor; |
||
2005 | $color = $this->saturday_color; |
||
2006 | } else { |
||
2007 | // Weekday |
||
2008 | $bgcolor = $this->weekday_bgcolor; |
||
2009 | $color = $this->weekday_color; |
||
2010 | } |
||
2011 | |||
2012 | // ��������طʿ��ϥ��饤�Ƚ��� |
||
2013 | if ($link == $this->caldate) { |
||
2014 | $body_bgcolor = $this->targetday_bgcolor; |
||
2015 | } else { |
||
2016 | $body_bgcolor = $bgcolor; |
||
2017 | } |
||
2018 | |||
2019 | $ret .= " |
||
2020 | <tr> |
||
2021 | <td><img src='$this->images_url/spacer.gif' alt='' width='10' height='80' /></td> |
||
2022 | <td bgcolor='$bgcolor' align='center' valign='middle' style='vertical-align:middle;text-align:center;$this->frame_css background-color:$bgcolor;'> |
||
2023 | <a href='{$this->make_cal_link($get_target, 'Daily', $this->now_cid, $link)}' class='calbody'><font size='3' color='$color'><b><span class='calbody'>$disp</span></b></font></a><br> |
||
2024 | $date_part_append |
||
2025 | </td> |
||
2026 | <td valign='top' colspan='6' bgcolor='$body_bgcolor' style='$this->frame_css background-color:$body_bgcolor'> |
||
2027 | $event_str |
||
2028 | </td> |
||
2029 | </tr>\n"; |
||
2030 | } |
||
2031 | |||
2032 | $ret .= "\t </table>\n"; |
||
2033 | |||
2034 | return $ret; |
||
2035 | } |
||
2036 | |||
2037 | // Get the html for the daily view |
||
2038 | |||
2039 | /** |
||
2040 | * @param string $get_target |
||
2041 | * @return string |
||
2042 | */ |
||
2043 | public function get_daily_html($get_target = '') |
||
2044 | { |
||
2045 | $roimage = XOOPS_URL . '/modules/apcal/assets/images/regonline/regonline.png'; // added by goffy: image for online registration |
||
2046 | // get the result of plugins |
||
2047 | $plugin_returns = array(); |
||
2048 | if (strtolower(get_class($this)) === 'apcal_xoops') { |
||
2049 | $db = XoopsDatabaseFactory::getDatabaseConnection(); |
||
2050 | $myts = MyTextSanitizer::getInstance(); |
||
2051 | $now = time(); |
||
2052 | $just1gif = 0; |
||
2053 | |||
2054 | $tzoffset_s2u = (int)(($this->user_TZ - $this->server_TZ) * 3600); |
||
2055 | $plugins = $this->get_plugins('daily'); |
||
0 ignored issues
–
show
It seems like you code against a specific sub-type and not the parent class
APCal as the method get_plugins() does only exist in the following sub-classes of APCal : APCal_xoops . Maybe you want to instanceof check for one of these explicitly?
Let’s take a look at an example: abstract class User
{
/** @return string */
abstract public function getPassword();
}
class MyUser extends User
{
public function getPassword()
{
// return something
}
public function getDisplayName()
{
// return some name.
}
}
class AuthSystem
{
public function authenticate(User $user)
{
$this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
// do something.
}
}
In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break. Available Fixes
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types
inside the if block in such a case.
![]() |
|||
2056 | foreach ($plugins as $plugin) { |
||
2057 | $include_ret = @include $this->base_path . '/' . $this->plugins_path_daily . '/' . $plugin['file']; |
||
2058 | if ($include_ret === false) { |
||
2059 | // daily emulator by monthly plugin |
||
2060 | @include $this->base_path . '/' . $this->plugins_path_monthly . '/' . $plugin['file']; |
||
0 ignored issues
–
show
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.
If you suppress an error, we recommend checking for the error condition explicitly: // For example instead of
@mkdir($dir);
// Better use
if (@mkdir($dir) === false) {
throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
![]() |
|||
2061 | } |
||
2062 | } |
||
2063 | } |
||
2064 | |||
2065 | list($bgcolor, $color) = $this->daytype_to_colors($this->daytype); |
||
0 ignored issues
–
show
The assignment to
$color is unused. Consider omitting it like so list($first,,$third) .
This checks looks for assignemnts to variables using the Consider the following code example. <?php
function returnThreeValues() {
return array('a', 'b', 'c');
}
list($a, $b, $c) = returnThreeValues();
print $a . " - " . $c;
Only the variables Instead, the list call could have been. list($a,, $c) = returnThreeValues();
![]() |
|||
2066 | |||
2067 | $ret = " |
||
2068 | <table border='0' cellspacing='0' cellpadding='0' width='100%' style='margin:0px;'> |
||
2069 | <tr> |
||
2070 | <td width='100%' class='calframe'> |
||
2071 | <table border='0' cellspacing='0' cellpadding='0' width='100%' style='margin:0px;'> |
||
2072 | <tr> |
||
2073 | <td colspan='8'><img src='$this->images_url/spacer.gif' alt='' width='570' height='10' /></td> |
||
2074 | </tr> |
||
2075 | <tr> |
||
2076 | <td><img src='$this->images_url/spacer.gif' alt='' width='10' height='350' /></td> |
||
2077 | <td colospan='7' valign='top' bgcolor='$bgcolor' style='$this->frame_css;background-color:$bgcolor'> |
||
2078 | <table border='0' cellpadding='0' cellspacing='0' style='margin:0px;'> |
||
2079 | <tr> |
||
2080 | <td><img src='$this->images_url/spacer.gif' alt='' width='120' height='10' /></td> |
||
2081 | <td><img src='$this->images_url/spacer.gif' alt='' width='440' height='10' /></td> |
||
2082 | </tr> |
||
2083 | \n"; |
||
2084 | |||
2085 | // WHERE Clause - Date |
||
2086 | $tzoffset = (int)(($this->user_TZ - $this->server_TZ) * 3600); |
||
2087 | $toptime_of_day = $this->unixtime + $this->day_start - $tzoffset; |
||
2088 | $bottomtime_of_day = $toptime_of_day + 86400; |
||
2089 | $whr_term = "(allday AND start<='$this->unixtime' AND end>'$this->unixtime') || ( ! allday AND start<'$bottomtime_of_day' AND (start='$toptime_of_day' OR end>'$toptime_of_day'))"; |
||
2090 | |||
2091 | // WHERE Clause - Categories |
||
2092 | $whr_categories = $this->get_where_about_categories(); |
||
2093 | |||
2094 | // WHERE Clause - Class |
||
2095 | $whr_class = $this->get_where_about_class(); |
||
2096 | |||
2097 | // MySQL Query |
||
2098 | $yrs = $GLOBALS['xoopsDB']->query("SELECT *,(start>='$toptime_of_day') AS is_start_date,(end<='$bottomtime_of_day') AS is_end_date FROM $this->table WHERE admission>0 AND ($whr_term) AND ($whr_categories) AND ($whr_class) ORDER BY start,end"); |
||
2099 | $num_rows = $GLOBALS['xoopsDB']->getRowsNum($yrs); |
||
2100 | |||
2101 | if ($num_rows == 0) { |
||
2102 | $ret .= '<tr><td></td><td>' . _APCAL_MB_NOEVENT . "</td></tr>\n"; |
||
2103 | } else { |
||
2104 | while ($event = $GLOBALS['xoopsDB']->fetchObject($yrs)) { |
||
2105 | // Get picture |
||
2106 | $pic = $GLOBALS['xoopsDB']->fetchObject($GLOBALS['xoopsDB']->query("SELECT picture FROM {$this->pic_table} WHERE event_id={$event->id} AND main_pic=1 LIMIT 0,1")); |
||
2107 | $picture = $pic && $this->showPicDaily ? "<img src='" . XOOPS_UPLOAD_URL . "/apcal/{$pic->picture}' alt='{$summary}' height='50' style='vertical-align: middle;' />" : ''; |
||
0 ignored issues
–
show
The variable
$summary does not seem to be defined for all execution paths leading up to this point.
If you define a variable conditionally, it can happen that it is not defined for all execution paths. Let’s take a look at an example: function myFunction($a) {
switch ($a) {
case 'foo':
$x = 1;
break;
case 'bar':
$x = 2;
break;
}
// $x is potentially undefined here.
echo $x;
}
In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined. Available Fixes
![]() |
|||
2108 | |||
2109 | // Google map |
||
2110 | View Code Duplication | if ($event->gmlat > 0 || $event->gmlong > 0) { |
|
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. ![]() |
|||
2111 | $this->gmPoints[] = array( |
||
2112 | 'summary' => $event->summary, |
||
2113 | 'gmlat' => $event->gmlat, |
||
2114 | 'gmlong' => $event->gmlong, |
||
2115 | 'location' => $event->location, |
||
2116 | 'contact' => $event->contact, |
||
2117 | 'startDate' => date('j', $event->start), |
||
2118 | 'event_id' => $event->id |
||
2119 | ); |
||
2120 | } |
||
2121 | |||
2122 | View Code Duplication | if ($event->allday) { |
|
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. ![]() |
|||
2123 | $time_part = " <img border='0' src='$this->images_url/dot_allday.gif' />"; |
||
2124 | } else { |
||
2125 | $time_part = $this->get_time_desc_for_a_day($event, $tzoffset, $bottomtime_of_day - $this->day_start, true, true); |
||
2126 | } |
||
2127 | |||
2128 | $description = $this->textarea_sanitizer_for_show($event->description); |
||
2129 | $summary = $this->text_sanitizer_for_show($event->summary); |
||
2130 | $summary_class = $event->allday ? 'calsummary_allday' : 'calsummary'; |
||
2131 | |||
2132 | $ret .= " |
||
2133 | <tr> |
||
2134 | <td valign='middle' align='center'> |
||
2135 | <pre style='margin:0px;'><font size='3'>$time_part</font></pre> |
||
2136 | </td> |
||
2137 | <td valign='middle'> |
||
2138 | <a href='{$this->make_event_link($event->id, $get_target)}'>{$picture}</a> |
||
2139 | <font size='3'><a href='{$this->make_event_link($event->id, $get_target)}' class='$summary_class'>$summary</a></font>"; |
||
2140 | View Code Duplication | if ($event->extkey0 == 1) { |
|
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. ![]() |
|||
2141 | $ret .= " <img src='{$roimage}' height='15px' alt='" . _APCAL_RO_ONLINE_POSS . "' title='" . _APCAL_RO_ONLINE_POSS . "'>"; |
||
2142 | } // added by goffy: mark this event, that online registration is active |
||
2143 | $ret .= "<br> |
||
2144 | <span style='font-size: x-small; '>$description</span><br> |
||
2145 | |
||
2146 | </td> |
||
2147 | </tr>\n"; |
||
2148 | } |
||
2149 | } |
||
2150 | |||
2151 | if ($this->isadmin || $this->user_id > 0) { |
||
2152 | $whr_uid = $this->isadmin ? '1' : "uid=$this->user_id "; |
||
2153 | $yrs = $GLOBALS['xoopsDB']->query("SELECT start,end,summary,id,allday,admission,uid,description,(start>='$toptime_of_day') AS is_start_date,(end<='$bottomtime_of_day') AS is_end_date FROM $this->table WHERE admission=0 AND $whr_uid AND ($whr_term) AND ($whr_categories) AND ($whr_class) ORDER BY start,end"); |
||
2154 | |||
2155 | while ($event = $GLOBALS['xoopsDB']->fetchObject($yrs)) { |
||
2156 | View Code Duplication | if ($event->allday) { |
|
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. ![]() |
|||
2157 | $time_part = " <img border='0' src='$this->images_url/dot_notadmit.gif' />"; |
||
2158 | } else { |
||
2159 | $time_part = $this->get_time_desc_for_a_day($event, $tzoffset, $bottomtime_of_day - $this->day_start, true, false); |
||
2160 | } |
||
2161 | |||
2162 | $summary = $this->text_sanitizer_for_show($event->summary); |
||
2163 | |||
2164 | $summary_class = $event->allday ? 'calsummary_allday' : 'calsummary'; |
||
2165 | |||
2166 | $ret .= " |
||
2167 | <tr> |
||
2168 | <td valign='top' align='center'> |
||
2169 | <pre style='margin:0px;'><font size='3'>$time_part</font></pre> |
||
2170 | </td> |
||
2171 | <td vlalign='top'> |
||
2172 | <font size='3'><a href='{$this->make_event_link($event->id, $get_target)}' class='$summary_class'><font color='#00FF00'>{$summary}</a></font>"; |
||
2173 | View Code Duplication | if ($event->extkey0 == 1) { |
|
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. ![]() |
|||
2174 | $ret .= " <img src='{$roimage}' height='15px' alt='" . _APCAL_RO_ONLINE_POSS . "' title='" . _APCAL_RO_ONLINE_POSS . "'>"; |
||
2175 | } // added by goffy: mark this event, that online registration is active |
||
2176 | $ret .= ' (' . _APCAL_MB_EVENT_NEEDADMIT . ") |
||
2177 | </td> |
||
2178 | </tr>\n"; |
||
2179 | } |
||
2180 | } |
||
2181 | |||
2182 | // drawing the result of plugins |
||
2183 | if (!empty($plugin_returns[$this->date])) { |
||
2184 | View Code Duplication | foreach ($plugin_returns[$this->date] as $item) { |
|
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. ![]() |
|||
2185 | $ret .= " |
||
2186 | <tr> |
||
2187 | <td></td> |
||
2188 | <td valign='top'> |
||
2189 | <font size='3'><a href='{$item['link']}' class='$summary_class'><img src='$this->images_url/{$item['dotgif']}' alt='{$item['title']}>' />{$item['title']}</a></font><br> |
||
0 ignored issues
–
show
The variable
$summary_class does not seem to be defined for all execution paths leading up to this point.
If you define a variable conditionally, it can happen that it is not defined for all execution paths. Let’s take a look at an example: function myFunction($a) {
switch ($a) {
case 'foo':
$x = 1;
break;
case 'bar':
$x = 2;
break;
}
// $x is potentially undefined here.
echo $x;
}
In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined. Available Fixes
![]() |
|||
2190 | <span style='font-size: x-small; '>{$item['description']}</span><br> |
||
2191 | |
||
2192 | </td> |
||
2193 | </tr>\n"; |
||
2194 | } |
||
2195 | } |
||
2196 | |||
2197 | // ͽ����ɲáʱ�ɮ��������� |
||
2198 | View Code Duplication | if ($this->insertable) { |
|
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. ![]() |
|||
2199 | $ret .= " |
||
2200 | <tr> |
||
2201 | <td valign='bottom' colspan='2'> |
||
2202 | <span style='font-size: x-small; '><a href='$get_target?cid=$this->now_cid&smode=Daily&action=Edit&caldate=$this->caldate'><img src='$this->images_url/addevent.gif' border='0' width='14' height='12' />" |
||
2203 | . _APCAL_MB_ADDEVENT |
||
2204 | . "</a></span> |
||
2205 | </td> |
||
2206 | </tr>\n"; |
||
2207 | } |
||
2208 | |||
2209 | $ret .= " |
||
2210 | </table> |
||
2211 | </td> |
||
2212 | </tr> |
||
2213 | </table> |
||
2214 | </td> |
||
2215 | </tr> |
||
2216 | </table>\n"; |
||
2217 | |||
2218 | return $ret; |
||
2219 | } |
||
2220 | |||
2221 | /*******************************************************************/ |
||
2222 | /* �ᥤ���� �ʸ��̥ǡ������� */ |
||
2223 | /*******************************************************************/ |
||
2224 | |||
2225 | /** |
||
2226 | * @param $event_id |
||
2227 | */ |
||
2228 | public function savepictures($event_id) |
||
2229 | { |
||
2230 | xoops_load('xoopsmediauploader'); |
||
2231 | $uploader = new XoopsMediaUploader(XOOPS_UPLOAD_PATH . '/apcal', array( |
||
2232 | 'image/gif', |
||
2233 | 'image/jpeg', |
||
2234 | 'image/pjpeg', |
||
2235 | 'image/x-png', |
||
2236 | 'image/png', |
||
2237 | 'image/bmp' |
||
2238 | ), $_POST['MAX_FILE_SIZE'], 4048, 4048); |
||
2239 | $uploader->setPrefix('APCal'); |
||
2240 | $err = array(); |
||
2241 | foreach ($_POST['files'] as $i => $file) { |
||
2242 | $main_pic = $file === 'picture0' ? 1 : 0; |
||
2243 | if ($uploader->fetchMedia($file)) { |
||
2244 | if (!$uploader->upload()) { |
||
2245 | $err[] = $uploader->getErrors(); |
||
2246 | } else { |
||
2247 | $filename = $uploader->getSavedFileName(); |
||
2248 | $result = $GLOBALS['xoopsDB']->query("INSERT INTO {$this->pic_table}(event_id, picture, main_pic) VALUES ({$event_id}, '{$filename}', {$main_pic})"); |
||
2249 | if (!$result) { |
||
2250 | $err[] = sprintf(_FAILSAVEIMG, $i); |
||
2251 | } else { |
||
2252 | Thumb::save($filename, $this->picWidth, $this->picHeight); |
||
2253 | } |
||
2254 | } |
||
2255 | } else { |
||
2256 | $err[] = sprintf(_FAILFETCHIMG, $i); |
||
2257 | $err = array_merge($err, $uploader->getErrors(false)); |
||
2258 | } |
||
2259 | } |
||
2260 | |||
2261 | //FOR DEBUG: var_dump($err); |
||
2262 | } |
||
2263 | |||
2264 | // Show an event |
||
2265 | |||
2266 | /** |
||
2267 | * @param bool $for_print |
||
2268 | * @return string |
||
0 ignored issues
–
show
|
|||
2269 | */ |
||
2270 | public function get_schedule_view_html($for_print = false) |
||
2271 | { |
||
2272 | global $xoopsTpl; |
||
2273 | |||
2274 | $smode = empty($_GET['smode']) ? 'Monthly' : preg_replace('/[^a-zA-Z0-9_-]/', '', $_GET['smode']); |
||
2275 | $editable = $this->editable; |
||
2276 | $superedit = $this->superedit; |
||
2277 | $deletable = $this->deletable; |
||
2278 | |||
2279 | $whr_categories = $this->get_where_about_categories(); |
||
2280 | |||
2281 | // CLASS |
||
2282 | $whr_class = $this->get_where_about_class(); |
||
2283 | |||
2284 | if (empty($_GET['event_id'])) { |
||
2285 | die(_APCAL_ERR_INVALID_EVENT_ID); |
||
2286 | } |
||
2287 | $this->original_id = $event_id = (int)$_GET['event_id']; |
||
2288 | $yrs = $GLOBALS['xoopsDB']->query("SELECT *,UNIX_TIMESTAMP(dtstamp) AS udtstamp FROM $this->table WHERE id='$event_id' AND ($whr_categories) AND ($whr_class)"); |
||
2289 | if ($GLOBALS['xoopsDB']->getRowsNum($yrs) < 1) { |
||
2290 | die(_APCAL_ERR_INVALID_EVENT_ID); |
||
2291 | } |
||
2292 | $event = $GLOBALS['xoopsDB']->fetchObject($yrs); |
||
2293 | |||
2294 | // rrule |
||
2295 | if (trim($event->rrule) !== '') { |
||
2296 | if ($event->rrule_pid != $event->id) { |
||
2297 | $event->id = $event->rrule_pid; |
||
2298 | $yrs = $GLOBALS['xoopsDB']->query("SELECT id,start,start_date FROM $this->table WHERE id='$event->rrule_pid' AND ($whr_categories) AND ($whr_class)"); |
||
2299 | if ($GLOBALS['xoopsDB']->getRowsNum($yrs) >= 1) { |
||
2300 | $event->id = $event->rrule_pid; |
||
2301 | $parent_event = $GLOBALS['xoopsDB']->fetchObject($yrs); |
||
2302 | $this->original_id = $parent_event->id; |
||
2303 | $is_extracted_record = true; |
||
2304 | } else { |
||
2305 | $parent_event = $event; |
||
2306 | } |
||
2307 | } |
||
2308 | $rrule = $this->rrule_to_human_language($event->rrule); |
||
2309 | } else { |
||
2310 | $rrule = ''; |
||
2311 | } |
||
2312 | |||
2313 | // submitter of event |
||
2314 | if ($event->uid != $this->user_id) { |
||
2315 | $editable = false; |
||
2316 | $deletable = false; |
||
2317 | } |
||
2318 | // user is admin or has right to edit/delete all events |
||
2319 | if ($this->isadmin || $superedit) { |
||
2320 | $editable = true; |
||
2321 | $deletable = true; |
||
2322 | } |
||
2323 | |||
2324 | // editable |
||
2325 | if (!$event->admission && !$editable) { |
||
2326 | die(_APCAL_ERR_NOPERM_TO_SHOW); |
||
2327 | } |
||
2328 | |||
2329 | if ($editable && !$for_print) { |
||
2330 | $edit_button = " |
||
2331 | <form class='apcalForm' method='get' action='" . XOOPS_URL . "/modules/apcal/index.php' style='margin:0px;'> |
||
2332 | <input type='hidden' name='smode' value='$smode' /> |
||
2333 | <input type='hidden' name='action' value='Edit' /> |
||
2334 | <input type='hidden' name='event_id' value='$event->id' /> |
||
2335 | <input type='hidden' name='caldate' value='{$_GET['date']}' /> |
||
2336 | <input type='submit' value='" . _APCAL_BTN_EDITEVENT . "' /> |
||
2337 | </form>\n"; |
||
2338 | } else { |
||
2339 | $edit_button = ''; |
||
2340 | } |
||
2341 | |||
2342 | if ($deletable && !$for_print) { |
||
2343 | $delete_button = " |
||
2344 | <form class='apcalForm' method='post' action='" |
||
2345 | . XOOPS_URL |
||
2346 | . "/modules/apcal/index.php' id='MainForm' name='MainForm' style='margin:0px;'> |
||
2347 | <input type='hidden' name='smode' value='$smode' /> |
||
2348 | <input type='hidden' name='last_smode' value='$smode' /> |
||
2349 | <input type='hidden' name='event_id' value='$event->id' /> |
||
2350 | <input type='hidden' name='subevent_id' value='$event_id' /> |
||
2351 | <input type='hidden' name='caldate' value='$this->caldate' /> |
||
2352 | <input type='hidden' name='last_caldate' value='{$_GET['date']}' /> |
||
2353 | <input type='submit' name='delete' value='" |
||
2354 | . _APCAL_BTN_DELETE |
||
2355 | . "' onclick='return confirm(\"" |
||
2356 | . _APCAL_CNFM_DELETE_YN |
||
2357 | . "\")' /> |
||
2358 | " |
||
2359 | . (!empty($is_extracted_record) ? "<input type='submit' name='delete_one' value='" |
||
2360 | . _APCAL_BTN_DELETE_ONE |
||
2361 | . "' onclick='return confirm(\"" |
||
2362 | . _APCAL_CNFM_DELETE_YN |
||
2363 | . "\")' />" : '') |
||
2364 | . ' |
||
2365 | ' |
||
2366 | . $GLOBALS['xoopsGTicket']->getTicketHtml(__LINE__) |
||
2367 | . " |
||
2368 | </form>\n"; |
||
2369 | } else { |
||
2370 | $delete_button = ''; |
||
2371 | } |
||
2372 | |||
2373 | // iCalendar |
||
2374 | if ($this->can_output_ics && !$for_print) { |
||
2375 | $php_self4disp = strtr(@$_SERVER['PHP_SELF'], '<>\'"', ' '); |
||
2376 | $ics_output_button = " |
||
2377 | <a href='http://{$_SERVER['HTTP_HOST']}$php_self4disp?fmt=single&event_id=$event->id&output_ics=1' target='_blank'><img border='0' src='$this->images_url/output_ics_win.gif' alt='" |
||
2378 | . _APCAL_BTN_OUTPUTICS_WIN |
||
2379 | . "' title='" |
||
2380 | . _APCAL_BTN_OUTPUTICS_WIN |
||
2381 | . "' /></a> |
||
2382 | <a href='webcal://{$_SERVER['HTTP_HOST']}$php_self4disp?fmt=single&event_id=$event->id&output_ics=1' target='_blank'><img border='0' src='$this->images_url/output_ics_mac.gif' alt='" |
||
2383 | . _APCAL_BTN_OUTPUTICS_MAC |
||
2384 | . "' title='" |
||
2385 | . _APCAL_BTN_OUTPUTICS_MAC |
||
2386 | . "' /></a>\n"; |
||
2387 | } else { |
||
2388 | $ics_output_button = ''; |
||
2389 | } |
||
2390 | |||
2391 | if ($event->allday) { |
||
2392 | $tzoffset = (int)(($this->user_TZ - $this->server_TZ) * 3600); |
||
2393 | //$event->end -= 300 ; |
||
2394 | $start_time_str = /*"("._APCAL_MB_ALLDAY_EVENT.")"*/ |
||
2395 | ''; |
||
2396 | $end_time_str = ''; |
||
2397 | } else { |
||
2398 | $tzoffset = (int)(($this->user_TZ - $this->server_TZ) * 3600); |
||
2399 | $disp_user_tz = $this->get_tz_for_display($this->user_TZ); |
||
2400 | $start_time_str = $this->get_middle_hi($event->start + $tzoffset) . " $disp_user_tz"; |
||
2401 | $end_time_str = $this->get_middle_hi($event->end + $tzoffset) . " $disp_user_tz"; |
||
2402 | if ($this->user_TZ != $event->event_tz) { |
||
2403 | $tzoffset_s2e = (int)(($event->event_tz - $this->server_TZ) * 3600); |
||
2404 | $disp_event_tz = $this->get_tz_for_display($event->event_tz); |
||
2405 | $start_time_str .= ' <small>' . $this->get_middle_dhi($event->start + $tzoffset_s2e) . " $disp_event_tz</small>"; |
||
2406 | $end_time_str .= ' <small>' . $this->get_middle_dhi($event->end + $tzoffset_s2e) . " $disp_event_tz</small>"; |
||
2407 | } |
||
2408 | } |
||
2409 | |||
2410 | $start_date_str = $this->get_long_ymdn($event->start + $tzoffset); |
||
2411 | $end_date_str = $this->get_long_ymdn($event->end + $tzoffset); |
||
2412 | |||
2413 | $start_datetime_str = "$start_date_str $start_time_str"; |
||
2414 | $end_datetime_str = "$end_date_str $end_time_str"; |
||
2415 | |||
2416 | if (trim($event->rrule) !== '') { |
||
2417 | if (isset($parent_event) && $parent_event != $event) { |
||
2418 | if (isset($parent_event->start_date)) { |
||
2419 | $parent_date_str = $parent_event->start_date; // GIJ TODO |
||
2420 | } else { |
||
2421 | $parent_date_str = $this->get_long_ymdn($parent_event->start + $tzoffset); |
||
2422 | } |
||
2423 | $rrule .= "<br><a href='?action=View&event_id=$parent_event->id' target='_blank'>" . _APCAL_MB_LINK_TO_RRULE1ST . " $parent_date_str</a>"; |
||
2424 | } else { |
||
2425 | $rrule .= '<br> ' . _APCAL_MB_RRULE1ST; |
||
2426 | } |
||
2427 | } |
||
2428 | |||
2429 | $cat_titles4show = ''; |
||
2430 | $cids = explode(',', $event->categories); |
||
2431 | foreach ($cids as $cid) { |
||
2432 | $cid = (int)$cid; |
||
2433 | if (isset($this->categories[$cid])) { |
||
2434 | $cat_titles4show .= "<a href='{$this->make_cal_link('', '', $cid, date('Y-n-j', $event->start))}'>" . $this->text_sanitizer_for_show($this->categories[$cid]->cat_title) . '</a>, '; |
||
2435 | } |
||
2436 | } |
||
2437 | if ($cat_titles4show !== '') { |
||
2438 | $cat_titles4show = substr($cat_titles4show, 0, -2); |
||
2439 | } |
||
2440 | |||
2441 | $submitter_info = $this->get_submitter_info($event->uid); |
||
2442 | |||
2443 | if ($event->class === 'PRIVATE') { |
||
2444 | $groupid = (int)$event->groupid; |
||
2445 | if ($groupid == 0) { |
||
2446 | $group = _APCAL_OPT_PRIVATEMYSELF; |
||
2447 | } elseif (isset($this->groups[$groupid])) { |
||
2448 | $group = sprintf(_APCAL_OPT_PRIVATEGROUP, $this->groups[$groupid]); |
||
2449 | } else { |
||
2450 | $group = _APCAL_OPT_PRIVATEINVALID; |
||
2451 | } |
||
2452 | $class_status = _APCAL_MB_PRIVATE . sprintf(_APCAL_MB_PRIVATETARGET, $group); |
||
2453 | } else { |
||
2454 | $class_status = _APCAL_MB_PUBLIC; |
||
2455 | } |
||
2456 | |||
2457 | $admission_status = $event->admission ? _APCAL_MB_EVENT_ADMITTED : _APCAL_MB_EVENT_NEEDADMIT; |
||
2458 | $last_modified = $this->get_long_ymdn($event->udtstamp - (int)(($this->user_TZ - $this->server_TZ) * 3600)); |
||
2459 | $description = $this->textarea_sanitizer_for_show($event->description); |
||
2460 | $summary = $this->text_sanitizer_for_show($event->summary); |
||
2461 | $location = $this->text_sanitizer_for_show($event->location); |
||
2462 | $contact = $this->text_sanitizer_for_show($event->contact); |
||
2463 | $contact = convertmycontacts($contact); // added one line by goffy: converting the contact name(s) into a link to member account this is not necessary for online registration |
||
2464 | $email = $this->text_sanitizer_for_show($event->email); |
||
2465 | $url = $this->text_sanitizer_for_show($event->url); |
||
2466 | $url = $url !== '' && substr($url, 0, 4) !== 'http' ? 'http://' . $url : $url; |
||
2467 | $otherHour = explode('-', $event->otherHours); |
||
2468 | if ($otherHour[0] !== '') { |
||
2469 | //$event->end += 300 ; |
||
2470 | $h = array( |
||
2471 | 0, |
||
2472 | date('H', $event->start + $tzoffset), |
||
2473 | date('i', $event->start + $tzoffset), |
||
2474 | date('H', $event->end + $tzoffset), |
||
2475 | date('i', $event->end + $tzoffset) |
||
2476 | ); |
||
2477 | $d = $this->get_long_ymdn($event->start + ($h[0] * 3600 * 24) + $tzoffset); |
||
2478 | $otherHours = '<br>' . $d . ' ' . sprintf('%02d', $h[1]) . ':' . sprintf('%02d', $h[2]) . ' - ' . sprintf('%02d', $h[3]) . ':' . sprintf('%02d', $h[4]); |
||
2479 | foreach ($otherHour as $day) { |
||
2480 | $h = explode(':', $day); |
||
2481 | $d = $this->get_long_ymdn($event->start + ($h[0] * 3600 * 24) + $tzoffset); |
||
2482 | $otherHours .= '<br>' . $d . ' ' . sprintf('%02d', $h[1]) . ':' . sprintf('%02d', $h[2]) . ' - ' . sprintf('%02d', $h[3]) . ':' . sprintf('%02d', $h[4]); |
||
2483 | } |
||
2484 | } |
||
2485 | |||
2486 | $this->last_summary = $summary; |
||
2487 | |||
2488 | /********************************************************************/ |
||
2489 | /* added by goffy: code for online registration */ |
||
2490 | /********************************************************************/ |
||
2491 | $this->regonline = (int)$event->extkey0; |
||
2492 | $registered = 0; |
||
2493 | if ($this->regonline == 1) { |
||
2494 | $result_ro = $GLOBALS['xoopsDB']->query('SELECT ' . XOOPS_DB_PREFIX . $this->table_ro_events . '.roe_number |
||
2495 | FROM ' . XOOPS_DB_PREFIX . $this->table_ro_events . ' |
||
2496 | WHERE (((roe_eventid)=' . $event->id . '))'); |
||
2497 | $row = $GLOBALS['xoopsDB']->fetchRow($result_ro); |
||
2498 | $itemstotal = $row[0]; |
||
2499 | if ($itemstotal == 0) { |
||
2500 | //$eventmembersall = "No limit for online registration"; |
||
2501 | } else { |
||
2502 | $eventmembersall = _APCAL_RO_QUANTITY2 . ': ' . $itemstotal . '<br>'; |
||
2503 | } |
||
2504 | |||
2505 | $result_ro = $GLOBALS['xoopsDB']->query('SELECT Count(rom_id) AS countevents |
||
2506 | FROM ' . XOOPS_DB_PREFIX . $this->table_ro_members . ' |
||
2507 | WHERE (((rom_eventid)=' . $event->id . '))'); |
||
2508 | $row = $GLOBALS['xoopsDB']->fetchRow($result_ro); |
||
2509 | $itemstotal = $row[0]; |
||
2510 | if ($itemstotal == 0) { |
||
2511 | $eventmembersall .= _APCAL_RO_NOMEMBERS; |
||
0 ignored issues
–
show
The variable
$eventmembersall does not seem to be defined for all execution paths leading up to this point.
If you define a variable conditionally, it can happen that it is not defined for all execution paths. Let’s take a look at an example: function myFunction($a) {
switch ($a) {
case 'foo':
$x = 1;
break;
case 'bar':
$x = 2;
break;
}
// $x is potentially undefined here.
echo $x;
}
In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined. Available Fixes
![]() |
|||
2512 | $eventmembers = ''; |
||
2513 | } else { |
||
2514 | $eventmembersall .= _APCAL_RO_ONLINE . ': ' . $itemstotal; |
||
2515 | if (!$this->user_id == 0 && $editable) { |
||
2516 | $eventmembers .= '<br>' . _APCAL_RO_UNAME . ':'; |
||
0 ignored issues
–
show
The variable
$eventmembers seems only to be defined at a later point. Did you maybe move this code here without moving the variable definition?
This error can happen if you refactor code and forget to move the variable initialization. Let’s take a look at a simple example: function someFunction() {
$x = 5;
echo $x;
}
The above code is perfectly fine. Now imagine that we re-order the statements: function someFunction() {
echo $x;
$x = 5;
}
In that case, ![]() |
|||
2517 | } else { |
||
2518 | $eventmembers = ''; |
||
2519 | } |
||
2520 | } |
||
2521 | |||
2522 | if (!$this->user_id == 0) { |
||
2523 | if ($editable) { |
||
2524 | $result_ro = $GLOBALS['xoopsDB']->query('SELECT ' |
||
2525 | . XOOPS_DB_PREFIX |
||
2526 | . '_users.uname, |
||
2527 | ' |
||
2528 | . XOOPS_DB_PREFIX |
||
2529 | . '_users.uid, count(rom_id) as counter |
||
2530 | FROM ' |
||
2531 | . XOOPS_DB_PREFIX |
||
2532 | . $this->table_ro_members |
||
2533 | . ' INNER JOIN ' |
||
2534 | . XOOPS_DB_PREFIX |
||
2535 | . '_users ON ' |
||
2536 | . XOOPS_DB_PREFIX |
||
2537 | . $this->table_ro_members |
||
2538 | . '.rom_submitter = ' |
||
2539 | . XOOPS_DB_PREFIX |
||
2540 | . '_users.uid |
||
2541 | WHERE (((' |
||
2542 | . XOOPS_DB_PREFIX |
||
2543 | . $this->table_ro_members |
||
2544 | . '.rom_eventid)=' |
||
2545 | . $event->id |
||
2546 | . ')) GROUP BY 1,2'); |
||
2547 | $num_rows = $GLOBALS['xoopsDB']->getRowsNum($result_ro); |
||
0 ignored issues
–
show
$num_rows 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 ![]() |
|||
2548 | $baseurl = XOOPS_URL; |
||
0 ignored issues
–
show
$baseurl 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 ![]() |
|||
2549 | |||
2550 | while ($row = $GLOBALS['xoopsDB']->fetchRow($result_ro)) { |
||
2551 | $uname = $row[0]; |
||
2552 | $uid = $row[1]; |
||
2553 | $counter = $row[2]; |
||
2554 | $eventmembers = (substr($eventmembers, strlen($eventmembers) - 1, 1) === ':') ? $eventmembers .= ' ' : $eventmembers .= ', '; |
||
2555 | $eventmembers .= "<a href='" . XOOPS_URL . '/userinfo.php?uid=' . $uid . "' title=" . $uname . '>' . $uname . '</a>'; |
||
2556 | |||
2557 | if ($this->user_id == $uid) { |
||
2558 | $registered = 1; |
||
2559 | } |
||
2560 | if ($counter > 1) { |
||
2561 | $eventmembers .= ' (' . $counter . ')'; |
||
2562 | } |
||
2563 | } |
||
2564 | } |
||
2565 | |||
2566 | View Code Duplication | if (!empty($_SERVER['HTTPS'])) { |
|
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. ![]() |
|||
2567 | $this->redirecturl = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; |
||
2568 | } else { |
||
2569 | $this->redirecturl = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; |
||
2570 | } |
||
2571 | |||
2572 | $eventmembers_only = ''; |
||
2573 | $eventmembers_form = ''; |
||
2574 | //if ($editable && !$for_print) { |
||
2575 | if (!$for_print) { |
||
2576 | $eventmembers_form = " |
||
2577 | <form class='apcalForm' method='post' id='RegOnlineForm' action='ro_regonlinehandler.php' name='roformmembers1' style='margin:0px;'> |
||
2578 | <input type='hidden' name='eventid' value='$event->id' /> |
||
2579 | <input type='hidden' name='event_uid' value='$event->uid' /> |
||
2580 | <input type='hidden' name='uid' value='$this->user_id' /> |
||
2581 | <input type='hidden' name='eventurl' value='$this->redirecturl' /> |
||
2582 | <input type='hidden' name='summary' value='$summary' /> |
||
2583 | <input type='hidden' name='date' value='$start_date_str' /> |
||
2584 | <input type='hidden' name='eventdate' value='$event->start' /> |
||
2585 | <input type='hidden' name='location' value='$location' /> |
||
2586 | <div style='float:right;'>"; |
||
2587 | if ($registered == 1) { |
||
2588 | $eventmembers_form .= "<input type='submit' name='form_add' value='" . _APCAL_RO_BTN_ADDMORE . "' />"; |
||
2589 | } else { |
||
2590 | $eventmembers_form .= "<input type='submit' name='form_add' value='" . _APCAL_RO_BTN_ADD . "' /> "; |
||
2591 | } |
||
2592 | if ($editable && !$for_print && $itemstotal > 0) { |
||
2593 | $eventmembers_form .= "<input type='submit' name='list' value='" . _APCAL_RO_BTN_LISTMEMBERS . "' />"; |
||
2594 | } |
||
2595 | $eventmembers_form .= "</div></form>\n"; |
||
2596 | } |
||
2597 | } else { |
||
2598 | $eventmembers_only = '<p>' . _APCAL_RO_ONLY_MEMBERS . '</p>'; |
||
2599 | $eventmembers_only .= "<a class='btn btn-primary' href='" . XOOPS_URL . "/modules/profile/user.php?xoops_redirect=/modules/apcal/?event_id=$event->id&action=View' title=''>Einloggen</a>"; |
||
2600 | $eventmembers_only .= "<br>Sie sind noch nicht als User registriert? Dann bitte zuerst <a class='btn btn-info cal-btn' href='" . XOOPS_URL . "/modules/profile/register.php' title=''>Registrieren</a>"; |
||
2601 | |||
2602 | } |
||
2603 | |||
2604 | $eventmembertable = " |
||
2605 | <tr> |
||
2606 | <td class='head'>" . _APCAL_RO_ONLINE . "</td> |
||
2607 | <td class='even'> |
||
2608 | <div style='float:left; margin: 2px;'>$eventmembersall$eventmembers"; |
||
2609 | if ('' !== $eventmembers_only) { |
||
2610 | $eventmembertable .= $eventmembers_only; |
||
2611 | } |
||
2612 | $eventmembertable .= "</div> |
||
2613 | <div style='float:left; margin: 2px;'>$eventmembers_form</div> |
||
0 ignored issues
–
show
The variable
$eventmembers_form does not seem to be defined for all execution paths leading up to this point.
If you define a variable conditionally, it can happen that it is not defined for all execution paths. Let’s take a look at an example: function myFunction($a) {
switch ($a) {
case 'foo':
$x = 1;
break;
case 'bar':
$x = 2;
break;
}
// $x is potentially undefined here.
echo $x;
}
In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined. Available Fixes
![]() |
|||
2614 | </td> |
||
2615 | </tr>"; |
||
2616 | } else { |
||
2617 | $eventmembertable = " |
||
2618 | <tr> |
||
2619 | <td class='head'>" . _APCAL_RO_ONLINE . "</td> |
||
2620 | <td class='even'> |
||
2621 | <div style='float:left; margin: 2px;'>" . _APCAL_RO_ONLINE_NO . '</div> |
||
2622 | </td> |
||
2623 | </tr>'; |
||
2624 | } |
||
2625 | /*******************************************************************/ |
||
2626 | /* end added by goffy: */ |
||
2627 | /*******************************************************************/ |
||
2628 | |||
2629 | $pictures = ''; |
||
2630 | $pics = $GLOBALS['xoopsDB']->query("SELECT picture FROM {$this->pic_table} WHERE event_id={$event_id} ORDER BY main_pic DESC, id ASC LIMIT 0,{$this->nbPictures}"); |
||
2631 | while ($pic = $GLOBALS['xoopsDB']->fetchObject($pics)) { |
||
2632 | if (!Thumb::exists($pic->picture)) { |
||
2633 | Thumb::save($pic->picture, $this->picWidth, $this->picHeight); |
||
2634 | } |
||
2635 | $pictures .= '<div style="padding: 10px 0;"> |
||
2636 | <a href="' . XOOPS_UPLOAD_URL . '/apcal/' . $pic->picture . '" class="highslide" onclick="return hs.expand(this)"> |
||
2637 | <img src="' . XOOPS_UPLOAD_URL . '/apcal/thumbs/' . $pic->picture . '" alt="Image" /> |
||
2638 | </a> |
||
2639 | </div>'; |
||
2640 | } |
||
2641 | |||
2642 | if ($xoopsTpl) { |
||
2643 | $prevEvent = $GLOBALS['xoopsDB']->query("SELECT id,start FROM $this->table WHERE id<{$event->id} AND start={$event->start} ORDER BY id DESC LIMIT 0,1"); |
||
2644 | $prevEvent = $GLOBALS['xoopsDB']->fetchObject($prevEvent); |
||
2645 | View Code Duplication | if (!$prevEvent) { |
|
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. ![]() |
|||
2646 | $prevEvent = $GLOBALS['xoopsDB']->query("SELECT id,start FROM $this->table WHERE start<{$event->start} ORDER BY start DESC LIMIT 0,1"); |
||
2647 | $prevEvent = $GLOBALS['xoopsDB']->fetchObject($prevEvent); |
||
2648 | } |
||
2649 | $prevEvent = $prevEvent ? $this->make_event_link($prevEvent->id) : false; |
||
2650 | $xoopsTpl->assign('prevEvent', $prevEvent); |
||
2651 | |||
2652 | $nextEvent = $GLOBALS['xoopsDB']->query("SELECT id,start FROM $this->table WHERE id>{$event->id} AND start={$event->start} ORDER BY id ASC LIMIT 0,1"); |
||
2653 | $nextEvent = $GLOBALS['xoopsDB']->fetchObject($nextEvent); |
||
2654 | View Code Duplication | if (!$nextEvent) { |
|
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. ![]() |
|||
2655 | $nextEvent = $GLOBALS['xoopsDB']->query("SELECT id,start FROM $this->table WHERE start>{$event->start} ORDER BY start ASC LIMIT 0,1"); |
||
2656 | $nextEvent = $GLOBALS['xoopsDB']->fetchObject($nextEvent); |
||
2657 | } |
||
2658 | $nextEvent = $nextEvent ? $this->make_event_link($nextEvent->id) : false; |
||
2659 | $xoopsTpl->assign('nextEvent', $nextEvent); |
||
2660 | |||
2661 | $xoopsTpl->assign('title', $summary); |
||
2662 | $xoopsTpl->assign('location', $location); |
||
2663 | $xoopsTpl->assign('contact', $contact); |
||
2664 | $xoopsTpl->assign('email', $email); |
||
2665 | $xoopsTpl->assign('url', $url); |
||
2666 | $xoopsTpl->assign('startdate', date('Y-n-j', $event->start)); |
||
2667 | $xoopsTpl->assign('calLink', $this->make_cal_link('', '', 0, date('Y-n-j', $event->start))); |
||
2668 | $xoopsTpl->assign('GMLat', $event->gmlat); |
||
2669 | $xoopsTpl->assign('GMLong', $event->gmlong); |
||
2670 | $xoopsTpl->assign('GMZoom', $event->gmzoom); |
||
2671 | $xoopsTpl->assign('GMheight', $this->gmheight . 'px'); |
||
2672 | $xoopsTpl->assign('eventNavEnabled', $this->eventNavEnabled); |
||
2673 | $xoopsTpl->assign('picsWidth', $pictures !== '' ? ($this->picWidth + 10) . 'px' : 0); |
||
2674 | $xoopsTpl->assign('picsMargin', $pictures !== '' ? ($this->picWidth + 20) . 'px' : 0); |
||
2675 | $xoopsTpl->assign('pictures', $pictures); |
||
2676 | $xoopsTpl->assign('showPrint', $this->enableprint); |
||
2677 | } |
||
2678 | |||
2679 | $ret = " |
||
2680 | <table border='0' cellpadding='0' cellspacing='2'>"; |
||
2681 | $ret .= ($summary !== '') ? " |
||
2682 | <tr> |
||
2683 | <td class='head'>" . _APCAL_TH_SUMMARY . "</td> |
||
2684 | <td class='even'>$summary</td> |
||
2685 | </tr>" : ''; |
||
2686 | $ret .= " |
||
2687 | <tr> |
||
2688 | <td class='head'>" . _APCAL_TH_STARTDATETIME . "</td> |
||
2689 | <td class='even'>$start_datetime_str</td> |
||
2690 | </tr> |
||
2691 | <tr> |
||
2692 | <td class='head'>" . _APCAL_TH_ENDDATETIME . "</td> |
||
2693 | <td class='even'>$end_datetime_str</td> |
||
2694 | </tr>"; |
||
2695 | $ret .= ($location !== '') ? " |
||
2696 | <tr> |
||
2697 | <td class='head'>" . _APCAL_TH_LOCATION . "</td> |
||
2698 | <td class='even'>$location</td> |
||
2699 | </tr>" : ''; |
||
2700 | $ret .= ($contact !== '') ? " |
||
2701 | <tr> |
||
2702 | <td class='head'>" . _APCAL_TH_CONTACT . "</td> |
||
2703 | <td class='even'>$contact</td> |
||
2704 | </tr>" : ''; |
||
2705 | $ret .= ($email !== '') ? " |
||
2706 | <tr> |
||
2707 | <td class='head'>" . _APCAL_TH_EMAIL . "</td> |
||
2708 | <td class='even'><a href='mailto:$email'>$email</a></td> |
||
2709 | </tr>" : ''; |
||
2710 | $ret .= ($url !== '') ? " |
||
2711 | <tr> |
||
2712 | <td class='head'>" . _APCAL_TH_URL . "</td> |
||
2713 | <td class='even'><a href='$url' target='_blank'>$url</a></td> |
||
2714 | </tr>" : ''; |
||
2715 | $ret .= ($description !== '' || $otherHours !== '') ? " |
||
0 ignored issues
–
show
The variable
$otherHours does not seem to be defined for all execution paths leading up to this point.
If you define a variable conditionally, it can happen that it is not defined for all execution paths. Let’s take a look at an example: function myFunction($a) {
switch ($a) {
case 'foo':
$x = 1;
break;
case 'bar':
$x = 2;
break;
}
// $x is potentially undefined here.
echo $x;
}
In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined. Available Fixes
![]() |
|||
2716 | <tr> |
||
2717 | <td class='head'>" . _APCAL_TH_DESCRIPTION . "</td> |
||
2718 | <td class='even'>$description<br>$otherHours</td> |
||
2719 | </tr>" : ''; |
||
2720 | $ret .= ($cat_titles4show !== '') ? " |
||
2721 | <tr> |
||
2722 | <td class='head'>" . _APCAL_TH_CATEGORIES . "</td> |
||
2723 | <td class='even'>$cat_titles4show</td> |
||
2724 | </tr>" : ''; |
||
2725 | $ret .= ($this->superedit ? " |
||
2726 | <tr> |
||
2727 | <td class='head'>" . _APCAL_TH_SUBMITTER . "</td> |
||
2728 | <td class='even'>$submitter_info</td> |
||
2729 | </tr> |
||
2730 | <tr> |
||
2731 | <td class='head'>" . _APCAL_TH_CLASS . "</td> |
||
2732 | <td class='even'>$class_status</td> |
||
2733 | </tr> |
||
2734 | <tr> |
||
2735 | <td class='head'>" . _APCAL_TH_RRULE . "</td> |
||
2736 | <td class='even'>$rrule</td> |
||
2737 | </tr> |
||
2738 | <tr> |
||
2739 | <td class='head'>" . _APCAL_TH_ADMISSIONSTATUS . "</td> |
||
2740 | <td class='even'>$admission_status</td> |
||
2741 | </tr> |
||
2742 | " : '') . " |
||
2743 | <tr> |
||
2744 | <td class='head'>" . _APCAL_TH_LASTMODIFIED . "</td> |
||
2745 | <td class='even'>$last_modified</td> |
||
2746 | </tr>" . ($this->enableregistration ? $eventmembertable : '') // goffy |
||
2747 | . "<tr> |
||
2748 | <td></td> |
||
2749 | <td align='center'> |
||
2750 | <div style='float:left; margin: 2px;'>$edit_button</div> |
||
2751 | <div style='float:left; margin: 2px;'>$delete_button</div> |
||
2752 | <div style='float:left; margin: 2px;'>$ics_output_button</div> |
||
2753 | </td> |
||
2754 | </tr> |
||
2755 | <tr> |
||
2756 | <td><img src='$this->images_url/spacer.gif' alt='' width='150' height='4' /></td> <td width='100%'></td> |
||
2757 | </tr> |
||
2758 | <tr> |
||
2759 | <td width='100%' align='right' colspan='2'>" . _MD_APCAL_COPYRIGHT . "</td> |
||
2760 | </tr> |
||
2761 | </table> |
||
2762 | \n"; |
||
2763 | |||
2764 | return $ret; |
||
2765 | } |
||
2766 | |||
2767 | // Edit an event form |
||
2768 | |||
2769 | /** |
||
2770 | * @return string |
||
0 ignored issues
–
show
|
|||
2771 | */ |
||
2772 | public function get_schedule_edit_html() |
||
2773 | { |
||
2774 | $editable = $this->editable; |
||
2775 | $superedit = $this->superedit; |
||
2776 | $deletable = $this->deletable; |
||
2777 | $smode = empty($_GET['smode']) ? 'Monthly' : preg_replace('/[^a-zA-Z0-9_-]/', '', $_GET['smode']); |
||
2778 | |||
2779 | if (!empty($_GET['event_id'])) { |
||
2780 | if (!$this->editable) { |
||
2781 | die('Not allowed'); |
||
2782 | } |
||
2783 | |||
2784 | $event_id = (int)$_GET['event_id']; |
||
2785 | $yrs = $GLOBALS['xoopsDB']->query("SELECT * FROM $this->table WHERE id='$event_id'"); |
||
2786 | if ($GLOBALS['xoopsDB']->getRowsNum($yrs) < 1) { |
||
2787 | die(_APCAL_ERR_INVALID_EVENT_ID); |
||
2788 | } |
||
2789 | $event = $GLOBALS['xoopsDB']->fetchObject($yrs); |
||
2790 | |||
2791 | // submitter of event |
||
2792 | if ($event->uid != $this->user_id) { |
||
2793 | $editable = false; |
||
2794 | $deletable = false; |
||
2795 | } |
||
2796 | // user is admin or has right to edit/delete all events |
||
2797 | if ($this->isadmin || $superedit) { |
||
2798 | $editable = true; |
||
2799 | $deletable = true; |
||
2800 | } |
||
2801 | |||
2802 | $description = $this->textarea_sanitizer_for_edit($event->description); |
||
2803 | $summary = $this->text_sanitizer_for_edit($event->summary); |
||
2804 | $location = $this->text_sanitizer_for_edit($event->location); |
||
2805 | $gmlat = $event->gmlat != 0 ? $event->gmlat : 0; |
||
2806 | $gmlong = $event->gmlong != 0 ? $event->gmlong : 0; |
||
2807 | $gmzoom = $event->gmzoom > 0 ? $event->gmzoom : 0; |
||
2808 | $contact = $this->text_sanitizer_for_edit($event->contact); |
||
2809 | $email = $this->text_sanitizer_for_edit($event->email); |
||
2810 | $url = $this->text_sanitizer_for_edit($event->url); |
||
2811 | $categories = $event->categories; |
||
2812 | $mainCategory = $event->mainCategory; |
||
2813 | if ($event->class === 'PRIVATE') { |
||
2814 | $class_private = 'checked'; |
||
2815 | $class_public = ''; |
||
2816 | $select_private_disabled = ''; |
||
2817 | } else { |
||
2818 | $class_private = ''; |
||
2819 | $class_public = 'checked'; |
||
2820 | $select_private_disabled = "disabled='disabled'"; |
||
2821 | } |
||
2822 | $groupid = $event->groupid; |
||
2823 | $rrule = $event->rrule; |
||
2824 | $admission_status = $event->admission ? _APCAL_MB_EVENT_ADMITTED : _APCAL_MB_EVENT_NEEDADMIT; |
||
2825 | $update_button = $editable ? "<input name='update' type='submit' value='" . _APCAL_BTN_SUBMITCHANGES . "' />" : ''; |
||
2826 | $insert_button = "<input name='saveas' type='submit' value='" . _APCAL_BTN_SAVEAS . "' onclick='return confirm(\"" . _APCAL_CNFM_SAVEAS_YN . "\")' />"; |
||
2827 | $delete_button = $deletable ? "<input name='delete' type='submit' value='" . _APCAL_BTN_DELETE . "' onclick='return confirm(\"" . _APCAL_CNFM_DELETE_YN . "\")' />" : ''; |
||
2828 | $tz_options = $this->get_tz_options($event->event_tz); |
||
2829 | $poster_tz = $event->poster_tz; |
||
2830 | |||
2831 | // added by goffy for online registration |
||
2832 | View Code Duplication | if (!empty($_SERVER['HTTPS'])) { |
|
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. ![]() |
|||
2833 | $this->redirecturl = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; |
||
2834 | } else { |
||
2835 | $this->redirecturl = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; |
||
2836 | } |
||
2837 | |||
2838 | $regonline_label = _APCAL_RO_ENABLE_ONLINE; |
||
0 ignored issues
–
show
$regonline_label 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 ![]() |
|||
2839 | $regonline_state = ($event->extkey0 == 1) ? _APCAL_RO_ONLINE_YES : _APCAL_RO_ONLINE_NO; |
||
2840 | |||
2841 | $regonline_state .= " |
||
2842 | <form class='apcalForm' method='post' id='RegOnlineForm' action='ro_regonlinehandler.php' name='roformactivate1' style='margin:0px;'> |
||
2843 | <input type='hidden' name='eventid' value='$event->id' /> |
||
2844 | <input type='hidden' name='uid' value='$this->user_id' /> |
||
2845 | <input type='hidden' name='eventurl' value='$this->redirecturl' /> |
||
2846 | <input type='hidden' name='title' value='$event->summary' /> |
||
2847 | <input type='hidden' name='eventdate' value='$event->start' /> |
||
2848 | <input type='hidden' name='location' value='$event->location' /> |
||
2849 | <div align='left'>"; |
||
2850 | if ($event->extkey0 == 1) { |
||
2851 | $regonline_state .= " |
||
2852 | <input type='submit' name='form_activate' value='" . _APCAL_RO_BTN_RO_EDIT . "' /> |
||
2853 | <input type='submit' name='deactivate_x' value='" . _APCAL_RO_BTN_RO_DEACTIVATE . "' />"; |
||
2854 | } else { |
||
2855 | $regonline_state .= "<input type='submit' name='form_activate' value='" . _APCAL_RO_BTN_RO_ACTIVATE . "' />"; |
||
2856 | } |
||
2857 | $regonline_state .= '</div> |
||
2858 | </form>'; |
||
2859 | |||
2860 | $ro_form_edit = "<table> |
||
2861 | <tr> |
||
2862 | <td class='odd' colspan='2'></td> |
||
2863 | </tr> |
||
2864 | <tr> |
||
2865 | <td class='head'>" . _APCAL_RO_ENABLE_ONLINE . "</td> |
||
2866 | <td class='even'>" . $regonline_state . '</td> |
||
2867 | </tr></table>'; |
||
2868 | $ro_form_new = ''; |
||
2869 | // end added by goffy |
||
2870 | |||
2871 | //$tmpEnd = date('H:i', $event->end) == '00:00' ? $event->end - 300 : $event->end; |
||
2872 | $diff = date('j', $event->end) - date('j', $event->start); |
||
2873 | if ($event->otherHours !== '' /*&& $event->allday <= 0*/) { |
||
2874 | $diffhours_checkbox = 'checked'; |
||
2875 | $otherHours = explode('-', $event->otherHours); |
||
2876 | foreach ($otherHours as $h) { |
||
2877 | $h = explode(':', $h); |
||
2878 | $startHours .= "<span name='StartSpan'>" . _APCAL_DAY . ' ' . ($h[0] + 1); |
||
0 ignored issues
–
show
The variable
$startHours does not seem to be defined for all execution paths leading up to this point.
If you define a variable conditionally, it can happen that it is not defined for all execution paths. Let’s take a look at an example: function myFunction($a) {
switch ($a) {
case 'foo':
$x = 1;
break;
case 'bar':
$x = 2;
break;
}
// $x is potentially undefined here.
echo $x;
}
In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined. Available Fixes
![]() |
|||
2879 | $startHours .= "<select name='StartH[]'>" . $this->get_options_for_hour($h[1]) . '</select>'; |
||
2880 | $startHours .= "<select name='StartM[]'>" . $this->get_options_for_min($h[2]) . '</select></span>'; |
||
2881 | $endHours .= "<span name='EndSpan'>" . _APCAL_DAY . ' ' . ($h[0] + 1); |
||
0 ignored issues
–
show
The variable
$endHours does not seem to be defined for all execution paths leading up to this point.
If you define a variable conditionally, it can happen that it is not defined for all execution paths. Let’s take a look at an example: function myFunction($a) {
switch ($a) {
case 'foo':
$x = 1;
break;
case 'bar':
$x = 2;
break;
}
// $x is potentially undefined here.
echo $x;
}
In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined. Available Fixes
![]() |
|||
2882 | $endHours .= "<select name='EndH[]'>" . $this->get_options_for_hour($h[3]) . '</select>'; |
||
2883 | $endHours .= "<select name='EndM[]'>" . $this->get_options_for_min($h[4]) . '</select></span>'; |
||
2884 | } |
||
2885 | } elseif ($diff > 0 /*&& $event->allday == 0*/) { |
||
2886 | //$samehours_checkbox = "checked"; |
||
2887 | for ($i = 0; $i < $diff; ++$i) { |
||
2888 | $startHours .= '<span>' . _APCAL_DAY . ' ' . ($i + 2); |
||
2889 | $startHours .= "<select name='StartH[]' disabled>" . $this->get_options_for_hour(9) . '</select>'; |
||
2890 | $startHours .= "<select name='StartM[]' disabled>" . $this->get_options_for_min(0) . '</select></span>'; |
||
2891 | $endHours .= '<span>' . _APCAL_DAY . ' ' . ($i + 2); |
||
2892 | $endHours .= "<select name='EndH[]' disabled>" . $this->get_options_for_hour(17) . '</select>'; |
||
2893 | $endHours .= "<select name='EndM[]' disabled>" . $this->get_options_for_min(0) . '</select></span>'; |
||
2894 | } |
||
2895 | } |
||
2896 | |||
2897 | if ($event->allday) { |
||
2898 | $select_timezone_disabled = "disabled='disabled'"; |
||
2899 | $tzoffset_s2e = (int)(($event->event_tz - $this->server_TZ) * 3600); |
||
2900 | $event->start += $tzoffset_s2e; |
||
2901 | $event->end += $tzoffset_s2e; |
||
2902 | $allday_checkbox = 'checked'; |
||
2903 | $allday_select = $event->allday == 5 ? "disabled='disabled'" : ''; |
||
2904 | $allday_bit1 = ($event->allday & 2) ? 'checked' : ''; |
||
0 ignored issues
–
show
$allday_bit1 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 ![]() |
|||
2905 | $allday_bit2 = ($event->allday & 4) ? 'checked' : ''; |
||
0 ignored issues
–
show
$allday_bit2 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 ![]() |
|||
2906 | $allday_bit3 = ($event->allday & 8) ? 'checked' : ''; |
||
0 ignored issues
–
show
$allday_bit3 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 ![]() |
|||
2907 | $allday_bit4 = ($event->allday & 16) ? 'checked' : ''; |
||
0 ignored issues
–
show
$allday_bit4 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 ![]() |
|||
2908 | if (isset($event->start_date)) { |
||
2909 | $start_ymd = $start_long_ymdn = $event->start_date; |
||
2910 | } else { |
||
2911 | $start_ymd = date('Y-m-d', $event->start); |
||
2912 | $start_long_ymdn = $this->get_long_ymdn($event->start); |
||
2913 | } |
||
2914 | $start_hour = date('H', $event->start); |
||
2915 | $start_min = date('i', $event->start); |
||
2916 | if (isset($event->end_date)) { |
||
2917 | $end_ymd = $end_long_ymdn = $event->end_date; |
||
2918 | } else { |
||
2919 | $end_ymd = date('Y-m-d', $event->end); |
||
2920 | $end_long_ymdn = $this->get_long_ymdn($event->end); |
||
2921 | } |
||
2922 | $end_hour = date('H', $event->end); |
||
2923 | $end_min = date('i', $event->end); |
||
2924 | } else { |
||
2925 | $select_timezone_disabled = ''; |
||
2926 | $tzoffset_s2e = (int)(($event->event_tz - $this->server_TZ) * 3600); |
||
2927 | $event->start += $tzoffset_s2e; |
||
2928 | $event->end += $tzoffset_s2e; |
||
2929 | $allday_checkbox = ''; |
||
2930 | if (!isset($samehours_checkbox) && !isset($samehours_checkbox)) { |
||
0 ignored issues
–
show
The variable
$samehours_checkbox seems only to be defined at a later point. As such the call to isset() seems to always evaluate to false .
This check marks calls to This is likely the result of code being shifted around. Consider removing these calls. ![]() |
|||
2931 | $samehours_checkbox = 'checked'; |
||
2932 | } |
||
2933 | $allday_select = ''; |
||
2934 | $allday_bit1 = $allday_bit2 = $allday_bit3 = $allday_bit4 = ''; |
||
0 ignored issues
–
show
$allday_bit4 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 ![]() $allday_bit3 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 ![]() $allday_bit2 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 ![]() $allday_bit1 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 ![]() |
|||
2935 | $start_ymd = date('Y-m-d', $event->start); |
||
2936 | $start_long_ymdn = $this->get_long_ymdn($event->start); |
||
2937 | $start_hour = date('H', $event->start); |
||
2938 | $start_min = date('i', $event->start); |
||
2939 | $end_ymd = date('Y-m-d', $event->end); |
||
2940 | $end_long_ymdn = $this->get_long_ymdn($event->end); |
||
2941 | $end_hour = date('H', $event->end); |
||
2942 | $end_min = date('i', $event->end); |
||
2943 | } |
||
2944 | } else { |
||
2945 | if (!$this->insertable) { |
||
2946 | die('Not allowed'); |
||
2947 | } |
||
2948 | |||
2949 | $event_id = 0; |
||
2950 | |||
2951 | $editable = true; |
||
2952 | $summary = ''; |
||
2953 | $select_timezone_disabled = ''; |
||
2954 | $location = ''; |
||
2955 | $gmlat = 0; |
||
2956 | $gmlong = 0; |
||
2957 | $gmzoom = 0; |
||
2958 | $contact = ''; |
||
2959 | $email = ''; |
||
2960 | $url = ''; |
||
2961 | $class_private = ''; |
||
2962 | $class_public = 'checked'; |
||
2963 | $select_private_disabled = "disabled='disabled'"; |
||
2964 | $groupid = 0; |
||
2965 | $rrule = ''; |
||
2966 | $description = ''; |
||
2967 | $categories = $this->now_cid > 0 ? sprintf('%05d,', $this->now_cid) : ''; |
||
2968 | $mainCategory = $this->now_cid > 0 ? sprintf('%05d,', $this->now_cid) : 0; |
||
2969 | $start_ymd = $end_ymd = $this->caldate; |
||
2970 | $start_long_ymdn = $end_long_ymdn = $this->get_long_ymdn($this->unixtime); |
||
2971 | $start_hour = 9; |
||
2972 | $start_min = 0; |
||
2973 | $end_hour = 17; |
||
2974 | $end_min = 0; |
||
2975 | $admission_status = _APCAL_MB_EVENT_NOTREGISTER; |
||
2976 | $update_button = ''; |
||
2977 | $insert_button = "<input name='insert' type='submit' value='" . _APCAL_BTN_NEWINSERTED . "' />"; |
||
2978 | $delete_button = ''; |
||
2979 | $allday_checkbox = $allday_select = ''; |
||
2980 | $allday_bit1 = $allday_bit2 = $allday_bit3 = $allday_bit4 = ''; |
||
0 ignored issues
–
show
$allday_bit4 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 ![]() $allday_bit3 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 ![]() $allday_bit2 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 ![]() $allday_bit1 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 ![]() |
|||
2981 | $tz_options = $this->get_tz_options($this->user_TZ); |
||
2982 | $poster_tz = $this->user_TZ; |
||
2983 | |||
2984 | // added by goffy for online registration |
||
2985 | $regonline_label = _APCAL_RO_ONLINE2; |
||
0 ignored issues
–
show
$regonline_label 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 ![]() |
|||
2986 | $regonline_state = _APCAL_RO_ONLINE_NO; |
||
0 ignored issues
–
show
$regonline_state 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 ![]() |
|||
2987 | $ro_form_edit = ''; |
||
2988 | $ro_form_new = " |
||
2989 | <tr> |
||
2990 | <td class='head'>" . _APCAL_RO_ONLINE2 . "</td> |
||
2991 | <td class='even'> |
||
2992 | <input type='radio' name='ro_activate' value='yes' > " . _APCAL_RO_ONLINE_ACTIVATE . "<br> |
||
2993 | <input type='radio' name='ro_activate' value='no' checked> " . _APCAL_RO_ONLINE_DEACTIVATE . ' |
||
2994 | </td> |
||
2995 | </tr>'; |
||
2996 | // end goffy |
||
2997 | } |
||
2998 | |||
2999 | // Start Date |
||
3000 | $textbox_start_date = $this->get_formtextdateselect('StartDate', $start_ymd, $start_long_ymdn); |
||
0 ignored issues
–
show
The call to
APCal::get_formtextdateselect() has too many arguments starting with $start_long_ymdn .
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. In this case you can add the ![]() |
|||
3001 | |||
3002 | // Start Hour |
||
3003 | $select_start_hour = "<select name='StartHour' $allday_select>\n"; |
||
3004 | $select_start_hour .= $this->get_options_for_hour($start_hour); |
||
3005 | $select_start_hour .= '</select>'; |
||
3006 | |||
3007 | // Start Minutes |
||
3008 | $select_start_min = "<select name='StartMin' $allday_select>\n"; |
||
3009 | for ($m = 0; $m < 60; $m += 5) { |
||
3010 | if ($m == $start_min) { |
||
3011 | $select_start_min .= "<option value='$m' selected>" . sprintf('%02d', $m) . "</option>\n"; |
||
3012 | } else { |
||
3013 | $select_start_min .= "<option value='$m'>" . sprintf('%02d', $m) . "</option>\n"; |
||
3014 | } |
||
3015 | } |
||
3016 | $select_start_min .= '</select>'; |
||
3017 | |||
3018 | // End Date |
||
3019 | $textbox_end_date = $this->get_formtextdateselect('EndDate', $end_ymd, $end_long_ymdn); |
||
0 ignored issues
–
show
The call to
APCal::get_formtextdateselect() has too many arguments starting with $end_long_ymdn .
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. In this case you can add the ![]() |
|||
3020 | |||
3021 | // End Hour |
||
3022 | $select_end_hour = "<select name='EndHour' $allday_select>\n"; |
||
3023 | $select_end_hour .= $this->get_options_for_hour($end_hour); |
||
3024 | $select_end_hour .= '</select>'; |
||
3025 | |||
3026 | // End Minutes |
||
3027 | $select_end_min = "<select name='EndMin' $allday_select>\n"; |
||
3028 | for ($m = 0; $m < 60; $m += 5) { |
||
3029 | if ($m == $end_min) { |
||
3030 | $select_end_min .= "<option value='$m' selected>" . sprintf('%02d', $m) . "</option>\n"; |
||
3031 | } else { |
||
3032 | $select_end_min .= "<option value='$m'>" . sprintf('%02d', $m) . "</option>\n"; |
||
3033 | } |
||
3034 | } |
||
3035 | $select_end_min .= '</select>'; |
||
3036 | |||
3037 | // Checkbox for selecting Categories |
||
3038 | $category_checkboxes = ''; |
||
3039 | foreach ($this->categories as $cid => $cat) { |
||
3040 | $cid4sql = sprintf('%05d,', $cid); |
||
3041 | $cat_title4show = $this->text_sanitizer_for_show($cat->cat_title); |
||
3042 | if ($cat->cat_depth < 2) { |
||
3043 | $category_checkboxes .= "<div style='float:left; margin:2px;'>\n"; |
||
3044 | } |
||
3045 | $category_checkboxes .= str_repeat('-', $cat->cat_depth - 1) |
||
3046 | . "<input type='checkbox' name='cids[]' value='$cid' " |
||
3047 | . (strstr($categories, $cid4sql) ? 'checked' : '') |
||
3048 | . " />$cat_title4show<br>\n"; |
||
3049 | } |
||
3050 | $category_checkboxes = substr(str_replace('<div', '</div><div', $category_checkboxes), 6) . "</div>\n"; |
||
3051 | |||
3052 | // Select for selecting main category |
||
3053 | $category_select = "<select name='mainCategory'>\n"; |
||
3054 | $category_select .= "<option value='0' " . ($mainCategory == 0 ? 'selected' : '') . ' />' . _APCAL_NONE . "</option>\n"; |
||
3055 | foreach ($this->canbemain_cats as $cid => $cat) { |
||
3056 | $cat_title4show = $this->text_sanitizer_for_show($cat->cat_title); |
||
3057 | $category_select .= "<option value='$cid' " . ($mainCategory == $cid ? 'selected' : '') . ' />' . str_repeat(' ', $cat->cat_depth - 1) . " $cat_title4show</option>\n"; |
||
3058 | } |
||
3059 | $category_select .= "</select>\n"; |
||
3060 | |||
3061 | // target for "class = PRIVATE" |
||
3062 | $select_private = "<select name='groupid' $select_private_disabled>\n<option value='0'>" . _APCAL_OPT_PRIVATEMYSELF . "</option>\n"; |
||
3063 | foreach ($this->groups as $sys_gid => $gname) { |
||
3064 | $option_desc = sprintf(_APCAL_OPT_PRIVATEGROUP, $gname); |
||
3065 | if ($sys_gid == $groupid) { |
||
3066 | $select_private .= "<option value='$sys_gid' selected>$option_desc</option>\n"; |
||
3067 | } else { |
||
3068 | $select_private .= "<option value='$sys_gid'>$option_desc</option>\n"; |
||
3069 | } |
||
3070 | } |
||
3071 | $select_private .= '</select>'; |
||
3072 | |||
3073 | if (defined('XOOPS_ROOT_PATH')) { |
||
3074 | require_once XOOPS_ROOT_PATH . '/include/xoopscodes.php'; |
||
3075 | ob_start(); |
||
3076 | $GLOBALS['description_text'] = $description; |
||
3077 | xoopsCodeTarea('description_text', 50, 6); |
||
3078 | $description_textarea = ob_get_contents(); |
||
3079 | ob_end_clean(); |
||
3080 | } else { |
||
3081 | $description_textarea = "<textarea name='description' cols='50' rows='6' wrap='soft'>$description</textarea>"; |
||
3082 | } |
||
3083 | |||
3084 | // MAIN PICTURE |
||
3085 | $picture = $event_id > 0 ? $GLOBALS['xoopsDB']->query("SELECT id, picture FROM {$this->pic_table} WHERE event_id={$event_id} AND main_pic=1 LIMIT 0,1") : false; |
||
3086 | if ($GLOBALS['xoopsDB']->getRowsNum($picture)) { |
||
3087 | $picture = $GLOBALS['xoopsDB']->fetchObject($picture); |
||
3088 | $mainPic = '<div id=mainPicture> |
||
3089 | <a href="' . XOOPS_UPLOAD_URL . '/apcal/' . $picture->picture . '"> |
||
3090 | <img src="' . XOOPS_URL . '/modules/apcal/thumbs/phpThumb.php?src=' . XOOPS_UPLOAD_PATH . '/apcal/' . $picture->picture . '&h=120&w=120" alt="" /> |
||
3091 | </a> |
||
3092 | <a href="javascript:deletePic(\'' . XOOPS_URL . '\', ' . $picture->id . ', ' . $event_id . ', 1, ' . $this->nbPictures . ');" title="Delete picture"> |
||
3093 | <img src="' . XOOPS_URL . '/modules/apcal/assets/images/delete.png" border="0" alt="Delete picture" /> |
||
3094 | </a> |
||
3095 | </div>'; |
||
3096 | } else { |
||
3097 | $mainPic = '<input type="hidden" name="MAX_FILE_SIZE" value="5000000" /> |
||
3098 | <input type="file" name="picture0" id="picture0" /> |
||
3099 | <input type="hidden" name="files[]" id="files[]" value="picture0">'; |
||
3100 | } |
||
3101 | |||
3102 | // OTHER PICTURES |
||
3103 | $nbPictures = $event_id |
||
3104 | > 0 ? $GLOBALS['xoopsDB']->fetchObject($GLOBALS['xoopsDB']->query("SELECT COUNT(id) AS count FROM {$this->pic_table} WHERE event_id={$event_id} AND main_pic=0"))->count : 0; |
||
3105 | $picturesList = ''; |
||
3106 | if ($nbPictures > 0) { |
||
3107 | $pictures = $GLOBALS['xoopsDB']->query("SELECT id, picture FROM {$this->pic_table} WHERE event_id={$event_id} AND main_pic=0 ORDER BY id ASC"); |
||
3108 | while ($pic = $GLOBALS['xoopsDB']->fetchObject($pictures)) { |
||
3109 | $picturesList .= '<span id="pic' . $pic->id . '"> |
||
3110 | <a href="' . XOOPS_UPLOAD_URL . '/apcal/' . $pic->picture . '"> |
||
3111 | <img src="' . XOOPS_URL . '/modules/apcal/thumbs/phpThumb.php?src=' . XOOPS_UPLOAD_PATH . '/apcal/' . $pic->picture . '&h=120&w=120" alt="" /> |
||
3112 | </a> |
||
3113 | <a href="javascript:deletePic(\'' . XOOPS_URL . '\', ' . $pic->id . ', ' . $event_id . ', 0, ' . $this->nbPictures . ');" title="Delete the picture"> |
||
3114 | <img src="' . XOOPS_URL . '/modules/apcal/assets/images/delete.png" border="0" alt="Delete the picture" /> |
||
3115 | </a> |
||
3116 | </span>'; |
||
3117 | } |
||
3118 | } |
||
3119 | $pictures = '<div id="picList">'; |
||
3120 | $maxInput = $this->nbPictures - $nbPictures; |
||
3121 | for ($i = 1; $i < $maxInput; ++$i) { |
||
3122 | $pictures .= '<input type="hidden" name="MAX_FILE_SIZE" value="5000000" /> |
||
3123 | <input type="file" name="picture' . $i . '" id="picture' . $i . '" /> |
||
3124 | <input type="hidden" name="files[]" id="files[]" value="picture' . $i . '"> |
||
3125 | <br>'; |
||
3126 | } |
||
3127 | $pictures .= '</div>'; |
||
3128 | |||
3129 | // FORM DISPLAY |
||
3130 | $caldate = explode('-', $_GET['caldate']); |
||
3131 | $caldate = strlen($caldate[0]) > 2 ? $caldate[0] . '-' . $caldate[1] . '-' . $caldate[2] : $caldate[2] . '-' . $caldate[1] . '-' . $caldate[0]; |
||
3132 | $ret = ' |
||
3133 | <h2>' |
||
3134 | . _APCAL_MB_TITLE_EVENTINFO |
||
3135 | . ' <small>-' |
||
3136 | . _APCAL_MB_SUBTITLE_EVENTEDIT |
||
3137 | . "-</small></h2> |
||
3138 | <form class='apcalForm' action='{$this->make_cal_link('', $smode, 0, $caldate)}' method='post' id='MainForm' name='MainForm' enctype='multipart/form-data'> |
||
3139 | " |
||
3140 | . $GLOBALS['xoopsGTicket']->getTicketHtml(__LINE__) |
||
3141 | . " |
||
3142 | <input type='hidden' name='caldate' value='{$caldate}' /> |
||
3143 | <input type='hidden' name='event_id' value='$event_id' /> |
||
3144 | <input type='hidden' name='last_smode' value='$smode' /> |
||
3145 | <input type='hidden' name='last_caldate' value='$this->caldate' /> |
||
3146 | <input type='hidden' name='poster_tz' value='$poster_tz' /> |
||
3147 | <input type='hidden' name='gmlatitude' value='$this->gmlat' /> |
||
3148 | <input type='hidden' name='gmlongitude' value='$this->gmlng' /> |
||
3149 | <input type='hidden' name='gmzoomlevel' value='$this->gmzoom' /> |
||
3150 | <table border='0' cellpadding='0' cellspacing='2'> |
||
3151 | <tr> |
||
3152 | <td class='head'>" |
||
3153 | . _APCAL_TH_SUMMARY |
||
3154 | . "</td> |
||
3155 | <td class='even'><input type='text' name='summary' size='60' maxlength='250' value='$summary' /></td> |
||
3156 | </tr>" |
||
3157 | . ($this->displayTimezone ? "<tr> |
||
3158 | <td class='head'>" . _APCAL_TH_TIMEZONE . "</td> |
||
3159 | <td class='even'><select name='event_tz' $select_timezone_disabled>$tz_options</select></td> |
||
3160 | </tr>" : '') |
||
3161 | . "<tr> |
||
3162 | <td class='head'>" |
||
3163 | . _APCAL_TH_STARTDATETIME |
||
3164 | . "</td> |
||
3165 | <td class='even'> |
||
3166 | $textbox_start_date |
||
3167 | {$select_start_hour} {$select_start_min}" |
||
3168 | . _APCAL_MB_MINUTE_SUF |
||
3169 | . "</select> |
||
3170 | <span id='start_datetime'>$startHours</span> |
||
3171 | </td> |
||
3172 | </tr> |
||
3173 | <tr> |
||
3174 | <td class='head'>" |
||
3175 | . _APCAL_TH_ENDDATETIME |
||
3176 | . "</td> |
||
3177 | <td class='even'> |
||
3178 | $textbox_end_date |
||
3179 | {$select_end_hour} {$select_end_min}" |
||
3180 | . _APCAL_MB_MINUTE_SUF |
||
3181 | . " |
||
3182 | <span id='end_datetime'>$endHours</span> |
||
3183 | </td> |
||
3184 | </tr> |
||
3185 | <tr> |
||
3186 | <td class='head'>" |
||
3187 | . _APCAL_TH_ALLDAYOPTIONS |
||
3188 | . "</td> |
||
3189 | <td class='even'> |
||
3190 | <input type='radio' name='allday_bits[]' value='2' {$allday_checkbox} onClick='document.MainForm.StartHour.disabled=document.MainForm.StartMin.disabled=document.MainForm.EndHour.disabled=document.MainForm.EndMin.disabled=true;enableSelects(true);' />" |
||
3191 | . _APCAL_MB_ALLDAY_EVENT |
||
3192 | . " |
||
3193 | <input type='radio' name='allday_bits[]' value='0' {$samehours_checkbox} onClick='document.MainForm.StartHour.disabled=document.MainForm.StartMin.disabled=document.MainForm.EndHour.disabled=document.MainForm.EndMin.disabled=false;enableSelects(true);' />" |
||
0 ignored issues
–
show
The variable
$samehours_checkbox does not seem to be defined for all execution paths leading up to this point.
If you define a variable conditionally, it can happen that it is not defined for all execution paths. Let’s take a look at an example: function myFunction($a) {
switch ($a) {
case 'foo':
$x = 1;
break;
case 'bar':
$x = 2;
break;
}
// $x is potentially undefined here.
echo $x;
}
In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined. Available Fixes
![]() |
|||
3194 | . _APCAL_SAMEHOURS |
||
3195 | . " |
||
3196 | <input type='radio' name='allday_bits[]' value='8' {$diffhours_checkbox} onClick='document.MainForm.StartHour.disabled=document.MainForm.StartMin.disabled=document.MainForm.EndHour.disabled=document.MainForm.EndMin.disabled=false;enableSelects(false);' />" |
||
0 ignored issues
–
show
The variable
$diffhours_checkbox does not seem to be defined for all execution paths leading up to this point.
If you define a variable conditionally, it can happen that it is not defined for all execution paths. Let’s take a look at an example: function myFunction($a) {
switch ($a) {
case 'foo':
$x = 1;
break;
case 'bar':
$x = 2;
break;
}
// $x is potentially undefined here.
echo $x;
}
In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined. Available Fixes
![]() |
|||
3197 | . _APCAL_DIFFERENTHOURS |
||
3198 | . " |
||
3199 | </td> |
||
3200 | </tr> |
||
3201 | <tr> |
||
3202 | <td class='head'>" |
||
3203 | . _APCAL_TH_LOCATION |
||
3204 | . "</td> |
||
3205 | <td class='even'><input type='text' id='location' name='location' size='40' maxlength='250' value='$location' /></td> |
||
3206 | </tr> |
||
3207 | <tr> |
||
3208 | <td class='head'></td> |
||
3209 | <td class='even' valign='top'> |
||
3210 | <a href='' onclick=\"window.open('" |
||
3211 | . XOOPS_URL |
||
3212 | . "/modules/apcal/getCoords.php', '_blank', 'height=450,width=550,modal=yes,alwaysRaised=yes');return false;\"> |
||
3213 | <img src='" |
||
3214 | . XOOPS_URL |
||
3215 | . "/modules/apcal/assets/images/gmap.png' />" |
||
3216 | . _APCAL_TH_GETCOORDS |
||
3217 | . "</a> |
||
3218 | </td> |
||
3219 | </tr> |
||
3220 | <tr> |
||
3221 | <td class='head'>" |
||
3222 | . _APCAL_TH_LATITUDE |
||
3223 | . "</td> |
||
3224 | <td class='even'><input type='text' name='gmlat' size='40' maxlength='250' value='$gmlat' /></td> |
||
3225 | </tr> |
||
3226 | <tr> |
||
3227 | <td class='head'>" |
||
3228 | . _APCAL_TH_LONGITUDE |
||
3229 | . "</td> |
||
3230 | <td class='even'><input type='text' name='gmlong' size='40' maxlength='250' value='$gmlong' /></td> |
||
3231 | </tr> |
||
3232 | <tr> |
||
3233 | <td class='head'>" |
||
3234 | . _APCAL_TH_ZOOM |
||
3235 | . "</td> |
||
3236 | <td class='even'><input type='text' name='gmzoom' size='40' maxlength='250' value='$gmzoom' /></td> |
||
3237 | </tr> |
||
3238 | <tr> |
||
3239 | <td class='head'>" |
||
3240 | . _APCAL_TH_CONTACT |
||
3241 | . "</td> |
||
3242 | <td class='even'><input type='text' name='contact' size='50' maxlength='250' value='$contact' /></td> |
||
3243 | </tr> |
||
3244 | <tr> |
||
3245 | <td class='head'>" |
||
3246 | . _APCAL_TH_EMAIL |
||
3247 | . "</td> |
||
3248 | <td class='even'><input type='text' name='email' size='50' maxlength='250' value='$email' /></td> |
||
3249 | </tr> |
||
3250 | <tr> |
||
3251 | <td class='head'>" |
||
3252 | . _APCAL_TH_URL |
||
3253 | . "</td> |
||
3254 | <td class='even'><input type='text' name='url' size='50' maxlength='250' value='$url' /></td> |
||
3255 | </tr> |
||
3256 | <tr> |
||
3257 | <td class='head'>" |
||
3258 | . _APCAL_TH_DESCRIPTION |
||
3259 | . "</td> |
||
3260 | <td class='even'>$description_textarea</td> |
||
3261 | </tr> |
||
3262 | <tr> |
||
3263 | <td class='head'>" |
||
3264 | . _APCAL_MAINPICTURE |
||
3265 | . "</td> |
||
3266 | <td class='even'>$mainPic</td> |
||
3267 | </tr> |
||
3268 | <tr> |
||
3269 | <td class='head'>" |
||
3270 | . _APCAL_PICTURES |
||
3271 | . "</td> |
||
3272 | <td class='even'>$pictures<br>$picturesList</td> |
||
3273 | </tr> |
||
3274 | <tr> |
||
3275 | <td class='head'>" |
||
3276 | . _APCAL_TH_MAINCATEGORY |
||
3277 | . "</td> |
||
3278 | <td class='even'>$category_select</td> |
||
3279 | </tr> |
||
3280 | <tr> |
||
3281 | <td class='head'>" |
||
3282 | . _APCAL_TH_CATEGORIES |
||
3283 | . "</td> |
||
3284 | <td class='even'>$category_checkboxes</td> |
||
3285 | </tr> |
||
3286 | <tr> |
||
3287 | <td class='head'>" |
||
3288 | . _APCAL_TH_CLASS |
||
3289 | . "</td> |
||
3290 | <td class='even'><input type='radio' name='class' value='PUBLIC' $class_public onClick='document.MainForm.groupid.disabled=true' />" |
||
3291 | . _APCAL_MB_PUBLIC |
||
3292 | . " <input type='radio' name='class' value='PRIVATE' $class_private onClick='document.MainForm.groupid.disabled=false' />" |
||
3293 | . _APCAL_MB_PRIVATE |
||
3294 | . sprintf(_APCAL_MB_PRIVATETARGET, $select_private) |
||
3295 | . "</td> |
||
3296 | </tr> |
||
3297 | <tr> |
||
3298 | <td class='head'>" |
||
3299 | . _APCAL_TH_RRULE |
||
3300 | . "</td> |
||
3301 | <td class='even'>" |
||
3302 | . $this->rrule_to_form($rrule, $end_ymd) |
||
3303 | . "</td> |
||
3304 | </tr> |
||
3305 | <tr> |
||
3306 | <td class='head'>" |
||
3307 | . _APCAL_TH_ADMISSIONSTATUS |
||
3308 | . "</td> |
||
3309 | <td class='even'>$admission_status</td> |
||
3310 | </tr>\n"; |
||
3311 | |||
3312 | if ($this->enableregistration) { |
||
3313 | $ret .= $ro_form_new; |
||
3314 | } //added one line by goffy |
||
3315 | |||
3316 | if ($editable) { |
||
3317 | $ret .= " |
||
3318 | <tr> |
||
3319 | <td style='text-align:center' colspan='2'> |
||
3320 | <input name='reset' type='reset' value='" . _APCAL_BTN_RESET . "' /> |
||
3321 | $update_button |
||
3322 | $insert_button |
||
3323 | $delete_button |
||
3324 | </td> |
||
3325 | </tr>\n"; |
||
3326 | } |
||
3327 | |||
3328 | $ret .= " |
||
3329 | <tr> |
||
3330 | <td><img src='$this->images_url/spacer.gif' alt='' width='150' height='4' /></td> <td width='100%'></td> |
||
3331 | </tr> |
||
3332 | </table> |
||
3333 | </form> |
||
3334 | \n"; |
||
3335 | |||
3336 | if ($this->enableregistration) { |
||
3337 | $ret .= $ro_form_edit; |
||
3338 | } // splitted and added one line by goffy |
||
3339 | $ret .= "<table> |
||
3340 | <tr><td><img src='$this->images_url/spacer.gif' alt='' height='4' /></td></tr> |
||
3341 | <tr><td width='100%' align='right'>" . _MD_APCAL_COPYRIGHT . '</td></tr> |
||
3342 | </table>'; |
||
3343 | |||
3344 | $ret .= " |
||
3345 | <script type='text/javascript'> |
||
3346 | function addHours() |
||
3347 | { |
||
3348 | var startDate = document.MainForm.StartDate.value.split('-'); |
||
3349 | var endDate = document.MainForm.EndDate.value.split('-'); |
||
3350 | startDate = new Date(startDate[0], startDate[1]-1, startDate[2]).getTime(); |
||
3351 | endDate = new Date(endDate[0], endDate[1]-1, endDate[2]).getTime(); |
||
3352 | var diff = (endDate - startDate) / 3600000 / 24; |
||
3353 | var diffBefore = document.getElementsByName('StartH[]').length; |
||
3354 | var start = document.getElementById('start_datetime'); |
||
3355 | var end = document.getElementById('end_datetime'); |
||
3356 | var maxDays = 30; |
||
3357 | |||
3358 | if (diffBefore < diff) { |
||
3359 | for (var i=diffBefore; i<diff&&i<=maxDays; i++) { |
||
3360 | var startNode = document.createElement('span'); |
||
3361 | var endNode = document.createElement('span'); |
||
3362 | |||
3363 | startNode.innerHTML += \"" . _APCAL_DAY . " \"+(i+2); |
||
3364 | startNode.innerHTML += \"<select name='StartH[]' disabled>" . str_replace("\n", '', $this->get_options_for_hour($start_hour)) . "</select>\"; |
||
3365 | startNode.innerHTML += \"<select name='StartM[]' disabled>" . str_replace("\n", '', $this->get_options_for_min($start_min)) . '</select>"; |
||
3366 | endNode.innerHTML += "' . _APCAL_DAY . " \"+(i+2); |
||
3367 | endNode.innerHTML += \"<select name='EndH[]' disabled>" . str_replace("\n", '', $this->get_options_for_hour($end_hour)) . "</select>\"; |
||
3368 | endNode.innerHTML += \"<select name='EndM[]' disabled>" . str_replace("\n", '', $this->get_options_for_min($end_min)) . "</select>\"; |
||
3369 | |||
3370 | start.appendChild(startNode); |
||
3371 | end.appendChild(endNode); |
||
3372 | } |
||
3373 | } elseif (diff >= 0 && diff<=maxDays) { |
||
3374 | var StartSpan = document.getElementById('start_datetime').getElementsByTagName('span'); |
||
3375 | var EndSpan = document.getElementById('end_datetime').getElementsByTagName('span'); |
||
3376 | for (var i=diffBefore-1; i>=diff; i--) { |
||
3377 | StartSpan[i].outerHTML = ''; |
||
3378 | EndSpan[i].outerHTML = ''; |
||
3379 | } |
||
3380 | } |
||
3381 | enableSelects(!document.getElementsByName('allday_bits[]')[2].checked); |
||
3382 | } |
||
3383 | |||
3384 | function enableSelects(disabled) |
||
3385 | { |
||
3386 | var StartH = document.getElementsByName('StartH[]'); |
||
3387 | var StartM = document.getElementsByName('StartM[]'); |
||
3388 | var EndH = document.getElementsByName('EndH[]'); |
||
3389 | var EndM = document.getElementsByName('EndM[]'); |
||
3390 | var nbItems = StartH.length; |
||
3391 | |||
3392 | for (var i=0; i<nbItems; i++) { |
||
3393 | StartH[i].disabled = disabled; |
||
3394 | StartM[i].disabled = disabled; |
||
3395 | EndH[i].disabled = disabled; |
||
3396 | EndM[i].disabled = disabled; |
||
3397 | } |
||
3398 | } |
||
3399 | |||
3400 | function checkChange() |
||
3401 | { |
||
3402 | var newStart = document.MainForm.StartDate.value; |
||
3403 | var newEnd = document.MainForm.EndDate.value; |
||
3404 | if (oldStart != newStart || oldEnd != newEnd) {addHours();} |
||
3405 | oldStart = newStart; |
||
3406 | oldEnd = newEnd; |
||
3407 | } |
||
3408 | var oldStart = document.MainForm.StartDate.value; |
||
3409 | var oldEnd = document.MainForm.EndDate.value; |
||
3410 | setInterval(checkChange, 750); |
||
3411 | </script>\n |
||
3412 | "; |
||
3413 | |||
3414 | return $ret; |
||
3415 | } |
||
3416 | |||
3417 | // Save an event |
||
3418 | |||
3419 | /** |
||
3420 | * @param string $set_sql_append |
||
3421 | * @param string $whr_sql_append |
||
3422 | * @param null $notify_callback |
||
3423 | */ |
||
3424 | public function update_schedule($set_sql_append = '', $whr_sql_append = '', $notify_callback = null) |
||
3425 | { |
||
3426 | if ($_POST['summary'] === '') { |
||
3427 | $_POST['summary'] = _APCAL_MB_NOSUBJECT; |
||
3428 | } |
||
3429 | |||
3430 | list($start, $start_date, $use_default) = $this->parse_posted_date($this->mb_convert_kana($_POST['StartDate'], 'a'), $this->unixtime); |
||
0 ignored issues
–
show
The assignment to
$use_default is unused. Consider omitting it like so list($first,,$third) .
This checks looks for assignemnts to variables using the Consider the following code example. <?php
function returnThreeValues() {
return array('a', 'b', 'c');
}
list($a, $b, $c) = returnThreeValues();
print $a . " - " . $c;
Only the variables Instead, the list call could have been. list($a,, $c) = returnThreeValues();
![]() |
|||
3431 | list($end, $end_date, $use_default) = $this->parse_posted_date($this->mb_convert_kana($_POST['EndDate'], 'a'), $this->unixtime); |
||
0 ignored issues
–
show
The assignment to
$use_default is unused. Consider omitting it like so list($first,,$third) .
This checks looks for assignemnts to variables using the Consider the following code example. <?php
function returnThreeValues() {
return array('a', 'b', 'c');
}
list($a, $b, $c) = returnThreeValues();
print $a . " - " . $c;
Only the variables Instead, the list call could have been. list($a,, $c) = returnThreeValues();
![]() |
|||
3432 | |||
3433 | $allday = 1; |
||
3434 | if (isset($_POST['allday_bits'])) { |
||
3435 | $bits = $_POST['allday_bits']; |
||
3436 | if (is_array($bits)) { |
||
3437 | foreach ($bits as $bit) { |
||
3438 | if ($bit > 0 && $bit < 8) { |
||
3439 | $allday += pow(2, (int)$bit); |
||
3440 | } |
||
3441 | } |
||
3442 | } |
||
3443 | } |
||
3444 | |||
3445 | $tzoffset_e2s = (int)(($this->server_TZ - $_POST['event_tz']) * 3600); |
||
3446 | if ($start_date || $end_date) { |
||
3447 | if ($start_date) { |
||
3448 | $date_append = ", start_date='$start_date'"; |
||
3449 | } else { |
||
3450 | $date_append = ', start_date=null'; |
||
3451 | } |
||
3452 | if ($end_date) { |
||
3453 | $date_append .= ", end_date='$end_date'"; |
||
3454 | } else { |
||
3455 | $date_append .= ', end_date=null'; |
||
3456 | $end += 86400; |
||
3457 | } |
||
3458 | $set_sql_date = "start='$start', end='$end', allday='$allday' $date_append"; |
||
3459 | $allday_flag = true; |
||
3460 | } elseif ($_POST['allday_bits'][0] > 0) { |
||
3461 | $start += $_POST['StartHour'] * 3600 + $_POST['StartMin'] * 60 + $tzoffset_e2s; |
||
3462 | $end += $_POST['EndHour'] * 3600 + $_POST['EndMin'] * 60 + $tzoffset_e2s; |
||
3463 | if ($start > $end) { |
||
3464 | list($start, $end) = array($end, $start); |
||
3465 | } elseif ($start == $end) { |
||
3466 | $start += 60; |
||
3467 | $end += (23 * 3600) + (59 * 60); |
||
3468 | } |
||
3469 | //$end += 86400 ; |
||
3470 | $set_sql_date = "start='$start', end='$end', allday='$allday', start_date=null, end_date=null"; |
||
3471 | $allday_flag = true; |
||
3472 | } else { |
||
3473 | if (!isset($_POST['event_tz'])) { |
||
3474 | $_POST['event_tz'] = $this->user_TZ; |
||
3475 | } |
||
3476 | $tzoffset_e2s = (int)(($this->server_TZ - $_POST['event_tz']) * 3600); |
||
3477 | //$tzoffset_e2s = (int)( date( 'Z' , $start ) - $_POST['event_tz'] * 3600 ) ; |
||
3478 | |||
3479 | $start += $_POST['StartHour'] * 3600 + $_POST['StartMin'] * 60 + $tzoffset_e2s; |
||
3480 | $end += $_POST['EndHour'] * 3600 + $_POST['EndMin'] * 60 + $tzoffset_e2s; |
||
3481 | if ($start > $end) { |
||
3482 | list($start, $end) = array($end, $start); |
||
3483 | } |
||
3484 | $set_sql_date = "start='$start', end='$end', allday=0, start_date=null, end_date=null"; |
||
3485 | $allday_flag = false; |
||
3486 | } |
||
3487 | |||
3488 | $otherHours = ''; |
||
3489 | if (isset($_POST['allday_bits'][0]) && $_POST['allday_bits'][0] == '8') { |
||
3490 | $otherHours = array(); |
||
3491 | foreach ($_POST['StartH'] as $i => $startH) { |
||
3492 | $otherHours[] = ($i + 1) . ':' . $startH . ':' . $_POST['StartM'][$i] . ':' . $_POST['EndH'][$i] . ':' . $_POST['EndM'][$i]; |
||
3493 | } |
||
3494 | $otherHours = implode('-', $otherHours); |
||
3495 | } |
||
3496 | |||
3497 | $set_sql_date .= ",server_tz='$this->server_TZ'"; |
||
3498 | |||
3499 | if (!isset($_POST['description']) && isset($_POST['description_text'])) { |
||
3500 | $_POST['description'] = $_POST['description_text']; |
||
3501 | } |
||
3502 | |||
3503 | $_POST['categories'] = ''; |
||
3504 | $cids = is_array(@$_POST['cids']) ? $_POST['cids'] : array(); |
||
3505 | if (!in_array($_POST['mainCategory'], $cids)) { |
||
3506 | $cids[] = $_POST['mainCategory']; |
||
3507 | } |
||
3508 | foreach ($cids as $cid) { |
||
3509 | $cid = (int)$cid; |
||
3510 | while (isset($this->categories[$cid])) { |
||
3511 | $cid4sql = sprintf('%05d,', $cid); |
||
3512 | if (stristr($_POST['categories'], $cid4sql) === false) { |
||
3513 | $_POST['categories'] .= sprintf('%05d,', $cid); |
||
3514 | } |
||
3515 | $cid = (int)$this->categories[$cid]->pid; |
||
3516 | } |
||
3517 | } |
||
3518 | |||
3519 | // RRULE |
||
3520 | $rrule = $this->rrule_from_post($start, $allday_flag); |
||
3521 | |||
3522 | $cols = array( |
||
3523 | 'summary' => '255:J:1', |
||
3524 | 'location' => '255:J:0', |
||
3525 | 'contact' => '255:J:0', |
||
3526 | 'email' => '255:J:0', |
||
3527 | 'url' => '255:J:0', |
||
3528 | 'description' => 'A:J:0', |
||
3529 | 'categories' => '255:E:0', |
||
3530 | 'class' => '255:E:0', |
||
3531 | 'groupid' => 'I:N:0', |
||
3532 | 'poster_tz' => 'F:N:0', |
||
3533 | 'event_tz' => 'F:N:0' |
||
3534 | ); |
||
3535 | |||
3536 | $set_str = $this->get_sql_set($cols) . ", $set_sql_date $set_sql_append"; |
||
3537 | $set_str .= ",shortsummary='" . $this->makeShort(utf8_decode($_POST['summary'])) . "'"; |
||
3538 | $set_str .= ",mainCategory='" . $_POST['mainCategory'] . "'"; |
||
3539 | $set_str .= ",otherHours='" . $otherHours . "'"; |
||
3540 | |||
3541 | // Check update or insert |
||
3542 | $event_id = (int)$_POST['event_id']; |
||
3543 | if ($event_id > 0) { |
||
3544 | $rs = $GLOBALS['xoopsDB']->query("SELECT rrule_pid FROM $this->table WHERE id='$event_id' $whr_sql_append"); |
||
3545 | if (!($event = $GLOBALS['xoopsDB']->fetchObject($rs))) { |
||
3546 | die('Record Not Exists.'); |
||
3547 | } |
||
3548 | View Code Duplication | if ($event->rrule_pid > 0) { |
|
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. ![]() |
|||
3549 | if (!$GLOBALS['xoopsDB']->query("DELETE FROM $this->table WHERE rrule_pid='$event->rrule_pid' AND id<>'$event_id'")) { |
||
3550 | echo $GLOBALS['xoopsDB']->error(); |
||
3551 | } |
||
3552 | } |
||
3553 | |||
3554 | // UPDATE |
||
3555 | if ($rrule !== '') { |
||
3556 | $set_str .= ', rrule_pid=id'; |
||
3557 | } |
||
3558 | $sql = "UPDATE $this->table SET $set_str , rrule='$rrule' , sequence=sequence+1, gmlat='{$_POST['gmlat']}', gmlong='{$_POST['gmlong']}', gmzoom='{$_POST['gmzoom']}' WHERE id='$event_id' $whr_sql_append"; |
||
3559 | if (!$GLOBALS['xoopsDB']->query($sql)) { |
||
3560 | echo $GLOBALS['xoopsDB']->error(); |
||
3561 | } |
||
3562 | |||
3563 | // RRULE |
||
3564 | if ($rrule !== '') { |
||
3565 | $this->rrule_extract($event_id); |
||
3566 | } |
||
3567 | |||
3568 | // ���٤Ƥ򹹿��塢���������դΥ����������?�� |
||
3569 | $last_smode = preg_replace('/[^a-zA-Z0-9_-]/', '', @$_POST['last_smode']); |
||
0 ignored issues
–
show
$last_smode 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 ![]() |
|||
3570 | //$last_caldate = preg_replace( '/[^a-zA-Z0-9_-]/' , '' , @$_POST['last_caldate'] ) ; |
||
3571 | $new_caldate = $start_date ?: date('Y-n-j', $start); |
||
0 ignored issues
–
show
$new_caldate 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 ![]() |
|||
3572 | //$this->redirect( "smode=$last_smode&caldate=$new_caldate" ) ; |
||
3573 | View Code Duplication | if (isset($_POST['saveas'])) { |
|
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. ![]() |
|||
3574 | $result = $GLOBALS['xoopsDB']->query("SELECT * FROM {$this->pic_table} WHERE event_id={$_POST['event_oldid']}"); |
||
3575 | while ($pic = $GLOBALS['xoopsDB']->fetchObject($result)) { |
||
3576 | $GLOBALS['xoopsDB']->query("INSERT INTO {$this->pic_table}(event_id, picture, main_pic) VALUES ({$event_id}, '{$pic->picture}', {$pic->main_pic})"); |
||
3577 | } |
||
3578 | $this->savepictures($event_id); |
||
3579 | } else { |
||
3580 | $this->savepictures($event_id); |
||
3581 | } |
||
3582 | } else { |
||
3583 | $sql = "INSERT INTO $this->table SET $set_str , rrule='$rrule' , sequence=0, gmlat='{$_POST['gmlat']}', gmlong='{$_POST['gmlong']}', gmzoom='{$_POST['gmzoom']}'"; |
||
3584 | if (!$GLOBALS['xoopsDB']->query($sql)) { |
||
3585 | echo $GLOBALS['xoopsDB']->error(); |
||
3586 | } |
||
3587 | // unique_id,rrule_pid |
||
3588 | $event_id = $GLOBALS['xoopsDB']->getInsertId($this->conn); |
||
3589 | $unique_id = 'apcal060-' . md5("{$_SERVER['HTTP_HOST']}{$_SERVER['PHP_SELF']}$event_id"); |
||
3590 | $rrule_pid = $rrule ? $event_id : 0; |
||
3591 | $GLOBALS['xoopsDB']->query("UPDATE $this->table SET unique_id='$unique_id',rrule_pid='$rrule_pid' WHERE id='$event_id'"); |
||
3592 | |||
3593 | // RRULE |
||
3594 | if ($rrule !== '') { |
||
3595 | $this->rrule_extract($event_id); |
||
3596 | } |
||
3597 | |||
3598 | if (isset($notify_callback)) { |
||
3599 | $this->$notify_callback($event_id); |
||
3600 | } |
||
3601 | |||
3602 | $last_smode = preg_replace('/[^a-zA-Z0-9_-]/', '', @$_POST['last_smode']); |
||
3603 | $last_caldate = preg_replace('/[^a-zA-Z0-9_-]/', '', @$_POST['last_caldate']); |
||
3604 | //$this->redirect( "smode=$last_smode&caldate=$last_caldate" ) ; |
||
3605 | |||
3606 | // Save pictures |
||
3607 | View Code Duplication | if (isset($_POST['saveas'])) { |
|
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. ![]() |
|||
3608 | $result = $GLOBALS['xoopsDB']->query("SELECT * FROM {$this->pic_table} WHERE event_id={$_POST['event_oldid']}"); |
||
3609 | while ($pic = $GLOBALS['xoopsDB']->fetchObject($result)) { |
||
3610 | $GLOBALS['xoopsDB']->query("INSERT INTO {$this->pic_table}(event_id, picture, main_pic) VALUES ({$event_id}, '{$pic->picture}', {$pic->main_pic})"); |
||
3611 | } |
||
3612 | $this->savepictures($event_id); |
||
3613 | } else { |
||
3614 | $this->savepictures($event_id); |
||
3615 | } |
||
3616 | |||
3617 | // added by goffy for registration online automatically redirect to form for set up parameters for online registration, if online registration is selected |
||
3618 | $ro_redirect = $_POST['ro_activate']; |
||
3619 | if ($ro_redirect === 'yes') { |
||
3620 | View Code Duplication | if (!empty($_SERVER['HTTPS'])) { |
|
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. ![]() |
|||
3621 | $this->redirecturl = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; |
||
3622 | } else { |
||
3623 | $this->redirecturl = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; |
||
3624 | } |
||
3625 | |||
3626 | $call_ro = 'ro_regonlinehandler.php?op=show_form_activate'; |
||
3627 | $call_ro .= "&uid=$uid"; |
||
0 ignored issues
–
show
|
|||
3628 | $call_ro .= "&eventid=$event_id"; |
||
3629 | $call_ro .= '&title=' . $_POST['summary']; |
||
3630 | $call_ro .= "&eventdate=$start";//.$_POST[ 'StartDate' ]." ".$_POST[ 'StartHour' ].":".$_POST[ 'StartMin' ]; |
||
3631 | $call_ro .= '&eventurl=' . $this->redirecturl; |
||
3632 | $call_ro .= "&smode=$last_smode"; |
||
3633 | $call_ro .= "&caldate=$last_caldate"; |
||
3634 | redirect_header($call_ro, 3, _APCAL_RO_SUCCESS_NEW_EVENT . '<br>' . _APCAL_RO_REDIRECT); |
||
3635 | } else { |
||
3636 | redirect_header($this->redirecturl . "?smode=$last_smode&caldate=$last_caldate", 3, _APCAL_RO_SUCCESS_NEW_EVENT); |
||
3637 | } |
||
3638 | // end goffy |
||
3639 | } |
||
3640 | } |
||
3641 | |||
3642 | // Delete an event |
||
3643 | |||
3644 | /** |
||
3645 | * @param string $whr_sql_append |
||
3646 | * @param null $eval_after |
||
3647 | */ |
||
3648 | public function delete_schedule($whr_sql_append = '', $eval_after = null) |
||
3649 | { |
||
3650 | if (!empty($_POST['event_id'])) { |
||
3651 | $event_id = (int)$_POST['event_id']; |
||
3652 | |||
3653 | $this->delete_regonline($event_id); // added one line by goffy |
||
3654 | $rs = $GLOBALS['xoopsDB']->query("SELECT rrule_pid FROM $this->table WHERE id='$event_id' $whr_sql_append"); |
||
3655 | if (!($event = $GLOBALS['xoopsDB']->fetchObject($rs))) { |
||
3656 | die('Record Not Exists.'); |
||
3657 | } |
||
3658 | if ($event->rrule_pid > 0) { |
||
3659 | View Code Duplication | if (!$GLOBALS['xoopsDB']->query("DELETE FROM $this->table WHERE rrule_pid='$event->rrule_pid' $whr_sql_append")) { |
|
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. ![]() |
|||
3660 | echo $GLOBALS['xoopsDB']->error(); |
||
3661 | } |
||
3662 | // ����������ɲý����eval�Ǽ����� (XOOPS�Ǥϡ������Ȥκ��� |
||
3663 | if ($GLOBALS['xoopsDB']->getAffectedRows() > 0 && isset($eval_after)) { |
||
3664 | $id = $event->rrule_pid; |
||
0 ignored issues
–
show
$id 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 ![]() |
|||
3665 | eval($eval_after); |
||
3666 | } |
||
3667 | } else { |
||
3668 | View Code Duplication | if (!$GLOBALS['xoopsDB']->query("DELETE FROM $this->table WHERE id='$event_id' $whr_sql_append")) { |
|
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. ![]() |
|||
3669 | echo $GLOBALS['xoopsDB']->error(); |
||
3670 | } |
||
3671 | // ����������ɲý����eval�Ǽ����� (XOOPS�Ǥϡ������Ȥκ��� |
||
3672 | if ($GLOBALS['xoopsDB']->getAffectedRows() == 1 && isset($eval_after)) { |
||
3673 | $id = $event_id; |
||
0 ignored issues
–
show
$id 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 ![]() |
|||
3674 | eval($eval_after); |
||
3675 | } |
||
3676 | } |
||
3677 | } |
||
3678 | $last_smode = preg_replace('/[^a-zA-Z0-9_-]/', '', @$_POST['last_smode']); |
||
3679 | $last_caldate = preg_replace('/[^a-zA-Z0-9_-]/', '', @$_POST['last_caldate']); |
||
3680 | $this->redirect("smode=$last_smode&caldate=$last_caldate"); |
||
3681 | } |
||
3682 | |||
3683 | // �������塼��ΰ�����RRULE�λҶ��쥳���ɡ� |
||
3684 | |||
3685 | /** |
||
3686 | * @param string $whr_sql_append |
||
3687 | */ |
||
3688 | public function delete_schedule_one($whr_sql_append = '') |
||
3689 | { |
||
3690 | if (!empty($_POST['subevent_id'])) { |
||
3691 | $event_id = (int)$_POST['subevent_id']; |
||
3692 | $this->delete_regonline($event_id); // added one line by goffy |
||
3693 | |||
3694 | View Code Duplication | if (!$GLOBALS['xoopsDB']->query("DELETE FROM $this->table WHERE id='$event_id' AND rrule_pid <> id $whr_sql_append")) { |
|
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. ![]() |
|||
3695 | echo $GLOBALS['xoopsDB']->error(); |
||
3696 | } |
||
3697 | } |
||
3698 | $last_smode = preg_replace('/[^a-zA-Z0-9_-]/', '', @$_POST['last_smode']); |
||
3699 | $last_caldate = preg_replace('/[^a-zA-Z0-9_-]/', '', @$_POST['last_caldate']); |
||
3700 | $this->redirect("smode=$last_smode&caldate=$last_caldate"); |
||
3701 | } |
||
3702 | |||
3703 | //added function by goffy |
||
3704 | |||
3705 | /** |
||
3706 | * @param $event_id |
||
3707 | */ |
||
3708 | public function delete_regonline($event_id) |
||
3709 | { |
||
3710 | //delete data from table apcal_ro_members |
||
3711 | $sql = 'DELETE ' |
||
3712 | . XOOPS_DB_PREFIX |
||
3713 | . $this->table_ro_members |
||
3714 | . '.* FROM ' |
||
3715 | . XOOPS_DB_PREFIX |
||
3716 | . $this->table_ro_members |
||
3717 | . ' WHERE ((' |
||
3718 | . XOOPS_DB_PREFIX |
||
3719 | . $this->table_ro_members |
||
3720 | . ".rom_eventid)=$event_id)"; |
||
3721 | $res = $GLOBALS['xoopsDB']->query($sql); |
||
0 ignored issues
–
show
$res 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 ![]() |
|||
3722 | |||
3723 | //delete data from table apcal_ro_notify |
||
3724 | $sql = 'DELETE ' |
||
3725 | . XOOPS_DB_PREFIX |
||
3726 | . $this->table_ro_notify |
||
3727 | . '.* FROM ' |
||
3728 | . XOOPS_DB_PREFIX |
||
3729 | . $this->table_ro_notify |
||
3730 | . ' WHERE ((' |
||
3731 | . XOOPS_DB_PREFIX |
||
3732 | . $this->table_ro_notify |
||
3733 | . ".ron_eventid)=$event_id)"; |
||
3734 | $res = $GLOBALS['xoopsDB']->query($sql); |
||
0 ignored issues
–
show
$res 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 ![]() |
|||
3735 | |||
3736 | //delete data from table apcal_ro_events |
||
3737 | $sql = 'DELETE ' |
||
3738 | . XOOPS_DB_PREFIX |
||
3739 | . $this->table_ro_events |
||
3740 | . '.* FROM ' |
||
3741 | . XOOPS_DB_PREFIX |
||
3742 | . $this->table_ro_events |
||
3743 | . ' WHERE ((' |
||
3744 | . XOOPS_DB_PREFIX |
||
3745 | . $this->table_ro_events |
||
3746 | . ".roe_eventid)=$event_id)"; |
||
3747 | $res = $GLOBALS['xoopsDB']->query($sql); |
||
0 ignored issues
–
show
$res 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 ![]() |
|||
3748 | } |
||
3749 | |||
3750 | /** |
||
3751 | * @param $query |
||
3752 | */ |
||
3753 | public function redirect($query) |
||
3754 | { |
||
3755 | // character white list and black list against 'javascript' |
||
3756 | if (!preg_match('/^[a-z0-9=&_-]*$/i', $query) || stristr($query, 'javascript')) { |
||
3757 | header(strtr("Location: $this->connection://{$_SERVER['HTTP_HOST']}{$_SERVER['PHP_SELF']}", "\r\n\0", ' ')); |
||
3758 | exit; |
||
3759 | } |
||
3760 | |||
3761 | if (headers_sent()) { |
||
3762 | echo " |
||
3763 | <html> |
||
3764 | <head> |
||
3765 | <title>redirection</title> |
||
3766 | <meta http-equiv='Refresh' content='0; url=?$query' /> |
||
3767 | </head> |
||
3768 | <body> |
||
3769 | <p> |
||
3770 | <a href='?$query'>push here if not redirected</a> |
||
3771 | </p> |
||
3772 | </body> |
||
3773 | </html>"; |
||
3774 | } else { |
||
3775 | header(strtr("Location: $this->connection://{$_SERVER['HTTP_HOST']}{$_SERVER['PHP_SELF']}?$query", "\r\n\0", ' ')); |
||
3776 | } |
||
3777 | exit; |
||
3778 | } |
||
3779 | |||
3780 | // -12.0��12.0�ޤǤ��ͤ�����ơ�(GMT+HH:MM) �Ȥ���ʸ������֤� |
||
3781 | |||
3782 | /** |
||
3783 | * @param $offset |
||
3784 | * @return string |
||
3785 | */ |
||
3786 | public function get_tz_for_display($offset) |
||
3787 | { |
||
3788 | return $this->displayTimezone ? '(GMT' . ($offset >= 0 ? '+' : '-') . sprintf('%02d:%02d', abs($offset), abs($offset) * 60 % 60) . ')' : ''; |
||
3789 | } |
||
3790 | |||
3791 | // -12.0��12.0�ޤǤ�Timzone SELECT�ܥå�����Optionʸ������֤� |
||
3792 | |||
3793 | /** |
||
3794 | * @param int $selected |
||
3795 | * @return string |
||
3796 | */ |
||
3797 | public function get_tz_options($selected = 0) |
||
3798 | { |
||
3799 | $tzs = array( |
||
3800 | '-12', |
||
3801 | '-11', |
||
3802 | '-10', |
||
3803 | '-9', |
||
3804 | '-8', |
||
3805 | '-7', |
||
3806 | '-6', |
||
3807 | '-5', |
||
3808 | '-4', |
||
3809 | '-3.5', |
||
3810 | '-3', |
||
3811 | '-2', |
||
3812 | '-1', |
||
3813 | '0', |
||
3814 | '1', |
||
3815 | '2', |
||
3816 | '3', |
||
3817 | '3.5', |
||
3818 | '4', |
||
3819 | '4.5', |
||
3820 | '5', |
||
3821 | '5.5', |
||
3822 | '6', |
||
3823 | '7', |
||
3824 | '8', |
||
3825 | '9', |
||
3826 | '9.5', |
||
3827 | '10', |
||
3828 | '11', |
||
3829 | '12' |
||
3830 | ); |
||
3831 | |||
3832 | $ret = ''; |
||
3833 | foreach ($tzs as $tz) { |
||
3834 | if ($tz == $selected) { |
||
3835 | $ret .= "\t<option value='$tz' selected>" . $this->get_tz_for_display($tz) . "</option>\n"; |
||
3836 | } else { |
||
3837 | $ret .= "\t<option value='$tz'>" . $this->get_tz_for_display($tz) . "</option>\n"; |
||
3838 | } |
||
3839 | } |
||
3840 | |||
3841 | return $ret; |
||
3842 | } |
||
3843 | |||
3844 | // -12.0��12.0�ޤǤ��ͤ�����ơ�array(TZOFFSET,TZID)���֤� |
||
3845 | |||
3846 | /** |
||
3847 | * @param $tz |
||
3848 | * @return array |
||
3849 | */ |
||
3850 | public function get_timezone_desc($tz) |
||
3851 | { |
||
3852 | if ($tz == 0) { |
||
3853 | $tzoffset = '+0000'; |
||
3854 | $tzid = 'GMT'; |
||
3855 | } elseif ($tz > 0) { |
||
3856 | $tzoffset = sprintf('+%02d%02d', $tz, $tz * 60 % 60); |
||
3857 | $tzid = 'Etc/GMT-' . sprintf('%d', $tz); |
||
3858 | } else { |
||
3859 | $tz = abs($tz); |
||
3860 | $tzoffset = sprintf('-%02d%02d', $tz, $tz * 60 % 60); |
||
3861 | $tzid = 'Etc/GMT+' . sprintf('%d', $tz); |
||
3862 | } |
||
3863 | |||
3864 | return array($tzoffset, $tzid); |
||
3865 | } |
||
3866 | |||
3867 | // ���ƥ��꡼����ʸ��ܥå�����ե����ऴ�Ⱥ������� |
||
3868 | |||
3869 | /** |
||
3870 | * @param string $get_target |
||
3871 | * @param null $smode |
||
3872 | * @return string |
||
3873 | */ |
||
3874 | public function get_categories_selform($get_target = '', $smode = null) |
||
3875 | { |
||
3876 | global $xoopsModule; |
||
3877 | |||
3878 | if (empty($this->categories)) { |
||
3879 | return ''; |
||
3880 | } |
||
3881 | |||
3882 | if (empty($smode)) { |
||
3883 | $smode = isset($_GET['smode']) ? $_GET['smode'] : 'Monthly'; |
||
3884 | } |
||
3885 | $smode = preg_replace('/[^a-zA-Z0-9_-]/', '', $smode); |
||
3886 | |||
3887 | $op = empty($_GET['op']) ? '' : preg_replace('/[^a-zA-Z0-9_-]/', '', $_GET['op']); |
||
3888 | |||
3889 | $ret = "<script type='text/javascript'>\n"; |
||
3890 | $ret .= "function submitCat(cid, smode, caldate)\n"; |
||
3891 | $ret .= "{\n"; |
||
3892 | if ($this->useurlrewrite) { |
||
3893 | $ret .= "var defaultView = '" . $this->default_view . "';\n"; |
||
3894 | $ret .= "var today = '" . date('Y-n-j') . "';\n"; |
||
3895 | |||
3896 | $ret .= "if (cid != 'All' && smode != defaultView && caldate != today) {document.catSel.action = '" . XOOPS_URL . "/modules/apcal/' + cid + '-' + smode + '-' + caldate;}\n"; |
||
3897 | $ret .= "else if (cid != 'All' && smode != defaultView && caldate == today) {document.catSel.action = '" . XOOPS_URL . "/modules/apcal/' + cid + '-' + smode;}\n"; |
||
3898 | $ret .= "else if (cid != 'All' && smode == defaultView && caldate != today) {document.catSel.action = '" . XOOPS_URL . "/modules/apcal/' + cid + '-' + caldate;}\n"; |
||
3899 | $ret .= "else if (cid == 'All' && smode != defaultView && caldate != today) {document.catSel.action = '" . XOOPS_URL . "/modules/apcal/' + smode + '-' + caldate;}\n"; |
||
3900 | $ret .= "else if (cid == 'All' && smode != defaultView && caldate == today) {document.catSel.action = '" . XOOPS_URL . "/modules/apcal/' + smode;}\n"; |
||
3901 | $ret .= "else if (cid == 'All' && smode == defaultView && caldate != today) {document.catSel.action = '" . XOOPS_URL . "/modules/apcal/' + caldate;}\n"; |
||
3902 | $ret .= "else if (cid != 'All' && smode == defaultView && caldate == today) {document.catSel.action = '" . XOOPS_URL . "/modules/apcal/' + cid;}\n"; |
||
3903 | $ret .= "else {document.catSel.action = '" . XOOPS_URL . "/modules/apcal/';}\n"; |
||
3904 | |||
3905 | //$ret .= "document.catSel.action = '".XOOPS_URL."/' + cid + '/' + smode + '/' + caldate;\n"; |
||
3906 | $ret .= "document.catSel.method = 'POST';\n"; |
||
3907 | } |
||
3908 | $ret .= "document.catSel.submit();\n"; |
||
3909 | $ret .= "}\n"; |
||
3910 | $ret .= "</script>\n"; |
||
3911 | $ret .= "<form class='apcalForm' action='$get_target' name='catSel' method='GET' style='margin:0px;'>\n"; |
||
3912 | $ret .= "<input type='hidden' name='caldate' value='$this->caldate' />\n"; |
||
3913 | $ret .= "<input type='hidden' name='smode' value='$smode' />\n"; |
||
3914 | $ret .= "<input type='hidden' name='op' value='$op' />\n"; |
||
3915 | $ret .= "<select name='cid' onchange='submitCat(document.catSel.cid.value, document.catSel.smode.value, document.catSel.caldate.value);'>\n"; |
||
3916 | $ret .= $this->useurlrewrite ? "\t<option value='All'>" . _APCAL_MB_SHOWALLCAT . "</option>\n" : "\t<option value='0'>" . _APCAL_MB_SHOWALLCAT . "</option>\n"; |
||
3917 | foreach ($this->categories as $cid => $cat) { |
||
3918 | $selected = $this->now_cid == $cid ? 'selected' : ''; |
||
3919 | $depth_desc = str_repeat('-', (int)$cat->cat_depth); |
||
3920 | $cat_title4show = $this->text_sanitizer_for_show($cat->cat_title); |
||
3921 | $ret .= $this->useurlrewrite ? "\t<option value='" |
||
3922 | . urlencode(urlencode($cat->cat_shorttitle)) |
||
3923 | . "' $selected>$depth_desc $cat_title4show</option>\n" : "\t<option value='$cid' $selected>$depth_desc $cat_title4show</option>\n"; |
||
3924 | } |
||
3925 | $ret .= "</select>\n</form>\n"; |
||
3926 | |||
3927 | return $ret; |
||
3928 | } |
||
3929 | |||
3930 | // ǯ����Υƥ����ȥܥå������Ϥ�����ơ�UnixTimestamp���֤� |
||
3931 | |||
3932 | /** |
||
3933 | * @param $date_desc |
||
3934 | * @param $default_unixtime |
||
3935 | * @return array |
||
3936 | */ |
||
3937 | public function parse_posted_date($date_desc, $default_unixtime) |
||
3938 | { |
||
3939 | if (!preg_match('#^([0-9][0-9]+)[-./]?([0-1]?[0-9])[-./]?([0-3]?[0-9])$#', $date_desc, $regs)) { |
||
3940 | $unixtime = $default_unixtime; |
||
3941 | $use_default = true; |
||
3942 | $iso_date = ''; |
||
3943 | } elseif ($regs[1] >= 2038) { |
||
3944 | // 2038ǯ�ʹߤξ�� 2038/1/1 �˥��å� |
||
3945 | $unixtime = mktime(0, 0, 0, 1, 1, 2038); |
||
3946 | $use_default = false; |
||
3947 | $iso_date = "{$regs[1]}-{$regs[2]}-{$regs[3]}"; |
||
3948 | } elseif ($regs[1] <= 1970) { |
||
3949 | // 1970ǯ�����ξ�� 1970/12/31�˥��å� |
||
3950 | $unixtime = mktime(0, 0, 0, 12, 31, 1970); |
||
3951 | $use_default = false; |
||
3952 | $iso_date = "{$regs[1]}-{$regs[2]}-{$regs[3]}"; |
||
3953 | } elseif (!checkdate($regs[2], $regs[3], $regs[1])) { |
||
3954 | $unixtime = $default_unixtime; |
||
3955 | $use_default = true; |
||
3956 | $iso_date = ''; |
||
3957 | } else { |
||
3958 | $unixtime = mktime(0, 0, 0, $regs[2], $regs[3], $regs[1]); |
||
3959 | $use_default = false; |
||
3960 | $iso_date = ''; |
||
3961 | } |
||
3962 | |||
3963 | return array($unixtime, $iso_date, $use_default); |
||
3964 | } |
||
3965 | |||
3966 | // timezone���������ơ�RFC2445��VTIMEZONE��ʸ������֤� |
||
3967 | |||
3968 | /** |
||
3969 | * @param $timezones |
||
3970 | * @return string |
||
3971 | */ |
||
3972 | public function get_vtimezones_str($timezones) |
||
3973 | { |
||
3974 | if (empty($timezones)) { |
||
3975 | return "BEGIN:VTIMEZONE\r |
||
3976 | TZID:GMT\r |
||
3977 | BEGIN:STANDARD\r |
||
3978 | DTSTART:19390101T000000\r |
||
3979 | TZOFFSETFROM:+0000\r |
||
3980 | TZOFFSETTO:+0000\r |
||
3981 | TZNAME:GMT\r |
||
3982 | END:STANDARD\r |
||
3983 | END:VTIMEZONE\r\n"; |
||
3984 | } else { |
||
3985 | $ret = ''; |
||
3986 | foreach ($timezones as $tz => $dummy) { |
||
3987 | list($for_tzoffset, $for_tzid) = $this->get_timezone_desc($tz); |
||
3988 | |||
3989 | $ret .= "BEGIN:VTIMEZONE\r |
||
3990 | TZID:$for_tzid\r |
||
3991 | BEGIN:STANDARD\r |
||
3992 | DTSTART:19390101T000000\r |
||
3993 | TZOFFSETFROM:$for_tzoffset\r |
||
3994 | TZOFFSETTO:$for_tzoffset\r |
||
3995 | TZNAME:$for_tzid\r |
||
3996 | END:STANDARD\r |
||
3997 | END:VTIMEZONE\r\n"; |
||
3998 | } |
||
3999 | |||
4000 | return $ret; |
||
4001 | } |
||
4002 | } |
||
4003 | |||
4004 | // Ϣ����������˼�ꡢ$_POST����INSERT,UPDATE�Ѥ�SETʸ���������륯�饹�ؿ� |
||
4005 | |||
4006 | /** |
||
4007 | * @param $cols |
||
4008 | * @return string |
||
0 ignored issues
–
show
|
|||
4009 | */ |
||
4010 | public function get_sql_set($cols) |
||
4011 | { |
||
4012 | $ret = ''; |
||
4013 | |||
4014 | foreach ($cols as $col => $types) { |
||
4015 | list($field, $lang, $essential) = explode(':', $types); |
||
4016 | |||
4017 | // ̤����ʤ�''�ȸ��ʤ� |
||
4018 | if (!isset($_POST[$col])) { |
||
4019 | $data = ''; |
||
4020 | } elseif (get_magic_quotes_gpc()) { |
||
4021 | $data = stripslashes($_POST[$col]); |
||
4022 | } else { |
||
4023 | $data = $_POST[$col]; |
||
4024 | } |
||
4025 | |||
4026 | // ɬ�ܥե�����ɤΥ����å� |
||
4027 | if ($essential && $data === '') { |
||
4028 | die(sprintf(_APCAL_ERR_LACKINDISPITEM, $col)); |
||
4029 | } |
||
4030 | |||
4031 | // ���졦����ʤɤ��̤ˤ����� |
||
4032 | 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. ![]() |
|||
4033 | case 'N': // ���� (����� , ����) |
||
4034 | $data = (int)str_replace(',', '', $data); |
||
4035 | break; |
||
4036 | case 'J': // ���ܸ�ƥ����� (Ⱦ�ѥ��ʢ����Ѥ���) |
||
4037 | $data = $this->mb_convert_kana($data, 'KV'); |
||
4038 | break; |
||
4039 | case 'E': // Ⱦ�ѱѿ���Τ� |
||
4040 | $data = $this->mb_convert_kana($data, 'as'); |
||
4041 | break; |
||
4042 | } |
||
4043 | |||
4044 | // �ե�����ɤη��ˤ����� |
||
4045 | switch ($field) { |
||
4046 | case 'A': // textarea |
||
4047 | $ret .= "$col='" . addslashes($data) . "',"; |
||
4048 | break; |
||
4049 | case 'I': // integer |
||
4050 | $data = (int)$data; |
||
4051 | $ret .= "$col='$data',"; |
||
4052 | break; |
||
4053 | case 'F': // float |
||
4054 | $data = (float)$data; |
||
4055 | $ret .= "$col='$data',"; |
||
4056 | break; |
||
4057 | default: // varchar(�ǥե����)�Ͽ��ͤˤ��ʸ������� |
||
4058 | if ($field < 1) { |
||
4059 | $field = 255; |
||
4060 | } |
||
4061 | $data = mb_strcut($data, 0, $field); |
||
4062 | $ret .= "$col='" . addslashes($data) . "',"; |
||
4063 | } |
||
4064 | } |
||
4065 | |||
4066 | // �Ǹ�� , ���� |
||
4067 | $ret = substr($ret, 0, -1); |
||
4068 | |||
4069 | return $ret; |
||
4070 | } |
||
4071 | |||
4072 | // unixtimestamp���顢���ߤθ����ɽ�����줿Ĺ��ɽ���� YMDN ������ |
||
4073 | |||
4074 | /** |
||
4075 | * @param $time |
||
4076 | * @return string |
||
4077 | */ |
||
4078 | public function get_long_ymdn($time) |
||
4079 | { |
||
4080 | return sprintf(_APCAL_FMT_YMDN, // format |
||
4081 | date('Y', $time), // Y |
||
4082 | $this->month_long_names[date('n', $time)], // M |
||
4083 | $this->date_long_names[date('j', $time)], // D |
||
4084 | $this->week_long_names[date('w', $time)] // N |
||
4085 | ); |
||
4086 | } |
||
4087 | |||
4088 | // unixtimestamp���顢���ߤθ����ɽ�����줿ɸ��Ĺɽ���� MD ������ |
||
4089 | |||
4090 | /** |
||
4091 | * @param $time |
||
4092 | * @return string |
||
4093 | */ |
||
4094 | public function get_middle_md($time) |
||
4095 | { |
||
4096 | return sprintf(_APCAL_FMT_MD, // format |
||
4097 | $this->month_middle_names[date('n', $time)], // M |
||
4098 | $this->date_short_names[date('j', $time)] // D |
||
4099 | ); |
||
4100 | } |
||
4101 | |||
4102 | // unixtimestamp���顢���ߤθ����ɽ�����줿 DHI ������ |
||
4103 | |||
4104 | /** |
||
4105 | * @param $time |
||
4106 | * @param bool $is_over24 |
||
4107 | * @return string |
||
4108 | */ |
||
4109 | View Code Duplication | public function get_middle_dhi($time, $is_over24 = false) |
|
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. ![]() |
|||
4110 | { |
||
4111 | $hour_offset = $is_over24 ? 24 : 0; |
||
4112 | |||
4113 | $hour4disp = $this->use24 ? $this->hour_names_24[date('G', $time) + $hour_offset] : $this->hour_names_12[date('G', $time) + $hour_offset]; |
||
0 ignored issues
–
show
The property
hour_names_24 does not exist. Did you maybe forget to declare it?
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code: class MyClass { }
$x = new MyClass();
$x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: class MyClass {
public $foo;
}
$x = new MyClass();
$x->foo = true;
![]() The property
hour_names_12 does not seem to exist. Did you mean hour_names_24 ?
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name. If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading. ![]() |
|||
4114 | |||
4115 | return sprintf(_APCAL_FMT_DHI, $this->date_short_names[date('j', $time)], // D |
||
4116 | $hour4disp, // H |
||
4117 | date(_APCAL_DTFMT_MINUTE, $time) // I |
||
4118 | ); |
||
4119 | } |
||
4120 | |||
4121 | // unixtimestamp���顢���ߤθ����ɽ�����줿 HI ������ |
||
4122 | |||
4123 | /** |
||
4124 | * @param $time |
||
4125 | * @param bool $is_over24 |
||
4126 | * @return string |
||
4127 | */ |
||
4128 | View Code Duplication | public function get_middle_hi($time, $is_over24 = false) |
|
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. ![]() |
|||
4129 | { |
||
4130 | $hour_offset = $is_over24 ? 24 : 0; |
||
4131 | |||
4132 | $hour4disp = $this->use24 ? $this->hour_names_24[date('G', $time) + $hour_offset] : $this->hour_names_12[date('G', $time) + $hour_offset]; |
||
0 ignored issues
–
show
The property
hour_names_12 does not seem to exist. Did you mean hour_names_24 ?
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name. If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading. ![]() |
|||
4133 | |||
4134 | return sprintf(_APCAL_FMT_HI, $hour4disp, // H |
||
4135 | date(_APCAL_DTFMT_MINUTE, $time) // I |
||
4136 | ); |
||
4137 | } |
||
4138 | |||
4139 | // Make <option>s for selecting "HOUR" (default_hour must be 0-23) |
||
4140 | |||
4141 | /** |
||
4142 | * @param int $default_hour |
||
4143 | * @return string |
||
4144 | */ |
||
4145 | public function get_options_for_hour($default_hour = 0) |
||
4146 | { |
||
4147 | $ret = ''; |
||
4148 | for ($h = 0; $h < 24; ++$h) { |
||
4149 | $ret .= $h == $default_hour ? "<option value='$h' selected>" : "<option value='$h'>"; |
||
4150 | $ret .= $this->use24 ? $this->hour_names_24[$h] : $this->hour_names_12[$h]; |
||
0 ignored issues
–
show
The property
hour_names_12 does not seem to exist. Did you mean hour_names_24 ?
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name. If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading. ![]() |
|||
4151 | $ret .= "</option>\n"; |
||
4152 | } |
||
4153 | |||
4154 | return $ret; |
||
4155 | } |
||
4156 | |||
4157 | // Make <option>s for selecting "MIN" (default_min must be 0-60 by 5) |
||
4158 | |||
4159 | /** |
||
4160 | * @param int $default_min |
||
4161 | * @return string |
||
4162 | */ |
||
4163 | public function get_options_for_min($default_min = 0) |
||
4164 | { |
||
4165 | $ret = ''; |
||
4166 | for ($m = 0; $m < 60; $m += 5) { |
||
4167 | $ret .= $m == $default_min ? "<option value='$m' selected>" : "<option value='$m'>"; |
||
4168 | $ret .= sprintf('%02d', $m) . '</option>'; |
||
4169 | } |
||
4170 | |||
4171 | return $ret; |
||
4172 | } |
||
4173 | |||
4174 | // unixtimestamp���顢�������(timestamp����)�ʹߤ�ͽ�������ʸ��������� |
||
4175 | |||
4176 | /** |
||
4177 | * @param $start |
||
4178 | * @param $now |
||
4179 | * @param bool $admission |
||
4180 | * @return string |
||
4181 | */ |
||
4182 | public function get_coming_time_description($start, $now, $admission = true) |
||
4183 | { |
||
4184 | // ��ǧ��Í̵�ˤ�äƥɥå�GIF���ؤ��� |
||
4185 | if ($admission) { |
||
4186 | $dot = ''; |
||
4187 | } else { |
||
4188 | $dot = "<img border='0' src='$this->images_url/dot_notadmit.gif' />"; |
||
4189 | } |
||
4190 | |||
4191 | if ($start >= $now && $start - $now < 86400) { |
||
4192 | // 24���ְ���Υ��٥�� |
||
4193 | if (!$dot) { |
||
4194 | $dot = "<img border='0' src='$this->images_url/dot_today.gif' />"; |
||
4195 | } |
||
4196 | $ret = "$dot <b>" . $this->get_middle_hi($start) . '</b>' . _APCAL_MB_TIMESEPARATOR; |
||
4197 | } elseif ($start < $now) { |
||
4198 | // ���Ǥ˳��Ϥ��줿���٥�� |
||
4199 | if (!$dot) { |
||
4200 | $dot = "<img border='0' src='$this->images_url/dot_started.gif' />"; |
||
4201 | } |
||
4202 | $ret = "$dot " . _APCAL_MB_CONTINUING; |
||
4203 | } else { |
||
4204 | // ����ʹߤ˳��Ϥˤʤ륤�٥�� |
||
4205 | if (!$dot) { |
||
4206 | $dot = "<img border='0' src='$this->images_url/dot_future.gif' />"; |
||
4207 | } |
||
4208 | // $ret = "$dot " . date( "n/j H:i" , $start ) . _APCAL_MB_TIMESEPARATOR ; |
||
4209 | $ret = "$dot " . $this->get_middle_md($start) . ' ' . $this->get_middle_hi($start) . _APCAL_MB_TIMESEPARATOR; |
||
4210 | } |
||
4211 | |||
4212 | return $ret; |
||
4213 | } |
||
4214 | |||
4215 | // ���Ĥ�unixtimestamp���顢������(Y-n-j����)��ͽ����֤�ʸ���������ʴ�˥��ߡ� |
||
4216 | |||
4217 | /** |
||
4218 | * @param $start |
||
4219 | * @param $end |
||
4220 | * @param $ynj |
||
4221 | * @param bool $justify |
||
4222 | * @param bool $admission |
||
4223 | * @param null $is_start_date |
||
4224 | * @param null $is_end_date |
||
4225 | * @param null $border_for_2400 |
||
4226 | * @return string |
||
4227 | */ |
||
4228 | public function get_todays_time_description( |
||
4229 | $start, |
||
4230 | $end, |
||
4231 | $ynj, |
||
4232 | $justify = true, |
||
4233 | $admission = true, |
||
4234 | $is_start_date = null, |
||
4235 | $is_end_date = null, |
||
4236 | $border_for_2400 = null |
||
4237 | ) { |
||
4238 | if (!isset($is_start_date)) { |
||
4239 | $is_start_date = (date('Y-n-j', $start) == $ynj); |
||
4240 | } |
||
4241 | if (!isset($is_end_date)) { |
||
4242 | $is_end_date = (date('Y-n-j', $end) == $ynj); |
||
4243 | } |
||
4244 | if (!isset($border_for_2400)) { |
||
4245 | $this->unixtime - (int)(($this->user_TZ - $this->server_TZ) * 3600) + 86400; |
||
4246 | } |
||
4247 | |||
4248 | // $day_start ���꤬������Ρ�24:00�ʹߤν��� |
||
4249 | if ($is_start_date && $start > $border_for_2400) { |
||
4250 | $start_desc = $this->get_middle_hi($start, true); |
||
4251 | } else { |
||
4252 | $start_desc = $this->get_middle_hi($start); |
||
4253 | } |
||
4254 | |||
4255 | View Code Duplication | if ($is_end_date && $end > $border_for_2400) { |
|
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. ![]() |
|||
4256 | $end_desc = $this->get_middle_hi($end, true); |
||
4257 | } else { |
||
4258 | $end_desc = $this->get_middle_hi($end); |
||
4259 | } |
||
4260 | |||
4261 | $stuffing = $justify ? ' ' : ''; |
||
4262 | |||
4263 | // ͽ����ֻ����Í̵����ǧ��Í̵�ˤ�äƥɥå�GIF���ؤ��� |
||
4264 | View Code Duplication | if ($admission) { |
|
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. ![]() |
|||
4265 | if ($is_start_date) { |
||
4266 | $dot = "<img border='0' src='$this->images_url/dot_startday.gif' />"; |
||
4267 | } elseif ($is_end_date) { |
||
4268 | $dot = "<img border='0' src='$this->images_url/dot_endday.gif' />"; |
||
4269 | } else { |
||
4270 | $dot = "<img border='0' src='$this->images_url/dot_interimday.gif' />"; |
||
4271 | } |
||
4272 | } else { |
||
4273 | $dot = "<img border='0' src='$this->images_url/dot_notadmit.gif' />"; |
||
4274 | } |
||
4275 | |||
4276 | View Code Duplication | if ($is_start_date) { |
|
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. ![]() |
|||
4277 | if ($is_end_date) { |
||
4278 | $ret = "$dot {$start_desc}" . _APCAL_MB_TIMESEPARATOR . "{$end_desc}"; |
||
4279 | } else { |
||
4280 | $ret = "$dot {$start_desc}" . _APCAL_MB_TIMESEPARATOR . "{$stuffing}"; |
||
4281 | } |
||
4282 | } else { |
||
4283 | if ($is_end_date) { |
||
4284 | $ret = "$dot {$stuffing}" . _APCAL_MB_TIMESEPARATOR . "{$end_desc}"; |
||
4285 | } else { |
||
4286 | $ret = "$dot " . _APCAL_MB_CONTINUING; |
||
4287 | } |
||
4288 | } |
||
4289 | |||
4290 | return $ret; |
||
4291 | } |
||
4292 | |||
4293 | // $event�������̤��顢�������ͽ����֤�ʸ�����������̾磻�٥�ȤΤߡ� |
||
4294 | |||
4295 | /** |
||
4296 | * @param $event |
||
4297 | * @param $tzoffset |
||
4298 | * @param $border_for_2400 |
||
4299 | * @param bool $justify |
||
4300 | * @param bool $admission |
||
4301 | * @return string |
||
4302 | */ |
||
4303 | public function get_time_desc_for_a_day( |
||
4304 | $event, |
||
4305 | $tzoffset, |
||
4306 | $border_for_2400, |
||
4307 | $justify = true, |
||
4308 | $admission = true |
||
4309 | ) { |
||
4310 | $start = $event->start + $tzoffset; |
||
4311 | $end = $event->end + $tzoffset; |
||
4312 | |||
4313 | // $day_start ���꤬������Ρ�24:00�ʹߤν��� |
||
4314 | View Code Duplication | if ($event->is_start_date && $event->start >= $border_for_2400) { |
|
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. ![]() |
|||
4315 | $start_desc = $this->get_middle_hi($start, true); |
||
4316 | } else { |
||
4317 | $start_desc = $this->get_middle_hi($start); |
||
4318 | } |
||
4319 | |||
4320 | View Code Duplication | if ($event->is_end_date && $event->end >= $border_for_2400) { |
|
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. ![]() |
|||
4321 | $end_desc = $this->get_middle_hi($end, true); |
||
4322 | } else { |
||
4323 | $end_desc = $this->get_middle_hi($end); |
||
4324 | } |
||
4325 | |||
4326 | $stuffing = $justify ? ' ' : ''; |
||
4327 | |||
4328 | // ͽ����ֻ����Í̵����ǧ��Í̵�ˤ�äƥɥå�GIF���ؤ��� |
||
4329 | View Code Duplication | if ($admission) { |
|
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. ![]() |
|||
4330 | if ($event->is_start_date) { |
||
4331 | $dot = "<img border='0' src='$this->images_url/dot_startday.gif' />"; |
||
4332 | } elseif ($event->is_end_date) { |
||
4333 | $dot = "<img border='0' src='$this->images_url/dot_endday.gif' />"; |
||
4334 | } else { |
||
4335 | $dot = "<img border='0' src='$this->images_url/dot_interimday.gif' />"; |
||
4336 | } |
||
4337 | } else { |
||
4338 | $dot = "<img border='0' src='$this->images_url/dot_notadmit.gif' />"; |
||
4339 | } |
||
4340 | |||
4341 | View Code Duplication | if ($event->is_start_date) { |
|
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. ![]() |
|||
4342 | if ($event->is_end_date) { |
||
4343 | $ret = "$dot {$start_desc}" . _APCAL_MB_TIMESEPARATOR . "{$end_desc}"; |
||
4344 | } else { |
||
4345 | $ret = "$dot {$start_desc}" . _APCAL_MB_TIMESEPARATOR . "{$stuffing}"; |
||
4346 | } |
||
4347 | } else { |
||
4348 | if ($event->is_end_date) { |
||
4349 | $ret = "$dot {$stuffing}" . _APCAL_MB_TIMESEPARATOR . "{$end_desc}"; |
||
4350 | } else { |
||
4351 | $ret = "$dot " . _APCAL_MB_CONTINUING; |
||
4352 | } |
||
4353 | } |
||
4354 | |||
4355 | return $ret; |
||
4356 | } |
||
4357 | |||
4358 | // �������ϥܥå����δؿ� (JavaScript�����Ϥ���ݤ�Override�о�) |
||
4359 | |||
4360 | /** |
||
4361 | * @param $name |
||
4362 | * @param $value |
||
4363 | * @return string |
||
4364 | */ |
||
4365 | public function get_formtextdateselect($name, $value) |
||
4366 | { |
||
4367 | return "<input type='text' name='$name' size='12' value='$value' style='ime-mode:disabled' />"; |
||
4368 | } |
||
4369 | |||
4370 | // $this->images_url���ˤ���style.css���ɤ߹��ߡ����˥��������ư��Ϥ� |
||
4371 | |||
4372 | /** |
||
4373 | * @return string |
||
4374 | */ |
||
4375 | public function get_embed_css() |
||
4376 | { |
||
4377 | $css_filename = "$this->images_path/style.css"; |
||
4378 | if (!is_readable($css_filename)) { |
||
4379 | return ''; |
||
4380 | } else { |
||
4381 | return strip_tags(implode('', file($css_filename))); |
||
4382 | } |
||
4383 | } |
||
4384 | |||
4385 | // ��ƼԤ�ɽ��ʸ������֤� (Override�о�) |
||
4386 | |||
4387 | /** |
||
4388 | * @param $uid |
||
4389 | * @return string |
||
4390 | */ |
||
4391 | public function get_submitter_info($uid) |
||
4392 | { |
||
4393 | return ''; |
||
4394 | } |
||
4395 | |||
4396 | // ���ƥ���ط���WHERE�Ѿ������� |
||
4397 | |||
4398 | /** |
||
4399 | * @return string |
||
4400 | */ |
||
4401 | public function get_where_about_categories() |
||
4402 | { |
||
4403 | if ($this->isadmin) { |
||
4404 | if (empty($this->now_cid)) { |
||
4405 | // �����Ԥ�����Ԥ�$cid���꤬�ʤ���о��True |
||
4406 | return '1'; |
||
4407 | } else { |
||
4408 | // �����Ԥ�����Ԥ�$cid���꤬����С���������LIKE���� |
||
4409 | return "categories LIKE '%" . sprintf('%05d,', $this->now_cid) . "%'"; |
||
4410 | } |
||
4411 | } else { |
||
4412 | if (empty($this->now_cid)) { |
||
4413 | // �����Ԥ�����԰ʳ���$cid���꤬�ʤ���С�CAT2GROUP�ˤ������ |
||
4414 | $limit_from_perm = "categories='' OR "; |
||
4415 | foreach ($this->categories as $cid => $cat) { |
||
4416 | $limit_from_perm .= "categories LIKE '%" . sprintf('%05d,', $cid) . "%' OR "; |
||
4417 | } |
||
4418 | $limit_from_perm = substr($limit_from_perm, 0, -3); |
||
4419 | |||
4420 | return $limit_from_perm; |
||
4421 | } else { |
||
4422 | // �����Ԥ�����԰ʳ���$cid���꤬����С����¥����å�����$cid���� |
||
4423 | if (isset($this->categories[$this->now_cid])) { |
||
4424 | return "categories LIKE '%" . sprintf('%05d,', $this->now_cid) . "%'"; |
||
4425 | } else { |
||
4426 | // ���ꤵ�줿cid�����¤ˤʤ� |
||
4427 | return '0'; |
||
4428 | } |
||
4429 | } |
||
4430 | } |
||
4431 | } |
||
4432 | |||
4433 | // CLASS(�����)�ط���WHERE�Ѿ������� |
||
4434 | |||
4435 | /** |
||
4436 | * @return string |
||
4437 | */ |
||
4438 | public function get_where_about_class() |
||
4439 | { |
||
4440 | if ($this->isadmin) { |
||
4441 | // �����Ԥ�����Ԥʤ���True |
||
4442 | return '1'; |
||
4443 | } elseif ($this->user_id <= 0) { |
||
4444 | // �����Ԥ������Ȥʤ��(PUBLIC)�쥳���ɤΤ� |
||
4445 | return "class='PUBLIC'"; |
||
4446 | } else { |
||
4447 | // �̾�桼���ʤ顢PUBLIC�쥳���ɤ����桼��ID�����פ���쥳���ɡ��ޤ��ϡ���°���Ƥ��륰�롼��ID�Τ����ΰ�Ĥ��쥳���ɤΥ��롼��ID�Ȱ��פ���쥳���� |
||
4448 | $ids = ' '; |
||
4449 | foreach ($this->groups as $id => $name) { |
||
4450 | $ids .= "$id,"; |
||
4451 | } |
||
4452 | $ids = substr($ids, 0, -1); |
||
4453 | if ((int)$ids == 0) { |
||
4454 | $group_section = ''; |
||
4455 | } else { |
||
4456 | $group_section = "OR groupid IN ($ids)"; |
||
4457 | } |
||
4458 | |||
4459 | return "(class='PUBLIC' OR uid=$this->user_id $group_section)"; |
||
4460 | } |
||
4461 | } |
||
4462 | |||
4463 | // mb_convert_kana��� |
||
4464 | |||
4465 | /** |
||
4466 | * @param $str |
||
4467 | * @param $option |
||
4468 | * @return string |
||
4469 | */ |
||
4470 | 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. ![]() |
|||
4471 | { |
||
4472 | // convert_kana �ν���ϡ����ܸ�ǤΤ߹Ԥ� |
||
4473 | if ($this->language !== 'japanese' || !function_exists('mb_convert_kana')) { |
||
4474 | return $str; |
||
4475 | } else { |
||
4476 | return mb_convert_kana($str, $option); |
||
4477 | } |
||
4478 | } |
||
4479 | |||
4480 | /*******************************************************************/ |
||
4481 | /* ���˥�������Ϣ�δؿ� (���֥��饹������������Override�о�) */ |
||
4482 | /*******************************************************************/ |
||
4483 | |||
4484 | /** |
||
4485 | * @param $data |
||
4486 | * @return string |
||
4487 | */ |
||
4488 | public function textarea_sanitizer_for_show($data) |
||
4489 | { |
||
4490 | return nl2br(htmlspecialchars($data, ENT_QUOTES)); |
||
4491 | } |
||
4492 | |||
4493 | /** |
||
4494 | * @param $data |
||
4495 | * @return string |
||
4496 | */ |
||
4497 | public function text_sanitizer_for_show($data) |
||
4498 | { |
||
4499 | return htmlspecialchars($data, ENT_QUOTES); |
||
4500 | } |
||
4501 | |||
4502 | /** |
||
4503 | * @param $data |
||
4504 | * @return string |
||
4505 | */ |
||
4506 | public function textarea_sanitizer_for_edit($data) |
||
4507 | { |
||
4508 | return htmlspecialchars($data, ENT_QUOTES); |
||
4509 | } |
||
4510 | |||
4511 | /** |
||
4512 | * @param $data |
||
4513 | * @return string |
||
4514 | */ |
||
4515 | public function text_sanitizer_for_edit($data) |
||
4516 | { |
||
4517 | return htmlspecialchars($data, ENT_QUOTES); |
||
4518 | } |
||
4519 | |||
4520 | /** |
||
4521 | * @param $data |
||
4522 | * @return mixed |
||
4523 | */ |
||
4524 | public function textarea_sanitizer_for_export_ics($data) |
||
4525 | { |
||
4526 | return $data; |
||
4527 | } |
||
4528 | |||
4529 | /*******************************************************************/ |
||
4530 | /* iCalendar ����ؿ� */ |
||
4531 | /*******************************************************************/ |
||
4532 | |||
4533 | // iCalendar�����ǤΥХå����ϥץ�åȥե����������ѥե�������֤� |
||
4534 | // $_POST['ids']�ǻ��� |
||
4535 | /** |
||
4536 | * @param $post_target |
||
4537 | * @param string $target |
||
4538 | * @return string |
||
4539 | */ |
||
4540 | public function output_ics_confirm($post_target, $target = '_self') |
||
4541 | { |
||
4542 | // POST�Ǽ�����ä�id�����event_ids����Ȥ���POST���� |
||
4543 | $hiddens = ''; |
||
4544 | foreach ($_POST['ids'] as $id) { |
||
4545 | $id = (int)$id; |
||
4546 | $hiddens .= "<input type='hidden' name='event_ids[]' value='$id' />\n"; |
||
4547 | } |
||
4548 | // webcal������� |
||
4549 | $webcal_url = str_replace('http://', 'webcal://', $post_target); |
||
4550 | |||
4551 | // ��ǧ�ե�������֤� |
||
4552 | return " |
||
4553 | <div style='text-align:center;width:100%;'> <br><b>" . _APCAL_MB_ICALSELECTPLATFORM . "</b><br> </div> |
||
4554 | <table border='0' cellpadding='5' cellspacing='2' width='100%'> |
||
4555 | <tr> |
||
4556 | <td align='right' width='50%'> |
||
4557 | <form class='apcalForm' action='$post_target?output_ics=1' method='post' target='$target'> |
||
4558 | $hiddens |
||
4559 | <input type='submit' name='do_output' value='" . _APCAL_BTN_OUTPUTICS_WIN . "' /> |
||
4560 | </form> |
||
4561 | </td> |
||
4562 | <td align='left' width='50%'> |
||
4563 | <form class='apcalForm' action='$webcal_url?output_ics=1' method='post' target='$target'> |
||
4564 | $hiddens |
||
4565 | <input type='submit' name='do_output' value='" . _APCAL_BTN_OUTPUTICS_MAC . "' /> |
||
4566 | </form> |
||
4567 | </td> |
||
4568 | </tr> |
||
4569 | </table><br><br>\n"; |
||
4570 | } |
||
4571 | |||
4572 | // iCalendar�����Ǥν��� (mbstringɬ��) |
||
4573 | // ���Ϥ����Τߤξ���$_GET['event_id']������ξ���$_POST['event_ids'] |
||
4574 | public function output_ics() |
||
4575 | { |
||
4576 | // $event_id �����ꤵ��Ƥ��ʤ���н�λ |
||
4577 | if (empty($_GET['event_id']) && empty($_POST['event_ids'])) { |
||
4578 | die(_APCAL_ERR_INVALID_EVENT_ID); |
||
4579 | } |
||
4580 | |||
4581 | // iCalendar���ϵ��Ĥ��ʤ���н�λ |
||
4582 | if (!$this->can_output_ics) { |
||
4583 | die(_APCAL_ERR_NOPERM_TO_OUTPUTICS); |
||
4584 | } |
||
4585 | if (isset($_GET['event_id'])) { |
||
4586 | // $_GET[ 'event_id' ] �ˤ��������λ���ξ�� |
||
4587 | $event_id = (int)$_GET['event_id']; |
||
4588 | $event_ids = array($event_id); |
||
4589 | // $rs = $xoopsDB->query("SELECT summary AS udtstmp FROM $this->table WHERE id='$event_id'"); |
||
4590 | $rs = $GLOBALS['xoopsDB']->query("SELECT summary AS udtstmp FROM $this->table WHERE id='$event_id'"); |
||
4591 | |||
4592 | if ($GLOBALS['xoopsDB']->getRowsNum($rs) < 1) { |
||
4593 | die(_APCAL_ERR_INVALID_EVENT_ID); |
||
4594 | } |
||
4595 | // $summary = mysql_result($rs, 0, 0); |
||
4596 | $summary = 0; |
||
4597 | $resultRow = $GLOBALS['xoopsDB']->fetchRow($rs); |
||
4598 | if (false !== $resultRow && isset($resultRow[$field])) { |
||
0 ignored issues
–
show
The variable
$field seems to never exist, and therefore isset should always return false . Did you maybe rename this variable?
This check looks for calls to This is most likely caused by the renaming of a variable or the removal of a function/method parameter. ![]() |
|||
4599 | $summary = $resultRow[0]; |
||
4600 | } |
||
4601 | // $rs = $xoopsDB->query("SELECT * FROM $cal->table WHERE WHERE id='$event_id'"); |
||
4602 | |||
4603 | // ��̾ �� X-WR-CALNAME �Ȥ��� |
||
4604 | $x_wr_calname = $summary; |
||
4605 | // �ե�����̾�˻Ȥ��ʤ�������ʸ��Ϻ�� |
||
4606 | if (function_exists('mb_ereg_replace')) { |
||
4607 | $summary = mb_ereg_replace('[<>|"?*,:;\\/]', '', $summary); |
||
4608 | } else { |
||
4609 | $summary = preg_replace('/[<>|"?*,:;\\/]/', '', $summary); |
||
4610 | } |
||
4611 | // �ػ�ʸ����ä���̾.ics ��ե�����̾�Ȥ��� (��SJIS�Ѵ�) |
||
4612 | $output_filename = mb_convert_encoding($summary, 'ASCII') . '.ics'; |
||
4613 | $output_filename = str_replace(' ', '', $output_filename); |
||
4614 | } elseif (is_array($_POST['event_ids'])) { |
||
4615 | // $_POST[ 'event_ids' ] �ˤ������ˤ�����ξ�� |
||
4616 | $event_ids = array_unique($_POST['event_ids']); |
||
4617 | // events-�������(GMT) �� X-WR-CALNAME �Ȥ��� |
||
4618 | $x_wr_calname = 'events-' . gmdate('Ymd\THis\Z'); |
||
4619 | // events-�������.ics ��ե�����̾�Ȥ��� |
||
4620 | $output_filename = $x_wr_calname . '.ics'; |
||
4621 | } else { |
||
4622 | die(_APCAL_ERR_INVALID_EVENT_ID); |
||
4623 | } |
||
4624 | |||
4625 | // HTTP header |
||
4626 | header('Pragma: public'); |
||
4627 | header('Expires: 0'); |
||
4628 | header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); |
||
4629 | header('Cache-Control: private', false); |
||
4630 | header('Content-Type: text/calendar'); |
||
4631 | header("Content-Disposition: attachment; filename=\"{$output_filename}\";"); |
||
4632 | |||
4633 | // iCalendar�إå� |
||
4634 | $ical_header = "BEGIN:VCALENDAR\r |
||
4635 | CALSCALE:GREGORIAN\r |
||
4636 | X-WR-TIMEZONE;VALUE=TEXT:GMT\r |
||
4637 | PRODID:ANTIQUES PROMOTION - APCal -\r"; |
||
4638 | $ical_header .= $this->ics_new_cal ? "X-WR-CALNAME;VALUE=TEXT:$x_wr_calname\r" : ''; |
||
4639 | $ical_header .= "VERSION:2.0\r |
||
4640 | METHOD:PUBLISH\r\n"; |
||
4641 | |||
4642 | // ���ƥ��꡼��Ϣ��WHERE������ |
||
4643 | $whr_categories = $this->get_where_about_categories(); |
||
4644 | |||
4645 | // CLASS��Ϣ��WHERE������ |
||
4646 | $whr_class = $this->get_where_about_class(); |
||
4647 | |||
4648 | // ���٥����Υ롼�� |
||
4649 | $vevents_str = ''; |
||
4650 | $timezones = array(); |
||
4651 | foreach ($event_ids as $event_id) { |
||
4652 | $event_id = (int)$event_id; |
||
4653 | $sql = "SELECT *,UNIX_TIMESTAMP(dtstamp) AS udtstmp,DATE_ADD(end_date,INTERVAL 1 DAY) AS end_date_offseted FROM $this->table WHERE id='$event_id' AND ($whr_categories) AND ($whr_class)"; |
||
4654 | if (!$rs = $GLOBALS['xoopsDB']->query($sql)) { |
||
4655 | echo $GLOBALS['xoopsDB']->error(); |
||
4656 | } |
||
4657 | $event = $GLOBALS['xoopsDB']->fetchObject($rs); |
||
4658 | if (!$event) { |
||
4659 | continue; |
||
4660 | } |
||
4661 | |||
4662 | if (isset($event->start_date)) { |
||
4663 | // 1970������2038ǯ�ʹߤ����դ��������ü������٥�� |
||
4664 | $dtstart = str_replace('-', '', $event->start_date); |
||
4665 | View Code Duplication | if (isset($event->end_date_offseted)) { |
|
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. ![]() |
|||
4666 | $dtend = str_replace('-', '', $event->end_date_offseted); |
||
4667 | } else { |
||
4668 | $dtend = date('Ymd', $event->end); |
||
4669 | } |
||
4670 | $dtstart_opt = $dtend_opt = ';VALUE=DATE'; |
||
4671 | } elseif ($event->allday) { |
||
4672 | // ����٥�ȡʻ�������ʤ��� |
||
4673 | $dtstart = date('Ymd', $event->start); |
||
4674 | View Code Duplication | if (isset($event->end_date_offseted)) { |
|
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. ![]() |
|||
4675 | $dtend = str_replace('-', '', $event->end_date_offseted); |
||
4676 | } else { |
||
4677 | $dtend = date('Ymd', $event->end); |
||
4678 | } |
||
4679 | // ���ϤȽ�λ��Ʊ��ξ��ϡ���λ������ˤ��餹 |
||
4680 | if ($dtstart == $dtend) { |
||
4681 | $dtend = date('Ymd', $event->end + 86400); |
||
4682 | } |
||
4683 | $dtstart_opt = $dtend_opt = ';VALUE=DATE'; |
||
4684 | } else { |
||
4685 | if ($event->rrule) { |
||
4686 | // �̾磻�٥�Ȥ�RRULE������С����٥��TZ�ǽ��� |
||
4687 | $tzoffset = (int)(($this->server_TZ - $event->event_tz) * 3600); |
||
4688 | list(, $tzid) = $this->get_timezone_desc($event->event_tz); |
||
4689 | $dtstart = date('Ymd\THis', $event->start - $tzoffset); |
||
4690 | $dtend = date('Ymd\THis', $event->end - $tzoffset); |
||
4691 | $dtstart_opt = $dtend_opt = ";TZID=$tzid"; |
||
4692 | // ����ˡ�����VTIMEZONE����� |
||
4693 | $timezones[$event->event_tz] = 1; |
||
4694 | } else { |
||
4695 | // �̾磻�٥�Ȥ�RRULE��̵����С������Фλ��������������GMTɽ�� |
||
4696 | $tzoffset = $this->server_TZ * 3600; |
||
4697 | $dtstart = date('Ymd\THis\Z', $event->start - $tzoffset); |
||
4698 | $dtend = date('Ymd\THis\Z', $event->end - $tzoffset); |
||
4699 | $dtstart_opt = $dtend_opt = ''; |
||
4700 | } |
||
4701 | } |
||
4702 | |||
4703 | // DTSTAMP�Ͼ��GMT |
||
4704 | $dtstamp = date('Ymd\THis\Z', $event->udtstmp - $this->server_TZ * 3600); |
||
4705 | |||
4706 | // DESCRIPTION�� folding , \r��� ����� \n -> \\n �Ѵ�, ���˥����� |
||
4707 | // (folding ̤����) TODO |
||
4708 | $description = str_replace("\r", '', $event->description); |
||
4709 | $description = str_replace("\n", '\n', $description); |
||
4710 | $description = $this->textarea_sanitizer_for_export_ics($description); |
||
4711 | |||
4712 | // ���ƥ��꡼��ɽ�� |
||
4713 | $categories = ''; |
||
4714 | $cids = explode(',', $event->categories); |
||
4715 | foreach ($cids as $cid) { |
||
4716 | $cid = (int)$cid; |
||
4717 | if (isset($this->categories[$cid])) { |
||
4718 | $categories .= $this->categories[$cid]->cat_title . ','; |
||
4719 | } |
||
4720 | } |
||
4721 | if ($categories !== '') { |
||
4722 | $categories = substr($categories, 0, -1); |
||
4723 | } |
||
4724 | |||
4725 | // RRULE�Ԥϡ�RRULE����Ȥ�������������� |
||
4726 | $rrule_line = $event->rrule ? "RRULE:{$event->rrule}\r\n" : ''; |
||
4727 | |||
4728 | // ���٥�ȥǡ����ν��� |
||
4729 | $vevents_str .= "BEGIN:VEVENT\r |
||
4730 | DTSTART{$dtstart_opt}:{$dtstart}\r |
||
4731 | DTEND{$dtend_opt}:{$dtend}\r |
||
4732 | LOCATION:{$event->location}\r |
||
4733 | TRANSP:OPAQUE\r |
||
4734 | SEQUENCE:{$event->sequence}\r |
||
4735 | UID:{$event->unique_id}\r |
||
4736 | DTSTAMP:{$dtstamp}\r |
||
4737 | CATEGORIES:{$categories}\r |
||
4738 | DESCRIPTION:{$description}\r |
||
4739 | SUMMARY:{$event->summary}\r |
||
4740 | {$rrule_line}PRIORITY:{$event->priority}\r |
||
4741 | CLASS:{$event->class}\r |
||
4742 | END:VEVENT\r\n"; |
||
4743 | } |
||
4744 | |||
4745 | // VTIMEZONE |
||
4746 | $vtimezones_str = $this->get_vtimezones_str($timezones); |
||
4747 | |||
4748 | // iCalendar�եå� |
||
4749 | $ical_footer = "END:VCALENDAR\r\n"; |
||
4750 | |||
4751 | $ical_data = "$ical_header$vtimezones_str$vevents_str$ical_footer"; |
||
4752 | |||
4753 | // mbstring ��������Τߡ�UTF-8 �ؤ��Ѵ� |
||
4754 | if (extension_loaded('mbstring')) { |
||
4755 | mb_http_output('pass'); |
||
4756 | $ical_data = mb_convert_encoding($ical_data, 'UTF-8'); |
||
4757 | } |
||
4758 | |||
4759 | echo $ical_data; |
||
4760 | |||
4761 | exit; |
||
4762 | } |
||
4763 | |||
4764 | /** |
||
4765 | * @param $uri |
||
4766 | * @param bool $force_http |
||
4767 | * @param string $user_uri |
||
4768 | * @return string |
||
4769 | */ |
||
4770 | public function import_ics_via_fopen($uri, $force_http = true, $user_uri = '') |
||
4771 | { |
||
4772 | if (strlen($uri) < 5) { |
||
4773 | return '-1:'; |
||
4774 | } |
||
4775 | $user_uri = empty($user_uri) ? '' : $uri; |
||
4776 | // webcal://* �� connection̤����⡢���٤� http://* ����� |
||
4777 | $uri = str_replace('webcal://', 'http://', $uri); |
||
4778 | |||
4779 | if ($force_http) { |
||
4780 | // if (substr($uri, 0, 7) !== 'http://') { |
||
4781 | if (0 !== strpos($uri, 'http://')) { |
||
4782 | $uri = 'http://' . $uri; |
||
4783 | } |
||
4784 | } |
||
4785 | |||
4786 | // iCal parser �ˤ����� |
||
4787 | require_once "$this->base_path/class/iCal_parser.php"; |
||
4788 | $ical = new iCal_parser(); |
||
4789 | $ical->language = $this->language; |
||
4790 | $ical->timezone = ($this->server_TZ >= 0 ? '+' : '-') . sprintf('%02d%02d', abs($this->server_TZ), abs($this->server_TZ) * 60 % 60); |
||
4791 | list($ret_code, $message, $filename) = explode(':', $ical->parse($uri, $user_uri), 3); |
||
4792 | if ($ret_code != 0) { |
||
4793 | // �ѡ������Ԥʤ�-1�ȥ��顼��å��������֤� |
||
4794 | return "-1: $message : $filename"; |
||
4795 | } |
||
4796 | $setsqls = $ical->output_setsqls(); |
||
4797 | |||
4798 | $count = 0; |
||
4799 | View Code Duplication | foreach ($setsqls as $setsql) { |
|
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. ![]() |
|||
4800 | $sql = "INSERT INTO $this->table SET $setsql,admission=1,uid=$this->user_id,poster_tz='$this->user_TZ',server_tz='$this->server_TZ'"; |
||
4801 | |||
4802 | if (!$GLOBALS['xoopsDB']->query($sql)) { |
||
4803 | die($GLOBALS['xoopsDB']->error()); |
||
4804 | } |
||
4805 | $this->update_record_after_import($GLOBALS['xoopsDB']->getInsertId($this->conn)); |
||
4806 | |||
4807 | ++$count; |
||
4808 | } |
||
4809 | |||
4810 | return "$count: $message:"; |
||
4811 | } |
||
4812 | |||
4813 | /** |
||
4814 | * @param $userfile |
||
4815 | * @return string |
||
4816 | */ |
||
4817 | public function import_ics_via_upload($userfile) |
||
4818 | { |
||
4819 | // ics�ե�����򥯥饤����ȥޥ��󤫤饢�åץ?�ɤ����ɹ��� |
||
4820 | require_once "$this->base_path/class/iCal_parser.php"; |
||
4821 | $ical = new iCal_parser(); |
||
4822 | $ical->language = $this->language; |
||
4823 | $ical->timezone = ($this->server_TZ >= 0 ? '+' : '-') . sprintf('%02d%02d', abs($this->server_TZ), abs($this->server_TZ) * 60 % 60); |
||
4824 | list($ret_code, $message, $filename) = explode(':', $ical->parse($_FILES[$userfile]['tmp_name'], $_FILES[$userfile]['name']), 3); |
||
4825 | if ($ret_code != 0) { |
||
4826 | // �ѡ������Ԥʤ�-1�ȥ��顼��å��������֤� |
||
4827 | return "-1: $message : $filename"; |
||
4828 | } |
||
4829 | $setsqls = $ical->output_setsqls(); |
||
4830 | |||
4831 | $count = 0; |
||
4832 | View Code Duplication | foreach ($setsqls as $setsql) { |
|
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. ![]() |
|||
4833 | $sql = "INSERT INTO $this->table SET $setsql,admission=1,uid=$this->user_id,poster_tz='$this->user_TZ',server_tz='$this->server_TZ'"; |
||
4834 | |||
4835 | if (!$GLOBALS['xoopsDB']->query($sql)) { |
||
4836 | die($GLOBALS['xoopsDB']->error()); |
||
4837 | } |
||
4838 | $this->update_record_after_import($GLOBALS['xoopsDB']->getInsertId($this->conn)); |
||
4839 | |||
4840 | ++$count; |
||
4841 | } |
||
4842 | |||
4843 | return "$count: $message :"; |
||
4844 | } |
||
4845 | |||
4846 | // ���쥳���ɤ��ɤ߹��߸�˹Ԥ����� ��rrule��Ÿ����categories��cid���ʤɡ� |
||
4847 | |||
4848 | /** |
||
4849 | * @param $event_id |
||
4850 | */ |
||
4851 | public function update_record_after_import($event_id) |
||
4852 | { |
||
4853 | $rs = $GLOBALS['xoopsDB']->query("SELECT categories,rrule FROM $this->table WHERE id='$event_id'"); |
||
4854 | $event = $GLOBALS['xoopsDB']->fetchObject($rs); |
||
4855 | |||
4856 | // categories �� cid�� ( '\,' -> ',' ��Outlook�к�) |
||
4857 | $event->categories = str_replace('\,', ',', $event->categories); |
||
4858 | $cat_names = explode(',', $event->categories); |
||
4859 | for ($i = 0, $iMax = count($cat_names); $i < $iMax; ++$i) { |
||
4860 | $cat_names[$i] = trim($cat_names[$i]); |
||
4861 | } |
||
4862 | $categories = ''; |
||
4863 | foreach ($this->categories as $cid => $cat) { |
||
4864 | if (in_array($cat->cat_title, $cat_names)) { |
||
4865 | $categories .= sprintf('%05d,', $cid); |
||
4866 | } |
||
4867 | } |
||
4868 | |||
4869 | // rrule_pid ��� |
||
4870 | $rrule_pid = $event->rrule ? $event_id : 0; |
||
4871 | |||
4872 | // �쥳���ɹ��� |
||
4873 | $GLOBALS['xoopsDB']->query("UPDATE $this->table SET categories='$categories',rrule_pid='$rrule_pid' WHERE id='$event_id'"); |
||
4874 | |||
4875 | // RRULE���顢�ҥ쥳���ɤ�Ÿ�� |
||
4876 | if ($event->rrule !== '') { |
||
4877 | $this->rrule_extract($event_id); |
||
4878 | } |
||
4879 | |||
4880 | // GIJ TODO category �μ�ư��Ͽ class,groupid �ν��� |
||
4881 | } |
||
4882 | |||
4883 | /*******************************************************************/ |
||
4884 | /* RRULE ����ؿ� */ |
||
4885 | /*******************************************************************/ |
||
4886 | |||
4887 | // rrule����������������륯�饹�ؿ� |
||
4888 | /** |
||
4889 | * @param $rrule |
||
4890 | * @return string |
||
4891 | */ |
||
4892 | public function rrule_to_human_language($rrule) |
||
4893 | { |
||
4894 | $rrule = trim($rrule); |
||
4895 | if ($rrule === '') { |
||
4896 | return ''; |
||
4897 | } |
||
4898 | |||
4899 | // rrule �γ����Ǥ��ѿ���Ÿ�� |
||
4900 | $rrule = strtoupper($rrule); |
||
4901 | $rules = explode(';', $rrule); |
||
4902 | View Code Duplication | foreach ($rules as $rule) { |
|
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. ![]() |
|||
4903 | list($key, $val) = explode('=', $rule, 2); |
||
4904 | $key = trim($key); |
||
4905 | $$key = trim($val); |
||
4906 | } |
||
4907 | |||
4908 | if (empty($FREQ)) { |
||
0 ignored issues
–
show
The variable
$FREQ seems only to be defined at a later point. As such the call to empty() seems to always evaluate to true .
This check marks calls to This is likely the result of code being shifted around. Consider removing these calls. ![]() |
|||
4909 | $FREQ = 'DAILY'; |
||
4910 | } |
||
4911 | if (empty($INTERVAL) || $INTERVAL <= 0) { |
||
0 ignored issues
–
show
The variable
$INTERVAL seems only to be defined at a later point. As such the call to empty() seems to always evaluate to true .
This check marks calls to This is likely the result of code being shifted around. Consider removing these calls. ![]() |
|||
4912 | $INTERVAL = 1; |
||
4913 | } |
||
4914 | |||
4915 | // ���پ����� |
||
4916 | $ret_freq = ''; |
||
4917 | $ret_day = ''; |
||
4918 | switch ($FREQ) { |
||
4919 | case 'DAILY': |
||
4920 | if ($INTERVAL == 1) { |
||
4921 | $ret_freq = _APCAL_RR_EVERYDAY; |
||
4922 | } else { |
||
4923 | $ret_freq = sprintf(_APCAL_RR_PERDAY, $INTERVAL); |
||
4924 | } |
||
4925 | break; |
||
4926 | case 'WEEKLY': |
||
4927 | if (empty($BYDAY)) { |
||
0 ignored issues
–
show
The variable
$BYDAY seems to never exist, and therefore empty should always return true . Did you maybe rename this variable?
This check looks for calls to This is most likely caused by the renaming of a variable or the removal of a function/method parameter. ![]() |
|||
4928 | break; |
||
4929 | } // BYDAY ɬ�� |
||
4930 | $ret_day = strtr($BYDAY, $this->byday2langday_w); |
||
4931 | if ($INTERVAL == 1) { |
||
4932 | $ret_freq = _APCAL_RR_EVERYWEEK; |
||
4933 | } else { |
||
4934 | $ret_freq = sprintf(_APCAL_RR_PERWEEK, $INTERVAL); |
||
4935 | } |
||
4936 | break; |
||
4937 | case 'MONTHLY': |
||
4938 | if (isset($BYMONTHDAY)) { |
||
0 ignored issues
–
show
The variable
$BYMONTHDAY seems to never exist, and therefore isset should always return false . Did you maybe rename this variable?
This check looks for calls to This is most likely caused by the renaming of a variable or the removal of a function/method parameter. ![]() |
|||
4939 | $ret_day = ''; |
||
4940 | $monthdays = explode(',', $BYMONTHDAY); |
||
4941 | foreach ($monthdays as $monthday) { |
||
4942 | $ret_day .= $this->date_long_names[$monthday] . ','; |
||
4943 | } |
||
4944 | $ret_day = substr($ret_day, 0, -1); |
||
4945 | } elseif (isset($BYDAY)) { |
||
4946 | $ret_day = strtr($BYDAY, $this->byday2langday_m); |
||
4947 | } else { |
||
4948 | break; // BYDAY �ޤ��� BYMONTHDAY ɬ�� |
||
4949 | } |
||
4950 | if ($INTERVAL == 1) { |
||
4951 | $ret_freq = _APCAL_RR_EVERYMONTH; |
||
4952 | } else { |
||
4953 | $ret_freq = sprintf(_APCAL_RR_PERMONTH, $INTERVAL); |
||
4954 | } |
||
4955 | break; |
||
4956 | case 'YEARLY': |
||
4957 | $ret_day = ''; |
||
4958 | if (!empty($BYMONTH)) { |
||
0 ignored issues
–
show
The variable
$BYMONTH seems to never exist, and therefore empty should always return true . Did you maybe rename this variable?
This check looks for calls to This is most likely caused by the renaming of a variable or the removal of a function/method parameter. ![]() |
|||
4959 | $months = explode(',', $BYMONTH); |
||
4960 | foreach ($months as $month) { |
||
4961 | $ret_day .= $this->month_long_names[$month] . ','; |
||
4962 | } |
||
4963 | $ret_day = substr($ret_day, 0, -1); |
||
4964 | } |
||
4965 | if (isset($BYDAY)) { |
||
4966 | $ret_day .= ' ' . strtr($BYDAY, $this->byday2langday_m); |
||
4967 | } |
||
4968 | if ($INTERVAL == 1) { |
||
4969 | $ret_freq = _APCAL_RR_EVERYYEAR; |
||
4970 | } else { |
||
4971 | $ret_freq = sprintf(_APCAL_RR_PERYEAR, $INTERVAL); |
||
4972 | } |
||
4973 | break; |
||
4974 | } |
||
4975 | |||
4976 | // ������� |
||
4977 | $ret_terminator = ''; |
||
4978 | // UNTIL �� COUNT ��ξ������ COUNT ͥ�� |
||
4979 | if (isset($COUNT) && $COUNT > 0) { |
||
0 ignored issues
–
show
The variable
$COUNT seems to never exist, and therefore isset should always return false . Did you maybe rename this variable?
This check looks for calls to This is most likely caused by the renaming of a variable or the removal of a function/method parameter. ![]() |
|||
4980 | $ret_terminator = sprintf(_APCAL_RR_COUNT, $COUNT); |
||
4981 | View Code Duplication | } elseif (isset($UNTIL)) { |
|
0 ignored issues
–
show
The variable
$UNTIL seems to never exist, and therefore isset should always return false . Did you maybe rename this variable?
This check looks for calls to This is most likely caused by the renaming of a variable or the removal of a function/method parameter. ![]() 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. ![]() |
|||
4982 | // UNTIL �ϡ�������Ǥ����̵���Ǹ��ʤ� |
||
4983 | $year = substr($UNTIL, 0, 4); |
||
4984 | $month = substr($UNTIL, 4, 2); |
||
4985 | $date = substr($UNTIL, 6, 2); |
||
4986 | $ret_terminator = sprintf(_APCAL_RR_UNTIL, "$year-$month-$date"); |
||
4987 | } |
||
4988 | |||
4989 | return "$ret_freq $ret_day $ret_terminator"; |
||
4990 | } |
||
4991 | |||
4992 | // rrule���Խ��ѥե������Ÿ�����륯�饹�ؿ� |
||
4993 | |||
4994 | /** |
||
4995 | * @param $rrule |
||
4996 | * @param $until_init |
||
4997 | * @return string |
||
4998 | */ |
||
4999 | public function rrule_to_form($rrule, $until_init) |
||
5000 | { |
||
5001 | // �ƽ���ͤ����� |
||
5002 | $norrule_checked = ''; |
||
0 ignored issues
–
show
$norrule_checked 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 ![]() |
|||
5003 | $daily_checked = ''; |
||
5004 | $weekly_checked = ''; |
||
5005 | $monthly_checked = ''; |
||
5006 | $yearly_checked = ''; |
||
5007 | $norrule_checked = ''; |
||
5008 | $noterm_checked = ''; |
||
5009 | $count_checked = ''; |
||
5010 | $until_checked = ''; |
||
5011 | $daily_interval_init = 1; |
||
5012 | $weekly_interval_init = 1; |
||
5013 | $monthly_interval_init = 1; |
||
5014 | $yearly_interval_init = 1; |
||
5015 | $count_init = 1; |
||
5016 | $wdays_checked = array( |
||
5017 | 'SU' => '', |
||
5018 | 'MO' => '', |
||
5019 | 'TU' => '', |
||
5020 | 'WE' => '', |
||
5021 | 'TH' => '', |
||
5022 | 'FR' => '', |
||
5023 | 'SA' => '' |
||
5024 | ); |
||
5025 | $byday_m_init = ''; |
||
5026 | $bymonthday_init = ''; |
||
5027 | $bymonths_checked = array(1 => '', '', '', '', '', '', '', '', '', '', '', ''); |
||
5028 | |||
5029 | if (trim($rrule) === '') { |
||
5030 | $norrule_checked = 'checked'; |
||
5031 | } else { |
||
5032 | |||
5033 | // rrule �γ����Ǥ��ѿ���Ÿ�� |
||
5034 | $rrule = strtoupper($rrule); |
||
5035 | $rules = explode(';', $rrule); |
||
5036 | View Code Duplication | foreach ($rules as $rule) { |
|
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. ![]() |
|||
5037 | list($key, $val) = explode('=', $rule, 2); |
||
5038 | $key = trim($key); |
||
5039 | $$key = trim($val); |
||
5040 | } |
||
5041 | |||
5042 | if (empty($FREQ)) { |
||
0 ignored issues
–
show
The variable
$FREQ seems only to be defined at a later point. As such the call to empty() seems to always evaluate to true .
This check marks calls to This is likely the result of code being shifted around. Consider removing these calls. ![]() |
|||
5043 | $FREQ = 'DAILY'; |
||
5044 | } |
||
5045 | if (empty($INTERVAL) || $INTERVAL <= 0) { |
||
0 ignored issues
–
show
The variable
$INTERVAL seems only to be defined at a later point. As such the call to empty() seems to always evaluate to true .
This check marks calls to This is likely the result of code being shifted around. Consider removing these calls. ![]() |
|||
5046 | $INTERVAL = 1; |
||
5047 | } |
||
5048 | |||
5049 | // ���پ����� |
||
5050 | switch ($FREQ) { |
||
5051 | case 'DAILY': |
||
5052 | $daily_interval_init = $INTERVAL; |
||
5053 | $daily_checked = 'checked'; |
||
5054 | break; |
||
5055 | case 'WEEKLY': |
||
5056 | if (empty($BYDAY)) { |
||
0 ignored issues
–
show
The variable
$BYDAY seems to never exist, and therefore empty should always return true . Did you maybe rename this variable?
This check looks for calls to This is most likely caused by the renaming of a variable or the removal of a function/method parameter. ![]() |
|||
5057 | break; |
||
5058 | } // BYDAY ɬ�� |
||
5059 | $weekly_interval_init = $INTERVAL; |
||
5060 | $weekly_checked = 'checked'; |
||
5061 | $wdays = explode(',', $BYDAY, 7); |
||
5062 | foreach ($wdays as $wday) { |
||
5063 | if (isset($wdays_checked[$wday])) { |
||
5064 | $wdays_checked[$wday] = 'checked'; |
||
5065 | } |
||
5066 | } |
||
5067 | break; |
||
5068 | case 'MONTHLY': |
||
5069 | if (isset($BYDAY)) { |
||
5070 | $byday_m_init = $BYDAY; |
||
5071 | } elseif (isset($BYMONTHDAY)) { |
||
0 ignored issues
–
show
The variable
$BYMONTHDAY does not exist. Did you mean $bymonthday_init ?
This check looks for variables that are accessed but have not been defined. It raises an issue if it finds another variable that has a similar name. The variable may have been renamed without also renaming all references. ![]() |
|||
5072 | $bymonthday_init = $BYMONTHDAY; |
||
5073 | } else { |
||
5074 | break; // BYDAY �ޤ��� BYMONTHDAY ɬ�� |
||
5075 | } |
||
5076 | $monthly_interval_init = $INTERVAL; |
||
5077 | $monthly_checked = 'checked'; |
||
5078 | break; |
||
5079 | case 'YEARLY': |
||
5080 | if (empty($BYMONTH)) { |
||
0 ignored issues
–
show
The variable
$BYMONTH seems only to be defined at a later point. As such the call to empty() seems to always evaluate to true .
This check marks calls to This is likely the result of code being shifted around. Consider removing these calls. ![]() |
|||
5081 | $BYMONTH = ''; |
||
5082 | } |
||
5083 | if (isset($BYDAY)) { |
||
5084 | $byday_m_init = $BYDAY; |
||
5085 | } |
||
5086 | $yearly_interval_init = $INTERVAL; |
||
5087 | $yearly_checked = 'checked'; |
||
5088 | $months = explode(',', $BYMONTH, 12); |
||
5089 | foreach ($months as $month) { |
||
5090 | $month = (int)$month; |
||
5091 | if ($month > 0 && $month <= 12) { |
||
5092 | $bymonths_checked[$month] = 'checked'; |
||
5093 | } |
||
5094 | } |
||
5095 | break; |
||
5096 | } |
||
5097 | |||
5098 | // ������� |
||
5099 | // UNTIL �� COUNT ��ξ������ COUNT ͥ�� |
||
5100 | if (isset($COUNT) && $COUNT > 0) { |
||
0 ignored issues
–
show
The variable
$COUNT seems to never exist, and therefore isset should always return false . Did you maybe rename this variable?
This check looks for calls to This is most likely caused by the renaming of a variable or the removal of a function/method parameter. ![]() |
|||
5101 | $count_init = $COUNT; |
||
5102 | $count_checked = 'checked'; |
||
5103 | View Code Duplication | } elseif (isset($UNTIL)) { |
|
0 ignored issues
–
show
The variable
$UNTIL seems to never exist, and therefore isset should always return false . Did you maybe rename this variable?
This check looks for calls to This is most likely caused by the renaming of a variable or the removal of a function/method parameter. ![]() 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. ![]() |
|||
5104 | // UNTIL �ϡ�����ǡ����Ǥ����̵���Ǹ��ʤ� |
||
5105 | $year = substr($UNTIL, 0, 4); |
||
5106 | $month = substr($UNTIL, 4, 2); |
||
5107 | $date = substr($UNTIL, 6, 2); |
||
5108 | $until_init = "$year-$month-$date"; |
||
5109 | $until_checked = 'checked'; |
||
5110 | } else { |
||
5111 | // ξ�ԤȤ���꤬�ʤ���С���λ���ʤ� |
||
5112 | $noterm_checked = 'checked'; |
||
5113 | } |
||
5114 | } |
||
5115 | |||
5116 | // UNTIL ����ꤹ�뤿��Υܥå��� |
||
5117 | $textbox_until = $this->get_formtextdateselect('rrule_until', $until_init); |
||
5118 | |||
5119 | // ������������å��ܥå�����Ÿ�� |
||
5120 | $wdays_checkbox = ''; |
||
5121 | foreach ($this->byday2langday_w as $key => $val) { |
||
5122 | $wdays_checkbox .= "<input type='checkbox' name='rrule_weekly_bydays[]' value='$key' {$wdays_checked[$key]} />$val \n"; |
||
5123 | } |
||
5124 | |||
5125 | // ����������å��ܥå�����Ÿ�� |
||
5126 | $bymonth_checkbox = "<table border='0' cellpadding='2'><tr>\n"; |
||
5127 | foreach ($bymonths_checked as $key => $val) { |
||
5128 | $bymonth_checkbox .= "<td><input type='checkbox' name='rrule_bymonths[]' value='$key' $val />{$this->month_short_names[$key]}</td>\n"; |
||
5129 | if ($key == 6) { |
||
5130 | $bymonth_checkbox .= "</tr>\n<tr>\n"; |
||
5131 | } |
||
5132 | } |
||
5133 | $bymonth_checkbox .= "</tr></table>\n"; |
||
5134 | |||
5135 | // ��N��������OPTION��Ÿ�� |
||
5136 | $byday_m_options = ''; |
||
5137 | foreach ($this->byday2langday_m as $key => $val) { |
||
5138 | if ($byday_m_init == $key) { |
||
5139 | $byday_m_options .= "<option value='$key' selected>$val</option>\n"; |
||
5140 | } else { |
||
5141 | $byday_m_options .= "<option value='$key'>$val</option>\n"; |
||
5142 | } |
||
5143 | } |
||
5144 | |||
5145 | return " |
||
5146 | <input type='radio' name='rrule_freq' value='none' $norrule_checked />" |
||
5147 | . _APCAL_RR_R_NORRULE |
||
5148 | . "<br> |
||
5149 | <br> |
||
5150 | <fieldset> |
||
5151 | <legend class='blockTitle'>" |
||
5152 | . _APCAL_RR_R_YESRRULE |
||
5153 | . "</legend> |
||
5154 | <fieldset> |
||
5155 | <legend class='blockTitle'><input type='radio' name='rrule_freq' value='daily' $daily_checked />" |
||
5156 | . _APCAL_RR_FREQDAILY |
||
5157 | . '</legend> |
||
5158 | ' |
||
5159 | . _APCAL_RR_FREQDAILY_PRE |
||
5160 | . " <input type='text' size='2' name='rrule_daily_interval' value='$daily_interval_init' /> " |
||
5161 | . _APCAL_RR_FREQDAILY_SUF |
||
5162 | . " |
||
5163 | </fieldset> |
||
5164 | <br> |
||
5165 | <fieldset> |
||
5166 | <legend class='blockTitle'><input type='radio' name='rrule_freq' value='weekly' $weekly_checked />" |
||
5167 | . _APCAL_RR_FREQWEEKLY |
||
5168 | . '</legend> |
||
5169 | ' |
||
5170 | . _APCAL_RR_FREQWEEKLY_PRE |
||
5171 | . "<input type='text' size='2' name='rrule_weekly_interval' value='$weekly_interval_init' /> " |
||
5172 | . _APCAL_RR_FREQWEEKLY_SUF |
||
5173 | . " <br> |
||
5174 | $wdays_checkbox |
||
5175 | </fieldset> |
||
5176 | <br> |
||
5177 | <fieldset> |
||
5178 | <legend class='blockTitle'><input type='radio' name='rrule_freq' value='monthly' $monthly_checked />" |
||
5179 | . _APCAL_RR_FREQMONTHLY |
||
5180 | . '</legend> |
||
5181 | ' |
||
5182 | . _APCAL_RR_FREQMONTHLY_PRE |
||
5183 | . "<input type='text' size='2' name='rrule_monthly_interval' value='$monthly_interval_init' /> " |
||
5184 | . _APCAL_RR_FREQMONTHLY_SUF |
||
5185 | . " |
||
5186 | <select name='rrule_monthly_byday'> |
||
5187 | <option value=''>" |
||
5188 | . _APCAL_RR_S_NOTSELECTED |
||
5189 | . "</option> |
||
5190 | $byday_m_options |
||
5191 | </select> " |
||
5192 | . _APCAL_RR_OR |
||
5193 | . " |
||
5194 | <input type='text' size='10' name='rrule_bymonthday' value='$bymonthday_init' />" |
||
5195 | . _APCAL_NTC_MONTHLYBYMONTHDAY |
||
5196 | . " |
||
5197 | </fieldset> |
||
5198 | <br> |
||
5199 | <fieldset> |
||
5200 | <legend class='blockTitle'><input type='radio' name='rrule_freq' value='yearly' $yearly_checked />" |
||
5201 | . _APCAL_RR_FREQYEARLY |
||
5202 | . '</legend> |
||
5203 | ' |
||
5204 | . _APCAL_RR_FREQYEARLY_PRE |
||
5205 | . "<input type='text' size='2' name='rrule_yearly_interval' value='$yearly_interval_init' /> " |
||
5206 | . _APCAL_RR_FREQYEARLY_SUF |
||
5207 | . " <br> |
||
5208 | $bymonth_checkbox <br> |
||
5209 | <select name='rrule_yearly_byday'> |
||
5210 | <option value=''>" |
||
5211 | . _APCAL_RR_S_SAMEASBDATE |
||
5212 | . "</option> |
||
5213 | $byday_m_options |
||
5214 | </select> |
||
5215 | </fieldset> |
||
5216 | <br> |
||
5217 | <input type='radio' name='rrule_terminator' value='noterm' $noterm_checked onClick='document.MainForm.rrule_until.disabled=true;document.MainForm.rrule_count.disabled=true;' />" |
||
5218 | . _APCAL_RR_R_NOCOUNTUNTIL |
||
5219 | . ' ' |
||
5220 | . sprintf(_APCAL_NTC_EXTRACTLIMIT, $this->max_rrule_extract) |
||
5221 | . " <br> |
||
5222 | <input type='radio' name='rrule_terminator' value='count' $count_checked onClick='document.MainForm.rrule_until.disabled=true;document.MainForm.rrule_count.disabled=false;' />" |
||
5223 | . _APCAL_RR_R_USECOUNT_PRE |
||
5224 | . " <input type='text' size='3' name='rrule_count' value='$count_init' /> " |
||
5225 | . _APCAL_RR_R_USECOUNT_SUF |
||
5226 | . "<br> |
||
5227 | <input type='radio' name='rrule_terminator' value='until' $until_checked onClick='document.MainForm.rrule_until.disabled=false;document.MainForm.rrule_count.disabled=true;' />" |
||
5228 | . _APCAL_RR_R_USEUNTIL |
||
5229 | . " $textbox_until |
||
5230 | </fieldset> |
||
5231 | \n"; |
||
5232 | } |
||
5233 | |||
5234 | // POST���줿rrule��Ϣ�������ͤ�RRULEʸ������Ȥ߾夲�륯�饹�ؿ� |
||
5235 | |||
5236 | /** |
||
5237 | * @param $start |
||
5238 | * @param $allday_flag |
||
5239 | * @return string |
||
0 ignored issues
–
show
|
|||
5240 | */ |
||
5241 | public function rrule_from_post($start, $allday_flag) |
||
5242 | { |
||
5243 | // �����֤�̵���ʤ顢̵���Ƕ�ʸ������֤� |
||
5244 | if ($_POST['rrule_freq'] === 'none') { |
||
5245 | return ''; |
||
5246 | } |
||
5247 | |||
5248 | // ���پ�� |
||
5249 | switch (strtoupper($_POST['rrule_freq'])) { |
||
5250 | case 'DAILY': |
||
5251 | $ret_freq = 'FREQ=DAILY;INTERVAL=' . abs((int)$_POST['rrule_daily_interval']); |
||
5252 | break; |
||
5253 | case 'WEEKLY': |
||
5254 | $ret_freq = 'FREQ=WEEKLY;INTERVAL=' . abs((int)$_POST['rrule_weekly_interval']); |
||
5255 | if (empty($_POST['rrule_weekly_bydays'])) { |
||
5256 | // ����λ��꤬��Ĥ�ʤ���С��������Ʊ������ˤ��� |
||
5257 | $bydays = array_keys($this->byday2langday_w); |
||
5258 | $byday = $bydays[date('w', $start)]; |
||
5259 | } else { |
||
5260 | $byday = ''; |
||
5261 | foreach ($_POST['rrule_weekly_bydays'] as $wday) { |
||
5262 | if (preg_match('/[^\w]+/', $wday)) { |
||
5263 | die('Some injection was tried'); |
||
5264 | } |
||
5265 | $byday .= substr($wday, 0, 2) . ','; |
||
5266 | } |
||
5267 | $byday = substr($byday, 0, -1); |
||
5268 | } |
||
5269 | $ret_freq .= ";BYDAY=$byday"; |
||
5270 | break; |
||
5271 | case 'MONTHLY': |
||
5272 | $ret_freq = 'FREQ=MONTHLY;INTERVAL=' . abs((int)$_POST['rrule_monthly_interval']); |
||
5273 | if ($_POST['rrule_monthly_byday'] !== '') { |
||
5274 | // ��N����ˤ����� |
||
5275 | $byday = substr(trim($_POST['rrule_monthly_byday']), 0, 4); |
||
5276 | if (preg_match('/[^\w-]+/', $byday)) { |
||
5277 | die('Some injection was tried'); |
||
5278 | } |
||
5279 | $ret_freq .= ";BYDAY=$byday"; |
||
5280 | } elseif ($_POST['rrule_bymonthday'] !== '') { |
||
5281 | // ���դˤ����� |
||
5282 | $bymonthday = preg_replace('/[^0-9,]+/', '', $_POST['rrule_bymonthday']); |
||
5283 | $ret_freq .= ";BYMONTHDAY=$bymonthday"; |
||
5284 | } else { |
||
5285 | // ��N��������դλ��꤬�ʤ���С��������Ʊ�����դȤ��� |
||
5286 | $ret_freq .= ';BYMONTHDAY=' . date('j', $start); |
||
5287 | } |
||
5288 | break; |
||
5289 | case 'YEARLY': |
||
5290 | $ret_freq = 'FREQ=YEARLY;INTERVAL=' . abs((int)$_POST['rrule_yearly_interval']); |
||
5291 | if (empty($_POST['rrule_bymonths'])) { |
||
5292 | // ��λ��꤬��Ĥ�ʤ���С��������Ʊ����ˤ��� |
||
5293 | $bymonth = date('n', $start); |
||
5294 | } else { |
||
5295 | $bymonth = ''; |
||
5296 | foreach ($_POST['rrule_bymonths'] as $month) { |
||
5297 | $bymonth .= (int)$month . ','; |
||
5298 | } |
||
5299 | $bymonth = substr($bymonth, 0, -1); |
||
5300 | } |
||
5301 | if ($_POST['rrule_yearly_byday'] !== '') { |
||
5302 | // ��N����ˤ����� |
||
5303 | $byday = substr(trim($_POST['rrule_yearly_byday']), 0, 4); |
||
5304 | if (preg_match('/[^\w-]+/', $byday)) { |
||
5305 | die('Some injection was tried'); |
||
5306 | } |
||
5307 | $ret_freq .= ";BYDAY=$byday"; |
||
5308 | } |
||
5309 | $ret_freq .= ";BYMONTH=$bymonth"; |
||
5310 | break; |
||
5311 | default: |
||
5312 | return ''; |
||
5313 | } |
||
5314 | |||
5315 | // ���� |
||
5316 | if (empty($_POST['rrule_terminator'])) { |
||
5317 | $_POST['rrule_terminator'] = ''; |
||
5318 | } |
||
5319 | switch (strtoupper($_POST['rrule_terminator'])) { |
||
5320 | case 'COUNT': |
||
5321 | $ret_term = ';COUNT=' . abs((int)$_POST['rrule_count']); |
||
5322 | break; |
||
5323 | case 'UNTIL': |
||
5324 | // UNTIL��Unixtime�� |
||
5325 | list($until, $until_date, $use_default) = $this->parse_posted_date($this->mb_convert_kana($_POST['rrule_until'], 'a'), $this->unixtime); |
||
0 ignored issues
–
show
The assignment to
$use_default is unused. Consider omitting it like so list($first,,$third) .
This checks looks for assignemnts to variables using the Consider the following code example. <?php
function returnThreeValues() {
return array('a', 'b', 'c');
}
list($a, $b, $c) = returnThreeValues();
print $a . " - " . $c;
Only the variables Instead, the list call could have been. list($a,, $c) = returnThreeValues();
![]() |
|||
5326 | // 1970������2038ǯ�ʹߤʤ顢UNTIL̵�� |
||
5327 | if ($until_date) { |
||
5328 | $ret_term = ''; |
||
5329 | } else { |
||
5330 | if (!$allday_flag) { |
||
5331 | // ����٥�ȤǤʤ����Ʊ���23:59:59��λ����ȸ��ʤ��ơ� UTC �ػ����׻����� |
||
5332 | $event_tz = isset($_POST['event_tz']) ? $_POST['event_tz'] : $this->user_TZ; |
||
5333 | $until = $until - (int)($event_tz * 3600) + 86400 - 1; |
||
5334 | } |
||
5335 | $ret_term = ';UNTIL=' . date('Ymd\THis\Z', $until); |
||
5336 | } |
||
5337 | break; |
||
5338 | case 'NOTERM': |
||
5339 | default: |
||
5340 | $ret_term = ''; |
||
5341 | break; |
||
5342 | } |
||
5343 | |||
5344 | // WKST�ϡ���ư������� |
||
5345 | $ret_wkst = $this->week_start ? ';WKST=MO' : ';WKST=SU'; |
||
5346 | |||
5347 | return $ret_freq . $ret_term . $ret_wkst; |
||
5348 | } |
||
5349 | |||
5350 | // �Ϥ��줿event_id����(��)�Ȥ��ơ�RRULE��Ÿ�����ƥǡ����١�����ȿ�� |
||
5351 | |||
5352 | /** |
||
5353 | * @param $event_id |
||
5354 | */ |
||
5355 | public function rrule_extract($event_id) |
||
5356 | { |
||
5357 | $yrs = $GLOBALS['xoopsDB']->query("SELECT *,TO_DAYS(end_date)-TO_DAYS(start_date) AS date_diff FROM $this->table WHERE id='$event_id'"); |
||
5358 | if ($GLOBALS['xoopsDB']->getRowsNum($yrs) < 1) { |
||
5359 | return; |
||
5360 | } |
||
5361 | $event = $GLOBALS['xoopsDB']->fetchObject($yrs); |
||
5362 | |||
5363 | if ($event->rrule === '') { |
||
5364 | return; |
||
5365 | } |
||
5366 | |||
5367 | // rrule �γ����Ǥ��ѿ���Ÿ�� |
||
5368 | $rrule = strtoupper($event->rrule); |
||
5369 | $rules = explode(';', $rrule); |
||
5370 | View Code Duplication | foreach ($rules as $rule) { |
|
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. ![]() |
|||
5371 | list($key, $val) = explode('=', $rule, 2); |
||
5372 | $key = trim($key); |
||
5373 | $$key = trim($val); |
||
5374 | } |
||
5375 | |||
5376 | // �����ˤ�äơ�RRULE�����ջ��꤬�ɤ��֤�����뤫�η׻� |
||
5377 | if ($event->allday) { |
||
5378 | $tzoffset_date = 0; |
||
5379 | } else { |
||
5380 | // ���٥�ȼ��Ȥ�TZ��Ÿ������ |
||
5381 | $tzoffset_s2e = (int)(($event->event_tz - $this->server_TZ) * 3600); |
||
5382 | $tzoffset_date = date('z', $event->start + $tzoffset_s2e) - date('z', $event->start); |
||
5383 | if ($tzoffset_date > 1) { |
||
5384 | $tzoffset_date = -1; |
||
5385 | } elseif ($tzoffset_date < -1) { |
||
5386 | $tzoffset_date = 1; |
||
5387 | } |
||
5388 | } |
||
5389 | |||
5390 | if (empty($FREQ)) { |
||
0 ignored issues
–
show
The variable
$FREQ seems only to be defined at a later point. As such the call to empty() seems to always evaluate to true .
This check marks calls to This is likely the result of code being shifted around. Consider removing these calls. ![]() |
|||
5391 | $FREQ = 'DAILY'; |
||
5392 | } |
||
5393 | if (empty($INTERVAL) || $INTERVAL <= 0) { |
||
0 ignored issues
–
show
The variable
$INTERVAL seems only to be defined at a later point. As such the call to empty() seems to always evaluate to true .
This check marks calls to This is likely the result of code being shifted around. Consider removing these calls. ![]() |
|||
5394 | $INTERVAL = 1; |
||
5395 | } |
||
5396 | |||
5397 | // �١����Ȥʤ�SQLʸ |
||
5398 | $base_sql = "INSERT INTO $this->table SET uid='$event->uid',groupid='$event->groupid',shortsummary='" |
||
5399 | . $this->makeShort(utf8_decode(addslashes($event->summary))) |
||
5400 | . "',summary='" |
||
5401 | . addslashes($event->summary) |
||
5402 | . "',location='" |
||
5403 | . addslashes($event->location) |
||
5404 | . "',gmlat='{$event->gmlat}',gmlong='{$event->gmlong}',gmzoom='{$event->gmzoom}',organizer='" |
||
5405 | . addslashes($event->organizer) |
||
5406 | . "',sequence='$event->sequence',contact='" |
||
5407 | . addslashes($event->contact) |
||
5408 | . "',email='" |
||
5409 | . addslashes($event->email) |
||
5410 | . "',url='" |
||
5411 | . addslashes($event->url) |
||
5412 | . "',tzid='$event->tzid',description='" |
||
5413 | . addslashes($event->description) |
||
5414 | . "',dtstamp='$event->dtstamp',mainCategory='{$event->mainCategory}',categories='" |
||
5415 | . addslashes($event->categories) |
||
5416 | . "',transp='$event->transp',priority='$event->priority',admission='$event->admission',class='$event->class',rrule='" |
||
5417 | . addslashes($event->rrule) |
||
5418 | . "',unique_id='$event->unique_id',allday='$event->allday',start_date=null,end_date=null,cid='$event->cid',event_tz='$event->event_tz',server_tz='$event->server_tz',poster_tz='$event->poster_tz',extkey0='$event->extkey0',extkey1='$event->extkey1',rrule_pid='$event_id'"; |
||
5419 | |||
5420 | // ������� |
||
5421 | // ������� |
||
5422 | $count = $this->max_rrule_extract; |
||
5423 | if (isset($COUNT) && $COUNT > 0 && $COUNT < $count) { |
||
0 ignored issues
–
show
The variable
$COUNT seems to never exist, and therefore isset should always return false . Did you maybe rename this variable?
This check looks for calls to This is most likely caused by the renaming of a variable or the removal of a function/method parameter. ![]() |
|||
5424 | $count = $COUNT; |
||
5425 | } |
||
5426 | // Ÿ����λ�� |
||
5427 | if (isset($UNTIL)) { |
||
0 ignored issues
–
show
The variable
$UNTIL seems to never exist, and therefore isset should always return false . Did you maybe rename this variable?
This check looks for calls to This is most likely caused by the renaming of a variable or the removal of a function/method parameter. ![]() |
|||
5428 | // UNTIL �ϡ�������Ǥ����̵���Ǹ��ʤ� |
||
5429 | $year = substr($UNTIL, 0, 4); |
||
5430 | $month = substr($UNTIL, 4, 2); |
||
5431 | $date = substr($UNTIL, 6, 2); |
||
5432 | if (!checkdate($month, $date, $year)) { |
||
5433 | $until = 0x7FFFFFFF; |
||
5434 | } else { |
||
5435 | $until = gmmktime(23, 59, 59, $month, $date, $year); |
||
5436 | if (!$event->allday) { |
||
5437 | // �����л��֤ȥ��٥�Ȼ��֤����դ��ۤʤ���ˤ�UNTIL�⤺�餹 |
||
5438 | $until -= (int)($tzoffset_date * 86400); |
||
5439 | // UTC -> server_TZ �λ����׻��ϹԤ�ʤ� |
||
5440 | // $until -= (int)( $this->server_TZ * 3600 ) ; |
||
5441 | } |
||
5442 | } |
||
5443 | } else { |
||
5444 | $until = 0x7FFFFFFF; |
||
5445 | } |
||
5446 | |||
5447 | // WKST |
||
5448 | if (empty($WKST)) { |
||
0 ignored issues
–
show
The variable
$WKST seems only to be defined at a later point. As such the call to empty() seems to always evaluate to true .
This check marks calls to This is likely the result of code being shifted around. Consider removing these calls. ![]() |
|||
5449 | $WKST = 'MO'; |
||
5450 | } |
||
5451 | |||
5452 | // UnixTimestamp�ϰϳ��ν��� |
||
5453 | if (isset($event->start_date)) { |
||
5454 | // ���Ϥ佪λ��2038ǯ�ʹߤʤ�Ÿ�����ʤ� |
||
5455 | if (date('Y', $event->start) >= 2038) { |
||
5456 | return; |
||
5457 | } |
||
5458 | if (date('Y', $event->end) >= 2038) { |
||
5459 | return; |
||
5460 | } |
||
5461 | |||
5462 | // 1971ǯ��Ʊ��Ʊ���Ÿ���١�����start�Ȥ��� |
||
5463 | $event->start = mktime(0, 0, 0, substr($event->start_date, 5, 2), substr($event->start_date, 8, 2), 1970 + 1); |
||
5464 | |||
5465 | // end��1970�����ʤ顢����Ȥä�ȿ�ǡ������Ǥʤ����ϤȤꤢ�������� TODO |
||
5466 | if (isset($event->end_date)) { |
||
5467 | $event->end = $event->start + ($event->date_diff + 1) * 86400; |
||
5468 | } |
||
5469 | } |
||
5470 | |||
5471 | // ���پ����� |
||
5472 | $sqls = array(); |
||
5473 | switch ($FREQ) { |
||
5474 | case 'DAILY': |
||
5475 | $gmstart = $event->start + date('Z', $event->start); |
||
5476 | $gmend = $event->end + date('Z', $event->end); |
||
5477 | for ($c = 1; $c < $count; ++$c) { |
||
5478 | $gmstart += $INTERVAL * 86400; |
||
5479 | $gmend += $INTERVAL * 86400; |
||
5480 | if ($gmstart > $until) { |
||
5481 | break; |
||
5482 | } |
||
5483 | $sqls[] = $base_sql . ",start=$gmstart ,end=$gmend "; |
||
5484 | } |
||
5485 | break; |
||
5486 | |||
5487 | case 'WEEKLY': |
||
5488 | $gmstart = $event->start + date('Z', $event->start); |
||
5489 | $gmstartbase = $gmstart; |
||
5490 | $gmend = $event->end + date('Z', $event->end); |
||
5491 | $duration = $gmend - $gmstart; |
||
5492 | $wtop_date = gmdate('j', $gmstart) - gmdate('w', $gmstart); |
||
5493 | if ($WKST !== 'SU') { |
||
5494 | $wtop_date = $wtop_date == 7 ? 1 : $wtop_date + 1; |
||
5495 | } |
||
5496 | $secondofday = $gmstart % 86400; |
||
5497 | $month = gmdate('m', $gmstart); |
||
5498 | $year = gmdate('Y', $gmstart); |
||
5499 | $week_top = gmmktime(0, 0, 0, $month, $wtop_date, $year); |
||
5500 | $c = 1; |
||
5501 | // ���Ͳ���������κ��� |
||
5502 | $temp_dates = explode(',', $BYDAY); |
||
0 ignored issues
–
show
|
|||
5503 | $wdays = array_keys($this->byday2langday_w); |
||
5504 | if ($WKST !== 'SU') { |
||
5505 | // rotate wdays for creating array starting with Monday |
||
5506 | $sun_date = array_shift($wdays); |
||
5507 | array_push($wdays, $sun_date); |
||
5508 | } |
||
5509 | $dates = array(); |
||
5510 | foreach ($temp_dates as $date) { |
||
5511 | // measure for bug of PHP<4.2.0 |
||
5512 | if (in_array($date, $wdays)) { |
||
5513 | $dates[] = array_search($date, $wdays); |
||
5514 | } |
||
5515 | } |
||
5516 | sort($dates); |
||
5517 | $dates = array_unique($dates); |
||
5518 | if (!count($dates)) { |
||
5519 | return; |
||
5520 | } |
||
5521 | while (1) { |
||
5522 | foreach ($dates as $date) { |
||
5523 | // �����л��֤ȥ��٥�Ȼ��֤�����ۤʤ���ν����ɲ� |
||
5524 | $gmstart = $week_top + ($date - $tzoffset_date) * 86400 + $secondofday; |
||
5525 | if ($gmstart <= $gmstartbase) { |
||
5526 | continue; |
||
5527 | } |
||
5528 | $gmend = $gmstart + $duration; |
||
5529 | if ($gmstart > $until) { |
||
5530 | break 2; |
||
5531 | } |
||
5532 | if (++$c > $count) { |
||
5533 | break 2; |
||
5534 | } |
||
5535 | $sqls[] = $base_sql . ",start=$gmstart ,end=$gmend "; |
||
5536 | } |
||
5537 | $week_top += $INTERVAL * 86400 * 7; |
||
5538 | } |
||
5539 | break; |
||
5540 | |||
5541 | case 'MONTHLY': |
||
5542 | $gmstart = $event->start + date('Z', $event->start); |
||
5543 | $gmstartbase = $gmstart; |
||
5544 | $gmend = $event->end + date('Z', $event->end); |
||
5545 | $duration = $gmend - $gmstart; |
||
5546 | $secondofday = $gmstart % 86400; |
||
5547 | $month = gmdate('m', $gmstart); |
||
5548 | $year = gmdate('Y', $gmstart); |
||
5549 | $c = 1; |
||
5550 | if (isset($BYDAY) && preg_match('/^(-1|[1-4])(SU|MO|TU|WE|TH|FR|SA)/', $BYDAY, $regs)) { |
||
5551 | // ��N�������(BYDAY)�ξ���ʣ���Բġ� |
||
5552 | // ��Ū�������ֹ����� |
||
5553 | $wdays = array_keys($this->byday2langday_w); |
||
5554 | $wday = array_search($regs[2], $wdays); |
||
5555 | $first_ymw = gmdate('Ym', $gmstart) . (int)((gmdate('j', $gmstart) - 1) / 7); |
||
0 ignored issues
–
show
$first_ymw 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 ![]() |
|||
5556 | if ($regs[1] == -1) { |
||
5557 | // �ǽ�������ξ��Υ롼�� |
||
5558 | $monthday_bottom = gmmktime(0, 0, 0, $month, 0, $year); |
||
5559 | View Code Duplication | while (1) { |
|
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. ![]() |
|||
5560 | for ($i = 0; $i < $INTERVAL; ++$i) { |
||
5561 | $monthday_bottom += gmdate('t', $monthday_bottom + 86400) * 86400; |
||
5562 | } |
||
5563 | // �ǽ���������Ĵ�٤� |
||
5564 | $last_monthdays_wday = gmdate('w', $monthday_bottom); |
||
5565 | $date_back = $wday - $last_monthdays_wday; |
||
5566 | if ($date_back > 0) { |
||
5567 | $date_back -= 7; |
||
5568 | } |
||
5569 | // �����л��֤ȥ��٥�Ȼ��֤�����ۤʤ���ν����ɲ� |
||
5570 | $gmstart = $monthday_bottom + ($date_back - $tzoffset_date) * 86400 + $secondofday; |
||
5571 | if ($gmstart <= $gmstartbase) { |
||
5572 | continue; |
||
5573 | } |
||
5574 | $gmend = $gmstart + $duration; |
||
5575 | if ($gmstart > $until) { |
||
5576 | break; |
||
5577 | } |
||
5578 | if (++$c > $count) { |
||
5579 | break; |
||
5580 | } |
||
5581 | $sqls[] = $base_sql . ",start=$gmstart ,end=$gmend "; |
||
5582 | } |
||
5583 | } else { |
||
5584 | // ��N������ξ��Υ롼�� |
||
5585 | $monthday_top = gmmktime(0, 0, 0, $month, 1, $year); |
||
5586 | $week_number_offset = ($regs[1] - 1) * 7 * 86400; |
||
5587 | while (1) { |
||
5588 | for ($i = 0; $i < $INTERVAL; ++$i) { |
||
5589 | $monthday_top += gmdate('t', $monthday_top) * 86400; |
||
5590 | } |
||
5591 | // ��N������������Ĵ�٤� |
||
5592 | $week_numbers_top_wday = gmdate('w', $monthday_top + $week_number_offset); |
||
5593 | $date_ahead = $wday - $week_numbers_top_wday; |
||
5594 | if ($date_ahead < 0) { |
||
5595 | $date_ahead += 7; |
||
5596 | } |
||
5597 | // �����л��֤ȥ��٥�Ȼ��֤�����ۤʤ���ν����ɲ� |
||
5598 | $gmstart = $monthday_top + $week_number_offset + ($date_ahead - $tzoffset_date) * 86400 + $secondofday; |
||
5599 | if ($gmstart <= $gmstartbase) { |
||
5600 | continue; |
||
5601 | } |
||
5602 | $gmend = $gmstart + $duration; |
||
5603 | if ($gmstart > $until) { |
||
5604 | break; |
||
5605 | } |
||
5606 | if (++$c > $count) { |
||
5607 | break; |
||
5608 | } |
||
5609 | $sqls[] = $base_sql . ",start=$gmstart ,end=$gmend "; |
||
5610 | } |
||
5611 | } |
||
5612 | } elseif (isset($BYMONTHDAY)) { |
||
0 ignored issues
–
show
The variable
$BYMONTHDAY seems to never exist, and therefore isset should always return false . Did you maybe rename this variable?
This check looks for calls to This is most likely caused by the renaming of a variable or the removal of a function/method parameter. ![]() |
|||
5613 | // ���ջ���(BYMONTHDAY)�ξ���ʣ���ġ� |
||
5614 | $monthday_top = gmmktime(0, 0, 0, $month, 1, $year); |
||
5615 | // BYMONTHDAY ��������ơ�$dates����ˤ��� |
||
5616 | $temp_dates = explode(',', $BYMONTHDAY); |
||
5617 | $dates = array(); |
||
5618 | foreach ($temp_dates as $date) { |
||
5619 | if ($date > 0 && $date <= 31) { |
||
5620 | $dates[] = (int)$date; |
||
5621 | } |
||
5622 | } |
||
5623 | sort($dates); |
||
5624 | $dates = array_unique($dates); |
||
5625 | if (!count($dates)) { |
||
5626 | return; |
||
5627 | } |
||
5628 | View Code Duplication | while (1) { |
|
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. ![]() |
|||
5629 | $months_day = gmdate('t', $monthday_top); |
||
5630 | foreach ($dates as $date) { |
||
5631 | // ��κǽ���ե?�����å� |
||
5632 | if ($date > $months_day) { |
||
5633 | $date = $months_day; |
||
5634 | } |
||
5635 | // �����л��֤ȥ��٥�Ȼ��֤����դ��ۤʤ���ν����ɲ� |
||
5636 | $gmstart = $monthday_top + ($date - 1 - $tzoffset_date) * 86400 + $secondofday; |
||
5637 | if ($gmstart <= $gmstartbase) { |
||
5638 | continue; |
||
5639 | } |
||
5640 | $gmend = $gmstart + $duration; |
||
5641 | if ($gmstart > $until) { |
||
5642 | break 2; |
||
5643 | } |
||
5644 | if (++$c > $count) { |
||
5645 | break 2; |
||
5646 | } |
||
5647 | $sqls[] = $base_sql . ",start=$gmstart ,end=$gmend "; |
||
5648 | } |
||
5649 | for ($i = 0; $i < $INTERVAL; ++$i) { |
||
5650 | $monthday_top += gmdate('t', $monthday_top) * 86400; |
||
5651 | } |
||
5652 | } |
||
5653 | } else { |
||
5654 | // Í���$BYDAY��$BYMONTHDAY��̵����С������֤�����ʤ� |
||
5655 | return; |
||
5656 | } |
||
5657 | break; |
||
5658 | |||
5659 | case 'YEARLY': |
||
5660 | $gmstart = $event->start + date('Z', $event->start); |
||
5661 | $gmstartbase = $gmstart; |
||
5662 | $gmend = $event->end + date('Z', $event->end); |
||
5663 | $duration = $gmend - $gmstart; |
||
5664 | $secondofday = $gmstart % 86400; |
||
5665 | $gmmonth = gmdate('n', $gmstart); |
||
5666 | |||
5667 | // empty BYMONTH |
||
5668 | if (empty($BYMONTH)) { |
||
0 ignored issues
–
show
The variable
$BYMONTH seems only to be defined at a later point. As such the call to empty() seems to always evaluate to true .
This check marks calls to This is likely the result of code being shifted around. Consider removing these calls. ![]() |
|||
5669 | $BYMONTH = $gmmonth; |
||
5670 | } |
||
5671 | |||
5672 | // BYMONTH ��������ơ�$months����ˤ����BYMONTH��ʣ���ġ� |
||
5673 | $temp_months = explode(',', $BYMONTH); |
||
5674 | $months = array(); |
||
5675 | foreach ($temp_months as $month) { |
||
5676 | if ($month > 0 && $month <= 12) { |
||
5677 | $months[] = (int)$month; |
||
5678 | } |
||
5679 | } |
||
5680 | sort($months); |
||
5681 | $months = array_unique($months); |
||
5682 | if (!count($months)) { |
||
5683 | return; |
||
5684 | } |
||
5685 | |||
5686 | if (isset($BYDAY) && preg_match('/^(-1|[1-4])(SU|MO|TU|WE|TH|FR|SA)/', $BYDAY, $regs)) { |
||
5687 | // ��N�������ξ���ʣ���Բġ� |
||
5688 | // ��Ū�������ֹ����� |
||
5689 | $wdays = array_keys($this->byday2langday_w); |
||
5690 | $wday = array_search($regs[2], $wdays); |
||
5691 | $first_ym = gmdate('Ym', $gmstart); |
||
5692 | $year = gmdate('Y', $gmstart); |
||
5693 | $c = 1; |
||
5694 | if ($regs[1] == -1) { |
||
5695 | // �ǽ�������ξ��Υ롼�� |
||
5696 | while (1) { |
||
5697 | foreach ($months as $month) { |
||
5698 | // �ǽ���������Ĵ�٤� |
||
5699 | $last_monthdays_wday = gmdate('w', gmmktime(0, 0, 0, $month + 1, 0, $year)); |
||
5700 | $date_back = $wday - $last_monthdays_wday; |
||
5701 | if ($date_back > 0) { |
||
5702 | $date_back -= 7; |
||
5703 | } |
||
5704 | $gmstart = gmmktime(0, 0, 0, $month + 1, $date_back - $tzoffset_date, $year) + $secondofday; |
||
5705 | // ����Ʊ����������ɤ��������å� |
||
5706 | if (gmdate('Ym', $gmstart) <= $first_ym) { |
||
5707 | continue; |
||
5708 | } |
||
5709 | $gmend = $gmstart + $duration; |
||
5710 | if ($gmstart > $until) { |
||
5711 | break 2; |
||
5712 | } |
||
5713 | if (++$c > $count) { |
||
5714 | break 2; |
||
5715 | } |
||
5716 | $sqls[] = $base_sql . ",start=$gmstart ,end=$gmend "; |
||
5717 | } |
||
5718 | $year += $INTERVAL; |
||
5719 | if ($year >= 2038) { |
||
5720 | break; |
||
5721 | } |
||
5722 | } |
||
5723 | } else { |
||
5724 | // ��N������ξ��Υ롼�� |
||
5725 | $week_numbers_top_date = 1 + ($regs[1] - 1) * 7; |
||
5726 | while (1) { |
||
5727 | foreach ($months as $month) { |
||
5728 | // ��N������������Ĵ�٤� |
||
5729 | $week_numbers_top_wday = gmdate('w', gmmktime(0, 0, 0, $month, $week_numbers_top_date, $year)); |
||
5730 | $date_ahead = $wday - $week_numbers_top_wday; |
||
5731 | if ($date_ahead < 0) { |
||
5732 | $date_ahead += 7; |
||
5733 | } |
||
5734 | $gmstart = gmmktime(0, 0, 0, $month, $week_numbers_top_date + $date_ahead - $tzoffset_date, $year) + $secondofday; |
||
5735 | // ����Ʊ����������ɤ��������å� |
||
5736 | if (gmdate('Ym', $gmstart) <= $first_ym) { |
||
5737 | continue; |
||
5738 | } |
||
5739 | $gmend = $gmstart + $duration; |
||
5740 | if ($gmstart > $until) { |
||
5741 | break 2; |
||
5742 | } |
||
5743 | if (++$c > $count) { |
||
5744 | break 2; |
||
5745 | } |
||
5746 | $sqls[] = $base_sql . ",start=$gmstart ,end=$gmend "; |
||
5747 | } |
||
5748 | $year += $INTERVAL; |
||
5749 | if ($year >= 2038) { |
||
5750 | break; |
||
5751 | } |
||
5752 | } |
||
5753 | } |
||
5754 | } else { |
||
5755 | // ���ջ���ξ��Υ롼�ס�ʣ���Բġ� |
||
5756 | $first_date = gmdate('j', $gmstart); |
||
5757 | $year = gmdate('Y', $gmstart); |
||
5758 | $c = 1; |
||
5759 | while (1) { |
||
5760 | foreach ($months as $month) { |
||
5761 | $date = $first_date; |
||
5762 | // ��κǽ���ե?�����å� |
||
5763 | while (!checkdate($month, $date, $year) && $date > 0) { |
||
5764 | $date--; |
||
5765 | } |
||
5766 | // $date �� gmdate('j') �������Ƥ��뤿�ᡢ$tzoffset_date �ν�������� |
||
5767 | $gmstart = gmmktime(0, 0, 0, $month, $date, $year) + $secondofday; |
||
5768 | if ($gmstart <= $gmstartbase) { |
||
5769 | continue; |
||
5770 | } |
||
5771 | $gmend = $gmstart + $duration; |
||
5772 | if ($gmstart > $until) { |
||
5773 | break 2; |
||
5774 | } |
||
5775 | if (++$c > $count) { |
||
5776 | break 2; |
||
5777 | } |
||
5778 | $sqls[] = $base_sql . ",start=$gmstart ,end=$gmend "; |
||
5779 | } |
||
5780 | $year += $INTERVAL; |
||
5781 | if ($year >= 2038) { |
||
5782 | break; |
||
5783 | } |
||
5784 | } |
||
5785 | } |
||
5786 | break; |
||
5787 | |||
5788 | default: |
||
5789 | return; |
||
5790 | } |
||
5791 | |||
5792 | // echo "<pre>" ; var_dump( $sqls ) ; echo "</pre>" ; exit ; |
||
5793 | foreach ($sqls as $sql) { |
||
5794 | $GLOBALS['xoopsDB']->query($sql); |
||
5795 | } |
||
5796 | |||
5797 | $result = $GLOBALS['xoopsDB']->query("SELECT id FROM {$this->table} WHERE rrule_pid={$event_id}"); |
||
5798 | $pics = $GLOBALS['xoopsDB']->query("SELECT * FROM {$this->pic_table} WHERE event_id={$event_id}"); |
||
5799 | while ($event = $GLOBALS['xoopsDB']->fetchObject($result)) { |
||
5800 | $GLOBALS['xoopsDB']->query("DELETE FROM {$this->pic_table} WHERE event_id={$event->id}"); |
||
5801 | mysqli_data_seek($pics, 0); |
||
5802 | while ($pic = $GLOBALS['xoopsDB']->fetchObject($pics)) { |
||
5803 | $GLOBALS['xoopsDB']->query("INSERT INTO {$this->pic_table} SET event_id='{$event->id}', picture='{$pic->picture}', main_pic='{$pic->main_pic}'"); |
||
5804 | } |
||
5805 | } |
||
5806 | } |
||
5807 | |||
5808 | // The End of Class |
||
5809 | } |
||
5810 | } |
||
5811 |
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.