@@ -5,31 +5,38 @@ discard block |
||
| 5 | 5 | $net = new \dautkom\ipv4\IPv4(); |
| 6 | 6 | |
| 7 | 7 | $_ = $_POST['genere']; |
| 8 | -if ( ($tables["$_"]['field']=='email') AND ($_POST['Value']!='ALL') ) |
|
| 8 | +if ( ($tables["$_"]['field']=='email') AND ($_POST['Value']!='ALL') ) { |
|
| 9 | 9 | if (!(filter_var($_POST['Value'], FILTER_VALIDATE_EMAIL))) |
| 10 | 10 | exit ('<pre><'.$_POST['Value'].'> is NOT a valid email address.</pre>'); |
| 11 | +} |
|
| 11 | 12 | |
| 12 | -if ( ($tables["$_"]['field']=='domain') AND ($_POST['Value']!='ALL') ) |
|
| 13 | +if ( ($tables["$_"]['field']=='domain') AND ($_POST['Value']!='ALL') ) { |
|
| 13 | 14 | if (!(filter_var(gethostbyname($_POST['Value']), FILTER_VALIDATE_IP))) |
| 14 | 15 | exit ('<pre><'.$_POST['Value'].'> is NOT a valid domain.</pre>'); |
| 16 | +} |
|
| 15 | 17 | |
| 16 | -if ( ($tables["$_"]['field']=='ip') AND ($_POST['Value']!='ALL') ) |
|
| 18 | +if ( ($tables["$_"]['field']=='ip') AND ($_POST['Value']!='ALL') ) { |
|
| 17 | 19 | if (!(filter_var($_POST['Value'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4))) |
| 18 | 20 | exit ('<pre><'.$_POST['Value'].'> is NOT a valid IP address.</pre>'); |
| 21 | +} |
|
| 19 | 22 | |
| 20 | 23 | if ( ($tables["$_"]['field']=='network') AND ($_POST['Value']!='ALL') ) { |
| 21 | 24 | $value = explode('/',$_POST['Value']); |
| 22 | - if (count($value) != 2) |
|
| 23 | - exit ('<pre><'.$_POST['Value'].'> is NOT a valid Network/Netmask pair.</pre>'); |
|
| 24 | - if (!$net->address($value[0])->mask($value[1])->isValid(1)) |
|
| 25 | - exit ('<pre><'.$_POST['Value'].'> is NOT a valid Network/Netmask.</pre>'); |
|
| 26 | -} |
|
| 25 | + if (count($value) != 2) { |
|
| 26 | + exit ('<pre><'.$_POST['Value'].'> is NOT a valid Network/Netmask pair.</pre>'); |
|
| 27 | + } |
|
| 28 | + if (!$net->address($value[0])->mask($value[1])->isValid(1)) { |
|
| 29 | + exit ('<pre><'.$_POST['Value'].'> is NOT a valid Network/Netmask.</pre>'); |
|
| 30 | + } |
|
| 31 | + } |
|
| 27 | 32 | |
| 28 | 33 | if ( ($tables["$_"]['field']=='username') AND ($_POST['Value']!='ALL') ) { |
| 29 | - if ( preg_match( '/[^\x20-\x7f]/', $_POST['Value']) ) |
|
| 30 | - exit('<pre><'.$_POST['Value'].'> contains NON ASCII chars.</pre>'); |
|
| 31 | - if ( preg_match( '/[$~=#*+%,{}()\/\\<>;:\"`\[\]&?\s]/', $_POST['Value']) ) |
|
| 32 | - exit('<pre><'.$_POST['Value'].'> contains invalid ASCII chars.</pre>'); |
|
| 34 | + if ( preg_match( '/[^\x20-\x7f]/', $_POST['Value']) ) { |
|
| 35 | + exit('<pre><'.$_POST['Value'].'> contains NON ASCII chars.</pre>'); |
|
| 36 | + } |
|
| 37 | + if ( preg_match( '/[$~=#*+%,{}()\/\\<>;:\"`\[\]&?\s]/', $_POST['Value']) ) { |
|
| 38 | + exit('<pre><'.$_POST['Value'].'> contains invalid ASCII chars.</pre>'); |
|
| 39 | + } |
|
| 33 | 40 | switch ( $_POST['Value'] ) { |
| 34 | 41 | case 'anonymous': |
| 35 | 42 | case 'anybody': |
@@ -40,9 +47,12 @@ discard block |
||
| 40 | 47 | } |
| 41 | 48 | |
| 42 | 49 | if (empty($_GET)) { |
| 43 | - if ($tables["$_"]['bl']) print "<p><i>$_</i> is a blocklist of ".$tables["$_"]['field'].'.</p>'; |
|
| 44 | - else print "<p><i>$_</i> is a whitelist of ".$tables["$_"]['field'].'.</p>'; |
|
| 45 | -} |
|
| 50 | + if ($tables["$_"]['bl']) { |
|
| 51 | + print "<p><i>$_</i> is a blocklist of ".$tables["$_"]['field'].'.</p>'; |
|
| 52 | + } else { |
|
| 53 | + print "<p><i>$_</i> is a whitelist of ".$tables["$_"]['field'].'.</p>'; |
|
| 54 | + } |
|
| 55 | + } |
|
| 46 | 56 | |
| 47 | 57 | openlog($tag, LOG_PID, $fac); |
| 48 | 58 | $user = username(); |
@@ -14,11 +14,14 @@ |
||
| 14 | 14 | require_once('function.php'); |
| 15 | 15 | |
| 16 | 16 | |
| 17 | -if ( $require_auth ) if ( username() == 'unknown' ) exit ("<p>You MUST configure your server to use authentication.</p>"); |
|
| 17 | +if ( $require_auth ) { |
|
| 18 | + if ( username() == 'unknown' ) exit ("<p>You MUST configure your server to use authentication.</p>"); |
|
| 19 | +} |
|
| 18 | 20 | |
| 19 | 21 | |
| 20 | -if ( $imapListActive ) |
|
| 22 | +if ( $imapListActive ) { |
|
| 21 | 23 | print ' <p style="text-align: right"><a href="/spamreport" target="_new">SPAM Learn Observer</a></p>'; |
| 24 | +} |
|
| 22 | 25 | |
| 23 | 26 | print <<<END |
| 24 | 27 | <form name="check" action="result.php" onSubmit="xmlhttpPost('result.php', 'check', 'Risultato', '<img src=\'/include/pleasewait.gif\'>'); return false;" enctype="text/plain" method="post" target="_self"> |
@@ -6,9 +6,12 @@ discard block |
||
| 6 | 6 | $table = $tables["$typedesc"]['name']; |
| 7 | 7 | |
| 8 | 8 | openlog($tag, LOG_PID, $fac); |
| 9 | -if (empty($_POST['reason'])) die ("<p>Please, specify a reason!</p>"); |
|
| 10 | -if (preg_match( '/[^\x20-\x7f]/', $_POST['reason'])) |
|
| 9 | +if (empty($_POST['reason'])) { |
|
| 10 | + die ("<p>Please, specify a reason!</p>"); |
|
| 11 | +} |
|
| 12 | +if (preg_match( '/[^\x20-\x7f]/', $_POST['reason'])) { |
|
| 11 | 13 | exit('<p>ERROR: <'.htmlentities($_POST['reason'],ENT_COMPAT | ENT_HTML401, 'ISO-8859-1').'> contains NON ASCII chars.</p>'); |
| 14 | +} |
|
| 12 | 15 | $user = username(); |
| 13 | 16 | |
| 14 | 17 | $mysqli = new mysqli($dbhost, $userdb, $pwd, $db, $dbport); |
@@ -20,10 +23,11 @@ discard block |
||
| 20 | 23 | } |
| 21 | 24 | syslog (LOG_INFO, $user.': Successfully connected to ' . $mysqli->host_info ); |
| 22 | 25 | |
| 23 | -if (addtolist ($mysqli,username(),$_POST['value'],$type,$table,$_POST['unit'],$_POST['quantity'],$_POST['reason'])) |
|
| 26 | +if (addtolist ($mysqli,username(),$_POST['value'],$type,$table,$_POST['unit'],$_POST['quantity'],$_POST['reason'])) { |
|
| 24 | 27 | print 'OK '.$_POST["type"].' <'.$_POST['value'].'> first time listed for '.$_POST['quantity'].$_POST['unit'].'.'; |
| 25 | -else |
|
| 28 | +} else { |
|
| 26 | 29 | print 'List operation ERROR; check log.'; |
| 30 | +} |
|
| 27 | 31 | $mysqli->close(); |
| 28 | 32 | closelog(); |
| 29 | 33 | ?> |
@@ -8,9 +8,12 @@ discard block |
||
| 8 | 8 | <td colspan="9" style="text-align: center"> |
| 9 | 9 | <?php |
| 10 | 10 | openlog($tag, LOG_PID, $fac); |
| 11 | -if (empty($_POST['reason'])) die ("Specify a reason, please!</td>"); |
|
| 12 | -if (preg_match( '/[^\x20-\x7f]/', $_POST['reason'])) |
|
| 11 | +if (empty($_POST['reason'])) { |
|
| 12 | + die ("Specify a reason, please!</td>"); |
|
| 13 | +} |
|
| 14 | +if (preg_match( '/[^\x20-\x7f]/', $_POST['reason'])) { |
|
| 13 | 15 | exit('ERROR: <'.htmlentities($_POST['reason'],ENT_COMPAT | ENT_HTML401, 'ISO-8859-1').'> contains NON ASCII chars.</td>'); |
| 16 | +} |
|
| 14 | 17 | $user = username(); |
| 15 | 18 | |
| 16 | 19 | $mysqli = new mysqli($dbhost, $userdb, $pwd, $db, $dbport); |
@@ -22,11 +25,14 @@ discard block |
||
| 22 | 25 | } |
| 23 | 26 | syslog(LOG_INFO, $user.': Successfully connected to ' . $mysqli->host_info) ; |
| 24 | 27 | |
| 25 | -if (isFull($mysqli,$typedesc,$tables)) die("ERROR in relist: ".htmlspecialchars("$typedesc has reached maximum value of ".$tables["$typedesc"]['limit'].' listed items.') ); |
|
| 26 | -if (relist ($mysqli,username(),$_POST['value'],$type,$table,$_POST['unit'],$_POST['quantity'],$_POST['reason'])) |
|
| 28 | +if (isFull($mysqli,$typedesc,$tables)) { |
|
| 29 | + die("ERROR in relist: ".htmlspecialchars("$typedesc has reached maximum value of ".$tables["$typedesc"]['limit'].' listed items.') ); |
|
| 30 | +} |
|
| 31 | +if (relist ($mysqli,username(),$_POST['value'],$type,$table,$_POST['unit'],$_POST['quantity'],$_POST['reason'])) { |
|
| 27 | 32 | print 'OK '.$_POST["type"].' <'.$_POST['value'].'> relisted for '.$_POST['quantity'].$_POST['unit']; |
| 28 | -else |
|
| 33 | +} else { |
|
| 29 | 34 | print 'ERROR in relist; check log'; |
| 35 | +} |
|
| 30 | 36 | $mysqli->close(); |
| 31 | 37 | closelog(); |
| 32 | 38 | print '</td>'; |
@@ -1,6 +1,9 @@ |
||
| 1 | 1 | <?php |
| 2 | -if (in_array($user,array_keys(array_filter($adm)))) $extopt = '<option value="MONTH">MONTHS</option><option value="YEAR">YEARS</option>'; |
|
| 3 | -else $extopt = NULL; |
|
| 2 | +if (in_array($user,array_keys(array_filter($adm)))) { |
|
| 3 | + $extopt = '<option value="MONTH">MONTHS</option><option value="YEAR">YEARS</option>'; |
|
| 4 | +} else { |
|
| 5 | + $extopt = NULL; |
|
| 6 | +} |
|
| 4 | 7 | ?> |
| 5 | 8 | <form style="margin:0; text-align: left;" name='ListButton<?php echo $type ?>' enctype="text/plain" method="post" target="_self" action="list.php" onSubmit="xmlhttpPost('list.php', 'ListButton<?php echo $type ?>', 'Risultato', '<img src=\'/include/pleasewait.gif\'>'); return false;" /> |
| 6 | 9 | |
@@ -12,8 +12,12 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | $shortopts = "c:"; // Required value |
| 14 | 14 | $options = getopt($shortopts); |
| 15 | -if ( !isset($options['c']) ) exit ("\n\nUSAGE: ${_SERVER['SCRIPT_NAME']} -c <file.conf>\n\n"); |
|
| 16 | -if ( !file_exists(dirname(__FILE__) . '/' . $options['c']) ) exit ("\n\nThe file <".$options['c']."> doesn't exists.\nExiting...\n\n"); |
|
| 15 | +if ( !isset($options['c']) ) { |
|
| 16 | + exit ("\n\nUSAGE: ${_SERVER['SCRIPT_NAME']} -c <file.conf>\n\n"); |
|
| 17 | +} |
|
| 18 | +if ( !file_exists(dirname(__FILE__) . '/' . $options['c']) ) { |
|
| 19 | + exit ("\n\nThe file <".$options['c']."> doesn't exists.\nExiting...\n\n"); |
|
| 20 | +} |
|
| 17 | 21 | |
| 18 | 22 | /************** Start of conf ************************/ |
| 19 | 23 | require_once('config.php'); |
@@ -77,14 +81,18 @@ discard block |
||
| 77 | 81 | $row = -1; |
| 78 | 82 | while (($data = fgetcsv($handle, 500, ',')) !== FALSE) { |
| 79 | 83 | $row++; |
| 80 | - if ($row == 0) continue; /* Skip heading line */ |
|
| 84 | + if ($row == 0) { |
|
| 85 | + continue; |
|
| 86 | + } |
|
| 87 | + /* Skip heading line */ |
|
| 81 | 88 | $thisVal = $data[1]; |
| 82 | 89 | unset($data[1]); |
| 83 | 90 | $data = array_values($data); |
| 84 | - if ( !in_array($thisVal,array_keys($tolist)) ) |
|
| 85 | - $tolist["$thisVal"] = $data; |
|
| 86 | - else if ($data[3]>$tolist[$thisVal][3]) |
|
| 87 | - $tolist["$thisVal"] = $data; |
|
| 91 | + if ( !in_array($thisVal,array_keys($tolist)) ) { |
|
| 92 | + $tolist["$thisVal"] = $data; |
|
| 93 | + } else if ($data[3]>$tolist[$thisVal][3]) { |
|
| 94 | + $tolist["$thisVal"] = $data; |
|
| 95 | + } |
|
| 88 | 96 | } |
| 89 | 97 | fclose($handle); |
| 90 | 98 | } |
@@ -115,17 +123,18 @@ discard block |
||
| 115 | 123 | $recip = emailToNotify($domainNotify_file,$domain); |
| 116 | 124 | $subject = sprintf('%s <%s> is now blocked because exceedes limits on outgoing emails', |
| 117 | 125 | $tables["$typedesc"]['field'], $value); |
| 118 | - if (!empty($recip)) |
|
| 119 | - if ( sendEmailWarn($tplfile,'[email protected]',$recip, |
|
| 126 | + if (!empty($recip)) { |
|
| 127 | + if ( sendEmailWarn($tplfile,'[email protected]',$recip, |
|
| 120 | 128 | $subject,$value,"$quantity $unit",$reason) ) |
| 121 | 129 | syslog(LOG_INFO, "$user: \"$recip\" was notified about the \"$value\" abuse."); |
| 130 | + } |
|
| 131 | + } else { |
|
| 132 | + syslog(LOG_ERR,"$user: <$domain> contains the '@' char. Notification cannot be sent."); |
|
| 122 | 133 | } |
| 123 | - else syslog(LOG_ERR,"$user: <$domain> contains the '@' char. Notification cannot be sent."); |
|
| 124 | 134 | } |
| 125 | 135 | } |
| 126 | 136 | } |
| 127 | - } |
|
| 128 | - else { |
|
| 137 | + } else { |
|
| 129 | 138 | $reason .= " But it has NOT been listed because it doesn't apply to the trigger condition."; |
| 130 | 139 | syslog (LOG_INFO, "$user: ".$reason); |
| 131 | 140 | } |
@@ -1,8 +1,9 @@ |
||
| 1 | 1 | #!/usr/bin/php |
| 2 | 2 | <?php |
| 3 | 3 | |
| 4 | -if (PHP_SAPI != "cli") |
|
| 4 | +if (PHP_SAPI != "cli") { |
|
| 5 | 5 | exit; |
| 6 | +} |
|
| 6 | 7 | |
| 7 | 8 | $home = '/var/www/html/RBL'; |
| 8 | 9 | require_once($home.'/config.php'); |
@@ -103,7 +103,9 @@ discard block |
||
| 103 | 103 | //$this->year_display_from_current = 50; |
| 104 | 104 | $this->date_picker = $date_picker; |
| 105 | 105 | |
| 106 | - if($timezone != "") $this->setTimezone($timezone); |
|
| 106 | + if($timezone != "") { |
|
| 107 | + $this->setTimezone($timezone); |
|
| 108 | + } |
|
| 107 | 109 | |
| 108 | 110 | //set default year display from current year |
| 109 | 111 | $thisyear = date('Y');
|
@@ -126,7 +128,9 @@ discard block |
||
| 126 | 128 | $days = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); |
| 127 | 129 | if($month > 0 && $year > 0){
|
| 128 | 130 | return ($month == 2 && $this->is_leapYear($year)) ? 29 : $days[$month-1]; |
| 129 | - }else return 31; |
|
| 131 | + } else { |
|
| 132 | + return 31; |
|
| 133 | + } |
|
| 130 | 134 | } |
| 131 | 135 | |
| 132 | 136 | //Deprecate since v1.6 |
@@ -143,7 +147,9 @@ discard block |
||
| 143 | 147 | $startdate = $this->startDate; |
| 144 | 148 | |
| 145 | 149 | for($i=0; $i<=6; $i++){
|
| 146 | - if($startdate >= sizeof($hdrs)) $startdate = 0; |
|
| 150 | + if($startdate >= sizeof($hdrs)) { |
|
| 151 | + $startdate = 0; |
|
| 152 | + } |
|
| 147 | 153 | //if(isset($hdrs[(string)$startdate])) |
| 148 | 154 | $rtn_hdrs[] = $hdrs[(string)$startdate]; |
| 149 | 155 | |
@@ -195,7 +201,9 @@ discard block |
||
| 195 | 201 | //specified location of the calendar_form.php |
| 196 | 202 | function setPath($path){
|
| 197 | 203 | $last_char = substr($path, strlen($path)-1, strlen($path)); |
| 198 | - if($last_char != "/") $path .= "/"; |
|
| 204 | + if($last_char != "/") { |
|
| 205 | + $path .= "/"; |
|
| 206 | + } |
|
| 199 | 207 | $this->path = $path; |
| 200 | 208 | } |
| 201 | 209 | |
@@ -233,9 +241,9 @@ discard block |
||
| 233 | 241 | |
| 234 | 242 | if($tz_sys_ms>=0 && $tz_new_ms<=0){
|
| 235 | 243 | $timezone_diff = 0-($tz_sys_ms+abs($tz_new_ms)); |
| 236 | - }elseif($tz_sys_ms<=0 && $tz_new_ms>=0){
|
|
| 244 | + } elseif($tz_sys_ms<=0 && $tz_new_ms>=0){
|
|
| 237 | 245 | $timezone_diff = abs($tz_sys_ms)+$tz_new_ms; |
| 238 | - }else{
|
|
| 246 | + } else{
|
|
| 239 | 247 | $timezone_diff = $tz_sys_ms-$tz_new_ms; |
| 240 | 248 | } |
| 241 | 249 | $timezone_diff_hr = $timezone_diff/3600; |
@@ -255,7 +263,7 @@ discard block |
||
| 255 | 263 | $this->year = date("Y", $n_time);
|
| 256 | 264 | $this->month = date("m", $n_time);
|
| 257 | 265 | $this->day = date("d", $n_time);
|
| 258 | - }else{
|
|
| 266 | + } else{
|
|
| 259 | 267 | $date = new DateTime($a_date, new DateTimeZone($this->system_timezone)); |
| 260 | 268 | $date->setTimezone(new DateTimeZone($this->timezone)); |
| 261 | 269 | $this->year = $date->format('Y');
|
@@ -276,7 +284,7 @@ discard block |
||
| 276 | 284 | $str .= $this->writeDay(); |
| 277 | 285 | $str .= $this->writeMonth(); |
| 278 | 286 | $str .= $this->writeYear(); |
| 279 | - }else{
|
|
| 287 | + } else{
|
|
| 280 | 288 | $str .= " <a href=\"javascript:toggleCalendar('".$this->objname."', ".$this->auto_hide.", ".$this->auto_hide_time.");\" class=\"tclabel\">";
|
| 281 | 289 | $str .= $this->writeDateContainer(); |
| 282 | 290 | $str .= "</a>"; |
@@ -285,19 +293,21 @@ discard block |
||
| 285 | 293 | $str .= " <a href=\"javascript:toggleCalendar('".$this->objname."', ".$this->auto_hide.", ".$this->auto_hide_time.");\">";
|
| 286 | 294 | if(is_file($this->icon)){
|
| 287 | 295 | $str .= "<img src=\"".$this->icon."\" id=\"tcbtn_".$this->objname."\" name=\"tcbtn_".$this->objname."\" border=\"0\" align=\"absmiddle\" style=\"vertical-align:middle;\" alt=\"".$this->txt."\" title=\"".$this->txt."\" />"; |
| 288 | - }else $str .= $this->txt; |
|
| 296 | + } else { |
|
| 297 | + $str .= $this->txt; |
|
| 298 | + } |
|
| 289 | 299 | $str .= "</a>"; |
| 290 | 300 | |
| 291 | 301 | $str .= $this->writeCalendarContainer(); |
| 292 | 302 | |
| 293 | 303 | $str .= "</div>"; |
| 294 | - }else{
|
|
| 304 | + } else{
|
|
| 295 | 305 | $str .= $this->writeCalendarContainer(); |
| 296 | 306 | } |
| 297 | 307 | |
| 298 | 308 | if($buffer){
|
| 299 | 309 | return $str; |
| 300 | - }else{
|
|
| 310 | + } else{
|
|
| 301 | 311 | echo($str); |
| 302 | 312 | } |
| 303 | 313 | } |
@@ -307,97 +317,157 @@ discard block |
||
| 307 | 317 | $params[] = "objname=".$this->objname; |
| 308 | 318 | |
| 309 | 319 | $param = $this->day; |
| 310 | - if($param != "") $params[] = "selected_day=".$param; |
|
| 320 | + if($param != "") { |
|
| 321 | + $params[] = "selected_day=".$param; |
|
| 322 | + } |
|
| 311 | 323 | |
| 312 | 324 | $param = $this->month; |
| 313 | - if($param != "") $params[] = "selected_month=".$param; |
|
| 325 | + if($param != "") { |
|
| 326 | + $params[] = "selected_month=".$param; |
|
| 327 | + } |
|
| 314 | 328 | |
| 315 | 329 | $param = $this->year; |
| 316 | - if($param != "") $params[] = "selected_year=".$param; |
|
| 330 | + if($param != "") { |
|
| 331 | + $params[] = "selected_year=".$param; |
|
| 332 | + } |
|
| 317 | 333 | |
| 318 | 334 | $param = $this->year_start_input; |
| 319 | - if($param != "") $params[] = "year_start=".$param; |
|
| 335 | + if($param != "") { |
|
| 336 | + $params[] = "year_start=".$param; |
|
| 337 | + } |
|
| 320 | 338 | |
| 321 | 339 | $param = $this->year_end_input; |
| 322 | - if($param != "") $params[] = "year_end=".$param; |
|
| 340 | + if($param != "") { |
|
| 341 | + $params[] = "year_end=".$param; |
|
| 342 | + } |
|
| 323 | 343 | |
| 324 | 344 | $param = ($this->date_picker) ? 1 : 0; |
| 325 | - if($param != "") $params[] = "dp=".$param; |
|
| 345 | + if($param != "") { |
|
| 346 | + $params[] = "dp=".$param; |
|
| 347 | + } |
|
| 326 | 348 | |
| 327 | 349 | $param = $this->time_allow1; |
| 328 | - if($param != "") $params[] = "da1=".$param; |
|
| 350 | + if($param != "") { |
|
| 351 | + $params[] = "da1=".$param; |
|
| 352 | + } |
|
| 329 | 353 | |
| 330 | 354 | $param = $this->time_allow2; |
| 331 | - if($param != "") $params[] = "da2=".$param; |
|
| 355 | + if($param != "") { |
|
| 356 | + $params[] = "da2=".$param; |
|
| 357 | + } |
|
| 332 | 358 | |
| 333 | 359 | $param = $this->show_not_allow; |
| 334 | - if($param != "") $params[] = "sna=".$param; |
|
| 360 | + if($param != "") { |
|
| 361 | + $params[] = "sna=".$param; |
|
| 362 | + } |
|
| 335 | 363 | |
| 336 | 364 | $param = $this->auto_submit; |
| 337 | - if($param != "") $params[] = "aut=".$param; |
|
| 365 | + if($param != "") { |
|
| 366 | + $params[] = "aut=".$param; |
|
| 367 | + } |
|
| 338 | 368 | |
| 339 | 369 | $param = $this->form_container; |
| 340 | - if($param != "") $params[] = "frm=".$param; |
|
| 370 | + if($param != "") { |
|
| 371 | + $params[] = "frm=".$param; |
|
| 372 | + } |
|
| 341 | 373 | |
| 342 | 374 | $param = $this->target_url; |
| 343 | - if($param != "") $params[] = "tar=".$param; |
|
| 375 | + if($param != "") { |
|
| 376 | + $params[] = "tar=".$param; |
|
| 377 | + } |
|
| 344 | 378 | |
| 345 | 379 | $param = $this->show_input; |
| 346 | - if($param != "") $params[] = "inp=".$param; |
|
| 380 | + if($param != "") { |
|
| 381 | + $params[] = "inp=".$param; |
|
| 382 | + } |
|
| 347 | 383 | |
| 348 | 384 | $param = $this->date_format; |
| 349 | - if($param != "") $params[] = "fmt=".$param; |
|
| 385 | + if($param != "") { |
|
| 386 | + $params[] = "fmt=".$param; |
|
| 387 | + } |
|
| 350 | 388 | |
| 351 | 389 | $param = implode(",", $this->dsb_days);
|
| 352 | - if($param != "") $params[] = "dis=".$param; |
|
| 390 | + if($param != "") { |
|
| 391 | + $params[] = "dis=".$param; |
|
| 392 | + } |
|
| 353 | 393 | |
| 354 | 394 | $param = $this->date_pair1; |
| 355 | - if($param != "") $params[] = "pr1=".$param; |
|
| 395 | + if($param != "") { |
|
| 396 | + $params[] = "pr1=".$param; |
|
| 397 | + } |
|
| 356 | 398 | |
| 357 | 399 | $param = $this->date_pair2; |
| 358 | - if($param != "") $params[] = "pr2=".$param; |
|
| 400 | + if($param != "") { |
|
| 401 | + $params[] = "pr2=".$param; |
|
| 402 | + } |
|
| 359 | 403 | |
| 360 | 404 | $param = $this->date_pair_value; |
| 361 | - if($param != "") $params[] = "prv=".$param; |
|
| 405 | + if($param != "") { |
|
| 406 | + $params[] = "prv=".$param; |
|
| 407 | + } |
|
| 362 | 408 | |
| 363 | 409 | $param = $this->path; |
| 364 | - if($param != "") $params[] = "pth=".$param; |
|
| 410 | + if($param != "") { |
|
| 411 | + $params[] = "pth=".$param; |
|
| 412 | + } |
|
| 365 | 413 | |
| 366 | 414 | $param = htmlspecialchars($this->check_json_encode($this->sp_dates), ENT_QUOTES); |
| 367 | - if($param != "") $params[] = "spd=".$param; |
|
| 415 | + if($param != "") { |
|
| 416 | + $params[] = "spd=".$param; |
|
| 417 | + } |
|
| 368 | 418 | |
| 369 | 419 | $param = $this->sp_type; |
| 370 | - if($param != "") $params[] = "spt=".$param; |
|
| 420 | + if($param != "") { |
|
| 421 | + $params[] = "spt=".$param; |
|
| 422 | + } |
|
| 371 | 423 | |
| 372 | 424 | $param = rawurlencode($this->tc_onchanged); |
| 373 | - if($param != "") $params[] = "och=".$param; |
|
| 425 | + if($param != "") { |
|
| 426 | + $params[] = "och=".$param; |
|
| 427 | + } |
|
| 374 | 428 | |
| 375 | 429 | $param = $this->startDate; |
| 376 | - if($param != "") $params[] = "str=".$param; |
|
| 430 | + if($param != "") { |
|
| 431 | + $params[] = "str=".$param; |
|
| 432 | + } |
|
| 377 | 433 | |
| 378 | 434 | $param = $this->rtl; |
| 379 | - if($param != "") $params[] = "rtl=".$param; |
|
| 435 | + if($param != "") { |
|
| 436 | + $params[] = "rtl=".$param; |
|
| 437 | + } |
|
| 380 | 438 | |
| 381 | 439 | $param = $this->show_week; |
| 382 | - if($param != "") $params[] = "wks=".$param; |
|
| 440 | + if($param != "") { |
|
| 441 | + $params[] = "wks=".$param; |
|
| 442 | + } |
|
| 383 | 443 | |
| 384 | 444 | $param = $this->interval; |
| 385 | - if($param != "") $params[] = "int=".$param; |
|
| 445 | + if($param != "") { |
|
| 446 | + $params[] = "int=".$param; |
|
| 447 | + } |
|
| 386 | 448 | |
| 387 | 449 | $param = $this->auto_hide; |
| 388 | - if($param != "") $params[] = "hid=".$param; |
|
| 450 | + if($param != "") { |
|
| 451 | + $params[] = "hid=".$param; |
|
| 452 | + } |
|
| 389 | 453 | |
| 390 | 454 | $param = $this->auto_hide_time; |
| 391 | - if($param != "") $params[] = "hdt=".$param; |
|
| 455 | + if($param != "") { |
|
| 456 | + $params[] = "hdt=".$param; |
|
| 457 | + } |
|
| 392 | 458 | |
| 393 | 459 | $param = $this->timezone; |
| 394 | - if($param != "") $params[] = "tmz=".$param; |
|
| 460 | + if($param != "") { |
|
| 461 | + $params[] = "tmz=".$param; |
|
| 462 | + } |
|
| 395 | 463 | |
| 396 | 464 | //$param = $this->system_timezone; |
| 397 | 465 | //if($param != "") $params[] = "stz=".$param; |
| 398 | 466 | |
| 399 | 467 | $param = $this->theme; |
| 400 | - if($param != "") $params[] = "thm=".$param; |
|
| 468 | + if($param != "") { |
|
| 469 | + $params[] = "thm=".$param; |
|
| 470 | + } |
|
| 401 | 471 | |
| 402 | 472 | $paramStr = (sizeof($params)>0) ? "?".implode("&", $params) : "";
|
| 403 | 473 | |
@@ -432,7 +502,7 @@ discard block |
||
| 432 | 502 | default: |
| 433 | 503 | $div_align .= "right:0px;"; |
| 434 | 504 | } |
| 435 | - }else{
|
|
| 505 | + } else{
|
|
| 436 | 506 | $div_display = "visible"; |
| 437 | 507 | $div_position = "relative"; |
| 438 | 508 | $div_align = ""; |
@@ -498,10 +568,10 @@ discard block |
||
| 498 | 568 | if($this->time_allow1 && $this->time_allow2){
|
| 499 | 569 | $year_start = $this->mydate->getDate("Y", $this->time_allow1);
|
| 500 | 570 | $year_end = $this->mydate->getDate("Y", $this->time_allow2);
|
| 501 | - }elseif($this->time_allow1){
|
|
| 571 | + } elseif($this->time_allow1){
|
|
| 502 | 572 | //only date 1 specified |
| 503 | 573 | $year_start = $this->mydate->getDate("Y", $this->time_allow1);
|
| 504 | - }elseif($this->time_allow2){
|
|
| 574 | + } elseif($this->time_allow2){
|
|
| 505 | 575 | //only date 2 specified |
| 506 | 576 | $year_end = $this->mydate->getDate("Y", $this->time_allow2);
|
| 507 | 577 | } |
@@ -518,7 +588,9 @@ discard block |
||
| 518 | 588 | |
| 519 | 589 | function eHidden($suffix, $value) {
|
| 520 | 590 | if(trim($value) != ""){
|
| 521 | - if($suffix) $suffix = "_".$suffix; |
|
| 591 | + if($suffix) { |
|
| 592 | + $suffix = "_".$suffix; |
|
| 593 | + } |
|
| 522 | 594 | return "<input type=\"hidden\" name=\"".$this->objname.$suffix."\" id=\"".$this->objname.$suffix."\" value=\"".$value."\" />"; |
| 523 | 595 | } |
| 524 | 596 | } |
@@ -575,7 +647,9 @@ discard block |
||
| 575 | 647 | // Auto sizing is applied |
| 576 | 648 | //--------------------------- |
| 577 | 649 | function setWidth($width){
|
| 578 | - if($width) $this->width = $width; |
|
| 650 | + if($width) { |
|
| 651 | + $this->width = $width; |
|
| 652 | + } |
|
| 579 | 653 | } |
| 580 | 654 | |
| 581 | 655 | //set height of calendar |
@@ -584,20 +658,26 @@ discard block |
||
| 584 | 658 | // Auto sizing is applied |
| 585 | 659 | //--------------------------- |
| 586 | 660 | function setHeight($height){
|
| 587 | - if($height) $this->height = $height; |
|
| 661 | + if($height) { |
|
| 662 | + $this->height = $height; |
|
| 663 | + } |
|
| 588 | 664 | } |
| 589 | 665 | |
| 590 | 666 | function setYearInterval($start, $end){
|
| 591 | 667 | $this->year_start_input = $start; |
| 592 | 668 | $this->year_end_input = $end; |
| 593 | 669 | |
| 594 | - if(!$start) $start = $this->year_start; |
|
| 595 | - if(!$end) $end = $this->year_end; |
|
| 670 | + if(!$start) { |
|
| 671 | + $start = $this->year_start; |
|
| 672 | + } |
|
| 673 | + if(!$end) { |
|
| 674 | + $end = $this->year_end; |
|
| 675 | + } |
|
| 596 | 676 | |
| 597 | 677 | if($start < $end){
|
| 598 | 678 | $this->year_start = $start; |
| 599 | 679 | $this->year_end = $end; |
| 600 | - }else{
|
|
| 680 | + } else{
|
|
| 601 | 681 | $this->year_start = $end; |
| 602 | 682 | $this->year_end = $start; |
| 603 | 683 | } |
@@ -615,12 +695,15 @@ discard block |
||
| 615 | 695 | //$this->startMonday = $flag; |
| 616 | 696 | |
| 617 | 697 | //change it so that it will not cause an error after version 3.61 |
| 618 | - if($flag) $this->startDate = 1; |
|
| 698 | + if($flag) { |
|
| 699 | + $this->startDate = 1; |
|
| 700 | + } |
|
| 619 | 701 | } |
| 620 | 702 | |
| 621 | 703 | function startDate($num){
|
| 622 | - if(is_numeric($num) && $num >= 0 && $num <= 6) |
|
| 623 | - $this->startDate = $num; |
|
| 704 | + if(is_numeric($num) && $num >= 0 && $num <= 6) { |
|
| 705 | + $this->startDate = $num; |
|
| 706 | + } |
|
| 624 | 707 | } |
| 625 | 708 | |
| 626 | 709 | function dateAllow($from = "", $to = "", $show_not_allow = true){
|
@@ -637,19 +720,27 @@ discard block |
||
| 637 | 720 | if ($time_from != null) {
|
| 638 | 721 | $this->time_allow1 = $time_from; |
| 639 | 722 | $y = $this->mydate->getDate('Y', $time_from);
|
| 640 | - if($this->year_start && $y > $this->year_start) $this->year_start = $y; |
|
| 723 | + if($this->year_start && $y > $this->year_start) { |
|
| 724 | + $this->year_start = $y; |
|
| 725 | + } |
|
| 641 | 726 | |
| 642 | 727 | //setup year end from year start |
| 643 | - if($time_to == null && !$this->year_end) $this->year_end = $this->year_start + $this->year_display_from_current; |
|
| 728 | + if($time_to == null && !$this->year_end) { |
|
| 729 | + $this->year_end = $this->year_start + $this->year_display_from_current; |
|
| 730 | + } |
|
| 644 | 731 | } |
| 645 | 732 | |
| 646 | 733 | if ($time_to>0) {
|
| 647 | 734 | $this->time_allow2 = $time_to; |
| 648 | 735 | $y = $this->mydate->getDate('Y', $time_to);
|
| 649 | - if($this->year_end && $y < $this->year_end) $this->year_end = $y; |
|
| 736 | + if($this->year_end && $y < $this->year_end) { |
|
| 737 | + $this->year_end = $y; |
|
| 738 | + } |
|
| 650 | 739 | |
| 651 | 740 | //setup year start from year end |
| 652 | - if($time_from == null && !$this->year_start) $this->year_start = $this->year_end - $this->year_display_from_current; |
|
| 741 | + if($time_from == null && !$this->year_start) { |
|
| 742 | + $this->year_start = $this->year_end - $this->year_display_from_current; |
|
| 743 | + } |
|
| 653 | 744 | } |
| 654 | 745 | |
| 655 | 746 | $this->show_not_allow = $show_not_allow; |
@@ -672,7 +763,9 @@ discard block |
||
| 672 | 763 | function writeDateContainer(){
|
| 673 | 764 | if($this->day && $this->month && $this->year){
|
| 674 | 765 | $dd = $this->mydate->getDate($this->date_format, $this->year."-".$this->month."-".$this->day); |
| 675 | - }else $dd = "Select Date"; |
|
| 766 | + } else { |
|
| 767 | + $dd = "Select Date"; |
|
| 768 | + } |
|
| 676 | 769 | |
| 677 | 770 | return "<div id=\"divCalendar_".$this->objname."_lbl\" class=\"date-tccontainer\">$dd</div>"; |
| 678 | 771 | } |
@@ -683,8 +776,9 @@ discard block |
||
| 683 | 776 | //------------------------------------------------------ |
| 684 | 777 | function disabledDay($day){
|
| 685 | 778 | $day = strtolower($day); //make it not case-sensitive |
| 686 | - if(in_array($day, $this->dsb_days) === false) |
|
| 687 | - $this->dsb_days[] = $day; |
|
| 779 | + if(in_array($day, $this->dsb_days) === false) { |
|
| 780 | + $this->dsb_days[] = $day; |
|
| 781 | + } |
|
| 688 | 782 | } |
| 689 | 783 | |
| 690 | 784 | function setAlignment($h_align, $v_align){
|
@@ -695,12 +789,14 @@ discard block |
||
| 695 | 789 | function setDatePair($calendar_name1, $calendar_name2, $pair_value = "0000-00-00 00:00:00"){
|
| 696 | 790 | if($calendar_name1 != $this->objname){
|
| 697 | 791 | $this->date_pair1 = $calendar_name1; |
| 698 | - if($pair_value != "0000-00-00 00:00:00") |
|
| 699 | - $this->date_pair_value = $pair_value; |
|
| 700 | - }elseif($calendar_name2 != $this->objname){
|
|
| 792 | + if($pair_value != "0000-00-00 00:00:00") { |
|
| 793 | + $this->date_pair_value = $pair_value; |
|
| 794 | + } |
|
| 795 | + } elseif($calendar_name2 != $this->objname){
|
|
| 701 | 796 | $this->date_pair2 = $calendar_name2; |
| 702 | - if($pair_value != "0000-00-00 00:00:00") |
|
| 703 | - $this->date_pair_value = $pair_value; |
|
| 797 | + if($pair_value != "0000-00-00 00:00:00") { |
|
| 798 | + $this->date_pair_value = $pair_value; |
|
| 799 | + } |
|
| 704 | 800 | } |
| 705 | 801 | } |
| 706 | 802 | |
@@ -713,16 +809,19 @@ discard block |
||
| 713 | 809 | if($this->mydate->validDate($sp_date)){
|
| 714 | 810 | switch($recursive){
|
| 715 | 811 | case "month": //add to monthly |
| 716 | - if(!in_array($sp_date, $this->sp_dates[1])) |
|
| 717 | - $this->sp_dates[1][] = $sp_date; |
|
| 812 | + if(!in_array($sp_date, $this->sp_dates[1])) { |
|
| 813 | + $this->sp_dates[1][] = $sp_date; |
|
| 814 | + } |
|
| 718 | 815 | break; |
| 719 | 816 | case "year": //add to yearly |
| 720 | - if(!in_array($sp_date, $this->sp_dates[2])) |
|
| 721 | - $this->sp_dates[2][] = $sp_date; |
|
| 817 | + if(!in_array($sp_date, $this->sp_dates[2])) { |
|
| 818 | + $this->sp_dates[2][] = $sp_date; |
|
| 819 | + } |
|
| 722 | 820 | break; |
| 723 | 821 | default: //add to no recursive |
| 724 | - if(!in_array($sp_date, $this->sp_dates[0])) |
|
| 725 | - $this->sp_dates[0][] = $sp_date; |
|
| 822 | + if(!in_array($sp_date, $this->sp_dates[0])) { |
|
| 823 | + $this->sp_dates[0][] = $sp_date; |
|
| 824 | + } |
|
| 726 | 825 | } |
| 727 | 826 | } |
| 728 | 827 | } |
@@ -790,10 +889,14 @@ discard block |
||
| 790 | 889 | if($this->mydate->dateBefore($this->time_allow1, $date_str, false) || $this->mydate->dateAfter($this->time_allow2, $date_str, false)){
|
| 791 | 890 | return false; |
| 792 | 891 | } |
| 793 | - }elseif($this->time_allow1){
|
|
| 794 | - if($this->mydate->dateBefore($this->time_allow1, $date_str, false)) return false; |
|
| 795 | - }elseif($this->time_allow2){
|
|
| 796 | - if($this->mydate->dateAfter($this->time_allow2, $date_str, false)) return false; |
|
| 892 | + } elseif($this->time_allow1){
|
|
| 893 | + if($this->mydate->dateBefore($this->time_allow1, $date_str, false)) { |
|
| 894 | + return false; |
|
| 895 | + } |
|
| 896 | + } elseif($this->time_allow2){
|
|
| 897 | + if($this->mydate->dateAfter($this->time_allow2, $date_str, false)) { |
|
| 898 | + return false; |
|
| 899 | + } |
|
| 797 | 900 | } |
| 798 | 901 | |
| 799 | 902 | //check with specific date |
@@ -830,11 +933,15 @@ discard block |
||
| 830 | 933 | case 0: |
| 831 | 934 | default: |
| 832 | 935 | //disabled specific and enabled others |
| 833 | - if($sp_found) return false; |
|
| 936 | + if($sp_found) { |
|
| 937 | + return false; |
|
| 938 | + } |
|
| 834 | 939 | break; |
| 835 | 940 | case 1: |
| 836 | 941 | //enabled specific and disabled others |
| 837 | - if(!$sp_found) return false; |
|
| 942 | + if(!$sp_found) { |
|
| 943 | + return false; |
|
| 944 | + } |
|
| 838 | 945 | break; |
| 839 | 946 | } |
| 840 | 947 | } |
@@ -854,17 +961,21 @@ discard block |
||
| 854 | 961 | if(is_array($obj)){
|
| 855 | 962 | if(function_exists("json_encode") && false){
|
| 856 | 963 | return json_encode($obj); |
| 857 | - }else{
|
|
| 964 | + } else{
|
|
| 858 | 965 | //only array is assumed for now |
| 859 | 966 | $return_arr = array(); |
| 860 | 967 | foreach($obj as $arr){
|
| 861 | - if(is_array($arr) && sizeof($arr)>0) |
|
| 862 | - $return_arr[] = "[\"".implode("\",\"", $arr)."\"]";
|
|
| 863 | - else $return_arr[] = "[]"; |
|
| 968 | + if(is_array($arr) && sizeof($arr)>0) { |
|
| 969 | + $return_arr[] = "[\"".implode("\",\"", $arr)."\"]"; |
|
| 970 | + } else { |
|
| 971 | + $return_arr[] = "[]"; |
|
| 972 | + } |
|
| 864 | 973 | } |
| 865 | 974 | return "[".implode(",", $return_arr)."]";
|
| 866 | 975 | } |
| 867 | - }else return ""; |
|
| 976 | + } else { |
|
| 977 | + return ""; |
|
| 978 | + } |
|
| 868 | 979 | } |
| 869 | 980 | |
| 870 | 981 | function &check_json_decode($str){
|
@@ -872,7 +983,7 @@ discard block |
||
| 872 | 983 | |
| 873 | 984 | if(function_exists("json_decode") && false){
|
| 874 | 985 | return json_decode($str); |
| 875 | - }else{
|
|
| 986 | + } else{
|
|
| 876 | 987 | //only array is assume for now |
| 877 | 988 | $str = stripslashes(rawurldecode($str)); |
| 878 | 989 | $str = trim($str); |
@@ -890,9 +1001,9 @@ discard block |
||
| 890 | 1001 | $arr = explode("],[", $str);
|
| 891 | 1002 | for($i=0; $i<sizeof($arr); $i++){
|
| 892 | 1003 | $this_v = $arr[$i]; |
| 893 | - if($this_v == "") |
|
| 894 | - $return_arr[] = array(); |
|
| 895 | - else{
|
|
| 1004 | + if($this_v == "") { |
|
| 1005 | + $return_arr[] = array(); |
|
| 1006 | + } else{
|
|
| 896 | 1007 | $this_arr = explode(",", $this_v);
|
| 897 | 1008 | |
| 898 | 1009 | for($j=0; $j<sizeof($this_arr); $j++){
|
@@ -905,8 +1016,12 @@ discard block |
||
| 905 | 1016 | } |
| 906 | 1017 | } |
| 907 | 1018 | return $return_arr; |
| 908 | - }else return array(); |
|
| 909 | - }else return array(); |
|
| 1019 | + } else { |
|
| 1020 | + return array(); |
|
| 1021 | + } |
|
| 1022 | + } else { |
|
| 1023 | + return array(); |
|
| 1024 | + } |
|
| 910 | 1025 | } |
| 911 | 1026 | } |
| 912 | 1027 | |
@@ -939,14 +1054,16 @@ discard block |
||
| 939 | 1054 | //check if today is in range of date allow |
| 940 | 1055 | if($this->time_allow1 != ""){
|
| 941 | 1056 | //check valid if today is after date_allow1 |
| 942 | - if($this->mydate->validDate($this->time_allow1) && !$this->mydate->dateAfter($this->time_allow1, $today)) |
|
| 943 | - return false; |
|
| 1057 | + if($this->mydate->validDate($this->time_allow1) && !$this->mydate->dateAfter($this->time_allow1, $today)) { |
|
| 1058 | + return false; |
|
| 1059 | + } |
|
| 944 | 1060 | } |
| 945 | 1061 | |
| 946 | 1062 | if($this->time_allow2 > 0){
|
| 947 | 1063 | //check valid if today is before date_allow2 |
| 948 | - if($this->mydate->validDate($this->time_allow2) && !$this->mydate->dateBefore($this->time_allow2, $today)) |
|
| 949 | - return false; |
|
| 1064 | + if($this->mydate->validDate($this->time_allow2) && !$this->mydate->dateBefore($this->time_allow2, $today)) { |
|
| 1065 | + return false; |
|
| 1066 | + } |
|
| 950 | 1067 | } |
| 951 | 1068 | return true; |
| 952 | 1069 | } |
@@ -966,8 +1083,7 @@ discard block |
||
| 966 | 1083 | if(!in_array($tt_time, $this->tt_dates[2])){
|
| 967 | 1084 | $this->tt_dates[2][] = $tt_time; |
| 968 | 1085 | $this->tt_tooltips[2][] = $tooltip; |
| 969 | - } |
|
| 970 | - else{
|
|
| 1086 | + } else{
|
|
| 971 | 1087 | $tt_key = array_search($tt_time, $this->tt_dates[2]); |
| 972 | 1088 | $this->tt_tooltips[2][$tt_key] = $this->tt_tooltips[2][$tt_key]."\n".$tooltip; |
| 973 | 1089 | } |
@@ -976,8 +1092,7 @@ discard block |
||
| 976 | 1092 | if(!in_array($tt_time, $this->tt_dates[1])){
|
| 977 | 1093 | $this->tt_dates[1][] = $tt_time; |
| 978 | 1094 | $this->tt_tooltips[1][] = $tooltip; |
| 979 | - } |
|
| 980 | - else{
|
|
| 1095 | + } else{
|
|
| 981 | 1096 | $tt_key = array_search($tt_time, $this->tt_dates[1]); |
| 982 | 1097 | $this->tt_tooltips[1][$tt_key] = $this->tt_tooltips[1][$tt_key]."\n".$tooltip; |
| 983 | 1098 | } |
@@ -986,8 +1101,7 @@ discard block |
||
| 986 | 1101 | if(!in_array($tt_time, $this->tt_dates[0])){
|
| 987 | 1102 | $this->tt_dates[0][] = $tt_time; |
| 988 | 1103 | $this->tt_tooltips[0][] = $tooltip; |
| 989 | - } |
|
| 990 | - else{
|
|
| 1104 | + } else{
|
|
| 991 | 1105 | $tt_key = array_search($tt_time, $this->tt_dates[0]); |
| 992 | 1106 | $this->tt_tooltips[0][$tt_key] = $this->tt_tooltips[0][$tt_key]."\n".$tooltip; |
| 993 | 1107 | } |
@@ -27,15 +27,18 @@ discard block |
||
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | function setDate($sdate){
|
| 30 | - if($this->validDate($sdate)) |
|
| 31 | - $this->mydate = strtotime($sdate); |
|
| 30 | + if($this->validDate($sdate)) { |
|
| 31 | + $this->mydate = strtotime($sdate); |
|
| 32 | + } |
|
| 32 | 33 | } |
| 33 | 34 | |
| 34 | 35 | function getDate($format = "Y-m-d", $cdate = ""){
|
| 35 | 36 | if(($cdate != "" && $this->validDate($cdate)) || $cdate == ""){
|
| 36 | 37 | $tmp_date = ($cdate != "") ? strtotime($cdate) : $this->mydate; |
| 37 | 38 | return date($format, $tmp_date); |
| 38 | - }else return ""; |
|
| 39 | + } else { |
|
| 40 | + return ""; |
|
| 41 | + } |
|
| 39 | 42 | } |
| 40 | 43 | |
| 41 | 44 | function setTimestamp($stime){
|
@@ -46,34 +49,44 @@ discard block |
||
| 46 | 49 | if(($cdate != "" && $this->validDate($cdate)) || $cdate == ""){
|
| 47 | 50 | $tmp_date = ($cdate != "") ? strtotime($cdate) : $this->mydate; |
| 48 | 51 | return $tmp_date; |
| 49 | - }else return 0; |
|
| 52 | + } else { |
|
| 53 | + return 0; |
|
| 54 | + } |
|
| 50 | 55 | } |
| 51 | 56 | |
| 52 | 57 | function getDateFromTimestamp($stime, $format = "Y-m-d"){
|
| 53 | 58 | if($stime && $stime > 0){
|
| 54 | 59 | return date($format, $stime); |
| 55 | - }else return "0000-00-00"; |
|
| 60 | + } else { |
|
| 61 | + return "0000-00-00"; |
|
| 62 | + } |
|
| 56 | 63 | } |
| 57 | 64 | |
| 58 | 65 | function addDay($format = "Y-m-d", $timespan, $cdate = ""){
|
| 59 | 66 | if(($cdate != "" && $this->validDate($cdate)) || $cdate == ""){
|
| 60 | 67 | $tmp_date = ($cdate != "") ? strtotime($cdate) : $this->mydate; |
| 61 | 68 | return date($format, mktime(0,0,0,date('m', $tmp_date),(date('d', $tmp_date)+$timespan),date('Y', $tmp_date)));
|
| 62 | - }else return "0000-00-00"; |
|
| 69 | + } else { |
|
| 70 | + return "0000-00-00"; |
|
| 71 | + } |
|
| 63 | 72 | } |
| 64 | 73 | |
| 65 | 74 | function addMonth($format = "Y-m-d", $timespan, $cdate = ""){
|
| 66 | 75 | if(($cdate != "" && $this->validDate($cdate)) || $cdate == ""){
|
| 67 | 76 | $tmp_date = ($cdate != "") ? strtotime($cdate) : $this->mydate; |
| 68 | 77 | return date($format, mktime(0,0,0,(date('m', $tmp_date)+$timespan),date('d', $tmp_date),date('Y', $tmp_date)));
|
| 69 | - }else return "0000-00-00"; |
|
| 78 | + } else { |
|
| 79 | + return "0000-00-00"; |
|
| 80 | + } |
|
| 70 | 81 | } |
| 71 | 82 | |
| 72 | 83 | function addYear($format = "Y-m-d", $timespan, $cdate = ""){
|
| 73 | 84 | if(($cdate != "" && $this->validDate($cdate)) || $cdate == ""){
|
| 74 | 85 | $tmp_date = ($cdate != "") ? strtotime($cdate) : $this->mydate; |
| 75 | 86 | return date($format, mktime(0,0,0,date('m', $tmp_date),date('d', $tmp_date),(date('Y', $tmp_date)+$timespan)));
|
| 76 | - }else return "0000-00-00"; |
|
| 87 | + } else { |
|
| 88 | + return "0000-00-00"; |
|
| 89 | + } |
|
| 77 | 90 | } |
| 78 | 91 | |
| 79 | 92 | //return the number of day different between date1 and date2 |
@@ -84,7 +97,9 @@ discard block |
||
| 84 | 97 | |
| 85 | 98 | $date_diff = $date1-strtotime($date2); |
| 86 | 99 | return abs($date_diff); |
| 87 | - }else return false; |
|
| 100 | + } else { |
|
| 101 | + return false; |
|
| 102 | + } |
|
| 88 | 103 | } |
| 89 | 104 | |
| 90 | 105 | //check if date1 is before date2 |
@@ -94,7 +109,9 @@ discard block |
||
| 94 | 109 | $date1 = ($date1 != "") ? strtotime($date1) : $this->mydate; |
| 95 | 110 | $date2 = strtotime($date2); |
| 96 | 111 | return ($equal) ? $date1<=$date2 : $date1<$date2; |
| 97 | - }else return false; |
|
| 112 | + } else { |
|
| 113 | + return false; |
|
| 114 | + } |
|
| 98 | 115 | } |
| 99 | 116 | |
| 100 | 117 | //check if date1 is after date2 |
@@ -104,7 +121,9 @@ discard block |
||
| 104 | 121 | $date1 = ($date1 != "") ? strtotime($date1) : $this->mydate; |
| 105 | 122 | $date2 = strtotime($date2); |
| 106 | 123 | return ($equal) ? $date1>=$date2 : $date1>$date2; |
| 107 | - }else return false; |
|
| 124 | + } else { |
|
| 125 | + return false; |
|
| 126 | + } |
|
| 108 | 127 | } |
| 109 | 128 | |
| 110 | 129 | function validDate($date_str){
|
@@ -113,8 +132,12 @@ discard block |
||
| 113 | 132 | |
| 114 | 133 | if((isset($date_arr[0]) && is_numeric($date_arr[0])) && (isset($date_arr[1]) && is_numeric($date_arr[1])) && (isset($date_arr[2]) && is_numeric($date_arr[2]))){
|
| 115 | 134 | return (checkdate($date_arr[1], $date_arr[2], $date_arr[0])) ? true : false; |
| 116 | - }else return false; |
|
| 117 | - }else return false; |
|
| 135 | + } else { |
|
| 136 | + return false; |
|
| 137 | + } |
|
| 138 | + } else { |
|
| 139 | + return false; |
|
| 140 | + } |
|
| 118 | 141 | } |
| 119 | 142 | } |
| 120 | 143 | ?> |
| 121 | 144 | \ No newline at end of file |