<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="code.xsl" ?>
<dns4.nl>
<voorbeeld>
<title>broncode van het auto faq script.</title>
<verwijzende_link>http://www.dns4.nl/pagina/html_code/auto_faq.html</verwijzende_link>
<informatie>


</informatie>
<programma_code>
<![CDATA[
<!-- de code begint vanaf hier.

<?php
$PHP_SELF = $_SERVER['PHP_SELF'];
$my_server = "http://".getenv("SERVER_NAME").":".getenv("SERVER_PORT"); // Jouw server (gewoonlijk hoef je dit niet te veranderen)
$my_root = getenv("DOCUMENT_ROOT"); // Jouw 'document root' (gewoonlijk hoef je dit niet te veranderen)
$s_dirs = array("/pagina/html_code/faq","/een/anderedir"); // In welke directories moet gezocht worden? ("/dir1","/dir2","/dir1/subdir2","/nogeenandere/directory")? --> $s_dirs = array(""); met de laatste zoek je op de hele server
$s_skip = array("..",".","subdir2"); // Welke files of directories moeten er overgeslagen worden?
$s_files = "html|htm|HTM|HTML|php|txt"; // Op welke extensies zoeken? 
$min_chars = "3"; // Minimum aantal letters (of cijfers) wat in de zoekbox moet worden ingevuld
$max_chars = "30"; // Maximum aantal letters (of cijfers) wat in de zoekbox mag worden ingevuld
$default_val = "zoekwoord"; // Default waarde van zoekveld
$limit_hits = array("5","10","25","50","100"); // Hoeveel zoekhits moeten er getoond worden, om het selectmenu niet te tonen voer je gewoon een vaste waarde in --> array("100")
$message_1 = "ongeldige zoekterm"; // ongeldige zoekterm
$message_2 = "voer op z`n minst in $min_chars, en maximaal $max_chars tekens."; // geen goede invoer lengte ($min_chars/$max_chars)
$message_3= "zoekresultaten voor "; // zoekresultaat
$message_4 = "oops, niets gevonden."; // noppes
$message_5 = "vinden"; // hoeveel zoekhits wil je hebben
$message_6 = "Match hoofdletters"; // hoofd of kleine letters exact of onbelangrijk
$no_title = "klik voor content"; // als er geen 'title' te vinden is laat je deze tekst zien
$limit_extracts = ""; // Hoeveel extracts per file wil je laten zien. Default: "" --> alles extracten, alternatief: 'integer' b.v. "3"
$byte_size = "51200"; // Hoeveel bytes per pagina mag worden gezocht? Hoe minder, hoe sneller...
function search_form($_GET, $limit_hits, $default_val, $message_5, $message_6, $PHP_SELF) {
	@$keyword=$_GET['keyword'];
	@$case=$_GET['case'];
	@$limit=$_GET['limit'];
	echo "<form action=\"$PHP_SELF\" method=\"get\">\n",
	"<div><input type=\"hidden\" value=\"SEARCH\" name=\"action\" />\n",
	"<input type=\"text\" name=\"keyword\" class=\"text\" size=\"10\"  maxlength=\"30\" value=\"" ;
	if(!$keyword)
		echo "$default_val";
	else
		echo str_replace("&amp;","&",htmlentities($keyword));
	echo "\" ";
	echo "onfocus=\" if (value == '";
	if(!$keyword)
		echo "$default_val"; 
	else
		echo str_replace("&amp;","&",htmlentities($keyword));
	echo "') {value=''}\" onblur=\"if (value == '') {value='";
	if(!$keyword)
		echo "$default_val"; 
	else
		echo str_replace("&amp;","&",htmlentities($keyword));
	echo "'}\" /> ";
	$j=count($limit_hits);
	if($j==1)
		echo "<input type=\"hidden\" value=\"".$limit_hits[0]."\" name=\"limit\" />";
	elseif($j>1) {
		echo
		"<select name=\"limit\" class=\"select\">\n";
		for($i=0;$i<$j;$i++) {
			echo "<option value=\"".$limit_hits[$i]."\"";
			if($limit==$limit_hits[$i])
				echo "";
			echo ">".$limit_hits[$i]." $message_5</option>\n";
			}
		echo "</select> ";
		}
	echo
	"<input type=\"submit\" value=\"OK\" class=\"button\" />\n",
	"<span class=\"checkbox\"><br />$message_6</span> <input type=\"checkbox\" name=\"case\" value=\"true\" class=\"checkbox\"";
	if($case)
		echo " CHECKED";
	echo
	" />\n",
	"\n",
	"</div></form>\n";
	}
function search_headline($_GET, $message_3) {
	@$keyword=$_GET['keyword'];
	@$action=$_GET['action'];
	if($action == "SEARCH") 
	echo "<h2 class=\"result\">$message_3 '<span class='schuinetekst'>".htmlentities(stripslashes($keyword))."</span>'</h2>";
	}
function search_error($_GET, $min_chars, $max_chars, $message_1, $message_2, $limit_hits) {
	global $_GET;
	@$keyword=$_GET['keyword'];
	@$action=$_GET['action'];
	@$limit=$_GET['limit'];
	if($action == "SEARCH") { 
		if(strlen($keyword)<$min_chars||strlen($keyword)>$max_chars||!in_array ($limit, $limit_hits)) { 
			echo "<p class=\"result\"><span class='vettetekst'>$message_1</span><br />$message_2</p>";
			$_GET['action'] = "ERROR"; 
			}
		}
	}
function search_dir($my_server, $my_root, $s_dirs, $s_files, $s_skip, $message_1, $message_2, $no_title, $limit_extracts, $byte_size, $_GET) {
	global $count_hits;
	@$keyword=$_GET['keyword'];
	@$action=$_GET['action'];
	@$limit=$_GET['limit'];
	@$case=$_GET['case'];
	if($action == "SEARCH") { 
		foreach($s_dirs as $dir) { 
			$handle = @opendir($my_root.$dir);
			while($file = @readdir($handle)) {
				if(in_array($file, $s_skip)) { 
					continue;
					}
				elseif($count_hits>=$limit) {
					break; 
					}
				elseif(is_dir($my_root.$dir."/".$file)) { 
					$s_dirs = array("$dir/$file");
					search_dir($my_server, $my_root, $s_dirs, $s_files, $s_skip, $message_1, $message_2, $no_title, $limit_extracts, $byte_size, $_GET); 
					}
				elseif(preg_match("/($s_files)$/i", $file)) { 
					$fd=fopen($my_root.$dir."/".$file,"r");
					$text=fread($fd, $byte_size); // 50 KB
					$keyword_html = htmlentities($keyword);
					if($case) { 
						$do=strstr($text, $keyword)||strstr($text, $keyword_html);
						}
					else {
						$do=stristr($text, $keyword)||stristr($text, $keyword_html);
						}
					if($do)	{
						$count_hits++; 
						if(preg_match_all("=<title[^>]*>(.*)</title>=siU", $text, $titel)) { 
							if(!$titel[1][0]) 
								$link_title=$no_title; 
							else
								$link_title=$titel[1][0];  
							}
						else {
							$link_title=$no_title; 
							}
						echo "<a href=\"$my_server$dir/$file\" onclick='laadInhoud(\"$my_server$dir/$file\");return false;' class=\"result\">$count_hits.  $link_title</a><br />"; 

						$auszug = strip_tags($text);
						$keyword = preg_quote($keyword); // unescapen
						$keyword = str_replace("/","\/","$keyword");
						$keyword_html = preg_quote($keyword_html); // unescapen
						$keyword_html = str_replace("/","\/","$keyword_html");
						echo "<span class=\"extract\">";
						if(preg_match_all("/((\s\S*){0,3})($keyword|$keyword_html)((\s?\S*){0,3})/i", $auszug, $match, PREG_SET_ORDER)); {
							if(!$limit_extracts)
								$number=count($match);
							else
								$number=$limit_extracts;
							for ($h=0;$h<$number;$h++) { 
								if (!empty($match[$h][3]))
									printf("<span class='schuinetekst'><span class='vettetekst'>..</span> %s<span class='vettetekst'>%s</span>%s <span class='vettetekst'>..</span></span>", $match[$h][1], $match[$h][3], $match[$h][4]);
								}
							}
						echo "</span><br /><br />";
						flush();
						}
					fclose($fd);
					}
				}
	  		@closedir($handle);
			}
		}
	}
function search_no_hits($_GET, $count_hits, $message_4) {
	@$action=$_GET['action'];
	if($action == "SEARCH" && $count_hits<1) 
		echo "<p class=\"result\">$message_4</p>";
	}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
		"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
		<html xmlns="http://www.w3.org/1999/xhtml" lang="nl" xml:lang="nl"><?php echo "\n";?>
<head>
	<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
	<title>auto faq</title>
	<meta name='keywords' content="auto,faq,script" />
	<meta name='description' content="automatisch f.a.q. script" />
	<meta name="author" content="Bobik" />
	<meta name="language" content="nederlands" />
	<script type="text/javascript">
		function laadInhoud(url)
			{ 
			var xmlRequest = null; 
			if(window.XMLHttpRequest)
				xmlRequest = new XMLHttpRequest(); 
			else if (window.ActiveXObject)  
				xmlRequest = new ActiveXObject("Microsoft.XMLHTTP"); 
				xmlRequest.onreadystatechange = function()
			{ 
				if(xmlRequest.readyState == 4)
				{
					if(xmlRequest.status == 200) 
						document.getElementById("iframe_xhtml").innerHTML = xmlRequest.responseText;   
					else 
						alert("Error: " + xmlRequest.status);
				} 
			}
			xmlRequest.open("GET", url, true); 
			xmlRequest.setRequestHeader("Content-Type","application/x-www-form-urlencoded");  
			xmlRequest.send(null); 
		} 
	</script>
	<style type="text/css" media="screen">
		body{
			background: #220000;
			color:#999999;
			height:100%;
			font-family:Helvetica,Geneva,Arial,SunSans-Regular,sans-serif;
			font-size:14px;
		}
		a{outline:none;}
		#autofaq{position:absolute;
			top:2px;
			left:45px;
			font-weight:bold;
			font-size:200%;
		}
		.kleineletters a{
			color:#ffbb00;
			background:inherit !important;
			font-size:40%;
		}
		#zoekformulier{position:absolute;top:120px;left:40px;}
		.schuinetekst{font-style:italic;}
		.vettetekst{font-weight:bold;}
		.laatoutputzien{
			border:solid 1px #bbbbbb;
			color:#ffffff;
			background:#2A4444;
			width: 400px;
			height:423px;
			overflow: auto;
		}
		table.nul{              
		position:absolute;top:0px;left:0px;height:100%;width:100%;
			color:#ffffff;
			background:#220000;
			border:solid 0px #000000;		
		}
		table{
			border:solid 1px #bbbbbb;
			padding-top:5px;
			color:#000001;
			background:#A1CEC0;
			width:402px;
		}
		table.twee{
			margin:5px;
			color:#000001;
			background:#666666;width:80%;
		}

		#iframe_xhtml{
			background: #666666;
			color:#dddddd;
			position:absolute;
			top:120px;
			left:460px;
			margin-top:0px;
			padding-left:10px;
			padding-top:17px;
			padding-right:10px;
			display:block;width:50%;height:500px;
			overflow:auto;
		}
		input.text  {
			color : #000001;
			background:#dddddd;
			font-weight : normal;
			font-size : 12px;
			text-decoration : none;
			width : 120px;
		}
		input.button  {
			color : #000001;
			background:#dddddd;
			font-weight : normal;
			font-size : 12px;
			text-decoration : none;
		}
		input.checkbox  {
			color : #000001;
			background:#888888;
			font-weight : normal;
			font-size : 12px;
			text-decoration : none;
		}
		span.checkbox  {
			color : #000001;
			background:#666666;
			font-weight : normal;
			font-size : 11px;
			text-decoration : none;
		}
		select.select  {
			color : #000001;
			background:#dddddd;
			font-weight : normal;
			font-size : 12px;
			text-decoration : none;
		}
		h2.result  {
			text-align:center;
			background:#551a8b;
			display : block;
			margin-top:2em;
			color : #ffffff;
			font-weight : bold;
			font-size : 13px;
			text-decoration : none;
		}
		p.result  {
			padding-left:2em;
			color : #eeeeee;
			background:inherit !important;
			font-weight : normal;
			font-size : 12px;
			text-decoration : none;
		}
		a.result:link  {
			color : #ffffbf;
			background:inherit !important;
			font-weight : bold;
			font-size : 12px;
			text-decoration : none;
		}
		a.result:visited  {
			color : #ffffbf;
			background:inherit !important;
			font-weight : bold;
			font-size : 12px;
			text-decoration : none;
		}
		a.result:active  {
			color : #9D9D9D;
			background:inherit !important;
			font-weight : bold;
			font-size : 12px;
			text-decoration : underline;
		}
		a.result:hover  {
			color : #9D9D9D;
			background:inherit !important;
			font-weight : bold;
			font-size : 12px;
			text-decoration : underline;
		}
		span.extract  {
			color : #ffffff;
			background:inherit !important;
			font-weight : bold;
			font-size : 11px;
			text-decoration : none;
		}
		a.ts:link  {
			color : #ffffbf;
			background:inherit !important;
			font-weight : normal;
			font-size : 9px;
			text-decoration : none;
		}
		a.ts:visited  {
			color : #ffffbf;
			background:inherit !important;
			font-weight : normal;
			font-size : 9px;
			text-decoration : none;
		}
		a.ts:active  {
			color : #9D9D9D;
			background:inherit !important;
			font-weight : normal;
			font-size : 9px;
			text-decoration : underline;
		}
		a.ts:hover  {
			color : #9D9D9D;
			background:inherit !important;
			font-weight : normal;
			font-size : 9px;
			text-decoration : underline;
		}
	</style>
