Changeset 489

Show
Ignore:
Timestamp:
01/02/06 17:10:03 (3 years ago)
Author:
donncha
Message:

WP Merge

Files:

Legend:

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

    r477 r489  
    12501250        } 
    12511251 
    1252         $parent = get_admin_page_parent(); 
     1252        $hook = get_plugin_page_hook($plugin_page, $pagenow); 
     1253 
     1254        $parent = $parent1 = get_admin_page_parent(); 
    12531255        if (empty ($parent)) { 
    12541256                foreach ($menu as $menu_array) { 
     
    12581260                                        return $menu_array[3]; 
    12591261                                } else 
    1260                                         if (isset ($plugin_page) && ($plugin_page == $menu_array[2])) { 
     1262                                        if (isset ($plugin_page) && ($plugin_page == $menu_array[2]) && ($hook == $menu_array[3])) { 
    12611263                                                $title = $menu_array[3]; 
    12621264                                                return $menu_array[3]; 
     
    12721274                                                return $submenu_array[3]; 
    12731275                                        } else 
    1274                                                 if (isset ($plugin_page) && ($plugin_page == $submenu_array[2])) { 
     1276                                                if (isset ($plugin_page) && ($plugin_page == $submenu_array[2]) && (($parent == $pagenow) || ($parent == $plugin_page) || ($plugin_page == $hook) || (($pagenow == 'admin.php') && ($parent1 != $submenu_array[2])))) { 
    12751277                                                        $title = $submenu_array[3]; 
    12761278                                                        return $submenu_array[3]; 
     
    17201722 
    17211723        // A properly uploaded file will pass this test. There should be no reason to override this one. 
    1722         if (! is_uploaded_file($file['tmp_name']) ) 
     1724        if (! @ is_uploaded_file($file['tmp_name']) ) 
    17231725                return $upload_error_handler($file, __('Specified file failed upload test.')); 
    17241726 
     
    17491751                $number = ''; 
    17501752                $filename = $file['name']; 
    1751                 while ( file_exists($uploads['path'] . "/$filename") ) 
    1752                         $filename = str_replace("$number.$ext", ++$number . ".$ext", $filename); 
     1753                if ( empty($ext) ) 
     1754                        $ext = ''; 
     1755                else 
     1756                        $ext = ".$ext"; 
     1757                while ( file_exists($uploads['path'] . "/$filename") ) { 
     1758                        if ( '' == "$number$ext" ) 
     1759                                $filename = $filename . ++$number . $ext; 
     1760                        else 
     1761                                $filename = str_replace("$number$ext", ++$number . $ext, $filename); 
     1762                } 
    17531763        } 
    17541764 
    17551765        // Move the file to the uploads dir 
    17561766        $new_file = $uploads['path'] . "/$filename"; 
    1757         if ( false === move_uploaded_file($file['tmp_name'], $new_file) ) 
     1767        if ( false === @ move_uploaded_file($file['tmp_name'], $new_file) ) 
    17581768                die(printf(__('The uploaded file could not be moved to %s.'), $file['path'])); 
    17591769 
  • trunk/wp-inst/wp-admin/admin-header.php

    r483 r489  
    131131function newCatAddIn() { 
    132132        if ( !document.getElementById('jaxcat') ) return false; 
    133         var ajaxcat = document.createElement('p'); 
     133        var ajaxcat = document.createElement('span'); 
    134134        ajaxcat.id = 'ajaxcat'; 
    135135 
     
    205205        names = myPload( newcat.value ); 
    206206        for ( i = 0; i < ids.length; i++ ) { 
    207                 id = ids[i].replace(/[\n\r\l]+/g, ""); 
     207                id = ids[i].replace(/[\n\r]+/g, ""); 
    208208                if ( id == '-1' ) { 
    209209                        p.innerHTML = "<?php echo addslashes(__("You don't have permission to do that.")); ?>"; 
  • trunk/wp-inst/wp-admin/edit-comments.php

    r430 r489  
    4545                $authordata = get_userdata( $wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $post_id") ); 
    4646                if ( current_user_can('edit_post', $post_id) ) : 
    47                         $wpdb->query("DELETE FROM $wpdb->comments WHERE comment_ID = $comment"); 
     47                        wp_set_comment_status($comment, "delete"); 
    4848                        ++$i; 
    4949                endif; 
  • trunk/wp-inst/wp-admin/execute-pings.php

    r475 r489  
    2020        } 
    2121        // Do Trackbacks 
    22         while ($trackback = $wpdb->get_row("SELECT ID FROM $wpdb->posts WHERE TRIM(to_ping) != '' AND post_status != 'draft' LIMIT 1")) { 
    23                 echo "Trackback : $trackback->ID<br/>"; 
    24                 do_trackbacks($trackback->ID); 
     22        $trackbacks = $wpdb->get_results("SELECT ID FROM $wpdb->posts WHERE TRIM(to_ping) != '' AND post_status != 'draft'"); 
     23 
     24        if (is_array($trackbacks) && count($trackbacks)) { 
     25                foreach ($trackbacks as $trackback  ) { 
     26                        echo "Trackback : $trackback->ID<br/>"; 
     27                        do_trackbacks($trackback->ID); 
     28                } 
    2529        } 
    2630} 
  • trunk/wp-inst/wp-admin/import/livejournal.php

    r205 r489  
     1<?php 
     2 
     3class LJ_Import { 
     4 
     5        var $file; 
     6 
     7        function header() { 
     8                echo '<div class="wrap">'; 
     9                echo '<h2>'.__('Import LiveJournal').'</h2>'; 
     10        } 
     11 
     12        function footer() { 
     13                echo '</div>'; 
     14        } 
     15 
     16        function unhtmlentities($string) { // From php.net for < 4.3 compat 
     17                $trans_tbl = get_html_translation_table(HTML_ENTITIES); 
     18                $trans_tbl = array_flip($trans_tbl); 
     19                return strtr($string, $trans_tbl); 
     20        } 
     21         
     22        function greet() { 
     23                echo '<p>'.__('Howdy! This importer allows you to extract posts from LiveJournal XML export file into your blog.  Pick a LiveJournal file to upload and click Import.').'</p>'; 
     24                wp_import_upload_form("admin.php?import=livejournal&amp;step=1"); 
     25        } 
     26 
     27        function import_posts() { 
     28                global $wpdb, $current_user; 
     29                 
     30                set_magic_quotes_runtime(0); 
     31                $importdata = file($this->file); // Read the file into an array 
     32                $importdata = implode('', $importdata); // squish it 
     33                $importdata = str_replace(array ("\r\n", "\r"), "\n", $importdata); 
     34 
     35                preg_match_all('|<entry>(.*?)</entry>|is', $importdata, $posts); 
     36                $posts = $posts[1]; 
     37                unset($importdata); 
     38                echo '<ol>';             
     39                foreach ($posts as $post) { 
     40                        flush(); 
     41                        preg_match('|<subject>(.*?)</subject>|is', $post, $post_title); 
     42                        $post_title = $wpdb->escape(trim($post_title[1])); 
     43                        if ( empty($post_title) ) { 
     44                                preg_match('|<itemid>(.*?)</itemid>|is', $post, $post_title); 
     45                                $post_title = $wpdb->escape(trim($post_title[1])); 
     46                        } 
     47 
     48                        preg_match('|<eventtime>(.*?)</eventtime>|is', $post, $post_date); 
     49                        $post_date = strtotime($post_date[1]); 
     50                        $post_date = gmdate('Y-m-d H:i:s', $post_date); 
     51 
     52                        preg_match('|<event>(.*?)</event>|is', $post, $post_content); 
     53                        $post_content = str_replace(array ('<![CDATA[', ']]>'), '', trim($post_content[1])); 
     54                        $post_content = $this->unhtmlentities($post_content); 
     55 
     56                        // Clean up content 
     57                        $post_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $post_content); 
     58                        $post_content = str_replace('<br>', '<br />', $post_content); 
     59                        $post_content = str_replace('<hr>', '<hr />', $post_content); 
     60                        $post_content = $wpdb->escape($post_content); 
     61 
     62                        $post_author = $current_user->ID; 
     63                        $post_status = 'publish'; 
     64 
     65                        echo '<li>'; 
     66                        if ($post_id = post_exists($post_title, $post_content, $post_date)) { 
     67                                printf(__('Post <i>%s</i> already exists.'), stripslashes($post_title)); 
     68                        } else { 
     69                                printf(__('Importing post <i>%s</i>...'), stripslashes($post_title)); 
     70                                $post = compact('post_author', 'post_date', 'post_content', 'post_title', 'post_status'); 
     71                                $post_id = wp_insert_post($post); 
     72                                if (!$post_id) { 
     73                                        _e("Couldn't get post ID"); 
     74                                        echo '</li>'; 
     75                                        break; 
     76                                } 
     77                        } 
     78 
     79                        preg_match_all('|<comment>(.*?)</comment>|is', $post, $comments); 
     80                        $comments = $comments[1]; 
     81                         
     82                        if ( $comments ) { 
     83                                $comment_post_ID = $post_id; 
     84                                $num_comments = 0; 
     85                                foreach ($comments as $comment) { 
     86                                        preg_match('|<event>(.*?)</event>|is', $comment, $comment_content); 
     87                                        $comment_content = str_replace(array ('<![CDATA[', ']]>'), '', trim($comment_content[1])); 
     88                                        $comment_content = $this->unhtmlentities($comment_content); 
     89 
     90                                        // Clean up content 
     91                                        $comment_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $comment_content); 
     92                                        $comment_content = str_replace('<br>', '<br />', $comment_content); 
     93                                        $comment_content = str_replace('<hr>', '<hr />', $comment_content); 
     94                                        $comment_content = $wpdb->escape($comment_content); 
     95 
     96                                        preg_match('|<eventtime>(.*?)</eventtime>|is', $comment, $comment_date); 
     97                                        $comment_date = trim($comment_date[1]); 
     98                                        $comment_date = date('Y-m-d H:i:s', strtotime($comment_date)); 
     99 
     100                                        preg_match('|<name>(.*?)</name>|is', $comment, $comment_author); 
     101                                        $comment_author = $wpdb->escape(trim($comment_author[1])); 
     102 
     103                                        preg_match('|<email>(.*?)</email>|is', $comment, $comment_author_email); 
     104                                        $comment_author_email = $wpdb->escape(trim($comment_author_email[1])); 
     105 
     106                                        $comment_approved = 1; 
     107                                        // Check if it's already there 
     108                                        if (!comment_exists($comment_author, $comment_date)) { 
     109                                                $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_date', 'comment_content', 'comment_approved'); 
     110                                                $commentdata = wp_filter_comment($commentdata); 
     111                                                wp_insert_comment($commentdata); 
     112                                                $num_comments++; 
     113                                        } 
     114                                } 
     115                        } 
     116                        if ( $num_comments ) 
     117                                printf(__('(%s comments)'), $num_comments); 
     118 
     119                        echo '</li>'; 
     120                        flush(); 
     121                        ob_flush(); 
     122                } 
     123                echo '</ol>'; 
     124        } 
     125 
     126        function import() { 
     127                $file = wp_import_handle_upload(); 
     128                if ( isset($file['error']) ) { 
     129                        echo $file['error']; 
     130                        return; 
     131                } 
     132 
     133                $this->file = $file['file']; 
     134                $this->import_posts(); 
     135                wp_import_cleanup($file['id']); 
     136                 
     137                echo '<h3>'; 
     138                printf(__('All done. <a href="%s">Have fun!</a>'), get_option('home')); 
     139                echo '</h3>'; 
     140        } 
     141 
     142        function dispatch() { 
     143                if (empty ($_GET['step'])) 
     144                        $step = 0; 
     145                else 
     146                        $step = (int) $_GET['step']; 
     147 
     148                $this->header(); 
     149                 
     150                switch ($step) { 
     151                        case 0 : 
     152                                $this->greet(); 
     153                                break; 
     154                        case 1 : 
     155                                $this->import(); 
     156                                break; 
     157                } 
     158                 
     159                $this->footer(); 
     160        } 
     161 
     162        function LJ_Import() { 
     163                // Nothing.      
     164        } 
     165} 
     166 
     167$livejournal_import = new LJ_Import(); 
     168 
     169register_importer('livejournal', 'LiveJournal', __('Import posts from LiveJournal'), array ($livejournal_import, 'dispatch')); 
     170?> 
  • trunk/wp-inst/wp-admin/import/mt.php

    r487 r489  
    5555                        ++ $this->j; 
    5656                        $this->mtnames[$this->j] = $author; //add that new mt author name to an array  
    57                         $user_id = username_exists($this->newauthornames[$j]); //check if the new author name defined by the user is a pre-existing wp user 
     57                        $user_id = username_exists($this->newauthornames[$this->j]); //check if the new author name defined by the user is a pre-existing wp user 
    5858                        if (!$user_id) { //banging my head against the desk now.  
    5959                                if ($newauthornames[$this->j] == 'left_blank') { //check if the user does not want to change the authorname 
     
    244244                                                        break; 
    245245                                                case 'ALLOW PINGS' : 
    246                                                         $post_allow_pings = trim($meta[2][0]); 
    247                                                         if ($post_allow_pings == 1) { 
    248                                                                 $post_allow_pings = 'open'; 
     246                                                        $ping_status = trim($meta[2][0]); 
     247                                                        if ($ping_status == 1) { 
     248                                                                $ping_status = 'open'; 
    249249                                                        } else { 
    250                                                                 $post_allow_pings = 'closed'; 
     250                                                                $ping_status = 'closed'; 
    251251                                                        } 
    252252                                                        break; 
     
    291291 
    292292                                $comment_post_ID = $post_id; 
     293                                $comment_approved = 1; 
    293294 
    294295                                // Now for comments 
     
    322323                                                // Check if it's already there 
    323324                                                if (!comment_exists($comment_author, $comment_date)) { 
    324                                                         $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_url', 'comment_author_email', 'comment_author_IP', 'comment_date', 'comment_content'); 
     325                                                        $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_url', 'comment_author_email', 'comment_author_IP', 'comment_date', 'comment_content', 'comment_approved'); 
    325326                                                        $commentdata = wp_filter_comment($commentdata); 
    326327                                                        wp_insert_comment($commentdata); 
     
    370371                                                // Check if it's already there 
    371372                                                if (!comment_exists($comment_author, $comment_date)) { 
    372                                                         $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_url', 'comment_author_email', 'comment_author_IP', 'comment_date', 'comment_content', 'comment_type'); 
     373                                                        $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_url', 'comment_author_email', 'comment_author_IP', 'comment_date', 'comment_content', 'comment_type', 'comment_approved'); 
    373374                                                        $commentdata = wp_filter_comment($commentdata); 
    374375                                                        wp_insert_comment($commentdata); 
  • trunk/wp-inst/wp-admin/import/rss.php

    r460 r489  
    11<?php 
    2  
    3 // Example: 
    4 // define('RSSFILE', '/home/example/public_html/rss.xml'); 
    5 define('RSSFILE', 'rss.xml'); 
    62 
    73class RSS_Import { 
  • trunk/wp-inst/wp-admin/link-import.php

    r487 r489  
    127127            } // end case 1 
    128128} // end switch 
     129 
     130include('admin-footer.php'); 
     131 
    129132?> 
    130 </body> 
    131 </html> 
  • trunk/wp-inst/wp-admin/list-manipulation.php

    r471 r489  
    3131case 'delete-page' : 
    3232        $id = (int) $_POST['id']; 
    33         if ( !current_user_can('edit_post', $post_id) )         
     33        if ( !current_user_can('edit_post', $id) )     { 
    3434                die('-1'); 
     35        } 
    3536 
    36         if ( wp_delete_post($id) ) 
     37        if ( wp_delete_post($id) ) { 
    3738                die('1'); 
    38         else  die('0'); 
     39        } else        die('0'); 
    3940        break; 
    4041case 'delete-cat' : 
  • trunk/wp-inst/wp-admin/options-permalink.php

    r465 r489  
    7878$category_base = get_settings('category_base'); 
    7979 
    80 generate_page_rewrite_rules(); 
    81  
    8280if ( (!file_exists($home_path.'.htaccess') && is_writable($home_path)) || is_writable($home_path.'.htaccess') ) 
    8381        $writable = true; 
     
    9088        $usingpi = false; 
    9189 
    92 save_mod_rewrite_rules(); 
     90$wp_rewrite->flush_rules(); 
    9391?> 
    9492 
  • trunk/wp-inst/wp-admin/options.php

    r452 r489  
    3131         
    3232        check_admin_referer(); 
    33      
     33 
    3434        if (!$_POST['page_options']) { 
    3535                foreach ($_POST as $key => $value) { 
    36                         $options[] = "$key"
     36                        $options[] = $key
    3737                } 
    3838        } else { 
     
    5555 
    5656            if( $option == 'blogdescription' || $option == 'blogname' ) 
    57                     $value = wp_filter_post_kses( $value ); 
     57                    if (current_user_can('unfiltered_html') == false) 
     58                            $value = wp_filter_post_kses( $value ); 
    5859 
    5960            if ( update_option($option, $value) ) 
     
    6667                        if ( get_settings('siteurl') != $old_siteurl || get_settings('home') != $old_home ) { 
    6768                                // If home changed, write rewrite rules to new location. 
    68                                 save_mod_rewrite_rules(); 
     69                                $wp_rewrite->flush_rules(); 
    6970                                // Get currently logged in user and password. 
    7071                                get_currentuserinfo(); 
  • trunk/wp-inst/wp-admin/plugins.php

    r469 r489  
    2929                header('Location: plugins.php?deactivate=true'); 
    3030        } 
     31        exit; 
    3132} 
    3233 
  • trunk/wp-inst/wp-admin/post.php

    r472 r489  
    241241 
    242242case 'unapprovecomment': 
    243  
    244         require_once('./admin-header.php'); 
    245243 
    246244        check_admin_referer(); 
  • trunk/wp-inst/wp-admin/templates.php

    r482 r489  
    8888        <?php if ( 'err' == $_GET['a'] ) : ?> 
    8989 <div id="message" class="error"><p><?php _e('Could not save file.') ?></p></div> 
    90         <? else: ?> 
     90        <?php else: ?> 
    9191 <div id="message" class="updated fade"><p><?php _e('File edited successfully.') ?></p></div> 
    92         <?endif; ?>    
     92        <?php endif; ?>        
    9393<?php endif; ?> 
    9494 <div class="wrap">  
  • trunk/wp-inst/wp-admin/upgrade-functions.php

    r469 r489  
    66// Functions to be called in install and upgrade scripts 
    77function upgrade_all() { 
    8         global $wp_current_db_version, $wp_db_version
     8        global $wp_current_db_version, $wp_db_version, $wp_rewrite
    99        $wp_current_db_version = __get_option('db_version'); 
    1010 
     
    3535                upgrade_160(); 
    3636 
    37         save_mod_rewrite_rules(); 
     37        $wp_rewrite->flush_rules(); 
    3838         
    3939        update_option('db_version', $wp_db_version); 
  • trunk/wp-inst/wp-includes/cache.php

    r477 r489  
    5454        var $cache_dir; 
    5555        var $cache_enabled = false; 
    56         var $expiration_time = 86400; 
     56        var $expiration_time = 900; 
    5757        var $flock_filename = 'wp_object_cache.lock'; 
    5858        var $cache = array (); 
     
    206206 
    207207                        if (!file_exists($this->cache_dir.$make_dir."index.php")) { 
     208                                $file_perms = $perms & 0000666; 
    208209                                @ touch($this->cache_dir.$make_dir."index.php"); 
     210                                @ chmod($this->cache_dir.$make_dir."index.php", $file_perms); 
    209211                        } 
    210212                } 
     
    269271                // Give the new dirs the same perms as wp-content. 
    270272                $stat = stat(ABSPATH.'wp-content'); 
    271                 $dir_perms = $stat['mode'] & 0000777; // Get the permission bits. 
     273                $dir_perms = $stat['mode'] & 0007777; // Get the permission bits. 
     274                $file_perms = $dir_perms & 0000666; // Remove execute bits for files. 
    272275 
    273276                // Make the base cache dir. 
     
    280283                if (!file_exists($this->cache_dir."index.php")) { 
    281284                        @ touch($this->cache_dir."index.php"); 
     285                        @ chmod($this->cache_dir."index.php", $file_perms); 
    282286                } 
    283287 
     
    315319                                        } 
    316320                                } 
     321                                @ chmod($cache_file, $file_perms); 
    317322                        } 
    318323                } 
  • trunk/wp-inst/wp-includes/classes.php

    r487 r489  
    382382                        $where .= " AND (ID = '$reqpage')"; 
    383383                } elseif ('' != $q['attachment']) { 
    384                         $q['attachment'] = sanitize_title($q['attachment']); 
     384                        $q['attachment'] = str_replace('%2F', '/', urlencode(urldecode($q['attachment']))); 
     385                        $attach_paths = '/' . trim($q['attachment'], '/'); 
     386                        $q['attachment'] = sanitize_title(basename($attach_paths)); 
    385387                        $q['name'] = $q['attachment']; 
    386388                        $where .= " AND post_name = '" . $q['attachment'] . "'"; 
     
    484486 
    485487                        $all_cat_ids = get_all_category_ids(); 
    486                         $q['cat'] = 0;                  
     488                        $q['cat'] = 0; $partial_match = 0; 
    487489                        foreach ( $all_cat_ids as $cat_id ) { 
    488490                                $cat = get_category($cat_id); 
     
    490492                                        $q['cat'] = $cat_id; 
    491493                                        break; 
    492                                 } 
    493                         } 
     494                                } elseif ( $cat->category_nicename == $q['category_name'] ) { 
     495                                        $partial_match = $cat_id; 
     496                                } 
     497                        } 
     498                         
     499                        //if we don't match the entire hierarchy fallback on just matching the nicename 
     500                        if (!$q['cat'] && $partial_match) { 
     501                                $q['cat'] = $partial_match; 
     502                        }                        
    494503 
    495504                        $tables = ", $wpdb->post2cat, $wpdb->categories"; 
     
    954963        function page_rewrite_rules() { 
    955964                $uris = get_settings('page_uris'); 
     965                $attachment_uris = get_settings('page_attachment_uris'); 
    956966 
    957967                $rewrite_rules = array(); 
    958968                $page_structure = $this->get_page_permastruct(); 
    959                 if( is_array( $uris ) ) 
    960                         { 
    961                                 foreach ($uris as $uri => $pagename) { 
    962                                         $this->add_rewrite_tag('%pagename%', "($uri)", 'pagename='); 
    963                                         $rewrite_rules += $this->generate_rewrite_rules($page_structure); 
    964                                 } 
    965                         } 
     969                if( is_array( $attachment_uris ) ) { 
     970                        foreach ($attachment_uris as $uri => $pagename) { 
     971                                $this->add_rewrite_tag('%pagename%', "($uri)", 'attachment='); 
     972                                $rewrite_rules += $this->generate_rewrite_rules($page_structure); 
     973                        } 
     974                } 
     975                if( is_array( $uris ) ) { 
     976                        foreach ($uris as $uri => $pagename) { 
     977                                $this->add_rewrite_tag('%pagename%', "($uri)", 'pagename='); 
     978                                $rewrite_rules += $this->generate_rewrite_rules($page_structure); 
     979                        } 
     980                } 
    966981 
    967982                return $rewrite_rules; 
     
    12261241 
    12271242                        if ($num_toks) { 
    1228                                 $post = 0; 
     1243                                $post = false; 
     1244                                $page = false; 
    12291245                                if (strstr($struct, '%postname%') || strstr($struct, '%post_id%') 
    12301246                                                || strstr($struct, '%pagename%') 
    12311247                                                || (strstr($struct, '%year%') &&  strstr($struct, '%monthnum%') && strstr($struct, '%day%') && strstr($struct, '%hour%') && strstr($struct, '%minute') && strstr($struct, '%second%'))) { 
    1232                                         $post = 1; 
     1248                                        $post = true; 
     1249                                        if  ( strstr($struct, '%pagename%') ) 
     1250                                                $page = true; 
    12331251                                        $trackbackmatch = $match . $trackbackregex; 
    12341252                                        $trackbackquery = $trackbackindex . '?' . $query . '&tb=1'; 
     
    12581276 
    12591277                                if ($post) { 
    1260                                         $rewrite = array($trackbackmatch => $trackbackquery) + $rewrite + 
    1261                                                 array($sub1 => $subquery, $sub1tb => $subtbquery, $sub1feed => $subfeedquery, $sub1feed2 => $subfeedquery) + 
    1262                                                 array($sub2 => $subquery, $sub2tb => $subtbquery, $sub2feed => $subfeedquery, $sub2feed2 => $subfeedquery); 
     1278                                        $rewrite = array($trackbackmatch => $trackbackquery) + $rewrite; 
     1279                                        if ( ! $page ) 
     1280                                                $rewrite = $rewrite + array($sub1 => $subquery, $sub1tb => $subtbquery, $sub1feed => $subfeedquery, $sub1feed2 => $subfeedquery); 
     1281                                        $rewrite = $rewrite + array($sub2 => $subquery, $sub2tb => $subtbquery, $sub2feed => $subfeedquery, $sub2feed2 => $subfeedquery); 
    12631282                                } 
    12641283                        } 
     
    13281347 
    13291348        function wp_rewrite_rules() { 
    1330                 $this->matches = 'matches'; 
    1331                 return $this->rewrite_rules(); 
     1349                $this->rules = get_option('rewrite_rules'); 
     1350                if ( empty($this->rules) ) { 
     1351                        $this->matches = 'matches'; 
     1352                        $this->rewrite_rules(); 
     1353                        update_option('rewrite_rules', $this->rules); 
     1354                } 
     1355 
     1356                return $this->rules; 
    13321357        } 
    13331358 
     
    13851410        } 
    13861411 
     1412        function flush_rules() { 
     1413                generate_page_rewrite_rules(); 
     1414                delete_option('rewrite_rules'); 
     1415                $this->wp_rewrite_rules(); 
     1416                if ( function_exists('save_mod_rewrite_rules') ) 
     1417                        save_mod_rewrite_rules(); 
     1418        } 
     1419 
    13871420        function init() { 
    13881421                $this->permalink_structure = get_settings('permalink_structure'); 
     
    14621495                        $home_path = parse_url(get_settings('home')); 
    14631496                        $home_path = $home_path['path']; 
     1497                        $home_path = trim($home_path, '/'); 
    14641498 
    14651499                        // Trim path info from the end and the leading home path from the 
     
    14681502                        // requested permalink.  
    14691503                        $req_uri = str_replace($pathinfo, '', $req_uri); 
    1470                         $req_uri = str_replace($home_path, '', $req_uri); 
    14711504                        $req_uri = trim($req_uri, '/'); 
    1472                         $pathinfo = str_replace($home_path, '', $pathinfo); 
     1505                        $req_uri = preg_replace("|^$home_path|", '', $req_uri); 
     1506                        $req_uri = trim($req_uri, '/'); 
    14731507                        $pathinfo = trim($pathinfo, '/'); 
     1508                        $pathinfo = preg_replace("|^$home_path|", '', $pathinfo); 
     1509                        $pathinfo = trim($pathinfo, '/'); 
     1510                        $self = trim($self, '/'); 
     1511                        $self = preg_replace("|^$home_path|", '', $self); 
    14741512                        $self = str_replace($home_path, '', $self); 
    14751513                        $self = trim($self, '/'); 
  • trunk/wp-inst/wp-includes/comment-functions.php

    r477 r489  
    7777        if ( ! isset($comment_parent) ) 
    7878                $comment_parent = 0; 
     79        if ( ! isset($comment_approved) ) 
     80                $comment_approved = 1; 
    7981 
    8082        $result = $wpdb->query("INSERT INTO $wpdb->comments  
  • trunk/wp-inst/wp-includes/functions-post.php

    r487 r489  
    77 */ 
    88function wp_insert_post($postarr = array()) { 
    9         global $wpdb, $allowedtags, $user_ID; 
     9        global $wpdb, $wp_rewrite, $allowedtags, $user_ID; 
    1010 
    1111        if ( is_object($postarr) ) 
     
    122122        if ($update) { 
    123123                $wpdb->query( 
    124                         "UPDATE $wpdb->posts SET 
     124                        "UPDATE IGNORE $wpdb->posts SET 
    125125                        post_author = '$post_author', 
    126126                        post_date = '$post_date', 
     
    144144        } else { 
    145145                $wpdb->query( 
    146                         "INSERT INTO $wpdb->posts 
     146                        "INSERT IGNORE INTO $wpdb->posts 
    147147                        (post_author, post_date, post_date_gmt, post_content, post_content_filtered, post_title, post_excerpt,  post_status, comment_status, ping_status, post_password, post_name, to_ping, pinged, post_modified, post_modified_gmt, post_parent, menu_order, post_mime_type) 
    148148                        VALUES