Размер файла: 3.88Kb
<?
/*[ Name: cFaq.php ] */
/*[ Author: Steve Hamilton ] */
/*[ WWW: http://www.phphelper.net/ ] /*
/*[ Version: 1.0 ] */
/*[ Created: 09/15/2001 ] */
/*
cFaq.php - Version 1.0
Copyright 2001 phphelper.net & Steve Hamilton [email protected]
Created 09/15/2001 Last Modified 09/15/01
COPYRIGHT NOTICE
Copyright 2001 Script-house.com & Steve Hamilton - All Rights Reserved.
http://www.phphelper.net/
Selling the code for this program, modifying or redistributing
this software in whole in in part over the Internet or in any
other medium is forbidden. Copyright and header may not be modified.
*/
/*[ Class: cFaq : START ] */
class cFaq {
var $sPath = ""; // Path to data files
var $sCat = "cat.dat"; // category file name
var $aCats = array();
var $aCat = array();
var $sFilename = array();
/*[ Function: Getcats : START ] */
function Getcats(){
if (file_exists($this->sPath . $this->sCat)) {
$oFile = fopen($this->sPath . $this->sCat,"r");
while (!feof ($oFile)) {
$this->aCats[$iTick] = fgets($oFile, 4096);
$iTick += 1;
}
fclose ($oFile);
return($this->aCats);
}
}
/*[ Function: Getcats : END ] */
/*[ Function: Getqa : START ] */
function Getqa($sFilename){
if(!$sFilename){
return;
}
if (file_exists($this->sPath . $sFilename)) {
$oFile = fopen($this->sPath . $sFilename,"r");
while (!feof ($oFile)) {
$sQa = fgets($oFile, 4096);
list($sQ, $sA) = explode("||", $sQa);
if($sQ && $sA){
$aQareturn[$sQ] = $sA;
}
}
fclose ($oFile);
}
return($aQareturn);
}
/*[ Function: Getqa : END ] */
/*[ Function: Getdata : START ] */
function Getdata(){
set_magic_quotes_runtime(0);
unset($this->aCats);
unset($this->aCat);
unset($this->sFilename);
unset($this->aQa);
$this->Getcats();
$iTick = 0;
while (list($sKey, $sValue) = each($this->aCats)){
list($this->aCat[], $this->sFilename[]) = explode("||", $sValue);
$this->aQa[$iTick] = $this->Getqa(trim($this->sFilename[$iTick]));
$iTick += 1;
}
}
/*[ Function: Getdata : END ] */
/*[ Function: DisplayQ : START ] */
function DisplayQ(){
reset($this->aQa);
$iTick = 0;
print "<a name=\"Cat_Top\"></a>";
while (list($sKey, $sValue) = each($this->aQa)){
print "<b>" . $this->aCat[$iTick] . "</b><br>";
if($sValue){
print "<OL type=\"1\">";
while (list($sKey2, $sValue2) = each($sValue)){
print "<LI><a href=\"#Cat$iTickqa\">$sKey2</a><br>";
$iTickqa += 1;
}
print "</OL>";
}
$iTick += 1;
}
}
/*[ Function: displayQ : END ] */
/*[ Function: DisplayA : START ] */
function DisplayA(){
$iTick = 0;
$iTickqa = 0;
reset($this->aQa);
while (list($sKey, $sValue) = each($this->aQa)){
if($sValue){
print $this->aCat[$iTick] . "<br>";
print "<OL type=\"1\">";
while (list($sKey2, $sValue2) = each($sValue)){
print "<LI><a name=\"Cat$iTickqa\"><b>$sKey2</b></a><br>$sValue2<br>";
print "<a href=\"#Cat_Top\"><font size=\"-1\">[Back to Top]</font></a><br><br>";
$iTickqa += 1;
}
print "</OL>";
}
$iTick += 1;
}
}
/*[ Function: displayA : END ] */
/*[ Function: AdminAddCat : START ] */
function AdminAddCat($sCatname, $sFile){
$oFile = fopen($this->sPath . $this->sCat,"a");
fputs($oFile, "$sCatname||$sFile\n");
fclose($oFile);
$oFile = fopen($this->sPath . $sFile,"a");
chmod($this->sPath . $sFile, 0666);
fclose($oFile);
}
/*[ Function: AdminAddCat : END ] */
}
/*[ Class: cFaq : END ] */
?>