Ejemplo n.º 1
0
 function handle($params)
 {
     session_write_close();
     header('Connection: close');
     $app = Dataface_Application::getInstance();
     $query = $app->getQuery();
     if (!@$query['job_id']) {
         throw new Exception("NO job id specified");
     }
     if (!@$query['url_hash']) {
         throw new Exception("No URL Hash specified");
     }
     $job = df_get_record('jobs', array('job_id' => '=' . $query['job_id']));
     if (!$job) {
         throw new Exception("Job could not be found.");
     }
     require_once 'inc/SweteJob.class.php';
     require_once 'inc/SweteJobPageSucker.php';
     $jobO = new SweteJob($job);
     $pageSucker = new SweteJobPageSucker($jobO);
     $resource = $pageSucker->loadResource($query['url_hash']);
     if (!$resource) {
         header('HTTP/1.0 404 Not Found');
         exit;
     }
     if (!$job->checkPermission('preview job')) {
         header('HTTP/1.0 400 Permission denied');
         exit;
     }
     $res = df_q("select * from job_content where job_content_id='" . addslashes($resource->val('job_content_id')) . "' limit 1");
     $content = mysql_fetch_object($res);
     $output = $content->content;
     if (preg_match('#css#', $content->content_type)) {
         $output = $pageSucker->renderCss($output, DATAFACE_SITE_HREF . '?-action=swete_job_serve_content&job_id=' . $query['job_id'] . '&url_hash=');
     }
     header('Content-Length: ' . strlen($output));
     header('Content-Type: ' . $content->content_type);
     echo $output;
     flush();
 }