Jul 6, 2008

Displaying The Website Uptime In Php - Help required in displaying the website uptime on my staff status page

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > PHP Programming

free web hosting

Displaying The Website Uptime In Php - Help required in displaying the website uptime on my staff status page

sportytalk
I have decided that on one of the staff pages on my website, I'd like to include the uptime of the website, which I assume would be the uptime of the trap17 server.

I've read a couple of tutorials on the internet and the system uptime works, but there's also another method which supposedly does the same thing. The problem is, this other method has had discussion about whether or not this method displaying the uptime is secure. I read on another site that some servers tend to block this php function from being used.

The methods which I found were
CODE
system("uptime")
which seemed to work on here and
CODE
shell_exec('uptime')
which I haven't tried as I wasn't sure whether it was a secure enough function to run on the trap17 forum. The site at which I found the php tutorial had a forum in which one of the registered members said he thought there may be a security vulnerability in using the exec function and it was said by someone else that some servers block exec from being used.

I'm really not sure which to use, or whether it's worth actually displaying the uptime in the first place.
Does anyone know the difference between these two methods? Which method would be the best one to use?

 

 

 


Reply

rvalkass
The two work slightly differently. Shell_exec, as the name suggests, executes a command on the shell and gives you the output. This is disabled by most free hosts as they run PHP in safe mode. Trap17 is one of the very few that do not run in safe mode and give us access to the full power of PHP. The system function executes a program rather than a shell command and is therefore deemed safer. Really, you need not worry which you are using unless your script is taking user input, in which case you should use system for security.

As to whether it is worth displaying the uptime, are your staff going to benefit from it? It is useful for us to know as webmasters so we can apologise to users for any downtime and to know how reliable the host is. It only takes a millisecond to appear and won't really impact loading times, so its up to you as to whether you think it is necessary or useful.

Reply

Saint_Michael
Did some searching and found some scripts that follow those two commends

http://www.4webhelp.net/scripts/php/uptime.php

CODE

<?php

  $data = shell_exec('uptime');
  $uptime = explode(' up ', $data);
  $uptime = explode(',', $uptime[1]);
  $uptime = $uptime[0].', '.$uptime[1];

  echo ('Current server uptime: '.$uptime.'');

?>



Although this is a stupid question since I most likely know the answer to. wouldn't the chmodding to 755 of either commands not be successful in preventing any security leaks or would a system wide hack compromise that chmod?

Reply

rvalkass
I think the main way that the script creates security problems is if any user input is accepted as a string, which could run some malicious code via the shell. It would require that they knew how your script was working, but a CHMOD would have no effect. Then again, there is no harm in locking down your files as much as possible.

Reply

CrazyRob
what you can do is download a php script which displays the server uptime. Do you want to have a complete server uptime system? as then you could check different ports on the servers like port 80 and then also get the script to display the total uptime. the command you need to use for this is fsockopen command - it will check a certain port on a server. here is an example
CODE

$http = @fsockopen(80, 4);
        if (!$http) {
            $http = "images/red.gif";
        } else {
            fclose($http);
            $http = "images/green.gif";
        }

That piece of code will check port 80 which is the http port and check if it working and if it is then it will display a green image and if its down it will display a red image.

To get the total server uptime so far you can use Saint_Michael's example but im not sure if it will work

 

 

 


Reply

sportytalk
Thanks for the replies.

I'm not fussed in having a complete uptime system, just something simple. Having just the uptime in days, hours, minutes and possibly seconds would be good enough. It's just to go on the staff status page so the staff and myself know if the site's been down so we can apologize to the users.

Thanks for the code St. Michael. However, it has been said that there is a security issue in using the shell_exec function. The first reply of this topic states that there isn't really an issue if user input isn't taken but i'm really not sure. Different webpages and different people say different things.
Is there a security issue if I just display the uptime in text?. I don't want to use this function at all if trap17 don't want it used or if it could make my website or the trap17 vulnerable.

My scripts would not be taking any user input. The uptime would be displayed in text form in the way mentioned at the top of this post (Days, hours, minutes, seconds).
If the system command runs a program on trap17, if many people view the page at the same time, wouldn't that then flood trap17 with this program being executed?

I'm really not sure which function to use. Both seem to have their advantages and disadvantages. If there are vulnerabilities in both functions, I'd rather just use my third method, which was to forget about displaying the uptime.

Reply

Saint_Michael
Wouldn't setting up a php url mask over scripts put a somewhat better security included using a combination of htaccess and some other password stuff keep it somewhat more secure?

