-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
97 lines (82 loc) · 3.41 KB
/
index.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
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>TiredTechnician</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="Description" lang="en" content="A handheld library technician to add books to your LazyLibrarian server">
<meta name="author" content="fireshaper">
<meta name="robots" content="NOINDEX, NOFOLLOW">
<!-- icons -->
<link rel="apple-touch-icon" href="assets/img/apple-touch-icon.png">
<link rel="shortcut icon" href="favicon.ico">
<!-- Override CSS file - add your own CSS rules -->
<link rel="stylesheet" href="assets/css/styles.css">
</head>
<body style="background-color: #000">
<div class="container">
<div class="header">
<h1 class="header-heading"><a href="." >TiredTechnician</a></h1>
<h6>A handheld library technician to add books to your LazyLibrarian server</h6><br />
<div class="nav">
[<a href="index.php">Search</a>] [<a href="wanted.php">Wanted Books</a>]
</div>
</div>
<div class="content">
<div class="info">
<?php
require_once('settings.php');
if (isset($_GET['bookid'])){
addBook($_GET['bookid']);
}
function addBook($bookid){
$addBookResult = file_get_contents($GLOBALS['url'] . '/api?apikey=' . $GLOBALS['apikey'] . '&cmd=addBook&id=' . $bookid );
if ($addBookResult == "OK"){
echo 'New Book added.<br />';
queueBook($bookid);
}
}
function queueBook($bookid){
echo 'Queueing book, please wait.';
//$queueBookResult = file_get_contents($GLOBALS['url'] . '/api?apikey=' . $GLOBALS['apikey'] . '&cmd=queueBook&id=' . $bookid);
while (file_get_contents($GLOBALS['url'] . '/api?apikey=' . $GLOBALS['apikey'] . '&cmd=queueBook&id=' . $bookid) != "OK"){
echo '.';
}
echo '<br />Searching for NZBs, please check your downloader.';
$forceBookSearch = file_get_contents($GLOBALS['url'] . '/api?apikey=' . $GLOBALS['apikey'] . '&cmd=forceBookSearch');
}
?>
</div>
<div class="main">
<h3>Search for (Title/Author/Keyword):</h3>
<form action="index.php" method="post">
<input type="text" name="booksearch"><br />
<input type="submit" value="Search">
</form>
</p>
<?php
if (isset($_POST['booksearch'])){
$booksearch = str_replace(' ', '+', $_POST['booksearch']);
$string = file_get_contents($url . '/api?apikey=' . $apikey . '&cmd=findBook&name="' . $booksearch . '"');
$json_a = json_decode($string, true);
echo '<p>Results:</p>';
foreach ($json_a as $book => $book_a) {
$cover = $book_a['bookimg'];
echo '<table width="100%"><tr>';
echo '<td width="33%"><img src="' . $cover . '" /></td>';
echo '<td width="33%"><b>' . $book_a['bookname'] . '</b><br />';
echo '<em>' . $book_a['authorname'] . '</em></td>';
echo '<td width="33%" style="text-align:center;vertical-align:middle"><a href="?bookid=' . $book_a['bookid'] . '"><button style="padding:15px 32px;background-color:#ffffc7;color:#333333;font-size:16px;font-weight:bold;">Add<br />Book</button></a></td>';
echo '</tr>';
}
echo '</table>';
}
?>
</div>
</div>
<div class="footer">
© Copyright fireshaper 2018
</div>
</div>
</body>
</html>