<?php
/********************************************************/
/* NSN Groupes Sections                                 */
/* By: NukeScripts Network (webmaster@nukescripts.fr)   */
/* http://www.nukescripts.fr                            */
/* Copyright  2000-2005 by NukeScripts Network         */
/* ==================================================== */
/* Based from:                                          */
/* PHP-NUKE: Web Portal System                          */
/********************************************************/
if (!defined('ADMIN_ALLOW') && !defined('ADMIN_MAX')) {
	die ("Access Denied");
}


include_once ("modules/Sections/includes/functions.php");

function menusections() {
global $admin_file;
    Max_OpenTable();
    echo "<center><font class='title'><b>" . _SECTIONSADMIN . "</b></font></center>";
    echo "<center><a href='".$admin_file.".php'><i>Administration</i></a> - <a href='".$admin_file.".php?op=sections'>Sections Administration</a> - <a href='modules.php?name=Sections'>Sections Module</a>"
    ."<br /><a href='".$admin_file.".php?op=ConfigSections'>Configuration Sections</a></center>";
    Max_CloseTable();
    br('1');
    Max_OpenTable();
    echo "<table width='100%' align='center'>";
    echo "<td width='33%' align='center'><a href='".$admin_file.".php?op=ajoutarticle'>"._SC_ADDARTICLE."</a><br />";
    echo "<a href='".$admin_file.".php?op=ajoutrubrique'>"._SC_ADDRUBRIQUE."</a></td>"
	 ."<td width='33%' align='center'><a href='".$admin_file.".php?op=lesarticles'>"._SC_ARTICLES."</a><br />"
	 ."<a href='".$admin_file.".php?op=sections'>"._SC_RUBRIQUES."</a></td>"
	 ."</table>";
    Max_CloseTable();
}

function ajoutarticle() {
global $db, $language, $multilingual, $admin_file, $wysiwyg;
    incoh();
if ( $wysiwyg == 'fck' ) {
   		 include_once('FCKeditor/fckeditor.php');
   		 }
    menusections();
    br('1');
	Max_OpenTable();
	echo "<center><font class=\"option\"><b>" . _ADDSECARTICLE . "</b></font></center><br />"
	    ."<form action=\"".$admin_file.".php\" method=\"post\">"
	    ."<b>" . _TITLE . "</b><br />"
	    ."<input type=\"text\" name=\"title\" size=\"60\"><br /><br />"
	    ."<b>" . _SELSECTION . ":</b><br />";

	    echo "<input type=\"hidden\" name=\"ajout\" value=\"1\">";

        $result2 = $db->sql_query("SELECT `secid`, `secname`, `view` from `".TABLE_NSNSECTIONS_RUBRIQUES."` order by `secid`");

     while ($row2 = $db->sql_fetchrow($result2)) {
	    $secid = $db->XMFnum($row2['secid']);
	    $secname = stripslashes($row2['secname']);
            $view = $db->XMFnum($row2['view']);

    if ($view == 0) {
        $view = ""._VISITEURS."";
    } elseif ($view == 1) {
        $view = ""._USERSI."";
    } elseif ($view == 2) {
        $view = ""._ADMINI."";
    } elseif ($view > 3) {
        $view = ""._GROUPS."";
    }

echo "<table width='100%'><td width='30%' align='left'><input type=\"radio\" name=\"secid\" value=\"$secid\"> $secname </td><td width='70%' align='left'> ( $view ) </td></table>";
	}
	echo "<br /><font class=\"content\"><b>" . _DONTSELECT . "</b></font><br />";
	if ($multilingual == 1) {
	    echo "<br /><b>" . _LANGUAGE . ": </b>"
		."<select name=\"slanguage\">";
	    $handle=opendir('language');
	    while ($file = readdir($handle)) {
		if (preg_match("/^lang\-(.+)\.php/", $file, $matches)) {
	    	    $langFound = $matches[1];
		    $languageslist .= "$langFound ";
		}
	    }
	    closedir($handle);
	    $languageslist = explode(" ", $languageslist);
	    sort($languageslist);
	    for ($i=0; $i < sizeof($languageslist); $i++) {
		if($languageslist[$i]!="") {
		    echo "<option value=\"$languageslist[$i]\" ";
		    if($languageslist[$i]==$language) echo "selected";
		    echo ">".ucfirst($languageslist[$i])."</option>\n";
		}
	    }
	    echo "</select>";
	} else {
	    echo "<input type=\"hidden\" name=\"slanguage\" value=\"$language\">";
	}
	echo "<br /><br /><b>" . _CONTENT . "</b><br />";
if ( $wysiwyg == 'fck' ) {
$oFCKeditor = new FCKeditor(content) ;
$oFCKeditor->InstanceName = "content" ;
$oFCKeditor->Create();
} else {
     echo "<textarea name=\"content\" cols=\"100\" rows=\"15\"></textarea>";
     }
	    br('1');

	    echo "<font class=\"content\">" . _PAGEBREAK . "</font><br /><br />";

    echo "<table><td width='40%'>"._ACTIF."</td><td width='60%'><select name=\"actif\">"
    ."<option value=\"1\" $act2>"._YES."</option>"
    ."<option value=\"0\" $act1>"._NO."</option>"
    ."</select></td></table>";
echo "<table><td width='30%'>"._VIEWPRIV."</td><td width='70%'><select name=\"view\">";
echo "<option value=\"0\">"._VISITEURS."</option>";
echo "<option value=\"1\">"._USERSI."</option>";
echo "<option value=\"2\">"._ADMINI."</option>";
echo "<option value=\"4\">"._GROUPS."</option>";
echo "</select></td></table>";
echo "<table><td width='100%' ALIGN='LEFT'>"._WHATGRDESC."</td></table>";
echo "<table><td width='30%' valign='top'>"._WHATGROUPS."</td><td width='70%'><select name='groups[]' multiple size='10'>\n";
$groupsResult = $db->sql_query("select gid, gname from ".TABLE_NSNGR_GROUPS."");
while(list($gid, $gname) = $db->sql_fetchrow($groupsResult)) { echo "<OPTION VALUE='$gid'>$gname</option>"; }
echo "</select></td>";
echo "</select></td></table>";
echo  "<input type=\"hidden\" name=\"op\" value=\"secarticleadd\">"
	    ."<input type=\"submit\" value=\"" . _ADDARTICLE . "\">"
	    ."</form>";
	Max_CloseTable();
	incof();
}

