WordPress.org

Plugin Directory


Ignore:
Timestamp:
04/09/09 00:10:52 (5 years ago)
Author:
mark8barnes
Message:
 
Location:
sermon-browser/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sermon-browser/trunk/sb-includes/podcast.php

    r108590 r108954  
    11<?php 
     2 
    23//Prints ISO date for podcast 
    34function sb_print_iso_date($sermon) { 
    45    $sermon_time = $sermon->time; 
    5     if ($sermon_time == "") 
     6    if ($sermon_time == '') 
    67        $sermon_time = sb_default_time ($sermon->sid); 
    7     echo date('D, d M Y H:i:s', strtotime($sermon->date.' '.$sermon_time))." +0000"; 
     8    $timezone = get_option('gmt_offset')*3600; 
     9    echo date('D, d M Y H:i:s O', strtotime($sermon->date.' '.$sermon_time)); 
    810} 
    911 
    10 //Prints size of first .mp3 file 
    11 function sb_first_mp3_size($sermon) { 
    12     $stuff = sb_get_stuff($sermon); 
    13     $stuff = array_merge((array)$stuff['Files'], (array)$stuff['URLs']); 
    14     foreach ((array) $stuff as $file) { 
    15         if (strtolower(substr($file, strrpos($file, '.') + 1)) == 'mp3') { 
    16             if (substr($file,0,7) == "http://") { 
    17                 if(ini_get('allow_url_fopen')) { 
    18                     $headers = array_change_key_case(get_headers($file, 1),CASE_LOWER); 
    19                     $filesize = $headers['content-length']; 
    20                     if ($filesize) return $filesize; 
    21                 } 
    22             } else { 
    23                 return @filesize(sb_get_value('wordpress_path').get_option('sb_sermon_upload_dir').$file); 
    24             break; 
    25             } 
     12//Prints size of file 
     13function sb_media_size($media_name, $media_type) { 
     14    if ($media_type == 'URLs') { 
     15        if(ini_get('allow_url_fopen')) { 
     16            $headers = array_change_key_case(get_headers($media_name, 1),CASE_LOWER); 
     17            $filesize = $headers['content-length']; 
     18            if ($filesize) return "length=\"{$filesize}\""; 
    2619        } 
    27     } 
     20    } else 
     21        return 'length="'.@filesize(sb_get_value('wordpress_path').get_option('sb_sermon_upload_dir').$media_name).'"'; 
    2822} 
    2923 
    30 //Prints size of first .mp3 file 
    31 function sb_first_mp3_length($sermon) { 
    32     $stuff = sb_get_stuff($sermon); 
    33     $stuff = array_merge((array)$stuff['Files'], (array)$stuff['URLs']); 
    34     foreach ((array) $stuff as $file) { 
    35         if (strtolower(substr($file, strrpos($file, '.') + 1)) == 'mp3') 
    36             if (substr($file,0,7) == "http://") 
    37                 return; 
    38             else { 
    39                 $mp3file = new mp3file(sb_get_value('wordpress_path').get_option('sb_sermon_upload_dir').$file); 
    40                 $meta = $mp3file->get_metadata(); 
    41                 return $meta['Length']; 
    42             } 
     24//Prints size of .mp3 file 
     25function sb_mp3_length($media_name, $media_type) { 
     26    if (strtolower(substr($media_name, -3)) == 'mp3' && $media_type == 'Files') { 
     27        $mp3file = new mp3file(sb_get_value('wordpress_path').get_option('sb_sermon_upload_dir').$media_name); 
     28        $meta = $mp3file->get_metadata(); 
     29        return $meta['Length']; 
    4330    } 
    4431} 
     
    4633//Replaces & with &amp; 
    4734function sb_ampersand_entity ($string) { 
    48     return str_replace('&amp;&amp;', '&amp;', str_replace('&', '&amp;', $string)); 
     35    return str_replace('&amp;amp;', '&amp;', str_replace('&', '&amp;', $string)); 
     36} 
     37 
     38// Convert filename to URL, perhaps with stats 
     39// Stats have to be turned off for iTunes compatibility 
     40function sb_podcast_file_url($media_name, $media_type) { 
     41    $user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''; 
     42    if (stripos($user_agent, 'itunes') !== FALSE | stripos($user_agent, 'FeedBurner') !== FALSE) 
     43        $stats = FALSE; 
     44    else 
     45        $stats = TRUE; 
     46    if ($media_type == 'URLs') { 
     47        if ($stats) 
     48            $media_name=sb_display_url().sb_query_char().'show&amp;url='.URLencode($media_name); 
     49    } else { 
     50        if (!$stats) 
     51            $media_name=sb_get_value('wordpress_url').get_option('sb_sermon_upload_dir').URLencode($media_name); 
     52        else 
     53            $media_name=sb_display_url().sb_query_char().'show&amp;file_name='.URLencode($media_name); 
     54    } 
     55    return sb_ampersand_entity($media_name); 
     56} 
     57 
     58// Returns correct MIME type 
     59function sb_mime_type($media_name) { 
     60    global $filetypes; 
     61    $extension = strtolower(substr($media_name, strrpos($media_name, '.') + 1)); 
     62    if (array_key_exists ($extension, $filetypes)) 
     63        return ' type="'.$filetypes[$extension]['content-type'].'"'; 
    4964} 
    5065 
     
    5267<channel> 
    5368    <atom:link href="<?php sb_ampersand_entity(get_option('sb_podcast')) ?>" rel="self" type="application/rss+xml" /> 
    54     <title><?php echo sb_ampersand_entity(get_bloginfo('name')) ?> Podcast</title> 
    55     <itunes:author></itunes:author> 
    56     <description><?php echo get_bloginfo('description') ?></description> 
    57     <link><?php echo sb_ampersand_entity(get_bloginfo('home')) ?></link> 
    58     <language>en-us</language> 
    59     <copyright></copyright> 
     69    <title><?php echo sb_ampersand_entity(get_bloginfo('name')) ?> Podcast</title> 
     70    <itunes:author></itunes:author> 
     71    <description><?php echo get_bloginfo('description') ?></description> 
     72    <link><?php echo sb_ampersand_entity(get_bloginfo('home')) ?></link> 
     73    <language>en-us</language> 
     74    <copyright></copyright> 
    6075    <itunes:explicit>no</itunes:explicit> 
    61     <itunes:owner> 
    62         <itunes:name></itunes:name> 
    63         <itunes:email></itunes:email> 
    64     </itunes:owner> 
     76    <itunes:owner> 
     77        <itunes:name></itunes:name> 
     78        <itunes:email></itunes:email> 
     79    </itunes:owner> 
    6580 
    6681    <lastBuildDate><?php sb_print_iso_date($sermon[0]) ?></lastBuildDate> 
     
    7085    <category>Religion &amp; Spirituality</category> 
    7186    <itunes:category text="Religion &amp; Spirituality"></itunes:category> 
    72 <?php foreach ($sermons as $sermon):  ++$i; if($i>15) break; 
    73     $stuff = sb_get_stuff($sermon); 
    74     if ($stuff['Files'][0] != "") { 
    75     ?> 
    76     <item> 
    77         <guid><?php echo sb_first_mp3($sermon) ?></guid> 
     87    <?php 
     88        $mp3count = 0; 
     89        $accepted_extensions = array ('mp3', 'm4a', 'mp4', 'm4v','mov', 'wma', 'wmv'); 
     90        foreach ($sermons as $sermon) { 
     91            if ($mp3count > 15) 
     92                break; 
     93            $media = sb_get_stuff($sermon); 
     94            if (is_array($media['Files']) | is_array($media['URLs'])) { 
     95                foreach ($media as $media_type => $media_names) 
     96                    if (is_array($media_names) && $media_type != 'Code') 
     97                        foreach ($media_names as $media_name) 
     98                            if (in_array(strtolower(substr($media_name, -3)), $accepted_extensions)) { 
     99                                $mp3count++; 
     100?> 
     101<item> 
     102        <guid><?php echo sb_podcast_file_url($media_name, $media_type) ?></guid> 
    78103        <title><?php echo sb_ampersand_entity(stripslashes($sermon->title)) ?></title> 
    79104        <link><?php echo sb_display_url().sb_query_char().'sermon_id='.$sermon->id ?></link> 
     
    81106        <description><![CDATA[<?php echo stripslashes($sermon->description) ?>]]></description> 
    82107        <itunes:summary><![CDATA[<?php echo stripslashes($sermon->description) ?>]]></itunes:summary> 
    83         <enclosure url="<?php echo sb_first_mp3($sermon) ?>" length="<?php echo sb_first_mp3_size($sermon) ?>" type="audio/mpeg"/> 
    84         <itunes:duration><?php echo sb_first_mp3_length($sermon) ?></itunes:duration> 
     108        <enclosure url="<?php echo sb_podcast_file_url($media_name, $media_type).'" '.sb_media_size($media_name, $media_type).sb_mime_type($media_name); ?> /> 
     109        <itunes:duration><?php echo sb_mp3_length($media_name, $media_type) ?></itunes:duration> 
    85110        <category><?php echo stripslashes($sermon->service) ?></category> 
    86111        <pubDate><?php sb_print_iso_date($sermon) ?></pubDate> 
    87112    </item> 
    88     <?php } 
    89         endforeach ?> 
     113    <?php 
     114                } 
     115            } 
     116        } 
     117    ?> 
    90118</channel> 
    91119</rss> 
  • sermon-browser/trunk/sermon.php

    r108596 r108954  
    55Description: Add sermons to your Wordpress blog. Coding by <a href="http://codeandmore.com/">Tien Do Xuan</a> and  
    66Author: Mark Barnes 
    7 Version: 0.41 
     7Version: 0.41.1 
    88Author URI: http://www.4-14.org.uk/ 
    99 
     
    3030 
    3131//Set global constants 
    32 define('SB_CURRENT_VERSION', '0.41'); 
     32define('SB_CURRENT_VERSION', '0.41.1'); 
    3333define('SB_DATABASE_VERSION', '1.5'); 
    3434 
     
    25112511    } else { 
    25122512        if (!function_exists('ap_insert_player_widgets')) { 
    2513             if ($wpdb->get_var("SELECT COUNT(id) FROM wp_sb_stuff WHERE name LIKE '%.mp3'")>0) 
     2513            if ($wpdb->get_var("SELECT COUNT(id) FROM {$wpdb->prefix}sb_stuff WHERE name LIKE '%.mp3'")>0) 
    25142514                echo '<div id="message" class="updated"><p><b>'.sprintf(__('Tip: Installing the %1$sWordpress Audio Player%2$s will allow users to listen to your sermons more easily.', $sermon_domain), '<a href="http://wpaudioplayer.com/" target="_blank">', '</a>').'</b></div>'; 
    25152515        } 
Note: See TracChangeset for help on using the changeset viewer.