-
Notifications
You must be signed in to change notification settings - Fork 3
/
searchTitles.php
30 lines (29 loc) · 1.06 KB
/
searchTitles.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
<!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">
<head>
<title>StackOverflow Search</title>
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;charset=utf-8"/>
<link rel="apple-touch-icon" href="icon.png" />
<script>
</script>
</head>
<body>
<?php
/* Read the search string from the URL */
$searchString = $_GET["searchString"];
/* Run a shell script to search for them */
$script = "bash /Users/peter/Sites/StackOverflow/searchTitles.sh ";
$script .= $searchString;
$out = "";
exec ($script, &$out);
/* Display each line of the output (not just the first line) */
foreach($out as $key=>$value) {
/* Substitute the delimiter with an additional double-quote to form a URL */
$value=str_replace('>','">',$value);
/* Display the search result, with a link to look up the post */
echo '<br><a href="http://localhost/StackOverflow/readPost.php?postId='.$value.'</a></br>';
}
?>
</body>
</html>