Jump to content

Warning: Variable passed to each() is not an array or object in C:\xampp\htdocs\


phpnado

Recommended Posts

hello,

please i need ur help!!!!

when i enter this url in my browser:http://localhost:10080/ntop/dumpData.html?language=php&proto

i get:

$ntopHash = array(

'ff02::1:2' => array(

'index' => '0',

'hostNumIpAddress' => 'ff02::1:2',

'hostResolvedName' => 'ff02::1:2',

'firstSeen' => '1337008485',

'lastSeen' => '1337009340',

'minTTL' => '0',

'maxTTL' => '0',

'pktSent' => '0',

'pktRcvd' => '15',

'ipBytesSent' => '0',

'ipBytesRcvd' => '0',

etc......

 

 

so i'm writing a script to extract these informations and put them in a new web interface in a table.

my script is:

<HTML>
<HEAD>
<LINK REL=stylesheet HREF=http://localhost:3000/style.css type="text/css">
</HEAD>
<BODY BGCOLOR=red>

<?php
$host="localhost";
$port=10080;
$url="http://localhost:10080/ntop/dumpData.html?language=php&proto";
$fp = fsockopen ($host, $port);

if (!$fp) {
echo "$errstr ($errno)<br>\n";
} else {
$outStr = "";
fputs($fp, "GET $url HTTP/1.1\r\nHost: $host\r\n\r\n");
while (!feof($fp)) {
$out = fgets($fp,128);
if($out == "\n")
$begin = 1;
else if($begin = 1)
$outStr = $out;
}
fclose ($fp);
#echo "<pre>$outStr</pre>";
eval($outStr);
}

echo "<center>\n<table border>\n";
echo "<tr><th BGCOLOR=white>Sessions</th><th BGCOLOR=white>Values</th></tr>\n";

while (list ($key, $val) = each($ntopHash)) {

echo "<tr><th align=center BGCOLOR=white>$key</th>\n";
echo "<td><table border>\n";
while (list ($key_1, $val_1) = each ($val))
if(gettype($val_1) == "array") {
echo "<tr><th align=left>$key_1</th><td><table border>\n";
while (list ($key_2, $val_2) = each ($val_1)) {
echo "<tr><th align=left>$key_2</th><td align=right> $val_2</td></tr>\n";
}
echo "</table></td></tr>\n";
} else if($val_1 != "0") {
if($key_1 == "sessionState") {
if($val_1 == 0) $val2 = "SYN";
else if($val_1 == 1) $val2 = "SYN_ACK";
else if($val_1 == 2) $val2 = "ACTIVE";
else if($val_1 == 3) $val2 = "FIN1_ACK0";
else if($val_1 == 4) $val2 = "FIN1_ACK1";
else if($val_1 == 5) $val2 = "FIN2_ACK0";
else if($val_1 == 6) $val2 = "FIN2_ACK1";
else if($val_1 == 7) $val2 = "FIN2_ACK2";
else if($val_1 == $val2 = "TIMEOUT";
else if($val_1 == 9) $val2 = "END";

echo "<tr><th align=left>$key_1</th><td align=right> $val2</td></tr>\n";
} else
echo "<tr><th align=left>$key_1</th><td align=right> $val_1</td></tr>\n";
}

echo "</table></td></tr>\n";
}

echo "</table>\n";

// echo "<pre>$outStr<pre>";
?>


</center>
</body>
</html>

 

and i'm having this error:

Sessions Values

 

Warning: Variable passed to each() is not an array or object in C:\xampp\htdocs\projet\sessions.php on line 33

 

 

please i need your helpppp

You say that you "see" the array in plain-text when you enter that URL?  That URL is .html, and if you are not rewriting to parse PHP, you would be merely sending a plain-text array to your PHP script, so of course the script wouldn't recognize it as an array.

 

Please correct me if I'm wrong.

 

What is the source of http://localhost:10080/ntop/dumpData.html?language=php&proto

yes this URL  will define the %hash array that contains information about

the active hosts.

what can i do?

 

And you're sure the .html file is outputting to PHP?  I see you have a &language=php in the URL, but that means nothing to me.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.