@@ -240,6 +240,9 @@ discard block |
||
| 240 | 240 | return $this->call(CANVAS_API_PUT, $path, $data, $throwsExceptions); |
| 241 | 241 | } |
| 242 | 242 | |
| 243 | + /** |
|
| 244 | + * @param string $page |
|
| 245 | + */ |
|
| 243 | 246 | private function pageLink($page) { |
| 244 | 247 | if (array_key_exists($page, $this->lastCall['pagination'])) { |
| 245 | 248 | $this->pagePest = new Pest($this->lastCall['pagination'][$page]); |
@@ -264,6 +267,9 @@ discard block |
||
| 264 | 267 | return $this->pageLink('last'); |
| 265 | 268 | } |
| 266 | 269 | |
| 270 | + /** |
|
| 271 | + * @param string $page |
|
| 272 | + */ |
|
| 267 | 273 | private function getPageNumber($page) { |
| 268 | 274 | if (array_key_exists($page, $this->lastCall['pagination'])) { |
| 269 | 275 | parse_str(parse_url($this->lastCall['pagination'][$page], PHP_URL_QUERY), $query); |
@@ -217,7 +217,7 @@ |
||
| 217 | 217 | /** |
| 218 | 218 | * Do CURL request |
| 219 | 219 | * @param resource $curl |
| 220 | - * @return mixed |
|
| 220 | + * @return string |
|
| 221 | 221 | * @throws Pest_Curl_Exec |
| 222 | 222 | * @throws Pest_Curl_Meta |
| 223 | 223 | */ |
@@ -150,20 +150,23 @@ discard block |
||
| 150 | 150 | throw new Pest_Curl_Init($this->processError(curl_error($curl), 'curl')); |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | - foreach ($opts as $opt => $val) |
|
| 154 | - curl_setopt($curl, $opt, $val); |
|
| 153 | + foreach ($opts as $opt => $val) { |
|
| 154 | + curl_setopt($curl, $opt, $val); |
|
| 155 | + } |
|
| 155 | 156 | |
| 156 | 157 | $this->last_request = array( |
| 157 | 158 | 'url' => $url |
| 158 | 159 | ); |
| 159 | 160 | |
| 160 | - if (isset($opts[CURLOPT_CUSTOMREQUEST])) |
|
| 161 | - $this->last_request['method'] = $opts[CURLOPT_CUSTOMREQUEST]; |
|
| 162 | - else |
|
| 163 | - $this->last_request['method'] = 'GET'; |
|
| 161 | + if (isset($opts[CURLOPT_CUSTOMREQUEST])) { |
|
| 162 | + $this->last_request['method'] = $opts[CURLOPT_CUSTOMREQUEST]; |
|
| 163 | + } else { |
|
| 164 | + $this->last_request['method'] = 'GET'; |
|
| 165 | + } |
|
| 164 | 166 | |
| 165 | - if (isset($opts[CURLOPT_POSTFIELDS])) |
|
| 166 | - $this->last_request['data'] = $opts[CURLOPT_POSTFIELDS]; |
|
| 167 | + if (isset($opts[CURLOPT_POSTFIELDS])) { |
|
| 168 | + $this->last_request['data'] = $opts[CURLOPT_POSTFIELDS]; |
|
| 169 | + } |
|
| 167 | 170 | |
| 168 | 171 | return $curl; |
| 169 | 172 | } |
@@ -261,14 +264,16 @@ discard block |
||
| 261 | 264 | */ |
| 262 | 265 | protected function checkLastResponseForError() |
| 263 | 266 | { |
| 264 | - if (!$this->throw_exceptions) |
|
| 265 | - return; |
|
| 267 | + if (!$this->throw_exceptions) { |
|
| 268 | + return; |
|
| 269 | + } |
|
| 266 | 270 | |
| 267 | 271 | $meta = $this->last_response['meta']; |
| 268 | 272 | $body = $this->last_response['body']; |
| 269 | 273 | |
| 270 | - if ($meta === false) |
|
| 271 | - return; |
|
| 274 | + if ($meta === false) { |
|
| 275 | + return; |
|
| 276 | + } |
|
| 272 | 277 | |
| 273 | 278 | $err = null; |
| 274 | 279 | switch ($meta['http_code']) { |
@@ -302,10 +307,11 @@ discard block |
||
| 302 | 307 | throw new Pest_InvalidRecord($this->processError($body)); |
| 303 | 308 | break; |
| 304 | 309 | default: |
| 305 | - if ($meta['http_code'] >= 400 && $meta['http_code'] <= 499) |
|
| 306 | - throw new Pest_ClientError($this->processError($body)); |
|
| 307 | - elseif ($meta['http_code'] >= 500 && $meta['http_code'] <= 599) |
|
| 308 | - throw new Pest_ServerError($this->processError($body)); elseif (!isset($meta['http_code']) || $meta['http_code'] >= 600) { |
|
| 310 | + if ($meta['http_code'] >= 400 && $meta['http_code'] <= 499) { |
|
| 311 | + throw new Pest_ClientError($this->processError($body)); |
|
| 312 | + } elseif ($meta['http_code'] >= 500 && $meta['http_code'] <= 599) { |
|
| 313 | + throw new Pest_ServerError($this->processError($body)); |
|
| 314 | + } elseif (!isset($meta['http_code']) || $meta['http_code'] >= 600) { |
|
| 309 | 315 | throw new Pest_UnknownResponse($this->processError($body)); |
| 310 | 316 | } |
| 311 | 317 | } |
@@ -356,7 +362,9 @@ discard block |
||
| 356 | 362 | |
| 357 | 363 | $curl_opts = $this->curl_opts; |
| 358 | 364 | $curl_opts[CURLOPT_CUSTOMREQUEST] = 'POST'; |
| 359 | - if (!is_array($data)) $headers[] = 'Content-Length: ' . strlen($data); |
|
| 365 | + if (!is_array($data)) { |
|
| 366 | + $headers[] = 'Content-Length: ' . strlen($data); |
|
| 367 | + } |
|
| 360 | 368 | $curl_opts[CURLOPT_HTTPHEADER] = $this->prepHeaders($headers); |
| 361 | 369 | $curl_opts[CURLOPT_POSTFIELDS] = $data; |
| 362 | 370 | |
@@ -405,7 +413,9 @@ discard block |
||
| 405 | 413 | |
| 406 | 414 | $curl_opts = $this->curl_opts; |
| 407 | 415 | $curl_opts[CURLOPT_CUSTOMREQUEST] = 'PUT'; |
| 408 | - if (!is_array($data)) $headers[] = 'Content-Length: ' . strlen($data); |
|
| 416 | + if (!is_array($data)) { |
|
| 417 | + $headers[] = 'Content-Length: ' . strlen($data); |
|
| 418 | + } |
|
| 409 | 419 | $curl_opts[CURLOPT_HTTPHEADER] = $this->prepHeaders($headers); |
| 410 | 420 | $curl_opts[CURLOPT_POSTFIELDS] = $data; |
| 411 | 421 | |
@@ -456,7 +466,9 @@ discard block |
||
| 456 | 466 | |
| 457 | 467 | $curl_opts = $this->curl_opts; |
| 458 | 468 | $curl_opts[CURLOPT_CUSTOMREQUEST] = 'DELETE'; |
| 459 | - if (!is_array($data)) $headers[] = 'Content-Length: ' . strlen($data); |
|
| 469 | + if (!is_array($data)) { |
|
| 470 | + $headers[] = 'Content-Length: ' . strlen($data); |
|
| 471 | + } |
|
| 460 | 472 | $curl_opts[CURLOPT_HTTPHEADER] = $this->prepHeaders($headers); |
| 461 | 473 | $curl_opts[CURLOPT_POSTFIELDS] = $data; |
| 462 | 474 | |
@@ -34,6 +34,9 @@ |
||
| 34 | 34 | return $basePath; |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | + /** |
|
| 38 | + * @param string $absolutePath |
|
| 39 | + */ |
|
| 37 | 40 | function deletePath($absolutePath) { |
| 38 | 41 | $dirs = array(); |
| 39 | 42 | $paths = array(); |
@@ -208,6 +208,9 @@ |
||
| 208 | 208 | // |
| 209 | 209 | // arg0: string version of php to check against |
| 210 | 210 | // return boolean true if $version is >= current php version |
| 211 | +/** |
|
| 212 | + * @param string $version |
|
| 213 | + */ |
|
| 211 | 214 | function check_php_version($version) { |
| 212 | 215 | // intval used for version like "4.0.4pl1" |
| 213 | 216 | $testVer=intval(str_replace(".", "",$version)); |
@@ -6,10 +6,10 @@ discard block |
||
| 6 | 6 | global $_SESSION; |
| 7 | 7 | if (!isset($_SESSION['phpical_loggedin']) || $_SESSION['phpical_loggedin'] == FALSE) { |
| 8 | 8 | return FALSE; |
| 9 | + } else { |
|
| 10 | + return TRUE; |
|
| 11 | + } |
|
| 9 | 12 | } |
| 10 | - else |
|
| 11 | - return TRUE; |
|
| 12 | -} |
|
| 13 | 13 | |
| 14 | 14 | // Attempt to login. If login is valid, set the session variable 'phpical_loggedin' to TRUE and store the username and password in the session |
| 15 | 15 | // |
@@ -51,7 +51,9 @@ discard block |
||
| 51 | 51 | |
| 52 | 52 | // set up basic connection |
| 53 | 53 | $conn_id = @ftp_connect($phpiCal_config->ftp_server, $phpiCal_config->ftp_port); |
| 54 | - if (!$conn_id) exit(error('Cannot connect to FTP server', $filename)); |
|
| 54 | + if (!$conn_id) { |
|
| 55 | + exit(error('Cannot connect to FTP server', $filename)); |
|
| 56 | + } |
|
| 55 | 57 | // login with username and password |
| 56 | 58 | $login_result = @ftp_login($conn_id, $username, $password); |
| 57 | 59 | |
@@ -74,11 +76,12 @@ discard block |
||
| 74 | 76 | function login_internal ($username, $password) { |
| 75 | 77 | global $phpiCal_config; |
| 76 | 78 | |
| 77 | - if ($phpiCal_config->auth_internal_username == $username && $phpiCal_config->auth_internal_password == $password) |
|
| 78 | - return TRUE; |
|
| 79 | - else |
|
| 80 | - return FALSE; |
|
| 81 | -} |
|
| 79 | + if ($phpiCal_config->auth_internal_username == $username && $phpiCal_config->auth_internal_password == $password) { |
|
| 80 | + return TRUE; |
|
| 81 | + } else { |
|
| 82 | + return FALSE; |
|
| 83 | + } |
|
| 84 | + } |
|
| 82 | 85 | |
| 83 | 86 | // Delete a calendar. If using ftp for authentication, use ftp to delete. Otherwise, use file system functions. |
| 84 | 87 | // |
@@ -100,15 +103,17 @@ discard block |
||
| 100 | 103 | $login_result = @ftp_login($conn_id, $_SESSION['phpical_username'], $_SESSION['phpical_password']); |
| 101 | 104 | |
| 102 | 105 | // check connection |
| 103 | - if ((!$conn_id) || (!$login_result)) |
|
| 104 | - return FALSE; |
|
| 106 | + if ((!$conn_id) || (!$login_result)) { |
|
| 107 | + return FALSE; |
|
| 108 | + } |
|
| 105 | 109 | |
| 106 | 110 | // delete the file |
| 107 | 111 | $delete = @ftp_delete($conn_id, $filename); |
| 108 | 112 | |
| 109 | 113 | // check delete status |
| 110 | - if (!$delete) |
|
| 111 | - return FALSE; |
|
| 114 | + if (!$delete) { |
|
| 115 | + return FALSE; |
|
| 116 | + } |
|
| 112 | 117 | |
| 113 | 118 | // close the FTP stream |
| 114 | 119 | @ftp_close($conn_id); |
@@ -131,8 +136,7 @@ discard block |
||
| 131 | 136 | clearstatcache(); |
| 132 | 137 | if (@file_exists($filename)) { |
| 133 | 138 | return FALSE; |
| 134 | - } |
|
| 135 | - else { |
|
| 139 | + } else { |
|
| 136 | 140 | return TRUE; |
| 137 | 141 | } |
| 138 | 142 | |
@@ -161,28 +165,28 @@ discard block |
||
| 161 | 165 | $login_result = ftp_login($conn_id, $_SESSION['phpical_username'], $_SESSION['phpical_password']); |
| 162 | 166 | |
| 163 | 167 | // check connection |
| 164 | - if ((!$conn_id) || (!$login_result)) |
|
| 165 | - return FALSE; |
|
| 168 | + if ((!$conn_id) || (!$login_result)) { |
|
| 169 | + return FALSE; |
|
| 170 | + } |
|
| 166 | 171 | |
| 167 | 172 | // upload the file |
| 168 | 173 | $upload = ftp_put($conn_id, $destination, $source, FTP_ASCII); |
| 169 | 174 | |
| 170 | 175 | // check upload status |
| 171 | - if (!$upload) |
|
| 172 | - return FALSE; |
|
| 176 | + if (!$upload) { |
|
| 177 | + return FALSE; |
|
| 178 | + } |
|
| 173 | 179 | |
| 174 | 180 | // close the FTP stream |
| 175 | 181 | ftp_close($conn_id); |
| 176 | 182 | |
| 177 | 183 | return TRUE; |
| 178 | - } |
|
| 179 | - else { |
|
| 184 | + } else { |
|
| 180 | 185 | $destination = $calendar_path . "/" . basename($destination); |
| 181 | 186 | |
| 182 | 187 | if (check_php_version('4.0.3')) { |
| 183 | 188 | return move_uploaded_file($source, $destination); |
| 184 | - } |
|
| 185 | - else { |
|
| 189 | + } else { |
|
| 186 | 190 | return copy($source, $destination); |
| 187 | 191 | } |
| 188 | 192 | } |
@@ -197,9 +201,9 @@ discard block |
||
| 197 | 201 | global $phpiCal_config; |
| 198 | 202 | global $calendar_path; |
| 199 | 203 | |
| 200 | - if ($phpiCal_config->ftp_calendar_path != '') |
|
| 201 | - return $phpiCal_config->ftp_calendar_path; |
|
| 202 | - else { |
|
| 204 | + if ($phpiCal_config->ftp_calendar_path != '') { |
|
| 205 | + return $phpiCal_config->ftp_calendar_path; |
|
| 206 | + } else { |
|
| 203 | 207 | return str_replace ("\\", "/", realpath($calendar_path)); |
| 204 | 208 | } |
| 205 | 209 | } |
@@ -212,8 +216,9 @@ discard block |
||
| 212 | 216 | // intval used for version like "4.0.4pl1" |
| 213 | 217 | $testVer=intval(str_replace(".", "",$version)); |
| 214 | 218 | $curVer=intval(str_replace(".", "",phpversion())); |
| 215 | - if( $curVer < $testVer ) |
|
| 216 | - return FALSE; |
|
| 219 | + if( $curVer < $testVer ) { |
|
| 220 | + return FALSE; |
|
| 221 | + } |
|
| 217 | 222 | return TRUE; |
| 218 | 223 | } |
| 219 | 224 | |
@@ -257,8 +262,7 @@ discard block |
||
| 257 | 262 | $error = $error . $upload_error . ": " . $upload_error_gen_lang; |
| 258 | 263 | break; |
| 259 | 264 | } |
| 260 | - } |
|
| 261 | - else { |
|
| 265 | + } else { |
|
| 262 | 266 | $error = $upload_error_gen_lang; |
| 263 | 267 | } |
| 264 | 268 | |
@@ -273,8 +277,7 @@ discard block |
||
| 273 | 277 | // Check the file extension for .ics. Can also check the the mime type, but it's not reliable so why bother... |
| 274 | 278 | if(preg_match("/.ics$/i", $filename)) { |
| 275 | 279 | return TRUE; |
| 276 | - } |
|
| 277 | - else { |
|
| 280 | + } else { |
|
| 278 | 281 | return FALSE; |
| 279 | 282 | } |
| 280 | 283 | } |
@@ -75,6 +75,9 @@ discard block |
||
| 75 | 75 | * Resolve relative paths |
| 76 | 76 | * Utility function for remote_filemtime() |
| 77 | 77 | */ |
| 78 | +/** |
|
| 79 | + * @param string $rel_path |
|
| 80 | + */ |
|
| 78 | 81 | function resolve_path($url, $rel_path) { |
| 79 | 82 | if (parse_url($rel_path) !== FALSE) { |
| 80 | 83 | // Path is a URL |
@@ -224,6 +227,9 @@ discard block |
||
| 224 | 227 | // $have is the current offset (ie, '-0500') |
| 225 | 228 | // $want is the wanted offset (ie, '-0700') |
| 226 | 229 | // $time is the unixtime relative to $have |
| 230 | +/** |
|
| 231 | + * @param integer $time |
|
| 232 | + */ |
|
| 227 | 233 | function calcTime($have, $want, $time) { |
| 228 | 234 | if ($have == 'none' || $want == 'none') return $time; |
| 229 | 235 | $have_secs = calcOffset($have); |
@@ -233,6 +239,9 @@ discard block |
||
| 233 | 239 | return $time; |
| 234 | 240 | } |
| 235 | 241 | |
| 242 | +/** |
|
| 243 | + * @param integer $time |
|
| 244 | + */ |
|
| 236 | 245 | function chooseOffset($time, $timezone = '') { |
| 237 | 246 | global $tz_array, $summary; |
| 238 | 247 | switch ($timezone) { |
@@ -12,11 +12,15 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | function remote_filemtime($url, $recurse = 0) { |
| 14 | 14 | // We hate infinite loops! |
| 15 | - if (++$recurse > 5) return 0; |
|
| 15 | + if (++$recurse > 5) { |
|
| 16 | + return 0; |
|
| 17 | + } |
|
| 16 | 18 | |
| 17 | 19 | // Caching the remote mtime is a Really Good Idea. |
| 18 | 20 | static $remote_files = array(); |
| 19 | - if (isset($remote_files[$url])) return $remote_files[$url]; |
|
| 21 | + if (isset($remote_files[$url])) { |
|
| 22 | + return $remote_files[$url]; |
|
| 23 | + } |
|
| 20 | 24 | |
| 21 | 25 | $uri = parse_url($url); |
| 22 | 26 | $uri['proto'] = ( |
@@ -44,7 +48,9 @@ discard block |
||
| 44 | 48 | $headers = array(); |
| 45 | 49 | while (!feof($handle)) { |
| 46 | 50 | $line = trim(fgets($handle, 1024)); |
| 47 | - if (empty($line)) break; |
|
| 51 | + if (empty($line)) { |
|
| 52 | + break; |
|
| 53 | + } |
|
| 48 | 54 | $headers[] = $line; |
| 49 | 55 | } |
| 50 | 56 | fclose($handle); |
@@ -64,7 +70,9 @@ discard block |
||
| 64 | 70 | $result = strtotime($value); |
| 65 | 71 | break; |
| 66 | 72 | } |
| 67 | - if ($result) break; |
|
| 73 | + if ($result) { |
|
| 74 | + break; |
|
| 75 | + } |
|
| 68 | 76 | } |
| 69 | 77 | |
| 70 | 78 | $remote_files[$url] = $result; |
@@ -121,7 +129,9 @@ discard block |
||
| 121 | 129 | function dateOfWeek($Ymd, $day) { |
| 122 | 130 | global $phpiCal_config; |
| 123 | 131 | $week_start_day = 'Sunday'; |
| 124 | - if (isset($phpiCal_config->week_start_day)) $week_start_day = $phpiCal_config->week_start_day; |
|
| 132 | + if (isset($phpiCal_config->week_start_day)) { |
|
| 133 | + $week_start_day = $phpiCal_config->week_start_day; |
|
| 134 | + } |
|
| 125 | 135 | $timestamp = strtotime($Ymd); |
| 126 | 136 | $num = date('w', strtotime($week_start_day)); |
| 127 | 137 | $start_day_time = strtotime((date('w',$timestamp)==$num ? "$week_start_day" : "last $week_start_day"), $timestamp); |
@@ -216,7 +226,9 @@ discard block |
||
| 216 | 226 | $hours = substr($offset_str, 1, 2); |
| 217 | 227 | $mins = substr($offset_str, 3, 2); |
| 218 | 228 | $secs = ((int)$hours * 3600) + ((int)$mins * 60); |
| 219 | - if ($sign == '-') $secs = 0 - $secs; |
|
| 229 | + if ($sign == '-') { |
|
| 230 | + $secs = 0 - $secs; |
|
| 231 | + } |
|
| 220 | 232 | return $secs; |
| 221 | 233 | } |
| 222 | 234 | |
@@ -225,7 +237,9 @@ discard block |
||
| 225 | 237 | // $want is the wanted offset (ie, '-0700') |
| 226 | 238 | // $time is the unixtime relative to $have |
| 227 | 239 | function calcTime($have, $want, $time) { |
| 228 | - if ($have == 'none' || $want == 'none') return $time; |
|
| 240 | + if ($have == 'none' || $want == 'none') { |
|
| 241 | + return $time; |
|
| 242 | + } |
|
| 229 | 243 | $have_secs = calcOffset($have); |
| 230 | 244 | $want_secs = calcOffset($want); |
| 231 | 245 | $diff = $want_secs - $have_secs; |
@@ -265,12 +279,16 @@ discard block |
||
| 265 | 279 | $start = localizeDate($dateFormat_week, $arr['start_unixtime']); |
| 266 | 280 | $end = localizeDate($dateFormat_week, ($arr['end_unixtime'] - 60)); |
| 267 | 281 | $title = $event_text; |
| 268 | - if ($start != $end) $title .= "\n$start - $end"; |
|
| 282 | + if ($start != $end) { |
|
| 283 | + $title .= "\n$start - $end"; |
|
| 284 | + } |
|
| 269 | 285 | } else { |
| 270 | 286 | $start = date($timeFormat, $arr['start_unixtime']); |
| 271 | 287 | $end = date($timeFormat, $arr['end_unixtime']); |
| 272 | 288 | $title = "$start: $event_text"; |
| 273 | - if ($start != $end) $title = "$event_text\n$start - $end"; |
|
| 289 | + if ($start != $end) { |
|
| 290 | + $title = "$event_text\n$start - $end"; |
|
| 291 | + } |
|
| 274 | 292 | } |
| 275 | 293 | |
| 276 | 294 | if (!empty($arr['location'])) { |
@@ -314,7 +332,9 @@ discard block |
||
| 314 | 332 | $event_text = strip_tags($event_text, '<b><i><u><img>'); |
| 315 | 333 | } |
| 316 | 334 | |
| 317 | - if (!empty($link_class)) $link_class = ' class="'.$link_class.'"'; |
|
| 335 | + if (!empty($link_class)) { |
|
| 336 | + $link_class = ' class="'.$link_class.'"'; |
|
| 337 | + } |
|
| 318 | 338 | |
| 319 | 339 | if (!empty($event_text)) { |
| 320 | 340 | $title = strip_tags(str_replace('<br />',"\n",$title)); |
@@ -360,7 +380,9 @@ discard block |
||
| 360 | 380 | $allday =''; #suppress error on returning undef. |
| 361 | 381 | // Check for zulu time. |
| 362 | 382 | $zulu_time = false; |
| 363 | - if (substr($data,-1) == 'Z') $zulu_time = true; |
|
| 383 | + if (substr($data,-1) == 'Z') { |
|
| 384 | + $zulu_time = true; |
|
| 385 | + } |
|
| 364 | 386 | // Pull out the timezone, or use GMT if zulu time was indicated. |
| 365 | 387 | if (preg_match('/^'.$property.';TZID=/i', $field)) { |
| 366 | 388 | $tz_tmp = explode('=', $field); |
@@ -384,7 +406,9 @@ discard block |
||
| 384 | 406 | // Extract date-time values. |
| 385 | 407 | // Pull out the date and time values. Minimum year is 1970. |
| 386 | 408 | preg_match ('/([0-9]{4})([0-9]{2})([0-9]{2})T{0,1}([0-9]{0,2})([0-9]{0,2})/', $data, $regs); |
| 387 | - if (!isset ($regs[1])) return; |
|
| 409 | + if (!isset ($regs[1])) { |
|
| 410 | + return; |
|
| 411 | + } |
|
| 388 | 412 | if ($regs[1] < 1970) { |
| 389 | 413 | $regs[1] = '1970'; |
| 390 | 414 | } |
@@ -403,10 +427,14 @@ discard block |
||
| 403 | 427 | $tz_dt = $phpiCal_config->timezone; |
| 404 | 428 | } |
| 405 | 429 | // Set the values. |
| 406 | - if ($allday == '') $unixtime = calcTime($offset_tmp, $server_offset_tmp, $unixtime); |
|
| 430 | + if ($allday == '') { |
|
| 431 | + $unixtime = calcTime($offset_tmp, $server_offset_tmp, $unixtime); |
|
| 432 | + } |
|
| 407 | 433 | #echo "offset_tmp $offset_tmp, server_offset_tmp $server_offset_tmp, $unixtime =".date("Ymd His",$unixtime)." $time<br>"; |
| 408 | 434 | $date = date('Ymd', $unixtime); |
| 409 | - if ($allday == '') $time = date('Hi', $unixtime); |
|
| 435 | + if ($allday == '') { |
|
| 436 | + $time = date('Hi', $unixtime); |
|
| 437 | + } |
|
| 410 | 438 | |
| 411 | 439 | // Return the results. |
| 412 | 440 | return array($unixtime, $date, $time, $allday, $tz_dt); |
@@ -420,9 +448,13 @@ discard block |
||
| 420 | 448 | */ |
| 421 | 449 | function match_tz($data){ |
| 422 | 450 | global $tz_array; |
| 423 | - if (isset($tz_array[$data])) return $data; |
|
| 451 | + if (isset($tz_array[$data])) { |
|
| 452 | + return $data; |
|
| 453 | + } |
|
| 424 | 454 | foreach ($tz_array as $key=>$val){ |
| 425 | - if (strpos(" $data",$key) > 0) return $key; |
|
| 455 | + if (strpos(" $data",$key) > 0) { |
|
| 456 | + return $key; |
|
| 457 | + } |
|
| 426 | 458 | } |
| 427 | 459 | return $data; |
| 428 | 460 | }?> |
| 429 | 461 | \ No newline at end of file |
@@ -38,6 +38,9 @@ discard block |
||
| 38 | 38 | |
| 39 | 39 | // word wrap function that returns specified number of lines |
| 40 | 40 | // when lines is 0, it returns the entire string as wordwrap() does it |
| 41 | +/** |
|
| 42 | + * @param integer $length |
|
| 43 | + */ |
|
| 41 | 44 | function word_wrap($str, $length, $lines=0) { |
| 42 | 45 | if ($lines > 0) { |
| 43 | 46 | $len = $length * $lines; |
@@ -51,6 +54,10 @@ discard block |
||
| 51 | 54 | |
| 52 | 55 | // String intercept By Bleakwind |
| 53 | 56 | // utf-8:$byte=3 | gb2312:$byte=2 | big5:$byte=2 |
| 57 | +/** |
|
| 58 | + * @param integer $start |
|
| 59 | + * @param double $len |
|
| 60 | + */ |
|
| 54 | 61 | function bite_str($string, $start, $len, $byte=3){ |
| 55 | 62 | $str = ""; |
| 56 | 63 | $count = 0; |
@@ -35,6 +35,7 @@ discard block |
||
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | 37 | * Truncate a string to a specific number of words |
| 38 | + * @param integer $count |
|
| 38 | 39 | */ |
| 39 | 40 | function chopToWordCount($string, $count) { |
| 40 | 41 | $wc = str_word_count($string); |
@@ -49,6 +50,7 @@ discard block |
||
| 49 | 50 | |
| 50 | 51 | /** |
| 51 | 52 | * Strip "dangerous" HTML to make it safe to print to web browsers |
| 53 | + * @param string $string |
|
| 52 | 54 | */ |
| 53 | 55 | function sanitizeForWeb($string) { |
| 54 | 56 | $string = preg_replace('/<br\s*\/?>/', "\n", $string); |
@@ -90,11 +90,15 @@ discard block |
||
| 90 | 90 | switch ($key){ |
| 91 | 91 | case 'action': |
| 92 | 92 | $actions = array('login','logout','addupdate','delete'); |
| 93 | - if (!in_array($val,$actions)) $val = ''; |
|
| 93 | + if (!in_array($val,$actions)) { |
|
| 94 | + $val = ''; |
|
| 95 | + } |
|
| 94 | 96 | break; |
| 95 | 97 | case 'date': |
| 96 | 98 | case 'time': |
| 97 | - if (!is_numeric($val)) $val = ''; |
|
| 99 | + if (!is_numeric($val)) { |
|
| 100 | + $val = ''; |
|
| 101 | + } |
|
| 98 | 102 | break; |
| 99 | 103 | default: |
| 100 | 104 | $val = recursiveSanitize($val); |
@@ -108,7 +112,7 @@ discard block |
||
| 108 | 112 | if (!is_array($val)){ |
| 109 | 113 | $val = strip_tags($val); |
| 110 | 114 | $_GET['cal'] = strip_tags($val); |
| 111 | - }else{ |
|
| 115 | + } else{ |
|
| 112 | 116 | unset ($_GET['cal']); |
| 113 | 117 | foreach($val as $cal){ |
| 114 | 118 | $_GET['cal'][]= strip_tags($cal); |
@@ -116,18 +120,24 @@ discard block |
||
| 116 | 120 | } |
| 117 | 121 | break; |
| 118 | 122 | case 'getdate': |
| 119 | - if (!is_numeric($val)) $val = ''; |
|
| 123 | + if (!is_numeric($val)) { |
|
| 124 | + $val = ''; |
|
| 125 | + } |
|
| 120 | 126 | break; |
| 121 | 127 | default: |
| 122 | 128 | $val = recursiveSanitize($val); |
| 123 | 129 | } |
| 124 | - if ($key != 'cal') $_GET[$key] = $val; |
|
| 130 | + if ($key != 'cal') { |
|
| 131 | + $_GET[$key] = $val; |
|
| 132 | + } |
|
| 125 | 133 | |
| 126 | 134 | } |
| 127 | 135 | foreach ($_COOKIE as $key=>$val){ |
| 128 | 136 | switch ($key){ |
| 129 | 137 | case 'time': |
| 130 | - if (!is_numeric($val)) $val = ''; |
|
| 138 | + if (!is_numeric($val)) { |
|
| 139 | + $val = ''; |
|
| 140 | + } |
|
| 131 | 141 | break; |
| 132 | 142 | default: |
| 133 | 143 | $val = recursiveSanitize($val); |
@@ -2,6 +2,9 @@ |
||
| 2 | 2 | /* values are offset in hhmm (not seconds!) relative to GMT |
| 3 | 3 | case The first value is for standard, and the second value is for daylight |
| 4 | 4 | */ |
| 5 | +/** |
|
| 6 | + * @param string $timezone |
|
| 7 | + */ |
|
| 5 | 8 | function is_daylight($time, $timezone){ |
| 6 | 9 | global $tz_array, $summary; |
| 7 | 10 | # default to std time, overwrite if daylight. |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | if(isset($tz_array[$timezone]['dt_start'][$year]) && isset($tz_array[$timezone]['st_start'][$year])){ |
| 17 | 17 | $start = $tz_array[$timezone]['dt_start'][$year]; |
| 18 | 18 | $end = $tz_array[$timezone]['st_start'][$year]; |
| 19 | - }else{ |
|
| 19 | + } else{ |
|
| 20 | 20 | switch ($timezone){ |
| 21 | 21 | case 'US/Samoa': # array('-1100', '-1100'); |
| 22 | 22 | case 'America/Adak': # array('-1000', '-0900'); |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | if ($year < 2007){ |
| 84 | 84 | $start = strtotime("+1 Sun",strtotime($year."0331")); |
| 85 | 85 | $end = strtotime("-1 Sun",strtotime($year."1101")); |
| 86 | - }else{ |
|
| 86 | + } else{ |
|
| 87 | 87 | $start = strtotime("+2 Sun",strtotime($year."0300")); |
| 88 | 88 | $end = strtotime("+1 Sun",strtotime($year."1031")); |
| 89 | 89 | } |
@@ -287,7 +287,9 @@ discard block |
||
| 287 | 287 | $dlst = date('I', $time); |
| 288 | 288 | } |
| 289 | 289 | } |
| 290 | - if (isset($start,$end) && $time >= $start && $time < $end) $dlst = 1; |
|
| 290 | + if (isset($start,$end) && $time >= $start && $time < $end) { |
|
| 291 | + $dlst = 1; |
|
| 292 | + } |
|
| 291 | 293 | #echo "$summary $dlst <br>"; |
| 292 | 294 | |
| 293 | 295 | return $dlst; |
@@ -1,6 +1,9 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | // function to determine maximum necessary columns per day |
| 3 | 3 | // actually an algorithm to get the smallest multiple for two numbers |
| 4 | +/** |
|
| 5 | + * @param integer $b |
|
| 6 | + */ |
|
| 4 | 7 | function kgv($a, $b) { |
| 5 | 8 | $x = $a; |
| 6 | 9 | $y = $b; |
@@ -5,8 +5,11 @@ discard block |
||
| 5 | 5 | $x = $a; |
| 6 | 6 | $y = $b; |
| 7 | 7 | while ($x != $y) { |
| 8 | - if ($x < $y) $x += $a; |
|
| 9 | - else $y += $b; |
|
| 8 | + if ($x < $y) { |
|
| 9 | + $x += $a; |
|
| 10 | + } else { |
|
| 11 | + $y += $b; |
|
| 12 | + } |
|
| 10 | 13 | } |
| 11 | 14 | return $x; |
| 12 | 15 | } |
@@ -63,8 +66,9 @@ discard block |
||
| 63 | 66 | |
| 64 | 67 | $count = 0; |
| 65 | 68 | foreach ($ol_ranges as $loop_range) { |
| 66 | - if ($count < $loop_range['count']) |
|
| 67 | - $count = $loop_range['count']; |
|
| 69 | + if ($count < $loop_range['count']) { |
|
| 70 | + $count = $loop_range['count']; |
|
| 71 | + } |
|
| 68 | 72 | } |
| 69 | 73 | |
| 70 | 74 | return $count; |
@@ -87,8 +91,12 @@ discard block |
||
| 87 | 91 | // check if blocks overlap |
| 88 | 92 | if (($loop_block['blockStart'] < $new_block['blockEnd']) && ($loop_block['blockEnd'] > $new_block['blockStart'])) { |
| 89 | 93 | // define start and end of merged overlap block |
| 90 | - if ($new_block['blockStart'] > $loop_block['blockStart']) $ol_blocks[$new_block_key]['blockStart'] = $loop_block['blockStart']; |
|
| 91 | - if ($new_block['blockEnd'] < $loop_block['blockEnd']) $ol_blocks[$new_block_key]['blockEnd'] = $loop_block['blockEnd']; |
|
| 94 | + if ($new_block['blockStart'] > $loop_block['blockStart']) { |
|
| 95 | + $ol_blocks[$new_block_key]['blockStart'] = $loop_block['blockStart']; |
|
| 96 | + } |
|
| 97 | + if ($new_block['blockEnd'] < $loop_block['blockEnd']) { |
|
| 98 | + $ol_blocks[$new_block_key]['blockEnd'] = $loop_block['blockEnd']; |
|
| 99 | + } |
|
| 92 | 100 | $ol_blocks[$new_block_key]['events'] = array_merge($new_block['events'], $loop_block['events']); |
| 93 | 101 | $new_block['events'] = $ol_blocks[$new_block_key]['events']; |
| 94 | 102 | foreach ($loop_block['overlapRanges'] as $ol_range) { |
@@ -134,7 +142,9 @@ discard block |
||
| 134 | 142 | // 'end' - end_time for the overlap block. |
| 135 | 143 | function checkOverlap($event_date, $event_time, $uid) { |
| 136 | 144 | global $master_array, $overlap_array; |
| 137 | - if (!isset($event_date)) return; |
|
| 145 | + if (!isset($event_date)) { |
|
| 146 | + return; |
|
| 147 | + } |
|
| 138 | 148 | $event = $master_array[$event_date][$event_time][$uid]; |
| 139 | 149 | // Copy out the array - we replace this at the end. |
| 140 | 150 | $ol_day_array = @$overlap_array[$event_date]; |
@@ -150,8 +160,12 @@ discard block |
||
| 150 | 160 | // ... unless it's already in the $ol_block |
| 151 | 161 | if (!in_array(array('time' => $drawTimes['draw_start'], 'key' => $uid), $loop_ol_block['events'])) { |
| 152 | 162 | $loop_ol_block['events'][] = array('time' => $drawTimes['draw_start'], 'key' => $uid); |
| 153 | - if ($loop_ol_block['blockStart'] > $drawTimes['draw_start']) $loop_ol_block['blockStart'] = $drawTimes['draw_start']; |
|
| 154 | - if ($loop_ol_block['blockEnd'] < $drawTimes['draw_end']) $loop_ol_block['blockEnd'] = $drawTimes['draw_end']; |
|
| 163 | + if ($loop_ol_block['blockStart'] > $drawTimes['draw_start']) { |
|
| 164 | + $loop_ol_block['blockStart'] = $drawTimes['draw_start']; |
|
| 165 | + } |
|
| 166 | + if ($loop_ol_block['blockEnd'] < $drawTimes['draw_end']) { |
|
| 167 | + $loop_ol_block['blockEnd'] = $drawTimes['draw_end']; |
|
| 168 | + } |
|
| 155 | 169 | |
| 156 | 170 | // Merge in the new overlap range |
| 157 | 171 | $loop_ol_block['overlapRanges'] = merge_range($loop_ol_block['overlapRanges'], $drawTimes['draw_start'], $drawTimes['draw_end']); |