-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimages-search.php
91 lines (72 loc) · 2.63 KB
/
images-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
<link rel="stylesheet" href="<?php echo $_REQUEST['path_base']?>sites/all/themes/assets/css/lightbox.min.css">
<script src="<?php echo $_REQUEST['path_base']?>sites/all/themes/assets/scripts/lightbox-plus-jquery.min.js"></script>
<?php
$q=$_REQUEST['input'];
if (empty($q)) {
print("No Result Found");
exit();
}
if($_SERVER['HTTP_HOST']=='localhost')
{
include 'C:\sphinx2210\api\sphinxapi.php';
}
else if($_SERVER['HTTP_HOST']=='MYSERVER.com')
{
include '/etc/sphinx/sphinxapi.php';
}
else
{
include '/etc/sphinx/sphinxapi.php';
}
// Build search query
$cl2 = new SphinxClient();
if($_SERVER['HTTP_HOST']=='localhost')
{
$cl2->SetServer( "localhost", 3312 );
}
else
{
$cl2->SetServer( "localhost", 9312 );
}
$cl2->SetLimits(0, 250);
$cl2->SetMatchMode(SPH_MATCH_EXTENDED);
$cl2->SetRankingMode ( SPH_RANK_SPH04 );
// Execute the query
if($_REQUEST['lang_name']=='en')
$q2 = '"' . $cl2->EscapeString($_REQUEST['input']) . '"/1';
//$q2 = '"' . $cl2->EscapeString($_REQUEST['input']) . '"/1 @lang en';
else
$q2 = '"' . $cl2->EscapeString($_REQUEST['input']) . '"/1';
//$q2 = '"' . $cl2->EscapeString($_REQUEST['input']) . '"/1 @lang ar';
if($_REQUEST['lang_name']=='en')
$indexer_name = 'drupal_images_search';
else
$indexer_name = 'drupal_images_search_arabic';
$searchresults2 = $cl2->Query('@(img_names) '.$q2, $indexer_name );
print_r($cl2-> GetLastError());
if (!isset($searchresults2["matches"]) )
{
print("No Result Found");
exit();
}
$keys = array_keys($searchresults2['matches']);
$count=count($keys);
echo '<div class="gallery-search">';
for ($i = 0; $i < $count; $i++) {
$name = $searchresults2['matches'][$keys[$i]]['attrs']['img_names'];
$dir = $searchresults2['matches'][$keys[$i]]['attrs']['dir'];
//print $src = $dir .$name ;
$src = $_REQUEST['path_base'].$dir .$name ;
$alt = substr($name, 0 , -4);
// echo '<div class="col-md-4 col-xl-4 media"><img class="myImg" id="'.$keys[$i].'" src="'.$src.'" onclick="image(this)" alt="'.$alt.'" ></div>';
//echo '<div class="col-md-4 col-xl-4 media"><a href=class="example-image-link" data-lightbox="example-set"> <img class="myImg" id="'.$keys[$i].'" src="'.$src.'" alt="'.$alt.'" ></a></div>';
echo'<div class="col-md-4 col-xl-4 media"><a class="example-image-link" href="'.$src.'" data-lightbox="example-set" data-title="'.$name.'"><img class="example-image" id="'.$keys[$i].'" src="'.$src.'" alt="'.$alt.'" /></a></div>';
}
echo '</div>';
echo '<!-- The Modal -->
<div id="SearchImgModal" class="search-modal">
<span class="close">×</span>
<img class="search-modal-content" id="img01">
<div id="caption"></div>
</div>' ;
?>