Skip to content

Commit

Permalink
fixes #1 ability to limit search on specific fields
Browse files Browse the repository at this point in the history
  • Loading branch information
plegall committed Oct 18, 2019
1 parent 8cf3cb2 commit 092d79b
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion main.inc.php
Expand Up @@ -88,7 +88,31 @@ function search_links_init_fake_search()
if (isset($_GET['word']))
{
$_POST['search_allwords'] = $_GET['word'];
$_POST['fields'] = array('file', 'name', 'comment');

// on which fields?
$basic_fields = array('file', 'name', 'comment');
$_POST['fields'] = array();
if (isset($_GET['fields']))
{
$user_fields = array();
foreach (explode(',', $_GET['fields']) as $field)
{
$field = trim($field);
if (in_array($field, $basic_fields))
{
$_POST['fields'][] = $field;
}
}

if (count($_POST['fields']) == 0)
{
die("invalid fields");
}
}
else
{
$_POST['fields'] = $basic_fields;
}

$is_search_link = true;
}
Expand Down

0 comments on commit 092d79b

Please sign in to comment.