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
/
common
/
commonphp.php
< prev
next >
Wrap
PHP Script
|
2010-09-07
|
20KB
|
638 lines
<?php
setlocale(LC_ALL, "");
require('common2.php');
$INSIDE_TEXT_WIDTH = 524;
define('GLOBAL_FSCSS_SERVICE_NAME', 'F-Secure Anti-Virus Server Daemon');
define('GLOBAL_FSMA_SERVICE_NAME', 'FSMA');
define('GLOBAL_FSAVIM_SERVICE_NAME', 'fsavag4im');
define('GLOBAL_FSAVIGW_SERVICE_NAME', 'F-Secure Anti-Virus for Internet Gateways Daemon');
define('GLOBAL_FSAVMSE_SERVICE_NAME', 'fsavmsed');
define('GLOBAL_FSAVMSE_SERVICE_NAME2', 'fsavag4mse');
define('GLOBAL_BACKWEB_SERVICE_NAME1', 'FSAUA');
define('GLOBAL_BACKWEB_SERVICE_NAME2', 'BackWeb Client - 7681197');
define('GLOBAL_BACKWEB_SERVICE_NAME3', 'BackWeb Plug-in - 7681197');
define('GLOBAL_WORLDMAP_SERVICE_NAME', 'F-Secure World Map Reporting Service');
define("GLOBAL_INT", 0);
define("GLOBAL_STR", 1);
define("GLOBAL_TBL", 2);
define("GLOBAL_TIME_TICKS", 3);
define("GLOBAL_TIMESTAMP", 4);
define("GLOBAL_REG_INT", 5);
define("GLOBAL_REG_STR", 6);
define("GLOBAL_SIZE_BYTES", fsloc('bytes'));
define("GLOBAL_SIZE_KB", fsloc('KB'));
define("GLOBAL_SIZE_MB", fsloc('MB'));
define("GLOBAL_SIZE_GB", fsloc('GB'));
define("GLOBAL_SIZE_TB", fsloc('TB'));
define('GLOBAL_EMPTYTBL_TEXT', 'No entries specified');
define('GLOBAL_MATCHLISTS_OID', '1.3.6.1.4.1.2213.20.1.100.40.10');
define('GLOBAL_MESSAGETEMPLATES_OID', '1.3.6.1.4.1.2213.20.1.100.40.20');
define('GLOBAL_WORLDMAP_SERVICE_NAME', 'F-Secure World Map Reporting Service');
$GLOBAL_PRODUCT_NAME = 'F-Secure Web Console';
$GLOBAL_LOC_LANGS = array('DEU' => 'de_DE', 'ENG' => 'en_EMEA', 'ESN' => 'en_EMEA', 'FRA' => 'fr_FR', 'JPN' => 'ja_JP', 'ITA' => 'it_IT');
/* no fsma mode */
if(GLOBAL_NO_FSMA_MODE == 1 || GLOBAL_NO_SERVICE_CHECK == 1)
define('GLOBAL_NO_FSMA_MODE', 1);
else
define('GLOBAL_NO_FSMA_MODE', 0);
/* no service checks mode */
if(isset($_SERVER[NO_SERVICE_CHECK]) && $_SERVER[NO_SERVICE_CHECK] == 1)
define('GLOBAL_NO_SERVICE_CHECK', 1);
else
define('GLOBAL_NO_SERVICE_CHECK', 0);
/* no fsma mode */
if(isset($_SERVER[DEMO_MODE]) && $_SERVER[DEMO_MODE] == 1)
{
define('GLOBAL_NO_SERVICE_CHECK', 1);
define('GLOBAL_DEMO_MODE', 1);
}
else
define('GLOBAL_DEMO_MODE', 0);
function readSettings($Page_Settings)
{
for($i = 0; $i < count($Page_Settings); $i++)
{
if(GLOBAL_NO_FSMA_MODE == 1)
{
if($Page_Settings[$i][type] == GLOBAL_INT)
settings_get_default_int($Page_Settings[$i][oid], &$Page_Settings[$i][value]);
else if($Page_Settings[$i][type] == GLOBAL_STR)
settings_get_default_str($Page_Settings[$i][oid], &$Page_Settings[$i][value]);
else if($Page_Settings[$i][type] == GLOBAL_REG_INT)
settings_get_reg_default_int($Page_Settings[$i][oid], &$Page_Settings[$i][value]);
else if($Page_Settings[$i][type] == GLOBAL_REG_STR)
settings_get_reg_default_str($Page_Settings[$i][oid], &$Page_Settings[$i][value]);
else if($Page_Settings[$i][type] == GLOBAL_TBL)
{
$Page_Settings[$i][value] = array();
settings_get_default_table($Page_Settings[$i][oid], $Page_Settings[$i][value]);
}
}
else
{
if($Page_Settings[$i][type] == GLOBAL_INT) {
settings_get_int($Page_Settings[$i][oid], &$Page_Settings[$i][value]);
// PHP supports unsigned integers only! values > 2147483647 becomes negative
// here we conert it to a normal view
if ($Page_Settings[$i][value] < 0) $Page_Settings[$i][value] = 4294967296 + $Page_Settings[$i][value];
}
else if($Page_Settings[$i][type] == GLOBAL_STR)
settings_get_str($Page_Settings[$i][oid], &$Page_Settings[$i][value]);
else if($Page_Settings[$i][type] == GLOBAL_REG_INT)
settings_get_reg_int($Page_Settings[$i][oid], &$Page_Settings[$i][value]);
else if($Page_Settings[$i][type] == GLOBAL_REG_STR)
settings_get_reg_str($Page_Settings[$i][oid], &$Page_Settings[$i][value]);
else if($Page_Settings[$i][type] == GLOBAL_TBL)
{
$Page_Settings[$i][value] = array();
settings_get_table($Page_Settings[$i][oid], $Page_Settings[$i][value]);
}
if(($Page_Settings[$i][type] == GLOBAL_INT || $Page_Settings[$i][type] == GLOBAL_STR)
&& settings_is_final($Page_Settings[$i][oid], 0))
$Page_Settings[$i][lock] = getLockImg();
}
}
}
function getLockImg()
{
return '<img src="/pics/lock.gif" border=0 alt="' . fsloc('Setting is final') . '" class="final_lock">';
}
function readDefaultSettings($Page_Settings)
{
for($i = 0; $i < count($Page_Settings); $i++)
{
if($Page_Settings[$i][skip] == true)
{
continue;
}
if($Page_Settings[$i][type] == GLOBAL_INT)
{
settings_get_default_int($Page_Settings[$i][oid], &$Page_Settings[$i][value]);
settings_set_int($Page_Settings[$i][oid], $Page_Settings[$i][value]);
}
else if($Page_Settings[$i][type] == GLOBAL_STR)
{
settings_get_default_str($Page_Settings[$i][oid], &$Page_Settings[$i][value]);
settings_set_str($Page_Settings[$i][oid], $Page_Settings[$i][value]);
}
else if($Page_Settings[$i][type] == GLOBAL_TBL)
{
$Page_Settings[$i][value] = array();
settings_get_default_table($Page_Settings[$i][oid], $Page_Settings[$i][value]);
settings_set_table($Page_Settings[$i][oid], $Page_Settings[$i][value]);
}
else if($Page_Settings[$i][type] == GLOBAL_REG_INT)
{
settings_get_reg_default_int($Page_Settings[$i][oid], &$Page_Settings[$i][value]);
settings_set_reg_int($Page_Settings[$i][oid], $Page_Settings[$i][value]);
}
else if($Page_Settings[$i][type] == GLOBAL_REG_STR)
{
settings_get_reg_default_str($Page_Settings[$i][oid], &$Page_Settings[$i][value]);
settings_set_reg_str($Page_Settings[$i][oid], $Page_Settings[$i][value]);
}
}
}
function writeSettings($Page_Settings)
{
if($_SERVER[CACHED_TAG] != $_SERVER[MASTER_CACHE])
return;
for($i = 0; $i < count($Page_Settings); $i++)
{
if(($Page_Settings[$i][type] == GLOBAL_INT || $Page_Settings[$i][type] == GLOBAL_STR)
&& settings_is_final($Page_Settings[$i][oid], 0))
continue;
if(isset($_POST["VAR_PAGE_SETTINGS_$i"]) && $Page_Settings[$i][type] == GLOBAL_INT)
settings_set_int($Page_Settings[$i][oid], $_POST["VAR_PAGE_SETTINGS_$i"]);
else if(isset($_POST["VAR_PAGE_SETTINGS_$i"]) && $Page_Settings[$i][type] == GLOBAL_STR)
settings_set_str($Page_Settings[$i][oid], stripslashes($_POST["VAR_PAGE_SETTINGS_$i"]));
else if($Page_Settings[$i][type] == GLOBAL_TBL)
settings_set_table($Page_Settings[$i][oid], $Page_Settings[$i][value]);
else if(isset($_POST["VAR_PAGE_SETTINGS_$i"]) && $Page_Settings[$i][type] == GLOBAL_REG_INT)
settings_set_reg_int($Page_Settings[$i][oid], $_POST["VAR_PAGE_SETTINGS_$i"]);
else if(isset($_POST["VAR_PAGE_SETTINGS_$i"]) && $Page_Settings[$i][type] == GLOBAL_REG_STR)
settings_set_reg_str($Page_Settings[$i][oid], stripslashes($_POST["VAR_PAGE_SETTINGS_$i"]));
}
if(isset($_POST[APPLY_SETTINGS])&& $_POST[APPLY_SETTINGS] == 1)
settings_write_changed();
}
function readPageData($Page_Settings)
{
for($i = 0; $i < count($Page_Settings); $i++)
{
if(isset($_POST["VAR_PAGE_SETTINGS_{$i}"]))
{
$Page_Settings[$i][value] = stripslashes($_POST["VAR_PAGE_SETTINGS_{$i}"]);
}
else if($Page_Settings[$i][type] == GLOBAL_INT)
settings_get_int($Page_Settings[$i][oid], &$Page_Settings[$i][value]);
else if($Page_Settings[$i][type] == GLOBAL_STR)
settings_get_str($Page_Settings[$i][oid], &$Page_Settings[$i][value]);
else if($Page_Settings[$i][type] == GLOBAL_REG_INT)
settings_get_reg_int($Page_Settings[$i][oid], &$Page_Settings[$i][value]);
else if($Page_Settings[$i][type] == GLOBAL_REG_STR)
settings_get_reg_str($Page_Settings[$i][oid], &$Page_Settings[$i][value]);
}
}
function cleanPath($path)
{
$arrsearch = array("\\\\", "//", "/");
$path = str_replace("\"", "", $path);
$path = str_replace($arrsearch, "\\", $path);
$result = array();
$pathA = explode('\\', $path);
if (!$pathA[0])
$result[] = '';
foreach ($pathA AS $key => $dir) {
if ($dir == '..') {
if (end($result) == '..') {
$result[] = '..';
} elseif (!array_pop($result)) {
$result[] = '..';
}
} elseif ($dir && $dir != '.') {
$result[] = $dir;
}
}
if (!end($pathA))
$result[] = '';
return implode('\\', $result);
}
function makeFullPath($param, $product)
{
if(strpos($param, '\\\\') === 0)
{
if(strpos($param, '\\\\\\\\') === 0)
return stripslashes($param);
else
return $param;
}
if(strpos($param, ':') !== false)
{
$param_m = cleanPath($param);
$ret = realpath($param_m);
if (strlen($ret)>0)
return $ret;
else
return $param_m;
}
if($product == 'MSE')
dfp_get_policy_str('1.3.6.1.4.1.2213.20.2.5', &$product_dir);
else if($product == 'AVIM')
dfp_get_policy_str('1.3.6.1.4.1.2213.22.2.5', &$product_dir);
else if($product == 'AVIGW')
dfp_get_policy_str('1.3.6.1.4.1.2213.24.2.5', &$product_dir);
else if($product == 'CSS')
dfp_get_policy_str('1.3.6.1.4.1.2213.18.2.5', &$product_dir);
// else if($product == 'AUA')
// dfp_get_policy_str('1.3.6.1.4.1.2213.42.2.5', &$product_dir);
else if($product == 'FSMA')
dfp_get_policy_str('1.3.6.1.4.1.2213.11.2.5', &$product_dir);
else if($product == 'FQM' || $product == 'AUA')
{
dfp_get_policy_str('1.3.6.1.4.1.2213.11.2.5', &$product_dir);
$slashposition = strrpos($product_dir, '\\', -2);
if($slashposition !== FALSE)
$product_dir = substr($product_dir, 0, $slashposition) . ($product == 'FQM' ? "\\Quarantine Manager\\" : "\\FSAUA\\");
}
else
return '';
if ($product_dir[strlen($product_dir)-1] != "\\")
$product_dir .= "\\";
$product_dir .= $param;
$product_dir = cleanPath($product_dir);
$ret = realpath($product_dir);
if ($ret == '')
return $product_dir;
else
return $ret;
}
function get_service_installed($service_name, $status, $cache = FALSE)
{
if(GLOBAL_DEMO_MODE)
{
$status = 4;
return $status;
}
if($cache)
system_is_service_installed_cache($service_name, &$status);
else
system_is_service_installed($service_name, &$status);
return $status;
}
function get_service_info($service_name, $status, $status_readable, $status_image)
{
$status_readable = fsloc('Unknown');
$status_image = '/pics/icon/icon_yellow.gif';
if(system_get_service_status($service_name, &$status) == -1)
return -1;
if($status == 1)
{
$status_image = '/pics/icon/icon_red.gif';
$status_readable = fsloc('Stopped');
}
else if($status == 2)
$status_readable = fsloc('Starting');
else if($status == 3)
$status_readable = fsloc('Stopping');
else if($status == 4)
{
$status_image = '/pics/icon/icon_green.gif';
$status_readable = fsloc('Running');
}
}
function chech_db_date($css_update_version)
{
$year = substr($css_update_version, 0, 4);
$month = substr($css_update_version, 5, 2);
$day = substr($css_update_version, 8, 2);
$database_age = time() - mktime(0, 0, 0, $month, $day, $year);
@dfp_get_policy_int('1.3.6.1.4.1.2213.18.1.27.51', &$database_allowed_age);
if($database_age / (60*60*24) > $database_allowed_age)
return false;
return true;
}
function submit_if_standalone()
{
if($GLOBALS["NoEdit"] != 'true')
{
echo '
document.form.SUBMIT_TABLE.value = 1;
document.form.submit();';
}
}
function ConvertKB2KMGTB($size)
{
if ($size === false || $size == "") $size = 0;
if($size > 1073741824)
$size_str = round($size / 1073741824) . ' ' . GLOBAL_SIZE_TB;
if($size > 1048576)
$size_str = round($size / 1048576) . ' ' . GLOBAL_SIZE_GB;
else if($size > 1024)
$size_str = round($size / 1024) . ' ' . GLOBAL_SIZE_MB;
else
$size_str = $size . ' ' . GLOBAL_SIZE_KB;
return $size_str;
}
function utf8_substr($str,$start)
{
preg_match_all("/./su", $str, $ar);
if(func_num_args() >= 3) {
$end = func_get_arg(2);
return join("",array_slice($ar[0],$start,$end));
} else {
return join("",array_slice($ar[0],$start));
}
}
function size_readable($size, $max_unit = null, $retstring = null, $need_unit = null)
{
// Units
$sizes = array(GLOBAL_SIZE_BYTES, GLOBAL_SIZE_KB, GLOBAL_SIZE_MB, GLOBAL_SIZE_GB, GLOBAL_SIZE_TB);
// Need unit
if ($need_unit !== null)
$need_unit = array_search((string) $need_unit, $sizes);
if($need_unit === null || $need_unit === false)
{
$need_unit = -1;
// Max unit
if ($max_unit !== null)
$max_unit = array_search((string) $max_unit, $sizes);
if ($max_unit === null || $max_unit === false)
$max_unit = 4;
}
else
$max_unit = $need_unit;
$i = 0;
while (($size >= 1024 || $i < $need_unit) && $i < $max_unit)
{
$size /= 1024;
$i++;
}
// Return string \
if ($retstring === null)
$retstring = '%01.2f %s';
// don't need 123.00 B
if($i == 0 && $size < 1024)
$retstring = '%s %s';
return sprintf($retstring, $size, $sizes[$i]);
}
function convert2localtime($time)
{
$i = preg_split("/[^0-9]/", $time); // 2005-11-15T11:59:01
// hours min sec months days years
return date('Y-n-j g:i:s A', mktime($i[3], $i[4], $i[5], $i[1], $i[2], $i[0]) + date('Z'));
}
function parse_time_period($miliseconds, &$normalized, &$index)
{
$miliseconds /= 100; // convert to seconds
$index = INDEX_UNKNOWN;
if($miliseconds<(60)) {
// Seconds
$normalized = $miliseconds;
$index = INDEX_SECONDS;
} else if($miliseconds<(60*60)) {
// Minutes
$normalized = round($miliseconds/60);
$index = INDEX_MINUTES;
} else if($miliseconds<(60*60*24)) {
// Hours
$normalized = round($miliseconds/60/60);
$index = INDEX_HOURS;
} else if($miliseconds<(60*60*24*7)) {
// Days
$normalized = round($miliseconds/60/60/24);
$index = INDEX_DAYS;
} else if($miliseconds<(60*60*24*30)) {
// Weeks
$normalized = round($miliseconds/60/60/24/7);
$index = INDEX_WEEKS;
} else if($miliseconds<(60*60*24*365)) {
// Months
$normalized = round($miliseconds/60/60/24/30);
$index = INDEX_MONTHS;
} else {
// Years
$normalized = round($miliseconds/60/60/24/365);
$index = INDEX_YEARS;
}
}
function myFind($sDir, $sPattern, $nFlags = NULL)
{
if(@file_exists("$sDir\\$sPattern"))
return $sDir;
$subfolders = glob($sDir . '\\*', GLOB_ONLYDIR);
if(is_array($subfolders) === FALSE)
return;
foreach ($subfolders as $sSubDir)
{
if(strlen($sSubDir) == 0)
continue;
$foundPath = myFind($sSubDir, $sPattern, $nFlags);
if(strlen($foundPath) > 0)
return $foundPath;
}
}
function empty_temp_folder()
{
$curpath = '..\\temp\\';
$dir = dir($curpath);
if(!$dir)
return;
while ($file = $dir->read())
{
if( $file != "." && $file != ".." &&
$file != 'f-secure-background.jpg' &&
is_file($curpath.$file))
{
unlink($curpath.$file);
}
}
$dir->close();
}
function adapt_range_bound($val, $adapt)
{
if ($adapt)
return $adapt."(".$val.")";
return $val;
}
function get_validation_script_impl($s, $adapt)
{
if ($s[type]==GLOBAL_INT)
{
// Numbers are converted to scientific format with guaranteed '.' separator.
// Manual conversion to scintific format is needed because min or max values before adaption
// may be outside of integer range and autoconverion to string in adapt_range_bound()
// may produce representation with ',' separator.
// Note that parseInt() used in parse_and_validate_int recognizes scientific
// representations correctly.
$min = adapt_range_bound(sprintf("%e", $s[min]), $adapt);
$max = adapt_range_bound(sprintf("%e", $s[max]), $adapt);
return "
msg = parse_and_validate_int(v, ".$min.",".$max.");
";
}
else if ($s[type]==GLOBAL_STR && isset($s[required]))
{
$s_name = isset($s[name]) ? ('"' . $s[name] . '"') : 'this setting';
return "
msg = (v && v != '') ? null : 'Empty value for $s_name is not allowed';
";
}
return "";
}
function make_search_virus_link($infection_name)
{
if ($infection_name == "")
return "-";
return "<a href='http://cgi.f-secure.com/cgi-bin/search.cgi?q=".urlencode($infection_name)."' target=_blank style='COLOR: blue;'>".$infection_name."</a>";
}
function get_validation_script($setting, $tab_name, $input_indices, $range_adapter_fn = null)
{
$form_name = "form_".$tab_name;
if ($setting[type]==GLOBAL_INT && (!isset($setting[min]) || !isset($setting[max])))
return "";
return "
{
var f = document.".$form_name.";
if (f)
{
var e = f.".$input_indices.";
if (e)
{
var v = e.value;
var msg = null;
".get_validation_script_impl($setting, $range_adapter_fn)."
if (msg != null)
{
show_webui_message_box('" . fsloc('Invalid input') . "', msg, 0);
try {e.focus();} catch (e) {}
return false;
}
}
}
};";
}
function is_backweb_service_installed()
{
foreach (array(GLOBAL_BACKWEB_SERVICE_NAME1, GLOBAL_BACKWEB_SERVICE_NAME2, GLOBAL_BACKWEB_SERVICE_NAME3) as $i)
if (get_service_installed($i, null, TRUE) == 1)
return $i;
return null;
}
function is_mse_service_installed()
{
if (!products_is_av4mse_installed())
return null;
foreach (array(GLOBAL_FSAVMSE_SERVICE_NAME, GLOBAL_FSAVMSE_SERVICE_NAME2) as $i)
if (get_service_installed($i, null, TRUE) == 1)
return $i;
return null;
}
function is_transport_agent_installed($mse_service_name)
{
if (!products_is_av4mse_installed())
return false;
if (GLOBAL_NO_SERVICE_CHECK)
return true;
if($mse_service_name == GLOBAL_FSAVMSE_SERVICE_NAME2)
return true;
return system_get_registry_value('HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\MSExchangeTransport', 'ObjectName', &$tra_acc) == 0 && $tra_acc != '';
}
function is_store_agent_installed()
{
if (!products_is_av4mse_installed())
return false;
if (GLOBAL_NO_SERVICE_CHECK)
return true;
return system_get_registry_value('HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\MSExchangeIS', 'ObjectName', &$store_acc) == 0 && $store_acc != '';
}
function get_query_string_param($key, $def = null)
{
foreach (explode('&', $_SERVER['QUERY_STRING']) as $entry)
{
$tmp = explode('=', $entry);
if (isset($tmp[0]) && $tmp[0] === $key && isset($tmp[1]))
return $tmp[1];
}
return $def;
}
function EscapeJSCodeString($str)
{
return '"'.htmlspecialchars(addcslashes($str, '"\\'), ENT_QUOTES).'"';
}
function cut_ctr_chars($string)
{
if ($string[0] >= 0 && $string[0] < 32)
{
return substr($string,1,-1);
}
return $string;
}
class SortUtil {
static private $sortfield = null;
static private $sortorder = 1;
static private function sort_callback(&$a, &$b) {
if($a[self::$sortfield] == $b[self::$sortfield]) return 0;
return ($a[self::$sortfield] < $b[self::$sortfield])? -self::$sortorder : self::$sortorder;
}
static function sort(&$v, $field, $asc=true) {
self::$sortfield = $field;
self::$sortorder = $asc? 1 : -1;
usort($v, array('SortUtil', 'sort_callback'));
}
}
?>