Made xmlstarlet finding code hopefully more POSIX

http://mywiki.wooledge.org/BashFAQ/081
This commit is contained in:
Kai Hendry
2012-06-27 12:06:39 +02:00
parent bccb4abc99
commit f3bdc2aac0
3 changed files with 21 additions and 18 deletions

View File

@@ -1,10 +1,15 @@
<?php
header('Content-type: application/json');
if (empty($_GET['q'])) { die(); }
// Is this the correct way to sanitise args to shell from PHP?
$QUERY=urldecode(escapeshellarg(urlencode($_GET['q'])));
// Debug Logging
//$fp = fopen('debug.log', 'a');
//fwrite($fp, $_GET['q'] . " : " . $QUERY . "\n");
//fclose($fp);
exec("grep -hi $QUERY *.txt", $array);
$data = json_encode($array);
echo $_GET['jsoncallback'] . '(' . $data . ');';