forked from avscms/avscms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearch.php
executable file
·70 lines (59 loc) · 2.15 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
<?php
define('_VALID', true);
require 'include/config.php';
require 'include/function_global.php';
require 'include/function_smarty.php';
require 'classes/filter.class.php';
require 'classes/pagination.class.php';
$filter = new VFilter();
$search_type = get_request_arg('search', 'STRING');
$search_query = get_request_arg($search_type, 'STRING');
$search_types = array('videos', 'photos', 'users', 'tags');
if ( !in_array($search_type, $search_types) ) {
VRedirect::go($config['BASE_URL']. '/notfound/invalid_search_type');
}
if ( !$search_query && isset($_POST['search_query'])) {
$search_query = $filter->get('search_query');
$search_query_f = str_replace(' ', '-', $search_query);
VRedirect::go($config['BASE_URL']. '/search/'.$search_type.'/'.$search_query_f);
} else {
$search_query = $filter->xss_filter($search_query);
$search_query_f = str_replace(' ', '-', $search_query);
}
if($search_type != "tags"){
$search_query_f = (str_replace('-', ' ', $search_query));
} else {
$search_query_f = $search_query;
}
$module = 'modules/search/' .$search_type. '.php';
$module_template = 'search_' .$search_type. '.tpl';
require $module;
$self_title = strtoupper($search_type) . " - " . str_replace('{#search_query#}', $search_query, $seo['search_title']);
switch ($search_type) {
case 'tags':
$active_menu = 'tags';
break;
case 'videos':
$active_menu = 'videos';
break;
case 'photos':
$active_menu = 'albums';
break;
case 'users':
$active_menu = 'community';
break;
}
$smarty->assign('errors',$errors);
$smarty->assign('messages',$messages);
$smarty->assign('menu', $active_menu);
$smarty->assign('search_query', $search_query);
$smarty->assign('search_query_f', $search_query_f);
$smarty->assign('search_type', $search_type);
$smarty->assign('self_title', $self_title);
$smarty->assign('self_description', $seo['search_desc']);
$smarty->assign('self_keywords', $seo['search_keywords']);
$smarty->loadFilter('output', 'trimwhitespace');
$smarty->display('header.tpl');
$smarty->display($module_template);
$smarty->display('footer.tpl');
?>