function ajoutrubrique() {
global $db, $language, $multilingual, $admin_file;
    incoh();
    menusections();
    br('1');
    Max_OpenTable();
    echo "<center><font class=\"option\"><b>" . _ADDSECTION . "</b></font></center><br />"
	."<form action=\"".$admin_file.".php\" method=\"post\"><br />"
	."<b>" . _SECTIONNAME . ":</b><br />"
	."<input type=\"text\" name=\"secname\" size=\"40\" maxlength=\"40\"><br /><br />"
	."<b>" . _SECTIONIMG . "</b><br /><font class=\"tiny\">" . _SECIMGEXAMPLE . "</font><br />";
echo "<input type=\"text\" name=\"image\" size=\"40\" maxlength=\"50\"><br /><br />";

    echo "<table><td width='40%'>"._ACTIF."</td><td width='60%'><select name=\"actif\">"
    ."<option value=\"1\" $act2>"._YES."</option>"
    ."<option value=\"0\" $act1>"._NO."</option>";

    echo "</select></td></table>";
echo "<table><td width='30%'>"._VIEWPRIV."</td><td width='70%'><select name=\"view\">";
echo "<option value=\"0\">"._VISITEURS."</option>";
echo "<option value=\"1\">"._USERSI."</option>";
echo "<option value=\"2\">"._ADMINI."</option>";
echo "<option value=\"4\">"._GROUPS."</option>";
echo "</select></td></table>";
echo "<table><td width='100%' ALIGN='LEFT'>"._WHATGRDESC."</td></table>";
echo "<table><td width='30%' valign='top'>"._WHATGROUPS."</td><td width='70%'><select name='groups[]' multiple size='10'>\n";
$groupsResult = $db->sql_query("select gid, gname from ".TABLE_NSNGR_GROUPS."");
while(list($gid, $gname) = $db->sql_fetchrow($groupsResult)) { echo "<OPTION VALUE='$gid'>$gname</option>"; }
echo "</select></td>";
echo "</select></td></table>";
echo "<input type=\"hidden\" name=\"op\" value=\"sectionmake\">"
	."<INPUT type=\"submit\" value=\"" . _ADDSECTIONBUT . "\">"
	."</form>";
    Max_CloseTable();
    incof();
}

