@@ -1,13 +1,13 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -function filterInput($str, $type = "text"){
|
|
| 3 | - switch(strtolower($type)){
|
|
| 2 | +function filterInput($str, $type = "text") {
|
|
| 3 | + switch (strtolower($type)) {
|
|
| 4 | 4 | case "number": |
| 5 | - if(is_numeric($str)) |
|
| 5 | + if (is_numeric($str)) |
|
| 6 | 6 | return array(true, $str); |
| 7 | 7 | else return array(false, "Invalid input - '$str', required number"); |
| 8 | 8 | break; |
| 9 | 9 | case "boolean": |
| 10 | - if($str == "" || $str == 0 || $str == 1 || is_bool($str)) |
|
| 10 | + if ($str == "" || $str == 0 || $str == 1 || is_bool($str)) |
|
| 11 | 11 | return array(true, $str); |
| 12 | 12 | else return array(false, "Invalid input - '$str', required boolean"); |
| 13 | 13 | break; |
@@ -19,23 +19,23 @@ discard block |
||
| 19 | 19 | } |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | -function getParameter($name, $type='text', $default=""){
|
|
| 22 | +function getParameter($name, $type = 'text', $default = "") {
|
|
| 23 | 23 | $v = isset($_REQUEST[$name]) ? trim($_REQUEST[$name]) : $default; |
| 24 | 24 | |
| 25 | 25 | $results = filterInput($v, $type); |
| 26 | 26 | $result_txt = isset($results[1]) ? $results[1] : ""; |
| 27 | - if(isset($results[0]) && $results[0] === true){
|
|
| 27 | + if (isset($results[0]) && $results[0] === true) {
|
|
| 28 | 28 | return $result_txt; |
| 29 | 29 | }else exit("Error returned '$name' - ".$result_txt);
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | -function getTranslatedTxt($txt, $allow_tag = false, $maps = array()){
|
|
| 32 | +function getTranslatedTxt($txt, $allow_tag = false, $maps = array()) {
|
|
| 33 | 33 | $content = $txt; |
| 34 | 34 | |
| 35 | 35 | //$content = unhtmlentities($content); |
| 36 | 36 | $content = htmlspecialchars_decode($content, ENT_QUOTES); |
| 37 | 37 | |
| 38 | - foreach($maps as $map_key=>$map_value){
|
|
| 38 | + foreach ($maps as $map_key=>$map_value) {
|
|
| 39 | 39 | $content = str_replace($map_key, $map_value, $content); |
| 40 | 40 | } |
| 41 | 41 | |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | $content = stripslashes($content); |
| 44 | 44 | $content = stripslashes($content); |
| 45 | 45 | |
| 46 | - if(!$allow_tag){
|
|
| 46 | + if (!$allow_tag) {
|
|
| 47 | 47 | $content = strip_tags($content); |
| 48 | 48 | } |
| 49 | 49 | |
@@ -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> |
@@ -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 | ?> |
@@ -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 | ?> |
@@ -15,15 +15,15 @@ |
||
| 15 | 15 | openlog($tag, LOG_PID, $fac); |
| 16 | 16 | $mysqli = new mysqli($dbhost, $userdb, $pwd, $db, $dbport); |
| 17 | 17 | if ($mysqli->connect_error) { |
| 18 | - syslog (LOG_EMERG, $user.': Connect Error (' . $mysqli->connect_errno . ') ' |
|
| 18 | + syslog(LOG_EMERG, $user.': Connect Error ('.$mysqli->connect_errno.') ' |
|
| 19 | 19 | . $mysqli->connect_error); |
| 20 | - die($user.': Connect Error (' . $mysqli->connect_errno . ') ' |
|
| 20 | + die($user.': Connect Error ('.$mysqli->connect_errno.') ' |
|
| 21 | 21 | . $mysqli->connect_error); |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | -syslog (LOG_INFO, $user.': Successfully connected to ' . $mysqli->host_info ); |
|
| 24 | +syslog(LOG_INFO, $user.': Successfully connected to '.$mysqli->host_info); |
|
| 25 | 25 | |
| 26 | -expire($mysqli,$user,$tables,$expireTime); |
|
| 26 | +expire($mysqli, $user, $tables, $expireTime); |
|
| 27 | 27 | $mysqli->close(); |
| 28 | 28 | closelog(); |
| 29 | 29 | ?> |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | require_once('config.php'); |
| 3 | 3 | require_once('function.php'); |
| 4 | -$typedesc=$_POST['type']; |
|
| 4 | +$typedesc = $_POST['type']; |
|
| 5 | 5 | $type = $tables["$typedesc"]['field']; |
| 6 | 6 | $table = $tables["$typedesc"]['name']; |
| 7 | 7 | ?> |
@@ -11,14 +11,14 @@ discard block |
||
| 11 | 11 | $user = username(); |
| 12 | 12 | $mysqli = new mysqli($dbhost, $userdb, $pwd, $db, $dbport); |
| 13 | 13 | if ($mysqli->connect_error) { |
| 14 | - syslog (LOG_EMERG, $user.': Connect Error (' . $mysqli->connect_errno . ') ' |
|
| 14 | + syslog(LOG_EMERG, $user.': Connect Error ('.$mysqli->connect_errno.') ' |
|
| 15 | 15 | . $mysqli->connect_error); |
| 16 | - exit ($user.': Connect Error (' . $mysqli->connect_errno . ') ' |
|
| 16 | + exit ($user.': Connect Error ('.$mysqli->connect_errno.') ' |
|
| 17 | 17 | . $mysqli->connect_error); |
| 18 | 18 | } |
| 19 | -syslog(LOG_INFO, $user.': Successfully connected to ' . $mysqli->host_info) ; |
|
| 19 | +syslog(LOG_INFO, $user.': Successfully connected to '.$mysqli->host_info); |
|
| 20 | 20 | |
| 21 | -if (changestatus($mysqli,username(),$_POST['value'],'0',$type,$table)) |
|
| 21 | +if (changestatus($mysqli, username(), $_POST['value'], '0', $type, $table)) |
|
| 22 | 22 | print 'OK '.$_POST["type"].' <'.$_POST['value'].'> delisted.'; |
| 23 | 23 | else |
| 24 | 24 | print 'ERROR in delist <'.$_POST['value'].'>; check log'; |
@@ -1,9 +1,9 @@ |
||
| 1 | 1 | <?php |
| 2 | - $typedesc=$_POST["typedesc"]; |
|
| 2 | + $typedesc = $_POST["typedesc"]; |
|
| 3 | 3 | $type = $tables["$typedesc"]['field']; |
| 4 | 4 | $table = $tables["$typedesc"]['name']; |
| 5 | 5 | $adm = unserialize($_POST["adm"]); |
| 6 | - if (in_array($_POST["user"],array_keys(array_filter($adm)))) $extopt = '<option value="MONTH">MONTHS</option><option value="YEAR">YEARS</option>'; |
|
| 6 | + if (in_array($_POST["user"], array_keys(array_filter($adm)))) $extopt = '<option value="MONTH">MONTHS</option><option value="YEAR">YEARS</option>'; |
|
| 7 | 7 | else $extopt = NULL; |
| 8 | 8 | ?> |
| 9 | 9 | |
@@ -11,7 +11,7 @@ |
||
| 11 | 11 | <h1> DNSBL Lookup</h1> |
| 12 | 12 | <?php |
| 13 | 13 | |
| 14 | -$_POST['Value'] = str_replace('_','.',array_keys($_GET)[0]); |
|
| 14 | +$_POST['Value'] = str_replace('_', '.', array_keys($_GET)[0]); |
|
| 15 | 15 | $_POST['genere'] = 'Spam IP'; |
| 16 | 16 | require_once('result.php'); |
| 17 | 17 | ?> |
@@ -1,25 +1,25 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -$version='1.9d'; |
|
| 3 | +$version = '1.9d'; |
|
| 4 | 4 | |
| 5 | 5 | function username() { |
| 6 | 6 | if (isset ($_SERVER['REMOTE_USER'])) $user = $_SERVER['REMOTE_USER']; |
| 7 | 7 | else if (isset ($_SERVER['USER'])) $user = $_SERVER['USER']; |
| 8 | - else $user='unknown'; |
|
| 8 | + else $user = 'unknown'; |
|
| 9 | 9 | return $user; |
| 10 | 10 | } |
| 11 | 11 | |
| 12 | 12 | |
| 13 | -function addtolist ($myconn,$user,$value,$type,$table,$expUnit,$expQ,$myreason) { |
|
| 13 | +function addtolist($myconn, $user, $value, $type, $table, $expUnit, $expQ, $myreason) { |
|
| 14 | 14 | // See MySQL manual for $expQ and $expUnit at |
| 15 | 15 | // https://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_timestampadd |
| 16 | 16 | |
| 17 | - $result=FALSE; |
|
| 18 | - $sub=array(); |
|
| 17 | + $result = FALSE; |
|
| 18 | + $sub = array(); |
|
| 19 | 19 | |
| 20 | 20 | switch ($type) { |
| 21 | 21 | case 'ip': |
| 22 | - $query= sprintf("INSERT INTO `$table` ( |
|
| 22 | + $query = sprintf("INSERT INTO `$table` ( |
|
| 23 | 23 | `$type` , |
| 24 | 24 | `date` , |
| 25 | 25 | `exp` , |
@@ -30,12 +30,12 @@ discard block |
||
| 30 | 30 | VALUES ( |
| 31 | 31 | INET_ATON( '%s' ) , |
| 32 | 32 | CURRENT_TIMESTAMP , TIMESTAMPADD(%s,%d,CURRENT_TIMESTAMP), '1', '%s', '%s' |
| 33 | - )" ,$value,$expUnit,$expQ,$user,$myreason); |
|
| 33 | + )", $value, $expUnit, $expQ, $user, $myreason); |
|
| 34 | 34 | break; |
| 35 | 35 | |
| 36 | 36 | case 'network': |
| 37 | - list($sub['net'],$sub['mask'])=explode('/',$value); |
|
| 38 | - $query= sprintf("INSERT INTO `$table` ( |
|
| 37 | + list($sub['net'], $sub['mask']) = explode('/', $value); |
|
| 38 | + $query = sprintf("INSERT INTO `$table` ( |
|
| 39 | 39 | `$type` , |
| 40 | 40 | `netmask`, |
| 41 | 41 | `date` , |
@@ -47,11 +47,11 @@ discard block |
||
| 47 | 47 | VALUES ( |
| 48 | 48 | INET_ATON( '%s' ) , INET_ATON( '%s' ) , |
| 49 | 49 | CURRENT_TIMESTAMP , TIMESTAMPADD(%s,%d,CURRENT_TIMESTAMP), '1', '%s', '%s' |
| 50 | - )" ,$sub['net'],$sub['mask'],$expUnit,$expQ,$user,$myreason); |
|
| 50 | + )", $sub['net'], $sub['mask'], $expUnit, $expQ, $user, $myreason); |
|
| 51 | 51 | break; |
| 52 | 52 | |
| 53 | 53 | default: |
| 54 | - $query= sprintf("INSERT INTO `$table` ( |
|
| 54 | + $query = sprintf("INSERT INTO `$table` ( |
|
| 55 | 55 | `$type` , |
| 56 | 56 | `date` , |
| 57 | 57 | `exp` , |
@@ -62,60 +62,60 @@ discard block |
||
| 62 | 62 | VALUES ( |
| 63 | 63 | '%s' , |
| 64 | 64 | CURRENT_TIMESTAMP , TIMESTAMPADD(%s,%d,CURRENT_TIMESTAMP), '1', '%s', '%s' |
| 65 | - )" ,$value,$expUnit,$expQ,$user,$myreason); |
|
| 65 | + )", $value, $expUnit, $expQ, $user, $myreason); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | if ($myconn->query($query) === TRUE) { |
| 69 | 69 | syslog(LOG_INFO, "$user: $type <$value> successfully listed on <$table> for $expQ $expUnit."); |
| 70 | - $result=TRUE; |
|
| 70 | + $result = TRUE; |
|
| 71 | 71 | } |
| 72 | 72 | else syslog(LOG_ERR, "$user: Error: ".$myconn->error); |
| 73 | 73 | return $result; |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | -function relist ($myconn,$user,$value,$type,$table,$expUnit,$expQ,$myreason) { |
|
| 76 | +function relist($myconn, $user, $value, $type, $table, $expUnit, $expQ, $myreason) { |
|
| 77 | 77 | |
| 78 | - $result=FALSE; |
|
| 78 | + $result = FALSE; |
|
| 79 | 79 | |
| 80 | 80 | switch ($type) { |
| 81 | 81 | case 'ip': |
| 82 | - $query= sprintf("UPDATE `$table` SET |
|
| 82 | + $query = sprintf("UPDATE `$table` SET |
|
| 83 | 83 | `active` = '1', |
| 84 | 84 | `user` = '%s', |
| 85 | 85 | `exp` = TIMESTAMPADD(%s,%d,CURRENT_TIMESTAMP), |
| 86 | 86 | `nlist` = `nlist` + 1, |
| 87 | 87 | `reason` = '%s' |
| 88 | - WHERE `$table`.`$type` = INET_ATON('%s') LIMIT 1" ,$user,$expUnit,$expQ,$myreason,$value); |
|
| 88 | + WHERE `$table`.`$type` = INET_ATON('%s') LIMIT 1", $user, $expUnit, $expQ, $myreason, $value); |
|
| 89 | 89 | break; |
| 90 | 90 | case 'network': |
| 91 | - list($sub['net'],$sub['mask'])=explode('/',$value); |
|
| 92 | - $query= sprintf("UPDATE `$table` SET |
|
| 91 | + list($sub['net'], $sub['mask']) = explode('/', $value); |
|
| 92 | + $query = sprintf("UPDATE `$table` SET |
|
| 93 | 93 | `active` = '1', |
| 94 | 94 | `user` = '%s', |
| 95 | 95 | `exp` = TIMESTAMPADD(%s,%d,CURRENT_TIMESTAMP), |
| 96 | 96 | `nlist` = `nlist` + 1, |
| 97 | 97 | `reason` = '%s' |
| 98 | - WHERE (`$table`.`$type` = INET_ATON('%s') AND `$table`.`netmask` = INET_ATON('%s')) LIMIT 1" ,$user,$expUnit,$expQ,$myreason,$sub['net'],$sub['mask']); |
|
| 98 | + WHERE (`$table`.`$type` = INET_ATON('%s') AND `$table`.`netmask` = INET_ATON('%s')) LIMIT 1", $user, $expUnit, $expQ, $myreason, $sub['net'], $sub['mask']); |
|
| 99 | 99 | break; |
| 100 | 100 | default: |
| 101 | - $query= sprintf("UPDATE `$table` SET |
|
| 101 | + $query = sprintf("UPDATE `$table` SET |
|
| 102 | 102 | `active` = '1', |
| 103 | 103 | `user` = '%s', |
| 104 | 104 | `exp` = TIMESTAMPADD(%s,%d,CURRENT_TIMESTAMP), |
| 105 | 105 | `nlist` = `nlist` + 1, |
| 106 | 106 | `reason` = '%s' |
| 107 | - WHERE `$table`.`$type` = '%s' LIMIT 1" ,$user,$expUnit,$expQ,$myreason,$value); |
|
| 107 | + WHERE `$table`.`$type` = '%s' LIMIT 1", $user, $expUnit, $expQ, $myreason, $value); |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | if ($myconn->query($query) === TRUE) { |
| 111 | 111 | syslog(LOG_INFO, "$user: relist $type <$value> on <$table> for $expQ $expUnit."); |
| 112 | - $result=TRUE; |
|
| 112 | + $result = TRUE; |
|
| 113 | 113 | } |
| 114 | - else syslog (LOG_ERR, "$user: Error: ". $myconn->error); |
|
| 114 | + else syslog(LOG_ERR, "$user: Error: ".$myconn->error); |
|
| 115 | 115 | return $result; |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | -function remove ($myconn,$user,$value,$type,$table) { |
|
| 118 | +function remove($myconn, $user, $value, $type, $table) { |
|
| 119 | 119 | |
| 120 | 120 | switch ($type) { |
| 121 | 121 | case 'ip': |
@@ -123,10 +123,10 @@ discard block |
||
| 123 | 123 | `$table`.`$type` = INET_ATON('%s') LIMIT 1", $value); |
| 124 | 124 | break; |
| 125 | 125 | case 'network': |
| 126 | - list($sub['net'],$sub['mask'])=explode('/',$value); |
|
| 126 | + list($sub['net'], $sub['mask']) = explode('/', $value); |
|
| 127 | 127 | $query = sprintf("DELETE FROM `$table` WHERE |
| 128 | 128 | `$table`.`$type` = INET_ATON('%s') AND `$table`.`netmask` = INET_ATON('%s') LIMIT 1", |
| 129 | - $sub['net'],$sub['mask']); |
|
| 129 | + $sub['net'], $sub['mask']); |
|
| 130 | 130 | break; |
| 131 | 131 | default: |
| 132 | 132 | $query = sprintf("DELETE FROM `$table` WHERE |
@@ -134,39 +134,39 @@ discard block |
||
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | |
| 137 | - if ($return=$myconn->query($query) === TRUE) |
|
| 137 | + if ($return = $myconn->query($query) === TRUE) |
|
| 138 | 138 | syslog(LOG_INFO, "$user: permanently DELETED $type <$value> from <$table>."); |
| 139 | - else syslog(LOG_ERR, "$user: Error: ". $myconn->error); |
|
| 139 | + else syslog(LOG_ERR, "$user: Error: ".$myconn->error); |
|
| 140 | 140 | |
| 141 | 141 | return $return; |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | |
| 145 | -function changestatus ($myconn,$user,$value,$status,$type,$table) { |
|
| 145 | +function changestatus($myconn, $user, $value, $status, $type, $table) { |
|
| 146 | 146 | |
| 147 | 147 | switch ($type) { |
| 148 | 148 | case 'ip': |
| 149 | - $query= sprintf("UPDATE `$table` SET `active` = '$status', `user` = '%s' WHERE `$table`.`$type` = INET_ATON('%s') LIMIT 1" ,$user, $value); |
|
| 149 | + $query = sprintf("UPDATE `$table` SET `active` = '$status', `user` = '%s' WHERE `$table`.`$type` = INET_ATON('%s') LIMIT 1", $user, $value); |
|
| 150 | 150 | break; |
| 151 | 151 | case 'network': |
| 152 | - list($sub['net'],$sub['mask'])=explode('/',$value); |
|
| 153 | - $query= sprintf("UPDATE `$table` SET `active` = '$status', `user` = '%s' WHERE (`$table`.`$type` = INET_ATON('%s') AND `$table`.`netmask` = INET_ATON('%s')) LIMIT 1" ,$user, $sub['net'],$sub['mask']); |
|
| 152 | + list($sub['net'], $sub['mask']) = explode('/', $value); |
|
| 153 | + $query = sprintf("UPDATE `$table` SET `active` = '$status', `user` = '%s' WHERE (`$table`.`$type` = INET_ATON('%s') AND `$table`.`netmask` = INET_ATON('%s')) LIMIT 1", $user, $sub['net'], $sub['mask']); |
|
| 154 | 154 | break; |
| 155 | 155 | default: |
| 156 | - $query= sprintf("UPDATE `$table` SET `active` = '$status', `user` = '%s' WHERE `$table`.`$type` = '%s' LIMIT 1" ,$user, $value); |
|
| 156 | + $query = sprintf("UPDATE `$table` SET `active` = '$status', `user` = '%s' WHERE `$table`.`$type` = '%s' LIMIT 1", $user, $value); |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - if ($return=$myconn->query($query) === TRUE) { |
|
| 159 | + if ($return = $myconn->query($query) === TRUE) { |
|
| 160 | 160 | syslog(LOG_INFO, "$user: change status of $type <$value>. The status is now <$status>"); |
| 161 | 161 | } |
| 162 | - else syslog(LOG_ERR, "$user: Error: ". $myconn->error); |
|
| 162 | + else syslog(LOG_ERR, "$user: Error: ".$myconn->error); |
|
| 163 | 163 | return $return; |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | |
| 167 | -function expire ($myconn,$user,$tables,$expireTime) { |
|
| 168 | - $return=TRUE; |
|
| 169 | - $log=array(); |
|
| 167 | +function expire($myconn, $user, $tables, $expireTime) { |
|
| 168 | + $return = TRUE; |
|
| 169 | + $log = array(); |
|
| 170 | 170 | $desc = array_keys($tables); |
| 171 | 171 | foreach ($desc as $tdesc) { |
| 172 | 172 | /* QUERY */ |
@@ -185,11 +185,11 @@ discard block |
||
| 185 | 185 | } while ($myconn->next_result()); |
| 186 | 186 | } |
| 187 | 187 | else { |
| 188 | - syslog(LOG_ERR, "Expire job - Error: ". $myconn->error); |
|
| 188 | + syslog(LOG_ERR, "Expire job - Error: ".$myconn->error); |
|
| 189 | 189 | $return = FALSE; |
| 190 | 190 | } |
| 191 | 191 | } |
| 192 | - if ( !($return) ) syslog(LOG_EMERG, 'End of Expire job with error. See above logs. SQL Connection terminated'); |
|
| 192 | + if (!($return)) syslog(LOG_EMERG, 'End of Expire job with error. See above logs. SQL Connection terminated'); |
|
| 193 | 193 | else syslog(LOG_INFO, 'Successfully End of Expire job. SQL Connection successfully terminated.'); |
| 194 | 194 | return $return; |
| 195 | 195 | } |
@@ -197,22 +197,22 @@ discard block |
||
| 197 | 197 | |
| 198 | 198 | function isListed($row) { |
| 199 | 199 | |
| 200 | - $exp=new DateTime($row['exp']); |
|
| 201 | - $now=new DateTime('NOW'); |
|
| 202 | - if (($exp > $now) and ($row['active'])) return true; |
|
| 200 | + $exp = new DateTime($row['exp']); |
|
| 201 | + $now = new DateTime('NOW'); |
|
| 202 | + if (($exp>$now) and ($row['active'])) return true; |
|
| 203 | 203 | else return false; |
| 204 | 204 | |
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | |
| 208 | -function ask($myconn,$id,$what,$alltables,$typedesc,$value,$lock,$user,$adm) { |
|
| 208 | +function ask($myconn, $id, $what, $alltables, $typedesc, $value, $lock, $user, $adm) { |
|
| 209 | 209 | |
| 210 | - $whynot=NULL; |
|
| 210 | + $whynot = NULL; |
|
| 211 | 211 | switch ($what) { |
| 212 | 212 | case 'Ok': |
| 213 | 213 | if ($lock) return NULL; |
| 214 | - if (in_array($user,array_keys($adm))) |
|
| 215 | - if ( consistentListing($myconn,$alltables,$typedesc,$value,$whynot) ) return require('relistButton.php'); |
|
| 214 | + if (in_array($user, array_keys($adm))) |
|
| 215 | + if (consistentListing($myconn, $alltables, $typedesc, $value, $whynot)) return require('relistButton.php'); |
|
| 216 | 216 | return htmlspecialchars($whynot); |
| 217 | 217 | case 'Listed': |
| 218 | 218 | case 'WhiteListed': |
@@ -221,17 +221,17 @@ discard block |
||
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | |
| 224 | -function consistentListing($myconn,$alltables,$typed,$value,&$warn) { |
|
| 224 | +function consistentListing($myconn, $alltables, $typed, $value, &$warn) { |
|
| 225 | 225 | /* Check if there are no pending mislisting */ |
| 226 | 226 | $warn = NULL; |
| 227 | 227 | foreach ($alltables["$typed"]['depend'] as $listdep) { |
| 228 | - if ($alltables["$typed"]['field'] != $alltables["$listdep"]['field'] ) { |
|
| 228 | + if ($alltables["$typed"]['field'] != $alltables["$listdep"]['field']) { |
|
| 229 | 229 | $warn = "Config ERROR: <$typed> and <$listdep> are of different types! I can't check consistency!"; |
| 230 | 230 | return FALSE; |
| 231 | 231 | } |
| 232 | - $entry = searchentry($myconn,$value,$alltables["$listdep"]); |
|
| 233 | - if ( $entry->num_rows ) { |
|
| 234 | - if ( $entry->num_rows == 1 ) { |
|
| 232 | + $entry = searchentry($myconn, $value, $alltables["$listdep"]); |
|
| 233 | + if ($entry->num_rows) { |
|
| 234 | + if ($entry->num_rows == 1) { |
|
| 235 | 235 | $riga = $entry->fetch_array(MYSQLI_ASSOC); |
| 236 | 236 | if (isListed($riga)) { |
| 237 | 237 | $warn = "<$value> is already present in <$listdep> list!"; |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | return FALSE; |
| 240 | 240 | } |
| 241 | 241 | } |
| 242 | - if ( $entry->num_rows > 1 ) {$warn = "<$value> seems to be present more than once in <$listdep>. Contact a sysadmin NOW!";} |
|
| 242 | + if ($entry->num_rows>1) {$warn = "<$value> seems to be present more than once in <$listdep>. Contact a sysadmin NOW!"; } |
|
| 243 | 243 | } |
| 244 | 244 | $entry->free(); |
| 245 | 245 | } |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | return TRUE; |
| 248 | 248 | } |
| 249 | 249 | |
| 250 | -function searchentry ($myconn,$value,$tablelist) { |
|
| 250 | +function searchentry($myconn, $value, $tablelist) { |
|
| 251 | 251 | /* Make a MYSQL query and return result */ |
| 252 | 252 | |
| 253 | 253 | $type = $tablelist['field']; |
@@ -257,24 +257,24 @@ discard block |
||
| 257 | 257 | else { |
| 258 | 258 | switch ($type) { |
| 259 | 259 | case 'ip': |
| 260 | - $query= "select * from $table where $type = INET_ATON('$value')"; |
|
| 260 | + $query = "select * from $table where $type = INET_ATON('$value')"; |
|
| 261 | 261 | break; |
| 262 | 262 | case 'network': |
| 263 | - list($sub['net'],$sub['mask'])=explode('/',$value); |
|
| 264 | - $query= 'select * from '.$table.' where (((inet_aton(\''.$sub['net'].'\') | (~ inet_aton(\''.$sub['mask'].'\'))) & netmask) = network)'; |
|
| 263 | + list($sub['net'], $sub['mask']) = explode('/', $value); |
|
| 264 | + $query = 'select * from '.$table.' where (((inet_aton(\''.$sub['net'].'\') | (~ inet_aton(\''.$sub['mask'].'\'))) & netmask) = network)'; |
|
| 265 | 265 | break; |
| 266 | 266 | default: |
| 267 | - $query= "select * from $table where $type = '$value'"; |
|
| 267 | + $query = "select * from $table where $type = '$value'"; |
|
| 268 | 268 | } |
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | $result = $myconn->query($query); |
| 272 | - if($result === false) |
|
| 272 | + if ($result === false) |
|
| 273 | 273 | syslog(LOG_EMERG, "ALERT: Query <$query> failed: ".$myconn->error); |
| 274 | 274 | return $result; |
| 275 | 275 | } |
| 276 | 276 | |
| 277 | -function countListed ($myconn,$table) { |
|
| 277 | +function countListed($myconn, $table) { |
|
| 278 | 278 | /* Return number of current listed items into a rbl table */ |
| 279 | 279 | $query = "SELECT COUNT(*) as `count` FROM `$table` WHERE (`active`=1 AND TIMESTAMPDIFF(MICROSECOND,NOW(),`exp`)>0) GROUP BY `active` ORDER BY `count` DESC LIMIT 1"; |
| 280 | 280 | $row = $myconn->query($query); |
@@ -285,37 +285,37 @@ discard block |
||
| 285 | 285 | } |
| 286 | 286 | |
| 287 | 287 | |
| 288 | -function isFull($myconn,$typedesc,$alltables) { |
|
| 288 | +function isFull($myconn, $typedesc, $alltables) { |
|
| 289 | 289 | if (isset($alltables["$typedesc"]['limit'])) { |
| 290 | - if ( countListed($myconn,$alltables["$typedesc"]['name']) >= $alltables["$typedesc"]['limit'] ) |
|
| 290 | + if (countListed($myconn, $alltables["$typedesc"]['name'])>=$alltables["$typedesc"]['limit']) |
|
| 291 | 291 | return TRUE; |
| 292 | 292 | } |
| 293 | 293 | return FALSE; |
| 294 | 294 | } |
| 295 | 295 | |
| 296 | -function rlookup ($myconn,$user,$adm,$value,$typedesc,$tables) { |
|
| 296 | +function rlookup($myconn, $user, $adm, $value, $typedesc, $tables) { |
|
| 297 | 297 | |
| 298 | 298 | $type = $tables["$typedesc"]['field']; |
| 299 | - $whynot=NULL; |
|
| 299 | + $whynot = NULL; |
|
| 300 | 300 | |
| 301 | - $result = searchentry ($myconn,$value,$tables["$typedesc"]); |
|
| 301 | + $result = searchentry($myconn, $value, $tables["$typedesc"]); |
|
| 302 | 302 | if ($result) { |
| 303 | 303 | printf("<pre>Your request for $type <$value> returned %d items.\n</pre>", $result->num_rows); |
| 304 | 304 | |
| 305 | 305 | /* Check for limit in number of listed items */ |
| 306 | - $full = isFull($myconn,$typedesc,$tables); |
|
| 306 | + $full = isFull($myconn, $typedesc, $tables); |
|
| 307 | 307 | if ($full) print '<p>'.htmlspecialchars("$typedesc has reached maximum value of ".$tables["$typedesc"]['limit'].' listed items.').'</p>'; |
| 308 | 308 | |
| 309 | 309 | if ($result->num_rows) { |
| 310 | 310 | print '<table><thead><tr><th>'.$type.'</th><th title="The date this object has been listed for the first time">DateAdd</th><th>DateMod</th><th>Exp</th><th>Status</th><th title="Number of times this object has been listed">#List</th><th>Authored by</th><th width="250">Reason</th><th>Action</th></tr></thead><tfoot><tr></tr></tfoot><tbody>'."\n"; |
| 311 | - $i=0; |
|
| 311 | + $i = 0; |
|
| 312 | 312 | while ($riga = $result->fetch_array(MYSQLI_ASSOC)) { |
| 313 | 313 | if (isListed($riga)) { |
| 314 | - if ($tables["$typedesc"]['bl']) $listed='Listed'; |
|
| 315 | - else $listed='WhiteListed'; |
|
| 314 | + if ($tables["$typedesc"]['bl']) $listed = 'Listed'; |
|
| 315 | + else $listed = 'WhiteListed'; |
|
| 316 | 316 | } |
| 317 | 317 | else |
| 318 | - $listed='Ok'; |
|
| 318 | + $listed = 'Ok'; |
|
| 319 | 319 | |
| 320 | 320 | switch ($type) { |
| 321 | 321 | case 'ip': |
@@ -328,15 +328,15 @@ discard block |
||
| 328 | 328 | $element = $riga["$type"]; |
| 329 | 329 | } |
| 330 | 330 | |
| 331 | - printf ("<tr id=id$i><td id='status$listed'>%s</td><td id='status$listed'>%s</td><td id='status$listed'>%s</td><td id='status$listed'>%s</td><td id='status$listed'>%s</td><td id='status$listed'>%s</td><td id='status$listed'>%s</td><td id='status$listed'>%s</td><td>%s</td></tr>\n", $element, $riga['date'], $riga['datemod'], $riga['exp'], $riga['active'], $riga['nlist'], $riga['user'],htmlspecialchars($riga['reason']),ask($myconn,$i,$listed,$tables,$typedesc,$element,$full,$user,$adm)); |
|
| 331 | + printf("<tr id=id$i><td id='status$listed'>%s</td><td id='status$listed'>%s</td><td id='status$listed'>%s</td><td id='status$listed'>%s</td><td id='status$listed'>%s</td><td id='status$listed'>%s</td><td id='status$listed'>%s</td><td id='status$listed'>%s</td><td>%s</td></tr>\n", $element, $riga['date'], $riga['datemod'], $riga['exp'], $riga['active'], $riga['nlist'], $riga['user'], htmlspecialchars($riga['reason']), ask($myconn, $i, $listed, $tables, $typedesc, $element, $full, $user, $adm)); |
|
| 332 | 332 | $i++; |
| 333 | 333 | } |
| 334 | 334 | print '</tbody></table>'; |
| 335 | 335 | } |
| 336 | 336 | else { |
| 337 | 337 | print "<pre>$type <$value> is not listed!\n</pre>"; |
| 338 | - if ( in_array($user,array_keys($adm)) AND ($value != 'ALL') ) |
|
| 339 | - if ( (!$full) AND (consistentListing($myconn,$tables,$typedesc,$value,$whynot)) ) require_once('listForm.php'); |
|
| 338 | + if (in_array($user, array_keys($adm)) AND ($value != 'ALL')) |
|
| 339 | + if ((!$full) AND (consistentListing($myconn, $tables, $typedesc, $value, $whynot))) require_once('listForm.php'); |
|
| 340 | 340 | else print '<p>'.htmlspecialchars($whynot).'</p>'; |
| 341 | 341 | |
| 342 | 342 | } |
@@ -346,12 +346,12 @@ discard block |
||
| 346 | 346 | } |
| 347 | 347 | |
| 348 | 348 | |
| 349 | -function sendEmailWarn($tplf,$from,$to,$sbj,$emailListed,$intervalToExpire,$detail) { |
|
| 349 | +function sendEmailWarn($tplf, $from, $to, $sbj, $emailListed, $intervalToExpire, $detail) { |
|
| 350 | 350 | $now = time(); |
| 351 | - setlocale (LC_TIME, 'it_IT'); |
|
| 352 | - $date = date("r",$now); |
|
| 353 | - $messageID = md5(uniqid($now,1)) . '@' . $_SERVER["HOSTNAME"]; |
|
| 354 | - $mua = 'PHP/' . phpversion(); |
|
| 351 | + setlocale(LC_TIME, 'it_IT'); |
|
| 352 | + $date = date("r", $now); |
|
| 353 | + $messageID = md5(uniqid($now, 1)).'@'.$_SERVER["HOSTNAME"]; |
|
| 354 | + $mua = 'PHP/'.phpversion(); |
|
| 355 | 355 | |
| 356 | 356 | /* Parsing headers */ |
| 357 | 357 | if (!file_exists($tplf['header'])) { |
@@ -360,10 +360,10 @@ discard block |
||
| 360 | 360 | } |
| 361 | 361 | |
| 362 | 362 | $head_tmpl = file_get_contents($tplf['header']); |
| 363 | - $arr_tpl_vars = array('{from}','{to}','{date}','{messageID}','{mua}'); |
|
| 364 | - $arr_tpl_data = array($from,$to,$date,$messageID,$mua); |
|
| 363 | + $arr_tpl_vars = array('{from}', '{to}', '{date}', '{messageID}', '{mua}'); |
|
| 364 | + $arr_tpl_data = array($from, $to, $date, $messageID, $mua); |
|
| 365 | 365 | $headers = str_replace($arr_tpl_vars, $arr_tpl_data, $head_tmpl); |
| 366 | - $headers = preg_replace( '/\r|\n/', "\r\n", $headers ); |
|
| 366 | + $headers = preg_replace('/\r|\n/', "\r\n", $headers); |
|
| 367 | 367 | |
| 368 | 368 | /* Parsing body */ |
| 369 | 369 | |
@@ -373,62 +373,62 @@ discard block |
||
| 373 | 373 | } |
| 374 | 374 | |
| 375 | 375 | $body_tmpl = file_get_contents($tplf['body']); |
| 376 | - $arr_tpl_vars = array('{emailListed}','{expInterval}','{reason}'); |
|
| 377 | - $arr_tpl_data = array($emailListed,$intervalToExpire,$detail); |
|
| 376 | + $arr_tpl_vars = array('{emailListed}', '{expInterval}', '{reason}'); |
|
| 377 | + $arr_tpl_data = array($emailListed, $intervalToExpire, $detail); |
|
| 378 | 378 | $body = str_replace($arr_tpl_vars, $arr_tpl_data, $body_tmpl); |
| 379 | - $body = preg_replace( "/\r|\n/", "\r\n", $body ); |
|
| 380 | - $body = wordwrap ( $body, 75 , "\r\n" ); |
|
| 379 | + $body = preg_replace("/\r|\n/", "\r\n", $body); |
|
| 380 | + $body = wordwrap($body, 75, "\r\n"); |
|
| 381 | 381 | |
| 382 | 382 | /* Send the mail! */ |
| 383 | - if ( strlen(ini_get("safe_mode"))< 1) { |
|
| 383 | + if (strlen(ini_get("safe_mode"))<1) { |
|
| 384 | 384 | $old_mailfrom = ini_get("sendmail_from"); |
| 385 | 385 | ini_set("sendmail_from", $from); |
| 386 | 386 | $params = sprintf("-oi -f %s", '<>'); |
| 387 | - if (!(mail($to,$sbj, $body,$headers,$params))) $flag=FALSE; |
|
| 388 | - else $flag=TRUE; |
|
| 387 | + if (!(mail($to, $sbj, $body, $headers, $params))) $flag = FALSE; |
|
| 388 | + else $flag = TRUE; |
|
| 389 | 389 | if (isset($old_mailfrom)) |
| 390 | 390 | ini_set("sendmail_from", $old_mailfrom); |
| 391 | 391 | } |
| 392 | 392 | else { |
| 393 | - if (!(mail($to,$sbj, $body,$headers))) $flag=FALSE; |
|
| 394 | - else $flag=TRUE; |
|
| 393 | + if (!(mail($to, $sbj, $body, $headers))) $flag = FALSE; |
|
| 394 | + else $flag = TRUE; |
|
| 395 | 395 | } |
| 396 | 396 | return $flag; |
| 397 | 397 | } |
| 398 | 398 | |
| 399 | -function emailToNotify($notify_file,$dom) { |
|
| 399 | +function emailToNotify($notify_file, $dom) { |
|
| 400 | 400 | $ini_array = parse_ini_file($notify_file); |
| 401 | - if (in_array($dom,array_keys($ini_array))) |
|
| 401 | + if (in_array($dom, array_keys($ini_array))) |
|
| 402 | 402 | return $ini_array["$dom"]; |
| 403 | 403 | else return FALSE; |
| 404 | 404 | } |
| 405 | 405 | |
| 406 | 406 | |
| 407 | -function searchAndList ($myconn,$loguser,$tables,$typedesc,$value,$unit,&$quantity,$reason) { |
|
| 407 | +function searchAndList($myconn, $loguser, $tables, $typedesc, $value, $unit, &$quantity, $reason) { |
|
| 408 | 408 | |
| 409 | 409 | /* Search and list value */ |
| 410 | 410 | $type = $tables["$typedesc"]['field']; |
| 411 | 411 | $table = $tables["$typedesc"]['name']; |
| 412 | - $result = searchentry ($myconn,$value,$tables["$typedesc"]); |
|
| 412 | + $result = searchentry($myconn, $value, $tables["$typedesc"]); |
|
| 413 | 413 | |
| 414 | 414 | /* Manage abnormal conditions */ |
| 415 | 415 | /* Value already present in db more than once. This is absurd. Panic! */ |
| 416 | - if ($result->num_rows > 1) { |
|
| 417 | - syslog(LOG_EMERG,"$loguser: PANIC! Select for $type '$value' returned ". $result->num_rows ." items instead of one. Abnormal. Contact a sysadmin or a developer."); |
|
| 416 | + if ($result->num_rows>1) { |
|
| 417 | + syslog(LOG_EMERG, "$loguser: PANIC! Select for $type '$value' returned ".$result->num_rows." items instead of one. Abnormal. Contact a sysadmin or a developer."); |
|
| 418 | 418 | $result->free(); |
| 419 | 419 | return FALSE; |
| 420 | 420 | } |
| 421 | 421 | |
| 422 | 422 | /* Value already present in db or not present: to list anyway */ |
| 423 | - if ($result->num_rows >= 0) { |
|
| 423 | + if ($result->num_rows>=0) { |
|
| 424 | 424 | /* First, check for limit in number of listed items */ |
| 425 | - if (isFull($myconn,$typedesc,$tables)) { |
|
| 426 | - syslog(LOG_EMERG,"$loguser: $typedesc has reached maximum value of ".$tables["$typedesc"]['limit'].' listed items. Abnormal exit.'); |
|
| 425 | + if (isFull($myconn, $typedesc, $tables)) { |
|
| 426 | + syslog(LOG_EMERG, "$loguser: $typedesc has reached maximum value of ".$tables["$typedesc"]['limit'].' listed items. Abnormal exit.'); |
|
| 427 | 427 | $result->free(); |
| 428 | 428 | return FALSE; |
| 429 | 429 | } |
| 430 | 430 | /* Second, check if the (re)list would be consistent now */ |
| 431 | - if (! consistentListing($myconn,$tables,$typedesc,$value,$whynot) ) { |
|
| 431 | + if (!consistentListing($myconn, $tables, $typedesc, $value, $whynot)) { |
|
| 432 | 432 | syslog(LOG_ERR, $loguser.': '.$whynot); |
| 433 | 433 | $result->free(); |
| 434 | 434 | return FALSE; |
@@ -443,7 +443,7 @@ discard block |
||
| 443 | 443 | /* Relist value if already present */ |
| 444 | 444 | case 1: |
| 445 | 445 | /* Entry already listed */ |
| 446 | - if ( isListed($thisentry) ) { |
|
| 446 | + if (isListed($thisentry)) { |
|
| 447 | 447 | syslog(LOG_INFO, $loguser.': '.$value.' already listed. Nothing to do.'); |
| 448 | 448 | $result->free(); |
| 449 | 449 | return FALSE; |
@@ -452,13 +452,13 @@ discard block |
||
| 452 | 452 | /* Entry delisted */ |
| 453 | 453 | $result->free(); |
| 454 | 454 | $quantity *= $thisentry['nlist']; |
| 455 | - return relist ($myconn,$loguser,$value,$type,$table,$unit,$quantity,$reason); |
|
| 455 | + return relist($myconn, $loguser, $value, $type, $table, $unit, $quantity, $reason); |
|
| 456 | 456 | |
| 457 | 457 | |
| 458 | 458 | /* First time list value */ |
| 459 | 459 | case 0: |
| 460 | 460 | $result->free(); |
| 461 | - return addtolist ($myconn,$loguser,$value,$type,$table,$unit,$quantity,$reason); |
|
| 461 | + return addtolist($myconn, $loguser, $value, $type, $table, $unit, $quantity, $reason); |
|
| 462 | 462 | } |
| 463 | 463 | } |
| 464 | 464 | |