mirror of
https://github.com/thewesker/greptweet.git
synced 2025-12-23 05:21:06 -05:00
Made xmlstarlet finding code hopefully more POSIX
http://mywiki.wooledge.org/BashFAQ/081
This commit is contained in:
5
grep.php
5
grep.php
@@ -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 . ');';
|
||||
|
||||
Reference in New Issue
Block a user