This might be a complicated process, but try to stay with me on this.
Background: I am trying to display the statistics for my Web Server from Alerta to display the stats on my website's Server Uptime page.
[Sorry for the link in the previous post, I posted the same article on another forum and forgot that the links posted here leaks PR or something still- so I edited it. BTW, the other post still shows a link to the alerta page, might want to edit that too and not just the page that I am asking for help on.]
Unfortunately you cannot see the page, but the font color is taken from the alerta page (which is black) and then pasted into my page.
Could I use:
Code:$table = str_replace('000000', 'FFFFFF', $table);
To replace the black color and change it to white?
Problem: The font color is black, and does not look good on my page. How would I change it to become white?
Code: [server_uptime.php]
Code:<table width=400px>
<tr>
<td align=center>
<?php
$servername = "servename";
// $headercolor can be the HTML hex color of your choice.
$headercolor = "#88A4C8";
include("include_stats.php");
?>
</td>
</tr>
</table>
Code: [include_stats.php]
Code:<?php
$servernames = array
(
"servernameo" => "servernumbero",
"servernamet" => "servernumbert"
);
// variables that should be set beforehand..
if(!isset($servername))
die('<b>Error!</b> Please set the variable "$servername" in your script.');
if(!isset($headercolor))
die('<b>Error!</b> Please set the variable "$headercolor" in your script.');
if(!array_key_exists($servername, $servernames))
{
$diestr = '<b>Error!</b> Invalid server name. Please ensure that "$servername" is one of the following:<br><br>';
foreach($servernames as $servername => $id)
$diestr .= ": $servername :";
die($diestr);
}
$fp = fsockopen("uptime.alertra.com", 80, $errno, $errstr, 30);
if(!$fp)
die("<b>Error!</b> Unable to connect to uptime server. Please try again later.");
else
{
$getstr = "GET /uptime2?id2=1111&id1={$servernames[$servername]} HTTP/1.0\r\nHost: uptime.alertra.com\r\n\r\n";
fputs($fp, $getstr);
$str='';
while(!feof($fp))
$str .= fgets($fp,128);
fclose($fp);
}
$start_delim =
'</b></font></td></tr>
</table>
';
$end_delim =
'<tr>
<td colspan=5 height=3 bgcolor=#00777F><img src="http://uptime.alertra.com/img/space1" alt="" height="1" width="1" border="0" /></td>
</tr>';
// grab the main uptime tables
preg_match("/" . preg_quote($start_delim, '/') . "(.*)" . preg_quote($end_delim, '/') . "/s", $str, $matches);
// get rid of the spacer row and replace it with our own
$table = str_replace('<tr><td colspan=2 height=8><img src="http://uptime.alertra.com/img/space1" alt="" height="1" width="1" border="0" /></td></tr>', '<tr><td> </td></tr>', $matches[1]);
// maintain anonymity in case something goes wrong
$table = str_replace('myserver', '', $table);
// had to lop off this last tag in the regex
$table .= "</table>";
if(isset($headercolor))
$table = str_replace("#00777F", $headercolor, $table);
print $table;
?>