/** * Standard import function. * * @param object The DB connection to import from * @param string The table prefix the target prefix is using * @param PATH The base directory we are importing from */ function import_ocf_forums($db, $table_prefix, $old_base_dir) { require_code('ocf_forums_action2'); $rows = $db->query('SELECT * FROM ' . $table_prefix . 'forums'); foreach ($rows as $row) { $remapped = import_id_remap_get('forum', strval($row['forum_id']), true); if (!is_null($remapped)) { continue; } $name = $row['forum_name']; $description = html_to_comcode($row['forum_description']); $position = $row['forum_order']; $post_count_increment = 1; $category_id = import_id_remap_get('category', strval($row['category_id']), true); $parent_forum = db_get_first_id(); $access_mapping = array(); $permissions = $db->query('SELECT * FROM ' . $table_prefix . 'forum_permissions WHERE forum_id=' . strval((int) $row['forum_id'])); foreach ($permissions as $p) { $v = 0; if ($p['view_others_topics'] == 1) { $v = 1; } if ($p['reply_to_others_topics'] == 1) { $v = 2; } if ($p['post_new_topics'] == 1) { $v = 3; } if ($p['post_polls'] == 1) { $v = 4; } // This ones a bit hackerish, but closest we can get to concept $group_id = import_id_remap_get('group', strval($p['user_group_id']), true); if (!is_null($group_id)) { $access_mapping[$group_id] = $v; } } $id_new = ocf_make_forum($name, $description, $category_id, $access_mapping, $parent_forum, $position, $post_count_increment, 0, ''); import_id_remap_put('forum', strval($row['forum_id']), $id_new); } }
/** * Standard import function. * * @param object The DB connection to import from * @param string The table prefix the target prefix is using * @param PATH The base directory we are importing from */ function import_ocf_forums($db, $table_prefix, $old_base_dir) { require_code('ocf_forums_action2'); $rows = $db->query('SELECT * FROM ' . $table_prefix . 'forums'); foreach ($rows as $row) { $remapped = import_id_remap_get('forum', strval($row['fid']), true); if (!is_null($remapped)) { continue; } $name = $row['fname']; ocf_over_msn(); //set the proper forum driver FORUM_DB $description = html_to_comcode($row['description']); ocf_over_local(); //return the OCF FORUM_DB $position = $row['forum_order']; $post_count_increment = 1; $category_id = import_id_remap_get('category', strval($row['cat_id']), true); $parent_forum = db_get_first_id(); $access_mapping = array(); if ($row['status'] == 0) { $permissions = $db->query('SELECT * FROM ' . $table_prefix . 'forumpermissions WHERE fpfid=' . strval((int) $row['fid'])); foreach ($permissions as $p) { $v = 0; if ($p['can_post_topic'] == 1) { $v = 2; } if ($p['can_reply'] == 1) { $v = 3; } if ($p['can_post_polls'] == 1) { $v = 4; } $group_id = import_id_remap_get('group', strval($p['fpugid']), true); if (is_null($group_id)) { continue; } $access_mapping[$group_id] = $v; } } $id_new = ocf_make_forum($name, $description, $category_id, $access_mapping, $parent_forum, $position, $post_count_increment, 0, ''); import_id_remap_put('forum', strval($row['fid']), $id_new); } }
/** * Standard import function. * * @param object The DB connection to import from * @param string The table prefix the target prefix is using * @param PATH The base directory we are importing from */ function import_ocf_forums($db, $table_prefix, $old_base_dir) { require_code('ocf_forums_action2'); $remap_id = array(); $rows = $db->query('SELECT * FROM ' . $table_prefix . 'forum WHERE parentid<>-1'); foreach ($rows as $row) { $remapped = import_id_remap_get('forum', strval($row['forumid']), true); if (!is_null($remapped)) { $remap_id[$row['forumid']] = $remapped; continue; } $name = $row['title']; $description = html_to_comcode($row['description']); $position = $row['displayorder']; $post_count_increment = 1; //$row['options']&4096; This didn't work, not important though $category_id = import_id_remap_get('category', strval($row['parentid']), true); if (is_null($category_id)) { $category_id = db_get_first_id(); } $parent_forum = db_get_first_id(); $permissions = $db->query('SELECT usergroupid,forumpermissions FROM ' . $table_prefix . 'forumpermission WHERE forumid=' . strval((int) $row['forumid'])); $access_mapping = array(); foreach ($permissions as $p) { $x = $p['forumpermissions']; $v = 0; if (($x & 2) != 0) { $v = 1; } if (($x & 16) != 0) { $v = 2; } if (($x & 16) != 0 && !(($x & 131072) != 0)) { $v = 3; } if (($x & 16) != 0 && !(($x & 131072) != 0) && ($x & 64) != 0) { $v = 4; } if (($x & 16) != 0 && ($x & 512) != 0) { $v = 5; } $group_id = import_id_remap_get('group', strval($p['usergroupid'])); $access_mapping[$group_id] = $v; } $id_new = ocf_make_forum($name, $description, $category_id, $access_mapping, $parent_forum, $position, $post_count_increment, 0, '', $row['password'], $row['link']); $remap_id[$row['forumid']] = $id_new; import_id_remap_put('forum', strval($row['forumid']), $id_new); } // Now we must fix parenting foreach ($rows as $row) { $parents = explode(',', $row['parentlist']); if (array_key_exists(2, $parents)) { $category_id = import_id_remap_get('category', strval($parents[1]), true); $r = $parents[is_null($category_id) ? 1 : 2]; if ($r != -1) { $parent_id = $remap_id[$r]; $GLOBALS['FORUM_DB']->query_update('f_forums', array('f_parent_forum' => $parent_id), array('id' => $remap_id[$row['forumid']]), '', 1); } } } }
/** * Convert HTML-filled Comcode to cleaner Comcode. * * @param LONG_TEXT The messy Comcode. * @return LONG_TEXT The cleaned Comcode. */ function force_clean_comcode($comcode) { $matches = array(); if (preg_match('#^\\[semihtml\\](.*)\\[/semihtml\\]$#s', $comcode, $matches) != 0) { if (strpos($matches[1], '[semihtml]') === false && strpos($matches[1], '[html]') === false) { return semihtml_to_comcode($matches[1], true); } } if (preg_match('#^\\[html\\](.*)\\[/html\\]$#s', $comcode, $matches) != 0) { if (strpos($matches[1], '[semihtml]') === false && strpos($matches[1], '[html]') === false) { return html_to_comcode($matches[1]); } } return $comcode; }
/** * Standard import function. * * @param object The DB connection to import from * @param string The table prefix the target prefix is using * @param PATH The base directory we are importing from */ function import_calendar($db, $table_prefix, $file_base) { require_code('calendar2'); $rows = $db->query_select('calendar'); foreach ($rows as $row) { if (import_check_if_imported('event', strval($row['id_event']))) { continue; } $submitter = import_id_remap_get('member', strval($row['id_member']), true); if (is_null($submitter)) { $submitter = $GLOBALS['OCF_DRIVER']->get_guest_id(); } $recurrence = 'none'; $recurrences = NULL; $days = intval(floor((strtotime($row['end_date']) - strtotime($row['start_date'])) / (60 * 60 * 24))); //Max 7 days in SMF if ($days == 0) { $recurrence = 'none'; } else { $recurrence = 'daily '; for ($i = 1; $i <= $days; $i++) { $recurrence .= '1'; } } list($start_year, $start_month, $start_day, $start_hour, $start_minute) = array_map('intval', explode('-', date('Y-m-d-h-i', strtotime($row['start_date'])))); list($end_year, $end_month, $end_day, $end_hour, $end_minute) = array_map('intval', explode('-', date('Y-m-d-h-i', strtotime($row['end_date'])))); $description = ''; if ($row['id_topic'] != 0) { $atts = $db->query('SELECT * FROM ' . $table_prefix . 'attachments WHERE id_msg=' . strval($row['id_topic']) . ' ORDER BY id_msg ASC'); $attid = isset($atts[0]['id_attach']) ? $atts[0]['id_attach'] : 0; $att_imported = $attid > 0 && import_check_if_imported('post_files', strval($attid)) ? true : false; $messages = $db->query('SELECT * FROM ' . $table_prefix . 'messages WHERE id_topic=' . strval($row['id_topic']) . ' ORDER BY id_topic ASC'); $description = isset($messages[0]['body']) && $messages[0]['body'] != '' ? str_replace(array('[html]', '[/html]'), array('', ''), html_to_comcode($messages[0]['body'])) : ''; } if ($att_imported) { $attid_new = import_id_remap_get('post_files', strval($attid), true); $description .= "\n\n" . '[attachment]' . strval($attid_new) . '[/attachment]'; } $id_new = add_calendar_event(db_get_first_id() + 1, $recurrence, $recurrences, 0, $row['title'], $description, 3, 1, $start_year, $start_month, $start_day, $start_hour, $start_minute, $end_year, $end_month, $end_day, $end_hour, $end_minute, NULL, 1, 1, 1, 1, 1, '', $submitter); if ($att_imported) { $GLOBALS['SITE_DB']->query_insert('attachment_refs', array('r_referer_type' => 'calendar', 'r_referer_id' => strval($id_new), 'a_id' => $attid_new)); } import_id_remap_put('event', strval($row['id_event']), $id_new); } $rows = array(); $rows = $db->query_select('calendar_holidays'); foreach ($rows as $row) { if (import_check_if_imported('event_holiday', strval($row['id_holiday']))) { continue; } $submitter = $GLOBALS['OCF_DRIVER']->get_guest_id(); $recurrence = 'none'; $recurrences = NULL; list($start_year, $start_month, $start_day, $start_hour, $start_minute) = array_map('intval', explode('-', date('Y-m-d-h-i', strtotime($row['event_date'])))); list($end_year, $end_month, $end_day, $end_hour, $end_minute) = array_map('intval', explode('-', date('Y-m-d-h-i', strtotime($row['event_date'])))); $id_new = add_calendar_event(db_get_first_id() + 1, $recurrence, $recurrences, 0, $row['title'], $row['title'], 3, 1, $start_year, $start_month, $start_day, $start_hour, $start_minute, $end_year, $end_month, $end_day, $end_hour, $end_minute, NULL, 1, 1, 1, 1, 1, '', $submitter); import_id_remap_put('event_holiday', strval($row['id_holiday']), $id_new); } }
/** * Standard import function. * * @param object The DB connection to import from * @param string The table prefix the target prefix is using * @param PATH The base directory we are importing from */ function import_ocf_forums($db, $table_prefix, $old_base_dir) { require_code('ocf_forums_action2'); $rows = $db->query('SELECT * FROM ' . $table_prefix . 'forums'); foreach ($rows as $row) { $remapped = import_id_remap_get('forum', strval($row['forum_id']), true); if (!is_null($remapped)) { continue; } $name = $row['forum_name']; ocf_over_msn(); $description = html_to_comcode($row['forum_desc']); ocf_over_local(); $position = $row['forum_order']; $post_count_increment = 1; $category_id = import_id_remap_get('category', strval($row['cat_id']), true); $parent_forum = db_get_first_id(); $access_mapping = array(); if ($row['forum_status'] == 0) { $permissions = $db->query('SELECT * FROM ' . $table_prefix . 'auth_access WHERE forum_id=' . strval((int) $row['forum_id'])); // $row['group_id']=-1; // $permissions[]=$row; foreach ($permissions as $p) { $v = 0; if ($p['auth_read'] == 1) { $v = 1; } if ($p['auth_post'] == 1) { $v = 2; } if ($p['auth_reply'] == 1) { $v = 3; } if ($p['auth_pollcreate'] == 1) { $v = 4; } // This ones a bit hackerish, but closest we can get to concept if (array_key_exists('auth_mod', $p) && $p['auth_mod'] == 1) { $v = 5; } //NOTE that if the group is not imported, this means that this group is a single user group if (!import_check_if_imported('group', strval($p['group_id']))) { continue; } $group_id = import_id_remap_get('group', strval($p['group_id'])); $access_mapping[$group_id] = $v; } } $id_new = ocf_make_forum($name, $description, $category_id, $access_mapping, $parent_forum, $position, $post_count_increment, 0, ''); import_id_remap_put('forum', strval($row['forum_id']), $id_new); } }
/** * Standard import function. * * @param object The DB connection to import from * @param string The table prefix the target prefix is using * @param PATH The base directory we are importing from */ function import_banners($db, $table_prefix, $old_base_dir) { require_code('banners2'); $categories = $db->query("SELECT title,id FROM " . $table_prefix . "categories WHERE section='com_banner'"); foreach ($categories as $category) { $cat_title = $category['title']; $category_exist = $GLOBALS['SITE_DB']->query_value_null_ok('banner_types', 'id', array('id' => $category['title'])); if (is_null($category_exist)) { add_banner_type($cat_title, 1, 160, 600, 70, 1); } $rows = $db->query("SELECT b.publish_down ,b.bid,c.title,b.name, b.clickurl, b.imageurl,b.date,bc.contact,bc.extrainfo,bc.email,b.showBanner,b.clicks,b.impmade FROM " . $table_prefix . "banner b INNER JOIN " . $table_prefix . "bannerclient bc ON b.cid=bc.cid INNER JOIN " . $table_prefix . "categories c ON b.catid=c.id AND c.title='" . db_escape_string($cat_title) . "' AND c.title <> ''"); foreach ($rows as $row) { $name = $row['name'] . strval($row['bid']); $test = $GLOBALS['SITE_DB']->query_value_null_ok('banners', 'name', array('name' => $name)); if (is_null($test)) { if ($row['imageurl'] != '') { $newimagepath = get_custom_file_base() . '/uploads/banners/' . rawurldecode($row['imageurl']); $newimage = $row['imageurl']; $oldimagepath = $old_base_dir . "/images/banners/" . rawurldecode($row['imageurl']); @copy($oldimagepath, $newimagepath); } else { $newimage = ''; } $type = 0; // Permanent $campaignremaining = 0; // Irrelevant $caption = $row['name']; $end_date = $this->mysql_time_to_timestamp($row['publish_down']); if ($end_date === false) { $end_date = NULL; } $url = $row['clickurl']; $image_url = $newimage; $member = $GLOBALS['FORUM_DRIVER']->get_member_from_username($row['contact']); if (is_null($member)) { $member = get_member(); } $desc = $row['email'] . chr(10) . $row['extrainfo']; $desc = html_to_comcode($desc); add_banner($name, $image_url, '', $caption, $campaignremaining, $url, 10, $desc, $type, $end_date, $member, 1, $cat_title, NULL, 0, 0, $row['clicks'], 0, $row['impmade']); } } } $row_start = 0; $rows = array(); do { $rows = $db->query("SELECT u.id, u.username, u.password, u.email, u.id, u.registerDate, u.lastvisitDate, u.sendEmail FROM " . $table_prefix . "bannerclient AS b INNER JOIN " . $table_prefix . "users AS u ON b.contact=u.name", 200, $row_start); foreach ($rows as $row) { if (import_check_if_imported('member', strval($row['id']))) { continue; } $test = $GLOBALS['OCF_DRIVER']->get_member_from_username($row['username']); if (!is_null($test)) { import_id_remap_put('member', strval($row['id']), $test); continue; } $primary_group = get_first_default_group(); $custom_fields = array(); $datetimearr = explode(' ', $row['registerDate']); $datearr = explode('-', $datetimearr[0]); $timearr = explode(':', $datetimearr[1]); $date = $datearr[2]; $month = $datearr[1]; $year = $datearr[0]; $hour = $timearr[0]; $min = $timearr[1]; $sec = $timearr[2]; $register_date = mktime($hour, $min, $sec, $month, $date, $year); $datetimearr = explode(' ', $row['lastvisitDate']); $datearr = explode('-', $datetimearr[0]); $timearr = explode(':', $datetimearr[1]); $date = $datearr[2]; $month = $datearr[1]; $year = $datearr[0]; $hour = $timearr[0]; $min = $timearr[1]; $sec = $timearr[2]; $last_visit_date = mktime($hour, $min, $sec, $month, $date, $year); $id = get_param_integer('keep_preserve_ids', 0) == 0 ? NULL : $row['id']; $id_new = ocf_make_member($row['username'], $row['password'], $row['email'], NULL, NULL, NULL, NULL, $custom_fields, NULL, $primary_group, 1, $register_date, $last_visit_date, '', NULL, '', 0, 0, 1, $row['name'], '', '', 1, 1, NULL, $row['sendEmail'], $row['sendEmail'], '', NULL, '', FALSE, NULL, '', 1, $last_visit_date, $id, 0, '*', ''); import_id_remap_put('member', strval($row['id']), $id_new); } $row_start += 200; } while (count($rows) > 0); }
/** * Import wordpress db */ function import_wordpress_db() { disable_php_memory_limit(); $data = get_wordpress_data(); $is_validated = post_param_integer('wp_auto_validate', 0); $to_own_account = post_param_integer('wp_add_to_own', 0); // Create members require_code('ocf_members_action'); require_code('ocf_groups'); $def_grp_id = get_first_default_group(); $cat_id = array(); $NEWS_CATS = $GLOBALS['SITE_DB']->query_select('news_categories', array('*'), array('nc_owner' => NULL)); $NEWS_CATS = list_to_map('id', $NEWS_CATS); foreach ($data as $values) { if (get_forum_type() == 'ocf') { $member_id = $GLOBALS['FORUM_DB']->query_value_null_ok('f_members', 'id', array('m_username' => $values['user_login'])); if (is_null($member_id)) { if (post_param_integer('wp_import_wordpress_users', 0) == 1) { $member_id = ocf_make_member($values['user_login'], $values['user_pass'], '', NULL, NULL, NULL, NULL, array(), NULL, $def_grp_id, 1, time(), time(), '', NULL, '', 0, 0, 1, '', '', '', 1, 0, '', 1, 1, '', NULL, '', false, 'wordpress'); } else { $member_id = $GLOBALS['FORUM_DRIVER']->get_member_from_username('admin'); // Set admin as owner if (is_null($member_id)) { $member_id = $GLOBALS['FORUM_DRIVER']->get_guest_id() + 1; } } } } else { $member_id = $GLOBALS['FORUM_DRIVER']->get_guest_id(); } // Guest user // If post should go to own account if ($to_own_account == 1) { $member_id = get_member(); } if (array_key_exists('POSTS', $values)) { // Create posts in blog foreach ($values['POSTS'] as $post_id => $post) { if (array_key_exists('category', $post)) { $cat_id = array(); foreach ($post['category'] as $cat_code => $category) { $cat_code = NULL; if ($category == 'Uncategorized') { continue; } // Skip blank category creation foreach ($NEWS_CATS as $id => $existing_cat) { if (get_translated_text($existing_cat['nc_title']) == $category) { $cat_code = $id; } } if (is_null($cat_code)) { $cat_code = add_news_category($category, 'newscats/community', $category); $NEWS_CATS = $GLOBALS['SITE_DB']->query_select('news_categories', array('*')); $NEWS_CATS = list_to_map('id', $NEWS_CATS); } $cat_id = array_merge($cat_id, array($cat_code)); } } $owner_category_id = $GLOBALS['SITE_DB']->query_value_null_ok('news_categories', 'id', array('nc_owner' => $member_id)); if ($post['post_type'] == 'post') { $id = add_news($post['post_title'], html_to_comcode($post['post_content']), NULL, $is_validated, 1, $post['comment_status'] == 'closed' ? 0 : 1, 1, '', html_to_comcode($post['post_content']), $owner_category_id, $cat_id, NULL, $member_id, 0, time(), NULL, ''); } elseif ($post['post_type'] == 'page') { // If dont have permission to write comcode page, skip the post if (!has_submit_permission('high', get_member(), get_ip_address(), NULL, NULL)) { continue; } require_code('comcode'); // Save articles as new comcode pages $zone = filter_naughty(post_param('zone', 'site')); $lang = filter_naughty(post_param('lang', 'EN')); $file = preg_replace('/[^A-Za-z0-9]/', '_', $post['post_title']); // Filter non alphanumeric charactors $parent_page = post_param('parent_page', ''); $fullpath = zone_black_magic_filterer(get_custom_file_base() . '/' . $zone . '/pages/comcode_custom/' . $lang . '/' . $file . '.txt'); // Check existancy of new page $submiter = $GLOBALS['SITE_DB']->query_value_null_ok('comcode_pages', 'p_submitter', array('the_zone' => $zone, 'the_page' => $file)); if (!is_null($submiter)) { continue; } // Skip existing titled articles - may need change require_code('submit'); give_submit_points('COMCODE_PAGE_ADD'); if (!addon_installed('unvalidated')) { $is_validated = 1; } $GLOBALS['SITE_DB']->query_insert('comcode_pages', array('the_zone' => $zone, 'the_page' => $file, 'p_parent_page' => $parent_page, 'p_validated' => $is_validated, 'p_edit_date' => NULL, 'p_add_date' => strtotime($post['post_date']), 'p_submitter' => $member_id, 'p_show_as_edit' => 0)); if (!file_exists($fullpath)) { $_content = html_to_comcode($post['post_content']); $myfile = @fopen($fullpath, 'wt'); if ($myfile === false) { intelligent_write_error($fullpath); } if (fwrite($myfile, $_content) < strlen($_content)) { warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE')); } fclose($myfile); sync_file($fullpath); } require_code('seo2'); seo_meta_set_for_explicit('comcode_page', $zone . ':' . $file, post_param('meta_keywords', ''), post_param('meta_description', '')); require_code('permissions2'); set_page_permissions_from_environment($zone, $file); } $content_url = build_url(array('page' => 'news', 'type' => 'view', 'id' => $id), get_module_zone('news'), NULL, false, false, true); $content_title = $post['post_title']; // Add comments if (post_param_integer('wp_import_blog_comments', 0) == 1) { if (array_key_exists('COMMENTS', $post)) { $submitter = NULL; foreach ($post['COMMENTS'] as $comment) { $submitter = $GLOBALS['FORUM_DB']->query_value_null_ok('f_members', 'id', array('m_username' => $comment['comment_author'])); if (is_null($submitter)) { $submitter = $GLOBALS['FORUM_DRIVER']->get_guest_id(); } // If comment is made by a non-member, assign comment to guest account $forum = is_null(get_value('comment_forum__news')) ? get_option('comments_forum_name') : get_value('comment_forum__news'); $result = $GLOBALS['FORUM_DRIVER']->make_post_forum_topic($forum, 'news_' . strval($id), $submitter, $post['post_title'], $comment['comment_content'], $content_title, do_lang('COMMENT'), $content_url, NULL, NULL, 1, 1, false); } } } } } } }
/** * The actualiser to import wordpress blog * * @return tempcode The UI */ function _import_wordpress() { check_specific_permission('mass_import', NULL, NULL, 'cms_news'); $title = get_page_title('IMPORT_WP_DB'); require_code('rss'); require_code('news'); require_code('news2'); $GLOBALS['LAX_COMCODE'] = true; require_code('uploads'); is_swf_upload(true); $is_validated = post_param_integer('wp_auto_validate', 0); $to_own_account = post_param_integer('wp_add_to_own', 0); //Wordpress post xml file importing method if (get_param('method') == 'xml') { $rss_url = post_param('xml_url', NULL); if (array_key_exists('file_novalidate', $_FILES)) { if (is_swf_upload(true) && array_key_exists('file_novalidate', $_FILES) || array_key_exists('file_novalidate', $_FILES) && is_uploaded_file($_FILES['file_novalidate']['tmp_name'])) { $rss_url = $_FILES['file_novalidate']['tmp_name']; } else { warn_exit(do_lang_tempcode('IMPROPERLY_FILLED_IN')); } } else { warn_exit(do_lang_tempcode('IMPROPERLY_FILLED_IN')); } $rss = new rss($rss_url, true); if (!is_null($rss->error)) { warn_exit($rss->error); } $cat_id = NULL; $NEWS_CATS = $GLOBALS['SITE_DB']->query_select('news_categories', array('*'), array('nc_owner' => NULL)); $NEWS_CATS = list_to_map('id', $NEWS_CATS); $extra_post_data = array(); foreach ($rss->gleamed_items as $item) { if (!array_key_exists('category', $item)) { $item['category'] = do_lang('NC_general'); } $extra_post_data[] = $item; foreach ($NEWS_CATS as $_cat => $news_cat) { if (get_translated_text($news_cat['nc_title']) == $item['category']) { $cat_id = $_cat; } } //Check for existing owner categories, if not create blog category for creator if ($to_own_account == 0) { $creator = $item['author']; $submitter_id = $GLOBALS['FORUM_DRIVER']->get_member_from_username($creator); } else { $submitter_id = get_member(); } //if(is_null($submitter_id)) continue; //Skip importing posts of nonexisting users $owner_category_id = $GLOBALS['SITE_DB']->query_value_null_ok('news_categories', 'id', array('nc_owner' => $submitter_id)); if (is_null($cat_id)) { $cat_id = add_news_category($item['category'], 'newscats/general', '', NULL); $NEWS_CATS = $GLOBALS['SITE_DB']->query_select('news_categories', array('*'), array('nc_owner' => NULL)); $NEWS_CATS = list_to_map('id', $NEWS_CATS); } // Add news add_news($item['title'], html_to_comcode($item['news']), NULL, $is_validated, 1, 1, 1, '', array_key_exists('news_article', $item) ? html_to_comcode($item['news_article']) : '', $owner_category_id, array($cat_id), NULL, $submitter_id, 0, time(), NULL, ''); } if (url_is_local($rss_url)) { // Means it is a temp file @unlink($rss_url); } } elseif (get_param('method') == 'db') { import_wordpress_db(); } breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('MANAGE_BLOGS')), array('_SELF:_SELF:import_wordpress', do_lang_tempcode('IMPORT_WORDPRESS')))); breadcrumb_set_self(do_lang_tempcode('DONE')); return inform_screen($title, do_lang_tempcode('IMPORT_WORDPRESS_DONE')); }
/** * Standard import function. * * @param object The DB connection to import from * @param string The table prefix the target prefix is using * @param PATH The base directory we are importing from */ function import_cedi($db, $table_prefix, $old_base_dir) { require_code('cedi'); $root_cat = db_get_first_id(); $rows = $db->query('SELECT * FROM ' . $table_prefix . 'encyclopedia'); $page_id_remap = array(); foreach ($rows as $i => $row) { $id = $GLOBALS['SITE_DB']->query_insert('seedy_pages', array('notes' => '', 'description' => insert_lang_comcode(html_to_comcode($row['description']), 2), 'add_date' => time(), 'title' => insert_lang($row['title'], 1), 'seedy_views' => 0, 'hide_posts' => 0), true); $page_id_remap[$row['eid']] = $id; $GLOBALS['SITE_DB']->query_insert('seedy_children', array('parent_id' => $root_cat, 'child_id' => $id, 'the_order' => $i, 'title' => $row['title'])); } $rows = $db->query('SELECT * FROM ' . $table_prefix . 'encyclopedia_text'); foreach ($rows as $i => $row) { $row['date'] = time(); $id = $GLOBALS['SITE_DB']->query_insert('seedy_pages', array('notes' => '', 'description' => insert_lang_comcode(html_to_comcode($row['text']), 2), 'add_date' => time(), 'title' => insert_lang($row['title'], 2), 'seedy_views' => 0, 'hide_posts' => 0), true); $GLOBALS['SITE_DB']->query_insert('seedy_children', array('parent_id' => $page_id_remap[$row['eid']], 'child_id' => $id, 'the_order' => $i, 'title' => $row['title'])); } }
/** * Standard import function. * * @param object The DB connection to import from * @param string The table prefix the target prefix is using * @param PATH The base directory we are importing from */ function import_reviews($db, $table_prefix, $old_base_dir) { require_code('menus2'); //check is the comment forum configured in ocPortal $this->test_for_comments_forum(); //include calatogue lib require_code('catalogues2'); // Can we comment the news? $com = 1; //get comments forum name $forum_name = get_option('comments_forum_name'); ocf_over_msn(); //used to fixed the correct forum prefix $forum_id = $GLOBALS['FORUM_DRIVER']->forum_id_from_name($forum_name); ocf_over_local(); //used to fixed the correct forum prefix //get specific reviews fields $catalogues = $db->query('SELECT * FROM ' . $table_prefix . 'reviews_sections'); $include_reviews_link = false; //include reviews link only once //go through all of the reviews sections foreach ($catalogues as $catalogue) { //make catalogue lang string $catalogue_name = strtoupper(preg_replace('#^[\\_\\.\\-]#', 'x', preg_replace('#[^\\w\\.\\-]#', '_', 'review_' . $catalogue['title']))); $catalogue['title'] = @html_entity_decode($catalogue['title'], ENT_QUOTES, get_charset()); $specific_fields = array(); // Add reviews catalogue if it doesn't already exist $current_review_catalogue = $GLOBALS['SITE_DB']->query_value_null_ok('catalogues', 'c_name', array('c_name' => strtolower($catalogue_name))); if (is_null($current_review_catalogue)) { $current_review_catalogue = actual_add_catalogue(strtolower($catalogue_name), $catalogue['title'], '', 0, 0, '', 30); $fields = array(array(do_lang('REVIEW_TITLE'), '', 'short_trans', 0, 1), array(do_lang('REVIEW_DESCRIPTION'), '', 'long_trans', 1, 1), array(do_lang('REVIEW_IMAGE'), '', 'picture', 0, 1), array(do_lang('REVIEW_REVIEW'), '', 'long_trans', 0, 1)); $specific_fields = array(); //add review/catalogue specific fields for ($i = 1; $i < 7; $i++) { if (strlen($catalogue['field' . strval($i)]) > 0) { //make lang string $lang_string = strtoupper(preg_replace('#^[\\_\\.\\-]#', 'x', preg_replace('#[^\\w\\.\\-]#', '_', $catalogue['field' . strval($i)]))); $lang_string = do_lang($lang_string, NULL, NULL, NULL, NULL, false); if (is_null($lang_string)) { $lang_string = $catalogue['field' . strval($i)]; } $fields[] = array($lang_string, '', 'long_trans', 0, 1); $specific_fields[] = $i; } } //add fields to catalogue foreach ($fields as $i => $field) { actual_add_catalogue_field(strtolower($catalogue_name), $field[0], '', $field[2], $i, $field[3], 1, 1, '', $field[4]); } } //import current reviews category $review_category_id = actual_add_catalogue_category(strtolower($catalogue_name), $catalogue['title'], '', '', NULL, ''); //include reviews link in main features menu if (!$include_reviews_link) { add_menu_item_simple('main_features', NULL, 'REVIEWS', 'site:catalogues:category:' . strval($review_category_id)); add_menu_item_simple('main_features', NULL, 'REVIEWS', 'site:catalogues:index:' . strtolower($catalogue_name)); $include_reviews_link = true; } $remappped_fields = collapse_1d_complexity('id', $GLOBALS['SITE_DB']->query_select('catalogue_fields', array('id'), array('c_name' => strtolower($catalogue_name)))); //select all reviews for current review catalogue $rows = $db->query('SELECT r.id AS review_id, r.title AS review_title, r.description AS review_description, r.field1 AS rf1, r.field2 AS rf2, r.field3 AS rf3, r.field4 AS rf4, r.field5 AS rf5, r.field6 AS rf6, r.field7 AS rf7, r.*, rc.title AS rc_title, rc.description AS rc_description, rc.field1 AS rcf1, rc.field2 AS rcf2, rc.field3 AS rcf3, rc.field4 AS rcf4, rc.field5 AS rcf5, rc.field6 AS rcf6, rc.field7 AS rcf7, rc.* FROM ' . $table_prefix . 'reviews r LEFT JOIN ' . $table_prefix . 'reviews_sections rc ON r.id_cat=rc.id WHERE r.id_cat=' . strval($catalogue['id'])); foreach ($rows as $row) { ocf_over_msn(); //used to fixed the correct forum prefix $map = array($remappped_fields[0] => html_to_comcode($row['review_title']), $remappped_fields[1] => html_to_comcode($row['review_description']), $remappped_fields[2] => $row['image'], $remappped_fields[3] => html_to_comcode($row['review'])); $map_next_ind = count($map); foreach ($specific_fields as $field_num) { if (!isset($remappped_fields[$map_next_ind])) { break; } // Don't want to import non-used fields $map[$remappped_fields[$map_next_ind]] = html_to_comcode($row['rf' . strval($field_num + 1)]); $map_next_ind++; } $new_id = actual_add_catalogue_entry($review_category_id, $row['validate'], '', 0, 0, 0, $map, $row['date'], $GLOBALS['FORUM_DRIVER']->get_member_from_username($row['author']), NULL, $row['click']); ocf_over_local(); //used to fixed the correct forum prefix //import rating too $this->_import_ratings($db, 'catalogues', $row['id'], $new_id, $row['rate'], $table_prefix); // Comments $comments = $db->query('SELECT * FROM ' . $table_prefix . 'reviews_comments WHERE id=' . strval($row['review_id']) . ' ORDER BY data'); if (!is_null($forum_id)) { foreach ($comments as $comment) { $member = $comment['id_autore']; //$GLOBALS['FORUM_DRIVER']->get_member_from_username($comment['userid']); ocf_over_msn(); //used to fixed the correct forum prefix if (is_null($member)) { $member = $GLOBALS['FORUM_DRIVER']->get_guest_id(); } ocf_over_local(); //used to fixed the correct forum prefix $title = $row['review_title']; $post = $comment['testo']; $content_url = build_url(array('page' => 'catalogues', 'id' => $new_id, 'type' => 'view'), get_module_zone('catalogues')); ocf_over_msn(); //used to fixed the correct forum prefix $GLOBALS['FORUM_DRIVER']->make_post_forum_topic($forum_name, 'reviews_' . strval($new_id), $member, $title, html_to_comcode($post), $row['review_title'], do_lang('COMMENT'), $content_url->evaluate()); ocf_over_local(); //used to fixed the correct forum prefix } } } } }
/** * Standard import function. * * @param object The DB connection to import from * @param string The table prefix the target prefix is using * @param PATH The base directory we are importing from */ function import_ocf_posts($db, $table_prefix, $file_base) { global $STRICT_FILE; $row_start = 0; $rows = array(); do { $rows = $db->query('SELECT * FROM ' . $table_prefix . 'posts ORDER BY pid', 200, $row_start); foreach ($rows as $row) { if (get_param_integer('keep_import_test', 0) == 1 && $row['new_topic'] == 0) { continue; } if (import_check_if_imported('post', strval($row['pid']))) { continue; } $topic_id = import_id_remap_get('topic', strval($row['topic_id']), true); if (is_null($topic_id)) { import_id_remap_put('post', strval($row['pid']), -1); continue; } $member_id = import_id_remap_get('member', strval($row['author_id']), true); if (is_null($member_id)) { $member_id = db_get_first_id(); } // This speeds up addition... using the cache can reduce about 7/8 of a query per post on average global $TOPIC_FORUM_CACHE; if (array_key_exists($topic_id, $TOPIC_FORUM_CACHE)) { $forum_id = $TOPIC_FORUM_CACHE[$topic_id]; } else { $forum_id = $GLOBALS['FORUM_DB']->query_value_null_ok('f_topics', 't_forum_id', array('id' => $topic_id)); if (is_null($forum_id)) { continue; } $TOPIC_FORUM_CACHE[$topic_id] = $forum_id; } $title = ''; if ($row['new_topic'] == 1) { $topics = $db->query('SELECT * FROM ' . $table_prefix . 'topics WHERE tid=' . strval($row['topic_id'])); $title = strip_tags(@html_entity_decode($topics[0]['title'], ENT_QUOTES, get_charset())); } elseif (!is_null($row['post_title'])) { $title = @html_entity_decode($row['post_title'], ENT_QUOTES, get_charset()); } ocf_over_msn(); $post = html_to_comcode($this->clean_ipb_post_2($row['post'])); ocf_over_local(); $last_edit_by = NULL; if (!is_null($row['edit_name'])) { $last_edit_by = $GLOBALS['OCF_DRIVER']->get_member_from_username(@html_entity_decode($row['edit_name'], ENT_QUOTES, get_charset())); } if (either_param('importer') == 'ipb2') { $post = str_replace('style_emoticons/<#EMO_DIR#>', '[/html]{$BASE_URL}[html]/data/legacy_emoticons', $post); $end = 0; while (($pos = strpos($post, '[right]')) !== false) { $e_pos = strpos($post, '[/right]', $pos); if ($e_pos === false) { break; } $end = $e_pos + strlen('[/right]'); $segment = substr($post, $pos, $end - $pos); global $LAX_COMCODE; $temp = $LAX_COMCODE; $LAX_COMCODE = true; $_comcode = comcode_to_tempcode($segment, $member_id); $LAX_COMCODE = $temp; $comcode = $_comcode->evaluate(); $comcode = str_replace($comcode, get_base_url(), '{$BASE_URL}'); $post = substr($post, 0, $pos) . $comcode . substr($post, $end); } } $id_new = ocf_make_post($topic_id, $title, $post, 0, $row['new_topic'] == 1, 1 - $row['queued'], 0, @html_entity_decode($row['author_name'], ENT_QUOTES, get_charset()), $row['ip_address'], $row['post_date'], $member_id, NULL, $row['edit_time'], $last_edit_by, false, false, $forum_id, false); import_id_remap_put('post', strval($row['pid']), $id_new); } $row_start += 200; } while (count($rows) > 0); }
/** * Standard import function. * * @param object The DB connection to import from * @param string The table prefix the target prefix is using * @param PATH The base directory we are importing from */ function import_calendar($db, $table_prefix, $file_base) { require_code('calendar2'); $rows = $db->query_select('calendar'); foreach ($rows as $row) { if (import_check_if_imported('event', strval($row['ID_EVENT']))) { continue; } $submitter = import_id_remap_get('member', strval($row['ID_MEMBER']), true); if (is_null($submitter)) { $submitter = $GLOBALS['OCF_DRIVER']->get_guest_id(); } $recurrence = 'none'; $recurrences = NULL; $days = intval(floor((strtotime($row['endDate']) - strtotime($row['startDate'])) / (60 * 60 * 24))); //Max 7 days in SMF if ($days == 0) { $recurrence = 'daily 1'; } else { $recurrence = 'daily '; for ($i = 1; $i <= $days; $i++) { $recurrence .= '1'; } } $start_hour = 0; $start_minute = 0; list($start_year, $start_month, $start_day) = array_map('intval', explode('-', $row['eventDate'])); list($end_year, $end_month, $end_day, $end_hour, $end_minute) = array($start_year, $start_month, $start_day, $start_hour, $start_minute); $description = ''; if ($row['ID_TOPIC'] != 0) { $messages = $db->query('SELECT * FROM ' . $table_prefix . 'messages WHERE ID_TOPIC=' . strval($row['ID_TOPIC']) . ' ORDER BY ID_TOPIC ASC'); ocf_over_msn(); $description = isset($messages[0]['body']) && $messages[0]['body'] != '' ? html_to_comcode($messages[0]['body']) : ''; ocf_over_local(); } ocf_over_msn(); $id_new = add_calendar_event(db_get_first_id() + 1, $recurrence, $recurrences, 0, $row['title'], $description, 3, 1, $start_year, $start_month, $start_day, $start_hour, $start_minute, $end_year, $end_month, $end_day, $end_hour, $end_minute, NULL, 1, 1, 1, 1, 1, '', $submitter); ocf_over_local(); import_id_remap_put('event', strval($row['ID_EVENT']), $id_new); } $rows = array(); $rows = $db->query_select('calendar_holidays'); foreach ($rows as $row) { if (import_check_if_imported('event', strval($row['ID_HOLIDAY']))) { continue; } $submitter = $GLOBALS['OCF_DRIVER']->get_guest_id(); $recurrence = 'none'; $recurrences = NULL; list($start_year, $start_month, $start_day, $start_hour, $start_minute) = array_map('intval', explode('-', date('Y-m-d-h-i', strtotime($row['eventDate'])))); list($end_year, $end_month, $end_day, $end_hour, $end_minute) = array_map('intval', explode('-', date('Y-m-d-h-i', strtotime($row['eventDate'])))); ocf_over_msn(); $id_new = add_calendar_event(db_get_first_id() + 1, $recurrence, $recurrences, 0, $row['title'], $row['title'], 3, 1, $start_year, $start_month, $start_day, $start_hour, $start_minute, $end_year, $end_month, $end_day, $end_hour, $end_minute, NULL, 1, 1, 1, 1, 1, '', $submitter); ocf_over_local(); import_id_remap_put('event', strval($row['ID_HOLIDAY']), $id_new); } }
/** * Standard import function. * * @param object The DB connection to import from * @param string The table prefix the target prefix is using * @param PATH The base directory we are importing from */ function import_ocf_forums($db, $table_prefix, $old_base_dir) { require_code('ocf_forums_action2'); $rows = $db->query('SELECT * FROM ' . $table_prefix . 'forums'); foreach ($rows as $row) { $remapped = import_id_remap_get('forum', strval($row['forum_id']), true); if (!is_null($remapped)) { continue; } if ($row['forum_type'] == 0) { $id_new = ocf_make_category($row['forum_name'], '', 1); import_id_remap_put('forum', strval($row['forum_id']), $id_new); continue; } $name = $row['forum_name']; $description = html_to_comcode($row['forum_desc']); $position = 1; $post_count_increment = 1; $category_id = db_get_first_id(); $parent_forum = db_get_first_id(); $rules = $this->fix_links($row['forum_rules'], $row['forum_rules_uid'], $db, $table_prefix); if ($row['forum_rules_link'] != '') { if ($rules != '') { $rules .= chr(10) . chr(10); } $rules .= '[url]' . $row['forum_rules_link'] . '[/url]'; } $answer = $row['forum_password']; if ($rules == '' && $answer != '') { $rules = do_lang('FORUM_PASSWORD_TO_INTRO_QUESTION'); } $id_new = ocf_make_forum($name, $description, $category_id, NULL, $parent_forum, $position, $post_count_increment, 0, $rules, $answer, $row['forum_link']); $permissions = $db->query('SELECT * FROM ' . $table_prefix . 'acl_groups WHERE forum_id=' . strval((int) $row['forum_id'])); foreach ($permissions as $p) { $group_id = import_id_remap_get('group', strval($p['group_id']), true); if (is_null($group_id)) { continue; } // maybe bots group (6) if ($p['auth_role_id'] != 0) { $rp = $db->query('SELECT * FROM ' . $table_prefix . 'acl_roles_data WHERE role_id=' . strval($p['auth_role_id'])); foreach ($rp as $_p) { $this->_import_perm($db, $table_prefix, $_p['auth_option_id'], $group_id, $id_new, $_p['auth_setting']); } } else { $this->_import_perm($db, $table_prefix, $p['auth_option_id'], $group_id, $id_new, $p['auth_setting']); } } import_id_remap_put('forum', strval($row['forum_id']), $id_new); } foreach ($rows as $row) { if ($row['forum_type'] == 1) { $remapped = import_id_remap_get('forum', strval($row['forum_id'])); list($cat_id, $parent_id) = $this->_find_parent_forum_and_category($rows, $row['parent_id']); $parent_forum = is_null($parent_id) ? db_get_first_id() : import_id_remap_get('forum', strval($parent_id)); $cat = is_null($cat_id) ? db_get_first_id() : import_id_remap_get('forum', strval($cat_id)); $GLOBALS['FORUM_DB']->query_update('f_forums', array('f_category_id' => $cat, 'f_parent_forum' => $parent_forum), array('id' => $remapped), '', 1); } } }
/** * The actualiser to import news * * @return tempcode The UI */ function _import_news() { check_specific_permission('mass_import'); $title = get_page_title('IMPORT_NEWS'); require_code('rss'); require_code('news'); require_code('files'); $GLOBALS['LAX_COMCODE'] = true; disable_php_memory_limit(); $rss_url = post_param('rss_feed_url', NULL); require_code('uploads'); if (is_swf_upload(true) && array_key_exists('file_novalidate', $_FILES) || array_key_exists('file_novalidate', $_FILES) && is_uploaded_file($_FILES['file_novalidate']['tmp_name'])) { $rss_url = $_FILES['file_novalidate']['tmp_name']; } if (is_null($rss_url)) { warn_exit(do_lang_tempcode('IMPROPERLY_FILLED_IN')); } $is_validated = post_param_integer('auto_validate', 0); $download_images = post_param_integer('download_images', 0); $rss = new rss($rss_url, true); if (!is_null($rss->error)) { warn_exit($rss->error); } $submitter = get_member(); $NEWS_CATS = $GLOBALS['SITE_DB']->query_select('news_categories', array('*'), array('nc_owner' => NULL)); $NEWS_CATS = list_to_map('id', $NEWS_CATS); $extra_post_data = array(); foreach ($rss->gleamed_items as $i => $item) { if (!array_key_exists('category', $item)) { $item['category'] = do_lang('NC_general'); } $extra_post_data[] = $item; $cats_to_process = array($item['category']); if (array_key_exists('extra_categories', $item)) { $cats_to_process = array_merge($cats_to_process, $item['extra_categories']); } $cat_id = mixed(); $extra_categories = array(); foreach ($cats_to_process as $j => $cat) { $_cat_id = mixed(); foreach ($NEWS_CATS as $_cat => $news_cat) { if (get_translated_text($news_cat['nc_title']) == $cat) { $_cat_id = $_cat; } } if (is_null($_cat_id)) { $_cat_id = add_news_category($cat, 'newscats/general', '', NULL); // Need to reload now $NEWS_CATS = $GLOBALS['SITE_DB']->query_select('news_categories', array('*'), array('nc_owner' => NULL)); $NEWS_CATS = list_to_map('id', $NEWS_CATS); } if ($j == 0) { $cat_id = $_cat_id; } else { $extra_categories[] = $_cat_id; } } $rep_image = ''; if (array_key_exists('rep_image', $item)) { $rep_image = $item['rep_image']; if ($download_images == 1) { $stem = 'uploads/grepimages/' . basename(urldecode($rep_image)); $target_path = get_custom_file_base() . '/' . $stem; $rep_image = 'uploads/grepimages/' . basename($rep_image); while (file_exists($target_path)) { $uniqid = uniqid(''); $stem = 'uploads/grepimages/' . $uniqid . '_' . basename(urldecode($rep_image)); $target_path = get_custom_file_base() . '/' . $stem; $rep_image = 'uploads/grepimages/' . $uniqid . '_' . basename($rep_image); } $target_handle = fopen($target_path, 'wb') or intelligent_write_error($target_path); $result = http_download_file($item['rep_image'], NULL, false, false, 'ocPortal', NULL, NULL, NULL, NULL, NULL, $target_handle); fclose($target_handle); } } // Add news $ts = array_key_exists('clean_add_date', $item) ? $item['clean_add_date'] : (array_key_exists('add_date', $item) ? strtotime($item['add_date']) : time()); if ($ts === false) { $ts = time(); } // Seen in error email, it's if the add date won't parse by PHP $edit_date = array_key_exists('clean_edit_date', $item) ? $item['clean_edit_date'] : (array_key_exists('edit_date', $item) ? strtotime($item['edit_date']) : NULL); if ($edit_date === false) { $edit_date = NULL; } $news = array_key_exists('news', $item) ? html_to_comcode($item['news']) : ''; $news_article = array_key_exists('news_article', $item) ? html_to_comcode($item['news_article']) : ''; $news_id = add_news($item['title'], $news, array_key_exists('author', $item) ? $item['author'] : $GLOBALS['FORUM_DRIVER']->get_username(get_member()), $is_validated, 1, 1, 1, '', $news_article, $cat_id, $extra_categories, $ts, $submitter, 0, $edit_date, NULL, $rep_image); $rss->gleamed_items[$i]['import_id'] = $news_id; $rss->gleamed_items[$i]['import__news'] = $news; $rss->gleamed_items[$i]['import__news_article'] = $news_article; } foreach ($rss->gleamed_items as $i => $item) { $news = $item['import__news']; $news_article = $item['import__news_article']; $this->_grab_images_and_fix_links($download_images == 1, $news, $rss->gleamed_items); $this->_grab_images_and_fix_links($download_images == 1, $news_article, $rss->gleamed_items); lang_remap_comcode($GLOBALS['SITE_DB']->query_value('news', 'news', array('id' => $item['import_id'])), $news); lang_remap_comcode($GLOBALS['SITE_DB']->query_value('news', 'news_article', array('id' => $item['import_id'])), $news_article); } breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('MANAGE_NEWS')), array('_SELF:_SELF:import', do_lang_tempcode('IMPORT_NEWS')))); breadcrumb_set_self(do_lang_tempcode('DONE')); if (url_is_local($rss_url)) { // Means it is a temp file @unlink($rss_url); } return inform_screen($title, do_lang_tempcode('IMPORT_NEWS_DONE')); }
/** * Standard import function. * * @param object The DB connection to import from * @param string The table prefix the target prefix is using * @param PATH The base directory we are importing from */ function import_ocf_forums($db, $table_prefix, $old_base_dir) { require_code('ocf_forums_action2'); $rows = $db->query('SELECT * FROM ' . $table_prefix . 'forums WHERE ' . db_string_equal_to('type', 'f')); foreach ($rows as $row) { $remapped = import_id_remap_get('forum', strval($row['fid']), true); if (!is_null($remapped)) { continue; } $name = $row['name']; ocf_over_msn(); $description = html_to_comcode($row['description']); ocf_over_local(); $position = $row['disporder']; $post_count_increment = 1; $parentlist = explode(',', $row['parentlist']); $cat_id = $parentlist[0]; $category_id = import_id_remap_get('category', $cat_id, true); end($parentlist); $prev = prev($parentlist); $parent_forum = $prev != $parentlist[0] ? intval($prev) : db_get_first_id(); $access_mapping = array(); if ($row['status'] == 1) { $permissions = $db->query('SELECT * FROM ' . $table_prefix . 'forumpermissions WHERE fid=' . strval((int) $row['fid'])); foreach ($permissions as $p) { $v = 0; if ($p['canpostthreads'] == 1) { $v = 2; } if ($p['canpostreplys'] == 1) { $v = 3; } if ($p['canpostpolls'] == 1) { $v = 4; } $group_id = import_id_remap_get('group', strval($p['gid'])); $access_mapping[$group_id] = $v; } } $id_new = ocf_make_forum($name, $description, $category_id, $access_mapping, $parent_forum, $position, $post_count_increment, 0, ''); import_id_remap_put('forum', strval($row['fid']), $id_new); } }