// Nodes
$start = microtime(true);
echo " nodes";
exec('mysql -h' . $this->slaveDbHost . ' ' . $this->sourceDb . ' ' . $this->sourceDBuser . ' ' . $this->sourceDBpassword . ' -N -q -e "SET NAMES binary;SELECT SQL_NO_CACHE forum.forumid AS node_id, REPLACE(forum.title, \'&\', \'&\'), forum.description, IF(LENGTH(forum.link) > 0, SUBSTRING(forum.link, 51), \'\\\\\\N\') AS node_name, IF(forum.parentid = -1, \'Category\', IF(LENGTH(forum.link) > 0, \'LinkForum\', \'Forum\')) AS node_type_id, IF(forum.parentid = -1, 0, forum.parentid) AS parent_node_id, forum.displayorder AS display_order, IF(forum.options & 1, 1, 0) AS display_in_list, \'0\' AS lft, \'0\' AS rgt, \'\' AS depth, forum.styleid AS style_id, forum.styleid AS effective_style_id FROM ' . self::$tablePrefix . 'forum as forum ORDER BY forum.forumid" ' . self::$extraOutCommand . ' > ' . self::$dataDir . 'xf_node.txt');
exec(self::$sedCommand . " -i 's/\\\\N/N/g' " . self::$dataDir . "xf_node.txt");
echo " (" . number_format(intval(shell_exec('wc -l ' . self::$dataDir . 'xf_node.txt'))) . ' records in ' . number_format(microtime(true) - $start, 2) . "s)...\r\n";
// Forums
$start = microtime(true);
echo " forums";
exec('mysql -h' . $this->slaveDbHost . ' ' . $this->sourceDb . ' ' . $this->sourceDBuser . ' ' . $this->sourceDBpassword . ' -N -q -e "SET NAMES binary;SELECT SQL_NO_CACHE forum.forumid AS node_id, forum.threadcount AS discussion_count, forum.replycount AS message_count, forum.lastpostid AS last_post_id, forum.lastpost AS last_post_date, ' . (self::$isVB4 ? 'forum.lastposterid' : "'0'") . ' AS last_post_user_id, forum.lastposter AS last_post_username, forum.lastthread AS last_thread_title, IF(forum.options & 8, 1, 0) AS moderate_threads, IF(forum.options & 8, 1, 0) AS moderate_replies, IF(forum.options & 2, 1, 0) AS allow_posting, 1 AS allow_poll, IF(forum.options & 4096, \'1\', \'0\') AS count_messages, \'1\' AS find_new, \'\' AS prefix_cache, \'0\' AS default_prefix_id, \'last_post_date\' AS default_sort_order, \'desc\' AS default_sort_direction, 0 AS list_date_limit_days, \'0\' AS require_prefix, \'thread\' AS allowed_watch_notifications FROM ' . self::$tablePrefix . 'forum as forum WHERE forum.parentid > 0 ORDER BY forum.forumid" ' . self::$extraOutCommand . ' > ' . self::$dataDir . 'xf_forum.txt');
echo " (" . number_format(intval(shell_exec('wc -l ' . self::$dataDir . 'xf_forum.txt'))) . ' records in ' . number_format(microtime(true) - $start, 2) . "s)...\r\n";