Ejemplo n.º 1
0
 function _populateDefaults()
 {
     parent::_populateDefaults();
     $this->_configDefaults['LogRequests'] = array('value' => 'BOOLEAN', 'description' => "Whether or not to add requests we make to the log.", 'default' => 1, 'empty_ok' => 1);
     $this->_configDefaults['LogResponses'] = array('value' => 'BOOLEAN', 'description' => "Whether or not to add responses we receive to the log.", 'default' => 1, 'empty_ok' => 1);
 }
Ejemplo n.º 2
0
/*
This script is called directly from the web browser. The HTML page is returned,
as long as the user can be authenticated via HTTP. This document includes styles
needed for a full window, liquid interface layout. The Movie Masher applet is
embedded using the swfObject JavaScript library.
*/
$err = '';
// load MovieMasher
if (!$err && !@(include_once 'MovieMasher/MovieMasher.php')) {
    $err = 'Problem loading MovieMasher.php';
}
// load objects from configuration
if (!$err) {
    try {
        $moviemasher =& MovieMasher::fromConfig('MovieMasher.xml', 'Client');
    } catch (Exception $ex) {
        $err = xml_safe($ex->getMessage());
    }
}
// load utilities
if (!$err && !@(include_once 'MovieMasher/lib/authutils.php')) {
    $err = 'Problem loading utility script';
}
// autheticate the user (will exit is not possible)
if (!$err && !authenticated()) {
    authenticate();
}
// if error encountered output it and exit, otherwise content below will output
if ($err) {
    print $err;
Ejemplo n.º 3
0
The script attempts to check on the progress of the job and either:
	* redirects client back to itself, if job is still processing, by setting 'url' attribute
	* directs client to refresh browser view if job is finished
	* displays javascript alert if error is encountered, by setting 'get' attribute
If possible, the response to client is logged.
*/
$err = '';
// load MovieMasher
if (!$err && !@(include_once 'MovieMasher/MovieMasher.php')) {
    $err = 'Problem loading MovieMasher.php';
}
// load objects from configuration
if (!$err) {
    try {
        $moviemasher_client =& MovieMasher::fromConfig('MovieMasher.xml', 'Client');
        $moviemasher_file =& MovieMasher::fromConfig('MovieMasher.xml', 'File');
    } catch (Exception $ex) {
        $err = xml_safe($ex->getMessage());
    }
}
// load utilities
if (!$err && !@(include_once 'MovieMasher/lib/authutils.php')) {
    $err = 'Problem loading utility script';
}
// see if the user is autheticated (will NOT exit)
if (!$err && !authenticated()) {
    $err = 'Unauthenticated access';
}
// check to make sure required parameters have been sent
if (!$err) {
    $job = empty($_REQUEST['job']) ? '' : $_REQUEST['job'];
Ejemplo n.º 4
0
/*
This script receives the decoded mash from Movie Masher Server as a video file in $_FILES. If the
file is okay, it's moved to the directory named $id in the server/media/upload directory. If an
error is encountered a 400 header is returned and it is logged, if possible.
*/
$err = '';
// load MovieMasher
if (!$err && !@(include_once 'MovieMasher/MovieMasher.php')) {
    $err = 'Problem loading MovieMasher script';
}
// load objects from configuration
if (!$err) {
    try {
        $moviemasher_client =& MovieMasher::fromConfig('MovieMasher.xml', 'Client');
        $moviemasher_file =& MovieMasher::fromConfig('MovieMasher.xml', 'File');
        $moviemasher_coder =& MovieMasher::fromConfig('MovieMasher.xml', 'Coder', 'Encoder');
    } catch (Exception $ex) {
        $err = xml_safe($ex->getMessage());
    }
}
// load utilities
if (!$err && !@(include_once 'MovieMasher/lib/authutils.php')) {
    $err = 'Problem loading utility script';
}
// see if the user is autheticated (will NOT exit)
if (!$err && !authenticated()) {
    $err = 'Unauthenticated access';
}
// check to make sure required parameters have been sent
if (!$err) {
    $id = empty($_REQUEST['id']) ? '' : $_REQUEST['id'];
Ejemplo n.º 5
0
 static function &fromConfig($xml, $module, $implementation = '', $init_options = array())
 {
     if (!$xml) {
         throw new InvalidArgumentException('Send XML configuration or path to it for first argument');
     }
     if (!$module) {
         throw new InvalidArgumentException('Send module name for second argument');
     }
     $config_is_file = '';
     if (is_string($xml)) {
         if (substr($xml, 0, 1) != '<') {
             $config_is_file = $xml;
             $xml_string = file_get($xml);
             if (!$xml_string) {
                 throw new RuntimeException('Could not load XML file: ' . $xml);
             }
             $xml = $xml_string;
         }
         $xml = @simplexml_load_string($xml);
     }
     if (!is_object($xml)) {
         throw new RuntimeException('Could not parse XML: ' . $xml);
     }
     $options = array();
     $options['module'] = $module;
     // add tags under MovieMasher tag, or root if tag not nested
     $moviemasher_options = MovieMasher::arrayFromXML($xml, 'MovieMasher');
     if (!$moviemasher_options) {
         $moviemasher_options = MovieMasher::arrayFromXML($xml);
     }
     $options = array_merge($options, $moviemasher_options);
     // add tags specific to module
     //$options = array_merge($options, MovieMasher::arrayFromXML($xml, $module));
     // if implementation was specified as argument, see if it's specified in the configuration
     if (!$implementation && !empty($options[$module])) {
         $implementation = $options[$module];
     }
     // if no implementation was specified anywhere then we'll wind up instancing immediate subclass of MovieMasher
     if ($implementation) {
         // but one was, so set it and add tags specific to implementation
         $options[$module] = $implementation;
         $options = array_merge($options, MovieMasher::arrayFromXML($xml, $module . $implementation));
     }
     if ($init_options) {
         $options = array_merge($options, $init_options);
     }
     $path = $name = $module;
     $c = 'MovieMasher';
     if (!empty($implementation)) {
         $path .= '/' . $implementation;
         $name .= '_' . $implementation;
         $c .= '_' . $name;
     }
     include_once dirname(__FILE__) . '/' . $path . '.php';
     if ($config_is_file && empty($options['PathConfiguration'])) {
         $options['PathConfiguration'] = $config_is_file;
     }
     $result = new $c($options);
     if (!is_object($result)) {
         throw new RuntimeException('Could not instance class: ' . $c);
     }
     $result->validateConfiguration();
     return $result;
 }
Ejemplo n.º 6
0
 function _populateDefaults()
 {
     parent::_populateDefaults();
     $this->_configDefaults['FileAudioMaxSize'] = array('value' => 'MEG', 'description' => "Maximum Size of uploaded audio Files, in megabytes.", 'default' => '0', 'emptyok' => 1);
     $this->_configDefaults['FileVideoMaxSize'] = array('value' => 'MEG', 'description' => "Maximum Size of uploaded video Files, in megabytes.", 'default' => '0', 'emptyok' => 1);
     $this->_configDefaults['FileImageMaxSize'] = array('value' => 'MEG', 'description' => "Maximum Size of uploaded image Files, in megabytes.", 'default' => '0', 'emptyok' => 1);
 }
Ejemplo n.º 7
0
 function _populateDefaults()
 {
     parent::_populateDefaults();
     $this->_configDefaults['DaemonPeekSeconds'] = array('value' => 'NUMBER', 'description' => "Seconds to wait between directory checks.", 'default' => 10, 'emptyok' => 1);
     $this->_configDefaults['DirJobsQueued'] = array('value' => 'URL', 'description' => "Location to write new jobs to.", 'default' => '');
     $this->_configDefaults['DirPID'] = array('value' => 'DIR', 'description' => "Process ID files will be created and removed from this directory.", 'default' => '/tmp/moviemasher/');
     $this->_configDefaults['LogRequests'] = array('value' => 'BOOLEAN', 'description' => "Whether or not to add requests we receive to the log.", 'default' => 1);
     $this->_configDefaults['LogResponses'] = array('value' => 'BOOLEAN', 'description' => "Whether or not to add responses we generate to the log.", 'default' => 1);
     $this->_configDefaults['PosixGroup'] = array('value' => 'GROUP', 'description' => "POSIX gid to run daemon under.", 'default' => '', 'emptyok' => 1);
     $this->_configDefaults['PosixUser'] = array('value' => 'GROUP', 'description' => "POSIX uid to run daemon under.", 'default' => '', 'emptyok' => 1);
 }
Ejemplo n.º 8
0
 function __storeFile($comp_file)
 {
     if (!file_exists($comp_file)) {
         throw new RuntimeException('No file was coded');
     }
     if (!is_dir($comp_file) && !($file_size = filesize($comp_file))) {
         throw new RuntimeException('Coded file was empty');
     }
     $coder_file_url = $this->_options['CoderFileURL'];
     if ($coder_file_url) {
         $url = parse_url($coder_file_url);
         if ($url) {
             $scheme = empty($url['scheme']) ? 'System' : $url['scheme'];
             $options = array();
             $options['url'] = $comp_file;
             $options['path'] = substr($coder_file_url, strlen($scheme) + 2);
             $options['delete'] = $this->_options['CoderFileDelete'];
             $file = '';
             switch ($scheme) {
                 case 'http':
                 case 'https':
                     $file = 'HTTP';
                     break;
                 default:
                     $file = ucwords($scheme);
             }
             if ($file) {
                 $path_configuration = $this->_options['PathConfiguration'];
                 if (!$path_configuration) {
                     throw new UnexpectedValueException('Configuration option PathConfiguration required');
                 }
                 $file = MovieMasher::fromConfig($path_configuration, 'File', $file, $this->_options);
                 $this->_progressStep('StoreFile', 10, "Storing File");
                 $options['ignore'] = $this->_ignore;
                 try {
                     $file->put($options);
                 } catch (Exception $ex) {
                     if (empty($this->_options['CoderIgnoreFileError'])) {
                         throw new RuntimeException('Problem transfering file to: ' . $coder_file_url);
                     }
                 }
                 $this->_progressStep('StoreFile', 100, 'Stored File');
             }
         } else {
             throw new RuntimeException('Could not parse URL: ' . $coder_file_url);
         }
     } else {
         $this->_progressStep('StoreFile', 100, "Saved to {$comp_file}");
     }
 }