function lesarticles() {
    global $db, $language, $multilingual,$bgcolor2,$bgcolor1,$bgcolor4, $admin_file;
    incoh();
    menusections();
	Max_OpenTable();
	echo "<center><font class=\"option\"><b>" . _LAST . " 100 " . _ARTICLES . "</b></font></center><br />";
	 //   ."<ul>";

echo "<table width='100%' border='0' cellpadding='2' cellspacing='2'><tr>\n";
echo "<td bgcolor='$bgcolor2' align='center'><font color='$textcolor2'><b>"._ID."</b></font></td>\n";
echo "<td bgcolor='$bgcolor2' align='center'><font color='$textcolor2'><b>"._TITLE."</b></font></td>\n";
echo "<td bgcolor='$bgcolor2' align='center'><font color='$textcolor2'><b>"._SECTIONNAME."</b></font></td>\n";
echo "<td bgcolor='$bgcolor2' align='center'><font color='$textcolor2'><b>"._ACCES."</b></font></td>\n";
echo "<td bgcolor='$bgcolor2' align='center'><font color='$textcolor2'><b>"._LANG."</b></font></td>\n";
echo "<td bgcolor='$bgcolor2' align='center'><font color='$textcolor2'><b>"._ACTIF."</b></font></td>\n";
echo "<td bgcolor='$bgcolor2' align='center'><font color='$textcolor2'><b>"._EDIT."</b></font></td>\n";
echo "<td bgcolor='$bgcolor2' align='center'><font color='$textcolor2'><b>"._DEL."</b></font></td>\n";
$dcolor_A = "$bgcolor4";
$dcolor_B = "$bgcolor1";

    $result3 = $db->sql_query("SELECT `artid`, `secid`, `title`, `content`, `slanguage`, `view`, `actif` from `".TABLE_NSNSECTIONS_ARTICLES."` order by `artid` desc limit 0,100");
    while ($row3 = $db->sql_fetchrow($result3)) {
$artid     = $db->XMFnum($row3['artid']);
$secid     = $db->XMFnum($row3['secid']);
$title     = stripslashes($row3['title']);
$content   = stripslashes($row3['content']);
$slanguage = stripslashes($row3['slanguage']);
$view      = $db->XMFnum($row3['view']);
$actif     = $db->XMFnum($row3['actif']);
$row4 = $db->sql_fetchrow($db->sql_query("SELECT `secid`, `secname` from `".TABLE_NSNSECTIONS_RUBRIQUES."` where `secid`='$secid'"));
$secid   = $db->XMFnum($row4['secid']);
$secname = stripslashes($row4['secname']);


    if ($view == 0) {
        $view = ""._VISITEURS."";
    } elseif ($view == 1) {
        $view = ""._USERSI."";
    } elseif ($view == 2) {
        $view = ""._ADMINI."";
    } elseif ($view > 3) {
        $view = ""._GROUPS."";
    }


$dcolor = ($a == 0 ? $dcolor_A : $dcolor_B);
 echo "<tr><td bgcolor='$dcolor' align='center'>$artid</b></font></a></td>";
echo "<td bgcolor='$dcolor' align='center'>$title</td>\n";
echo "<td bgcolor='$dcolor' align='center'>$secname</td>\n";
echo "<td bgcolor='$dcolor' align='center'>$view</td>\n";
echo "<td bgcolor='$dcolor' align='center'>$slanguage</td>\n";
if ( $actif == 0 ){ $actif = "<fonT color='red'>"._NO."</FONT>";}
ELSEif ( $actif == 1 ){ $actif = "<fonT color='green'>"._YES."</FONT>";}
echo "<td bgcolor='$dcolor' align='center'>$actif</td>\n";


echo "<td bgcolor='$dcolor' align='center'><a href=\"".$admin_file.".php?op=secartedit&amp;artid=$artid\">" . _EDIT . "</a></td>\n";
echo "<td bgcolor='$dcolor' align='center'><a href=\"".$admin_file.".php?op=secartdelete&amp;artid=$artid&amp;ok=0\">" . _DELETE . "</a></td>\n";
echo "</tr>\n";
$a = ($dcolor == $dcolor_A ? 1 : 0);
	}
echo "</table>\n";
	echo "</ul>"
	    ."<form action=\"".$admin_file.".php\" method=\"post\">"
	    ."" . _EDITARTID . ": <input type=\"text\" name=\"artid\" size=\"10\" />&nbsp;&nbsp;"
	    ."<input type=\"hidden\" name=\"op\" value=\"secartedit\" />"
	    ."<input type=\"submit\" value=\"" . _OK . "\" />"
	    ."</form>";
	Max_CloseTable();
    incof();
}


function sections() {
    global $db, $language, $multilingual, $admin_file;
    incoh();
    menusections();
    br('1');
    $result = $db->sql_query("SELECT `secid`, `secname`, `image`, `view`, `actif` from `".TABLE_NSNSECTIONS_RUBRIQUES."` order by `secid`");
    $numrows = $db->sql_numrows($result);
    if ($numrows > 0) {
	Max_OpenTable();
	echo "<center><b>" . _ACTIVESECTIONS . "</b><br /><font class='content'>" . _CLICK2EDITSEC . "</font></center><br />"
	    ."<table border='0' width='100%' align='center'><tr>";
   $a = 0;
	while($row = $db->sql_fetchrow($result)) {
	    $secid = $db->XMFnum($row['secid']);
	    $secname = stripslashes($row["secname"]);
	    $image = stripslashes($row["image"]);
	    $view  = $db->XMFnum($row['view']);
	    $actif  = $db->XMFnum($row['actif']);

    if ($view == 0) {
        $view = ""._VISITEURS."";
    } elseif ($view == 1) {
        $view = ""._USERSI."";
    } elseif ($view == 2) {
        $view = ""._ADMINI."";
    } elseif ($view > 3) {
        $view = ""._GROUPS."";
    }

     if ($actif == 0) {
        $actif = "<font color='red'>"._NO."</font>";
    } elseif ($actif == 1) {
        $actif = "<font color='green'>"._YES."</font>";
	}


echo "<td bgcolor='$dcolor' align='center'>";
Max_opentable();
if ($image) { $w1 = "15%"; $w2 ="85%" ;} else {$w1 = ""; $w2 ="100%"; }
echo "<td width='$w1' align='left' valign='top'>";
if ($image) {
echo "<a href=\"".$admin_file.".php?op=sectionedit&amp;secid=$secid\"><img src='images/sections/$image' border='0' alt='$secname'></a>";
}
echo "</td><td width='$w2' align='left' valign='top'><a href=\"".$admin_file.".php?op=sectionedit&amp;secid=$secid\"><b>$secname</b></a><br /><br /><b>"._AFFVIS."</b>: $view<br /><b>"._ACTIVE."</b> $actif";
Max_CloseTable();
echo "</td>";

$a++;
if ($a >= 3) {echo "<tr>"; $a=0;}	}
echo "</tr></table>";
	Max_CloseTable();
}
    br('1');
  incof();
}

