[vscweb-commit] SF.net SVN: vscweb: [465] trunk/Main/Host/Scan
Brought to you by:
cirrusrex
|
From: <hc...@us...> - 2006-08-15 20:16:55
|
Revision: 465 Author: hctv19 Date: 2006-08-15 13:16:51 -0700 (Tue, 15 Aug 2006) ViewCVS: http://svn.sourceforge.net/vscweb/?rev=465&view=rev Log Message: ----------- Added error checking for policy-id's of 0 or null and also fixed a bug that monthly recurring scans wouldn't actually recur Modified Paths: -------------- trunk/Main/Host/Scan/include/libscan.inc trunk/Main/Host/Scan/request.php Modified: trunk/Main/Host/Scan/include/libscan.inc =================================================================== --- trunk/Main/Host/Scan/include/libscan.inc 2006-08-11 20:10:19 UTC (rev 464) +++ trunk/Main/Host/Scan/include/libscan.inc 2006-08-15 20:16:51 UTC (rev 465) @@ -92,11 +92,22 @@ function SCAN_NewRequest($policy_id, $domain,$userid, $requested_on, $scheduled_for,$priority) { //begin transaction DB_TRANS_BEGIN(); - $sql = "INSERT INTO nessus_scan_request - (policy_id, domain,userid,requested_on,scheduled_for,priority) - VALUES('$policy_id','$domain','$userid',FROM_UNIXTIME('$requested_on'), - FROM_UNIXTIME('$scheduled_for'),'$priority')"; - $res = DB_TGetResult($sql); + $res = true; + + //This if-block should make sure policy id's of 0 can't get into the db - nessus chokes on these evidently + if ($policy_id != NULL && $policy_id !=0 ) + { + $sql = "INSERT INTO nessus_scan_request + (policy_id, domain,userid,requested_on,scheduled_for,priority) + VALUES('$policy_id','$domain','$userid',FROM_UNIXTIME('$requested_on'), + FROM_UNIXTIME('$scheduled_for'),'$priority')"; + $res = DB_TGetResult($sql); + } + else + { + $res = false; + } + if ($res === false) { //print DB_GetError(); //Perfect place for error loggin Modified: trunk/Main/Host/Scan/request.php =================================================================== --- trunk/Main/Host/Scan/request.php 2006-08-11 20:10:19 UTC (rev 464) +++ trunk/Main/Host/Scan/request.php 2006-08-15 20:16:51 UTC (rev 465) @@ -400,6 +400,7 @@ if ($i->action == "Finish") { /* INSERT NEW REQUEST INTO TABLE */ $scan_id = SCAN_NewRequest($__scan['policy_id'], $_USER['domain'],$_USER['userid'], $__scan['request_time'],$__scan['scheduled_for'],5); + if ($scan_id < 1) { UI_Style("Error requesting scan.", STY_BOLD|STY_ITALIC); echo DB_GetError(); @@ -445,18 +446,21 @@ } } } else if ($freq == "monthly") { + $ts = $start_ts; $s_day = JDDayOfWeek(unixtojd($ts),0); do { $ts += 2592000; $jd = unixtojd($ts); $day = JDDayOfWeek($jd,0); - if ($day != $s_day) { + if ($day != $s_day) + { $diff = $s_day - $day; if ($diff > 3 || $diff < -3) $diff *= -1; $ts += $diff * 86400; - } - $r = SCAN_Recur_AddDate($scan_id, $j); + } + $r = SCAN_Recur_AddDate($scan_id, $ts); + } while ($ts < $end_ts); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |