<?PHP
/************************************************************************/
/* DUNE by NPDS                                                         */
/* ===========================                                          */
/*                                                                      */
/* This version name NPDS Copyright (c) 2001-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.       */
/************************************************************************/

function block_user_info() {
   $ModInc="block-User_Info";
   $block_User_Info = "";
   if (!isset($username)) $username = "";
   if (!isset($ip)) $ip = "";
   if (!isset($guest)) $guest = "";
   global $language, $user, $username, $cookie, $anonymous, $long_chain, $YNmail;
   global $NPDS_Prefix;

   // inclusion du fichier de traduction : L'origine est TOUJOURS le Français
   if (file_exists("modules/block-User_Info/language/block-User_Info.lang-".$language.".php"))
      include ("modules/block-User_Info/language/block-User_Info.lang-".$language.".php");
   else
      include ("modules/block-User_Info/language/block-User_Info.lang-french.php");

   if (!$long_chain) {$long_chain=15;}
   if ($user)
   {
      cookiedecode($user);
      $username = $cookie[1];
      if ($username)
      {
         $Mel_To_username = base64_decode($user);
         $Mel_To_userdata = explode(":", $Mel_To_username);
         $total_messages   = sql_num_rows(sql_query("SELECT msg_id FROM ".$NPDS_Prefix."priv_msgs WHERE to_userid = '".$Mel_To_userdata[0]."' and type_msg='0'"));
         $new_messages  = sql_num_rows(sql_query("SELECT msg_id FROM ".$NPDS_Prefix."priv_msgs WHERE to_userid = '".$Mel_To_userdata[0]."' AND read_msg='0' and type_msg='0'"));
         if ( (!$total_messages) Or ($total_messages < 1) )
         {
            $Info_Total_Message = "<a href=\"viewpmsg.php\" class=\"menulink\"><font site=\"1\"><u>".block_user_info_translate("Message")."</font></u></a>&nbsp;:&nbsp;".$total_messages."";
         }
         else if ($total_messages == 1)
         {
            $Info_Total_Message = "<a href=\"viewpmsg.php\" class=\"menulink\"><font site=\"1\"><u>".block_user_info_translate("Message")."</font></u></a>&nbsp;:&nbsp;".$total_messages."";
         }
         else if ($total_messages > 1)
         {
            $Info_Total_Message = "<a href=\"viewpmsg.php\" class=\"menulink\"><font site=\"1\"><u>".block_user_info_translate("Messages")."</font></u></a>&nbsp;:&nbsp;".$total_messages."";
         }
         else {
            $Info_Total_Message = "<a href=\"viewpmsg.php\" class=\"menulink\"><font site=\"1\"><u>".block_user_info_translate("Message")."</font></u></a>&nbsp;:&nbsp;".$total_messages."";
         }
         $PopUp1 = JavaPopUp("readpmsg_imm.php?op=new_msg","IMM",500,400);
         $Info_New_Message = "<font size=\"1\">".block_user_info_translate("Non lu")."&nbsp;:&nbsp;</font>";
         $Info_New_Message .= "<a href=\"javascript:void(0);\" onClick=\"window.open($PopUp1);\" class=\"noir\">";
         $Info_New_Message .= "<b>".$new_messages."</b></a>";
         $PopUp2 = JavaPopUp("readpmsg_imm.php?op=msg","IMM",500,400);
         $Info_Old_Message = "<font size=\"1\">".block_user_info_translate("Lu")."&nbsp;:&nbsp;</font>";
         $Info_Old_Message .= "<a href=\"javascript:void(0);\" onClick=\"window.open($PopUp2);\" class=\"noir\">";
         $Info_Old_Message .= "<b>".($total_messages - $new_messages)."</b></a>";
      }
      $block_User_Info .= "&nbsp;<a href=\"memberslist.php\" alt=\"".block_user_info_translate("Liste des membres")."\" title=\"".block_user_info_translate("Liste des membres")."\"><img src=\"modules/".$ModInc."/images/group-4.gif\" height=\"14\" width=\"17\" border=\"0\"></a>&nbsp;\n";
      $block_User_Info .= "".block_user_info_translate("Bonjour").",&nbsp;<a href=\"user.php\" class=\"noir\"><b>".$username."</b></a>";
      $block_User_Info .= "<br />\n";
      $block_User_Info .= "<p align=\"right\"><a href=\"user.php?op=logout\" class=\"menulink\"><b>".block_user_info_translate("D&eacute;connexion")."</b></a>&nbsp;</p\n";
      $block_User_Info .= "<hr noshade width=\"95%\" />\n";
      $block_User_Info .= "<img src=\"modules/".$ModInc."/images/email-y.gif\" height=\"10\" width=\"14\">&nbsp;".$Info_Total_Message."\n";
      $block_User_Info .= "<br />\n";
      $block_User_Info .= "<img src=\"modules/".$ModInc."/images/email-r.gif\" height=\"10\" width=\"14\">&nbsp;".$Info_New_Message."";
      $block_User_Info .= "<br />\n";
      $block_User_Info .= "<img src=\"modules/".$ModInc."/images/email-g.gif\" height=\"10\" width=\"14\">&nbsp;".$Info_Old_Message."";
   }
   if (!isset($user))
   {
      $block_User_Info .= "<img src=\"modules/".$ModInc."/images/group-4.gif\" height=\"14\" width=\"17\" border=\"0\" />&nbsp;";
      $block_User_Info .= "".block_user_info_translate("Bonjour").",&nbsp;<b>".translate("".$anonymous."")."</b>";
      $block_User_Info .= "<hr noshade width=\"95%\" />\n";
      $block_User_Info .= "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"95%\" align=\"center\">\n";
      $block_User_Info .= "<form action=\"user.php\" method=\"post\">";
      $block_User_Info .= "<tr>\n";
      $block_User_Info .= "<td width=\"40%\">&nbsp;".block_user_info_translate("Pseudo :")."</td>\n";
      $block_User_Info .= "<td align=\"left\" width=\"60%\"><input type=\"text\" name=\"uname\" size=\"15\" maxlength=\"25\" class=\"textbox\" style=\"width:100%;\"></td>\n";
      $block_User_Info .= "</tr>";
      $block_User_Info .= "<tr>\n";
      $block_User_Info .= "<td width=\"40%\">&nbsp;".block_user_info_translate("Mot de Passe :")."</td>\n";
      $block_User_Info .= "<td align=\"left\" width=\"60%\"><input type=\"password\" name=\"pass\" size=\"15\" maxlength=\"20\" class=\"textbox\" style=\"width:100%;\"></td>\n";
      $block_User_Info .= "</tr>";
      $block_User_Info .= "<input type=\"hidden\" name=\"op\" value=\"login\">";
      $block_User_Info .= "<tr>\n";
      $block_User_Info .= "<td colspan=\"2\" align=\"center\"><input type=\"submit\" value=\"".block_user_info_translate("Identifiant ")."\" class=\"bouton_standard\"></td>\n";
      $block_User_Info .= "</tr>";
      $block_User_Info .= "<tr>\n";
      $block_User_Info .= "<td width=\"50%\" align=\"center\"><a href=\"user.php?op=forgetpassword\" title=\"Vous avez perdu votre mot de passe d'accès au site\" class=\"noir\">".block_user_info_translate("Perdu")."</a></td>\n";
      $block_User_Info .= "<td width=\"50%\" align=\"center\"><a href=\"user.php?op=only_newuser\" title=\"".block_user_info_translate("Vous n'avez pas encore de compte personnel ? Vous devriez en créer un. Une fois enregistré, vous aurez certains avantages, comme pouvoir modifier l'aspect du site,ou poster des Commentaires signés...")."\" class=\"noir\">".block_user_info_translate("Inscription")."</a></td>\n";
      $block_User_Info .= "</tr>\n";
      $block_User_Info .= "</form>\n";
      $block_User_Info .= "</table>\n";
   }
   return ($block_User_Info);
}
?>