Ticket #1064: new_feed_protection_and_fixes_for_feed_settings_pages.2.patch

File new_feed_protection_and_fixes_for_feed_settings_pages.2.patch, 43.2 KB (added by ntm, 2 years ago)

contains now a php version check in the podpress_feed_functions.php

  • podpress_admin_class.php

     
    344344                                echo '                                          </td>'."\n"; 
    345345                                echo '                                          <td>'."\n"; 
    346346                                echo '                                                  <input type="text" id="podPressMedia_'.$num.'_dimensionW" name="podPressMedia['.$num.'][dimensionW]" size="5" value="'.$thisMedia['dimensionW'].'" onchange="javascript: podPressMediaFiles['.$num.'][\'dimensionW\'] = this.value;" />x<input type="text" id="podPressMedia_'.$num.'_dimensionH" name="podPressMedia['.$num.'][dimensionH]" size="5" value="'.$thisMedia['dimensionH'].'" onchange="javascript: podPressMediaFiles['.$num.'][\'dimensionH\'] = this.value;" /> '."\n"; 
    347                                 echo '                                                  <select onchange="javascript: podPressUpdateDimensions(\''.$num.'\', this.value);">'."\n"; podPress_videoDimensionOptions();    echo '</select>'."\n"; 
     347                                echo '                                                  <select onchange="javascript: podPressUpdateDimensions(\''.$num.'\', this.value);">'."\n"; podPress_videoDimensionOptions($thisMedia['dimensionW'].':'.$thisMedia['dimensionH']);       echo '</select>'."\n"; 
    348348                                echo '                                          </td>'."\n"; 
    349349                                echo '                                  </tr>'."\n"; 
    350350 
     
    881881                                echo '                                          <td>'."\n"; 
    882882                                echo '                                                  <div id="podPressPlayerSpace_'.$num.'"></div>'."\n"; 
    883883                                echo '<script type="text/javascript"><!--'."\n"; 
    884                                 echo "  document.getElementById('podPressPlayerSpace_".$num."').innerHTML = podPressGenerateVideoPreview (".$num.", '', '', '', document.getElementById('podPressMedia_".$num."_previewImage').value, true);\n"; 
     884                                echo "  document.getElementById('podPressPlayerSpace_".$num."').innerHTML = podPressGenerateVideoPreview (".$num.", '', '', '', document.getElementById('podPressMedia_".$num."_previewImage').value, true, true);\n"; 
    885885                                echo "--></script>\n"; 
    886886                                echo '                                          </td>'."\n"; 
    887887                                echo '                                  </tr>'."\n"; 
     
    892892                                echo '                                          </td>'."\n"; 
    893893                                echo '                                          <td>'."\n"; 
    894894                                echo '                                                  <input type="text" id="podPressMedia_'.$num.'_dimensionW" name="podPressMedia['.$num.'][dimensionW]" size="5" value="'.$thisMedia['dimensionW'].'" onchange="javascript: podPressMediaFiles['.$num.'][\'dimensionW\'] = this.value;" />x<input type="text" id="podPressMedia_'.$num.'_dimensionH" name="podPressMedia['.$num.'][dimensionH]" size="5" value="'.$thisMedia['dimensionH'].'" onchange="javascript: podPressMediaFiles['.$num.'][\'dimensionH\'] = this.value;" /> '."\n"; 
    895                                 echo '                                                  <select onchange="javascript: podPressUpdateDimensions(\''.$num.'\', this.value);">'."\n"; podPress_videoDimensionOptions();    echo '</select>'."\n"; 
     895                                echo '                                                  <select onchange="javascript: podPressUpdateDimensions(\''.$num.'\', this.value);">'."\n"; podPress_videoDimensionOptions($thisMedia['dimensionW'].':'.$thisMedia['dimensionH']);       echo '</select>'."\n"; 
    896896                                echo '                                          </td>'."\n"; 
    897897                                echo '                                  </tr>'."\n"; 
    898898 
     
    12761276                        echo '          <fieldset class="options">'."\n"; 
    12771277                        echo '                  <legend>'.__('Podcast Feed Options', 'podpress').'</legend>'."\n"; 
    12781278 
    1279                         echo '          <table width="110%" cellspacing="2" cellpadding="5" class="editform" >'."\n"; 
     1279                        echo '          <table width="110%" cellspacing="2" cellpadding="5" class="editform" id="podpress_feed_options_table">'."\n"; 
    12801280                        echo '                  <tr>'."\n"; 
    12811281                        echo '                          <td width="50%"><h3>'.__('iTunes Settings', 'podpress').'</h3></td>'."\n"; 
    12821282                        echo '                          <td width="50%"><h3>'.__('Standard Settings', 'podpress').'</h3></td>'."\n"; 
     
    13641364 
    13651365                        echo '                  <tr valign="top">'."\n"; 
    13661366                        echo '                          <td width="50%">'; 
    1367                         echo '                                  <label for="iTunesImageChoice"><strong>'.__('iTunes:Image', 'podpress').' (300*300 pixels)</strong></label>'."\n"; 
     1367                        echo '                                  <label for="iTunesImageChoice"><strong>'.__('iTunes:Image', 'podpress').'</strong></label>'."\n"; 
    13681368                        echo '                                  <br/>'; 
     1369                        echo '                                  '.__('The iTunes image should be a square image with <a href="http://www.apple.com/itunes/podcasts/specs.html#image" target="_blank">at least 600 x 600 pixels</a> as Apple writes (01/2010) in "<a href="http://www.apple.com/itunes/podcasts/specs.html" target="_blank">Making a Podcast</a>" of their own Podcasting Resources. In the past 300 x 300 pixels were recommended. iTunes supports JPEG and PNG images (the file name extensions should ".jpg" or ".png").', 'podpress')."\n"; 
     1370                        echo '                                  <br/>'; 
    13691371                        echo '                                  <select id="iTunesImageChoice" name="iTunesImageChoice" onchange="javascript: podPress_updateCategoryCasting();">'."\n"; 
    13701372                        echo '                                          <option value="Global" '; if($data['iTunesImageChoice'] != 'Custom') { echo 'selected="selected"';      }       echo '>'.__('Use Global', 'podpress').'</option>'."\n"; 
    13711373                        echo '                                          <option value="Custom" '; if($data['iTunesImageChoice'] == 'Custom') { echo 'selected="selected"';      }       echo '>'.__('Custom', 'podpress').'</option>'."\n"; 
     
    13761378                        echo '                                          <input id="global_iTunesImage" type="hidden" value="'.$this->settings['iTunes']['image'].'"/>'."\n"; 
    13771379                        echo '                                  </div>'."\n"; 
    13781380                        echo '                                  <br/>'; 
    1379                         echo '                                  <img id="itunes_image_display" width="300" height="300" alt="Podcast Image - Big" src="" />'."\n"; 
     1381                        echo '                                  <img id="itunes_image_display" style="width:300px; height:300px;" alt="Podcast Image - Big" src="" /><br />'."\n"; 
     1382                        echo '                                  <em>'.__('(This image is only a preview which is limited to 300 x 300 pixels.) ', 'podpress').'</em>'; 
    13801383                        echo '                          </td>'."\n"; 
    13811384                        echo '                          <td width="50%">'; 
    1382                         echo '                                  <label for="rss_imageChoice"><strong>'.__('Blog/RSS Image', 'podpress').' (144*144 pixels)</strong></label>'."\n"; 
     1385                        echo '                                  <label for="rss_imageChoice"><strong>'.__('Blog/RSS Image (144 x 144 pixels)', 'podpress').'</strong></label>'."\n"; 
    13831386                        echo '                                  <br/>'; 
    13841387                        echo '                                  <select id="rss_imageChoice" name="rss_imageChoice" onchange="javascript: podPress_updateCategoryCasting();">'."\n"; 
    13851388                        echo '                                          <option value="Global" '; if($data['rss_imageChoice'] != 'Custom') { echo 'selected="selected"';        }       echo '>'.__('Use Global', 'podpress').'</option>'."\n"; 
     
    13911394                        echo '                                          <input id="global_rss_image" type="hidden" value="'.get_option('rss_image').'"/>'."\n"; 
    13921395                        echo '                                  </div>'."\n"; 
    13931396                        echo '                                  <br/>'; 
    1394                         echo '                                  <img id="rss_image_Display" width="144" height="144" alt="Podcast Image - Small" src="" />'."\n"; 
     1397                        echo '                                  <img id="rss_image_Display" style="width:144px; height:144px;" alt="Podcast Image - Small" src="" />'."\n"; 
    13951398                        echo '                          </td>'."\n"; 
    13961399                        echo '                  </tr>'."\n"; 
    13971400 
     
    14481451                        echo '                                  <label for="rss_language"><strong>'.__('Language', 'podpress').'</strong></label>:'."\n"; 
    14491452                        echo '                                  <br/>'; 
    14501453                        echo '                                  <select id="rss_language" name="rss_language" onchange="javascript: podPress_updateCategoryCasting();">'."\n"; 
     1454                        echo '                                          <optgroup label="'.__('Select Language', 'podpress').'">'."\n"; 
    14511455                        echo '                                          <option value="##Global##" '; if($data['rss_language'] == '##Global##' || empty($data['rss_language'])) { echo 'selected="selected"';   }       echo '>'.__('Use Global', 'podpress').' - '.$langs[get_option('rss_language')].' ['.get_option('rss_language').']</option>'."\n"; 
    14521456                        podPress_itunesLanguageOptions($data['rss_language']); 
     1457                        echo '                                          </optgroup>'."\n"; 
    14531458                        echo '                                  </select>'."\n"; 
    14541459                        echo '                                  <input type="hidden" id="global_rss_language" value="'.$langs[get_option('rss_language')].'['.stripslashes(get_option('rss_language')).']" /></td>'."\n"; 
    14551460                        echo '                          </td>'."\n"; 
     
    14771482                        echo '                                  <label for="iTunesCategory_0"><strong>'.__('iTunes:Categories', 'podpress').'</strong></label>'; 
    14781483                        echo '                                  <br/>'; 
    14791484                        echo '                                  <select id="iTunesCategory_0" name="iTunesCategory[0]" onchange="podPress_updateCategoryCasting();">'."\n"; 
    1480                         echo '                                          <option value="##Global##" '; if($data['iTunesCategory'][0] == '##Global##' || empty($data['iTunesCategory'][0])) { echo 'selected="selected"'; }       echo '>'.__('Use Global', 'podpress').' ('.$this->settings['iTunes']['category'][0].')</option>'."\n"; 
    1481                         podPress_itunesCategoryOptions(htmlentities($data['iTunesCategory'][0]), ENT_QUOTES, $blog_charset); 
     1485                        echo '                                          <optgroup label="'.__('Select Primary', 'podpress').'">'."\n"; 
     1486                        echo '                                          <option value="##Global##" '; if($data['iTunesCategory'][0] == '##Global##' || empty($data['iTunesCategory'][0])) { echo 'selected="selected"'; } echo '>'.__('Use Global', 'podpress').' ('.$this->settings['iTunes']['category'][0].')</option>'."\n"; 
     1487                        if (empty($data['iTunesCategory'][0])) { 
     1488                                podPress_itunesCategoryOptions(htmlentities('##Global##'), ENT_QUOTES, $blog_charset); 
     1489                        } else { 
     1490                                podPress_itunesCategoryOptions(htmlentities($data['iTunesCategory'][0]), ENT_QUOTES, $blog_charset); 
     1491                        } 
     1492                        echo '                                          </optgroup>'."\n"; 
    14821493                        echo '                                  </select><br/>'."\n"; 
    14831494                        echo '                                  <input type="hidden" id="global_iTunesCategory" value="'.htmlentities(stripslashes($this->settings['iTunes']['category'][0]), ENT_QUOTES, $blog_charset).'" />'."\n"; 
    14841495                        echo '                                  <select name="iTunesCategory[1]">'."\n"; 
     1496                        echo '                                          <optgroup label="'.__('Select Second', 'podpress').'">'."\n"; 
    14851497                        echo '                                          <option value="##Global##" '; if($data['iTunesCategory'][1] == '##Global##' || empty($data['iTunesCategory'][1])) { echo 'selected="selected"'; }       echo '>'.__('Use Global', 'podpress').' ('.$this->settings['iTunes']['category'][1].')</option>'."\n"; 
    1486                         podPress_itunesCategoryOptions(htmlentities($data['iTunesCategory'][1]), ENT_QUOTES, $blog_charset); 
     1498                        if (empty($data['iTunesCategory'][1])) { 
     1499                                podPress_itunesCategoryOptions(htmlentities('##Global##'), ENT_QUOTES, $blog_charset); 
     1500                        } else { 
     1501                                podPress_itunesCategoryOptions(htmlentities($data['iTunesCategory'][1]), ENT_QUOTES, $blog_charset); 
     1502                        } 
     1503                        echo '                                          </optgroup>'."\n"; 
    14871504                        echo '                                  </select><br/>'."\n"; 
    14881505                        echo '                                  <select name="iTunesCategory[2]">'."\n"; 
     1506                        echo '                                          <optgroup label="'.__('Select Third', 'podpress').'">'."\n"; 
    14891507                        echo '                                          <option value="##Global##" '; if($data['iTunesCategory'][2] == '##Global##' || empty($data['iTunesCategory'][2])) { echo 'selected="selected"'; }       echo '>'.__('Use Global', 'podpress').' ('.$this->settings['iTunes']['category'][2].')</option>'."\n"; 
    1490                         podPress_itunesCategoryOptions(htmlentities($data['iTunesCategory'][2]), ENT_QUOTES, $blog_charset); 
     1508                        if (empty($data['iTunesCategory'][2])) { 
     1509                                podPress_itunesCategoryOptions(htmlentities('##Global##'), ENT_QUOTES, $blog_charset); 
     1510                        } else { 
     1511                                podPress_itunesCategoryOptions(htmlentities($data['iTunesCategory'][2]), ENT_QUOTES, $blog_charset); 
     1512                        } 
     1513                        echo '                                          </optgroup>'."\n"; 
    14911514                        echo '                                  </select>'."\n"; 
    14921515                        echo '                          </td>'."\n"; 
    14931516                        echo '                  </tr>'."\n"; 
  • podpress_admin_feed_class.php

     
    4747                        echo '          <input type="submit" name="Submit" value="'.__('Update Options', 'podpress').' &raquo;" /> '."\n"; 
    4848                        echo '          </p> '."\n"; 
    4949                        */ 
    50                         echo '          <table width="100%" cellspacing="2" cellpadding="5" class="editform" >'."\n"; 
     50                        echo '          <table width="100%" cellspacing="2" cellpadding="5" class="editform" id="podpress_feed_options_table">'."\n"; 
    5151                        echo '                  <tr>'."\n"; 
    5252                        echo '                          <td width="50%"><h3>'.__('iTunes Settings', 'podpress').'</h3></td>'."\n"; 
    5353                        echo '                          <td width="50%"><h3>'.__('Standard Settings', 'podpress').'</h3></td>'."\n"; 
     
    125125 
    126126                        echo '                  <tr valign="top">'."\n"; 
    127127                        echo '                          <td width="50%">'."\n"; 
    128                         echo '                                  <label for="iTunesImage"><strong>'.__('iTunes:Image', 'podpress').' (300*300 pixels)</strong></label>'."\n"; 
     128                        echo '                                  <label for="iTunesImage"><strong>'.__('iTunes:Image', 'podpress').'</strong></label>'; 
    129129                        echo '                                  <br/>'; 
     130                        echo '                                  '.__('The iTunes image should be a square image with <a href="http://www.apple.com/itunes/podcasts/specs.html#image" target="_blank">at least 600 x 600 pixels</a> as Apple writes (2009) in "<a href="http://www.apple.com/itunes/podcasts/specs.html" target="_blank">Making a Podcast</a>" of their own Podcasting Resources. In the past 300 x 300 pixels were recommended. iTunes supports JPEG and PNG images (the file name extensions should ".jpg" or ".png").', 'podpress')."\n"; 
     131                        echo '                                  <br/>'; 
    130132                        echo '                                  <input id="iTunesImage" type="text" name="iTunes[image]" value="'.$this->settings['iTunes']['image'].'" size="40" onchange="podPress_updateFeedSettings();"/>'."\n"; 
    131133                        echo '                                  <br />'; 
    132                         echo '                                  <img id="iTunesImagePreview" width="300" height="300" alt="Podcast Image - Big" src="" />'."\n"; 
     134                        echo '                                  <img id="iTunesImagePreview" style="width:300px; height:300px;" alt="Podcast Image - Big" src="" />'."<br />\n"; 
     135                        echo '                                  <em>'.__('(This image is only a preview which is limited to 300 x 300 pixels.) ', 'podpress').'</em>'; 
    133136                        echo '                          </td>'."\n"; 
    134137                        echo '                          <td width="50%">'."\n"; 
    135                         echo '                                  <label for="rss_image"><strong>'.__('Blog/RSS Image', 'podpress').' (144*144 pixels)</strong></label>'."\n"; 
     138                        echo '                                  <label for="rss_image"><strong>'.__('Blog/RSS Image (144 x 144 pixels)', 'podpress').'</strong></label>'."\n"; 
    136139                        echo '                                  <br/>'; 
    137140                        echo '                                  <input id="rss_image" type="text" name="rss_image" value="'.get_option('rss_image').'" size="40" onchange="podPress_updateFeedSettings();"/>'."\n"; 
    138141                        echo '                                  <br />'; 
    139                         echo '                                  <img id="rss_imagePreview" width="144" height="144" alt="Podcast Image - Small" src="" />'."\n"; 
     142                        echo '                                  <img id="rss_imagePreview" style="width:144px; height:144px;" alt="Podcast Image - Small" src="" />'."\n"; 
    140143                        echo '                          </td>'."\n"; 
    141144                        echo '                  </tr>'."\n"; 
    142145 
     
    164167                        echo '                                  <label for="rss_language"><strong>'.__('Language', 'podpress').'</strong></label>'; 
    165168                        echo '                                  <br/>'; 
    166169                        echo '                                  <select id="rss_language" name="rss_language" onchange="podPress_updateFeedSettings();">'."\n"; 
    167                         echo '                                          <option value="#">'.__('Select Language', 'podpress').'</option>'."\n"; 
     170                        echo '                                          <optgroup label="'.__('Select Language', 'podpress').'">'."\n"; 
    168171                        podPress_itunesLanguageOptions(get_option('rss_language')); 
     172                        echo '                                          </optgroup>'."\n"; 
    169173                        echo '                                  </select>'."\n"; 
    170                         echo '                                  <br/>'.__('Used as default Podcast Episode Title', 'podpress').' (255 '.__('characters', 'podpress').')'."\n"; 
    171174                        echo '                          </td>'."\n"; 
    172175                        echo '                  </tr>'."\n"; 
    173176 
     
    194197                        echo '                                  <label for="iTunesCategory_0"><strong>'.__('iTunes:Categories', 'podpress').'</strong></label>'; 
    195198                        echo '                                  <br/>'; 
    196199                        echo '                                  <select id="iTunesCategory_0" name="iTunes[category][0]" onchange="podPress_updateFeedSettings();">'."\n"; 
    197                         echo '                                          <option value="#">'.__('Select Primary', 'podpress').'</option>'."\n"; 
     200                        echo '                                          <optgroup label="'.__('Select Primary', 'podpress').'">'."\n"; 
    198201                        podPress_itunesCategoryOptions(htmlentities($this->settings['iTunes']['category'][0]), ENT_QUOTES, $blog_charset); 
     202                        echo '                                          </optgroup>'."\n"; 
    199203                        echo '                                  </select>'."\n"; 
    200204                        echo '                                  <select name="iTunes[category][1]">'."\n"; 
    201                         echo '                                          <option value="#">'.__('Select Second', 'podpress').'</option>'."\n"; 
     205                        echo '                                          <optgroup label="'.__('Select Second', 'podpress').'">'."\n"; 
    202206                        podPress_itunesCategoryOptions(htmlentities($this->settings['iTunes']['category'][1]), ENT_QUOTES, $blog_charset); 
     207                        echo '                                          </optgroup>'."\n"; 
    203208                        echo '                                  </select>'."\n"; 
    204209                        echo '                                  <select name="iTunes[category][2]">'."\n"; 
    205                         echo '                                          <option value="#">'.__('Select Third', 'podpress').'</option>'."\n"; 
     210                        echo '                                          <optgroup label="'.__('Select Third', 'podpress').'">'."\n"; 
    206211                        podPress_itunesCategoryOptions(htmlentities($this->settings['iTunes']['category'][2]), ENT_QUOTES, $blog_charset); 
     212                        echo '                                          </optgroup>'."\n"; 
    207213                        echo '                                  </select>'."\n"; 
    208214                        echo '                          </td>'."\n"; 
    209215                        echo '                          <td width="50%">'."\n"; 
     
    286292                        echo '                                          <option value="No" '; if($this->settings['protectFeed'] != 'Yes') { echo 'selected="selected"'; } echo '>'.__('No', 'podpress').'</option>'."\n"; 
    287293                        echo '                                          <option value="Yes" '; if($this->settings['protectFeed'] == 'Yes') { echo 'selected="selected"'; } echo '>'.__('Yes', 'podpress').'</option>'."\n"; 
    288294                        echo '                                  </select>'."\n"; 
    289                         echo '                                  <br/>'.__('This will strip out any invalid characters, as well as images and links from your post content in the feeds. Only works with UTF-8 feeds.', 'podpress')."\n"; 
     295                        echo '                                  <br/>'.__('"Yes" will convert any invalid characters to their numeric character references in the feeds. "No" will convert only ampersand, less-than, greater-than, apostrophe and quotation signs to their numeric character references.', 'podpress')."\n"; 
    290296                        echo '                          </td>'."\n"; 
    291297                        echo '                  </tr>'."\n"; 
    292298 
  • podpress_admin_functions.php

     
    359359        } 
    360360 
    361361 
    362         function podPress_videoDimensionOptions() { 
     362        function podPress_videoDimensionOptions($selected='320:240') { 
    363363                $dimensions = array(); 
    364364                reset($dimensions); 
    365365 
    366                 $dimensions['0'] = __('Common Dimensions', 'podpress'); 
    367366                $dimensions['160:120'] = '160 x 120'; 
    368367                $dimensions['320:240'] = '320 x 240'; 
    369368                $dimensions['640:480'] = '640 x 480'; 
     
    372371                $dimensions['480:260'] = '480 x 260 [16:9 - 1.85:1]'; 
    373372                $dimensions['720:405'] = '720 x 405 [16:9 - 1.78:1]'; 
    374373                $dimensions['720:390'] = '720 x 390 [16:9 - 1.85:1]'; 
    375  
     374                echo '<optgroup label="'.__('Common Dimensions', 'podpress').'">'."\n"; 
    376375                foreach ($dimensions as $key => $value) { 
    377                         echo '<option value="'.$key.'">'.$value.'</option>'."\n"; 
     376                        if ($key == $selected) { 
     377                                $selected_str =' selected="selected"'; 
     378                        } else { 
     379                                $selected_str =''; 
     380                        } 
     381                        echo '<option value="'.$key.'"'.$selected_str.'>'.$value.'</option>'."\n"; 
    378382                } 
     383                echo '</optgroup>'."\n"; 
    379384        } 
    380385 
    381386        function podPress_itunesLanguageArray() { 
     
    480485        } 
    481486 
    482487        function podPress_itunesLanguageOptions($current = 'en-us') { 
    483  
    484488                $langs = podPress_itunesLanguageArray(); 
    485489                reset($langs); 
    486490                foreach ($langs as $key => $value) { 
     
    494498 
    495499        function podPress_itunesCategoryOptions($current = '') { 
    496500                $cats = array(); 
     501                if ('' == trim($current) AND '##Global##' != $current) { 
     502                        $current='[ '.__('nothing', 'podpress').' ]'; 
     503                } 
     504                $cats[] = '[ '.__('nothing', 'podpress').' ]'; 
    497505 
    498506                $cats[] = 'Arts'; 
    499507                $cats[] = 'Arts:Design'; 
     
    590598                        } 
    591599                        echo ' >'.$value.'</option>'."\n"; 
    592600                } 
    593  
    594                 if(!$foundit) { 
     601                 
     602                if(!$foundit AND '##Global##' != $current) { 
    595603                        $current = podPress_upgradeCategory($current); 
    596604                        echo '<option selected="selected">'.$current.'</option>'."\n"; 
    597605                } 
  • podpress_admin_wp27plus.css

     
    88        line-height:100%; 
    99        padding-top:0.5em; 
    1010} 
     11 
     12#podpress_feed_options_table td { 
     13padding:15px 0px 0px 0px; 
     14} 
     15 No newline at end of file 
  • podpress_feed_functions.php

     
    2121        /*************************************************************/ 
    2222        /* feed generation functions                                 */ 
    2323        /*************************************************************/ 
    24  
    25         function podPress_feedSafeContent($input, $aggressive = false) 
    26         { 
     24         
     25        function podPress_feedSafeContent($input, $aggressive = false) { 
    2726                GLOBAL $podPress; 
    28                 if ( ('no' == strtolower($podPress->settings['protectFeed']) OR FALSE === $podPress->settings['protectFeed']) AND !$aggressive) { 
     27                /* 
     28                // if the feed should not be protect agressively (option in the backend) then return immediately 
     29                if ( ('no' == strtolower($podPress->settings['protectFeed']) OR FALSE === $podPress->settings['protectFeed']) AND FALSE === $aggressive) { 
    2930                        return $input; 
    3031                } 
    31                 $result = htmlentities($input, ENT_NOQUOTES, get_bloginfo('charset'), FALSE); 
    32                 if($aggressive) { 
    33                         $result = str_replace(array('&amp;', '&lt;', '&gt;', '&'), '', $result); 
     32                */ 
     33                // replace the relevant characters with their HTML entities 
     34                if (TRUE === $aggressive OR 'yes' == strtolower($podPress->settings['protectFeed']) OR TRUE === $podPress->settings['protectFeed'] ) { // this option is only reachable via php source code and via the WP backend 
     35                        if (TRUE === version_compare(PHP_VERSION, '5.2.3', '>=')) { 
     36                                $result = htmlentities($input, ENT_NOQUOTES, get_bloginfo('charset'), FALSE); 
     37                        } else { 
     38                                $result = htmlentities($input, ENT_NOQUOTES, get_bloginfo('charset')); 
     39                        } 
     40                } else { 
     41                        if (TRUE === version_compare(PHP_VERSION, '5.2.3', '>=')) { 
     42                                $result = htmlspecialchars($input, ENT_NOQUOTES, get_bloginfo('charset'), FALSE); 
     43                        } else { 
     44                                $result = htmlspecialchars($input, ENT_NOQUOTES, get_bloginfo('charset')); 
     45                        } 
    3446                } 
     47                 
     48                if (TRUE === $aggressive) { // this option is only reachable via php source code and via the WP backend 
     49                        $input = $result; 
     50                        $result = str_replace(array('&amp;', '&lt;', '&gt;', '&'), '', $input); 
     51                } 
     52                $input = $result; 
     53                 
     54                // get the HTML translation table 
     55                $table = get_html_translation_table(HTML_ENTITIES);//HTML_SPECIALCHARS 
     56                 
     57                // replace the HTML entities with their numeric entities which are okay for XML 
     58                foreach ($table as $chr => $htmlentity) { 
     59                        $ord = ord($chr); // get the ASCII number of the character 
     60                        $result = str_replace($htmlentity, '&#'.$ord.';', $input); 
     61                        $input = $result; 
     62                } 
    3563                return $result; 
    3664        } 
    3765 
     
    5482                                } 
    5583                        } 
    5684                } 
    57  
    5885                if(!isset($podPress->settings['category_data'])) { 
    5986                        podPress_feed_getCategory(); 
    6087                } 
     
    129156                if(!empty($data['rss_ttl']) && $data['rss_ttl'] < 1440) { 
    130157                        $data['rss_ttl'] = 1440; 
    131158                } 
    132                 echo '  <!-- podcast_generator="podPress/'.PODPRESS_VERSION.'" - maintenance_release="'.PODPRESS_MAINTENANCE_VERSION.'" -->'."\n"; 
     159                echo '<!-- podcast_generator="podPress/'.PODPRESS_VERSION.'" - maintenance_release="'.PODPRESS_MAINTENANCE_VERSION.'" -->'."\n"; 
    133160                if (empty($data['rss_copyright'])) { 
    134                         echo '          <copyright>'.podPress_feedSafeContent(__('Copyright', 'podpress').' &#xA9; '. date('Y',time())).' '.get_bloginfo('blogname').' '.$podPress->settings['rss_license_url'].'</copyright>'."\n"; 
     161                        echo '  <copyright>'.podPress_feedSafeContent(__('Copyright', 'podpress').' &#xA9; '. date('Y',time())).' '.get_bloginfo('blogname').' '.$podPress->settings['rss_license_url'].'</copyright>'."\n"; 
    135162                } else { 
    136                         echo '          <copyright>'.podPress_feedSafeContent($data['rss_copyright']).' '.$podPress->settings['rss_license_url'].'</copyright>'."\n"; 
     163                        echo '  <copyright>'.podPress_feedSafeContent($data['rss_copyright']).' '.$podPress->settings['rss_license_url'].'</copyright>'."\n"; 
    137164                } 
    138165                if($data['new-feed-url'] == 'Enable') { 
    139166                        if(!empty($data['podcastFeedURL']) && !strpos(strtolower($data['podcastFeedURL']), 'phobos.apple.com') && !strpos(strtolower($data['podcastFeedURL']), 'itpc://')) { 
    140167                                echo '          <itunes:new-feed-url>'.podPress_feedSafeContent($data['podcastFeedURL']).'</itunes:new-feed-url>'."\n"; 
    141168                        } 
    142169                } 
    143                 echo '          <managingEditor>'.podPress_feedSafeContent(stripslashes(get_option('admin_email'))).' ('.podPress_feedSafeContent($data['author']).')</managingEditor>'."\n"; 
    144                 echo '          <webMaster>'.podPress_feedSafeContent(get_option('admin_email')).' ('.podPress_feedSafeContent($data['author']).')</webMaster>'."\n"; 
    145                 echo '          <category>'.podPress_feedSafeContent($rss_category).'</category>'."\n"; 
     170                echo '  <managingEditor>'.podPress_feedSafeContent(stripslashes(get_option('admin_email'))).' ('.podPress_feedSafeContent($data['author']).')</managingEditor>'."\n"; 
     171                echo '  <webMaster>'.podPress_feedSafeContent(get_option('admin_email')).' ('.podPress_feedSafeContent($data['author']).')</webMaster>'."\n"; 
     172                echo '  <category>'.podPress_feedSafeContent($rss_category).'</category>'."\n"; 
    146173                if(!empty($data['rss_ttl'])) { 
    147                         echo '          <ttl>'.$data['rss_ttl'].'</ttl>'."\n"; 
     174                        echo '  <ttl>'.$data['rss_ttl'].'</ttl>'."\n"; 
    148175                } 
    149                 echo '          <itunes:keywords>'.podPress_stringLimiter(podPress_feedSafeContent($data['keywords'], true), 255).'</itunes:keywords>'."\n"; 
    150                 echo '          <itunes:subtitle>'.podPress_stringLimiter(podPress_feedSafeContent($data['subtitle'], true), 255).'</itunes:subtitle>'."\n"; 
    151                 echo '          <itunes:summary>'.podPress_stringLimiter(podPress_feedSafeContent($data['summary'], true), 4000).'</itunes:summary>'."\n"; 
    152                 echo '          <itunes:author>'.podPress_feedSafeContent($data['author']).'</itunes:author>'."\n"; 
    153                 echo '          ' .podPress_getiTunesCategoryTags(); 
    154                 echo '          <itunes:owner>'."\n"; 
    155                 echo '                  <itunes:name>'.stripslashes(podPress_feedSafeContent($data['author'])).'</itunes:name>'."\n"; 
    156                 echo '                  <itunes:email>'.podPress_feedSafeContent($data['admin_email']).'</itunes:email>'."\n"; 
    157                 echo '          </itunes:owner>'."\n"; 
     176                echo '  <itunes:keywords>'.podPress_stringLimiter(podPress_feedSafeContent($data['keywords']), 255).'</itunes:keywords>'."\n"; 
     177                echo '  <itunes:subtitle>'.podPress_stringLimiter(podPress_feedSafeContent($data['subtitle']), 255).'</itunes:subtitle>'."\n"; 
     178                echo '  <itunes:summary>'.podPress_stringLimiter(podPress_feedSafeContent($data['summary']), 4000).'</itunes:summary>'."\n"; 
     179                echo '  <itunes:author>'.podPress_feedSafeContent($data['author']).'</itunes:author>'."\n"; 
     180                echo podPress_getiTunesCategoryTags(); 
     181                echo '  <itunes:owner>'."\n"; 
     182                echo '          <itunes:name>'.stripslashes(podPress_feedSafeContent($data['author'])).'</itunes:name>'."\n"; 
     183                echo '          <itunes:email>'.podPress_feedSafeContent($data['admin_email']).'</itunes:email>'."\n"; 
     184                echo '  </itunes:owner>'."\n"; 
    158185                if(empty($data['block'])) { 
    159186                        $data['block'] = 'No'; 
    160187                } 
    161                 echo '          <itunes:block>'.$data['block'].'</itunes:block>'."\n"; 
    162                 echo '          <itunes:explicit>'.podPress_feedSafeContent(strtolower($data['explicit'])).'</itunes:explicit>'."\n"; 
    163                 echo '          <itunes:image href="'.$data['image'].'" />'."\n"; 
    164                 echo '          <image>'."\n"; 
    165                 echo '                  <url>'.podPress_feedSafeContent($data['rss_image']).'</url>'."\n"; 
    166                 echo '                  <title>'; bloginfo_rss('name'); echo '</title>'."\n"; 
    167                 echo '                  <link>'; bloginfo_rss('url'); echo '</link>'."\n"; 
    168                 echo '                  <width>144</width>'."\n"; 
    169                 echo '                  <height>144</height>'."\n"; 
    170                 echo '          </image>'."\n"; 
     188                echo '  <itunes:block>'.$data['block'].'</itunes:block>'."\n"; 
     189                echo '  <itunes:explicit>'.podPress_feedSafeContent(strtolower($data['explicit'])).'</itunes:explicit>'."\n"; 
     190                echo '  <itunes:image href="'.$data['image'].'" />'."\n"; 
     191                echo '  <image>'."\n"; 
     192                echo '          <url>'.$data['rss_image'].'</url>'."\n"; 
     193                echo '          <title>'.podPress_feedSafeContent(get_bloginfo('blogname')).'</title>'."\n"; 
     194                echo '          <link>'.get_bloginfo('siteurl').'</link>'."\n"; 
     195                echo '          <width>144</width>'."\n"; 
     196                echo '          <height>144</height>'."\n"; 
     197                echo '  </image>'."\n"; 
    171198        } 
    172199 
    173200        function podPress_rss2_item() { 
     
    175202                $enclosureTag = podPress_getEnclosureTags(); 
    176203                if($enclosureTag != '') // if no enclosure tag, no need for iTunes tags 
    177204                { 
    178                         echo "\t" . $enclosureTag; 
     205                        echo $enclosureTag; 
    179206 
    180207                        if($post->podPressPostSpecific['itunes:subtitle'] == '##PostExcerpt##') { 
    181208                                ob_start(); 
     
    187214                        if(empty($post->podPressPostSpecific['itunes:subtitle'])) { 
    188215                                $post->podPressPostSpecific['itunes:subtitle'] = get_the_title_rss(); 
    189216                        } 
    190                         echo '          <itunes:subtitle>'.podPress_feedSafeContent($post->podPressPostSpecific['itunes:subtitle'], true).'</itunes:subtitle>'."\n"; 
     217                        echo '          <itunes:subtitle>'.podPress_feedSafeContent($post->podPressPostSpecific['itunes:subtitle']).'</itunes:subtitle>'."\n"; 
    191218 
    192219                        if($post->podPressPostSpecific['itunes:summary'] == '##Global##') { 
    193220                                $post->podPressPostSpecific['itunes:summary'] = $podPress->settings['iTunes']['summary']; 
     
    202229                        if(empty($post->podPressPostSpecific['itunes:summary'])) { 
    203230                                $post->podPressPostSpecific['itunes:summary'] = $podPress->settings['iTunes']['summary']; 
    204231                        } 
    205                         echo '          <itunes:summary>'.podPress_stringLimiter(podPress_feedSafeContent($post->podPressPostSpecific['itunes:summary'], true), 4000).'</itunes:summary>'."\n"; 
     232                        echo '          <itunes:summary>'.podPress_stringLimiter(podPress_feedSafeContent($post->podPressPostSpecific['itunes:summary']), 4000).'</itunes:summary>'."\n"; 
    206233 
    207234                        if($post->podPressPostSpecific['itunes:keywords'] == '##WordPressCats##') { 
    208235                                $categories = get_the_category(); 
    209236                                $post->podPressPostSpecific['itunes:keywords'] = ''; 
    210237                                if(is_array($categories)) { 
    211238                                        foreach ($categories as $category) { 
    212                                                 $category->cat_name = $category->cat_name; 
    213                                                 if($post->podPressPostSpecific['itunes:keywords'] != '') { 
    214                                                         $post->podPressPostSpecific['itunes:keywords'] .= ', '; 
    215                                                 } 
    216                                                 $post->podPressPostSpecific['itunes:keywords'] .= $category->cat_name; 
     239                                                $category_names[] = $category->cat_name; 
    217240                                        } 
    218                                         $post->podPressPostSpecific['itunes:keywords'] = trim($post->podPressPostSpecific['itunes:keywords']); 
     241                                        $post->podPressPostSpecific['itunes:keywords'] = implode(', ', $category_names); 
    219242                                } 
    220                         } elseif($post->podPressPostSpecific['itunes:keywords'] == '##Global##') { 
     243                        } elseif ($post->podPressPostSpecific['itunes:keywords'] == '##Global##') { 
    221244                                $post->podPressPostSpecific['itunes:keywords'] = $podPress->settings['iTunes']['keywords']; 
    222245                        } 
    223                         echo '          <itunes:keywords>'.podPress_stringLimiter(podPress_feedSafeContent(str_replace(' ', ',', $post->podPressPostSpecific['itunes:keywords']), true), 255).'</itunes:keywords>'."\n"; 
     246                        echo '          <itunes:keywords>'.podPress_stringLimiter(podPress_feedSafeContent($post->podPressPostSpecific['itunes:keywords']), 255).'</itunes:keywords>'."\n"; 
    224247 
    225248                        if($post->podPressPostSpecific['itunes:author'] == '##Global##') { 
    226249                                $post->podPressPostSpecific['itunes:author'] = $podPress->settings['iTunes']['author']; 
     
    228251                                        $post->podPressPostSpecific['itunes:author'] = stripslashes(get_option('admin_email')); 
    229252                                } 
    230253                        } 
    231                         echo '          <itunes:author>'.podPress_feedSafeContent($post->podPressPostSpecific['itunes:author'], true).'</itunes:author>'."\n"; 
     254                        echo '          <itunes:author>'.podPress_feedSafeContent($post->podPressPostSpecific['itunes:author']).'</itunes:author>'."\n"; 
    232255 
    233256                        if($post->podPressPostSpecific['itunes:explicit'] == 'Default') { 
    234257                                $post->podPressPostSpecific['itunes:explicit'] = $podPress->settings['iTunes']['explicit']; 
     
    253276                $episodeLicenseTags = podPress_getEpisodeLicenseTags(); 
    254277                if ($episodeLicenseTags != '') 
    255278                { 
    256                         echo "\t" . $episodeLicenseTags; 
     279                        echo $episodeLicenseTags; 
    257280                } 
    258281                if(isset($post_meta_cache[$blog_id][$post->ID]['enclosure_podPressHold'])) { 
    259282                        $post_meta_cache[$blog_id][$post->ID]['enclosure'] = $post_meta_cache[$blog_id][$post->ID]['enclosure_podPressHold']; 
     
    267290                if(!isset($podPress->settings['category_data'])) { 
    268291                        podPress_feed_getCategory(); 
    269292                } 
    270                 echo '<!-- podcast_generator="podPress/'.PODPRESS_VERSION.'" - maintenance_release="'.PODPRESS_MAINTENANCE_VERSION.'" -->'."\n"; 
     293                echo "\t".'<!-- podcast_generator="podPress/'.PODPRESS_VERSION.'" - maintenance_release="'.PODPRESS_MAINTENANCE_VERSION.'" -->'."\n"; 
    271294                if ($podPress->settings['category_data']['categoryCasting'] == 'true' && $podPress->settings['category_data']['rss_imageChoice'] == 'Custom') { 
    272295                        echo "\t".'<logo>'.podPress_feedSafeContent($podPress->settings['category_data']['rss_image']).'</logo>'."\n"; 
    273296                } else { 
    274297                        echo "\t".'<logo>'.podPress_feedSafeContent(get_option('rss_image')).'</logo>'."\n"; 
    275298                } 
    276299                if (empty($data['rss_copyright'])) { 
    277                         echo '          <rights>'.podPress_feedSafeContent(__('Copyright', 'podpress').' &#xA9; '. date('Y',time())).' '.get_bloginfo('blogname').'</rights>'."\n"; 
     300                        echo "\t".'<rights>'.podPress_feedSafeContent(__('Copyright', 'podpress').' &#xA9; '. date('Y',time())).' '.get_bloginfo('blogname').'</rights>'."\n"; 
    278301                } else { 
    279                         echo '          <rights>'.podPress_feedSafeContent($data['rss_copyright']).'</rights>'."\n"; 
     302                        echo "\t".'<rights>'.podPress_feedSafeContent($data['rss_copyright']).'</rights>'."\n"; 
    280303                } 
    281304                if ( !empty($podPress->settings['rss_license_url']) ) { 
    282305                        echo "\t".'<link rel="license" type="text/html" href="'.$podPress->settings['rss_license_url'].'" />'."\n"; 
     
    287310                $enclosureTag = podPress_getEnclosureTags('atom'); 
    288311                if ($enclosureTag != '') // if no enclosure tag, no need for iTunes tags 
    289312                { 
    290                         echo "\t" . $enclosureTag; 
     313                        echo $enclosureTag; 
    291314                } 
    292315                $episodeLicenseTags = podPress_getEpisodeLicenseTags('atom'); 
    293316                if ($episodeLicenseTags != '') 
    294317                { 
    295                         echo "\t" . $episodeLicenseTags; 
     318                        echo $episodeLicenseTags; 
    296319                } 
    297320        } 
    298321 
     
    304327                $more = 1; 
    305328                echo '<?xml version="1.0" encoding="'.get_settings('blog_charset').'" ?'.">\n"; 
    306329                echo '<playlist version="1" xmlns="http://xspf.org/ns/0/">'."\n"; 
    307                 echo "\t".'<title>'. get_bloginfo('blogname') . '</title>'."\n"; 
     330                echo "\t".'<title>'. podPress_feedSafeContent(get_bloginfo('blogname')) . '</title>'."\n"; 
    308331                echo "\t".'<annotation><![CDATA['. $podPress->settings['iTunes']['summary'].']]></annotation>'."\n"; 
    309332                if (empty($podPress->settings['iTunes']['author'])) { 
    310333                        $creator = get_bloginfo('blogname'); 
    311334                } else { 
    312335                        $creator = $podPress->settings['iTunes']['author']; 
    313336                } 
    314                 echo "\t".'<creator>'. $creator. '</creator>'."\n"; 
     337                echo "\t".'<creator>'. podPress_feedSafeContent($creator). '</creator>'."\n"; 
    315338                echo "\t".'<location>'.get_feed_link('playlist.xspf').'</location>'."\n"; 
    316339                if ( !empty($podPress->settings['rss_license_url']) ) { 
    317340                        echo "\t".'<license>'.$podPress->settings['rss_license_url'].'</license>'."\n"; 
     
    357380                                                case 'rss' : 
    358381                                                case 'rdf' : // license tags for entries with the help of the Dublin Core 
    359382                                                        if (TRUE == isset($license['podcast_episode_license_url']) AND FALSE == isset($license['podcast_episode_license_name'])) { 
    360                                                                 $result = "\t".'<dc:rights>'.$license['podcast_episode_license_url'].'</dc:rights>'."\n"; 
     383                                                                $result = "\t\t".'<dc:rights>'.$license['podcast_episode_license_url'].'</dc:rights>'."\n"; 
    361384                                                        } elseif (TRUE == isset($license['podcast_episode_license_name']) AND TRUE == isset($license['podcast_episode_license_name'])) { 
    362                                                                 $result = "\t".'<dc:rights>'.$license['podcast_episode_license_name'].' - '.$license['podcast_episode_license_url'].'</dc:rights>'."\n"; 
     385                                                                $result = "\t\t".'<dc:rights>'.podPress_feedSafeContent($license['podcast_episode_license_name']).' '.$license['podcast_episode_license_url'].'</dc:rights>'."\n"; 
    363386                                                        } 
    364387                                                break; 
    365388                                                case 'atom' : // Atom License Extension -  http://tools.ietf.org/html/rfc4946 
     
    367390                                                                $result = "\t".'<rights>'.$license['podcast_episode_license_url'].'</rights>'."\n"; 
    368391                                                                $result .= "\t".'<link rel="license" type="text/html" href="'.$license['podcast_episode_license_url'].'" />'."\n"; 
    369392                                                        } elseif (TRUE == isset($license['podcast_episode_license_name']) AND TRUE == isset($license['podcast_episode_license_name'])) { 
    370                                                                 $result = "\t".'<rights>'.$license['podcast_episode_license_name'].'</rights>'."\n"; 
     393                                                                $result = "\t".'<rights>'.podPress_feedSafeContent($license['podcast_episode_license_name']).'</rights>'."\n"; 
    371394                                                                $result .= "\t".'<link rel="license" type="text/html" href="'.$license['podcast_episode_license_url'].'" />'."\n"; 
    372395                                                        } 
    373396                                                break; 
     
    380403                } 
    381404                return $result; 
    382405        } 
    383          
     406 
    384407        function podPress_getEnclosureTags($feedtype = 'rss2') { 
    385408                GLOBAL $podPress, $post; 
    386409                $result = ''; 
     
    426449                                        } elseif ($feedtype == 'xspf') { 
    427450                                                $post->podPressMedia[$key]['URI'] = $podPress->convertPodcastFileNameToValidWebPath($post->podPressMedia[$key]['URI']); 
    428451                                                if (podPress_getFileExt($post->podPressMedia[$key]['URI']) == 'mp3') { 
    429                                                         $result .= "\t"."\t"."\t".'<location>'.$post->podPressMedia[$key]['URI']."</location>\n"; 
     452                                                        $result .= "\t\t\t".'<location>'.$post->podPressMedia[$key]['URI']."</location>\n"; 
    430453                                                        if (!empty($post->podPressMedia[$key]['title'])) { 
    431                                                                 $result .= "\t"."\t"."\t".'<annotation>'.podPress_feedSafeContent($post->podPressMedia[$key]['title'])."</annotation>\n"; 
    432                                                                 $result .= "\t"."\t"."\t".'<title>'.podPress_feedSafeContent($post->podPressMedia[$key]['title'])."</title>\n"; 
     454                                                                $result .= "\t\t\t".'<annotation>'.podPress_feedSafeContent($post->podPressMedia[$key]['title'])."</annotation>\n"; 
     455                                                                $result .= "\t\t\t".'<title>'.podPress_feedSafeContent($post->podPressMedia[$key]['title'])."</title>\n"; 
    433456                                                        } else { 
    434                                                                 $result .= "\t"."\t"."\t".'<annotation>'.podPress_feedSafeContent($post->post_title)."</annotation>\n"; 
    435                                                                 $result .= "\t"."\t"."\t".'<title>'.podPress_feedSafeContent($post->post_title)."</title>\n"; 
     457                                                                $result .= "\t\t\t".'<annotation>'.podPress_feedSafeContent($post->post_title)."</annotation>\n"; 
     458                                                                $result .= "\t\t\t".'<title>'.podPress_feedSafeContent($post->post_title)."</title>\n"; 
    436459                                                        } 
    437460                                                        if ( '##Global##' == $post->podPressPostSpecific['itunes:author']) { 
    438461                                                                if (empty($podPress->settings['iTunes']['author'])) { 
     
    440463                                                                } else { 
    441464                                                                        $creator = $podPress->settings['iTunes']['author']; 
    442465                                                                } 
    443                                                                 $result .= "\t"."\t"."\t".'<creator>'.$creator.'</creator>'."\n"; 
     466                                                                $result .= "\t\t\t".'<creator>'.podPress_feedSafeContent($creator).'</creator>'."\n"; 
    444467                                                        } else { 
    445                                                                 $result .= "\t"."\t"."\t".'<creator>'.$post->podPressPostSpecific['itunes:author'].'</creator>'."\n"; 
     468                                                                $result .= "\t\t\t".'<creator>'.podPress_feedSafeContent($post->podPressPostSpecific['itunes:author']).'</creator>'."\n"; 
    446469                                                        } 
    447                                                         if ( 'UNKNOWN' != $post->podPressMedia[$key]['duration']) { 
    448                                                                 $result .= "\t"."\t"."\t".'<duration>'.$post->podPressMedia[$key]['duration'].'</duration>'."\n"; 
     470                                                        if ( 'UNKNOWN' != $post->podPressMedia[$key]['duration'] AND FALSE === empty($post->podPressMedia[$key]['duration'])) { 
     471                                                                $result .= "\t\t\t".'<duration>'.podpress_strtomilliseconds($post->podPressMedia[$key]['duration']).'</duration>'."\n"; 
    449472                                                        }  
    450473                                                        if(!empty($post->podPressMedia[$key]['previewImage'])) { 
    451                                                                 $result .= "\t"."\t"."\t".'<image>'.$post->podPressMedia[$key]['previewImage']."</image>\n"; 
     474                                                                $result .= "\t\t\t".'<image>'.$post->podPressMedia[$key]['previewImage']."</image>\n"; 
    452475                                                        } 
    453476                                                } 
    454477                                        } elseif ($feedtype == 'rss2') { 
     
    469492                                                        } elseif($preferredFormat) { 
    470493                                                                $foundPreferred = true; 
    471494                                                        } 
    472                                                         $result = '<enclosure url="'.$post->podPressMedia[$key]['URI'].'" length="'.$post->podPressMedia[$key]['size'].'" type="'.$post->podPressMedia[$key]['mimetype'].'"/>'."\n"; 
    473                                                         $result .= $durationTag; 
    474                                                 } elseif($preferredFormat && !$foundPreferred AND FALSE === $same_enclosure_URL_in_postmeta_exists) { 
    475                                                         $result = '<enclosure url="'.$post->podPressMedia[$key]['URI'].'" length="'.$post->podPressMedia[$key]['size'].'" type="'.$post->podPressMedia[$key]['mimetype'].'"/>'."\n"; 
    476                                                         $result .= $durationTag; 
     495                                                        $result = "\t\t".'<enclosure url="'.$post->podPressMedia[$key]['URI'].'" length="'.$post->podPressMedia[$key]['size'].'" type="'.$post->podPressMedia[$key]['mimetype'].'"/>'."\n"; 
     496                                                        $result .= "\t\t".$durationTag; 
     497                                                } elseif ($preferredFormat && !$foundPreferred AND FALSE === $same_enclosure_URL_in_postmeta_exists) { 
     498                                                        $result = "\t\t".'<enclosure url="'.$post->podPressMedia[$key]['URI'].'" length="'.$post->podPressMedia[$key]['size'].'" type="'.$post->podPressMedia[$key]['mimetype'].'"/>'."\n"; 
     499                                                        $result .= "\t\t".$durationTag; 
    477500                                                        $foundPreferred = true; 
    478501                                                } 
    479502                                        } 
     
    502525                return $exists; 
    503526        } 
    504527 
     528function podpress_strtomilliseconds($durationstr) { 
     529        $dstr_parts=explode(':', $durationstr); 
     530        $nr_dstr_parts=count($dstr_parts); 
     531        if (1 < $nr_dstr_parts AND 5 > $nr_dstr_parts) { 
     532                switch ($nr_dstr_parts) { 
     533                        case 2 : 
     534                                // this method is only good if the input data which consist of two parts is most likely in the format m:s because  
     535                                // m:s 
     536                                $duration = podpress_strtomilliseconds_core(1, 2, $dstr_parts); 
     537                                if ($durationstr != podpress_millisecondstostring($duration)) { 
     538                                        // h:m 
     539                                        $duration = podpress_strtomilliseconds_core(0, 2, $dstr_parts); 
     540                                        if ($durationstr != podpress_millisecondstostring($duration)) { 
     541                                                // s:ms 
     542                                                $duration = podpress_strtomilliseconds_core(2, 2, $dstr_parts); 
     543                                        } 
     544                                } 
     545                        break; 
     546                        case 3 : 
     547                                // h:m:s 
     548                                $duration = podpress_strtomilliseconds_core(0, 3, $dstr_parts); 
     549                                if ($durationstr != podpress_millisecondstostring($duration)) { 
     550                                        // m:s:ms 
     551                                        $duration = podpress_strtomilliseconds_core(1, 3, $dstr_parts); 
     552                                } 
     553                        break; 
     554                        case 4 : 
     555                                $duration = podpress_strtomilliseconds_core(0, 4, $dstr_parts); 
     556                        break; 
     557                } 
     558        } 
     559        if (!isset($duration) OR $duration < 0) { 
     560                $duration = 0; 
     561        } 
     562        return $duration; 
     563} 
     564 
     565function podpress_strtomilliseconds_core($startindex=0, $max_nr_parts=4, $dstr_parts=array()){ 
     566        $duration = $j = 0; 
     567        if (!empty($dstr_parts)) { 
     568                for ($i=$startindex; $i < ($max_nr_parts+$startindex); $i++) { 
     569                        switch ($i) { 
     570                                case 0 : // hours 
     571                                        $duration += 3600000 * intval(substr($dstr_parts[$j], 0, 2)); 
     572                                        $j++; 
     573                                break; 
     574                                case 1 : // minutes 
     575                                        $duration += 60000 * intval(substr($dstr_parts[$j], 0, 2)); 
     576                                        $j++; 
     577                                break; 
     578                                case 2 : // seconds 
     579                                        $duration += 1000 * intval(substr($dstr_parts[$j], 0, 2)); 
     580                                        $j++; 
     581                                break; 
     582                                case 3 : // milliseconds 
     583                                        $duration += intval(substr($dstr_parts[$j], 0, 2)); 
     584                                        $j++; 
     585                                break; 
     586                        } 
     587                } 
     588        } 
     589        return $duration; 
     590} 
     591 
     592function podpress_millisecondstostring($duration) { 
     593// This function gives the milliseconds value back in the format H:M:S:MS or if the H:M:S if the milliseconds part is zero. 
     594// If the leading parts is zero then the return string will not contain this part. 
     595        $hours = intval($duration / (3600000)); 
     596        $minutes = intval($duration / (60000) % 60); 
     597        $seconds = intval($duration / (1000) % 60); 
     598        $mseconds = intval($duration % 1000); 
     599        $duration_array = array($hours, $minutes, $seconds, $mseconds); 
     600        $dur_str =""; 
     601        $j=0; 
     602        foreach($duration_array as $key => $dur_part) { 
     603                if ("" == $dur_str AND 0 == $dur_part) { 
     604                } else { 
     605                        if (3 == $key AND  0 == $dur_part) { 
     606                        } else { 
     607                                if ($j > 0) {  
     608                                        $dur_str .= ":".strval($dur_part); 
     609                                } else { 
     610                                        $dur_str .= strval($dur_part); 
     611                                } 
     612                                $j++; 
     613                        } 
     614                } 
     615        } 
     616        return $dur_str; 
     617} 
     618 
    505619        function podPress_getiTunesCategoryTags() { 
    506620                GLOBAL $podPress, $post; 
    507621                $result = ''; 
     
    522636                } 
    523637                if(is_array($data)) { 
    524638                        foreach($data as $thiscat) { 
    525                                 if(strstr($thiscat, ':')) { 
     639                                if (strstr($thiscat, ':')) { 
    526640                                        list($cat, $subcat) = explode(":", $thiscat); 
    527                                         $result .= '<itunes:category text="'.str_replace('&', '&amp;', $cat).'">'."\n"; 
    528                                         $result .= "\t".'<itunes:category text="'.str_replace('&', '&amp;', $subcat).'"/>'."\n"; 
    529                                         $result .= '</itunes:category>'."\n"; 
     641                                        $result .= "\t".'<itunes:category text="'.str_replace('&', '&amp;', $cat).'">'."\n"; 
     642                                        $result .= "\t\t".'<itunes:category text="'.str_replace('&', '&amp;', $subcat).'" />'."\n"; 
     643                                        $result .= "\t".'</itunes:category>'."\n"; 
     644                                } elseif (!empty($thiscat) AND '[ '.__('nothing', 'podpress').' ]' != $thiscat ) { 
     645                                        $result .= "\t".'<itunes:category text="'.str_replace('&', '&amp;', $thiscat).'" />'."\n"; 
    530646                                } 
    531                                 elseif(!empty($thiscat)) 
    532                                 { 
    533                                         $result .= '<itunes:category text="'.str_replace('&', '&amp;', $thiscat).'"/>'."\n"; 
    534                                 } 
    535647                        } 
    536648                } 
    537649                if(empty($result)) { 
    538                         $result .= '<itunes:category text="Society &amp; Culture"/>'."\n"; 
     650                        $result .= "\t".'<itunes:category text="Society &amp; Culture" />'."\n"; 
    539651                } 
    540652                return $result; 
    541653        }