<?php
/*
   The Index software may be freely distributed.
   See license.txt for details.
*/
define('ROOT', './');
include(ROOT . 'text.inc');
include(ROOT . 'counts/count.inc');
include(ROOT . 'layout.inc');
include(ROOT . 'list/list.inc');
include(ROOT . 'notes/notes.inc');

ReadList();

start_page();

if ($name!= "")
{
    $name = submit2text($name);
    $author = submit2text($author);
    $url = submit2text($url);
    if (
               strpos($desc, '<') !== false 
            or strpos($desc, '>') !== false
            or strpos($desc, 'http:') !== false
            or (trim($desc) == '')
       )
        $spam = true;
    $desc = submit2text($desc);
    $category = submit2text($category);
    $email = submit2text($email);

    if (is_array($cats))
        $category = implode(",", $cats);
    else
        $category = "08new";
    $visitoritem = MakeVisitorItem($name, $author, $url, $desc, $category, $email);
    if ($preview != "Preview") 
    {
        if (!$spam)
            StoreVisitorItem($visitoritem);
        $name = $author = $url = $desc = $cats = $category = $email = "";
        ?><h2>This item has been added</h2><?php
    }
    else
    {
        ?><h2>Preview of your item</h2><?php
    }
    start_itemlist();
    start_item();
    item("", $visitoritem, 0, 0);
    end_item();
    end_itemlist();
}
else
{
    ?><h2>Submit an item</h2>

    <p>
    Did you find a source of information on NetHack on the web that you
    think should be on the NetHack Index? If so, you can enter the information
    about it here.  It will then be included in the NetHack Index in the category
    "Visitor's items". Once in a while visitor's items will be reviewed and 
    entered in the main list.
    Of course you can also send an e-mail to
    <i><a href="mailto:nethack@nicolaas.net">nethack@nicolaas.net</a></i>.
    </p>
    <?php
}
submit_form("submit.php", $key, 0, $name, $author, $url, $desc, $category, $email);
end_page();
?>