function secartedit($artid) {
    global $db, $multilingual, $admin_file, $wysiwyg;
    incoh();
if ( $wysiwyg == 'fck' ) {
   		 include_once('FCKeditor/fckeditor.php');
   		 }
    menusections();
    br('1');
        $artid = $db->XMFnum($artid);
    $row = $db->sql_fetchrow($db->sql_query("SELECT `artid`, `secid`, `title`, `content`, `slanguage`, `view`, `groups`, `actif` from `".TABLE_NSNSECTIONS_ARTICLES."` where `artid`='$artid'"));
	$artid = $db->XMFnum($row['artid']);
	$secid = $db->XMFnum($row['secid']);
	$title = stripslashes($row['title']);
	$content = stripslashes($row['content']);
	$slanguage = stripslashes($row['slanguage']);
	$view = $db->XMFnum($row['view']);
	$groups = $db->XMFnum($row['groups']);
	$actif = $db->XMFnum($row['actif']);

    Max_OpenTable();
    echo "<center><font class=\"option\"><b>" . _EDITARTICLE . "</b></font></center><br />"
	."<form action=\"".$admin_file.".php\" method=\"post\">"
	."<b>" . _TITLE . "</b><br />"
	."<input type=\"text\" name=\"title\" size=\"60\" value=\"$title\"><br /><br />"
	."<b>" . _SELSECTION . ":</b><br />";
        $result2 = $db->sql_query("SELECT `secid`, `secname`, `view` from `".TABLE_NSNSECTIONS_RUBRIQUES."` order by `secname`");
        while ($row2 = $db->sql_fetchrow($result2)) {
	    $secid2 = $db->XMFnum($row2['secid']);
	    $secname = stripslashes($row2['secname']);
	    $view2 = $db->XMFnum($row2['view']);

    if ($view2 == 0) {
        $view2 = ""._VISITEURS."";
    } elseif ($view2 == 1) {
        $view2 = ""._USERSI."";
    } elseif ($view2 == 2) {
        $view2 = ""._ADMINI."";
    } elseif ($view2 > 3) {
        $view2 = ""._GROUPS."";
    }

	    if ($secid2==$secid) {
		$che = "checked";
	    }
echo "<input type=\"radio\" name=\"secid\" value=\"$secid2\" $che>$secname ( $view2 )<br />";
	    $che = "";
    }
    if ($multilingual == 1) {
	echo "<br /><b>" . _LANGUAGE . ": </b>"
	    ."<select name=\"slanguage\">";
	$handle=opendir('language');
	while ($file = readdir($handle)) {
	    if (preg_match("/^lang\-(.+)\.php/", $file, $matches)) {
	        $langFound = $matches[1];
	        $languageslist .= "$langFound ";
	    }
	}
	closedir($handle);
	$languageslist = explode(" ", $languageslist);
	sort($languageslist);
	for ($i=0; $i < sizeof($languageslist); $i++) {
	    if($languageslist[$i]!="") {
		echo "<option value=\"$languageslist[$i]\" ";
		if($languageslist[$i]==$slanguage) echo "selected";
		echo ">".ucfirst($languageslist[$i])."</option>\n";
	    }
	}
	echo "</select><br />";
    } else {
	echo "<input type=\"hidden\" name=\"slanguage\" value=\"$language\" />";
    }
    echo "<br /><b>" . _CONTENT . "</b><br />";

if ( $wysiwyg == 'fck' ) {
$oFCKeditor = new FCKeditor(content) ;
$oFCKeditor->InstanceName = "content" ;
$oFCKeditor->Value = "$content" ;
$oFCKeditor->Create();
} else {
     echo "<textarea name=\"content\" cols=\"100\" rows=\"15\">$content</textarea>";
     }
	br('2');


    $act1 = $act2 = "";
    if ($actif == 0) {
        $act1 = "selected";
    } elseif ($actif == 1) {
        $act2 = "selected";
	}

    echo "<table><td width='40%'>"._ACTIF."</td><td width='60%'><select name=\"actif\">";
    echo "<option value=\"0\" $act1>"._NO."</option>";
    echo "<option value=\"1\" $act2>"._YES."</option>";
    echo "</select></td></table>";



    $sel1 = $sel2 = $sel3 = $sel4 = $sel5 = "";
    if ($view == 0) {
        $sel1 = "selected";
    } elseif ($view == 1) {
        $sel2 = "selected";
    } elseif ($view == 2) {
        $sel3 = "selected";
    } elseif ($view == 3) {
        $sel4 = "selected";
    } elseif ($view > 3) {
        $sel5 = "selected";
    }
 echo "<table><td width='30%'>"._VIEWPRIV."</td><td width='70%'><select name=\"view\">";
    echo "<option value=\"0\" $sel1>"._VISITEURS."</option>";
    echo "<option value=\"1\" $sel2>"._USERSI."</option>";
    echo "<option value=\"2\" $sel3>"._ADMINI."</option>";
    echo "<option value=\"4\" $sel5>"._GROUPS."</option>";
        echo "</select></td></table>";
  echo "<table><td width='100%' ALIGN='LEFT'>"._WHATGRDESC."</td></table>";
    echo "<table><td width='30%' valign='top'>"._WHATGROUPS."</td><td width='70%'><select name='groups[]' multiple size='10'>\n";
    $ingroups = explode("-",$groups);
    $groupsResult = $db->sql_query("select `gid`, `gname` from `".TABLE_NSNGR_GROUPS."`");
    while(list($gid, $gname) = $db->sql_fetchrow($groupsResult)) {
        if(in_array($gid,$ingroups)) { $sel = " selected"; } else { $sel = ""; }
        echo "<OPTION VALUE='$gid'$sel>$gname</option>";
    }
    echo "</select></td>";
    echo "</select></td></table>";

echo "<input type=\"hidden\" name=\"artid\" value=\"$artid\">"
	."<input type=\"hidden\" name=\"op\" value=\"secartchange\" />"
	."<input type=\"submit\" value=\"" . _SAVECHANGES . "\" /> [ <a href=\"".$admin_file.".php?op=secartdelete&amp;artid=$artid&amp;ok=0\">" . _DELETE . "</a> ]"
	."</form>";
    Max_CloseTable();
    incof();
}

