-
+ C57BE38C164F3FA4DDD78683D82FAE14230A83E4A3D571C83F53689C447EEDD0ACA7C9D97C1C67EFF7FE9DA868ED0D7148457CAF5EAFB2357FD973732B153058mp-wp/wp-admin/import/textpattern.php(0 . 0)(1 . 700)
 20354 <?php
 20355 /**
 20356  * TextPattern Importer
 20357  *
 20358  * @package WordPress
 20359  * @subpackage Importer
 20360  */
 20361 
 20362 if(!function_exists('get_comment_count'))
 20363 {
 20364 	/**
 20365 	 * Get the comment count for posts.
 20366 	 *
 20367 	 * @package WordPress
 20368 	 * @subpackage Textpattern_Import
 20369 	 *
 20370 	 * @param int $post_ID Post ID
 20371 	 * @return int
 20372 	 */
 20373 	function get_comment_count($post_ID)
 20374 	{
 20375 		global $wpdb;
 20376 		return $wpdb->get_var( $wpdb->prepare("SELECT count(*) FROM $wpdb->comments WHERE comment_post_ID = %d", $post_ID) );
 20377 	}
 20378 }
 20379 
 20380 if(!function_exists('link_exists'))
 20381 {
 20382 	/**
 20383 	 * Check whether link already exists.
 20384 	 *
 20385 	 * @package WordPress
 20386 	 * @subpackage Textpattern_Import
 20387 	 *
 20388 	 * @param string $linkname
 20389 	 * @return int
 20390 	 */
 20391 	function link_exists($linkname)
 20392 	{
 20393 		global $wpdb;
 20394 		return $wpdb->get_var( $wpdb->prepare("SELECT link_id FROM $wpdb->links WHERE link_name = %s", $linkname) );
 20395 	}
 20396 }
 20397 
 20398 /**
 20399  * TextPattern Importer Class
 20400  *
 20401  * @since unknown
 20402  */
 20403 class Textpattern_Import {
 20404 
 20405 	function header()
 20406 	{
 20407 		echo '<div class="wrap">';
 20408 		screen_icon();
 20409 		echo '<h2>'.__('Import Textpattern').'</h2>';
 20410 		echo '<p>'.__('Steps may take a few minutes depending on the size of your database. Please be patient.').'</p>';
 20411 	}
 20412 
 20413 	function footer()
 20414 	{
 20415 		echo '</div>';
 20416 	}
 20417 
 20418 	function greet() {
 20419 		echo '<div class="narrow">';
 20420 		echo '<p>'.__('Howdy! This imports categories, users, posts, comments, and links from any Textpattern 4.0.2+ into this blog.').'</p>';
 20421 		echo '<p>'.__('This has not been tested on previous versions of Textpattern.  Mileage may vary.').'</p>';
 20422 		echo '<p>'.__('Your Textpattern Configuration settings are as follows:').'</p>';
 20423 		echo '<form action="admin.php?import=textpattern&step=1" method="post">';
 20424 		wp_nonce_field('import-textpattern');
 20425 		$this->db_form();
 20426 		echo '<p class="submit"><input type="submit" name="submit" class="button" value="'.attribute_escape(__('Import')).'" /></p>';
 20427 		echo '</form>';
 20428 		echo '</div>';
 20429 	}
 20430 
 20431 	function get_txp_cats()
 20432 	{
 20433 		global $wpdb;
 20434 		// General Housekeeping
 20435 		$txpdb = new wpdb(get_option('txpuser'), get_option('txppass'), get_option('txpname'), get_option('txphost'));
 20436 		set_magic_quotes_runtime(0);
 20437 		$prefix = get_option('tpre');
 20438 
 20439 		// Get Categories
 20440 		return $txpdb->get_results('SELECT
 20441 			id,
 20442 			name,
 20443 			title
 20444 			FROM '.$prefix.'txp_category
 20445 			WHERE type = "article"',
 20446 			ARRAY_A);
 20447 	}
 20448 
 20449 	function get_txp_users()
 20450 	{
 20451 		global $wpdb;
 20452 		// General Housekeeping
 20453 		$txpdb = new wpdb(get_option('txpuser'), get_option('txppass'), get_option('txpname'), get_option('txphost'));
 20454 		set_magic_quotes_runtime(0);
 20455 		$prefix = get_option('tpre');
 20456 
 20457 		// Get Users
 20458 
 20459 		return $txpdb->get_results('SELECT
 20460 			user_id,
 20461 			name,
 20462 			RealName,
 20463 			email,
 20464 			privs
 20465 			FROM '.$prefix.'txp_users', ARRAY_A);
 20466 	}
 20467 
 20468 	function get_txp_posts()
 20469 	{
 20470 		// General Housekeeping
 20471 		$txpdb = new wpdb(get_option('txpuser'), get_option('txppass'), get_option('txpname'), get_option('txphost'));
 20472 		set_magic_quotes_runtime(0);
 20473 		$prefix = get_option('tpre');
 20474 
 20475 		// Get Posts
 20476 		return $txpdb->get_results('SELECT
 20477 			ID,
 20478 			Posted,
 20479 			AuthorID,
 20480 			LastMod,
 20481 			Title,
 20482 			Body,
 20483 			Excerpt,
 20484 			Category1,
 20485 			Category2,
 20486 			Status,
 20487 			Keywords,
 20488 			url_title,
 20489 			comments_count
 20490 			FROM '.$prefix.'textpattern
 20491 			', ARRAY_A);
 20492 	}
 20493 
 20494 	function get_txp_comments()
 20495 	{
 20496 		global $wpdb;
 20497 		// General Housekeeping
 20498 		$txpdb = new wpdb(get_option('txpuser'), get_option('txppass'), get_option('txpname'), get_option('txphost'));
 20499 		set_magic_quotes_runtime(0);
 20500 		$prefix = get_option('tpre');
 20501 
 20502 		// Get Comments
 20503 		return $txpdb->get_results('SELECT * FROM '.$prefix.'txp_discuss', ARRAY_A);
 20504 	}
 20505 
 20506 		function get_txp_links()
 20507 	{
 20508 		//General Housekeeping
 20509 		$txpdb = new wpdb(get_option('txpuser'), get_option('txppass'), get_option('txpname'), get_option('txphost'));
 20510 		set_magic_quotes_runtime(0);
 20511 		$prefix = get_option('tpre');
 20512 
 20513 		return $txpdb->get_results('SELECT
 20514 			id,
 20515 			date,
 20516 			category,
 20517 			url,
 20518 			linkname,
 20519 			description
 20520 			FROM '.$prefix.'txp_link',
 20521 			ARRAY_A);
 20522 	}
 20523 
 20524 	function cat2wp($categories='')
 20525 	{
 20526 		// General Housekeeping
 20527 		global $wpdb;
 20528 		$count = 0;
 20529 		$txpcat2wpcat = array();
 20530 		// Do the Magic
 20531 		if(is_array($categories))
 20532 		{
 20533 			echo '<p>'.__('Importing Categories...').'<br /><br /></p>';
 20534 			foreach ($categories as $category)
 20535 			{
 20536 				$count++;
 20537 				extract($category);
 20538 
 20539 
 20540 				// Make Nice Variables
 20541 				$name = $wpdb->escape($name);
 20542 				$title = $wpdb->escape($title);
 20543 
 20544 				if($cinfo = category_exists($name))
 20545 				{
 20546 					$ret_id = wp_insert_category(array('cat_ID' => $cinfo, 'category_nicename' => $name, 'cat_name' => $title));
 20547 				}
 20548 				else
 20549 				{
 20550 					$ret_id = wp_insert_category(array('category_nicename' => $name, 'cat_name' => $title));
 20551 				}
 20552 				$txpcat2wpcat[$id] = $ret_id;
 20553 			}
 20554 
 20555 			// Store category translation for future use
 20556 			add_option('txpcat2wpcat',$txpcat2wpcat);
 20557 			echo '<p>'.sprintf(__ngettext('Done! <strong>%1$s</strong> category imported.', 'Done! <strong>%1$s</strong> categories imported.', $count), $count).'<br /><br /></p>';
 20558 			return true;
 20559 		}
 20560 		echo __('No Categories to Import!');
 20561 		return false;
 20562 	}
 20563 
 20564 	function users2wp($users='')
 20565 	{
 20566 		// General Housekeeping
 20567 		global $wpdb;
 20568 		$count = 0;
 20569 		$txpid2wpid = array();
 20570 
 20571 		// Midnight Mojo
 20572 		if(is_array($users))
 20573 		{
 20574 			echo '<p>'.__('Importing Users...').'<br /><br /></p>';
 20575 			foreach($users as $user)
 20576 			{
 20577 				$count++;
 20578 				extract($user);
 20579 
 20580 				// Make Nice Variables
 20581 				$name = $wpdb->escape($name);
 20582 				$RealName = $wpdb->escape($RealName);
 20583 
 20584 				if($uinfo = get_userdatabylogin($name))
 20585 				{
 20586 
 20587 					$ret_id = wp_insert_user(array(
 20588 								'ID'			=> $uinfo->ID,
 20589 								'user_login'	=> $name,
 20590 								'user_nicename'	=> $RealName,
 20591 								'user_email'	=> $email,
 20592 								'user_url'		=> 'http://',
 20593 								'display_name'	=> $name)
 20594 								);
 20595 				}
 20596 				else
 20597 				{
 20598 					$ret_id = wp_insert_user(array(
 20599 								'user_login'	=> $name,
 20600 								'user_nicename'	=> $RealName,
 20601 								'user_email'	=> $email,
 20602 								'user_url'		=> 'http://',
 20603 								'display_name'	=> $name)
 20604 								);
 20605 				}
 20606 				$txpid2wpid[$user_id] = $ret_id;
 20607 
 20608 				// Set Textpattern-to-WordPress permissions translation
 20609 				$transperms = array(1 => '10', 2 => '9', 3 => '5', 4 => '4', 5 => '3', 6 => '2', 7 => '0');
 20610 
 20611 				// Update Usermeta Data
 20612 				$user = new WP_User($ret_id);
 20613 				if('10' == $transperms[$privs]) { $user->set_role('administrator'); }
 20614 				if('9'  == $transperms[$privs]) { $user->set_role('editor'); }
 20615 				if('5'  == $transperms[$privs]) { $user->set_role('editor'); }
 20616 				if('4'  == $transperms[$privs]) { $user->set_role('author'); }
 20617 				if('3'  == $transperms[$privs]) { $user->set_role('contributor'); }
 20618 				if('2'  == $transperms[$privs]) { $user->set_role('contributor'); }
 20619 				if('0'  == $transperms[$privs]) { $user->set_role('subscriber'); }
 20620 
 20621 				update_usermeta( $ret_id, 'wp_user_level', $transperms[$privs] );
 20622 				update_usermeta( $ret_id, 'rich_editing', 'false');
 20623 			}// End foreach($users as $user)
 20624 
 20625 			// Store id translation array for future use
 20626 			add_option('txpid2wpid',$txpid2wpid);
 20627 
 20628 
 20629 			echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> users imported.'), $count).'<br /><br /></p>';
 20630 			return true;
 20631 		}// End if(is_array($users)
 20632 
 20633 		echo __('No Users to Import!');
 20634 		return false;
 20635 
 20636 	}// End function user2wp()
 20637 
 20638 	function posts2wp($posts='')
 20639 	{
 20640 		// General Housekeeping
 20641 		global $wpdb;
 20642 		$count = 0;
 20643 		$txpposts2wpposts = array();
 20644 		$cats = array();
 20645 
 20646 		// Do the Magic
 20647 		if(is_array($posts))
 20648 		{
 20649 			echo '<p>'.__('Importing Posts...').'<br /><br /></p>';
 20650 			foreach($posts as $post)
 20651 			{
 20652 				$count++;
 20653 				extract($post);
 20654 
 20655 				// Set Textpattern-to-WordPress status translation
 20656 				$stattrans = array(1 => 'draft', 2 => 'private', 3 => 'draft', 4 => 'publish', 5 => 'publish');
 20657 
 20658 				//Can we do this more efficiently?
 20659 				$uinfo = ( get_userdatabylogin( $AuthorID ) ) ? get_userdatabylogin( $AuthorID ) : 1;
 20660 				$authorid = ( is_object( $uinfo ) ) ? $uinfo->ID : $uinfo ;
 20661 
 20662 				$Title = $wpdb->escape($Title);
 20663 				$Body = $wpdb->escape($Body);
 20664 				$Excerpt = $wpdb->escape($Excerpt);
 20665 				$post_status = $stattrans[$Status];
 20666 
 20667 				// Import Post data into WordPress
 20668 
 20669 				if($pinfo = post_exists($Title,$Body))
 20670 				{
 20671 					$ret_id = wp_insert_post(array(
 20672 						'ID'				=> $pinfo,
 20673 						'post_date'			=> $Posted,
 20674 						'post_date_gmt'		=> $post_date_gmt,
 20675 						'post_author'		=> $authorid,
 20676 						'post_modified'		=> $LastMod,
 20677 						'post_modified_gmt' => $post_modified_gmt,
 20678 						'post_title'		=> $Title,
 20679 						'post_content'		=> $Body,
 20680 						'post_excerpt'		=> $Excerpt,
 20681 						'post_status'		=> $post_status,
 20682 						'post_name'			=> $url_title,
 20683 						'comment_count'		=> $comments_count)
 20684 						);
 20685 					if ( is_wp_error( $ret_id ) )
 20686 						return $ret_id;
 20687 				}
 20688 				else
 20689 				{
 20690 					$ret_id = wp_insert_post(array(
 20691 						'post_date'			=> $Posted,
 20692 						'post_date_gmt'		=> $post_date_gmt,
 20693 						'post_author'		=> $authorid,
 20694 						'post_modified'		=> $LastMod,
 20695 						'post_modified_gmt' => $post_modified_gmt,
 20696 						'post_title'		=> $Title,
 20697 						'post_content'		=> $Body,
 20698 						'post_excerpt'		=> $Excerpt,
 20699 						'post_status'		=> $post_status,
 20700 						'post_name'			=> $url_title,
 20701 						'comment_count'		=> $comments_count)
 20702 						);
 20703 					if ( is_wp_error( $ret_id ) )
 20704 						return $ret_id;
 20705 				}
 20706 				$txpposts2wpposts[$ID] = $ret_id;
 20707 
 20708 				// Make Post-to-Category associations
 20709 				$cats = array();
 20710 				$category1 = get_category_by_slug($Category1);
 20711 				$category1 = $category1->term_id;
 20712 				$category2 = get_category_by_slug($Category2);
 20713 				$category2 = $category2->term_id;
 20714 				if($cat1 = $category1) { $cats[1] = $cat1; }
 20715 				if($cat2 = $category2) { $cats[2] = $cat2; }
 20716 
 20717 				if(!empty($cats)) { wp_set_post_categories($ret_id, $cats); }
 20718 			}
 20719 		}
 20720 		// Store ID translation for later use
 20721 		add_option('txpposts2wpposts',$txpposts2wpposts);
 20722 
 20723 		echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> posts imported.'), $count).'<br /><br /></p>';
 20724 		return true;
 20725 	}
 20726 
 20727 	function comments2wp($comments='')
 20728 	{
 20729 		// General Housekeeping
 20730 		global $wpdb;
 20731 		$count = 0;
 20732 		$txpcm2wpcm = array();
 20733 		$postarr = get_option('txpposts2wpposts');
 20734 
 20735 		// Magic Mojo
 20736 		if(is_array($comments))
 20737 		{
 20738 			echo '<p>'.__('Importing Comments...').'<br /><br /></p>';
 20739 			foreach($comments as $comment)
 20740 			{
 20741 				$count++;
 20742 				extract($comment);
 20743 
 20744 				// WordPressify Data
 20745 				$comment_ID = ltrim($discussid, '0');
 20746 				$comment_post_ID = $postarr[$parentid];
 20747 				$comment_approved = (1 == $visible) ? 1 : 0;
 20748 				$name = $wpdb->escape($name);
 20749 				$email = $wpdb->escape($email);
 20750 				$web = $wpdb->escape($web);
 20751 				$message = $wpdb->escape($message);
 20752 
 20753 				if($cinfo = comment_exists($name, $posted))
 20754 				{
 20755 					// Update comments
 20756 					$ret_id = wp_update_comment(array(
 20757 						'comment_ID'			=> $cinfo,
 20758 						'comment_post_ID'		=> $comment_post_ID,
 20759 						'comment_author'		=> $name,
 20760 						'comment_author_email'	=> $email,
 20761 						'comment_author_url'	=> $web,
 20762 						'comment_date'			=> $posted,
 20763 						'comment_content'		=> $message,
 20764 						'comment_approved'		=> $comment_approved)
 20765 						);
 20766 				}
 20767 				else
 20768 				{
 20769 					// Insert comments
 20770 					$ret_id = wp_insert_comment(array(
 20771 						'comment_post_ID'		=> $comment_post_ID,
 20772 						'comment_author'		=> $name,
 20773 						'comment_author_email'	=> $email,
 20774 						'comment_author_url'	=> $web,
 20775 						'comment_author_IP'		=> $ip,
 20776 						'comment_date'			=> $posted,
 20777 						'comment_content'		=> $message,
 20778 						'comment_approved'		=> $comment_approved)
 20779 						);
 20780 				}
 20781 				$txpcm2wpcm[$comment_ID] = $ret_id;
 20782 			}
 20783 			// Store Comment ID translation for future use
 20784 			add_option('txpcm2wpcm', $txpcm2wpcm);
 20785 
 20786 			// Associate newly formed categories with posts
 20787 			get_comment_count($ret_id);
 20788 
 20789 
 20790 			echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> comments imported.'), $count).'<br /><br /></p>';
 20791 			return true;
 20792 		}
 20793 		echo __('No Comments to Import!');
 20794 		return false;
 20795 	}
 20796 
 20797 	function links2wp($links='')
 20798 	{
 20799 		// General Housekeeping
 20800 		global $wpdb;
 20801 		$count = 0;
 20802 
 20803 		// Deal with the links
 20804 		if(is_array($links))
 20805 		{
 20806 			echo '<p>'.__('Importing Links...').'<br /><br /></p>';
 20807 			foreach($links as $link)
 20808 			{
 20809 				$count++;
 20810 				extract($link);
 20811 
 20812 				// Make nice vars
 20813 				$category = $wpdb->escape($category);
 20814 				$linkname = $wpdb->escape($linkname);
 20815 				$description = $wpdb->escape($description);
 20816 
 20817 				if($linfo = link_exists($linkname))
 20818 				{
 20819 					$ret_id = wp_insert_link(array(
 20820 								'link_id'			=> $linfo,
 20821 								'link_url'			=> $url,
 20822 								'link_name'			=> $linkname,
 20823 								'link_category'		=> $category,
 20824 								'link_description'	=> $description,
 20825 								'link_updated'		=> $date)
 20826 								);
 20827 				}
 20828 				else
 20829 				{
 20830 					$ret_id = wp_insert_link(array(
 20831 								'link_url'			=> $url,
 20832 								'link_name'			=> $linkname,
 20833 								'link_category'		=> $category,
 20834 								'link_description'	=> $description,
 20835 								'link_updated'		=> $date)
 20836 								);
 20837 				}
 20838 				$txplinks2wplinks[$link_id] = $ret_id;
 20839 			}
 20840 			add_option('txplinks2wplinks',$txplinks2wplinks);
 20841 			echo '<p>';
 20842 			printf(__ngettext('Done! <strong>%s</strong> link imported', 'Done! <strong>%s</strong> links imported', $count), $count);
 20843 			echo '<br /><br /></p>';
 20844 			return true;
 20845 		}
 20846 		echo __('No Links to Import!');
 20847 		return false;
 20848 	}
 20849 
 20850 	function import_categories()
 20851 	{
 20852 		// Category Import
 20853 		$cats = $this->get_txp_cats();
 20854 		$this->cat2wp($cats);
 20855 		add_option('txp_cats', $cats);
 20856 
 20857 
 20858 
 20859 		echo '<form action="admin.php?import=textpattern&step=2" method="post">';
 20860 		wp_nonce_field('import-textpattern');
 20861 		printf('<p class="submit"><input type="submit" name="submit" class="button" value="%s" /></p>', attribute_escape(__('Import Users')));
 20862 		echo '</form>';
 20863 
 20864 	}
 20865 
 20866 	function import_users()
 20867 	{
 20868 		// User Import
 20869 		$users = $this->get_txp_users();
 20870 		$this->users2wp($users);
 20871 
 20872 		echo '<form action="admin.php?import=textpattern&step=3" method="post">';
 20873 		wp_nonce_field('import-textpattern');
 20874 		printf('<p class="submit"><input type="submit" name="submit" class="button" value="%s" /></p>', attribute_escape(__('Import Posts')));
 20875 		echo '</form>';
 20876 	}
 20877 
 20878 	function import_posts()
 20879 	{
 20880 		// Post Import
 20881 		$posts = $this->get_txp_posts();
 20882 		$result = $this->posts2wp($posts);
 20883 		if ( is_wp_error( $result ) )
 20884 			return $result;
 20885 
 20886 		echo '<form action="admin.php?import=textpattern&step=4" method="post">';
 20887 		wp_nonce_field('import-textpattern');
 20888 		printf('<p class="submit"><input type="submit" name="submit" class="button" value="%s" /></p>', attribute_escape(__('Import Comments')));
 20889 		echo '</form>';
 20890 	}
 20891 
 20892 	function import_comments()
 20893 	{
 20894 		// Comment Import
 20895 		$comments = $this->get_txp_comments();
 20896 		$this->comments2wp($comments);
 20897 
 20898 		echo '<form action="admin.php?import=textpattern&step=5" method="post">';
 20899 		wp_nonce_field('import-textpattern');
 20900 		printf('<p class="submit"><input type="submit" name="submit" class="button" value="%s" /></p>', attribute_escape(__('Import Links')));
 20901 		echo '</form>';
 20902 	}
 20903 
 20904 	function import_links()
 20905 	{
 20906 		//Link Import
 20907 		$links = $this->get_txp_links();
 20908 		$this->links2wp($links);
 20909 		add_option('txp_links', $links);
 20910 
 20911 		echo '<form action="admin.php?import=textpattern&step=6" method="post">';
 20912 		wp_nonce_field('import-textpattern');
 20913 		printf('<p class="submit"><input type="submit" name="submit" class="button" value="%s" /></p>', attribute_escape(__('Finish')));
 20914 		echo '</form>';
 20915 	}
 20916 
 20917 	function cleanup_txpimport()
 20918 	{
 20919 		delete_option('tpre');
 20920 		delete_option('txp_cats');
 20921 		delete_option('txpid2wpid');
 20922 		delete_option('txpcat2wpcat');
 20923 		delete_option('txpposts2wpposts');
 20924 		delete_option('txpcm2wpcm');
 20925 		delete_option('txplinks2wplinks');
 20926 		delete_option('txpuser');
 20927 		delete_option('txppass');
 20928 		delete_option('txpname');
 20929 		delete_option('txphost');
 20930 		do_action('import_done', 'textpattern');
 20931 		$this->tips();
 20932 	}
 20933 
 20934 	function tips()
 20935 	{
 20936 		echo '<p>'.__('Welcome to WordPress.  We hope (and expect!) that you will find this platform incredibly rewarding!  As a new WordPress user coming from Textpattern, there are some things that we would like to point out.  Hopefully, they will help your transition go as smoothly as possible.').'</p>';
 20937 		echo '<h3>'.__('Users').'</h3>';
 20938 		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 Textpattern, 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 Textpattern 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.'), get_bloginfo( 'wpurl' ) . '/wp-login.php').'</p>';
 20939 		echo '<h3>'.__('Preserving Authors').'</h3>';
 20940 		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>';
 20941 		echo '<h3>'.__('Textile').'</h3>';
 20942 		echo '<p>'.__('Also, since you’re coming from Textpattern, 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>';
 20943 		echo '<h3>'.__('WordPress Resources').'</h3>';
 20944 		echo '<p>'.__('Finally, there are numerous WordPress resources around the internet.  Some of them are:').'</p>';
 20945 		echo '<ul>';
 20946 		echo '<li>'.__('<a href="http://www.wordpress.org">The official WordPress site</a>').'</li>';
 20947 		echo '<li>'.__('<a href="http://wordpress.org/support/">The WordPress support forums</a>').'</li>';
 20948 		echo '<li>'.__('<a href="http://codex.wordpress.org">The Codex (In other words, the WordPress Bible)</a>').'</li>';
 20949 		echo '</ul>';
 20950 		echo '<p>'.sprintf(__('That’s it! What are you waiting for? Go <a href="%1$s">login</a>!'), get_bloginfo( 'wpurl' ) . '/wp-login.php').'</p>';
 20951 	}
 20952 
 20953 	function db_form()
 20954 	{
 20955 		echo '<table class="form-table">';
 20956 		printf('<tr><th scope="row"><label for="dbuser">%s</label></th><td><input type="text" name="dbuser" id="dbuser" /></td></tr>', __('Textpattern Database User:'));
 20957 		printf('<tr><th scope="row"><label for="dbpass">%s</label></th><td><input type="password" name="dbpass" id="dbpass" /></td></tr>', __('Textpattern Database Password:'));
 20958 		printf('<tr><th scope="row"><label for="dbname">%s</label></th><td><input type="text" id="dbname" name="dbname" /></td></tr>', __('Textpattern Database Name:'));
 20959 		printf('<tr><th scope="row"><label for="dbhost">%s</label></th><td><input type="text" id="dbhost" name="dbhost" value="localhost" /></td></tr>', __('Textpattern Database Host:'));
 20960 		printf('<tr><th scope="row"><label for="dbprefix">%s</label></th><td><input type="text" name="dbprefix" id="dbprefix"  /></td></tr>', __('Textpattern Table prefix (if any):'));
 20961 		echo '</table>';
 20962 	}
 20963 
 20964 	function dispatch()
 20965 	{
 20966 
 20967 		if (empty ($_GET['step']))
 20968 			$step = 0;
 20969 		else
 20970 			$step = (int) $_GET['step'];
 20971 		$this->header();
 20972 
 20973 		if ( $step > 0 )
 20974 		{
 20975 			check_admin_referer('import-textpattern');
 20976 
 20977 			if($_POST['dbuser'])
 20978 			{
 20979 				if(get_option('txpuser'))
 20980 					delete_option('txpuser');
 20981 				add_option('txpuser', sanitize_user($_POST['dbuser'], true));
 20982 			}
 20983 			if($_POST['dbpass'])
 20984 			{
 20985 				if(get_option('txppass'))
 20986 					delete_option('txppass');
 20987 				add_option('txppass',  sanitize_user($_POST['dbpass'], true));
 20988 			}
 20989 
 20990 			if($_POST['dbname'])
 20991 			{
 20992 				if(get_option('txpname'))
 20993 					delete_option('txpname');
 20994 				add_option('txpname',  sanitize_user($_POST['dbname'], true));
 20995 			}
 20996 			if($_POST['dbhost'])
 20997 			{
 20998 				if(get_option('txphost'))
 20999 					delete_option('txphost');
 21000 				add_option('txphost',  sanitize_user($_POST['dbhost'], true));
 21001 			}
 21002 			if($_POST['dbprefix'])
 21003 			{
 21004 				if(get_option('tpre'))
 21005 					delete_option('tpre');
 21006 				add_option('tpre',  sanitize_user($_POST['dbprefix']));
 21007 			}
 21008 
 21009 
 21010 		}
 21011 
 21012 		switch ($step)
 21013 		{
 21014 			default:
 21015 			case 0 :
 21016 				$this->greet();
 21017 				break;
 21018 			case 1 :
 21019 				$this->import_categories();
 21020 				break;
 21021 			case 2 :
 21022 				$this->import_users();
 21023 				break;
 21024 			case 3 :
 21025 				$result = $this->import_posts();
 21026 				if ( is_wp_error( $result ) )
 21027 					echo $result->get_error_message();
 21028 				break;
 21029 			case 4 :
 21030 				$this->import_comments();
 21031 				break;
 21032 			case 5 :
 21033 				$this->import_links();
 21034 				break;
 21035 			case 6 :
 21036 				$this->cleanup_txpimport();
 21037 				break;
 21038 		}
 21039 
 21040 		$this->footer();
 21041 	}
 21042 
 21043 	function Textpattern_Import()
 21044 	{
 21045 		// Nothing.
 21046 	}
 21047 }
 21048 
 21049 $txp_import = new Textpattern_Import();
 21050 
 21051 register_importer('textpattern', __('Textpattern'), __('Import categories, users, posts, comments, and links from a Textpattern blog.'), array ($txp_import, 'dispatch'));
 21052 
 21053 ?>