duffman452001 Posted August 4, 2011 Share Posted August 4, 2011 Hi First time post here. I am working on a system status page using php. It lists various applications and services of our users and keeps track of what is up and down in a flat file. I borrowed code from this thread http://hardforum.com/archive/index.php/t-914963.html and modified it to fit my needs. I will admit I know very little about php but I know enough about programming to be able to modify (for the most part) it for my use. I have been pretty much able to add everything I want except for one thing. I would like to be able to have an update button on each service that also shows the time (in the text of the button) that it was last updated. Here is the code I currently have: <HEAD> <TITLE>Kent County Systems Status Page</TITLE> <STYLE type="text/css"> BODY {text-align: center} </STYLE> <BODY> <b><font size=24>Kent County Applications <br> and Services Status Page</font></b> <br> <br> <? $ff="statusdb.txt"; ini_set('display_errors', 'Off'); ini_set('display_startup_errors', 'Off'); error_reporting(0); chmod("inoutdb.txt",0755); if (isset($_POST['update'])) { foreach ($_POST as $name=>$value) { if ($value=="on" || $value=="po" || $value=="of" ) { $somecontent.= $value . "\n"; } elseif ($value=='update' || $value=='Update') { } else { $somecontent.= $value . ","; } } $handle=fopen($ff, "w+"); if (fwrite($handle, $somecontent) === FALSE) { echo "Cannot write to file ($ff)"; exit; } fclose($ff); } display_file($ff); //Functions------------------------ function display_file($file){ //Put file into $contents $contents = file_get_contents($file); //Split each file row into an array value $contents=explode("\n",$contents); // You could try using $PHP_SELF instead of $_SERVER['PHP_SELF'], but if the page is only being accessed through IE you can just leave it. $i=0; echo "<form action='".$PHP_SELF."' method='POST'><table>"; echo "<tr><td colspan=2><b>Application/Service</td><td><b>Description</td><td><b>Up/Down</td></tr>"; foreach ($contents as $item){ $person=explode(",",$item); if ($person[0]=="" || $person[2]==""){ } else { echo " <tr><td><input type='hidden' name='$i' value='$person[0]'>$person[0]</td><td>"; if (substr($person[2],0,2)=='on') { $mark1='CHECKED'; $mark2=''; $mark3=''; $color = "#00CC66"; } if (substr($person[2],0,2)=='po') { $mark1=''; $mark2='CHECKED'; $mark3=''; $color = "#CCFF00"; } if (substr($person[2],0,2)=='of') { $mark1=''; $mark2=''; $mark3='CHECKED'; $color = "#FF0000"; } echo "<td><input type='text' size='100' height='40px' name='".$i."t' value='".$person[1]."' style='background-color:$color'></td>"; echo "<td><input type='radio' name='".$i."c' value='on' $mark1>Up <input type='radio' name='".$i."c' value='po' $mark2>Partial Outage<input type='radio' name='".$i."c' value='of' $mark3>Down</td></tr>"; $i+=1; } } // Put the Update button under it all echo "<tr><td><input type='hidden' name='update' value='update'><input type='submit' name='Submit' value='Update'></td></tr>"; echo "</table></form>"; } ?> Is there an easy way to make this happen? Thanks in advance MOD EDIT: code tags added. Quote Link to comment https://forums.phpfreaks.com/topic/243865-php-system-status-board/ Share on other sites More sharing options...
Pikachu2000 Posted August 4, 2011 Share Posted August 4, 2011 When posting code, enclose it within the forum's . . . BBCode tags. Quote Link to comment https://forums.phpfreaks.com/topic/243865-php-system-status-board/#findComment-1252199 Share on other sites More sharing options...
phpSensei Posted August 4, 2011 Share Posted August 4, 2011 XML would be your best option, this approach is weak because of this very purpose... Quote Link to comment https://forums.phpfreaks.com/topic/243865-php-system-status-board/#findComment-1252207 Share on other sites More sharing options...
duffman452001 Posted August 4, 2011 Author Share Posted August 4, 2011 Whoops thanks for cleaning my post up. XML you say? I've actually never done anything with XML, and in fact really did not know what purpose it served. A quick googling of XML shows me that it is indeed perfect for this purpose. Is there still a way to do this with PHP or will XML ultimately be the way to go? Quote Link to comment https://forums.phpfreaks.com/topic/243865-php-system-status-board/#findComment-1252219 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.