public function getPagesOfBook()
{
global $core;
+ set_time_limit(0);
$this->json = true;
foreach ($pages as $page => $info) {
//$book->getFile($page, 'swf', 150);
$book->getFile($page, 'jpg', 150, true, true, 'html');
- $book->getFile($page, 'jpg', 'thumb');
- $file = WS_DOCS . '/' . $info['document_id'] . '/p' . $info['document_page'] . '.jpg';
+ $file=$book->getFile($page, 'jpg', 'thumb');
+ //$file = WS_DOCS . '/' . $info['document_id'] . '/p' . $info['document_page'] . '.jpg';
if (!file_exists($file)) {
$info['resolution'] = 150;
$info['method'] = 1;
} else {
$this->jsonDatas['numerotation'] = explode(',', $book->numerotation);
}
- error_log(json_encode($this->jsonDatas));
+ //error_log(json_encode($this->jsonDatas));
}
public function getTheme()
return self::$_farmServers[$i];
}
- public static function getFCGIConnexion(array $farm, $timeout = 30): NetworkSocket
+ public static function getFCGIConnexion(array $farm, $timeout = 120): NetworkSocket
{
$timeout *= 1000;
return new NetworkSocket(
);
}
- public static function sendRequest($farmer, $url, $params = [], $timeout = 30)
+ public static function sendRequest($farmer, $url, $params = [], $timeout = 120)
{
$client = new Client();
$response = $client->sendRequest(self::getFCGIConnexion($farmer, $timeout), new PostRequest($url, http_build_query($params)));
$farmer = self::pickOneFarmServer();
$params = ['page' => $page, 'format' => $format, 'resolution' => $resolution, 'withText' => $withText, 'withGraphics' => $withGraphics, 'version' => $version, 'force' => $force, 'out' => $this->out, 'resolutionRatio' => $this->getResolutionRatio(), 'mobileRatio' => $this->getMobileFirstRatio()];
- $output = self::sendRequest($farmer, 'process.php', $params);
- if (preg_match('|/data1/extranet/www/[^\s]+|', $output, $matches)) {
- $o = $matches[0];
- } else {
- $o = $output;
- }
- $o = str_replace('/data1/extranet/www/', '/application/', $o);
- if (file_exists($o)) {
- $res = $o;
- } else {
- echo $output;
+ try {
+ $output = self::sendRequest($farmer, 'process.php', $params);
+ if (preg_match('|/data1/extranet/www/[^\s]+|', $output, $matches)) {
+ $o = $matches[0];
+ } else {
+ $o = $output;
+ }
+ $o = str_replace('/data1/extranet/www/', '/application/', $o);
+ if (file_exists($o)) {
+ $res = $o;
+ } else {
+ echo $output;
+ $res = false;
+ }
+ } catch (Exception $e) {
+ $output = 'error : on page ' . json_encode($params) . ' : ' . $e->getMessage();
$res = false;
}
+
$time = round(microtime(true) - $start, 4);
$log = '[' . $farmer['name'] . ']' . "\t" . date('Y-m-d H:i:s') . "\t\t\t\t" . $time . "\t\t\t\t$page|$format|$resolution|$withText|$withGraphics|$version\t\t\t\t$res\t\t\t\t$output\n";