<?php
/**
 * $Source: /home/cvs/nukescripts/modules/NSN_HELP/index.php,v $
 * $Revision: 1.0.0-1 $
 * $Author: Benoit $
 * $Date: 2006/07/03 16:16:01 $
 * Fix Piermin Bug 131
 */
/********************************************************/
/* NSN HELP 1.1.0 for PHP-Nuke 7.5/7.6                  */
/* Author: Benoit (gargamel10@msn.com)                  */
/*                                                      */
/* http://www.nukescripts.net                           */
/*http://www.nukescripts.fr                             */
/* Copyright © 2005 by NukeScripts Network              */
/********************************************************/
defined('MAXIMUS') or Header("Location: ../../index.php");
require_once("mainfile.php");
$module_name = basename(dirname(__FILE__));
get_lang($module_name);

$pagetitle = "- $module_name";
###################NE PAS SUPPRIMER !!!#########################################
########:::..Inutile qu'une personne anonyme propose une aide..:::##############
if (!is_user($user)){
       $pagetitle = "- "._ACCESSDENIED."";
            incoh();
                 title("$sitename: "._ACCESSDENIED."");
                      Max_OpenTable();
                          echo "<center><b>"._RESTRICTEDAREA."</b><br /><br />"
                              .""._MODULEUSERS."";
                                  echo "<br /><br />"._GOBACK."";
                                      Max_CloseTable();
                                          incof();
                                              die();
                                                          }
####################NOT TO REMOVE !!!###########################################
else {
   require_once("modules/$module_name/includes/functions.php");
   $help_config = help_get_configs();

function aide_main(){
   global $prefix, $cookie, $db, $module_name, $help_config;
   incoh();
   $aide_user_name = $cookie[1];
   $aide_user_id = $cookie[0];
   $result = $db->sql_query("SELECT fonction_titre, fonction_desc FROM ".$prefix."_nsnhelp_fonction  ORDER BY fonction_titre");
   if (!$db->sql_numrows($result)){
   Max_OpenTable();
   echo "<font class=\"content\"><center>" . $help_config['nohelp'] . "</center></font>";
   Max_CloseTable();
   } else {
   Max_OpenTable();
   echo "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr>\n";
   echo "<td align=\"center\"><font class=\"content\">" . $help_config['iasafun'] . "</font></td></tr></table>";
   Max_CloseTable();
   Max_OpenTable();
   echo "<table width=\"100%\" border=\"" . $help_config['border'] . "\" cellpadding=\"4\" cellspacing=\"1\"><tr>\n";
   echo "<th  width=\"5%\" align=\"center\"><font class=\"content\"><strong>" . $help_config['col1'] . "</strong></font></th>"
    . "<th  width=\"40%\" align=\"center\"><font class=\"content\"><strong>" . $help_config['col2'] . "</strong></font></th>"
    . "<th  width=\"55%\" align=\"center\"><font class=\"content\"><strong>" . $help_config['col3'] . "</strong></font></th></tr>";
   while ($row = $db->sql_fetchrow($result)) {$fonction_titre = stripslashes(filter_text($row['fonction_titre']));$fonction_desc = stripslashes(filter_text($row['fonction_desc']));
   echo "<form action=\"modules.php?name=$module_name&op=submit_help\" method=\"post\">"
    . "<tr><td width=\"5%\" align=\"center\"><input type='radio' name='fonction_titre' value='$fonction_titre'></td>"
    . " <td width=\"40%\" align=\"center\">$fonction_titre</td>"
    . " <td width=\"55%\" align=\"center\">$fonction_desc</td></tr>";
   }
   echo "<tr><td width=\"5%\" align=\"center\"><input type='radio' name='fonction_titre' value='1'></td>"
   . "<td width=\"100%\" colspan=\"2\" align=\"left\">" . $help_config['anderfonction'] . "</td></tr>"
   . "<td width=\"50%\" colspan=\"2\" align=\"left\">" . $help_config['infoshelp'] . "</td>"
   . "<td width=\"50%\"  align=\"left\">"._YOUR_PSEUDO."<b>$aide_user_name</b><br /><textarea cols=\"70\" rows=\"12\" name=\"aide\"></textarea></td></tr>"
   . "<input type=\"hidden\" name=\"aide_user_name\" value=\"$aide_user_name\">"
   . "<input type=\"hidden\" name=\"aide_user_id\" value=\"$aide_user_id\">"
   . "<td width=\"100%\" colspan=\"3\" align=\"center\"><input type=\"submit\" value=\""._VALIDATE."\"></td></tr></table>";

   Max_CloseTable();
   }
   $db->sql_freeresult($result);
   incof();
}

function Submit_Aide($aide, $fonction_titre, $aide_user_name, $aide_user_id){
   global $prefix, $db, $help_config;
   incoh();
   $aide_user_id = intval($aide_user_id);
   $aide = stripslashes(check_html(FixQuotes($aide, "nohtml")));
   $fonction_titre = stripslashes(check_html(FixQuotes($fonction_titre, "nohtml")));
   $aide_user_name = stripslashes(check_html(FixQuotes($aide_user_name, "nohtml")));
   $aide = trim($aide);
   if($fonction_titre == 1){
   $fonction_titre = _NEW_FONCTION;}
   if(!$aide  OR $aide == ""){
   Max_OpenTable();
   echo "<font class=\"content\"><strong><center>"._NIET_CORRECT."</strong></font><br /><br />"._BACK."</center>";
   Max_CloseTable();
   incof();
   exit();
   }else{
   $result = $db->sql_query("INSERT INTO ".$prefix."_nsnhelp_help VALUES (NULL, '$aide_user_id', '$aide_user_name', '$aide', '$fonction_titre', now(), 0)");
   Max_OpenTable();
   echo "<font class=\"content\"><center>" . $help_config['thx'] . "";
   Max_CloseTable();
   $db->sql_freeresult($result);
   incof();
   }
}

switch($op) {

    case "submit_help":
	Submit_Aide($aide, $fonction_titre, $aide_user_name, $aide_user_id);
	break;
    default:
	aide_main();
	break;
  }
}