Fortune Cookies. [message #7297] |
Sat, 16 November 2002 05:59 |
Wolven
Messages: 6 Registered: November 2002 Location: Acheron
Karma:
|
Junior Member |
|
|
Okay, this was an idea I got from another site a long time ago, and I've basically stolen some of the code out of FUDforum to get the pretty table I wanted. I'm *very* new to PHP, HTML, and anything else that requires typing to get the code I want (grin). So, if this is ugly, please, feel free to correct me. Anyway, here goes.
It's a small script for those who would like to output the fortune cookies from their unix/linux system to their web page.
The end result is that each time the page refresh, the unix command /usr/games/fortune is executed. The output is placed on the web browser. If your "fortune" program is somewhere else, you will have to edit it. Oh, and for those who don't know, this can be used for a directory listing, or anything else that gives data to standard out.
(Hope I didn't over-explain that, but I do so in case there are others like me out there. Enjoy.)
------Beginning of code--------------
<div align="left" class="SmallText">Here's your fortune for the day: </div>
<table width="100%" border="0" cellspacing="3" cellpadding="5"><tr><td class="ForumBackground" align="center">
<b>.::.</b>
<TABLE BORDER="1" BGCOLOR="#ffffdd" CELLPADDING="6" CELLSPACING="0">
<PRE><?php
// NOTE: check the path to fortune before using this code
system("/usr/games/fortune");
?></PRE>
</TD></TR></TABLE>
<p>
</td></tr></table>
</body>
-----End of Code---------
Oh, and for best practice, I put this in a seperate file, such as fortunecookie.php, and at the bottom of index.php, I place
include "fortunecookie.php";
Make sure to read up on securities before playing with things like this, as this requires PHP to be able to run system commands, which sometimes only nuts like me will do. :_)
Feedback is appreciated.
[Updated on: Sat, 16 November 2002 06:04] Report message to a moderator
|
|
|