Ejemplo n.º 1
0
 * @link http://www.thinkglobalschool.com/
 *
 */
// Get the guid
$podcast_guid = get_input("guid");
// Get the file
$podcast = new ElggPodcast($podcast_guid);
// Check for valid podcast
if (!$podcast) {
    register_error(elgg_echo("podcasts:downloadfailed"));
    forward(REFERER);
}
// Podcast file info
$mime = $podcast->getMimeType();
$podcastname = $podcast->getFileTitle();
$filename = $podcast->getFilenameOnFilestore();
if (!file_exists($filename)) {
    register_error(elgg_echo("podcasts:notfound"));
    forward(REFERER);
}
$size = filesize($filename);
// Output file
header("Pragma: public");
// fix for IE https issue
header("Content-Type: {$mime}");
header("Content-Disposition: attachment; filename=\"{$podcastname}\"");
header("Content-Length: " . $size);
ob_clean();
flush();
readfile($filename);
exit;
Ejemplo n.º 2
0
/**
 * Get file info using exiftool
 *
 * @param ElggPodcast $podcast
 *
 * @return mixed  - 0 on success or error message 
 */
function podcasts_populate_file_info($podcast)
{
    // Get exiftool command path
    $cmd_path = elgg_get_plugin_setting('podcasts_exiftool_root', 'podcasts');
    // Get podcast filename
    $filename = $podcast->getFilenameOnFilestore();
    // Set up exif tool command
    $command = $cmd_path . "exiftool -S -Duration -n \"{$filename}\"";
    $output = array();
    $return = 0;
    // Run command
    exec($command, $output, $return);
    // If we have valid output..
    if ($return == 0 && count($output) >= 1) {
        $duration = $output[0];
        // This will be something like: Duration: 134.22424 (in seconds)
        $duration = (int) round((double) trim(substr($duration, strpos($duration, ":") + 1)));
        // Got a valid number? Set duration.
        if (is_int($duration)) {
            $podcast->duration = $duration;
        } else {
            // Something wrong
            $return = 1;
        }
    }
    // Return value
    return $return;
}