<?php

if ( ! @include_once( './mainfile.php' ) ) { exit( '!! INCLUDE ERROR. ACCESS DENIED !!' ); }
error_reporting( _E_VALUE );


/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
// | myPHPNuke Version 188_8 RC2                                          |
// +----------------------------------------------------------------------+
// | License: GNU/GPL - http://www.gnu.org/copyleft/gpl.html              |
// +----------------------------------------------------------------------+
// | Support: http://myphpnuke.com/                                       |
// +----------------------------------------------------------------------+
// | Author: myPHPNuke Dev Team                                           |
// +----------------------------------------------------------------------+
// | Copyright: © 2001-2004 myPHPNuke Dev Team                            |
// +----------------------------------------------------------------------+
// $Id: chatinput.php,v 1.10.2.4 2004/08/27 15:51:16 kirilt Exp $



######################################################################
# ChatBox II
# =============
#
# Copyright (C) 2001 by Gerard Samuel (trini0@optonline.net)
#
# Based on code found in myPHPNuke
# I don't know who wrote the one for myphpnuke, but you are
# mentioned <u>HERE</u> &
# Ingo van Peeren (ingo@beginner-ag.de)
######################################################################
# This program is free software. You can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License.
######################################################################

$userinfo =& $GLOBALS['uinf'];
$username = ( _MPN_USER ) ? ( $userinfo['uname'] ) : ( (bool)FALSE );

if ( ! isset( $userinfo['theme'] ) || $userinfo['theme'] == "" || ! is_dir( './themes/' . $userinfo['theme'] ) )
{
    $getTheme = $Default_Theme;
}
else
{
    $getTheme = $userinfo['theme'];
}

include 'themes/' . $getTheme . '/theme.' . $phpEx;

// INSERT INTO CHAT //

if ( isset( $_POST['message'] ) && $_POST['message'] != '' )
{
    $chat = trim( $_POST['message'] );

    $timestamp = time();
    $chat = htmlspecialchars( $chat );

    $sql = 'INSERT INTO ' . $mpnTables['chatboxII'] . ' SET username = "' . $userinfo['uname'] . '", message = "' . $chat . '", date = ' . (int)$timestamp;

    $result = mysql_query( $sql );
}

// DATABASE MAINTAINANCE //

$sql = "SELECT count(username) FROM ".$mpnTables['chatboxII']."";
$result = mysql_query( $sql );

$count = ( $result ) ? ( mysql_result( $result, 0 ) ) : ( 0 );

if ( $count > 60 )
{
    $nuke = time() - 120;
    $sql = "DELETE FROM ".$mpnTables['chatboxII']." WHERE date < ".$nuke."";
    $result = mysql_query($sql);
}

// OUTPUT

echo "<!DOCTYPE html
	PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"
    \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";

echo "<html id='chatinput'>\n";

    echo "<head>\n";

    echo "<title>Chat Input</title>\n";

    echo "<meta http-equiv=\"content-type\" content=\"text/html; charset=ISO-8859-1\" />\n";

    if ( ! is_dir( './themes/' . $getTheme . '/style/' . $getTheme . '.css' ) )
    {
        $getCSS = './themes/' . $getTheme . '/style/' . $getTheme . '.css';

        echo "<link rel='stylesheet' href='$getCSS' type='text/css' />\n";
    }

    echo '<script type="text/javascript" src="' . _MPN_ROOT_URI . 'mpn_bbcode.js"></script>' . "\n";

    echo "</head>\n";

    echo "<body bgcolor=\"$bgcolor2\">\n";

    $ipth = "<img src=\"images/forum/smilies/";

if ( ! _MPN_USER )
{
    echo "<div align=\"center\">".translate("You are not logged in.")."</div>\n";
    echo "<div align=\"center\">".translate("Click")." <a href=\"javascript:top.close();\">".translate("Here")."</a> ".translate("to close window.")."</div>\n";
}
else
{
    echo '<form name="coolsus" action="' . $_SERVER['PHP_SELF'] . '" method="post">' . "\n";

        echo '<div class="center">' . "\n";

            echo '<input type="text" size="50" maxlength="75" name="message" />' . "\n";
            echo '&nbsp;&nbsp;';
            echo '<input class="button" type="submit" value="' . translate( 'Say' ) . '" />' . "\n";
            echo '<br />' . "\n";

            echo "<a href=\"javascript: x()\" onClick=\"DoSmilie(' :) ');\">".$ipth."icon_smile.gif\" alt=\"".translate("smile")."\" border=\"0\"></a>";
            echo " <a href=\"javascript: x()\" onClick=\"DoSmilie(' :( ');\">".$ipth."icon_frown.gif\" alt=\"".translate("sad")."\" border=\"0\"></a>";
            echo " <a href=\"javascript: x()\" onClick=\"DoSmilie(' :D ');\">".$ipth."icon_biggrin.gif\" alt=\"".translate("big grin")."\" border=\"0\"></a>";
            echo " <a href=\"javascript: x()\" onClick=\"DoSmilie(' :O ');\">".$ipth."icon_eek.gif\" alt=\"".translate("surprised")."\" border=\"0\"></a>";
            echo " <a href=\"javascript: x()\" onClick=\"DoSmilie(' ;) ');\">".$ipth."icon_wink.gif\" alt=\"".translate("wink")."\" border=\"0\"></a>";
            echo " <a href=\"javascript: x()\" onClick=\"DoSmilie(' :x ');\">".$ipth."icon_mad.gif\" alt=\"".translate("mad")."\" border=\"0\"></a>";
            echo " <a href=\"javascript: x()\" onClick=\"DoSmilie(' :-? ');\">".$ipth."icon_confused.gif\" alt=\"".translate("confused")."\" border=\"0\"></a>  ";

            echo translate("need") . " <a href=\"bb_smilies.php\" target=\"_blank\">" . translate("more") . "</a>...\n";

        echo '</div>';

    echo '</form>' . "\n";

    echo '<script>';

        echo 'document.coolsus.message.focus();';

    echo '</script>' . "\n";
}

echo '</body></html>' . "\n";

?>