<?php

if ( ! @include_once( './mainfile.php' ) ) { exit( '!! INCLUDE ERROR. ACCESS DENIED !!' ); }
error_reporting( _E_VALUE );


/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
// | myPHPNuke Version 188_8 RC2                                          |
// +----------------------------------------------------------------------+
// | License: GNU/GPL - http://www.gnu.org/copyleft/gpl.html              |
// +----------------------------------------------------------------------+
// | Support: http://myphpnuke.com/                                       |
// +----------------------------------------------------------------------+
// | Author: myPHPNuke Dev Team                                           |
// +----------------------------------------------------------------------+
// | Copyright: © 2001-2004 myPHPNuke Dev Team                            |
// +----------------------------------------------------------------------+
// $Id: faq.php,v 1.8.2.2 2004/04/18 12:45:42 ajvwaay Exp $

$extStyle = 4;
$id_cat = ( ! isset( $_REQUEST['id_cat'] ) ) ? ( NULL ) : ( $_REQUEST['id_cat'] );

include './header.php';

echo '<div id="faqs">' . "\n";

    echo "<h1 id='top'>" . translate ( 'FAQs ' ) . "</h1>\n";
    echo "<b>&#040; <i>" . translate ( 'Frequently Asked Questions' ) . "</i> &#041;</b>\n";
    echo "<br /><br />\n";
    nav( $id_cat );

    if ( ! isset( $_REQUEST['show'] ) )
    {
        echo "<h2 class='tabletitles t-left'>" . translate ( 'Categories' ) . "</h2>\n";

        echo "<hr class='w80 t-left' /><br />\n";

        echo '<ul class="indent15">' . "\n";

        $result = mysql_query("select id_cat, categories from ".$mpnTables['faqcategories']);

        while( list( $id_cat, $categories ) = mysql_fetch_row( $result ) )
        {
            $res = mysql_query( "SELECT count( id_cat ) FROM " . $mpnTables['faqanswer'] . " WHERE id_cat = '$id_cat'" );

            list( $cnt ) = mysql_fetch_row( $res );

            mysql_free_result( $res );

            $wrd = ( $cnt > 1 || $cnt == 0 ) ? ( translate( 'FAQs' ) ) : ( translate( 'FAQ' ) );

            echo"<li><a class='subtitle1' href=\"./faq.php?show=1&id_cat=$id_cat\">$categories</a>  ( $cnt $wrd )</li>";
        }

        echo '</ul>' . "\n";

        mysql_free_result( $result );
    }
    else
    {
        ShowFaqs( $id_cat );
    }

echo '</div>' . "\n";

include './footer.php';


// FUNCTIONS


function nav( $id_cat )
{
    global $mpnTables;

    if ( empty( $id_cat ) ) { return; }

    $result = mysql_query( "SELECT categories FROM " . $mpnTables['faqcategories'] . " WHERE id_cat = '$id_cat'" );

    list( $categories ) = mysql_fetch_row( $result );

    echo "<div class='subtitle1'>\n";

        echo translate( 'Category:' ) . ' <a href="./faq.php">' . translate("Main") . "</a> &gt;&gt; " . $categories;

    echo "</div>\n";

    echo "<br /><br ><hr class='w80' /><br />\n";
}


function ShowFaqs( $id_cat )
{
    global $bgcolor2, $sitename, $mpnTables;

    $result = mysql_query( "SELECT id, id_cat, question, answer FROM ".$mpnTables['faqanswer']." WHERE id_cat = '$id_cat' ORDER BY id" );

    $cnt = mysql_num_rows( $result );

    if ( $cnt == 0 )
    {
        echo "<h2>" . translate ( 'No FAQ\'s Found In This Category' ) . "</h2>\n";
    }
    else
    {
        while( list( $id, $id_cat, $question, $answer ) = mysql_fetch_row( $result ) )
        {
            $_SERVER['SAN'] -> adjustFormat( $answer, 3, 10 );

            echo "<p id='$id' class='tabletitles'>" . translate ( 'Question' ) . "</p>\n";

            echo "<div class='indent15'>\n";

                echo $question;

            echo "</div>\n";

           echo "<p class='tabletitles'>" . translate ( 'Answer' ) . "</p>\n";

            echo "<div class='indent15'>\n";

                echo $answer;

                echo "<br /><br />\n";

                echo "&#091; <a href=\"#$id\">" .translate( "Back to Question" )."</a> &#093;\n";

                echo "&nbsp;&nbsp;\n";

                echo "&#091; <a href=\"#top\">" .translate( "Top" )."</a> &#093;\n";

            echo "</div>\n";

            echo "<br /><hr class='w80 t-left' /><br />\n";
        }
    }

    echo "<br /><br />\n";

    echo "<div class='center'>\n";

        echo "<b>&#091; <a href=\"./faq.php\">" .translate("Back to FAQ Index")."</a> &#093;</b>\n";

    echo "</div>";
}

?>
