<?php require_once 'utils.php'; require_once 'process.php'; header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); if (isset($_REQUEST["key"]) and isset($_REQUEST["format"])) { $key = $_REQUEST["key"]; $format = $_REQUEST["format"]; $conv = new ConvertBook(); try { $conv->convertFromS3($key, $format); httpRedirect("status.php?key={$key}&format={$format}"); } catch (Exception $e) { error_log("FB2PDF ERROR. Convert: " . $e->getMessage()); httpResponseCode("400 Bad Request", "Ошибка конвертации. Пожалуйста, попробуйте ешё раз."); } } else { if (isset($_REQUEST["url"])) { // redirect to the index page $url = $_REQUEST["url"]; if (isset($_REQUEST["auto"])) { httpRedirect("uploader.php?url={$url}"); } else { httpRedirect("index.php?url={$url}"); } } else { httpResponseCode("400 Bad Request", "Missing parameter \"url\""); } }
<?php require_once 'process.php'; require_once 'utils.php'; $url = isset($_GET["url"]) ? $_GET["url"] : null; $email = isset($_POST["email"]) ? $_POST["email"] : null; if (isset($_POST["format"])) { $format = $_POST["format"]; } if (!$format || $format == '') { $format = 1; } $conv = new ConvertBook(); $file = null; try { if ($url || $_POST['uploadtype'] == 'url') { $file = $url ? $url : $_POST['url']; $conv->convertFromUrl($file, $format, $email); } else { if ($_POST['uploadtype'] == 'file') { $err_upload = $_FILES['fileupload']['error']; if ($err_upload == UPLOAD_ERR_OK) { // check uploaded file $path = $_FILES['fileupload']['tmp_name']; $file = $_FILES['fileupload']['name']; $conv->convertFromFile($path, $file, $format, $email); } else { // deal with errors if ($err_upload == UPLOAD_ERR_INI_SIZE || $err_upload == UPLOAD_ERR_FORM_SIZE) { throw new Exception("The uploaded file exceeds the maximum allowed size.", ConvertBook::ERR_SIZE); } else {
<html> <body> <?php require_once '../process.php'; try { $p = new ConvertBook(); $p->convertFromUrl("http://google.com"); print "OK"; } catch (Exception $e) { print $e->getCode() . " - " . $e->getMessage(); } ?> </body> </html>
<?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());
<?php require_once 'process.php'; require_once 'utils.php'; if (!isset($_GET["url"])) { httpResponseCode("400 Bad Request", "Missing paremeter \"url\""); die; } try { $conv = new ConvertBook(); $conv->convertFromUrl($_GET["url"], $_GET["format"]); $key = $conv->bookKey; $author = $conv->book->author; $title = $conv->book->title; // generate response header('HTTP/1.0 200 OK'); header('Content-type: application/json'); $response = "{\n 'key' : '{$key}',\n 'author': '{$author}',\n 'title' : '{$title}'\n }"; echo $response; } catch (Exception $e) { $errCode = null; if ($e->getCode() == ConvertBook::ERR_ILLEGAL_ARG) { $errCode = "400 Bad Request"; } else { if ($e->getCode() == ConvertBook::ERR_LOAD) { $errCode = "400 Bad Request"; } else { if ($e->getCode() == ConvertBook::ERR_FORMAT) { $errCode = "404 Not Found"; } else { if ($e->getCode() == ConvertBook::ERR_CONVERT) {
<?php require_once 'process.php'; require_once 'utils.php'; $password = trim($_POST['pass']); $email = trim($_POST['email']); $key = trim($_POST['key']); $status = trim($_POST['status']); if (isset($_POST['ver'])) { $ver = trim($_POST['ver']); } else { $ver = 0; } if (isset($_POST['format'])) { $format = trim($_POST['format']); } if (!$format || $format == '') { $format = 1; } try { $conv = new ConvertBook(); $conv->converted($email, $password, $key, $status, $ver, $format); httpResponseCode("200 OK"); } catch (Exception $e) { error_log("FB2PDF ERROR. Callback: " . $e->getMessage()); httpResponseCode("400 Bad Request", $e->getMessage()); }