-
Notifications
You must be signed in to change notification settings - Fork 3
/
search.php
104 lines (97 loc) · 2.6 KB
/
search.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<?php
$lang = basename(dirname(__FILE__));
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" type="text/css" href="doku.css">
<title><?php echo $lang == 'de' ? 'Entwicklermodus' : 'Developer Mode' ?></title>
<style>
ul {
list-style-position: inside;
list-style-image: url(images/bullet_sheet.gif);
}
ul a {
color: navy;
text-decoration: none;
}
ul a.visited {
color: navy;
text-decoration: none;
}
</style>
</head>
<body>
<?php
if ($lang == 'de') {
echo <<<HEADER
<ul class="nav">
<li class="fineprint">Clonk Entwicklermodus Dokumentation</li>
<li><a href="sdk/index.html">Einleitung</a></li>
<li><a href="content.html">Inhalt</a></li>
<li><a href="search.php">Suche</a></li>
<li><a href="sdk/console.html">Engine</a></li>
<li><a href="sdk/cmdline.html">Kommandozeile</a></li>
<li><a href="sdk/files.html">Spieldaten</a></li>
<li><a href="sdk/script/index.html">Script</a></li>
</ul>
<h1>Suche nach Scriptfunktionen</h1>
HEADER;
} else {
echo <<<HEADER
<ul class="nav"><li class="fineprint">Clonk Developer Mode Documentation</li>
<li><a href="sdk/index.html">Introduction</a></li>
<li><a href="content.html">Contents</a></li>
<li><a href="search.php">Search</a></li>
<li><a href="sdk/console.html">Engine</a></li>
<li><a href="sdk/cmdline.html">Command Line</a></li>
<li><a href="sdk/files.html">Game Data</a></li>
<li><a href="sdk/script/index.html">Script</a></li>
</ul>
<h1>Search for Script Functions</h1>
HEADER;
}
?>
<div class="text">
<form action="search.php" method="get">
<?php
echo $lang == 'de' ? '<b>Suchbegriff:</b>' : '<b>Search term:</b>';
echo ' <input type="text" name="func"';
if (isset($_GET['func'])) echo ' value="' . htmlspecialchars($_GET['func']) . '"';
echo '> ';
echo '<input type="submit" value="' . ($lang == 'de' ? 'Suchen' : 'Search') . '">';
?>
</form>
<?php
//parameters: $_GET('func')
//search?
if(isset($_GET['func']) && strlen($_GET['func']) > 0)
{
$path = "sdk/script/fn/";
$search = strtolower($_GET['func']);
$found = false;
echo "<ul>\n";
$dir = opendir($path);
//search
while (($item = readdir($dir)) !== FALSE)
{
$name = substr($item,0,strpos($item,'.'));
if ("." != $item && ".." != $item
&& (strpos(strtolower($name), $search) !== FALSE)
&& !is_dir($path.$item))
{
echo "<li><a href=\"$path$item\">$name</a></li>\n";
$found = true;
}
}
echo "</ul>\n";
//nothing found
if (!$found)
{
echo $lang == 'de' ? 'Es wurde keine Funktion gefunden.' : 'No function found.';
}
}
?>
</div>
</body></html>