-
Notifications
You must be signed in to change notification settings - Fork 5
/
search.php
340 lines (228 loc) · 12.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
<?php
/**
* Allomani Audio & Video (Songs) v3.0
*
* @package Allomani.Songs
* @version 3.0
* @copyright (c) 2006-2018 Allomani , All rights reserved.
* @author Ali Allomani <[email protected]>
* @link http://allomani.com
* @license GNU General Public License version 3.0 (GPLv3)
*
*/
require("global.php");
require(CWD . "/includes/framework_start.php");
//----------------------------------------------------
if($settings['enable_search']){
$keyword = trim($keyword);
if(strlen($keyword) >= $settings['search_min_letters']){
$keyword = htmlspecialchars($keyword);
compile_hook('search_start');
open_table("$phrases[search_results]" );
if(!$op || $op=="songs"){
$field_id = (int) $field_id;
//----------------- start pages system ----------------------
$start=intval($start);
$page_string= "search.php?op=songs&".iif($ext,"ext=".intval($ext)."&").iif($c_ext,"c_ext=".htmlspecialchars($c_ext)."&").iif($field_id,"field_id=".intval($field_id)."&")."keyword=".urlencode($keyword)."&start={start}" ;
$perpage = $settings['songs_perpage'] ;
//--------------------------------------------------------------
/* if($full_text_search && strlen($keyword) >=4){
$qr=db_query("select *,match(name) against('".db_escape($keyword)."') as score from songs_songs where match(name) against('".db_clean_string($keyword,"code","read")."') order by score desc limit $start,$perpage");
$page_result=db_qr_fetch("select count(*) as count from songs_songs where match(name) against('".db_clean_string($keyword,"code","read")."')");
}else{ */
if($ext){
$by_field_query = "( songs_songs.ext='".intval($ext)."'";
if($global_songs_exts[$ext]['period_from'] || $global_songs_exts[$ext]['period_to']){
$time_from = time() - ($global_songs_exts[$ext]['period_from']*60*60*24);
$time_to = time() - ($global_songs_exts[$ext]['period_to']*60*60*24);
$by_field_query .= " or ( songs_songs.date <= $time_from and songs_songs.date >= $time_to and ext=0 )";
}
$by_field_query .= " ) ";
}else{
$by_field_query = iif($field_id,"songs_songs.field_".$field_id ." like '".db_escape($keyword)."' ",iif($c_ext,"songs_songs.c_ext like '".db_escape($keyword)."' ","songs_songs.name like '%".db_escape($keyword)."%' "));
}
$qr = db_query("select songs_songs.*,songs_singers.name as singer_name,songs_singers.id as singer_id , songs_singers.page_name as singer_page_name from songs_songs,songs_singers where ".$by_field_query." and songs_singers.id = songs_songs.album order by name asc limit $start,$perpage");
// }
if(db_num($qr)){
$page_result = db_qr_fetch("select count(*) as count from songs_songs where ".$by_field_query);
// $lyrics_count = valueof(db_qr_fetch("select count(*) as count from songs_songs where ".$by_field_query." and trim(lyrics)!='' limit $start,$songs_perpage"),"count");
//$videos_count = valueof(db_qr_fetch("select count(*) as count from songs_songs where ".$by_field_query." and video_id > 0 limit $start,$songs_perpage"),"count");
//--- save results to array -----------
unset($saved_results);
$lyrics_count = 0;
$videos_count = 0;
while($data = db_fetch($qr)){
$saved_results[] = $data;
if($data['lyrics']){$lyrics_count++;}
if($data['video_id']){$videos_count++;}
}
//------------------------------------
run_template("browse_songs_header");
$tr_ord = 1 ;
foreach($saved_results as $data){
$song_ext = get_song_ext($data['ext'],$data['date']) ;
if($tr_class=="row_1"){
$tr_class="row_2" ;
}else{
$tr_class="row_1";
}
$data_singer['name'] = $data['singer_name'];
$data_singer['id'] = $data['singer_id'];
$data_singer['page_name'] = $data['singer_page_name'];
// $data['name'] = str_replace("$keyword","<font class=\"search_replace\">$keyword</font>",$data['name']);
// print "<tr class='$tr_class'>";
//------------ sync urls data ------------//
run_template('browse_songs');
// print "</tr>";
}
run_template('browse_songs_footer');
//-------------------- pages system ------------------------
print_pages_links($start,$page_result['count'],$perpage,$page_string);
//------------ end pages system -------------
}else{
print "<center> $phrases[no_results] </center>";
}
//---------------------------------------------------------------------------------
}elseif($op=="videos"){
//----------------- start pages system ----------------------
$start=intval($start);
$page_string= "search.php?op=videos&keyword=".urlencode($keyword)."&start={start}" ;
$perpage = $settings['videos_perpage'] ;
//--------------------------------------------------------------
$qr=db_query("select a.*,b.name as cat_name , b.id as cat_id from songs_videos_data a , songs_videos_cats b where a.name like '%".db_escape($keyword)."%' and b.id=a.cat limit $start,$perpage");
if(db_num($qr)){
$page_result = db_qr_fetch("select count(*) as count from songs_videos_data where name like '%".db_escape($keyword)."%'");
run_template('browse_videos_header');
$c=0;
while($data = db_fetch($qr)){
if ($c==$settings['songs_cells']) {
run_template("browse_videos_sep");
$c = 0 ;
}
$data_cat['name'] = $data['cat_name'];
$data_cat['id'] = $data['cat_id'];
run_template('browse_videos');
$c++;
}
run_template('browse_videos_footer');
//-------------------- pages system ------------------------
print_pages_links($start,$page_result['count'],$perpage,$page_string);
//-----------------------------
}else{
print "<center> $phrases[no_results] </center>";
}
//--------------------- singers -----------------------
}elseif($op=="singers"){
/*if($full_text_search && strlen($keyword) >=4){
$qr=db_query("select *,match(name) against('".db_clean_string($keyword,"code","read")."') as score from songs_singers where match(name) against('".db_clean_string($keyword,"code","read")."') order by score desc limit $start,$perpage");
}else{ */
//$qr = db_query("select * from songs_singers where name like '%".db_clean_string($keyword,"code")."%' order by binary name ASC");
//}
$field_id = (int) $field_id;
//----------------- start pages system ----------------------
$start=intval($start);
$page_string= "search.php?op=singers&".iif($field_id,"field_id=".intval($field_id)."&")."keyword=".urlencode($keyword)."&start={start}" ;
$perpage = $settings['singers_perpage'] ;
//--------------------------------------------------------------
$by_field_query = iif($field_id,"field_".$field_id." like '".db_escape($keyword)."'","name like '%".db_escape($keyword)."%'");
$qr = db_query("select songs_singers.*,songs_cats.name as cat_name , songs_cats.id as cat_id , songs_cats.page_name as cat_page_name from songs_singers,songs_cats where songs_singers.active=1 and songs_singers.cat=songs_cats.id and songs_cats.active=1 and songs_singers.".$by_field_query." order by songs_singers.name asc limit $start,$perpage");
if(db_num($qr)){
$page_result = db_qr_fetch("select count(*) as count from songs_singers where ".$by_field_query);
print "<table width=100%><tr>";
while($data = db_fetch($qr)){
// $data_cat = db_qr_fetch("select id,name from songs_cats where id='$data[cat]'");
if ($c==$settings['songs_cells']) {
print " </tr><TR>" ;
$c = 0 ;
}
++$c ;
// $singer_songs_count = db_qr_fetch("select count(id) as count from songs_songs where album='$data[id]'");
print "<td>";
run_template('browse_singers');
print "</td>";
}
print "</tr></table>";
print_pages_links($start,$page_result['count'],$perpage,$page_string);
}else{
print "<center> $phrases[no_results] </center>";
}
//----------- albums ---------------
}elseif($op=="albums"){
/*if($full_text_search && strlen($keyword) >=4){
$qr=db_query("select *,match(name) against('".db_clean_string($keyword,"code","read")."') as score from songs_singers where match(name) against('".db_clean_string($keyword,"code","read")."') order by score desc limit $start,$perpage");
}else{ */
//$qr = db_query("select * from songs_singers where name like '%".db_clean_string($keyword,"code")."%' order by binary name ASC");
//}
$field_id = (int) $field_id;
//----------------- start pages system ----------------------
$start=intval($start);
$page_string= "search.php?op=albums&".iif($field_id,"field_id=".intval($field_id)."&").iif($year,"year=".intval($year)."&")."keyword=".urlencode($keyword)."&start={start}" ;
$perpage = $settings['albums_perpage'] ;
//--------------------------------------------------------------
$by_field_query = iif($year,"year like '".db_escape($keyword)."'",iif($field_id,"field_".$field_id." like '".db_escape($keyword)."'","name like '%".db_escape($keyword)."%'"));
$qr = db_query("select songs_albums.*,songs_singers.name as singer_name , songs_singers.id as singer_id , songs_singers.page_name as singer_page_name from songs_singers,songs_albums where songs_singers.id=songs_albums.cat and songs_albums.".$by_field_query." order by songs_albums.year desc , id desc limit $start,$perpage");
if(db_num($qr)){
print "<table width=100%><tr>";
while($data_album = db_fetch($qr)){
$page_result = db_qr_fetch("select count(*) as count from songs_albums where ".$by_field_query);
// $data_cat = db_qr_fetch("select id,name from songs_cats where id='$data[cat]'");
if ($c==$settings['songs_cells']) {
print " </tr><TR>" ;
$c = 0 ;
}
++$c ;
// $singer_songs_count = db_qr_fetch("select count(id) as count from songs_songs where album='$data[id]'");
print "<td>";
run_template('browse_albums');
print "</td>";
}
print "</tr></table>";
print_pages_links($start,$page_result['count'],$perpage,$page_string);
}else{
print "<center> $phrases[no_results] </center>";
}
//-----------------------------------------------------
}elseif($op=="news"){
//----------------- start pages system ----------------------
$start=intval($start);
$page_string= "search.php?op=news&keyword=".urlencode($keyword)."&start={start}" ;
$news_perpage = $settings['news_perpage'];
//--------------------------------------------------------------
$qr = db_query("select * from songs_news where title like '%".db_escape($keyword)."%' or content like '%".db_escape($keyword)."%' or details like '%".db_escape($keyword)."%' order by id desc limit $start,$news_perpage");
if(db_num($qr)){
$page_result = db_qr_fetch("select count(*) as count from songs_news where title like '%".db_escape($keyword)."%' or content like '%".db_escape($keyword)."%' or details like '%".db_escape($keyword)."%'");
// run_template("browse_news_header");
while($data = db_fetch($qr)){
/* if ($c==$settings['songs_cells']) {
run_template("browse_news_sep");
$c = 0 ;
}
++$c ;*/
run_template('browse_news');
}
//run_template('browse_news_footer');
//-------------------- pages system ------------------------
print_pages_links($start,$page_result['count'],$news_perpage,$page_string);
//------------ end pages system -------------
}else{
print "<center> $phrases[no_results] </center>";
}
}
//-----------------------------------------------------
close_table();
compile_hook('search_end');
//----------------
}else{
open_table();
$phrases['type_search_keyword'] = str_replace('{letters}',$settings['search_min_letters'],$phrases['type_search_keyword']);
print "<center> $phrases[type_search_keyword] </center>";
close_table();
}
}else{
open_table();
print "<center> $phrases[sorry_search_disabled]</center>";
close_table();
}
//---------------------------------------------------
require(CWD . "/includes/framework_end.php");
?>