FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » FUDforum Development » Plugins and Code Hacks » Fortune Cookies.
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
Fortune Cookies. [message #7297] Sat, 16 November 2002 05:59 Go to next message
Wolven is currently offline  Wolven   United States
Messages: 6
Registered: November 2002
Location: Acheron
Karma: 0
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

Re: Fortune Cookies. [message #7307 is a reply to message #7297] Sun, 17 November 2002 21:15 Go to previous message
Wolven is currently offline  Wolven   United States
Messages: 6
Registered: November 2002
Location: Acheron
Karma: 0
Junior Member
Okay, as I learn more about FUDforum, I see my mistake.
Instead of editing the index.php file directly, may I suggestion going to the Admin Control Panel, editing the template, and adding



<?php
include "fortunes.php";
?>



to the footer.tmpl/footer



This should allow you to select which views you would like it in, as well as to keep it from being overwritten when a new index.php is written.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Users Online hack
Next Topic: Registration authorization via email + small bug fixes
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Nov 22 07:52:36 GMT 2024

Total time taken to generate the page: 0.03111 seconds