//TODO: Clean up this fucking mess /* Forums search result page */ include(SERVER_ROOT.'/classes/text.class.php'); $Text = new TEXT; list($Page, $Limit) = Format::page_limit(POSTS_PER_PAGE); if ((isset($_GET['type']) && $_GET['type'] == 'body')) { $Type = 'body'; } else { $Type='title'; } // What are we looking for? Let's make sure it isn't dangerous. if (isset($_GET['search'])) { $Search = trim($_GET['search']); } else { $Search = ''; } $ThreadAfterDate = db_string($_GET['thread_created_after']); $ThreadBeforeDate = db_string($_GET['thread_created_before']); $ThreadAfterDateDisplay = ""; $ThreadBeforeDateDisplay = ""; if (!empty($ThreadAfterDate) && !is_date($ThreadAfterDate)) { error('Incorrect topic after date format'); } elseif (!empty($ThreadAfterDate)) { $ThreadAfterDateDisplay = "value='" . date('Y-m-d', strtotime($ThreadAfterDate)) . "'"; } if (!empty($ThreadBeforeDate) && !is_date($ThreadBeforeDate)) { error('Incorrect topic before date format'); } elseif (!empty($ThreadBeforeDate)) { $ThreadBeforeDateDisplay = "value='" . date('Y-m-d', strtotime($ThreadBeforeDate)) . "'"; } $PostAfterDate = db_string($_GET['post_created_after']); $PostBeforeDate = db_string($_GET['post_created_before']); $PostAfterDateDisplay = ""; $PostBeforeDateDisplay = ""; if (!empty($PostAfterDate) && !is_date($PostAfterDate)) { error('Incorrect post after date format'); } elseif (!empty($PostAfterDate)) { $PostAfterDateDisplay = "value='" . date('Y-m-d', strtotime($PostAfterDate)) . "'"; } if (!empty($PostBeforeDate) && !is_date($PostBeforeDate)) { error('Incorrect post before date format'); } elseif (!empty($PostBeforeDate)) { $PostBeforeDateDisplay = "value='" . date('Y-m-d', strtotime($PostBeforeDate)) . "'"; } // Searching for posts by a specific user if (!empty($_GET['user'])) { $User = trim($_GET['user']); $DB->query(" SELECT ID FROM users_main WHERE Username = '".db_string($User)."'"); list($AuthorID) = $DB->next_record(); if ($AuthorID === null) { $AuthorID = 0; //this will cause the search to return 0 results. //workaround in line 276 to display that the username was wrong. } } else { $User = ''; } // Are we looking in individual forums? if (isset($_GET['forums']) && is_array($_GET['forums'])) { $ForumArray = array(); foreach ($_GET['forums'] as $Forum) { if (is_number($Forum)) { $ForumArray[]=$Forum; } } if (count($ForumArray) > 0) { $SearchForums = implode(', ',$ForumArray); } } // Searching for posts in a specific thread if (!empty($_GET['threadid']) && is_number($_GET['threadid'])) { $ThreadID = $_GET['threadid']; $Type = 'body'; $SQL = " SELECT Title FROM forums_topics AS t JOIN forums AS f ON f.ID=t.ForumID WHERE t.ID=$ThreadID AND " . Forums::user_forums_sql(); $DB->query($SQL); if (list($Title) = $DB->next_record()) { $Title = " > $Title"; } else { error(404); } } else { $ThreadID = ''; } // Let's hope we got some results - start printing out the content. View::show_header('Forums > Search', 'bbcode,forum_search'); ?>
Forum | =((!empty($ThreadID)) ? 'Post begins' : 'Topic')?> | Topic creation time | Last post time |
Nothing found=((isset($AuthorID) && $AuthorID == 0) ? ' (unknown username)' : '')?>! | |||
=$ForumName?> | if (empty($ThreadID)) { ?> =Format::cut_string($Title, 80); ?> } else { ?> =Format::cut_string($Title, 80); ?> } if ($Type == 'body') { ?> (Show) "> } ?> | =time_diff($ThreadCreatedTime)?> | =time_diff($LastTime)?> |