View file faqman/admin.php

File size: 8.75Kb
<html>
<head>
<script language="JavaScript">
<!--hide
function Popupcat(sWin){
	sEditcat=prompt('Enter new category name',' ');
	if (sEditcat)
	window.location= sWin + sEditcat;
}
function GP_popupConfirmMsg(msg) { 
  document.MM_returnValue = confirm(msg);
}
//-->
</script> 
<title>FAQ Admin</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head> 
<body bgcolor="#FFFFFF" text="#000000">
<?

// EDIT THE LINE BELOW TO POINT TO THE LOCATION OF cfaq.php
require("cFaq.php");

$faq = new cFaq;
if($sAction=="sEcat"){
	$faq->Getdata();
	$aCats = $faq->Getcats();
	$iTick = 0;
	$oFile = fopen($faq->sPath . $faq->sCat,"w");
	while (list($sKey, $sValue) = each($faq->aCat)){
		$sCat = $sValue;
		$sFile = $faq->sFilename[$iTick];
		if($sCid == $iTick){
			$sCat = $sEditcat;
		}
		if($sCat && $sFile){
			$sPuts = "$sCat||$sFile";
			fputs($oFile, "$sPuts");
		}
		$iTick += 1;
	}
	fclose($oFile);
	
}
elseif($sAction=="addqa"){
	if($sQ && $sA){
		$faq->Getdata();
		$oFile = fopen($faq->sPath . trim($faq->sFilename[$sAddqa]),"a");
		fputs($oFile, "$sQ||$sA\n");
		fclose($oFile);
	}
}
elseif($sAction=="AddCat"){
	$faq->AdminAddCat($sCat, $sFile);
}
elseif($sAction=="DelQ"){
	$faq->Getdata();
	$iTickqa = 0;
	reset($faq->aQa);
	$sFile = trim($faq->sFilename[$sId1]);
	$oFile = fopen($faq->sPath . $sFile,"w");
	while (list($sKey, $sValue) = each($faq->aQa[$sId1])){
		if($iTickqa != $sId2){
			$sPuts = "$sKey||$sValue";
			fputs($oFile, $sPuts . "\n");
		}
		$iTickqa += 1;
	}
	fclose($oFile);
}
elseif($sAction == "Doedit"){
	$faq->Getdata();
	$iTickqa = 0;
	reset($faq->aQa);
	$sFile = trim($faq->sFilename[$sId1]);
	$oFile = fopen($faq->sPath . $sFile,"w");
	while (list($sKey, $sValue) = each($faq->aQa[$sId1])){
		// print "$sKey , $sValue <br>";
		if($iTickqa == $sId2){
			$sPuts = "$sQ||$sA";
		}
		else{
			$sPuts = "$sKey||$sValue";
		}
		fputs($oFile, $sPuts . "\n");
		$iTickqa += 1;
	}
	fclose($oFile);
}
elseif($sAction == "EditQ"){
	$faq->Getdata();
?>

<table cellspacing=1 cellpadding=4 width="100%">
  <tr> 
    <td bgcolor="#FFCC66" height="7"><font face="arial,helvetica" size="-1"><b>Edit Question</b></font></td>
  </tr>
  <tr> 
    <td bgcolor=white height="22"> 
      <?
$iTick = 0;
$iTickqa = 0;
reset($faq->aQa);
$sFile = trim($faq->sFilename[$sId1]);
$oFile = fopen($faq->sPath . $sFile,"r");
while (list($sKey, $sValue) = each($faq->aQa[$sId1])){
	if($iTickqa == $sId2){
		$sQ = $sKey;
		$sA = $sValue;
	}
	$iTickqa += 1;
}
?>
      <form name="form1" method="post" action="">
        <input type="text" name="sQ" value="<? echo $sQ; ?>">
        <input type="text" name="sA" value="<? echo $sA; ?>">
        <input type="hidden" name="sId1" value="<? echo $sId1; ?>">
        <input type="hidden" name="sId2" value="<? echo $sId2; ?>">
        <input type="hidden" name="sAction" value="Doedit">
        <input type="submit" name="Submit" value="Submit">
      </form>
    
  </tr>
</table>
<?
	exit;
}
	
$faq->Getdata();

?>
<table width="100%" border="0">
  <tr> 
    <td width="78%" height="398"> 
      <table cellspacing=0 cellpadding=0 border=0 width="100%">
        <tr bgcolor="#FFCC66"> 
          <td valign=top height="2"> 
            <table cellpadding=0 cellspacing=0 border=0 width="100%">
              <tr> 
                <td bgcolor="#999999"> 
                  <table cellspacing=1 cellpadding=4 width="100%">
                    <tr> 
                      <td bgcolor=white height="2"> 
                        <p> 
                          <? echo $message ; ?>
                      </td>
                    </tr>
                    <tr> 
                      <td bgcolor="#FFCC66" height="7"><font face="arial,helvetica" size="-1"><b>Categories</b></font></td>
                    </tr>
                    <tr> 
                      <td bgcolor=white height="22"> 
                        <?
