forked from flazyforum/Flazy-Core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearch.php
641 lines (530 loc) · 37.5 KB
/
search.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
<?php
/**
* Позволяет участникам искать на форуме сообщения, темы, на основе различных критерий.
*
* @copyright Copyright (C) 2008 PunBB, partially based on code copyright (C) 2008 FluxBB.org
* @modified Copyright (C) 2014-2018 Flazy
* @license http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
* @package Flazy
*/
if (!defined('FORUM_ROOT'))
define('FORUM_ROOT', './');
require FORUM_ROOT . 'include/common.php';
($hook = get_hook('se_start')) ? eval($hook) : null;
// Load the search.php language file
require FORUM_ROOT . 'lang/' . $forum_user['language'] . '/search.php';
// Load the necessary search functions
require FORUM_ROOT . 'include/functions/search.php';
if (!$forum_user['g_read_board'])
message($lang_common['No view']);
else if (!$forum_user['g_search'])
message($lang_search['No search permission']);
// If a search_id was supplied
if (isset($_GET['search_id'])) {
$search_id = intval($_GET['search_id']);
if ($search_id < 1)
message($lang_common['Bad request']);
// Generate the query to grab the cached results
$query = generate_cached_search_query($search_id, $show_as, $keywords);
$url_type = $forum_url['search_results'];
}
// We aren't just grabbing a cached search
else if (isset($_GET['action'])) {
$action = $_GET['action'];
// Validate action
if (!validate_search_action($action))
message($lang_common['Bad request']);
// If it's a regular search (keywords and/or author)
if ($action == 'search') {
$keywords = (isset($_GET['keywords'])) ? forum_trim($_GET['keywords']) : null;
$author = (isset($_GET['author'])) ? forum_trim($_GET['author']) : null;
$sort_dir = (isset($_GET['sort_dir'])) ? (($_GET['sort_dir'] == 'DESC') ? 'DESC' : 'ASC') : 'DESC';
$show_as = (isset($_GET['show_as'])) ? $_GET['show_as'] : 'posts';
$sort_by = (isset($_GET['sort_by'])) ? intval($_GET['sort_by']) : null;
$search_in = (!isset($_GET['search_in']) || $_GET['search_in'] == 'all') ? 0 : (($_GET['search_in'] == 'message') ? 1 : -1);
$forum = (isset($_GET['forum']) && is_array($_GET['forum'])) ? array_map('intval', $_GET['forum']) : array(-1);
if (preg_match('#^[\*%]+$#', $keywords))
$keywords = '';
if (preg_match('#^[\*%]+$#', $author))
$author = '';
if (!$keywords && !$author)
message($lang_search['No terms']);
// Create a cache of the results and redirect the user to the results
create_search_cache($keywords, $author, $search_in, $forum, $show_as, $sort_by, $sort_dir);
}
// Its not a regular search, so its a quicksearch
else {
$value = null;
// Get any additional variables for quicksearches
if ($action == 'show_user_posts' || $action == 'show_user_topics' || $action == 'show_subscriptions') {
$value = isset($_GET['user_id']) ? intval($_GET['user_id']) : 0;
if ($value < 2)
message($lang_common['Bad request']);
}
else if ($action == 'show_recent')
$value = (isset($_GET['value'])) ? intval($_GET['value']) : 86400;
else if ($action == 'show_new')
$value = (isset($_GET['forum'])) ? intval($_GET['forum']) : -1;
($hook = get_hook('se_additional_quicksearch_variables')) ? eval($hook) : null;
$search_id = $keywords = '';
$show_as = 'topics';
// Generate the query for the search
$query = generate_action_search_query($action, $value, $search_id, $url_type, $show_as);
}
}
($hook = get_hook('se_pre_search_query')) ? eval($hook) : null;
// We have the query to get the results, lets get them!
if (isset($query)) {
// No results?
if (!$query)
no_search_results();
// Work out the settings for pagination
$forum_page['per_page'] = ($show_as == 'posts') ? $forum_user['disp_posts'] : $forum_user['disp_topics'];
// We now have a query that will give us our results in $query, lets get the data!
$num_hits = get_search_results($query, $search_set);
($hook = get_hook('se_post_results_fetched')) ? eval($hook) : null;
// No search results?
if ($num_hits == 0)
no_search_results($action);
//
// Output the search results
//
$forum_page['main_title'] = $lang_common['Search'];
// Setup breadcrumbs and results header and footer
$forum_page['main_foot_options']['new_search'] = '<a class="user-option" href="' . forum_link($forum_url['search']) . '">' . $lang_search['Perform new search'] . '</a>';
$forum_page['crumbs'][] = array($forum_config['o_board_title'], forum_link($forum_url['index']));
$action = (isset($action)) ? $action : null;
generate_search_crumbs($action);
// Generate paging links
$forum_page['page_post']['paging'] = '<p class="paging"><span class="pages">' . $lang_common['Pages'] . '</span> ' . paginate($forum_page['num_pages'], $forum_page['page'], $url_type, $lang_common['Paging separator'], $search_id) . '</p>';
// Get topic/forum tracking data
if (!$forum_user['is_guest'])
$tracked_topics = get_tracked_topics();
// Navigation links for header and page numbering for title/meta description
if ($forum_page['page'] < $forum_page['num_pages']) {
$forum_page['nav']['last'] = '<link rel="last" href="' . forum_sublink($url_type, $forum_url['page'], $forum_page['num_pages'], $search_id) . '" title="' . $lang_common['Page'] . ' ' . $forum_page['num_pages'] . '" />';
$forum_page['nav']['next'] = '<link rel="next" href="' . forum_sublink($url_type, $forum_url['page'], ($forum_page['page'] + 1), $search_id) . '" title="' . $lang_common['Page'] . ' ' . ($forum_page['page'] + 1) . '" />';
}
if ($forum_page['page'] > 1) {
$forum_page['nav']['prev'] = '<link rel="prev" href="' . forum_sublink($url_type, $forum_url['page'], ($forum_page['page'] - 1), $search_id) . '" title="' . $lang_common['Page'] . ' ' . ($forum_page['page'] - 1) . '" />';
$forum_page['nav']['first'] = '<link rel="first" href="' . forum_link($url_type, $search_id) . '" title="' . $lang_common['Page'] . ' 1" />';
}
// Setup main heading
if ($forum_page['num_pages'] > 1)
$forum_page['main_head_pages'] = sprintf($lang_common['Page info'], $forum_page['page'], $forum_page['num_pages']);
// Setup main options header
$forum_page['main_options_head'] = $lang_search['Search options'];
($hook = get_hook('se_results_pre_header_load')) ? eval($hook) : null;
$forum_js->file(array('jquery', 'material', 'flazy', 'common'));
$forum_js->code('$(function() {
$(\'.hide-head\').toggle(
function() {
$(this).children().text(\'' . $lang_common['Hidden text'] . '\');
$(this).next().show("slow");
},
function() {
$(this).children().text(\'' . $lang_common['Hidden show text'] . '\');
$(this).next().hide("slow");
}
);
$(\'.item-subject a\').tooltip({ track: true, delay: 0, showURL: false, showBody: " - ", fade: 250 });
$(\'#block\').click($.tooltip.block);
});');
define('FORUM_PAGE', $show_as == 'topics' ? 'searchtopics' : 'searchposts');
require FORUM_ROOT . 'header.php';
// START SUBST - <forum_main>
ob_start();
($hook = get_hook('se_results_output_start')) ? eval($hook) : null;
if ($show_as == 'topics') {
// Load the forum.php language file
require FORUM_ROOT . 'lang/' . $forum_user['language'] . '/forum.php';
$forum_page['item_header'] = array();
$forum_page['item_header']['title'] = '<th class="item-subject" scope="col">' . $lang_forum['Topics'] . '</th>';
$forum_page['item_header']['forum'] = '<th class="info-forum" scope="col">' . $lang_forum['Forum'] . '</th>';
$forum_page['item_header']['replies'] = '<th class="info-replies" scope="col">' . $lang_forum['Replies'] . '</th>';
$forum_page['item_header']['lastpost'] = '<th class="info-lastpost" scope="col">' . $lang_forum['Last post'] . '</th>';
($hook = get_hook('se_results_topics_pre_item_header_output')) ? eval($hook) : null;
?>
<div class="main-head">
<?php
if (!empty($forum_page['main_head_options']))
echo "\t\t" . '<p class="options">' . implode(' ', $forum_page['main_head_options']) . '</p>' . "\n";
?>
<h2 class="hn"><span><?php echo $forum_page['items_info'] ?></span></h2>
</div>
<div class="main-content main-forum">
<table cellspacing="0">
<thead>
<tr>
<?php echo implode("\n\t\t\t\t", $forum_page['item_header']) . "\n" ?>
</tr>
</thead>
<tbody>
<?php
}
else {
// Load the topic.php language file
require FORUM_ROOT . 'lang/' . $forum_user['language'] . '/topic.php';
?>
<div class="main-head">
<?php
if (!empty($forum_page['main_head_options']))
echo "\t\t" . '<p class="options">' . implode(' ', $forum_page['main_head_options']) . '</p>' . "\n";
?>
<h2 class="hn"><span><?php echo $forum_page['items_info'] ?></span></h2>
</div>
<div class="main-content main-topic">
<?php
}
$forum_page['item_count'] = 0;
if ($show_as == 'posts') {
if (!defined('FORUM_PARSER_LOADED'))
require FORUM_ROOT . 'include/parser.php';
}
$forum_js->file(array('jquery', 'material', 'flazy', 'common'));
// Finally, lets loop through the results and output them
foreach ($search_set as $cur_set) {
($hook = get_hook('se_results_loop_start')) ? eval($hook) : null;
++$forum_page['item_count'];
if ($forum_config['o_censoring']) {
$cur_set['subject'] = censor_words($cur_set['subject']);
$cur_set['description'] = censor_words($cur_set['description']);
$cur_set['question'] = censor_words($cur_set['question']);
}
if ($show_as == 'posts') {
// Generate the result heading
$forum_page['post_ident'] = array();
$forum_page['post_ident']['num'] = '<span class="post-num">' . forum_number_format($forum_page['start_from'] + $forum_page['item_count']) . '</span>';
$forum_page['post_ident']['byline'] = '<span class="post-byline">' . sprintf((($cur_set['pid'] == $cur_set['first_post_id']) ? $lang_topic['Topic byline'] : $lang_topic['Reply byline']), '<strong>' . forum_htmlencode($cur_set['pposter']) . '</strong>') . '</span>';
$forum_page['post_ident']['link'] = '<a class="permalink" rel="bookmark" title="' . $lang_topic['Permalink topic'] . '" href="' . forum_link($forum_url['topic'], array($cur_set['tid'], sef_friendly($cur_set['subject']))) . '">' . sprintf((($cur_set['pid'] == $cur_set['first_post_id']) ? $lang_topic['Topic title'] : $lang_topic['Reply title']), forum_htmlencode($cur_set['subject'])) . '</a> <small>' . sprintf($lang_topic['Search replies'], forum_number_format($cur_set['num_replies']), '<a href="' . forum_link($forum_url['forum'], array($cur_set['forum_id'], sef_friendly($cur_set['forum_name']))) . '">' . forum_htmlencode($cur_set['forum_name']) . '</a>') . '</small>';
($hook = get_hook('se_results_posts_row_pre_item_ident_merge')) ? eval($hook) : null;
// Generate author identification
$forum_page['user_ident'] = ($cur_set['poster_id'] > 1 && $forum_user['g_view_users']) ? '<strong class="username"><a title="' . sprintf($lang_search['Go to profile'], forum_htmlencode($cur_set['pposter'])) . '" href="' . forum_link($forum_url['user'], $cur_set['poster_id']) . '">' . forum_htmlencode($cur_set['pposter']) . '</a></strong>' : '<strong class="username">' . forum_htmlencode($cur_set['pposter']) . '</strong>';
$forum_page['post_contacts'] = array();
$forum_page['post_contacts']['pposted'] = '<span><a class="permalink" rel="bookmark" title="' . $lang_topic['Permalink post'] . '" href="' . forum_link($forum_url['post'], $cur_set['pid']) . '">' . format_time($cur_set['pposted']) . '</a></span>';
// Generate the post actions links
$forum_page['post_actions'] = array();
$forum_page['post_actions']['forum'] = '<span class="forum-search"><a href="' . forum_link($forum_url['forum'], array($cur_set['forum_id'], sef_friendly($cur_set['forum_name']))) . '">' . $lang_search['Go to forum'] . '<span>: ' . forum_htmlencode($cur_set['forum_name']) . '</span></a></span>';
if ($cur_set['pid'] != $cur_set['first_post_id'])
$forum_page['post_actions']['topic'] = '<span class="topic-search"><a class="permalink" rel="bookmark" title="' . $lang_topic['Permalink topic'] . '" href="' . forum_link($forum_url['topic'], array($cur_set['tid'], sef_friendly($cur_set['subject']))) . '">' . $lang_search['Go to topic'] . '<span>: ' . forum_htmlencode($cur_set['subject']) . '</span></a></span>';
$forum_page['post_actions']['post'] = '<span class="post-search"><a class="permalink" rel="bookmark" title="' . $lang_topic['Permalink post'] . '" href="' . forum_link($forum_url['post'], $cur_set['pid']) . '">' . $lang_search['Go to post'] . '<span> ' . forum_number_format($forum_page['start_from'] + $forum_page['item_count']) . '</span></a></span>';
$forum_page['message'] = parse_message($cur_set['message'], $cur_set['hide_smilies']);
if ($keywords != '') {
$hilit_array = array_filter(explode('|', $keywords), 'strlen');
foreach ($hilit_array as $key => $value) {
$hilit_array[$key] = '/(?<=^|\s)(' . str_replace('\*', '[[:punct:]а-яА-ЯёЁ\w]*?', preg_quote($value, '/')) . ')(?=$|\s)/iu';
$hilit_array[$key] = preg_replace('#(^|\s)\\\\w\*\?(\s|$)#', '$1\w+?$2', $hilit_array[$key]);
}
$forum_page['message'] = utf8_substr(preg_replace($hilit_array, '<span class="posthilit">$1</span>', ' ' . $forum_page['message'] . ' '), 1, -1);
}
// Give the post some class
$forum_page['item_status'] = array(
'post',
(($forum_page['item_count'] % 2 != 0) ? 'odd' : 'even' )
);
if ($forum_page['item_count'] == 1)
$forum_page['item_status']['firstpost'] = 'firstpost';
if (($forum_page['start_from'] + $forum_page['item_count']) == $forum_page['finish_at'])
$forum_page['item_status']['lastpost'] = 'lastpost';
if ($cur_set['pid'] == $cur_set['first_post_id'])
$forum_page['item_status']['topicpost'] = 'topicpost';
($hook = get_hook('se_results_posts_row_pre_display')) ? eval($hook) : null;
?>
<div class="<?php echo implode(' ', $forum_page['item_status']) ?> resultpost">
<div class="posthead">
<h3 class="hn post-ident"><?php echo implode(' ', $forum_page['post_ident']) ?></h3>
</div>
<div class="postbody">
<div class="post-entry">
<div class="entry-content">
<?php echo $forum_page['message'] ?>
</div>
<?php ($hook = get_hook('se_results_posts_row_new_post_entry_data')) ? eval($hook) : null; ?>
</div>
</div>
<div class="postfoot">
<div class="post-options">
<p class="post-contacts"><?php echo implode(' ', $forum_page['post_contacts']) ?></p>
<p class="post-actions"><?php echo implode(' ', $forum_page['post_actions']) ?></p>
</div>
</div>
</div>
<?php
}
else {
// Start from scratch
$forum_page['item_subject'] = $forum_page['item_body'] = $forum_page['item_status'] = $forum_page['item_nav'] = $forum_page['item_title'] = $forum_page['item_title_status'] = array();
// Assemble the Topic heading
if (!$forum_user['is_guest'] && $forum_config['o_show_dot'] && $cur_set['has_posted'] > 0) {
$forum_page['item_title']['posted'] = '<span class="posted-mark">' . $lang_forum['You posted indicator'] . '</span>';
$forum_page['item_status']['posted'] = 'posted';
}
if ($cur_set['sticky']) {
$forum_page['item_title_status']['sticky'] = '<em class="sticky">' . $lang_forum['Sticky'] . '</em>';
$forum_page['item_status']['sticky'] = 'sticky';
} else if ($cur_set['closed']) {
$forum_page['item_title_status']['closed'] = '<em class="closed">' . $lang_forum['Closed'] . '</em>';
$forum_page['item_status']['closed'] = 'closed';
} else if ($cur_set['question'] != '') {
$forum_page['item_title_status']['poll'] = '<em class="poll">' . $lang_forum['Poll'] . '</em>';
$forum_page['item_status']['poll'] = 'poll';
}
($hook = get_hook('se_results_topics_row_pre_item_title_status_merge')) ? eval($hook) : null;
if (!empty($forum_page['item_title_status']))
$forum_page['item_title']['status'] = '<span class="item-status">' . sprintf($lang_forum['Item status'], implode(', ', $forum_page['item_title_status'])) . '</span>';
$topic_desc = array();
if ($cur_set['description'] != '')
$topic_desc['description'] = $lang_common['Title separator'] . forum_htmlencode(forum_htmlencode($cur_set['description']));
if ($cur_set['question'] != '')
$topic_desc['question'] = $lang_common['Title separator'] . forum_htmlencode(forum_htmlencode($cur_set['question']));
$forum_page['item_title']['link'] = '<strong><a href="' . forum_link($forum_url['topic'], array($cur_set['tid'], sef_friendly($cur_set['subject']))) . '"' . (!empty($topic_desc) ? ' title="' . $lang_forum['Description'] . implode('', $topic_desc) . '"' : '') . '>' . forum_htmlencode($cur_set['subject']) . '</a></strong>';
($hook = get_hook('se_results_topic_loop_normal_topic_pre_item_title_merge')) ? eval($hook) : null;
$forum_page['item_body']['subject']['title'] = '<h3>' . implode(' ', $forum_page['item_title']) . '</h3>';
// Assemble the Topic subject
$forum_page['item_subject']['starter'] = '<span class="item-starter">' . sprintf($lang_forum['Topic starter'], '<cite><a href="' . forum_link($forum_url['user'], $cur_set['poster_id']) . '">' . forum_htmlencode($cur_set['poster']) . '</a></cite>') . '</span>';
($hook = get_hook('se_results_topics_row_pre_item_subject_merge')) ? eval($hook) : null;
if (empty($forum_page['item_status']))
$forum_page['item_status']['normal'] = 'normal';
($hook = get_hook('se_results_topics_pre_item_status_merge')) ? eval($hook) : null;
$forum_page['item_pages'] = ceil(($cur_set['num_replies'] + 1) / $forum_user['disp_posts']);
if ($forum_page['item_pages'] > 1)
$forum_page['item_nav']['pages'] = '<span class="pages">' . $lang_forum['Pages'] . ' </span>' . paginate($forum_page['item_pages'], -1, $forum_url['topic'], $lang_common['Page separator'], array($cur_set['tid'], sef_friendly($cur_set['subject'])));
// Does this topic contain posts we haven't read? If so, tag it accordingly.
if (!$forum_user['is_guest'] && $cur_set['last_post'] > $forum_user['last_visit'] && (!isset($tracked_topics['topics'][$cur_set['tid']]) || $tracked_topics['topics'][$cur_set['tid']] < $cur_set['last_post']) && (!isset($tracked_topics['forums'][$cur_set['forum_id']]) || $tracked_topics['forums'][$cur_set['forum_id']] < $cur_set['last_post'])) {
$forum_page['item_nav']['new'] = '<small><a href="' . forum_link($forum_url['topic_new_posts'], array($cur_set['tid'], sef_friendly($cur_set['subject']))) . '" title="' . $lang_forum['New posts info'] . '">' . $lang_forum['New posts'] . '</a></small>';
$forum_page['item_status']['new'] = 'new';
}
($hook = get_hook('se_topic_loop_normal_topic_pre_item_nav_merge')) ? eval($hook) : null;
if (!empty($forum_page['item_nav']))
$forum_page['item_title']['nav'] = '<span class="item-nav">' . sprintf($lang_forum['Topic navigation'], implode('  ', $forum_page['item_nav'])) . '</span>';
$forum_page['item_body']['subject']['title'] = '<h3>' . implode(' ', $forum_page['item_title']) . '</h3>';
$forum_page['item_body']['subject']['desc'] = implode(' ', $forum_page['item_subject']);
($hook = get_hook('se_topic_loop_normal_topic_pre_item_subject_merge')) ? eval($hook) : null;
$forum_page['item_body']['info']['forum'] = '<td class="info-forum"><a href="' . forum_link($forum_url['forum'], array($cur_set['forum_id'], sef_friendly($cur_set['forum_name']))) . '">' . $cur_set['forum_name'] . '</a></td>';
$forum_page['item_body']['info']['replies'] = '<td class="info-replies"><span class="' . item_size($cur_set['num_replies']) . '">' . forum_number_format($cur_set['num_replies']) . '</span></td>';
$forum_page['item_body']['info']['lastpost'] = '<td class="info-lastpost"><span><a href="' . forum_link($forum_url['post'], $cur_set['last_post_id']) . '">' . format_time($cur_set['last_post']) . '</a></span> <cite>' . sprintf($lang_forum['by poster'], '<a href="' . forum_link($forum_url['user'], $cur_set['last_poster_id']) . '">' . forum_htmlencode($cur_set['last_poster']) . '</a>') . '</cite></td>';
($hook = get_hook('se_results_topics_row_pre_display')) ? eval($hook) : null;
$forum_page['item_style'] = (($forum_page['item_count'] % 2 != 0) ? ' odd' : ' even') . (($forum_page['item_count'] == 1) ? ' main-first-item' : '') . ((!empty($forum_page['item_status'])) ? ' ' . implode(' ', $forum_page['item_status']) : '');
($hook = get_hook('se_row_pre_display')) ? eval($hook) : null;
?>
<tr class="<?php echo implode(' ', $forum_page['item_status']) ?> <?php echo ($forum_page['item_count'] % 2 != 0) ? 'odd' : 'even' ?><?php echo ($forum_page['item_count'] == 1) ? ' row1' : '' ?>">
<td class="item-subject">
<div class="icon"><!-- --></div>
<div class="tclcon">
<?php echo implode("\n\t\t\t\t", $forum_page['item_body']['subject']) . "\n" ?>
</div>
</td>
<?php echo implode("\n\t\t\t\t", $forum_page['item_body']['info']) . "\n" ?>
</tr>
<?php
}
}
?>
</tbody>
</table>
</div>
<div class="main-foot">
<?php
if (!empty($forum_page['main_foot_options']))
echo "\t\t" . '<p class="options">' . implode(' ', $forum_page['main_foot_options']) . '</p>' . "\n";
?>
<h2 class="hn"><span><?php echo $forum_page['items_info'] ?></span></h2>
</div>
<?php
($hook = get_hook('se_results_end')) ? eval($hook) : null;
$tpl_temp = forum_trim(ob_get_contents());
$tpl_main = str_replace('<forum_main>', $tpl_temp, $tpl_main);
ob_end_clean();
// END SUBST - <forum_main>
require FORUM_ROOT . 'footer.php';
}
//
// Display the search form
//
// Setup form information
$forum_page['frm-info'] = array(
'search' => '<p>' . $lang_search['Search info'] . '</p>',
'keywords' => '<p>' . $lang_search['Keywords info'] . '</p>',
'refine' => '<p>' . $lang_search['Refine info'] . '</p>',
'wildcard' => '<p>' . $lang_search['Wildcard info'] . '</p>'
);
if ($forum_config['o_search_all_forums'] || $forum_user['is_admmod'])
$forum_page['frm-info']['forums'] = '<p>' . $lang_search['Forum default info'] . '</p>';
else
$forum_page['frm-info']['forums'] = '<p>' . $lang_search['Forum require info'] . '</p>';
// Setup sort by options
$forum_page['frm-sort'] = array(
'post_time' => '<option value="0">' . $lang_search['Sort by post time'] . '</option>',
'author' => '<option value="1">' . $lang_search['Sort by author'] . '</option>',
'subject' => '<option value="2">' . $lang_search['Sort by subject'] . '</option>',
'forum_name' => '<option value="3">' . $lang_search['Sort by forum'] . '</option>'
);
// Setup breadcrumbs
$forum_page['crumbs'] = array(
array($forum_config['o_board_title'], forum_link($forum_url['index'])),
array($lang_common['Search'], forum_link($forum_url['search']))
);
// Setup form
$forum_page['group_count'] = $forum_page['item_count'] = $forum_page['fld_count'] = 0;
($hook = get_hook('se_pre_header_load')) ? eval($hook) : null;
$forum_js->file(array('jquery', 'material', 'flazy', 'common'));
define('FORUM_PAGE', 'search');
require FORUM_ROOT . 'header.php';
// START SUBST - <forum_main>
ob_start();
($hook = get_hook('se_main_output_start')) ? eval($hook) : null;
?>
<div class="row">
<div class="col s12 m12 l12">
<div class="alert alert-info">
<?php echo implode("\n\t\t\t\t", $forum_page['frm-info']) . "\n" ?>
</div>
</div>
<div class="col s12 m12 l12">
<div class="card">
<div class="card-content">
<form id="afocus" class="frm-form" method="get" accept-charset="utf-8" action="<?php echo forum_link($forum_url['search']) ?>">
<div class="hidden">
<input type="hidden" name="action" value="search" />
</div>
<div class="row">
<?php ($hook = get_hook('se_pre_criteria_fieldset')) ? eval($hook) : null; ?>
<fieldset class="frm-group group<?php echo ++$forum_page['group_count'] ?>">
<?php ($hook = get_hook('se_pre_keywords')) ? eval($hook) : null; ?>
<div class="col s12 m12 l4">
<div class="sf-set set<?php echo ++$forum_page['item_count'] ?>">
<div class="sf-box text">
<label for="fld<?php echo ++$forum_page['fld_count'] ?>"><span><?php echo $lang_search['Keyword search'] ?></span></label><br />
<span class="fld-input"><input type="text" id="fld<?php echo $forum_page['fld_count'] ?>" name="keywords" size="40" maxlength="100" /></span>
</div>
</div>
</div>
<?php ($hook = get_hook('se_pre_author')) ? eval($hook) : null; ?>
<div class="col s12 m12 l4 set<?php echo ++$forum_page['item_count'] ?>">
<div class="sf-box text">
<label for="fld<?php echo ++$forum_page['fld_count'] ?>"><span><?php echo $lang_search['Author search'] ?></span></label><br />
<span class="fld-input"><input id="fld<?php echo $forum_page['fld_count'] ?>" type="text" name="author" size="25" maxlength="25" /></span>
</div>
</div>
<?php ($hook = get_hook('se_pre_search_in')) ? eval($hook) : null; ?>
<div class="col s12 m12 l4 set<?php echo ++$forum_page['item_count'] ?>">
<div class="sf-box select">
<label for="fld<?php echo ++$forum_page['fld_count'] ?>"><span><?php echo $lang_search['Search in'] ?></span></label><br />
<span class="fld-input"><select id="fld<?php echo $forum_page['fld_count'] ?>" name="search_in">
<option value="all"><?php echo $lang_search['Message and subject'] ?></option>
<option value="message"><?php echo $lang_search['Message only'] ?></option>
<option value="topic"><?php echo $lang_search['Topic only'] ?></option>
</select></span>
</div>
</div>
<?php ($hook = get_hook('se_pre_forum_fieldset')) ? eval($hook) : null; ?>
<fieldset class="mf-set set<?php echo ++$forum_page['item_count'] ?>">
<legend><span><?php echo $lang_search['Forum search'] ?> <em><?php echo ($forum_config['o_search_all_forums'] || $forum_user['is_admmod']) ? $lang_search['Forum search default'] : $lang_search['Forum search require'] ?></em></span></legend>
<?php ($hook = get_hook('se_pre_forum_checklist')) ? eval($hook) : null; ?>
<div class="mf-box">
<div class="checklist">
<?php
// Get the list of categories and forums
$query = array(
'SELECT' => 'c.id AS cid, c.cat_name, f.id AS fid, f.forum_name, f.redirect_url',
'FROM' => 'categories AS c',
'JOINS' => array(
array(
'INNER JOIN' => 'forums AS f',
'ON' => 'c.id=f.cat_id'
),
array(
'LEFT JOIN' => 'forum_perms AS fp',
'ON' => '(fp.forum_id=f.id AND fp.group_id=' . $forum_user['g_id'] . ')'
)
),
'WHERE' => '(fp.read_forum IS NULL OR fp.read_forum=1) AND f.redirect_url IS NULL',
'ORDER BY' => 'c.disp_position, c.id, f.disp_position'
);
($hook = get_hook('se_qr_get_cats_and_forums')) ? eval($hook) : null;
$result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
$cur_category = 0;
while ($cur_forum = $forum_db->fetch_assoc($result)) {
($hook = get_hook('se_forum_loop_start')) ? eval($hook) : null;
if ($cur_forum['cid'] != $cur_category) { // A new category since last iteration?
if ($cur_category)
echo "\t\t\t\t\t\t\t" . '</fieldset>' . "\n";
echo "\t\t\t\t\t\t\t" . '<fieldset>' . "\n\t\t\t\t\t\t\t\t" . '<legend><span>' . forum_htmlencode($cur_forum['cat_name']) . ':</span></legend>' . "\n";
$cur_category = $cur_forum['cid'];
}
echo "\t\t\t\t\t\t\t\t" . '<div class="checklist-item"><span class="fld-input"><input type="checkbox" id="fld' . ( ++$forum_page['fld_count']) . '" name="forum[]" value="' . $cur_forum['fid'] . '" /></span> <label for="fld' . $forum_page['fld_count'] . '">' . forum_htmlencode($cur_forum['forum_name']) . '</label></div>' . "\n";
}
?>
</fieldset>
</div>
</div>
<?php ($hook = get_hook('se_pre_forum_fieldset_end')) ? eval($hook) : null; ?>
</fieldset>
<?php ($hook = get_hook('se_forum_fieldset_end')) ? eval($hook) : null; ?>
</fieldset>
</div>
<?php ($hook = get_hook('se_criteria_fieldset_end')) ? eval($hook) : null; ?>
<?php $forum_page['item_count'] = 0; ?>
<?php ($hook = get_hook('se_pre_results_fieldset')) ? eval($hook) : null; ?>
<fieldset class="frm-group group<?php echo ++$forum_page['group_count'] ?>">
<legend class="group-legend"><strong><?php echo $lang_search['Results legend'] ?></strong></legend>
<?php ($hook = get_hook('se_pre_sort_by')) ? eval($hook) : null; ?>
<div class="sf-set set<?php echo ++$forum_page['item_count'] ?>">
<div class="sf-box select">
<label for="fld<?php echo ++$forum_page['fld_count'] ?>"><span><?php echo $lang_search['Sort by'] ?></span></label><br />
<span class="fld-input"><select id="fld<?php echo $forum_page['fld_count'] ?>" name="sort_by">
<?php echo implode("\n\t\t\t\t\t\t", $forum_page['frm-sort']) . "\n" ?>
</select></span>
</div>
</div>
<?php ($hook = get_hook('se_pre_sort_order_fieldset')) ? eval($hook) : null; ?>
<fieldset class="mf-set set<?php echo ++$forum_page['item_count'] ?>">
<legend><span><?php echo $lang_search['Sort order'] ?></span></legend>
<?php ($hook = get_hook('se_pre_sort_order')) ? eval($hook) : null; ?>
<div class="mf-box mf-yesno">
<div class="mf-item">
<span class="fld-input"><input type="radio" id="fld<?php echo ++$forum_page['fld_count'] ?>" name="sort_dir" value="ASC" /></span>
<label for="fld<?php echo $forum_page['fld_count'] ?>"><?php echo $lang_search['Ascending'] ?></label>
</div>
<div class="mf-item">
<span class="fld-input"><input type="radio" id="fld<?php echo ++$forum_page['fld_count'] ?>" name="sort_dir" value="DESC" checked="checked" /></span>
<label for="fld<?php echo $forum_page['fld_count'] ?>"><?php echo $lang_search['Descending'] ?></label>
</div>
</div>
<?php ($hook = get_hook('se_pre_sort_order_fieldset_end')) ? eval($hook) : null; ?>
</fieldset>
<?php ($hook = get_hook('se_pre_display_choices_fieldset')) ? eval($hook) : null; ?>
<fieldset class="mf-set set<?php echo ++$forum_page['item_count'] ?>">
<legend><span><?php echo $lang_search['Display results'] ?></span></legend>
<?php ($hook = get_hook('se_pre_display_choices')) ? eval($hook) : null; ?>
<div class="mf-box mf-yesno">
<div class="mf-item">
<span class="fld-input"><input type="radio" id="fld<?php echo ++$forum_page['fld_count'] ?>" name="show_as" value="topics" /></span>
<label for="fld<?php echo $forum_page['fld_count'] ?>"><?php echo $lang_search['Show as topics'] ?></label>
</div>
<div class="mf-item">
<span class="fld-input"><input type="radio" id="fld<?php echo ++$forum_page['fld_count'] ?>" name="show_as" value="posts" checked="checked" /></span>
<label for="fld<?php echo $forum_page['fld_count'] ?>"><?php echo $lang_search['Show as posts'] ?></label>
</div>
<?php ($hook = get_hook('se_new_display_choices')) ? eval($hook) : null; ?>
</div>
<?php ($hook = get_hook('se_pre_display_choices_fieldset_end')) ? eval($hook) : null; ?>
</fieldset>
<?php ($hook = get_hook('se_pre_results_fieldset_end')) ? eval($hook) : null; ?>
</fieldset>
<?php ($hook = get_hook('se_results_fieldset_end')) ? eval($hook) : null; ?>
<div class="frm-buttons">
<span class="submit"><input type="submit" name="search" value="<?php echo $lang_search['Submit search'] ?>" /></span>
</div>
</form>
</div>
</div>
</div>
</div>
<?php
($hook = get_hook('se_end')) ? eval($hook) : null;
$tpl_temp = forum_trim(ob_get_contents());
$tpl_main = str_replace('<forum_main>', $tpl_temp, $tpl_main);
ob_end_clean();
// END SUBST - <forum_main>
require FORUM_ROOT . 'footer.php';