-
Notifications
You must be signed in to change notification settings - Fork 0
/
search.php
129 lines (111 loc) · 3.71 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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>homepage</title>
<link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<h1>Search Page Result</h1>
<?php
$paper_title = $_GET["paper_title"];
if ($paper_title) {
echo "Search for Title: ".$paper_title;
$ch = curl_init();
$timeout = 5;
$query = urlencode(str_replace(' ', '+', $paper_title));
$url = "http://localhost:8983/solr/core_new/select?indent=on&q=Title:".$query."&wt=json";
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$result = json_decode(curl_exec($ch), true);
curl_close($ch);
?>
<table class="table table-bordered">
<thead><tr><th>Title</th><th>Authors</th><th>Conference</th></tr></thead>
<?php
foreach ($result['response']['docs'] as $paper) {
echo "<tbody><tr>";
echo "<td>";
echo $paper['Title'];
echo "</td>";
echo "<td>";
foreach ($paper['AuthorsName'] as $idx => $author) {
$author_id = $paper['AuthorsID'][$idx];
echo "<a href=\"/author.php?author_id=$author_id\">$author</a>; ";
}
echo "</td>";
echo "<td>";
echo $paper['ConferenceName'];
echo "<td>";
echo "</tr></tbody>";
}
echo "</table><br><br>";
}
$Author_Name = $_GET["Author_Name"];
if ($Author_Name) {
echo "Search for Author Name: ".$Author_Name;
$ch = curl_init();
$timeout = 5;
$query = urlencode(str_replace(' ', '+', $Author_Name));
$url = "http://localhost:8983/solr/core_new/select?indent=on&q=AuthorsName:".$query."&wt=json";
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$result = json_decode(curl_exec($ch), true);
curl_close($ch);
echo "<table border=\"1\"><tr><th>Title</th><th>Authors</th><th>Conference</th></tr>";
foreach ($result['response']['docs'] as $paper) {
echo "<tr>";
echo "<td>";
echo $paper['Title'];
echo "</td>";
echo "<td>";
foreach ($paper['AuthorsName'] as $idx => $author) {
$author_id = $paper['AuthorsID'][$idx];
echo "<a href=\"/author.php?author_id=$author_id\">$author</a>; ";
}
echo "</td>";
echo "<td>";
echo $paper['ConferenceName'];
echo "<td>";
echo "</tr>";
}
echo "</table><br><br>";
}
$Conference_Name = $_GET["Conference_Name"];
if ($Conference_Name) {
echo "Search for Conference Name: ".$Conference_Name;
$ch = curl_init();
$timeout = 5;
$query = urlencode(str_replace(' ', '+', $Conference_Name));
$url = "http://localhost:8983/solr/core_new/select?indent=on&q=ConferenceName:".$query."&wt=json";
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$result = json_decode(curl_exec($ch), true);
curl_close($ch);
echo "<table border=\"1\"><tr><th>Title</th><th>Authors</th><th>Conference</th></tr>";
foreach ($result['response']['docs'] as $paper) {
echo "<tr>";
echo "<td>";
echo $paper['Title'];
echo "</td>";
echo "<td>";
foreach ($paper['AuthorsName'] as $idx => $author) {
$author_id = $paper['AuthorsID'][$idx];
echo "<a href=\"/author.php?author_id=$author_id\">$author</a>; ";
}
echo "</td>";
echo "<td>";
echo $paper['ConferenceName'];
echo "<td>";
echo "</tr>";
}
echo "</table><br><br>";
}
?>
</body>
</html>