vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 2.x Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=4)
-   -   Server Uptime (https://vborg.vbsupport.ru/showthread.php?t=40401)

Etcher 06-27-2002 10:00 PM

Server Uptime
 
Not really a HACK, but nice little script for information...

I added "System Uptime" to the footer of my site:

Save this as uptime.php:

<?PHP

$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;

echo "<center><font size=1>";
echo "System Uptime: ";
echo $wholeday . " Days ";
echo $wholehour . " Hours ";
echo $wholeminute . " Minutes <br>";
echo "</font></center>";

?>

Then "include" that file in your footer, or anywhere else you want it displayed.

The actual uptime is a check of mySQL dB.

Enjoy!

filburt1 06-28-2002 02:53 PM

You can also put that in your phpinclude template and then write the variables in the footer template.

Chris M 06-28-2002 02:59 PM

Cool!

Satan

Chris M 06-28-2002 03:07 PM

I think you will find that if you wanted add it to the Admin CP, you could do this :

in admin/index.php
Find :
PHP Code:

makenavselect("Options","<hr>");
// ************************************************* 

And add below :
PHP Code:

makenavoption("Uptime","uptime.php?s=");
makenavselect("Database");
// *** 

Then create a new file called uptime.php, and enter :
PHP Code:

<html>
<head>
<link rel="stylesheet" href="../cp.css">
</head>
</html>
<?PHP 

$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

echo 
"<center><font size=1>"
echo 
"System Uptime: "
echo 
$wholeday " Days "
echo 
$wholehour " Hours "
echo 
$wholeminute " Minutes <br>"
echo 
"</font></center>"

?>

(The difference is, that this takes the CP colours and uses them instead of just white and black)

Satan

Chris M 06-28-2002 03:08 PM

Just incase you want to know:)

Satan

Boofo 06-28-2002 05:02 PM

How would I use the code for this? Where would I put the code and how would I call it in here?

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

Chris M 06-28-2002 06:29 PM

Just put the php in a file called "uptime.php", and upload it to your admin folder...

Satan

TheWulff 06-28-2002 09:43 PM

How would I change the text color to white ? Sorry newbie to PHP..

Chris M 06-28-2002 10:00 PM

I believe you would enter this :

PHP Code:

<html>
<head>
<link rel="stylesheet" href="../cp.css">
</head>
</html>
<?PHP 

$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

echo 
"<center><font color="#FFFFFF"><font size=1>"; 
echo "System Uptime: "
echo 
$wholeday " Days "
echo 
$wholehour " Hours "
echo 
$wholeminute " Minutes <br>"
echo 
"</font></font></center>"

?>

Satan

TheWulff 06-28-2002 10:08 PM

Thanks for the reply but nope, bot this error...

Parse error: parse error, expecting `','' or `';'' in /home/sites/site33/web/uptime.php on line 15

Bluemann 06-28-2002 10:25 PM

Ok well im a newbie at this, i created the uptime.php and uploaded it but how do i "include" that in my footer, is there a code?

Chris M 06-28-2002 10:31 PM

PHP Code:

include("./uptime.php"); 

Assuming that uptime.php is located in the root folder...

TheWulff - Hmmm...

Try :

PHP Code:

<html>
<head>
<link rel="stylesheet" href="../cp.css">
</head>
</html>
<?PHP 

$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;

echo 
"<center><font color=#FFFFFF><font size=1>"
echo 
"System Uptime: "
echo 
$wholeday " Days "
echo 
$wholehour " Hours "
echo 
$wholeminute " Minutes <br>"
echo 
"</font></font></center>"

?>

Satan

Bluemann 06-28-2002 11:06 PM

<a href="http://www.mwgclan.net/forums/" target="_blank">http://www.mwgclan.net/forums/ </a> php is in the root.php is in the root.i included your code at the bototm where it says server uptime: but it dosent work, and yes the file is in the root

Boofo 06-28-2002 11:10 PM

I am trying to put it in the Quick Stats between Server type and MySQL. I want it to display the time there.

Quote:

Originally posted by hellsatan
Just put the php in a file called "uptime.php", and upload it to your admin folder...

Satan


nuno 06-29-2002 12:01 AM

nice

nuno 06-29-2002 12:01 AM

nice

nuno 06-29-2002 12:02 AM

nice :)

TheWulff 06-29-2002 02:47 AM

hellsatan code worked this time, but still lost as to the include ? do I have to include it in phpinclude ? or copy the code above in the footer ? Thanks for the help, much apperciated.

Chris M 06-29-2002 12:30 PM

What...

You mean :
PHP Code:

include("./uptime.php"); 

That wasnt for you, it was for the person who replied after you:)

Satan

Chris M 06-29-2002 12:30 PM

What...

You mean :
PHP Code:

include("./uptime.php"); 

That wasnt for you, it was for the person who replied after you:)

Satan

Chris M 06-29-2002 12:30 PM

What...

You mean :
PHP Code:

include("./uptime.php"); 

That wasnt for you, it was for the person who replied after you:)

Satan

TheWulff 06-29-2002 01:47 PM

hehe I now that but I dont know how to include it in my footer ;(

SemperFidelis 06-29-2002 02:53 PM

Now this is a pretty cool idea
Cheers to evryone for their input so far
:)

Does anyone have an idea on what the best way would be to integrate this with Admin Quick Stats ?

This is what currently is displayed in my /admin/index.php

http://www.vianet.net.au/~daren/vbul...quickstats.jpg

And I would like to add its content directly below
-Server Type
-MYSQL
entries if possible

