home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.f-secure.com
/
2014.06.ftp.f-secure.com.tar
/
ftp.f-secure.com
/
support
/
hotfix
/
fsav-server
/
FSAVSRV900_HF07.fsfix
/
iuwebui
/
forms
/
tree_server
/
server-scheduled.php
< prev
Wrap
PHP Script
|
2010-09-07
|
21KB
|
571 lines
<?php
include ('../common/commonphp.php');
$tab_name = "tabServerScheduledScanning";
$Page_Settings = array(
array(oid => "1.3.6.1.4.1.2213.12.1.160.65", type => GLOBAL_INT),
array(oid => "1.3.6.1.4.1.2213.12.1.160.60", type => GLOBAL_TBL)
);
if(!isset($_POST[SUBMIT_TABLE]))
{
/* first load of the page */
readSettings(&$Page_Settings);
set_empty_schedule(&$Page_Settings);
}
else
{
readPageData(&$Page_Settings);
$Page_Settings[1][value] = array();
if(isset($_POST['SCHEDULED_PARAMS']) && $_POST['SCHEDULED_PARAMS'] != '')
{
$Page_Settings[1][value][] = array(
'Scheduled scanning task',
$_POST['SCHEDULED_PARAMS'],
2,
''
);
}
if($_POST[SUBMIT_TABLE] == 1)
{
writeSettings($Page_Settings);
}
exit(0);
}
function is_new_report()
{
$LogFileName = 'fsav_cmd.htm';
dfp_get_policy_str('1.3.6.1.4.1.2213.12.2.5', &$log_directory_name);
$new_report = $log_directory_name . '\\'. $LogFileName;
while(strpos($new_report, '\\\\'))
$new_report = str_replace('\\\\', '\\', $new_report);
$webui_dir = getcwd();
$webui_dir = substr($webui_dir, 0, strpos($webui_dir, '\\forms\\') + strlen('\\forms\\'));
$webui_dir .= 'temp';
$old_report = $webui_dir . '\\fsav_cmd.[htm]-';
if (file_exists($new_report))
{
if (!file_exists($old_report))
return true;
else
{
if (filemtime($old_report) < filemtime($new_report))
return true;
}
}
return false;
}
function set_empty_schedule($page_settings)
{
$default_params = '/t01:00 /rdaily';
if (strlen($page_settings[1][value][0][1]) == 0)
{
$page_settings[0][value] = 0;
$page_settings[1][value][] = array(
'Scheduled scanning task',
$default_params,
2,
''
);
}
}
function get_schedule($page_settings)
{
$string = $page_settings[1][value][0][1];
if (strpos($string,'rmonthly') !== false)
return 'Monthly';
else if (strpos($string,'rweekly') !== false)
return 'Weekly';
else if (strpos($string,'rdaily') !== false)
return 'Daily';
}
function get_start_time($page_settings)
{
$string = $page_settings[1][value][0][1];
$ti = '';
preg_match_all("/t\d+\:\d+/",$string,$out1);
$t = str_replace('t','',$out1[0][0]);
preg_match_all("/ti\d+/",$string,$out2);
if (count($out2[0])>0)
{
$ti = str_replace('ti','',$out2[0][0]);
return array(1,$t,$ti);
}
return array(0,$t,$ti);
}
function get_daily_schedule($page_settings, $number_of_days)
{
$string = $page_settings[1][value][0][1];
$schedule_array = array();
$not_null_values = array();
if (strpos($string,'rweekly') !== false || strpos($string,'rmonthly') !== false)
{ $k = 0;
for ($i = 1; $i <= $number_of_days; $i++)
{
if (strpos($string,"s" . $i . ' '))
{
$not_null_values[$k] = $i;
$schedule_array[$i] = 1;
$k++;
}
else
$schedule_array[$i] = 0;
}
}
else if (strpos($string, 'rdaily') !== false)
return array(array(1=>1,1,1,1,1,1,1),array(1=>1,1,1,1,1,1,1));
return array($schedule_array, $not_null_values);
}
?>
<script language='JavaScript' type='text/javascript'>
WEEKLY_DIVS = ['weekly1', 'weekly2', 'weekly3'];
MONTHLY_DIVS = ['monthly1', 'monthly2', 'monthly3'];
TIME_LIST = 'list_time'
TIME_TEXT = 'text_time'
DAILY_ID = 'daily';
WEEKLY_ID = 'weekly';
MONTHLY_ID = 'monthly';
<?php echo $tab_name;?>enableControls = function()
{
if(!document.form_<?php echo $tab_name;?> || !document.form_<?php echo $tab_name;?>.VAR_PAGE_SETTINGS_0)
return;
var is_disabled = !document.form_<?php echo $tab_name;?>.VAR_PAGE_SETTINGS_0[1].checked;
dojo.byId('daily_radio').disabled = is_disabled;
dojo.byId('monthly_radio').disabled = is_disabled;
dojo.byId('weekly_radio').disabled = is_disabled;
dojo.byId('time_radio1').disabled = is_disabled;
dojo.byId(TIME_LIST).disabled = is_disabled;
dojo.byId(TIME_TEXT).disabled = is_disabled;
disable_enable_div(MONTHLY_DIVS[0],is_disabled);
disable_enable_div(MONTHLY_DIVS[1],is_disabled);
disable_enable_div(MONTHLY_DIVS[2],is_disabled);
dojo.byId(TIME_LIST).disabled = (is_disabled) ? is_disabled : !dojo.byId('time_radio1').checked;
if (dojo.byId('daily_radio').checked)
is_disabled = true;
disable_enable_div(WEEKLY_DIVS[0],is_disabled);
disable_enable_div(WEEKLY_DIVS[1],is_disabled);
disable_enable_div(WEEKLY_DIVS[2],is_disabled);
}
startup<?php echo $tab_name;?>enableControls = function()
{
<?php echo $tab_name;?>enableControls();
}
disable_enable_div = function(div_id, is_disabled)
{
var inputs = [];
inputs = get_div_inputs(div_id,inputs);
for (var i = 0; i < inputs.length; i++)
{
inputs[i].disabled = is_disabled;
}
}
get_div_inputs = function(div_id,inputs)
{
var div = dojo.byId(div_id);
for (var child_item in div.childNodes)
{
if (typeof(div.childNodes[child_item]) == 'object' && div.childNodes[child_item].nodeName.toLowerCase() != '#text')
{
if (div.childNodes[child_item].nodeName.toLowerCase() == 'input' || div.childNodes[child_item].nodeName.toLowerCase() == 'select' )
inputs.push(div.childNodes[child_item]);
else
inputs.concat(get_div_inputs(div.childNodes[child_item],inputs));
}
}
return inputs;
}
check_div_checkboxes = function(div_id, is_checked)
{
var inputs = [];
inputs = get_div_inputs(div_id,inputs);
for (var i = 0; i < inputs.length; i++)
{
if (inputs[i].getAttribute('type').toLowerCase() == 'checkbox' && !inputs[i].checked)
inputs[i].checked = is_checked;
}
}
show_element_by_id = function(id)
{
var is_disabled = true;
var weekly1 = dojo.byId(WEEKLY_DIVS[0]);
var weekly2 = dojo.byId(WEEKLY_DIVS[1]);
var weekly3 = dojo.byId(WEEKLY_DIVS[2]);
var monthly1 = dojo.byId(MONTHLY_DIVS[0]);
var monthly2 = dojo.byId(MONTHLY_DIVS[1]);
var monthly3 = dojo.byId(MONTHLY_DIVS[2]);
weekly1.style.display = 'none';
weekly2.style.display = 'none';
weekly3.style.display = 'none';
monthly1.style.display = 'none';
monthly2.style.display = 'none';
monthly3.style.display = 'none';
if (id == DAILY_ID)
{
weekly1.style.display = 'block';
weekly2.style.display = 'block';
weekly3.style.display = 'block';
check_div_checkboxes(WEEKLY_DIVS[0],is_disabled);
check_div_checkboxes(WEEKLY_DIVS[1],is_disabled);
check_div_checkboxes(WEEKLY_DIVS[2],is_disabled);
}
else if (id == WEEKLY_ID)
{
weekly1.style.display = 'block';
weekly2.style.display = 'block';
weekly3.style.display = 'block';
is_disabled = false;
}
else if (id == MONTHLY_ID)
{
monthly1.style.display = 'block';
monthly2.style.display = 'block';
monthly3.style.display = 'block';
}
disable_enable_div(WEEKLY_DIVS[0],is_disabled);
disable_enable_div(WEEKLY_DIVS[1],is_disabled);
disable_enable_div(WEEKLY_DIVS[2],is_disabled);
}
<?php echo $tab_name;?>_submitit_hit = function()
{
var tab = document.form_<?php echo $tab_name;?>;
var time,freq,day = '';
tab.SUBMIT_TABLE.value = 1;
if (tab.monthly_radio.checked)
{
freq = '/rmonthly';
if (tab.Day1.checked)
day += ' /s' + tab.month_select1.value + ' ';
if (tab.Day2.checked)
day += ' /s' + tab.month_select2.value + ' ';
if (tab.Day3.checked)
day += ' /s' + tab.month_select3.value + ' ';
}
if (tab.weekly_radio.checked)
{
freq = '/rweekly';
if (tab.Monday.checked)
day += ' /s1 ';
if (tab.Tuesday.checked)
day += ' /s2 ';
if (tab.Wednesday.checked)
day += ' /s3 ';
if (tab.Thursday.checked)
day += ' /s4 ';
if (tab.Friday.checked)
day += ' /s5 ';
if (tab.Saturday.checked)
day += ' /s6 ';
if (tab.Sunday.checked)
day += ' /s7 ';
}
if (tab.daily_radio.checked)
freq = '/rdaily'
else if (tab.weekly_radio.checked)
freq = '/rweekly';
else if (tab.daily_radio.checked)
freq = '/rdaily';
time = '/t' + tab.time_text.value;
if (tab.time_radio1.checked)
time += ' /ti' + tab.time_list.value;
if (!tab.VAR_PAGE_SETTINGS_0[1].checked)
tab.SCHEDULED_PARAMS.value = '';
else
tab.SCHEDULED_PARAMS.value = time + ' '+ freq + ' ' + day;
return true;
}
<?php echo $tab_name;?>_settings_check = function()
{
var tab = document.form_<?php echo $tab_name;?>;
if (!tab.VAR_PAGE_SETTINGS_0[1].checked)
return true;
var reg = /^(\d{2}):(\d{2})$/;
var arr = reg.exec(tab.time_text.value);
msg = localized_strings.TimeShouldBeInCorrectFormat;
if(!reg.test(tab.time_text.value))
{
show_webui_message_box(localized_strings.InvalidInput,msg,0);
return false;
}
else if (arr != null)
{
if (arr[1] > 23 || arr[2] > 59)
{
show_webui_message_box(localized_strings.InvalidInput,msg,0);
return false;
}
}
return true;
}
</script>
<?php show_form_management($tab_name); ?>
<form method="POST" action='<?php echo "{$_SERVER['PHP_SELF']}?{$_SERVER['QUERY_STRING']}";?>' id="form_<?php echo $tab_name;?>" name="form_<?php echo $tab_name;?>" style="padding: 0; margin: 0;">
<input type="hidden" name="SUBMIT_TABLE" value="0">
<input type="hidden" name="SCHEDULED_PARAMS" value="">
<input type="hidden" name="APPLY_SETTINGS" value="0">
<?php show_action_menu('Settings', $tab_name); ?>
<table border="0" cellspacing="5" cellpadding="0" class="main_page_table">
<tr>
<td valign="top" width="100%">
<input type="hidden" name="VAR_PAGE_SETTINGS_0" value="0">
<?=$Page_Settings[0][lock];?><input id='ServerScheduled: scanningEnabled' class='top_checkbox' type="checkbox"
name="VAR_PAGE_SETTINGS_0" value="1"
onclick="javascript: <?php echo $tab_name;?>enableControls();"
<?php if($Page_Settings[0][value] == 1) echo 'checked';?>>
<label for='ServerScheduled: scanningEnabled'><?=fsloc("Turn on scheduled scanning")?></label>
</td>
<tr>
<td>
<table cellspacing="0" cellpadding="0" border="0" width="100%" class="table_settings">
<?php show_section_title($Page_Settings[1][lock] . 'Scan performed'); $date = get_schedule($Page_Settings);?>
<tr align="left" class="tr_setting">
<td class="td_setting" nowrap width='100px'>
<input type="radio" id="daily_radio" name="<?php echo $date;?>" value="<?php echo $date;?>" <?php if($date == 'Daily') echo 'checked';?> onclick="javascript:show_element_by_id('daily');"/>
<label for="daily_radio"><?=fsloc("Daily")?></label>
</td>
<td align="left" class="td_setting" nowrap rowspan=3 width ='50px'>
<img src='../pics/scheduled_separator.png'/>
</td>
<td class="td_setting" nowrap width='300px'>
<?php $day = get_daily_schedule($Page_Settings, 7); $day = $day[0];?>
<div id="weekly1" style="display:<?php echo ($date == 'Weekly' || $date == 'Daily') ? 'block':'none';?>">
<table>
<tr>
<td width=100px>
<input type="hidden" name="monday" value="0"/>
<input type="checkbox" id='Monday' name="week_monday" value="1" <?php if($day[1] == 1) echo 'checked';?>/>
<label for="Monday"><?=fsloc("Monday")?></label>
</td>
<td width=100px>
<input type="hidden" name="tuesday" value="0"/>
<input type="checkbox" id='Tuesday' name="week_tuesday" value="1" <?php if($day[2] == 1) echo 'checked';?>/>
<label for="Tuesday"><?=fsloc("Tuesday")?></label>
</td>
<td width=100px>
<input type="hidden" name="wednesday" value="0"/>
<input type="checkbox" id='Wednesday' name="week_wednesday" value="1" <?php if($day[3] == 1) echo 'checked';?>/>
<label for="Wednesday"><?=fsloc("Wednesday")?></label>
</td>
</tr>
</table>
</div>
<?php $day_month = get_daily_schedule($Page_Settings, 31);?>
<div id = "monthly1" style="display:<?php echo ($date == 'Monthly') ? 'block':'none';?>">
<input type="hidden" name="month_day1" value="0"/>
<input type="checkbox" id='Day1' name="month_day1" value="1" <?php if (count($day_month[1]) >0) echo 'checked';?>/>
<label for="Day1"><?=fsloc("Day")?></label>
<select name = "month_select1" id='day1_list'>
<?php foreach (range(1,31) as $number)
{
$selected ='';
if ($number == $day_month[1][0])
$selected = "selected";
echo "<option value='". $number . "' " . $selected . ">" . $number . "</option>";
}
?>
</select>
</div>
</td>
</tr>
<tr align="left" class="tr_setting">
<td class="td_setting" nowrap width='100px'>
<input type="radio" id="weekly_radio" name="<?php echo $date;?>" value="<?php echo $date;?>" <?php if($date == 'Weekly') echo 'checked';?> onclick="javascript:show_element_by_id('weekly');"/>
<label for="weekly_radio"><?=fsloc("Weekly")?></label>
</td>
<td class="td_setting" nowrap width='300px'>
<div id ='weekly2' style="display:<?php echo ($date == 'Weekly' || $date == 'Daily') ? 'block':'none';?>">
<table>
<tr>
<td width=100px>
<input type="hidden" name="thursday" value="0"/>
<input type="checkbox" id='Thursday' name="week_thursday" value="1" <?php if($day[4] == 1) echo 'checked';?>/>
<label for="Thursday"><?=fsloc("Thursday")?></label>
</td>
<td width=100px>
<input type="hidden" name="friday" value="0"/>
<input type="checkbox" id='Friday' name="week_friday" value="1" <?php if($day[5] == 1) echo 'checked';?>/>
<label for="Friday"><?=fsloc("Friday")?></label>
</td>
<td width=100px>
<input type="hidden" name="saturday" value="0"/>
<input type="checkbox" id='Saturday' name="week_saturday" value="1" <?php if($day[6] == 1) echo 'checked';?>/>
<label for="Saturday"><?=fsloc("Saturday")?></label>
</td>
</tr>
</table>
</div>
<div id = "monthly2" style="display:<?php echo ($date == 'Monthly') ? 'block':'none';?>">
<input type="hidden" name="month_day2" value="0"/>
<input type="checkbox" id='Day2' name="month_day2" value="10" <?php if(count($day_month[1]) >1) echo 'checked';?>/>
<label for="Day2"><?=fsloc("Day")?></label>
<select name = "month_select2" id='day2_list'>
<?php foreach (range(1,31) as $number)
{
$selected ='';
if ($number == $day_month[1][1])
$selected = "selected";
echo "<option value='". $number . "' " . $selected . ">" . $number . "</option>";
}
?>
</select>
</div>
</td>
</tr>
<tr align="left" class="tr_setting">
<td class="td_setting" nowrap width='100px'>
<input type="radio" id="monthly_radio" name="<?php echo $date;?>" value="<?php echo $date;?>" <?php if($date == 'Monthly') echo 'checked';?> onclick="javascript:show_element_by_id('monthly');"/>
<label for="monthly_radio"><?=fsloc("Monthly")?></label>
</td>
<td class="td_setting" nowrap width='200px'>
<div id ='weekly3' style="display:<?php echo ($date == 'Weekly' || $date == 'Daily') ? 'block':'none';?>">
<table>
<tr>
<td width=100px>
<input type="hidden" name="sunday" value="0"/>
<input type="checkbox" id='Sunday' name="week_sunday" value="1" <?php if($day[7] == 1) echo 'checked';?>/>
<label for="Sunday"><?=fsloc("Sunday")?></label>
</td>
</tr>
</table>
</div>
<div id = "monthly3" style="display:<?php echo ($date == 'Monthly') ? 'block':'none';?>">
<input type="hidden" name="month_day3" value="0"/>
<input type="checkbox" id='Day3' name="month_day3" value="20" <?php if(count($day_month[1]) > 2) echo 'checked';?>/>
<label for="Day3"><?=fsloc("Day")?></label>
<select name = "month_select3" id='day3_list'>
<?php foreach (range(1,31) as $number)
{
$selected ='';
if ($number == $day_month[1][2])
$selected = "selected";
echo "<option value='". $number . "' " . $selected . ">" . $number . "</option>";
}
?>
</select>
</div>
</td>
</tr>
</table>
<table cellspacing="0" cellpadding="0" border="0" width="100%" class="table_settings">
<?php show_section_title($Page_Settings[1][lock] . 'Start time');$time = get_start_time($Page_Settings);?>
<tr align="left" class="tr_setting">
<td class="td_setting" nowrap width='200px'>
<?=fsloc("Start time (hh:mm format):")?>
</td>
<td class="td_setting" nowrap width='100px'>
<input type="text" id="text_time" name="time_text" value="<?php echo (strlen($time[1]) > 0)?$time[1]:'00:00';?>" size=5>
</td>
</tr>
<tr align="left" class="tr_setting">
<td class="td_setting" nowrap width='200px'>
<input type="checkbox" id="time_radio1" name="time_radio" value="1" <?php echo ($time[0]==1)? 'checked':'' ?> onclick = 'javascript: dojo.byId(TIME_LIST).disabled = !dojo.byId("time_radio1").checked;'>
<label for="time_radio1"><?=fsloc("After computer is not used for:")?></label>
</td>
<td class="td_setting" nowrap width='100px'>
<select name = "time_list" id = "list_time">
<?php foreach(array(5,15,30,60) as $time_option)
{ $selected = '';
if ($time[2] == $time_option)
$selected = 'selected';
$timeStr = fsloc("%d min");
$timeStr = str_replace("%d", $time_option, $timeStr);
echo '<option value = "'. $time_option . '"' . $selected. '>' . $timeStr .'</option>';
}
?>
</select>
</td>
</tr>
</table>
<table cellspacing="0" cellpadding="0" border="0" width="100%" class="table_settings">
<?php show_section_title('Note');?>
<tr align="left" class="tr_setting">
<td class="td_setting">
<?=fsloc("Scheduled scanning uses the currently defined manual scanning settings. All archives are scanned automatically. All viruses, worms and trojans are cleaned automatically.")?>
</td>
</tr>
</table>
</td>
<td valign="top">
<table width="200" border="0" cellpadding="0" cellspacing="0" style="margin-top: 10px;">
<?php show_tasks_title('Last scanning report');?>
<tr>
<td class="table_toolbox2_content" valign="top">
<table cellpadding="3" cellspacing="0" border="0">
<tr>
<td><img src="../pics/icon/icon_blue_arrow.gif" width="4" height="8" alt="">
</td>
<td><a href="javascript:;" onClick="open_window_max('/tree_server/scheduled_report.php');"><?php echo (is_new_report())?fsloc('New report available'):fsloc('View scanning report'); ?>...</a>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<?php show_action_buttons($tab_name, true, false); ?>
</table>
</form>