-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsearchOLBookData.php
More file actions
77 lines (56 loc) · 1.82 KB
/
searchOLBookData.php
File metadata and controls
77 lines (56 loc) · 1.82 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
<?php
$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$starttime = $mtime;
require_once dirname(__FILE__).'/inc/APIResponse.php';
require_once dirname(__FILE__).'/inc/OpenLibrary.php';
header ("content-type: application/json");
$tokenLookup = $_ENV['FF_API_TOKEN'];
$dbHost = $_ENV['FF_DB_MYSQL_HOST'];
$dbUsername = $_ENV['FF_DB_MYSQL_USERNAME'];
$dbPassword = $_ENV['FF_DB_MYSQL_PASSWORD'];
$returnVal = new APIResponse();
$returnVal->response = array();
$returnVal->http_response = 200;
$returnVal->message = "";
if( !isset( $_REQUEST['token'] ) )
{
$msg = 'token is missing';
$returnVal->http_response = 400;
$returnVal->message = $msg;
$returnVal->ex_time = microtime(true) - $starttime;
header("HTTP/1.1 400 $msg");
echo json_encode($returnVal);
return FALSE;
}
$token = $_REQUEST['token'];
if( $token != $tokenLookup )
{
$msg = 'token is incorrect';
$returnVal->http_response = 400;
$returnVal->message = $msg;
$returnVal->ex_time = microtime(true) - $starttime;
header("HTTP/1.1 400 $msg");
echo json_encode($returnVal);
return FALSE;
}
if( !isset( $_REQUEST['searchstr'] ) )
{
$msg = 'search string is missing';
$returnVal->http_response = 400;
$returnVal->message = $msg;
$returnVal->ex_time = microtime(true) - $starttime;
header("HTTP/1.1 400 $msg");
echo json_encode($returnVal);
return FALSE;
}
$searchstr = $_REQUEST['searchstr'];
$dbConfigArray = array();
$dbConfigArray['config_db_read_host'] = $dbHost;
$dbConfigArray['config_db_read_user'] = $dbUsername;
$dbConfigArray['config_db_read_pass'] = $dbPassword;
$checkVal = OpenLibrary::search( $searchstr, $dbConfigArray );
$returnVal->response['searchresults'] = $checkVal;
$returnVal->ex_time = microtime(true) - $starttime;
echo json_encode( $returnVal );