autoJoin(); $file_broken = realpath('Pman/templates/images/file-broken.png'); if(empty($id) || !$cms_page->get($id)){ $this->serve($file_broken); } if ($cms_page->page_type_id_name == 'element') { $cms_page = $cms_page->parent(); } if($cms_page->page_type_id_name != 'page'){ $this->serve($file_broken); } $opts = HTML_FlexyFramework::get()->Pman_Cms; if (!isset($opts['basePHP'])) { $this->serve($file_broken); } $basePHP = $opts['basePHP']; $strip = 0; $pl = $cms_page->page_link; if (is_array($opts['basePHP'])) { foreach($opts['basePHP'] as $k=>$v) { if ($k == substr($pl,0, strlen($k))) { $pl = substr($pl, strlen($k)+1); $basePHP = $v; $matched = true; break; } } if (!$matched) { $this->serve($file_broken); } } switch($pl) { case 'Home': case 'Site': $pl = ''; break; default: if($pl[0] != '/') { $pl = '/' . $pl; } break; } $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://"; $url = $protocol . $_SERVER['HTTP_HOST'] . $this->rootURL .'/'. $basePHP . $pl; $file = $cms_page->getStoreName(); if(file_exists($file) && strtotime($cms_page->updated) < filemtime($file)){ $this->serve($file); } require_once 'System.php'; $conv = System::which('wkhtmltoimage'); if (!$conv) { $this->jerr("missing wkhtmltoimage"); } $xvfb = System::which('xvfb-run'); if (!$xvfb) { $this->jerr("missing xvfb-run"); } $cmd = $xvfb . ' --auto-servernum ' . $conv . ' --width 300 --height 300 --zoom 0.3 --disable-smart-width --enable-javascript --javascript-delay 1000 ' . escapeshellarg($url) . ' ' .escapeshellarg($file); exec($cmd); if(!file_exists($file)){ $this->serve($file_broken); } $this->serve($file); exit; } function serve($file) { $this->sessionState(0); require_once 'File/Convert.php'; $fc = new File_Convert($file, 'image/png'); $fc->convert('image/png'); $fc->serve('inline'); exit; } }