Exemple #1
0
function date_safe($string)
{
    if (preg_match("/(\\d{4})/", $string, $matches)) {
        return $matches[0];
    } else {
        return xml_safe($string);
    }
}
    }
}
// get job status from Movie Masher Server, and check for error
if (!$err) {
    $path_media .= authenticated_userid() . '/';
    $start = empty($_REQUEST['start']) ? 0 : $_REQUEST['start'];
    try {
        $get_target = $job;
        if ($moviemasher_client->progressesLocally()) {
            $media_host = $uploads_locally ? $renders_locally ? $moviemasher_file->getOption('HostLocal') : $moviemasher_file->getOption('Host') : $moviemasher_file->getOption('HostMedia');
            $get_target = 'http://' . $media_host . '/' . $path_media . $id . '/';
            $get_target = meta_file_path('progress', $get_target);
        }
        $progress = $moviemasher_client->get('encode', $get_target);
    } catch (Exception $ex) {
        $err = xml_safe($ex->getMessage());
    }
}
if (!$err) {
    $attrs = '';
    // if job is still processing, redirect back here with same parameters
    if ($progress['percent'] < 100) {
        $progress['percent'] = max(1, $start + $progress['percent'] / 100 * (100 - $start));
        $attrs = ' delay="5" url="media/php/encoding.php?job=' . $job . '&amp;id=' . $id . '&amp;start=' . $start . '"';
    } else {
        if (!$moviemasher_file->uploadsLocally()) {
            $media_dir = 'http://' . $moviemasher_file->getOption('HostMedia') . '/';
        } else {
            $media_dir = $moviemasher_client->getOption('DirHost');
        }
        $media_dir .= $path_media . $id . '/';
 function _codeJob()
 {
     // at this point this is only called by Daemon::Local
     $ex = FALSE;
     try {
         $this->_validateJob($this->_jobXML);
         $type = MovieMasher_Daemon::jobType($this->_jobXML);
         $coder = $this->_coder($type);
         $coder->codeFile($this->_jobID);
     } catch (Exception $ex) {
         $ex = $ex->getMessage();
     }
     // even if there was an error we want to make sure there's a progress file for job
     $dir_cache = $this->_options['DirCache'];
     if ($dir_cache) {
         $progress_path = $dir_cache . $this->_jobID . '/media.xml';
         if ($ex || !file_exists($progress_path)) {
             $xml_string = '';
             $xml_string .= '<Progress>' . "\n";
             $xml_string .= "\t" . '<PercentDone>-1</PercentDone>' . "\n";
             $xml_string .= "\t" . '<Date>' . http_date_string() . '</Date>' . "\n";
             $xml_string .= "\t" . '<Status>' . xml_safe($ex) . '</Status>' . "\n";
             $xml_string .= '</Progress>' . "\n";
             if (safe_path($progress_path) && @file_put_contents($progress_path, $xml_string)) {
                 set_file_info($progress_path, 'cached', gmdate("Y-m-d H:i:s"));
             }
         }
     }
     try {
         $this->__codedFile();
     } catch (Exception $ex2) {
         $ex = $ex2->getMessage();
     }
     // wait for any child processes to die
     while (pcntl_waitpid(-1, $status, WNOHANG) > 0) {
     }
     if ($ex) {
         throw new RuntimeException($ex);
     }
 }
 function __outputProgress($s)
 {
     if ($s) {
         $dir_cache = $this->getOption('DirCache');
         if ($dir_cache) {
             //$s = htmlspecialchars(htmlspecialchars_decode($s));
             $xml_string = '';
             $xml_string .= '<Progress>' . "\n";
             $xml_string .= "\t" . '<PercentDone>' . $this->__percentDone . '</PercentDone>' . "\n";
             $xml_string .= "\t" . '<Date>' . http_date_string() . '</Date>' . "\n";
             $xml_string .= "\t" . '<Status>' . xml_safe($s) . '</Status>' . "\n";
             $xml_string .= '</Progress>' . "\n";
             $progress_path = $this->_options['DirCache'] . $this->__jobID . '/media.xml';
             @file_put_contents($progress_path, $xml_string, $this->_options['Verbose'] ? FILE_APPEND : NULL);
             $coder_progress_url = $this->getOption('CoderProgressURL');
             if ($coder_progress_url) {
                 if ($this->_options['Verbose']) {
                     $xml_string = file_get($progress_path);
                 }
                 http_post_xml($coder_progress_url, "<moviemasher>\r{$xml_string}</moviemasher>");
             }
         }
         if (!empty($this->_options['LogProgress'])) {
             $this->log($this->__percentDone . '% ' . $s);
         }
     }
 }