Happy Codings - Programming Code Examples
Html Css Web Design Sample Codes CPlusPlus Programming Sample Codes JavaScript Programming Sample Codes C Programming Sample Codes CSharp Programming Sample Codes Java Programming Sample Codes Php Programming Sample Codes Visual Basic Programming Sample Codes


Php Programming Code Examples

Php > Complete Programs Code Examples

Searches through a local INN server's discussions

Searches through a local INN server's discussions <?php #INNSearch #This allows users to search through a local INN server's archives #We use it to search through old postings to our private newsgroups #location of news active file $active = "/var/lib/news/active"; #locate of news spool $spooldir = "/var/spool/news/"; #number of levels deep subdirs of $spooldir are $dirdepth = 4; #minimum number of articles in group to show up on main search page $minarticles = 1; #groups with more articles than this will not be selected by default $maxarticles = 1000; print( "<HTML>"); print( "<head>"); print( "<title>"); print( "INNSearch"); print( "</title>"); print( "</head>"); if ($query) { $searchgroups = ""; $sgroups = split( "&", getenv( "QUERY_STRING")); for ($i=0; $i < count($sgroups); $i++) { if (ereg( "=on", $sgroups[$i])) { $tgroup = split( "=", $sgroups[$i]); $tgroup[0] = ereg_replace( "\.", "/", $tgroup[0]); $searchgroups = $searchgroups . " " . $spooldir . $tgroup[0]. "/*"; } } print ( "Search for \"$query\"<P>"); $fp = popen( "/bin/grep \"$query\" $searchgroups", "r"); while ($line = fgets($fp, 150)) { $file = explode( ":", $line); $group = explode( "/", $file[0]); $newsgroup = ""; for ($i = $dirdepth; $i < (count($group)-1); $i++) { if ($i > $dirdepth) { $newsgroup = $newsgroup . ".";} $newsgroup = "$newsgroup$group[$i]"; } if ($newsgroup) { print( "<B>$newsgroup</B>"); print( " <A HREF=\"innsearch.phtml?article=$newsgroup.$group[$i]\">$grou p[$i]</A>"); $la = split( ":", $line, 2); $line = htmlspecialchars($la[1]); print( " $line<BR>\n"); reset($file); reset($group); } } pclose($fp); } else if ($article) { $article = ereg_replace( "\.", "/", $article); $fp = popen( "/bin/cat $spooldir$article", "r"); while ($line = fgets($fp, 150)) { $line = htmlspecialchars($line); print( "$line<BR>\n"); } pclose($fp); } else { print ( "INNSearch<P>\n"); print ( "<FORM METHOD=\"get\" action=\"innsearch.phtml\">\n"); print ( "<INPUT name=\"query\" size=\"25\">\n"); print ( "<INPUT type=\"submit\" value = \"Search\"><BR>\n"); $fp = popen( "cat $active", "r"); while ($line = fgets($fp, 150)) { $group = split( " ", $line); if ($group[1] > $minarticles) { print( "<input type=\"checkbox\" name=\"$group[0]\""); if ($group[1] < $maxarticles) { print( " checked "); } print( ">$group[0]<BR>\n"); } } pclose($fp); print ( "</FORM>\n"); } ?>