$decoder_extension = $moviemasher_client->getOption('EncoderAudioExtension'); $type = 'audio'; } $label = (string) $mash_xml->mash[0]['label']; if (!$label) { $label = 'Untitled Mash'; } $meta = array(); $meta['label'] = $label; $meta['extension'] = $decoder_extension; $meta['type'] = $type; if ($moviemasher_client->progressesLocally()) { $xml_string = ''; $xml_string .= '<Progress>' . "\n"; $xml_string .= "\t" . '<PercentDone>4</PercentDone>' . "\n"; $xml_string .= "\t" . '<Date>' . http_date_string() . '</Date>' . "\n"; $xml_string .= "\t" . '<Status>Queued</Status>' . "\n"; $xml_string .= '</Progress>' . "\n"; $meta['progress'] = $xml_string; } $meta_path = $path_media . $mash_media_id . '/'; if ($uploads_locally) { $meta_path = $dir_host . $meta_path; } if (!$moviemasher_file->addMeta($meta_path, $meta)) { $err = 'Problem saving mash meta data: ' . $meta_path; } } } } // create and post decode job to Movie Masher Server
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); } } }
function _processJob() { $dir_cache = $this->_options['DirCache']; $dir_jobs_queued = $this->_options['DirJobsQueued']; if (!($dir_cache && $dir_jobs_queued)) { throw new UnexpectedValueException('Configuration options DirCache, DirJobsQueued required'); } // create job file $this->_jobXML->asXML($dir_jobs_queued . $this->_jobID . '.xml'); $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>Queued</Status>' . "\n"; $xml_string .= '</Progress>' . "\n"; $progress_path = $dir_cache . $this->_jobID . '/media.xml'; if (!safe_path($progress_path)) { throw new RuntimeException('Could not create path: ' . $progress_path); } if (!@file_put_contents($progress_path, $xml_string)) { throw new RuntimeException('Could not write file: ' . $progress_path); } if (!set_file_info($progress_path, 'cached', gmdate("Y-m-d H:i:s"))) { throw new RuntimeException('Could not set cached info: ' . $progress_path); } }
function __postResponse($request) { $body = ''; switch ($request['path']) { case 'encode': case 'decode': $xml_str = $request['data']; $auth_key = $this->_options['AuthKey']; if (!empty($auth_key)) { if (empty($request['headers']) || empty($request['headers']['X-Moviemasher-Date']) || empty($request['headers']['Authorization'])) { throw new BadFunctionCallException('X-Moviemasher-Date and Authorization headers required'); } } $xml_ob = @simplexml_load_string($xml_str); if (!$xml_ob) { throw new BadFunctionCallException('Could not parse XML request'); } if (!empty($auth_key)) { $sig = array(); $gmd = $request['headers']['X-Moviemasher-Date']; $kids = $xml_ob->children(); $z = sizeof($kids); for ($i = 0; $i < $z; $i++) { $sig[$kids[$i]->getName()] = (string) $kids[$i]; } ksort($sig); $sigs = array(); foreach ($sig as $k => $v) { $sigs[] = $k . '=' . $v; } $sig = $gmd . join('&', $sigs); $this->__authCheck($request['headers']['Authorization'], $sig); } $this->_validateJob($xml_ob); $uc_path = ucwords($request['path']); $this->_jobXML = $xml_ob; $this->_jobID = (string) $this->_jobXML->JobID; if (empty($this->_jobID)) { $this->_jobID = unique_id('jobid'); } $body .= "\n" . '<' . $uc_path . 'Response>'; $body .= "\n\t" . '<JobID>' . $this->_jobID . '</JobID>'; $body .= "\n\t" . '<Date>' . http_date_string() . '</Date>'; $body .= "\n" . '</' . $uc_path . 'Response>'; break; default: throw new BadFunctionCallException('Path not found: ' . $request['path']); } return $body; }