webkitpdf.php
authorAlan Knowles <alan@roojs.com>
Mon, 23 Nov 2015 05:31:41 +0000 (13:31 +0800)
committerAlan Knowles <alan@roojs.com>
Mon, 23 Nov 2015 05:31:41 +0000 (13:31 +0800)
webkitpdf.php

index 663c6e0..c8683a0 100644 (file)
@@ -30,6 +30,11 @@ class WebkitPdf
         
         require_once 'System.php';
         
+        $timeout= System::which('timeout');
+        if (empty($timeout)) {
+            $this->h404("missing timeout");
+        }
+        
         $xvfb = System::which('xvfb');
         if (empty($xvfb)) {
             $this->h404("missing xvfb");
@@ -49,8 +54,8 @@ class WebkitPdf
         unlink($outpr);
         $out = $outpr .'.pdf';
         
-        $cmd = "$xvfb --auto-servernum $webkitpdf  " .
-                " --url " . escapeshellarg($_REQUEST['url']) . ' '
+        $cmd = "timeout 30s $xvfb --auto-servernum $webkitpdf  " .
+                " --url " . escapeshellarg($_REQUEST['url']) . ' ' .
                 " --pdf " . $tmpfile . ' ';