function sectionedit($secid) {
    global $db, $admin_file;
    incoh();
    menusections();
    $secid = $db->XMFnum($secid);
    $row = $db->sql_fetchrow($db->sql_query("SELECT `secid`, `secname`, `image`, `view`, `groups`, `actif` from `".TABLE_NSNSECTIONS_RUBRIQUES."` where `secid`='$secid'"));
	$secid   = $db->XMFnum($row['secid']);
	$secname = stripslashes(check_html($row["secname"], "nohtml"));
	$image   = stripslashes(check_html($row["image"], "nohtml"));
	$view    = $db->XMFnum($row['view']);
	$groups  = $db->XMFnum($row['groups']);
	$actif   = $db->XMFnum($row['actif']);
	$result2 = $db->sql_query("SELECT `artid` from `".TABLE_NSNSECTIONS_ARTICLES."` where `secid`='$secid'");
        $number  = $db->sql_numrows($result2);

echo     "<table width='100%'><td width='50%' valign='top'>";
Max_OpenTable();
echo     "<font class=\"option\"><b>" . _EDITSECTION . ": $secname</b></font>"
	."<br />(" . _SECTIONHAS . " $number " . _ARTICLESATTACH . ")"
	."<br /><br />";
if ($image) {
echo "<img src=\"images/sections/$image\" border=\"0\" alt=\"$secname\" title=\"$secname\" /><br /><br />";
} else {
echo "<I>"._NOIMAGE."</I><br /><br />";
}
echo "<form action=\"".$admin_file.".php\" method=\"post\">"
	."<b>" . _SECTIONNAME . "</b><br /><font class=\"tiny\">" . _40CHARSMAX . "</font><br />"
	."<input type=\"text\" name=\"secname\" size=\"40\" maxlength=\"40\" value=\"$secname\" /><br /><br />"
	."<b>" . _SECTIONIMG . "</b><br /><font class=\"tiny\">" . _SECIMGEXAMPLE . "</font><br />"
	."<input type=\"text\" name=\"image\" size=\"40\" maxlength=\"50\" value=\"$image\" /><br /><br />";
Max_CloseTable();

echo "</td><td width='50%' valign='top'>";
Max_opentable();
    $act1 = $act2 = "";
    if ($actif == 0) {
        $act1 = "selected";
    } elseif ($actif == 1) {
        $act2 = "selected";
	}

    echo "<table><td width='40%'>"._ACTIF."</td><td width='60%'><select name=\"actif\">";
    echo "<option value=\"0\" $act1>"._NO."</option>";
    echo "<option value=\"1\" $act2>"._YES."</option>";
    echo "</select></td></table>";


    $sel1 = $sel2 = $sel3 = $sel4 = $sel5 = "";
    if ($view == 0) {
        $sel1 = "selected";
    } elseif ($view == 1) {
        $sel2 = "selected";
    } elseif ($view == 2) {
        $sel3 = "selected";
    } elseif ($view == 3) {
        $sel4 = "selected";
    } elseif ($view > 3) {
        $sel5 = "selected";
    }
    echo "<table><td width='30%'>"._VIEWPRIV."</td><td width='70%'><select name=\"view\">";
    echo "<option value=\"0\" $sel1>"._VISITEURS."</option>";
    echo "<option value=\"1\" $sel2>"._USERSI."</option>";
    echo "<option value=\"2\" $sel3>"._ADMINI."</option>";
    echo "<option value=\"4\" $sel5>"._GROUPS."</option>";
    echo "</select></td></table>";
    echo "<table><td width='100%' ALIGN='LEFT'>"._WHATGRDESC."</td></table>";
    echo "<table><td width='30%' valign='top'>"._WHATGROUPS."</td><td width='70%'><select name='groups[]' multiple size='10'>\n";
    $ingroups = explode("-",$groups);
    $groupsResult = $db->sql_query("select gid, gname from ".TABLE_NSNGR_GROUPS."");
    while(list($gid, $gname) = $db->sql_fetchrow($groupsResult)) {
        if(in_array($gid,$ingroups)) { $sel = " selected"; } else { $sel = ""; }
        echo "<OPTION VALUE='$gid'$sel>$gname</option>";
    }
    echo "</select></td>";
    echo "</select></td></table>";
    Max_CloseTable();
    echo "</td></table>";

    Max_opentable();
echo "<input type=\"hidden\" name=\"secid\" value=\"$secid\" />"
	."<input type=\"hidden\" name=\"op\" value=\"sectionchange\">"
	."<center><input type=\"submit\" value=\"" . _SAVECHANGES . "\" /> [ <a href=\"".$admin_file.".php?op=sectiondelete&amp;secid=$secid&amp;ok=0\">" . _DELETE . "</a> ]</center>"
	."</form>";
    Max_CloseTable();
    incof();
}

