Happy Codings - Programming Code Examples
Html Css Web Design Sample Codes CPlusPlus Programming Sample Codes JavaScript Programming Sample Codes C Programming Sample Codes CSharp Programming Sample Codes Java Programming Sample Codes Php Programming Sample Codes Visual Basic Programming Sample Codes

Php Programming Code Examples

Php > Other Code Examples

Super Simple Discussion 4 sysadmins

Super Simple Discussion 4 sysadmins <?php /* A small board for communication between sysadmins or such like. The user is identified by $REMOTE_USER If the user is identified then he/she can delete his/her own messages. $REMOTE_USER is an apache variable and can be used. Or you can write a login script to parse the variable. */ ?> <html> <head> </head> <body> <? function date_str($timestamp) { $date_str = getdate($timestamp); $year = $date_str["year"]; $mon = $date_str["mon"]; $mday = $date_str["mday"]; $hours = $date_str["hours"]; $minutes = $date_str["minutes"]; $seconds = $date_str["seconds"]; return "$hours:$minutes:$seconds $mday/$mon/$year"; } $message1 = "message1.txt"; $message2 = "message2.txt"; $message3 = "message3.txt"; $message4 = "message4.txt"; if ($deluser) { copy("./blank.txt", "./$deluser.txt"); } $message1fp = fopen("./message1.txt", "a+"); $message2fp = fopen("./message2.txt", "a+"); $message3fp = fopen("./message3.txt", "a+"); $message4fp = fopen("./message4.txt", "a+"); if ($postto == "message2") fwrite($message2fp, $posttext); else if ($postto == "messagel") fwrite($message1fp, $posttext); else if ($postto == "message3") fwrite($message3fp, $posttext); else if ($postto == "message4") fwrite($message4fp, $posttext); else echo "......"; if ($REMOTE_USER) echo "Welcome: $REMOTE_USER"; else echo "Welcome: Unknow person"; ?> <form method=post action="./post.php"> <table width=100% border=1> <tr><td bgcolor=gray width=50%><font size=1><b>message2</b>   -   Last Modified <? echo date_str(filemtime($message2)); ?>       <input type=radio name="postto" value="message2"> <td bgcolor=gray width=50%><font size=1><b>message3</b>   -   Last Modified <? echo date_str(filemtime($message3)); ?>       <input type=radio name="postto" value="message3"> <tr><td><? $lines = file($message2); while (list($ElementIndexValue, $ElementContents) = each($lines)) { echo $ElementContents."<br>"; } ?><td> <? $lines = file($message3); while (list($ElementIndexValue, $ElementContents) = each($lines)) { echo $ElementContents."<br>"; } ?> <tr><td bgcolor=gray width=50%><font size=1><b>message1</b>   -   Last Modified <? echo date_str(filemtime($message1)); ?>       <input type=radio name="postto" value="message1"> <td bgcolor=gray width=50%><font size=1><b>message4</b>   -   Last Modified <? echo date_str(filemtime($message4)); ?>       <input type=radio name="postto" value="message4"> <tr><td> <? $lines = file($message1); while (list($ElementIndexValue, $ElementContents) = each($lines)) { echo $ElementContents."<br>"; } ?> <td> <? $lines = file($message4); while (list($ElementIndexValue, $ElementContents) = each($lines)) { echo $ElementContents."<br>"; } ?> </table> <center> <TEXTAREA name="posttext" cols=60 rows=15></TEXTAREA> <br> <input type=submit value="Post Message"> </form> <p> <form method=post action="./post.php"> <input type=hidden name="deluser" value="<? echo $REMOTE_USER; ?>"> <input type=submit value="Delete my messages"> </form> <p> <? fclose($message1fp); fclose($message2fp); fclose($message4fp); fclose($message3fp); ?> </html>