<?PHP
/************************************************************************/
/* DUNE by NPDS                                                         */
/* ===========================                                          */
/*                                                                      */
/* Based on PhpNuke 4.x source code                                     */
/*                                                                      */
/* NPDS Copyright (c) 2002-2007 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.       */
/************************************************************************/
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");
   }
   $Titlesitename="NPDS";
   include("meta/meta.php");
   echo import_css($tmp_theme, $language, $site_font, basename($PHP_SELF), "");
   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\">".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;
   }
?>