<?php
if (isset($_REQUEST['tag']) and strlen($_REQUEST['tag']) > 0) {
$tag = $_REQUEST['tag'];
$taglist = file_get_contents("tags");
$pattern = "/\n" . addslashes(urldecode($tag)) . "\\t(.+)\\t\/\*/";
if (preg_match($pattern, $taglist, $line)) {
$URL = $line[1] . ".html#" . $tag;
header ("Location: $URL");
} else {
$pattern = "/\n(.*?"
. addslashes(urldecode($tag))
. ".*?)\\t(.+)\\t\/\*/";
if (preg_match_all ($pattern, $taglist, $matches)) {
$list = "";
for ($i = 0; $i < count($matches[0]); $i++) {
$list = $list . "<li><a href=\"" . $matches[2][$i]
. ".html#" . $matches[1][$i] . "\">"
. $matches[1][$i] . "</a></li>";
}
}
unset($line);
}
}
?>
<html xmlns="http://www.w3.org/1999/xhtml" lang="fr" xml:lang="fr">
<head>
<title>Manuels de Vim - Accueil</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
</head>
<body>
<h1>Accès aux manuels Vim traduits</h1>
<p>Cette page vous offre deux possibilités :</p>
<ul>
<li>Accéder directement au
<a href="help.txt.html">fichier principal de l'aide</a>.</li>
<li>Rechercher un sujet pour y accéder directement :
<?php
if (isset($tag) && !isset($line)) {
echo "<p>Le sujet '<b>", $tag,
"</b>' n'a pas été trouvé";
if (isset($list)) {
echo ", mais les sujets suivants contiennent '" . $tag
. "' :</p> <ul>" . $list . "</ul>";
} else {
echo ".</p>";
}
}
?>
<form method="get" action="./index.php">
<p><input type="text"
value="<?php if (isset($tag)) { echo $tag; } ?>"
name="tag"/>
<input type="submit" value="Rechercher"/></p>
</form> </li>
</ul>
<hr/>
</body>
</html>