PDA

View Full Version : makelabelcode...


Boofo
06-28-2002, 04:03 PM
Can someone please help me with this? I want to be able to call up this file for the information in it for the server load and add it to quik stats. I know it's not right yet. :)

makelabelcode('Server Uptime', 'uptime.php');

Admin
06-29-2002, 07:53 AM
What?

Boofo
06-29-2002, 05:59 PM
There's a small hack out that gives the server uptime according to the db. Here is the code I have in my phpinclude:

//Server Uptime Code
$result = mysql_query("show status");
while ($row = mysql_fetch_array($result)){
if ($row['Variable_name'] == "Uptime") { $uptime = $row['Value']; }
}
$days = ((($uptime/60)/60)/24);
$wholeday = (int) $days;
$hours = (($days - $wholeday)*24);
$wholehour = (int) $hours;
$minutes = (($hours - $wholehour)*60);
$wholeminute = (int) $minutes;


I want to be able to call this to work in Freddie's Quick Stats using:

makelabelcode('Server Uptime', 'whatever I need to put here');

Admin
06-30-2002, 06:00 AM
makelabelcode('Server Uptime', "whatever variables you want here");
And you can use this:
$days
$wholedays
$hours
$wholehours
$minutes
$wholeminutes

So for example you can do this:
makelabelcode('Server Uptime', "$wholedays days, $wholehours hours and $wholeminutes minutes.");
You just need to include the code you pasted above this line.

Boofo
06-30-2002, 08:01 AM
Thanks, Chen. I forgot about the double quotes. I was trying to do it with single quotes. :)

Is there an easier way to have it say like 1 day instead of 1 days than what I did here? Maybe a global way for all of the s variables instead of having to do them one at a time here?

//Server Uptime Code
$result = mysql_query("show status");
while ($row = mysql_fetch_array($result)){
if ($row['Variable_name'] == "Uptime") { $uptime = $row['Value']; }
}
$days = ((($uptime/60)/60)/24);
$wholeday = (int) $days;
$a='s';
if (intval($wholeday)<1){
$wholeday=0;
}if (intval($wholeday)==1){
$a='';
}
$hours = (($days - $wholeday)*24);
$wholehour = (int) $hours;
$b='s';
if (intval($wholehour)<1){
$wholehour=0;
}if (intval($wholehour)==1){
$b='';
}
$minutes = (($hours - $wholehour)*60);
$wholeminute = (int) $minutes;
$c='s';
if (intval($wholeminute)<1){
$wholeminute=0;
}if (intval($wholeminute)==1){
$c='';
}
$seconds = (($minutes - $wholeminute)*60);
$wholesecond = (int) $seconds;
$d='s';
if (intval($wholesecond)<1){
$wholesecond=0;
}if (intval($wholesecond)==1){
$d='';
}


I had to use a,b,c,d for the variables because when I tried to do s for all of them, it wouldn't work. :)

makelabelcode('Server Uptime', "$wholeday day$a, $wholehour hour$b, $wholeminute minute$c and $wholesecond second$d.");

Admin
06-30-2002, 08:14 AM
There's no easier way, no.

Boofo
06-30-2002, 08:50 AM
Thanks, Chen. I didn't think there was an easier way. :)