phpnado Posted May 14, 2012 Share Posted May 14, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/262520-warning-variable-passed-to-each-is-not-an-array-or-object-in-cxampphtdocs/ Share on other sites More sharing options...
Maq Posted May 14, 2012 Share Posted May 14, 2012 in the future, place OR tags around your code. Quote Link to comment https://forums.phpfreaks.com/topic/262520-warning-variable-passed-to-each-is-not-an-array-or-object-in-cxampphtdocs/#findComment-1345352 Share on other sites More sharing options...
mrMarcus Posted May 14, 2012 Share Posted May 14, 2012 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 Quote Link to comment https://forums.phpfreaks.com/topic/262520-warning-variable-passed-to-each-is-not-an-array-or-object-in-cxampphtdocs/#findComment-1345364 Share on other sites More sharing options...
phpnado Posted May 14, 2012 Author Share Posted May 14, 2012 yes this URL will define the %hash array that contains information about the active hosts. what can i do? Quote Link to comment https://forums.phpfreaks.com/topic/262520-warning-variable-passed-to-each-is-not-an-array-or-object-in-cxampphtdocs/#findComment-1345368 Share on other sites More sharing options...
phpnado Posted May 14, 2012 Author Share Posted May 14, 2012 i'm using ntop server Quote Link to comment https://forums.phpfreaks.com/topic/262520-warning-variable-passed-to-each-is-not-an-array-or-object-in-cxampphtdocs/#findComment-1345369 Share on other sites More sharing options...
mrMarcus Posted May 14, 2012 Share Posted May 14, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/262520-warning-variable-passed-to-each-is-not-an-array-or-object-in-cxampphtdocs/#findComment-1345372 Share on other sites More sharing options...
phpnado Posted May 14, 2012 Author Share Posted May 14, 2012 yess Quote Link to comment https://forums.phpfreaks.com/topic/262520-warning-variable-passed-to-each-is-not-an-array-or-object-in-cxampphtdocs/#findComment-1345373 Share on other sites More sharing options...
Jessica Posted May 14, 2012 Share Posted May 14, 2012 Why would you have it in a .html? Did you configure your server to parse .html files as php? Try making it a .php and see if it works. What is the content of your .html file? Quote Link to comment https://forums.phpfreaks.com/topic/262520-warning-variable-passed-to-each-is-not-an-array-or-object-in-cxampphtdocs/#findComment-1345375 Share on other sites More sharing options...
mrMarcus Posted May 14, 2012 Share Posted May 14, 2012 yess noo You said you "see" the array on the screen when you enter that file into your browser. That means you are NOT outputting the contents of the file to PHP. Quote Link to comment https://forums.phpfreaks.com/topic/262520-warning-variable-passed-to-each-is-not-an-array-or-object-in-cxampphtdocs/#findComment-1345384 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.