forked from SwiftDeal/eCommerce
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunction.search.php
More file actions
162 lines (136 loc) · 4.89 KB
/
Copy pathfunction.search.php
File metadata and controls
162 lines (136 loc) · 4.89 KB
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
<?php
/**
* Search
*/
function search_results($keywords, $per_page, $offset, $state){
$returned_results = array();
$where = "";
$created = strftime("%Y-%m-%d %H:%M:%S", time());
$keywords = preg_split('/[\s]+/', $keywords);
$total_keywords = count($keywords);
$table_cols = array('title', 'category');
foreach ($keywords as $key => $keyword) {
$where .= "{$table_cols[0]} LIKE '%$keyword%' OR ";
}
foreach ($keywords as $key => $keyword) {
$where .= "{$table_cols[1]} LIKE '%$keyword%'";
if ($key != $total_keywords-1) {
$where .= " OR ";
}
}
$sql = "SELECT id FROM items WHERE ({$where}) AND (city LIKE '%$state%') ORDER BY id DESC LIMIT {$per_page} OFFSET {$offset}";
$results_num = ($results = mysql_query($sql)) ? mysql_num_rows($results) : 0;
//echo $sql."<br>";
//echo $results_num."<br>";
if ($results_num == 0) {
return false;
} else {
while ($results_row = mysql_fetch_assoc($results)) {
$returned_results[] = array('id' => $results_row['id']);
}
return $returned_results;
}
}
function search_count($keywords, $place){
$returned_results = array();
$where = "";
$created = strftime("%Y-%m-%d %H:%M:%S", time());
$keywords = preg_split('/[\s]+/', $keywords);
$total_keywords = count($keywords);
$table_cols = array('title', 'category');
foreach ($keywords as $key => $keyword) {
$where .= "{$table_cols[0]} LIKE '%$keyword%' OR ";
}
foreach ($keywords as $key => $keyword) {
$where .= "{$table_cols[1]} LIKE '%$keyword%'";
if ($key != $total_keywords-1) {
$where .= " OR ";
}
}
$sql = "SELECT COUNT(*) FROM items WHERE ({$where}) AND (city LIKE '%$place%')";
$result = mysql_query($sql);
return mysql_result($result, 0);
}
//category Search
function search_category($keywords, $per_page, $offset, $state){
$returned_results = array();
$where = "";
$created = strftime("%Y-%m-%d %H:%M:%S", time());
$keywords = preg_split('/[\s]+/', $keywords);
$total_keywords = count($keywords);
foreach ($keywords as $key => $keyword) {
$where .= "category LIKE '%$keyword%'";
if ($key != $total_keywords-1) {
$where .= " OR ";
}
}
$sql = "SELECT id FROM items WHERE ({$where}) AND (city LIKE '%$state%') ORDER BY id DESC LIMIT {$per_page} OFFSET {$offset}";
$results_num = ($results = mysql_query($sql)) ? mysql_num_rows($results) : 0;
if ($results_num == 0) {
return false;
} else {
while ($results_row = mysql_fetch_assoc($results)) {
$returned_results[] = array('id' => $results_row['id']);
}
return $returned_results;
}
}
//city Search
function search_city($city, $per_page, $offset){
$returned_results = array();
$where = "";
$created = strftime("%Y-%m-%d %H:%M:%S", time());
$sql = "SELECT id FROM items WHERE (city LIKE '%$city%') ORDER BY id DESC LIMIT {$per_page} OFFSET {$offset}";
$results_num = ($results = mysql_query($sql)) ? mysql_num_rows($results) : 0;
if ($results_num == 0) {
return false;
} else {
while ($results_row = mysql_fetch_assoc($results)) {
$returned_results[] = array('id' => $results_row['id']);
}
return $returned_results;
}
}
function search_count_city($city){
$returned_results = array();
$where = "";
$created = strftime("%Y-%m-%d %H:%M:%S", time());
$sql = "SELECT COUNT(*) FROM items WHERE city LIKE '%$city%'";
$result = mysql_query($sql);
return mysql_result($result, 0);
}
function title_search($keywords){
$returned_results = array();
$where = "";
$created = strftime("%Y-%m-%d %H:%M:%S", time());
$keywords = preg_split('/[\s]+/', $keywords);
$total_keywords = count($keywords);
$table_cols = array('title');
foreach ($keywords as $key => $keyword) {
$where .= "{$table_cols[0]} LIKE '%$keyword%'";
if ($key != $total_keywords-1) {
$where .= " OR ";
}
}
$sql = "SELECT id FROM items WHERE {$where} ORDER BY id DESC LIMIT 1";
$results_num = ($results = mysql_query($sql)) ? mysql_num_rows($results) : 0;
if ($results_num == 0) {
return false;
} else {
while ($results_row = mysql_fetch_assoc($results)) {
$returned_results[] = array('id' => $results_row['id']);
}
return $returned_results;
}
}
//Help Functions
function swearWords($keywords){
$swearWords = array('anal', 'anus', 'arse', 'ass', 'ballsack', 'balls', 'bastard', 'bitch', 'biatch', 'bloody', 'blowjob', 'blow job', 'bollock', 'bollok', 'boner', 'boob', 'bugger', 'bum', 'butt', 'buttplug', 'clitoris', 'cock', 'coon', 'crap', 'cunt', 'damn', 'dick', 'dildo', 'dyke', 'fag', 'feck', 'fellate', 'fellatio', 'felching', 'fuck', 'f u c k', 'fudgepacker', 'fudge packer', 'flange', 'Goddamn', 'God damn', 'hell', 'homo', 'jerk', 'jizz', 'knobend', 'knob end', 'labia', 'lmao', 'lmfao', 'muff', 'nigger', 'nigga', 'omg', 'penis', 'piss', 'poop', 'prick', 'pube', 'pussy', 'queer', 'scrotum', 'sex', 'shit', 's hit', 'sh1t', 'slut', 'smegma', 'spunk', 'tit', 'tosser', 'turd', 'twat', 'vagina', 'wank', 'whore', 'wtf');
foreach($swearWords as $swearWord){
if($keywords == $swearWord){
return true;
}
}
return false;
}
?>