public function on_shoutem_post_start($params)
 {
     $attachments =& $params['attachments_ref'];
     $post = $params['wp_post'];
     //Podpress support.
     if (function_exists('podPress_get_post_meta') && isset($GLOBALS['podPress'])) {
         global $podPress;
         //podcasts are stored in post metadata
         $audio_meta = podPress_get_post_meta($post->ID, '_podPressMedia', true);
         if (!$audio_meta) {
             $audio_meta = podPress_get_post_meta($post->ID, 'podPressMedia', true);
         }
         if ($audio_meta) {
             foreach ($audio_meta as $key => $audio) {
                 $uri = $podPress->convertPodcastFileNameToWebPath($post->ID, $key, $audio['URI'], 'web');
                 $audio_record = array('id' => '', 'src' => $uri, 'type' => 'audio', 'duration' => '');
                 $attachments['audio'][] = $audio_record;
             }
         }
     }
     return '';
 }
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 addPostData($input, $forEdit = false)
 {
     $input->podPressMedia = podPress_get_post_meta($input->ID, '_podPressMedia', true);
     if (!is_array($input->podPressMedia)) {
         $x = maybe_unserialize($input->podPressMedia);
         if (is_array($x)) {
             $input->podPressMedia = $x;
         }
         if (!is_array($input->podPressMedia)) {
             $x = maybe_unserialize($input->podPressMedia, true);
             if (is_array($x)) {
                 $input->podPressMedia = $x;
             }
         }
     }
     if (is_array($input->podPressMedia)) {
         reset($input->podPressMedia);
         while (list($key) = each($input->podPressMedia)) {
             if (!empty($input->podPressMedia[$key]['URI'])) {
                 if (TRUE == isset($input->podPressMedia[$key]['premium_only']) and $input->podPressMedia[$key]['premium_only'] == 'on' || $input->podPressMedia[$key]['premium_only'] == true) {
                     $input->podPressMedia[$key]['content_level'] = 'premium_content';
                 } elseif (!isset($input->podPressMedia[$key]['content_level'])) {
                     $input->podPressMedia[$key]['content_level'] = 'free';
                 }
                 if (!isset($input->podPressMedia[$key]['type'])) {
                     $input->podPressMedia[$key]['type'] = '';
                 }
                 settype($input->podPressMedia[$key]['size'], 'int');
                 if (0 >= $input->podPressMedia[$key]['size']) {
                     $filepath = $this->convertPodcastFileNameToSystemPath($input->podPressMedia[$key]['URI']);
                     if ($filepath) {
                         $input->podPressMedia[$key]['size'] = filesize($filepath);
                     } else {
                         $input->podPressMedia[$key]['size'] = 1;
                     }
                 }
                 $input->podPressMedia[$key]['ext'] = podPress_getFileExt($input->podPressMedia[$key]['URI']);
                 $input->podPressMedia[$key]['mimetype'] = podPress_mimetypes($input->podPressMedia[$key]['ext']);
                 if (!$forEdit && $this->settings['enablePremiumContent'] && $input->podPressMedia[$key]['content_level'] != 'free' && @$GLOBALS['current_user']->allcaps[$input->podPressMedia[$key]['content_level']] != 1) {
                     $input->podPressMedia[$key]['authorized'] = false;
                     $input->podPressMedia[$key]['URI'] = '';
                     $input->podPressMedia[$key]['URI_torrent'] = '';
                 } else {
                     $input->podPressMedia[$key]['authorized'] = true;
                 }
             }
         }
     }
     $input->podPressPostSpecific = podPress_get_post_meta($input->ID, '_podPressPostSpecific', true);
     if (!is_array($input->podPressPostSpecific)) {
         $input->podPressPostSpecific = array();
     }
     if (empty($input->podPressPostSpecific['itunes:subtitle'])) {
         $input->podPressPostSpecific['itunes:subtitle'] = '##PostExcerpt##';
     }
     if (empty($input->podPressPostSpecific['itunes:summary'])) {
         $input->podPressPostSpecific['itunes:summary'] = '##PostExcerpt##';
     }
     if (empty($input->podPressPostSpecific['itunes:keywords'])) {
         $input->podPressPostSpecific['itunes:keywords'] = '##WordPressCats##';
     }
     if (empty($input->podPressPostSpecific['itunes:author'])) {
         $input->podPressPostSpecific['itunes:author'] = '##Global##';
     }
     if (empty($input->podPressPostSpecific['itunes:explicit'])) {
         $input->podPressPostSpecific['itunes:explicit'] = 'Default';
     }
     if (empty($input->podPressPostSpecific['itunes:block'])) {
         $input->podPressPostSpecific['itunes:block'] = 'Default';
     }
     return $input;
 }
/** podPress_get_real_url - demasks an URL which is masked with the podPress stats scheme
 * @package podPress
 * @since 8.8.10.3 beta 5
 * @param mixed $url - the masked url
 * @param mixed $print - print (TRUE) or return the result (FALSE)
 * @return string - the real URL
 */
function podPress_get_real_url($url, $count = TRUE, $print = TRUE)
{
    $requested = parse_url($url);
    $requested = $requested['path'];
    $realURL = 'false';
    $pos = 0;
    if ($pos = strpos($requested, 'podpress_trac')) {
        if ($pos == 0) {
            $pos = strpos($requested, 'podpress_trac');
        }
        $pos = $pos + 14;
        if (substr($requested, $pos, 1) == '/') {
            $pos = $pos + 1;
        }
        $requested = substr($requested, $pos);
        $parts = explode('/', $requested);
        if (count($parts) == 4) {
            $postID = $parts[1];
            $mediaNum = $parts[2];
            $filename = rawurlencode($parts[3]);
            $method = $parts[0];
            $allowedMethods = array('feed', 'play', 'web');
            $realSysPath = false;
            $statID = false;
            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 (TRUE === $count) {
                $badextensions = array('.smi', '.jpg', '.png', '.gif');
                if ($filename && !in_array(strtolower(substr($filename, -4)), $badextensions)) {
                    global $podPress;
                    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;
            //~ }
        }
    }
    if (TRUE === $print) {
        echo $realURL;
    } else {
        return $realURL;
    }
}