#include <infodrom.style>
#include <quote.style>
#include <addresses.inc>
#include "fortunes.inc"

<page title="Infodrom Fortune Cookies">

<?
  if (strlen ($_POST['fortune'])) {

    if (strpos($_POST['fortune'], 'http://') !=== false) {
      header ('Location: http://www.infodrom.org/');
      exit(0);
    }

    $body = $_POST['fortune'];
    if (strlen ($_POST['origin'])) {
      $body .= "\n-- " . $_POST['origin'];
      if (strlen ($_POST['email'])) {
        $from = "From: " . $_POST['email'];
        if (strlen ($_POST['name'])) {
          $from .= " (" . $_POST['name'] . ")";
        }
	$from = strtr($from, "\015\012", '  ');
      }
      $body .= "\n\n-- \nhttp://www.infodrom.org/Infodrom/fortunes/submit.html\n"
           ."\n\n"
           ."HTTP_USER_AGENT: " . $_SERVER['HTTP_USER_AGENT'] . "\n"
           ."REMOTE_ADDR    : " . $_SERVER['REMOTE_ADDR'] . "\n"
           ."SCRIPT_URI     : " . $_SERVER['SCRIPT_URI'] . "\n";

      mail ("joey@infodrom.org", "New fortune via webform", $body, $from);
      echo "<p><b>Fortune:</b> Sent to the master.  Thanks.  "
	  ."After review the fortune may be included.</p>";
    } else {
      echo "<p><b>Bummer:</b> Forgot to include the origin.</p>";
    }
  } else {
    echo "<p><b>Bummer:</b> Forgot to include something useful.</p>";

  }
?>

<fortune title="Random Fortune Cookie"
         source="/usr/games/fortune -s 34% infodrom 33% infodrom-linux 33% linuxtag">

</page>

# Local variables:
# mode: html
# mode: auto-fill
# mode: iso-accents
# end:
