1
   

Changing font while using getstr

 
 
Reply Wed 3 Dec, 2003 09:46 pm
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;

?>
  • Topic Stats
  • Top Replies
  • Link to this Topic
Type: Discussion • Score: 1 • Views: 1,582 • Replies: 8
No top replies

 
Craven de Kere
 
  1  
Reply Wed 3 Dec, 2003 10:02 pm
1) No PR drain here. All external links go through an intermediary step to eliminate all PR.

2) Set a CSS class for the table cell in the PHP script.

3) Add the class to your CSS and make it change the color of the text within the cells.
0 Replies
 
BobbyDouglas
 
  1  
Reply Wed 3 Dec, 2003 10:15 pm
1) No PR drain here. All external links go through an intermediary step to eliminate all PR.
- Oh, Why delete links then?

2) Set a CSS class for the table cell in the PHP script.
3) Add the class to your CSS and make it change the color of the text within the cells.
But the page is displayed with the black font. Saying font color=000000. A CSS class wont overide that.

This is what the output currently looks like:
Code:<table width=400px>
<tr>
<td align=center>

<table border="0" cellpadding="0" width="100%" cellspacing="0">
<tr valign=top>
<td>
<table border="0" cellpadding="2" width="100%" cellspacing="1">
<tr>
<td colspan=2 height=18 bgcolor=#88A4C8 align=left><font face="Verdana" size="1" color=#FFFFFF>Server Uptime Monitoring</font></td>
</tr>
<tr>
<td align=left width="80"><font face="Verdana" size=1 color=#000000>Since:</font></td>
<td align=left><font face="Verdana" size=1 color=#000000>10/14/2003</font></td>
</tr>
<tr>
<td align=left><font face="Verdana" size=1 color=#000000>Outages:</font></td>
<td align=left><font face="Verdana" size=1 color=#000000>4</font></td>
</tr>
<tr>
<td align=left><font face="Verdana" size=1 color=#000000>Uptime:</font></td>
<td align=left><font face="Verdana" size=1 color=#000000><b> 99.804%</b></font></td>
</tr>
</table>
</td>
<td>
<table border="0" cellpadding="2" width="100%" cellspacing="1">
<tr>
<td height=18 bgcolor=#88A4C8 align=left><font face="Verdana" size="1" color=#FFFFFF>Year</font></td>
<td height=18 bgcolor=#88A4C8 align=right><font face="Verdana" size="1" color=#FFFFFF>Outages</font></td>
<td height=18 bgcolor=#88A4C8 align=right><font face="Verdana" size="1" color=#FFFFFF>Uptime</font></td>
</tr>
<tr>
<td height=18 align=left><font face="Verdana" size=1 color=#000000>2003</font></td>
<td align=right><font face="Verdana" size=1 color=#000000>4</font></td>
<td align=right><font face="Verdana" size=1 color=#000000><b> 99.804%</b></font></td>
</tr>
</table>
</td>
</tr>
<tr><td> </td></tr>
</table>
<table border="0" cellpadding="2" width="100%" cellspacing="1">
<tr>
<td height=18 bgcolor=#88A4C8 align=left><font face="Verdana" size="1" color=#FFFFFF>Year</font></td>
<td height=18 bgcolor=#88A4C8 align=left><font face="Verdana" size="1" color=#FFFFFF>Month</font></td>
<td height=18 bgcolor=#88A4C8 align=right><font face="Verdana" size="1" color=#FFFFFF>Outages</font></td>
<td height=18 bgcolor=#88A4C8 align=right><font face="Verdana" size="1" color=#FFFFFF>Downtime</font></td>
<td height=18 bgcolor=#88A4C8 align=right><font face="Verdana" size="1" color=#FFFFFF>Uptime</font></td>
</tr>
<tr>
<td height=18 align=left><font face="Verdana" size=1 color=#000000>2003</font></td>
<td align=left><font face="Verdana" size=1 color=#000000>December</font></td>
<td align=right><font face="Verdana" size=1 color=#000000>0</font></td>
<td align=right><font face="Verdana" size=1 color=#000000>0 hrs, 0 mins, 0 secs</font></td>
<td align=right><font face="Verdana" size=1 color=#000000><b>100.000%</b></font></td>
</tr>
<tr>
<td height=18 align=left><font face="Verdana" size=1 color=#000000> </font></td>
<td align=left><font face="Verdana" size=1 color=#000000>November</font></td>
<td align=right><font face="Verdana" size=1 color=#000000>4</font></td>
<td align=right><font face="Verdana" size=1 color=#000000>2 hrs, 20 mins, 25 secs</font></td>
<td align=right><font face="Verdana" size=1 color=#000000><b> 99.675%</b></font></td>
</tr>
<tr>
<td height=18 align=left><font face="Verdana" size=1 color=#000000> </font></td>
<td align=left><font face="Verdana" size=1 color=#000000>October</font></td>
<td align=right><font face="Verdana" size=1 color=#000000>0</font></td>
<td align=right><font face="Verdana" size=1 color=#000000>0 hrs, 0 mins, 0 secs</font></td>
<td align=right><font face="Verdana" size=1 color=#000000><b>100.000%</b></font></td>
</tr>
</table>
</td>
</tr>
</table>