</head>
<body onload="laadInhoud('faq/uitleg.html')">
	<table class="nul" border="0" cellspacing="0" cellpadding="0">
		<tr>
			<td>
				<div id="iframe_xhtml"></div>
				<div id="zoekformulier">
					<table  cellspacing="1" cellpadding="0">
						<tr>
							<td>
								<table class="twee" border="0" cellspacing="0" cellpadding="3">
									<tr>
										<td>
											<?
												search_form($_GET, $limit_hits, $default_val, $message_5, $message_6, $PHP_SELF);
											?>
										</td>
									</tr>
								</table>	
							</td>
						</tr>
					</table>
					<div class="laatoutputzien">	
						<?php
							search_headline($_GET, $message_3);
							search_error($_GET, $min_chars, $max_chars, $message_1, $message_2, $limit_hits);
							search_dir($my_server, $my_root, $s_dirs, $s_files, $s_skip, $message_1, $message_2, $no_title, $limit_extracts, $byte_size, $_GET);
							search_no_hits($_GET, $count_hits, $message_4);
						?>
					</div>	
				</div>
			</td>
		</tr>
	</table>
	<div id="autofaq">
		<p>
			AUTO FAQ<br />
			<span class="kleineletters">
				&laquo; <a href="http://www.dns4.nl/pagina/html.html"> naar vorige 
			pagina </a> 
			</span> 
		</p>
	</div>
</body>
</html>

de code is hier geeindigd.
// -->
]]>
</programma_code>
<code_link>http://www.dns4.nl/pagina/alle_tekst_files.html</code_link>
</voorbeeld>
</dns4.nl>
