<?php
/*
 ########################################################################
#                                                                        #
#           Version 4       /                        /   /               #
#          -----------__---/__---__------__----__---/---/-               #
#           | /| /  /___) /   ) (_ `   /   ) /___) /   /                 #
#          _|/_|/__(___ _(___/_(__)___/___/_(___ _/___/___               #
#                       Free Content / Management System                 #
#                                   /                                    #
#                                                                        #
#                                                                        #
#   Copyright 2005-2006 by webspell.org                                  #
#                                                                        #
#   visit webSPELL.org, webspell.info to get webSPELL for free           #
#   - Script runs under the GNU GENERAL PUBLIC LICENSE                   #
#   - It's NOT allowed to remove this copyright-tag                      #
#   -- http://www.fsf.org/licensing/licenses/gpl.html                    #
#                                                                        #
#   Code based on WebSPELL Clanpackage (Michael Gruber - webspell.at),   #
#   Far Development by Development Team - webspell.org                   #
#                                                                        #
#   visit webspell.org                                                   #
#                                                                        #
 ########################################################################
*/

eval ("\$title_faq = \"".gettemplate("title_faq")."\";");
echo $title_faq;

if($_GET['action']=="faqcat") {
	if(ispageadmin($userID)) echo'<input type="button" class="button" onClick="MM_openBrWindow(\'admin/admincenter.php?site=faq\',\'News\',\'toolbar=yes,status=yes,scrollbars=yes,resizable=yes,width=800,height=600\')" value="FAQ Administration"><br><br>';

  $faqcatID=$_GET['faqcatID'];
  $faqID=$_GET['faqID'];

  $faqcat=safe_query("SELECT question,faqID,sort FROM ".PREFIX."faq WHERE faqcatID='$faqcatID' ORDER BY sort");
  if(mysql_num_rows($faqcat)) {
    eval ("\$faq_question_head = \"".gettemplate("faq_question_head")."\";");
      echo $faq_question_head;
      $i=1;
	  while($ds=mysql_fetch_array($faqcat)){
      if($i%2) {
        $bg1=BG_1;
        $bg2=BG_2;
        }
        else {
        $bg1=BG_3;
        $bg2=BG_4;
        }
        $i++;

      $sort=$ds[sort];
      $question='<a href="index.php?site=faq&action=faq&faqID='.$ds[faqID].'">'.$ds[question].'</a>';

		  eval ("\$faq_question = \"".gettemplate("faq_question")."\";");
        echo $faq_question;
		  }
	  eval ("\$faq_foot = \"".gettemplate("faq_foot")."\";");
      echo $faq_foot;
	}
  else echo 'no faq available.<br><br>
             [ <a href="index.php?site=faq">go back</a> ]';
}

elseif($_GET['action']=="faq") {
	if(ispageadmin($userID)) echo'<input type="button" class="button" onClick="MM_openBrWindow(\'admin/admincenter.php?site=faq\',\'News\',\'toolbar=yes,status=yes,scrollbars=yes,resizable=yes,width=800,height=600\')" value="FAQ Administration"><br><br>';

  $faqcatID=$_GET['faqcatID'];
  $faqID=$_GET['faqID'];

  $cat=safe_query("SELECT faqcatID FROM ".PREFIX."faq WHERE faqID='$faqID'");
    if(mysql_num_rows($cat)) {
      while($da=mysql_fetch_array($cat)) {
        $backlink='<a href="index.php?site=faq&action=faqcat&faqcatID='.$da[faqcatID].'">Questions</a>';
      }
    }

  $faq=safe_query("SELECT faqcatID,question,answer FROM ".PREFIX."faq WHERE faqID='$faqID'");
  	if(mysql_num_rows($faq)) {
      eval ("\$faq_answer_head = \"".gettemplate("faq_answer_head")."\";");
        echo $faq_answer_head;
	    while($ds=mysql_fetch_array($faq)){

      $bg1=BG_1;
      $answer=htmloutput($ds[answer]);
      $question=$ds[question];

		  eval ("\$faq_answer = \"".gettemplate("faq_answer")."\";");
        echo $faq_answer;
		  }
		eval ("\$faq_foot = \"".gettemplate("faq_foot")."\";");
      echo $faq_foot;
	}
  else echo 'no faq available.<br><br>
             [ <a href="index.php?site=faq">go back</a> ]';
}

else {
	if(ispageadmin($userID)) echo'<input type="button" class="button" onClick="MM_openBrWindow(\'admin/admincenter.php?site=faq\',\'News\',\'toolbar=yes,status=yes,scrollbars=yes,resizable=yes,width=800,height=600\')" value="FAQ Administration"><br><br>';

  $faqcats=safe_query("SELECT * FROM ".PREFIX."faq_categories ORDER BY sort");
    if(mysql_num_rows($faqcats)) {
      $anzcats=mysql_num_rows(safe_query("SELECT faqcatID FROM ".PREFIX."faq_categories"));
      eval ("\$faq_category_head = \"".gettemplate("faq_category_head")."\";");
        echo $faq_category_head;
        $i=1;
      while($ds=mysql_fetch_array($faqcats)) {
        $anzfaqs=mysql_num_rows(safe_query("SELECT faqID FROM ".PREFIX."faq WHERE faqcatID='".$ds[faqcatID]."'"));
        if($i%2) {
				  $bg1=BG_1;
          $bg2=BG_2;
				}
        else {
          $bg1=BG_3;
          $bg2=BG_4;
        }
        $faqcatname='&#8226; <a href="index.php?site=faq&action=faqcat&faqcatID='.$ds[faqcatID].'"><b>'.$ds[faqcatname].'</b></a>';
        $description=cleartext($ds[description]);

      eval ("\$faq_category = \"".gettemplate("faq_category")."\";");
        echo $faq_category;
        $i++;
      }
    eval ("\$faq_foot = \"".gettemplate("faq_foot")."\";");
      echo $faq_foot;
    }
  else echo 'no categories available.';
}
?>