diff --git a/importer/Importers/SmfCommonSource.php b/importer/Importers/SmfCommonSource.php index c13b9bac..10b8957c 100644 --- a/importer/Importers/SmfCommonSource.php +++ b/importer/Importers/SmfCommonSource.php @@ -230,7 +230,7 @@ public function specialAttachments($force = false) $this->db->free_result($result); if (empty($this->avatarUploadDir)) - $this->avatarUploadDir = null; + $this->avatarUploadDir = ''; if (empty($this->id_attach)) $this->id_attach = 1; @@ -353,7 +353,6 @@ public function removeAttachments() */ protected function createAttachFoldersStructure($folders) { - $source_base = $this->guessBase($folders); $destination_base = $this->guessBase($this->config->destination->getAllAttachDirs()); @@ -528,10 +527,10 @@ public function substep1() $to_prefix = $this->config->to_prefix; $request = $this->db->query(" - SELECT id_board, MAX(id_msg) AS id_last_msg, MAX(modified_time) AS last_edited + SELECT + id_board, MAX(id_msg) AS id_last_msg, MAX(modified_time) AS last_edited FROM {$to_prefix}messages GROUP BY id_board"); - $modifyData = array(); $modifyMsg = array(); while ($row = $this->db->fetch_assoc($request)) @@ -607,7 +606,8 @@ public function substep2() $to_prefix = $this->config->to_prefix; $request = $this->db->query(" - SELECT id_group + SELECT + id_group FROM {$to_prefix}membergroups WHERE min_posts = -1"); @@ -617,7 +617,8 @@ public function substep2() $this->db->free_result($request); $request = $this->db->query(" - SELECT id_board, member_groups + SELECT + id_board, member_groups FROM {$to_prefix}boards WHERE FIND_IN_SET(0, member_groups)"); @@ -629,20 +630,25 @@ public function substep2() $this->db->free_result($request); } + /** + * Fix various system totals + */ public function substep3() { $to_prefix = $this->config->to_prefix; // Get the number of messages... $result = $this->db->query(" - SELECT COUNT(*) AS totalMessages, MAX(id_msg) AS maxMsgID + SELECT + COUNT(*) AS totalMessages, MAX(id_msg) AS maxMsgID FROM {$to_prefix}messages"); $row = $this->db->fetch_assoc($result); $this->db->free_result($result); // Update the latest member. (Highest ID_MEMBER) $result = $this->db->query(" - SELECT id_member AS latestMember, real_name AS latestreal_name + SELECT + id_member AS latestMember, real_name AS latestreal_name FROM {$to_prefix}members ORDER BY id_member DESC LIMIT 1"); @@ -660,14 +666,16 @@ public function substep3() // Update the member count. $result = $this->db->query(" - SELECT COUNT(*) AS totalMembers + SELECT + COUNT(*) AS totalMembers FROM {$to_prefix}members"); $row += $this->db->fetch_assoc($result); $this->db->free_result($result); // Get the number of topics. $result = $this->db->query(" - SELECT COUNT(*) AS totalTopics + SELECT + COUNT(*) AS totalTopics FROM {$to_prefix}topics"); $row += $this->db->fetch_assoc($result); $this->db->free_result($result); @@ -692,7 +700,8 @@ public function substep4() $to_prefix = $this->config->to_prefix; $request = $this->db->query(" - SELECT id_group, min_posts + SELECT + id_group, min_posts FROM {$to_prefix}membergroups WHERE min_posts != -1 ORDER BY min_posts DESC"); @@ -731,7 +740,8 @@ public function substep5() $to_prefix = $this->config->to_prefix; $result_topics = $this->db->query(" - SELECT id_board, COUNT(*) as num_topics + SELECT + id_board, COUNT(*) as num_topics FROM {$to_prefix}topics GROUP BY id_board"); @@ -744,7 +754,8 @@ public function substep5() // Find how many messages are in the board. $result_posts = $this->db->query(" - SELECT id_board, COUNT(*) as num_posts + SELECT + id_board, COUNT(*) as num_posts FROM {$to_prefix}messages GROUP BY id_board"); @@ -766,7 +777,8 @@ public function substep6() while (true) { $resultTopic = $this->db->query(" - SELECT t.id_topic, COUNT(m.id_msg) AS num_msg + SELECT + t.id_topic, COUNT(m.id_msg) AS num_msg FROM {$to_prefix}topics AS t LEFT JOIN {$to_prefix}messages AS m ON (m.id_topic = t.id_topic) GROUP BY t.id_topic @@ -845,9 +857,8 @@ public function substep7() /** * * Get the id_member associated with the specified message. - * @global type $to_prefix - * @global type $db - * @param type $messageID + * + * @param int $messageID * @return int */ protected function getMsgMemberID($messageID) @@ -856,7 +867,8 @@ protected function getMsgMemberID($messageID) // Find the topic and make sure the member still exists. $result = $this->db->query(" - SELECT IFNULL(mem.id_member, 0) + SELECT + IFNULL(mem.id_member, 0) FROM {$to_prefix}messages AS m LEFT JOIN {$to_prefix}members AS mem ON (mem.id_member = m.id_member) WHERE m.id_msg = " . (int) $messageID . " @@ -882,7 +894,8 @@ public function substep8() // First, let's get an array of boards and parents. $request = $this->db->query(" - SELECT id_board, id_parent, id_cat + SELECT + id_board, id_parent, id_cat FROM {$to_prefix}boards"); $child_map = array(); @@ -952,7 +965,8 @@ protected function fixInexistentCategories($cat_map) // Last check: any boards not in a good category? $request = $this->db->query(" - SELECT id_cat + SELECT + id_cat FROM {$to_prefix}categories"); $real_cats = array(); while ($row = $this->db->fetch_assoc($request)) @@ -986,7 +1000,8 @@ public function substep9() $to_prefix = $this->config->to_prefix; $request = $this->db->query(" - SELECT c.id_cat, c.cat_order, b.id_board, b.board_order + SELECT + c.id_cat, c.cat_order, b.id_board, b.board_order FROM {$to_prefix}categories AS c LEFT JOIN {$to_prefix}boards AS b ON (b.id_cat = c.id_cat) ORDER BY c.cat_order, b.child_level, b.board_order, b.id_board"); @@ -1011,12 +1026,16 @@ public function substep9() $this->db->free_result($request); } + /** + * Fix attachment size, W & H values + */ public function substep11() { $to_prefix = $this->config->to_prefix; $request = $this->db->query(" - SELECT COUNT(*) + SELECT + COUNT(*) FROM {$to_prefix}attachments"); list ($attachments) = $this->db->fetch_row($request); $this->db->free_result($request); @@ -1024,7 +1043,8 @@ public function substep11() while ($_REQUEST['start'] < $attachments) { $request = $this->db->query(" - SELECT id_attach, filename, attachment_type, id_folder + SELECT + id_attach, filename, attachment_type, id_folder FROM {$to_prefix}attachments WHERE id_thumb = 0 AND (RIGHT(filename, 4) IN ('.gif', '.jpg', '.png', '.bmp') OR RIGHT(filename, 5) = '.jpeg') diff --git a/importer/Importers/elkarte1.0/UBB75_importer.xml b/importer/Importers/elkarte1.0/UBB75_importer.xml index 2886584f..d1a2ab6d 100644 --- a/importer/Importers/elkarte1.0/UBB75_importer.xml +++ b/importer/Importers/elkarte1.0/UBB75_importer.xml @@ -1,5 +1,5 @@ - + UBB Threads 7.5.x ElkArte 1.0 @@ -73,7 +73,7 @@ SELECT FORUM_ID AS id_board, CATEGORY_ID as id_cat, SUBSTRING(FORUM_TITLE, 1, 255) AS name, SUBSTRING(FORUM_DESCRIPTION, 1, 65534) AS description, FORUM_SORT_ORDER AS board_order, - FORUM_POSTS AS num_posts, IFNULL(FORUM_PARENT, 0) as id_parent, FORUM_POSTS_COUNT AS count_posts, + FORUM_POSTS AS num_posts, IFNULL(FORUM_PARENT, 0) as id_parent, FORUM_POSTS_COUNT AS count_posts, '' AS member_groups FROM {$from_prefix}FORUMS; @@ -331,7 +331,7 @@ copy_smileys($smf_smileys_dir, $smileys_dir); - + Importing statistics (activity log) {$from_prefix}log_activity diff --git a/importer/Importers/elkarte1.0/elkarte1.0_importer.php b/importer/Importers/elkarte1.0/elkarte1.0_importer.php index c007bfe1..c4ef6b43 100644 --- a/importer/Importers/elkarte1.0/elkarte1.0_importer.php +++ b/importer/Importers/elkarte1.0/elkarte1.0_importer.php @@ -39,13 +39,17 @@ class elkarte1_0_importer_step1 extends Importers\SmfCommonSourceStep1 class elkarte1_0_importer_step2 extends Importers\SmfCommonSourceStep2 { + /** + * Repair any wrong number of personal messages + */ public function substep0() { $to_prefix = $this->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 + 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 @@ -63,7 +67,8 @@ public function substep0() $this->db->free_result($request); $request = $this->db->query(" - SELECT mem.id_member, COUNT(pmr.id_pm) AS real_num, mem.unread_messages + 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 @@ -81,13 +86,17 @@ public function substep0() $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 + 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"); @@ -104,13 +113,17 @@ public function substep100() $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 + SELECT + COUNT(*) AS count, id_poster FROM {$to_prefix}message_likes GROUP BY id_poster"); while ($row = $this->db->fetch_assoc($request)) @@ -126,13 +139,17 @@ public function substep101() $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 + SELECT + COUNT(*) AS count, id_member FROM {$to_prefix}message_likes GROUP BY id_member"); while ($row = $this->db->fetch_assoc($request)) diff --git a/importer/Importers/elkarte1.0/mybb18_importer.php b/importer/Importers/elkarte1.0/mybb18_importer.php index 09e5066a..08b5d74c 100644 --- a/importer/Importers/elkarte1.0/mybb18_importer.php +++ b/importer/Importers/elkarte1.0/mybb18_importer.php @@ -43,4 +43,64 @@ public function getTableTest() { return 'users'; } + + /** + * Copy attachment files + * + * @param string g$dir + * @param array $row + * @param int $id_attach + * @param string $destination_path + * @param bool $thumb + * + * @return array + */ + public function mybb_copy_files($dir, $row, $id_attach, $destination_path, $thumb = false) + { + // Some extra details + list($ext, $basename, $mime_type) = attachment_type($row['filename']); + + // Prepare for the copy + $file = $thumb ? $row['thumbnail'] : $row['attachname']; + $source = $dir . '/' . $file; + $file_hash = createAttachmentFileHash($file); + $destination = $destination_path . '/' . $id_attach . '_' . $file_hash . '.elk'; + $width = 0; + $height = 0; + $type = 0; + + // Copy it over + copy_file($source, $destination); + + // If its an image, then make sure it has legit width/height + if (!empty($ext)) + { + list ($width, $height) = getimagesize($destination); + if (empty($width)) + { + $width = 0; + $height = 0; + } + else + { + $type = ($thumb) ? 3 : 0; + } + } + + // Prepare our insert + return array( + 'id_attach' => $id_attach, + 'id_thumb' => !$thumb && !empty($row['thumbnail']) ? ++$id_attach : 0, + 'size' => file_exists($destination) ? filesize($destination) : 0, + 'filename' => $basename . '.' . ($thumb ? $ext . '_thumb' : $ext), + 'file_hash' => $file_hash, + 'file_ext' => $ext, + 'mime_type' => $mime_type, + 'attachment_type' => $type, + 'id_msg' => $row['id_msg'], + 'downloads' => $row['downloads'], + 'width' => $width, + 'height' => $height, + ); + } } \ No newline at end of file diff --git a/importer/Importers/elkarte1.0/mybb18_importer.xml b/importer/Importers/elkarte1.0/mybb18_importer.xml index 56bd7fb9..5c1a585e 100644 --- a/importer/Importers/elkarte1.0/mybb18_importer.xml +++ b/importer/Importers/elkarte1.0/mybb18_importer.xml @@ -263,9 +263,10 @@ TRUNCATE {$to_prefix}attachments; - $keys = array('id_attach', 'size', 'filename', 'file_hash', 'id_msg', 'downloads', 'width', 'height'); - $no_add = true; + // DB values to store + $this->keys = array('id_attach', 'id_thumb', 'size', 'filename', 'file_hash', 'fileext', 'mime_type', 'attachment_type', 'id_msg', 'downloads', 'width', 'height'); + // Need where they files are on mybb if (!isset($mybb_attachment_dir)) { $result = $this->db->query(" @@ -280,48 +281,21 @@ $mybb_attachment_dir = $_POST['path_from'] . ltrim($mybb_attachment_dir, '.'); } - // Create some useful shortcuts, we start with images.. - $ext = strtolower(substr(strrchr($row['filename'], '.'), 1)); - if (!in_array($ext, array('jpg', 'jpeg', 'gif', 'png'))) - { - $ext = ''; - } - - $source = $mybb_attachment_dir . '/' . $row['attachname']; - $file_hash = createAttachmentFileHash($row['filename']); + // Copy the attachment + $destination_path = $this->step1_importer->getAttachDir($this->row); $id_attach = $this->step1_importer->newIdAttach(); - $destination = $this->step1_importer->getAttachDir($row) . '/' . $id_attach . '_' . $file_hash . '.elk'; - $width = 0; - $height = 0; - - copy_file($source, $destination); + $this->rows[] = $this->config->source->mybb_copy_files($mybb_attachment_dir, $this->row, $id_attach, $destination_path, false); - // Is image? we need a thumbnail - if (!empty($ext)) + // If we have its thumbnail, might as well copy it also + if (!empty($this->row['thumbnail'])) { - list ($width, $height) = getimagesize($destination); - if (empty($width)) - { - $width = 0; - $height = 0; - } + $id_attach = $this->step1_importer->newIdAttach(); + $this->rows[] = $this->config->source->mybb_copy_files($mybb_attachment_dir, $this->row, $id_attach, $destination_path, true); } - - // Prepare our insert - $rows[] = array( - 'id_attach' => $id_attach, - 'size' => filesize($destination), - 'filename' => $row['filename'], - 'file_hash' => $file_hash, - 'id_msg' => $row['id_msg'], - 'downloads' => $row['downloads'], - 'width' => $width, - 'height' => $height, - ); SELECT - pid AS id_msg, downloads, filename, filesize, attachname + pid AS id_msg, downloads, filename, filesize, attachname, thumbnail FROM {$from_prefix}attachments; @@ -333,25 +307,24 @@ true - $keys = array('size', 'filename', 'file_hash', 'id_member'); - $no_add = true; + $this->keys = array('size', 'filename', 'file_hash', 'id_member'); // Create some useful shortcuts - $source = $_POST['path_from'] . strtok(ltrim($row['filename'], '.'), '?'); - $filename = preg_replace('~avatar_(.+?)\?dateline=\d*~is', 'avatar_$1', $row['filename']); + $source = $_POST['path_from'] . strtok(ltrim($this->row['filename'], '.'), '?'); + $filename = preg_replace('~avatar_(.+?)\?dateline=\d*~is', 'avatar_$1', $this->row['filename']); $file = substr(strrchr($filename, "/"), 1); $file_hash = createAttachmentFileHash($filename); $id_attach = $this->step1_importer->newIdAttach(); - $destination = $this->step1_importer->getAttachDir($row) . '/' . $id_attach . '_' . $file_hash . '.elk'; + $destination = $this->step1_importer->getAttachDir($this->row) . '/' . $id_attach . '_' . $file_hash . '.elk'; copy_file($source, $destination); // Prepare the insert - $rows[] = array( + $this->rows[] = array( 'size' => file_exists($destination) ? filesize($destination) : 0, 'filename' => $file, 'file_hash' => $file_hash, - 'id_member' => $row['id_member'], + 'id_member' => $this->row['id_member'], ); diff --git a/importer/Importers/elkarte1.0/phpbb3_importer.xml b/importer/Importers/elkarte1.0/phpbb3_importer.xml index c85b22cf..d3f906b4 100644 --- a/importer/Importers/elkarte1.0/phpbb3_importer.xml +++ b/importer/Importers/elkarte1.0/phpbb3_importer.xml @@ -1,5 +1,5 @@ - + phpBB3 ElkArte 1.0 @@ -88,17 +88,17 @@ SELECT t.topic_id AS id_topic, t.forum_id AS id_board, t.topic_first_post_id AS id_first_msg, - CASE t.topic_type - WHEN 1 THEN 1 - WHEN 2 THEN 1 - ELSE 0 + CASE t.topic_type + WHEN 1 THEN 1 + WHEN 2 THEN 1 + ELSE 0 END AS is_sticky, t.topic_last_post_id AS id_last_msg, t.topic_poster AS id_member_started, t.topic_last_poster_id AS id_member_updated, IF(po.topic_id > 0, po.topic_id, 0) AS id_poll, t.topic_replies AS num_replies, t.topic_views AS num_views, - CASE t.topic_status - WHEN 1 THEN 1 - ELSE 0 + CASE t.topic_status + WHEN 1 THEN 1 + ELSE 0 END AS locked FROM {$from_prefix}topics AS t LEFT JOIN {$from_prefix}poll_options AS po ON (po.topic_id = t.topic_id); @@ -174,7 +174,7 @@ true - SELECT + SELECT topic_id AS id_poll, vote_user_id AS id_member, poll_option_id AS id_choice FROM {$from_prefix}poll_votes WHERE vote_user_id > 0; @@ -198,7 +198,7 @@ pm.msg_id AS id_pm, pm.author_id AS id_member_from, pm.message_time AS msgtime, SUBSTRING(uf.username, 1, 255) AS from_name, SUBSTRING(pm.message_subject, 1, 255) AS subject, pm.bbcode_uid AS tmp_bbc_replace, - SUBSTRING(REPLACE(IF(pm.bbcode_uid = '', pm.message_text, + SUBSTRING(REPLACE(IF(pm.bbcode_uid = '', pm.message_text, REPLACE(REPLACE(pm.message_text, CONCAT(':1:', pm.bbcode_uid), ''), CONCAT(':', pm.bbcode_uid), '')), '\n', '
'), 1, 65534) AS body FROM {$from_prefix}privmsgs AS pm LEFT JOIN {$from_prefix}users AS uf ON (uf.user_id = pm.author_id); diff --git a/importer/Importers/elkarte1.0/smf1-1_importer.php b/importer/Importers/elkarte1.0/smf1-1_importer.php index 7ff7f1e2..7d5227f8 100644 --- a/importer/Importers/elkarte1.0/smf1-1_importer.php +++ b/importer/Importers/elkarte1.0/smf1-1_importer.php @@ -7,7 +7,7 @@ * @version 1.0 Alpha */ -class SMF1_1 extends AbstractSourceImporter +class SMF1_1 extends Importers\AbstractSourceImporter { protected $setting_file = '/Settings.php'; diff --git a/importer/Importers/elkarte1.0/smf1-1_importer.xml b/importer/Importers/elkarte1.0/smf1-1_importer.xml index 459af58f..0a2738f5 100644 --- a/importer/Importers/elkarte1.0/smf1-1_importer.xml +++ b/importer/Importers/elkarte1.0/smf1-1_importer.xml @@ -1,5 +1,5 @@ - + SMF 1.1 ElkArte 1.0 @@ -196,7 +196,7 @@ TRUNCATE {$to_prefix}members; SELECT - ID_MEMBER as id_member, memberName AS member_name, dateRegistered AS date_registered, + 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, @@ -334,7 +334,7 @@ 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, + posterIP AS poster_ip, smileysEnabled AS smileys_enabled, modifiedTime AS modified_time, modifiedName AS modified_name, body, icon FROM {$from_prefix}messages; diff --git a/importer/Importers/elkarte1.0/smf2-0_importer.xml b/importer/Importers/elkarte1.0/smf2-0_importer.xml index 5dbd8e98..d30b22b4 100644 --- a/importer/Importers/elkarte1.0/smf2-0_importer.xml +++ b/importer/Importers/elkarte1.0/smf2-0_importer.xml @@ -1,5 +1,5 @@ - + SMF 2.0 SMF2_0 @@ -696,11 +696,11 @@ {$to_prefix}message_likes TRUNCATE {$to_prefix}message_likes; - $keys = array('id_member', 'id_msg', 'id_poster', 'like_timestamp'); - $rows = $this->config->source->fetchLikes(); + $this->keys = array('id_member', 'id_msg', 'id_poster', 'like_timestamp'); + $this->rows = $this->config->source->fetchLikes(); $special_table = $this->config->to_prefix . 'message_likes'; - $this->insertRows($rows, $keys, $special_table); + $this->insertRows($special_table); \ No newline at end of file diff --git a/importer/Importers/elkarte1.0/smf2-1_importer.xml b/importer/Importers/elkarte1.0/smf2-1_importer.xml index a82b9aa0..e5cd4965 100644 --- a/importer/Importers/elkarte1.0/smf2-1_importer.xml +++ b/importer/Importers/elkarte1.0/smf2-1_importer.xml @@ -664,11 +664,11 @@ {$to_prefix}message_likes TRUNCATE {$to_prefix}message_likes; - $keys = array('id_member', 'id_msg', 'id_poster', 'like_timestamp'); - $rows = $this->config->source->fetchLikes(); + $this->keys = array('id_member', 'id_msg', 'id_poster', 'like_timestamp'); + $this->rows = $this->config->source->fetchLikes(); $special_table = $this->config->to_prefix . 'message_likes'; - $this->insertRows($rows, $keys, $special_table); + $this->insertRows($special_table); \ No newline at end of file diff --git a/importer/Importers/elkarte1.0/vbulletin4_importer.xml b/importer/Importers/elkarte1.0/vbulletin4_importer.xml index a1d6f486..cc86cc9f 100644 --- a/importer/Importers/elkarte1.0/vbulletin4_importer.xml +++ b/importer/Importers/elkarte1.0/vbulletin4_importer.xml @@ -1,5 +1,5 @@ - + vBulletin 4 ElkArte 1.0 @@ -109,7 +109,7 @@ { foreach ($cats as $key => $value) { - if ($key == $row['id_cat']) + if ($key == $row['id_cat']) $db->query(" UPDATE {$to_prefix}boards SET id_cat = '$key' diff --git a/importer/Importers/elkarte1.0/viscacha_importer.xml b/importer/Importers/elkarte1.0/viscacha_importer.xml index bbffccfe..ea1fdc09 100644 --- a/importer/Importers/elkarte1.0/viscacha_importer.xml +++ b/importer/Importers/elkarte1.0/viscacha_importer.xml @@ -1,5 +1,5 @@ - + Viscacha 0.8 ElkArte 1.0 @@ -18,7 +18,7 @@ SUBSTRING(u.name, 1, 255) AS real_name, SUBSTRING(u.pw, 1, 64) AS passwd, IF(u.gender != '', u.gender, 0) AS gender, - SUBSTRING(u.mail, 1, 255) AS email_address, + SUBSTRING(u.mail, 1, 255) AS email_address, u.lastvisit AS last_login, u.regdate AS date_registered, u.birthday AS birthdate, u.location AS location, IF (u.groups = 1, 1, 0) AS id_group, @@ -32,7 +32,7 @@ {$to_prefix}categories TRUNCATE {$to_prefix}categories; - SELECT + SELECT id AS id_cat, name AS name, position AS cat_order FROM {$from_prefix}categories; @@ -50,7 +50,7 @@ SELECT - id AS id_board, SUBSTRING(name, 1, 255) AS name, '-1,0,1,2' AS member_groups, + id AS id_board, SUBSTRING(name, 1, 255) AS name, '-1,0,1,2' AS member_groups, SUBSTRING(description, 1, 65534) AS description, position AS board_order, (topics + replies) AS num_posts, topics AS num_topics, parent AS id_cat, parent AS id_parent FROM {$from_prefix}forums; @@ -80,10 +80,10 @@ SELECT - t.id AS id_topic, t.board AS id_board, - t.sticky AS is_sticky, t.name AS id_member_started, + t.id AS id_topic, t.board AS id_board, + t.sticky AS is_sticky, t.name AS id_member_started, t.last_name AS id_member_updated, t.vquestion AS id_poll, - MIN(p.id) AS id_first_msg, MAX(p.id) AS id_last_msg, + MIN(p.id) AS id_first_msg, MAX(p.id) AS id_last_msg, t.status AS locked FROM {$from_prefix}topics AS t LEFT JOIN {$from_prefix}replies AS p ON (p.topic_id = t.id) @@ -119,7 +119,7 @@ $row['modified_name'] = $editdata[0]; $row['modified_time'] = $editdata[1]; } - else + else $row['modified_time'] = 0; $row['id_member'] = (int) $row['id_member']; @@ -132,10 +132,10 @@ SELECT - p.id AS id_msg, p.topic_id AS id_topic, p.board AS id_board, + p.id AS id_msg, p.topic_id AS id_topic, p.board AS id_board, p.date AS poster_time, p.name AS id_member, p.topic AS subject, - u.name AS poster_name, u.mail AS poster_email, p.ip AS poster_ip, - p.dosmileys AS smileys_enabled, p.edit AS modified_name, '' AS modified_time, + u.name AS poster_name, u.mail AS poster_email, p.ip AS poster_ip, + p.dosmileys AS smileys_enabled, p.edit AS modified_name, '' AS modified_time, p.comment AS body, 'xx' AS icon FROM {$from_prefix}replies AS p LEFT JOIN {$from_prefix}user AS u ON (u.id = p.name) @@ -148,7 +148,7 @@ {$to_prefix}moderators TRUNCATE {$to_prefix}moderators; - SELECT + SELECT mid AS id_member, bid AS id_board FROM {$from_prefix}moderators; @@ -239,7 +239,7 @@ $row['votes'] = $count; - SELECT + SELECT tid AS id_poll, id AS id_choice, SUBSTRING(answer, 1, 255) AS label, 0 AS votes FROM {$from_prefix}vote; @@ -252,7 +252,7 @@ {$to_prefix}log_polls - SELECT + SELECT p.tid AS id_poll, v.mid AS id_member, v.aid AS id_choice FROM {$from_prefix}votes AS v LEFT JOIN {$from_prefix}vote AS p ON (v.aid = p.id); @@ -303,7 +303,7 @@ $file = explode('/', $row['filenamepath']); $row['filename'] = end($file); - + $source = $_POST['path_from'] . '/' . $row['filenamepath']; $destination = $attachmentUploadDir . '/' . $physical_filename; diff --git a/importer/Importers/elkarte1.0/wbb3_importer.xml b/importer/Importers/elkarte1.0/wbb3_importer.xml index 8a335862..44d5aae7 100644 --- a/importer/Importers/elkarte1.0/wbb3_importer.xml +++ b/importer/Importers/elkarte1.0/wbb3_importer.xml @@ -1,5 +1,5 @@ - + Woltlab Burning Board 3.1 ElkArte 1.0 @@ -57,13 +57,13 @@ SELECT * FROM {$from_prefix}{$wcf_prefix}user_option_value WHERE userID = $row[id_member]"); - + while ($userdata = $db->fetch_assoc($request)) $smfOptions = $userdata; - + $db->free_result($request); - /* now we can fix some profile options*/ + /* now we can fix some profile options*/ $row['birthdate'] = $smfOptions['userOption'. $userOptions['birthday']]; $row['show_online'] = !empty($smfOptions['userOption'. $userOptions['invisible']]) ? (int) $smfOptions['userOption'. $userOptions['invisible']] : 0; $row['hide_email'] = (int)$smfOptions['userOption'. $userOptions['hideEmailAddress']]; @@ -98,7 +98,7 @@ o.position AS cat_order FROM {$from_prefix}{$wbb_prefix}board AS c LEFT JOIN {$from_prefix}{$wbb_prefix}board_structure AS o ON (o.boardID = c.boardID) - WHERE boardType = 1; + WHERE boardType = 1; @@ -116,7 +116,7 @@ b.threads AS num_topics, b.countUserPosts AS num_posts, '2,-1,0,1' AS member_groups FROM {$from_prefix}{$wbb_prefix}board AS b LEFT JOIN {$from_prefix}{$wbb_prefix}board_structure AS o ON (o.boardID = b.boardID) - WHERE boardType = 0; + WHERE boardType = 0; @@ -212,7 +212,7 @@ {$to_prefix}poll_choices if (!isset($_SESSION['convert_last_poll']) || $_SESSION['convert_last_poll'] != $row['id_poll']) - { + { $_SESSION['convert_last_poll'] = $row['id_poll']; $_SESSION['convert_last_choice'] = 0; } diff --git a/importer/Importers/elkarte1.0/wedge_importer.xml b/importer/Importers/elkarte1.0/wedge_importer.xml index 7c60a812..eda8a601 100644 --- a/importer/Importers/elkarte1.0/wedge_importer.xml +++ b/importer/Importers/elkarte1.0/wedge_importer.xml @@ -1,5 +1,5 @@ - + Wedge 1.0 Wedge1_0 @@ -639,11 +639,11 @@ {$to_prefix}message_likes TRUNCATE {$to_prefix}message_likes; - $keys = array('id_member', 'id_msg', 'id_poster', 'like_timestamp'); - $rows = $this->config->source->fetchLikes(); + $this->keys = array('id_member', 'id_msg', 'id_poster', 'like_timestamp'); + $this->rows = $this->config->source->fetchLikes(); $special_table = $this->config->to_prefix . 'message_likes'; - $this->insertRows($rows, $keys, $special_table); + $this->insertRows($special_table); \ No newline at end of file diff --git a/importer/Importers/elkarte1.0/wordpress3_importer.xml b/importer/Importers/elkarte1.0/wordpress3_importer.xml index a25d3f64..fbb1f20b 100644 --- a/importer/Importers/elkarte1.0/wordpress3_importer.xml +++ b/importer/Importers/elkarte1.0/wordpress3_importer.xml @@ -1,5 +1,5 @@ - + Wordpress 3.x ElkArte 1.0 @@ -58,7 +58,7 @@ SELECT tax.term_id AS id_board, '1' AS id_cat, terms.name AS name, 0 AS board_order, - SUBSTRING(tax.description, 1, 65534) AS description, '1,2,3,-1,0' AS member_groups, + SUBSTRING(tax.description, 1, 65534) AS description, '1,2,3,-1,0' AS member_groups, tax.count AS num_topics, tax.parent AS id_parent, 0 AS num_posts FROM {$from_prefix}term_taxonomy AS tax LEFT JOIN {$from_prefix}terms AS terms ON (tax.term_id = terms.term_id) @@ -121,7 +121,7 @@ SELECT - p.comment_post_ID AS id_topic, t.id_board AS id_board, + p.comment_post_ID AS id_topic, t.id_board AS id_board, UNIX_TIMESTAMP(p.comment_date) AS poster_time, p.user_id AS id_member, c.post_title AS subject, p.comment_author_IP AS poster_ip, p.comment_author AS poster_name, p.comment_author_email AS poster_email, diff --git a/importer/Importers/elkarte1.0/xenforo11_importer.xml b/importer/Importers/elkarte1.0/xenforo11_importer.xml index dcc1fcd1..20394443 100644 --- a/importer/Importers/elkarte1.0/xenforo11_importer.xml +++ b/importer/Importers/elkarte1.0/xenforo11_importer.xml @@ -1,5 +1,5 @@ - + Xenforo 1.1 ElkArte 1.0 @@ -20,7 +20,7 @@ $row['passwd'] = $pass['hash']; else $row['passwd'] = sha1(md5(mktime())); - + if (isset($pass['salt'])) $row['password_salt'] = $pass['salt']; else @@ -36,7 +36,7 @@ '' AS openid_uri, m.register_date AS date_registered, m.last_activity AS last_login, '' AS ignore_boards, 1 AS hide_email, details.homepage AS website_title, - details.homepage AS website_url, IF(m.is_admin = 1, 1, 0) AS id_group, + details.homepage AS website_url, IF(m.is_admin = 1, 1, 0) AS id_group, details.location AS location, '' AS lngfile, '' AS buddy_list, '' AS pm_ignore_list, '' AS message_labels, '' AS personal_text, '' AS time_format, '' AS avatar, @@ -55,7 +55,7 @@ {$to_prefix}categories TRUNCATE {$to_prefix}categories; - SELECT + SELECT node_id AS id_cat, SUBSTRING(title, 1, 255) AS name, display_order AS cat_order FROM {$from_prefix}node WHERE node_type_id = 'Category'; @@ -73,16 +73,16 @@ DELETE FROM {$to_prefix}board_permissions WHERE id_profile > 4; - $request = $db->query(" - SELECT + $request = $this->db->query(" + SELECT thread_id, last_post_id FROM {$from_prefix}thread WHERE node_id = $row[id_board] ORDER BY thread_id DESC LIMIT 1"); - list($tmp, $row['id_last_msg']) = $db->fetch_row($request); - $db->free_result($request); + list($tmp, $row['id_last_msg']) = $this->db->fetch_row($request); + $this->db->free_result($request); SELECT @@ -105,7 +105,7 @@ SELECT - t.thread_id AS id_topic, t.node_id AS id_board, t.sticky AS is_sticky, + t.thread_id AS id_topic, t.node_id AS id_board, t.sticky AS is_sticky, IF(t.discussion_open = 1, 0, 1) AS locked, t.last_post_user_id AS id_member_updated, t.view_count AS num_views, t.reply_count AS num_replies, t.user_id AS id_member_started, t.first_post_id id_first_msg, t.last_post_id AS id_last_msg diff --git a/importer/Importers/elkarte1.0/xenforo14_importer.php b/importer/Importers/elkarte1.0/xenforo14_importer.php new file mode 100644 index 00000000..f568e90d --- /dev/null +++ b/importer/Importers/elkarte1.0/xenforo14_importer.php @@ -0,0 +1,185 @@ +getDbName(); + + // Seems to only be xf_ in recent versions + $db_prefix = 'xf_'; + + return '`' . $db_name . '`.' . $db_prefix; + } + + public function getDbName() + { + return $this->fetchSetting('dbname'); + } + + public function getTableTest() + { + return 'user'; + } + + protected function fetchSetting($name) + { + static $content = null; + + if ($content === null) + { + $content = file_get_contents($this->path . $this->setting_file); + } + + $match = array(); + preg_match('~\$config\[\'db\'\]\[\'' . $name . '\'\]\s*=\s*\'(.*?)\';~', $content, $match); + + return isset($match[1]) ? $match[1] : ''; + } + + public function xen_copy_files($dir, $row, $id_attach, $destination_path, $thumb = false) + { + // Extra details + list($ext, $basename, $mime_type) = attachment_type($row['filename']); + + // Prep for the copy + $file = xen_attach_filename($row) . ($thumb ? '.' . $ext : '.data'); + $source = $dir . '/' . $file; + $file_hash = createAttachmentFileHash($file); + $destination = $destination_path . '/' . $id_attach . '_' . $file_hash . '.elk'; + $type = 0; + + // Copy it over + copy_file($source, $destination); + + // If its an image, then make sure it has legit width/height + if (!empty($ext)) + { + list ($width) = getimagesize($destination); + if (!empty($width)) + { + $type = ($thumb) ? 3 : 0; + } + } + + // Prepare our insert + return array( + 'id_attach' => $id_attach, + 'id_thumb' => !$thumb && !empty($row['thumbnail_width']) ? ++$id_attach : 0, + 'size' => file_exists($destination) ? filesize($destination) : 0, + 'filename' => $basename . '.' . ($thumb ? $ext . '_thumb' : $ext), + 'file_hash' => $file_hash, + 'file_ext' => $ext, + 'mime_type' => $mime_type, + 'attachment_type' => $type, + 'id_msg' => $row['content_id'], + 'downloads' => $row['view_count'], + 'width' => $thumb ? $row['thumbnail_width'] : $row['width'], + 'height' => $thumb ? $row['thumbnail_height'] : $row['height'] + ); + } + + public function fetchLikes() + { + $from_prefix = $this->config->from_prefix; + + $request = $this->db->query(" + SELECT + likes, like_users, post_id, user_id, post_date + FROM {$from_prefix}post + WHERE likes != '0'"); + $return = array(); + while ($row = $this->db->fetch_assoc($request)) + { + $likers = unserialize($row['like_users']); + foreach ($likers as $likes) + { + $return[] = array( + 'id_member' => $likes['user_id'], + 'id_msg' => $row['post_id'], + 'id_poster' => $row['user_id'], + 'like_timestamp' => $row['post_date'], + ); + } + } + + return $return; + } +} + +// Utility Functions + +/** + * Converts a binary string containing IPv4 back to standard format + * + * I'm not really sure what is being stored in the DB but found + * 7f 00 00 01 for 127.0.0.1 which is a dec2hex(long2ip($ip)) + * + * @param string $ip IP data + * + * @return bool|string + */ +function convertIp($ip) +{ + if (strlen($ip) == 8) + { + return long2ip(hexdec($ip) + 0); + } + else if (strlen($ip) == 4) + { + $parts = array(); + foreach (str_split($ip) AS $char) + { + $parts[] = ord($char); + } + + return implode('.', $parts); + } + else if (preg_match('/^[0-9]+$/', $ip)) + { + return long2ip($ip + 0); + } + else + { + return '127.0.0.1'; + } +} + +/** + * Return the subdir/filename combo to a given file + * + * Does not include the .data, .jpg, etc + * + * @param $row + * + * @return string + */ +function xen_attach_filename($row) +{ + $subdir = floor($row['data_id'] / 1000); + $name = $subdir . "/{$row['data_id']}-{$row['file_hash']}"; + + return $name; +} \ No newline at end of file diff --git a/importer/Importers/elkarte1.0/xenforo14_importer.xml b/importer/Importers/elkarte1.0/xenforo14_importer.xml new file mode 100644 index 00000000..6257e3d9 --- /dev/null +++ b/importer/Importers/elkarte1.0/xenforo14_importer.xml @@ -0,0 +1,285 @@ + + + + Xenforo 1.4 + ElkArte 1.0 + XenForo1_4 + + + Importing Members + {$from_prefix}user + {$to_prefix}members + + TRUNCATE {$to_prefix}members; + + + // Extract the password hash + $pass = unserialize($row['tmp']); + + if (isset($pass['hash'])) + $row['passwd'] = $pass['hash']; + else + $row['passwd'] = sha1(md5(mktime())); + + if (isset($pass['salt'])) + $row['password_salt'] = $pass['salt']; + else + $row['password_salt'] = ''; + + // Yes I used AND to avoid CDATA here + $row['birthdate'] = '0000-00-00'; + if ($row['dob_day'] != '0' AND $row['dob_month'] != '0') + { + $row['birthdate'] = $row['dob_year'] . '-' . $row['dob_month'] . '-' . $row['dob_day']; + } + + // Remove these temp columns + unset($row['tmp'], $row['dob_day'], $row['dob_month'], $row['dob_year']); + + + SELECT + m.user_id AS id_member, SUBSTRING(m.username, 1, 80) AS member_name, + SUBSTRING(m.username, 1, 255) AS real_name, + SUBSTRING(m.email, 1, 255) AS email_address, + (CASE WHEN m.gender = 'male' THEN 1 WHEN m.gender = 'female' THEN 2 ELSE 0 END) AS gender, + m.custom_title AS usertitle, m.visible AS show_online, IF(m.is_admin = 1, 1, 0) AS id_group, + m.message_count AS posts, m.conversations_unread AS unread_messages, m.register_date AS date_registered, + m.last_activity AS last_login, + '' AS passwd, '' AS password_salt, '' AS openid_uri, '' AS ignore_boards, 1 AS hide_email, + '' AS lngfile, '' AS buddy_list, '' AS pm_ignore_list, '' AS message_labels, + '' AS personal_text, '' AS time_format, '' AS avatar, + '' AS member_ip, '' AS secret_question, '' AS secret_answer, + '' AS validation_code, '' AS additional_groups, '' AS smiley_set, '' AS member_ip2, + details.homepage AS website_title, details.homepage AS website_url, details.location AS location, + details.signature AS signature, details.dob_day, details.dob_month, details.dob_year, + p.data AS tmp + FROM {$from_prefix}user AS m + INNER JOIN {$from_prefix}user_authenticate AS p ON (m.user_id = p.user_id) + LEFT JOIN {$from_prefix}user_profile AS details ON (m.user_id = details.user_id) + WHERE m.user_state != 'email_confirm'; + + + + Importing Categories + {$from_prefix}node WHERE node_type_id = 'Category' + {$to_prefix}categories + TRUNCATE {$to_prefix}categories; + + SELECT + node_id AS id_cat, SUBSTRING(title, 1, 255) AS name, display_order AS cat_order + FROM {$from_prefix}node + WHERE node_type_id = 'Category'; + + + + Importing Boards + {$from_prefix}node WHERE node_type_id = 'Forum' + {$to_prefix}boards + + true + + + TRUNCATE {$to_prefix}boards; + DELETE FROM {$to_prefix}board_permissions WHERE id_profile > 4; + + + $request = $this->db->query(" + SELECT + thread_id, last_post_id + FROM {$from_prefix}thread + WHERE node_id = $row[id_board] + ORDER BY thread_id DESC + LIMIT 1"); + + list($tmp, $row['id_last_msg']) = $this->db->fetch_row($request); + $this->db->free_result($request); + + + SELECT + node_id AS id_board, parent_node_id AS id_cat, display_order AS board_order, + SUBSTRING(title, 1, 255) AS name, + SUBSTRING(description, 1, 65534) AS description, '-1,0' AS member_groups + FROM {$from_prefix}node + WHERE node_type_id = 'Forum'; + + + + Importing Topics + {$from_prefix}thread + {$to_prefix}topics + + TRUNCATE {$to_prefix}topics; + TRUNCATE {$to_prefix}log_topics; + TRUNCATE {$to_prefix}log_boards; + TRUNCATE {$to_prefix}log_mark_read; + + + SELECT + t.thread_id AS id_topic, t.node_id AS id_board, t.sticky AS is_sticky, + IF(t.discussion_open = 1, 0, 1) AS locked, t.last_post_user_id AS id_member_updated, + t.view_count AS num_views, t.reply_count AS num_replies, t.user_id AS id_member_started, + t.first_post_id id_first_msg, t.last_post_id AS id_last_msg + FROM {$from_prefix}thread AS t + WHERE t.discussion_state != 'deleted'; + + + + Importing Messages + {$from_prefix}post + {$to_prefix}messages + TRUNCATE {$to_prefix}messages; + + false + true + 100 + + + $this->row['poster_ip'] = convertIp($this->row['poster_ip']); + + + SELECT + m.post_id AS id_msg, m.thread_id AS id_topic, m.post_date AS poster_time, + m.last_edit_user_id AS id_msg_modified, m.last_edit_date AS modified_time, + SUBSTRING(t.title, 1, 255) AS subject, m.user_id AS id_member, mu.username AS modified_name, + SUBSTRING(m.username, 1, 255) AS poster_name, + SUBSTRING(m.username, 1, 255) AS poster_email, + SUBSTRING(i.ip, 1, 255) AS poster_ip, t.node_id AS id_board, + SUBSTRING(m.message, 1, 65534) AS body, '' AS modified_name, 'xx' AS icon + FROM {$from_prefix}post AS m + LEFT JOIN {$from_prefix}user AS u ON (u.user_id = m.user_id) + LEFT JOIN {$from_prefix}user AS mu ON (mu.user_id = m.last_edit_user_id) + LEFT JOIN {$from_prefix}ip AS i ON (i.ip_id = m.ip_id) + INNER JOIN {$from_prefix}thread AS t ON (m.thread_id = t.thread_id) + WHERE t.discussion_state != 'deleted'; + + + + Importing personal messages + {$from_prefix}conversation_message + {$to_prefix}personal_messages + + TRUNCATE {$to_prefix}personal_messages; + TRUNCATE {$to_prefix}pm_recipients; + + + SELECT + msg.message_id AS id_pm, msg.user_id AS id_member_from, msg.message_date AS msgtime, + 0 AS deleted_by_sender, msg.conversation_id AS id_pm_head, + SUBSTRING(IFNULL(msg.username, "Guest"), 1, 255) AS from_name, + SUBSTRING(mt.title, 1, 255) AS subject, + SUBSTRING(msg.message, 1, 65534) AS body + FROM {$from_prefix}conversation_message as msg + INNER JOIN {$from_prefix}conversation_master AS mt ON (mt.conversation_id = msg.conversation_id); + + + + Importing pm recipients + {$from_prefix}conversation_recipient + {$to_prefix}pm_recipients + + SELECT + msg.message_id AS id_pm, r.user_id AS id_member, 1 AS is_read, + 0 AS deleted, '-1' AS labels + FROM {$from_prefix}conversation_message AS msg + INNER JOIN {$from_prefix}conversation_recipient AS r ON (r.conversation_id = msg.conversation_id) + WHERE msg.user_id != r.user_id + ORDER BY id_pm; + + + + Importing attachments + {$from_prefix}attachment + {$to_prefix}attachments + + true + + + TRUNCATE {$to_prefix}attachments; + + + // DB values to store + $this->keys = array('id_attach', 'id_thumb', 'size', 'filename', 'file_hash', 'fileext', 'mime_type', 'attachment_type', 'id_msg', 'downloads', 'width', 'height'); + + if (!isset($xen_attachment_dir)) + { + $xen_attachment_dir = rtrim($_POST['path_from'], '/\\') . "/internal_data/attachments/"; + $xen_thumbnail_dir = rtrim($_POST['path_from'], '/\\') . "/data/attachments/"; + } + + // Copy the attachment + $destination_path = $this->step1_importer->getAttachDir($this->row); + $id_attach = $this->step1_importer->newIdAttach(); + $this->rows[] = $this->config->source->xen_copy_files($xen_attachment_dir, $this->row, $id_attach, $destination_path, false); + + // If we have its thumbnail ... + if (!empty($this->row['thumbnail_width'])) + { + $id_attach = $this->step1_importer->newIdAttach(); + $this->rows[] = $this->config->source->xen_copy_files($xen_thumbnail_dir, $this->row, $id_attach, $destination_path, true); + } + + + SELECT + a.attachment_id, a.data_id, a.view_count, a.content_id, a.content_type, + d.filename, d.file_size, d.file_hash, d.width, d.height, d.thumbnail_width, d.thumbnail_height + FROM {$from_prefix}attachment AS a + LEFT JOIN {$from_prefix}attachment_data AS d ON (a.data_id = d.data_id) + WHERE content_type = "post"; + + + + Importing avatars + {$from_prefix}user + {$to_prefix}attachments + + true + + + $this->keys = array('size', 'filename', 'file_hash', 'fileext', 'mime_type', 'id_member'); + + // Create some useful shortcuts + $xen_avatar_dir = rtrim($_POST['path_from'], '/\\') . '/data/avatars/'; + $xen_avatar_name = 'l/' . floor($this->row['id_member']/1000) . '/' . $this->row['id_member'] . '.jpg'; + + // Create the destination name + $source = $xen_avatar_dir . $xen_avatar_name; + $filename = $this->row['id_member'] . '.jpg'; + $file_hash = createAttachmentFileHash($filename); + $id_attach = $this->step1_importer->newIdAttach(); + $destination = $this->step1_importer->getAttachDir($this->row) . '/' . $id_attach . '_' . $file_hash . '.elk'; + + // Copy it! + copy_file($source, $destination); + + // Prepare the insert + $this->rows[] = array( + 'size' => file_exists($destination) ? filesize($destination) : 0, + 'filename' => $filename, + 'file_hash' => $file_hash, + 'fileext' => 'jpg', + 'mime_type' => 'image/jpg', + 'id_member' => $this->row['id_member'], + ); + + + SELECT + user_id AS id_member, user_id AS filename, avatar_date, gravatar + FROM {$from_prefix}user + WHERE avatar_date > 0 + OR gravatar != ''; + + + + Importing likes + {$from_prefix}post + {$to_prefix}message_likes + TRUNCATE {$to_prefix}message_likes; + + $this->keys = array('id_member', 'id_msg', 'id_poster', 'like_timestamp'); + $this->rows = $this->config->source->fetchLikes(); + $special_table = $this->config->to_prefix . 'message_likes'; + + $this->insertRows($special_table); + + + \ No newline at end of file diff --git a/importer/OpenImporter/Lang.php b/importer/OpenImporter/Lang.php index ab21c408..5894def4 100644 --- a/importer/OpenImporter/Lang.php +++ b/importer/OpenImporter/Lang.php @@ -128,7 +128,7 @@ protected function findLanguage($path, $language) */ public function has($key) { - return isset($this->_lang[$key]); + return isset($this->_lang[(string) $key]); } /** @@ -165,7 +165,7 @@ public function get($key) return $this->_lang[$key]; } - return null; + return (string) $key; } /** diff --git a/importer/OpenImporter/Template.php b/importer/OpenImporter/Template.php index d8968e35..429b2ffa 100644 --- a/importer/OpenImporter/Template.php +++ b/importer/OpenImporter/Template.php @@ -193,6 +193,7 @@ function processRequest() req.send(null); }; } + function validateField(string) { var target = document.getElementById(string), @@ -209,7 +210,7 @@ function validateCallback(responseXML, string) validate = document.getElementById(\'validate_\' + string), submitBtn = document.getElementById("submit_button"); - if (msg == "false") + if (msg === "false") { field.className = "invalid_field"; validate.innerHTML = "' . $this->language->get('invalid') . '"; @@ -225,6 +226,11 @@ function validateCallback(responseXML, string) submitBtn.disabled = false; } } + + window.onload = function() { + validateField(\'path_to\'); + validateField(\'path_from\'); + }