function sectiondelete($secid, $ok=0) {
    global $db, $admin_file;
    $secid = $db->XMFnum($secid);
    if ($ok==1) {
        $db->sql_query("delete from `".TABLE_NSNSECTIONS_ARTICLES."` where `secid`='$secid'");
        $db->sql_query("delete from `".TABLE_NSNSECTIONS_RUBRIQUES."` where `secid`='$secid'");
        redirect_url("".$admin_file.".php?op=sections");
    } else {
        incoh();
        menusections();
	br('1');
    $row = $db->sql_fetchrow($db->sql_query("SELECT `secname` from `".TABLE_NSNSECTIONS_RUBRIQUES."` where `secid`='$secid'"));
	$secname = stripslashes($row['secname']);
	Max_OpenTable();
	echo "<center><b>" . _DELSECTION . ": $secname</b><br /><br />"
	    ."" . _DELSECWARNING . " $secname?<br />"
	    ."" . _DELSECWARNING1 . "<br /><br />"
	    ."[ <a href=\"".$admin_file.".php?op=sections\">" . _NO . "</a> | <a href=\"".$admin_file.".php?op=sectiondelete&amp;secid=$secid&amp;ok=1\">" . _YES . "</a> ]</center>";
	Max_CloseTable();
        incof();
    }
}
function secartdelete($artid, $ok=0) {
    global $db, $admin_file;
    $artid = $db->XMFnum($artid);
    if ($ok==1) {
        $db->sql_query("delete from `".TABLE_NSNSECTIONS_ARTICLES."` where `artid`='$artid'");
        redirect_url("".$admin_file.".php?op=sections");
    } else {
        incoh();
        menusections();
	br('1');
	$row = $db->sql_fetchrow($db->sql_query("SELECT `title` from `".TABLE_NSNSECTIONS_ARTICLES."` where `artid`='$artid'"));
	$title = stripslashes($row['title']);
	Max_OpenTable();
	echo "<center><b>" . _DELARTICLE . ": $title</b><br /><br />"
	    ."" . _DELARTWARNING . "<br /><br />"
	    ."[ <a href=\"".$admin_file.".php?op=sections\">" . _NO . "</a> | <a href=\"".$admin_file.".php?op=secartdelete&amp;artid=$artid&amp;ok=1\">" . _YES . "</a> ]</center>";
	Max_CloseTable();
        incof();
    }
}

