'); } if (!is_dir($cache)) { mkdir($cache); file_put_contents($cache . 'index.php', ''); } $w = 1024; $h = 768; if (isset($_REQUEST['w'])) { $w = intval($_REQUEST['w']); } if (isset($_REQUEST['h'])) { $h = intval($_REQUEST['h']); } if (isset($_REQUEST['clipw'])) { $clipw = intval($_REQUEST['clipw']); } if (isset($_REQUEST['cliph'])) { $cliph = intval($_REQUEST['cliph']); } if (isset($_REQUEST['download'])) { $download = $_REQUEST['download']; } $url = strip_tags($url); $url = str_replace(';', '', $url); $url = str_replace('"', '', $url); $url = str_replace('\'', '/', $url); $url = str_replace('= $cache_life)) { $refresh = true; } if (isset($_GET['cache'])) { if($_GET['cache']==0) $refresh = true; } } //$url = escapeshellcmd($url); if (!is_file($cache_job) or $refresh == true) { $src = " var page = require('webpage').create(); page.viewportSize = { width: {$w}, height: {$h} }; "; if (isset($clipw) && isset($cliph)) { $src .= "page.clipRect = { top: 0, left: 0, width: {$clipw}, height: {$cliph} };"; } $src .= " page.open('{$url}', function () { page.render('{$screen_file}'); phantom.exit(); }); "; $job_file = $jobs . $url_segs['host'] . crc32($src) . '.js'; file_put_contents($job_file, $src); $exec = $bin_files . 'phantomjs ' . $job_file; //$escaped_command = escapeshellcmd($exec); $escaped_command = $exec; exec($escaped_command); if (is_file($here . $screen_file)) { @rename($here . $screen_file, $cache_job) ; } } if (is_file($cache_job)) { if ($download != false) { $file = $cache_job; $file_name=basename($file); $type = 'image/jpeg'; header("Content-disposition: attachment; filename={$file_name}"); header("Content-type: {$type}"); readfile($file); } else { $file = $cache_job; $type = 'image/jpeg'; header('Content-Type:' . $type); header('Content-Length: ' . filesize($file)); readfile($file); } }