Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP fread problem
    primarykey
    data
    text
    <p>ive ran into an issue while creating a PHP telnet script at work to gather network data.</p> <p>as the amount of data returned from the 'Action: Status' command could be of any size... im concerned about using a static number with fread() on line 13. I have also tried using fgets() instead but it only grabs the first line of data (the META HTTP line... without the table). how can I grab an arbitrary amount of data from the socket using PHP? please help</p> <pre><code>&lt;?php $ami = fsockopen("192.100.100.180", 5038, $errno, $errstr); if (!$ami) { echo "ERROR: $errno - $errstr&lt;br /&gt;\n"; } else { fwrite($ami, "Action: Login\r\nUsername: 1005\r\nSecret: password\r\nEvents: off\r\n\r\n"); fwrite($ami, "Action: Status\r\n\r\n"); sleep(1); $record = fread($ami,9999);#this line could over run!!! $record = explode("\r\n", $record); echo "&lt;META HTTP-EQUIV=Refresh CONTENT=\"9\"&gt;"; #refresh page every 9 seconds echo "&lt;table border=\"1\"&gt;"; foreach($record as $value){ if(!strlen(stristr($value,'Asterisk'))&gt;0 &amp;&amp; !strlen(stristr($value,'Response'))&gt;0 &amp;&amp; !strlen(stristr($value,'Message'))&gt;0 &amp;&amp; !strlen(stristr($value,'Event'))&gt;0 &amp;&amp; strlen(strpos($value,' '))&gt;0) #remove blank lines php_table($value);; } echo "&lt;/table&gt;"; fclose($ami); } function php_table($value){ $row1 = true; $value = explode(" ", $value); foreach($value as $field){ if($row1){ echo "&lt;tr&gt;&lt;td&gt;".$field."&lt;/td&gt;"; $row1 = false; } else{ echo "&lt;td&gt;".$field."&lt;/td&gt;&lt;/tr&gt;"; $row1 = true; } } } ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload