@@ -1,8 +1,8 @@ |
||
1 | 1 | <?php |
2 | -if (in_array($user,array_keys(array_filter($adm)))) $extopt = '<option value="MONTH">MONTHS</option><option value="YEAR">YEARS</option>'; |
|
2 | +if (in_array($user, array_keys(array_filter($adm)))) $extopt = '<option value="MONTH">MONTHS</option><option value="YEAR">YEARS</option>'; |
|
3 | 3 | else $extopt = NULL; |
4 | 4 | ?> |
5 | 5 | <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 | 6 | |
7 | 7 | List <?php echo $typedesc.' <'.$value.'>'; ?> for <input name="type" type="hidden" value="<?php echo $typedesc; ?>" /><input name="value" type="hidden" class="input_text" value="<?php echo $value; ?>" /> |
8 | - <select name="quantity" class="input_text" size="1"><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="20">20</option></select><select class="input_text" name="unit" size="1"><option value="DAY">DAYS</option><option value="WEEK">WEEKS</option><?php echo $extopt;?></select> Reason:<input maxlength="128" name="reason" size="30" type="text" class="input_text" /><input name="List" class="button" id="bwarn" type="submit" value="List"/></form> |
|
8 | + <select name="quantity" class="input_text" size="1"><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="20">20</option></select><select class="input_text" name="unit" size="1"><option value="DAY">DAYS</option><option value="WEEK">WEEKS</option><?php echo $extopt; ?></select> Reason:<input maxlength="128" name="reason" size="30" type="text" class="input_text" /><input name="List" class="button" id="bwarn" type="submit" value="List"/></form> |
@@ -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 |
@@ -48,8 +48,8 @@ discard block |
||
48 | 48 | |
49 | 49 | /* check you select a blocklist */ |
50 | 50 | if ( !$tables["$typedesc"]['bl'] ) { |
51 | - syslog(LOG_EMERG,"$user: <$typedesc> is not a blocklist. Are you stupid? Do you want to whitelist a spammer? I refuse to continue."); |
|
52 | - exit (254); |
|
51 | + syslog(LOG_EMERG,"$user: <$typedesc> is not a blocklist. Are you stupid? Do you want to whitelist a spammer? I refuse to continue."); |
|
52 | + exit (254); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | |
@@ -69,33 +69,33 @@ discard block |
||
69 | 69 | $tolist = array(); |
70 | 70 | |
71 | 71 | if ( !file_exists($splfile) ) { |
72 | - syslog(LOG_ERR,"$user: File <$splfile> not found! Exit."); |
|
73 | - exit (254); |
|
72 | + syslog(LOG_ERR,"$user: File <$splfile> not found! Exit."); |
|
73 | + exit (254); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | if (($handle = gzopen($splfile, 'r')) !== FALSE) { |
77 | - $row = -1; |
|
78 | - while (($data = fgetcsv($handle, 500, ',')) !== FALSE) { |
|
79 | - $row++; |
|
80 | - if ($row == 0) continue; /* Skip heading line */ |
|
81 | - $thisVal = $data[1]; |
|
82 | - unset($data[1]); |
|
83 | - $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; |
|
88 | - } |
|
89 | - fclose($handle); |
|
77 | + $row = -1; |
|
78 | + while (($data = fgetcsv($handle, 500, ',')) !== FALSE) { |
|
79 | + $row++; |
|
80 | + if ($row == 0) continue; /* Skip heading line */ |
|
81 | + $thisVal = $data[1]; |
|
82 | + unset($data[1]); |
|
83 | + $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; |
|
88 | + } |
|
89 | + fclose($handle); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /* Make MYSQL connection */ |
93 | 93 | |
94 | 94 | $mysqli = new mysqli($dbhost, $userdb, $pwd, $db, $dbport); |
95 | 95 | if ($mysqli->connect_error) { |
96 | - syslog (LOG_EMERG, $user.': Connect Error (' . $mysqli->connect_errno . ') ' |
|
97 | - . $mysqli->connect_error); |
|
98 | - exit (254); |
|
96 | + syslog (LOG_EMERG, $user.': Connect Error (' . $mysqli->connect_errno . ') ' |
|
97 | + . $mysqli->connect_error); |
|
98 | + exit (254); |
|
99 | 99 | |
100 | 100 | } |
101 | 101 | |
@@ -103,28 +103,28 @@ discard block |
||
103 | 103 | |
104 | 104 | foreach ( array_keys($tolist) as $value) { |
105 | 105 | $reason = 'On ['.$tolist["$value"][0]."] <$value> sent ".$tolist["$value"][1].' messages to '.$tolist["$value"][2].' recipients.'; |
106 | - if ( $tolist["$value"][3] >= $threshold ) { |
|
107 | - if ( searchAndList ($mysqli,$user,$tables,$typedesc,$value,$unit,$quantity,$reason) ) { |
|
108 | - syslog (LOG_INFO, "$user: ".'Listing reason: '.$reason); |
|
109 | - /* Send a email to domain admin if you list an email */ |
|
110 | - if ( ( $tables["$typedesc"]['field'] == 'email' ) OR ( $tables["$typedesc"]['field'] == 'username' ) ) { |
|
106 | + if ( $tolist["$value"][3] >= $threshold ) { |
|
107 | + if ( searchAndList ($mysqli,$user,$tables,$typedesc,$value,$unit,$quantity,$reason) ) { |
|
108 | + syslog (LOG_INFO, "$user: ".'Listing reason: '.$reason); |
|
109 | + /* Send a email to domain admin if you list an email */ |
|
110 | + if ( ( $tables["$typedesc"]['field'] == 'email' ) OR ( $tables["$typedesc"]['field'] == 'username' ) ) { |
|
111 | 111 | /* Sometime uid are in the form of <user>@<domain> ... */ |
112 | 112 | if ( strpos($value, '@') !== FALSE ) { |
113 | - $domain = array_pop(explode('@',$value,2)); |
|
113 | + $domain = array_pop(explode('@',$value,2)); |
|
114 | 114 | if ( strpos($domain, '@') === FALSE ) { |
115 | - $recip = emailToNotify($domainNotify_file,$domain); |
|
116 | - $subject = sprintf('%s <%s> is now blocked because exceedes limits on outgoing emails', |
|
115 | + $recip = emailToNotify($domainNotify_file,$domain); |
|
116 | + $subject = sprintf('%s <%s> is now blocked because exceedes limits on outgoing emails', |
|
117 | 117 | $tables["$typedesc"]['field'], $value); |
118 | - if (!empty($recip)) |
|
119 | - if ( sendEmailWarn($tplfile,'[email protected]',$recip, |
|
118 | + if (!empty($recip)) |
|
119 | + if ( sendEmailWarn($tplfile,'[email protected]',$recip, |
|
120 | 120 | $subject,$value,"$quantity $unit",$reason) ) |
121 | - syslog(LOG_INFO, "$user: \"$recip\" was notified about the \"$value\" abuse."); |
|
121 | + syslog(LOG_INFO, "$user: \"$recip\" was notified about the \"$value\" abuse."); |
|
122 | 122 | } |
123 | 123 | else syslog(LOG_ERR,"$user: <$domain> contains the '@' char. Notification cannot be sent."); |
124 | 124 | } |
125 | - } |
|
126 | - } |
|
127 | - } |
|
125 | + } |
|
126 | + } |
|
127 | + } |
|
128 | 128 | else { |
129 | 129 | $reason .= " But it has NOT been listed because it doesn't apply to the trigger condition."; |
130 | 130 | syslog (LOG_INFO, "$user: ".$reason); |
@@ -10,33 +10,33 @@ discard block |
||
10 | 10 | # |
11 | 11 | */ |
12 | 12 | |
13 | -$shortopts = "c:"; // Required value |
|
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'])) 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"); |
|
17 | 17 | |
18 | 18 | /************** Start of conf ************************/ |
19 | 19 | require_once('config.php'); |
20 | 20 | |
21 | 21 | /* Syslog */ |
22 | -$tag .= 'SplunkLister'; |
|
22 | +$tag .= 'SplunkLister'; |
|
23 | 23 | |
24 | -$conf = parse_ini_file( dirname(__FILE__) . '/' . $options['c'] ); |
|
24 | +$conf = parse_ini_file(dirname(__FILE__).'/'.$options['c']); |
|
25 | 25 | |
26 | 26 | /* Splunk inherited parameters */ |
27 | -$threshold = $conf['threshold']; /* Threshold value on trigger condition; the same which engage the alert */ |
|
28 | -$splfile = $argv[10]; /* Full path of result Splunk file, see at |
|
27 | +$threshold = $conf['threshold']; /* Threshold value on trigger condition; the same which engage the alert */ |
|
28 | +$splfile = $argv[10]; /* Full path of result Splunk file, see at |
|
29 | 29 | http://docs.splunk.com/Documentation/Splunk/6.2.2/Alert/Configuringscriptedalerts |
30 | 30 | It is 8+2 because of -c <conf> */ |
31 | 31 | /* Blacklist name */ |
32 | -$typedesc = $conf['typedesc']; |
|
32 | +$typedesc = $conf['typedesc']; |
|
33 | 33 | |
34 | 34 | /* How long to list's parameters */ |
35 | -$unit = $conf['unit']; /* MySQL language ;) */ |
|
35 | +$unit = $conf['unit']; /* MySQL language ;) */ |
|
36 | 36 | $quantity = $conf['quantity']; |
37 | 37 | |
38 | 38 | /* Syslog */ |
39 | -$tag .= $conf['tag']; |
|
39 | +$tag .= $conf['tag']; |
|
40 | 40 | |
41 | 41 | /************** End of conf *************************/ |
42 | 42 | |
@@ -47,8 +47,8 @@ discard block |
||
47 | 47 | $user = 'Splunk'; |
48 | 48 | |
49 | 49 | /* check you select a blocklist */ |
50 | -if ( !$tables["$typedesc"]['bl'] ) { |
|
51 | - syslog(LOG_EMERG,"$user: <$typedesc> is not a blocklist. Are you stupid? Do you want to whitelist a spammer? I refuse to continue."); |
|
50 | +if (!$tables["$typedesc"]['bl']) { |
|
51 | + syslog(LOG_EMERG, "$user: <$typedesc> is not a blocklist. Are you stupid? Do you want to whitelist a spammer? I refuse to continue."); |
|
52 | 52 | exit (254); |
53 | 53 | } |
54 | 54 | |
@@ -68,8 +68,8 @@ discard block |
||
68 | 68 | |
69 | 69 | $tolist = array(); |
70 | 70 | |
71 | -if ( !file_exists($splfile) ) { |
|
72 | - syslog(LOG_ERR,"$user: File <$splfile> not found! Exit."); |
|
71 | +if (!file_exists($splfile)) { |
|
72 | + syslog(LOG_ERR, "$user: File <$splfile> not found! Exit."); |
|
73 | 73 | exit (254); |
74 | 74 | } |
75 | 75 | |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | $thisVal = $data[1]; |
82 | 82 | unset($data[1]); |
83 | 83 | $data = array_values($data); |
84 | - if ( !in_array($thisVal,array_keys($tolist)) ) |
|
84 | + if (!in_array($thisVal, array_keys($tolist))) |
|
85 | 85 | $tolist["$thisVal"] = $data; |
86 | 86 | else if ($data[3]>$tolist[$thisVal][3]) |
87 | 87 | $tolist["$thisVal"] = $data; |
@@ -93,46 +93,46 @@ discard block |
||
93 | 93 | |
94 | 94 | $mysqli = new mysqli($dbhost, $userdb, $pwd, $db, $dbport); |
95 | 95 | if ($mysqli->connect_error) { |
96 | - syslog (LOG_EMERG, $user.': Connect Error (' . $mysqli->connect_errno . ') ' |
|
96 | + syslog(LOG_EMERG, $user.': Connect Error ('.$mysqli->connect_errno.') ' |
|
97 | 97 | . $mysqli->connect_error); |
98 | 98 | exit (254); |
99 | 99 | |
100 | 100 | } |
101 | 101 | |
102 | -syslog(LOG_INFO, $user.': Successfully mysql connected to ' . $mysqli->host_info) ; |
|
102 | +syslog(LOG_INFO, $user.': Successfully mysql connected to '.$mysqli->host_info); |
|
103 | 103 | |
104 | -foreach ( array_keys($tolist) as $value) { |
|
104 | +foreach (array_keys($tolist) as $value) { |
|
105 | 105 | $reason = 'On ['.$tolist["$value"][0]."] <$value> sent ".$tolist["$value"][1].' messages to '.$tolist["$value"][2].' recipients.'; |
106 | - if ( $tolist["$value"][3] >= $threshold ) { |
|
107 | - if ( searchAndList ($mysqli,$user,$tables,$typedesc,$value,$unit,$quantity,$reason) ) { |
|
108 | - syslog (LOG_INFO, "$user: ".'Listing reason: '.$reason); |
|
106 | + if ($tolist["$value"][3]>=$threshold) { |
|
107 | + if (searchAndList($mysqli, $user, $tables, $typedesc, $value, $unit, $quantity, $reason)) { |
|
108 | + syslog(LOG_INFO, "$user: ".'Listing reason: '.$reason); |
|
109 | 109 | /* Send a email to domain admin if you list an email */ |
110 | - if ( ( $tables["$typedesc"]['field'] == 'email' ) OR ( $tables["$typedesc"]['field'] == 'username' ) ) { |
|
110 | + if (($tables["$typedesc"]['field'] == 'email') OR ($tables["$typedesc"]['field'] == 'username')) { |
|
111 | 111 | /* Sometime uid are in the form of <user>@<domain> ... */ |
112 | - if ( strpos($value, '@') !== FALSE ) { |
|
113 | - $domain = array_pop(explode('@',$value,2)); |
|
114 | - if ( strpos($domain, '@') === FALSE ) { |
|
115 | - $recip = emailToNotify($domainNotify_file,$domain); |
|
112 | + if (strpos($value, '@') !== FALSE) { |
|
113 | + $domain = array_pop(explode('@', $value, 2)); |
|
114 | + if (strpos($domain, '@') === FALSE) { |
|
115 | + $recip = emailToNotify($domainNotify_file, $domain); |
|
116 | 116 | $subject = sprintf('%s <%s> is now blocked because exceedes limits on outgoing emails', |
117 | 117 | $tables["$typedesc"]['field'], $value); |
118 | 118 | if (!empty($recip)) |
119 | - if ( sendEmailWarn($tplfile,'[email protected]',$recip, |
|
120 | - $subject,$value,"$quantity $unit",$reason) ) |
|
119 | + if (sendEmailWarn($tplfile, '[email protected]', $recip, |
|
120 | + $subject, $value, "$quantity $unit", $reason)) |
|
121 | 121 | syslog(LOG_INFO, "$user: \"$recip\" was notified about the \"$value\" abuse."); |
122 | 122 | } |
123 | - else syslog(LOG_ERR,"$user: <$domain> contains the '@' char. Notification cannot be sent."); |
|
123 | + else syslog(LOG_ERR, "$user: <$domain> contains the '@' char. Notification cannot be sent."); |
|
124 | 124 | } |
125 | 125 | } |
126 | 126 | } |
127 | 127 | } |
128 | 128 | else { |
129 | 129 | $reason .= " But it has NOT been listed because it doesn't apply to the trigger condition."; |
130 | - syslog (LOG_INFO, "$user: ".$reason); |
|
130 | + syslog(LOG_INFO, "$user: ".$reason); |
|
131 | 131 | } |
132 | 132 | } |
133 | 133 | |
134 | 134 | /* Close connection */ |
135 | -syslog (LOG_INFO, "$user: ".'Successfully end of session.'); |
|
135 | +syslog(LOG_INFO, "$user: ".'Successfully end of session.'); |
|
136 | 136 | $mysqli->close(); |
137 | 137 | closelog(); |
138 | 138 |
@@ -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 | } |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | <?php |
3 | 3 | |
4 | 4 | if (PHP_SAPI != "cli") |
5 | - exit; |
|
5 | + exit; |
|
6 | 6 | |
7 | 7 | $home = '/var/www/html/RBL'; |
8 | 8 | require_once($home.'/config.php'); |
@@ -20,30 +20,30 @@ discard block |
||
20 | 20 | |
21 | 21 | $opts = getopt('f:t:'); |
22 | 22 | if ( isset($opts['f']) ) { |
23 | - $filetemplate = $opts['f']; |
|
23 | + $filetemplate = $opts['f']; |
|
24 | 24 | } else { |
25 | 25 | print "\nNo option for '-f' given.\n"; |
26 | - exit ( usage() ); |
|
26 | + exit ( usage() ); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | if ( isset($opts['t']) ) { |
30 | - $tablename = $opts['t']; |
|
30 | + $tablename = $opts['t']; |
|
31 | 31 | } else { |
32 | 32 | print "\nNo option for '-t' given.\n"; |
33 | - exit ( usage() ); |
|
33 | + exit ( usage() ); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | if ( ($typedescN = array_search( $tablename, array_column($tables, 'name'))) === FALSE ) { |
37 | - print "\nDB <$tablename> doesn't exist!\n"; |
|
38 | - syslog (LOG_EMERG, "$user: DB <$tablename> doesn't exist!"); |
|
39 | - exit ( usage() ); |
|
37 | + print "\nDB <$tablename> doesn't exist!\n"; |
|
38 | + syslog (LOG_EMERG, "$user: DB <$tablename> doesn't exist!"); |
|
39 | + exit ( usage() ); |
|
40 | 40 | } |
41 | 41 | $typedesc = array_keys($tables)[$typedescN]; |
42 | 42 | |
43 | 43 | if (! file_exists($filetemplate) ) { |
44 | - print "\nFile <$filetemplate> doesn't exists!\n"; |
|
44 | + print "\nFile <$filetemplate> doesn't exists!\n"; |
|
45 | 45 | syslog (LOG_EMERG, "$user: File <$filetemplate> doesn't exist!"); |
46 | - exit ( usage() ); |
|
46 | + exit ( usage() ); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | if (! in_array( $typedesc, array_keys($tables) ) ) { |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | |
54 | 54 | if (! $tables["$typedesc"]['active'] ) { |
55 | 55 | print "\nList <$typedesc> is not active. Please provide an active list name.\n"; |
56 | - exit ( usage() ); |
|
56 | + exit ( usage() ); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | |
@@ -73,10 +73,10 @@ discard block |
||
73 | 73 | |
74 | 74 | $mysqli = new mysqli($dbhost, $userdb, $pwd, $db, $dbport); |
75 | 75 | if ($mysqli->connect_error) { |
76 | - syslog (LOG_EMERG, $user.': Connect Error (' . $mysqli->connect_errno . ') ' |
|
77 | - . $mysqli->connect_error); |
|
78 | - exit ($user.': Connect Error (' . $mysqli->connect_errno . ') ' |
|
79 | - . $mysqli->connect_error); |
|
76 | + syslog (LOG_EMERG, $user.': Connect Error (' . $mysqli->connect_errno . ') ' |
|
77 | + . $mysqli->connect_error); |
|
78 | + exit ($user.': Connect Error (' . $mysqli->connect_errno . ') ' |
|
79 | + . $mysqli->connect_error); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | syslog(LOG_INFO, $user.': Successfully mysql connected to ' . $mysqli->host_info) ; |
@@ -87,14 +87,14 @@ discard block |
||
87 | 87 | while ($riga = $result->fetch_array(MYSQLI_ASSOC)) { |
88 | 88 | if (isListed($riga)) { |
89 | 89 | switch ( $tables["$typedesc"]['field'] ) { |
90 | - case 'ip': |
|
91 | - $element[] = long2ip($riga['ip']); |
|
92 | - break; |
|
93 | - case 'network': |
|
94 | - $element[] = long2ip($riga['network']).'/'.long2ip($riga['netmask']); |
|
95 | - break; |
|
96 | - default: |
|
97 | - $element[] = $riga["$type"]; |
|
90 | + case 'ip': |
|
91 | + $element[] = long2ip($riga['ip']); |
|
92 | + break; |
|
93 | + case 'network': |
|
94 | + $element[] = long2ip($riga['network']).'/'.long2ip($riga['netmask']); |
|
95 | + break; |
|
96 | + default: |
|
97 | + $element[] = $riga["$type"]; |
|
98 | 98 | } |
99 | 99 | } |
100 | 100 | } |
@@ -19,74 +19,74 @@ discard block |
||
19 | 19 | $user = username(); |
20 | 20 | |
21 | 21 | $opts = getopt('f:t:'); |
22 | -if ( isset($opts['f']) ) { |
|
22 | +if (isset($opts['f'])) { |
|
23 | 23 | $filetemplate = $opts['f']; |
24 | -} else { |
|
24 | +}else { |
|
25 | 25 | print "\nNo option for '-f' given.\n"; |
26 | - exit ( usage() ); |
|
26 | + exit (usage()); |
|
27 | 27 | } |
28 | 28 | |
29 | -if ( isset($opts['t']) ) { |
|
29 | +if (isset($opts['t'])) { |
|
30 | 30 | $tablename = $opts['t']; |
31 | -} else { |
|
31 | +}else { |
|
32 | 32 | print "\nNo option for '-t' given.\n"; |
33 | - exit ( usage() ); |
|
33 | + exit (usage()); |
|
34 | 34 | } |
35 | 35 | |
36 | -if ( ($typedescN = array_search( $tablename, array_column($tables, 'name'))) === FALSE ) { |
|
36 | +if (($typedescN = array_search($tablename, array_column($tables, 'name'))) === FALSE) { |
|
37 | 37 | print "\nDB <$tablename> doesn't exist!\n"; |
38 | - syslog (LOG_EMERG, "$user: DB <$tablename> doesn't exist!"); |
|
39 | - exit ( usage() ); |
|
38 | + syslog(LOG_EMERG, "$user: DB <$tablename> doesn't exist!"); |
|
39 | + exit (usage()); |
|
40 | 40 | } |
41 | 41 | $typedesc = array_keys($tables)[$typedescN]; |
42 | 42 | |
43 | -if (! file_exists($filetemplate) ) { |
|
43 | +if (!file_exists($filetemplate)) { |
|
44 | 44 | print "\nFile <$filetemplate> doesn't exists!\n"; |
45 | - syslog (LOG_EMERG, "$user: File <$filetemplate> doesn't exist!"); |
|
46 | - exit ( usage() ); |
|
45 | + syslog(LOG_EMERG, "$user: File <$filetemplate> doesn't exist!"); |
|
46 | + exit (usage()); |
|
47 | 47 | } |
48 | 48 | |
49 | -if (! in_array( $typedesc, array_keys($tables) ) ) { |
|
49 | +if (!in_array($typedesc, array_keys($tables))) { |
|
50 | 50 | print "\nUnknown list <$typedesc>. Please provide an existent list name.\n"; |
51 | - exit ( usage() ); |
|
51 | + exit (usage()); |
|
52 | 52 | } |
53 | 53 | |
54 | -if (! $tables["$typedesc"]['active'] ) { |
|
54 | +if (!$tables["$typedesc"]['active']) { |
|
55 | 55 | print "\nList <$typedesc> is not active. Please provide an active list name.\n"; |
56 | - exit ( usage() ); |
|
56 | + exit (usage()); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | |
60 | 60 | |
61 | -$now=new DateTime('NOW'); |
|
61 | +$now = new DateTime('NOW'); |
|
62 | 62 | $timeunix = $now->format('U'); |
63 | 63 | $dateRFC822 = $now->format('r'); |
64 | 64 | $year = $now->format('Y'); |
65 | -$rbltype= ($tables["$typedesc"]['bl']) ? 'Blocklist' : 'Whitelist'; |
|
65 | +$rbltype = ($tables["$typedesc"]['bl']) ? 'Blocklist' : 'Whitelist'; |
|
66 | 66 | |
67 | 67 | |
68 | 68 | $tmpl = file_get_contents($filetemplate); |
69 | -$arr_tpl_vars = array('{rblname}','{rbltype}','{date822}','{year}','{unixtimestamp}','{rblname64}','{hostname}'); |
|
70 | -$arr_tpl_data = array($typedesc,$rbltype,$dateRFC822,$year,$timeunix,base64_encode($typedesc),gethostname()); |
|
69 | +$arr_tpl_vars = array('{rblname}', '{rbltype}', '{date822}', '{year}', '{unixtimestamp}', '{rblname64}', '{hostname}'); |
|
70 | +$arr_tpl_data = array($typedesc, $rbltype, $dateRFC822, $year, $timeunix, base64_encode($typedesc), gethostname()); |
|
71 | 71 | $headerList = str_replace($arr_tpl_vars, $arr_tpl_data, $tmpl); |
72 | 72 | |
73 | 73 | |
74 | 74 | $mysqli = new mysqli($dbhost, $userdb, $pwd, $db, $dbport); |
75 | 75 | if ($mysqli->connect_error) { |
76 | - syslog (LOG_EMERG, $user.': Connect Error (' . $mysqli->connect_errno . ') ' |
|
76 | + syslog(LOG_EMERG, $user.': Connect Error ('.$mysqli->connect_errno.') ' |
|
77 | 77 | . $mysqli->connect_error); |
78 | - exit ($user.': Connect Error (' . $mysqli->connect_errno . ') ' |
|
78 | + exit ($user.': Connect Error ('.$mysqli->connect_errno.') ' |
|
79 | 79 | . $mysqli->connect_error); |
80 | 80 | } |
81 | 81 | |
82 | -syslog(LOG_INFO, $user.': Successfully mysql connected to ' . $mysqli->host_info) ; |
|
82 | +syslog(LOG_INFO, $user.': Successfully mysql connected to '.$mysqli->host_info); |
|
83 | 83 | |
84 | -$result = searchentry ($mysqli,'ALL',$tables["$typedesc"]); |
|
84 | +$result = searchentry($mysqli, 'ALL', $tables["$typedesc"]); |
|
85 | 85 | if ($result->num_rows) { |
86 | 86 | $element = array(); |
87 | 87 | while ($riga = $result->fetch_array(MYSQLI_ASSOC)) { |
88 | 88 | if (isListed($riga)) { |
89 | - switch ( $tables["$typedesc"]['field'] ) { |
|
89 | + switch ($tables["$typedesc"]['field']) { |
|
90 | 90 | case 'ip': |
91 | 91 | $element[] = long2ip($riga['ip']); |
92 | 92 | break; |
@@ -104,6 +104,6 @@ discard block |
||
104 | 104 | $mysqli->close(); |
105 | 105 | |
106 | 106 | /* Print to file */ |
107 | -file_put_contents( $tables["$typedesc"]['name'], $headerList . implode("\n",$element) ); |
|
107 | +file_put_contents($tables["$typedesc"]['name'], $headerList.implode("\n", $element)); |
|
108 | 108 | closelog(); |
109 | 109 | ?> |
@@ -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'); |
@@ -7,7 +7,7 @@ |
||
7 | 7 | print '<p>List of available Reports for '.date('l, d M Y', strtotime($theDate)).'</p><ul>'; |
8 | 8 | foreach($dir as $file) |
9 | 9 | { |
10 | - if ( basename($file) != basename(__FILE__) ) { |
|
10 | + if ( basename($file) != basename(__FILE__) ) { |
|
11 | 11 | $modalDiv = 'openModal'.basename($file); |
12 | 12 | echo '<li><a href="#'.$modalDiv.'">'.str_replace("-$theDate.html",'',basename($file)).'</a></li>'; |
13 | 13 | # echo '<li><pre><a href="'.basename($file).'" title="'.str_replace("-$theDate.html",'',basename($file))." of $theDate".'" onClick="Modalbox.show(this.href, {title: this.title, height: 600}); return false;">'.str_replace("-$theDate.html",'',basename($file)).'</a></pre></li>'; |
@@ -5,11 +5,11 @@ |
||
5 | 5 | |
6 | 6 | |
7 | 7 | print '<p>List of available Reports for '.date('l, d M Y', strtotime($theDate)).'</p><ul>'; |
8 | -foreach($dir as $file) |
|
8 | +foreach ($dir as $file) |
|
9 | 9 | { |
10 | - if ( basename($file) != basename(__FILE__) ) { |
|
10 | + if (basename($file) != basename(__FILE__)) { |
|
11 | 11 | $modalDiv = 'openModal'.basename($file); |
12 | - echo '<li><a href="#'.$modalDiv.'">'.str_replace("-$theDate.html",'',basename($file)).'</a></li>'; |
|
12 | + echo '<li><a href="#'.$modalDiv.'">'.str_replace("-$theDate.html", '', basename($file)).'</a></li>'; |
|
13 | 13 | # echo '<li><pre><a href="'.basename($file).'" title="'.str_replace("-$theDate.html",'',basename($file))." of $theDate".'" onClick="Modalbox.show(this.href, {title: this.title, height: 600}); return false;">'.str_replace("-$theDate.html",'',basename($file)).'</a></pre></li>'; |
14 | 14 | print <<<MODAL |
15 | 15 | <div id="$modalDiv" class="overlay"> |
@@ -21,7 +21,7 @@ |
||
21 | 21 | <?php |
22 | 22 | $reports = array(); |
23 | 23 | foreach (glob("*.{htm,html}", GLOB_BRACE) as $filename) { |
24 | - $reports[$filename] = filemtime($filename); |
|
24 | + $reports[$filename] = filemtime($filename); |
|
25 | 25 | } |
26 | 26 | arsort($reports); |
27 | 27 | $newest = array_shift($reports); |
@@ -31,9 +31,9 @@ |
||
31 | 31 | /* Write Calendar */ |
32 | 32 | $myCalendar = new tc_calendar("calSpam"); |
33 | 33 | $myCalendar->setIcon("calendar/images/iconCalendar.gif"); |
34 | - $myCalendar->setDate(date('d',$newest), date('m',$newest), date('Y',$newest)); |
|
34 | + $myCalendar->setDate(date('d', $newest), date('m', $newest), date('Y', $newest)); |
|
35 | 35 | $myCalendar->setPath("calendar/"); |
36 | - $myCalendar->setYearInterval(date('Y',$oldest), date('Y', $newest)); |
|
36 | + $myCalendar->setYearInterval(date('Y', $oldest), date('Y', $newest)); |
|
37 | 37 | $myCalendar->dateAllow(date('Y-m-d', $oldest), date('Y-m-d', $newest)); |
38 | 38 | $myCalendar->setDateFormat('j F Y'); |
39 | 39 | $myCalendar->startDate(1); |
@@ -5,81 +5,81 @@ discard block |
||
5 | 5 | // written by TJ @triconsole |
6 | 6 | //************************************* |
7 | 7 | |
8 | -class tc_date_main{ |
|
8 | +class tc_date_main { |
|
9 | 9 | var $mydate; |
10 | 10 | |
11 | - function tc_date_main(){ |
|
11 | + function tc_date_main() { |
|
12 | 12 | $this->mydate = strtotime(date('Y-m-d')); |
13 | 13 | } |
14 | 14 | |
15 | - function getDayOfWeek($cdate = ""){ |
|
16 | - if(($cdate != "" && $this->validDate($cdate)) || $cdate == ""){ |
|
15 | + function getDayOfWeek($cdate = "") { |
|
16 | + if (($cdate != "" && $this->validDate($cdate)) || $cdate == "") { |
|
17 | 17 | $tmp_date = ($cdate != "") ? strtotime($cdate) : $this->mydate; |
18 | 18 | return date('w', $tmp_date); |
19 | 19 | } |
20 | 20 | } |
21 | 21 | |
22 | - function getWeekNumber($cdate = ""){ |
|
23 | - if(($cdate != "" && $this->validDate($cdate)) || $cdate == ""){ |
|
22 | + function getWeekNumber($cdate = "") { |
|
23 | + if (($cdate != "" && $this->validDate($cdate)) || $cdate == "") { |
|
24 | 24 | $tmp_date = ($cdate != "") ? strtotime($cdate) : $this->mydate; |
25 | 25 | return date('W', $tmp_date); |
26 | 26 | } |
27 | 27 | } |
28 | 28 | |
29 | - function setDate($sdate){ |
|
30 | - if($this->validDate($sdate)) |
|
29 | + function setDate($sdate) { |
|
30 | + if ($this->validDate($sdate)) |
|
31 | 31 | $this->mydate = strtotime($sdate); |
32 | 32 | } |
33 | 33 | |
34 | - function getDate($format = "Y-m-d", $cdate = ""){ |
|
35 | - if(($cdate != "" && $this->validDate($cdate)) || $cdate == ""){ |
|
34 | + function getDate($format = "Y-m-d", $cdate = "") { |
|
35 | + if (($cdate != "" && $this->validDate($cdate)) || $cdate == "") { |
|
36 | 36 | $tmp_date = ($cdate != "") ? strtotime($cdate) : $this->mydate; |
37 | 37 | return date($format, $tmp_date); |
38 | 38 | }else return ""; |
39 | 39 | } |
40 | 40 | |
41 | - function setTimestamp($stime){ |
|
41 | + function setTimestamp($stime) { |
|
42 | 42 | $this->mydate = $stime; |
43 | 43 | } |
44 | 44 | |
45 | - function getTimestamp($cdate = ""){ |
|
46 | - if(($cdate != "" && $this->validDate($cdate)) || $cdate == ""){ |
|
45 | + function getTimestamp($cdate = "") { |
|
46 | + if (($cdate != "" && $this->validDate($cdate)) || $cdate == "") { |
|
47 | 47 | $tmp_date = ($cdate != "") ? strtotime($cdate) : $this->mydate; |
48 | 48 | return $tmp_date; |
49 | 49 | }else return 0; |
50 | 50 | } |
51 | 51 | |
52 | - function getDateFromTimestamp($stime, $format = "Y-m-d"){ |
|
53 | - if($stime && $stime > 0){ |
|
52 | + function getDateFromTimestamp($stime, $format = "Y-m-d") { |
|
53 | + if ($stime && $stime>0) { |
|
54 | 54 | return date($format, $stime); |
55 | 55 | }else return "0000-00-00"; |
56 | 56 | } |
57 | 57 | |
58 | - function addDay($format = "Y-m-d", $timespan, $cdate = ""){ |
|
59 | - if(($cdate != "" && $this->validDate($cdate)) || $cdate == ""){ |
|
58 | + function addDay($format = "Y-m-d", $timespan, $cdate = "") { |
|
59 | + if (($cdate != "" && $this->validDate($cdate)) || $cdate == "") { |
|
60 | 60 | $tmp_date = ($cdate != "") ? strtotime($cdate) : $this->mydate; |
61 | - return date($format, mktime(0,0,0,date('m', $tmp_date),(date('d', $tmp_date)+$timespan),date('Y', $tmp_date))); |
|
61 | + return date($format, mktime(0, 0, 0, date('m', $tmp_date), (date('d', $tmp_date)+$timespan), date('Y', $tmp_date))); |
|
62 | 62 | }else return "0000-00-00"; |
63 | 63 | } |
64 | 64 | |
65 | - function addMonth($format = "Y-m-d", $timespan, $cdate = ""){ |
|
66 | - if(($cdate != "" && $this->validDate($cdate)) || $cdate == ""){ |
|
65 | + function addMonth($format = "Y-m-d", $timespan, $cdate = "") { |
|
66 | + if (($cdate != "" && $this->validDate($cdate)) || $cdate == "") { |
|
67 | 67 | $tmp_date = ($cdate != "") ? strtotime($cdate) : $this->mydate; |
68 | - return date($format, mktime(0,0,0,(date('m', $tmp_date)+$timespan),date('d', $tmp_date),date('Y', $tmp_date))); |
|
68 | + return date($format, mktime(0, 0, 0, (date('m', $tmp_date)+$timespan), date('d', $tmp_date), date('Y', $tmp_date))); |
|
69 | 69 | }else return "0000-00-00"; |
70 | 70 | } |
71 | 71 | |
72 | - function addYear($format = "Y-m-d", $timespan, $cdate = ""){ |
|
73 | - if(($cdate != "" && $this->validDate($cdate)) || $cdate == ""){ |
|
72 | + function addYear($format = "Y-m-d", $timespan, $cdate = "") { |
|
73 | + if (($cdate != "" && $this->validDate($cdate)) || $cdate == "") { |
|
74 | 74 | $tmp_date = ($cdate != "") ? strtotime($cdate) : $this->mydate; |
75 | - return date($format, mktime(0,0,0,date('m', $tmp_date),date('d', $tmp_date),(date('Y', $tmp_date)+$timespan))); |
|
75 | + return date($format, mktime(0, 0, 0, date('m', $tmp_date), date('d', $tmp_date), (date('Y', $tmp_date)+$timespan))); |
|
76 | 76 | }else return "0000-00-00"; |
77 | 77 | } |
78 | 78 | |
79 | 79 | //return the number of day different between date1 and date2 |
80 | 80 | //if date1 omitted use set date |
81 | - function differentDate($date2, $date1 = ""){ |
|
82 | - if($this->validDate($date2)){ |
|
81 | + function differentDate($date2, $date1 = "") { |
|
82 | + if ($this->validDate($date2)) { |
|
83 | 83 | $date1 = ($date1 != "") ? strtotime($date1) : $this->mydate; |
84 | 84 | |
85 | 85 | $date_diff = $date1-strtotime($date2); |
@@ -89,8 +89,8 @@ discard block |
||
89 | 89 | |
90 | 90 | //check if date1 is before date2 |
91 | 91 | //if date1 omitted use set date |
92 | - function dateBefore($date2, $date1 = "", $equal = true){ |
|
93 | - if($this->validDate($date2)){ |
|
92 | + function dateBefore($date2, $date1 = "", $equal = true) { |
|
93 | + if ($this->validDate($date2)) { |
|
94 | 94 | $date1 = ($date1 != "") ? strtotime($date1) : $this->mydate; |
95 | 95 | $date2 = strtotime($date2); |
96 | 96 | return ($equal) ? $date1<=$date2 : $date1<$date2; |
@@ -99,19 +99,19 @@ discard block |
||
99 | 99 | |
100 | 100 | //check if date1 is after date2 |
101 | 101 | //if date1 omitted use set date |
102 | - function dateAfter($date2, $date1 = "", $equal = true){ |
|
103 | - if($this->validDate($date2)){ |
|
102 | + function dateAfter($date2, $date1 = "", $equal = true) { |
|
103 | + if ($this->validDate($date2)) { |
|
104 | 104 | $date1 = ($date1 != "") ? strtotime($date1) : $this->mydate; |
105 | 105 | $date2 = strtotime($date2); |
106 | 106 | return ($equal) ? $date1>=$date2 : $date1>$date2; |
107 | 107 | }else return false; |
108 | 108 | } |
109 | 109 | |
110 | - function validDate($date_str){ |
|
111 | - if($date_str != ""){ |
|
110 | + function validDate($date_str) { |
|
111 | + if ($date_str != "") { |
|
112 | 112 | $date_arr = explode("-", $date_str, 3); |
113 | 113 | |
114 | - 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]))){ |
|
114 | + 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 | 115 | return (checkdate($date_arr[1], $date_arr[2], $date_arr[0])) ? true : false; |
116 | 116 | }else return false; |
117 | 117 | }else return false; |
@@ -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 |
@@ -2,9 +2,9 @@ discard block |
||
2 | 2 | require_once("classes/tc_calendar.php"); |
3 | 3 | require_once("classes/tc_date.php"); |
4 | 4 | |
5 | -if(!isset($show_calendar_info)) $show_calendar_info = true; |
|
6 | -if(!isset($show_fb_info)) $show_fb_info = true; |
|
7 | -if(!isset($show_servertime_info)) $show_servertime_info = true; |
|
5 | +if (!isset($show_calendar_info)) $show_calendar_info = true; |
|
6 | +if (!isset($show_fb_info)) $show_fb_info = true; |
|
7 | +if (!isset($show_servertime_info)) $show_servertime_info = true; |
|
8 | 8 | |
9 | 9 | $tobj = new tc_calendar(""); |
10 | 10 | $version = $tobj->version; |
@@ -12,22 +12,22 @@ discard block |
||
12 | 12 | |
13 | 13 | $tdate = new tc_date(); |
14 | 14 | |
15 | -if(!isset($timezone)) $timezone = date_default_timezone_get(); |
|
15 | +if (!isset($timezone)) $timezone = date_default_timezone_get(); |
|
16 | 16 | |
17 | 17 | $wan_enabled = 0; |
18 | 18 | $new_version = 0; |
19 | -if($wan_enabled = @fsockopen("www.google.com", 80, $errno, $errstr, 1)){ |
|
20 | - if($check_version && $wan_enabled){ |
|
21 | - if(function_exists("file_get_contents")){ |
|
19 | +if ($wan_enabled = @fsockopen("www.google.com", 80, $errno, $errstr, 1)) { |
|
20 | + if ($check_version && $wan_enabled) { |
|
21 | + if (function_exists("file_get_contents")) { |
|
22 | 22 | $new_version = @file_get_contents("http://www.triconsole.com/php/tc_calendar_version.php?v=".$version); |
23 | 23 | } |
24 | 24 | } |
25 | 25 | } |
26 | -elseif(function_exists("file_get_contents")){ |
|
26 | +elseif (function_exists("file_get_contents")) { |
|
27 | 27 | $ctx = stream_context_create(array('http' => array('timeout' => 1))); |
28 | - $wan_enabled = @file_get_contents("http://www.google.com",null,$ctx,0,1); |
|
29 | - if($check_version && $wan_enabled){ |
|
30 | - if(function_exists("file_get_contents")){ |
|
28 | + $wan_enabled = @file_get_contents("http://www.google.com", null, $ctx, 0, 1); |
|
29 | + if ($check_version && $wan_enabled) { |
|
30 | + if (function_exists("file_get_contents")) { |
|
31 | 31 | # $new_version = @file_get_contents("http://www.triconsole.com/php/tc_calendar_version.php?v=".$version); |
32 | 32 | } |
33 | 33 | } |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | define("L_ABOUT", "<b>PHP Datepicker Calendar</b><br />Version: <b>".strval($version)."</b>".($new_version ? "<br /><b><font color=\"red\">Update available <a href=\"$WEB_SUPPORT\" target=\"_blank\">here</a> !</font></b>" : "").($wan_enabled ? ($show_fb_info ? "<br /><div class=\"fb-like\" data-href=\"https://www.facebook.com/DatePicker\" data-send=\"false\" data-layout=\"button_count\" data-show-faces=\"false\" data-font=\"tahoma\" ref=\"std_about_info\"></div>" : "") : "")."<br />©2006-".$tdate->getDate("Y")." <b><a href=\"$WEB_SUPPORT\" target=\"_blank\" title=\"http://triconsole.com\">$AUTHOR</a></b>".($show_servertime_info ? "<br />Server Timezone:".($timezone ? "<br />$timezone" : "")."<br /><span id=\"timecontainer\">".$tdate->getDate("Y-m-d H:i:s")."</span>" : "")); |
37 | 37 | |
38 | 38 | ?> |
39 | -<?php if($wan_enabled && $show_fb_info){ ?> |
|
39 | +<?php if ($wan_enabled && $show_fb_info) { ?> |
|
40 | 40 | <link href="calendar_info.css" rel="stylesheet" type="text/css" /> |
41 | 41 | <div id="fb-root"></div> |
42 | 42 | <script> |
@@ -2,9 +2,15 @@ discard block |
||
2 | 2 | require_once("classes/tc_calendar.php"); |
3 | 3 | require_once("classes/tc_date.php"); |
4 | 4 | |
5 | -if(!isset($show_calendar_info)) $show_calendar_info = true; |
|
6 | -if(!isset($show_fb_info)) $show_fb_info = true; |
|
7 | -if(!isset($show_servertime_info)) $show_servertime_info = true; |
|
5 | +if(!isset($show_calendar_info)) { |
|
6 | + $show_calendar_info = true; |
|
7 | +} |
|
8 | +if(!isset($show_fb_info)) { |
|
9 | + $show_fb_info = true; |
|
10 | +} |
|
11 | +if(!isset($show_servertime_info)) { |
|
12 | + $show_servertime_info = true; |
|
13 | +} |
|
8 | 14 | |
9 | 15 | $tobj = new tc_calendar(""); |
10 | 16 | $version = $tobj->version; |
@@ -12,7 +18,9 @@ discard block |
||
12 | 18 | |
13 | 19 | $tdate = new tc_date(); |
14 | 20 | |
15 | -if(!isset($timezone)) $timezone = date_default_timezone_get(); |
|
21 | +if(!isset($timezone)) { |
|
22 | + $timezone = date_default_timezone_get(); |
|
23 | +} |
|
16 | 24 | |
17 | 25 | $wan_enabled = 0; |
18 | 26 | $new_version = 0; |
@@ -22,8 +30,7 @@ discard block |
||
22 | 30 | $new_version = @file_get_contents("http://www.triconsole.com/php/tc_calendar_version.php?v=".$version); |
23 | 31 | } |
24 | 32 | } |
25 | -} |
|
26 | -elseif(function_exists("file_get_contents")){ |
|
33 | +} elseif(function_exists("file_get_contents")){ |
|
27 | 34 | $ctx = stream_context_create(array('http' => array('timeout' => 1))); |
28 | 35 | $wan_enabled = @file_get_contents("http://www.google.com",null,$ctx,0,1); |
29 | 36 | if($check_version && $wan_enabled){ |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | //timezone var, need to setup before any other tasks |
14 | 14 | $timezone = getParameter("tmz"); |
15 | 15 | |
16 | -if(!$timezone) $timezone = date_default_timezone_get(); |
|
16 | +if (!$timezone) $timezone = date_default_timezone_get(); |
|
17 | 17 | @date_default_timezone_set($timezone); |
18 | 18 | |
19 | 19 | $cdate = new tc_date(); |
@@ -23,9 +23,9 @@ discard block |
||
23 | 23 | $slm = getParameter("selected_month"); |
24 | 24 | $sly = getParameter("selected_year"); |
25 | 25 | |
26 | -if(!is_numeric($sld)) $sld = "00"; |
|
27 | -if(!is_numeric($slm)) $slm = "00"; |
|
28 | -if(!is_numeric($sly)) $sly = "0000"; |
|
26 | +if (!is_numeric($sld)) $sld = "00"; |
|
27 | +if (!is_numeric($slm)) $slm = "00"; |
|
28 | +if (!is_numeric($sly)) $sly = "0000"; |
|
29 | 29 | |
30 | 30 | $year_start = getParameter("year_start", "number", 0); |
31 | 31 | $year_end = getParameter("year_end", "number", 0); |
@@ -73,63 +73,63 @@ discard block |
||
73 | 73 | $theme = getParameter("thm"); |
74 | 74 | |
75 | 75 | //check year to be select in case of date_allow is set |
76 | -if(!$show_not_allow){ |
|
76 | +if (!$show_not_allow) { |
|
77 | 77 | if ($ta1_set && $cdate->validDate($time_allow1)) $year_start = $cdate->getDate('Y', $time_allow1); |
78 | 78 | if ($ta2_set && $cdate->validDate($time_allow2)) $year_end = $cdate->getDate('Y', $time_allow2); |
79 | 79 | } |
80 | 80 | |
81 | -if(isset($_REQUEST["m"])) |
|
81 | +if (isset($_REQUEST["m"])) |
|
82 | 82 | $m = getParameter("m", "number"); |
83 | -else{ |
|
84 | - if($slm != "00"){ |
|
83 | +else { |
|
84 | + if ($slm != "00") { |
|
85 | 85 | $m = $slm; |
86 | - }else{ |
|
87 | - if($ta2_set && $year_end > 0){ |
|
86 | + }else { |
|
87 | + if ($ta2_set && $year_end>0) { |
|
88 | 88 | //compare which one is more |
89 | 89 | $year_allow2 = $cdate->getDate('Y', $time_allow2); |
90 | - if($year_allow2 >= $year_end){ |
|
90 | + if ($year_allow2>=$year_end) { |
|
91 | 91 | //use time_allow2 |
92 | 92 | $m = ($cdate->dateBefore($time_allow2)) ? $cdate->getDate("m") : $cdate->getDate('m', $time_allow2); |
93 | - }else{ |
|
93 | + }else { |
|
94 | 94 | //use year_end |
95 | - $m = ($year_end > $cdate->getDate("Y")) ? $cdate->getDate("m") : 12; |
|
95 | + $m = ($year_end>$cdate->getDate("Y")) ? $cdate->getDate("m") : 12; |
|
96 | 96 | } |
97 | - }elseif($ta2_set){ |
|
97 | + }elseif ($ta2_set) { |
|
98 | 98 | $m = ($cdate->dateBefore($time_allow2)) ? $cdate->getDate("m") : $cdate->getDate('m', $time_allow2); |
99 | - }elseif($year_end > 0){ |
|
100 | - $m = ($year_end > $cdate->getDate("Y")) ? $cdate->getDate("m") : 12; //date('m') |
|
101 | - }else{ |
|
99 | + }elseif ($year_end>0) { |
|
100 | + $m = ($year_end>$cdate->getDate("Y")) ? $cdate->getDate("m") : 12; //date('m') |
|
101 | + }else { |
|
102 | 102 | $m = $cdate->getDate("m"); |
103 | 103 | } |
104 | 104 | } |
105 | 105 | } |
106 | 106 | |
107 | -if($m < 1 && $m > 12) $m = $cdate->getDate("m"); |
|
107 | +if ($m<1 && $m>12) $m = $cdate->getDate("m"); |
|
108 | 108 | |
109 | 109 | $m = str_pad($m, 2, "0", STR_PAD_LEFT); |
110 | 110 | |
111 | 111 | $cyr = ($sly != "0000") ? true : false; |
112 | -if($cyr && $sly && $sly < $year_start) $sly = $year_start; |
|
113 | -if($cyr && $sly && $sly > $year_end) $sly = $year_end; |
|
112 | +if ($cyr && $sly && $sly<$year_start) $sly = $year_start; |
|
113 | +if ($cyr && $sly && $sly>$year_end) $sly = $year_end; |
|
114 | 114 | |
115 | -if(isset($_REQUEST["y"])) |
|
115 | +if (isset($_REQUEST["y"])) |
|
116 | 116 | $y = getParameter("y", "number"); |
117 | 117 | else |
118 | 118 | $y = ($cyr) ? $sly : $cdate->getDate("Y"); |
119 | 119 | |
120 | -if($y <= 0) $y = $cdate->getDate("Y"); |
|
120 | +if ($y<=0) $y = $cdate->getDate("Y"); |
|
121 | 121 | |
122 | 122 | // ensure m-y fits date allow range |
123 | 123 | if (!$show_not_allow) { |
124 | 124 | if ($ta1_set) { |
125 | 125 | $m1 = $cdate->getDate('m', $time_allow1); |
126 | 126 | $y1 = $cdate->getDate('Y', $time_allow1); |
127 | - if ($y == $y1 && (int)$m < (int)$m1) $m = $m1; |
|
127 | + if ($y == $y1 && (int) $m<(int) $m1) $m = $m1; |
|
128 | 128 | } |
129 | 129 | if ($ta2_set) { |
130 | 130 | $m2 = $cdate->getDate('m', $time_allow2); |
131 | 131 | $y2 = $cdate->getDate('Y', $time_allow2); |
132 | - if ($y == $y2 && (int)$m > (int)$m2) $m = $m2; |
|
132 | + if ($y == $y2 && (int) $m>(int) $m2) $m = $m2; |
|
133 | 133 | } |
134 | 134 | } |
135 | 135 | |
@@ -147,15 +147,15 @@ discard block |
||
147 | 147 | $cobj->setTimezone($timezone); //set for further usage, nothing for now |
148 | 148 | |
149 | 149 | $theme_path = ($theme != "") ? $cobj->getThemePath($theme) : ""; |
150 | -if(!is_file($theme_path)) $theme_path = ""; |
|
150 | +if (!is_file($theme_path)) $theme_path = ""; |
|
151 | 151 | |
152 | 152 | //check and show default calendar month and year on valid range of date_allow |
153 | -if(!isset($_REQUEST["m"])){ |
|
154 | - if($time_allow1 != ""){ |
|
153 | +if (!isset($_REQUEST["m"])) { |
|
154 | + if ($time_allow1 != "") { |
|
155 | 155 | //get date of time allow1 |
156 | - if($cdate->validDate($time_allow1)){ |
|
156 | + if ($cdate->validDate($time_allow1)) { |
|
157 | 157 | //check valid if today is after date_allow1 |
158 | - if(!$cdate->dateAfter($time_allow1, $today)){ |
|
158 | + if (!$cdate->dateAfter($time_allow1, $today)) { |
|
159 | 159 | //reset default calendar display |
160 | 160 | $y = $cdate->getDate('Y', $time_allow1); |
161 | 161 | $m = $cdate->getDate('m', $time_allow1); |
@@ -168,23 +168,23 @@ discard block |
||
168 | 168 | $year_end = $cobj->year_end; |
169 | 169 | |
170 | 170 | //check year display in valid range |
171 | -if($y >= $year_end) $y = $year_end; |
|
172 | -if($y <= $year_start) $y = $year_start; |
|
171 | +if ($y>=$year_end) $y = $year_end; |
|
172 | +if ($y<=$year_start) $y = $year_start; |
|
173 | 173 | |
174 | 174 | $total_thismonth = $cobj->total_days($m, $y); |
175 | 175 | |
176 | -if($m == 1){ |
|
176 | +if ($m == 1) { |
|
177 | 177 | $previous_month = 12; |
178 | 178 | $previous_year = $y-1; |
179 | -}else{ |
|
179 | +}else { |
|
180 | 180 | $previous_month = $m-1; |
181 | 181 | $previous_year = $y; |
182 | 182 | } |
183 | 183 | |
184 | -if($m == 12){ |
|
184 | +if ($m == 12) { |
|
185 | 185 | $next_month = 1; |
186 | 186 | $next_year = $y+1; |
187 | -}else{ |
|
187 | +}else { |
|
188 | 188 | $next_month = $m+1; |
189 | 189 | $next_year = $y; |
190 | 190 | } |
@@ -193,13 +193,13 @@ discard block |
||
193 | 193 | |
194 | 194 | $firstdate = $cdate->getDayOfWeek($y."-".$m."-1"); //first date of month, 0 (for Sunday) through 6 (for Saturday) |
195 | 195 | |
196 | -if($firstdate == $startDate){ |
|
196 | +if ($firstdate == $startDate) { |
|
197 | 197 | //skip last month |
198 | 198 | $startwrite = $total_lastmonth+1; |
199 | -}elseif($firstdate < $startDate){ |
|
200 | - $startwrite = $total_lastmonth - (6-($startDate-$firstdate)); |
|
201 | -}else{ |
|
202 | - $startwrite = $total_lastmonth - ($firstdate - $startDate - 1); |
|
199 | +}elseif ($firstdate<$startDate) { |
|
200 | + $startwrite = $total_lastmonth-(6-($startDate-$firstdate)); |
|
201 | +}else { |
|
202 | + $startwrite = $total_lastmonth-($firstdate-$startDate-1); |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | //-------------------------------- |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | $row_count = 0; |
213 | 213 | |
214 | 214 | //write previous month |
215 | -for($day=$startwrite; $day<=$total_lastmonth; $day++){ |
|
215 | +for ($day = $startwrite; $day<=$total_lastmonth; $day++) { |
|
216 | 216 | $calendar_rows[$row_count][] = array($day, "", "othermonth", ""); |
217 | 217 | $dayinweek_counter++; |
218 | 218 | |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | $prev_d = $y."-".$prev_m."-".$day; |
221 | 221 | |
222 | 222 | $wknum = $cdate->getWeekNumber($prev_d); |
223 | - if(!isset($week_rows[$row_count][$wknum])){ |
|
223 | + if (!isset($week_rows[$row_count][$wknum])) { |
|
224 | 224 | $week_rows[$row_count][$wknum] = 1; |
225 | 225 | }else $week_rows[$row_count][$wknum] = $week_rows[$row_count][$wknum]+1; |
226 | 226 | } |
@@ -228,31 +228,31 @@ discard block |
||
228 | 228 | $pvMonthTime = $previous_year."-".$previous_month."-".$total_lastmonth; |
229 | 229 | |
230 | 230 | //check lastmonth is on allowed date |
231 | -if($ta1_set && !$show_not_allow){ |
|
232 | - if($cdate->dateBefore($pvMonthTime, $time_allow1)){ |
|
231 | +if ($ta1_set && !$show_not_allow) { |
|
232 | + if ($cdate->dateBefore($pvMonthTime, $time_allow1)) { |
|
233 | 233 | $show_previous = true; |
234 | 234 | }else $show_previous = false; |
235 | 235 | }else $show_previous = true; //always show when not set |
236 | 236 | |
237 | 237 | $date_num = $cdate->getDayOfWeek(($previous_year."-".$previous_month."-".$total_lastmonth)); |
238 | -if(($startDate == 0 && $date_num == 6) || ($startDate > 0 && $date_num == $startDate-1) && $startwrite<$total_lastmonth){ |
|
239 | - if(isset($calendar_rows[0])) $row_count++; |
|
238 | +if (($startDate == 0 && $date_num == 6) || ($startDate>0 && $date_num == $startDate-1) && $startwrite<$total_lastmonth) { |
|
239 | + if (isset($calendar_rows[0])) $row_count++; |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | $dp_time = ($date_pair_value) ? $date_pair_value : ""; |
243 | 243 | |
244 | 244 | $select_days = array(); |
245 | -if($sld>0 && $slm>0 && $sly>0){ |
|
245 | +if ($sld>0 && $slm>0 && $sly>0) { |
|
246 | 246 | $sldate = "$sly-$slm-$sld"; |
247 | 247 | |
248 | - for($i=0; $i<$interval; $i++){ |
|
248 | + for ($i = 0; $i<$interval; $i++) { |
|
249 | 249 | $this_day = $cdate->addDay("Y-m-d", $i, $sldate); |
250 | 250 | $select_days[] = $this_day; |
251 | 251 | } |
252 | 252 | } |
253 | 253 | |
254 | 254 | //write current month |
255 | -for($day=1; $day<=$total_thismonth; $day++){ |
|
255 | +for ($day = 1; $day<=$total_thismonth; $day++) { |
|
256 | 256 | $date_str = $y."-".str_pad($m, 2, "0", STR_PAD_LEFT)."-".str_pad($day, 2, "0", STR_PAD_LEFT); |
257 | 257 | |
258 | 258 | $date_num = $cdate->getDayOfWeek($date_str); |
@@ -267,40 +267,40 @@ discard block |
||
267 | 267 | $dateLink = true; |
268 | 268 | |
269 | 269 | //check date allowed |
270 | - if($ta1_set && $ta2_set){ |
|
270 | + if ($ta1_set && $ta2_set) { |
|
271 | 271 | //both date specified |
272 | 272 | $dateLink = ($cdate->dateBefore($date_str, $time_allow1) && $cdate->dateAfter($date_str, $time_allow2)) ? true : false; |
273 | - }elseif($ta1_set){ |
|
273 | + }elseif ($ta1_set) { |
|
274 | 274 | //only date 1 specified |
275 | 275 | $dateLink = $cdate->dateBefore($date_str, $time_allow1) ? true : false; |
276 | - }elseif($ta2_set){ |
|
276 | + }elseif ($ta2_set) { |
|
277 | 277 | //only date 2 specified |
278 | 278 | $dateLink = $cdate->dateAfter($date_str, $time_allow2) ? true : false; |
279 | - }else{ |
|
279 | + }else { |
|
280 | 280 | //no date allow specified, assume show all |
281 | 281 | $dateLink = true; |
282 | 282 | } |
283 | 283 | |
284 | - if($dateLink){ |
|
284 | + if ($dateLink) { |
|
285 | 285 | //check for disable days |
286 | - if(in_array(strtolower($day_txt), $cobj->dsb_days) !== false){ |
|
286 | + if (in_array(strtolower($day_txt), $cobj->dsb_days) !== false) { |
|
287 | 287 | $dateLink = false; |
288 | 288 | } |
289 | 289 | } |
290 | 290 | |
291 | 291 | //check specific date |
292 | - if($dateLink){ |
|
293 | - if(is_array($sp_dates) && sizeof($sp_dates) > 0){ |
|
292 | + if ($dateLink) { |
|
293 | + if (is_array($sp_dates) && sizeof($sp_dates)>0) { |
|
294 | 294 | //check if it is current date |
295 | 295 | $sp_found = false; |
296 | 296 | |
297 | 297 | //check on yearly recursive |
298 | - if(isset($sp_dates[2]) && is_array($sp_dates[2])){ |
|
299 | - foreach($sp_dates[2] as $sp_time){ |
|
300 | - if($sp_time != ""){ |
|
301 | - $sp_time_md = (int)$cdate->getDate('md', $sp_time); //date('md', $sp_time); |
|
302 | - $this_md = (int)$cdate->getDate('md', $date_str); //date('md', $currentTime); |
|
303 | - if($sp_time_md == $this_md){ |
|
298 | + if (isset($sp_dates[2]) && is_array($sp_dates[2])) { |
|
299 | + foreach ($sp_dates[2] as $sp_time) { |
|
300 | + if ($sp_time != "") { |
|
301 | + $sp_time_md = (int) $cdate->getDate('md', $sp_time); //date('md', $sp_time); |
|
302 | + $this_md = (int) $cdate->getDate('md', $date_str); //date('md', $currentTime); |
|
303 | + if ($sp_time_md == $this_md) { |
|
304 | 304 | $sp_found = true; |
305 | 305 | break; |
306 | 306 | } |
@@ -309,11 +309,11 @@ discard block |
||
309 | 309 | } |
310 | 310 | |
311 | 311 | //check on monthly recursive |
312 | - if(isset($sp_dates[1]) && is_array($sp_dates[1]) && !$sp_found){ |
|
313 | - foreach($sp_dates[1] as $sp_time){ |
|
314 | - if($sp_time != "" && $sp_time > 0){ |
|
315 | - $sp_time_d = (int)$cdate->getDate('d', $sp_time); //date('d', $sp_time); |
|
316 | - if($sp_time_d == $day){ |
|
312 | + if (isset($sp_dates[1]) && is_array($sp_dates[1]) && !$sp_found) { |
|
313 | + foreach ($sp_dates[1] as $sp_time) { |
|
314 | + if ($sp_time != "" && $sp_time>0) { |
|
315 | + $sp_time_d = (int) $cdate->getDate('d', $sp_time); //date('d', $sp_time); |
|
316 | + if ($sp_time_d == $day) { |
|
317 | 317 | $sp_found = true; |
318 | 318 | break; |
319 | 319 | } |
@@ -322,11 +322,11 @@ discard block |
||
322 | 322 | } |
323 | 323 | |
324 | 324 | //check on no recursive |
325 | - if(isset($sp_dates[0]) && is_array($sp_dates[0]) && !$sp_found){ |
|
325 | + if (isset($sp_dates[0]) && is_array($sp_dates[0]) && !$sp_found) { |
|
326 | 326 | $sp_found = in_array($date_str, $sp_dates[0]); |
327 | 327 | } |
328 | 328 | |
329 | - switch($sp_type){ |
|
329 | + switch ($sp_type) { |
|
330 | 330 | case 0: |
331 | 331 | default: |
332 | 332 | //disabled specific and enabled others |
@@ -340,23 +340,23 @@ discard block |
||
340 | 340 | } |
341 | 341 | } |
342 | 342 | |
343 | - if($date_pair_value){ |
|
343 | + if ($date_pair_value) { |
|
344 | 344 | //check date_pair1 & 2 |
345 | - if($date_pair1 && $date_pair_value != "0000-00-00" && $cdate->dateAfter($date_pair_value, $date_str) && (($slm>0 && $sld>0 && $sly>0) && $cdate->dateBefore("$sly-$slm-$sld", $date_str))){ //set date only after date_pair1 |
|
346 | - if(!in_array("select", $htmlClass)) |
|
345 | + if ($date_pair1 && $date_pair_value != "0000-00-00" && $cdate->dateAfter($date_pair_value, $date_str) && (($slm>0 && $sld>0 && $sly>0) && $cdate->dateBefore("$sly-$slm-$sld", $date_str))) { //set date only after date_pair1 |
|
346 | + if (!in_array("select", $htmlClass)) |
|
347 | 347 | $htmlClass[] = "select"; |
348 | 348 | } |
349 | 349 | |
350 | - if($date_pair2 && $date_pair_value != "0000-00-00" && $cdate->dateBefore($date_pair_value, $date_str) && (($slm>0 && $sld>0 && $sly>0) && $cdate->dateAfter("$sly-$slm-$sld", $date_str))){ //set date only before date_pair2 |
|
351 | - if(!in_array("select", $htmlClass)) |
|
350 | + if ($date_pair2 && $date_pair_value != "0000-00-00" && $cdate->dateBefore($date_pair_value, $date_str) && (($slm>0 && $sld>0 && $sly>0) && $cdate->dateAfter("$sly-$slm-$sld", $date_str))) { //set date only before date_pair2 |
|
351 | + if (!in_array("select", $htmlClass)) |
|
352 | 352 | $htmlClass[] = "select"; |
353 | 353 | } |
354 | 354 | } |
355 | 355 | |
356 | 356 | $htmlClass[] = strtolower($day_txt); |
357 | 357 | |
358 | - if($dateLink){ |
|
359 | - if(in_array($date_str, $select_days) && !in_array("select", $htmlClass)){ |
|
358 | + if ($dateLink) { |
|
359 | + if (in_array($date_str, $select_days) && !in_array("select", $htmlClass)) { |
|
360 | 360 | $htmlClass[] = "select"; |
361 | 361 | } |
362 | 362 | |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | $class = implode(" ", $htmlClass); |
365 | 365 | |
366 | 366 | $calendar_rows[$row_count][] = array($day, "javascript:selectDay('".str_pad($day, 2, "0", STR_PAD_LEFT)."');", $class, "$y".str_pad($m, 2, "0", STR_PAD_LEFT).str_pad($day, 2, "0", STR_PAD_LEFT)); |
367 | - }else{ |
|
367 | + }else { |
|
368 | 368 | $htmlClass[] = "disabledate"; |
369 | 369 | $class = implode(" ", $htmlClass); |
370 | 370 | |
@@ -372,12 +372,12 @@ discard block |
||
372 | 372 | $calendar_rows[$row_count][] = array($day, "", $class, "$y".str_pad($m, 2, "0", STR_PAD_LEFT).str_pad($day, 2, "0", STR_PAD_LEFT)); |
373 | 373 | |
374 | 374 | //check if selected date is a disabled date |
375 | - if($date_str == $sly."-".str_pad($slm, 2, "0", STR_PAD_LEFT)."-".str_pad($sld, 2, "0", STR_PAD_LEFT)){ |
|
375 | + if ($date_str == $sly."-".str_pad($slm, 2, "0", STR_PAD_LEFT)."-".str_pad($sld, 2, "0", STR_PAD_LEFT)) { |
|
376 | 376 | //disabled |
377 | 377 | //$sly = $slm = $sld = ""; |
378 | 378 | } |
379 | 379 | } |
380 | - if(($startDate == 0 && $date_num == 6) || ($startDate > 0 && $date_num == $startDate-1)){ |
|
380 | + if (($startDate == 0 && $date_num == 6) || ($startDate>0 && $date_num == $startDate-1)) { |
|
381 | 381 | $row_count++; |
382 | 382 | |
383 | 383 | $dayinweek_counter = 0; |
@@ -385,19 +385,19 @@ discard block |
||
385 | 385 | |
386 | 386 | $wknum = $cdate->getWeekNumber(($y."-".$m."-".$day)); |
387 | 387 | |
388 | - if(!isset($week_rows[$row_count][$wknum])){ |
|
388 | + if (!isset($week_rows[$row_count][$wknum])) { |
|
389 | 389 | $week_rows[$row_count][$wknum] = 1; |
390 | 390 | }else $week_rows[$row_count][$wknum] = $week_rows[$row_count][$wknum]+1; |
391 | 391 | } |
392 | 392 | |
393 | 393 | //write next other month |
394 | 394 | $write_end_days = (6-$dayinweek_counter)+1; |
395 | -if($write_end_days > 0){ |
|
396 | - for($day=1; $day<=$write_end_days; $day++){ |
|
395 | +if ($write_end_days>0) { |
|
396 | + for ($day = 1; $day<=$write_end_days; $day++) { |
|
397 | 397 | $calendar_rows[$row_count][] = array($day, "", "othermonth", ""); |
398 | 398 | |
399 | 399 | $wknum = $cdate->getWeekNumber($cdate->addMonth("Y-m-d", 1, ($y."-".$m."-".$day))); //date('W', mktime(0,0,0, $m+1, $day, $y)); |
400 | - if(!isset($week_rows[$row_count][$wknum])){ |
|
400 | + if (!isset($week_rows[$row_count][$wknum])) { |
|
401 | 401 | $week_rows[$row_count][$wknum] = 1; |
402 | 402 | }else $week_rows[$row_count][$wknum] = $week_rows[$row_count][$wknum]+1; |
403 | 403 | } |
@@ -405,14 +405,14 @@ discard block |
||
405 | 405 | } |
406 | 406 | |
407 | 407 | //write fulfil row to 6 rows |
408 | -for($day=$row_count; $day<6; $day++){ |
|
408 | +for ($day = $row_count; $day<6; $day++) { |
|
409 | 409 | $tmpday = $write_end_days+1; |
410 | - for($f=$tmpday; $f<=($tmpday+6); $f++){ |
|
410 | + for ($f = $tmpday; $f<=($tmpday+6); $f++) { |
|
411 | 411 | $calendar_rows[$row_count][] = array($f, "", "othermonth", ""); |
412 | 412 | |
413 | 413 | $wknum = $cdate->getWeekNumber($cdate->addMonth("Y-m-d", 1, ($y."-".$m."-".$f))); //date('W', mktime(0,0,0, $m+1, $f, $y)); |
414 | 414 | |
415 | - if(!isset($week_rows[$row_count][$wknum])){ |
|
415 | + if (!isset($week_rows[$row_count][$wknum])) { |
|
416 | 416 | $week_rows[$row_count][$wknum] = 1; |
417 | 417 | }else $week_rows[$row_count][$wknum] = $week_rows[$row_count][$wknum]+1; |
418 | 418 | } |
@@ -420,20 +420,20 @@ discard block |
||
420 | 420 | } |
421 | 421 | |
422 | 422 | //check next month is on allowed date |
423 | -if($ta2_set && !$show_not_allow){ |
|
423 | +if ($ta2_set && !$show_not_allow) { |
|
424 | 424 | $nxMonthTime = $next_year."-".$next_month."-1"; |
425 | - if($cdate->dateAfter($nxMonthTime, $time_allow2)){ |
|
425 | + if ($cdate->dateAfter($nxMonthTime, $time_allow2)) { |
|
426 | 426 | $show_next = true; |
427 | 427 | }else $show_next = false; |
428 | 428 | }else $show_next = true; //always show when not set |
429 | 429 | ?> |
430 | 430 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
431 | -<html xmlns="http://www.w3.org/1999/xhtml"<?php if($rtl) echo(" dir=\"rtl\""); ?>> |
|
431 | +<html xmlns="http://www.w3.org/1999/xhtml"<?php if ($rtl) echo(" dir=\"rtl\""); ?>> |
|
432 | 432 | <head> |
433 | 433 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
434 | 434 | <title>TriConsole.com - PHP Calendar Date Picker</title> |
435 | 435 | <link href="calendar.css" rel="stylesheet" type="text/css" /> |
436 | -<?php if($theme_path){ ?> |
|
436 | +<?php if ($theme_path) { ?> |
|
437 | 437 | <link href="<?php echo($theme_path); ?>" rel="stylesheet" type="text/css" /> |
438 | 438 | <?php } ?> |
439 | 439 | <script type="text/javascript"> |
@@ -442,8 +442,8 @@ discard block |
||
442 | 442 | var today_month = "<?php echo($cdate->getDate('m')); ?>"; |
443 | 443 | var today_year = "<?php echo($cdate->getDate('Y')); ?>"; |
444 | 444 | var obj_name = "<?php echo($objname); ?>"; |
445 | -var current_month = "<?php echo($m);?>"; |
|
446 | -var current_year = "<?php echo($y);?>"; |
|
445 | +var current_month = "<?php echo($m); ?>"; |
|
446 | +var current_year = "<?php echo($y); ?>"; |
|
447 | 447 | |
448 | 448 | var this_time = "<?php echo(date("F d, Y H:i:s", time())); ?>"; |
449 | 449 | //--> |
@@ -454,12 +454,12 @@ discard block |
||
454 | 454 | function submitNow(dvalue, mvalue, yvalue){ |
455 | 455 | <?php |
456 | 456 | //write auto submit script |
457 | - if($auto_submit){ |
|
457 | + if ($auto_submit) { |
|
458 | 458 | echo("if(yvalue>0 && mvalue>0 && dvalue>0){\n"); |
459 | - if($form_name){ |
|
459 | + if ($form_name) { |
|
460 | 460 | //submit value by post form |
461 | 461 | echo("window.parent.document.".$form_name.".submit();\n"); |
462 | - }elseif($target_url){ |
|
462 | + }elseif ($target_url) { |
|
463 | 463 | //submit value by get method |
464 | 464 | echo("var date_selected = yvalue + \"-\" + mvalue + \"-\" + dvalue;\n"); |
465 | 465 | echo("window.parent.location.href='".$target_url."?".$objname."='+date_selected;\n"); |
@@ -474,25 +474,25 @@ discard block |
||
474 | 474 | <body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"> |
475 | 475 | <span id="calendar-page" class="font"> |
476 | 476 | <div id="calendar-header" align="center"> |
477 | - <?php if($show_calendar_info) include("calendar_info.php"); ?> |
|
478 | - <?php if($dp && !$auto_hide){ ?> |
|
477 | + <?php if ($show_calendar_info) include("calendar_info.php"); ?> |
|
478 | + <?php if ($dp && !$auto_hide) { ?> |
|
479 | 479 | <div style="float: right;" class="closeme"><a href="javascript:closeMe();"><img src="images/close.gif" border="0" alt="Close" title="Close" /></a></div> |
480 | 480 | <?php } ?> |
481 | 481 | |
482 | 482 | <?php |
483 | - if(sizeof($cobj->warning_msgs)>0){ |
|
483 | + if (sizeof($cobj->warning_msgs)>0) { |
|
484 | 484 | echo("<div id=\"calendar-alert\">".implode(", ", $cobj->warning_msgs)."</div>"); |
485 | 485 | } |
486 | 486 | ?> |
487 | 487 | |
488 | - <form id="calendarform" name="calendarform" method="post" action="<?php echo($thispage);?>"> |
|
488 | + <form id="calendarform" name="calendarform" method="post" action="<?php echo($thispage); ?>"> |
|
489 | 489 | <table align="center" cellpadding="1" cellspacing="0"> |
490 | 490 | <tr> |
491 | 491 | <td align="right"><select name="m" onchange="javascript:submitCalendar();" class="font"> |
492 | 492 | <?php |
493 | 493 | $monthnames = $cobj->getMonthNames(); |
494 | - for($f=1; $f<=sizeof($monthnames); $f++){ |
|
495 | - $selected = ($f == (int)$m) ? " selected='selected'" : ""; |
|
494 | + for ($f = 1; $f<=sizeof($monthnames); $f++) { |
|
495 | + $selected = ($f == (int) $m) ? " selected='selected'" : ""; |
|
496 | 496 | echo("<option value=\"".str_pad($f, 2, "0", STR_PAD_LEFT)."\"".$selected.">".$monthnames[$f-1]."</option>"); |
497 | 497 | } |
498 | 498 | ?> |
@@ -501,7 +501,7 @@ discard block |
||
501 | 501 | $thisyear = $cdate->getDate('Y'); |
502 | 502 | |
503 | 503 | //write year options |
504 | - for($year=$year_end; $year>=$year_start; $year--){ |
|
504 | + for ($year = $year_end; $year>=$year_start; $year--) { |
|
505 | 505 | $selected = ($year == $y) ? " selected='selected'" : ""; |
506 | 506 | echo("<option value=\"".$year."\"".$selected.">".$year."</option>"); |
507 | 507 | } |
@@ -510,44 +510,44 @@ discard block |
||
510 | 510 | </td> |
511 | 511 | </tr> |
512 | 512 | </table> |
513 | - <input name="selected_day" type="hidden" id="selected_day" value="<?php echo($sld);?>" /> |
|
514 | - <input name="selected_month" type="hidden" id="selected_month" value="<?php echo($slm);?>" /> |
|
515 | - <input name="selected_year" type="hidden" id="selected_year" value="<?php echo($sly);?>" /> |
|
516 | - <input name="year_start" type="hidden" id="year_start" value="<?php echo($cobj->year_start_input);?>" /> |
|
517 | - <input name="year_end" type="hidden" id="year_end" value="<?php echo($cobj->year_end_input);?>" /> |
|
518 | - <input name="objname" type="hidden" id="objname" value="<?php echo($objname);?>" /> |
|
519 | - <input name="dp" type="hidden" id="dp" value="<?php echo($dp);?>" /> |
|
520 | - |
|
521 | - <input name="da1" type="hidden" id="da1" value="<?php echo($time_allow1);?>" /> |
|
522 | - <input name="da2" type="hidden" id="da2" value="<?php echo($time_allow2);?>" /> |
|
523 | - <input name="sna" type="hidden" id="sna" value="<?php echo($show_not_allow);?>" /> |
|
524 | - <input name="aut" type="hidden" id="aut" value="<?php echo($auto_submit);?>" /> |
|
525 | - <input name="frm" type="hidden" id="frm" value="<?php echo($form_name);?>" /> |
|
526 | - <input name="tar" type="hidden" id="tar" value="<?php echo($target_url);?>" /> |
|
527 | - <input name="inp" type="hidden" id="inp" value="<?php echo($show_input);?>" /> |
|
528 | - <input name="fmt" type="hidden" id="fmt" value="<?php echo($date_format);?>" /> |
|
529 | - <input name="dis" type="hidden" id="dis" value="<?php echo($dsb_txt);?>" /> |
|
530 | - |
|
531 | - <input name="pr1" type="hidden" id="pr1" value="<?php echo($date_pair1);?>" /> |
|
532 | - <input name="pr2" type="hidden" id="pr2" value="<?php echo($date_pair2);?>" /> |
|
533 | - <input name="prv" type="hidden" id="prv" value="<?php echo($date_pair_value);?>" /> |
|
534 | - <input name="pth" type="hidden" id="pth" value="<?php echo($path);?>" /> |
|
535 | - |
|
536 | - <input name="spd" type="hidden" id="spd" value="<?php echo(htmlspecialchars($cobj->check_json_encode($sp_dates), ENT_QUOTES));?>" /> |
|
537 | - <input name="spt" type="hidden" id="spt" value="<?php echo($sp_type);?>" /> |
|
538 | - |
|
539 | - <input name="och" type="hidden" id="och" value="<?php echo(urldecode($tc_onchanged));?>" /> |
|
540 | - |
|
541 | - <input name="str" type="hidden" id="str" value="<?php echo($startDate);?>" /> |
|
542 | - <input name="rtl" type="hidden" id="rtl" value="<?php echo($rtl);?>" /> |
|
543 | - <input name="wks" type="hidden" id="wks" value="<?php echo($show_weeks);?>" /> |
|
544 | - <input name="int" type="hidden" id="int" value="<?php echo($interval);?>" /> |
|
545 | - |
|
546 | - <input name="hid" type="hidden" id="hid" value="<?php echo($auto_hide);?>" /> |
|
547 | - <input name="hdt" type="hidden" id="hdt" value="<?php echo($auto_hide_time);?>" /> |
|
548 | - |
|
549 | - <input name="tmz" type="hidden" id="tmz" value="<?php echo($timezone);?>" /> |
|
550 | - <input name="thm" type="hidden" id="thm" value="<?php echo($theme);?>" /> |
|
513 | + <input name="selected_day" type="hidden" id="selected_day" value="<?php echo($sld); ?>" /> |
|
514 | + <input name="selected_month" type="hidden" id="selected_month" value="<?php echo($slm); ?>" /> |
|
515 | + <input name="selected_year" type="hidden" id="selected_year" value="<?php echo($sly); ?>" /> |
|
516 | + <input name="year_start" type="hidden" id="year_start" value="<?php echo($cobj->year_start_input); ?>" /> |
|
517 | + <input name="year_end" type="hidden" id="year_end" value="<?php echo($cobj->year_end_input); ?>" /> |
|
518 | + <input name="objname" type="hidden" id="objname" value="<?php echo($objname); ?>" /> |
|
519 | + <input name="dp" type="hidden" id="dp" value="<?php echo($dp); ?>" /> |
|
520 | + |
|
521 | + <input name="da1" type="hidden" id="da1" value="<?php echo($time_allow1); ?>" /> |
|
522 | + <input name="da2" type="hidden" id="da2" value="<?php echo($time_allow2); ?>" /> |
|
523 | + <input name="sna" type="hidden" id="sna" value="<?php echo($show_not_allow); ?>" /> |
|
524 | + <input name="aut" type="hidden" id="aut" value="<?php echo($auto_submit); ?>" /> |
|
525 | + <input name="frm" type="hidden" id="frm" value="<?php echo($form_name); ?>" /> |
|
526 | + <input name="tar" type="hidden" id="tar" value="<?php echo($target_url); ?>" /> |
|
527 | + <input name="inp" type="hidden" id="inp" value="<?php echo($show_input); ?>" /> |
|
528 | + <input name="fmt" type="hidden" id="fmt" value="<?php echo($date_format); ?>" /> |
|
529 | + <input name="dis" type="hidden" id="dis" value="<?php echo($dsb_txt); ?>" /> |
|
530 | + |
|
531 | + <input name="pr1" type="hidden" id="pr1" value="<?php echo($date_pair1); ?>" /> |
|
532 | + <input name="pr2" type="hidden" id="pr2" value="<?php echo($date_pair2); ?>" /> |
|
533 | + <input name="prv" type="hidden" id="prv" value="<?php echo($date_pair_value); ?>" /> |
|
534 | + <input name="pth" type="hidden" id="pth" value="<?php echo($path); ?>" /> |
|
535 | + |
|
536 | + <input name="spd" type="hidden" id="spd" value="<?php echo(htmlspecialchars($cobj->check_json_encode($sp_dates), ENT_QUOTES)); ?>" /> |
|
537 | + <input name="spt" type="hidden" id="spt" value="<?php echo($sp_type); ?>" /> |
|
538 | + |
|
539 | + <input name="och" type="hidden" id="och" value="<?php echo(urldecode($tc_onchanged)); ?>" /> |
|
540 | + |
|
541 | + <input name="str" type="hidden" id="str" value="<?php echo($startDate); ?>" /> |
|
542 | + <input name="rtl" type="hidden" id="rtl" value="<?php echo($rtl); ?>" /> |
|
543 | + <input name="wks" type="hidden" id="wks" value="<?php echo($show_weeks); ?>" /> |
|
544 | + <input name="int" type="hidden" id="int" value="<?php echo($interval); ?>" /> |
|
545 | + |
|
546 | + <input name="hid" type="hidden" id="hid" value="<?php echo($auto_hide); ?>" /> |
|
547 | + <input name="hdt" type="hidden" id="hdt" value="<?php echo($auto_hide_time); ?>" /> |
|
548 | + |
|
549 | + <input name="tmz" type="hidden" id="tmz" value="<?php echo($timezone); ?>" /> |
|
550 | + <input name="thm" type="hidden" id="thm" value="<?php echo($theme); ?>" /> |
|
551 | 551 | |
552 | 552 | <!-- focus var //--> |
553 | 553 | <input name="fcs" type="hidden" id="fcs" value="0" /> |
@@ -564,15 +564,15 @@ discard block |
||
564 | 564 | if ($show_weeks) echo("<td align=\"center\" class=\"header wk-hdr\"><div>".$cobj->week_hdr."</div></td>"); |
565 | 565 | |
566 | 566 | //write calendar day header |
567 | - foreach($day_headers as $dh){ |
|
567 | + foreach ($day_headers as $dh) { |
|
568 | 568 | echo("<td align=\"center\" class=\"header\"><div>".$dh."</div></td>"); |
569 | 569 | } |
570 | 570 | echo("</tr>"); |
571 | 571 | |
572 | - for($row=0; $row<sizeof($calendar_rows); $row++){ |
|
572 | + for ($row = 0; $row<sizeof($calendar_rows); $row++) { |
|
573 | 573 | echo("<tr>"); |
574 | 574 | |
575 | - if ($show_weeks){ |
|
575 | + if ($show_weeks) { |
|
576 | 576 | asort($week_rows[$row]); |
577 | 577 | |
578 | 578 | //get week number with highest member |
@@ -581,7 +581,7 @@ discard block |
||
581 | 581 | echo("<td align=\"center\" class=\"wk\"><div>".$cw_keys[(sizeof($cw_keys)-1)]."</div></td>"); |
582 | 582 | } |
583 | 583 | |
584 | - foreach($calendar_rows[$row] as $column){ |
|
584 | + foreach ($calendar_rows[$row] as $column) { |
|
585 | 585 | $this_day = isset($column[0]) ? $column[0] : ""; |
586 | 586 | $this_link = isset($column[1]) ? $column[1] : ""; |
587 | 587 | $this_class = isset($column[2]) ? $column[2] : ""; |
@@ -589,9 +589,9 @@ discard block |
||
589 | 589 | |
590 | 590 | $id_str = ($this_id) ? " id=\"".$this_id."\"" : ""; |
591 | 591 | |
592 | - if($this_link){ |
|
592 | + if ($this_link) { |
|
593 | 593 | echo("<td".$id_str." align=\"center\" class=\"".$this_class."\"><div><a href=\"".$this_link."\">".$this_day."</a></div></td>"); |
594 | - }else{ |
|
594 | + }else { |
|
595 | 595 | echo("<td".$id_str." align=\"center\" class=\"".$this_class."\"><div>".$this_day."</div></td>"); |
596 | 596 | } |
597 | 597 | } |
@@ -602,21 +602,21 @@ discard block |
||
602 | 602 | </div> |
603 | 603 | |
604 | 604 | <?php |
605 | - if(($previous_year >= $year_start || $next_year <= $year_end) && ($show_previous || $show_next)){ |
|
605 | + if (($previous_year>=$year_start || $next_year<=$year_end) && ($show_previous || $show_next)) { |
|
606 | 606 | ?> |
607 | 607 | <div id="calendar-footer"> |
608 | 608 | <div style="float: <?php echo($rtl ? "right" : "left"); ?>;" class="btn"> |
609 | 609 | <?php |
610 | - if($previous_year >= $year_start && $show_previous){ |
|
611 | - ?><a href="javascript:move('<?php echo(str_pad($previous_month, 2, "0", STR_PAD_LEFT));?>', '<?php echo($previous_year);?>');"><img src="images/btn_<?php echo($rtl ? "next" : "previous"); ?>.gif" width="16" height="16" border="0" alt="Previous" title="Previous" /></a> |
|
610 | + if ($previous_year>=$year_start && $show_previous) { |
|
611 | + ?><a href="javascript:move('<?php echo(str_pad($previous_month, 2, "0", STR_PAD_LEFT)); ?>', '<?php echo($previous_year); ?>');"><img src="images/btn_<?php echo($rtl ? "next" : "previous"); ?>.gif" width="16" height="16" border="0" alt="Previous" title="Previous" /></a> |
|
612 | 612 | <?php |
613 | 613 | }else echo(" "); |
614 | 614 | ?> |
615 | 615 | </div> |
616 | 616 | <div style="float: <?php echo($rtl ? "left" : "right"); ?>;" class="btn"> |
617 | 617 | <?php |
618 | - if($next_year <= $year_end && $show_next){ |
|
619 | - ?><a href="javascript:move('<?php echo(str_pad($next_month, 2, "0", STR_PAD_LEFT));?>', '<?php echo($next_year);?>');"><img src="images/btn_<?php echo($rtl ? "previous" : "next"); ?>.gif" width="16" height="16" border="0" alt="Next" title="Next" /></a> |
|
618 | + if ($next_year<=$year_end && $show_next) { |
|
619 | + ?><a href="javascript:move('<?php echo(str_pad($next_month, 2, "0", STR_PAD_LEFT)); ?>', '<?php echo($next_year); ?>');"><img src="images/btn_<?php echo($rtl ? "previous" : "next"); ?>.gif" width="16" height="16" border="0" alt="Next" title="Next" /></a> |
|
620 | 620 | <?php |
621 | 621 | }else echo(" "); |
622 | 622 | ?> |
@@ -625,13 +625,13 @@ discard block |
||
625 | 625 | <?php |
626 | 626 | $footer_links = array(); |
627 | 627 | |
628 | - if($cobj->validTodayDate() && ($m != $cdate->getDate('m') || $y != $cdate->getDate('Y'))) |
|
628 | + if ($cobj->validTodayDate() && ($m != $cdate->getDate('m') || $y != $cdate->getDate('Y'))) |
|
629 | 629 | $footer_links[] = "<a href=\"javascript:today();\" class=\"txt\" alt=\"Today\" title=\"Today\">Today</a>"; |
630 | 630 | |
631 | - if($sld>0 && $slm>0 && $sly>0) |
|
631 | + if ($sld>0 && $slm>0 && $sly>0) |
|
632 | 632 | $footer_links[] = "<a href=\"javascript:unsetValue();\" class=\"txt\" alt=\"Unset\" title=\"Unset\">Unset</a>"; |
633 | 633 | |
634 | - if(sizeof($footer_links)>0){ |
|
634 | + if (sizeof($footer_links)>0) { |
|
635 | 635 | echo(implode(" | ", $footer_links)); |
636 | 636 | } |
637 | 637 | ?> |
@@ -13,7 +13,9 @@ discard block |
||
13 | 13 | //timezone var, need to setup before any other tasks |
14 | 14 | $timezone = getParameter("tmz"); |
15 | 15 | |
16 | -if(!$timezone) $timezone = date_default_timezone_get(); |
|
16 | +if(!$timezone) { |
|
17 | + $timezone = date_default_timezone_get(); |
|
18 | +} |
|
17 | 19 | @date_default_timezone_set($timezone); |
18 | 20 | |
19 | 21 | $cdate = new tc_date(); |
@@ -23,9 +25,15 @@ discard block |
||
23 | 25 | $slm = getParameter("selected_month"); |
24 | 26 | $sly = getParameter("selected_year"); |
25 | 27 | |
26 | -if(!is_numeric($sld)) $sld = "00"; |
|
27 | -if(!is_numeric($slm)) $slm = "00"; |
|
28 | -if(!is_numeric($sly)) $sly = "0000"; |
|
28 | +if(!is_numeric($sld)) { |
|
29 | + $sld = "00"; |
|
30 | +} |
|
31 | +if(!is_numeric($slm)) { |
|
32 | + $slm = "00"; |
|
33 | +} |
|
34 | +if(!is_numeric($sly)) { |
|
35 | + $sly = "0000"; |
|
36 | +} |
|
29 | 37 | |
30 | 38 | $year_start = getParameter("year_start", "number", 0); |
31 | 39 | $year_end = getParameter("year_end", "number", 0); |
@@ -74,62 +82,79 @@ discard block |
||
74 | 82 | |
75 | 83 | //check year to be select in case of date_allow is set |
76 | 84 | if(!$show_not_allow){ |
77 | - if ($ta1_set && $cdate->validDate($time_allow1)) $year_start = $cdate->getDate('Y', $time_allow1); |
|
78 | - if ($ta2_set && $cdate->validDate($time_allow2)) $year_end = $cdate->getDate('Y', $time_allow2); |
|
79 | -} |
|
80 | - |
|
81 | -if(isset($_REQUEST["m"])) |
|
82 | - $m = getParameter("m", "number"); |
|
83 | -else{ |
|
85 | + if ($ta1_set && $cdate->validDate($time_allow1)) { |
|
86 | + $year_start = $cdate->getDate('Y', $time_allow1); |
|
87 | + } |
|
88 | + if ($ta2_set && $cdate->validDate($time_allow2)) { |
|
89 | + $year_end = $cdate->getDate('Y', $time_allow2); |
|
90 | + } |
|
91 | + } |
|
92 | + |
|
93 | +if(isset($_REQUEST["m"])) { |
|
94 | + $m = getParameter("m", "number"); |
|
95 | +} else{ |
|
84 | 96 | if($slm != "00"){ |
85 | 97 | $m = $slm; |
86 | - }else{ |
|
98 | + } else{ |
|
87 | 99 | if($ta2_set && $year_end > 0){ |
88 | 100 | //compare which one is more |
89 | 101 | $year_allow2 = $cdate->getDate('Y', $time_allow2); |
90 | 102 | if($year_allow2 >= $year_end){ |
91 | 103 | //use time_allow2 |
92 | 104 | $m = ($cdate->dateBefore($time_allow2)) ? $cdate->getDate("m") : $cdate->getDate('m', $time_allow2); |
93 | - }else{ |
|
105 | + } else{ |
|
94 | 106 | //use year_end |
95 | 107 | $m = ($year_end > $cdate->getDate("Y")) ? $cdate->getDate("m") : 12; |
96 | 108 | } |
97 | - }elseif($ta2_set){ |
|
109 | + } elseif($ta2_set){ |
|
98 | 110 | $m = ($cdate->dateBefore($time_allow2)) ? $cdate->getDate("m") : $cdate->getDate('m', $time_allow2); |
99 | - }elseif($year_end > 0){ |
|
111 | + } elseif($year_end > 0){ |
|
100 | 112 | $m = ($year_end > $cdate->getDate("Y")) ? $cdate->getDate("m") : 12; //date('m') |
101 | - }else{ |
|
113 | + } else{ |
|
102 | 114 | $m = $cdate->getDate("m"); |
103 | 115 | } |
104 | 116 | } |
105 | 117 | } |
106 | 118 | |
107 | -if($m < 1 && $m > 12) $m = $cdate->getDate("m"); |
|
119 | +if($m < 1 && $m > 12) { |
|
120 | + $m = $cdate->getDate("m"); |
|
121 | +} |
|
108 | 122 | |
109 | 123 | $m = str_pad($m, 2, "0", STR_PAD_LEFT); |
110 | 124 | |
111 | 125 | $cyr = ($sly != "0000") ? true : false; |
112 | -if($cyr && $sly && $sly < $year_start) $sly = $year_start; |
|
113 | -if($cyr && $sly && $sly > $year_end) $sly = $year_end; |
|
114 | - |
|
115 | -if(isset($_REQUEST["y"])) |
|
116 | - $y = getParameter("y", "number"); |
|
117 | -else |
|
118 | - $y = ($cyr) ? $sly : $cdate->getDate("Y"); |
|
119 | - |
|
120 | -if($y <= 0) $y = $cdate->getDate("Y"); |
|
126 | +if($cyr && $sly && $sly < $year_start) { |
|
127 | + $sly = $year_start; |
|
128 | +} |
|
129 | +if($cyr && $sly && $sly > $year_end) { |
|
130 | + $sly = $year_end; |
|
131 | +} |
|
132 | + |
|
133 | +if(isset($_REQUEST["y"])) { |
|
134 | + $y = getParameter("y", "number"); |
|
135 | +} else { |
|
136 | + $y = ($cyr) ? $sly : $cdate->getDate("Y"); |
|
137 | +} |
|
138 | + |
|
139 | +if($y <= 0) { |
|
140 | + $y = $cdate->getDate("Y"); |
|
141 | +} |
|
121 | 142 | |
122 | 143 | // ensure m-y fits date allow range |
123 | 144 | if (!$show_not_allow) { |
124 | 145 | if ($ta1_set) { |
125 | 146 | $m1 = $cdate->getDate('m', $time_allow1); |
126 | 147 | $y1 = $cdate->getDate('Y', $time_allow1); |
127 | - if ($y == $y1 && (int)$m < (int)$m1) $m = $m1; |
|
148 | + if ($y == $y1 && (int)$m < (int)$m1) { |
|
149 | + $m = $m1; |
|
150 | + } |
|
128 | 151 | } |
129 | 152 | if ($ta2_set) { |
130 | 153 | $m2 = $cdate->getDate('m', $time_allow2); |
131 | 154 | $y2 = $cdate->getDate('Y', $time_allow2); |
132 | - if ($y == $y2 && (int)$m > (int)$m2) $m = $m2; |
|
155 | + if ($y == $y2 && (int)$m > (int)$m2) { |
|
156 | + $m = $m2; |
|
157 | + } |
|
133 | 158 | } |
134 | 159 | } |
135 | 160 | |
@@ -147,7 +172,9 @@ discard block |
||
147 | 172 | $cobj->setTimezone($timezone); //set for further usage, nothing for now |
148 | 173 | |
149 | 174 | $theme_path = ($theme != "") ? $cobj->getThemePath($theme) : ""; |
150 | -if(!is_file($theme_path)) $theme_path = ""; |
|
175 | +if(!is_file($theme_path)) { |
|
176 | + $theme_path = ""; |
|
177 | +} |
|
151 | 178 | |
152 | 179 | //check and show default calendar month and year on valid range of date_allow |
153 | 180 | if(!isset($_REQUEST["m"])){ |
@@ -168,15 +195,19 @@ discard block |
||
168 | 195 | $year_end = $cobj->year_end; |
169 | 196 | |
170 | 197 | //check year display in valid range |
171 | -if($y >= $year_end) $y = $year_end; |
|
172 | -if($y <= $year_start) $y = $year_start; |
|
198 | +if($y >= $year_end) { |
|
199 | + $y = $year_end; |
|
200 | +} |
|
201 | +if($y <= $year_start) { |
|
202 | + $y = $year_start; |
|
203 | +} |
|
173 | 204 | |
174 | 205 | $total_thismonth = $cobj->total_days($m, $y); |
175 | 206 | |
176 | 207 | if($m == 1){ |
177 | 208 | $previous_month = 12; |
178 | 209 | $previous_year = $y-1; |
179 | -}else{ |
|
210 | +} else{ |
|
180 | 211 | $previous_month = $m-1; |
181 | 212 | $previous_year = $y; |
182 | 213 | } |
@@ -184,7 +215,7 @@ discard block |
||
184 | 215 | if($m == 12){ |
185 | 216 | $next_month = 1; |
186 | 217 | $next_year = $y+1; |
187 | -}else{ |
|
218 | +} else{ |
|
188 | 219 | $next_month = $m+1; |
189 | 220 | $next_year = $y; |
190 | 221 | } |
@@ -196,9 +227,9 @@ discard block |
||
196 | 227 | if($firstdate == $startDate){ |
197 | 228 | //skip last month |
198 | 229 | $startwrite = $total_lastmonth+1; |
199 | -}elseif($firstdate < $startDate){ |
|
230 | +} elseif($firstdate < $startDate){ |
|
200 | 231 | $startwrite = $total_lastmonth - (6-($startDate-$firstdate)); |
201 | -}else{ |
|
232 | +} else{ |
|
202 | 233 | $startwrite = $total_lastmonth - ($firstdate - $startDate - 1); |
203 | 234 | } |
204 | 235 | |
@@ -222,8 +253,10 @@ discard block |
||
222 | 253 | $wknum = $cdate->getWeekNumber($prev_d); |
223 | 254 | if(!isset($week_rows[$row_count][$wknum])){ |
224 | 255 | $week_rows[$row_count][$wknum] = 1; |
225 | - }else $week_rows[$row_count][$wknum] = $week_rows[$row_count][$wknum]+1; |
|
226 | -} |
|
256 | + } else { |
|
257 | + $week_rows[$row_count][$wknum] = $week_rows[$row_count][$wknum]+1; |
|
258 | + } |
|
259 | + } |
|
227 | 260 | |
228 | 261 | $pvMonthTime = $previous_year."-".$previous_month."-".$total_lastmonth; |
229 | 262 | |
@@ -231,13 +264,20 @@ discard block |
||
231 | 264 | if($ta1_set && !$show_not_allow){ |
232 | 265 | if($cdate->dateBefore($pvMonthTime, $time_allow1)){ |
233 | 266 | $show_previous = true; |
234 | - }else $show_previous = false; |
|
235 | -}else $show_previous = true; //always show when not set |
|
267 | + } else { |
|
268 | + $show_previous = false; |
|
269 | + } |
|
270 | + } else { |
|
271 | + $show_previous = true; |
|
272 | +} |
|
273 | +//always show when not set |
|
236 | 274 | |
237 | 275 | $date_num = $cdate->getDayOfWeek(($previous_year."-".$previous_month."-".$total_lastmonth)); |
238 | 276 | if(($startDate == 0 && $date_num == 6) || ($startDate > 0 && $date_num == $startDate-1) && $startwrite<$total_lastmonth){ |
239 | - if(isset($calendar_rows[0])) $row_count++; |
|
240 | -} |
|
277 | + if(isset($calendar_rows[0])) { |
|
278 | + $row_count++; |
|
279 | + } |
|
280 | + } |
|
241 | 281 | |
242 | 282 | $dp_time = ($date_pair_value) ? $date_pair_value : ""; |
243 | 283 | |
@@ -270,13 +310,13 @@ discard block |
||
270 | 310 | if($ta1_set && $ta2_set){ |
271 | 311 | //both date specified |
272 | 312 | $dateLink = ($cdate->dateBefore($date_str, $time_allow1) && $cdate->dateAfter($date_str, $time_allow2)) ? true : false; |
273 | - }elseif($ta1_set){ |
|
313 | + } elseif($ta1_set){ |
|
274 | 314 | //only date 1 specified |
275 | 315 | $dateLink = $cdate->dateBefore($date_str, $time_allow1) ? true : false; |
276 | - }elseif($ta2_set){ |
|
316 | + } elseif($ta2_set){ |
|
277 | 317 | //only date 2 specified |
278 | 318 | $dateLink = $cdate->dateAfter($date_str, $time_allow2) ? true : false; |
279 | - }else{ |
|
319 | + } else{ |
|
280 | 320 | //no date allow specified, assume show all |
281 | 321 | $dateLink = true; |
282 | 322 | } |
@@ -343,13 +383,15 @@ discard block |
||
343 | 383 | if($date_pair_value){ |
344 | 384 | //check date_pair1 & 2 |
345 | 385 | if($date_pair1 && $date_pair_value != "0000-00-00" && $cdate->dateAfter($date_pair_value, $date_str) && (($slm>0 && $sld>0 && $sly>0) && $cdate->dateBefore("$sly-$slm-$sld", $date_str))){ //set date only after date_pair1 |
346 | - if(!in_array("select", $htmlClass)) |
|
347 | - $htmlClass[] = "select"; |
|
386 | + if(!in_array("select", $htmlClass)) { |
|
387 | + $htmlClass[] = "select"; |
|
388 | + } |
|
348 | 389 | } |
349 | 390 | |
350 | 391 | if($date_pair2 && $date_pair_value != "0000-00-00" && $cdate->dateBefore($date_pair_value, $date_str) && (($slm>0 && $sld>0 && $sly>0) && $cdate->dateAfter("$sly-$slm-$sld", $date_str))){ //set date only before date_pair2 |
351 | - if(!in_array("select", $htmlClass)) |
|
352 | - $htmlClass[] = "select"; |
|
392 | + if(!in_array("select", $htmlClass)) { |
|
393 | + $htmlClass[] = "select"; |
|
394 | + } |
|
353 | 395 | } |
354 | 396 | } |
355 | 397 | |
@@ -364,7 +406,7 @@ discard block |
||
364 | 406 | $class = implode(" ", $htmlClass); |
365 | 407 | |
366 | 408 | $calendar_rows[$row_count][] = array($day, "javascript:selectDay('".str_pad($day, 2, "0", STR_PAD_LEFT)."');", $class, "$y".str_pad($m, 2, "0", STR_PAD_LEFT).str_pad($day, 2, "0", STR_PAD_LEFT)); |
367 | - }else{ |
|
409 | + } else{ |
|
368 | 410 | $htmlClass[] = "disabledate"; |
369 | 411 | $class = implode(" ", $htmlClass); |
370 | 412 | |
@@ -381,14 +423,18 @@ discard block |
||
381 | 423 | $row_count++; |
382 | 424 | |
383 | 425 | $dayinweek_counter = 0; |
384 | - }else $dayinweek_counter++; |
|
426 | + } else { |
|
427 | + $dayinweek_counter++; |
|
428 | + } |
|
385 | 429 | |
386 | 430 | $wknum = $cdate->getWeekNumber(($y."-".$m."-".$day)); |
387 | 431 | |
388 | 432 | if(!isset($week_rows[$row_count][$wknum])){ |
389 | 433 | $week_rows[$row_count][$wknum] = 1; |
390 | - }else $week_rows[$row_count][$wknum] = $week_rows[$row_count][$wknum]+1; |
|
391 | -} |
|
434 | + } else { |
|
435 | + $week_rows[$row_count][$wknum] = $week_rows[$row_count][$wknum]+1; |
|
436 | + } |
|
437 | + } |
|
392 | 438 | |
393 | 439 | //write next other month |
394 | 440 | $write_end_days = (6-$dayinweek_counter)+1; |
@@ -399,7 +445,9 @@ discard block |
||
399 | 445 | $wknum = $cdate->getWeekNumber($cdate->addMonth("Y-m-d", 1, ($y."-".$m."-".$day))); //date('W', mktime(0,0,0, $m+1, $day, $y)); |
400 | 446 | if(!isset($week_rows[$row_count][$wknum])){ |
401 | 447 | $week_rows[$row_count][$wknum] = 1; |
402 | - }else $week_rows[$row_count][$wknum] = $week_rows[$row_count][$wknum]+1; |
|
448 | + } else { |
|
449 | + $week_rows[$row_count][$wknum] = $week_rows[$row_count][$wknum]+1; |
|
450 | + } |
|
403 | 451 | } |
404 | 452 | $row_count++; |
405 | 453 | } |
@@ -414,7 +462,9 @@ discard block |
||
414 | 462 | |
415 | 463 | if(!isset($week_rows[$row_count][$wknum])){ |
416 | 464 | $week_rows[$row_count][$wknum] = 1; |
417 | - }else $week_rows[$row_count][$wknum] = $week_rows[$row_count][$wknum]+1; |
|
465 | + } else { |
|
466 | + $week_rows[$row_count][$wknum] = $week_rows[$row_count][$wknum]+1; |
|
467 | + } |
|
418 | 468 | } |
419 | 469 | $write_end_days += 6; |
420 | 470 | } |
@@ -424,11 +474,19 @@ discard block |
||
424 | 474 | $nxMonthTime = $next_year."-".$next_month."-1"; |
425 | 475 | if($cdate->dateAfter($nxMonthTime, $time_allow2)){ |
426 | 476 | $show_next = true; |
427 | - }else $show_next = false; |
|
428 | -}else $show_next = true; //always show when not set |
|
477 | + } else { |
|
478 | + $show_next = false; |
|
479 | + } |
|
480 | + } else { |
|
481 | + $show_next = true; |
|
482 | +} |
|
483 | +//always show when not set |
|
429 | 484 | ?> |
430 | 485 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
431 | -<html xmlns="http://www.w3.org/1999/xhtml"<?php if($rtl) echo(" dir=\"rtl\""); ?>> |
|
486 | +<html xmlns="http://www.w3.org/1999/xhtml"<?php if($rtl) { |
|
487 | + echo(" dir=\"rtl\""); |
|
488 | +} |
|
489 | +?>> |
|
432 | 490 | <head> |
433 | 491 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
434 | 492 | <title>TriConsole.com - PHP Calendar Date Picker</title> |
@@ -459,7 +517,7 @@ discard block |
||
459 | 517 | if($form_name){ |
460 | 518 | //submit value by post form |
461 | 519 | echo("window.parent.document.".$form_name.".submit();\n"); |
462 | - }elseif($target_url){ |
|
520 | + } elseif($target_url){ |
|
463 | 521 | //submit value by get method |
464 | 522 | echo("var date_selected = yvalue + \"-\" + mvalue + \"-\" + dvalue;\n"); |
465 | 523 | echo("window.parent.location.href='".$target_url."?".$objname."='+date_selected;\n"); |
@@ -474,7 +532,10 @@ discard block |
||
474 | 532 | <body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"> |
475 | 533 | <span id="calendar-page" class="font"> |
476 | 534 | <div id="calendar-header" align="center"> |
477 | - <?php if($show_calendar_info) include("calendar_info.php"); ?> |
|
535 | + <?php if($show_calendar_info) { |
|
536 | + include("calendar_info.php"); |
|
537 | +} |
|
538 | +?> |
|
478 | 539 | <?php if($dp && !$auto_hide){ ?> |
479 | 540 | <div style="float: right;" class="closeme"><a href="javascript:closeMe();"><img src="images/close.gif" border="0" alt="Close" title="Close" /></a></div> |
480 | 541 | <?php } ?> |
@@ -561,7 +622,9 @@ discard block |
||
561 | 622 | |
562 | 623 | echo("<tr>"); |
563 | 624 | |
564 | - if ($show_weeks) echo("<td align=\"center\" class=\"header wk-hdr\"><div>".$cobj->week_hdr."</div></td>"); |
|
625 | + if ($show_weeks) { |
|
626 | + echo("<td align=\"center\" class=\"header wk-hdr\"><div>".$cobj->week_hdr."</div></td>"); |
|
627 | + } |
|
565 | 628 | |
566 | 629 | //write calendar day header |
567 | 630 | foreach($day_headers as $dh){ |
@@ -591,7 +654,7 @@ discard block |
||
591 | 654 | |
592 | 655 | if($this_link){ |
593 | 656 | echo("<td".$id_str." align=\"center\" class=\"".$this_class."\"><div><a href=\"".$this_link."\">".$this_day."</a></div></td>"); |
594 | - }else{ |
|
657 | + } else{ |
|
595 | 658 | echo("<td".$id_str." align=\"center\" class=\"".$this_class."\"><div>".$this_day."</div></td>"); |
596 | 659 | } |
597 | 660 | } |
@@ -610,7 +673,9 @@ discard block |
||
610 | 673 | if($previous_year >= $year_start && $show_previous){ |
611 | 674 | ?><a href="javascript:move('<?php echo(str_pad($previous_month, 2, "0", STR_PAD_LEFT));?>', '<?php echo($previous_year);?>');"><img src="images/btn_<?php echo($rtl ? "next" : "previous"); ?>.gif" width="16" height="16" border="0" alt="Previous" title="Previous" /></a> |
612 | 675 | <?php |
613 | - }else echo(" "); |
|
676 | + } else { |
|
677 | + echo(" "); |
|
678 | + } |
|
614 | 679 | ?> |
615 | 680 | </div> |
616 | 681 | <div style="float: <?php echo($rtl ? "left" : "right"); ?>;" class="btn"> |
@@ -618,18 +683,22 @@ discard block |
||
618 | 683 | if($next_year <= $year_end && $show_next){ |
619 | 684 | ?><a href="javascript:move('<?php echo(str_pad($next_month, 2, "0", STR_PAD_LEFT));?>', '<?php echo($next_year);?>');"><img src="images/btn_<?php echo($rtl ? "previous" : "next"); ?>.gif" width="16" height="16" border="0" alt="Next" title="Next" /></a> |
620 | 685 | <?php |
621 | - }else echo(" "); |
|
686 | + } else { |
|
687 | + echo(" "); |
|
688 | + } |
|
622 | 689 | ?> |
623 | 690 | </div> |
624 | 691 | <div class="links"> |
625 | 692 | <?php |
626 | 693 | $footer_links = array(); |
627 | 694 | |
628 | - if($cobj->validTodayDate() && ($m != $cdate->getDate('m') || $y != $cdate->getDate('Y'))) |
|
629 | - $footer_links[] = "<a href=\"javascript:today();\" class=\"txt\" alt=\"Today\" title=\"Today\">Today</a>"; |
|
695 | + if($cobj->validTodayDate() && ($m != $cdate->getDate('m') || $y != $cdate->getDate('Y'))) { |
|
696 | + $footer_links[] = "<a href=\"javascript:today();\" class=\"txt\" alt=\"Today\" title=\"Today\">Today</a>"; |
|
697 | + } |
|
630 | 698 | |
631 | - if($sld>0 && $slm>0 && $sly>0) |
|
632 | - $footer_links[] = "<a href=\"javascript:unsetValue();\" class=\"txt\" alt=\"Unset\" title=\"Unset\">Unset</a>"; |
|
699 | + if($sld>0 && $slm>0 && $sly>0) { |
|
700 | + $footer_links[] = "<a href=\"javascript:unsetValue();\" class=\"txt\" alt=\"Unset\" title=\"Unset\">Unset</a>"; |
|
701 | + } |
|
633 | 702 | |
634 | 703 | if(sizeof($footer_links)>0){ |
635 | 704 | echo(implode(" | ", $footer_links)); |
@@ -5,10 +5,10 @@ discard block |
||
5 | 5 | include_once($path.'config.php'); |
6 | 6 | require_once($path.'function.php'); |
7 | 7 | if ( !isset($version) ) { |
8 | - openlog('myRBLemergency', LOG_PID, LOG_LOCAL0); |
|
9 | - syslog (LOG_EMERG, 'unknown: I can\'t read the config files. Do you have configured the $path in getip.php?'); |
|
10 | - closelog(); |
|
11 | - exit(255); |
|
8 | + openlog('myRBLemergency', LOG_PID, LOG_LOCAL0); |
|
9 | + syslog (LOG_EMERG, 'unknown: I can\'t read the config files. Do you have configured the $path in getip.php?'); |
|
10 | + closelog(); |
|
11 | + exit(255); |
|
12 | 12 | } |
13 | 13 | include_once(dirname(__FILE__) . '/function.php'); |
14 | 14 | $conf = parse_ini_file($confImap_file); |
@@ -35,12 +35,12 @@ discard block |
||
35 | 35 | |
36 | 36 | /* check you select a right list */ |
37 | 37 | if ( !$tables[$conf['list']['spam']]['bl'] ) { |
38 | - syslog(LOG_EMERG, $conf['user'].': <'.$conf['list']['spam'].'> is not a blocklist. Are you stupid? Do you want to whitelist a spammer? I refuse to continue.'); |
|
39 | - exit (254); |
|
38 | + syslog(LOG_EMERG, $conf['user'].': <'.$conf['list']['spam'].'> is not a blocklist. Are you stupid? Do you want to whitelist a spammer? I refuse to continue.'); |
|
39 | + exit (254); |
|
40 | 40 | } |
41 | 41 | if ( $tables[$conf['list']['ham']]['bl'] ) { |
42 | - syslog(LOG_EMERG, $conf['user'].': <'.$conf['list']['ham'].'> is a blocklist. Are you stupid? Do you want to block a legitimate sender? I refuse to continue.'); |
|
43 | - exit (254); |
|
42 | + syslog(LOG_EMERG, $conf['user'].': <'.$conf['list']['ham'].'> is a blocklist. Are you stupid? Do you want to block a legitimate sender? I refuse to continue.'); |
|
43 | + exit (254); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | /* Make MYSQL connection Array */ |
@@ -1,16 +1,16 @@ discard block |
||
1 | 1 | #!/usr/bin/php |
2 | 2 | <?php |
3 | 3 | /* Config */ |
4 | -$path='/web/RBL/'; |
|
4 | +$path = '/web/RBL/'; |
|
5 | 5 | include_once($path.'config.php'); |
6 | 6 | require_once($path.'function.php'); |
7 | -if ( !isset($version) ) { |
|
7 | +if (!isset($version)) { |
|
8 | 8 | openlog('myRBLemergency', LOG_PID, LOG_LOCAL0); |
9 | - syslog (LOG_EMERG, 'unknown: I can\'t read the config files. Do you have configured the $path in getip.php?'); |
|
9 | + syslog(LOG_EMERG, 'unknown: I can\'t read the config files. Do you have configured the $path in getip.php?'); |
|
10 | 10 | closelog(); |
11 | 11 | exit(255); |
12 | 12 | } |
13 | -include_once(dirname(__FILE__) . '/function.php'); |
|
13 | +include_once(dirname(__FILE__).'/function.php'); |
|
14 | 14 | $conf = parse_ini_file($confImap_file); |
15 | 15 | |
16 | 16 | |
@@ -19,8 +19,8 @@ discard block |
||
19 | 19 | openlog($tag, LOG_PID, $fac); |
20 | 20 | |
21 | 21 | |
22 | -if ( !$imapListActive ) { |
|
23 | - syslog (LOG_INFO, $conf['user'].': This plugin isn\'t active.'); |
|
22 | +if (!$imapListActive) { |
|
23 | + syslog(LOG_INFO, $conf['user'].': This plugin isn\'t active.'); |
|
24 | 24 | closelog(); |
25 | 25 | exit(255); |
26 | 26 | } |
@@ -31,20 +31,20 @@ discard block |
||
31 | 31 | $arr_tpl_data = array(date("Y-m-d", time())); |
32 | 32 | |
33 | 33 | |
34 | -if ( !$conf['onlyReport'] ) { |
|
34 | +if (!$conf['onlyReport']) { |
|
35 | 35 | |
36 | 36 | /* check you select a right list */ |
37 | - if ( !$tables[$conf['list']['spam']]['bl'] ) { |
|
37 | + if (!$tables[$conf['list']['spam']]['bl']) { |
|
38 | 38 | syslog(LOG_EMERG, $conf['user'].': <'.$conf['list']['spam'].'> is not a blocklist. Are you stupid? Do you want to whitelist a spammer? I refuse to continue.'); |
39 | 39 | exit (254); |
40 | 40 | } |
41 | - if ( $tables[$conf['list']['ham']]['bl'] ) { |
|
41 | + if ($tables[$conf['list']['ham']]['bl']) { |
|
42 | 42 | syslog(LOG_EMERG, $conf['user'].': <'.$conf['list']['ham'].'> is a blocklist. Are you stupid? Do you want to block a legitimate sender? I refuse to continue.'); |
43 | 43 | exit (254); |
44 | 44 | } |
45 | 45 | |
46 | 46 | /* Make MYSQL connection Array */ |
47 | - $mysqlconf= array( |
|
47 | + $mysqlconf = array( |
|
48 | 48 | 'dbhost' => $dbhost, |
49 | 49 | 'userdb' => $userdb, |
50 | 50 | 'pwd' => $pwd, |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | |
56 | 56 | else { |
57 | 57 | $mysqlconf = NULL; |
58 | - syslog(LOG_INFO, $conf['user'].': Report only, no listing activated in configuration.') ; |
|
58 | + syslog(LOG_INFO, $conf['user'].': Report only, no listing activated in configuration.'); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | |
@@ -67,16 +67,16 @@ discard block |
||
67 | 67 | |
68 | 68 | |
69 | 69 | /* The hard work has hidden in imapReport */ |
70 | -$learnfromArray = array('ham','spam'); |
|
71 | -foreach ( $learnfromArray as $learnfrom ) { |
|
70 | +$learnfromArray = array('ham', 'spam'); |
|
71 | +foreach ($learnfromArray as $learnfrom) { |
|
72 | 72 | $conf['reportFile']["$learnfrom"] = str_replace($arr_tpl_vars, $arr_tpl_data, $conf['reportFile']["$learnfrom"]); |
73 | 73 | $conf['badreportFile']["$learnfrom"] = str_replace($arr_tpl_vars, $arr_tpl_data, $conf['badreportFile']["$learnfrom"]); |
74 | - imapReport ($conf,$mysqlconf,$splservice,$tables,$learnfrom); |
|
74 | + imapReport($conf, $mysqlconf, $splservice, $tables, $learnfrom); |
|
75 | 75 | } |
76 | 76 | |
77 | -if ( !$conf['onlyReport'] ) { |
|
77 | +if (!$conf['onlyReport']) { |
|
78 | 78 | /* Close connection */ |
79 | - syslog (LOG_INFO, $conf['user'].': Successfully end of session.'); |
|
79 | + syslog(LOG_INFO, $conf['user'].': Successfully end of session.'); |
|
80 | 80 | } |
81 | 81 | closelog(); |
82 | 82 | ?> |
@@ -51,9 +51,7 @@ |
||
51 | 51 | 'db' => $db, |
52 | 52 | 'dbport' => $dbport |
53 | 53 | ); |
54 | -} |
|
55 | - |
|
56 | -else { |
|
54 | +} else { |
|
57 | 55 | $mysqlconf = NULL; |
58 | 56 | syslog(LOG_INFO, $conf['user'].': Report only, no listing activated in configuration.') ; |
59 | 57 | } |