<?php
$admin = 2;
$file = __FILE__;
include ("../inc/inc_common.php");
include ("../inc/inc_connect.php");
include ("../inc/inc_admincheck.php");
include ("../inc/inc_getdate.php");
include ("../inc/inc_forumname.php");
$page = "Admin - Spell Checker";
$pagelink = $file;
include("../inc/inc_setonline.php");
$title = "$name1 Admin - $gfcookie[1]";
include ("../inc/inc_head.php");
include ("../inc/inc_body.php");
$title = "Spell Checker";
include ("../inc/inc_title.php");

if ($actionb == "add")
{
    $query = "INSERT INTO $wordtable ( strWord) values( '$word')";
    mysql_query( $query, $link ) or die ( "Error! : ".mysql_error() );
}

if ($actionb == "accept")
{
    $query = "INSERT INTO $wordtable ( strWord) values( '$word')";
    mysql_query( $query, $link ) or die ( "Error! : ".mysql_error() );

    $query = "DELETE FROM $spelltable WHERE memOrigPost = 'Spelling Suggestion' AND memPost = '$word'";
    mysql_query( $query, $link ) or die ( "Error! : ".mysql_error() );

    $actionb = "add";
}

if ($actionb == "delete")
{
    $query = "DELETE FROM $spelltable WHERE memOrigPost = 'Spelling Suggestion' AND memPost = '$word'";
    mysql_query( $query, $link ) or die ( "Error! : ".mysql_error() );
}

print "<font size=$fontsizeb><br><center>";

$result=mysql_query("SELECT * FROM $wordtable");
$num_rows = mysql_num_rows( $result );
print "<b>$num_rows words are held on the system.</b><br><br><font size=$fontsize><br><br>";
if ($actionb == "add")
{
    print "<br>$word has been added.<br>";
}

print "<form method=\"post\" action\"admin_spell.php\">
<input type=\"hidden\" value=\"add\" name=\"actionb\">
<input type=\"text\" name=\"word\"> &nbsp;<input type=\"submit\" value=\"Add This Word\"></form><br><b>User Submissions</b><br><br>";

$result=mysql_query("SELECT * FROM $spelltable WHERE memOrigPost = 'Spelling Suggestion'");
$num_rows = mysql_num_rows( $result );
while ( $a_row = mysql_fetch_object( $result ) )
{
    print "$a_row->strName suggests \"$a_row->memPost\": <a href=\"admin_spell.php?actionb=accept&word=$a_row->memPost\">Accept</a> / <a href=\"admin_spell.php?actionb=delete&word=$a_row->memPost\">Decline</a><br>";
}

if ($num_rows == 0)
{
    print "There are no user submittions at this time.";
}


include ("../inc/inc_footer.php");

?>