<?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                          */
/********************************************************/
defined('MAXIMUS') or Header("Location: index.php");

    $sections_config = sections_get_configs();
    $blockr = $sections_config['blockr'];
    $nblect = $sections_config['nblect'];
    $nbword = $sections_config['nbword'];
    $fimp = $sections_config['fimp'];
    $afftime = $sections_config['afftime'];
    
    $index = $blockr; 
    incoh();
    global $module_name;
    menu();
    
    
    $artid = $GLOBALS['db']->XMFnum($artid);
    if (($page == 1) OR ($page == "")) {
	$GLOBALS['db']->sql_query("UPDATE `".TABLE_NSNSECTIONS_ARTICLES."` SET `counter`=counter+1 WHERE `artid`='$artid'");
    }
    $row = $GLOBALS['db']->sql_fetchrow($GLOBALS['db']->sql_query("SELECT `artid`, `secid`, `title`, `content`, `counter`, `time` FROM `".TABLE_NSNSECTIONS_ARTICLES."` WHERE `artid`='$artid' AND `actif`='1' "));
        $artid   = $GLOBALS['db']->XMFnum($row['artid']);
        $secid   = $GLOBALS['db']->XMFnum($row['secid']);
        $title   = stripslashes($row['title']);
        $content = stripslashes($row['content']);
        $counter = $GLOBALS['db']->XMFnum($row['counter']);
	$time    = $row['time'];
	$time    = formatTimestamp($time);
    $row2 = $GLOBALS['db']->sql_fetchrow($GLOBALS['db']->sql_query("SELECT `secid`, `secname` FROM `".TABLE_NSNSECTIONS_RUBRIQUES."` WHERE `secid`='$secid'"));
        $secid   = $GLOBALS['db']->XMFnum($row2['secid']);
        $secname = stripslashes($row2['secname']);
        $words   = sizeof(explode(" ", $content));
    echo "<center>";
    Max_OpenTable();
    $contentpages = explode( "<!--pagebreak-->", $content );
    $pageno = count($contentpages);
    if ( $page=="" || $page < 1 )
	$page = 1;
    if ( $page > $pageno )
	$page = $pageno;
    $arrayelement = (int)$page;
    $arrayelement --;
    echo "<font class=\"option\"><b>$title</b></font><br /><br /><font class=\"content\">";
    if ($afftime) {
	echo "<i>"._WRITE." $time </i><br />";
	}
    if ($pageno > 1) {
	echo ""._PAGE.": $page/$pageno<br />";
    }
    if ($nbword) {
    echo "($words "._TOTALWORDS.")<br />";
    }
    if ($nblect) {
    echo "($counter "._READS.") &nbsp;&nbsp;";
    }
    if ($fimp) {
    echo "<a href=\"modules.php?name=$module_name&amp;op=printpage&amp;artid=$artid\" target='new'> "._SC_IMPRIM." <img src=\"modules/Sections/images/print.png\" border=\"0\" Alt=\""._PRINTER."\" ></a>";
    }
    
    echo "</font>";
    br('4');
    echo "$contentpages[$arrayelement]";

    if($page >= $pageno) {
	  $next_page = "";
    } else {
	$next_pagenumber = $page + 1;
	if ($page != 1) {
	    $next_page .= "<img src=\"images/blackpixel.gif\" width=\"10\" height=\"2\" border=\"0\" alt=\"\"> &nbsp;&nbsp; ";
	}
	$next_page .= "<a href=\"modules.php?name=$module_name&amp;op=viewarticle&amp;artid=$artid&amp;page=$next_pagenumber\">"._NEXT." ($next_pagenumber/$pageno)</a> <a href=\"modules.php?name=$module_name&amp;op=viewarticle&amp;artid=$artid&amp;page=$next_pagenumber\"><img src=\"images/right.gif\" border=\"0\" alt=\""._NEXT."\"></a>";
    }
    if($page <= 1) {
	$previous_page = "";
    } else {
	$previous_pagenumber = $page - 1;
	$previous_page = "<a href=\"modules.php?name=$module_name&amp;op=viewarticle&amp;artid=$artid&amp;page=$previous_pagenumber\"><img src=\"images/left.gif\" border=\"0\" alt=\""._PREVIOUS."\"></a> <a href=\"modules.php?name=$module_name&amp;op=viewarticle&amp;artid=$artid&amp;page=$previous_pagenumber\">"._PREVIOUS." ($previous_pagenumber/$pageno)</a>";
    }
    echo "<center>"
	."$previous_page &nbsp;&nbsp; $next_page<br /><br />"
	."[ <a href=\"modules.php?name=$module_name&amp;op=listarticles&amp;secid=$secid\">"._BACKTO." $secname</a> | "
	."<a href=\"modules.php?name=$module_name\">"._SECINDEX."</a> ]";
    Max_CloseTable();
    echo "</center>";
    incof();