<?PHP
/************************************************************************/
/* NPDS V : Net Portal Dynamic System .                                 */
/* ===========================                                          */
/*                                                                      */
/* This version name NPDS Copyright (c) 2001-2004 by Philippe Brunier   */
/*                                                                      */
/* 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.       */
/************************************************************************/
/************************************************************************/
/* based on ChatBox Michael Yarbrough (http://www.comediccadavers.com/) */
/* Mod by Jules  / OVNI (webmaster@lajec.com)                           */
/************************************************************************/
if (!function_exists("Mysql_Connexion")) {include ("mainfile.php");}
if (!function_exists("makeChatBox")) {include ("powerpack_f.php");}
include("functions.php");

   if (!autorisation_block("makeChatBox")) {die();}

   if (isset($user)) {
      if ($cookie[9]=="") $cookie[9]=$Default_Theme;
      if (isset($theme)) $cookie[9]=$theme;
      $tmp_theme=$cookie[9];
      if (!$file=@opendir("themes/$cookie[9]")) {
         $tmp_theme=$Default_Theme;
         include("themes/$Default_Theme/theme.php");
      } else {
         include("themes/$cookie[9]/theme.php");
      }
   } else {
      $tmp_theme=$Default_Theme;
      include("themes/$Default_Theme/theme.php");
   }
   include("meta/meta.php");
   echo import_css($tmp_theme, $language, $site_font);
   include("lib/formhelp.java.php");
   echo "</head>\n<body topmargin=\"2\" bottommargin=\"2\" leftmargin=\"2\" rightmargin=\"2\" class=\"LIGNA\">";
   echo "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"1\" class=\"HEADER\">";
   echo "<form name=\"coolsus\" action=\"chatinput.php\" method=\"post\">
         <input type=\"hidden\" name=\"op\" value=\"set\">";
   if (!isset($cookie[1])) {
      $pseudo = ((isset($name))?($name):getip());
   } else {
      $pseudo = $cookie[1];
   }
   echo "<input type=\"hidden\" name=\"name\" value=\"$pseudo\">";
   echo "<tr>
   <td align=\"left\" nowrap=\"nowrap\" class=\"BOX\">".pp_translate("You are logged in as")." <b>$pseudo</b></td>
   <td align=\"right\"><input class=\"BOUTON_STANDARD\" type=\"submit\" tabindex=\"1\" value=\"".pp_translate("Submit")."\"></td></tr>";

   echo "<tr><td align=\"left\" nowrap=\"nowrap\">".putitems()."</td></tr>";

   $xJava = 'name="message" onSelect="storeCaret(this);" onClick="storeCaret(this);" onKeyup="storeCaret(this);" onFocus="storeForm(this)"';
   echo "<tr>
        <td colspan=\"2\" align=\"left\" nowrap=\"nowrap\" class=\"HEADER\">".pp_translate("Text:")."
        <input class=\"TEXTBOX_STANDARD\" type=\"text\" $xJava size=\"40\" maxlength=\"100\" name=\"message\" tabindex=\"0\" style=\"width: 87%;\"></td>
        </form>
        </tr>
        </table>
        <script>document.coolsus.message.focus();</script>
        </body>
        </html>";

   switch ($op) {
      case "set":
           if (!isset($cookie[1]) && isset($name)) {
              $uname = $name;
              $dbname = 0;
           } else {
              $uname = $cookie[1];
              $dbname = 1;
           }
           insertChat($uname, $message, $dbname);
           break;
   }
?>