Reply

electron
Hey this is really cool .
I was in search of that script for such a long time and i had wasted a hell lot of time on this uptime stuff.
Thanks a lot for giving that code.
Also shell execution is really a good feature in PHP.
I love it but doesn't it work if the safe mode is on.
So your script might not work altogether.
Weill try this script immediately in safe mode and without it.

Thanks and have a good day.

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Similar Topics

Keywords : displaying website uptime php required displaying website uptime staff status

  1. Script Help Required: Undefined Variable - A fault I cannot spot in PHP (3)
  2. Script That Tracks The User Status - how can I track on or offline users? (4)
    long explaination: hey, I'm building a user profile site right now. And, I kinda know how to
    make a online/offline detector, but not totally sure. I know I can make a mysql database to track
    them, but how does it entrer the information? I could easily put in a field where when they login it
    sets them to online, but if they don't sign out, and just exit the browser, how can I tell.
    short: I want someone to tell me how to make a online/offline status detector, like they have here
    on trap17. I'd be thrilled if you can post to this, thanks, arcticsnpr...
  3. Making Sure They Did Not Leave Any Required Fields Blank - (3)
    how to make sure they did not leave any required fields blank? CODE <?php
        include("config/config.inc.php");
        include("config/dbcon.php");     include("checksession.php");
                 if(isset($_POST['action'])){         $gname =
    $_POST['gname'];         $gemail = $_POST['mail'];
            $gmsg = $_POST['gmsg'];         $date =
    date("m.d.y"); $sql = "insert into tblg...
  4. Displaying 10 Records Per Page - (5)
    how to display 10 messages per page? CODE <?php
        include("config/config.inc.php");
        include("config/dbcon.php");     include("checksession.php");
                 if(isset($_POST['action'])){         $gname =
    $_POST['gname'];         $gemail = $_POST['mail'];
            $gmsg = $_POST['gmsg'];         $date =
    date("m.d.y"); $sql = "insert into tblguestbook "; $sql ...
  5. Displaying Date And Time (gmt+8) - (5)
    how to display date and time (gmt+8)? any help would be appreciated....
  6. What Coding Languages Are Required? - (5)
    I want to add a feature in my website so that users can make a professional -looking resume-like web
    page. It will be like a form based series of questions that visitor ll need to answer.Based on this
    a webpage as prescribed in pre-defined template ll be created .I want to know to do this what
    languages are used? I want some suggestion regarding this.My site is currently on Joomla platform.
    thanks in advance...
  7. Creating A Login Box That Links To My Phpbb Forum - Have my phpBB Forum Intergrated with my Website (4)
    Can someone please give me a code that I can use to put a login box on my website, that will login a
    user into my phpBB Forum? Sort of like Having my phpBB Forum Intergrated with my Website? Thank you
    so much if you can! /angel.gif" style="vertical-align:middle" emoid=":angel:" border="0"
    alt="angel.gif" /> Ex. ...
  8. Displaying Your Phone Number On A Wap Site - (3)
    I have a wap site elitezone.co.za and what i want to add is a code to the index page that displays
    your operator and phone number. Does any one know the coding for this function if so please show me
    here. Help will appriacated. Topic title modified. ...
  9. Trap17 Board Status Dynamic Image - (13)
    I was really board a few days ago and decided to make a trap17 board status image for my sig
    /tongue.gif" style="vertical-align:middle" emoid=":P" border="0" alt="tongue.gif" /> That is the
    current beta. I'm still working on it so that it might display the most recent post or
    somthing, i'm not sure. After I finish it ill give out the source code but if you want one
    right now you can pm me and ill set one up to get the info on your account ^.^ So I was wondering
    how you members liked it? You'll probably think that its a waist of time, but alas as I sai...
  10. How To Delete A Row In Mysql. - A very simple help required (4)
    Im using the following code, for very simple work.. it simply gets and print the comments which are
    stored in the database. Now it will show like comment 1. comment 2. comment 3. etc etc i want to
    add 'delete' option that i can delete any comment. it displays like comment 1.
    Delete comment 2. Delete comment 3. Delete
    So that when i click on delete, it simply deletes the comment and print the remaining comments. Its
    very simple. i hope you understand. QUOTE $result = mysql_query("sele...
  11. Updating Website From Another -- Website - Is it possible, and how? (7)
    i was just thinking about this project that i'm doing, and i thought that it would be a good
    thing that i could update my website let's say on trap17 from my localhost computer with a click
    of a mouse, without all of that ftp mambo-yumbo the thing is that i wanted an "UPDATE" button on my
    site which woud connect to my localhost and update all the things needed. let's say i added few
    profiles localy, and i want to update them on site.. how could it be done. if i was crude in
    explanation please write what info u still need and i'll post it back......
  12. Help With Some Website Coding - Databases and saving form results (4)
    Hey all, I was looking for some help with creating my new website. I have a form already created,
    with some text areas, checkboxes, drop down menu's, ect. I need some help setting up the code to
    save the form data once the user clicks "Submit" after filling in their information in the form. I
    was hoping to do this 2 ways - 1. Saving the information into some type of database (MySQL I'm
    guessing?) and 2. Have the form results emailed to me. I am familiar with the old way of emailing
    the results by putting "mailto:email@domain.com" into the form, but new browse...
  13. Files Required? - (5)
    I want to learn php and I am already on the first steps to doing it. I have set up my server using
    easyPHP as well as XAMPP which is a package containing FileZilla, Apache and MySQL. Other than
    easyPHP, XAMPP and MySQL, what other softwares are required to be set up for me to successfully
    learn how to program with PHP?...
  14. Displaying Files Of A Directory - (2)
    I want to display the contents of a directory.. i have the following code.. It gives the output in
    one column only... like file1 file2 file3 file4 . . . . . Since there are lot of files so this
    column gets very long..i want to display the x number of files in each column.. like if there are 22
    files.. then file 1 file 11 file 21 file 2 . file 22 file 3 .. . . . file 10
    file 20 This was just an example..I know it can be done by using but i dont know how to do it
    with loop. Please help me. QUOTE $dir = './'; $handle =...
  15. Question: Securing A Website For Beginners - (1)
    I don't really understand 'bout it. What kind of security we have to make to hold our web
    secure. Only log in features? how bout 'deface' method? how does it work? thx in advance
    Please use detailed topic title. ...
  16. Directory Files Displaying - (5)
    I have many files in a directory..I want to create a page , like A B C D E F ..... when some one
    click on A , it should display all the files starting from letter A , and when clicks on B , it
    should show all the files in that directory starting from B , and so on... I have no idea how to
    display the files of the directory iin that way. Kindly assist me.....
  17. Displaying Latest Added Files Of Subdirectories ? - (5)
    For example,i have a directory , which has 3 sub directories a,b and c...and i have some files in
    all subdirectories.. is it possible that i can display the latest added files to any of sub
    directory a,b, or c.?i think i will have to use sort by date function but how it should be done that
    it compares the files of all the subdirectories directories ?...
  18. How I Can Display Forum Topic On Main Website ? - (4)
    Suppose i have a website.. domain.com , and have phpbb forums on domain.com/forums.. And i want to
    display the new topics written in the forum on the main page of website...how i can do that.. ? for
    example ,I want to display this topic `? "domain.com/forums/viewtopic.php?t=16" how can i do
    that ?...
  19. Sending Messeges Over A Website. - (3)
    i want to learn how members of a website can send messeges to each other using php since im learning
    it. okay i can write in more detail..that for example if users can register on a website , suppose
    there are some users on the website , and now i want to learn how they can send messeges to each
    other.suppose each user has a unique ID ... and for example if some one has send the messege to
    other member of website , then he can know that he has recieved a new messege..something like inbox
    on the website where all of his messeges can be stored...lets say same way like on t...
  20. Php Code Fix Required - URGENT (3)
    I am running a Web Chat and need to get this to display the User IP to them, but this code isnt
    working. CODE <PARAM NAME="welcomemessage" VALUE="<?php
    echo  $_SERVER['REMOTE_SERVER'];" has been logged. Chat powered by
    GCN"> Any help would be extremly grateful. Thank you Inserted the code in CODES tag ...
  21. Some Php Functions Explaination Required - (2)
    Can some one please tell me what is the purpose of the following functions , although there's a
    little explaination with everyline but i cant understand, can some one exaplin it bit clearly and
    tell me that why it is needed in config.inc.php.. what is its purpose and will it work if i dont
    include these files in config.inc.php thanks QUOTE ### Url were Website has been installed, not
    '/' in end! define('C_URL','http://www.test.com/Website'); ### Internal
    path to Website directory define('C_PATH','Z:/home/www.test.com/www/...
  22. Imap Status Set Flags Problem - IMAP status set flags problem (1)
    i'd like to set or clear the seen flag to any selected message: CODE if
    (isset($_GET['hmark']) &&
    isset($_GET['dmsg']) &&
    isset($_GET['fresh'])) {     $dmsg =
    $_GET['dmsg'];     $flagtype = $_GET['hmark'];
        $fresh = $_GET['fresh'];     $used =
    isset($_SESSION['used']) ? $_SESSION['used'] :
    array();     if (&#...
  23. Can My Forum And Website Use The Same Profiles? - (3)
    I've been programming a 'rate-em' site from scratch. You know like Hot Or Not. YEs,..
    yet another rate-em website. Anyway, i'ts done and before I launch it I need to add a forum as
    the finishing touch, but all the forum softeware out there seems so hard to integrate. I'm
    trying to make it so that when a user logs into my rate-em website they are also logged into 'my
    forum'. i.e. i want my forum and web site to use the same profile data. If anyone knows of a
    forum program made for this objective please let me know. I'm in over my head, a...
  24. Music Website - (3)
    http://www.metalmania.net I'm pretty much a novice when it comes to php/mysql and I have been
    trying to figure out how to build something similar to the way the site above works. Do any of you
    know of a tutorial or script or something that would show me how to accomplish something very
    similar to that? I have also been exploring phpnuke platinum with the TopMusic mod, but it just
    doesnt want to do what I want it to do. Sure it has a lot of features already done for me, but the
    architecture and navigation is very poor in my opinion, not nearly as efficent as the n...
  25. Free Website Portal - (2)
    hey everyone, have you ever used PHP??? well if you have you know how cool it is and nice to work
    with and it has nice mods and stuff for it.... well i got the ultimate php its called
    PHP-Platinum very very very nice Portal and Engine Coding, slick sleek and smooth are 3 words for
    this portal... if you want to see it in action and see features of it or even download it and check
    it out for yourself visit this site PHP-Nuke Platinum Features & Downloads its a very nice
    thing to use so go check it out, i love it cause its got nice protection so your site stays s...
  26. Php/mysql Search Engine Help - Having issues displaying results (1)
    I've been using a tutorial
    (http://www.devarticles.com/c/a/MySQL/Developing-A-Site-Search-Engine-With-PHP-And-MySQL/) at this
    address to help me get started on building my own search engine. I've completed the tutorial but
    when I run the search, I get no results on the results page. I'm wondering if anyone will take a
    look at this script and see if they can figure out why my I'm not getting any results displayed.
    I'm using phpMyAdmin to build the database and simple notepad to build the PHP script. CODE
    <?php $submit = $_POST[&...
  27. Website Help - Need php programmers to help me. (10)
    I need some php programmers help. I am working on a website. I have asked for some code in another
    topic and would now like help. These will possibly be sold. And if they do I am willing to pay the
    people who help me out a lot some of it. Dun start asking to help and like help a tiny bit and
    expect to get something big out of it. I am only paying to people who help a lot and once they are
    sent out. You must also be good with making clan websites. These will be for clans. If you bother me
    about getting money than no pay. More info on aim. My aim is generalds2001...
  28. Personal Blog - [ Database Required ] (4)
    Okay, after a week, I have successfully created a personal web blog. I first created it using a flat
    text file, I but realized that it was just too limited like that. So, I redid it in a
    database-compatible manner. NOTES: CODE - This blog does not support comments yet. If you
    want, you can build  on this script by creating a comment system as well. I may also    update it
    with a comment system in the future. - You should have an average to intermediate knowledge of
    MySQL    commands and database manipulation in general, especially if you    want to add a ...
  29. Php Website Assistance? - Help Me (1)
    Hello, i have just set up a website, and want to protect the site using login and password
    protection. Can anyone give me some PHP scripts which will keep a track of usernames and passwords,
    and add them to the access rights list. is this possible? If so, i would be much obliged if you
    would do so. Thank you. P.S If anyone needs assistance with HTML, that is my speciality, so send
    me a message. Always happy to help...
  30. Returning Game Status - retrieving game status (11)
    I'm currently making a fansite for a game thats coming out soon and im wondering how I can show
    the game status: Meaning..is the game down? or is the game up? I of course don't have access to
    their servers and I have no IP whatsoever, Im very sure they won't give out much info on their
    servers either, because their current game (GunBound) is getting hacked like crazy, releasing server
    info might cause problems for both me and Softnyx At the moment I have only the forum status (wich
    is pretty easy), and a n/a image on my Game Status. Is there a possibility ...



Looking for Displaying, The, Website, Uptime, In, Php

Searching Video's for Displaying, The, Website, Uptime, In, Php
advertisement



Displaying The Website Uptime In Php - Help required in displaying the website uptime on my staff status page



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE