function podPress_getEnclosureTags($feedtype = 'rss2')
{
    global $podPress, $post, $podpress_allowed_ext, $wp_query;
    $result = '';
    $hasMediaFileAccessible = false;
    $same_enclosure_URL_in_postmeta_exists = false;
    $is_podpress_feed = FALSE;
    $feedslug = $wp_query->query_vars['feed'];
    foreach ($podPress->settings['podpress_feeds'] as $feed) {
        if ($feedslug === $feed['slug']) {
            $is_podpress_feed = TRUE;
            break;
        }
    }
    if (TRUE === $is_podpress_feed and TRUE == isset($feed['bypass_incl_selection']) and TRUE === $feed['bypass_incl_selection']) {
        $ignore_incl_selection = TRUE;
    } else {
        $ignore_incl_selection = FALSE;
    }
    if (is_array($post->podPressMedia)) {
        $foundPreferred = false;
        reset($post->podPressMedia);
        while (list($key, $val) = each($post->podPressMedia)) {
            $preferredFormat = false;
            if (!$post->podPressMedia[$key]['authorized']) {
                if ($podPress->settings['premiumContentFakeEnclosure']) {
                    $post->podPressMedia[$key]['URI'] = 'podPress_Protected_Content.mp3';
                } else {
                    continue;
                }
            }
            if (defined('PODPRESS_TORRENTCAST') && !empty($post->podPressMedia[$key]['authorized']['URI_torrent'])) {
                $post->podPressMedia[$key]['URI'] = $post->podPressMedia[$key]['URI_torrent'];
            }
            $hasMediaFileAccessible = true;
            if (is_array($podpress_allowed_ext)) {
                if (FALSE == in_array($post->podPressMedia[$key]['ext'], $podpress_allowed_ext)) {
                    continue;
                } else {
                    $preferredFormat = true;
                }
            }
            if (isset($_GET['format']) && $_GET['format'] == $post->podPressMedia[$key]['ext']) {
                $preferredFormat = true;
            }
            if ($post->podPressMedia[$key]['rss'] == 'on' || $post->podPressMedia[$key]['atom'] == 'on' || $preferredFormat === true || $ignore_incl_selection === TRUE) {
                if ($feedtype == 'atom' && ($post->podPressMedia[$key]['atom'] == 'on' or $preferredFormat === TRUE or $ignore_incl_selection === TRUE)) {
                    $post->podPressMedia[$key]['URI'] = $podPress->convertPodcastFileNameToWebPath($post->ID, $key, $post->podPressMedia[$key]['URI'], 'feed');
                    $result .= '<link rel="enclosure" type="' . $post->podPressMedia[$key]['mimetype'] . '" href="' . $post->podPressMedia[$key]['URI'] . '" length="' . $post->podPressMedia[$key]['size'] . '" />' . "\n";
                } elseif ($feedtype == 'xspf') {
                    $post->podPressMedia[$key]['URI'] = $podPress->convertPodcastFileNameToValidWebPath($post->podPressMedia[$key]['URI']);
                    //$post->podPressMedia[$key]['URI'] = $podPress->convertPodcastFileNameToWebPath($post->ID, $key, $post->podPressMedia[$key]['URI'], 'feed');
                    if ('mp3' == podPress_getFileExt($post->podPressMedia[$key]['URI'])) {
                        $result .= "\t\t" . '<track>' . "\n";
                        $result .= "\t\t\t" . '<location>' . $post->podPressMedia[$key]['URI'] . "</location>\n";
                        if (!empty($post->podPressMedia[$key]['title'])) {
                            $result .= "\t\t\t" . '<annotation>' . podPress_feedSafeContent(html_entity_decode($post->podPressMedia[$key]['title'])) . "</annotation>\n";
                            $result .= "\t\t\t" . '<title>' . podPress_feedSafeContent(html_entity_decode($post->podPressMedia[$key]['title'])) . "</title>\n";
                        } else {
                            $result .= "\t\t\t" . '<annotation>' . podPress_feedSafeContent(html_entity_decode($post->post_title)) . "</annotation>\n";
                            $result .= "\t\t\t" . '<title>' . podPress_feedSafeContent(html_entity_decode($post->post_title)) . "</title>\n";
                        }
                        if ('##Global##' == $post->podPressPostSpecific['itunes:author']) {
                            if (empty($podPress->settings['iTunes']['author'])) {
                                $creator = get_bloginfo('blogname');
                            } else {
                                $creator = $podPress->settings['iTunes']['author'];
                            }
                            $result .= "\t\t\t" . '<creator>' . podPress_feedSafeContent(html_entity_decode($creator)) . '</creator>' . "\n";
                        } else {
                            $result .= "\t\t\t" . '<creator>' . podPress_feedSafeContent(html_entity_decode($post->podPressPostSpecific['itunes:author'])) . '</creator>' . "\n";
                        }
                        if ('UNKNOWN' != $post->podPressMedia[$key]['duration'] and FALSE === empty($post->podPressMedia[$key]['duration'])) {
                            $result .= "\t\t\t" . '<duration>' . $podPress->strtomilliseconds($post->podPressMedia[$key]['duration']) . '</duration>' . "\n";
                        }
                        if (!empty($post->podPressMedia[$key]['previewImage'])) {
                            $result .= "\t\t\t" . '<image>' . $post->podPressMedia[$key]['previewImage'] . "</image>\n";
                        }
                        $result .= "\t\t" . '</track>' . "\n";
                    }
                } elseif ($feedtype == 'rss2') {
                    $post->podPressMedia[$key]['URI'] = $podPress->convertPodcastFileNameToWebPath($post->ID, $key, $post->podPressMedia[$key]['URI'], 'feed');
                    if (!isset($post->podPressMedia[$key]['duration']) || !preg_match("/([0-9]):([0-9])/", $post->podPressMedia[$key]['duration'])) {
                        $post->podPressMedia[$key]['duration'] = '00:01';
                        // m:s
                    }
                    // for more info: http://www.apple.com/itunes/podcasts/specs.html#duration
                    // the duration string is sometimes in the format mmm:ss. That is why it is a rebuilding this string might be necessary.
                    $durationTag = '<itunes:duration>' . $podPress->millisecondstostring($podPress->strtomilliseconds($post->podPressMedia[$key]['duration']), 'h:m:s') . '</itunes:duration>' . "\n";
                    // $foundPreferred is the limiter for enclosures in RSS items
                    // $preferredFormat signals whether a file type filter is active or not
                    if ($post->podPressMedia[$key]['rss'] == 'on' || $ignore_incl_selection === TRUE) {
                        if (!$preferredFormat && $foundPreferred) {
                            continue;
                        } elseif ($preferredFormat) {
                            $foundPreferred = true;
                        }
                        $result .= "\t\t" . '<enclosure url="' . $post->podPressMedia[$key]['URI'] . '" length="' . $post->podPressMedia[$key]['size'] . '" type="' . $post->podPressMedia[$key]['mimetype'] . '" />' . "\n";
                        $result .= "\t\t" . $durationTag;
                    } elseif ($preferredFormat && !$foundPreferred) {
                        $result .= "\t\t" . '<enclosure url="' . $post->podPressMedia[$key]['URI'] . '" length="' . $post->podPressMedia[$key]['size'] . '" type="' . $post->podPressMedia[$key]['mimetype'] . '" />' . "\n";
                        $result .= "\t\t" . $durationTag;
                        $foundPreferred = true;
                    }
                }
            }
        }
    }
    if ($hasMediaFileAccessible && $result == '' && $feedtype != 'xspf') {
        echo "<!-- Media File exists for this post, but its not enabled for this feed -->\n";
    }
    switch ($feedtype) {
        case 'atom':
            return apply_filters('podpress_entry_enclosuretags', $result);
            break;
        case 'xspf':
            return apply_filters('podpress_xspf_trackinformation', $result);
            break;
        case 'rss2':
        default:
            return apply_filters('podpress_item_enclosure_and_itunesduration', $result);
            break;
    }
}
Exemplo n.º 2
0
function podPress_processDownloadRedirect($postID, $mediaNum, $filename, $method = '')
{
    global $podPress, $wpdb;
    $allowedMethods = array('feed', 'play', 'web');
    $realURL = false;
    $realSysPath = false;
    $statID = false;
    if (substr($filename, -20, 20) == 'podPressStatTest.txt') {
        status_header('200');
        echo 'Worked';
        // Don't translate this!
        exit;
    }
    if (in_array($method, $allowedMethods) && is_numeric($postID) && is_numeric($mediaNum)) {
        $mediaFiles = podPress_get_post_meta($postID, '_podPressMedia', true);
        if (isset($mediaFiles[$mediaNum])) {
            if ($mediaFiles[$mediaNum]['URI'] == urldecode($filename)) {
                $realURL = $filename;
            } elseif (podPress_getFileName($mediaFiles[$mediaNum]['URI']) == urldecode($filename)) {
                $realURL = $mediaFiles[$mediaNum]['URI'];
            } elseif (podPress_getFileName($mediaFiles[$mediaNum]['URI_torrent']) == urldecode($filename)) {
                $realURL = $mediaFiles[$mediaNum]['URI_torrent'];
            }
        }
    }
    if (!$realURL) {
        header('X-PodPress-Location: ' . get_option('siteurl'));
        header('Location: ' . get_option('siteurl'));
        exit;
    }
    $badextensions = array('.smi', '.jpg', '.png', '.gif');
    if ($filename && !in_array(strtolower(substr($filename, -4)), $badextensions)) {
        podPress_StatCounter($postID, $filename, $method);
        if ($podPress->settings['statLogging'] == 'Full' || $podPress->settings['statLogging'] == 'FullPlus') {
            $statID = podPress_StatCollector($postID, $filename, $method);
        }
    }
    $realSysPath = $podPress->convertPodcastFileNameToSystemPath(str_replace('%20', ' ', $realURL));
    if (FALSE === $realSysPath) {
        $realSysPath = $podPress->TryToFindAbsFileName(str_replace('%20', ' ', $realURL));
    }
    $realURL = $podPress->convertPodcastFileNameToValidWebPath($realURL);
    if ($podPress->settings['enable3rdPartyStats'] == 'PodTrac') {
        $realURL = str_replace(array('ftp://', 'http://', 'https://'), '', $realURL);
        $realURL = $podPress->podtrac_url . $realURL;
    } elseif (strtolower($podPress->settings['enable3rdPartyStats']) == 'blubrry' && !empty($podPress->settings['statBluBrryProgramKeyword'])) {
        $realURL = str_replace('http://', '', $realURL);
        $realURL = $podPress->blubrry_url . $podPress->settings['statBluBrryProgramKeyword'] . '/' . $realURL;
    } elseif ($podPress->settings['statLogging'] == 'FullPlus' && $realSysPath !== false) {
        status_header('200');
        $content_type = podPress_mimetypes(podPress_getFileExt($realSysPath));
        if ($method == 'web') {
            header("Pragma: ");
            header("Cache-Control: ");
            header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
            header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
            header("Cache-Control: no-store, no-cache, must-revalidate");
            // HTTP/1.1
            header("Cache-Control: post-check=0, pre-check=0", false);
            header('Content-Disposition: attachment; filename="' . $filename . '"');
            header("Content-Description: " . trim(htmlentities($filename)));
            header("Connection: close");
            if (substr($content_type, 0, 4) != 'text') {
                header("Content-Transfer-Encoding: binary");
            }
        } else {
            header("Connection: Keep-Alive");
        }
        header("X-ForcedBy: podPress");
        header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
        header('Content-type: ' . $content_type);
        header('Content-Length: ' . filesize($realSysPath));
        set_time_limit(0);
        $chunksize = 1 * (1024 * 1024);
        // how many bytes per chunk
        if ($handle = fopen($realSysPath, 'rb')) {
            while (!feof($handle) && connection_status() == 0) {
                echo fread($handle, $chunksize);
                ob_flush();
                flush();
            }
            fclose($handle);
        }
        if ($statID !== false && connection_status() == 0 && !connection_aborted()) {
            $sqlU = "UPDATE " . $wpdb->prefix . "podpress_stats SET completed=1 WHERE id=" . $statID;
            $wpdb->hide_errors();
            $result = $wpdb->query($sqlI);
            if (!$result) {
                $wpdb->query($sqlU);
            }
        }
        exit;
    }
    $realURL = str_replace(' ', '%20', $realURL);
    status_header('302');
    header('X-PodPress-Location: ' . $realURL, true, 302);
    header('Location: ' . $realURL, true, 302);
    header('Content-Length: 0');
    exit;
}
 function upgrade_convert39to40mediaFile($url, $size = '', $duration = '', $dimension = '')
 {
     $result = array();
     $result['URI'] = $url;
     $result['size'] = $size;
     $result['duration'] = $duration;
     $result['atom'] = 'on';
     $filext = podPress_getFileExt($url);
     switch ($filext) {
         case 'mp3':
             $result['type'] = 'audio_mp3';
             break;
         case 'ogg':
             $result['type'] = 'audio_ogg';
             break;
         case 'm4a':
             $result['type'] = 'audio_m4a';
             break;
         case 'mp4':
             $result['type'] = 'video_mp4';
             break;
         case 'm4v':
             $result['type'] = 'video_m4v';
             break;
         case 'mov':
             $result['type'] = 'video_mov';
             break;
         case 'qt':
             $result['type'] = 'video_qt';
             break;
         case 'avi':
             $result['type'] = 'video_avi';
             break;
         case 'mpg':
         case 'mpeg':
             $result['type'] = 'video_mpg';
             break;
         case 'asf':
             $result['type'] = 'video_asf';
             break;
         case 'wma':
             $result['type'] = 'audio_wma';
             break;
         case 'wmv':
             $result['type'] = 'video_wmv';
             break;
         case 'flv':
             $result['type'] = 'video_flv';
             break;
         case 'swf':
             $result['type'] = 'video_swf';
             break;
         case 'pdf':
             $result['type'] = 'ebook_pdf';
             break;
         case 'epub':
             $result['type'] = 'ebook_epub';
             break;
         default:
             $result['type'] = 'misc_other';
     }
     if (strpos($dimension, ':')) {
         $dimensionParts = explode(':', $dimension);
         $result['dimensionW'] = $dimensionParts[0];
         $result['dimensionH'] = $dimensionParts[1];
     }
     return $result;
 }
 function post_form_wp25plus($entryType = 'post')
 {
     global $wp_version;
     $blog_charset = get_bloginfo('charset');
     if (TRUE == version_compare($wp_version, '2.7', '>=') and TRUE == version_compare($wp_version, '2.8', '<')) {
         // for WP 2.7.x (because the plugins_url() worked differently in WP 2.7.x)
         $plugins_url = plugins_url('podpress', __FILE__);
     } else {
         $plugins_url = plugins_url('', __FILE__);
     }
     if (!is_object($GLOBALS['post']) && isset($GLOBALS['post_cache'][$GLOBALS['post']])) {
         $post = $GLOBALS['post_cache'][$GLOBALS['post']];
     } else {
         $post = $GLOBALS['post'];
     }
     $post = $this->addPostData($post, true);
     if ($_GET['action'] == 'edit') {
         $post_id = $_GET['post'];
         if (!is_array($post->podPressMedia)) {
             $post->podPressMedia = array();
         }
     }
     $files = array();
     $mediaFilePath = stripslashes($this->settings['mediaFilePath']);
     if (@is_dir($mediaFilePath)) {
         $dh = opendir($mediaFilePath);
         while (false !== ($filename = readdir($dh))) {
             if ($filename != '.' && $filename != '..' && !is_dir($mediaFilePath . '/' . $filename) && !in_array(podPress_getFileExt($filename), array('php', 'html'))) {
                 $files[] = $filename;
             }
         }
         natcasesort($files);
     }
     if ($this->settings['enablePodangoIntegration']) {
         if (!empty($post->podPressPostSpecific['PodangoEpisodeID'])) {
             if (empty($post->podPressPostSpecific['PodangoMediaFileID'])) {
                 $x = $this->podangoapi->GetEpisode($post->podPressPostSpecific['PodangoEpisodeID']);
                 $post->podPressPostSpecific['PodangoMediaFileID'] = $x['MediaFileId'];
                 unset($x);
             }
             $podangoMediaFiles = $this->podangoapi->GetMediaFile($post->podPressPostSpecific['PodangoMediaFileID']);
         } else {
             $podangoMediaFiles = $this->podangoapi->GetMediaFiles();
         }
     }
     if (FALSE == isset($this->settings['videoDefaultPlayerSize_x'])) {
         $this->settings['videoDefaultPlayerSize_x'] = 320;
     }
     if (FALSE == isset($this->settings['videoDefaultPlayerSize_y'])) {
         $this->settings['videoDefaultPlayerSize_y'] = 240;
     }
     echo '<input type="hidden" id="podpress_mediadefault_dimensionW" value="' . $this->settings['videoDefaultPlayerSize_x'] . '" />' . "\n";
     echo '<input type="hidden" id="podpress_mediadefault_dimensionH" value="' . $this->settings['videoDefaultPlayerSize_y'] . '" />' . "\n";
     echo '<script type="text/javascript">' . "\n";
     echo "var podPressMaxMediaFiles = " . $this->settings['maxMediaFiles'] . ";\n";
     $newMediaDefaults = array();
     echo "var newMediaDefaults = new Array();\n";
     $newMediaDefaults['URI'] = '';
     echo "newMediaDefaults['URI'] = '" . $newMediaDefaults['URI'] . "';\n";
     $newMediaDefaults['title'] = '';
     echo "newMediaDefaults['title'] = '" . $newMediaDefaults['title'] . "';\n";
     $newMediaDefaults['type'] = 'audio_mp3';
     echo "newMediaDefaults['type'] = '" . $newMediaDefaults['type'] . "';\n";
     $newMediaDefaults['size'] = '';
     echo "newMediaDefaults['size'] = '" . $newMediaDefaults['size'] . "';\n";
     $newMediaDefaults['duration'] = '';
     echo "newMediaDefaults['duration'] = '" . $newMediaDefaults['duration'] . "';\n";
     $newMediaDefaults['dimensionW'] = strval($this->settings['videoDefaultPlayerSize_x']);
     echo "newMediaDefaults['dimensionW'] = '" . $newMediaDefaults['dimensionW'] . "';\n";
     $newMediaDefaults['dimensionH'] = strval($this->settings['videoDefaultPlayerSize_y']);
     echo "newMediaDefaults['dimensionH'] = '" . $newMediaDefaults['dimensionH'] . "';\n";
     $newMediaDefaults['previewImage'] = podPress_url() . 'images/vpreview_center.png';
     echo "newMediaDefaults['previewImage'] = '" . $newMediaDefaults['previewImage'] . "';\n";
     $newMediaDefaults['rss'] = 'false';
     echo "newMediaDefaults['rss'] = " . $newMediaDefaults['rss'] . ";\n";
     $newMediaDefaults['atom'] = 'true';
     echo "newMediaDefaults['atom'] = " . $newMediaDefaults['atom'] . ";\n";
     $newMediaDefaults['feedonly'] = 'true';
     echo "newMediaDefaults['feedonly'] = " . $newMediaDefaults['feedonly'] . ";\n";
     $newMediaDefaults['disablePlayer'] = 'false';
     echo "newMediaDefaults['disablePlayer'] = " . $newMediaDefaults['disablePlayer'] . ";\n";
     $newMediaDefaults['disablePreview'] = 'false';
     echo "newMediaDefaults['disablePreview'] = " . $newMediaDefaults['disablePreview'] . ";\n";
     $newMediaDefaults['content_level'] = 'free';
     echo "newMediaDefaults['content_level'] = '" . $newMediaDefaults['content_level'] . "';\n";
     $newMediaDefaults['showme'] = 'false';
     echo "newMediaDefaults['showme'] = " . $newMediaDefaults['showme'] . ";\n";
     if (FALSE !== empty($post->podPressMedia)) {
         $num = 0;
     } else {
         $num = count($post->podPressMedia);
         $num = intval($num);
         if ($num > $this->settings['maxMediaFiles']) {
             $num = $this->settings['maxMediaFiles'];
         }
     }
     while ($num < $this->settings['maxMediaFiles']) {
         $post->podPressMedia[$num] = $newMediaDefaults;
         $num++;
     }
     $num = 0;
     while ($num < $this->settings['maxMediaFiles']) {
         if (!isset($post->podPressMedia[$num]['showme'])) {
             $post->podPressMedia[$num]['showme'] = 'true';
         }
         if ($post->podPressMedia[$num]['showme'] == 'false') {
             $num++;
             continue;
         }
         if ($this->settings['enablePodangoIntegration']) {
             if ($podangoMediaFiles[$post->podPressPostSpecific['PodangoMediaFileID']]['Filename'] == basename($post->podPressMedia[$num]['URI'])) {
                 $post->podPressMedia[$num]['URI'] = 'Podango:' . $podangoMediaFiles[$post->podPressPostSpecific['PodangoMediaFileID']]['Podcast'] . ':' . $podangoMediaFiles[$post->podPressPostSpecific['PodangoMediaFileID']]['ID'] . ':' . $podangoMediaFiles[$post->podPressPostSpecific['PodangoMediaFileID']]['EpisodeID'] . ':' . $podangoMediaFiles[$post->podPressPostSpecific['PodangoMediaFileID']]['Filename'];
             }
         }
         if ($post->podPressMedia[$num]['rss'] == 'on') {
             $post->podPressMedia[$num]['rss'] = 'true';
         } else {
             $post->podPressMedia[$num]['rss'] = 'false';
         }
         if ($post->podPressMedia[$num]['atom'] == 'on') {
             $post->podPressMedia[$num]['atom'] = 'true';
         } else {
             $post->podPressMedia[$num]['atom'] = 'false';
         }
         if ($post->podPressMedia[$num]['feedonly'] == 'on') {
             $post->podPressMedia[$num]['feedonly'] = 'true';
         } else {
             $post->podPressMedia[$num]['feedonly'] = 'false';
         }
         if (!isset($post->podPressMedia[$num]['disablePlayer']) || $post->podPressMedia[$num]['disablePlayer'] == false || $post->podPressMedia[$num]['disablePlayer'] == 'false') {
             $post->podPressMedia[$num]['disablePlayer'] = 'false';
         } else {
             $post->podPressMedia[$num]['disablePlayer'] = 'true';
         }
         if (!isset($post->podPressMedia[$num]['disablePreview']) || $post->podPressMedia[$num]['disablePreview'] == false || $post->podPressMedia[$num]['disablePreview'] == 'false') {
             $post->podPressMedia[$num]['disablePreview'] = 'false';
         } else {
             $post->podPressMedia[$num]['disablePreview'] = 'true';
         }
         if ($post->podPressMedia[$num]['premium_only'] == 'on' || $post->podPressMedia[$num]['premium_only'] == true) {
             $post->podPressMedia[$num]['content_level'] = 'premium_content';
         }
         if (!isset($post->podPressMedia[$num]['content_level'])) {
             $post->podPressMedia[$num]['content_level'] = 'free';
         }
         echo "\n";
         echo "podPressAddMediaFile(" . $post->podPressMedia[$num]['showme'] . ", '" . js_escape($post->podPressMedia[$num]['URI']) . "', '" . js_escape($post->podPressMedia[$num]['URI_torrent']) . "', '" . js_escape($post->podPressMedia[$num]['title']) . "', '" . $post->podPressMedia[$num]['type'] . "', '" . $post->podPressMedia[$num]['size'] . "', '" . $post->podPressMedia[$num]['duration'] . "', '" . $post->podPressMedia[$num]['dimensionW'] . "', '" . $post->podPressMedia[$num]['dimensionH'] . "', '" . $post->podPressMedia[$num]['previewImage'] . "', " . $post->podPressMedia[$num]['rss'] . ", " . $post->podPressMedia[$num]['atom'] . ", " . $post->podPressMedia[$num]['feedonly'] . ", " . $post->podPressMedia[$num]['disablePlayer'] . ", '" . $post->podPressMedia[$num]['content_level'] . "');\n";
         $num++;
     }
     echo '</script>' . "\n";
     echo '<input type="hidden" id="podPressMedia_defaultpreviewImage" value="' . $plugins_url . '/images/vpreview_center.png" />' . "\n";
     if (defined('NONCE_KEY') and is_string(constant('NONCE_KEY')) and '' != trim(constant('NONCE_KEY'))) {
         echo '<input type="hidden" id="podPress_AJAX_sec" value="' . wp_create_nonce(NONCE_KEY) . '" />' . "\n";
     } else {
         echo '<input type="hidden" id="podPress_AJAX_sec" value="' . wp_create_nonce('Af|F07*wC7g-+OX$;|Z5;R@Pi]ZgoU|Zex8=`?mO-Mdvu+WC6l=6<O^2d~+~U3MM') . '" />' . "\n";
     }
     echo '<p style="padding-bottom:1em;">' . sprintf(__('To control player location in your post, you may put %1$s where you want it to appear. You can choose the default postion on the general settings page of podPress.', 'podpress'), $this->podcasttag) . ' ' . __('File Uploading support is not part of podPress.', 'podpress') . '</p>' . "\n";
     echo '<h4>' . __('Podcasting Files:', 'podpress') . '</h4>' . "\n";
     $num = 0;
     while ($num < $this->settings['maxMediaFiles']) {
         if (!isset($post->podPressMedia[$num])) {
             $num++;
             continue;
         }
         $thisMedia = $post->podPressMedia[$num];
         if ($thisMedia['showme'] == 'true') {
             $display_text = 'block';
         } else {
             $display_text = 'none';
         }
         echo '     			<div id="podPressMediaFileContainer_' . $num . '" class="wrap" style="visibility: visible; display: ' . $display_text . ';">' . "\n";
         echo '				<table class="podpress_editor_table">' . "\n";
         echo '					<tr>' . "\n";
         echo '						<th id="podpress_media_file_header"><em>' . __('Media File:', 'podpress') . '</em></th>';
         echo '						<td id="podpress_media_file_buttons">';
         echo '						<input type="button" value="' . __('Move Up', 'podpress') . '" onclick="podPressMoveFile(' . $num . ', \'up\'); podPressDisplayMediaFiles();"/>' . "\n";
         echo '						<input type="button" value="' . __('Move Down', 'podpress') . '" onclick="podPressMoveFile(' . $num . ', \'down\'); podPressDisplayMediaFiles();"/>' . "\n";
         echo '						<input type="button" name="podPressAddAnother" value="' . __('Remove File', 'podpress') . '" onclick="podPressRemoveFile(' . $num . '); podPressDisplayMediaFiles();"/>';
         echo '						</td>';
         echo '					</tr>' . "\n";
         echo '					<tr>' . "\n";
         echo '						<th>' . "\n";
         echo '							<label for="podPressMedia_' . $num . '_URI">' . __('Location', 'podpress') . '</label>: ' . "\n";
         echo '						</th>' . "\n";
         echo '						<td>' . "\n";
         if (!empty($files) || $this->settings['enablePodangoIntegration']) {
             $fileOptionList = '';
             echo '						<select name="podPressMedia[' . $num . '][URI]" id="podPressMedia_' . $num . '_URI" width="35" onchange="javascript: if(this.value==\'!\') { podPress_customSelectVal(this, \'Specifiy URL.\'); } podPressMediaFiles[' . $num . '][\'URI\'] = this.value; podPressDetectType(' . $num . ');">' . "\n";
             echo '							<option value="!">' . __('Specify URL ...', 'podpress') . '</option>' . "\n";
             $fileSelected = false;
             if ($this->settings['enablePodangoIntegration']) {
                 $podangoOptGroup = '';
                 $podangoFirstOptGroup = true;
                 foreach ($podangoMediaFiles as $podangoMediaFile) {
                     if (!empty($podangoMediaFile['EpisodeID']) && $podangoMediaFile['EpisodeID'] != $post->podPressPostSpecific['PodangoEpisodeID'] && $post->post_title != $podangoMediaFile['EpisodeTitle']) {
                         continue;
                     }
                     if ($podangoOptGroup != $podangoMediaFile['Podcast']) {
                         $podangoOptGroup = $podangoMediaFile['Podcast'];
                         if (!$podangoFirstOptGroup) {
                             echo "\t\t\t\t\t\t\t</optgroup>\n";
                         }
                         $x = $this->podangoapi->GetPodcast($podangoMediaFile['Podcast'], true);
                         echo '							<optgroup name="PodangoOptGroup' . $podangoMediaFile['Podcast'] . '" label="Podango Podcast: ' . $x['Title'] . '">' . "\n";
                         unset($x);
                     }
                     $key = 'Podango:' . $podangoMediaFile['Podcast'] . ':' . $podangoMediaFile['ID'] . ':' . $podangoMediaFile['EpisodeID'] . ':' . $podangoMediaFile['Filename'];
                     if ($key == $thisMedia['URI']) {
                         $xSelected = ' selected="selected"';
                         $fileSelected = true;
                     } else {
                         $xSelected = '';
                     }
                     echo '								<option value="' . $key . '"' . $xSelected . '>' . $podangoMediaFile['Filename'] . '</option>' . "\n";
                 }
                 echo "\t\t\t\t\t\t\t</optgroup>\n";
                 echo '							<optgroup name="LocallyHosted" label="Locally Hosted">' . "\n";
             }
             foreach ($files as $key => $val) {
                 if (is_numeric($key)) {
                     $key = $val;
                 }
                 if ($key == $thisMedia['URI']) {
                     $xSelected = ' selected="selected"';
                     $fileSelected = true;
                 } else {
                     $xSelected = '';
                 }
                 if (TRUE == version_compare(PHP_VERSION, '5.0', '<')) {
                     // html_entity_decode can not handle the charset UTF-8 in most of the PHP 4 version
                     $fileOptionList .= '							<option value="' . attribute_escape(htmlentities($key)) . '"' . $xSelected . '>' . htmlentities(podPress_stringLimiter($val, 100, true)) . '</option>' . "\n";
                 } else {
                     if (FALSE === stristr(PHP_OS, 'WIN')) {
                         $fileOptionList .= '							<option value="' . attribute_escape(htmlentities($key, ENT_COMPAT, $blog_charset)) . '"' . $xSelected . '>' . htmlentities(podPress_stringLimiter($val, 100, true), ENT_COMPAT, $blog_charset) . '</option>' . "\n";
                     } else {
                         $fileOptionList .= '							<option value="' . attribute_escape(htmlentities($key)) . '"' . $xSelected . '>' . htmlentities(podPress_stringLimiter($val, 100, true)) . '</option>' . "\n";
                     }
                 }
             }
             if (!$fileSelected) {
                 if (TRUE == version_compare(PHP_VERSION, '5.0', '<')) {
                     // html_entity_decode can not handle the charset UTF-8 in most of the PHP 4 version
                     echo '							<option value="' . attribute_escape(htmlentities($thisMedia['URI'])) . '" selected="selected">' . htmlentities(podPress_stringLimiter($thisMedia['URI'], 100, true)) . '</option>' . "\n";
                 } else {
                     if (FALSE === stristr(PHP_OS, 'WIN')) {
                         echo '							<option value="' . attribute_escape(htmlentities($thisMedia['URI']), ENT_COMPAT, $blog_charset) . '" selected="selected">' . htmlentities(podPress_stringLimiter($thisMedia['URI'], 100, true), ENT_COMPAT, $blog_charset) . '</option>' . "\n";
                     } else {
                         echo '							<option value="' . attribute_escape($thisMedia['URI']) . '" selected="selected">' . htmlentities(podPress_stringLimiter($thisMedia['URI'], 100, true), ENT_COMPAT, $blog_charset) . '</option>' . "\n";
                     }
                 }
             }
             echo $fileOptionList;
             unset($fileOptionList);
             if ($this->settings['enablePodangoIntegration']) {
                 echo "\t\t\t\t\t\t\t</optgroup>\n";
             }
             echo '						</select>' . "\n";
             echo '							<input type="hidden" id="podPressMedia_' . $num . '_cleanURI" value="no" />' . "\n";
         } else {
             echo '							<input type="text" id="podPressMedia_' . $num . '_URI" name="podPressMedia[' . $num . '][URI]" class="podpress_wide_text_field" size="40" value="' . attribute_escape($thisMedia['URI']) . '" onchange="javascript: podPressMediaFiles[' . $num . '][\'URI\'] = this.value; podPressDetectType(' . $num . '); podPressCheckForNotSafeFilenameChr( ' . $num . ', this.value );" />' . "\n";
             echo '							<span id="podPressMedia_' . $num . '_URI_chrWarning" class="podpress_notice podPressMedia_URI_chrWarning">' . sprintf(__('<strong>Notice:</strong> It is not recommended to use other than these characters: %1$s or whitespaces in file and folder names.', 'podpress'), 'abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789 .:/_-\\ ') . '</span>' . "\n";
             echo '							<input type="hidden" id="podPressMedia_' . $num . '_cleanURI" value="yes" />' . "\n";
         }
         echo '						</td>' . "\n";
         echo '					</tr>' . "\n";
         if ($this->settings['enableTorrentCasting']) {
             echo '					<tr>' . "\n";
             echo '						<th>' . "\n";
             echo '							<label for="podPressMedia_' . $num . '_URItorrent">' . __('.torrent Location', 'podpress') . '</label>: ' . "\n";
             echo '						</th>' . "\n";
             echo '						<td>' . "\n";
             echo '							<input type="text" id="podPressMedia_' . $num . '_URItorrent" name="podPressMedia[' . $num . '][URI_torrent]" size="40" value="' . attribute_escape($thisMedia['URI_torrent']) . '" onchange="javascript: podPressMediaFiles[' . $num . '][\'URI_torrent\'] = this.value;" />' . "\n";
             echo '						</td>' . "\n";
             echo '					</tr>' . "\n";
         }
         echo '					<tr>' . "\n";
         echo '						<th>' . "\n";
         echo '							<label for="podPressMedia_' . $num . '_title">' . __('Title', 'podpress') . '</label>: ' . "\n";
         echo '						</th>' . "\n";
         echo '						<td>' . "\n";
         echo '							<input type="text" id="podPressMedia_' . $num . '_title" name="podPressMedia[' . $num . '][title]" class="podpress_wide_text_field" size="40" value="' . attribute_escape($thisMedia['title']) . '" onchange="javascript: podPressMediaFiles[' . $num . '][\'title\'] = this.value;" />' . "\n";
         echo '						</td>' . "\n";
         echo '					</tr>' . "\n";
         echo '					<tr>' . "\n";
         echo '						<th>' . "\n";
         echo '							<label for="podPressMedia_' . $num . '_type">' . __('Type', 'podpress') . '</label>: ' . "\n";
         echo '						</th>' . "\n";
         echo '						<td>' . "\n";
         echo '							<select id="podPressMedia_' . $num . '_type" name="podPressMedia[' . $num . '][type]" onchange="javascript: podPressMediaFiles[' . $num . '][\'type\'] = this.value; podPressAdjustMediaFieldsBasedOnType(' . $num . ');" >' . "\n";
         podPress_mediaOptions();
         echo '</select>' . "\n";
         echo '						</td>' . "\n";
         echo '					</tr>' . "\n";
         echo '					<tr id="podPressMediaSizeWrapper_' . $num . '" >' . "\n";
         echo '						<th>' . "\n";
         echo '							<label for="podPressMedia_' . $num . '_size">' . __('File Size', 'podpress') . '</label>: ' . "\n";
         echo '						</th>' . "\n";
         echo '						<td>' . "\n";
         echo '							<input type="text" id="podPressMedia_' . $num . '_size" name="podPressMedia[' . $num . '][size]" size="10" value="' . $thisMedia['size'] . '" onchange="javascript: podPressMediaFiles[' . $num . '][\'size\'] = this.value;"/> ' . __('[in byte]', 'podpress') . ' <img src="' . $plugins_url . '/images/ajax-loader.gif" id="podPressMedia_' . $num . '_size_loadimg" class="podpress_ajax_loader_img" /><input type="button" id="podPressMedia_' . $num . '_size_detectbutton" value="' . __('Auto Detect', 'podpress') . '" onclick="podPress_getfileinfo(\'size\', ' . $num . ');" />' . "\n";
         echo '						</td>' . "\n";
         echo '					</tr>' . "\n";
         echo '					<tr id="podPressMediaDurationWrapper_' . $num . '" style="display: none;">' . "\n";
         echo '						<th>' . "\n";
         echo '							<label for="podPressMedia_' . $num . '_duration">' . __('Duration', 'podpress') . '</label>: ' . "\n";
         echo '						</th>' . "\n";
         echo '						<td>' . "\n";
         echo '							<input type="text" id="podPressMedia_' . $num . '_duration" name="podPressMedia[' . $num . '][duration]" size="10" value="' . $thisMedia['duration'] . '" onchange="javascript: podPressMediaFiles[' . $num . '][\'duration\'] = this.value;"/> <span class="podpress_abbr" title="' . __('hours:minutes:seconds - for example: 2:45:10 or 34:01 or 1:36 or 120:47 or 0:10', 'podpress') . '">' . __('[hh:mm:ss]', 'podpress') . '</span> <img src="' . $plugins_url . '/images/ajax-loader.gif" id="podPressMedia_' . $num . '_duration_loadimg" class="podpress_ajax_loader_img" /><input type="button" id="podPressMedia_' . $num . '_duration_detectbutton" value="' . __('Auto Detect', 'podpress') . '" onclick="podPress_getfileinfo(\'duration\', ' . $num . ');" /> (' . sprintf(__('This may take some time for remote files. %1$s', 'podpress'), '<span class="podpress_abbr" title="' . __('If the file is not on the same server as your blog then podPress will attempt to download the file in order to get this information with the help of getID3() which is only able to retrieve ID3 tags from local files. podPress removes the temporary download file at the end of this process. It is likely that this feature works only for relative small files because the download is probably limited by execution time and memory limits on the server of your blog.', 'podpress') . '">' . __('Because ...', 'podpress') . '</span>') . ')' . "\n";
         echo '						</td>' . "\n";
         echo '					</tr>' . "\n";
         if (empty($thisMedia['previewImage'])) {
             $thisMedia['previewImage'] = podPress_url() . 'images/vpreview_center.png';
         }
         echo '					<tr id="podPressMediaPreviewImageWrapper_' . $num . '" style="display: none;">' . "\n";
         echo '						<th>' . "\n";
         echo '							<label for="podPressMedia_' . $num . '_previewImage">' . __('Preview Image URL', 'podpress') . '</label>: ' . "\n";
         echo '						</th>' . "\n";
         echo '						<td>' . "\n";
         echo '							<input type="text" id="podPressMedia_' . $num . '_previewImage" name="podPressMedia[' . $num . '][previewImage]" class="podpress_wide_text_field" size="40" value="' . attribute_escape($thisMedia['previewImage']) . '" onchange="javascript: podPressPreviewImageOnChange(' . $num . ', this.value);" />' . "\n";
         echo '						</td>' . "\n";
         echo '					</tr>' . "\n";
         echo '					<tr id="podPressMediaPreviewImageDisplayWrapper_' . $num . '" style="display: none;">' . "\n";
         echo '						<th>' . "\n";
         echo '							' . __('Preview Image', 'podpress') . ': ' . "\n";
         echo '						</th>' . "\n";
         echo '						<td>' . "\n";
         echo '							<div id="podPressPlayerSpace_' . $num . '"></div>' . "\n";
         echo '<script type="text/javascript"><!--' . "\n";
         //echo "	document.getElementById('podPressPlayerSpace_".$num."').innerHTML = podPressGenerateVideoPreview (".$num.", '', , , document.getElementById('podPressMedia_".$num."_previewImage').value, true);\n";
         echo "\tdocument.getElementById('podPressPlayerSpace_" . $num . "').innerHTML = podPressGenerateVideoPreview (" . $num . ", '', " . $thisMedia['dimensionW'] . ", " . $thisMedia['dimensionH'] . ", document.getElementById('podPressMedia_" . $num . "_previewImage').value, true);\n";
         //echo "	document.getElementById('podPressPlayerSpace_".$num."').innerHTML = podPressGenerateVideoPreview (".$num.", '', ".intval($thisMedia['dimensionW']).", ".intval($thisMedia['dimensionH']).", document.getElementById('podPressMedia_".$num."_previewImage').value, true);\n";
         echo "--></script>\n";
         echo '						</td>' . "\n";
         echo '					</tr>' . "\n";
         echo '					<tr id="podPressMediaDimensionWrapper_' . $num . '">' . "\n";
         echo '						<th>' . "\n";
         echo '							' . __('Dimensions', 'podpress') . ' (WxH): ' . "\n";
         echo '						</th>' . "\n";
         echo '						<td>' . "\n";
         echo '							<input type="text" id="podPressMedia_' . $num . '_dimensionW" name="podPressMedia[' . $num . '][dimensionW]" size="5" value="' . $thisMedia['dimensionW'] . '" onchange="javascript: podPressMediaFiles[' . $num . '][\'dimensionW\'] = this.value; podPressUpdateDimensionList(\'' . $num . '\');" />x<input type="text" id="podPressMedia_' . $num . '_dimensionH" name="podPressMedia[' . $num . '][dimensionH]" size="5" value="' . $thisMedia['dimensionH'] . '" onchange="javascript: podPressMediaFiles[' . $num . '][\'dimensionH\'] = this.value; podPressUpdateDimensionList(\'' . $num . '\')" /> ' . "\n";
         echo '							 ' . __('or', 'podpress') . ' ';
         echo '							<select id="podPressMedia_' . $num . '_dimensionList" onchange="javascript: podPressUpdateDimensions(\'' . $num . '\', this.value);">' . "\n";
         podPress_videoDimensionOptions($thisMedia['dimensionW'] . ':' . $thisMedia['dimensionH']);
         echo '</select>' . "\n";
         echo '						</td>' . "\n";
         echo '					</tr>' . "\n";
         if ($post->post_status == 'static') {
             echo '					<tr style="display: none;">' . "\n";
         } else {
             echo '					<tr>' . "\n";
         }
         echo '						<th>' . "\n";
         echo '							' . __('Included in', 'podpress') . ': ' . "\n";
         echo '						</th>' . "\n";
         echo '						<td>' . "\n";
         echo '							&nbsp;<label for="podPressMedia_' . $num . '_rss">' . __('RSS2', 'podpress') . '</label> <input type="checkbox" id="podPressMedia_' . $num . '_rss" name="podPressMedia[' . $num . '][rss]" onchange="javascript: podPressMediaFiles[' . $num . '][\'rss\'] = this.checked; podPressSetSingleRSS(' . $num . ');" />' . "\n";
         echo '							&nbsp;<label for="podPressMedia_' . $num . '_atom">' . __('ATOM', 'podpress') . '</label> <input type="checkbox" id="podPressMedia_' . $num . '_atom" name="podPressMedia[' . $num . '][atom]" onchange="javascript: podPressMediaFiles[' . $num . '][\'atom\'] = this.checked;" />' . "\n";
         echo '							&nbsp;<label for="podPressMedia_' . $num . '_feedonly">' . __('Feed Only', 'podpress') . '</label> <input type="checkbox" id="podPressMedia_' . $num . '_feedonly" name="podPressMedia[' . $num . '][feedonly]" onchange="javascript: podPressMediaFiles[' . $num . '][\'feedonly\'] = this.checked;" />' . "\n";
         echo '						</td>' . "\n";
         echo '					</tr>' . "\n";
         if ($this->settings['enablePremiumContent']) {
             echo '					<tr>' . "\n";
             echo '						<th>' . "\n";
             echo '							<label for="podPressMedia_' . $num . '_content_level">' . __('Subscription', 'podpress') . '</label>:';
             echo '						</th>' . "\n";
             echo '						<td>' . "\n";
             echo '							<select id="podPressMedia_' . $num . '_content_level" name="podPressMedia[' . $num . '][content_level]" onchange="javascript: podPressMediaFiles[' . $num . '][\'content_level\'] = this.value;">' . "\n";
             echo '								<option value="free" ';
             if (empty($thisMedia['content_level']) || $thisMedia['content_level'] == 'free') {
                 echo 'selected="selected"';
             }
             echo '>' . __('Free', 'podpress') . '</option>' . "\n";
             foreach (podPress_getCapList(true) as $cap) {
                 if (substr($cap, -8, 8) == '_content') {
                     echo '								<option value="' . $cap . '" ';
                     if ($thisMedia['content_level'] == $cap) {
                         echo 'selected="selected"';
                     }
                     echo '>' . __(podPress_getCapName($cap), 'podpress') . '</option>' . "\n";
                 }
             }
             echo '							</select>' . "\n";
             echo '						</td>' . "\n";
             echo '					</tr>' . "\n";
         }
         echo '					<tr>' . "\n";
         echo '						<th>' . "\n";
         echo '							<label for="podPressMedia_' . $num . '_disablePlayer">' . __('Disable Player', 'podpress') . '</label>:' . "\n";
         echo '						</th>' . "\n";
         echo '						<td>' . "\n";
         echo '							<input type="checkbox" id="podPressMedia_' . $num . '_disablePlayer" name="podPressMedia[' . $num . '][disablePlayer]"';
         if ($thisMedia['disablePlayer'] != 'false') {
             echo 'checked="checked" ';
         }
         echo ' onchange="javascript: podPressMediaFiles[' . $num . '][\'disablePlayer\'] = this.checked;" />' . "\n";
         echo '							&nbsp;&nbsp; ' . __('(Use if this media file is not compatible with one of the included players.)', 'podpress') . "\n";
         echo '						</td>' . "\n";
         echo '					</tr>' . "\n";
         echo '					<tr>' . "\n";
         echo '						<th>' . "\n";
         echo '							<label for="podPressMedia_' . $num . '_disablePreview">' . __('Disable Preview Player', 'podpress') . '</label>:' . "\n";
         echo '						</th>' . "\n";
         echo '						<td>' . "\n";
         echo '							<input type="checkbox" id="podPressMedia_' . $num . '_disablePreview" name="podPressMedia[' . $num . '][disablePreview]"';
         if ($thisMedia['disablePreview'] != 'false') {
             echo 'checked="checked" ';
         }
         echo ' onchange="javascript: podPressMediaFiles[' . $num . '][\'disablePreview\'] = this.checked;" />' . "\n";
         echo '							&nbsp;&nbsp; ' . __('(Use this to disable the "Click to Play" preview player.)', 'podpress') . "\n";
         echo '						</td>' . "\n";
         echo '					</tr>' . "\n";
         $actionMedia = $thisMedia;
         $actionMedia['num'] = $num;
         do_action('podPress_customMediaData', array($actionMedia));
         echo '					<tr id="podPressMedia_' . $num . '_id3tags_details_row">' . "\n";
         echo '						<th>' . "\n";
         echo '							' . __('ID3 Tag Info', 'podpress') . ":\n";
         echo '						</th>' . "\n";
         echo '						<td>' . "\n";
         echo '							<img src="' . $plugins_url . '/images/ajax-loader.gif" id="podPressMedia_' . $num . '_id3tags_loadimg" class="podpress_ajax_loader_img" /><input type="button" id="podPressMedia_' . $num . '_id3tags_detectbutton" value="' . __('Show', 'podpress') . '" onclick="javascript: podPressShowHideID3Tags(' . $num . ');" /> (' . sprintf(__('This may take some time for remote files. %1$s', 'podpress'), '<span class="podpress_abbr" title="' . __('If the file is not on the same server as your blog then podPress will attempt to download the file in order to get this information with the help of getID3() which is only able to retrieve ID3 tags from local files. podPress removes the temporary download file at the end of this process. It is likely that this feature works only for relative small files because the download is probably limited by execution time and memory limits on the server of your blog.', 'podpress') . '">' . __('Because ...', 'podpress') . '</span>') . ')' . "\n";
         echo '						</td>' . "\n";
         echo '					</tr>' . "\n";
         echo '					<tr>' . "\n";
         echo '						<td colspan="2">' . "\n";
         echo '							<div id="podPressMedia_' . $num . '_id3tags" style="display: none; vertical-align: top;">' . "\n";
         echo '							</div>' . "\n";
         echo '						</td>' . "\n";
         echo '					</tr>' . "\n";
         echo '				</table>' . "\n";
         echo '			</div> <!-- end: podPressMediaFileContainer_' . $num . ' -->' . "\n";
         $num++;
     }
     echo '			<input type="button" name="podPressAddAnother" value="' . __('Add Media File', 'podpress') . '" onclick="javascript: podPressAddMediaFile(true, \'\', \'\', \'\', \'\', \'\', \'\', \'\', \'\', \'\', \'new\', true, false, false, \'free\'); podPressDisplayMediaFiles();"/>' . "\n";
     if ($entryType != 'page') {
         echo '			<br/>' . "\n";
         echo '			<h4>' . __('Post specific settings for iTunes:', 'podpress') . '</h4>' . "\n";
         //echo '			<input type="button" name="iTunesSpecificSettings_button" id="iTunesSpecificSettings_button" value="Show" onclick="javascript: podPressShowHideDiv(\'iTunesSpecificSettings\');"/>'."\n";
         echo '     			<div class="wrap" id="iTunesSpecificSettings">' . "\n";
         echo '				<table class="podpress_editor_table">' . "\n";
         echo '					<tr>' . "\n";
         echo '						<th>' . "\n";
         echo '							<label for="iTunesSubtitleChoice">' . __('iTunes:Subtitle', 'podpress') . '</label> <a href="javascript:void(null);" onclick="javascript: podPressShowHideRow(\'iTunesSubtitleHelp\');">(?)</a>:' . "\n";
         echo '						</th>' . "\n";
         echo '						<td>' . "\n";
         echo '							<select id="iTunesSubtitleChoice" name="iTunesSubtitleChoice" onchange="javascript: if(this.value == \'Custom\') { document.getElementById(\'iTunesSubtitleWrapper\').style.display=\'\'; } else { document.getElementById(\'iTunesSubtitleWrapper\').style.display=\'none\'; }">' . "\n";
         echo '								<option value="PostExcerpt" ';
         if ($post->podPressPostSpecific['itunes:subtitle'] == '##PostExcerpt##') {
             echo 'selected="selected"';
         }
         echo '>' . __('Use the excerpt', 'podpress') . '</option>' . "\n";
         echo '								<option value="Custom" ';
         if ($post->podPressPostSpecific['itunes:subtitle'] != '##PostExcerpt##') {
             echo 'selected="selected"';
         }
         echo '>' . __('Insert custom value', 'podpress') . '</option>' . "\n";
         echo '							</select>' . "\n";
         echo '						</td>' . "\n";
         echo '					</tr>' . "\n";
         echo '					<tr id="iTunesSubtitleHelp" style="display: none;">' . "\n";
         echo '						<th>&nbsp;</th>' . "\n";
         echo '						<td>' . sprintf(__('"%1$s" (default) podPress takes the first 255 characters from the excerpt of the excerpt and if there is none from the blog Post text.', 'podpress'), __('Use the excerpt', 'podpress')) . '</td>' . "\n";
         echo '					</tr>' . "\n";
         if ($post->podPressPostSpecific['itunes:subtitle'] == '##PostExcerpt##') {
             $tempShowMe = 'style="display: none;"';
             $post->podPressPostSpecific['itunes:subtitle'] = '';
         } else {
             $tempShowMe = '';
         }
         echo '					<tr id="iTunesSubtitleWrapper" ' . $tempShowMe . '>' . "\n";
         echo '						<th>&nbsp;</th>' . "\n";
         echo '						<td>' . "\n";
         echo '							<textarea name="iTunesSubtitle" class="podpress_wide_text_field" rows="4" cols="40">' . stripslashes($post->podPressPostSpecific['itunes:subtitle']) . '</textarea>' . "\n";
         echo '						</td>' . "\n";
         echo '					</tr>' . "\n";
         echo '					<tr>' . "\n";
         echo '						<th>' . "\n";
         echo '							<label for="iTunesSummaryChoice">' . __('iTunes:Summary', 'podpress') . '</label> <a href="javascript:void(null);" onclick="javascript: podPressShowHideRow(\'iTunesSummaryHelp\');">(?)</a>:' . "\n";
         echo '						</th>' . "\n";
         echo '						<td>' . "\n";
         echo '							<select id="iTunesSummaryChoice" name="iTunesSummaryChoice" onchange="javascript: if(this.value == \'Custom\') { document.getElementById(\'iTunesSummaryWrapper\').style.display=\'\'; } else { document.getElementById(\'iTunesSummaryWrapper\').style.display=\'none\'; }">' . "\n";
         echo '								<option value="PostExcerpt" ';
         if ($post->podPressPostSpecific['itunes:summary'] == '##PostExcerpt##') {
             echo 'selected="selected"';
         }
         echo '>' . __('Use the excerpt', 'podpress') . '</option>' . "\n";
         echo '								<option value="PostContentShortened" ';
         if ($post->podPressPostSpecific['itunes:summary'] == '##PostContentShortened##') {
             echo 'selected="selected"';
         }
         echo '>' . __('autom. excerpt of the post content', 'podpress') . '</option>' . "\n";
         echo '								<option value="Global" ';
         if ($post->podPressPostSpecific['itunes:summary'] == '##Global##') {
             echo 'selected="selected"';
         }
         echo '>' . __('Use Global', 'podpress') . '</option>' . "\n";
         echo '								<option value="Custom" ';
         if ($post->podPressPostSpecific['itunes:summary'] != '##Global##' && $post->podPressPostSpecific['itunes:summary'] != '##PostExcerpt##' && $post->podPressPostSpecific['itunes:summary'] != '##PostContentShortened##') {
             echo 'selected="selected"';
         }
         echo '>' . __('Insert custom value', 'podpress') . '</option>' . "\n";
         echo '							</select>' . "\n";
         echo '						</td>' . "\n";
         echo '					</tr>' . "\n";
         echo '					<tr id="iTunesSummaryHelp" style="display: none;">' . "\n";
         echo '						<th>&nbsp;</th>' . "\n";
         echo '						<td>' . sprintf(__('"%1$s" (default) podPress takes the excerpt. If you have not written an excerpt then it takes a part from the blog Post text.', 'podpress'), __('Use the excerpt', 'podpress')) . '</td>' . "\n";
         echo '					</tr>' . "\n";
         if ($post->podPressPostSpecific['itunes:summary'] == '##Global##' || $post->podPressPostSpecific['itunes:summary'] == '##PostExcerpt##' || $post->podPressPostSpecific['itunes:summary'] == '##PostContentShortened##') {
             $tempShowMe = 'style="display: none;"';
             $post->podPressPostSpecific['itunes:summary'] = '';
         } else {
             $tempShowMe = '';
         }
         echo '					<tr id="iTunesSummaryWrapper" ' . $tempShowMe . '>' . "\n";
         echo '						<th>&nbsp;</th>' . "\n";
         echo '						<td>' . "\n";
         echo '							<textarea name="iTunesSummary" class="podpress_wide_text_field" rows="4" cols="40">' . stripslashes($post->podPressPostSpecific['itunes:summary']) . '</textarea>' . "\n";
         echo '						</td>' . "\n";
         echo '					</tr>' . "\n";
         echo '					<tr>' . "\n";
         echo '						<th>' . "\n";
         echo '							<label for="iTunesKeywordsChoice">' . __('iTunes:Keywords', 'podpress') . '</label> <a href="javascript:void(null);" onclick="javascript: podPressShowHideRow(\'iTunesKeywordsHelp\');">(?)</a>:' . "\n";
         echo '						</th>' . "\n";
         echo '						<td>' . "\n";
         echo '							<select id="iTunesKeywordsChoice" name="iTunesKeywordsChoice" onchange="javascript: if(this.value == \'Custom\') { document.getElementById(\'iTunesKeywordsWrapper\').style.display=\'\'; } else { document.getElementById(\'iTunesKeywordsWrapper\').style.display=\'none\'; }">' . "\n";
         echo '								<option value="WordPressCats" ';
         if ($post->podPressPostSpecific['itunes:keywords'] == '##WordPressCats##') {
             echo 'selected="selected"';
         }
         echo '>' . __('Use WordPress Categories', 'podpress') . '</option>' . "\n";
         echo '								<option value="post_tags" ';
         if ($post->podPressPostSpecific['itunes:keywords'] == '##post_tags##') {
             echo 'selected="selected"';
         }
         echo '>' . __('Use the tags of the post', 'podpress') . '</option>' . "\n";
         echo '								<option value="Global" ';
         if ($post->podPressPostSpecific['itunes:keywords'] == '##Global##') {
             echo 'selected="selected"';
         }
         echo '>' . __('Use Global', 'podpress') . ' (' . podPress_stringLimiter(stripslashes($this->settings['iTunes']['keywords']), 40) . ')</option>' . "\n";
         echo '								<option value="Custom" ';
         if ($post->podPressPostSpecific['itunes:keywords'] != '##Global##' and $post->podPressPostSpecific['itunes:keywords'] != '##WordPressCats##' and $post->podPressPostSpecific['itunes:keywords'] != '##post_tags##') {
             echo 'selected="selected"';
         }
         echo '>' . __('Insert custom value', 'podpress') . '</option>' . "\n";
         echo '							</select>' . "\n";
         echo '						</td>' . "\n";
         echo '					</tr>' . "\n";
         echo '					<tr id="iTunesKeywordsHelp" style="display: none;">' . "\n";
         echo '						<th>&nbsp;</th>' . "\n";
         echo '						<td>' . __('Not visible in iTunes, but used for searches.', 'podpress') . '</td>' . "\n";
         echo '					</tr>' . "\n";
         if ($post->podPressPostSpecific['itunes:keywords'] == '##Global##' or $post->podPressPostSpecific['itunes:keywords'] == '##WordPressCats##' or $post->podPressPostSpecific['itunes:keywords'] == '##post_tags##') {
             $tempShowMe = 'style="display: none;"';
             $post->podPressPostSpecific['itunes:keywords'] = '';
         } else {
             $tempShowMe = '';
         }
         echo '					<tr id="iTunesKeywordsWrapper" ' . $tempShowMe . '>' . "\n";
         echo '						<th>&nbsp;</th>' . "\n";
         echo '						<td>' . "\n";
         echo '							' . __('a list of max. 12 comma separated words', 'podpress') . '<br/><textarea name="iTunesKeywords" class="podpress_wide_text_field" rows="4" cols="40">' . stripslashes($post->podPressPostSpecific['itunes:keywords']) . '</textarea>' . "\n";
         echo '						</td>' . "\n";
         echo '					</tr>' . "\n";
         echo '					<tr>' . "\n";
         echo '						<th>' . "\n";
         echo '							<label for="iTunesAuthorChoice">' . __('iTunes:Author', 'podpress') . '</label> <a href="javascript:void(null);" onclick="javascript: podPressShowHideRow(\'iTunesAuthorHelp\');">(?)</a>:' . "\n";
         echo '						</th>' . "\n";
         echo '						<td>' . "\n";
         echo '							<select id="iTunesAuthorChoice" name="iTunesAuthorChoice" onchange="javascript: if(this.value == \'Custom\') { document.getElementById(\'iTunesAuthorWrapper\').style.display=\'\'; } else { document.getElementById(\'iTunesAuthorWrapper\').style.display=\'none\'; }">' . "\n";
         echo '								<option value="Global" ';
         if ($post->podPressPostSpecific['itunes:author'] == '##Global##') {
             echo 'selected="selected"';
         }
         echo '>' . __('Use Global', 'podpress') . ' (' . podPress_stringLimiter(ucfirst(stripslashes($this->settings['iTunes']['author'])), 40) . ')</option>' . "\n";
         echo '								<option value="Custom" ';
         if ($post->podPressPostSpecific['itunes:author'] != '##Global##') {
             echo 'selected="selected"';
         }
         echo '>' . __('Insert custom value', 'podpress') . '</option>' . "\n";
         echo '							</select>' . "\n";
         echo '						</td>' . "\n";
         echo '					</tr>' . "\n";
         echo '					<tr id="iTunesAuthorHelp" style="display: none;">' . "\n";
         echo '						<th>&nbsp;</th>' . "\n";
         echo '						<td>' . __('Used if this Author is different than the feeds author.', 'podpress') . '</td>' . "\n";
         echo '					</tr>' . "\n";
         if ($post->podPressPostSpecific['itunes:author'] == '##Global##') {
             $tempShowMe = 'style="display: none;"';
             $post->podPressPostSpecific['itunes:author'] = '';
         } else {
             $tempShowMe = '';
         }
         echo '					<tr id="iTunesAuthorWrapper" ' . $tempShowMe . '>' . "\n";
         echo '						<th>&nbsp;</th>' . "\n";
         echo '						<td><input type="text" name="iTunesAuthor" class="podpress_wide_text_field" size="40" value="' . attribute_escape($post->podPressPostSpecific['itunes:author']) . '" /></td>' . "\n";
         echo '					</tr>' . "\n";
         echo '					<tr>' . "\n";
         echo '						<th>' . "\n";
         echo '							<label for="iTunesExplicit">' . __('iTunes:Explicit', 'podpress') . '</label> <a href="javascript:void(null);" onclick="javascript: podPressShowHideRow(\'iTunesExplicitHelp\');">(?)</a>:' . "\n";
         echo '						</th>' . "\n";
         echo '						<td>' . "\n";
         echo '							<select id="iTunesExplicit" name="iTunesExplicit">' . "\n";
         echo '								<option value="Default" ';
         if ($post->podPressPostSpecific['itunes:explicit'] == 'Default') {
             echo 'selected="selected"';
         }
         echo '>' . __('Use Default', 'podpress') . ' (' . $this->settings['iTunes']['explicit'] . ')</option>' . "\n";
         echo '								<option value="No" ';
         if ($post->podPressPostSpecific['itunes:explicit'] == 'No') {
             echo 'selected="selected"';
         }
         echo '>' . __('No', 'podpress') . '</option>' . "\n";
         echo '								<option value="Yes" ';
         if ($post->podPressPostSpecific['itunes:explicit'] == 'Yes') {
             echo 'selected="selected"';
         }
         echo '>' . __('Yes', 'podpress') . '</option>' . "\n";
         echo '								<option value="Clean" ';
         if ($post->podPressPostSpecific['itunes:explicit'] == 'Clean') {
             echo 'selected="selected"';
         }
         echo '>' . __('Clean', 'podpress') . '</option>' . "\n";
         echo '							</select>' . "\n";
         echo '						</td>' . "\n";
         echo '					</tr>' . "\n";
         echo '					<tr id="iTunesExplicitHelp" style="display: none;">' . "\n";
         echo '						<th>&nbsp;</th>' . "\n";
         echo '						<td>' . __('Does your podcast contain explicit language or adult content? (If you choose "Yes" or "Clean" then a corresponding notice will show up in iTunes (Explicit resp. Clean). If you choose "No" then there will be special notice.)', 'podpress') . '</td>' . "\n";
         echo '					</tr>' . "\n";
         echo '					<tr>' . "\n";
         echo '						<th>' . "\n";
         echo '							<label for="iTunesBlock">' . __('iTunes:Block', 'podpress') . '</label> <a href="javascript:void(null);" onclick="javascript: podPressShowHideRow(\'itunesBlockHelp\');">(?)</a>:' . "\n";
         echo '						</th>' . "\n";
         echo '						<td>' . "\n";
         echo '							<select id="iTunesBlock" name="iTunesBlock">' . "\n";
         echo '								<option value="Default" ';
         if ($post->podPressPostSpecific['itunes:block'] == 'Default') {
             echo 'selected="selected"';
         }
         echo '>' . __('Use Default', 'podpress') . ' (' . $this->settings['iTunes']['block'] . ')</option>' . "\n";
         echo '								<option value="No" ';
         if ($post->podPressPostSpecific['itunes:block'] == 'No') {
             echo 'selected="selected"';
         }
         echo '>' . __('No', 'podpress') . '</option>' . "\n";
         echo '								<option value="Yes" ';
         if ($post->podPressPostSpecific['itunes:block'] == 'Yes') {
             echo 'selected="selected"';
         }
         echo '>' . __('Yes', 'podpress') . '</option>' . "\n";
         echo '							</select>' . "\n";
         echo '						</td>' . "\n";
         echo '					</tr>' . "\n";
         echo '					<tr id="itunesBlockHelp" style="display: none;">' . "\n";
         echo '						<th>&nbsp;</th>' . "\n";
         echo '						<td>' . __('Prevent this episode or podcast from appearing in iTunes.', 'podpress') . '</td>' . "\n";
         echo '					</tr>' . "\n";
         echo '				</table>' . "\n";
         echo '			</div> <!-- end: iTunesSpecificSettings -->' . "\n";
     }
     if ($this->settings['enablePodangoIntegration']) {
         echo "\t\t\t<br/>\n";
         echo '			<strong>Podango File Uploader</strong>';
         if ($this->settings['podangoDefaultPodcast'] == '##ALL##') {
             $podangoPodcastList = $this->podangoapi->GetPodcasts(true);
             echo ' <strong>for: </strong><select name="podPressPodangoPodcastID" id="podPressPodangoPodcastID" onChange="javascript: document.getElementById(\'podangoUploadFrame\').src=\'' . $this->podangoapi->fileUploader . '?podcastId=\'+this.value">' . "\n";
             foreach ($podangoPodcastList as $k => $v) {
                 if (!isset($podangoPodcastID)) {
                     $podangoPodcastID = $k;
                 }
                 echo '						<option value="' . $k . '">' . $v['Title'] . '</option>' . "\n";
             }
             echo '					</select>' . "\n";
         } else {
             $podangoPodcastID = $this->settings['podangoDefaultPodcast'];
         }
         echo '<br/>' . "\n";
         echo '			<iframe src="' . $this->podangoapi->fileUploader . '?podcastId=' . $podangoPodcastID . '" id="podangoUploadFrame" title="Podango Upload" border="0" width="560" height="110"> </iframe>' . "\n";
     }
     echo '<script type="text/javascript">podPressDisplayMediaFiles(); </script>' . "\n";
 }
Exemplo n.º 5
0
 function xmlrpc_post_addMedia($input)
 {
     $postdata = $input['postdata'];
     $content_struct = $input['content_struct'];
     if (isset($content_struct['enclosure']) && !empty($content_struct['enclosure']['url'])) {
         $media[0]['URI'] = $content_struct['enclosure']['url'];
         $media[0]['authorized'] = true;
         if (!empty($content_struct['enclosure']['type'])) {
             $media[0]['type'] = $content_struct['enclosure']['type'];
         } else {
             $media[0]['type'] = podPress_mimetypes(podPress_getFileExt($content_struct['enclosure']['url']));
         }
         if ($media[0]['type'] == 'video/x-ms-wmv') {
             $media[0]['type'] = 'video/wmv';
         } elseif ($media[0]['type'] == 'video/x-flv') {
             $media[0]['type'] = 'video/flv';
         }
         $media[0]['type'] = str_replace('/', '_', $media[0]['type']);
         if (!empty($content_struct['enclosure']['duration'])) {
             $media[0]['duration'] = $content_struct['enclosure']['duration'];
         } else {
             $media[0]['duration'] = 0;
         }
         if (!empty($content_struct['enclosure']['size'])) {
             $media[0]['size'] = $content_struct['enclosure']['size'];
         } else {
             $media[0]['size'] = 0;
         }
         if (!empty($content_struct['enclosure']['title'])) {
             $media[0]['title'] = $content_struct['enclosure']['title'];
         }
         if (!empty($content_struct['enclosure']['previewImage'])) {
             $media[0]['previewImage'] = $content_struct['enclosure']['previewImage'];
         }
         if (!empty($content_struct['enclosure']['rss'])) {
             $media[0]['rss'] = $content_struct['enclosure']['rss'];
         } else {
             $media[0]['rss'] = true;
         }
         delete_post_meta($postdata['ID'], '_podPressMedia');
         podPress_add_post_meta($postdata['ID'], '_podPressMedia', $media, true);
     }
     return true;
 }
Exemplo n.º 6
0
/**
 * podPress_downloadFile - downloads the header a part or the whole file from a remote server (to give getID3() the chance to retrieve the ID3 information like duration etc.)
 *
 * @package podPress
 * @since (unknown)
 *
 * @param string $uriFileName - the URL of the media file
 * @param boolean $getHeaders - download only the header (TRUE) or more than that (FALSE)
 * @param numeric $limitDownload - file size in kb to limit the amount data which should be downloaded from a remote media file (used in podPress_getCoverArt())
 *
 * return mixed - the full HTTP response header or the file name of the downloaded file
 */
function podPress_downloadFile($uriFileName, $getHeaders = false, $limitDownload = false)
{
    global $podPress;
    $max_time = podPress_get_max_execution_time();
    podPress_var_dump('podPress_downloadFile - time limit: ' . $max_time);
    $safety = 2;
    // seconds
    $aborttimelimit = FALSE;
    $aborthttperror = FALSE;
    $start_time = array_sum(explode(chr(32), microtime()));
    podPress_var_dump('podPress_downloadFile - given URL: ' . $uriFileName);
    $uriFileName = podPress_ResolveReDirects($uriFileName);
    if (FALSE === function_exists('curl_init')) {
        $aURL = parse_url($uriFileName);
        if ($aURL['scheme'] != 'http') {
            podPress_var_dump('podPress_downloadFile - returning - not a http:// URL : ' . var_export($aURL, TRUE));
            return;
        }
        $sHost = $aURL['host'];
        $sFilepath = (isset($aURL['path']) ? $aURL['path'] : '/') . (isset($aURL['query']) ? '?' . $aURL['query'] : '');
        // mask white spaces in the file name
        $sFilepath = str_replace(' ', '%20', $sFilepath);
        $nPort = isset($aURL['port']) ? $aURL['port'] : 80;
        if (function_exists('fsockopen')) {
            $fpRemote = @fsockopen($sHost, $nPort, $errno, $errstr, 30);
        } else {
            $fpRemote = FALSE;
            return FALSE;
        }
        if (TRUE === $getHeaders) {
            podPress_var_dump('podPress_downloadFile - get only the header');
            podPress_var_dump('podPress_downloadFile - ' . $sHost . $sFilepath);
            $sHeaders = "HEAD " . $sFilepath . " HTTP/1.1\r\n";
            $sHeaders .= "Host: " . $sHost . "\r\n";
            $sHeaders .= "Connection: Close\r\n\r\n";
            podPress_var_dump($sHeaders);
            // Sending headers
            fwrite($fpRemote, $sHeaders);
            // Getting back the header information
            $header = '';
            $line = '';
            $continue = true;
            $soFar = 0;
            // Processing the server answer (header) line by line
            while (!feof($fpRemote) && $continue) {
                $line = fgets($fpRemote, 1024);
                $soFar = $soFar + 1024;
                if ($limitDownload !== false && $soFar > $limitDownload) {
                    $continue = false;
                }
                $header .= $line;
            }
            // Closing the socket
            fclose($fpRemote);
            podPress_var_dump('podPress_downloadFile - (header) before return');
            podPress_var_dump($header);
            return $header;
        } else {
            podPress_var_dump('podPress_downloadFile - download the file');
            podPress_var_dump('podPress_downloadFile - ' . $sHost . $sFilepath);
            $sHeaders = "GET " . $sFilepath . " HTTP/1.1\r\n";
            $sHeaders .= "Host: " . $sHost . "\r\n";
            $sHeaders .= "Connection: Close\r\n\r\n";
            // Sending headers
            fwrite($fpRemote, $sHeaders);
            // determine a temp folder and temp file name
            $ext = podPress_getFileExt($uriFileName);
            $pos = strpos($ext, '?');
            if ($pos) {
                $ext = substr($ext, 0, $pos);
            }
            // Trying to write into the servers temp folder. The temp file has to have the media files extension. Because getID3 does not work without it.
            $localtempfilename = @tempnam('/tmp', 'getID3') . '.' . $ext;
            if (FALSE == $localtempfilename or '.' . $ext == $localtempfilename) {
                // If it is not possible to get the temp folder via tempnam() then try to write into the temp folder of podPress
                $podPress->checkWritableTempFileDir();
                $localtempfilename = $podPress->tempfilesystempath . '/podpress_tmp.' . $ext;
            }
            if (!($fp_local = @fopen($localtempfilename, 'wb'))) {
                // if it is not possible to open a temp file then return
                // Closing the socket
                fclose($fpRemote);
                return '';
            }
            podPress_var_dump('podPress_downloadFile - (file) localtempfilename: ' . $localtempfilename);
            // Getting back header + content
            $continue = true;
            $is_body = false;
            $soFar = 0;
            $line = "";
            $trimmed_line = "";
            $step_time = array_sum(explode(chr(32), microtime()));
            // Processing the server answer (header + content) line by line
            while (!feof($fpRemote) && $continue) {
                $line = fgets($fpRemote, 1024);
                $soFar = $soFar + 1024;
                // some times the answer of the remote server contains a HTTP header which should not be a part of the temp file
                // after the HTTP should always be a empty line which is followed by the remote file - see http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4
                if ($is_body) {
                    if ($limitDownload !== false && $soFar > $limitDownload) {
                        $continue = false;
                    }
                    // write the content of the remote file into the temp file
                    fwrite($fp_local, $line);
                } else {
                    $trimmed_line = Trim($line);
                    // contol the first line (chunk) of the header information
                    if ($soFar <= 1024) {
                        // check the HTTP status number
                        $HTTP_result = preg_match('/HTTP\\/[0-9].[0-9] ([1-5][0-9][0-9])/', $trimmed_line, $headerMatches);
                        // If the HTTP status is not 200 then something with the filename (or URL) was not ok  or something on the server was wrong.
                        if (isset($headerMatches[1]) and '200' != $headerMatches[1]) {
                            podPress_var_dump('podPress_downloadFile - aborting - HTTP status: ' . $headerMatches[1]);
                            $aborthttperror = TRUE;
                            $continue = FALSE;
                        }
                    }
                    if (FALSE !== empty($trimmed_line)) {
                        // if the line is empty then the last line of the HTTP header of the server answer and the file content begins
                        $is_body = true;
                    }
                }
                $step_time = array_sum(explode(chr(32), microtime()));
                if ($step_time - $start_time >= $max_time - $safety) {
                    $continue = FALSE;
                    $aborttimelimit = TRUE;
                    podPress_var_dump('podPress_downloadFile - aborting download because of a time limit');
                }
            }
            // Closing the temp file
            fclose($fp_local);
            // Closing the socket
            fclose($fpRemote);
            podPress_var_dump('podPress_downloadFile - (file) before return');
            // return the name of the temp file
            return $localtempfilename;
        }
    } else {
        if (TRUE === $getHeaders) {
            podPress_var_dump('podPress_downloadFile - curl_init is available | getHeaders = true');
            return podPress_get_HTTP_header_via_cURL($uriFileName, $max_time, $safety);
        } else {
            podPress_var_dump('podPress_downloadFile - curl_init is available | getHeaders = false');
            // determine a temp folder and temp file name
            $ext = podPress_getFileExt($uriFileName);
            $pos = strpos($ext, '?');
            if ($pos) {
                $ext = substr($ext, 0, $pos);
            }
            // Trying to write into the servers temp folder. The temp file has to have the media files extension. Because getID3 does not work without it.
            $localtempfilename = @tempnam('/tmp', 'getID3') . '.' . $ext;
            if (FALSE == $localtempfilename or '.' . $ext == $localtempfilename) {
                // If it is not possible to get the temp folder via tempnam() then try to write into the temp folder of podPress
                $podPress->checkWritableTempFileDir();
                $localtempfilename = $podPress->tempfilesystempath . '/podpress_tmp.' . $ext;
            }
            if (!($fp_local = @fopen($localtempfilename, 'wb'))) {
                // if it is not possible to open a temp file then return
                podPress_var_dump('podPress_downloadFile - (file) it is not possible to open a temp file');
                return '';
            }
            podPress_var_dump('podPress_downloadFile - (file) localtempfilename: ' . $localtempfilename);
            // starting cURL
            $ch = curl_init($uriFileName);
            podPress_var_dump('podPress_downloadFile - cURL HTTP code:');
            podPress_var_dump(curl_getinfo($ch, CURLINFO_HTTP_CODE));
            // make sure we get the header
            curl_setopt($ch, CURLOPT_HEADER, TRUE);
            // make it a http GET request
            curl_setopt($ch, CURLOPT_NOBODY, FALSE);
            curl_setopt($ch, CURLOPT_HTTPGET, TRUE);
            // add useragent
            curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13');
            if (FALSE !== $limitDownload) {
                podPress_var_dump('podPress_downloadFile - download only that part: 0-' . $limitDownload);
                curl_setopt($ch, CURLOPT_RANGE, '0-' . $limitDownload);
            }
            // Do not put the response into a variable. (Put it into a file.)
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, FALSE);
            // the target file (handle) for the download
            curl_setopt($ch, CURLOPT_FILE, $fp_local);
            // The maximum number of seconds to allow cURL to wait for a connection.
            curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, min(10, $max_time - $safety));
            // The maximum number of seconds to allow cURL functions to execute.
            curl_setopt($ch, CURLOPT_TIMEOUT, $max_time - $safety);
            // Tell curl to stop when it encounters an error
            curl_setopt($ch, CURLOPT_FAILONERROR, TRUE);
            @curl_exec($ch);
            // If the HTTP status is not 200 then something with the filename (or URL) was not ok  or something on the server was wrong.
            $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
            if ('200' != $http_code) {
                podPress_var_dump('podPress_downloadFile - aborting - HTTP status: ' . $http_code);
            }
            // Check if any error occured
            if (!curl_errno($ch)) {
                $bytes = curl_getinfo($ch, CURLINFO_CONTENT_LENGTH_DOWNLOAD);
                $total_time = curl_getinfo($ch, CURLINFO_TOTAL_TIME);
                podPress_var_dump('File size: ' . $bytes . ' bytes');
                podPress_var_dump('Took ' . $total_time . ' seconds to send a request to ' . $url);
                //clearstatcache();
            }
            @curl_close($ch);
            // Closing the temp file
            fclose($fp_local);
            return $localtempfilename;
        }
    }
}