$aCats = $faq->Getcats();
$iTick = 0;
while (list($sKey, $sValue) = each($faq->aCat)){
	if($sValue){
		print "$sValue&nbsp;&nbsp;&nbsp;\n";
		print "<a href=\"$PHP_SELF?sAction=sEcat&sCid=$iTick&sEditcat=\"><img src=\"del.gif\" border=\"0\" onClick=\"GP_popupConfirmMsg('Delete this category?');return document.MM_returnValue\"></a>\n";
		print "<a href=\"#\"><img src=\"edit.gif\" border=\"0\" onClick=\"Popupcat('$PHP_SELF?sAction=sEcat&sCid=$iTick&sEditcat=');\"></a><br>\n";
		print "<font size=\"-1\">Filename: <i>" . $faq->sFilename[$iTick] . "</i></font><br><br>\n";
	}
		$iTick += 1;
}
?>
                    </tr>
                    <tr> 
                      <td bgcolor=white  height="2"><strong>Add Question &amp; 
                        Answer</strong><br>
                        <hr>
                        <form name="addqa" method="post" action="<? echo $PHP_SELF; ?>">
                          Category:<br>
                          <select name="sAddqa">
                            <?

$iTick= 0;
reset($faq->aCat);
// $faq->Getdata();
while (list($sKey, $sValue) = each($faq->aCat)){
	if($sValue){
		print "<option value=\"$iTick\">$sValue</option>\n";
	}
	$iTick += 1;
}
?>
                          </select>
                          <br>
                          Question:<br>
                          <input type="text" name="sQ" size="40" maxlength="255">
                          <br>
                          Answer: <br>
                          <input type="text" name="sA" size="40">
                          <input type="hidden" name="sAction" value="addqa">
                          <input type="image" border="0" name="imageField2" src="add.gif" width="39" height="18">
                          <br>
                          <br>
                          Choose a Category, Type in your question and answer 
                          then click ADD to add the question to that category. 
                        </form>
                      </td>
                    </tr>
                    <tr> 
                      <td bgcolor=white  height="2"><strong>Add Category</strong><br>
                        <hr>
                        <form name="addcat" method="post" action="<? echo $PHP_SELF; ?>">
                          Category Name 
                          <input type="text" name="sCat">
                          Filename 
                          <input type="text" name="sFile">
                          <input type="hidden" name="sAction" value="AddCat">
                          <input type="image" border="0" name="imageField" src="add.gif" width="39" height="18">
                          <br>
                          <br>
                          Type in a category name, it can be anything, then type 
                          in the filename you wish to use to store this categories 
                          questions and answers. 
                        </form>
                      </td>
                    </tr>
                    <!-- End search word summary. -->
                  </table>
                </td>
              </tr>
            </table>
      </table>
    </td>
  </tr>
  <tr> 
    <td width="78%" height="2"> 
      <table cellspacing=0 cellpadding=0 border=0 width="100%">
        <tr bgcolor="#FFCC66"> 
          <td valign=top height="33"> 
            <table cellpadding=0 cellspacing=0 border=0 width="100%">
              <tr> 
                <td bgcolor="#999999" height="2"> 
                  <table cellspacing=1 cellpadding=4 width="100%">
                    <tr> 
                      <td bgcolor="#FFCC66" height="7"><font face="arial,helvetica" size="-1"><b>Questions</b></font></td>
                    </tr>
                    <tr> 
                      <td bgcolor=white height="22"> 
                        <?
		$iTick = 0;
		$iTickqa = 0;
		reset($faq->aQa);
		while (list($sKey, $sValue) = each($faq->aQa)){
			if($sValue){
				print $faq->aCat[$iTick] . "<br>";
				print "<OL type=\"1\">";
				$iTickqa = 0;
				while (list($sKey2, $sValue2) = each($sValue)){
					print "<LI>";
					print "<b>$sKey2</b>";
					print "<br>$sValue2<br>";
					print "<a href=\"$PHP_SELF?sAction=EditQ&sId1=$iTick&sId2=$iTickqa\"><img src=\"edit.gif\" border=\"0\"></a>";
					print "<a href=\"$PHP_SELF?sAction=DelQ&sId1=$iTick&sId2=$iTickqa\"><img src=\"del.gif\" border=\"0\" onClick=\"GP_popupConfirmMsg('Delete this question?');return document.MM_returnValue\"></a>";
					$iTickqa += 1;
				}
				print "</OL>";
			}
			$iTick += 1;
		}
		
?>
                    </tr>
                    <!-- End search word summary. -->
                  </table>
                </td>
              </tr>
            </table>
      </table>
    </td>
  </tr>
</table>
</body>
</html>