Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for search warnings, errors and addressing issue 114 #116

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/classes/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
*/

class Form {

public $description;
public $prefillValues;
public $formName;
public $components;
public $saveAdditional;
Expand Down Expand Up @@ -144,7 +145,7 @@ public function show() {
case "autocomplete":
$afterJS .= $this->autocompleteJS($componentInfo['options']['list'], $componentInfo['options']['real_id'], $componentInfo['options']['fake_id']);
$fakeComponentName = "fake".$componentName;
$displayForm .= "<input type='text' name='".$fakeComponentName."' value='".filterText($_POST[$fakeComponentName])."' ".$dispAttributes." id='".$componentInfo['options']['fake_id']."'><input type='hidden' name='".$componentName."' value='".($componentInfo['value'] ?? '')."' id='".$componentInfo['options']['real_id']."'>";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was it intentional to delete the hidden <input> here?

$displayForm .= "<input type='text' name='".$fakeComponentName."' value='".filterText($_POST[$fakeComponentName] ?? '')."' ".$dispAttributes." id='".$componentInfo['options']['fake_id']."'><input type='hidden' name='".$componentName."' value='".($componentInfo['value'] ?? '')."' id='".$componentInfo['options']['real_id']."'>";
break;
case "textarea":
$displayForm .= "<textarea name='".$componentName."' ".$dispAttributes.">".$componentInfo['value']."</textarea>";
Expand Down
6 changes: 3 additions & 3 deletions src/forum/search.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
$breadcrumbObj->addCrumb("Search Forum");

if (count($_GET) > 0) {
$_POST['fakesearchuser'] = $_GET['searchuser'];
$_POST['fakesearchuser'] = $_GET['searchuser'] ?? '';
$_POST['checkCSRF'] = $_SESSION['csrfKey'];
$_POST['submit'] = true;
$_POST['filtertopics_replies'] = 0;
Expand All @@ -63,7 +63,7 @@
$_POST['sortresults'] = 0;
$_POST['sortresults_ascdesc'] = 0;

if (count($_GET['filterboards']) == 0) {
if (count($_GET['filterboards'] ?? []) == 0) {
$_POST['filterboards'][] = 0;
}

Expand Down Expand Up @@ -122,7 +122,7 @@ function check_filter_boards() {
global $boardObj, $formObj;

$countErrors = 0;
foreach ($_POST['filterboards'] as $value) {
foreach ($_POST['filterboards'] ?? [] as $value) {
if (!$boardObj->select($value) && $value != 0) {
$countErrors++;
}
Expand Down
26 changes: 14 additions & 12 deletions src/forum/search_results.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
if (trim($_POST['keyword']) != "") {
$_POST['keyword'] = str_replace("%", "\%", $_POST['keyword']);

if ($_POST['filterkeyword'] == 0) {
if (($_POST['filterkeyword'] ?? 0) == 0) {
$filterKeyword = ["message" => $_POST['keyword'], "title" => $_POST['keyword']];

$filterResults[] = " (".$postTable.".message LIKE '%".$mysqli->real_escape_string($_POST['keyword'])."%' OR ".$postTable.".title LIKE '%".$mysqli->real_escape_string($_POST['keyword'])."%') ";
Expand All @@ -88,7 +88,7 @@
// Filter By Username
$filterByUsername = "";
$memberIDList = [];
if (trim($_POST['fakesearchuser']) != "") {
if (trim($_POST['fakesearchuser'] ?? '') != "") {
$_POST['fakesearchuser'] = str_replace("*", "%", $_POST['fakesearchuser']);

$memberList = $member->get_entries(["username" => $_POST['fakesearchuser']], "username", true, ["username" => "Like"]);
Expand Down Expand Up @@ -141,18 +141,20 @@
$filterByDateGTLT = ">=";
}

$filterResults[] = " ".$postTable.".dateposted ".$filterByDateGTLT." '".$arrFilterDates[$_POST['filterposts']]."' ";
}
// Filter Board
$arrFilterBoards = [];
$filterBoards = $_POST['filterboards'] ?? [];

if (!in_array(0, $filterBoards)) {
$arrFilterBoards = $filterBoards;

// Filter Board
$arrFilterBoards = [];
if (!in_array(0, $_POST['filterboards'])) {
$arrFilterBoards = $_POST['filterboards'];
if ($_POST['include_subforums'] == 1) {
foreach ($filterBoards as $value) {
$boardObj->select($value);
$arrFilterBoards = array_merge($arrFilterBoards, $boardObj->getAllSubForums());
}

if ($_POST['include_subforums'] == 1) {
foreach ($_POST['filterboards'] as $value) {
$boardObj->select($value);
$arrFilterBoards = array_merge($arrFilterBoards, $boardObj->getAllSubForums());
$arrFilterBoards = array_unique($arrFilterBoards);
}

$arrFilterBoards = array_unique($arrFilterBoards);
Expand Down
13 changes: 9 additions & 4 deletions src/forum/templates/searchform.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,15 @@
echo "

<div class='formDiv' style='border: 0px; background: none; overflow: auto'>
<div class='largeFont' style='float: right'>
<b>".$searchLabel.":</b> <input type='text' class='textBox' id='searchTerm'> <input type='button' class='submitButton' id='btnSearchForum' ".$setFilterTopic.$setFilterBoard." style='padding: 3px 8px' value='GO'>
<br><span class='tinyFont'><a href='".$MAIN_ROOT."forum/search.php'>Advanced Search</a></span>
</div>
<form id='forumSearchForm' action='".$MAIN_ROOT."forum/search.php' method='get'>
<div class='largeFont' style='float: right'>
<b>".$searchLabel.":</b>
<input type='text' class='textBox' name='keyword' id='searchTerm'>
<input type='submit' class='submitButton' style='padding: 3px 8px' value='GO'>
<br><span class='tinyFont'><a href='".$MAIN_ROOT."forum/search.php'>Advanced Search</a></span>
</div>
".$addToURL."
</form>
</div>

<script type='text/javascript'>
Expand Down
Loading