I can successfully read this file as expected using echo…
<?php echo file_get_contents("http://pictureclock.ca/ip/ip.txt"); ?>But I can’t seem to read this the same way in this code, i must be missing something.
Perhaps there is a solution.
I want to read this from the external file and also populate the div spans with the same file get contents.
<?php
//$ip = '97.109.160.121'; //IP or web addy works fine as hard text.
**$ip = 'echo file_get_contents("http://pictureclock.ca/ip/ip.txt")';**
$port = "80"; //Port
$sock = @fsockopen( $ip, $port, $num, $error, 2 ); //2 is the ping time, you can sub what you need
//Since fsockopen function returns TRUE or FALSE we can just plug it into the IF/THEN statement. An IF/ELSE would have worked to
if( !$sock ){
//Do this if it is closed
echo
"<div
style='background-color: #FF1A0E;
color: white;
padding: 10px;
border-radius:1rem;
width: 180px;
height: 140px;
text-align: center;'>
"."
<p><b>MPGRCOM-IP</b><br>
<span>97.109.160.121</span><br>
DOWN</p></div>";
}
if( $sock ){
//Do this if it is open
echo"
<div
class='pulseBtn'
style='background-color: #008000;
color: white;
padding: 10px;
border-radius:1rem;
width: 180px;
height: 140px;
text-align: center;'>
"."
<p><b>MPGRCOM-IP</b><br>
<span>97.109.160.121</span><br>
OK</p></div>";
fclose($sock);
}
?>