<?xml version="1.0"?>
<importer xmlns="http://www.elkarte.net/xml/importer" xmlns:elkarte="http://www.elkarte.net/">
	<general>
		<name>SMF 1.1</name>
		<version>ElkArte 1.0</version>
		<className>SMF1_1</className>
	</general>
	<step>
		<title>Importing settings</title>
		<detect>{$from_prefix}settings</detect>
		<destination>{$to_prefix}settings</destination>
		<options>
			<replace>true</replace>
		</options>
		<code>
			$do_import = array(
				'news',
				'compactTopicPagesContiguous',
				'compactTopicPagesEnable',
				'enablePinnedTopics',
				'todayMod',
				'enablePreviousNext',
				'pollMode',
				'enableVBStyleLogin',
				'enableCompressedOutput',
				'attachmentSizeLimit',
				'attachmentPostLimit',
				'attachmentNumPerPostLimit',
				'attachmentDirSizeLimit',
				'attachmentExtensions',
				'attachmentCheckExtensions',
				'attachmentShowImages',
				'attachmentEnable',
				'attachmentEncryptFilenames',
				'attachmentThumbnails',
				'attachmentThumbWidth',
				'attachmentThumbHeight',
				'censorIgnoreCase',
				'mostOnline',
				'mostOnlineToday',
				'mostDate',
				'allow_disableAnnounce',
				'trackStats',
				'userLanguage',
				'titlesEnable',
				'topicSummaryPosts',
				'enableErrorLogging',
				'max_image_width',
				'max_image_height',
				'onlineEnable',
				'smtp_host',
				'smtp_port',
				'smtp_username',
				'smtp_password',
				'mail_type',
				'timeLoadPageEnable',
				'totalMembers',
				'totalTopics',
				'totalMessages',
				'simpleSearch',
				'censor_vulgar',
				'censor_proper',
				'enablePostHTML',
				'enableEmbeddedFlash',
				'xmlnews_enable',
				'xmlnews_maxlen',
				'hotTopicPosts',
				'hotTopicVeryPosts',
				'registration_method',
				'send_validation_onChange',
				'send_welcomeEmail',
				'allow_editDisplayName',
				'allow_hideOnline',
				'guest_hideContacts',
				'spamWaitTime',
				'pm_spam_settings',
				'reserveWord',
				'reserveCase',
				'reserveUser',
				'reserveName',
				'reserveNames',
				'autoLinkUrls',
				'banLastUpdated',
				'avatar_max_height_external',
				'avatar_max_width_external',
				'avatar_action_too_large',
				'avatar_max_height_upload',
				'avatar_max_width_upload',
				'avatar_resize_upload',
				'avatar_download_png',
				'failed_login_threshold',
				'oldTopicDays',
				'edit_wait_time',
				'edit_disable_time',
				'autoFixDatabase',
				'allow_guestAccess',
				'time_format',
				'number_format',
				'enableBBC',
				'max_messageLength',
				'signature_settings',
				'autoOptMaxOnline',
				'defaultMaxMessages',
				'defaultMaxTopics',
				'defaultMaxMembers',
				'enableParticipation',
				'recycle_enable',
				'recycle_board',
				'maxMsgID',
				'enableAllMessages',
				'fixLongWords',
				'who_enabled',
				'time_offset',
				'cookieTime',
				'lastActive',
				'requireAgreement',
				'unapprovedMembers',
				'package_make_backups',
				'databaseSession_enable',
				'databaseSession_loose',
				'databaseSession_lifetime',
				'search_cache_size',
				'search_results_per_page',
				'search_weight_frequency',
				'search_weight_age',
				'search_weight_length',
				'search_weight_subject',
				'search_weight_first_message',
				'search_max_results',
				'search_floodcontrol_time',
				'permission_enable_deny',
				'permission_enable_postgroups',
				'mail_next_send',
				'mail_recent',
				'settings_updated',
				'next_task_time',
				'warning_settings',
				'admin_features',
				'last_mod_report_action',
				'pruningOptions',
				'cache_enable',
				'reg_verification',
				'enable_buddylist',
				'birthday_email',
				'globalCookies',
				'default_timezone',
				'memberlist_updated',
				'latestMember',
				'latestRealName',
				'db_mysql_group_by_fix',
				'rand_seed',
				'mostOnlineUpdated',
				'search_pointer',
				'spider_name_cache',
				'modlog_enabled',
				'disabledBBC',
				'latest_member',
				'latest_real_name',
				'total_members',
				'total_messages',
				'max_msg_id',
				'total_topics',
				'disable_hash_time',
				'latestreal_name',
				'disableHashTime',
			);

			$request = $this->db->query("
				SELECT variable, value
				FROM {$from_prefix}settings;");

			while ($row = $this->db->fetch_assoc($request))
			{
				if (in_array($row['variable'], $do_import))
				{
					$this->db->query("
						REPLACE INTO {$to_prefix}settings
							(variable, value)
						VALUES('$row[variable]', '" . addcslashes($row['value'], '\'\\"') . "')");
				}

				if ($row['variable'] == 'pretty_board_urls')
				{
					$pretty_urls = $row['value'];
					store_global('pretty_urls', $row['value']);
				}
			}

			$this->db->free_result($request);
		</code>
	</step>
	<step type="mandatory">
		<title>Importing members</title>
		<detect>{$from_prefix}members</detect>
		<destination>{$to_prefix}members</destination>
		<presql>TRUNCATE {$to_prefix}members;</presql>
		<query>
			SELECT
				ID_MEMBER as id_member, memberName AS member_name, dateRegistered AS date_registered,
				posts, ID_GROUP as id_group, lngfile, lastLogin AS last_login,
				realName AS real_name, instantMessages AS personal_messages,
				unreadMessages AS unread_messages, buddy_list, pm_ignore_list,
				messageLabels AS message_labels, passwd, emailAddress AS email_address,
				personalText AS personal_text, gender, birthdate, websiteUrl AS website_url,
				websiteTitle AS website_title, location, hideEmail AS hide_email,
				showOnline AS show_online, timeFormat AS time_format, signature,
				timeOffset AS time_offset, avatar, pm_email_notify, usertitle, '' AS ignore_boards,
				notifyAnnouncements AS notify_announcements, notifyOnce AS notify_regularity,
				notifySendBody AS notify_send_body,	notifyTypes AS notify_types,
				memberIP AS member_ip, memberIP2 AS member_ip2,	secretQuestion AS secret_question,
				secretAnswer AS secret_answer, is_activated,
				validation_code, ID_MSG_LAST_VISIT AS id_msg_last_visit, additionalGroups AS additional_groups,
				smileySet AS smiley_set, ID_POST_GROUP AS id_post_group,
				totalTimeLoggedIn AS total_time_logged_in, passwordSalt AS password_salt
			FROM {$from_prefix}members;
		</query>
	</step>
	<step>
		<title>Importing attachments</title>
		<detect>{$from_prefix}attachments</detect>
		<destination>{$to_prefix}attachments</destination>
		<presql>TRUNCATE {$to_prefix}attachments;</presql>
		<presqlMethod>removeAttachments</presqlMethod>
		<preparsecode>
			moveAttachment($row, $this->db, $this->config->from_prefix, $this->step1_importer->getAttachDir($row));
		</preparsecode>
		<query>
			SELECT
				ID_ATTACH AS id_attach, ID_THUMB AS id_thumb, ID_MSG AS id_msg, ID_MEMBER AS id_member,
				attachmentType AS attachment_type, filename, file_hash, '' AS fileext,size, downloads,
				width, height,'' AS mime_type
			FROM {$from_prefix}attachments;
		</query>
	</step>
	<step>
		<title>Importing avatars</title>
		<code>
			$avatarg = $this->db->query("
				SELECT value
				FROM {$from_prefix}settings
				WHERE variable = 'avatar_directory';");
			list ($smf_avatarg) = $this->db->fetch_row($avatarg);
			$this->db->free_result($avatarg);

			$avatarg = $this->db->query("
				SELECT value
				FROM {$to_prefix}settings
				WHERE variable = 'avatar_directory';");
			list ($elk_avatarg) = $this->db->fetch_row($avatarg);
			$this->db->free_result($avatarg);

			if (!empty($smf_avatarg) and !empty($elk_avatarg))
				copy_dir_recursive($smf_avatarg, $elk_avatarg);

			$avatarg = $this->db->query("
				SELECT value
				FROM {$from_prefix}settings
				WHERE variable = 'custom_avatar_dir';");
			list ($smf_avatarg) = $this->db->fetch_row($avatarg);
			$this->db->free_result($avatarg);

			$avatarg = $this->db->query("
				SELECT value
				FROM {$to_prefix}settings
				WHERE variable = 'custom_avatar_dir';");
			list ($elk_avatarg) = $this->db->fetch_row($avatarg);
			$this->db->free_result($avatarg);

			if (!empty($smf_avatarg) and !empty($elk_avatarg))
				copy_dir_recursive($smf_avatarg, $elk_avatarg);
		</code>
	</step>
	<step>
		<title>Importing categories</title>
		<detect>{$from_prefix}categories</detect>
		<destination>{$to_prefix}categories</destination>
		<presql>TRUNCATE {$to_prefix}categories;</presql>
		<query>
			SELECT
				ID_CAT AS id_cat, name, catOrder AS cat_order, canCollapse AS can_collapse
			FROM {$from_prefix}categories;
		</query>
	</step>
	<step>
		<title>Importing collapsed categories</title>
		<detect>{$from_prefix}collapsed_categories</detect>
		<destination>{$to_prefix}collapsed_categories</destination>
		<presql>TRUNCATE {$to_prefix}collapsed_categories;</presql>
		<query>
			SELECT
				ID_CAT AS id_cat, ID_MEMBER AS id_member
			FROM {$from_prefix}collapsed_categories;
		</query>
	</step>
	<step>
		<title>Importing boards</title>
		<detect>{$from_prefix}boards</detect>
		<destination>{$to_prefix}boards</destination>
		<presql>TRUNCATE {$to_prefix}boards;</presql>
		<query>
			SELECT
				ID_BOARD AS id_board, ID_CAT AS id_cat, childLevel AS child_level,
				ID_PARENT AS id_parent, boardOrder AS board_order, ID_LAST_MSG AS id_last_msg,
				ID_MSG_UPDATED AS id_msg_updated, memberGroups AS member_groups,
				name, description, numTopics AS num_topics, numPosts AS num_posts,
				countPosts AS count_posts, ID_THEME AS id_theme, override_theme
			FROM {$from_prefix}boards;
		</query>
	</step>
	<step>
		<title>Importing topics</title>
		<detect>{$from_prefix}topics</detect>
		<destination>{$to_prefix}topics</destination>
		<presql>TRUNCATE {$to_prefix}topics;</presql>
		<query>
			SELECT
				ID_TOPIC AS id_topic, isSticky AS is_sticky, ID_BOARD AS id_board,
				ID_FIRST_MSG AS id_first_msg, ID_LAST_MSG AS id_last_msg,
				ID_MEMBER_STARTED AS id_member_started, ID_MEMBER_UPDATED AS id_member_updated,
				ID_POLL AS id_poll,numReplies AS num_replies, numViews AS num_views, locked
			FROM {$from_prefix}topics;
		</query>
	</step>
	<step>
		<title>Importing messages</title>
		<detect>{$from_prefix}messages</detect>
		<destination>{$to_prefix}messages</destination>
		<presql>TRUNCATE {$to_prefix}messages;</presql>
		<options>
			<limit>100</limit>
		</options>
		<query>
			SELECT
				ID_MSG AS id_msg, ID_TOPIC AS id_topic, ID_BOARD AS id_board, posterTime AS poster_time,
				ID_MEMBER AS id_member, ID_MSG_MODIFIED AS id_msg_modified,
				subject, posterName AS poster_name, posterEmail AS poster_email,
				posterIP AS poster_ip, smileysEnabled AS smileys_enabled,
				modifiedTime AS modified_time, modifiedName AS modified_name, body, icon
			FROM {$from_prefix}messages;
		</query>
	</step>
	<step>
		<title>Importing polls</title>
		<detect>{$from_prefix}polls</detect>
		<destination>{$to_prefix}polls</destination>
		<presql>TRUNCATE {$to_prefix}polls;</presql>
		<query>
			SELECT
				ID_POLL AS id_poll, question, votingLocked AS voting_locked,
				maxVotes AS max_votes, expireTime AS expire_time, hideResults AS hide_results,
				changeVote AS change_vote, ID_MEMBER AS id_member, posterName AS poster_name
			FROM {$from_prefix}polls;
		</query>
	</step>
	<step>
		<title>Importing poll choices</title>
		<detect>{$from_prefix}poll_choices</detect>
		<destination>{$to_prefix}poll_choices</destination>
		<presql>TRUNCATE {$to_prefix}poll_choices;</presql>
		<query>
			SELECT
				ID_POLL AS id_poll, ID_CHOICE AS id_choice, label, votes
			FROM {$from_prefix}poll_choices;
		</query>
	</step>
	<step>
		<title>Importing poll votes</title>
		<detect>{$from_prefix}log_polls</detect>
		<destination>{$to_prefix}log_polls</destination>
		<presql>TRUNCATE {$to_prefix}log_polls;</presql>
		<query>
			SELECT
				ID_POLL AS id_poll, ID_MEMBER AS id_member, ID_CHOICE AS id_choice
			FROM {$from_prefix}log_polls;
		</query>
	</step>
	<step>
		<title>Importing personal messages</title>
		<detect>{$from_prefix}personal_messages</detect>
		<destination>{$to_prefix}personal_messages</destination>
		<presql>TRUNCATE {$to_prefix}personal_messages;</presql>
		<options>
			<limit>200</limit>
		</options>
		<query>
			SELECT
				ID_PM AS id_pm, ID_PM AS id_pm_head, ID_MEMBER_FROM AS id_member_from, deletedBySender AS deleted_by_sender,
				fromName AS from_name, msgtime, subject, body
			FROM {$from_prefix}personal_messages;
		</query>
	</step>
	<step>
		<title>Importing pm recipients</title>
		<detect>{$from_prefix}pm_recipients</detect>
		<destination>{$to_prefix}pm_recipients</destination>
		<presql>TRUNCATE {$to_prefix}pm_recipients;</presql>
		<query>
			SELECT
				ID_PM AS id_pm, ID_MEMBER AS id_member, labels, bcc, is_read, deleted
			FROM {$from_prefix}pm_recipients;
		</query>
	</step>
	<step>
		<title>Importing board moderators</title>
		<detect>{$from_prefix}moderators</detect>
		<destination>{$to_prefix}moderators</destination>
		<presql>TRUNCATE {$to_prefix}moderators;</presql>
		<query>
			SELECT
				ID_BOARD AS id_board, ID_MEMBER AS id_member
			FROM {$from_prefix}moderators;
		</query>
	</step>
	<step>
		<title>Importing mark read data (boards)</title>
		<detect>{$from_prefix}log_boards</detect>
		<destination>{$to_prefix}log_boards</destination>
		<presql>TRUNCATE {$to_prefix}log_boards;</presql>
		<query>
			SELECT
				ID_MEMBER AS id_member, ID_BOARD AS id_board, ID_MSG AS id_msg
			FROM {$from_prefix}log_boards;
		</query>
	</step>
	<step>
		<title>Importing mark read data (topics)</title>
		<detect>{$from_prefix}log_topics</detect>
		<destination>{$to_prefix}log_topics</destination>
		<presql>TRUNCATE {$to_prefix}log_topics;</presql>
		<query>
			SELECT
				ID_MEMBER AS id_member, ID_TOPIC AS id_topic, ID_MSG AS id_msg
			FROM {$from_prefix}log_topics;
		</query>
	</step>
	<step>
		<title>Importing mark read data</title>
		<detect>{$from_prefix}log_mark_read</detect>
		<destination>{$to_prefix}log_mark_read</destination>
		<presql>TRUNCATE {$to_prefix}log_mark_read;</presql>
		<query>
			SELECT
				ID_MEMBER AS id_member, ID_BOARD AS id_board, ID_MSG AS id_msg
			FROM {$from_prefix}log_mark_read;
		</query>
	</step>
	<step>
		<title>Importing notifications</title>
		<detect>{$from_prefix}log_notify</detect>
		<destination>{$to_prefix}log_notify</destination>
		<presql>TRUNCATE {$to_prefix}log_notify;</presql>
		<query>
			SELECT
				ID_MEMBER AS id_member, ID_TOPIC AS id_topic, ID_BOARD AS id_board, sent
			FROM {$from_prefix}log_notify;
		</query>
	</step>
	<step>
		<title>Importing membergroups</title>
		<detect>{$from_prefix}membergroups</detect>
		<destination>{$to_prefix}membergroups</destination>
		<options>
			<replace>true</replace>
		</options>
		<query>
			SELECT
				ID_GROUP AS id_group, groupName AS group_name, onlineColor AS online_color, minPosts AS min_posts,
				maxMessages AS max_messages, stars AS icons, 1 AS group_type
			FROM {$from_prefix}membergroups;
		</query>
	</step>
	<step>
		<title>Importing permissions</title>
		<detect>{$from_prefix}permissions</detect>
		<destination>{$to_prefix}permissions</destination>
		<options>
			<replace>true</replace>
		</options>
		<query>
			SELECT
				ID_GROUP AS id_group, permission, addDeny AS add_deny
			FROM {$from_prefix}permissions;
		</query>
	</step>
	<step>
		<title>Importing board permissions</title>
		<detect>{$from_prefix}board_permissions</detect>
		<destination>{$to_prefix}board_permissions</destination>
		<options>
			<replace>true</replace>
		</options>
		<query>
			SELECT
				ID_GROUP AS id_group, 1 as id_profile, permission, addDeny AS add_deny
			FROM {$from_prefix}board_permissions;
		</query>
	</step>
	<step>
		<title>Importing smileys</title>
		<detect>{$from_prefix}smileys</detect>
		<destination>{$to_prefix}smileys</destination>
		<options>
			<replace>true</replace>
		</options>
		<query>
			SELECT
				ID_SMILEY AS id_smiley, code, filename, description, smileyRow AS smiley_row,
				smileyOrder AS smiley_order, hidden
			FROM {$from_prefix}smileys;
		</query>
	</step>
	<step>
		<title>Copying smileys</title>
		<detect>{$from_prefix}smileys</detect>
		<code>
			$request = $this->db->query("
				SELECT value
				FROM {$to_prefix}settings
				WHERE variable='smileys_dir';");
			list ($smileys_dir) = $this->db->fetch_row($request);

			$request = $this->db->query("
				SELECT value
				FROM {$from_prefix}settings
				WHERE variable='smileys_dir';");
			list ($smf_smileys_dir) = $this->db->fetch_row($request);

			copy_smileys($smf_smileys_dir, $smileys_dir);
		</code>
	</step>
</importer>
