Skip to:
Content

bbPress.org

Changes from tags/0.9.0.6 at r2338 to tags/0.9.0.7 at r3715


Ignore:
Location:
tags/0.9.0.7
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • tags/0.9.0.7/bb-admin/admin-functions.php

    r2338 r3715  
    7777{
    7878    global $bb_menu;
     79    global $bb_registered_plugin_callbacks;
     80    if ( empty( $bb_registered_plugin_callbacks ) ) {
     81        $bb_registered_plugin_callbacks = array();
     82    }
     83
    7984    if ($display_name && $capability && $file_name) {
     85        if ( strpos( $file_name, '.php' ) === false ) {
     86            $bb_registered_plugin_callbacks[] = $file_name;
     87        }
    8088        $bb_menu[] = array($display_name, $capability, $file_name);
    8189    }
     
    8593{
    8694    global $bb_submenu;
     95    global $bb_registered_plugin_callbacks;
     96    if ( empty( $bb_registered_plugin_callbacks ) ) {
     97        $bb_registered_plugin_callbacks = array();
     98    }
     99
    87100    if ($display_name && $capability && $file_name) {
     101        if ( strpos( $file_name, '.php' ) === false ) {
     102            $bb_registered_plugin_callbacks[] = $file_name;
     103        }
    88104        $bb_submenu[$parent][] = array($display_name, $capability, $file_name);
    89105    }
  • tags/0.9.0.7/bb-admin/admin.php

    r2338 r3715  
    1313require('admin-functions.php');
    1414
    15 if ( isset($_GET['plugin']) )
    16     $bb_admin_page = $_GET['plugin'];
    17 else    $bb_admin_page = bb_find_filename($_SERVER['PHP_SELF']);
     15$bb_admin_page = bb_find_filename( $_SERVER['PHP_SELF'] );
     16
     17$_check_callback = false;
     18if ( $bb_admin_page == 'admin-base.php' ) {
     19    $bb_admin_page = (string) @$_GET['plugin'];
     20    $_check_callback = true;
     21}
    1822
    1923bb_admin_menu_generator();
    2024bb_get_current_admin_menu();
     25
     26if ( $_check_callback ) {
     27    if ( empty( $bb_registered_plugin_callbacks ) || empty( $bb_admin_page ) || !in_array( $bb_admin_page, $bb_registered_plugin_callbacks ) ) {
     28        unset( $bb_admin_page );
     29    }
     30}
    2131?>
  • tags/0.9.0.7/bb-admin/bb-do-counts.php

    r2338 r3715  
    1616if ( isset($_POST['topic-posts']) && 1 == $_POST['topic-posts'] ):
    1717    echo "\t<li>\n";
    18     if ( $topics = (array) $bbdb->get_results("SELECT topic_id, COUNT(post_id) AS count FROM $bbdb->posts WHERE post_status = '0' GROUP BY topic_id") ) :
    19         echo "\t\t" . __('Counting posts...') . "<br />\n";
    20         foreach ($topics as $topic)
    21             $bbdb->query("UPDATE $bbdb->topics SET topic_posts = '$topic->count' WHERE topic_id = '$topic->topic_id'");
    22         unset($topics, $topic);
    23     endif;
     18    $sql = "INSERT INTO `$bbdb->topics` (`topic_id`, `topic_posts`) (SELECT `topic_id`, COUNT(`post_status`) as `topic_posts` FROM `$bbdb->posts` WHERE `post_status` = '0' GROUP BY `topic_id`) ON DUPLICATE KEY UPDATE `topic_posts` = VALUES(`topic_posts`);";
     19    $bbdb->query($sql);
    2420    echo "\t\t" . __('Done counting posts.');
    2521    echo "\n\t</li>\n";
     
    2824if ( isset($_POST['topic-deleted-posts']) && 1 == $_POST['topic-deleted-posts'] ):
    2925    echo "\t<li>\n";
    30     $old = (array) $bbdb->get_col("SELECT topic_id FROM $bbdb->topicmeta WHERE meta_key = 'deleted_posts'");
    31     $old = array_flip($old);
    32     if ( $topics = (array) $bbdb->get_results("SELECT topic_id, COUNT(post_id) AS count FROM $bbdb->posts WHERE post_status != '0' GROUP BY topic_id") ) :
    33         echo "\t\t" . __('Counting deleted posts...') . "<br />\n";
    34         foreach ( $topics as $topic ) :
    35             bb_update_topicmeta( $topic->topic_id, 'deleted_posts', $topic->count );
    36             unset($old[$topic->topic_id]);
    37         endforeach;
    38         unset($topics, $topic);
    39     endif;
    40     if ( $old ) :
    41         $old = join(',', array_flip($old));
    42         $bbdb->query("DELETE FROM $bbdb->topicmeta WHERE topic_id IN ($old) AND meta_key = 'deleted_posts'");
    43         echo "\t\t" . __('Done counting deleted posts.');
    44     else :
    45         echo "\t\t" . __('No deleted posts to count.');
    46     endif;
     26    $sql_delete = "DELETE FROM `$bbdb->topicmeta` WHERE `meta_key` = 'deleted_posts';";
     27    if ( $bbdb->query( $sql_delete ) ) {
     28        $sql = "INSERT INTO `$bbdb->topicmeta` (`topic_id`, `meta_key`, `meta_value`) (SELECT `topic_id`, 'deleted_posts', COUNT(`post_status`) as `meta_value` FROM `$bbdb->posts` WHERE `post_status` != '0' GROUP BY `topic_id`);";
     29        $bbdb->query( $sql );
     30    }
     31    echo "\t\t" . __('Done counting deleted posts.');
    4732    echo "\n\t</li>\n";
    4833endif;
     
    5035if ( isset($_POST['forums']) && 1 == $_POST['forums'] ) :
    5136    echo "\t<li>\n";
    52     if ( $all_forums = (array) $bbdb->get_col("SELECT forum_id FROM $bbdb->forums") ) :
    53         echo "\t\t" . __('Counting forum topics and posts...') . "<br />\n";
    54         $all_forums = array_flip( $all_forums );
    55         $forums = $bbdb->get_results("SELECT forum_id, COUNT(topic_id) AS topic_count, SUM(topic_posts) AS post_count FROM $bbdb->topics
    56             WHERE topic_status = 0 GROUP BY forum_id");
    57         foreach ( (array) $forums as $forum ) :
    58             $bbdb->query("UPDATE $bbdb->forums SET topics = '$forum->topic_count', posts = '$forum->post_count' WHERE forum_id = '$forum->forum_id'");
    59             unset($all_forums[$forum->forum_id]);
    60         endforeach;
    61         if ( $all_forums ) :
    62             $all_forums = implode(',', array_flip( $all_forums ) );
    63             $bbdb->query("UPDATE $bbdb->forums SET topics = 0, posts = 0 WHERE forum_id IN ($all_forums)");
    64         endif;
    65         unset($all_forums, $forums, $forum);
    66     endif;
     37    $sql = "INSERT INTO `$bbdb->forums` (`forum_id`, `topics`) (SELECT `forum_id`, COUNT(`topic_status`) as `topics` FROM `$bbdb->topics` WHERE `topic_status` = '0' GROUP BY `forum_id`) ON DUPLICATE KEY UPDATE `topics` = VALUES(`topics`);";
     38    $bbdb->query( $sql );
     39    $sql = "INSERT INTO `$bbdb->forums` (`forum_id`, `posts`) (SELECT `forum_id`, COUNT(`post_status`) as `posts` FROM `$bbdb->posts` WHERE `post_status` = '0' GROUP BY `forum_id`) ON DUPLICATE KEY UPDATE `posts` = VALUES(`posts`);";
     40    $bbdb->query( $sql );
    6741    echo "\t\t" . __('Done counting forum topics and posts.');
    6842    echo "\n\t</li>\n";
  • tags/0.9.0.7/bb-includes/compat.php

    r2338 r3715  
    105105}
    106106
    107 if ( !function_exists( '_mb_strcut' ) ) {
     107if ( !function_exists( '_mb_substr' ) ) {
    108108    function _mb_substr( $str, $start, $length = null, $encoding = null )
    109109    {
  • tags/0.9.0.7/bb-includes/default-filters.php

    r2338 r3715  
    3333
    3434add_filter('edit_text', 'bb_code_trick_reverse');
    35 add_filter('edit_text', 'htmlspecialchars');
     35add_filter('edit_text', 'wp_specialchars_decode');
    3636add_filter('edit_text', 'trim', 15);
    3737
  • tags/0.9.0.7/bb-includes/functions.php

    r2338 r3715  
    151151function get_latest_topics( $forum = false, $page = 1, $exclude = '') {
    152152    if ( $exclude ) {
    153         $exclude = '-' . str_replace(',', '-,', $exclude);
     153        $exclude = '-' . str_replace(',', ',-', $exclude);
    154154        $exclude = str_replace('--', '-', $exclude);
    155155        if ( $forum )
     
    14481448        break;
    14491449    case 'version' :
    1450         return '0.9.0.6'; // Don't filter
     1450        return '0.9.0.7'; // Don't filter
    14511451        break;
    14521452    case 'bb_db_version' :
     
    14611461    case 'url' :
    14621462        $option = 'uri';
     1463        break;
    14631464    case 'bb_table_prefix' :
    14641465    case 'table_prefix' :
  • tags/0.9.0.7/bb-includes/pluggable.php

    r2338 r3715  
    154154        return false;
    155155
    156     $user = bb_get_user_by_name($username);
    157     if ( ! $user )
    158         return false;
     156    $username = sanitize_user( $username, true );
     157    global $bbdb;
     158    if ( $user = $bbdb->get_row( $bbdb->prepare( "SELECT * FROM $bbdb->users WHERE user_login = %s", $username ) ) ) {
     159        bb_append_meta( $user, 'user' );
     160    }
     161   
     162    if ( empty( $user->ID ) ) {
     163        return false;
     164    }
    159165
    160166    return $user->ID;
  • tags/0.9.0.7/bb-includes/registration-functions.php

    r2338 r3715  
    5353    global $bbdb;
    5454    $key = sanitize_user( $key, true );
    55     if ( empty( $key ) )
     55    if ( empty( $key ) || !is_string( $key ) )
    5656        bb_die(__('Key not found.'));
    5757    if ( !$user_id = $bbdb->get_var( $bbdb->prepare( "SELECT user_id FROM $bbdb->usermeta WHERE meta_key = 'newpwdkey' AND meta_value = %s", $key ) ) )
  • tags/0.9.0.7/bb-includes/template-functions.php

    r2338 r3715  
    14881488            ) {
    14891489                echo "\t<dt>{$label[1]}</dt>\n";
    1490                 echo "\t<dd>" . make_clickable( $val ) . "</dd>\n";
     1490
     1491                $val = make_clickable( $val );
     1492                if (isset($label[2]) && !empty($label[2]))
     1493                    if (preg_match("#^<a#i", $val))
     1494                        $val = preg_replace("#^<a#i", '<a class="' . attribute_escape($label[2]) . '"', $val);
     1495                    else
     1496                        $val = '<span class="' . attribute_escape($label[2]) . '">' . $val . '</span>';
     1497               
     1498                echo "\t<dd>" . $val . "</dd>\n";
    14911499            }
    14921500        }
     
    15311539            $name = attribute_escape( $key );
    15321540            $type = isset($label[2]) ? attribute_escape( $label[2] ) : 'text';
     1541            $checked = false;
    15331542
    15341543            if ( in_array( $key, $error_codes ) ) {
    15351544                $class .= ' form-invalid';
    15361545                $data = $errors->get_error_data( $key );
    1537                 if ( isset($data['data']) )
    1538                     $value = $data['data'];
    1539                 else
    1540                     $value = $_POST[$key];
     1546
     1547                if ( 'checkbox' == $type ) {
     1548                    if ( isset($data['data']) )
     1549                        $checked = $data['data'];
     1550                    else
     1551                        $checked = $_POST[$key];
     1552                    $value = $label[3];
     1553                    $checked = $checked == $value;
     1554                } else {
     1555                    if ( isset($data['data']) )
     1556                        $value = $data['data'];
     1557                    else
     1558                        $value = $_POST[$key];
     1559                }
    15411560
    15421561                $message = wp_specialchars( $errors->get_error_message( $key ) );
    15431562                $message = "<p class='error'>$message</p>";
    15441563            } else {
    1545                 $value = $user->$key;
     1564                if ( 'checkbox' == $type ) {
     1565                    $checked = $user->$key == $label[3] || $label[4] == $label[3];
     1566                    $value = $label[3];
     1567                } else {
     1568                    $value = isset($user->$key) ? $user->$key : '';
     1569                }
    15461570                $message = '';
    15471571            }
     1572
     1573            $checked = $checked ? ' checked="checked"' : '';
    15481574            $value = attribute_escape( $value );
    15491575
     
    15531579    <th scope="row"><label for="<?php echo $name; ?>"><?php echo $title; ?></label></th>
    15541580    <td>
    1555         <input name="<?php echo $name; ?>" type="<?php echo $type; ?>" id="<?php echo $name; ?>" value="<?php echo $value; ?>" />
     1581        <input name="<?php echo $name; ?>" type="<?php echo $type; ?>" id="<?php echo $name; ?>" value="<?php echo $value; ?>"<?php echo $checked; ?> />
    15561582        <?php echo $message; ?>
    15571583    </td>
  • tags/0.9.0.7/bb-includes/wp-functions.php

    r2338 r3715  
    99/* Formatting */
    1010
    11 if ( !function_exists( 'clean_url' ) ) : // [WP6182]
     11if ( !function_exists( 'clean_url' ) ) : // [WP11615]
    1212function clean_url( $url, $protocols = null, $context = 'display' ) {
    1313    $original_url = $url;
    1414
    15     if ('' == $url) return $url;
    16     $url = preg_replace('|[^a-z0-9-~+_.?#=!&;,/:%@]|i', '', $url);
    17     $strip = array('%0d', '%0a');
    18     $url = str_replace($strip, '', $url);
     15    if ( '' == $url )
     16        return $url;
     17    $url = preg_replace('|[^a-z0-9-~+_.?#=!&;,/:%@$\|*\'()\\x80-\\xff]|i', '', $url);
     18    $strip = array('%0d', '%0a', '%0D', '%0A');
     19    $url = _deep_replace($strip, $url);
    1920    $url = str_replace(';//', '://', $url);
    2021    /* If the URL doesn't appear to contain a scheme, we
    2122     * presume it needs http:// appended (unless a relative
    2223     * link starting with / or a php file).
    23     */
     24     */
    2425    if ( strpos($url, ':') === false &&
    25         substr( $url, 0, 1 ) != '/' && !preg_match('/^[a-z0-9-]+?\.php/i', $url) )
     26        substr( $url, 0, 1 ) != '/' && substr( $url, 0, 1 ) != '#' && !preg_match('/^[a-z0-9-]+?\.php/i', $url) )
    2627        $url = 'http://' . $url;
    2728
    28     // Replace ampersands ony when displaying.
    29     if ( 'display' == $context )
    30         $url = preg_replace('/&([^#])(?![a-z]{2,8};)/', '&#038;$1', $url);
     29    // Replace ampersands and single quotes only when displaying.
     30    if ( 'display' == $context ) {
     31        $url = wp_kses_normalize_entities( $url );
     32        $url = str_replace( '&amp;', '&#038;', $url );
     33        $url = str_replace( "'", '&#039;', $url );
     34    }
    3135
    3236    if ( !is_array($protocols) )
    33         $protocols = array('http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet');
     37        $protocols = array ('http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet', 'mms', 'rtsp', 'svn');
    3438    if ( wp_kses_bad_protocol( $url, $protocols ) != $url )
    3539        return '';
    3640
    3741    return apply_filters('clean_url', $url, $original_url, $context);
     42}
     43endif;
     44
     45if ( !function_exists( '_deep_replace' ) ) : // [WP11615]
     46function _deep_replace($search, $subject){
     47    $found = true;
     48    while($found) {
     49        $found = false;
     50        foreach( (array) $search as $val ) {
     51            while(strpos($subject, $val) !== false) {
     52                $found = true;
     53                $subject = str_replace($val, '', $subject);
     54            }
     55        }
     56    }
     57
     58    return $subject;
     59}
     60endif;
     61
     62if ( !function_exists( 'esc_url' ) ) : // [WP11383]
     63function esc_url( $url, $protocols = null ) {
     64    return clean_url( $url, $protocols, 'display' );
    3865}
    3966endif;
     
    468495endif;
    469496
    470 if ( !function_exists('make_clickable') ) : // [WP4387]
     497if ( !function_exists('make_clickable') ) : // [WP12250]
    471498function make_clickable($ret) {
    472499    $ret = ' ' . $ret;
    473500    // in testing, using arrays here was found to be faster
    474     $ret = preg_replace(
    475         array(
    476             '#([\s>])([\w]+?://[\w\#$%&~/.\-;:=,?@\[\]+]*)#is',
    477             '#([\s>])((www|ftp)\.[\w\#$%&~/.\-;:=,?@\[\]+]*)#is',
    478             '#([\s>])([a-z0-9\-_.]+)@([^,< \n\r]+)#i'),
    479         array(
    480             '$1<a href="$2" rel="nofollow">$2</a>',
    481             '$1<a href="http://$2" rel="nofollow">$2</a>',
    482             '$1<a href="mailto:$2@$3">$2@$3</a>'),$ret);
     501    $ret = preg_replace_callback('#(?<=[\s>])(\()?([\w]+?://(?:[\w\\x80-\\xff\#$%&~/=?@\[\](+-]|[.,;:](?![\s<]|(\))?([\s]|$))|(?(1)\)(?![\s<.,;:]|$)|\)))+)#is', '_make_url_clickable_cb', $ret);
     502    $ret = preg_replace_callback('#([\s>])((www|ftp)\.[\w\\x80-\\xff\#$%&~/.\-;:=,?@\[\]+]+)#is', '_make_web_ftp_clickable_cb', $ret);
     503    $ret = preg_replace_callback('#([\s>])([.0-9a-z_+-]+)@(([0-9a-z-]+\.)+[0-9a-z]{2,})#i', '_make_email_clickable_cb', $ret);
    483504    // this one is not in an array because we need it to run last, for cleanup of accidental links within links
    484505    $ret = preg_replace("#(<a( [^>]+?>|>))<a [^>]+?>([^>]+?)</a></a>#i", "$1$3</a>", $ret);
    485506    $ret = trim($ret);
    486507    return $ret;
     508}
     509endif;
     510
     511if ( !function_exists( '_make_url_clickable_cb' ) ) : // [WP12088]
     512function _make_url_clickable_cb($matches) {
     513    $url = $matches[2];
     514
     515    $url = esc_url($url);
     516    if ( empty($url) )
     517            return $matches[0];
     518
     519    return $matches[1] . "<a href=\"$url\" rel=\"nofollow\">$url</a>";
     520}
     521endif;
     522
     523if ( !function_exists( '_make_web_ftp_clickable_cb' ) ) : // [WP11844]
     524function _make_web_ftp_clickable_cb($matches) {
     525    $ret = '';
     526    $dest = $matches[2];
     527    $dest = 'http://' . $dest;
     528    $dest = esc_url($dest);                                                       
     529    if ( empty($dest) )
     530        return $matches[0];
     531
     532    // removed trailing [.,;:)] from URL
     533    if ( in_array( substr($dest, -1), array('.', ',', ';', ':', ')') ) === true ) {
     534        $ret = substr($dest, -1);
     535        $dest = substr($dest, 0, strlen($dest)-1);
     536    }
     537    return $matches[1] . "<a href=\"$dest\" rel=\"nofollow\">$dest</a>$ret";
     538}
     539endif;
     540
     541if ( !function_exists( '_make_email_clickable_cb' ) ) : // [WP6449]
     542function _make_email_clickable_cb($matches) {
     543    $email = $matches[2] . '@' . $matches[3];
     544    return $matches[1] . "<a href=\"mailto:$email\">$email</a>";
    487545}
    488546endif;
  • tags/0.9.0.7/bb-plugins/akismet.php

    r2338 r3715  
    1010
    1111// Add filters for the admin area
    12 add_action('bb_admin_menu_generator', 'bb_ksd_configuration_page_add');
    1312add_action('bb_admin-header.php', 'bb_ksd_configuration_page_process');
    14 
    15 function bb_ksd_configuration_page_add() {
    16     bb_admin_add_submenu(__('Akismet Configuration'), 'use_keys', 'bb_ksd_configuration_page');
    17 }
    1813
    1914function bb_ksd_configuration_page() {
     
    256251}
    257252
    258 function bb_ksd_admin_menu() {
    259     global $bb_submenu;
    260     $bb_submenu['content.php'][] = array(__('Akismet Spam'), 'moderate', 'bb_ksd_admin_page');
    261 }
    262253
    263254function bb_ksd_delete_post( $post_id, $new_status, $old_status )
     
    281272        return;
    282273    }
     274}
     275
     276function bb_ksd_admin_menu() {
     277    bb_admin_add_submenu(__('Akismet Configuration'), 'use_keys', 'bb_ksd_configuration_page');
     278    bb_admin_add_submenu(__('Akismet Spam'), 'moderate', 'bb_ksd_admin_page', 'content.php');
    283279}
    284280
     
    322318add_action( 'bb_delete_post', 'bb_ksd_delete_post', 10, 3);
    323319add_filter( 'post_delete_link', 'bb_ksd_post_delete_link', 10, 2 );
    324 ?>
  • tags/0.9.0.7/search.php

    r2338 r3715  
    1010    add_filter( 'bb_recent_search_fields',   create_function( '$f', 'return $f . ", MAX(post_time) AS post_time";' ) );
    1111    add_filter( 'bb_recent_search_group_by', create_function( '', 'return "t.topic_id";' ) );
    12     $bb_query_form->BB_Query_Form( 'post', array(), array( 'per_page' => 5, 'post_status' => 0, 'topic_status' => 0, 'post_text' => $q, 'forum_id', 'tag', 'topic_author', 'post_author' ), 'bb_recent_search' );
     12    $bb_query_form->BB_Query_Form( 'post', array(), array( 'order_by' => 'p.post_time', 'per_page' => 5, 'post_status' => 0, 'topic_status' => 0, 'post_text' => $q, 'forum_id', 'tag', 'topic_author', 'post_author' ), 'bb_recent_search' );
    1313    $recent = $bb_query_form->results;
    1414
Note: See TracChangeset for help on using the changeset viewer.