<?php
defined('MAXIMUS') or Header("Location: index.php");

    $sections_config = sections_get_configs();
    $blockr = $sections_config['blockr'];
    $actsearch = $sections_config['actsearch'];
    
    
    if (!$actsearch) {  Header("Location: modules.php?name=Sections"); }
    $index = $blockr; 

        $query     = addslashes($query);
        $the_query = stripslashes($query);
        $the_query = str_replace("\'", "'", $the_query);
	
        incoh();
        menu();
        if ($query != "") {
            title(_SEARCHRESULTS.": $the_query");
            Max_OpenTable();
            echo "<table width='100%' bgcolor='$bgcolor2'><tr><td align='center'><font class='storytitle'><b>"._SRUBRIQUE."</b></font></td></tr></table>";
            $crows  = $GLOBALS['db']->sql_numrows($GLOBALS['db']->sql_query("SELECT * FROM `".TABLE_NSNSECTIONS_RUBRIQUES."` WHERE `secname` LIKE '%$query%' AND `actif`>'0' ORDER BY `secname` DESC"));
            if ($crows > 0) {
                $result2 = $GLOBALS['db']->sql_query("SELECT * FROM `".TABLE_NSNSECTIONS_RUBRIQUES."` WHERE `secname` LIKE '%$query%' ORDER BY secname DESC");
                while($cidinfo2 = $GLOBALS['db']->sql_fetchrow($result2)) {
            $numrows = $GLOBALS['db']->sql_numrows($GLOBALS['db']->sql_query("SELECT * FROM `".TABLE_NSNSECTIONS_RUBRIQUES."` WHERE `secid`='".$cidinfo2['secid']."'"));
            $cidinfo3 = $GLOBALS['db']->sql_fetchrow($GLOBALS['db']->sql_query("SELECT * FROM `".TABLE_NSNSECTIONS_RUBRIQUES."` WHERE `secid`='".$cidinfo2['secid']."'"));
                     $cidinfo3['secname'] = ereg_replace($query, "<b>$query</b>", $cidinfo3['secname']);
echo "<strong><big>·</big></strong>&nbsp;<a href='modules.php?name=$module_name&amp;op=listarticles&amp;secid=".$cidinfo2['secid']."'>".$cidinfo3['secname']."</a> ($numrows)<br />";
                }
            } else {
                echo "<center><font class='option'><b>"._NOMATCHES."</b></font><br /><br /></center>";
            }
            Max_CloseTable();
            echo"<br />\n";
            Max_OpenTable();
               echo "<table width='100%' bgcolor='$bgcolor2'><tr><td align='center'><font class='storytitle'><b>"._SARTICLE."</b></font></td></tr></table>";
            $crows  = $GLOBALS['db']->sql_numrows($GLOBALS['db']->sql_query("SELECT * FROM ".TABLE_NSNSECTIONS_ARTICLES." WHERE (title LIKE '%$query%' OR content LIKE '%$query%') AND actif>'0' ORDER BY title DESC"));
            if ($crows > 0) {
                $result2 = $GLOBALS['db']->sql_query("SELECT * FROM `".TABLE_NSNSECTIONS_ARTICLES."` WHERE (`title` LIKE '%$query%' OR `content` LIKE '%$query%') ORDER BY `title` DESC");
                while($cidinfo2 = $GLOBALS['db']->sql_fetchrow($result2)) {
            $numrows = $GLOBALS['db']->sql_numrows($GLOBALS['db']->sql_query("SELECT * FROM `".TABLE_NSNSECTIONS_ARTICLES."` WHERE `artid`='".$cidinfo2['artid']."'"));
            $cidinfo3 = $GLOBALS['db']->sql_fetchrow($GLOBALS['db']->sql_query("SELECT * FROM `".TABLE_NSNSECTIONS_ARTICLES."` WHERE `artid`='".$cidinfo2['artid']."'"));
                    $cidinfo3['title'] = ereg_replace($query, "<b>$query</b>", $cidinfo3['title']);
		    $cidinfo3['content'] = ereg_replace($query, "<b>$query</b>", $cidinfo3['content']);
echo "<strong><big>·</big></strong>&nbsp;"._TITLE.":&nbsp;<a href='modules.php?name=$module_name&amp;op=viewarticle&amp;artid=".$cidinfo2['artid']."'> ".$cidinfo3['title']."</a> ($numrows)<br />";
 echo "<strong><big>·</big></strong>&nbsp;"._CONTENT.":&nbsp;<a href='modules.php?name=$module_name&amp;op=viewarticle&amp;artid=".$cidinfo2['artid']."'> ".$cidinfo3['content']."</a> ($numrows)<br />";
                }
            } else {
                echo "<center><font class='option'><b>"._NOMATCHES."</b></font></center><br /><br />";
            }
        }
	elseif ($query == "") {
	Max_OpenTable();
	echo "<center><font class='option'><b>"._NOQUERY."</b></font></center><br />";
	}
        Max_CloseTable();
        incof();