Changeset 3375
- Timestamp:
- 12/29/2005 01:25:41 AM (19 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/admin-functions.php
r3367 r3375 1751 1751 $number = ''; 1752 1752 $filename = $file['name']; 1753 while ( file_exists($uploads['path'] . "/$filename") ) 1754 $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 } 1755 1763 } 1756 1764 -
trunk/wp-admin/import/livejournal.php
r3374 r3375 3 3 class LJ_Import { 4 4 5 var $posts = array ();6 5 var $file; 7 6 … … 26 25 } 27 26 28 function get_posts() {27 function import_posts() { 29 28 global $wpdb, $current_user; 30 29 31 30 set_magic_quotes_runtime(0); 32 $ datalines= file($this->file); // Read the file into an array33 $importdata = implode('', $ datalines); // squish it31 $importdata = file($this->file); // Read the file into an array 32 $importdata = implode('', $importdata); // squish it 34 33 $importdata = str_replace(array ("\r\n", "\r"), "\n", $importdata); 35 34 36 preg_match_all('|<entry>(.*?)</entry>|is', $importdata, $this->posts); 37 $this->posts = $this->posts[1]; 38 $index = 0; 39 foreach ($this->posts as $post) { 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(); 40 41 preg_match('|<subject>(.*?)</subject>|is', $post, $post_title); 41 42 $post_title = $wpdb->escape(trim($post_title[1])); 42 43 if ( empty($post_title) ) { 43 preg_match('|< eventid>(.*?)</eventid>|is', $post, $post_title);44 preg_match('|<itemid>(.*?)</itemid>|is', $post, $post_title); 44 45 $post_title = $wpdb->escape(trim($post_title[1])); 45 46 } 46 47 47 48 preg_match('|<eventtime>(.*?)</eventtime>|is', $post, $post_date); 48 49 49 $post_date = strtotime($post_date[1]); 50 50 $post_date = gmdate('Y-m-d H:i:s', $post_date); 51 51 52 52 preg_match('|<event>(.*?)</event>|is', $post, $post_content); 53 $post_content = str_replace(array ('<![CDATA[', ']]>'), '', $wpdb->escape(trim($post_content[1]))); 54 55 if (!$post_content) { 56 // This is for feeds that put content in description 57 preg_match('|<description>(.*?)</description>|is', $post, $post_content); 58 $post_content = $wpdb->escape($this->unhtmlentities(trim($post_content[1]))); 59 } 53 $post_content = str_replace(array ('<![CDATA[', ']]>'), '', trim($post_content[1])); 54 $post_content = $this->unhtmlentities($post_content); 60 55 61 56 // Clean up content … … 63 58 $post_content = str_replace('<br>', '<br />', $post_content); 64 59 $post_content = str_replace('<hr>', '<hr />', $post_content); 60 $post_content = $wpdb->escape($post_content); 65 61 66 62 $post_author = $current_user->ID; 67 63 $post_status = 'publish'; 68 $this->posts[$index] = compact('post_author', 'post_date', 'post_content', 'post_title', 'post_status');69 $index++;70 }71 }72 64 73 function import_posts() { 74 echo '<ol>'; 75 76 foreach ($this->posts as $post) { 77 echo "<li>".__('Importing post...'); 78 79 extract($post); 80 65 echo '<li>'; 81 66 if ($post_id = post_exists($post_title, $post_content, $post_date)) { 82 _e('Post already imported');67 printf(__('Post <i>%s</i> already exists.'), stripslashes($post_title)); 83 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'); 84 71 $post_id = wp_insert_post($post); 85 72 if (!$post_id) { 86 73 _e("Couldn't get post ID"); 87 return; 74 echo '</li>'; 75 break; 88 76 } 77 } 89 78 90 _e('Done !'); 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 } 91 115 } 116 if ( $num_comments ) 117 printf(__('(%s comments)'), $num_comments); 118 92 119 echo '</li>'; 120 flush(); 121 ob_flush(); 93 122 } 94 95 123 echo '</ol>'; 96 97 124 } 98 125 … … 105 132 106 133 $this->file = $file['file']; 107 $this->get_posts();108 134 $this->import_posts(); 109 135 wp_import_cleanup($file['id']); … … 141 167 $livejournal_import = new LJ_Import(); 142 168 143 //register_importer('livejournal', 'LiveJournal', __('Import posts from LiveJournal'), array ($livejournal_import, 'dispatch'));169 register_importer('livejournal', 'LiveJournal', __('Import posts from LiveJournal'), array ($livejournal_import, 'dispatch')); 144 170 ?> -
trunk/wp-includes/comment-functions.php
r3331 r3375 77 77 if ( ! isset($comment_parent) ) 78 78 $comment_parent = 0; 79 if ( ! isset($comment_approved) ) 80 $comment_approved = 1; 79 81 80 82 $result = $wpdb->query("INSERT INTO $wpdb->comments
Note: See TracChangeset
for help on using the changeset viewer.