| px | top | add code | search | signup | login | help |
<center>
<!-- Start Bravenet.com Affiliate Code -->
<script language="JavaScript" src="http://www.bravenet.com/cserv.php?pid=4&tid=2&afilid=853055196"></script>
<!-- End Bravenet.com Affiliate Code -->
</center><br>
<?php
$err="";
$totfound=0;
if(!isset($idx)) $idx=0;
function QuestionHere($cnt,$Q)
{
print "<b>$cnt. $Q</b><br>";
}
function AnswerHere($cnt,$A)
{
print "$A <font size=1><br><br></font>";
}
//read all with .faq ext.
$currdir=getcwd();
$dir=@opendir($currdir);
if(!$dir) print "Error dir $currdir";
$aCategory=array();
$n=0;
while($file=@readdir($dir))
{
if(substr($file,-4)==".faq")
{
$aCategory[]=$file;
//print substr($file,-4)." = $n. $aCategory[$n]<br>"; $n++;
}
}
sort($aCategory);
$nMaxCate=count($aCategory);
//Search
if(isset($searchtxt) && strlen($searchtxt)<3)
{
$err="Search at least 3 characters.";
$idx=-1;
$aFound=array();
}
elseif(isset($searchtxt) && $searchtxt!="")
{
$idx=-1;
$aFound=array();
for($a=0;$a<$nMaxCate;$a++)
{
$nFirst=0;
$ccfile=$currdir."/".$aCategory[$a];
$fp=@fopen($ccfile,"r");
if(!@fp) {print "Error reading ".$currdir."/".$aCategory[$a]; exit;}
$QorA=0;
$cnt=1;
$TempQ="";
$okenter=0;
while(!feof($fp))
{
$ln=fgets($fp,5000);
if(trim($ln)!="")
{
if(stristr($ln,$searchtxt) || $okenter==1)
{
if($nFirst==0)
{
$cCate=str_replace("_"," ",$aCategory[$a]);
$cCate=substr(substr($cCate,1),0,-4);
$aFound[]="@CATEGORY@$cCate";
$nFirst=1;
}
if($QorA==0) //Question
{
$QorA=1;
$okenter=1;
$totfound++;
}
else
{
$QorA=0;
if($okenter==0)
{
$totfound++;
$TempQ=str_replace($searchtxt,"<font color='000080'>$searchtxt</font>",$TempQ);
$aFound[]=$TempQ;
}
$okenter=0;
}
$ln=str_replace($searchtxt,"<font color='000080'>$searchtxt</font>",$ln);
$aFound[]=$ln;
}
else
{
if($QorA==0) {$TempQ=$ln; $QorA=1;}
elseif($QorA==1) {$QorA=0; $TempQ="";}
}
}
}
}
}
?>
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>FAQ</title>
<STYLE type="text/css">
<!--
A { text-decoration:none; color: #0000cc }
-->
</STYLE>
<style fprolloverstyle>A:hover {color: #cc0000;}</style>
</head>
<body>
<center>
<table border="0" width="750" style="font-family: Arial; font-size: 10pt" cellspacing="0" cellpadding="5">
<tr>
<td width="100%" bgcolor="#000080">
<p align="center"><font color="#FFFFFF" size="4"><b>FAQ</b></font></td>
</tr>
<tr>
<td width="100%">
<p align="center"><b>Categories :</b><br>
<?php
for($a=0;$a<$nMaxCate;$a++)
{
$cCate=str_replace("_","<font color=#ffffff>_</font>",$aCategory[$a]);
$cCate=substr(substr($cCate,1),0,-4);
$$cCate=strtoupper($file);
if($a==$idx) {print "[<b><font color='#008080'>$cCate</font></b>] "; $cSelectedCate=$cCate;}
else print "[<a href='faq.php?idx=$a'>$cCate</a>] ";
}
?>
</p>
</td>
</tr>
<tr>
<td width="100%">
<form method="POST" action="faq.php">
<p align="center"><b>Search :</b>
<input type="text" name="searchtxt" size="20" style="font-family: Arial; font-size: 8pt">
<input type="submit" value="Go" name="Search" style="font-family: Arial; font-size: 8pt">
</form>
</p>
</td>
</tr>
<tr>
<td width="100%">
<hr width="95%" size="1" color="#777777">
<?php
if($idx>=0)
{
print "<font size='3' color='#008080'><b>$cSelectedCate<br><br></b></font>";
$fp=@fopen($aCategory[$idx],"r");
if(!$fp) {print "Error reading ".$currdir."/".$aCategory[$a]; exit;}
$QorA=0;
$cnt=1;
while(!feof($fp))
{
$ln=fgets($fp,500);
if(trim($ln)!="")
{
if($QorA==0) {QuestionHere($cnt,$ln); $QorA=1;}
else {AnswerHere($cnt,$ln); $QorA=0; $cnt++;}
}
}
}
else
{ // SEARCH MODULE
$nMaxFound=count($aFound);
if($nMaxFound==0)
{
if($err!="") print "<br><font color='cc0000'>$err</font>";
else print "No search found for <b>$searchtxt</b>";
}
else
{
print "<font color=#000080 size=3>Search \"<b>$searchtxt</b>\", found <b>$totfound</b> topics.<br></font>";
$cnt=1;
$QorA=0;
for($a=0;$a<$nMaxFound;$a++)
{
if(substr($aFound[$a],0,10)=="@CATEGORY@")
{
$cSelectedCate=substr($aFound[$a],10);
print "<br><font size='3' color='#008080'><b>$cSelectedCate<br></b></font>";
$QorA=0;
}
else
{
if($QorA==0) {QuestionHere($cnt,$aFound[$a]); $QorA=1;}
else {AnswerHere($cnt,$aFound[$a]); $QorA=0; $cnt++;}
}
}
}
}
?>
<br><br><font size=1>Powered by <a href='http://smallcapitalbusiness.com'>SmallCapitalBusiness.com</a></font>
</td>
</tr>
</table>
</body>
</html>
Comments or questions?
PX is running PHP 5.2.11
Thanks to Miranda Productions for hosting and bandwidth.
Use of any code from PX is at your own risk.