Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Set eol style. fixes #3264

git-svn-id: http://svn.automattic.com/wordpress/trunk@4424 1a063a9b-81f0-0310-95a4-ce76da25c4cd
  • Loading branch information...
commit c4760296741dea3a3dcb699d4eefd6b37b40f76f 1 parent ea1d50f
ryan authored
View
440 wp-admin/comment.php
@@ -1,220 +1,220 @@
-<?php
-require_once('admin.php');
-
-$parent_file = 'edit.php';
-$submenu_file = 'edit-comments.php';
-
-wp_reset_vars(array('action'));
-
-if ( isset( $_POST['deletecomment'] ) )
- $action = 'deletecomment';
-
-switch($action) {
-case 'editcomment':
- $title = __('Edit Comment');
-
- require_once ('admin-header.php');
-
- $comment = (int) $_GET['comment'];
-
- if ( ! $comment = get_comment($comment) )
- wp_die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'javascript:history.go(-1)'));
-
- if ( !current_user_can('edit_post', $comment->comment_post_ID) )
- wp_die( __('You are not allowed to edit comments on this post.') );
-
- $comment = get_comment_to_edit($comment);
-
- include('edit-form-comment.php');
-
- break;
-
-case 'confirmdeletecomment':
-case 'mailapprovecomment':
-
- require_once('./admin-header.php');
-
- $comment = (int) $_GET['comment'];
- $p = (int) $_GET['p'];
- $formaction = 'confirmdeletecomment' == $action ? 'deletecomment' : 'approvecomment';
- $nonce_action = 'confirmdeletecomment' == $action ? 'delete-comment_' : 'approve-comment_';
- $nonce_action .= $comment;
-
- if ( ! $comment = get_comment($comment) )
- wp_die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'edit.php'));
-
- if ( !current_user_can('edit_post', $comment->comment_post_ID) )
- wp_die( 'confirmdeletecomment' == $action ? __('You are not allowed to delete comments on this post.') : __('You are not allowed to edit comments on this post, so you cannot approve this comment.') );
-?>
-<div class='wrap'>
-
-<div class="narrow">
-<?php if ( 'spam' == $_GET['delete_type'] ) { ?>
-<p><?php _e('<strong>Caution:</strong> You are about to mark the following comment as spam:'); ?></p>
-<?php } elseif ( 'confirmdeletecomment' == $action ) { ?>
-<p><?php _e('<strong>Caution:</strong> You are about to delete the following comment:'); ?></p>
-<?php } else { ?>
-<p><?php _e('<strong>Caution:</strong> You are about to approve the following comment:'); ?></p>
-<?php } ?>
-
-<p><?php _e('Are you sure you want to do that?'); ?></p>
-
-<form action='<?php echo get_option('siteurl'); ?>/wp-admin/comment.php' method='get'>
-
-<table width="100%">
-<tr>
-<td><input type='button' value='<?php _e('No'); ?>' onclick="self.location='<?php echo get_option('siteurl'); ?>/wp-admin/edit-comments.php';" /></td>
-<td align="right"><input type='submit' value='<?php _e('Yes'); ?>' /></td>
-</tr>
-</table>
-
-<?php wp_nonce_field($nonce_action); ?>
-<input type='hidden' name='action' value='<?php echo $formaction; ?>' />
-<?php if ( 'spam' == $_GET['delete_type'] ) { ?>
-<input type='hidden' name='delete_type' value='spam' />
-<?php } ?>
-<input type='hidden' name='p' value='<?php echo $comment->comment_post_ID; ?>' />
-<input type='hidden' name='comment' value='<?php echo $comment->comment_ID; ?>' />
-<input type='hidden' name='noredir' value='1' />
-</form>
-
-<table class="editform" cellpadding="5">
-<tr class="alt">
-<th scope="row"><?php _e('Author:'); ?></th>
-<td><?php echo $comment->comment_author; ?></td>
-</tr>
-<?php if ( $comment->comment_author_email ) { ?>
-<tr>
-<th scope="row"><?php _e('E-mail:'); ?></th>
-<td><?php echo $comment->comment_author_email; ?></td>
-</tr>
-<?php } ?>
-<?php if ( $comment->comment_author_url ) { ?>
-<tr>
-<th scope="row"><?php _e('URL:'); ?></th>
-<td><?php echo $comment->comment_author_url; ?></td>
-</tr>
-<?php } ?>
-<tr>
-<th scope="row" valign="top"><p><?php _e('Comment:'); ?></p></th>
-<td><?php echo apply_filters( 'comment_text', $comment->comment_content ); ?></td>
-</tr>
-</table>
-
-</div>
-</div>
-<?php
- break;
-
-case 'deletecomment':
- $comment = (int) $_REQUEST['comment'];
- check_admin_referer('delete-comment_' . $comment);
-
- $p = (int) $_REQUEST['p'];
- if ( isset($_REQUEST['noredir']) ) {
- $noredir = true;
- } else {
- $noredir = false;
- }
-
- $postdata = get_post($p) or
- wp_die(sprintf(__('Oops, no post with this ID. <a href="%s">Go back</a>!'), 'edit.php'));
-
- if ( ! $comment = get_comment($comment) )
- wp_die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'edit-comments.php'));
-
- if ( !current_user_can('edit_post', $comment->comment_post_ID) )
- wp_die( __('You are not allowed to edit comments on this post.') );
-
- if ( 'spam' == $_REQUEST['delete_type'] )
- wp_set_comment_status($comment->comment_ID, 'spam');
- else
- wp_delete_comment($comment->comment_ID);
-
- if ((wp_get_referer() != '') && (false == $noredir)) {
- wp_redirect(wp_get_referer());
- } else {
- wp_redirect(get_option('siteurl') .'/wp-admin/edit-comments.php');
- }
- exit();
- break;
-
-case 'unapprovecomment':
- $comment = (int) $_GET['comment'];
- check_admin_referer('unapprove-comment_' . $comment);
-
- $p = (int) $_GET['p'];
- if (isset($_GET['noredir'])) {
- $noredir = true;
- } else {
- $noredir = false;
- }
-
- if ( ! $comment = get_comment($comment) )
- wp_die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'edit.php'));
-
- if ( !current_user_can('edit_post', $comment->comment_post_ID) )
- wp_die( __('You are not allowed to edit comments on this post, so you cannot disapprove this comment.') );
-
- wp_set_comment_status($comment->comment_ID, "hold");
-
- if ((wp_get_referer() != "") && (false == $noredir)) {
- wp_redirect(wp_get_referer());
- } else {
- wp_redirect(get_option('siteurl') .'/wp-admin/edit.php?p='.$p.'&c=1#comments');
- }
- exit();
- break;
-
-case 'approvecomment':
- $comment = (int) $_GET['comment'];
- check_admin_referer('approve-comment_' . $comment);
-
- $p = (int) $_GET['p'];
- if (isset($_GET['noredir'])) {
- $noredir = true;
- } else {
- $noredir = false;
- }
-
- if ( ! $comment = get_comment($comment) )
- wp_die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'edit.php'));
-
- if ( !current_user_can('edit_post', $comment->comment_post_ID) )
- wp_die( __('You are not allowed to edit comments on this post, so you cannot approve this comment.') );
-
- wp_set_comment_status($comment->comment_ID, "approve");
- if (get_option("comments_notify") == true) {
- wp_notify_postauthor($comment->comment_ID);
- }
-
-
- if ((wp_get_referer() != "") && (false == $noredir)) {
- wp_redirect(wp_get_referer());
- } else {
- wp_redirect(get_option('siteurl') .'/wp-admin/edit.php?p='.$p.'&c=1#comments');
- }
- exit();
- break;
-
-case 'editedcomment':
-
- $comment_ID = (int) $_POST['comment_ID'];
- $comment_post_ID = (int) $_POST['comment_post_id'];
-
- check_admin_referer('update-comment_' . $comment_ID);
-
- edit_comment();
-
- $location = ( empty($_POST['referredby']) ? "edit.php?p=$comment_post_ID&c=1" : $_POST['referredby'] ) . '#comment-' . $comment_ID;
- $location = apply_filters('comment_edit_redirect', $location, $comment_ID);
- wp_redirect($location);
-
- break;
-default:
- break;
-} // end switch
-
-include('admin-footer.php');
-
-?>
+<?php
+require_once('admin.php');
+
+$parent_file = 'edit.php';
+$submenu_file = 'edit-comments.php';
+
+wp_reset_vars(array('action'));
+
+if ( isset( $_POST['deletecomment'] ) )
+ $action = 'deletecomment';
+
+switch($action) {
+case 'editcomment':
+ $title = __('Edit Comment');
+
+ require_once ('admin-header.php');
+
+ $comment = (int) $_GET['comment'];
+
+ if ( ! $comment = get_comment($comment) )
+ wp_die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'javascript:history.go(-1)'));
+
+ if ( !current_user_can('edit_post', $comment->comment_post_ID) )
+ wp_die( __('You are not allowed to edit comments on this post.') );
+
+ $comment = get_comment_to_edit($comment);
+
+ include('edit-form-comment.php');
+
+ break;
+
+case 'confirmdeletecomment':
+case 'mailapprovecomment':
+
+ require_once('./admin-header.php');
+
+ $comment = (int) $_GET['comment'];
+ $p = (int) $_GET['p'];
+ $formaction = 'confirmdeletecomment' == $action ? 'deletecomment' : 'approvecomment';
+ $nonce_action = 'confirmdeletecomment' == $action ? 'delete-comment_' : 'approve-comment_';
+ $nonce_action .= $comment;
+
+ if ( ! $comment = get_comment($comment) )
+ wp_die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'edit.php'));
+
+ if ( !current_user_can('edit_post', $comment->comment_post_ID) )
+ wp_die( 'confirmdeletecomment' == $action ? __('You are not allowed to delete comments on this post.') : __('You are not allowed to edit comments on this post, so you cannot approve this comment.') );
+?>
+<div class='wrap'>
+
+<div class="narrow">
+<?php if ( 'spam' == $_GET['delete_type'] ) { ?>
+<p><?php _e('<strong>Caution:</strong> You are about to mark the following comment as spam:'); ?></p>
+<?php } elseif ( 'confirmdeletecomment' == $action ) { ?>
+<p><?php _e('<strong>Caution:</strong> You are about to delete the following comment:'); ?></p>
+<?php } else { ?>
+<p><?php _e('<strong>Caution:</strong> You are about to approve the following comment:'); ?></p>
+<?php } ?>
+
+<p><?php _e('Are you sure you want to do that?'); ?></p>
+
+<form action='<?php echo get_option('siteurl'); ?>/wp-admin/comment.php' method='get'>
+
+<table width="100%">
+<tr>
+<td><input type='button' value='<?php _e('No'); ?>' onclick="self.location='<?php echo get_option('siteurl'); ?>/wp-admin/edit-comments.php';" /></td>
+<td align="right"><input type='submit' value='<?php _e('Yes'); ?>' /></td>
+</tr>
+</table>
+
+<?php wp_nonce_field($nonce_action); ?>
+<input type='hidden' name='action' value='<?php echo $formaction; ?>' />
+<?php if ( 'spam' == $_GET['delete_type'] ) { ?>
+<input type='hidden' name='delete_type' value='spam' />
+<?php } ?>
+<input type='hidden' name='p' value='<?php echo $comment->comment_post_ID; ?>' />
+<input type='hidden' name='comment' value='<?php echo $comment->comment_ID; ?>' />
+<input type='hidden' name='noredir' value='1' />
+</form>
+
+<table class="editform" cellpadding="5">
+<tr class="alt">
+<th scope="row"><?php _e('Author:'); ?></th>
+<td><?php echo $comment->comment_author; ?></td>
+</tr>
+<?php if ( $comment->comment_author_email ) { ?>
+<tr>
+<th scope="row"><?php _e('E-mail:'); ?></th>
+<td><?php echo $comment->comment_author_email; ?></td>
+</tr>
+<?php } ?>
+<?php if ( $comment->comment_author_url ) { ?>
+<tr>
+<th scope="row"><?php _e('URL:'); ?></th>
+<td><?php echo $comment->comment_author_url; ?></td>
+</tr>
+<?php } ?>
+<tr>
+<th scope="row" valign="top"><p><?php _e('Comment:'); ?></p></th>
+<td><?php echo apply_filters( 'comment_text', $comment->comment_content ); ?></td>
+</tr>
+</table>
+
+</div>
+</div>
+<?php
+ break;
+
+case 'deletecomment':
+ $comment = (int) $_REQUEST['comment'];
+ check_admin_referer('delete-comment_' . $comment);
+
+ $p = (int) $_REQUEST['p'];
+ if ( isset($_REQUEST['noredir']) ) {
+ $noredir = true;
+ } else {
+ $noredir = false;
+ }
+
+ $postdata = get_post($p) or
+ wp_die(sprintf(__('Oops, no post with this ID. <a href="%s">Go back</a>!'), 'edit.php'));
+
+ if ( ! $comment = get_comment($comment) )
+ wp_die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'edit-comments.php'));
+
+ if ( !current_user_can('edit_post', $comment->comment_post_ID) )
+ wp_die( __('You are not allowed to edit comments on this post.') );
+
+ if ( 'spam' == $_REQUEST['delete_type'] )
+ wp_set_comment_status($comment->comment_ID, 'spam');
+ else
+ wp_delete_comment($comment->comment_ID);
+
+ if ((wp_get_referer() != '') && (false == $noredir)) {
+ wp_redirect(wp_get_referer());
+ } else {
+ wp_redirect(get_option('siteurl') .'/wp-admin/edit-comments.php');
+ }
+ exit();
+ break;
+
+case 'unapprovecomment':
+ $comment = (int) $_GET['comment'];
+ check_admin_referer('unapprove-comment_' . $comment);
+
+ $p = (int) $_GET['p'];
+ if (isset($_GET['noredir'])) {
+ $noredir = true;
+ } else {
+ $noredir = false;
+ }
+
+ if ( ! $comment = get_comment($comment) )
+ wp_die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'edit.php'));
+
+ if ( !current_user_can('edit_post', $comment->comment_post_ID) )
+ wp_die( __('You are not allowed to edit comments on this post, so you cannot disapprove this comment.') );
+
+ wp_set_comment_status($comment->comment_ID, "hold");
+
+ if ((wp_get_referer() != "") && (false == $noredir)) {
+ wp_redirect(wp_get_referer());
+ } else {
+ wp_redirect(get_option('siteurl') .'/wp-admin/edit.php?p='.$p.'&c=1#comments');
+ }
+ exit();
+ break;
+
+case 'approvecomment':
+ $comment = (int) $_GET['comment'];
+ check_admin_referer('approve-comment_' . $comment);
+
+ $p = (int) $_GET['p'];
+ if (isset($_GET['noredir'])) {
+ $noredir = true;
+ } else {
+ $noredir = false;
+ }
+
+ if ( ! $comment = get_comment($comment) )
+ wp_die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'edit.php'));
+
+ if ( !current_user_can('edit_post', $comment->comment_post_ID) )
+ wp_die( __('You are not allowed to edit comments on this post, so you cannot approve this comment.') );
+
+ wp_set_comment_status($comment->comment_ID, "approve");
+ if (get_option("comments_notify") == true) {
+ wp_notify_postauthor($comment->comment_ID);
+ }
+
+
+ if ((wp_get_referer() != "") && (false == $noredir)) {
+ wp_redirect(wp_get_referer());
+ } else {
+ wp_redirect(get_option('siteurl') .'/wp-admin/edit.php?p='.$p.'&c=1#comments');
+ }
+ exit();
+ break;
+
+case 'editedcomment':
+
+ $comment_ID = (int) $_POST['comment_ID'];
+ $comment_post_ID = (int) $_POST['comment_post_id'];
+
+ check_admin_referer('update-comment_' . $comment_ID);
+
+ edit_comment();
+
+ $location = ( empty($_POST['referredby']) ? "edit.php?p=$comment_post_ID&c=1" : $_POST['referredby'] ) . '#comment-' . $comment_ID;
+ $location = apply_filters('comment_edit_redirect', $location, $comment_ID);
+ wp_redirect($location);
+
+ break;
+default:
+ break;
+} // end switch
+
+include('admin-footer.php');
+
+?>
View
214 wp-admin/export.php
@@ -1,108 +1,108 @@
-<?php
-require_once ('admin.php');
-$title = __('Export');
-$parent_file = 'edit.php';
-
-if ( isset( $_GET['download'] ) )
- export_wp();
-
-require_once ('admin-header.php');
-?>
-
-<div class="wrap">
-<h2><?php _e('Export'); ?></h2>
-<div class="narrow">
-<p><?php _e('When you click the button below WordPress will create a XML file for you to save to your computer.'); ?></p>
-<p><?php _e('This format, which we call WordPress eXtended RSS or WXR, will contain your posts, comments, custom fields, and categories.'); ?></p>
-<form action="" method="get">
-<p class="submit"><input type="submit" name="submit" value="<?php _e('Download Export File'); ?> &raquo;" />
-<input type="hidden" name="download" value="true" />
-</p>
-</form>
-</div>
-</div>
-
-<?php
-
-function export_wp() {
- global $wpdb, $posts, $post;
- $filename = 'wordpress.' . date('Y-m-d') . '.xml';
-header('Content-Description: File Transfer');
-header('Content-Type: application/octet-stream');
-header("Content-Disposition: attachment; filename=$filename");
-header('Content-type: text/xml; charset=' . get_option('blog_charset'), true);
-//$posts = query_posts('');
-$posts = $wpdb->get_results("SELECT * FROM $wpdb->posts ORDER BY post_date_gmt ASC");
-?>
-<!-- generator="wordpress/<?php bloginfo_rss('version') ?>" created="<?php echo date('Y-m-d H:m'); ?>"-->
-<rss version="2.0"
- xmlns:content="http://purl.org/rss/1.0/modules/content/"
- xmlns:wfw="http://wellformedweb.org/CommentAPI/"
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:wp="http://wordpress.org/export/1.0/"
->
-
-<channel>
- <title><?php bloginfo_rss('name'); ?></title>
- <link><?php bloginfo_rss('url') ?></link>
- <description><?php bloginfo_rss("description") ?></description>
- <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false); ?></pubDate>
- <generator>http://wordpress.org/?v=<?php bloginfo_rss('version'); ?></generator>
- <language><?php echo get_option('rss_language'); ?></language>
- <?php do_action('rss2_head'); ?>
- <?php if ($posts) { foreach ($posts as $post) { start_wp(); ?>
-<item>
-<title><?php the_title_rss() ?></title>
-<link><?php permalink_single_rss() ?></link>
-<pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false); ?></pubDate>
-<dc:creator><?php the_author() ?></dc:creator>
-<?php the_category_rss() ?>
-
-<guid isPermaLink="false"><?php the_guid(); ?></guid>
-<description></description>
-<content:encoded><![CDATA[<?php echo $post->post_content ?>]]></content:encoded>
-<wp:post_date><?php echo $post->post_date; ?></wp:post_date>
-<wp:post_date_gmt><?php echo $post->post_date_gmt; ?></wp:post_date_gmt>
-<wp:comment_status><?php echo $post->comment_status; ?></wp:comment_status>
-<wp:ping_status><?php echo $post->ping_status; ?></wp:ping_status>
-<wp:post_name><?php echo $post->post_name; ?></wp:post_name>
-<wp:status><?php echo $post->post_status; ?></wp:status>
-<wp:post_parent><?php echo $post->post_parent; ?></wp:post_parent>
-<wp:post_type><?php echo $post->post_type; ?></wp:post_type>
-<?php
-$postmeta = $wpdb->get_results("SELECT * FROM $wpdb->postmeta WHERE post_id = $post->ID");
-if ( $postmeta ) {
-?>
-<?php foreach( $postmeta as $meta ) { ?>
-<wp:postmeta>
-<wp:meta_key><?php echo $meta->meta_key; ?></wp:meta_key>
-<wp:meta_value><?Php echo $meta->meta_value; ?></wp:meta_value>
-</wp:postmeta>
-<?php } ?>
-<?php } ?>
-<?php
-$comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = $post->ID");
-if ( $comments ) { foreach ( $comments as $c ) { ?>
-<wp:comment>
-<wp:comment_author><?php echo $c->comment_author; ?></wp:comment_author>
-<wp:comment_author_email><?php echo $c->comment_author_email; ?></wp:comment_author_email>
-<wp:comment_author_url><?php echo $c->comment_author_url; ?></wp:comment_author_url>
-<wp:comment_author_IP><?php echo $c->comment_author_IP; ?></wp:comment_author_IP>
-<wp:comment_date><?php echo $c->comment_date; ?></wp:comment_date>
-<wp:comment_date_gmt><?php echo $c->comment_date_gmt; ?></wp:comment_date_gmt>
-<wp:comment_content><?php echo $c->comment_content; ?></wp:comment_content>
-<wp:comment_approved><?php echo $c->comment_approved; ?></wp:comment_approved>
-<wp:comment_type><?php echo $c->comment_type; ?></wp:comment_type>
-<wp:comment_parent><?php echo $c->comment_parent; ?></wp:comment_parent>
-</wp:comment>
-<?php } } ?>
- </item>
-<?php } } ?>
-</channel>
-</rss>
-<?php
- die();
-}
-
-include ('admin-footer.php');
+<?php
+require_once ('admin.php');
+$title = __('Export');
+$parent_file = 'edit.php';
+
+if ( isset( $_GET['download'] ) )
+ export_wp();
+
+require_once ('admin-header.php');
+?>
+
+<div class="wrap">
+<h2><?php _e('Export'); ?></h2>
+<div class="narrow">
+<p><?php _e('When you click the button below WordPress will create a XML file for you to save to your computer.'); ?></p>
+<p><?php _e('This format, which we call WordPress eXtended RSS or WXR, will contain your posts, comments, custom fields, and categories.'); ?></p>
+<form action="" method="get">
+<p class="submit"><input type="submit" name="submit" value="<?php _e('Download Export File'); ?> &raquo;" />
+<input type="hidden" name="download" value="true" />
+</p>
+</form>
+</div>
+</div>
+
+<?php
+
+function export_wp() {
+ global $wpdb, $posts, $post;
+ $filename = 'wordpress.' . date('Y-m-d') . '.xml';
+header('Content-Description: File Transfer');
+header('Content-Type: application/octet-stream');
+header("Content-Disposition: attachment; filename=$filename");
+header('Content-type: text/xml; charset=' . get_option('blog_charset'), true);
+//$posts = query_posts('');
+$posts = $wpdb->get_results("SELECT * FROM $wpdb->posts ORDER BY post_date_gmt ASC");
+?>
+<!-- generator="wordpress/<?php bloginfo_rss('version') ?>" created="<?php echo date('Y-m-d H:m'); ?>"-->
+<rss version="2.0"
+ xmlns:content="http://purl.org/rss/1.0/modules/content/"
+ xmlns:wfw="http://wellformedweb.org/CommentAPI/"
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:wp="http://wordpress.org/export/1.0/"
+>
+
+<channel>
+ <title><?php bloginfo_rss('name'); ?></title>
+ <link><?php bloginfo_rss('url') ?></link>
+ <description><?php bloginfo_rss("description") ?></description>
+ <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false); ?></pubDate>
+ <generator>http://wordpress.org/?v=<?php bloginfo_rss('version'); ?></generator>
+ <language><?php echo get_option('rss_language'); ?></language>
+ <?php do_action('rss2_head'); ?>
+ <?php if ($posts) { foreach ($posts as $post) { start_wp(); ?>
+<item>
+<title><?php the_title_rss() ?></title>
+<link><?php permalink_single_rss() ?></link>
+<pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false); ?></pubDate>
+<dc:creator><?php the_author() ?></dc:creator>
+<?php the_category_rss() ?>
+
+<guid isPermaLink="false"><?php the_guid(); ?></guid>
+<description></description>
+<content:encoded><![CDATA[<?php echo $post->post_content ?>]]></content:encoded>
+<wp:post_date><?php echo $post->post_date; ?></wp:post_date>
+<wp:post_date_gmt><?php echo $post->post_date_gmt; ?></wp:post_date_gmt>
+<wp:comment_status><?php echo $post->comment_status; ?></wp:comment_status>
+<wp:ping_status><?php echo $post->ping_status; ?></wp:ping_status>
+<wp:post_name><?php echo $post->post_name; ?></wp:post_name>
+<wp:status><?php echo $post->post_status; ?></wp:status>
+<wp:post_parent><?php echo $post->post_parent; ?></wp:post_parent>
+<wp:post_type><?php echo $post->post_type; ?></wp:post_type>
+<?php
+$postmeta = $wpdb->get_results("SELECT * FROM $wpdb->postmeta WHERE post_id = $post->ID");
+if ( $postmeta ) {
+?>
+<?php foreach( $postmeta as $meta ) { ?>
+<wp:postmeta>
+<wp:meta_key><?php echo $meta->meta_key; ?></wp:meta_key>
+<wp:meta_value><?Php echo $meta->meta_value; ?></wp:meta_value>
+</wp:postmeta>
+<?php } ?>
+<?php } ?>
+<?php
+$comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = $post->ID");
+if ( $comments ) { foreach ( $comments as $c ) { ?>
+<wp:comment>
+<wp:comment_author><?php echo $c->comment_author; ?></wp:comment_author>
+<wp:comment_author_email><?php echo $c->comment_author_email; ?></wp:comment_author_email>
+<wp:comment_author_url><?php echo $c->comment_author_url; ?></wp:comment_author_url>
+<wp:comment_author_IP><?php echo $c->comment_author_IP; ?></wp:comment_author_IP>
+<wp:comment_date><?php echo $c->comment_date; ?></wp:comment_date>
+<wp:comment_date_gmt><?php echo $c->comment_date_gmt; ?></wp:comment_date_gmt>
+<wp:comment_content><?php echo $c->comment_content; ?></wp:comment_content>
+<wp:comment_approved><?php echo $c->comment_approved; ?></wp:comment_approved>
+<wp:comment_type><?php echo $c->comment_type; ?></wp:comment_type>
+<wp:comment_parent><?php echo $c->comment_parent; ?></wp:comment_parent>
+</wp:comment>
+<?php } } ?>
+ </item>
+<?php } } ?>
+</channel>
+</rss>
+<?php
+ die();
+}
+
+include ('admin-footer.php');
?>
View
388 wp-admin/import/blogware.php
@@ -1,194 +1,194 @@
-<?php
-
-/* By Shayne Sweeney - http://www.theshayne.com/ */
-
-class BW_Import {
-
- var $file;
-
- function header() {
- echo '<div class="wrap">';
- echo '<h2>'.__('Import Blogware').'</h2>';
- }
-
- function footer() {
- echo '</div>';
- }
-
- function unhtmlentities($string) { // From php.net for < 4.3 compat
- $trans_tbl = get_html_translation_table(HTML_ENTITIES);
- $trans_tbl = array_flip($trans_tbl);
- return strtr($string, $trans_tbl);
- }
-
- function greet() {
- echo '<div class="narrow">';
- echo '<p>'.__('Howdy! This importer allows you to extract posts from Blogware XML export file into your blog. Pick a Blogware file to upload and click Import.').'</p>';
- wp_import_upload_form("admin.php?import=blogware&amp;step=1");
- echo '</div>';
- }
-
- function import_posts() {
- global $wpdb, $current_user;
-
- set_magic_quotes_runtime(0);
- $importdata = file($this->file); // Read the file into an array
- $importdata = implode('', $importdata); // squish it
- $importdata = str_replace(array ("\r\n", "\r"), "\n", $importdata);
-
- preg_match_all('|(<item[^>]+>(.*?)</item>)|is', $importdata, $posts);
- $posts = $posts[1];
- unset($importdata);
- echo '<ol>';
- foreach ($posts as $post) {
- flush();
- preg_match('|<item type=\"(.*?)\">|is', $post, $post_type);
- $post_type = $post_type[1];
- if($post_type == "photo") {
- preg_match('|<photoFilename>(.*?)</photoFilename>|is', $post, $post_title);
- } else {
- preg_match('|<title>(.*?)</title>|is', $post, $post_title);
- }
- $post_title = $wpdb->escape(trim($post_title[1]));
-
- preg_match('|<pubDate>(.*?)</pubDate>|is', $post, $post_date);
- $post_date = strtotime($post_date[1]);
- $post_date = gmdate('Y-m-d H:i:s', $post_date);
-
- preg_match_all('|<category>(.*?)</category>|is', $post, $categories);
- $categories = $categories[1];
-
- $cat_index = 0;
- foreach ($categories as $category) {
- $categories[$cat_index] = $wpdb->escape($this->unhtmlentities($category));
- $cat_index++;
- }
-
- if(strcasecmp($post_type, "photo") === 0) {
- preg_match('|<sizedPhotoUrl>(.*?)</sizedPhotoUrl>|is', $post, $post_content);
- $post_content = '<img src="'.trim($post_content[1]).'" />';
- $post_content = $this->unhtmlentities($post_content);
- } else {
- preg_match('|<body>(.*?)</body>|is', $post, $post_content);
- $post_content = str_replace(array ('<![CDATA[', ']]>'), '', trim($post_content[1]));
- $post_content = $this->unhtmlentities($post_content);
- }
-
- // Clean up content
- $post_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $post_content);
- $post_content = str_replace('<br>', '<br />', $post_content);
- $post_content = str_replace('<hr>', '<hr />', $post_content);
- $post_content = $wpdb->escape($post_content);
-
- $post_author = $current_user->ID;
- preg_match('|<postStatus>(.*?)</postStatus>|is', $post, $post_status);
- $post_status = trim($post_status[1]);
-
- echo '<li>';
- if ($post_id = post_exists($post_title, $post_content, $post_date)) {
- printf(__('Post <i>%s</i> already exists.'), stripslashes($post_title));
- } else {
- printf(__('Importing post <i>%s</i>...'), stripslashes($post_title));
- $postdata = compact('post_author', 'post_date', 'post_content', 'post_title', 'post_status');
- $post_id = wp_insert_post($postdata);
- if (!$post_id) {
- _e("Couldn't get post ID");
- echo '</li>';
- break;
- }
- if(0 != count($categories))
- wp_create_categories($categories, $post_id);
- }
-
- preg_match_all('|<comment>(.*?)</comment>|is', $post, $comments);
- $comments = $comments[1];
-
- if ( $comments ) {
- $comment_post_ID = $post_id;
- $num_comments = 0;
- foreach ($comments as $comment) {
- preg_match('|<body>(.*?)</body>|is', $comment, $comment_content);
- $comment_content = str_replace(array ('<![CDATA[', ']]>'), '', trim($comment_content[1]));
- $comment_content = $this->unhtmlentities($comment_content);
-
- // Clean up content
- $comment_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $comment_content);
- $comment_content = str_replace('<br>', '<br />', $comment_content);
- $comment_content = str_replace('<hr>', '<hr />', $comment_content);
- $comment_content = $wpdb->escape($comment_content);
-
- preg_match('|<pubDate>(.*?)</pubDate>|is', $comment, $comment_date);
- $comment_date = trim($comment_date[1]);
- $comment_date = date('Y-m-d H:i:s', strtotime($comment_date));
-
- preg_match('|<author>(.*?)</author>|is', $comment, $comment_author);
- $comment_author = $wpdb->escape(trim($comment_author[1]));
-
- $comment_author_email = NULL;
-
- $comment_approved = 1;
- // Check if it's already there
- if (!comment_exists($comment_author, $comment_date)) {
- $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_date', 'comment_content', 'comment_approved');
- $commentdata = wp_filter_comment($commentdata);
- wp_insert_comment($commentdata);
- $num_comments++;
- }
- }
- }
- if ( $num_comments ) {
- echo ' ';
- printf(__('(%s comments)'), $num_comments);
- }
- echo '</li>';
- flush();
- ob_flush();
- }
- echo '</ol>';
- }
-
- function import() {
- $file = wp_import_handle_upload();
- if ( isset($file['error']) ) {
- echo $file['error'];
- return;
- }
-
- $this->file = $file['file'];
- $this->import_posts();
- wp_import_cleanup($file['id']);
-
- echo '<h3>';
- printf(__('All done. <a href="%s">Have fun!</a>'), get_option('home'));
- echo '</h3>';
- }
-
- function dispatch() {
- if (empty ($_GET['step']))
- $step = 0;
- else
- $step = (int) $_GET['step'];
-
- $this->header();
-
- switch ($step) {
- case 0 :
- $this->greet();
- break;
- case 1 :
- $this->import();
- break;
- }
-
- $this->footer();
- }
-
- function BW_Import() {
- // Nothing.
- }
-}
-
-$blogware_import = new BW_Import();
-
-register_importer('blogware', __('Blogware'), __('Import posts from Blogware'), array ($blogware_import, 'dispatch'));
-?>
+<?php
+
+/* By Shayne Sweeney - http://www.theshayne.com/ */
+
+class BW_Import {
+
+ var $file;
+
+ function header() {
+ echo '<div class="wrap">';
+ echo '<h2>'.__('Import Blogware').'</h2>';
+ }
+
+ function footer() {
+ echo '</div>';
+ }
+
+ function unhtmlentities($string) { // From php.net for < 4.3 compat
+ $trans_tbl = get_html_translation_table(HTML_ENTITIES);
+ $trans_tbl = array_flip($trans_tbl);
+ return strtr($string, $trans_tbl);
+ }
+
+ function greet() {
+ echo '<div class="narrow">';
+ echo '<p>'.__('Howdy! This importer allows you to extract posts from Blogware XML export file into your blog. Pick a Blogware file to upload and click Import.').'</p>';
+ wp_import_upload_form("admin.php?import=blogware&amp;step=1");
+ echo '</div>';
+ }
+
+ function import_posts() {
+ global $wpdb, $current_user;
+
+ set_magic_quotes_runtime(0);
+ $importdata = file($this->file); // Read the file into an array
+ $importdata = implode('', $importdata); // squish it
+ $importdata = str_replace(array ("\r\n", "\r"), "\n", $importdata);
+
+ preg_match_all('|(<item[^>]+>(.*?)</item>)|is', $importdata, $posts);
+ $posts = $posts[1];
+ unset($importdata);
+ echo '<ol>';
+ foreach ($posts as $post) {
+ flush();
+ preg_match('|<item type=\"(.*?)\">|is', $post, $post_type);
+ $post_type = $post_type[1];
+ if($post_type == "photo") {
+ preg_match('|<photoFilename>(.*?)</photoFilename>|is', $post, $post_title);
+ } else {
+ preg_match('|<title>(.*?)</title>|is', $post, $post_title);
+ }
+ $post_title = $wpdb->escape(trim($post_title[1]));
+
+ preg_match('|<pubDate>(.*?)</pubDate>|is', $post, $post_date);
+ $post_date = strtotime($post_date[1]);
+ $post_date = gmdate('Y-m-d H:i:s', $post_date);
+
+ preg_match_all('|<category>(.*?)</category>|is', $post, $categories);
+ $categories = $categories[1];
+
+ $cat_index = 0;
+ foreach ($categories as $category) {
+ $categories[$cat_index] = $wpdb->escape($this->unhtmlentities($category));
+ $cat_index++;
+ }
+
+ if(strcasecmp($post_type, "photo") === 0) {
+ preg_match('|<sizedPhotoUrl>(.*?)</sizedPhotoUrl>|is', $post, $post_content);
+ $post_content = '<img src="'.trim($post_content[1]).'" />';
+ $post_content = $this->unhtmlentities($post_content);
+ } else {
+ preg_match('|<body>(.*?)</body>|is', $post, $post_content);
+ $post_content = str_replace(array ('<![CDATA[', ']]>'), '', trim($post_content[1]));
+ $post_content = $this->unhtmlentities($post_content);
+ }
+
+ // Clean up content
+ $post_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $post_content);
+ $post_content = str_replace('<br>', '<br />', $post_content);
+ $post_content = str_replace('<hr>', '<hr />', $post_content);
+ $post_content = $wpdb->escape($post_content);
+
+ $post_author = $current_user->ID;
+ preg_match('|<postStatus>(.*?)</postStatus>|is', $post, $post_status);
+ $post_status = trim($post_status[1]);
+
+ echo '<li>';
+ if ($post_id = post_exists($post_title, $post_content, $post_date)) {
+ printf(__('Post <i>%s</i> already exists.'), stripslashes($post_title));
+ } else {
+ printf(__('Importing post <i>%s</i>...'), stripslashes($post_title));
+ $postdata = compact('post_author', 'post_date', 'post_content', 'post_title', 'post_status');
+ $post_id = wp_insert_post($postdata);
+ if (!$post_id) {
+ _e("Couldn't get post ID");
+ echo '</li>';
+ break;
+ }
+ if(0 != count($categories))
+ wp_create_categories($categories, $post_id);
+ }
+
+ preg_match_all('|<comment>(.*?)</comment>|is', $post, $comments);
+ $comments = $comments[1];
+
+ if ( $comments ) {
+ $comment_post_ID = $post_id;
+ $num_comments = 0;
+ foreach ($comments as $comment) {
+ preg_match('|<body>(.*?)</body>|is', $comment, $comment_content);
+ $comment_content = str_replace(array ('<![CDATA[', ']]>'), '', trim($comment_content[1]));
+ $comment_content = $this->unhtmlentities($comment_content);
+
+ // Clean up content
+ $comment_content = preg_replace('|<(/?[A-Z]+)|e', "'<' . strtolower('$1')", $comment_content);
+ $comment_content = str_replace('<br>', '<br />', $comment_content);
+ $comment_content = str_replace('<hr>', '<hr />', $comment_content);
+ $comment_content = $wpdb->escape($comment_content);
+
+ preg_match('|<pubDate>(.*?)</pubDate>|is', $comment, $comment_date);
+ $comment_date = trim($comment_date[1]);
+ $comment_date = date('Y-m-d H:i:s', strtotime($comment_date));
+
+ preg_match('|<author>(.*?)</author>|is', $comment, $comment_author);
+ $comment_author = $wpdb->escape(trim($comment_author[1]));
+
+ $comment_author_email = NULL;
+
+ $comment_approved = 1;
+ // Check if it's already there
+ if (!comment_exists($comment_author, $comment_date)) {
+ $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_date', 'comment_content', 'comment_approved');
+ $commentdata = wp_filter_comment($commentdata);
+ wp_insert_comment($commentdata);
+ $num_comments++;
+ }
+ }
+ }
+ if ( $num_comments ) {
+ echo ' ';
+ printf(__('(%s comments)'), $num_comments);
+ }
+ echo '</li>';
+ flush();
+ ob_flush();
+ }
+ echo '</ol>';
+ }
+
+ function import() {
+ $file = wp_import_handle_upload();
+ if ( isset($file['error']) ) {
+ echo $file['error'];
+ return;
+ }
+
+ $this->file = $file['file'];
+ $this->import_posts();
+ wp_import_cleanup($file['id']);
+
+ echo '<h3>';
+ printf(__('All done. <a href="%s">Have fun!</a>'), get_option('home'));
+ echo '</h3>';
+ }
+
+ function dispatch() {
+ if (empty ($_GET['step']))
+ $step = 0;
+ else
+ $step = (int) $_GET['step'];
+
+ $this->header();
+
+ switch ($step) {
+ case 0 :
+ $this->greet();
+ break;
+ case 1 :
+ $this->import();
+ break;
+ }
+
+ $this->footer();
+ }
+
+ function BW_Import() {
+ // Nothing.
+ }
+}
+
+$blogware_import = new BW_Import();
+
+register_importer('blogware', __('Blogware'), __('Import posts from Blogware'), array ($blogware_import, 'dispatch'));
+?>
View
1,494 wp-admin/import/dotclear.php
@@ -1,747 +1,747 @@
-<?php
-/*
- * Dotclear import plugin
- * by Thomas Quinot - http://thomas.quinot.org/
- */
-
-/**
- Add These Functions to make our lives easier
-**/
-if(!function_exists('get_catbynicename'))
-{
- function get_catbynicename($category_nicename)
- {
- global $wpdb;
-
- $cat_id -= 0; // force numeric
- $name = $wpdb->get_var('SELECT cat_ID FROM '.$wpdb->categories.' WHERE category_nicename="'.$category_nicename.'"');
-
- return $name;
- }
-}
-
-if(!function_exists('get_comment_count'))
-{
- function get_comment_count($post_ID)
- {
- global $wpdb;
- return $wpdb->get_var('SELECT count(*) FROM '.$wpdb->comments.' WHERE comment_post_ID = '.$post_ID);
- }
-}
-
-if(!function_exists('link_cat_exists'))
-{
- function link_cat_exists($catname)
- {
- global $wpdb;
- return $wpdb->get_var('SELECT cat_id FROM '.$wpdb->linkcategories.' WHERE cat_name = "'.$wpdb->escape($catname).'"');
- }
-}
-
-if(!function_exists('link_exists'))
-{
- function link_exists($linkname)
- {
- global $wpdb;
- return $wpdb->get_var('SELECT link_id FROM '.$wpdb->links.' WHERE link_name = "'.$linkname.'"');
- }
-}
-
-/*
- Identify UTF-8 text
- Taken from http://www.php.net/manual/fr/function.mb-detect-encoding.php#50087
-*/
-//
-// utf8 encoding validation developed based on Wikipedia entry at:
-// http://en.wikipedia.org/wiki/UTF-8
-//
-// Implemented as a recursive descent parser based on a simple state machine
-// copyright 2005 Maarten Meijer
-//
-// This cries out for a C-implementation to be included in PHP core
-//
- function valid_1byte($char) {
- if(!is_int($char)) return false;
- return ($char & 0x80) == 0x00;
- }
-
- function valid_2byte($char) {
- if(!is_int($char)) return false;
- return ($char & 0xE0) == 0xC0;
- }
-
- function valid_3byte($char) {
- if(!is_int($char)) return false;
- return ($char & 0xF0) == 0xE0;
- }
-
- function valid_4byte($char) {
- if(!is_int($char)) return false;
- return ($char & 0xF8) == 0xF0;
- }
-
- function valid_nextbyte($char) {
- if(!is_int($char)) return false;
- return ($char & 0xC0) == 0x80;
- }
-
- function valid_utf8($string) {
- $len = strlen($string);
- $i = 0;
- while( $i < $len ) {
- $char = ord(substr($string, $i++, 1));
- if(valid_1byte($char)) { // continue
- continue;
- } else if(valid_2byte($char)) { // check 1 byte
- if(!valid_nextbyte(ord(substr($string, $i++, 1))))
- return false;
- } else if(valid_3byte($char)) { // check 2 bytes
- if(!valid_nextbyte(ord(substr($string, $i++, 1))))
- return false;
- if(!valid_nextbyte(ord(substr($string, $i++, 1))))
- return false;
- } else if(valid_4byte($char)) { // check 3 bytes
- if(!valid_nextbyte(ord(substr($string, $i++, 1))))
- return false;
- if(!valid_nextbyte(ord(substr($string, $i++, 1))))
- return false;
- if(!valid_nextbyte(ord(substr($string, $i++, 1))))
- return false;
- } // goto next char
- }
- return true; // done
- }
-
-function csc ($s) {
- if (valid_utf8 ($s)) {
- return $s;
- } else {
- return iconv(get_option ("dccharset"),"UTF-8",$s);
- }
-}
-
-function textconv ($s) {
- return csc (preg_replace ('|(?<!<br />)\s*\n|', ' ', $s));
-}
-
-/**
- The Main Importer Class
-**/
-class Dotclear_Import {
-
- function header()
- {
- echo '<div class="wrap">';
- echo '<h2>'.__('Import DotClear').'</h2>';
- echo '<p>'.__('Steps may take a few minutes depending on the size of your database. Please be patient.').'</p>';
- }
-
- function footer()
- {
- echo '</div>';
- }
-
- function greet()
- {
- echo '<div class="narrow"><p>'.__('Howdy! This importer allows you to extract posts from a DotClear database into your blog. Mileage may vary.').'</p>';
- echo '<p>'.__('Your DotClear Configuration settings are as follows:').'</p>';
- echo '<form action="admin.php?import=dotclear&amp;step=1" method="post">';
- $this->db_form();
- echo '<p class="submit"><input type="submit" name="submit" value="'.__('Import Categories').' &raquo;" /></p>';
- echo '</form></div>';
- }
-
- function get_dc_cats()
- {
- global $wpdb;
- // General Housekeeping
- $dcdb = new wpdb(get_option('dcuser'), get_option('dcpass'), get_option('dcname'), get_option('dchost'));
- set_magic_quotes_runtime(0);
- $dbprefix = get_option('dcdbprefix');
-
- // Get Categories
- return $dcdb->get_results('SELECT * FROM '.$dbprefix.'categorie', ARRAY_A);
- }
-
- function get_dc_users()
- {
- global $wpdb;
- // General Housekeeping
- $dcdb = new wpdb(get_option('dcuser'), get_option('dcpass'), get_option('dcname'), get_option('dchost'));
- set_magic_quotes_runtime(0);
- $dbprefix = get_option('dcdbprefix');
-
- // Get Users
-
- return $dcdb->get_results('SELECT * FROM '.$dbprefix.'user', ARRAY_A);
- }
-
- function get_dc_posts()
- {
- // General Housekeeping
- $dcdb = new wpdb(get_option('dcuser'), get_option('dcpass'), get_option('dcname'), get_option('dchost'));
- set_magic_quotes_runtime(0);
- $dbprefix = get_option('dcdbprefix');
-
- // Get Posts
- return $dcdb->get_results('SELECT '.$dbprefix.'post.*, '.$dbprefix.'categorie.cat_libelle_url AS post_cat_name
- FROM '.$dbprefix.'post INNER JOIN '.$dbprefix.'categorie
- ON '.$dbprefix.'post.cat_id = '.$dbprefix.'categorie.cat_id', ARRAY_A);
- }
-
- function get_dc_comments()
- {
- global $wpdb;
- // General Housekeeping
- $dcdb = new wpdb(get_option('dcuser'), get_option('dcpass'), get_option('dcname'), get_option('dchost'));
- set_magic_quotes_runtime(0);
- $dbprefix = get_option('dcdbprefix');
-
- // Get Comments
- return $dcdb->get_results('SELECT * FROM '.$dbprefix.'comment', ARRAY_A);
- }
-
- function get_dc_links()
- {
- //General Housekeeping
- $dcdb = new wpdb(get_option('dcuser'), get_option('dcpass'), get_option('dcname'), get_option('dchost'));
- set_magic_quotes_runtime(0);
- $dbprefix = get_option('dcdbprefix');
-
- return $dcdb->get_results('SELECT * FROM '.$dbprefix.'link ORDER BY position', ARRAY_A);
- }
-
- function cat2wp($categories='')
- {
- // General Housekeeping
- global $wpdb;
- $count = 0;
- $dccat2wpcat = array();
- // Do the Magic
- if(is_array($categories))
- {
- echo '<p>'.__('Importing Categories...').'<br /><br /></p>';
- foreach ($categories as $category)
- {
- $count++;
- extract($category);
-
- // Make Nice Variables
- $name = $wpdb->escape($cat_libelle_url);
- $title = $wpdb->escape(csc ($cat_libelle));
- $desc = $wpdb->escape(csc ($cat_desc));
-
- if($cinfo = category_exists($name))
- {
- $ret_id = wp_insert_category(array('cat_ID' => $cinfo, 'category_nicename' => $name, 'cat_name' => $title, 'category_description' => $desc));
- }
- else
- {
- $ret_id = wp_insert_category(array('category_nicename' => $name, 'cat_name' => $title, 'category_description' => $desc));
- }
- $dccat2wpcat[$id] = $ret_id;
- }
-
- // Store category translation for future use
- add_option('dccat2wpcat',$dccat2wpcat);
- echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> categories imported.'), $count).'<br /><br /></p>';
- return true;
- }
- echo __('No Categories to Import!');
- return false;
- }
-
- function users2wp($users='')
- {
- // General Housekeeping
- global $wpdb;
- $count = 0;
- $dcid2wpid = array();
-
- // Midnight Mojo
- if(is_array($users))
- {
- echo '<p>'.__('Importing Users...').'<br /><br /></p>';
- foreach($users as $user)
- {
- $count++;
- extract($user);
-
- // Make Nice Variables
- $name = $wpdb->escape(csc ($name));
- $RealName = $wpdb->escape(csc ($user_pseudo));
-
- if($uinfo = get_userdatabylogin($name))
- {
-
- $ret_id = wp_insert_user(array(
- 'ID' => $uinfo->ID,
- 'user_login' => $user_id,
- 'user_nicename' => $Realname,
- 'user_email' => $user_email,
- 'user_url' => 'http://',
- 'display_name' => $Realname)
- );
- }
- else
- {
- $ret_id = wp_insert_user(array(
- 'user_login' => $user_id,
- 'user_nicename' => csc ($user_pseudo),
- 'user_email' => $user_email,
- 'user_url' => 'http://',
- 'display_name' => $Realname)
- );
- }
- $dcid2wpid[$user_id] = $ret_id;
-
- // Set Dotclear-to-WordPress permissions translation
-
- // Update Usermeta Data
- $user = new WP_User($ret_id);
- $wp_perms = $user_level + 1;
- if(10 == $wp_perms) { $user->set_role('administrator'); }
- else if(9 == $wp_perms) { $user->set_role('editor'); }
- else if(5 <= $wp_perms) { $user->set_role('editor'); }
- else if(4 <= $wp_perms) { $user->set_role('author'); }
- else if(3 <= $wp_perms) { $user->set_role('contributor'); }
- else if(2 <= $wp_perms) { $user->set_role('contributor'); }
- else { $user->set_role('subscriber'); }
-
- update_usermeta( $ret_id, 'wp_user_level', $wp_perms);
- update_usermeta( $ret_id, 'rich_editing', 'false');
- update_usermeta( $ret_id, 'first_name', csc ($user_prenom));
- update_usermeta( $ret_id, 'last_name', csc ($user_nom));
- }// End foreach($users as $user)
-
- // Store id translation array for future use
- add_option('dcid2wpid',$dcid2wpid);
-
-
- echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> users imported.'), $count).'<br /><br /></p>';
- return true;
- }// End if(is_array($users)
-
- echo __('No Users to Import!');
- return false;
-
- }// End function user2wp()
-
- function posts2wp($posts='')
- {
- // General Housekeeping
- global $wpdb;
- $count = 0;
- $dcposts2wpposts = array();
- $cats = array();
-
- // Do the Magic
- if(is_array($posts))
- {
- echo '<p>'.__('Importing Posts...').'<br /><br /></p>';
- foreach($posts as $post)
- {
- $count++;
- extract($post);
-
- // Set Dotclear-to-WordPress status translation
- $stattrans = array(0 => 'draft', 1 => 'publish');
- $comment_status_map = array (0 => 'closed', 1 => 'open');
-
- //Can we do this more efficiently?
- $uinfo = ( get_userdatabylogin( $user_id ) ) ? get_userdatabylogin( $user_id ) : 1;
- $authorid = ( is_object( $uinfo ) ) ? $uinfo->ID : $uinfo ;
-
- $Title = $wpdb->escape(csc ($post_titre));
- $post_content = textconv ($post_content);
- $post_excerpt = "";
- if ($post_chapo != "") {
- $post_excerpt = textconv ($post_chapo);
- $post_content = $post_excerpt ."\n<!--more-->\n".$post_content;
- }
- $post_excerpt = $wpdb->escape ($post_excerpt);
- $post_content = $wpdb->escape ($post_content);
- $post_status = $stattrans[$post_pub];
-
- // Import Post data into WordPress
-
- if($pinfo = post_exists($Title,$post_content))
- {
- $ret_id = wp_insert_post(array(
- 'ID' => $pinfo,
- 'post_author' => $authorid,
- 'post_date' => $post_dt,
- 'post_date_gmt' => $post_dt,
- 'post_modified' => $post_upddt,
- 'post_modified_gmt' => $post_upddt,
- 'post_title' => $Title,
- 'post_content' => $post_content,
- 'post_excerpt' => $post_excerpt,
- 'post_status' => $post_status,
- 'post_name' => $post_titre_url,
- 'comment_status' => $comment_status_map[$post_open_comment],
- 'ping_status' => $comment_status_map[$post_open_tb],
- 'comment_count' => $post_nb_comment + $post_nb_trackback)
- );
- }
- else
- {
- $ret_id = wp_insert_post(array(
- 'post_author' => $authorid,
- 'post_date' => $post_dt,
- 'post_date_gmt' => $post_dt,
- 'post_modified' => $post_modified_gmt,
- 'post_modified_gmt' => $post_modified_gmt,
- 'post_title' => $Title,
- 'post_content' => $post_content,
- 'post_excerpt' => $post_excerpt,
- 'post_status' => $post_status,
- 'post_name' => $post_titre_url,
- 'comment_status' => $comment_status_map[$post_open_comment],
- 'ping_status' => $comment_status_map[$post_open_tb],
- 'comment_count' => $post_nb_comment + $post_nb_trackback)
- );
- }
- $dcposts2wpposts[$post_id] = $ret_id;
-
- // Make Post-to-Category associations
- $cats = array();
- if($cat1 = get_catbynicename($post_cat_name)) { $cats[1] = $cat1; }
-
- if(!empty($cats)) { wp_set_post_categories($ret_id, $cats); }
- }
- }
- // Store ID translation for later use
- add_option('dcposts2wpposts',$dcposts2wpposts);
-
- echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> posts imported.'), $count).'<br /><br /></p>';
- return true;
- }
-
- function comments2wp($comments='')
- {
- // General Housekeeping
- global $wpdb;
- $count = 0;
- $dccm2wpcm = array();
- $postarr = get_option('dcposts2wpposts');
-
- // Magic Mojo
- if(is_array($comments))
- {
- echo '<p>'.__('Importing Comments...').'<br /><br /></p>';
- foreach($comments as $comment)
- {
- $count++;
- extract($comment);
-
- // WordPressify Data
- $comment_ID = ltrim($comment_id, '0');
- $comment_post_ID = $postarr[$post_id];
- $comment_approved = "$comment_pub";
- $name = $wpdb->escape(csc ($comment_auteur));
- $email = $wpdb->escape($comment_email);
- $web = "http://".$wpdb->escape($comment_site);
- $message = $wpdb->escape(textconv ($comment_content));
-
- if($cinfo = comment_exists($name, $comment_dt))
- {
- // Update comments
- $ret_id = wp_update_comment(array(
- 'comment_ID' => $cinfo,
- 'comment_post_ID' => $comment_post_ID,
- 'comment_author' => $name,
- 'comment_author_email' => $email,
- 'comment_author_url' => $web,
- 'comment_author_IP' => $comment_ip,
- 'comment_date' => $comment_dt,
- 'comment_date_gmt' => $comment_dt,
- 'comment_content' => $message,
- 'comment_approved' => $comment_approved)
- );
- }
- else
- {
- // Insert comments
- $ret_id = wp_insert_comment(array(
- 'comment_post_ID' => $comment_post_ID,
- 'comment_author' => $name,
- 'comment_author_email' => $email,
- 'comment_author_url' => $web,
- 'comment_author_IP' => $comment_ip,
- 'comment_date' => $comment_dt,
- 'comment_date_gmt' => $comment_dt,
- 'comment_content' => $message,
- 'comment_approved' => $comment_approved)
- );
- }
- $dccm2wpcm[$comment_ID] = $ret_id;
- }
- // Store Comment ID translation for future use
- add_option('dccm2wpcm', $dccm2wpcm);
-
- // Associate newly formed categories with posts
- get_comment_count($ret_id);
-
-
- echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> comments imported.'), $count).'<br /><br /></p>';
- return true;
- }
- echo __('No Comments to Import!');
- return false;
- }
-
- function links2wp($links='')
- {
- // General Housekeeping
- global $wpdb;
- $count = 0;
-
- // Deal with the links
- if(is_array($links))
- {
- echo '<p>'.__('Importing Links...').'<br /><br /></p>';
- foreach($links as $link)
- {
- $count++;
- extract($link);
-
- if ($title != "") {
- if ($cinfo = link_cat_exists (csc ($title))) {
- $category = $cinfo;
- } else {
- $wpdb->query ("INSERT INTO $wpdb->linkcategories (cat_name) VALUES ('".
- $wpdb->escape (csc ($title))."')");
- $category = $wpdb->insert_id;
- }
- } else {
- $linkname = $wpdb->escape(csc ($label));
- $description = $wpdb->escape(csc ($title));
-
- if($linfo = link_exists($linkname)) {
- $ret_id = wp_insert_link(array(
- 'link_id' => $linfo,
- 'link_url' => $href,
- 'link_name' => $linkname,
- 'link_category' => $category,
- 'link_description' => $description)
- );
- } else {
- $ret_id = wp_insert_link(array(
- 'link_url' => $url,
- 'link_name' => $linkname,
- 'link_category' => $category,
- 'link_description' => $description)
- );
- }
- $dclinks2wplinks[$link_id] = $ret_id;
- }
- }
- add_option('dclinks2wplinks',$dclinks2wplinks);
- echo '<p>';
- printf(__('Done! <strong>%s</strong> links or link categories imported'), $count);
- echo '<br /><br /></p>';
- return true;
- }
- echo __('No Links to Import!');
- return false;
- }
-
- function import_categories()
- {
- // Category Import
- $cats = $this->get_dc_cats();
- $this->cat2wp($cats);
- add_option('dc_cats', $cats);
-
-
-
- echo '<form action="admin.php?import=dotclear&amp;step=2" method="post">';
- printf('<input type="submit" name="submit" value="%s" />', __('Import Users'));
- echo '</form>';
-
- }
-
- function import_users()
- {
- // User Import
- $users = $this->get_dc_users();
- $this->users2wp($users);
-
- echo '<form action="admin.php?import=dotclear&amp;step=3" method="post">';
- printf('<input type="submit" name="submit" value="%s" />', __('Import Posts'));
- echo '</form>';
- }
-
- function import_posts()
- {
- // Post Import
- $posts = $this->get_dc_posts();
- $this->posts2wp($posts);
-
- echo '<form action="admin.php?import=dotclear&amp;step=4" method="post">';
- printf('<input type="submit" name="submit" value="%s" />', __('Import Comments'));
- echo '</form>';
- }
-
- function import_comments()
- {
- // Comment Import
- $comments = $this->get_dc_comments();
- $this->comments2wp($comments);
-
- echo '<form action="admin.php?import=dotclear&amp;step=5" method="post">';
- printf('<input type="submit" name="submit" value="%s" />', __('Import Links'));
- echo '</form>';
- }
-
- function import_links()
- {
- //Link Import
- $links = $this->get_dc_links();
- $this->links2wp($links);
- add_option('dc_links', $links);
-
- echo '<form action="admin.php?import=dotclear&amp;step=6" method="post">';
- printf('<input type="submit" name="submit" value="%s" />', __('Finish'));
- echo '</form>';
- }
-
- function cleanup_dcimport()
- {
- delete_option('dcdbprefix');
- delete_option('dc_cats');
- delete_option('dcid2wpid');
- delete_option('dccat2wpcat');
- delete_option('dcposts2wpposts');
- delete_option('dccm2wpcm');
- delete_option('dclinks2wplinks');
- delete_option('dcuser');
- delete_option('dcpass');
- delete_option('dcname');
- delete_option('dchost');
- delete_option('dccharset');
- $this->tips();
- }
-
- function tips()
- {
- echo '<p>'.__('Welcome to WordPress. We hope (and expect!) that you will find this platform incredibly rewarding! As a new WordPress user coming from DotClear, there are some things that we would like to point out. Hopefully, they will help your transition go as smoothly as possible.').'</p>';
- echo '<h3>'.__('Users').'</h3>';
- echo '<p>'.sprintf(__('You have already setup WordPress and have been assigned an administrative login and password. Forget it. You didn\'t have that login in DotClear, why should you have it here? Instead we have taken care to import all of your users into our system. Unfortunately there is one downside. Because both WordPress and DotClear uses a strong encryption hash with passwords, it is impossible to decrypt it and we are forced to assign temporary passwords to all your users. <strong>Every user has the same username, but their passwords are reset to password123.</strong> So <a href="%1$s">Login</a> and change it.'), '/wp-login.php').'</p>';
- echo '<h3>'.__('Preserving Authors').'</h3>';
- echo '<p>'.__('Secondly, we have attempted to preserve post authors. If you are the only author or contributor to your blog, then you are safe. In most cases, we are successful in this preservation endeavor. However, if we cannot ascertain the name of the writer due to discrepancies between database tables, we assign it to you, the administrative user.').'</p>';
- echo '<h3>'.__('Textile').'</h3>';
- echo '<p>'.__('Also, since you\'re coming from DotClear, you probably have been using Textile to format your comments and posts. If this is the case, we recommend downloading and installing <a href="http://www.huddledmasses.org/category/development/wordpress/textile/">Textile for WordPress</a>. Trust me... You\'ll want it.').'</p>';
- echo '<h3>'.__('WordPress Resources').'</h3>';
- echo '<p>'.__('Finally, there are numerous WordPress resources around the internet. Some of them are:').'</p>';
- echo '<ul>';
- echo '<li>'.__('<a href="http://www.wordpress.org">The official WordPress site</a>').'</li>';
- echo '<li>'.__('<a href="http://wordpress.org/support/">The WordPress support forums</a>').'</li>';
- echo '<li>'.__('<a href="http://codex.wordpress.org">The Codex (In other words, the WordPress Bible)</a>').'</li>';
- echo '</ul>';
- echo '<p>'.sprintf(__('That\'s it! What are you waiting for? Go <a href="%1$s">login</a>!'), '../wp-login.php').'</p>';
- }
-
- function db_form()
- {
- echo '<table class="editform">';
- printf('<tr><th><label for="dbuser">%s</label></th><td><input type="text" name="dbuser" id="dbuser" /></td></tr>', __('Dotclear Database User:'));
- printf('<tr><th><label for="dbpass">%s</label></th><td><input type="password" name="dbpass" id="dbpass" /></td></tr>', __('DotClear Database Password:'));
- printf('<tr><th><label for="dbname">%s</label></th><td><input type="text" name="dbname" id="dbname" /></td></tr>', __('Dotclear Database Name:'));
- printf('<tr><th><label for="dbhost">%s</label></th><td><input type="text" name="dbhost" nameid="dbhost" value="localhost" /></td></tr>', __('DotClear Database Host:'));
- printf('<tr><th><label for="dbprefix">%s</label></th><td><input type="text" name="dbprefix" id="dbprefix" value="dc_"/></td></tr>', __('DotClear Table prefix:'));
- printf('<tr><th><label for="dccharset">%s</label></th><td><input type="text" name="dccharset" id="dccharset" value="ISO-8859-15"/></td></tr>', __('Originating character set:'));
- echo '</table>';
- }
-
- function dispatch()
- {
-
- if (empty ($_GET['step']))
- $step = 0;
- else
- $step = (int) $_GET['step'];
- $this->header();
-
- if ( $step > 0 )
- {
- if($_POST['dbuser'])
- {
- if(get_option('dcuser'))
- delete_option('dcuser');
- add_option('dcuser',$_POST['dbuser']);
- }
- if($_POST['dbpass'])
- {
- if(get_option('dcpass'))
- delete_option('dcpass');
- add_option('dcpass',$_POST['dbpass']);
- }
-
- if($_POST['dbname'])
- {
- if(get_option('dcname'))
- delete_option('dcname');
- add_option('dcname',$_POST['dbname']);
- }
- if($_POST['dbhost'])
- {
- if(get_option('dchost'))
- delete_option('dchost');
- add_option('dchost',$_POST['dbhost']);
- }
- if($_POST['dccharset'])
- {
- if(get_option('dccharset'))
- delete_option('dccharset');
- add_option('dccharset',$_POST['dccharset']);
- }
- if($_POST['dbprefix'])
- {
- if(get_option('dcdbprefix'))
- delete_option('dcdbprefix');
- add_option('dcdbprefix',$_POST['dbprefix']);
- }
-
-
- }
-
- switch ($step)
- {
- default:
- case 0 :
- $this->greet();
- break;
- case 1 :
- $this->import_categories();
- break;
- case 2 :
- $this->import_users();
- break;
- case 3 :
- $this->import_posts();
- break;
- case 4 :
- $this->import_comments();
- break;
- case 5 :
- $this->import_links();
- break;
- case 6 :
- $this->cleanup_dcimport();
- break;
- }
-
- $this->footer();
- }
-
- function Dotclear_Import()
- {
- // Nothing.
- }
-}
-
-$dc_import = new Dotclear_Import();
-register_importer('dotclear', __('DotClear'), __('Import posts from a DotClear Blog'), array ($dc_import, 'dispatch'));
-?>
+<?php
+/*
+ * Dotclear import plugin
+ * by Thomas Quinot - http://thomas.quinot.org/
+ */
+
+/**
+ Add These Functions to make our lives easier
+**/
+if(!function_exists('get_catbynicename'))
+{
+ function get_catbynicename($category_nicename)
+ {
+ global $wpdb;
+
+ $cat_id -= 0; // force numeric
+ $name = $wpdb->get_var('SELECT cat_ID FROM '.$wpdb->categories.' WHERE category_nicename="'.$category_nicename.'"');
+
+ return $name;
+ }
+}
+
+if(!function_exists('get_comment_count'))
+{
+ function get_comment_count($post_ID)
+ {
+ global $wpdb;
+ return $wpdb->get_var('SELECT count(*) FROM '.$wpdb->comments.' WHERE comment_post_ID = '.$post_ID);
+ }
+}
+
+if(!function_exists('link_cat_exists'))
+{
+ function link_cat_exists($catname)
+ {
+ global $wpdb;
+ return $wpdb->get_var('SELECT cat_id FROM '.$wpdb->linkcategories.' WHERE cat_name = "'.$wpdb->escape($catname).'"');
+ }
+}
+
+if(!function_exists('link_exists'))
+{
+ function link_exists($linkname)
+ {
+ global $wpdb;
+ return $wpdb->get_var('SELECT link_id FROM '.$wpdb->links.' WHERE link_name = "'.$linkname.'"');
+ }
+}
+
+/*
+ Identify UTF-8 text
+ Taken from http://www.php.net/manual/fr/function.mb-detect-encoding.php#50087
+*/
+//
+// utf8 encoding validation developed based on Wikipedia entry at:
+// http://en.wikipedia.org/wiki/UTF-8
+//
+// Implemented as a recursive descent parser based on a simple state machine
+// copyright 2005 Maarten Meijer
+//
+// This cries out for a C-implementation to be included in PHP core
+//
+ function valid_1byte($char) {
+ if(!is_int($char)) return false;
+ return ($char & 0x80) == 0x00;
+ }
+
+ function valid_2byte($char) {
+ if(!is_int($char)) return false;
+ return ($char & 0xE0) == 0xC0;
+ }
+
+ function valid_3byte($char) {
+ if(!is_int($char)) return false;
+ return ($char & 0xF0) == 0xE0;
+ }
+
+ function valid_4byte($char) {
+ if(!is_int($char)) return false;
+ return ($char & 0xF8) == 0xF0;
+ }
+
+ function valid_nextbyte($char) {
+ if(!is_int($char)) return false;
+ return ($char & 0xC0) == 0x80;
+ }
+
+ function valid_utf8($string) {
+ $len = strlen($string);
+ $i = 0;
+ while( $i < $len ) {
+ $char = ord(substr($string, $i++, 1));
+ if(valid_1byte($char)) { // continue
+ continue;
+ } else if(valid_2byte($char)) { // check 1 byte
+ if(!valid_nextbyte(ord(substr($string, $i++, 1))))
+ return false;
+ } else if(valid_3byte($char)) { // check 2 bytes
+ if(!valid_nextbyte(ord(substr($string, $i++, 1))))
+ return false;
+ if(!valid_nextbyte(ord(substr($string, $i++, 1))))
+ return false;
+ } else if(valid_4byte($char)) { // check 3 bytes
+ if(!valid_nextbyte(ord(substr($string, $i++, 1))))
+ return false;
+ if(!valid_nextbyte(ord(substr($string, $i++, 1))))
+ return false;
+ if(!valid_nextbyte(ord(substr($string, $i++, 1))))
+ return false;
+ } // goto next char
+ }
+ return true; // done
+ }
+
+function csc ($s) {
+ if (valid_utf8 ($s)) {
+ return $s;
+ } else {
+ return iconv(get_option ("dccharset"),"UTF-8",$s);
+ }
+}
+
+function textconv ($s) {
+ return csc (preg_replace ('|(?<!<br />)\s*\n|', ' ', $s));
+}
+
+/**
+ The Main Importer Class
+**/
+class Dotclear_Import {
+
+ function header()
+ {
+ echo '<div class="wrap">';
+ echo '<h2>'.__('Import DotClear').'</h2>';
+ echo '<p>'.__('Steps may take a few minutes depending on the size of your database. Please be patient.').'</p>';
+ }
+
+ function footer()
+ {
+ echo '</div>';
+ }
+
+ function greet()
+ {
+ echo '<div class="narrow"><p>'.__('Howdy! This importer allows you to extract posts from a DotClear database into your blog. Mileage may vary.').'</p>';
+ echo '<p>'.__('Your DotClear Configuration settings are as follows:').'</p>';
+ echo '<form action="admin.php?import=dotclear&amp;step=1" method="post">';
+ $this->db_form();
+ echo '<p class="submit"><input type="submit" name="submit" value="'.__('Import Categories').' &raquo;" /></p>';
+ echo '</form></div>';
+ }
+
+ function get_dc_cats()
+ {
+ global $wpdb;
+ // General Housekeeping
+ $dcdb = new wpdb(get_option('dcuser'), get_option('dcpass'), get_option('dcname'), get_option('dchost'));
+ set_magic_quotes_runtime(0);
+ $dbprefix = get_option('dcdbprefix');
+
+ // Get Categories
+ return $dcdb->get_results('SELECT * FROM '.$dbprefix.'categorie', ARRAY_A);
+ }
+
+ function get_dc_users()
+ {
+ global $wpdb;
+ // General Housekeeping
+ $dcdb = new wpdb(get_option('dcuser'), get_option('dcpass'), get_option('dcname'), get_option('dchost'));
+ set_magic_quotes_runtime(0);
+ $dbprefix = get_option('dcdbprefix');
+
+ // Get Users
+
+ return $dcdb->get_results('SELECT * FROM '.$dbprefix.'user', ARRAY_A);
+ }
+
+ function get_dc_posts()
+ {
+ // General Housekeeping
+ $dcdb = new wpdb(get_option('dcuser'), get_option('dcpass'), get_option('dcname'), get_option('dchost'));
+ set_magic_quotes_runtime(0);
+ $dbprefix = get_option('dcdbprefix');
+
+ // Get Posts
+ return $dcdb->get_results('SELECT '.$dbprefix.'post.*, '.$dbprefix.'categorie.cat_libelle_url AS post_cat_name
+ FROM '.$dbprefix.'post INNER JOIN '.$dbprefix.'categorie
+ ON '.$dbprefix.'post.cat_id = '.$dbprefix.'categorie.cat_id', ARRAY_A);
+ }
+
+ function get_dc_comments()
+ {
+ global $wpdb;
+ // General Housekeeping
+ $dcdb = new wpdb(get_option('dcuser'), get_option('dcpass'), get_option('dcname'), get_option('dchost'));
+ set_magic_quotes_runtime(0);
+ $dbprefix = get_option('dcdbprefix');
+
+ // Get Comments
+ return $dcdb->get_results('SELECT * FROM '.$dbprefix.'comment', ARRAY_A);
+ }
+
+ function get_dc_links()
+ {
+ //General Housekeeping
+ $dcdb = new wpdb(get_option('dcuser'), get_option('dcpass'), get_option('dcname'), get_option('dchost'));
+ set_magic_quotes_runtime(0);
+ $dbprefix = get_option('dcdbprefix');
+
+ return $dcdb->get_results('SELECT * FROM '.$dbprefix.'link ORDER BY position', ARRAY_A);
+ }
+
+ function cat2wp($categories='')
+ {
+ // General Housekeeping
+ global $wpdb;
+ $count = 0;
+ $dccat2wpcat = array();
+ // Do the Magic
+ if(is_array($categories))
+ {
+ echo '<p>'.__('Importing Categories...').'<br /><br /></p>';
+ foreach ($categories as $category)
+ {
+ $count++;
+ extract($category);
+
+ // Make Nice Variables
+ $name = $wpdb->escape($cat_libelle_url);
+ $title = $wpdb->escape(csc ($cat_libelle));
+ $desc = $wpdb->escape(csc ($cat_desc));
+
+ if($cinfo = category_exists($name))
+ {
+ $ret_id = wp_insert_category(array('cat_ID' => $cinfo, 'category_nicename' => $name, 'cat_name' => $title, 'category_description' => $desc));
+ }
+ else
+ {
+ $ret_id = wp_insert_category(array('category_nicename' => $name, 'cat_name' => $title, 'category_description' => $desc));
+ }
+ $dccat2wpcat[$id] = $ret_id;
+ }
+
+ // Store category translation for future use
+ add_option('dccat2wpcat',$dccat2wpcat);
+ echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> categories imported.'), $count).'<br /><br /></p>';
+ return true;
+ }
+ echo __('No Categories to Import!');
+ return false;
+ }
+
+ function users2wp($users='')
+ {
+ // General Housekeeping
+ global $wpdb;
+ $count = 0;
+ $dcid2wpid = array();
+