Just wondering... Why edit links if it doesn't effect the PR? Also, why lock the topic if the link was removed?

Thanks for the help btw http://mrbobdouglas.com/junk/banana.gif
0 Replies
 
Craven de Kere
 
  1  
Reply Wed 3 Dec, 2003 10:37 pm
Links are removed because that's the rule. That's the rule because of abuse.

You are right that the color tag will override.

Is that code from their end? And you can't change it there?
0 Replies
 
Craven de Kere
 
  1  
Reply Wed 3 Dec, 2003 10:44 pm
You can always do a str_replace on 000000 and replace it with what you want.
0 Replies
 
BobbyDouglas
 
  1  
Reply Wed 3 Dec, 2003 10:45 pm
"That's the rule because of abuse."
- Hate it when one person screws things up for the others who actually shouldn't be effected.

Rules are rules.

That is the code that I end up receiving from THEIR end into my end.

That code was taken directly from my page that displays the results.

I was wodnering if I could use:
Code:$table = str_replace('000000', 'FFFFFF', $table);
to replace the 000000.
0 Replies
 
Craven de Kere
 
  1  
Reply Wed 3 Dec, 2003 10:49 pm
Try it, that's exactly what I would do, (actually I'd declare it as a variable but there's no need for that).

I can't test it as I do not have the key to fetch from the stats site.

You might have to rename the table variables and such but you are on the right path.
0 Replies
 
BobbyDouglas
 
  1  
Reply Wed 3 Dec, 2003 11:01 pm
Holy sh!t. It works and looks sexy. Time 2 dance!! http://mrbobdouglas.com/junk/banana.gifhttp://mrbobdouglas.com/junk/banana.gifhttp://mrbobdouglas.com/junk/banana.gifhttp://mrbobdouglas.com/junk/banana.gifhttp://mrbobdouglas.com/junk/banana.gif
0 Replies
 
Craven de Kere
 
  1  
Reply Wed 3 Dec, 2003 11:03 pm
Looks good. Laughing See ya next time.
0 Replies
 
 

Related Topics

Webdevelopment and hosting - Question by harisit2005
Showing an Ico File - Discussion by Brandon9000
how to earn money in internet - Discussion by rizwanaraj
The version 10 bug. Worse then Y2K! - Discussion by Nick Ashley
CSS Border style colors - Question by meesa
There is no Wisdom in Crowds - Discussion by ebrown p
THANK YOU CRAVEN AND NICK!!! - Discussion by dagmaraka
I'm the developer - Discussion by Nick Ashley
 
  1. Forums
  2. » Changing font while using getstr
Copyright © 2024 MadLab, LLC :: Terms of Service :: Privacy Policy :: Page generated in 0.03 seconds on 04/23/2024 at 06:11:14