示例#1
0
<?php

require_once 'process.php';
require_once 'utils.php';
if (!isset($_GET["key"])) {
    httpResponseCode("400 Bad Request", "Missing parameter \"key\"");
    die;
}
$key = $_GET["key"];
$format = $_GET["format"];
$bs = new BookStatus();
try {
    $bs->checkOriginal($key);
    $status = $bs->checkConverted($key, $format);
    // generate response json
    header('Content-type: application/json');
    $response = "{\n        'status'    : '{$status}',\n        'source'    : '{$bs->fbFile}',\n        'converted' : '{$bs->convFile}',\n        'log'       : '{$bs->logFile}'\n    }";
    echo $response;
} catch (Exception $e) {
    error_log("FB2PDF ERROR. Status: " . $e->getMessage());
    httpResponseCode("400 Bad Request", $e->getMessage());
}
示例#2
0
<?php

require_once 'utils.php';
require_once 'db.php';
require_once 'process.php';
require_once 'book_status.php';
if (!isset($_GET['key'])) {
    httpResponseCode("400 Bad Request", "Missing parameter \"key\"");
    die;
}
$key = removeExt($_GET['key']);
$bs = new BookStatus();
$cb = new ConvertBook();
try {
    $bs->checkOriginal($key);
    // get book info
    $db = getDBObject();
    $bookInfo = $db->getBookByKey($key);
    $id = $bookInfo["id"];
    $title = $bookInfo["title"];
    $author = $bookInfo["author"];
    if (!$author) {
        $author = "Автор неизвестен";
    }
    if (!$title) {
        $title = "Название неизвестно";
    }
    $formats = $db->getFormats();
} catch (Exception $e) {
    error_log("FB2PDF ERROR. Status: " . $e->getMessage());
    httpResponseCode("400 Bad Request", $e->getMessage());