firewars 06-29-2002 02:54 PM

Neither way is working.
I tried including it in the footer: how would that work anyway? No PHP parsing down there.
I tried parsing the code in the phpinclude-template and then used echo to show the values: there are none.

Somehow I just can't get values to show - not even running "uptime.php" directly gives me valid numbers (0 0 0 must be wrong).

nuno 06-29-2002 03:02 PM

*gee* :eek:
paste this into your phpinclude template
PHP 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

paste this into your footer template, right after $copyrighttext<br>
Code:

<smallfont>System Uptime: $wholeday Days $wholehour Hours $wholeminute Minutes
</smallfont>

All done :)

firewars 06-29-2002 03:27 PM

I told you I did that.
And as I said, it's (still) not working.

firewars 06-29-2002 03:34 PM

Ok, it's somehow my fault.
I've already got a "script" in my phpinclude-template and it looks like it doesn't really like yours.
Any way to let the vB know where one "script" ends and where another one starts?

firewars 06-29-2002 03:36 PM

Never mind.
I just cut the script there was out and pasted it back in - it seems to work now.
Thanks ;)

Boofo 06-29-2002 05:19 PM

How would you make a single variable out of it so you can call it like this:

$sysuptime

I'm trying to put it in my Quick Stats in the admin cp. And where would I call the variable from? Still in my phpinclude?

Quote:

Originally posted by nuno
*gee* :eek:
paste this into your phpinclude template
PHP 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

paste this into your footer template, right after $copyrighttext<br>
Code:

<smallfont>System Uptime: $wholeday Days $wholehour Hours $wholeminute Minutes
</smallfont>

All done :)


firewars 06-29-2002 05:33 PM

For those that want seconds as well, here you go :)

PHP 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;
$seconds = (($minutes $wholeminute)*60);
$wholesecond = (int) $seconds

..for those who want 1 variable that has all the stuff in it, add this line below all the code:

PHP Code:

$sysuptime "System Uptime: $wholeday Days $wholehour Hours $wholeminute Minutes"

..with seconds (see my code):

PHP Code:

$sysuptime "System Uptime: $wholeday Days $wholehour Hours $wholeminute Minutes $wholesecond Seconds"

..then put $sysuptime where you want that line to show - enjoy.

Brad 06-29-2002 08:42 PM

You can also call it via its own template. use nuno's code then do this


in global.php find

PHP Code:

$header='';
$footer=''

under that code add

PHP Code:

eval("\$uptime = \"".gettemplate('uptime')."\";"); 


go to your admin cp and add a new template called uptime and paste this into it


Code:

<smallfont>System Uptime: $wholeday Days $wholehour Hours $wholeminute Minutes
</smallfont>


in the footer replace this

Code:

$copyrighttext<br>
with this

Code:

$copyrighttext<br>$uptime

untested but sould work :)

Boofo 06-29-2002 08:46 PM

How would I use this in the admin cp in the index file? It doesn't seem to like it when I try to call it from phpinclude...nothing show up.

SemperFidelis 07-01-2002 12:06 AM

Has anyone come up with a way to do this
https://vborg.vbsupport.ru/showthrea...264#post267264

Boofo 07-01-2002 12:17 AM

Do the following:

In your admin/index.php add this:

Code:

//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='';
}

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

right above this:

Code:

makelabelcode('MySQL', 'v' . $mysqlversion['version']);
and you'll be all set. I even added code that will make it say 1 day or 1 minute instead of days or minutes (plural).

Enjoy! :)

Quote:

Originally posted by v-net
Has anyone come up with a way to do this
https://vborg.vbsupport.ru/showthrea...264#post267264


SemperFidelis 07-01-2002 12:34 AM

Cheers Boofo
Worked like a charm
:)

Quote:

Server Type Linux / PHP v4.1.2
MySQL v3.23.49-log
Server Uptime 149 days, 6 hours, 7 minutes and 23 seconds.

Boofo 07-01-2002 01:02 AM

I'm also working on an extention to the Quick Stats that will give you even more information. This is just a start.

Code:

Server Type
 Linux / PHP v4.2.1 | Protocol:HTTP/1.0 | Port:80
 
Server Load Averages
 0.85, 1.01, 0.81
 
Server Uptime
 2 days, 1 hour, 55 minutes and 41 seconds.
 
Current Online Users
 1 users online (1 members & 0 guests).
 
MySQL
 v3.23.45

By the way, notice the "1 hour" above instead of "1 hours" with an s. :)

Quote:

Originally posted by v-net
Cheers Boofo
Worked like a charm
:)



SemperFidelis 07-01-2002 01:12 AM

Looks pretty cool so far
Good luck
:)

Boofo 07-01-2002 01:17 AM

Here's the top part of it that I have done and working so far. It is in a table like the Quick Stas but shorter. :)

vBulletin Extra Options Menu

vBulletin Options
Modify Replacements
Private Messages
View Main Forum
View Memberlist

Run a SQL query
Modify Templates
Spin Threads
New Message Posts
View Online Users

Quick Template Search

hypedave 07-01-2002 11:39 AM

jus moved my forum over to a new forum, and now the uptime is stuck on my last server's uptime, any suggestions

Boofo 07-01-2002 11:52 AM

Use myphpadmin and go to the table and delete the row, I think. Look in the database and it should be pretty self-explanatory.


All times are GMT. The time now is 03:00 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01521 seconds
  • Memory Usage 1,877KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (8)bbcode_code_printable
  • (16)bbcode_php_printable
  • (5)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete