Created
December 18, 2013 12:31
-
-
Save k0nsl/8021525 to your computer and use it in GitHub Desktop.
Uptime via PHP. Saved from my blog since I have now replaced this with a much more efficient and secure method (bash > html outoput).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function linuxUptime() { | |
| $ut = strtok(exec("cat /proc/uptime" ), "."); | |
| $days = sprintf("%2d", ($ut/(3600*24))); | |
| $hours = sprintf("%2d", ( ($ut % (3600*24)) / 3600)); | |
| $min = sprintf("%2d", ($ut % (3600*24) % 3600)/60); | |
| $sec = sprintf("%2d", ($ut % (3600*24) % 3600)%60); | |
| return array($days, $hours, $min, $sec); | |
| } | |
| $ut = linuxUptime(); | |
| echo "<small>\nUptime: $ut[0] days, $ut[1] hours and $ut[2] minutes</small>\n"; | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment