Пример #1
0
function _prettifyObj($d)
{
    static $z = 0;
    switch (true) {
        case is_null($d):
            return 'null';
        case is_bool($d):
            return $d ? 'true' : 'false';
        case is_numeric($d):
            return $d;
        case is_string($d):
            return empty($d) || is_numeric($d) || $z !== 0 || $d !== addslashes($d) || strpos($d, ' ') !== false ? '"' . addslashes($d) . '"' : $d;
        case is_array($d) && empty($d):
            return '[]';
        case is_array($d) && isList($d):
            $z++;
            $out = '[ ' . join(",", array_map(function ($i) use(&$z) {
                $z++;
                $out = _prettifyObj($i);
                $z--;
                return $out;
            }, $d)) . ' ]';
            $out = str_replace("", strlen($out) > 120 ? "\n" . str_repeat('  ', $z + 1) : ' ', $out);
            $z--;
            return $out;
        case is_array($d):
            $out = [];
            foreach ($d as $k => $v) {
                $z++;
                $out[] = _prettifyObj($k) . ': ' . _prettifyObj($v);
                $z--;
            }
            $out = "{ " . join(",", $out) . ' }';
            $out = str_replace("", strlen($out) > 120 ? "\n" . str_repeat('  ', $z + 1) : ' ', $out);
            return $out;
        case is_object($d):
            //, 'stdClass') || is_a($d, '\\BEM\\Context'):
            $out = [];
            foreach ($d as $k => $v) {
                $z++;
                $out[] = _prettifyObj($k) . ': ' . _prettifyObj($v);
                $z--;
            }
            $cls = get_class($d);
            $out = "{ " . ($cls === 'stdClass' ? '' : '/*' . $cls . "*/") . join(",", $out) . ' }';
            $out = str_replace("", strlen($out) > 120 ? "\n" . str_repeat('  ', $z + 1) : ' ', $out);
            return $out;
        case is_object($d):
            return str_replace("\n", "\n" . str_repeat("  ", $z), json_encode($d, JSON_PRETTY_PRINT));
        default:
            return var_export($d, 1);
    }
    return 'xxx';
}
Пример #2
0
 /**
  * Array.isArray analogue
  * @param mixed $ex
  * @return boolean
  */
 public function isArray($ex)
 {
     return isList($ex);
 }
Пример #3
0
	<tr>
		<th style="white-space: nowrap; padding: 5px;font-size:12px">
			<?php 
echo gettext("Sensor");
?>
		</th>
	</tr>
	<tr><td class="nobborder">&middot; <i><?php 
echo _("Empty selection means ANY sensor");
?>
</i></td></tr>
	<tr>
		<td class="nobborder">
		<select id="sensorselect" class="multiselect_sensor" multiple="multiple" name="sensorselect[]" style="display:none;width:600px">
		<?php 
if (isList($rule->sensor) && $rule->sensor != "") {
    ?>
		<?php 
    $sensor_list = $rule->sensor;
    if ($host_list = getSensorList()) {
        foreach ($host_list as $host) {
            $hostname = $host->get_name();
            $ip = $host->get_ip();
            if (in_array($ip, split(',', $sensor_list))) {
                echo "<option value='{$ip}' selected>{$hostname}</option>\n";
            }
        }
    }
    ?>
		<?php 
}
Пример #4
0
echo preg_match("/\\:...\\_IP/", $rule->to) ? "hidden" : "visible";
?>
">
									<table>
										<tr>
											<td class="nobborder" valign="top">
												<table align="center" class="noborder">
												<tr>
													<th style="background-position:top center"><?php 
echo _("Destination");
?>
													</th>
													<td class="left nobborder">
														<select id="toselect" name="toselect[]" size="12" multiple="multiple" style="width:150px">
														<?php 
if (isList($rule->to) && $rule->to != "" && !preg_match("/\\:...\\_IP/", $rule->to)) {
    ?>
														<?php 
    $to_list = $rule->to;
    foreach ($host_list as $host) {
        $hostname = $host->get_hostname();
        $ip = $host->get_ip();
        if (in_array($ip, split(',', $to_list))) {
            echo "<option value='{$ip}'>{$ip}</option>\n";
        }
        if (in_array("!" . $ip, split(',', $to_list))) {
            echo "<option value='!{$ip}'>!{$ip}</option>\n";
        }
    }
    foreach ($net_list as $net) {
        $netname = $net->get_name();
Пример #5
0
?>
	<!--
	<tr>
		<td style="width: <?php 
echo $left_select_width;
?>
;text-align: left; padding-left: 5px">
			<select style="width: <?php 
echo $left_select_width;
?>
" name="plugin_sid" id="plugin_sid" onchange="onChangePluginSid()">
				<?php 
$selected = selectIf(isAny($rule->plugin_sid));
echo "<option value=\"ANY\"{$selected}>ANY</option>";
for ($i = 1; $i <= $rule->level - 1; $i++) {
    $sublevel = $i . ":PLUGIN_SID";
    echo "<option value=\"{$sublevel}\">{$sublevel}</option>";
    $sublevel = "!" . $i . ":PLUGIN_SID";
    echo "<option value=\"{$sublevel}\">{$sublevel}</option>";
}
$selected = selectIf(isList($rule->plugin_sid));
echo "<option value=\"LIST\"{$selected}>LIST</option>";
?>
			</select>
		</td>
	</tr>
	-->
</table>
</div>
	<!-- #################### END: global properties ##################### -->
Пример #6
0
 /**
  * Brings items of inner simple arrays to root level if exists
  * @param  array $a
  * @return array
  */
 public static function flattenList($a)
 {
     if (!isList($a)) {
         return $a;
     }
     do {
         $flatten = false;
         for ($i = 0, $l = sizeof($a); $i < $l; $i++) {
             if (isList($a[$i])) {
                 $flatten = true;
                 break;
             }
         }
         if (!$flatten) {
             break;
         }
         $res = [];
         for ($i = 0; $i < $l; $i++) {
             if (!isList($a[$i])) {
                 // filter empty arrays inside
                 if (!(is_array($a[$i]) && empty($a[$i]))) {
                     $res[] = $a[$i];
                 }
             } else {
                 $res = array_merge($res, (array) $a[$i]);
             }
         }
         $a = $res;
     } while ($flatten);
     return $a;
 }
Пример #7
0
?>
',
		'<?php 
echo isList($rule->to) ? $rule->to : '';
?>
',
		'<?php 
echo isList($rule->port_from) ? $rule->port_from : '';
?>
',
		'<?php 
echo isList($rule->port_to) ? $rule->port_to : '';
?>
',
		'<?php 
echo isList($rule->sensor) ? $rule->sensor : '';
?>
'
	)" >
	<!-- #################### main container #################### -->
  <form method="POST" id="frule" name="frule" action="../../include/utils.php?query=save_rule">
	<table class="transparent" width="100%">
		<tr>
			<td class="nobborder" id="steps" style="border-bottom:1px solid #EEEEEE">
				<table class="transparent">
					<?php 
$display = $rule->plugin_id > 0 ? "" : ";display:none";
?>
					<tr>
						<td class="nobborder"><img src="../../../pixmaps/wand.png" alt="wizard"></img></td>
						<td class="nobborder" style="font-size:11px" nowrap><?php