WordPress.org

Plugin Directory

Changeset 56704 for sermon-browser/trunk


Ignore:
Timestamp:
07/28/08 13:47:54 (6 years ago)
Author:
mark8barnes
Message:
 
Location:
sermon-browser/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • sermon-browser/trunk/dictionary.php

    r52938 r56704  
    11<?php  
    22 
    3 $mdict = array( 
    4     '[filters_form]' => '<?php sb_print_filters() ?>', 
    5     '[tag_cloud]' => '<?php sb_print_tag_clouds() ?>', 
    6     '[sermons_count]' => '<?php echo $record_count ?>', 
    7     '[sermons_loop]' => '<?php foreach ($sermons as $sermon): ?><?php $stuff = sb_get_stuff($sermon) ?>', 
    8     '[/sermons_loop]' => '<?php endforeach ?>', 
    9     '[sermon_title]' => '<a href="<?php sb_print_sermon_link($sermon) ?>"><?php echo stripslashes($sermon->title) ?></a>', 
    10     '[preacher_link]' => '<a href="<?php sb_print_preacher_link($sermon) ?>"><?php echo stripslashes($sermon->preacher) ?></a>', 
    11     '[series_link]' => '<a href="<?php sb_print_series_link($sermon) ?>"><?php echo stripslashes($sermon->series) ?></a>', 
    12     '[service_link]' => '<a href="<?php sb_print_service_link($sermon) ?>"><?php echo stripslashes($sermon->service) ?></a>',    
    13     '[date]' => '<?php echo date("j F Y", strtotime($sermon->date)) ?>', 
    14     '[first_passage]' => '<?php $foo = unserialize($sermon->start); $bar = unserialize($sermon->end); echo sb_get_books($foo[0], $bar[0]) ?>', 
    15     '[files_loop]' => '<?php foreach ((array) $stuff["Files"] as $file): ?>', 
    16     '[/files_loop]' => '<?php endforeach ?>', 
    17     '[file]' => '<?php sb_print_url($file) ?>', 
    18     '[file_with_download]' => '<?php sb_print_url_link($file) ?>', 
    19     '[embed_loop]' => '<?php foreach ((array) $stuff["Code"] as $code): ?>', 
    20     '[/embed_loop]' => '<?php endforeach ?>', 
    21     '[embed]' => '<?php sb_print_code($code) ?>', 
    22     '[next_page]' => '<?php sb_print_next_page_link() ?>', 
    23     '[previous_page]' => '<?php sb_print_prev_page_link() ?>',   
    24     '[podcast_for_search]' => '<?php echo sb_podcast_url() ?>', 
    25     '[podcast]' => '<?php echo get_option("sb_podcast") ?>', 
    26     '[itunes_podcast]' => '<?php echo str_replace("http://", "itpc://", get_option("sb_podcast")) ?>', 
    27     '[itunes_podcast_for_search]' => '<?php echo str_replace("http://", "itpc://", sb_podcast_url()) ?>', 
    28     '[podcasticon]' => '<img alt="Subscribe to full podcast" title="Subscribe to full podcast" class="podcasticon" src="<?php echo get_bloginfo("wpurl") ?>/wp-content/plugins/sermon-browser/icons/podcast.png"/>', 
    29     '[podcasticon_for_search]' => '<img alt="Subscribe to custom podcast" title="Subscribe to custom podcast" class="podcasticon" src="<?php echo get_bloginfo("wpurl") ?>/wp-content/plugins/sermon-browser/icons/podcast_custom.png"/>', 
    30     '[editlink]' => '<?php sb_edit_link($sermon->id) ?>', 
    31     '[creditlink]' => '<div id="poweredbysermonbrowser">Powered by <a href="http://www.4-14.org.uk/sermon-browser">Sermon Browser</a></div>', 
    32 ); 
     3function sb_search_results_dictionary() { 
     4    return array( 
     5        '[filters_form]' => '<?php sb_print_filters() ?>', 
     6        '[tag_cloud]' => '<?php sb_print_tag_clouds() ?>', 
     7        '[sermons_count]' => '<?php echo $record_count ?>', 
     8        '[sermons_loop]' => '<?php foreach ($sermons as $sermon): ?><?php $stuff = sb_get_stuff($sermon) ?>', 
     9        '[/sermons_loop]' => '<?php endforeach ?>', 
     10        '[sermon_title]' => '<a href="<?php sb_print_sermon_link($sermon) ?>"><?php echo stripslashes($sermon->title) ?></a>', 
     11        '[preacher_link]' => '<a href="<?php sb_print_preacher_link($sermon) ?>"><?php echo stripslashes($sermon->preacher) ?></a>', 
     12        '[series_link]' => '<a href="<?php sb_print_series_link($sermon) ?>"><?php echo stripslashes($sermon->series) ?></a>', 
     13        '[service_link]' => '<a href="<?php sb_print_service_link($sermon) ?>"><?php echo stripslashes($sermon->service) ?></a>',    
     14        '[date]' => '<?php echo date("j F Y", strtotime($sermon->date)) ?>', 
     15        '[first_passage]' => '<?php $foo = unserialize($sermon->start); $bar = unserialize($sermon->end); echo sb_get_books($foo[0], $bar[0]) ?>', 
     16        '[files_loop]' => '<?php foreach ((array) $stuff["Files"] as $file): ?>', 
     17        '[/files_loop]' => '<?php endforeach ?>', 
     18        '[file]' => '<?php sb_print_url($file) ?>', 
     19        '[file_with_download]' => '<?php sb_print_url_link($file) ?>', 
     20        '[embed_loop]' => '<?php foreach ((array) $stuff["Code"] as $code): ?>', 
     21        '[/embed_loop]' => '<?php endforeach ?>', 
     22        '[embed]' => '<?php sb_print_code($code) ?>', 
     23        '[next_page]' => '<?php sb_print_next_page_link() ?>', 
     24        '[previous_page]' => '<?php sb_print_prev_page_link() ?>',   
     25        '[podcast_for_search]' => '<?php echo sb_podcast_url() ?>', 
     26        '[podcast]' => '<?php echo get_option("sb_podcast") ?>', 
     27        '[itunes_podcast]' => '<?php echo str_replace("http://", "itpc://", get_option("sb_podcast")) ?>', 
     28        '[itunes_podcast_for_search]' => '<?php echo str_replace("http://", "itpc://", sb_podcast_url()) ?>', 
     29        '[podcasticon]' => '<img alt="Subscribe to full podcast" title="Subscribe to full podcast" class="podcasticon" src="<?php echo sb_get_value("plugin_url") ?>/icons/podcast.png"/>', 
     30        '[podcasticon_for_search]' => '<img alt="Subscribe to custom podcast" title="Subscribe to custom podcast" class="podcasticon" src="<?php sb_get_value("plugin_url") ?>/icons/podcast_custom.png"/>', 
     31        '[editlink]' => '<?php sb_edit_link($sermon->id) ?>', 
     32        '[creditlink]' => '<div id="poweredbysermonbrowser">Powered by <a href="http://www.4-14.org.uk/sermon-browser">Sermon Browser</a></div>', 
     33    ); 
     34} 
    3335 
    34 $sdict = array( 
    35     '[sermon_title]' => '<?php echo stripslashes($sermon["Sermon"]->title) ?>', 
    36     '[sermon_description]' => '<?php echo wpautop(stripslashes($sermon["Sermon"]->description)) ?>', 
    37     '[preacher_link]' => '<a href="<?php sb_print_preacher_link($sermon["Sermon"]) ?>"><?php echo stripslashes($sermon["Sermon"]->preacher) ?></a>', 
    38     '[preacher_description]' => '<?php sb_print_preacher_description($sermon["Sermon"]) ?>', 
    39     '[preacher_image]' => '<?php sb_print_preacher_image($sermon["Sermon"]) ?>', 
    40     '[series_link]' => '<a href="<?php sb_print_series_link($sermon["Sermon"]) ?>"><?php echo stripslashes($sermon["Sermon"]->series) ?></a>', 
    41     '[service_link]' => '<a href="<?php sb_print_service_link($sermon["Sermon"]) ?>"><?php echo stripslashes($sermon["Sermon"]->service) ?></a>', 
    42     '[date]' => '<?php echo date("j F Y", strtotime($sermon["Sermon"]->date)) ?>', 
    43     '[passages_loop]' => '<?php for ($i = 0; $i < count($sermon["Sermon"]->start); $i++): ?>', 
    44     '[/passages_loop]' => '<?php endfor ?>', 
    45     '[passage]' => '<?php echo sb_get_books($sermon["Sermon"]->start[$i], $sermon["Sermon"]->end[$i]) ?>', 
    46     '[files_loop]' => '<?php foreach ((array) $sermon["Files"] as $file): ?>', 
    47     '[/files_loop]' => '<?php endforeach ?>', 
    48     '[file]' => '<?php sb_print_url($file) ?>', 
    49     '[file_with_download]' => '<?php sb_print_url_link($file) ?>', 
    50     '[embed_loop]' => '<?php foreach ((array) $sermon["Code"] as $code): ?>', 
    51     '[/embed_loop]' => '<?php endforeach ?>', 
    52     '[embed]' => '<?php sb_print_code($code) ?>', 
    53     '[next_sermon]' => '<?php sb_print_next_sermon_link($sermon["Sermon"]) ?>', 
    54     '[prev_sermon]' => '<?php sb_print_prev_sermon_link($sermon["Sermon"]) ?>', 
    55     '[sameday_sermon]' => '<?php sb_print_sameday_sermon_link($sermon["Sermon"]) ?>', 
    56     '[tags]' => '<?php sb_print_tags($sermon["Tags"]) ?>', 
    57     '[esvtext]' => '<?php for ($i = 0; $i < count($sermon["Sermon"]->start); $i++): echo sb_add_bible_text ($sermon["Sermon"]->start[$i], $sermon["Sermon"]->end[$i], "esv"); endfor ?>', 
    58     '[kjvtext]' => '<?php for ($i = 0; $i < count($sermon["Sermon"]->start); $i++): echo sb_add_bible_text ($sermon["Sermon"]->start[$i], $sermon["Sermon"]->end[$i], "kjv"); endfor ?>', 
    59     '[asvtext]' => '<?php for ($i = 0; $i < count($sermon["Sermon"]->start); $i++): echo sb_add_bible_text ($sermon["Sermon"]->start[$i], $sermon["Sermon"]->end[$i], "asv"); endfor ?>', 
    60     '[ylttext]' => '<?php for ($i = 0; $i < count($sermon["Sermon"]->start); $i++): echo sb_add_bible_text ($sermon["Sermon"]->start[$i], $sermon["Sermon"]->end[$i], "asv"); endfor ?>', 
    61     '[webtext]' => '<?php for ($i = 0; $i < count($sermon["Sermon"]->start); $i++): echo sb_add_bible_text ($sermon["Sermon"]->start[$i], $sermon["Sermon"]->end[$i], "asv"); endfor ?>', 
    62     '[biblepassage]' => '<?php for ($i = 0; $i < count($sermon["Sermon"]->start); $i++): sb_print_bible_passage ($sermon["Sermon"]->start[$i], $sermon["Sermon"]->end[$i]); endfor ?>', 
    63     '[editlink]' => '<?php sb_edit_link($_GET["sermon_id"]) ?>', 
    64     '[creditlink]' => '<div id="poweredbysermonbrowser">Powered by <a href="http://www.4-14.org.uk/sermon-browser">Sermon Browser</a></div>', 
    65 ); 
    66  
     36function sb_sermon_page_dictionary() { 
     37    return array( 
     38        '[sermon_title]' => '<?php echo stripslashes($sermon["Sermon"]->title) ?>', 
     39        '[sermon_description]' => '<?php echo wpautop(stripslashes($sermon["Sermon"]->description)) ?>', 
     40        '[preacher_link]' => '<a href="<?php sb_print_preacher_link($sermon["Sermon"]) ?>"><?php echo stripslashes($sermon["Sermon"]->preacher) ?></a>', 
     41        '[preacher_description]' => '<?php sb_print_preacher_description($sermon["Sermon"]) ?>', 
     42        '[preacher_image]' => '<?php sb_print_preacher_image($sermon["Sermon"]) ?>', 
     43        '[series_link]' => '<a href="<?php sb_print_series_link($sermon["Sermon"]) ?>"><?php echo stripslashes($sermon["Sermon"]->series) ?></a>', 
     44        '[service_link]' => '<a href="<?php sb_print_service_link($sermon["Sermon"]) ?>"><?php echo stripslashes($sermon["Sermon"]->service) ?></a>', 
     45        '[date]' => '<?php echo date("j F Y", strtotime($sermon["Sermon"]->date)) ?>', 
     46        '[passages_loop]' => '<?php for ($i = 0; $i < count($sermon["Sermon"]->start); $i++): ?>', 
     47        '[/passages_loop]' => '<?php endfor ?>', 
     48        '[passage]' => '<?php echo sb_get_books($sermon["Sermon"]->start[$i], $sermon["Sermon"]->end[$i]) ?>', 
     49        '[files_loop]' => '<?php foreach ((array) $sermon["Files"] as $file): ?>', 
     50        '[/files_loop]' => '<?php endforeach ?>', 
     51        '[file]' => '<?php sb_print_url($file) ?>', 
     52        '[file_with_download]' => '<?php sb_print_url_link($file) ?>', 
     53        '[embed_loop]' => '<?php foreach ((array) $sermon["Code"] as $code): ?>', 
     54        '[/embed_loop]' => '<?php endforeach ?>', 
     55        '[embed]' => '<?php sb_print_code($code) ?>', 
     56        '[next_sermon]' => '<?php sb_print_next_sermon_link($sermon["Sermon"]) ?>', 
     57        '[prev_sermon]' => '<?php sb_print_prev_sermon_link($sermon["Sermon"]) ?>', 
     58        '[sameday_sermon]' => '<?php sb_print_sameday_sermon_link($sermon["Sermon"]) ?>', 
     59        '[tags]' => '<?php sb_print_tags($sermon["Tags"]) ?>', 
     60        '[esvtext]' => '<?php for ($i = 0; $i < count($sermon["Sermon"]->start); $i++): echo sb_add_bible_text ($sermon["Sermon"]->start[$i], $sermon["Sermon"]->end[$i], "esv"); endfor ?>', 
     61        '[kjvtext]' => '<?php for ($i = 0; $i < count($sermon["Sermon"]->start); $i++): echo sb_add_bible_text ($sermon["Sermon"]->start[$i], $sermon["Sermon"]->end[$i], "kjv"); endfor ?>', 
     62        '[asvtext]' => '<?php for ($i = 0; $i < count($sermon["Sermon"]->start); $i++): echo sb_add_bible_text ($sermon["Sermon"]->start[$i], $sermon["Sermon"]->end[$i], "asv"); endfor ?>', 
     63        '[ylttext]' => '<?php for ($i = 0; $i < count($sermon["Sermon"]->start); $i++): echo sb_add_bible_text ($sermon["Sermon"]->start[$i], $sermon["Sermon"]->end[$i], "asv"); endfor ?>', 
     64        '[webtext]' => '<?php for ($i = 0; $i < count($sermon["Sermon"]->start); $i++): echo sb_add_bible_text ($sermon["Sermon"]->start[$i], $sermon["Sermon"]->end[$i], "asv"); endfor ?>', 
     65        '[biblepassage]' => '<?php for ($i = 0; $i < count($sermon["Sermon"]->start); $i++): sb_print_bible_passage ($sermon["Sermon"]->start[$i], $sermon["Sermon"]->end[$i]); endfor ?>', 
     66        '[editlink]' => '<?php sb_edit_link($_GET["sermon_id"]) ?>', 
     67        '[creditlink]' => '<div id="poweredbysermonbrowser">Powered by <a href="http://www.4-14.org.uk/sermon-browser">Sermon Browser</a></div>', 
     68    ); 
     69} 
    6770 
    6871?> 
  • sermon-browser/trunk/filetypes.php

    r51888 r56704  
    66//      'name' => 'Description of filetype', 
    77//      'icon' => 'iconfilename.png', 
    8 //      'icon' => 'content-type',  
     8//      'content-type' => 'content-type',  
    99//  ),       
    10 // Consult http://www.w3schools.com/media/media_mimeref.asp for contenty-type reference. Use application/octet-stream if unsure. 
     10// Consult http://www.w3schools.com/media/media_mimeref.asp for content-type reference. Use application/octet-stream 
     11// if unsure. 
    1112 
    1213$filetypes = array( 
  • sermon-browser/trunk/frontend.php

    r52938 r56704  
    2121    global $display_url, $wpdb; 
    2222    if (!$display_url) { 
    23         $pageid = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_content = '[sermons]' AND post_status = 'publish' AND post_date < NOW();"); 
     23        $pageid = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_content LIKE '%[sermons]%' AND post_status = 'publish' AND post_date < NOW();"); 
    2424        $display_url = get_permalink($pageid); 
    2525    } 
     
    4848} 
    4949 
    50 //Shows database statistics in the HTML comments if define('SAVEQUERIES', true); is set in wp-config.php Useful for diagnostics 
     50//Shows database statistics in the HTML comments if define('SAVEQUERIES', true); is set in wp-config.php 
     51//Useful for diagnostics 
    5152function sb_footer_stats() { 
    5253    if (SAVEQUERIES) { 
     
    147148    } 
    148149    else { 
    149         global $books; 
     150        $books = sb_bible_books(); 
    150151        $r1 = array_search($start['book'], $books)+1; 
    151152        $r2 = $start['chapter']; 
     
    238239    //Displays podcast 
    239240    if (isset($_REQUEST['podcast'])) { 
    240         global $wordpressRealPath; 
    241241        $sermons = sb_get_sermons(array( 
    242242            'title' => $_REQUEST['title'], 
     
    258258        header('Content-Type: application/rss+xml'); 
    259259        echo '<?xml version="1.0" encoding="UTF-8"?>'; 
    260         include($wordpressRealPath.'/wp-content/plugins/sermon-browser/podcast.php'); 
     260        include(sb_get_value('plugin_path').'podcast.php'); 
    261261        die(); 
    262262    } 
     
    264264    //Forces sermon download of local file 
    265265    if (isset($_REQUEST['download']) AND isset($_REQUEST['file_name'])) { 
    266         global $wordpressRealPath; 
    267266        $file_name = urldecode($_GET['file_name']); 
    268267        header("Pragma: public"); 
     
    275274        header("Content-Transfer-Encoding: binary"); 
    276275        sb_increase_download_count ($file_name); 
    277         $file_name = $wordpressRealPath.get_option("sb_sermon_upload_dir").$file_name; 
     276        $file_name = sb_get_value('wordpress_path').get_option("sb_sermon_upload_dir").$file_name; 
    278277        header("Content-Length: ".filesize($file_name)); 
    279278        @readfile($file_name); 
     
    322321    //Returns local file (doesn't force download) 
    323322    if (isset($_REQUEST['show']) AND isset($_REQUEST['file_name'])) { 
    324         global $wordpressRealPath, $filetypes; 
     323        global $filetypes; 
    325324        $file_name = urldecode($_GET['file_name']); 
    326325        $ext = substr($file_name, strrpos($file_name, '.') + 1); 
     
    330329            header ("Content-Type: application/octet-stream"); } 
    331330        sb_increase_download_count ($file_name); 
    332         $file_name = $wordpressRealPath.get_option("sb_sermon_upload_dir").$file_name; 
     331        $file_name = sb_get_value('wordpress_path').get_option("sb_sermon_upload_dir").$file_name; 
    333332        header("Content-Length: ".filesize($file_name)); 
    334333        header("Content-Transfer-Encoding: binary"); 
     
    423422function sb_sermons_filter($content) { 
    424423    global $wpdb, $clr, $record_count; 
    425     global $wordpressRealPath; 
    426424    ob_start(); 
    427425     
     
    476474// Adds sermon-browser code to Wordpress header 
    477475function sb_print_header() { 
    478     global $sermon_domain, $sermompage; 
    479     $url = get_bloginfo('wpurl'); 
    480476?> 
    481477    <link rel="alternate" type="application/rss+xml" title="<?php _e('Sermon podcast', $sermon_domain) ?>" href="<?php echo get_option('sb_podcast') ?>" /> 
    482     <link rel="stylesheet" href="<?php echo $url ?>/wp-content/plugins/sermon-browser/datepicker.css" type="text/css"/> 
    483     <link rel="stylesheet" href="<?php echo $url ?>/wp-content/plugins/sermon-browser/style.php" type="text/css"/> 
    484     <script type="text/javascript" src="<?php echo $url ?>/wp-includes/js/jquery/jquery.js"></script> 
    485     <script type="text/javascript" src="<?php echo $url ?>/wp-content/plugins/sermon-browser/datePicker.js"></script> 
    486478<?php 
     479    global $sermon_domain, $post, $wpdb; 
     480    if ($_REQUEST['title'] OR $_REQUEST['preacher'] OR $_REQUEST['date'] OR $_REQUEST['enddate'] OR $_REQUEST['series'] OR $_REQUEST['service'] OR $_REQUEST['book'] OR $_REQUEST['stag']) { 
     481?> 
     482    <link rel="alternate" type="application/rss+xml" title="<?php _e('Custom sermon podcast', $sermon_domain) ?>" href="<?php echo sb_podcast_url() ?>" /> 
     483<?php 
     484    } 
     485    $pageinfo = $wpdb->get_results("SELECT ID, post_type FROM {$wpdb->posts} WHERE post_content LIKE '%[sermons]%' AND post_status = 'publish' AND post_date < NOW();"); 
     486    $pageinfo = $pageinfo [0]; 
     487    if (($pageinfo->ID == $post->ID) OR $pageinfo->post_type == "post") { 
     488?> 
     489    <link rel="stylesheet" href="<?php echo sb_get_value('plugin_url') ?>/datepicker.css" type="text/css"/> 
     490    <link rel="stylesheet" href="<?php echo sb_get_value('plugin_url') ?>/style.php" type="text/css"/> 
     491    <script type="text/javascript" src="<?php echo sb_get_value('wordpress_url') ?>/wp-includes/js/jquery/jquery.js"></script> 
     492    <script type="text/javascript" src="<?php echo sb_get_value('plugin_url') ?>/datePicker.js"></script> 
     493<?php 
     494    } 
    487495} 
    488496 
     
    566574//Prints link to next page 
    567575function sb_print_next_page_link($limit = 0) { 
    568     global $sermon_domain, $record_count, $sermons_per_page; 
    569     if ($limit == 0) $limit = $sermons_per_page; 
     576    global $sermon_domain, $record_count; 
     577    if ($limit == 0) $limit = sb_get_value('sermons_per_page'); 
    570578    $current = $_REQUEST['page'] ? (int) $_REQUEST['page'] : 1; 
    571579    if ($current < ceil($record_count / $limit)) { 
     
    577585//Prints link to previous page 
    578586function sb_print_prev_page_link($limit = 0) { 
    579     global $sermon_domain, $sermons_per_page; 
    580     if ($limit == 0) $limit = $sermons_per_page; 
     587    global $sermon_domain; 
     588    if ($limit == 0) $limit = sb_get_value('sermons_per_page'); 
    581589    $current = $_REQUEST['page'] ? (int) $_REQUEST['page'] : 1; 
    582590    if ($current > 1) { 
     
    590598    global $siteicons, $default_site_icon ,$filetypes; 
    591599    if (substr($url,0,7) == "http://") { 
    592         $url=get_bloginfo('wpurl').'?show&url='.URLencode($url); 
     600        $url=sb_get_value('wordpress_url').'?show&url='.URLencode($url); 
    593601    } else { 
    594         $url=get_bloginfo('wpurl').'?show&file_name='.URLencode($url); 
    595     } 
    596     $icon_url = get_bloginfo('wpurl').'/wp-content/plugins/sermon-browser/icons/'; 
     602        $url=sb_get_value('wordpress_url').'?show&file_name='.URLencode($url); 
     603    } 
     604    $icon_url = sb_get_value('plugin_url').'/icons/'; 
    597605    $uicon = $default_site_icon; 
    598606    foreach ($siteicons as $site => $icon) { 
     
    608616        echo ap_insert_player_widgets('[audio:'.$url.']'); 
    609617    } else { 
    610         echo '<a href="'.$url.'"><img class="site-icon" alt="'.$url.'" title="'.$url.'" src="'.$icon_url.$uicon.'"></a>'; 
     618        echo '<a href="'.$url.'"><img class="site-icon" alt="'.$filetypes[$ext]['name'].'" title="'.$filetypes[$ext]['name'].'" src="'.$icon_url.$uicon.'"></a>'; 
    611619    } 
    612620     
     
    693701        $tags[] = $tag->name; 
    694702    } 
    695     foreach ($stuff as $cur) { 
     703foreach ($stuff as $cur) { 
    696704        switch ($cur->type) { 
    697705            case "file": 
     
    716724//Get multiple sermons from the database 
    717725function sb_get_sermons($filter, $order, $page = 1, $limit = 0) { 
    718     global $wpdb, $record_count, $sermons_per_page; 
    719     if ($limit == 0) $limit = $sermons_per_page; 
     726    global $wpdb, $record_count; 
     727    if ($limit == 0) $limit = sb_get_value('sermons_per_page'); 
    720728    $default_filter = array( 
    721729        'title' => '', 
     
    806814//Displays the filter on sermon search page 
    807815function sb_print_filters() { 
    808     global $wpdb, $sermon_domain, $books; 
    809      
    810     $url = get_bloginfo('wpurl'); 
     816    global $wpdb, $sermon_domain; 
    811817     
    812818    $preachers = $wpdb->get_results("SELECT p.*, count(p.id) AS count FROM {$wpdb->prefix}sb_preachers AS p JOIN {$wpdb->prefix}sb_sermons AS s ON p.id = s.preacher_id GROUP BY p.id ORDER BY count DESC, s.date DESC");    
  • sermon-browser/trunk/podcast.php

    r53067 r56704  
    77//Prints first .mp3 file 
    88function sb_first_mp3($sermon) { 
     9    $user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''; 
     10    $itunes = stristr($user_agent, 'itunes') ? true : false; 
    911    $stuff = sb_get_stuff($sermon); 
    1012    foreach ((array) $stuff['Files'] as $file) { 
    1113        if (strtolower(substr($file, strrpos($file, '.') + 1)) == 'mp3') { 
    1214            if (substr($file,0,7) == "http://") { 
    13                 $file=get_bloginfo('wpurl').'?show&amp;url='.URLencode($file); 
     15                if (!$itunes) $file=sb_get_value('wordpress_url').'?show&amp;url='.URLencode($file); 
    1416            } else { 
    15                 $file=get_bloginfo('wpurl').'?show&amp;file_name='.URLencode($file); 
     17                if ($itunes) 
     18                    $file=sb_get_value('wordpress_url').get_option('sb_sermon_upload_dir').URLencode($file); 
     19                else 
     20                    $file=sb_get_value('wordpress_url').'?show&amp;file_name='.URLencode($file); 
    1621            } 
    1722            return $file; 
     
    2328//Prints size of first .mp3 file 
    2429function sb_first_mp3_size($sermon) { 
    25     global $wordpressRealPath; 
    2630    $stuff = sb_get_stuff($sermon); 
    2731    foreach ((array) $stuff['Files'] as $file) { 
     
    2933            if (substr($file,0,7) == "http://") { 
    3034                if(ini_get('allow_url_fopen')) { 
    31                     $headers = array_change_key_case(get_headers($url, 1),CASE_LOWER); 
     35                    $headers = array_change_key_case(get_headers($file, 1),CASE_LOWER); 
    3236                    $filesize = $headers['content-length']; 
    3337                    if ($filesize) return $filesize; 
    3438                } 
    3539            } else { 
    36                 return @filesize($wordpressRealPath.get_option('sb_sermon_upload_dir').$file); 
     40                return @filesize(sb_get_value('wordpress_path').get_option('sb_sermon_upload_dir').$file); 
     41            break; 
    3742            } 
    38             break; 
    3943        } 
    4044    } 
    4145} 
    42 ?> 
    43 <rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> 
     46?><rss xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> 
    4447<channel> 
    4548    <atom:link href="<?php echo get_option('sb_podcast') ?>" rel="self" type="application/rss+xml" /> 
     
    6265    <category>Religion &amp; Spirituality</category> 
    6366    <itunes:category text="Religion &amp; Spirituality"></itunes:category> 
    64         <?php foreach ($sermons as $sermon):  ++$i; if($i>15) break; ?> 
     67<?php foreach ($sermons as $sermon):  ++$i; if($i>15) break; ?> 
    6568        <item> 
    6669            <guid><?php echo sb_first_mp3($sermon) ?></guid> 
    6770            <title><?php echo stripslashes($sermon->title) ?></title> 
    68             <link><?php echo sb_first_mp3($sermon) ?></link> 
     71            <link><?php echo sb_display_url().sb_query_char().'sermon_id='.$sermon->id ?></link> 
    6972            <description><?php echo stripslashes($sermon->description) ?></description> 
    7073            <enclosure url="<?php echo sb_first_mp3($sermon) ?>" length="<?php echo sb_first_mp3_size($sermon) ?>" type="audio/mpeg"/> 
  • sermon-browser/trunk/readme.txt

    r52938 r56704  
    44Tags: sermons, podcast, mp3, church, bible, audio, widget, embed, video, esv 
    55Requires at least: 2.2 
    6 Tested up to: 2.5 
     6Tested up to: 2.6 
    77Stable tag: trunk 
    88 
  • sermon-browser/trunk/sermon.php

    r53127 r56704  
    55Description: Add sermons to your Wordpress blog. Main coding by <a href="http://codeandmore.com/">Tien Do Xuan</a>. Design and additional coding 
    66Author: Mark Barnes 
    7 Version: 0.31 
     7Version: 0.32 
    88Author URI: http://www.4-14.org.uk/ 
    99 
     
    2525*/ 
    2626 
    27 // Localization and set-up 
     27/*************************************** 
     28 ** Set up                            ** 
     29 **************************************/ 
     30 
    2831$sermon_domain = 'sermon-browser'; 
    2932load_plugin_textdomain($sermon_domain, 'wp-content/plugins/sermon-browser'); 
     
    3235include('frontend.php'); // Everything related to displaying sermons 
    3336 
    34 // Assign global variables 
    35 global $url, $wordpressRealPath, $defaultSermonPath, $display_mode, $sermons_per_page, $display_url; 
    36 $url = get_bloginfo('wpurl'); 
    37 $wordpressRealPath = str_replace("\\", "/", dirname(dirname(dirname(dirname(__FILE__))))); 
    38 $defaultSermonPath = '/'.get_option('upload_path').'/sermons/'; 
    39 $display_method = get_option('sb_display_method'); 
    40 $defaultSermonURL = get_bloginfo('wpurl').'/'.get_option('upload_path').'/sermons/'; 
    41 $books = array('Genesis', 'Exodus', 'Leviticus', 'Numbers', 'Deuteronomy', 'Joshua', 'Judges', 'Ruth', '1 Samuel', '2 Samuel', '1 Kings', '2 Kings', '1 Chronicles', '2 Chronicles', 'Ezra', 'Nehemiah', 'Esther', 'Job', 'Psalm', 'Proverbs', 'Ecclesiastes', 'Song of Solomon', 'Isaiah', 'Jeremiah', 'Lamentations', 'Ezekiel', 'Daniel', 'Hosea', 'Joel', 'Amos', 'Obadiah', 'Jonah', 'Micah', 'Nahum', 'Habakkuk', 'Zephaniah', 'Haggai', 'Zechariah', 'Malachi', 'Matthew', 'Mark', 'Luke', 'John', 'Acts', 'Romans', '1 Corinthians', '2 Corinthians', 'Galatians', 'Ephesians', 'Philippians', 'Colossians', '1 Thessalonians', '2 Thessalonians', '1 Timothy', '2 Timothy', 'Titus', 'Philemon', 'Hebrews', 'James', '1 Peter', '2 Peter', '1 John', '2 John', '3 John', 'Jude', 'Revelation'); 
    42 $sermons_per_page = get_option('sb_sermons_per_page'); 
    43  
    4437if ($_POST['sermon'] == 1) sb_return_ajax_data(); // Return AJAX data if that is all that is required 
    4538 
     
    5346    add_menu_page(__('Sermons', $sermon_domain), __('Sermons', $sermon_domain), 'edit_posts', __FILE__, 'sb_manage_sermons'); 
    5447    add_submenu_page(__FILE__, __('Sermons', $sermon_domain), __('Sermons', $sermon_domain), 'edit_posts', __FILE__, 'sb_manage_sermons'); 
    55     add_submenu_page(__FILE__, __('New Sermon', $sermon_domain), __('New Sermon', $sermon_domain), 'publish_posts', 'sermon-browser/new_sermon.php', 'sb_new_sermon'); 
     48    if ($_REQUEST['page'] == 'sermon-browser/new_sermon.php' && $_REQUEST['mid']) { 
     49        add_submenu_page(__FILE__, __('Edit Sermon', $sermon_domain), __('Edit Sermon', $sermon_domain), 'publish_posts', 'sermon-browser/new_sermon.php', 'sb_new_sermon'); 
     50    } else { 
     51        add_submenu_page(__FILE__, __('Add Sermon', $sermon_domain), __('Add Sermon', $sermon_domain), 'publish_posts', 'sermon-browser/new_sermon.php', 'sb_new_sermon'); 
     52    } 
    5653    add_submenu_page(__FILE__, __('Preachers', $sermon_domain), __('Preachers', $sermon_domain), 'manage_categories', 'sermon-browser/preachers.php', 'sb_manage_preachers'); 
    5754    add_submenu_page(__FILE__, __('Series &amp; Services', $sermon_domain), __('Series &amp; Services', $sermon_domain), 'manage_categories', 'sermon-browser/manage.php', 'sb_manage_everything'); 
     
    6259} 
    6360 
     61/*************************************** 
     62 ** Main Functions in Admin           ** 
     63 **************************************/ 
     64 
    6465// Installer 
    6566function sb_sermon_install () { 
    66     global $books; 
    6767    //Attempt to set php.ini directives 
    6868    if (sb_return_kbytes(ini_get('upload_max_filesize'))<15360) ini_set('upload_max_filesize', '15M'); 
     
    7474    // Only proceed with install if necessary 
    7575    if(get_option('sb_sermon_db_version') =='1.4') return; 
    76     global $wpdb, $mdict, $sdict, $books;    
    77     global $wordpressRealPath, $defaultSermonPath, $defaultSermonURL, $defaultMultiForm, $defaultSingleForm, $defaultStyle; 
     76    global $wpdb; 
     77    global $defaultMultiForm, $defaultSingleForm, $defaultStyle; 
    7878    require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); 
    79     $sermonUploadDir = $defaultSermonPath; 
    80     if (!is_dir($wordpressRealPath.$sermonUploadDir)) { 
    81         if (@mkdir($wordpressRealPath.$sermonUploadDir)) { 
    82             @chmod($wordpressRealPath.$sermonUploadDir, 0777);           
    83         } 
    84     } 
    85     if(!is_dir($wordpressRealPath.$sermonUploadDir.'images') && @mkdir($wordpressRealPath.$sermonUploadDir.'images')){ 
    86         @chmod($wordpressRealPath.$sermonUploadDir.'images', 0777); 
     79    $sermonUploadDir = sb_get_default('sermon_path'); 
     80    if (!is_dir(sb_get_value('wordpress_path').$sermonUploadDir)) { 
     81        if (@mkdir(sb_get_value('wordpress_path').$sermonUploadDir)) { 
     82            @chmod(sb_get_value('wordpress_path').$sermonUploadDir, 0777);           
     83        } 
     84    } 
     85    if(!is_dir(sb_get_value('wordpress_path').$sermonUploadDir.'images') && @mkdir(sb_get_value('wordpress_path').$sermonUploadDir.'images')){ 
     86        @chmod(sb_get_value('wordpress_path').$sermonUploadDir.'images', 0777); 
    8787    } 
    8888    //Upgrade database from earlier versions 
     89    $books = sb_get_default('bible_books'); 
    8990    switch (get_option('sb_sermon_db_version')) { 
    9091        case '1.0': // Also moves files from old default folder to new default folder 
    91             $oldSermonPath = "/wp-content/plugins/sermonbrowser/files/"; 
     92            $oldSermonPath = sb_get_value('plugin_path')."/files/"; 
    9293            $files = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}sb_stuff WHERE type = 'file' ORDER BY name asc");  
    9394            foreach ((array)$files as $file) { 
    94                 @chmod($wordpressRealPath.$oldSermonPath.$file->name, 0777); 
    95                 @rename($wordpressRealPath.$oldSermonPath.$file->name, $wordpressRealPath.$defaultSermonPath.$file->name); 
     95                @chmod(sb_get_value('wordpress_path').$oldSermonPath.$file->name, 0777); 
     96                @rename(sb_get_value('wordpress_path').$oldSermonPath.$file->name, sb_get_value('wordpress_path').$sermonUploadDir.$file->name); 
    9697            } 
    9798            $table_name = $wpdb->prefix . "sb_preachers"; 
     
    102103        case '1.1': 
    103104            add_option('sb_sermon_style', base64_encode($defaultStyle)); 
    104             if(!is_dir($wordpressRealPath.$sermonUploadDir.'images') && @mkdir($wordpressRealPath.$sermonUploadDir.'images')){ 
    105                 @chmod($wordpressRealPath.$sermonUploadDir.'images', 0777); 
     105            if(!is_dir(sb_get_value('wordpress_path').$sermonUploadDir.'images') && @mkdir(sb_get_value('wordpress_path').$sermonUploadDir.'images')){ 
     106                @chmod(sb_get_value('wordpress_path').$sermonUploadDir.'images', 0777); 
    106107            } 
    107108            update_option('sb_sermon_db_version', '1.2');    
    108109        case '1.2': 
    109             $table_name = $wpdb->prefix . "sb_stuff"; 
    110             if($wpdb->get_var("show tables like '$table_name'") == $table_name) 
    111                   $wpdb->query("ALTER TABLE ".$table_name." ADD count INT(10) NOT NULL"); 
    112             $table_name = $wpdb->prefix . "sb_books_sermons"; 
    113             if($wpdb->get_var("show tables like '$table_name'") == $table_name) 
    114                   $wpdb->query("ALTER TABLE ".$table_name." ADD INDEX (sermon_id)"); 
    115             $table_name = $wpdb->prefix . "sb_sermons_tags"; 
    116             if($wpdb->get_var("show tables like '$table_name'") == $table_name) 
    117                   $wpdb->query("ALTER TABLE ".$table_name." ADD INDEX (sermon_id)"); 
     110            $wpdb->query("ALTER TABLE ".$wpdb->prefix."sb_stuff ADD count INT(10) NOT NULL"); 
     111            $wpdb->query("ALTER TABLE ".$wpdb->prefix."sb_books_sermons ADD INDEX (sermon_id)"); 
     112            $wpdb->query("ALTER TABLE ".$wpdb->prefix."sb_sermons_tags ADD INDEX (sermon_id)"); 
    118113            update_option('sb_sermon_db_version', '1.3'); 
    119114        case '1.3': 
    120             $table_name = $wpdb->prefix . "sb_series"; 
    121             if($wpdb->get_var("show tables like '$table_name'") == $table_name) 
    122                   $wpdb->query("ALTER TABLE ".$table_name." ADD page_id INT(10) NOT NULL"); 
    123             $table_name = $wpdb->prefix . "sb_sermons"; 
    124             if($wpdb->get_var("show tables like '$table_name'") == $table_name) 
    125                   $wpdb->query("ALTER TABLE ".$table_name." ADD page_id INT(10) NOT NULL"); 
     115            $wpdb->query("ALTER TABLE ".$wpdb->prefix."sb_series ADD page_id INT(10) NOT NULL"); 
     116            $wpdb->query("ALTER TABLE ".$wpdb->prefix."sb_sermons ADD page_id INT(10) NOT NULL"); 
    126117            add_option('sb_display_method', 'dynamic'); 
    127118            add_option('sb_sermons_per_page', '15'); 
    128             $wpdb->query("TRUNCATE TABLE {$wpdb->prefix}sb_books"); // Fix missing data bug from earlier versions 
    129             for ($i=0; $i < count($books); $i++) {  
    130                 $wpdb->query("INSERT INTO {$wpdb->prefix}sb_books VALUES (null, '$books[$i]')");  
    131             } 
    132             add_option('sb_sermon_multi_output', base64_encode(strtr(stripslashes(get_option('sb_sermon_multi_form')), $mdict))); 
    133             add_option('sb_sermon_single_output', base64_encode(strtr(stripslashes(get_option('sb_sermon_single_form')), $sdict))); 
    134             add_option('sb_sermon_style_output', base64_encode(stripslashes(get_option('sb_sermon_style')))); 
     119            add_option('sb_sermon_multi_output', base64_encode(strtr(sb_get_value('multi_form')), sb_search_results_dictionary())); 
     120            add_option('sb_sermon_single_output', base64_encode(strtr(sb_get_value('single_form'), sb_sermon_page_dictionary()))); 
     121            add_option('sb_sermon_style_output', base64_encode(stripslashes(base64_decode(get_option('sb_sermon_style'))))); 
    135122            add_option('sb_sermon_style_date_modified', strtotime('now')); 
    136123            update_option('sb_sermon_db_version', '1.4'); 
     124        case '1.4' : 
    137125            return; 
    138126        default: 
    139127            update_option('sb_sermon_db_version', '1.0'); 
     128            return; 
    140129    }        
    141130 
     
    274263    $welcome_text = __('Congratulations, you just completed the installation!', $sermon_domain);     
    275264    add_option('sb_sermon_upload_dir', $sermonUploadDir); 
    276     add_option('sb_sermon_upload_url', $defaultSermonURL); 
    277     add_option('sb_podcast', get_bloginfo('url').sb_display_url().'?podcast'); 
     265    add_option('sb_sermon_upload_url', sb_get_default('attachment_url')); 
     266    add_option('sb_podcast', sb_display_url().'?podcast'); 
    278267    add_option('sb_display_method', 'dynamic'); 
    279268    add_option('sb_sermons_per_page', '15'); 
     
    284273    delete_option('sb_sermon_style'); 
    285274    add_option('sb_sermon_style', base64_encode(sb_default_css())); 
    286     add_option('sb_sermon_multi_output', base64_encode(strtr(stripslashes(get_option('sb_sermon_multi_form')), $mdict))); 
    287     add_option('sb_sermon_single_output', base64_encode(strtr(stripslashes(get_option('sb_sermon_single_form')), $sdict))); 
    288     add_option('sb_sermon_style_output', base64_encode(stripslashes(get_option('sb_sermon_style')))); 
     275    add_option('sb_sermon_multi_output', base64_encode(strtr(sb_default_multi_template(), sb_search_results_dictionary()))); 
     276    add_option('sb_sermon_single_output', base64_encode(strtr(sb_default_single_template(), sb_sermon_page_dictionary()))); 
     277    add_option('sb_sermon_style_output', base64_encode(sb_default_css())); 
    289278    for ($i=0; $i < count($books); $i++) {  
    290         $wpdb->query("INSERT INTO {$wpdb->prefix}sb_books VALUES (null, '$books[$i]');"); 
     279        $wpdb->query("INSERT INTO {$wpdb->prefix}sb_books VALUES (null, '{$books[$i]}');"); 
    291280    } 
    292281    add_option('sb_sermon_db_version', '1.4'); 
    293 } 
    294  
    295 // Tidy the textarea input 
    296 function sb_build_textarea($name, $html) { 
    297     $out = '<textarea name="'.$name.'" cols="75" rows="15">'; 
    298     $out .= stripslashes(str_replace('\r\n', "\n", base64_decode($html)));  
    299     $out .= '</textarea>'; 
    300     echo $out; 
    301282} 
    302283 
    303284// Display the options page and handle changes 
    304285function sb_options() { 
    305     global $wpdb, $sermon_domain, $mdict, $sdict, $url, $display_method; 
    306     global $wordpressRealPath, $defaultSermonPath, $defaultSermonURL, $books; 
     286    global $wpdb, $sermon_domain; 
    307287    //Security check 
    308288    if (function_exists('current_user_can')&&!current_user_can('manage_options')) 
     
    310290    //Reset options to default 
    311291    if ($_POST['resetdefault']) { 
    312         $dir = $defaultSermonPath; 
     292        $dir = sb_get_default('sermon_path'); 
    313293        update_option('sb_podcast', sb_display_url().'?podcast'); 
    314         update_option('sb_sermon_upload_dir', $defaultSermonPath); 
    315         update_option('sb_sermon_upload_url', $defaultSermonURL); 
     294        update_option('sb_sermon_upload_dir', $dir); 
     295        update_option('sb_sermon_upload_url', sb_get_default('attachment_url')); 
    316296        update_option('sb_display_method', 'dynamic'); 
    317297        update_option('sb_sermons_per_page', '15'); 
    318         $wpdb->query("TRUNCATE TABLE {$wpdb->prefix}sb_books"); // Reset bible books database 
    319         for ($i=0; $i < count($books); $i++) {  
    320             $wpdb->query("INSERT INTO {$wpdb->prefix}sb_books VALUES (null, '$books[$i]')"); 
    321         } 
    322         if (!is_dir($wordpressRealPath.$dir)) { 
     298        if (!is_dir(sb_get_value('wordpress_path').$dir)) { 
    323299          //Create that folder 
    324           if (@mkdir($wordpressRealPath.$dir)) { 
     300          if (@mkdir(sb_get_value('wordpress_path').$dir)) { 
    325301             //try CHMOD it to 777 
    326              @chmod($wordpressRealPath.$dir, 0777);  
     302             @chmod(sb_get_value('wordpress_path').$dir, 0777);  
    327303          } 
    328304        } 
    329         if(!is_dir($wordpressRealPath.$sermonUploadDir.'images') && @mkdir($wordpressRealPath.$sermonUploadDir.'images')){ 
    330          @chmod($wordpressRealPath.$sermonUploadDir.'images', 0777); 
    331         }            
     305        if(!is_dir(sb_get_value('wordpress_path').$sermonUploadDir.'images') && @mkdir(sb_get_value('wordpress_path').$sermonUploadDir.'images')){ 
     306         @chmod(sb_get_value('wordpress_path').$sermonUploadDir.'images', 0777); 
     307        } 
     308        $books = sb_get_default('bible_books'); 
     309        $wpdb->query("TRUNCATE TABLE {$wpdb->prefix}sb_books");  
     310        for ($i=0; $i < count($books); $i++) { // Reset bible books database 
     311            $wpdb->query("INSERT INTO {$wpdb->prefix}sb_books VALUES (null, '$books[$i]')"); 
     312        } 
    332313        $checkSermonUpload = sb_checkSermonUploadable(); 
    333314        switch ($checkSermonUpload) { 
     
    348329                break; 
    349330            } 
    350         //sb_delete_all_pages(); 
    351     } 
    352     // Rewrite posts/pages if display mode changes (reserved for version 0.40) 
    353     // elseif ($_REQUEST['rewrite']=="true" && ($_REQUEST['method']="page" | $_REQUEST['method']="post")) sb_rewrite_all_pages ($_REQUEST['start']); 
     331    } 
    354332    // Save options 
    355333    elseif ($_POST['save']) { 
     
    358336        if (intval($_POST['perpage']) > 0) update_option('sb_sermons_per_page', $_POST['perpage']); 
    359337        update_option('sb_sermon_upload_dir', $dir); 
    360         update_option('sb_sermon_upload_url', get_bloginfo('url').$dir);         
    361         if (!is_dir($wordpressRealPath.$dir)) { 
    362           if (@mkdir($wordpressRealPath.$dir)) { 
    363              @chmod($wordpressRealPath.$dir, 0777); 
     338        update_option('sb_sermon_upload_url', get_bloginfo('wpurl').$dir);       
     339        if (!is_dir(sb_get_value('wordpress_path').$dir)) { 
     340          if (@mkdir(sb_get_value('wordpress_path').$dir)) { 
     341             @chmod(sb_get_value('wordpress_path').$dir, 0777); 
    364342            } 
    365343        } 
    366         /* Reserved for version 0.40 
    367         $new_display_method = $_REQUEST['displaymethod']; 
    368         if ($display_method != $new_display_method) { 
    369             sb_delete_all_pages(); 
    370             update_option('sb_display_method', $new_display_method); 
    371             $display_method = $new_display_method; 
    372             if ($display_method != "dynamic") { 
    373                 echo "<script>document.location = '$url/wp-admin/admin.php?page=sermon-browser/options.php&rewrite=true&start=0&method={$new_display_method}&mode={$_REQUEST['mode']}';</script>"; 
    374             } else { 
    375                 echo "<script>document.location = '$url/wp-admin/admin.php?page=sermon-browser/options.php';</script>"; 
    376             } 
    377         } 
    378         */ 
    379         if(!is_dir($wordpressRealPath.$dir.'images') && @mkdir($wordpressRealPath.$sermonUploadDir.'images')){ 
    380             @chmod($wordpressRealPath.$dir.'images', 0777); 
     344        if(!is_dir(sb_get_value('wordpress_path').$dir.'images') && @mkdir(sb_get_value('wordpress_path').$sermonUploadDir.'images')){ 
     345            @chmod(sb_get_value('wordpress_path').$dir.'images', 0777); 
    381346        }            
    382347        $checkSermonUpload = sb_checkSermonUploadable(); 
     
    402367    elseif ($_POST['uninstall']) { 
    403368        if ($_POST['wipe'] == 1) { 
    404             $dir = $wordpressRealPath.get_option('sb_sermon_upload_dir'); 
     369            $dir = sb_get_value('wordpress_path').get_option('sb_sermon_upload_dir'); 
    405370            if ($dh = @opendir($dir)) { 
    406371                while (false !== ($file = readdir($dh))) { 
     
    421386        if ($wpdb->get_var("show tables like '$table_name'") == $table_name) $wpdb->query("DROP TABLE $table_name"); 
    422387        $table_name = $wpdb->prefix."sb_stuff"; 
     388        if ($wpdb->get_var("show tables like '$table_name'") == $table_name) $wpdb->query("DROP TABLE $table_name"); 
     389        $table_name = $wpdb->prefix."sb_books"; 
     390        if ($wpdb->get_var("show tables like '$table_name'") == $table_name) $wpdb->query("DROP TABLE $table_name"); 
     391        $table_name = $wpdb->prefix."sb_books_sermons"; 
     392        if ($wpdb->get_var("show tables like '$table_name'") == $table_name) $wpdb->query("DROP TABLE $table_name"); 
     393        $table_name = $wpdb->prefix."sb_sermons_tags"; 
     394        if ($wpdb->get_var("show tables like '$table_name'") == $table_name) $wpdb->query("DROP TABLE $table_name"); 
     395        $table_name = $wpdb->prefix."sb_tags"; 
    423396        if ($wpdb->get_var("show tables like '$table_name'") == $table_name) $wpdb->query("DROP TABLE $table_name"); 
    424397         
     
    468441                <td><?php echo sb_display_url().'?podcast' ?></td> 
    469442            </tr> 
    470             <?php /* Reserved for version 0.40  
    471             <tr> 
    472                 <td align="right" style="vertical-align:middle"><?php _e('Display method', $sermon_domain) ?>: </td> 
    473                 <td><select name="displaymethod" id="displaymethod"> 
    474                     <option value="post" <?php echo $display_method == "post" ? 'selected="selected"' : '' ?>><?php _e("Post for each sermon", $sermon_domain) ?></option> 
    475                     <option value="page" <?php echo $display_method == "page" ? 'selected="selected"' : '' ?>><?php _e("Page for each sermon", $sermon_domain) ?></option> 
    476                     <option value="dynamic" <?php echo $display_method == "dynamic" ? 'selected="selected"' : '' ?>><?php _e("Single dynamic page", $sermon_domain) ?></option> 
    477                     </select> 
    478                 </td> 
    479             </tr> 
    480             */ ?> 
    481443            <tr> 
    482444                <td align="right" style="vertical-align:middle"><?php _e('Sermons per page', $sermon_domain) ?>: </td> 
     
    527489// Display the templates page and handle changes 
    528490function sb_templates () { 
    529     global $wordpressRealPath, $mdict, $sdict, $sermon_domain; 
     491    global $sermon_domain; 
    530492    //Security check 
    531493    if (function_exists('current_user_can')&&!current_user_can('manage_options')) 
     
    544506        update_option('sb_sermon_single_form', base64_encode($single)); 
    545507        update_option('sb_sermon_style', base64_encode($style)); 
    546         update_option('sb_sermon_multi_output', base64_encode(strtr(stripslashes($multi), $mdict))); 
    547         update_option('sb_sermon_single_output', base64_encode(strtr(stripslashes($single), $sdict))); 
     508        update_option('sb_sermon_multi_output', base64_encode(strtr(stripslashes($multi), sb_search_results_dictionary()))); 
     509        update_option('sb_sermon_single_output', base64_encode(strtr(stripslashes($single), sb_sermon_page_dictionary()))); 
    548510        update_option('sb_sermon_style_output', base64_encode(stripslashes($style))); 
    549511        update_option('sb_sermon_style_date_modified', strtotime('now')); 
     
    558520    <div class="wrap"> 
    559521        <h2><?php _e('Templates', $sermon_domain) ?></h2> 
     522        <br/> 
    560523        <table border="0" class="widefat"> 
    561524            <tr> 
    562                 <td align="right"><?php _e('Multi-sermons form', $sermon_domain) ?>: </td> 
     525                <td align="right"><?php _e('Search results page', $sermon_domain) ?>: </td> 
    563526                <td> 
    564527                    <?php sb_build_textarea('multi', get_option('sb_sermon_multi_form')) ?> 
     
    566529            </tr> 
    567530            <tr> 
    568                 <td align="right"><?php _e('Single sermon form', $sermon_domain) ?>: </td> 
     531                <td align="right"><?php _e('Sermon page', $sermon_domain) ?>: </td> 
    569532                <td> 
    570533                    <?php sb_build_textarea('single', get_option('sb_sermon_single_form')) ?> 
     
    593556function sb_manage_preachers() { 
    594557    global $wpdb, $sermon_domain; 
    595     global $wordpressRealPath; 
    596558    //Security check 
    597559    if (function_exists('current_user_can')&&!current_user_can('manage_categories')) 
    598560            wp_die(__("You do not have the correct permissions to manage the preachers' database", $sermon_domain)); 
    599     $url = get_bloginfo('wpurl'); 
    600561    if ($_GET['saved']) { 
    601562        echo '<div id="message" class="updated fade"><p><b>'.__('Preacher saved to database.', $sermon_domain).'</b></div>'; 
     
    615576            $prefix = ''; 
    616577            $sermonUploadDir = get_option('sb_sermon_upload_dir'); 
    617             if(!is_dir($wordpressRealPath.$sermonUploadDir.'images') && @mkdir($wordpressRealPath.$sermonUploadDir.'images')){ 
    618                 @chmod($wordpressRealPath.$sermonUploadDir.'images', 0777); 
    619             } 
    620             $dest = $wordpressRealPath.$sermonUploadDir.'images/'.$filename; 
     578            if(!is_dir(sb_get_value('wordpress_path').$sermonUploadDir.'images') && @mkdir(sb_get_value('wordpress_path').$sermonUploadDir.'images')){ 
     579                @chmod(sb_get_value('wordpress_path').$sermonUploadDir.'images', 0777); 
     580            } 
     581            $dest = sb_get_value('wordpress_path').$sermonUploadDir.'images/'.$filename; 
    621582            if (@move_uploaded_file($_FILES['upload']['tmp_name'], $dest)) { 
    622583                $filename = $prefix.mysql_real_escape_string($filename); 
     
    624585                $error = true; 
    625586                echo '<div id="message" class="updated fade"><p><b>'.__('Could not save uploaded file. Please try again.', $sermon_domain).'</b></div>'; 
    626                 @chmod($wordpressRealPath.$sermonUploadDir.'images', 0777); 
     587                @chmod(sb_get_value('wordpress_path').$sermonUploadDir.'images', 0777); 
    627588            } 
    628589        } else { 
     
    636597            $wpdb->query("UPDATE {$wpdb->prefix}sb_preachers SET name = '$name', description = '$description', image = '$filename' WHERE id = $pid"); 
    637598            if ($_POST['old'] != $filename) { 
    638                 @unlink($wordpressRealPath.get_option('sb_sermon_upload_dir').'images/'.mysql_real_escape_string($_POST['old'])); 
     599                @unlink(sb_get_value('wordpress_path').get_option('sb_sermon_upload_dir').'images/'.mysql_real_escape_string($_POST['old'])); 
    639600            }            
    640601        } 
    641602        if(isset($_POST['remove'])){ 
    642603            $wpdb->query("UPDATE {$wpdb->prefix}sb_preachers SET name = '$name', description = '$description', image = '' WHERE id = $pid"); 
    643             @unlink($wordpressRealPath.get_option('sb_sermon_upload_dir').'images/'.mysql_real_escape_string($_POST['old'])); 
    644         } 
    645         if(!$error) echo "<script>document.location = '$url/wp-admin/admin.php?page=sermon-browser/preachers.php&saved=true';</script>"; 
     604            @unlink(sb_get_value('wordpress_path').get_option('sb_sermon_upload_dir').'images/'.mysql_real_escape_string($_POST['old'])); 
     605        } 
     606        if(!$error) echo "<script>document.location = '".sb_get_value('wordpress_url')."/wp-admin/admin.php?page=sermon-browser/preachers.php&saved=true';</script>"; 
    646607    } 
    647608     
     
    652613        }else { 
    653614            $p = $wpdb->get_row("SELECT image FROM {$wpdb->prefix}sb_preachers WHERE id = $die"); 
    654             @unlink($wordpressRealPath.get_option('sb_sermon_upload_dir').'images/'.$p->image); 
     615            @unlink(sb_get_value('wordpress_path').get_option('sb_sermon_upload_dir').'images/'.$p->image); 
    655616            $wpdb->query("DELETE FROM {$wpdb->prefix}sb_preachers WHERE id = $die"); 
    656617        } 
     
    668629            $checkSermonUpload = sb_checkSermonUploadable('images/'); 
    669630            if ($checkSermonUpload == 'notexist') { 
    670                 if(!is_dir($wordpressRealPath.$sermonUploadDir.'images') && @mkdir($wordpressRealPath.$sermonUploadDir.'images')){ 
    671                     @chmod($wordpressRealPath.$sermonUploadDir.'images', 0777); 
     631                if(!is_dir(sb_get_value('wordpress_path').$sermonUploadDir.'images') && @mkdir(sb_get_value('wordpress_path').$sermonUploadDir.'images')){ 
     632                    @chmod(sb_get_value('wordpress_path').$sermonUploadDir.'images', 0777); 
    672633                } 
    673634                $checkSermonUpload = sb_checkSermonUploadable('images/'); 
     
    700661                    <td> 
    701662                        <?php if ($_GET['act'] == 'edit'): ?> 
    702                         <div><img src="<?php echo $url ?><?php echo get_option('sb_sermon_upload_dir').'images/'.$preacher->image ?>"></div> 
     663                        <div><img src="<?php echo sb_get_value('wordpress_url') ?><?php echo get_option('sb_sermon_upload_dir').'images/'.$preacher->image ?>"></div> 
    703664                        <input type="hidden" name="old" value="<?php echo $preacher->image ?>"> 
    704665                        <?php endif ?> 
     
    722683?> 
    723684    <div class="wrap"> 
    724         <h2><?php _e('Preachers', $sermon_domain) ?> (<a href="<?php echo $url ?>/wp-admin/admin.php?page=sermon-browser/preachers.php&act=new"><?php _e('add new', $sermon_domain) ?></a>)</h2> 
     685        <h2><?php _e('Preachers', $sermon_domain) ?> (<a href="<?php echo sb_get_value('wordpress_url') ?>/wp-admin/admin.php?page=sermon-browser/preachers.php&act=new"><?php _e('add new', $sermon_domain) ?></a>)</h2> 
     686        <br> 
    725687        <table class="widefat"> 
    726688            <thead> 
     
    737699                        <td><?php echo $preacher->id ?></td> 
    738700                        <td><?php echo stripslashes($preacher->name) ?></td> 
    739                         <td><img src="<?php echo empty($preacher->image) ? '' : $url.get_option('sb_sermon_upload_dir').'images/'.$preacher->image ?>"></td> 
     701                        <td><img src="<?php echo empty($preacher->image) ? '' : sb_get_value('wordpress_url').get_option('sb_sermon_upload_dir').'images/'.$preacher->image ?>"></td> 
    740702                        <td align="center"> 
    741                             <a href="<?php echo $url ?>/wp-admin/admin.php?page=sermon-browser/preachers.php&act=edit&pid=<?php echo $preacher->id ?>"><?php _e('Edit', $sermon_domain) ?></a> | <a onclick="return confirm('Are you sure?')" href="<?php echo $url ?>/wp-admin/admin.php?page=sermon-browser/preachers.php&act=kill&pid=<?php echo $preacher->id ?>"><?php _e('Delete', $sermon_domain) ?></a> 
     703                            <a href="<?php echo sb_get_value('wordpress_url') ?>/wp-admin/admin.php?page=sermon-browser/preachers.php&act=edit&pid=<?php echo $preacher->id ?>"><?php _e('Edit', $sermon_domain) ?></a> | <a onclick="return confirm('Are you sure?')" href="<?php echo sb_get_value('wordpress_url') ?>/wp-admin/admin.php?page=sermon-browser/preachers.php&act=kill&pid=<?php echo $preacher->id ?>"><?php _e('Delete', $sermon_domain) ?></a> 
    742704                        </td> 
    743705                    </tr> 
     
    755717    if (function_exists('current_user_can')&&!current_user_can('manage_categories')) 
    756718            wp_die(__("You do not have the correct permissions to manage the series and services database", $sermon_domain)); 
    757      
    758     $url = get_bloginfo('wpurl'); 
    759719     
    760720    $series = $wpdb->get_results("SELECT ss.*, m.id AS mid FROM {$wpdb->prefix}sb_series AS ss LEFT OUTER JOIN {$wpdb->prefix}sb_sermons AS m ON ss.id = m.series_id ORDER BY ss.name asc");     
     
    767727    sb_check_sermon_tag(); 
    768728?> 
    769     <script type="text/javascript" src="<?php echo $url ?>/wp-includes/js/jquery/jquery.js"></script> 
    770     <script type="text/javascript" src="<?php echo $url ?>/wp-includes/js/fat.js"></script> 
     729    <script type="text/javascript" src="<?php echo sb_get_value('wordpress_url') ?>/wp-includes/js/jquery/jquery.js"></script> 
     730    <script type="text/javascript" src="<?php echo sb_get_value('wordpress_url') ?>/wp-includes/js/fat.js"></script> 
    771731    <script type="text/javascript"> 
    772732        //<![CDATA[ 
     
    786746            } 
    787747            if (s != null) { 
    788                 jQuery.post('<?php echo $url ?>/wp-admin/admin.php?page=sermon-browser/sermon.php', {sname: s, sermon: 1}, function(r) {                 
     748                jQuery.post('<?php echo sb_get_value('wordpress_url') ?>/wp-admin/admin.php?page=sermon-browser/sermon.php', {sname: s, sermon: 1}, function(r) {                
    789749                    if (r) { 
    790750                        sz = s.match(/(.*?)@(.*)/)[1]; 
     
    810770            var ss = prompt("New series' name?", "Series' name"); 
    811771            if (ss != null) { 
    812                 jQuery.post('<?php echo $url ?>/wp-admin/admin.php?page=sermon-browser/sermon.php', {ssname: ss, sermon: 1}, function(r) { 
     772                jQuery.post('<?php echo sb_get_value('wordpress_url') ?>/wp-admin/admin.php?page=sermon-browser/sermon.php', {ssname: ss, sermon: 1}, function(r) { 
    813773                    if (r) { 
    814774                        jQuery('#Series-list').append('\ 
     
    829789        } 
    830790        function deleteSeries(id) { 
    831             jQuery.post('<?php echo $url ?>/wp-admin/admin.php?page=sermon-browser/sermon.php', {ssname: 'dummy', ssid: id, del: 1, sermon: 1}, function(r) { 
     791            jQuery.post('<?php echo sb_get_value('wordpress_url') ?>/wp-admin/admin.php?page=sermon-browser/sermon.php', {ssname: 'dummy', ssid: id, del: 1, sermon: 1}, function(r) { 
    832792                if (r) { 
    833793                    jQuery('#rowSeries' + id).fadeOut(function() { 
     
    838798        } 
    839799        function deleteServices(id) { 
    840             jQuery.post('<?php echo $url ?>/wp-admin/admin.php?page=sermon-browser/sermon.php', {sname: 'dummy', sid: id, del: 1, sermon: 1}, function(r) { 
     800            jQuery.post('<?php echo sb_get_value('wordpress_url') ?>/wp-admin/admin.php?page=sermon-browser/sermon.php', {sname: 'dummy', sid: id, del: 1, sermon: 1}, function(r) { 
    841801                if (r) { 
    842802                    jQuery('#rowServices' + id).fadeOut(function() { 
     
    849809            var ss = prompt("New series' name?", old); 
    850810            if (ss != null) { 
    851                 jQuery.post('<?php echo $url ?>/wp-admin/admin.php?page=sermon-browser/sermon.php', {ssid: id, ssname: ss, sermon: 1}, function(r) { 
     811                jQuery.post('<?php echo sb_get_value('wordpress_url') ?>/wp-admin/admin.php?page=sermon-browser/sermon.php', {ssid: id, ssname: ss, sermon: 1}, function(r) { 
    852812                    if (r) { 
    853813                        jQuery('#Series' + id).text(ss); 
     
    865825            } 
    866826            if (s != null) { 
    867                 jQuery.post('<?php echo $url ?>/wp-admin/admin.php?page=sermon-browser/sermon.php', {sid: id, sname: s, sermon: 1}, function(r) { 
     827                jQuery.post('<?php echo sb_get_value('wordpress_url') ?>/wp-admin/admin.php?page=sermon-browser/sermon.php', {sid: id, sname: s, sermon: 1}, function(r) { 
    868828                    if (r) { 
    869829                        sz = s.match(/(.*?)@(.*)/)[1]; 
     
    936896// Display upload page and handle changes 
    937897function sb_uploads() { 
    938     global $wpdb, $filetypes, $sermon_domain, $sermons_per_page; 
    939     global $wordpressRealPath; 
     898    global $wpdb, $filetypes, $sermon_domain; 
    940899    //Security check 
    941900    if (function_exists('current_user_can')&&!current_user_can('upload_files')) 
     
    944903    sb_scan_dir(); 
    945904     
    946     $url = get_bloginfo('wpurl'); 
    947      
    948905    if ($_POST['save']) { 
    949906        if ($_FILES['upload']['error'] == UPLOAD_ERR_OK) { 
    950907            $filename = basename($_FILES['upload']['name']); 
    951908            $prefix = ''; 
    952             $dest = $wordpressRealPath.get_option('sb_sermon_upload_dir').$prefix.$filename; 
     909            $dest = sb_get_value('wordpress_path').get_option('sb_sermon_upload_dir').$prefix.$filename; 
    953910            if($wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->prefix}sb_stuff WHERE name = '$filename'") == 0) { 
    954911                if (move_uploaded_file($_FILES['upload']['tmp_name'], $dest)) { 
     
    964921    }    
    965922     
    966     $unlinked = $wpdb->get_results("SELECT f.*, s.title FROM {$wpdb->prefix}sb_stuff AS f LEFT JOIN {$wpdb->prefix}sb_sermons AS s ON f.sermon_id = s.id WHERE f.sermon_id = 0 AND f.type = 'file' ORDER BY f.name LIMIT 0, {$sermons_per_page};"); 
    967     $linked = $wpdb->get_results("SELECT f.*, s.title FROM {$wpdb->prefix}sb_stuff AS f LEFT JOIN {$wpdb->prefix}sb_sermons AS s ON f.sermon_id = s.id WHERE f.sermon_id <> 0 AND f.type = 'file' ORDER BY f.name LIMIT 0, {$sermons_per_page};"); 
     923    $unlinked = $wpdb->get_results("SELECT f.*, s.title FROM {$wpdb->prefix}sb_stuff AS f LEFT JOIN {$wpdb->prefix}sb_sermons AS s ON f.sermon_id = s.id WHERE f.sermon_id = 0 AND f.type = 'file' ORDER BY f.name LIMIT 0, ".sb_get_value('sermons_per_page')); 
     924    $linked = $wpdb->get_results("SELECT f.*, s.title FROM {$wpdb->prefix}sb_stuff AS f LEFT JOIN {$wpdb->prefix}sb_sermons AS s ON f.sermon_id = s.id WHERE f.sermon_id <> 0 AND f.type = 'file' ORDER BY f.name LIMIT 0, ".sb_get_value('sermons_per_page')); 
    968925     
    969926    //Removes missing attachments from the database 
     
    973930        $wanted = array(-1); 
    974931        foreach ((array) $unlinked as $k => $file) { 
    975             if (!file_exists($wordpressRealPath.get_option('sb_sermon_upload_dir').$file->name)) { 
     932            if (!file_exists(sb_get_value('wordpress_path').get_option('sb_sermon_upload_dir').$file->name)) { 
    976933                $wanted[] = $file->id; 
    977934                unset($unlinked[$k]); 
     
    979936        } 
    980937        foreach ((array) $linked as $k => $file) {       
    981             if (!file_exists($wordpressRealPath.get_option('sb_sermon_upload_dir').$file->name)) {           
     938            if (!file_exists(sb_get_value('wordpress_path').get_option('sb_sermon_upload_dir').$file->name)) {           
    982939                $wanted[] = $file->id; 
    983940                unset($unlinked[$k]); 
     
    993950    sb_check_sermon_tag(); 
    994951?> 
    995     <script type="text/javascript" src="<?php echo $url ?>/wp-includes/js/jquery/jquery.js"></script> 
    996     <script type="text/javascript" src="<?php echo $url ?>/wp-includes/js/fat.js"></script> 
     952    <script type="text/javascript" src="<?php echo sb_get_value('wordpress_url') ?>/wp-includes/js/jquery/jquery.js"></script> 
     953    <script type="text/javascript" src="<?php echo sb_get_value('wordpress_url') ?>/wp-includes/js/fat.js"></script> 
    997954    <script> 
    998955        function rename(id, old) { 
    999956            var f = prompt("<?php _e('New file name?', $sermon_domain) ?>", old); 
    1000957            if (f != null) { 
    1001                 jQuery.post('<?php echo $url ?>/wp-admin/admin.php?page=sermon-browser/uploads.php', {fid: id, oname: old, fname: f, sermon: 1}, function(r) { 
     958                jQuery.post('<?php echo sb_get_value('wordpress_url') ?>/wp-admin/admin.php?page=sermon-browser/uploads.php', {fid: id, oname: old, fname: f, sermon: 1}, function(r) { 
    1002959                    if (r) { 
    1003960                        if (r == 'renamed') { 
     
    1016973        } 
    1017974        function kill(id, f) { 
    1018             jQuery.post('<?php echo $url ?>/wp-admin/admin.php?page=sermon-browser/uploads.php', {fname: f, fid: id, del: 1, sermon: 1}, function(r) { 
     975            jQuery.post('<?php echo sb_get_value('wordpress_url') ?>/wp-admin/admin.php?page=sermon-browser/uploads.php', {fname: f, fid: id, del: 1, sermon: 1}, function(r) { 
    1019976                if (r) { 
    1020977                    if (r == 'deleted') { 
     
    1042999        } 
    10431000        function fetchU(st) { 
    1044             jQuery.post('<?php echo $url ?>/wp-admin/admin.php?page=sermon-browser/uploads.php', {fetchU: st + 1, sermon: 1}, function(r) { 
     1001            jQuery.post('<?php echo sb_get_value('wordpress_url') ?>/wp-admin/admin.php?page=sermon-browser/uploads.php', {fetchU: st + 1, sermon: 1}, function(r) { 
    10451002                if (r) { 
    10461003                    jQuery('#the-list-u').html(r);                   
    1047                     if (st >= <?php echo $sermons_per_page ?>) { 
    1048                         x = st - <?php echo $sermons_per_page ?>; 
     1004                    if (st >= <?php echo sb_get_value('sermons_per_page') ?>) { 
     1005                        x = st - <?php echo sb_get_value('sermons_per_page') ?>; 
    10491006                        jQuery('#uleft').html('<a href="javascript:fetchU(' + x + ')">&laquo; <?php _e('Previous', $sermon_domain) ?></a>'); 
    10501007                    } else { 
    10511008                        jQuery('#uleft').html(''); 
    10521009                    } 
    1053                     if (st + <?php echo $sermons_per_page ?> <= <?php echo $cntu ?>) { 
    1054                         y = st + <?php echo $sermons_per_page ?>; 
     1010                    if (st + <?php echo sb_get_value('sermons_per_page') ?> <= <?php echo $cntu ?>) { 
     1011                        y = st + <?php echo sb_get_value('sermons_per_page') ?>; 
    10551012                        jQuery('#uright').html('<a href="javascript:fetchU(' + y + ')"><?php _e('Next', $sermon_domain) ?> &raquo;</a>'); 
    10561013                    } else { 
     
    10611018        } 
    10621019        function fetchL(st) { 
    1063             jQuery.post('<?php echo $url ?>/wp-admin/admin.php?page=sermon-browser/uploads.php', {fetchL: st + 1, sermon: 1}, function(r) { 
     1020            jQuery.post('<?php echo sb_get_value('wordpress_url') ?>/wp-admin/admin.php?page=sermon-browser/uploads.php', {fetchL: st + 1, sermon: 1}, function(r) { 
    10641021                if (r) { 
    10651022                    jQuery('#the-list-l').html(r);                   
    1066                     if (st >= <?php echo $sermons_per_page ?>) { 
    1067                         x = st - <?php echo $sermons_per_page ?>; 
     1023                    if (st >= <?php echo sb_get_value('sermons_per_page') ?>) { 
     1024                        x = st - <?php echo sb_get_value('sermons_per_page') ?>; 
    10681025                        jQuery('#left').html('<a href="javascript:fetchL(' + x + ')">&laquo; <?php _e('Previous', $sermon_domain) ?></a>'); 
    10691026                    } else { 
    10701027                        jQuery('#left').html(''); 
    10711028                    } 
    1072                     if (st + <?php echo $sermons_per_page ?> <= <?php echo $cntl ?>) { 
    1073                         y = st + <?php echo $sermons_per_page ?>; 
     1029                    if (st + <?php echo sb_get_value('sermons_per_page') ?> <= <?php echo $cntl ?>) { 
     1030                        y = st + <?php echo sb_get_value('sermons_per_page') ?>; 
    10741031                        jQuery('#right').html('<a href="javascript:fetchL(' + y + ')"><?php _e('Next', $sermon_domain) ?> &raquo;</a>'); 
    10751032                    } else { 
     
    10801037        } 
    10811038        function findNow() { 
    1082             jQuery.post('<?php echo $url ?>/wp-admin/admin.php?page=sermon-browser/uploads.php', {search: jQuery('#search').val(), sermon: 1}, function(r) { 
     1039            jQuery.post('<?php echo sb_get_value('wordpress_url') ?>/wp-admin/admin.php?page=sermon-browser/uploads.php', {search: jQuery('#search').val(), sermon: 1}, function(r) { 
    10831040                if (r) { 
    10841041                    jQuery('#the-list-s').html(r);                                       
     
    12221179    </div> 
    12231180    <script> 
    1224         <?php if ($cntu > $sermons_per_page): ?> 
    1225             jQuery('#uright').html('<a href="javascript:fetchU(<?php echo $sermons_per_page ?>)">Next &raquo;</a>'); 
     1181        <?php if ($cntu > sb_get_value('sermons_per_page')): ?> 
     1182            jQuery('#uright').html('<a href="javascript:fetchU(<?php echo sb_get_value('sermons_per_page') ?>)">Next &raquo;</a>'); 
    12261183        <?php endif ?> 
    1227         <?php if ($cntl > $sermons_per_page): ?> 
    1228             jQuery('#right').html('<a href="javascript:fetchL(<?php echo $sermons_per_page ?>)">Next &raquo;</a>'); 
     1184        <?php if ($cntl > sb_get_value('sermons_per_page')): ?> 
     1185            jQuery('#right').html('<a href="javascript:fetchL(<?php echo sb_get_value('sermons_per_page') ?>)">Next &raquo;</a>'); 
    12291186        <?php endif ?> 
    12301187    </script> 
     
    12431200} 
    12441201 
    1245 //Count download stats for sermon 
    1246 function sb_sermon_stats($sermonid) { 
    1247     global $wpdb; 
    1248     $stats = $wpdb->get_var("SELECT SUM(count) FROM ".$wpdb->prefix."sb_stuff WHERE sermon_id=".$sermonid); 
    1249     if ($stats > 0) return $stats; 
    1250 } 
    1251  
    12521202// Displays Sermons page 
    12531203function sb_manage_sermons() { 
    1254     global $wpdb, $sermon_domain, $sermons_per_page; 
     1204    global $wpdb, $sermon_domain; 
    12551205    //Security check 
    12561206    if (function_exists('current_user_can')&&!(current_user_can('edit_posts')|current_user_can('publish_posts'))) 
    12571207        wp_die(__("You do not have the correct permissions to edit sermons", $sermon_domain)); 
    1258     $url = get_bloginfo('wpurl'); 
    12591208    sb_check_sermon_tag(); 
    12601209    if ($_GET['saved']) { 
     
    12781227    $cnt = $cnt['COUNT(*)'];         
    12791228             
    1280     $sermons = $wpdb->get_results("SELECT m.id, m.title, m.date, p.name as pname, s.name as sname, ss.name as ssname FROM {$wpdb->prefix}sb_sermons as m, {$wpdb->prefix}sb_preachers as p, {$wpdb->prefix}sb_services as s, {$wpdb->prefix}sb_series as ss where (m.preacher_id = p.id and m.service_id = s.id and m.series_id = ss.id) ORDER BY m.date desc, s.time desc LIMIT 0, {$sermons_per_page};");  
     1229    $sermons = $wpdb->get_results("SELECT m.id, m.title, m.date, p.name as pname, s.name as sname, ss.name as ssname FROM {$wpdb->prefix}sb_sermons as m, {$wpdb->prefix}sb_preachers as p, {$wpdb->prefix}sb_services as s, {$wpdb->prefix}sb_series as ss where (m.preacher_id = p.id and m.service_id = s.id and m.series_id = ss.id) ORDER BY m.date desc, s.time desc LIMIT 0, ".sb_get_value('sermons_per_page')); 
    12811230    $preachers = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}sb_preachers ORDER BY name;");     
    12821231    $series = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}sb_series ORDER BY name;"); 
    12831232?>   
    1284     <script type="text/javascript" src="<?php echo $url ?>/wp-includes/js/jquery/jquery.js"></script> 
     1233    <script type="text/javascript" src="<?php echo sb_get_value('wordpress_url') ?>/wp-includes/js/jquery/jquery.js"></script> 
    12851234    <script> 
    12861235        function fetch(st) { 
    1287             jQuery.post('<?php echo $url ?>/wp-admin/admin.php?page=sermon-browser/sermon.php', {fetch: st + 1, sermon: 1, title: jQuery('#search').val(), preacher: jQuery('#preacher option[@selected]').val(), series: jQuery('#series option[@selected]').val() }, function(r) { 
     1236            jQuery.post('<?php echo sb_get_value('wordpress_url') ?>/wp-admin/admin.php?page=sermon-browser/sermon.php', {fetch: st + 1, sermon: 1, title: jQuery('#search').val(), preacher: jQuery('#preacher option[@selected]').val(), series: jQuery('#series option[@selected]').val() }, function(r) { 
    12881237                if (r) { 
    12891238                    jQuery('#the-list').html(r);                     
    1290                     if (st >= <?php echo $sermons_per_page ?>) { 
    1291                         x = st - <?php echo $sermons_per_page ?>; 
     1239                    if (st >= <?php echo sb_get_value('sermons_per_page') ?>) { 
     1240                        x = st - <?php echo sb_get_value('sermons_per_page') ?>; 
    12921241                        jQuery('#left').html('<a href="javascript:fetch(' + x + ')">&laquo; Previous</a>'); 
    12931242                    } else { 
    12941243                        jQuery('#left').html(''); 
    12951244                    } 
    1296                     if (st + <?php echo $sermons_per_page ?> <= <?php echo $cnt ?>) { 
    1297                         y = st + <?php echo $sermons_per_page ?>; 
     1245                    if (st + <?php echo sb_get_value('sermons_per_page') ?> <= <?php echo $cnt ?>) { 
     1246                        y = st + <?php echo sb_get_value('sermons_per_page') ?>; 
    12981247                        jQuery('#right').html('<a href="javascript:fetch(' + y + ')">Next &raquo;</a>'); 
    12991248                    } else { 
     
    13611310                            <?php //Security check 
    13621311                                    if (function_exists('current_user_can')&&current_user_can('edit_posts')) { ?> 
    1363                                     <a href="<?php echo $url ?>/wp-admin/admin.php?page=sermon-browser/new_sermon.php&mid=<?php echo $sermon->id ?>"><?php _e('Edit', $sermon_domain) ?></a> | <a onclick="return confirm('Are you sure?')" href="<?php echo $url ?>/wp-admin/admin.php?page=sermon-browser/sermon.php&mid=<?php echo $sermon->id ?>"><?php _e('Delete', $sermon_domain); ?></a> 
     1312                                    <a href="<?php echo sb_get_value('wordpress_url') ?>/wp-admin/admin.php?page=sermon-browser/new_sermon.php&mid=<?php echo $sermon->id ?>"><?php _e('Edit', $sermon_domain) ?></a> | <a onclick="return confirm('Are you sure?')" href="<?php echo sb_get_value('wordpress_url') ?>/wp-admin/admin.php?page=sermon-browser/sermon.php&mid=<?php echo $sermon->id ?>"><?php _e('Delete', $sermon_domain); ?></a> 
    13641313                            <?php } else { ?>&nbsp;<?php } ?> 
    13651314                        </td> 
     
    13751324    </div>   
    13761325    <script> 
    1377         <?php if ($cnt > $sermons_per_page): ?> 
    1378             jQuery('#right').html('<a href="javascript:fetch(<?php echo $sermons_per_page ?>)">Next &raquo;</a>'); 
     1326        <?php if ($cnt > sb_get_value('sermons_per_page')): ?> 
     1327            jQuery('#right').html('<a href="javascript:fetch(<?php echo sb_get_value('sermons_per_page') ?>)">Next &raquo;</a>'); 
    13791328        <?php endif ?> 
    13801329    </script> 
     
    13841333// Displays new/edit sermon page 
    13851334function sb_new_sermon() { 
    1386     global $wpdb, $books, $sermon_domain; 
    1387     global $wordpressRealPath, $allowedposttags; 
     1335    global $wpdb, $sermon_domain; 
     1336    global $allowedposttags; 
    13881337    //Security check 
    13891338    if (function_exists('current_user_can')&&!(current_user_can('edit_posts')|current_user_can('publish_posts'))) 
    13901339        wp_die(__("You do not have the correct permissions to edit or create sermons", $sermon_domain)); 
    1391     include_once ($wordpressRealPath.'/wp-includes/kses.php'); 
     1340    include_once (sb_get_value('wordpress_path').'/wp-includes/kses.php'); 
    13921341    // sync 
    13931342    sb_scan_dir(); 
    1394      
    1395     $url = get_bloginfo('wpurl'); 
    13961343 
    13971344    if ($_POST['save'] && $_POST['title']) {         
     
    14021349        $series_id = (int) $_POST['series']; 
    14031350        $time = mysql_real_escape_string($_POST['time']); 
    1404         for ($foo = 0; $foo < count($_POST['start']); $foo++) {  
     1351        for ($foo = 0; $foo < count($_POST['start']['book']); $foo++) {  
    14051352            if (!empty($_POST['start']['chapter'][$foo]) && !empty($_POST['end']['chapter'][$foo]) && !empty($_POST['start']['verse'][$foo]) && !empty($_POST['end']['verse'][$foo])) { 
    14061353                $startz[] = array( 
     
    14551402                $filename = basename($_FILES['upload']['name'][$uid]); 
    14561403                $prefix = ''; 
    1457                 $dest = $wordpressRealPath.get_option('sb_sermon_upload_dir').$prefix.$filename; 
     1404                $dest = sb_get_value('wordpress_path').get_option('sb_sermon_upload_dir').$prefix.$filename; 
    14581405                if ($wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->prefix}sb_stuff WHERE name = '$filename'") == 0 && move_uploaded_file($_FILES['upload']['tmp_name'][$uid], $dest)) { 
    14591406                    $filename = $prefix.mysql_real_escape_string($filename); 
     
    14921439        } 
    14931440        // everything is fine, get out of here! 
    1494         if(!$error) echo "<script>document.location = '$url/wp-admin/admin.php?page=sermon-browser/sermon.php&saved=true';</script>"; 
     1441        if(!$error) echo "<script>document.location = '".sb_get_value('wordpress_url')."/wp-admin/admin.php?page=sermon-browser/sermon.php&saved=true';</script>"; 
    14951442    }        
    14961443     
     
    15041451    $wanted[] = -1; 
    15051452    foreach ((array) $files as $k => $file) { 
    1506         if (!file_exists($wordpressRealPath.get_option('sb_sermon_upload_dir').$file->name)) { 
     1453        if (!file_exists(sb_get_value('wordpress_path').get_option('sb_sermon_upload_dir').$file->name)) { 
    15071454            $wanted[] = $file->id; 
    15081455            unset($files[$k]); 
     
    15331480        $tags = implode(', ', (array) $tags); 
    15341481    } 
     1482    $books = sb_get_value('bible_books'); 
    15351483?> 
    1536     <link rel="stylesheet" href="<?php echo $url ?>/wp-content/plugins/sermon-browser/style.php" type="text/css"> 
    1537     <link rel="stylesheet" href="<?php echo $url ?>/wp-content/plugins/sermon-browser/datepicker.css" type="text/css"> 
    1538     <script type="text/javascript" src="<?php echo $url ?>/wp-includes/js/jquery/jquery.js"></script> 
    1539     <script type="text/javascript" src="<?php echo $url ?>/wp-content/plugins/sermon-browser/datePicker.js"></script> 
    1540     <script type="text/javascript" src="<?php echo $url ?>/wp-content/plugins/sermon-browser/64.js"></script> 
     1484    <link rel="stylesheet" href="<?php echo sb_get_value('plugin_url') ?>/style.php" type="text/css"> 
     1485    <link rel="stylesheet" href="<?php echo sb_get_value('plugin_url') ?>/datepicker.css" type="text/css"> 
     1486    <script type="text/javascript" src="<?php echo sb_get_value('wordpress_url') ?>/wp-includes/js/jquery/jquery.js"></script> 
     1487    <script type="text/javascript" src="<?php echo sb_get_value('plugin_url') ?>/datePicker.js"></script> 
     1488    <script type="text/javascript" src="<?php echo sb_get_value('plugin_url') ?>/64.js"></script> 
    15411489    <script type="text/javascript">      
    15421490        var timeArr = new Array(); 
     
    15461494            var p = prompt("New preacher's name?", "Preacher's name"); 
    15471495            if (p != null) { 
    1548                 jQuery.post('<?php echo $url ?>/wp-admin/admin.php?page=sermon-browser/sermon.php', {pname: p, sermon: 1}, function(r) { 
     1496                jQuery.post('<?php echo sb_get_value('wordpress_url') ?>/wp-admin/admin.php?page=sermon-browser/sermon.php', {pname: p, sermon: 1}, function(r) { 
    15491497                    if (r) { 
    15501498                        jQuery('#preacher option:first').before('<option value="' + r + '">' + p + '</option>'); 
     
    15671515            } 
    15681516            if (s != null) { 
    1569                 jQuery.post('<?php echo $url ?>/wp-admin/admin.php?page=sermon-browser/sermon.php', {sname: s, sermon: 1}, function(r) { 
     1517                jQuery.post('<?php echo sb_get_value('wordpress_url') ?>/wp-admin/admin.php?page=sermon-browser/sermon.php', {sname: s, sermon: 1}, function(r) { 
    15701518                    if (r) { 
    15711519                        jQuery('#service option:first').before('<option value="' + r + '">' + s.match(/(.*?)@/)[1] + '</option>');   
     
    15801528            var ss = prompt("New series' name?", "Series' name"); 
    15811529            if (ss != null) { 
    1582                 jQuery.post('<?php echo $url ?>/wp-admin/admin.php?page=sermon-browser/sermon.php', {ssname: ss, sermon: 1}, function(r) { 
     1530                jQuery.post('<?php echo sb_get_value('wordpress_url') ?>/wp-admin/admin.php?page=sermon-browser/sermon.php', {ssname: ss, sermon: 1}, function(r) { 
    15831531                    if (r) { 
    15841532                        jQuery('#series option:first').before('<option value="' + r + '">' + ss + '</option>');          
     
    16471595    <div class="wrap"> 
    16481596        <h2><?php echo $_GET['mid'] ? 'Edit Sermon' : 'Add Sermon' ?></h2> 
     1597        <br> 
    16491598        <form method="post" enctype="multipart/form-data"> 
    16501599        <fieldset> 
     
    19201869} 
    19211870 
    1922 // Find new files uploaded by FTP 
    1923 function sb_scan_dir() { 
    1924     global $wpdb; 
    1925     global $wordpressRealPath; 
    1926      
    1927     $files = $wpdb->get_results("SELECT name FROM {$wpdb->prefix}sb_stuff WHERE type = 'file';"); 
    1928     $bnn = array(); 
    1929     foreach ($files as $file) { 
    1930         $bnn[] = $file->name; 
    1931     } 
    1932      
    1933     $dir = $wordpressRealPath.get_option('sb_sermon_upload_dir');    
    1934     if ($dh = @opendir($dir)) { 
    1935         while (false !== ($file = readdir($dh))) { 
    1936             if ($file != "." && $file != ".." && !is_dir($dir.$file) && !in_array($file, $bnn)) {                
    1937                 $wpdb->query("INSERT INTO {$wpdb->prefix}sb_stuff VALUES (null, 'file', '$file', 0, 0);"); 
    1938             }    
    1939         } 
    1940         closedir($dh); 
    1941     } 
    1942 } 
    1943  
    1944 // Check to see if upload folder is writeable 
    1945 function sb_checkSermonUploadable($foldername = "") { 
    1946     global $wordpressRealPath; 
    1947     $sermonUploadDir = $wordpressRealPath.get_option('sb_sermon_upload_dir').$foldername; 
    1948     if (is_dir($sermonUploadDir)) { 
    1949         //Dir exist 
    1950         $fp = @fopen($sermonUploadDir.'sermontest.txt', 'w'); 
    1951         if ($fp) { 
    1952             //Delete this test file 
    1953             fclose($fp); 
    1954             unset($fp); 
    1955             @unlink($sermonUploadDir.'sermontest.txt'); 
    1956             return 'writeable';          
    1957         } else { 
    1958             return 'unwriteable'; 
    1959         } 
    1960     } else { 
    1961         return 'notexist'; 
    1962     } 
    1963     return false; 
    1964 } 
    1965  
    19661871// Displays the help page 
    19671872function sb_help() { 
     
    21152020} 
    21162021 
    2117 // Returns data for ajax calls 
     2022/*************************************** 
     2023 ** Data handler for Ajax calls       ** 
     2024 **************************************/ 
     2025 
    21182026function sb_return_ajax_data () { 
    21192027    // Throughout this plugin, p stands for preacher, s stands for service and ss stands for series 
    2120     global $wpdb, $sermons_per_page; 
     2028    global $wpdb; 
    21212029    if ($_POST['pname']) { // preacher 
    21222030        $pname = mysql_real_escape_string($_POST['pname']); 
     
    21712079            $oname = mysql_real_escape_string($_POST['oname']);          
    21722080            if ($_POST['del']) { 
    2173                 if (!file_exists($wordpressRealPath.get_option('sb_sermon_upload_dir').$fname) || unlink($wordpressRealPath.get_option('sb_sermon_upload_dir').$fname)) { 
     2081                if (!file_exists(sb_get_value('wordpress_path').get_option('sb_sermon_upload_dir').$fname) || unlink(sb_get_value('wordpress_path').get_option('sb_sermon_upload_dir').$fname)) { 
    21742082                    $wpdb->query("DELETE FROM {$wpdb->prefix}sb_stuff WHERE id = $fid;"); 
    21752083                    echo 'deleted'; 
     
    21792087            } else {                 
    21802088                $oname = mysql_real_escape_string($_POST['oname']);  
    2181                 if ( !is_writable($wordpressRealPath.get_option('sb_sermon_upload_dir').$fname) && rename($wordpressRealPath.get_option('sb_sermon_upload_dir').$oname, $wordpressRealPath.get_option('sb_sermon_upload_dir').$fname)) { 
     2089                if (!is_writable(sb_get_value('wordpress_path').get_option('sb_sermon_upload_dir').$fname) && rename(sb_get_value('wordpress_path').get_option('sb_sermon_upload_dir').$oname, sb_get_value('wordpress_path').get_option('sb_sermon_upload_dir').$fname)) { 
    21822090                    $wpdb->query("UPDATE {$wpdb->prefix}sb_stuff SET name = '$fname' WHERE id = $fid;"); 
    21832091                    echo 'renamed'; 
     
    21982106            $cond .= 'and m.series_id = ' . (int) $_POST['series'] . ' '; 
    21992107        } 
    2200         $m = $wpdb->get_results("SELECT m.id, m.title, m.date, p.name as pname, s.name as sname, ss.name as ssname FROM {$wpdb->prefix}sb_sermons as m, {$wpdb->prefix}sb_preachers as p, {$wpdb->prefix}sb_services as s, {$wpdb->prefix}sb_series as ss where m.preacher_id = p.id and m.service_id = s.id and m.series_id = ss.id {$cond} ORDER BY m.date desc, s.time desc LIMIT {$st}, {$sermons_per_page};"); 
     2108        $m = $wpdb->get_results("SELECT m.id, m.title, m.date, p.name as pname, s.name as sname, ss.name as ssname FROM {$wpdb->prefix}sb_sermons as m, {$wpdb->prefix}sb_preachers as p, {$wpdb->prefix}sb_services as s, {$wpdb->prefix}sb_series as ss where m.preacher_id = p.id and m.service_id = s.id and m.series_id = ss.id {$cond} ORDER BY m.date desc, s.time desc LIMIT {$st}, ".sb_get_value('sermons_per_page')); 
    22012109        $cnt = $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->prefix}sb_sermons as m, {$wpdb->prefix}sb_preachers as p, {$wpdb->prefix}sb_services as s, {$wpdb->prefix}sb_series as ss where m.preacher_id = p.id and m.service_id = s.id and m.series_id = ss.id $cond;"); 
    22022110        ?> 
     
    22112119                <td><?php echo sb_sermon_stats($sermon->id) ?></td> 
    22122120                <td style="text-align:center"> 
    2213                     <a href="<?php echo $url ?>/wp-admin/admin.php?page=sermon-browser/new_sermon.php&mid=<?php echo $sermon->id ?>"><?php _e('Edit', $sermon_domain) ?></a> | <a onclick="return confirm('Are you sure?')" href="<?php echo $url ?>/wp-admin/admin.php?page=sermon-browser/sermon.php&mid=<?php echo $sermon->id ?>"><?php _e('Delete', $sermon_domain) ?></a> 
     2121                    <a href="<?php echo sb_get_value('wordpress_url') ?>/wp-admin/admin.php?page=sermon-browser/new_sermon.php&mid=<?php echo $sermon->id ?>"><?php _e('Edit', $sermon_domain) ?></a> | <a onclick="return confirm('Are you sure?')" href="<?php echo sb_get_value('wordpress_url') ?>/wp-admin/admin.php?page=sermon-browser/sermon.php&mid=<?php echo $sermon->id ?>"><?php _e('Delete', $sermon_domain) ?></a> 
    22142122                </td> 
    22152123            </tr> 
    22162124        <?php endforeach ?> 
    22172125        <script type="text/javascript"> 
    2218         <?php if($cnt<$sermons_per_page || $cnt <= $st+$sermons_per_page): ?> 
     2126        <?php if($cnt<sb_get_value('sermons_per_page') || $cnt <= $st+sb_get_value('sermons_per_page')): ?> 
    22192127            jQuery('#right').css('display','none'); 
    2220         <?php elseif($cnt > $st+$sermons_per_page): ?> 
     2128        <?php elseif($cnt > $st+sb_get_value('sermons_per_page')): ?> 
    22212129            jQuery('#right').css('display',''); 
    22222130        <?php endif ?> 
     
    22262134        if ($_POST['fetchU']) { 
    22272135            $st = (int) $_POST['fetchU'] - 1; 
    2228             $abc = $wpdb->get_results("SELECT f.*, s.title FROM {$wpdb->prefix}sb_stuff AS f LEFT JOIN {$wpdb->prefix}sb_sermons AS s ON f.sermon_id = s.id WHERE f.sermon_id = 0 AND f.type = 'file' ORDER BY f.name LIMIT {$st}, {$sermons_per_page};"); 
     2136            $abc = $wpdb->get_results("SELECT f.*, s.title FROM {$wpdb->prefix}sb_stuff AS f LEFT JOIN {$wpdb->prefix}sb_sermons AS s ON f.sermon_id = s.id WHERE f.sermon_id = 0 AND f.type = 'file' ORDER BY f.name LIMIT {$st}, ".sb_get_value('sermons_per_page')); 
    22292137        } elseif ($_POST['fetchL']) { 
    22302138            $st = (int) $_POST['fetchL'] - 1; 
    2231             $abc = $wpdb->get_results("SELECT f.*, s.title FROM {$wpdb->prefix}sb_stuff AS f LEFT JOIN {$wpdb->prefix}sb_sermons AS s ON f.sermon_id = s.id WHERE f.sermon_id <> 0 AND f.type = 'file' ORDER BY f.name LIMIT {$st}, {$sermons_per_page}"); 
     2139            $abc = $wpdb->get_results("SELECT f.*, s.title FROM {$wpdb->prefix}sb_stuff AS f LEFT JOIN {$wpdb->prefix}sb_sermons AS s ON f.sermon_id = s.id WHERE f.sermon_id <> 0 AND f.type = 'file' ORDER BY f.name LIMIT {$st}, ".sb_get_value('sermons_per_page')); 
    22322140        } else { 
    22332141            $s = mysql_real_escape_string($_POST['search']); 
     
    22682176} 
    22692177 
     2178/*************************************** 
     2179 ** Supplementary functions           ** 
     2180 **************************************/ 
     2181 
     2182// Warns if [sermons] tag not found 
    22702183function sb_check_sermon_tag() { 
    2271     if (sb_display_url() == "") echo '<div id="message" class="updated"><p><b>'.__('You must create a post or page that includes the code [sermons] in order for your sermons to be displayed on your site.', $sermon_domain).'</b></div>'; 
    2272 } 
    2273  
    2274 //Processing for php.ini values 
     2184    if (sb_display_url() == "") echo '<div id="message" class="updated"><p><b>'.__('You must create a post or preferably a page that includes the code [sermons] in order for your sermons to be displayed on your site.', $sermon_domain).'</b></div>'; 
     2185} 
     2186 
     2187// Show the textarea input 
     2188function sb_build_textarea($name, $html) { 
     2189    $out = '<textarea name="'.$name.'" cols="75" rows="20" style="width:100%">'; 
     2190    $out .= stripslashes(str_replace('\r\n', "\n", base64_decode($html)));  
     2191    $out .= '</textarea>'; 
     2192    echo $out; 
     2193} 
     2194 
     2195// Find new files uploaded by FTP 
     2196function sb_scan_dir() { 
     2197    global $wpdb; 
     2198    $files = $wpdb->get_results("SELECT name FROM {$wpdb->prefix}sb_stuff WHERE type = 'file';"); 
     2199    $bnn = array(); 
     2200    foreach ($files as $file) { 
     2201        $bnn[] = $file->name; 
     2202    } 
     2203     
     2204    $dir = sb_get_value('wordpress_path').get_option('sb_sermon_upload_dir');    
     2205    if ($dh = @opendir($dir)) { 
     2206        while (false !== ($file = readdir($dh))) { 
     2207            if ($file != "." && $file != ".." && !is_dir($dir.$file) && !in_array($file, $bnn)) {                
     2208                $wpdb->query("INSERT INTO {$wpdb->prefix}sb_stuff VALUES (null, 'file', '$file', 0, 0);"); 
     2209            }    
     2210        } 
     2211        closedir($dh); 
     2212    } 
     2213} 
     2214 
     2215// Check to see if upload folder is writeable 
     2216function sb_checkSermonUploadable($foldername = "") { 
     2217    $sermonUploadDir = sb_get_value('wordpress_path').get_option('sb_sermon_upload_dir').$foldername; 
     2218    if (is_dir($sermonUploadDir)) { 
     2219        //Dir exist 
     2220        $fp = @fopen($sermonUploadDir.'sermontest.txt', 'w'); 
     2221        if ($fp) { 
     2222            //Delete this test file 
     2223            fclose($fp); 
     2224            unset($fp); 
     2225            @unlink($sermonUploadDir.'sermontest.txt'); 
     2226            return 'writeable';          
     2227        } else { 
     2228            return 'unwriteable'; 
     2229        } 
     2230    } else { 
     2231        return 'notexist'; 
     2232    } 
     2233    return false; 
     2234} 
     2235 
     2236// Processing for php.ini values 
    22752237function sb_return_kbytes($val) { 
    22762238    $val = trim($val); 
     
    22842246   return intval($val); 
    22852247} 
     2248 
     2249//Count download stats for sermon 
     2250function sb_sermon_stats($sermonid) { 
     2251    global $wpdb; 
     2252    $stats = $wpdb->get_var("SELECT SUM(count) FROM ".$wpdb->prefix."sb_stuff WHERE sermon_id=".$sermonid); 
     2253    if ($stats > 0) return $stats; 
     2254} 
     2255 
     2256// Returns and caches common values 
     2257function sb_get_value ($value_type, $clear = FALSE) { // $clear clears the cache 
     2258    switch ($value_type) { 
     2259        case 'single_form' : 
     2260            global $single_form; 
     2261            if (!$single_form | $clear) $single_form = stripslashes(base64_decode(get_option('sb_sermon_single_form'))); 
     2262            return $single_form; 
     2263        case 'multi_form' : 
     2264            global $multi_form; 
     2265            if (!$multi_form | $clear) $multi_form = stripslashes(base64_decode(get_option('sb_sermon_multi_form'))); 
     2266            return $multi_form; 
     2267        case 'wordpress_url' : 
     2268            global $wordpress_url; 
     2269            if (!$wordpress_url | $clear) $wordpress_url = get_bloginfo('wpurl'); 
     2270            return $wordpress_url; 
     2271        case 'wordpress_path' : 
     2272            global $wordpressRealPath; 
     2273            if (!$wordpressRealPath | $clear) $wordpressRealPath = str_replace("\\", "/", dirname(dirname(dirname(dirname(__FILE__))))); 
     2274            return $wordpressRealPath; 
     2275        case 'display_method' : 
     2276            global $display_method; 
     2277            if (!$display_method | $clear) $display_method = get_option('sb_display_method'); 
     2278            return $display_method; 
     2279        case 'bible_books' : 
     2280            global $bible_books, $wpdb; 
     2281            if (!$bible_books | $clear) $bible_books = $wpdb->get_col("SELECT name FROM wp_sb_books order by id"); 
     2282            return $bible_books; 
     2283        case 'sermons_per_page' : 
     2284            global $sermons_per_page; 
     2285            if (!$sermons_per_page | $clear) $sermons_per_page = get_option('sb_sermons_per_page'); 
     2286            return $sermons_per_page; 
     2287        case 'plugin_path' : 
     2288            global $sb_plugin_path; 
     2289            if (!$sb_plugin_path | $clear) { 
     2290                if ( !defined('WP_CONTENT_DIR') ) 
     2291                    define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' ); 
     2292                $sb_plugin_path = WP_CONTENT_DIR.'/plugins/'.plugin_basename(dirname(__FILE__)); 
     2293            } 
     2294            return $plugin_path; 
     2295        case 'plugin_url' : 
     2296            global $sb_plugin_url; 
     2297            if (!$plugin_path | $clear) { 
     2298                if ( !defined('WP_CONTENT_URL') ) 
     2299                    define( 'WP_CONTENT_URL', get_option('siteurl') . '/wp-content'); 
     2300                $sb_plugin_url = WP_CONTENT_URL.'/plugins/'.plugin_basename(dirname(__FILE__)); 
     2301            } 
     2302            return $sb_plugin_url; 
     2303    } 
     2304} 
     2305 
     2306// Returns default values 
     2307function sb_get_default ($default_type) { 
     2308    global $sermon_domain; 
     2309    switch ($default_type) { 
     2310        case 'sermon_path': return '/'.get_option('upload_path').'/sermons/'; 
     2311        case 'attachment_url': return get_bloginfo('wpurl').'/'.get_option('upload_path').'/sermons/'; 
     2312        case 'bible_books': return array(__('Genesis', $sermon_domain), __('Exodus', $sermon_domain), __('Leviticus', $sermon_domain), __('Numbers', $sermon_domain), __('Deuteronomy', $sermon_domain), __('Joshua', $sermon_domain), __('Judges', $sermon_domain), __('Ruth', $sermon_domain), __('1 Samuel', $sermon_domain), __('2 Samuel', $sermon_domain), __('1 Kings', $sermon_domain), __('2 Kings', $sermon_domain), __('1 Chronicles', $sermon_domain), __('2 Chronicles',$sermon_domain), __('Ezra', $sermon_domain), __('Nehemiah', $sermon_domain), __('Esther', $sermon_domain), __('Job', $sermon_domain), __('Psalm', $sermon_domain), __('Proverbs', $sermon_domain), __('Ecclesiastes', $sermon_domain), __('Song of Solomon', $sermon_domain), __('Isaiah', $sermon_domain), __('Jeremiah', $sermon_domain), __('Lamentations', $sermon_domain), __('Ezekiel', $sermon_domain), __('Daniel', $sermon_domain), __('Hosea', $sermon_domain), __('Joel', $sermon_domain), __('Amos', $sermon_domain), __('Obadiah', $sermon_domain), __('Jonah', $sermon_domain), __('Micah', $sermon_domain), __('Nahum', $sermon_domain), __('Habakkuk', $sermon_domain), __('Zephaniah', $sermon_domain), __('Haggai', $sermon_domain), __('Zechariah', $sermon_domain), __('Malachi', $sermon_domain), __('Matthew', $sermon_domain), __('Mark', $sermon_domain), __('Luke', $sermon_domain), __('John', $sermon_domain), __('Acts', $sermon_domain), __('Romans', $sermon_domain), __('1 Corinthians', $sermon_domain), __('2 Corinthians', $sermon_domain), __('Galatians', $sermon_domain), __('Ephesians', $sermon_domain), __('Philippians', $sermon_domain), __('Colossians', $sermon_domain), __('1 Thessalonians', $sermon_domain), __('2 Thessalonians', $sermon_domain), __('1 Timothy', $sermon_domain), __('2 Timothy', $sermon_domain), __('Titus', $sermon_domain), __('Philemon', $sermon_domain), __('Hebrews', $sermon_domain), __('James', $sermon_domain), __('1 Peter', $sermon_domain), __('2 Peter', $sermon_domain), __('1 John', $sermon_domain), __('2 John', $sermon_domain), __('3 John', $sermon_domain), __('Jude', $sermon_domain), __('Revelation', $sermon_domain)); 
     2313    } 
     2314} 
     2315             
     2316 
     2317 
     2318/*************************************** 
     2319 ** Default templates and styles      ** 
     2320 **************************************/ 
    22862321 
    22872322//Default template for search results 
     
    25892624} 
    25902625 
    2591 /* Code below reserved for version 0.40 
    2592  
    25932626function sb_default_excerpt_template () { 
    25942627$multi = <<<HERE 
     
    26172650    return $multi; 
    26182651} 
    2619  
    2620 function sb_get_single_form () { 
    2621     global $single_form; 
    2622     if (!$single_form) $single_form = base64_decode(get_option('sb_sermon_single_form')); 
    2623     return $single_form; 
    2624 } 
    2625  
    2626 function sb_create_page($sermon_id, $mass_update = FALSE) { 
    2627     //Security check 
    2628     if (function_exists('current_user_can')&&!current_user_can('publish_posts')) 
    2629         wp_die(__("You do not have the correct permissions to create sermons", $sermon_domain)); 
    2630     global $wordpressRealPath, $wpdb, $display_method, $sermon_domain, $mdict, $sdict; 
    2631     //Create page content (extract) 
    2632     $sermons = sb_get_sermons(array('id'=>$sermon_id), array('by'=>'m.date', 'dir'=>'asc'),1, 99999); 
    2633     ob_start(); 
    2634     eval('?>'.strtr(sb_default_excerpt_template(), $mdict)); 
    2635     $post_excerpt = ob_get_contents(); 
    2636     //Create page content (post body) 
    2637     ob_end_clean(); 
    2638     $sermon = sb_get_single_sermon($sermon_id); 
    2639     ob_start(); 
    2640     $single_form = get_single_form(); 
    2641     eval('?>'.strtr(base64_decode(get_option('sb_sermon_single_form')), $sdict)); 
    2642     $post_content = ob_get_contents(); 
    2643     ob_end_clean(); 
    2644     //Check to see if page exists 
    2645     $sermon_page = $wpdb->get_results("SELECT sermons.page_id, sermons.series_id FROM {$wpdb->prefix}sb_sermons AS sermons WHERE sermons.id = '{$sermon_id}'"); 
    2646     $series_id = $sermon_page[0]->series_id; 
    2647     $sermon_page = $sermon_page[0]->page_id; 
    2648     //Add data to array 
    2649     if ($sermon_page!=0) $new_post->ID = $sermon_page; 
    2650     $tags = $sermon["Tags"]; 
    2651     $sermon = $sermon["Sermon"]; 
    2652     $tags[] = $sermon->series; 
    2653     $tags[] = $sermon->preacher; // Think about creating authors for preachers. 
    2654     $tags[] = $sermon->service; 
    2655     $start = $sermon->start; 
    2656     if ($start) foreach ($start as $passage) { 
    2657         $tags[] = $passage['book']; 
    2658     } 
    2659     $end = $sermon->end; 
    2660     if ($end) foreach ($end as $passage) { 
    2661         $tags[] = $passage['book']; 
    2662     } 
    2663     $tags = array_filter(array_unique($tags)); 
    2664     $new_post->post_title = stripslashes($sermon->title); 
    2665     $new_post->post_content = $post_content; 
    2666     $new_post->post_status = 'publish'; 
    2667     $new_post->post_page_template = '_wp_page_template'; 
    2668     $new_post->post_date =  $sermon->date; 
    2669     get_currentuserinfo(); 
    2670     $new_post->post_author = $userdata->ID; 
    2671     $new_post->post_type = $display_method; 
    2672     $new_post->tags_input = $tags; 
    2673     $new_post->post_excerpt = $post_excerpt; 
    2674     if ($display_method == "page") { 
    2675         //Check to see if series page exists, and create/re-write it 
    2676         $series_page=sb_create_series_page($series_id, !$mass_update); 
    2677         $new_post->post_parent = $series_page; 
    2678     } else { 
    2679         $category_id = wp_create_category (__("Sermons", $sermon_domain)); 
    2680         $new_post->post_category = array($category_id); 
    2681     } 
    2682     //Write page 
    2683     $page_id = wp_insert_post($new_post); 
    2684     //Update sermon table with page id 
    2685     $table_name = $wpdb->prefix . "sb_sermons"; 
    2686     $wpdb->query("UPDATE {$table_name} SET page_id = '{$page_id}' WHERE id={$sermon->id}"); 
    2687     return $page_id; 
    2688 } 
    2689  
    2690 function sb_create_series_page($series_id, $rewrite_series = TRUE) { 
    2691     global $wpdb, $wordpressRealPath; 
    2692     //Security check 
    2693     if (function_exists('current_user_can')&&!current_user_can('publish_posts')) 
    2694         wp_die(__("You do not have the correct permissions to create series pages", $sermon_domain)); 
    2695     //Check to see if page exists 
    2696     $table_name = $wpdb->prefix . "sb_series"; 
    2697     $series_page = intval($wpdb->get_var("SELECT page_id FROM {$table_name} WHERE id = '{$series_id}'")); 
    2698     //Decide what to do 
    2699     if ($series_page!=0 AND $rewrite_series) { 
    2700         $new_post->ID = $series_page; 
    2701     } 
    2702     elseif ($series_page!=0 AND !$rewrite_series) { 
    2703         return $series_page; 
    2704     } 
    2705     //Create page content 
    2706     $sermons = sb_get_sermons(array('series'=>$series_id), array('by'=>'m.date', 'dir'=>'asc'),1, 99999); 
    2707     ob_start(); 
    2708     eval('?><div class="sermon-browser-series"> 
    2709         <ul> 
    2710         <?php foreach ($sermons as $sermon): ?><?php $stuff = sb_get_stuff($sermon) ?>   
    2711             <li><a class="sermon-title" href="<?php sb_print_sermon_link($sermon) ?>"><?php echo stripslashes($sermon->title) ?></a>  
    2712             <span class="passage">(<?php $foo = unserialize($sermon->start); $bar = unserialize($sermon->end); echo sb_get_books($foo[0], $bar[0]) ?>)</span><br\> 
    2713             Preached by <a class="preacher" href="<?php sb_print_preacher_link($sermon) ?>"><?php echo stripslashes($sermon->preacher) ?></a> on <?php echo date("j F Y", strtotime($sermon->date)) ?> (<a href="<?php sb_print_service_link($sermon) ?>"><?php echo stripslashes($sermon->service) ?></a>).</li> 
    2714         <?php endforeach ?> 
    2715         </ul> 
    2716         <div id="poweredbysermonbrowser">Powered by <a href="http://www.4-14.org.uk/sermon-browser">Sermon Browser</a></div> 
    2717     </div>'); 
    2718     $result = ob_get_contents(); 
    2719     ob_end_clean(); 
    2720     //Add data to array 
    2721     $new_post->post_title = $sermon->series; 
    2722     $new_post->post_content = $result; 
    2723     $new_post->post_status = 'publish'; 
    2724     $new_post->post_type = 'page'; 
    2725     $new_post->post_parent = 5; 
    2726     $new_post->post_date =  $sermon->date; 
    2727     get_currentuserinfo(); 
    2728     $new_post->post_author = $userdata->ID; 
    2729     //Write page 
    2730     $page_id = wp_insert_post($new_post); 
    2731     //Update series table with page id 
    2732     $table_name = $wpdb->prefix . "sb_series"; 
    2733     $wpdb->query("UPDATE {$table_name} SET page_id = '{$page_id}' WHERE id={$series_id}"); 
    2734     sb_reorder_pages ($series_id); 
    2735     return $page_id; 
    2736 } 
    2737  
    2738 function sb_reorder_pages ($series_id) { 
    2739     global $wpdb; 
    2740     $page_ids = $wpdb->get_results("SELECT page_id FROM {$wpdb->prefix}sb_sermons WHERE series_id='{$series_id}' ORDER BY date ASC"); 
    2741     $page_order = 0; 
    2742     foreach ($page_ids as $page_id) { 
    2743         $wpdb->query("UPDATE {$wpdb->prefix}posts SET menu_order = '{$page_order}' WHERE id = {$page_id->page_id}"); 
    2744         $page_order++; 
    2745     } 
    2746 } 
    2747  
    2748 function sb_rewrite_all_pages ($start_page = 0, $limit = 20, $mode = "") { 
    2749     global $wpdb, $url, $display_method, $sermon_domain; 
    2750     //Security check 
    2751     if (function_exists('current_user_can')&&!current_user_can('manage_options')) 
    2752         wp_die(__("You do not have the correct permissions to rewrite the sermons pages", $sermon_domain)); 
    2753     define('WP_IMPORTING', true); //Server will get overwhelmed if pinging on every post. Setting WP_IMPORTING to true turns pinging off. 
    2754     if ($mode =="") $mode = $_REQUEST['mode']; 
    2755     if ($mode =="") $mode = "sermons"; 
    2756     $start_page = intval($start_page); 
    2757     if ($mode != "series") { 
    2758         // Create sermons pages 
    2759         $sermons = $wpdb->get_results("SELECT SQL_CALC_FOUND_ROWS id, title FROM {$wpdb->prefix}sb_sermons ORDER BY id ASC LIMIT {$start_page}, {$limit}"); 
    2760         $record_count = $wpdb->get_var("SELECT FOUND_ROWS()"); 
    2761         $i = $start_page; 
    2762         foreach ($sermons as $sermon) { 
    2763             $i++; 
    2764             echo '<p style="margin: 0 0 0 17px">'.__('Writing', $sermon_domain).": ".stripslashes($sermon->title)." (".$i."/".$record_count.")</p>"; 
    2765             flush(); 
    2766             ob_flush(); 
    2767             sb_create_page ($sermon->id, TRUE); 
    2768         } 
    2769         if ($i < $record_count) echo "<script>document.location = '$url/wp-admin/admin.php?page=sermon-browser/options.php&rewrite=true&start={$i}&method={$display_method}';</script>"; 
    2770         $start_page = 0; 
    2771     } 
    2772     if ($display_method == "page") { 
    2773         // Create series pages 
    2774         $i = $start_page; 
    2775         $limit = round($limit/4); 
    2776         if ($limit < 3) $limit = 2; 
    2777         $series = $wpdb->get_results("SELECT SQL_CALC_FOUND_ROWS ss.id, ss.name FROM {$wpdb->prefix}sb_series AS ss JOIN {$wpdb->prefix}sb_sermons AS sermons ON ss.id = sermons.series_id GROUP BY ss.id  LIMIT {$start_page}, {$limit}"); 
    2778         $record_count = $wpdb->get_var("SELECT FOUND_ROWS()"); 
    2779         foreach ($series as $one_series) { 
    2780             $i++; 
    2781             echo '<p style="margin: 0 0 0 17px">'.__('Writing', $sermon_domain).": ".stripslashes($one_series->name)." (".$i."/".$record_count.")</p>"; 
    2782             flush(); 
    2783             ob_flush(); 
    2784             sb_create_series_page ($one_series->id, TRUE); 
    2785         } 
    2786         if ($i < $record_count) echo "<script>document.location = '$url/wp-admin/admin.php?page=sermon-browser/options.php&rewrite=true&start={$i}&method={$display_method}&mode=series';</script>"; 
    2787     } 
    2788     echo "<script>document.location = '$url/wp-admin/admin.php?page=sermon-browser/options.php';</script>"; 
    2789 } 
    2790  
    2791 function sb_delete_all_pages() { 
    2792     global $wpdb, $sermon_domain; 
    2793     //Security check 
    2794     if (function_exists('current_user_can')&&!current_user_can('manage_options')) 
    2795         wp_die(__("You do not have the correct permissions to delete all the sermon pages", $sermon_domain)); 
    2796     //Delete all series pages 
    2797     $i=0; 
    2798     $series = $wpdb->get_results("SELECT ss.page_id FROM {$wpdb->prefix}sb_series AS ss JOIN {$wpdb->prefix}sb_sermons AS sermons ON ss.id = sermons.series_id GROUP BY ss.id"); 
    2799     echo '<p style="margin: 0 0 0 17px">'.__('Deleting series pages', $sermon_domain).' '; 
    2800     foreach ($series as $one_series) { 
    2801         wp_delete_post($one_series->page_id); 
    2802         $wpdb->query("UPDATE {$wpdb->prefix}sb_series SET page_id = 0 WHERE page_id = {$one_series->page_id}");              
    2803         $i++; 
    2804         if (($i % 10)==0) { 
    2805             echo "."; 
    2806             flush(); 
    2807             ob_flush(); 
    2808         } 
    2809     } 
    2810     echo '</p>'; 
    2811     //Delete all sermon pages 
    2812     $sermons = $wpdb->get_results("SELECT page_id FROM {$wpdb->prefix}sb_sermons"); 
    2813     echo '<p style="margin: 0 0 0 17px">'.__('Deleting sermon pages', $sermon_domain).' '; 
    2814     foreach ($sermons as $sermon) { 
    2815         wp_delete_post($sermon->page_id); 
    2816         $wpdb->query("UPDATE {$wpdb->prefix}sb_sermons SET page_id = 0 WHERE page_id = {$sermon->page_id}");                 
    2817         $i++; 
    2818         if (($i % 10)==0) { 
    2819             echo "."; 
    2820             flush(); 
    2821             ob_flush(); 
    2822         } 
    2823     } 
    2824     echo '</p>'; 
    2825     //Delete empty tags 
    2826     if (function_exists('get_terms')) { 
    2827         echo '<p style="margin: 0 0 0 17px">'.__('Deleting empty tags', $sermon_domain).' '; 
    2828         $tags = get_terms('post_tag', array('hide_empty' => false)); 
    2829         foreach ($tags as $tag) 
    2830             if ($tag->count == 0) wp_delete_term($tag->term_id, 'post_tag'); 
    2831         echo '</p>'; 
    2832     } 
    2833 } 
    2834  
    2835 */ 
    28362652?> 
  • sermon-browser/trunk/widget.php

    r51332 r56704  
    110110} 
    111111function sb_widget_sermon_control( $widget_args = 1 ) { 
    112     global $wpdb, $sermon_domain, $books; 
     112    global $wpdb, $sermon_domain; 
    113113    global $wp_registered_widgets; 
    114114    static $updated = false; // Whether or not we have already updated the data after a POST submit 
Note: See TracChangeset for help on using the changeset viewer.