From 3d0d216af081afb409a60acbcd885b11448626cb Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Tue, 7 Feb 2023 14:33:35 +0000 Subject: [PATCH] wait #5716 @1 --- inc/ws/Controlleur/class.ws.flash.php | 7 +++--- inc/ws/Metier/class.ws.document.php | 32 ++++++++++++++++----------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/inc/ws/Controlleur/class.ws.flash.php b/inc/ws/Controlleur/class.ws.flash.php index e01336eb8..f870ece19 100644 --- a/inc/ws/Controlleur/class.ws.flash.php +++ b/inc/ws/Controlleur/class.ws.flash.php @@ -345,6 +345,7 @@ class wsFlash extends cubeFlashGateway public function getPagesOfBook() { global $core; + set_time_limit(0); $this->json = true; @@ -357,8 +358,8 @@ class wsFlash extends cubeFlashGateway 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; @@ -388,7 +389,7 @@ class wsFlash extends cubeFlashGateway } else { $this->jsonDatas['numerotation'] = explode(',', $book->numerotation); } - error_log(json_encode($this->jsonDatas)); + //error_log(json_encode($this->jsonDatas)); } public function getTheme() diff --git a/inc/ws/Metier/class.ws.document.php b/inc/ws/Metier/class.ws.document.php index aea4e34cd..c961c6b9f 100644 --- a/inc/ws/Metier/class.ws.document.php +++ b/inc/ws/Metier/class.ws.document.php @@ -472,7 +472,7 @@ class wsDocument extends cubeMetier 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( @@ -483,7 +483,7 @@ class wsDocument extends cubeMetier ); } - 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))); @@ -496,19 +496,25 @@ class wsDocument extends cubeMetier $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"; -- 2.39.5