diff --git a/importer/Importers/portamx1.0/portamx1.0_importer.php b/importer/Importers/portamx1.0/portamx1.0_importer.php new file mode 100644 index 00000000..15beab5a --- /dev/null +++ b/importer/Importers/portamx1.0/portamx1.0_importer.php @@ -0,0 +1,175 @@ +config->to_prefix; + /* + + // Get all members with wrong number of personal messages and fix it + $request = $this->db->query(" + SELECT + mem.id_member, COUNT(pmr.id_pm) AS real_num, mem.personal_messages + FROM {$to_prefix}members AS mem + LEFT JOIN {$to_prefix}pm_recipients AS pmr ON (mem.id_member = pmr.id_member AND pmr.deleted = 0) + GROUP BY mem.id_member + HAVING real_num != personal_messages"); + while ($row = $this->db->fetch_assoc($request)) + { + $this->db->query(" + UPDATE {$to_prefix}members + SET personal_messages = $row[real_num] + WHERE id_member = $row[id_member] + LIMIT 1"); + + pastTime(0); + } + $this->db->free_result($request); + + $request = $this->db->query(" + SELECT + mem.id_member, COUNT(pmr.id_pm) AS real_num, mem.unread_messages + FROM {$to_prefix}members AS mem + LEFT JOIN {$to_prefix}pm_recipients AS pmr ON (mem.id_member = pmr.id_member AND pmr.deleted = 0 AND pmr.is_read = 0) + GROUP BY mem.id_member + HAVING real_num != unread_messages"); + while ($row = $this->db->fetch_assoc($request)) + { + $this->db->query(" + UPDATE {$to_prefix}members + SET unread_messages = $row[real_num] + WHERE id_member = $row[id_member] + LIMIT 1"); + + pastTime(0); + } + $this->db->free_result($request); + } + + * + * Count the topic likes based on first message id + + public function substep100() + { + $to_prefix = $this->config->to_prefix; + + // Set the number of topic likes based on likes to the first message in the topic + $request = $this->db->query(" + SELECT + COUNT(*) AS count, t.id_topic + FROM {$to_prefix}message_likes AS ml + INNER JOIN {$to_prefix}topics AS t ON (t.id_first_msg = ml.id_msg) + GROUP BY t.id_topic"); + while ($row = $this->db->fetch_assoc($request)) + { + $this->db->query(" + UPDATE {$to_prefix}topics + SET num_likes = $row[count] + WHERE id_topic = $row[id_topic] + LIMIT 1"); + + pastTime(0); + } + $this->db->free_result($request); + } + + + * Validate / Update member likes received + + public function substep101() + { + $to_prefix = $this->config->to_prefix; + + // Update the likes each member has received based on liked messages + $request = $this->db->query(" + SELECT + COUNT(*) AS count, id_poster + FROM {$to_prefix}message_likes + GROUP BY id_poster"); + while ($row = $this->db->fetch_assoc($request)) + { + $this->db->query(" + UPDATE {$to_prefix}members + SET likes_received = $row[count] + WHERE id_member = $row[id_poster] + LIMIT 1"); + + pastTime(0); + } + $this->db->free_result($request); + } + + + * Validate / Update likes given by a member + + public function substep102() + { + $to_prefix = $this->config->to_prefix; + + // Update the likes each member has given + $request = $this->db->query(" + SELECT + COUNT(*) AS count, id_member + FROM {$to_prefix}message_likes + GROUP BY id_member"); + while ($row = $this->db->fetch_assoc($request)) + { + $this->db->query(" + UPDATE {$to_prefix}members + SET likes_given = $row[count] + WHERE id_member = $row[id_member] + LIMIT 1"); + + pastTime(0); + } + $this->db->free_result($request); + } + + */ + } +} + +class portamx1_0_importer_step3 extends Importers\SmfCommonSourceStep3 +{ +} \ No newline at end of file diff --git a/importer/Importers/portamx1.0/smf2-0_importer.php b/importer/Importers/portamx1.0/smf2-0_importer.php new file mode 100644 index 00000000..b2d14a2d --- /dev/null +++ b/importer/Importers/portamx1.0/smf2-0_importer.php @@ -0,0 +1,245 @@ +getDbName(); + $db_prefix = $this->fetchSetting('db_prefix'); + + return '`' . $db_name . '`.' . $db_prefix; + } + + public function getDbName() + { + return $this->fetchSetting('db_name'); + } + + public function getTableTest() + { + return 'members'; + } + + protected function fetchSetting($name) + { + static $content = null; + + if ($content === null) + $content = file_get_contents($this->path . '/Settings.php'); + + $match = array(); + preg_match('~\$' . $name . '\s*=\s*\'(.*?)\';~', $content, $match); + + return isset($match[1]) ? $match[1] : ''; + } + + /** + * Read the attachment directory structure from the source db + * + * @return array|null + */ + public function getAttachmentDirs() + { + if ($this->smf_attach_folders === null) + { + $from_prefix = $this->config->from_prefix; + + $request = $this->db->query(" + SELECT value + FROM {$from_prefix}settings + WHERE variable='attachmentUploadDir';"); + list ($smf_attachments_dir) = $this->db->fetch_row($request); + + $this->smf_attach_folders = @unserialize($smf_attachments_dir); + + if (!is_array($this->smf_attach_folders)) + $this->smf_attach_folders = array(1 => $smf_attachments_dir); + } + + return $this->smf_attach_folders; + } + + /** + * Import likes from one of the known addons + * + * @return array + */ + public function fetchLikes() + { + if ($this->isNibogo()) + return $this->fetchNibogo(); + else + return $this->fetchIllori(); + } + + /** + * Nibogo version of likes + * + * @return array + */ + protected function fetchNibogo() + { + $from_prefix = $this->config->from_prefix; + + $request = $this->db->query(" + SELECT l.id_member, t.id_first_msg, t.id_member_started + FROM {$from_prefix}likes + INNER JOIN {$from_prefix}topics AS t ON (t.id_topic = l.id_topic)"); + $return = array(); + while ($row = $this->db->fetch_assoc($request)) + $return[] = array( + 'id_member' => $row['id_member'], + 'id_msg' => $row['id_first_msg'], + 'id_poster' => $row['id_member_started'], + 'like_timestamp' => 0, + ); + $this->db->free_result($request); + + return $return; + } + + /** + * Illori version of likes + * + * @return array + */ + protected function fetchIllori() + { + $from_prefix = $this->config->from_prefix; + + $request = $this->db->query(" + SELECT l.id_member, l.id_message, m.id_member as id_poster + FROM {$from_prefix}likes AS l + INNER JOIN {$from_prefix}messages AS m ON (m.id_msg = l.id_message)"); + $return = array(); + while ($row = $this->db->fetch_assoc($request)) + $return[] = array( + 'id_member' => $row['id_member'], + 'id_msg' => $row['id_message'], + 'id_poster' => $row['id_poster'], + 'like_timestamp' => 0, + ); + $this->db->free_result($request); + + return $return; + } + + /** + * Figure out which likes system may be in use + * + * @return bool|null + */ + protected function isNibogo() + { + $from_prefix = $this->config->from_prefix; + + if ($this->_is_nibogo_like !== null) + return $this->_is_nibogo_like; + + $request = $this->db->query(" + SHOW COLUMNS + FROM {$from_prefix}likes"); + while ($row = $this->db->fetch_assoc($request)) + { + // This is Nibogo + if ($row['Field'] == 'id_topic') + { + $this->_is_nibogo_like = true; + return $this->_is_nibogo_like; + } + } + + // Not Nibogo means Illori + $this->_is_nibogo_like = false; + return $this->_is_nibogo_like; + } +} + +/** + * Copy attachments from the source to our destination + * + * @param array $row + * @param \OpenImporter\Database $db + * @param string $from_prefix + * @param string $attachmentUploadDir + */ +function moveAttachment(&$row, $db, $from_prefix, $attachmentUploadDir) +{ + static $smf_folders = null; + + $attachmentUploadDir = str_replace('{"1":"','',$attachmentUploadDir); + $attachmentUploadDir = str_replace('"}','',$attachmentUploadDir); + +//$attachmentUploadDir_folders = unserialize($attachmentUploadDir); + +//die("test:" . $attachmentUploadDir); + // We need to know where the attachments are located + if ($smf_folders === null) + { + $request = $db->query(" + SELECT value + FROM {$from_prefix}settings + WHERE variable='attachmentUploadDir';"); + list ($smf_attachments_dir) = $db->fetch_row($request); + + $smf_folders = @unserialize($smf_attachments_dir); + + // print_r($smf_folders); + + if (!is_array($smf_folders)) + $smf_folders = array(1 => $smf_attachments_dir); + } + + + + + // If something is broken, better try to account for it as well. + if (isset($smf_folders[$row['id_folder']])) + $smf_attachments_dir = $smf_folders[$row['id_folder']]; + else + $smf_attachments_dir = $smf_folders[1]; + + // Missing the file hash ... create one + if (empty($row['file_hash'])) + { + $row['file_hash'] = createAttachmentFileHash($row['filename']); + $source_file = $row['filename']; + } + else + $source_file = $row['id_attach'] . '_' . $row['file_hash']; + + // Copy it over + copy_file($smf_attachments_dir . '/' . $source_file, $attachmentUploadDir . '/' . $row['id_attach'] . '_' . $row['file_hash'] . '.dat'); +} \ No newline at end of file diff --git a/importer/Importers/portamx1.0/smf2-0_importer.xml b/importer/Importers/portamx1.0/smf2-0_importer.xml new file mode 100644 index 00000000..d19233bf --- /dev/null +++ b/importer/Importers/portamx1.0/smf2-0_importer.xml @@ -0,0 +1,644 @@ + + + + SMF 2.0 + SMF2_0 + Portamx 1.0 + + + Importing settings + {$from_prefix}settings + {$to_prefix}settings + + true + + + $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', + 'dont_repeat_theme_core', + 'dont_repeat_smileys_20', + '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', + 'paid_enabled', + 'paid_email', + 'paid_email_to', + 'paid_currency_code', + 'paid_currency_symbol', + 'paypal_email', + 'smiley_enable', + 'messageIcons_enable', + ); + + $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'], '\'\\"') . "')"); + } + + + } + + $this->db->free_result($request); + + + + Importing members + {$from_prefix}members + {$to_prefix}members + TRUNCATE {$to_prefix}members; + + SELECT + id_member, member_name, date_registered, posts, id_group, lngfile, last_login, + real_name, unread_messages, unread_messages, new_pm, buddy_list, pm_ignore_list, + pm_prefs, mod_prefs, passwd, email_address, personal_text, + gender, birthdate, website_url, website_title, location, hide_email, show_online, + signature, time_offset, avatar, + usertitle, member_ip, member_ip2, secret_question, secret_answer, 1 AS id_theme, is_activated, + validation_code, id_msg_last_visit, additional_groups, smiley_set, id_post_group, + total_time_logged_in, password_salt, ignore_boards, + IFNULL(warning, 0) AS warning, passwd_flood + + FROM {$from_prefix}members; + + + + Importing categories + {$from_prefix}categories + {$to_prefix}categories + TRUNCATE {$to_prefix}categories; + + SELECT + id_cat, name, cat_order, can_collapse + FROM {$from_prefix}categories; + + + + Importing boards + {$from_prefix}boards + {$to_prefix}boards + TRUNCATE {$to_prefix}boards; + + SELECT + id_board, id_cat, child_level, id_parent, board_order, id_last_msg, id_msg_updated, member_groups, + id_profile, name, description, num_topics, num_posts, count_posts, id_theme, + override_theme, unapproved_posts, unapproved_topics, redirect + FROM {$from_prefix}boards; + + + + Importing topics + {$from_prefix}topics + {$to_prefix}topics + TRUNCATE {$to_prefix}topics; + + SELECT + id_topic, is_sticky, id_board, id_first_msg, id_last_msg, id_member_started, + id_member_updated, id_poll,id_previous_board, id_previous_topic, num_replies, + num_views, locked, unapproved_posts, approved + FROM {$from_prefix}topics; + + + + Importing messages + {$from_prefix}messages + {$to_prefix}messages + TRUNCATE {$to_prefix}messages; + + 100 + + + SELECT + id_msg, id_topic, id_board, poster_time, id_member, id_msg_modified, subject, poster_name, + poster_email, poster_ip, smileys_enabled, modified_time, modified_name, body, icon, approved + FROM {$from_prefix}messages; + + + + Importing polls + {$from_prefix}polls + {$to_prefix}polls + TRUNCATE {$to_prefix}polls; + + SELECT + id_poll, question, voting_locked, max_votes, expire_time, hide_results, change_vote, + guest_vote, num_guest_voters, reset_poll, id_member, poster_name + FROM {$from_prefix}polls; + + + + Importing poll choices + {$from_prefix}poll_choices + {$to_prefix}poll_choices + TRUNCATE {$to_prefix}poll_choices; + + SELECT + id_poll, id_choice, label, votes + FROM {$from_prefix}poll_choices; + + + + Importing poll votes + {$from_prefix}log_polls + {$to_prefix}log_polls + TRUNCATE {$to_prefix}log_polls; + + SELECT + id_poll, id_member, id_choice + FROM {$from_prefix}log_polls; + + + + Importing personal messages + {$from_prefix}personal_messages + {$to_prefix}personal_messages + TRUNCATE {$to_prefix}personal_messages; + + 200 + + + SELECT + id_pm, id_pm_head, id_member_from, deleted_by_sender, from_name, + msgtime, subject, body + FROM {$from_prefix}personal_messages; + + + + Importing pm recipients + {$from_prefix}pm_recipients + {$to_prefix}pm_recipients + TRUNCATE {$to_prefix}pm_recipients; + + SELECT + id_pm, id_member, bcc, is_read, is_new, deleted + FROM {$from_prefix}pm_recipients; + + + + Importing pm rules + {$from_prefix}pm_rules + {$to_prefix}pm_rules + TRUNCATE {$to_prefix}pm_rules; + + SELECT + id_rule, id_member, rule_name, criteria, actions, delete_pm, is_or + FROM {$from_prefix}pm_rules; + + + + Importing board moderators + {$from_prefix}moderators + {$to_prefix}moderators + TRUNCATE {$to_prefix}moderators; + + SELECT + id_board, id_member + FROM {$from_prefix}moderators; + + + + Importing mark read data (boards) + {$from_prefix}log_boards + {$to_prefix}log_boards + TRUNCATE {$to_prefix}log_boards; + + SELECT + id_member, id_board, id_msg + FROM {$from_prefix}log_boards; + + + + Importing mark read data (topics) + {$from_prefix}log_topics + {$to_prefix}log_topics + TRUNCATE {$to_prefix}log_topics; + + SELECT + id_member, id_topic, id_msg + FROM {$from_prefix}log_topics; + + + + Importing mark read data + {$from_prefix}log_mark_read + {$to_prefix}log_mark_read + TRUNCATE {$to_prefix}log_mark_read; + + SELECT + id_member, id_board, id_msg + FROM {$from_prefix}log_mark_read; + + + + Importing notifications + {$from_prefix}log_notify + {$to_prefix}log_notify + TRUNCATE {$to_prefix}log_notify; + + SELECT + id_member, id_topic, id_board, sent + FROM {$from_prefix}log_notify; + + + + Importing membergroups + {$from_prefix}membergroups + {$to_prefix}membergroups + + true + + + SELECT + id_group, group_name, description, online_color, min_posts, + max_messages, stars AS icons, group_type, hidden, id_parent + FROM {$from_prefix}membergroups; + + + + Importing group moderators + {$from_prefix}group_moderators + {$to_prefix}group_moderators + + true + + + SELECT + id_group, id_member + FROM {$from_prefix}group_moderators; + + + + Importing permission profiles + {$from_prefix}permission_profiles + {$to_prefix}permission_profiles + + true + + + SELECT + id_profile, profile_name + FROM {$from_prefix}permission_profiles; + + + + Importing permissions + {$from_prefix}permissions + {$to_prefix}permissions + + true + + + SELECT + id_group, permission, add_deny + FROM {$from_prefix}permissions; + + + + Importing board permissions + {$from_prefix}board_permissions + {$to_prefix}board_permissions + + true + + + SELECT + id_group, id_profile, permission, add_deny + FROM {$from_prefix}board_permissions; + + + + Importing smileys + {$from_prefix}smileys + {$to_prefix}smileys + + true + + + SELECT + id_smiley, code, filename, description, smiley_row, + smiley_order, hidden + FROM {$from_prefix}smileys; + + + + Copying smileys + {$from_prefix}smileys + + $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); + + + + Importing statistics (activity log) + {$from_prefix}log_activity + {$to_prefix}log_activity + TRUNCATE {$to_prefix}log_activity; + + SELECT + date, hits, topics, posts, registers, most_on + FROM {$from_prefix}log_activity; + + + + Importing logged actions + {$from_prefix}log_actions + {$to_prefix}log_actions + TRUNCATE {$to_prefix}log_actions; + + SELECT + id_action, id_log, log_time, id_member, ip, action, id_board, + id_topic, id_msg, extra + FROM {$from_prefix}log_actions; + + + + Importing reported posts + {$from_prefix}log_reported + {$to_prefix}log_reported + TRUNCATE {$to_prefix}log_reported; + + SELECT + id_report, id_msg, id_topic, id_board, id_member, membername, subject, + body, time_started, time_updated, num_reports, closed, ignore_all + FROM {$from_prefix}log_reported; + + + + Importing reported comments + {$from_prefix}log_reported_comments + {$to_prefix}log_reported_comments + TRUNCATE {$to_prefix}log_reported_comments; + + SELECT + id_comment, id_report, id_member, membername, comment, time_sent + FROM {$from_prefix}log_reported_comments; + + + + Importing spider hits + {$from_prefix}log_spider_hits + {$to_prefix}log_spider_hits + TRUNCATE {$to_prefix}log_spider_hits; + + SELECT + id_hit, id_spider, log_time, url, processed + FROM {$from_prefix}log_spider_hits; + + + + Importing spider stats + {$from_prefix}log_spider_stats + {$to_prefix}log_spider_stats + TRUNCATE {$to_prefix}log_spider_stats; + + SELECT + id_spider, page_hits, last_seen, stat_date + FROM {$from_prefix}log_spider_stats; + + + + Importing subscriptions + {$from_prefix}subscriptions + {$to_prefix}subscriptions + TRUNCATE {$to_prefix}subscriptions; + + SELECT + id_subscribe, name, description, cost, length, id_group, + add_groups, active, repeatable, allow_partial, reminder, email_complete + FROM {$from_prefix}subscriptions; + + + + Importing custom fields + {$from_prefix}custom_fields + {$to_prefix}custom_fields + TRUNCATE {$to_prefix}custom_fields; + + SELECT + col_name, field_name, field_desc, field_type, field_length, + field_options, mask, show_reg, show_display, show_profile, private, + active, bbc, can_search, default_value, enclose, placement + FROM {$from_prefix}custom_fields; + + + + Importing attachments + {$from_prefix}attachments + {$to_prefix}attachments + TRUNCATE {$to_prefix}attachments; + removeAttachments + + moveAttachment($row, $this->db, $this->config->from_prefix, $this->step1_importer->getAttachDir($row)); + + + SELECT + id_attach, id_thumb, id_msg, id_member, attachment_type, filename, file_hash, size, downloads, + width, height, fileext, mime_type, id_folder + FROM {$from_prefix}attachments; + + + + Importing avatars + + // First check avatar_directory + $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); + + // Next check custom_avatar_dir + $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); + + + \ No newline at end of file diff --git a/importer/Importers/smf2.0/elkarte1-1_importer.php b/importer/Importers/smf2.0/elkarte1-1_importer.php new file mode 100644 index 00000000..b22eba22 --- /dev/null +++ b/importer/Importers/smf2.0/elkarte1-1_importer.php @@ -0,0 +1,151 @@ +getDbName(); + $db_prefix = $this->fetchSetting('db_prefix'); + + return '`' . $db_name . '`.' . $db_prefix; + } + + public function getDbName() + { + return $this->fetchSetting('db_name'); + } + + public function getTableTest() + { + return 'members'; + } + + protected function fetchSetting($name) + { + static $content = null; + + if ($content === null) + $content = file_get_contents($this->path . '/Settings.php'); + + $match = array(); + preg_match('~\$' . $name . '\s*=\s*\'(.*?)\';~', $content, $match); + + return isset($match[1]) ? $match[1] : ''; + } + + /** + * Read the attachment directory structure from the source db + * + * @return array|null + */ + public function getAttachmentDirs() + { + if ($this->smf_attach_folders === null) + { + $from_prefix = $this->config->from_prefix; + + $request = $this->db->query(" + SELECT value + FROM {$from_prefix}settings + WHERE variable='attachmentUploadDir';"); + list ($smf_attachments_dir) = $this->db->fetch_row($request); + + $this->smf_attach_folders = @unserialize($smf_attachments_dir); + + if (!is_array($this->smf_attach_folders)) + $this->smf_attach_folders = array(1 => $smf_attachments_dir); + } + + return $this->smf_attach_folders; + } + + + +} + +/** + * Copy attachments from the source to our destination + * + * @param array $row + * @param \OpenImporter\Database $db + * @param string $from_prefix + * @param string $attachmentUploadDir + */ +function moveAttachment(&$row, $db, $from_prefix, $attachmentUploadDir) +{ + static $smf_folders = null; + + + // We need to know where the attachments are located + if ($smf_folders === null) + { + $request = $db->query(" + SELECT value + FROM {$from_prefix}settings + WHERE variable='attachmentUploadDir';"); + list ($smf_attachments_dir) = $db->fetch_row($request); + + $smf_folders = @unserialize($smf_attachments_dir); + + // print_r($smf_folders); + + if (!is_array($smf_folders)) + $smf_folders = array(1 => $smf_attachments_dir); + } + + + + + // If something is broken, better try to account for it as well. + if (isset($smf_folders[$row['id_folder']])) + $smf_attachments_dir = $smf_folders[$row['id_folder']]; + else + $smf_attachments_dir = $smf_folders[1]; + + // Missing the file hash ... create one + if (empty($row['file_hash'])) + { + $row['file_hash'] = createAttachmentFileHash($row['filename']); + $source_file = $row['filename']; + } + else + $source_file = $row['id_attach'] . '_' . $row['file_hash']; + + // Copy it over + if (file_exists($smf_attachments_dir . '/' . $source_file . '.elk')) + copy_file($smf_attachments_dir . '/' . $source_file . '.elk', $attachmentUploadDir . '/' . $row['id_attach'] . '_' . $row['file_hash']); + + if (file_exists($smf_attachments_dir . '/' . $source_file . '.elk_thumb')) + copy_file($smf_attachments_dir . '/' . $source_file . '.elk_thumb', $attachmentUploadDir . '/' . $row['id_attach'] . '_' . $row['file_hash'] . '_thumb'); +} \ No newline at end of file diff --git a/importer/Importers/smf2.0/elkarte1-1_importer.xml b/importer/Importers/smf2.0/elkarte1-1_importer.xml new file mode 100644 index 00000000..0a65236c --- /dev/null +++ b/importer/Importers/smf2.0/elkarte1-1_importer.xml @@ -0,0 +1,644 @@ + + + + Elkarte 1.1 + elkarte1_1 + SMF 2.0 + + + Importing settings + {$from_prefix}settings + {$to_prefix}settings + + true + + + $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', + 'dont_repeat_theme_core', + 'dont_repeat_smileys_20', + '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', + 'paid_enabled', + 'paid_email', + 'paid_email_to', + 'paid_currency_code', + 'paid_currency_symbol', + 'paypal_email', + 'smiley_enable', + 'messageIcons_enable', + ); + + $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'], '\'\\"') . "')"); + } + + + } + + $this->db->free_result($request); + + + + Importing members + {$from_prefix}members + {$to_prefix}members + TRUNCATE {$to_prefix}members; + + SELECT + id_member, member_name, date_registered, posts, id_group, lngfile, last_login, + real_name, unread_messages, unread_messages, new_pm, buddy_list, pm_ignore_list, + pm_prefs, mod_prefs, passwd, email_address, personal_text, + gender, birthdate, website_url, website_title, location, hide_email, show_online, + signature, time_offset, avatar, + usertitle, member_ip, member_ip2, secret_question, secret_answer, 1 AS id_theme, is_activated, + validation_code, id_msg_last_visit, additional_groups, smiley_set, id_post_group, + total_time_logged_in, password_salt, ignore_boards, + IFNULL(warning, 0) AS warning, passwd_flood + + FROM {$from_prefix}members; + + + + Importing categories + {$from_prefix}categories + {$to_prefix}categories + TRUNCATE {$to_prefix}categories; + + SELECT + id_cat, name, cat_order, can_collapse + FROM {$from_prefix}categories; + + + + Importing boards + {$from_prefix}boards + {$to_prefix}boards + TRUNCATE {$to_prefix}boards; + + SELECT + id_board, id_cat, child_level, id_parent, board_order, id_last_msg, id_msg_updated, member_groups, + id_profile, name, description, num_topics, num_posts, count_posts, id_theme, + override_theme, unapproved_posts, unapproved_topics, redirect + FROM {$from_prefix}boards; + + + + Importing topics + {$from_prefix}topics + {$to_prefix}topics + TRUNCATE {$to_prefix}topics; + + SELECT + id_topic, is_sticky, id_board, id_first_msg, id_last_msg, id_member_started, + id_member_updated, id_poll,id_previous_board, id_previous_topic, num_replies, + num_views, locked, unapproved_posts, approved + FROM {$from_prefix}topics; + + + + Importing messages + {$from_prefix}messages + {$to_prefix}messages + TRUNCATE {$to_prefix}messages; + + 100 + + + SELECT + id_msg, id_topic, id_board, poster_time, id_member, id_msg_modified, subject, poster_name, + poster_email, poster_ip, smileys_enabled, modified_time, modified_name, body, icon, approved + FROM {$from_prefix}messages; + + + + Importing polls + {$from_prefix}polls + {$to_prefix}polls + TRUNCATE {$to_prefix}polls; + + SELECT + id_poll, question, voting_locked, max_votes, expire_time, hide_results, change_vote, + guest_vote, num_guest_voters, reset_poll, id_member, poster_name + FROM {$from_prefix}polls; + + + + Importing poll choices + {$from_prefix}poll_choices + {$to_prefix}poll_choices + TRUNCATE {$to_prefix}poll_choices; + + SELECT + id_poll, id_choice, label, votes + FROM {$from_prefix}poll_choices; + + + + Importing poll votes + {$from_prefix}log_polls + {$to_prefix}log_polls + TRUNCATE {$to_prefix}log_polls; + + SELECT + id_poll, id_member, id_choice + FROM {$from_prefix}log_polls; + + + + Importing personal messages + {$from_prefix}personal_messages + {$to_prefix}personal_messages + TRUNCATE {$to_prefix}personal_messages; + + 200 + + + SELECT + id_pm, id_pm_head, id_member_from, deleted_by_sender, from_name, + msgtime, subject, body + FROM {$from_prefix}personal_messages; + + + + Importing pm recipients + {$from_prefix}pm_recipients + {$to_prefix}pm_recipients + TRUNCATE {$to_prefix}pm_recipients; + + SELECT + id_pm, id_member, bcc, is_read, is_new, deleted + FROM {$from_prefix}pm_recipients; + + + + Importing pm rules + {$from_prefix}pm_rules + {$to_prefix}pm_rules + TRUNCATE {$to_prefix}pm_rules; + + SELECT + id_rule, id_member, rule_name, criteria, actions, delete_pm, is_or + FROM {$from_prefix}pm_rules; + + + + Importing board moderators + {$from_prefix}moderators + {$to_prefix}moderators + TRUNCATE {$to_prefix}moderators; + + SELECT + id_board, id_member + FROM {$from_prefix}moderators; + + + + Importing mark read data (boards) + {$from_prefix}log_boards + {$to_prefix}log_boards + TRUNCATE {$to_prefix}log_boards; + + SELECT + id_member, id_board, id_msg + FROM {$from_prefix}log_boards; + + + + Importing mark read data (topics) + {$from_prefix}log_topics + {$to_prefix}log_topics + TRUNCATE {$to_prefix}log_topics; + + SELECT + id_member, id_topic, id_msg + FROM {$from_prefix}log_topics; + + + + Importing mark read data + {$from_prefix}log_mark_read + {$to_prefix}log_mark_read + TRUNCATE {$to_prefix}log_mark_read; + + SELECT + id_member, id_board, id_msg + FROM {$from_prefix}log_mark_read; + + + + Importing notifications + {$from_prefix}log_notify + {$to_prefix}log_notify + TRUNCATE {$to_prefix}log_notify; + + SELECT + id_member, id_topic, id_board, sent + FROM {$from_prefix}log_notify; + + + + Importing membergroups + {$from_prefix}membergroups + {$to_prefix}membergroups + + true + + + SELECT + id_group, group_name, description, online_color, min_posts, + max_messages, icons AS stars, group_type, hidden, id_parent + FROM {$from_prefix}membergroups; + + + + Importing group moderators + {$from_prefix}group_moderators + {$to_prefix}group_moderators + + true + + + SELECT + id_group, id_member + FROM {$from_prefix}group_moderators; + + + + Importing permission profiles + {$from_prefix}permission_profiles + {$to_prefix}permission_profiles + + true + + + SELECT + id_profile, profile_name + FROM {$from_prefix}permission_profiles; + + + + Importing permissions + {$from_prefix}permissions + {$to_prefix}permissions + + true + + + SELECT + id_group, permission, add_deny + FROM {$from_prefix}permissions; + + + + Importing board permissions + {$from_prefix}board_permissions + {$to_prefix}board_permissions + + true + + + SELECT + id_group, id_profile, permission, add_deny + FROM {$from_prefix}board_permissions; + + + + Importing smileys + {$from_prefix}smileys + {$to_prefix}smileys + + true + + + SELECT + id_smiley, code, filename, description, smiley_row, + smiley_order, hidden + FROM {$from_prefix}smileys; + + + + Copying smileys + {$from_prefix}smileys + + $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); + + + + Importing statistics (activity log) + {$from_prefix}log_activity + {$to_prefix}log_activity + TRUNCATE {$to_prefix}log_activity; + + SELECT + date, hits, topics, posts, registers, most_on + FROM {$from_prefix}log_activity; + + + + Importing logged actions + {$from_prefix}log_actions + {$to_prefix}log_actions + TRUNCATE {$to_prefix}log_actions; + + SELECT + id_action, id_log, log_time, id_member, ip, action, id_board, + id_topic, id_msg, extra + FROM {$from_prefix}log_actions; + + + + Importing reported posts + {$from_prefix}log_reported + {$to_prefix}log_reported + TRUNCATE {$to_prefix}log_reported; + + SELECT + id_report, id_msg, id_topic, id_board, id_member, membername, subject, + body, time_started, time_updated, num_reports, closed, ignore_all + FROM {$from_prefix}log_reported; + + + + Importing reported comments + {$from_prefix}log_reported_comments + {$to_prefix}log_reported_comments + TRUNCATE {$to_prefix}log_reported_comments; + + SELECT + id_comment, id_report, id_member, membername, comment, time_sent + FROM {$from_prefix}log_reported_comments; + + + + Importing spider hits + {$from_prefix}log_spider_hits + {$to_prefix}log_spider_hits + TRUNCATE {$to_prefix}log_spider_hits; + + SELECT + id_hit, id_spider, log_time, url, processed + FROM {$from_prefix}log_spider_hits; + + + + Importing spider stats + {$from_prefix}log_spider_stats + {$to_prefix}log_spider_stats + TRUNCATE {$to_prefix}log_spider_stats; + + SELECT + id_spider, page_hits, last_seen, stat_date + FROM {$from_prefix}log_spider_stats; + + + + Importing subscriptions + {$from_prefix}subscriptions + {$to_prefix}subscriptions + TRUNCATE {$to_prefix}subscriptions; + + SELECT + id_subscribe, name, description, cost, length, id_group, + add_groups, active, repeatable, allow_partial, reminder, email_complete + FROM {$from_prefix}subscriptions; + + + + Importing custom fields + {$from_prefix}custom_fields + {$to_prefix}custom_fields + TRUNCATE {$to_prefix}custom_fields; + + SELECT + col_name, field_name, field_desc, field_type, field_length, + field_options, mask, show_reg, show_display, show_profile, private, + active, bbc, can_search, default_value, enclose, placement + FROM {$from_prefix}custom_fields; + + + + Importing attachments + {$from_prefix}attachments + {$to_prefix}attachments + TRUNCATE {$to_prefix}attachments; + removeAttachments + + moveAttachment($row, $this->db, $this->config->from_prefix, $this->step1_importer->getAttachDir($row)); + + + SELECT + id_attach, id_thumb, id_msg, id_member, attachment_type, filename, file_hash, size, downloads, + width, height, fileext, mime_type, id_folder + FROM {$from_prefix}attachments; + + + + Importing avatars + + // First check avatar_directory + $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); + + // Next check custom_avatar_dir + $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); + + + \ No newline at end of file diff --git a/importer/Importers/smf2.0/smf2.0_importer.php b/importer/Importers/smf2.0/smf2.0_importer.php new file mode 100644 index 00000000..c23630a3 --- /dev/null +++ b/importer/Importers/smf2.0/smf2.0_importer.php @@ -0,0 +1,54 @@ +config->to_prefix; + + } +} + +class smf2_0_importer_step3 extends Importers\SmfCommonSourceStep3 +{ +} \ No newline at end of file