Beispiel #1
0
function media_submit_error($tmp_name)
{
    global $submit_upload_dir;
    global $submit_upload_failed_dir;
    // Sanity checks
    if (!is_dir($submit_upload_dir)) {
        ezmam_last_error($submit_upload_dir . ' is not a directory');
        return false;
    }
    if (!is_dir($submit_upload_failed_dir)) {
        ezmam_last_error($submit_upload_failed_dir . ' is not a directory');
        return false;
    }
    $folder_path = $submit_upload_dir . '/' . $tmp_name;
    if (file_exists($folder_path)) {
        rename($folder_path, $submit_upload_failed_dir . '/' . $tmp_name);
    } else {
        ezmam_last_error('Asset does not exist.');
        return false;
    }
    return true;
}
Beispiel #2
0
/**
 * Displays the popup with the ulb code to copypaste
 * @global type $input
 * @global type $repository_path
 * @global type $url 
 */
function popup_ulb_code()
{
    global $input;
    global $repository_path;
    $asset_name = $input['asset'];
    ezmam_repository_path($repository_path);
    template_load_dictionnary('translations.xml');
    //
    // Sanity checks
    //
    if (!isset($input['album']) || !isset($input['asset']) || !isset($input['media'])) {
        echo 'Usage: index.php?action=show_popup&popup=ulb_code&album=ALBUM&asset=ASSET&media=MEDIA';
        die;
    }
    if (!ezmam_album_exists($input['album']) || !ezmam_asset_exists($input['album'], $input['asset'])) {
        error_print_message(ezmam_last_error());
        die;
    }
    $ulb_code = get_code_to_media($input['album'], $input['asset'], $input['media']);
    // Displaying the popup
    require_once template_getpath('popup_ulb_code.php');
}
Beispiel #3
0
/**
 * insert original cam or slide in repository and if user submit, checks submitted file's extension
 * @param string $camslide
 * @param assoc_array $recording_metadata
 * @param string $recording_dir
 * @return bool
 */
function originals_mam_insert_media($album_name, $asset_name, $camslide, &$recording_metadata, $recording_dir)
{
    $media_name = 'original_' . $camslide;
    //initialize media metadata and media metadata
    $media_meta['author'] = $recording_metadata['author'];
    $media_meta['title'] = $recording_metadata['title'];
    $media_meta['description'] = $recording_metadata['description'];
    $media_meta['record_date'] = $recording_metadata['record_date'];
    $media_meta['width'] = "N/A";
    $media_meta['height'] = "N/A";
    $media_meta['duration'] = "N/A";
    $media_meta['video_codec'] = "N/A";
    $media_meta['audio_codec'] = "N/A";
    $media_meta['disposition'] = 'file';
    //check the name of submited file to keep the extension (pcastaction is quite sensitive to extension type)
    if (isset($recording_metadata['submitted_' . $camslide])) {
        $res = file_get_extension($recording_metadata['submitted_' . $camslide]);
        $ext = $res['ext'];
        if ($ext == '') {
            //if there wasn't an extension, then check mimetype
            $mimetype = $recording_metadata['submitted_mimetype'];
            list($type, $subtype) = explode('/', $mimetype);
            $mimetypes2ext = array('mpeg' => 'mpg', 'quicktime' => 'mov', 'x-msvideo' => 'avi');
            if (isset($mimetypes2ext[$subtype])) {
                $ext = $mimetypes2ext[$subtype];
            } else {
                $ext = 'mov';
            }
            //default extension
        }
        if (ctype_alnum($ext)) {
            //an extension should not have bad chars
            $mov_filepath = $recording_dir . '/' . $camslide . '.mov';
            $goodext_filepath = $recording_dir . '/' . $camslide . '.' . $ext;
            //rename cam.mov into cam.mpg if submit was an .mpg file
            rename($mov_filepath, $goodext_filepath);
            $media_file_path = $goodext_filepath;
            $media_meta['filename'] = "{$camslide}.{$ext}";
        } else {
            print "submitted filename has bad extension: {$ext}";
            myerror("submitted filename has bad extension: {$ext}");
        }
    } else {
        $media_file_path = system("ls {$recording_dir}/{$camslide}.*");
        $media_meta['filename'] = basename($media_file_path);
    }
    $filesize = round(filesize($media_file_path) / 1048576);
    $media_meta['file_size'] = $filesize;
    $res1 = ezmam_media_new($album_name, $asset_name, $media_name, $media_meta, $media_file_path);
    if (!$res1) {
        myerror("error adding original_{$camslide}:" . ezmam_last_error() . "\n");
    } else {
        print "{$camslide} media inserted in repository in {$album_name} {$asset_name} {$media_name}\n";
    }
    return $res1;
}
function high_low_media_mam_insert($album, $asset, $high_low, $cam_slide, $processing_assoc, $render_dir)
{
    global $title, $duration;
    //get qtinfo assoc info
    $qtinfo_assoc = metadata2assoc_array($render_dir . "/{$high_low}_{$cam_slide}_qtinfo.xml");
    if (!is_array($qtinfo_assoc)) {
        myerror("error in intro-title-movie {$high_low}_{$cam_slide}_qtinfo.xml missing/corrupted");
    }
    //first copy most of the parameters from original media
    $movie_filename = $high_low . '_' . $cam_slide . '.mov';
    $media_meta['duration'] = $qtinfo_assoc['duration'];
    if (isset($qtinfo_assoc['duration'])) {
        $duration = $qtinfo_assoc['duration'];
    }
    $media_meta['height'] = $qtinfo_assoc['height'];
    $media_meta['width'] = $qtinfo_assoc['width'];
    $media_meta['videocodec'] = $qtinfo_assoc['videoCodec'];
    $media_meta['audiocodec'] = $qtinfo_assoc['audioCodec'];
    $media_meta['filename'] = $movie_filename;
    $filesize = round(filesize($render_dir . '/' . $movie_filename) / 1048576);
    $media_meta['file_size'] = $filesize;
    $media_meta['disposition'] = "file";
    $media_meta['duration'] = $qtinfo_assoc['duration'];
    $media = $high_low . '_' . $cam_slide;
    if (!isset($duration)) {
        $duration = $qtinfo_assoc['duration'];
    }
    //put  the media in the repository
    //use copy option to have the right owner
    print "insert media {$album} {$asset} {$media}\n";
    $res = ezmam_media_new($album, $asset, $media, $media_meta, $render_dir . '/' . $movie_filename);
    if (!$res) {
        myerror("could not add media to repository: " . ezmam_last_error());
    }
    // remove processed video (owned by remote user but we are owner of upper dir)
    //unlink($media_file_path);
    return true;
}
Beispiel #5
0
/**
 * Adds the metadata for the incoming submitted media into upload queue.
 * This functino does *not* add the media file itself.
 * @param string $tmp_name The directory name where the file will be stored in the queue
 * @param assoc_array $metadata Metadata as used by cli_mam_insert.php
 */
