From 58306bdc63b7dcaf964ab3541fe4b5a8e0c813b0 Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Mon, 29 Jul 2013 16:18:06 -0400 Subject: Search posts --- templates/mod/search_results.html | 97 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 94 insertions(+), 3 deletions(-) (limited to 'templates/mod/search_results.html') diff --git a/templates/mod/search_results.html b/templates/mod/search_results.html index b441a28f..035773fb 100644 --- a/templates/mod/search_results.html +++ b/templates/mod/search_results.html @@ -39,7 +39,7 @@ {% endfor %} -{% endif %} +{% endif %} {% if search_type == 'bans' %} @@ -125,7 +125,7 @@ {% endfor %}
-{% endif %} +{% endif %} {% if search_type == 'log' %} @@ -166,7 +166,98 @@ {% endfor %}
-{% endif %} +{% endif %} + +{% if search_type == 'posts' %} + + + + + + + + + + + + + {% for post in results %} + + + + + + + + + + + + {% endfor %} +
TimeBoardIDThreadIPNameSubjectFileBody (snippet)
+ {{ post.time | ago }} ago + + {{ config.board_abbreviation|sprintf(post.board) }} + + {% if post.thread %} + {% set thread = post.thread %} + {% else %} + {% set thread = post.id %} + {% endif %} + + {{ post.id }} + + + + {% if post.thread %} + {{ post.thread }} + {% else %} + (OP) + {% endif %} + + + {% if mod|hasPermission(config.mod.show_ip, post.board) %} + + {{ post.ip }} + + {% else %} + hidden + {% endif %} + + + {% if post.email|length > 0 %} + {# start email #} + + {% endif %} + {% if capcode %} + {{ capcode.cap }} + {% endif %} + + + {% if post.subject %} + {{ post.subject }} + {% else %} + – + {% endif %} + + {% if post.file %} + {{ post.file }} ({{ post.filesize | filesize }}) + {% else %} + – + {% endif %} + + {{ post.snippet }} +
+{% endif %} {% if result_count > results|count %}

-- cgit v1.3 From c8e93f04d2522224dd84b7d93e526b918a105451 Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Mon, 29 Jul 2013 16:24:11 -0400 Subject: Update search results template --- templates/mod/search_results.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'templates/mod/search_results.html') diff --git a/templates/mod/search_results.html b/templates/mod/search_results.html index 035773fb..aeaf57b0 100644 --- a/templates/mod/search_results.html +++ b/templates/mod/search_results.html @@ -189,7 +189,7 @@ {{ config.board_abbreviation|sprintf(post.board) }} - + {% if post.thread %} {% set thread = post.thread %} {% else %} @@ -217,7 +217,7 @@ hidden {% endif %} - + {% if post.email|length > 0 %} {# start email #} @@ -237,14 +237,14 @@ {% endif %} - + {% if post.subject %} {{ post.subject }} {% else %} – {% endif %} - + {% if post.file %} {{ post.file }} ({{ post.filesize | filesize }}) {% else %} -- cgit v1.3 From e0bc0a622de2e4b9a8e02f9b48979d14dba04c94 Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Mon, 29 Jul 2013 16:26:32 -0400 Subject: Post serach results: link to posts with ?/ --- templates/mod/debug/recent_posts.html | 2 +- templates/mod/search_results.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'templates/mod/search_results.html') diff --git a/templates/mod/debug/recent_posts.html b/templates/mod/debug/recent_posts.html index 740ed21e..13eb4d5a 100644 --- a/templates/mod/debug/recent_posts.html +++ b/templates/mod/debug/recent_posts.html @@ -24,7 +24,7 @@ {% else %} {% set thread = post.id %} {% endif %} - + {{ post.id }} diff --git a/templates/mod/search_results.html b/templates/mod/search_results.html index aeaf57b0..de753198 100644 --- a/templates/mod/search_results.html +++ b/templates/mod/search_results.html @@ -195,7 +195,7 @@ {% else %} {% set thread = post.id %} {% endif %} - + {{ post.id }} -- cgit v1.3 From d44b4f19a8760699a8895cbf9856a4cc0a0f5a65 Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Mon, 29 Jul 2013 16:31:36 -0400 Subject: See last commit --- templates/mod/debug/recent_posts.html | 2 +- templates/mod/search_results.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'templates/mod/search_results.html') diff --git a/templates/mod/debug/recent_posts.html b/templates/mod/debug/recent_posts.html index 13eb4d5a..b84d24ab 100644 --- a/templates/mod/debug/recent_posts.html +++ b/templates/mod/debug/recent_posts.html @@ -1,4 +1,4 @@ - +
diff --git a/templates/mod/search_results.html b/templates/mod/search_results.html index de753198..fbad0381 100644 --- a/templates/mod/search_results.html +++ b/templates/mod/search_results.html @@ -169,7 +169,7 @@ {% endif %} {% if search_type == 'posts' %} -
Time Board
+
-- cgit v1.3 From 1759ac2ea30d3c374beb6b5b6fa76bfa5501da9f Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Mon, 29 Jul 2013 20:20:07 -0400 Subject: Post search: Search other fields too --- inc/mod/pages.php | 16 ++++++++++++++-- templates/mod/search_results.html | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) (limited to 'templates/mod/search_results.html') diff --git a/inc/mod/pages.php b/inc/mod/pages.php index 8289d0b0..d447fa51 100644 --- a/inc/mod/pages.php +++ b/inc/mod/pages.php @@ -174,6 +174,11 @@ function mod_search_redirect() { $query = str_replace('_', '%5F', $query); $query = str_replace('+', '_', $query); + if ($query === '') { + header('Location: ?/', true, $config['redirect_http']); + return; + } + header('Location: ?/search/' . $_POST['type'] . '/' . $query, true, $config['redirect_http']); } else { header('Location: ?/', true, $config['redirect_http']); @@ -225,7 +230,7 @@ function mod_search($type, $search_query_escaped, $page_no = 1) { // Which `field` to search? if ($type == 'posts') - $sql_field = 'body_nomarkup'; + $sql_field = array('body_nomarkup', 'filename', 'subject', 'filehash', 'ip', 'name', 'trip'); if ($type == 'IP_notes') $sql_field = 'body'; if ($type == 'bans') @@ -239,7 +244,14 @@ function mod_search($type, $search_query_escaped, $page_no = 1) { if (!empty($sql_like)) $sql_like .= ' AND '; $phrase = preg_replace('/^\'(.+)\'$/', '\'%$1%\'', $phrase); - $sql_like .= '`' . $sql_field . '` LIKE ' . $phrase . ' ESCAPE \'!\''; + if (is_array($sql_field)) { + foreach ($sql_field as $field) { + $sql_like .= '`' . $field . '` LIKE ' . $phrase . ' ESCAPE \'!\' OR'; + } + $sql_like = preg_replace('/ OR$/', '', $sql_like); + } else { + $sql_like .= '`' . $sql_field . '` LIKE ' . $phrase . ' ESCAPE \'!\''; + } } diff --git a/templates/mod/search_results.html b/templates/mod/search_results.html index fbad0381..0c87f75f 100644 --- a/templates/mod/search_results.html +++ b/templates/mod/search_results.html @@ -246,7 +246,7 @@
Time Board {% if post.file %} - {{ post.file }} ({{ post.filesize | filesize }}) + {{ post.filename }} ({{ post.filesize | filesize }}) {% else %} – {% endif %} -- cgit v1.3