Make WordPress Core


Ignore:
Timestamp:
02/09/2004 08:41:08 AM (23 years ago)
Author:
saxmatt
Message:

Import fixes from Phil Ringnalda.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/import-mt.php

    r757 r847  
    8181        echo "<li>Importing post... ";
    8282
    83         // Take the comments out first
     83        // Take the pings out first
     84        preg_match("|(-----\n\nPING:.*)|s", $post, $pings);
     85        $post = preg_replace("|(-----\n\nPING:.*)|s", '', $post);
     86
     87        // Then take the comments out
    8488        preg_match("|(-----\nCOMMENT:.*)|s", $post, $comments);
    8589        $post = preg_replace("|(-----\nCOMMENT:.*)|s", '', $post);
    … …  
    131135                $post_allow_comments = $value;
    132136                if ($post_allow_comments == 1) {
    133                     $post_allow_comments = "open";
     137                    $comment_status = 'open';
    134138                } else {
    135                     $post_allow_comments = "closed";
     139                    $comment_status = 'closed';
    136140                }
    137141                break;
    … …  
    142146                $post_allow_pings = trim($meta[2][0]);
    143147                if ($post_allow_pings == 1) {
    144                     $post_allow_pings = "open";
     148                    $post_allow_pings = 'open';
    145149                } else {
    146                     $post_allow_pings = "closed";
     150                    $post_allow_pings = 'closed';
    147151                }
    148152                break;
    … …  
    223227                        $comment_date = date('Y-m-d H:i:s', strtotime($comment_date));
    224228                        $comment = preg_replace('|(\n?DATE:.*)|', '', $comment);
    225                
     229
    226230                        $comment_content = addslashes(trim($comment));
    227231                        $comment_content = str_replace('-----', '', $comment_content);
    228                        
     232
    229233                        // Check if it's already there
    230234                        if (!$wpdb->get_row("SELECT * FROM $tablecomments WHERE comment_date = '$comment_date' AND comment_content = '$comment_content'")) {
    … …  
    234238                                echo " Comment added.";
    235239                        }
     240                }
     241                }
     242
     243                // Finally the pings
     244                // fix the double newline on the first one
     245                $pings[0] = str_replace("-----\n\n", "-----\n", $pings[0]);
     246                $pings = explode("-----\nPING:", $pings[0]);
     247                foreach ($pings as $ping) {
     248                if ('' != trim($ping)) {
     249                        // 'Author'
     250                        preg_match("|BLOG NAME:(.*)|", $ping, $comment_author);
     251                        $comment_author = addslashes(trim($comment_author[1]));
     252                        $ping = preg_replace('|(\n?BLOG NAME:.*)|', '', $ping);
     253
     254                        $comment_email = '';
     255
     256                        preg_match("|IP:(.*)|", $ping, $comment_ip);
     257                        $comment_ip = trim($comment_ip[1]);
     258                        $ping = preg_replace('|(\n?IP:.*)|', '', $ping);
     259
     260                        preg_match("|URL:(.*)|", $ping, $comment_url);
     261                        $comment_url = addslashes(trim($comment_url[1]));
     262                        $ping = preg_replace('|(\n?URL:.*)|', '', $ping);
     263
     264                        preg_match("|DATE:(.*)|", $ping, $comment_date);
     265                        $comment_date = trim($comment_date[1]);
     266                        $comment_date = date('Y-m-d H:i:s', strtotime($comment_date));
     267                        $ping = preg_replace('|(\n?DATE:.*)|', '', $ping);
     268     
     269                        preg_match("|TITLE:(.*)|", $ping, $ping_title);
     270                        $ping_title = addslashes(trim($ping_title[1]));
     271                        $ping = preg_replace('|(\n?TITLE:.*)|', '', $ping);
     272
     273                        $comment_content = addslashes(trim($ping));
     274                        $comment_content = str_replace('-----', '', $comment_content);
     275                       
     276                        $comment_content = "<trackback /><strong>$ping_title</strong>\n$comment_content";
     277     
     278                        // Check if it's already there
     279                        if (!$wpdb->get_row("SELECT * FROM $tablecomments WHERE comment_date = '$comment_date' AND comment_content = '$comment_content'")) {
     280                                $wpdb->query("INSERT INTO $tablecomments (comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_author_IP, comment_date, comment_content, comment_approved)
     281                                VALUES
     282                                ($post_id, '$comment_author', '$comment_email', '$comment_url', '$comment_ip', '$comment_date', '$comment_content', '1')");
     283                                echo " Comment added.";
     284                        }
     285
    236286                }
    237287                }
Note: See TracChangeset for help on using the changeset viewer.