function ezmam_media_submit_create_metadata($tmp_name, $metadata)
{
    global $submit_upload_dir;
    // Sanity checks
    if (!is_dir($submit_upload_dir)) {
        ezmam_last_error($submit_upload_dir . ' is not a directory');
        return false;
    }
    if (!$metadata) {
        ezmam_last_error('not metadata provided');
        return false;
    }
    // 1) create directory
    $folder_path = $submit_upload_dir . '/' . $tmp_name;
    echo mkdir($folder_path);
    // 2) put metadata into xml file
    $res = assoc_array2metadata_file($metadata, $folder_path . '/_metadata.xml');
    if (!$res) {
        ezmam_last_error('ezmam_media_submit_create_metadata: could not save metadata');
        return false;
    }
    return true;
}
Beispiel #6
0
/**
 * Returns a special code that contains information about the media
 * @global type $url
 * @param string $album
 * @param string $asset
 * @param string $media
 * @return string Media
 */
function get_code_to_media($album, $asset, $media)
{
    global $ezplayer_url;
    global $distribute_url;
    global $repository_path;
    ezmam_repository_path($repository_path);
    //
    // Usual sanity checks
    //
    if (!ezmam_album_exists($album)) {
        error_print_message('get_link_to_media: Album ' . $album . ' does not exist');
        return false;
    }
    if (!ezmam_asset_exists($album, $asset)) {
        error_print_message('get_link_to_media: Asset ' . $asset . ' does not exist');
        return false;
    }
    // We take the asset's token if it exists.
    // If not, then we use the album's token instead.
    $token = ezmam_asset_token_get($album, $asset);
    if (!$token) {
        $token = ezmam_album_token_get($album);
    }
    if (!$token) {
        error_print_message('get_link_to_media: ' . ezmam_last_error());
        return false;
    }
    $media_infos = explode('_', $media);
    // 'media' is like high_cam, so we want to extract the "high" part (quality) and the "cam" part (type)
    $quality = $media_infos[0];
    $type = $media_infos[1];
    return $album . '/' . $asset . '/' . $type . '/' . $quality . '/' . $token;
}