-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsearch.php
More file actions
46 lines (27 loc) · 934 Bytes
/
search.php
File metadata and controls
46 lines (27 loc) · 934 Bytes
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
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
include('NetSearcher.php');
include('DBComparator.php');
use DBComparator\DBComparator;
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
session_start();
$text = $_POST['text'];
$searchType = $_POST['searchType'];
$_SESSION['text'] = $text;
$searcher = new NetSearcher($searchType);
try {
$links = $searcher->perform($text);
} catch (Google\Service\Exception $e) {
header("HTTP/1.1 500 Internal Server Error");
die("'error':'limit has become empty'");
}
// $dbComparator = new DBComparator();
// $articles = $dbComparator->perform($text);
// foreach ($articles as $article) {
// $html .= '<div> <b>ID:</b>' . $article->id .
// ' <b>Совпадение:</b>' . $article->similarity . '%</div><br>';
// }
echo json_encode($links);
}