Changeset 1575

Show
Ignore:
Timestamp:
07/02/08 14:53:07 (5 months ago)
Author:
sambauers
Message:

bb_uri() and bb_get_uri() commit bomb.

BB_URI_CONTEXT_* definitions applied to all link creation functions and passed to their filters.

First stages of SSL support for user forms (login, registration, etc.) and admin area.

Links rewritten for SSL at this stage, but pages are not yet forced to SSL if loaded as non-secure.

bb_force_ssl_user_forms() and bb_force_ssl_admin() also included.

Introducing new config constants, BB_FORCE_SSL_USER_FORMS and BB_FORCE_SSL_ADMIN.

New config variable $bb->uri_ssl, a complete URI for the SSL links to go to. If not set it is based on replacing http with https in $bb->uri.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/bb-admin/admin-functions.php

    r1546 r1575  
    168168        endif; 
    169169        if ( $bb_current_submenu && !bb_current_user_can( $bb_current_submenu[1] ) || !bb_current_user_can( $bb_current_menu[1] ) ) { 
    170                 wp_redirect( bb_get_option( 'uri' ) ); 
     170                wp_redirect( bb_get_uri(null, null, BB_URI_CONTEXT_HEADER) ); 
    171171                exit(); 
    172172        } 
     
    644644        $r .= "\t\t\t<div class='alignright'>\n"; 
    645645        if ( bb_current_user_can( 'manage_forums' ) ) 
    646                 $r .= "\t\t\t\t<a class='edit' href='" . attribute_escape( bb_get_option('uri') . "bb-admin/content-forums.php?action=edit&id=$_forum->forum_id" ) . "'>" . __('Edit') . "</a>\n"; 
     646                $r .= "\t\t\t\t<a class='edit' href='" . attribute_escape( bb_get_uri('bb-admin/content-forums.php', array('action' => 'edit', 'id' => $_forum->forum_id), BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_ADMIN) ) . "'>" . __('Edit') . "</a>\n"; 
    647647        if ( bb_current_user_can( 'delete_forum', $_forum->forum_id ) && 1 < $forums_count ) 
    648                 $r .= "\t\t\t\t<a class='delete' href='" . attribute_escape( bb_get_option('uri') . "bb-admin/content-forums.php?action=delete&id=$_forum->forum_id" ) . "'>" . __('Delete') . "</a>\n"; 
     648                $r .= "\t\t\t\t<a class='delete' href='" . attribute_escape( bb_get_uri('bb-admin/content-forums.php', array('action' => 'delete', 'id' => $_forum->forum_id), BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_ADMIN) ) . "'>" . __('Delete') . "</a>\n"; 
    649649        $r .= "\t\t\t</div>\n"; 
    650650        $r .= "\t\t\t" . get_forum_name( $_forum->forum_id ) . ' &#8212; ' . get_forum_description( $_forum->forum_id ) . "\n\t\t</div>\n"; 
     
    663663        $action = $forum_id ? 'update' : 'add'; 
    664664?> 
    665 <form method="post" id="<?php echo $action; ?>-forum" action="<?php bb_option('uri'); ?>bb-admin/bb-forum.php"> 
     665<form method="post" id="<?php echo $action; ?>-forum" action="<?php bb_uri('bb-admin/bb-forum.php', null, BB_URI_CONTEXT_FORM_ACTION + BB_URI_CONTEXT_BB_ADMIN); ?>"> 
    666666        <fieldset> 
    667667        <table><col /><col style="width: 80%" /> 
  • trunk/bb-admin/admin-header.php

    r1367 r1575  
    44        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
    55        <title><?php bb_admin_title() ?></title> 
    6         <link rel="stylesheet" href="<?php bb_option('uri'); ?>bb-admin/style.css" type="text/css" /> 
     6        <link rel="stylesheet" href="<?php bb_uri('bb-admin/style.css', null, BB_URI_CONTEXT_LINK_STYLESHEET_HREF + BB_URI_CONTEXT_BB_ADMIN); ?>" type="text/css" /> 
    77<?php if ( 'rtl' == bb_get_option( 'text_direction' ) ) : ?> 
    8         <link rel="stylesheet" href="<?php bb_option('uri'); ?>bb-admin/style-rtl.css" type="text/css" /> 
     8        <link rel="stylesheet" href="<?php bb_uri('bb-admin/style-rtl.css', null, BB_URI_CONTEXT_LINK_STYLESHEET_HREF + BB_URI_CONTEXT_BB_ADMIN); ?>" type="text/css" /> 
    99<?php endif; do_action('bb_admin_print_scripts'); do_action( 'bb_admin_head' ); ?> 
    1010</head> 
     
    1818                                </h1> 
    1919                                <div id="bbVisitSite"> 
    20                                         <a href="<?php bb_option('uri'); ?>"><span><?php _e('Visit Site'); ?></span></a> 
     20                                        <a href="<?php bb_uri(); ?>"><span><?php _e('Visit Site'); ?></span></a> 
    2121                                </div> 
    2222                        </div> 
     
    2525                                        <?php printf( __('Howdy, %1$s!'), bb_get_profile_link( array( 'text' => bb_get_current_user_info( 'name' ) ) ) );?> 
    2626                                        | <?php bb_logout_link(); ?> 
    27                                         | <a href="http://bbpress.org/forums/">Forums</a> 
     27                                        | <a href="http://bbpress.org/forums/">Support forums</a> 
    2828                                </p> 
    2929                        </div> 
  • trunk/bb-admin/bb-forum.php

    r1285 r1575  
    66 
    77if ( !isset($_POST['action']) ) 
    8         wp_redirect( bb_get_option( 'uri' ) . 'bb-admin/content-forums.php' ); 
     8        wp_redirect( bb_get_uri('bb-admin/content-forums.php', null, BB_URI_CONTEXT_HEADER + BB_URI_CONTEXT_BB_ADMIN) ); 
    99 
    1010$sent_from = wp_get_referer(); 
  • trunk/bb-admin/class-install.php

    r1574 r1575  
    503503                                        // The database needs upgrading 
    504504                                        $this->strings[-1]['messages'][0][] = __('bbPress is already installed, but appears to require an upgrade.'); 
    505                                         $this->strings[-1]['messages'][0][] = sprintf(__('Perhaps you meant to run the <a href="%s">upgrade script</a> instead?'), bb_get_option('uri') . 'bb-admin/upgrade.php'); 
     505                                        $this->strings[-1]['messages'][0][] = sprintf( 
     506                                                __('Perhaps you meant to run the <a href="%s">upgrade script</a> instead?'), 
     507                                                bb_get_uri('bb-admin/upgrade.php', null, BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_ADMIN) 
     508                                        ); 
    506509                                        $this->step = -1; 
    507510                                } else { 
    508511                                        // Redirect to the base url 
    509                                         bb_safe_redirect(bb_get_option('uri')); 
     512                                        bb_safe_redirect(bb_get_uri(null, null, BB_URI_CONTEXT_HEADER)); 
    510513                                        die(); 
    511514                                } 
     
    18811884                        $keymaster_email_message = sprintf( 
    18821885                                __("Your new bbPress site has been successfully set up at:\n\n%1\$s\n\nYou can log in to the key master account with the following information:\n\nUsername: %2\$s\nPassword: %3\$s\n\nWe hope you enjoy your new forums. Thanks!\n\n--The bbPress Team\nhttp://bbpress.org/"), 
    1883                                 bb_get_option( 'uri' ), 
     1886                                bb_get_uri(null, null, BB_URI_CONTEXT_TEXT), 
    18841887                                $data3['keymaster_user_login']['value'], 
    18851888                                $data4['keymaster_user_password']['value'] 
  • trunk/bb-admin/content-forums.php

    r1385 r1575  
    1818                break; 
    1919        case 'deleted' : 
    20                 bb_admin_notice( sprintf(__('Forum deleted.  You should have bbPress <a href="%s">recount your site information</a>.'), bb_get_option( 'uri' ) . 'bb-admin/site.php') ); 
     20                bb_admin_notice( sprintf( 
     21                        __('Forum deleted.  You should have bbPress <a href="%s">recount your site information</a>.'), 
     22                        bb_get_uri('bb-admin/site.php', null, BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_ADMIN) 
     23                ) ); 
    2124                break; 
    2225        endswitch; 
     
    4548        </ul> 
    4649 
    47         <form method="post" id="delete-forums" action="<?php bb_option('uri'); ?>bb-admin/bb-forum.php"> 
     50        <form method="post" id="delete-forums" action="<?php bb_uri('bb-admin/bb-forum.php', null, BB_URI_CONTEXT_FORM_ACTION + BB_URI_CONTEXT_BB_ADMIN); ?>"> 
    4851                <p> 
    4952                        <label for="move-topics-delete"><input type="radio" name="move_topics" id="move-topics-delete" value="delete" /> <?php _e('Delete all topics and posts in this forum. <em>This can never be undone.</em>'); ?></label><br /> 
     
    5861                <?php bb_nonce_field( 'delete-forums' ); ?> 
    5962        </form> 
    60         <form method="get" action="<?php bb_option('uri'); ?>bb-admin/bb-forum.php"> 
     63        <form method="get" action="<?php bb_uri('bb-admin/bb-forum.php', null, BB_URI_CONTEXT_FORM_ACTION + BB_URI_CONTEXT_BB_ADMIN); ?>"> 
    6164                <p class="submit alignleft"> 
    6265                        <input type="submit" value="<?php _e('&laquo; Go back'); ?>" tabindex="10" /> 
  • trunk/bb-admin/delete-post.php

    r1285 r1575  
    55 
    66if ( !bb_current_user_can( 'delete_post', $post_id ) ) { 
    7         wp_redirect( bb_get_option( 'uri' ) ); 
     7        wp_redirect( bb_get_uri(null, null, BB_URI_CONTEXT_HEADER) ); 
    88        exit(); 
    99} 
  • trunk/bb-admin/delete-topic.php

    r728 r1575  
    55 
    66if ( !bb_current_user_can( 'delete_topic', $topic_id ) ) { 
    7         wp_redirect( bb_get_option( 'uri' ) ); 
     7        wp_redirect( bb_get_uri(null, null, BB_URI_CONTEXT_HEADER) ); 
    88        exit(); 
    99} 
  • trunk/bb-admin/options-general.php

    r1504 r1575  
    4343<h2><?php _e('General Settings'); ?></h2> 
    4444 
    45 <form class="settings" method="post" action="<?php bb_option('uri'); ?>bb-admin/options-general.php"> 
     45<form class="settings" method="post" action="<?php bb_uri('bb-admin/options-general.php', null, BB_URI_CONTEXT_FORM_ACTION + BB_URI_CONTEXT_BB_ADMIN); ?>"> 
    4646        <fieldset> 
    4747                <div> 
  • trunk/bb-admin/options-wordpress.php

    r1507 r1575  
    6161</p> 
    6262 
    63 <form class="settings" method="post" action="<?php bb_option('uri'); ?>bb-admin/options-wordpress.php"> 
     63<form class="settings" method="post" action="<?php bb_uri('bb-admin/options-wordpress.php', null, BB_URI_CONTEXT_FORM_ACTION + BB_URI_CONTEXT_BB_ADMIN); ?>"> 
    6464        <fieldset> 
    6565                <legend><?php _e('Cookies'); ?></legend> 
     
    317317$wpRolesMap = bb_get_option('wp_roles_map'); 
    318318?> 
    319 <form class="settings" method="post" action="<?php bb_option('uri'); ?>bb-admin/options-wordpress.php"> 
     319<form class="settings" method="post" action="<?php bb_uri('bb-admin/options-wordpress.php', null, BB_URI_CONTEXT_FORM_ACTION + BB_URI_CONTEXT_BB_ADMIN); ?>"> 
    320320        <fieldset> 
    321321<?php 
  • trunk/bb-admin/plugins.php

    r1299 r1575  
    143143                $href = attribute_escape( 
    144144                        bb_nonce_url( 
    145                                 add_query_arg( 
     145                                bb_get_uri( 
     146                                        'bb-admin/plugins.php', 
    146147                                        array( 
    147148                                                'action' => $action, 
    148149                                                'plugin' => urlencode($plugin) 
    149150                                        ), 
    150                                         bb_get_option( 'uri' ) . 'bb-admin/plugins.php' 
     151                                        BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_ADMIN 
    151152                                ), 
    152153                                $action . '-plugin_' . $plugin 
  • trunk/bb-admin/rewrite-rules.php

    r1045 r1575  
    55 
    66if ( !bb_current_user_can('manage_options') ) { 
    7         wp_redirect( bb_get_option( 'uri' ) ); 
     7        wp_redirect( bb_get_uri(null, null, BB_URI_CONTEXT_HEADER) ); 
    88        exit(); 
    99} 
  • trunk/bb-admin/site.php

    r1325 r1575  
    1111pagination oddities.") ?></p> 
    1212 
    13 <form method="post" action="<?php bb_option('uri'); ?>bb-admin/bb-do-counts.php"> 
     13<form method="post" action="<?php bb_uri('bb-admin/bb-do-counts.php', null, BB_URI_CONTEXT_FORM_ACTION + BB_URI_CONTEXT_BB_ADMIN); ?>"> 
    1414        <fieldset> 
    1515                <legend><?php _e('Choose items to recalculate') ?></legend> 
  • trunk/bb-admin/sticky.php

    r1287 r1575  
    1010 
    1111if ( !bb_current_user_can( 'stick_topic', $topic_id ) ) { 
    12         wp_redirect( bb_get_option( 'uri' ) ); 
     12        wp_redirect( bb_get_uri(null, null, BB_URI_CONTEXT_HEADER) ); 
    1313        exit(); 
    1414} 
  • trunk/bb-admin/tag-destroy.php

    r1140 r1575  
    1616        printf(__("Rows deleted from tags table: %d <br />\n"), $destroyed['tags']); 
    1717        printf(__("Rows deleted from tagged table: %d <br />\n"), $destroyed['tagged']); 
    18         printf(__('<a href="%s">Home</a>'), bb_get_option( 'uri' )); 
     18        printf(__('<a href="%s">Home</a>'), bb_get_uri()); 
    1919} else { 
    2020   die(printf(__("Something odd happened when attempting to destroy that tag.<br />\n<a href=\"%s\">Try Again?</a>"), wp_get_referer())); 
  • trunk/bb-admin/themes.php

    r1556 r1575  
    1111if ( isset($_GET['theme']) ) { 
    1212        if ( !bb_current_user_can( 'manage_themes' ) ) { 
    13                 wp_redirect( bb_get_option( 'uri' ) ); 
     13                wp_redirect( bb_get_uri(null, null, BB_URI_CONTEXT_HEADER) ); 
    1414                exit; 
    1515        } 
     
    3131        } 
    3232        do_action( 'bb_activate_theme_' . $theme ); 
    33         wp_redirect( bb_get_option( 'uri' ) . 'bb-admin/themes.php?activated&name=' . urlencode($name) ); 
     33        wp_redirect( bb_get_uri('bb-admin/themes.php', array('activated' => 1, 'name' => $name ), BB_URI_CONTEXT_HEADER + BB_URI_CONTEXT_BB_ADMIN ) ); 
    3434        exit; 
    3535} 
     
    5353        $theme_data = file_exists( $theme_directory . 'style.css' ) ? bb_get_theme_data( $theme ) : false; 
    5454        $screen_shot = file_exists( $theme_directory . 'screenshot.png' ) ? clean_url( bb_get_theme_uri( $theme ) . 'screenshot.png' ) : false; 
    55         $activation_url = clean_url( bb_nonce_url( add_query_arg( 'theme', urlencode($theme), bb_get_option( 'uri' ) . 'bb-admin/themes.php' ), 'switch-theme' ) ); 
     55        $activation_url = bb_get_uri('bb-admin/themes.php', array('theme' => $theme), BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_ADMIN); 
     56        $activation_url = clean_url( bb_nonce_url( $activation_url, 'switch-theme' ) ); 
    5657?> 
    5758        <li<?php alt_class( 'theme', $class ); ?>> 
  • trunk/bb-admin/topic-move.php

    r1285 r1575  
    99 
    1010if ( !bb_current_user_can( 'move_topic', $topic_id, $forum_id ) ) { 
    11         wp_redirect( bb_get_option( 'uri' ) ); 
     11        wp_redirect( bb_get_uri(null, null, BB_URI_CONTEXT_HEADER) ); 
    1212        exit(); 
    1313} 
  • trunk/bb-admin/topic-toggle.php

    r1285 r1575  
    99 
    1010if ( !bb_current_user_can( 'close_topic', $topic_id ) ) { 
    11         wp_redirect( bb_get_option( 'uri' ) ); 
     11        wp_redirect( bb_get_uri(null, null, BB_URI_CONTEXT_HEADER) ); 
    1212        exit(); 
    1313} 
  • trunk/bb-admin/upgrade.php

    r1553 r1575  
    8080?> 
    8181                <p class="last"> 
    82                         <?php printf( __('Nothing to upgrade.  <a href="%s">Get back to work!</a>'), bb_get_option( 'uri' ) . 'bb-admin/' ); ?> 
     82                        <?php printf( __('Nothing to upgrade.  <a href="%s">Get back to work!</a>'), bb_get_uri('bb-admin/', null, BB_URI_CONTEXT_A_HREF + BB_URI_CONTEXT_BB_ADMIN) ); ?> 
    8383                </p> 
    8484<?php 
     
    115115                                        <span class="first">!</span> <?php _e('Your database has been successfully updated.<br />Enjoy!'); ?> 
    116116                                </p> 
    117                                 <form action="<?php bb_option('uri'); ?>bb-admin/" method="get"> 
     117                                <form action="<?php bb_uri('bb-admin/', null, BB_URI_CONTEXT_FORM_ACTION + BB_URI_CONTEXT_BB_ADMIN); ?>" method="get"> 
    118118                                        <label for="upgrade_log_container_toggle"> 
    119119                                                <?php _e('Show upgrade log:'); ?> 
  • trunk/bb-admin/view-ip.php

    r1299 r1575  
    33 
    44if ( !bb_current_user_can('view_by_ip') ) { 
    5         wp_redirect( bb_get_option( 'uri' ) ); 
     5        wp_redirect( bb_get_uri(null, null, BB_URI_CONTEXT_HEADER) ); 
    66        exit(); 
    77} 
  • trunk/bb-edit.php

    r1339 r1575  
    99 
    1010if ( !$bb_post ) { 
    11         wp_redirect( bb_get_option( 'uri' ) ); 
     11        wp_redirect( bb_get_uri(null, null, BB_URI_CONTEXT_HEADER) ); 
    1212        die(); 
    1313} 
     
    2929        wp_redirect( get_post_link( $post_id ) ); 
    3030else 
    31         wp_redirect( bb_get_option( 'uri' ) ); 
     31        wp_redirect( bb_get_uri(null, null, BB_URI_CONTEXT_HEADER) ); 
    3232?> 
  • trunk/bb-includes/default-filters.php

    r1535 r1575  
    7575        add_filter( 'bb_stylesheet_uri', 'attribute_escape', 1, 9999 ); 
    7676        add_filter( 'forum_link', 'attribute_escape', 1, 9999 ); 
    77         add_filter( 'forum_rss_link', 'attribute_escape', 1, 9999 ); 
     77        add_filter( 'bb_forum_posts_rss_link', 'attribute_escape', 1, 9999 ); 
     78        add_filter( 'bb_forum_topics_rss_link', 'attribute_escape', 1, 9999 ); 
    7879        add_filter( 'bb_tag_link', 'attribute_escape', 1, 9999 ); 
    7980        add_filter( 'tag_rss_link', 'attribute_escape', 1, 9999 ); 
  • trunk/bb-includes/deprecated.php

    r1553 r1575  
    535535function bb_path_to_url( $path ) { 
    536536        bb_log_deprecated('function', __FUNCTION__, 'no alternative'); 
    537         return apply_filters( 'bb_path_to_url', bb_convert_path_base( $path, BB_PATH, bb_get_option( 'uri' ) ), $path ); 
     537        return apply_filters( 'bb_path_to_url', bb_convert_path_base( $path, BB_PATH, bb_get_uri(null, null, BB_URI_CONTEXT_TEXT) ), $path ); 
    538538} 
    539539 
     
    541541function bb_url_to_path( $url ) { 
    542542        bb_log_deprecated('function', __FUNCTION__, 'no alternative'); 
    543         return apply_filters( 'bb_url_to_path', bb_convert_path_base( $url, bb_get_option( 'uri' ), BB_PATH ), $url ); 
     543        return apply_filters( 'bb_url_to_path', bb_convert_path_base( $url, bb_get_uri(null, null, BB_URI_CONTEXT_TEXT), BB_PATH ), $url ); 
    544544} 
    545545 
     
    648648function forum_rss_link( $forum_id = 0 ) { 
    649649        bb_log_deprecated('function', __FUNCTION__, 'bb_get_forum_posts_rss_link'); 
    650         echo bb_get_forum_posts_rss_link( $forum_id ); 
     650        bb_forum_posts_rss_link( $forum_id ); 
    651651} 
    652652 
  • trunk/bb-includes/functions.php

    r1572 r1575  
    17151715                                        $r = 0; 
    17161716                                        break; 
     1717                                case 'uri_ssl': 
     1718                                        $r = preg_replace('|^http://|i', 'https://', bb_get_option('uri')); 
    17171719                        } 
    17181720                } 
     
    17631765                'description' => '', 
    17641766                'uri' => '', 
     1767                'uri_ssl' => '', 
    17651768                'from_email' => '', 
    17661769                'secret' => '', 
     
    18081811function bb_delete_option( $option, $value = '' ) { 
    18091812        return bb_delete_meta( 0, $option, $value, 'option', true ); 
     1813} 
     1814 
     1815/** 
     1816 * BB_URI_CONTEXT_* - Bitwise definitions for bb_uri() and bb_get_uri() contexts 
     1817 * 
     1818 * @since 1.0-beta 
     1819 **/ 
     1820define('BB_URI_CONTEXT_HEADER',               1); 
     1821define('BB_URI_CONTEXT_TEXT',                 2); 
     1822define('BB_URI_CONTEXT_A_HREF',               4); 
     1823define('BB_URI_CONTEXT_FORM_ACTION',          8); 
     1824define('BB_URI_CONTEXT_IMG_SRC',              16); 
     1825define('BB_URI_CONTEXT_LINK_STYLESHEET_HREF', 32); 
     1826define('BB_URI_CONTEXT_LINK_ALTERNATE_HREF',  64); 
     1827define('BB_URI_CONTEXT_SCRIPT_SRC',           128); 
     1828//define('BB_URI_CONTEXT_*',                    256);    // Reserved for future definitions 
     1829//define('BB_URI_CONTEXT_*',                    512);    // Reserved for future definitions 
     1830define('BB_URI_CONTEXT_BB_FEED',              1024); 
     1831define('BB_URI_CONTEXT_BB_USER_FORMS',        2048); 
     1832define('BB_URI_CONTEXT_BB_ADMIN',             4096); 
     1833//define('BB_URI_CONTEXT_*',                    8192);   // Reserved for future definitions 
     1834//define('BB_URI_CONTEXT_*',                    16384);  // Reserved for future definitions 
     1835//define('BB_URI_CONTEXT_*',                    32768);  // Reserved for future definitions 
     1836//define('BB_URI_CONTEXT_*',                    65536);  // Reserved for future definitions 
     1837//define('BB_URI_CONTEXT_*',                    131072); // Reserved for future definitions 
     1838//define('BB_URI_CONTEXT_*',                    262144); // Reserved for future definitions 
     1839define('BB_URI_CONTEXT_AKISMET',              524288); 
     1840 
     1841/** 
     1842 * bb_uri() - echo a URI based on the URI setting 
     1843 * 
     1844 * @since 1.0-beta 
     1845 * 
     1846 * @param $resource string The directory, may include a querystring 
     1847 * @param $query mixed The query arguments as a querystring or an associative array 
     1848 * @param $context integer The context of the URI, use BB_URI_CONTEXT_* 
     1849 * @return void 
     1850 **/ 
     1851function bb_uri($resource = null, $query = null, $context = BB_URI_CONTEXT_A_HREF) { 
     1852        echo apply_filters('bb_uri', bb_get_uri($resource, $query, $context), $resource, $query, $context); 
     1853} 
     1854 
     1855/** 
     1856 * bb_get_uri() - return a URI based on the URI setting 
     1857 * 
     1858 * @since 1.0-beta 
     1859 * 
     1860 * @param $resource string The directory, may include a querystring 
     1861 * @param $query mixed The query arguments as a querystring or an associative array 
     1862 * @param $context integer The context of the URI, use BB_URI_CONTEXT_* 
     1863 * @return string The complete URI 
     1864 **/ 
     1865function bb_get_uri($resource = null, $query = null, $context = BB_URI_CONTEXT_A_HREF) { 
     1866        // If there is a querystring in the resource then extract it 
     1867        if ($resource && strpos($resource, '?') !== false) { 
     1868                list($_resource, $_query) = explode('?', trim($resource)); 
     1869                $resource = $_resource; 
     1870                $_query = wp_parse_args($_query); 
     1871        } 
     1872         
     1873        // Make sure $_query is an array for array_merge() 
     1874        if (!$_query) { 
     1875                $_query = array(); 
     1876        } 
     1877         
     1878        // $query can be an array as well as a string 
     1879        if ($query) { 
     1880                if (is_string($query)) { 
     1881                        $query = ltrim(trim($query), '?'); 
     1882                } 
     1883                $query = wp_parse_args($query); 
     1884        } 
     1885         
     1886        // Make sure $query is an array for array_merge() 
     1887        if (!$query) { 
     1888                $query = array(); 
     1889        } 
     1890         
     1891        // Merge the queries into a single array 
     1892        $query = array_merge($_query, $query); 
     1893         
     1894        // Make sure context is an integer 
     1895        if (!$context || !is_integer($context)) { 
     1896                $context = BB_URI_CONTEXT_A_HREF; 
     1897        } 
     1898         
     1899        // Get the base URI 
     1900        $uri = bb_get_option('uri'); 
     1901         
     1902        // Force https when required on user forms 
     1903        if (($context & BB_URI_CONTEXT_BB_USER_FORMS) && bb_force_ssl_user_forms()) { 
     1904                $uri = bb_get_option('uri_ssl'); 
     1905        } 
     1906         
     1907        // Force https when required in admin 
     1908        if (($context & BB_URI_CONTEXT_BB_ADMIN) && bb_force_ssl_admin()) { 
     1909                $uri = bb_get_option('uri_ssl'); 
     1910        } 
     1911         
     1912        // Add the directory 
     1913        $uri .= ltrim($resource, '/'); 
     1914         
     1915        // Add the query string to the URI 
     1916        $uri = add_query_arg($query, $uri); 
     1917         
     1918        return apply_filters('bb_get_uri', $uri, $resource, $context); 
     1919} 
     1920 
     1921/** 
     1922 * bb_force_ssl_user_forms() - Whether SSL should be forced when sensitive user data is being submitted. 
     1923 * 
     1924 * @since 1.0-beta 
     1925 * 
     1926 * @param string|bool $force Optional. 
     1927 * @return bool True if forced, false if not forced. 
     1928 **/ 
     1929function bb_force_ssl_user_forms($force = '') { 
     1930        static $forced; 
     1931         
     1932        if ( '' != $force ) { 
     1933                $old_forced = $forced; 
     1934                $forced = $force; 
     1935                return $old_forced; 
     1936        } 
     1937         
     1938        return $forced; 
     1939} 
     1940 
     1941/** 
     1942 * bb_force_ssl_admin() - Whether SSL should be forced when using the admin area. 
     1943 * 
     1944 * @since 1.0-beta 
     1945 * 
     1946 * @param string|bool $force Optional. 
     1947 * @return bool True if forced, false if not forced. 
     1948 **/ 
     1949function bb_force_ssl_admin($force = '') { 
     1950        static $forced; 
     1951         
     1952        if ( '' != $force ) { 
     1953                $old_forced = $forced; 
     1954                $forced = $force; 
     1955                return $old_forced; 
     1956        } 
     1957         
     1958        return $forced; 
    18101959} 
    18111960 
     
    25332682                 
    25342683                $uri = false; 
    2535                 if ( function_exists('bb_get_option') && !BB_INSTALLING ) 
    2536                         $uri = bb_get_option('uri'); 
     2684                if ( function_exists('bb_get_uri') && !BB_INSTALLING ) { 
     2685                        $uri = bb_get_uri(); 
     2686                        $uri_stylesheet = bb_get_uri('bb-admin/install.css', null, BB_URI_CONTEXT_LINK_STYLESHEET_HREF + BB_URI_CONTEXT_BB_INSTALLER); 
     2687                        $uri_stylesheet_rtl = bb_get_uri('bb-admin/install-rtl.css', null, BB_URI_CONTEXT_LINK_STYLESHEET_HREF + BB_URI_CONTEXT_BB_INSTALLER); 
     2688                        $uri_logo = bb_get_uri('bb-admin/images/install-logo.gif', null, BB_URI_CONTEXT_IMG_SRC + BB_URI_CONTEXT_BB_INSTALLER); 
     2689                } 
    25372690                 
    2538                 if (!$uri) 
     2691                if (!$uri) { 
    25392692                        $uri = preg_replace('|(/bb-admin)?/[^/]+?$|', '/', $_SERVER['PHP_SELF']); 
     2693                        $uri_stylesheet = $uri . 'bb-admin/install.css'; 
     2694                        $uri_stylesheet_rtl = $uri . 'bb-admin/install-rtl.css'; 
     2695                        $uri_logo = $uri . 'bb-admin/images/install-logo.gif'; 
     2696                } 
    25402697         
    25412698        header('Content-Type: text/html; charset=utf-8'); 
     
    25472704        <title><?php echo $title; ?></title> 
    25482705        <meta name="robots" content="noindex, nofollow" /> 
    2549         <link rel="stylesheet" href="<?php echo $uri; ?>bb-admin/install.css" type="text/css" /> 
     2706        <link rel="stylesheet" href="<?php echo $uri_stylesheet; ?>" type="text/css" /> 
    25502707<?php 
    25512708        if ( function_exists( 'bb_get_option' ) && 'rtl' == bb_get_option( 'text_direction' ) ) { 
    25522709?> 
    2553         <link rel="stylesheet" href="<?php echo $uri; ?>bb-admin/install-rtl.css" type="text/css" /> 
     2710        <link rel="stylesheet" href="<?php echo $uri_stylesheet_rtl; ?>" type="text/css" /> 
    25542711<?php 
    25552712        } 
     
    25592716        <div id="container"> 
    25602717                <div class="logo"> 
    2561                         <img src="<?php echo $uri; ?>bb-admin/images/install-logo.gif" alt="bbPress Installation" /> 
     2718                        <img src="<?php echo $uri_logo; ?>" alt="bbPress Installation" /> 
    25622719                </div> 
    25632720<?php 
     
    25922749        <p><?php echo $message; ?></p> 
    25932750<?php 
    2594         if ($uri = bb_get_option('uri')) { 
     2751        if ($uri = bb_get_uri()) { 
    25952752?> 
    25962753        <p class="last"><?php printf( __('Back to <a href="%s">%s</a>.'), $uri, bb_get_option( 'name' ) ); ?></p> 
  • trunk/bb-includes/pluggable.php

    r1562 r1575  
    55        if ( !wp_validate_auth_cookie() ) { 
    66                nocache_headers(); 
    7                 header('Location: ' . bb_get_option('uri')); 
     7                header('Location: ' . bb_get_uri(null, null, BB_URI_CONTEXT_HEADER)); 
    88                exit(); 
    99        } 
     
    192192 
    193193        $lp  = parse_url($location); 
    194         $wpp = parse_url(bb_get_option('uri')); 
     194        $wpp = parse_url(bb_get_uri()); 
    195195 
    196196        $allowed_hosts = (array) apply_filters('allowed_redirect_hosts', array($wpp['host']), isset($lp['host']) ? $lp['host'] : ''); 
    197197 
    198198        if ( isset($lp['host']) && !in_array($lp['host'], $allowed_hosts) ) 
    199                 $location = bb_get_option('uri'); 
     199                $location = bb_get_uri(null, null, BB_URI_CONTEXT_HEADER); 
    200200 
    201201        wp_redirect($location, $status); 
     
    412412        if (!count(preg_grep('/^from:\s/im', $headers))) { 
    413413                if (!$from = bb_get_option('from_email')) 
    414                         if ($uri_parsed = parse_url(bb_get_option('uri'))) 
     414                        if ($uri_parsed = parse_url(bb_get_uri())) 
    415415                                if ($uri_parsed['host']) 
    416416                                        $from = 'bbpress@' . trim(preg_replace('/^www./i', '', $uri_parsed['host'])); 
  • trunk/bb-includes/registration-functions.php

    r1509 r1575  
    8383        bb_update_usermeta( $user->ID, 'newpwdkey', $resetkey ); 
    8484 
    85         $message = sprintf( __("If you wanted to reset your password, you may do so by visiting the following address:\n\n%s\n\nIf you don't want to reset your password, just ignore this email. Thanks!"), bb_get_option('uri') . "bb-reset-password.php?key=$resetkey" ); 
     85        $message = sprintf( 
     86                __("If you wanted to reset your password, you may do so by visiting the following address:\n\n%s\n\nIf you don't want to reset your password, just ignore this email. Thanks!"), 
     87                bb_get_uri( 
     88                        'bb-reset-password.php', 
     89                        array('key' => $resetkey), 
     90                        BB_URI_CONTEXT_TEXT + BB_URI_CONTEXT_BB_USER_FORMS 
     91                ) 
     92        ); 
    8693 
    8794        return bb_mail( bb_get_user_email( $user->ID ), bb_get_option('name') . ': ' . __('Password Reset'), $message ); 
     
    165172                bb_get_user_email( $user->ID ), 
    166173                bb_get_option('name') . ': ' . __('Password'), 
    167                 sprintf( $message, $user->user_login, $pass, bb_get_option('uri')
     174                sprintf($message, $user->user_login, $pass, bb_get_uri(null, null, BB_URI_CONTEXT_TEXT)
    168175        ); 
    169176} 
  • trunk/bb-includes/script-loader.php

    r1544 r1575  
    22 
    33function bb_default_scripts( &$scripts ) { 
    4         $scripts->base_url = bb_get_option( 'uri' ); 
     4        $scripts->base_url = bb_get_uri(BB_INC, null, BB_URI_CONTEXT_SCRIPT_SRC); 
     5        $scripts->base_url_admin = bb_get_uri('bb-admin/', null, BB_URI_CONTEXT_SCRIPT_SRC + BB_URI_CONTEXT_BB_ADMIN); 
    56        $scripts->default_version = bb_get_option( 'version' ); 
    67         
    7         $scripts->add( 'fat', $scripts->base_url . BB_INC . 'js/fat.js', array('add-load-event'), '1.0-RC1_3660' ); 
    8         $scripts->add( 'prototype', $scripts->base_url . BB_INC . 'js/prototype.js', false, '1.5.0' ); 
    9         $scripts->add( 'wp-ajax', $scripts->base_url . BB_INC . 'js/wp-ajax-js.php', array('prototype'), '2.1-beta2' ); 
    10         $scripts->add( 'listman', $scripts->base_url . BB_INC . 'js/list-manipulation-js.php', array('add-load-event', 'wp-ajax', 'fat'), '440' ); 
    11         $scripts->add( 'wp-ajax-response', $scripts->base_url . BB_INC . 'js/wp-ajax-response.js', array('jquery'), '20080316' ); 
     8        $scripts->add( 'fat',              $scripts->base_url . 'js/fat.js', array('add-load-event'), '1.0-RC1_3660' ); 
     9        $scripts->add( 'prototype',        $scripts->base_url . 'js/prototype.js', false, '1.5.0' ); 
     10        $scripts->add( 'wp-ajax',          $scripts->base_url . 'js/wp-ajax-js.php', array('prototype'), '2.1-beta2' ); 
     11        $scripts->add( 'listman',          $scripts->base_url . 'js/list-manipulation-js.php', array('add-load-event', 'wp-ajax', 'fat'), '440' ); 
     12        $scripts->add( 'wp-ajax-response', $scripts->base_url . 'js/wp-ajax-response.js', array('jquery'), '20080316' ); 
    1213        $scripts->localize( 'wp-ajax-response', 'wpAjax', array( 
    1314                'noPerm' => __('You do not have permission to do that.'), 
    1415                'broken' => __('An unidentified error has occurred.') 
    1516        ) ); 
    16         $scripts->add( 'wp-lists', $scripts->base_url . BB_INC . 'js/wp-lists.js', array('wp-ajax-response','jquery-color'), '20080411' ); 
     17        $scripts->add( 'wp-lists',         $scripts->base_url . 'js/wp-lists.js', array('wp-ajax-response','jquery-color'), '20080411' ); 
    1718        $scripts->localize( 'wp-lists', 'wpListL10n', array( 
    18                 'url' => "{$scripts->base_url}bb-admin/admin-ajax.php" 
     19                'url' => $scripts->base_url_admin . 'admin-ajax.php' 
    1920        ) ); 
    20         $scripts->add( 'topic', $scripts->base_url . BB_INC . 'js/topic.js', array('wp-lists'), '20080506' ); 
    21         $scripts->add( 'jquery', $scripts->base_url . BB_INC . 'js/jquery/jquery.js', false, '1.1.3.1'); 
    22         $scripts->add( 'interface', $scripts->base_url . BB_INC . 'js/jquery/interface.js', array('jquery'), '1.2.3'); 
    23         $scripts->add( 'jquery-color', $scripts->base_url . BB_INC . 'js/jquery/jquery.color.js', array('jquery'), '2.0-4561' ); 
    24         $scripts->add( 'add-load-event', $scripts->base_url . BB_INC . 'js/add-load-event.js' ); 
    25         $scripts->add( 'content-forums', $scripts->base_url . 'bb-admin/js/content-forums.js', array('listman', 'interface'), '20080309' ); 
     21        $scripts->add( 'topic',            $scripts->base_url . 'js/topic.js', array('wp-lists'), '20080506' ); 
     22        $scripts->add( 'jquery',           $scripts->base_url . 'js/jquery/jquery.js', false, '1.1.3.1'); 
     23        $scripts->add( 'interface',        $scripts->base_url . 'js/jquery/interface.js', array('jquery'), '1.2.3'); 
     24        $scripts->add( 'jquery-color',     $scripts->bas