webkitpdf.php
[app.webkitpdf] / webkitpdf.php
1 <?php
2
3 // a simple service to run webkitpdf and return the PDF...
4 // note - this will only run on localhost by default...
5
6 // needs pear in the 
7 // test:  http://localhost/webkitpdf.php
8
9 // create a simple file:
10 /*
11 ini_set('include_path', 
12             dirname(__FILE__). ':' . 
13             dirname(__FILE__).'/pear:' . 
14             ini_get('include_path'));
15
16 require_once 'webkitpdf.php';
17 new WebkitPdf();
18 */
19
20
21
22 class WebkitPdf
23 {
24     
25     function WebkitPdf()
26     {
27         if (empty($_REQUEST['url'])) {
28             $this->h404("missing url");
29         }
30         
31         require_once 'System.php';
32         
33         $xvfb = System::which('xvfb');
34         if (empty($xvfb)) {
35             $this->h404("missing xvfb");
36         }
37         
38         $webkitpdf = System::which('webkitpdf');
39         if (empty($webkitpdf )) {
40             $this->h404("missing webkitpdf (compile it..)");
41         }
42         // max delay 20 seconds.? bit generous..
43         $delay = empty($_REQUEST['delay']) ? 1 : max(20,$_REQUEST['delay']);
44         
45         //?? allow injections?
46         // not yet..
47         
48         $cmd = "$xvfb --auto-servernum $webkitpdf  " .
49                 " --url " . escapeshellarg($_REQUEST['url']) . ' '
50                 " --pdf " . $tmpfile . ' '
51                 
52         
53         
54         
55     }
56     
57 }