if($admintest && $adminsecu)  {
switch ($op) {
default:
    case "sections":
    sections();
    break;

    case "ConfigSections":
    incoh();
    global $admin_file;
    $sections_config = sections_get_configs();
    menusections();
    ECHO "<br />";
    Max_OpenTable();
    $row = $db->sql_fetchrow($db->sql_query("select * from `".TABLE_NSNSECTIONS_CONFIG."`") );
    $title   = $sections_config['title'];
    $sstitle = $sections_config['sstitle'];
    $blockr  = $sections_config['blockr'];
    $nblect  = $sections_config['nblect'];
    $nbword  = $sections_config['nbword'];
    $fimp    = $sections_config['fimp'];
    $actsearch= $sections_config['actsearch'];
    $class    = $sections_config['class'];
    $nbart    = $sections_config['nbart'];
    $affvis   = $sections_config['affvis'];

echo "<center><table border='0' cellpadding='2' cellspacing='2'>"
."<form action=\"".$admin_file.".php\" method=\"post\">"
."<tr><td align='center' bgcolor='$bgcolor3' colspan='2' width='30%'>" . _TITLE . "</td><td width='70%'>"
."<input type=\"text\" name=\"xtitle\" value=\"$title\" size=\"50\" maxlength=\"50\" /></td></tr>"
."<tr><td align='center' bgcolor='$bgcolor3' colspan='2'>" . _SSTITLE . "</td><td>"
."<input type=\"text\" name=\"xsstitle\" value=\"$sstitle\" size=\"50\" maxlength=\"50\" /></td></tr>";

    if ($class == "time") {
	$sel1 = "selected";
	$sel2 = "";
	$sel3 = "";
	$sel4 = "";
	$sel5 = "";
	$sel6 = "";
    } elseif ($class == "time desc") {
	$sel1 = "";
	$sel2 = "selected";
	$sel3 = "";
	$sel4 = "";
	$sel5 = "";
	$sel6 = "";
    } elseif ($class == "title") {
	$sel1 = "";
	$sel2 = "";
	$sel3 = "selected";
	$sel4 = "";
	$sel5 = "";
	$sel6 = "";
    } elseif ($class == "title desc") {
	$sel1 = "";
	$sel2 = "";
	$sel3 = "";
	$sel4 = "selected";
	$sel5 = "";
	$sel6 = "";
    } elseif ($class == "counter") {
	$sel1 = "";
	$sel2 = "";
	$sel3 = "";
	$sel4 = "";
	$sel5 = "selected";
	$sel6 = "";
    } elseif ($class == "counter desc") {
	$sel1 = "";
	$sel2 = "";
	$sel3 = "";
	$sel4 = "";
	$sel5 = "";
	$sel6 = "selected";
    }
echo "<tr><td align='center' bgcolor='$bgcolor3' colspan='2'>"._ARTCLASS."</td><td><select name=\"xclass\">"
."<option name=\"xclass\" value=\"time\" $sel1>"._DATEASC."</option>"
."<option name=\"xclass\" value=\"time desc\" $sel2>"._DATEDESC."</option>"
."<option name=\"xclass\" value=\"title\" $sel3>"._TITLEASC."</option>"
."<option name=\"xclass\" value=\"title desc\" $sel4>"._TITLEDESC."</option>"
."<option name=\"xclass\" value=\"counter\" $sel5>"._COUNTERASC."</option>"
."<option name=\"xclass\" value=\"counter desc\" $sel6>"._COUNTERDESC."</option>"
."</select></td></tr>";

echo "<tr><td align='center' bgcolor='$bgcolor3' colspan='2'>" . _AFFBLOCKR . " </td><td>";
if ($blockr==0) { $ck1 = ""; $ck2 = " checked"; } else { $ck1 = " checked"; $ck2 = ""; }
echo "<input type='radio' name='xblockr' value='1'$ck1>"._YES." &nbsp;"
    ."<input type='radio' name='xblockr' value='0'$ck2>"._NO."</td></tr>";

echo "<tr><td align='center' bgcolor='$bgcolor3' colspan='2'>" . _AFFSEARCH . " </td><td>";
if ($actsearch==0) { $ck1 = ""; $ck2 = " checked"; } else { $ck1 = " checked"; $ck2 = ""; }
echo "<input type='radio' name='xactsearch' value='1'$ck1>"._YES." &nbsp;"
    ."<input type='radio' name='xactsearch' value='0'$ck2>"._NO."</td></tr>";

echo "<tr><td align='center' bgcolor='$bgcolor3' colspan='2'>" . _NBART . " </td><td>";
if ($nbart==0) { $ck1 = ""; $ck2 = " checked"; } else { $ck1 = " checked"; $ck2 = ""; }
echo "<input type='radio' name='xnbart' value='1'$ck1>"._YES." &nbsp;"
    ."<input type='radio' name='xnbart' value='0'$ck2>"._NO."</td></tr>";

echo "<tr><td align='center' bgcolor='$bgcolor3' colspan='2'>" . _AFFVIS . " </td><td>";
if ($affvis==0) { $ck1 = ""; $ck2 = " checked"; } else { $ck1 = " checked"; $ck2 = ""; }
echo "<input type='radio' name='xaffvis' value='1'$ck1>"._YES." &nbsp;"
    ."<input type='radio' name='xaffvis' value='0'$ck2>"._NO."</td></tr>";

echo "<tr><td align='center' bgcolor='$bgcolor3' colspan='2'>" . _NBLECT . " </td><td>";
if ($nblect==0) { $ck1 = ""; $ck2 = " checked"; } else { $ck1 = " checked"; $ck2 = ""; }
echo "<input type='radio' name='xnblect' value='1'$ck1>"._YES." &nbsp;"
    ."<input type='radio' name='xnblect' value='0'$ck2>"._NO."</td></tr>";

echo "<tr><td align='center' bgcolor='$bgcolor3' colspan='2'>" . _NBWORD . " </td><td>";
if ($nbword==0) { $ck1 = ""; $ck2 = " checked"; } else { $ck1 = " checked"; $ck2 = ""; }
echo "<input type='radio' name='xnbword' value='1'$ck1>"._YES." &nbsp;"
    ."<input type='radio' name='xnbword' value='0'$ck2>"._NO."</td></tr>";

echo "<tr><td align='center' bgcolor='$bgcolor3' colspan='2'>" . _FIMP . " </td><td>";
if ($fimp==0) { $ck1 = ""; $ck2 = " checked"; } else { $ck1 = " checked"; $ck2 = ""; }
echo "<input type='radio' name='xfimp' value='1'$ck1>"._YES." &nbsp;"
    ."<input type='radio' name='xfimp' value='0'$ck2>"._NO."</td></tr></table>";

echo "<br /><input type=\"hidden\" name=\"op\" value=\"SaveConfigSections\">"
	."<input type=\"submit\" value=\"" . _SAVECHANGES . "\"></form>"
    ."</center>";
    Max_CloseTable();
    incof();
    break;

    case "SaveConfigSections":
    global $admin_file;
    sections_save_config('title', $xtitle);
    sections_save_config('sstitle', $xsstitle);
    sections_save_config('blockr', $xblockr);
    sections_save_config('nblect', $xnblect);
    sections_save_config('nbword', $xnbword);
    sections_save_config('fimp', $xfimp);
    sections_save_config('actsearch', $xactsearch);
    sections_save_config('class', $xclass);
    sections_save_config('nbart', $xnbart);
    sections_save_config('affvis', $xaffvis);
    redirect_url("".$admin_file.".php?op=ConfigSections");
    break;

    case "ajoutarticle":
    ajoutarticle();
    break;

    case "ajoutrubrique":
    ajoutrubrique();
    break;

    case "lesarticles":
    lesarticles();
    break;

    case "sectionedit":
    sectionedit($secid);
    break;

    case "sectionmake":
    global $admin_file;
    $secname = stripslashes(FixQuotes($secname));
    $image = stripslashes(FixQuotes($image));
    $view = $db->XMFnum($row['view']);
    $groups = $db->XMFnum($row['groups']);
    $actif = $db->XMFnum($actif);
    $ingroups = implode("-",$groups);
    if($view < 4) { $ingroups = ""; }
    $db->sql_query("INSERT INTO `".TABLE_NSNSECTIONS_RUBRIQUES."` VALUES (NULL,'$secname', '$image','$view','$ingroups','$actif')");
    redirect_url("".$admin_file.".php?op=sections");
    break;

    case "sectiondelete":
    sectiondelete($secid, $ok);
    break;

    case "sectionchange":
    global $admin_file;
    $secname = stripslashes(FixQuotes($secname));
    $image = stripslashes(FixQuotes($image));
    $secid = $db->XMFnum($secid);
    $view = $db->XMFnum($view);
    $groups = $db->XMFnum($groups);
    $ingroups = implode("-",$groups);
    $actif = $db->XMFnum($actif);
    if($view < 4) { $ingroups = ""; }
    $db->sql_query("update `".TABLE_NSNSECTIONS_RUBRIQUES."` set `secname`='$secname', `image`='$image', `view`='$view', `groups`='$ingroups', `actif`='$actif' where `secid`='$secid'");
    redirect_url("".$admin_file.".php?op=sections");
    break;

    case "secarticleadd":
    global $admin_file;
    $ingroups = implode("-",$groups);
    if($view < 4) { $ingroups = ""; }
    $title = stripslashes(FixQuotes($title));
    $content = stripslashes(FixQuotes($content));
    $slanguage = stripslashes(FixQuotes($slanguage));
    $secid = $db->XMFnum($secid);
    $actif = $db->XMFnum($actif);
    $db->sql_query("INSERT INTO `".TABLE_NSNSECTIONS_ARTICLES."` VALUES (NULL,'$secid','$title','$content','0','$slanguage',now(),'$view','$ingroups','$actif')");
    redirect_url("".$admin_file.".php?op=lesarticles");
    break;

    case "secartedit":
    secartedit($artid);
    break;

    case "secartchange":
    global $admin_file;
    $title = stripslashes(FixQuotes($title));
    $content = stripslashes(FixQuotes($content));
    $secid = $db->XMFnum($secid);
    $view = $db->XMFnum($view);
    $groups = $db->XMFnum($groups);
    $actif = $db->XMFnum($actif);
    $ingroups = implode("-",$groups);
    if($view < 4) { $ingroups = ""; }
    $db->sql_query("update `".TABLE_NSNSECTIONS_ARTICLES."` set `secid`='$secid', `title`='$title', `content`='$content', `slanguage`='$slanguage', `view`='$view', `groups`='$ingroups', `actif`='$actif' where `artid`='$artid'");
    redirect_url("".$admin_file.".php?op=lesarticles");
    break;

    case "secartdelete":
    secartdelete($artid, $ok);
    break;
}
}