Changeset 1264 for trunk/wp-admin/import-rss.php
- Timestamp:
- 05/12/2004 07:42:42 AM (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/import-rss.php
r1134 r1264 9 9 $timezone_offset = 0; // GMT offset of posts your importing 10 10 11 function unhtmlentities($string) { // From php.net for < 4.3 compat 12 $trans_tbl = get_html_translation_table(HTML_ENTITIES); 13 $trans_tbl = array_flip($trans_tbl); 14 return strtr($string, $trans_tbl); 15 } 11 16 12 17 $add_hours = intval($timezone_offset); … … 58 63 <p>You want to define where the RSS file we'll be working with is, for example: </p> 59 64 <p><code>define('RSSFILE', 'rss.xml');</code></p> 60 <p>You have to do this manually for security reasons.</p> 61 <p>If you've done that and you’re all ready, <a href="import-rss.php?step=1">let's go</a>!</p> 65 <p>You have to do this manually for security reasons. When you're done reload this page and we'll take you to the next step.</p> 66 <?php if ('' != RSSFILE) : ?> 67 <h2 style="text-align: right;"><a href="import-rss.php?step=1">Begin RSS Import »</a></h2> 68 <?php endif; ?> 62 69 <?php 63 70 break; 64 71 65 72 case 1: 66 if ('' != RSSFILE && !file_exists(RSSFILE)) die("The file you specified does not seem to exist. Please check the path you've given.");67 if ('' == RSSFILE) die("You must edit the RSSFILE line as described on the <a href='import-rss.php'>previous page</a> to continue.");68 73 69 74 // Bring in the data … … 94 99 endif; 95 100 96 $post_date = date('Y-m-d H:i:s', $date);101 $post_date = gmdate('Y-m-d H:i:s', $date); 97 102 98 103 preg_match_all('|<category>(.*?)</category>|is', $post, $categories); … … 109 114 if (!$content) : // This is for feeds that put content in description 110 115 preg_match('|<description>(.*?)</description>|is', $post, $content); 111 $content = addslashes( trim($content[1]) ); 116 $content = $wpdb->escape( unhtmlentities( trim($content[1]) ) ); 117 endif; 118 119 // Clean up content 120 $content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $content); 121 $content = str_replace('<br>', '<br />', $content); 122 $content = str_replace('<hr>', '<hr />', $content); 123 124 // This can mess up on posts with no titles, but checking content is much slower 125 // So we do it as a last resort 126 if ('' == $title) : 127 $dupe = $wpdb->get_var("SELECT ID FROM $tableposts WHERE post_content = '$content' AND post_date = '$post_date'"); 128 else : 129 $dupe = $wpdb->get_var("SELECT ID FROM $tableposts WHERE post_title = '$title' AND post_date = '$post_date'"); 112 130 endif; 113 131 114 132 // Now lets put it in the DB 115 if ($ wpdb->get_var("SELECT ID FROM $tableposts WHERE post_title = '$title' AND post_date = '$post_date'")) :133 if ($dupe) : 116 134 echo 'Post already imported'; 117 135 else : … … 125 143 if (0 != count($categories)) : 126 144 foreach ($categories as $post_category) : 145 $post_category = unhtmlentities($post_category); 127 146 // See if the category exists yet 128 147 $cat_id = $wpdb->get_var("SELECT cat_ID from $tablecategories WHERE cat_name = '$post_category'");
Note: See TracChangeset
for help on using the changeset viewer.