function setUp() { parent::setUp(); require_code('ocf_members_action'); require_code('ocf_members_action2'); require_lang('ocf'); $this->user_id = ocf_make_member('testuser', '123456', '*****@*****.**', array(), 10, 1, 1980, array(), NULL, NULL, 1, NULL, NULL, '', NULL, '', 0, 0, 1, '', '', '', 1, 1, NULL, 1, 1, '', NULL, '', true, NULL, '', 1, NULL, NULL, 0, '*', ''); // Test the forum was actually created $this->assertTrue('testuser' == $GLOBALS['FORUM_DB']->query_value('f_members', 'm_username', array('id' => $this->user_id))); }
/** * 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_members($db, $table_prefix, $file_base) { if ($this->on_same_msn($file_base)) { return; } $cpf_types = collapse_2d_complexity('id', 'cf_type', $GLOBALS['FORUM_DB']->query_select('f_custom_fields', array('id', 'cf_type'))); $row_start = 0; $rows = array(); do { $rows = $db->query('SELECT * FROM ' . $table_prefix . 'f_members ORDER BY id', 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['m_username']); if (!is_null($test)) { // Fix usergroup leadership $GLOBALS['FORUM_DB']->query_update('f_groups', array('g_group_leader' => $test), array('g_group_leader' => -$row['id'])); import_id_remap_put('member', strval($row['id']), $test); continue; } $primary_group = import_id_remap_get('group', strval($row['m_primary_group'])); $custom_fields = array(); $id = get_param_integer('keep_preserve_ids', 0) == 0 ? NULL : $row['id']; $timezone = $row['m_timezone_offset']; if (is_integer($timezone)) { $timezone = strval($timezone); } if (!isset($row['m_auto_monitor_contrib_content'])) { $row['m_auto_monitor_contrib_content'] = $row['m_track_contributed_topics']; } $id_new = ocf_make_member($row['m_username'], $row['m_pass_hash_salted'], $row['m_email_address'], NULL, $row['m_dob_day'], $row['m_dob_month'], $row['m_dob_year'], $custom_fields, $timezone, $primary_group, $row['m_validated'], $row['m_join_time'], $row['m_last_visit_time'], $row['m_theme'], $row['m_avatar_url'], $this->get_lang_string($db, $row['m_signature']), $row['m_is_perm_banned'], $row['m_preview_posts'], $row['m_reveal_age'], $row['m_title'], $row['m_photo_url'], $row['m_photo_thumb_url'], $row['m_views_signatures'], $row['m_auto_monitor_contrib_content'], $row['m_language'], $row['m_allow_emails'], array_key_exists('m_allow_emails_from_staff', $row) ? $row['m_allow_emails_from_staff'] : $row['m_allow_emails'], $row['m_notes'], $row['m_ip_address'], $row['m_validated_email_confirm_code'], false, array_key_exists('m_password_compat_scheme', $row) ? $row['m_password_compat_scheme'] : $row['m_password_compatibility_scheme'], $row['m_pass_salt'], $row['m_zone_wide'], $row['m_last_submit_time'], $id, array_key_exists('m_highlighted_name', $row) ? $row['m_highlighted_name'] : 0, array_key_exists('m_pt_allow', $row) ? $row['m_pt_allow'] : '*', array_key_exists('m_pt_rules_text', $row) ? $this->get_lang_string($db, $row['m_pt_rules_text']) : ''); $rows2 = $db->query('SELECT * FROM ' . $table_prefix . 'f_member_custom_fields WHERE mf_member_id=' . strval((int) $row['id']), 1); if (array_key_exists(0, $rows2)) { $row2 = array(); foreach ($rows2[0] as $key => $val) { if (is_null($val)) { $val = ''; } if (substr($key, 0, 6) == 'field_') { $cpf_id = import_id_remap_get('cpf', substr($key, 6), true); if (is_null($cpf_id)) { continue; } $cpf_type = $cpf_types[$cpf_id]; if ($cpf_type == 'short_trans' || $cpf_type == 'long_trans') { $val = strval(insert_lang($this->get_lang_string($db, intval($val)), 3)); } $row2['field_' . strval($cpf_id)] = $val; } } $GLOBALS['SITE_DB']->query_update('f_member_custom_fields', $row2, array('mf_member_id' => $id_new), '', 1); } // Fix some tricky dependences that we shoved to one side $GLOBALS['FORUM_DB']->query_update('f_groups', array('g_group_leader' => $id_new), array('g_group_leader' => -$row['id'])); $GLOBALS['SITE_DB']->query_update('attachments', array('a_member_id' => $id_new), array('a_member_id' => -$row['id'])); import_id_remap_put('member', strval($row['id']), $id_new); } $row_start += 200; } while (count($rows) > 0); // Group membership $rows = $db->query('SELECT * FROM ' . $table_prefix . 'f_group_members'); foreach ($rows as $row) { $row['gm_group_id'] = import_id_remap_get('group', strval($row['gm_group_id']), true); if (is_null($row['gm_group_id'])) { continue; } $row['gm_member_id'] = import_id_remap_get('member', strval($row['gm_member_id']), true); if (is_null($row['gm_member_id'])) { continue; } $GLOBALS['SITE_DB']->query_insert('f_group_members', $row, false, true); } // Known login IPs $rows = $db->query('SELECT * FROM ' . $table_prefix . 'f_member_known_login_ips'); foreach ($rows as $row) { $row['i_member_id'] = import_id_remap_get('member', strval($row['i_member_id']), true); if (is_null($row['i_member_id'])) { continue; } $GLOBALS['SITE_DB']->query_insert('f_member_known_login_ips', $row); } // Group member timeouts $rows = $db->query('SELECT * FROM ' . $table_prefix . 'f_group_member_timeouts'); foreach ($rows as $row) { $member_id = import_id_remap_get('member', strval($row['member_id'])); if (is_null($member_id)) { continue; } $group_id = import_id_remap_get('group', strval($row['group_id'])); if (is_null($group_id)) { continue; } $GLOBALS['SITE_DB']->query_insert('f_group_member_timeouts', array('member_id' => $member_id, 'group_id' => $group_id, 'timeout' => $row['timeout'])); } // Invites $rows = $db->query('SELECT * FROM ' . $table_prefix . 'f_invites ORDER BY id', NULL, NULL, true); if (!is_null($rows)) { foreach ($rows as $row) { $i_inviter = import_id_remap_get('member', strval($row['i_inviter']), true); if (is_null($i_inviter)) { continue; } $GLOBALS['SITE_DB']->query_insert('f_invites', array('i_inviter' => $i_inviter, 'i_email_address' => $row['i_email_address'], 'i_time' => $row['i_time'], 'i_taken' => $row['i_taken']), false, true); } } }
/** * 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); }
/** * 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_members($db, $table_prefix, $file_base) { $default_group = get_first_default_group(); $row_start = 0; $rows = array(); do { $rows = $db->query('SELECT * FROM ' . $table_prefix . 'users u LEFT JOIN ' . $table_prefix . 'banlist b ON u.user_id=b.ban_userid WHERE u.user_id<>-1 ORDER BY u.user_id', 200, $row_start); foreach ($rows as $row) { if (import_check_if_imported('member', strval($row['user_id']))) { continue; } $test = $GLOBALS['OCF_DRIVER']->get_member_from_username($row['username']); if (!is_null($test)) { import_id_remap_put('member', strval($row['user_id']), $test); continue; } $language = ''; if ($row['user_lang'] != '') { switch ($language) { case 'english': $language = 'EN'; break; } } $primary_group = $default_group; $rows2 = $db->query('SELECT * FROM ' . $table_prefix . 'user_group WHERE user_id=' . strval((int) $row['user_id']), 200, $row_start); $secondary_groups = array(); foreach ($rows2 as $row2) { $g = import_id_remap_get('group', strval($row2['group_id']), true); if (!is_null($g)) { $secondary_groups[] = array($g, $row2['user_pending']); } } if ($row['user_level'] == 1) { $secondary_groups[] = array(db_get_first_id() + 1, 0); } $custom_fields = array(ocf_make_boiler_custom_field('im_icq') => $row['user_icq'], ocf_make_boiler_custom_field('im_aim') => $row['user_aim'], ocf_make_boiler_custom_field('im_msn') => $row['user_msnm'], ocf_make_boiler_custom_field('im_yahoo') => $row['user_yim'], ocf_make_boiler_custom_field('interests') => $row['user_interests'], ocf_make_boiler_custom_field('location') => $row['user_from'], ocf_make_boiler_custom_field('occupation') => $row['user_occ']); if ($row['user_website'] != '') { $custom_fields[ocf_make_boiler_custom_field('website')] = strlen($row['user_website']) > 0 ? '[url]' . $row['user_website'] . '[/url]' : ''; } $signature = $this->fix_links($row['user_sig'], $db, $table_prefix); $validated = $row['user_active']; $reveal_age = 0; list($bday_day, $bday_month, $bday_year) = array(NULL, NULL, NULL); $views_signatures = 1; $preview_posts = 1; $track_posts = $row['user_notify']; $title = ''; // These are done in the members-files stage $avatar_url = ''; $photo_url = ''; $photo_thumb_url = ''; $password = $row['user_password']; $type = 'md5'; $salt = ''; $id_new = ocf_make_member($row['username'], $password, $row['user_email'], NULL, $bday_day, $bday_month, $bday_year, $custom_fields, strval($row['user_timezone']), $primary_group, $validated, $row['user_regdate'], $row['user_lastvisit'], '', $avatar_url, $signature, !is_null($row['ban_id']) ? 1 : 0, $preview_posts, $reveal_age, $title, $photo_url, $photo_thumb_url, $views_signatures, $track_posts, $language, $row['user_allow_pm'], 1, '', '', '', false, $type, $salt, 1); // Fix usergroup leadership $GLOBALS['FORUM_DB']->query_update('f_groups', array('g_group_leader' => $id_new), array('g_group_leader' => -$row['user_id'])); import_id_remap_put('member', strval($row['user_id']), $id_new); // Set up usergroup membership foreach ($secondary_groups as $s) { list($group, $userpending) = $s; ocf_add_member_to_group($id_new, $group, 1 - $userpending); } } $row_start += 200; } while (count($rows) > 0); }
/** * Standard modular directory creation function for OcCLE FS hooks. * * @param array The current meta-directory path * @param string The root node of the current meta-directory * @param string The new directory name * @param array A reference to the OcCLE filesystem object * @return boolean Success? */ function make_directory($meta_dir, $meta_root_node, $new_dir_name, &$occle_fs) { if (get_forum_type() != 'ocf') { return false; } if (count($meta_dir) < 1) { //We're at the top level, and adding a new member require_code('ocf_members_action'); require_code('ocf_members_action2'); ocf_make_member($new_dir_name, 'occle', '', NULL, NULL, NULL, NULL, array(), NULL, NULL, 1, NULL, NULL, '', '', '', 0, 1, 1, '', '', '', 1, 1, NULL, 1, 1, '', NULL, '', false); } else { return false; } //Directories aren't allowed to be added anywhere else return true; }
/** * 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_members($db, $table_prefix, $file_base) { $row_start = 0; $rows = array(); do { $rows = $db->query('SELECT *,u.userid AS userid FROM ' . $table_prefix . 'user u LEFT JOIN ' . $table_prefix . 'administrator a ON u.userid=a.userid LEFT JOIN ' . $table_prefix . 'usertextfield t ON u.userid=t.userid ORDER BY u.userid', 200, $row_start); foreach ($rows as $row) { if (import_check_if_imported('member', strval($row['userid']))) { continue; } $test = $GLOBALS['OCF_DRIVER']->get_member_from_username($row['username']); if (!is_null($test)) { import_id_remap_put('member', strval($row['userid']), $test); continue; } $language = ''; if ($row['languageid'] != 0) { $rows2 = $db->query('SELECT languagecode FROM ' . $table_prefix . 'language WHERE languageid=' . strval((int) $row['languageid'])); if (array_key_exists(0, $rows2)) { $language = strtoupper($rows2[0]['languagecode']); if (!file_exists(get_custom_file_base() . '/lang_custom/' . $language) && !file_exists(get_file_base() . '/lang/' . $language)) { $language = ''; } } } $primary_group = import_id_remap_get('group', strval($row['usergroupid'])); $secondary_groups = array(); if ($row['membergroupids'] != '') { $secondary_groups = explode(',', $row['membergroupids']); } $custom_fields = array(ocf_make_boiler_custom_field('im_icq') => $row['icq'], ocf_make_boiler_custom_field('im_aim') => $row['aim'], ocf_make_boiler_custom_field('im_yahoo') => $row['yahoo']); if ($row['homepage'] != '') { $custom_fields[ocf_make_boiler_custom_field('website')] = strlen($row['homepage']) > 0 ? '[url]' . $row['homepage'] . '[/url]' : ''; } if ($row['msn'] != '') { $custom_fields[ocf_make_boiler_custom_field('im_msn')] = $row['msn']; } $signature = $row['signature']; $validated = 1; $reveal_age = $row['birthday'] != '' ? 1 : 0; $bits = explode('-', $row['birthday']); if ($reveal_age == 1 && count($bits) == 3) { list($bday_month, $bday_day, $bday_year) = $bits; } else { list($bday_month, $bday_day, $bday_year) = array(0, 0, 0); } $title = $row['customtitle'] == 1 ? $row['usertitle'] : ''; $views_signatures = $row['options'] & 1; $preview_posts = 1; // These are done in the members-files stage $avatar_url = ''; $photo_url = ''; $photo_thumb_url = ''; $password = $row['password']; $type = 'vb3'; $salt = $row['salt']; $requests = $db->query('SELECT * FROM ' . $table_prefix . 'usergrouprequest WHERE userid=' . strval((int) $row['userid'])); foreach ($requests as $i => $request) { $requests[$i]['usergroupid'] = import_id_remap_get('group', strval($request['usergroupid'])); } //if (($row['adminpermissions']&256)!=0) $secondary_groups[]=array('usergroupid'=>db_get_first_id()+1); $id_new = ocf_make_member($row['username'], $password, $row['email'], NULL, $bday_day, $bday_month, $bday_year, $custom_fields, strval($row['timezoneoffset']), $primary_group, $validated, $row['joindate'], $row['lastvisit'], '', $avatar_url, $signature, 0, $preview_posts, $reveal_age, $title, $photo_url, $photo_thumb_url, $views_signatures, $row['autosubscribe'], $language, $row['options'] & 16, $row['options'] & 16, '', $row['ipaddress'], '', false, $type, $salt, 1, $row['lastpost'] == 0 ? $row['lastpost'] : NULL); // Fix usergroup leadership $GLOBALS['FORUM_DB']->query_update('f_groups', array('g_group_leader' => $id_new), array('g_group_leader' => -$row['userid'])); import_id_remap_put('member', strval($row['userid']), $id_new); // Set up usergroup membership foreach ($secondary_groups as $group) { $group = import_id_remap_get('group', strval($group['usergroupid'])); ocf_add_member_to_group($id_new, $group, 1); } foreach ($requests as $request) { ocf_add_member_to_group($id_new, $request['usergroupid'], 0); } } $row_start += 200; } while (count($rows) > 0); }
/** * Finishing off of a member profile (such as for LDAP or httpauth, where a partial profile is automatically made, but needs completion). * * @param SHORT_TEXT The username for the member profile. * @param SHORT_TEXT The password for the member profile. * @param ID_TEXT The type of member profile we are finishing off. * @param boolean Whether to check for duplicated email addresses. * @param string Auto-detected e-mail address (blank: none) * @param ?integer Auto-detected DOB day (NULL: unknown) * @param ?integer Auto-detected DOB month (NULL: unknown) * @param ?integer Auto-detected DOB year (NULL: unknown) * @param ?ID_TEXT Auto-detected Timezone (NULL: unknown) * @param ?ID_TEXT Auto-detected Language (NULL: unknown) * @param ?URLPATH The URL to the member's avatar (blank: none) (NULL: choose one automatically). * @param URLPATH The URL to the member's photo (blank: none). * @param URLPATH The URL to the member's photo thumbnail (blank: none). * @return MEMBER The member ID for the finished off profile. */ function ocf_member_external_linker($username, $password, $type, $email_check = true, $email_address = '', $dob_day = NULL, $dob_month = NULL, $dob_year = NULL, $timezone = NULL, $language = NULL, $avatar_url = NULL, $photo_url = '', $photo_thumb_url = '') { // Read in data $email_address = trim(post_param('email_address', $email_address)); $dob_day = post_param_integer('dob_day', $dob_day); $dob_month = post_param_integer('dob_month', $dob_month); $dob_year = post_param_integer('dob_year', $dob_year); $reveal_age = post_param_integer('reveal_age', 0); // For default privacy, default off require_code('temporal'); if (is_null($timezone)) { $timezone = get_site_timezone(); } $timezone = post_param('timezone', $timezone); if (is_null($language)) { $language = get_site_default_lang(); } $language = post_param('language', $language); $allow_emails = post_param_integer('allow_emails', 0); // For default privacy, default off $allow_emails_from_staff = post_param_integer('allow_emails_from_staff', 0); // For default privacy, default off require_code('ocf_groups'); $custom_fields = ocf_get_all_custom_fields_match(ocf_get_all_default_groups(true), NULL, NULL, NULL, NULL, NULL, NULL, 0, true); $actual_custom_fields = ocf_read_in_custom_fields($custom_fields); foreach ($actual_custom_fields as $key => $val) { if ($val == STRING_MAGIC_NULL) { $actual_custom_fields[$key] = ''; } } $groups = ocf_get_all_default_groups(true); // $groups will contain the built in default primary group too (it is not $secondary_groups) $primary_group = post_param_integer('primary_group', NULL); if ($primary_group !== NULL && !in_array($primary_group, $groups)) { // Check security $test = $GLOBALS['FORUM_DB']->query_value('f_groups', 'g_is_presented_at_install', array('id' => $primary_group)); if ($test == 1) { $groups = ocf_get_all_default_groups(false); // Get it so it does not include the built in default primary group $groups[] = $primary_group; // And add in the *chosen* primary group } else { $primary_group = NULL; } } else { $primary_group = NULL; } if ($primary_group === NULL) { $primary_group = get_first_default_group(); } // Check that the given address isn't already used (if one_per_email_address on) if (get_option('one_per_email_address') == '1' && $email_address != '' && $email_check) { $test = $GLOBALS['FORUM_DB']->query_value_null_ok('f_members', 'm_username', array('m_email_address' => $email_address)); if (!is_null($test)) { global $MEMBER_CACHED; $MEMBER_CACHED = db_get_first_id(); $reset_url = build_url(array('page' => 'lostpassword', 'email_address' => $email_address), get_module_zone('lostpassword')); warn_exit(do_lang_tempcode('EMAIL_ADDRESS_IN_USE', escape_html(get_site_name()), escape_html($reset_url->evaluate()))); } } // Add member require_code('ocf_members_action'); $ret = ocf_make_member($username, $password, $email_address, $groups, $dob_day, $dob_month, $dob_year, $actual_custom_fields, $timezone, NULL, 1, time(), time(), '', $avatar_url, '', 0, 1, $reveal_age, '', $photo_url, $photo_thumb_url, 1, 1, $language, $allow_emails, $allow_emails_from_staff, '', get_ip_address(), '', false, $type, ''); return $ret; }
/** * 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_members($db, $table_prefix, $file_base) { $row_start = 0; $rows = array(); do { $query = 'SELECT * FROM ' . $table_prefix . 'members ORDER BY id'; if (either_param('importer') == 'ipb2') { $query = 'SELECT * FROM ' . $table_prefix . 'members m LEFT JOIN ' . $table_prefix . 'members_converge c ON c.converge_id=m.id ORDER BY id'; } $rows = $db->query($query, 200, $row_start); foreach ($rows as $row) { $row['name'] = @html_entity_decode($row['name'], ENT_QUOTES, get_charset()); if (import_check_if_imported('member', strval($row['id']))) { continue; } if ($row['id'] == 0) { import_id_remap_put('member', '0', $GLOBALS['OCF_DRIVER']->get_guest_id()); continue; } $test = $GLOBALS['OCF_DRIVER']->get_member_from_username($row['name']); if (!is_null($test)) { import_id_remap_put('member', strval($row['id']), $test); continue; } if ($row['mgroup'] == 0) { $row['mgroup'] = db_get_first_id(); } // Not really necessary - but repairs problem in my test db $primary_group = import_id_remap_get('group', strval($row['mgroup'])); $language = is_null($row['language']) ? '' : strtoupper($row['language']); if (!file_exists(get_custom_file_base() . '/lang_custom/' . $language) && !file_exists(get_file_base() . '/lang/' . $language)) { $language = ''; } if (either_param('importer') == 'ipb1') { $custom_fields = array(ocf_make_boiler_custom_field('im_icq') => $row['icq_number'], ocf_make_boiler_custom_field('im_aim') => $row['aim_name'], ocf_make_boiler_custom_field('im_msn') => $row['msnname'], ocf_make_boiler_custom_field('im_yahoo') => $row['yahoo'], ocf_make_boiler_custom_field('interests') => $row['interests'], ocf_make_boiler_custom_field('location') => $row['location']); if ($row['website'] != '') { $custom_fields[ocf_make_boiler_custom_field('website')] = strlen($row['website']) > 0 ? '[url]' . $row['website'] . '[/url]' : ''; } } else { $custom_fields = array(); $signature = ''; } $rows2 = $db->query('SELECT * FROM ' . $table_prefix . 'member_extra WHERE id=' . strval($row['id'])); $notes = ''; if (array_key_exists(0, $rows2)) { $row2 = $rows2[0]; $custom_fields[ocf_make_boiler_custom_field('SELF_DESCRIPTION')] = @html_entity_decode($row2['bio'], ENT_QUOTES, get_charset()); $notes = $row2['notes']; if (either_param('importer') == 'ipb2') { ocf_over_msn(); $signature = html_to_comcode($this->clean_ipb_post_2($row2['signature'])); ocf_over_local(); $custom_fields = array(ocf_make_boiler_custom_field('im_aim') => $row2['aim_name'], ocf_make_boiler_custom_field('im_msn') => $row2['msnname'], ocf_make_boiler_custom_field('im_yahoo') => $row2['yahoo'], ocf_make_boiler_custom_field('interests') => $row2['interests'], ocf_make_boiler_custom_field('location') => $row2['location']); if ($row2['website'] != '') { $custom_fields[ocf_make_boiler_custom_field('website')] = strlen($row2['website']) > 0 ? '[url]' . $row2['website'] . '[/url]' : ''; } if ($row2['icq_number'] != 0) { $custom_fields[ocf_make_boiler_custom_field('im_icq')] = $row2['icq_number']; } } } if (either_param('importer') == 'ipb1') { ocf_over_msn(); $signature = html_to_comcode($this->clean_ipb_post_2($row['signature'])); ocf_over_local(); } $validated = 1; if (either_param('importer') == 'ipb2') { $password = $row['converge_pass_hash']; $type = 'converge'; $salt = $row['converge_pass_salt']; } else { $password = $row['password']; $type = 'md5'; $salt = ''; } if (is_null($password)) { $password = ''; } $id_new = ocf_make_member($row['name'], $password, $row['email'], NULL, $row['bday_day'], $row['bday_month'], $row['bday_year'], $custom_fields, strval($row['time_offset']), $primary_group, $validated, $row['joined'], $row['last_visit'], '', '', $signature, 0, 1, 1, $row['title'], '', '', $row['view_sigs'], $row['auto_track'], $language, $row['email_pm'], $row['email_pm'], $notes, $row['ip_address'], '', false, $type, $salt); if ($row['mgroup'] == 5) { $GLOBALS['FORUM_DB']->query_update('f_members', array('m_is_perm_banned' => 1), array('id' => $id_new), '', 1); } import_id_remap_put('member', strval($row['id']), $id_new); } $row_start += 200; } while (count($rows) > 0); }
/** * Install/upgrade OCF. * * @param ?float The version to upgrade from (NULL: fresh install). */ function install_ocf($upgrade_from = NULL) { require_code('ocf_members'); require_code('ocf_topics'); require_code('ocf_groups'); require_code('ocf_forums'); require_lang('ocf'); require_lang('ocf_config'); require_code('ocf_moderation_action'); require_code('ocf_posts_action'); require_code('ocf_members_action'); require_code('ocf_groups_action'); require_code('ocf_general_action'); require_code('ocf_forums_action'); require_code('ocf_topics_action'); require_code('database_action'); if (is_null($upgrade_from)) { uninstall_ocf_everytime(); uninstall_ocf(); } $test = $GLOBALS['FORUM_DB']->query('SELECT id FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_forums', NULL, NULL, true); $not_installed = is_null($test); if ($not_installed) { $upgrade_from = NULL; } if (is_null($upgrade_from) || $upgrade_from < 4.2) { add_config_option('ENCRYPTION_KEY', 'encryption_key', 'line', 'require_code(\'encryption\');return is_encryption_available()?\'\':NULL;', 'PRIVACY', 'ADVANCED'); add_config_option('DECRYPTION_KEY', 'decryption_key', 'line', 'require_code(\'encryption\');return is_encryption_available()?\'\':NULL;', 'PRIVACY', 'ADVANCED'); add_config_option('IS_ON_POST_TITLES', 'is_on_post_titles', 'tick', 'return is_null($old=get_value(\'no_post_titles\'))?\'0\':invert_value($old);', 'SECTION_FORUMS', 'GENERAL'); add_config_option('IS_ON_ANONYMOUS_POSTS', 'is_on_anonymous_posts', 'tick', 'return is_null($old=get_value(\'ocf_no_anonymous_post\'))?\'0\':invert_value($old);', 'SECTION_FORUMS', 'GENERAL'); add_config_option('IS_ON_TIMEZONE_DETECTION', 'is_on_timezone_detection', 'tick', 'return is_null($old=get_value(\'no_js_timezone_detect\'))?\'0\':invert_value($old);', 'SECTION_FORUMS', 'GENERAL'); add_config_option('IS_ON_TOPIC_DESCRIPTIONS', 'is_on_topic_descriptions', 'tick', 'return is_null($old=get_value(\'no_topic_descriptions\'))?\'1\':invert_value($old);', 'SECTION_FORUMS', 'GENERAL'); add_config_option('IS_ON_TOPIC_EMOTICONS', 'is_on_topic_emoticons', 'tick', 'return is_null($old=get_value(\'ocf_no_topic_emoticons\'))?\'1\':invert_value($old);', 'SECTION_FORUMS', 'GENERAL'); add_config_option('DEFAULT_PREVIEW_GUESTS', 'default_preview_guests', 'tick', 'return is_null($old=get_value(\'no_default_preview_guests\'))?\'0\':invert_value($old);', 'SECTION_FORUMS', 'GENERAL'); add_config_option('FORCED_PREVIEW_OPTION', 'forced_preview_option', 'tick', 'return is_null($old=get_value(\'no_forced_preview_option\'))?\'0\':invert_value($old);', 'SECTION_FORUMS', 'GENERAL'); add_config_option('OVERT_WHISPER_SUGGESTION', 'overt_whisper_suggestion', 'tick', 'return is_null($old=get_value(\'disable_overt_whispering\'))?\'1\':invert_value($old);', 'SECTION_FORUMS', 'GENERAL'); add_config_option('IS_ON_INVISIBILITY', 'is_on_invisibility', 'tick', 'return is_null($old=get_value(\'no_invisible_option\'))?\'0\':invert_value($old);', 'SECTION_FORUMS', 'GENERAL'); add_config_option('ALLOW_ALPHA_SEARCH', 'allow_alpha_search', 'tick', 'return is_null($old=get_value(\'allow_alpha_search\'))?\'0\':$old;', 'SECTION_FORUMS', 'GENERAL'); add_config_option('ALLOW_EMAIL_DISABLE', 'allow_email_disable', 'tick', 'return is_null($old=get_value(\'disable_allow_emails_field\'))?\'1\':invert_value($old);', 'SECTION_FORUMS', 'GENERAL'); add_config_option('MAX_MEMBER_TITLE_LENGTH', 'max_member_title_length', 'integer', 'return addon_installed(\'ocf_member_titles\')?\'20\':NULL;', 'SECTION_FORUMS', 'GENERAL'); $GLOBALS['FORUM_DB']->drop_if_exists('f_member_cpf_perms'); $GLOBALS['FORUM_DB']->create_table('f_member_cpf_perms', array('member_id' => '*USER', 'field_id' => '*AUTO_LINK', 'guest_view' => 'BINARY', 'member_view' => 'BINARY', 'friend_view' => 'BINARY', 'group_view' => 'SHORT_TEXT')); } if (is_null($upgrade_from) || $upgrade_from < 2.5) { add_config_option('HTTPAUTH_IS_ENABLED', 'httpauth_is_enabled', 'tick', 'return \'0\';', 'SECTION_FORUMS', 'ADVANCED', 1); add_config_option('POST_HISTORY_DAYS', 'post_history_days', 'integer', 'return \'21\';', 'SECTION_FORUMS', 'GENERAL', 1); } if (is_null($upgrade_from)) { // Add config options add_config_option('FORUM_POSTS_PER_PAGE', 'forum_posts_per_page', 'integer', 'return has_no_forum()?NULL:\'20\';', 'SECTION_FORUMS', 'GENERAL'); add_config_option('FORUM_TOPICS_PER_PAGE', 'forum_topics_per_page', 'integer', 'return has_no_forum()?NULL:\'30\';', 'SECTION_FORUMS', 'GENERAL'); add_config_option('PREVENT_SHOUTING', 'prevent_shouting', 'tick', 'return has_no_forum()?NULL:\'1\';', 'SECTION_FORUMS', 'GENERAL'); add_config_option('RESTRICTED_USERNAMES', 'restricted_usernames', 'line', 'return do_lang(\'GUEST\').\', \'.do_lang(\'STAFF\').\', \'.do_lang(\'ADMIN\').\', \'.do_lang(\'MODERATOR\').\', googlebot\';', 'SECTION_FORUMS', 'GENERAL'); add_config_option('REQUIRE_NEW_MEMBER_VALIDATION', 'require_new_member_validation', 'tick', 'return \'0\';', 'SECTION_FORUMS', 'USERNAMES_AND_PASSWORDS'); add_config_option('REPORTED_POSTS_FORUM', 'reported_posts_forum', 'forum', 'return (has_no_forum()||(!addon_installed(\'ocf_reported_posts\')))?NULL:do_lang(\'ocf:REPORTED_POSTS_FORUM\');', 'SECTION_FORUMS', 'GENERAL'); add_config_option('ONE_PER_EMAIL_ADDRESS', 'one_per_email_address', 'tick', 'return \'1\';', 'SECTION_FORUMS', 'GENERAL'); add_config_option('HOT_TOPIC_DEFINITION', 'hot_topic_definition', 'integer', 'return has_no_forum()?NULL:\'20\';', 'SECTION_FORUMS', 'GENERAL'); } if (!is_null($upgrade_from) && $upgrade_from < 7.2) { $rows = $GLOBALS['FORUM_DB']->query('SELECT m_name FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'db_meta WHERE (' . db_string_equal_to('m_type', '?INTEGER') . ' OR ' . db_string_equal_to('m_type', 'BINARY') . ') AND ' . db_string_equal_to('m_table', 'f_member_custom_fields')); foreach ($rows as $row) { $GLOBALS['FORUM_DB']->alter_table_field('f_member_custom_fields', $row['m_name'], 'SHORT_TEXT'); } $i = 0; do { $rows = $GLOBALS['FORUM_DB']->query_select('f_member_custom_fields', array('*'), NULL, '', 100, $i); foreach ($rows as $j => $row) { foreach ($row as $key => $val) { if (substr($key, 0, 6) == 'field_') { $val = str_replace('|', chr(10), $val); $row[$key] = $val; } } if ($rows[$j] != $row) { $GLOBALS['FORUM_DB']->query_update('f_member_custom_fields', array('mf_member_id' => $row['mf_member_id']), $row, '', 1); } } $i += 100; } while (count($rows) != 0); $GLOBALS['FORUM_DB']->alter_table_field('f_members', 'm_track_contributed_topics', 'BINARY', 'm_auto_monitor_contrib_content'); } if (!is_null($upgrade_from) && $upgrade_from < 4.0) { $GLOBALS['FORUM_DB']->alter_table_field('f_members', 'm_password_compatibility_scheme', 'ID_TEXT', 'm_password_compat_scheme'); $GLOBALS['FORUM_DB']->delete_table_field('f_members', 'm_track_all_forums'); } if (!is_null($upgrade_from) && $upgrade_from < 3.1) { $GLOBALS['FORUM_DB']->add_table_field('f_emoticons', 'e_is_special', 'BINARY', 0); $GLOBALS['FORUM_DB']->add_table_field('f_members', 'm_highlighted_name', 'BINARY', 0); } if (!is_null($upgrade_from) && $upgrade_from < 3.0) { $rows = $GLOBALS['FORUM_DB']->query_select('f_forum_group_access', array('*')); foreach ($rows as $row) { if ($row['a_level'] > 1) { $GLOBALS['SITE_DB']->query_insert('group_category_access', array('module_the_name' => 'forums', 'category_name' => strval($row['a_forum_id']), 'group_id' => $row['a_group_id'])); } } $GLOBALS['FORUM_DB']->drop_if_exists('f_forum_group_access'); delete_specific_permission('allow_deletive_moderation'); $GLOBALS['FORUM_DB']->delete_table_field('f_post_templates', 't_minimum_access_level'); $GLOBALS['FORUM_DB']->add_table_field('f_groups', 'g_is_presented_at_install', 'BINARY', 0); $GLOBALS['FORUM_DB']->alter_table_field('f_custom_fields', 'cf_name', 'SHORT_TRANS'); $GLOBALS['FORUM_DB']->alter_table_field('f_groups', 'g_rank_image', 'ID_TEXT'); } if (!is_null($upgrade_from) && $upgrade_from < 2.6) { $GLOBALS['FORUM_DB']->add_table_field('f_groups', 'g_is_default', 'BINARY'); } if (is_null($upgrade_from) || $upgrade_from < 4.0) { add_config_option('MINIMUM_PASSWORD_LENGTH', 'minimum_password_length', 'integer', 'return \'4\';', 'SECTION_FORUMS', 'USERNAMES_AND_PASSWORDS'); add_config_option('MAXIMUM_PASSWORD_LENGTH', 'maximum_password_length', 'integer', 'return \'20\';', 'SECTION_FORUMS', 'USERNAMES_AND_PASSWORDS'); add_config_option('MINIMUM_USERNAME_LENGTH', 'minimum_username_length', 'integer', 'return \'1\';', 'SECTION_FORUMS', 'USERNAMES_AND_PASSWORDS'); add_config_option('MAXIMUM_USERNAME_LENGTH', 'maximum_username_length', 'integer', 'return \'20\';', 'SECTION_FORUMS', 'USERNAMES_AND_PASSWORDS'); add_config_option('PROHIBIT_PASSWORD_WHITESPACE', 'prohibit_password_whitespace', 'tick', 'return \'1\';', 'SECTION_FORUMS', 'USERNAMES_AND_PASSWORDS'); //add_config_option('PROHIBIT_PASSWORD_DICTIONARY','prohibit_password_dictionary','tick','return \'0\';','SECTION_FORUMS','USERNAMES_AND_PASSWORDS'); add_config_option('PROHIBIT_USERNAME_WHITESPACE', 'prohibit_username_whitespace', 'tick', 'return \'0\';', 'SECTION_FORUMS', 'USERNAMES_AND_PASSWORDS'); add_config_option('ASSIGN_RANDOM_AVATARS', 'random_avatars', 'tick', 'return addon_installed(\'ocf_member_avatars\')?\'1\':NULL;', 'SECTION_FORUMS', 'GENERAL'); add_config_option('CLUB_FORUM_PARENT_FORUM', 'club_forum_parent_forum', 'forum', 'return has_no_forum()?NULL:strval(db_get_first_id());', 'SECTION_FORUMS', 'GENERAL'); add_config_option('CLUB_FORUM_PARENT_CATEGORY', 'club_forum_parent_category', 'category', 'return has_no_forum()?NULL:strval(db_get_first_id());', 'SECTION_FORUMS', 'GENERAL'); add_config_option('DELETE_TRASHED_PTS', 'delete_trashed_pts', 'tick', 'return has_no_forum()?NULL:\'0\';', 'SECTION_FORUMS', 'GENERAL'); //add_config_option('ALLOW_MEMBER_INTEGRATION','allow_member_integration','list','return \'off\';','SECTION_FORUMS','USERNAMES_AND_PASSWORDS',0,'strict|on|hidden|off'); add_config_option('PROBATION_USERGROUP', 'probation_usergroup', 'usergroup', 'return do_lang(\'PROBATION\');', 'SECTION_FORUMS', 'USERNAMES_AND_PASSWORDS'); add_config_option('SHOW_FIRST_JOIN_PAGE', 'show_first_join_page', 'tick', 'return \'1\';', 'SECTION_FORUMS', 'USERNAMES_AND_PASSWORDS'); add_config_option('SKIP_EMAIL_CONFIRM_JOIN', 'skip_email_confirm_join', 'tick', 'return \'1\';', 'SECTION_FORUMS', 'USERNAMES_AND_PASSWORDS'); add_config_option('NO_DOB_ASK', 'no_dob_ask', 'list', 'return \'0\';', 'SECTION_FORUMS', 'USERNAMES_AND_PASSWORDS', 0, '0|1|2'); add_config_option('ALLOW_INTERNATIONAL', 'allow_international', 'tick', 'return \'1\';', 'SECTION_FORUMS', 'USERNAMES_AND_PASSWORDS'); } if (is_null($upgrade_from) || $upgrade_from < 8.0) { add_config_option('ALLOW_EMAIL_FROM_STAFF_DISABLE', 'allow_email_from_staff_disable', 'tick', 'return \'0\';', 'SECTION_FORUMS', 'GENERAL'); add_config_option('INTRO_FORUM_ID', 'intro_forum_id', '?forum', 'return \'\';', 'SECTION_FORUMS', 'USERNAMES_AND_PASSWORDS'); add_config_option('SIGNUP_FULLNAME', 'signup_fullname', 'tick', 'return \'0\';', 'SECTION_FORUMS', 'USERNAMES_AND_PASSWORDS'); } if (!is_null($upgrade_from) && $upgrade_from < 8.1) { delete_config_option('no_dob_ask'); add_config_option('NO_DOB_ASK', 'no_dob_ask', 'list', 'return \'0\';', 'SECTION_FORUMS', 'USERNAMES_AND_PASSWORDS', 0, '0|1|2'); // Recreate option } if (!is_null($upgrade_from) && $upgrade_from < 8.0) { $GLOBALS['FORUM_DB']->add_table_field('f_members', 'm_allow_emails_from_staff', 'BINARY'); $GLOBALS['FORUM_DB']->add_table_field('f_custom_fields', 'cf_show_on_join_form', 'BINARY'); $GLOBALS['FORUM_DB']->add_table_field('f_forums', 'f_is_threaded', 'BINARY', 0); $GLOBALS['FORUM_DB']->add_table_field('f_posts', 'p_parent_id', '?AUTO_LINK', NULL); $GLOBALS['FORUM_DB']->query('UPDATE ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_custom_fields SET cf_show_on_join_form=cf_required'); delete_config_option('send_staff_message_post_validation'); require_code('notifications'); $start = 0; do { $rows = $GLOBALS['FORUM_DB']->query_select('f_forum_tracking', array('r_forum_id', 'r_member_id'), NULL, '', 100, $start); foreach ($rows as $row) { enable_notifications('ocf_topic', 'forum:' . strval($row['r_forum_id']), $row['r_member_id']); } $start += 100; } while (count($rows) == 100); $start = 0; do { $rows = $GLOBALS['FORUM_DB']->query_select('f_topic_tracking', array('r_topic_id', 'r_member_id'), NULL, '', 100, $start); foreach ($rows as $row) { enable_notifications('ocf_topic', strval($row['r_topic_id']), $row['r_member_id']); } $start += 100; } while (count($rows) == 100); $GLOBALS['FORUM_DB']->drop_if_exists('f_forum_tracking'); $GLOBALS['FORUM_DB']->drop_if_exists('f_topic_tracking'); } if (!is_null($upgrade_from) && $upgrade_from < 4.2) { $GLOBALS['FORUM_DB']->add_table_field('f_topics', 't_description_link', 'SHORT_TEXT'); $GLOBALS['FORUM_DB']->add_table_field('f_custom_fields', 'cf_encrypted', 'BINARY', 0); } if (!is_null($upgrade_from) && $upgrade_from < 4.0) { $GLOBALS['FORUM_DB']->add_table_field('f_members', 'm_on_probation_until', '?TIME', time()); $GLOBALS['FORUM_DB']->add_table_field('f_members', 'm_pt_rules_text', 'LONG_TRANS', ''); $GLOBALS['FORUM_DB']->add_table_field('f_members', 'm_pt_allow', 'SHORT_TEXT', '*'); $GLOBALS['FORUM_DB']->add_table_field('f_forums', 'f_order', 'ID_TEXT', 'last_post'); // last_post,first_post,title $GLOBALS['FORUM_DB']->add_table_field('f_groups', 'g_hidden', 'BINARY', 0); $GLOBALS['FORUM_DB']->add_table_field('f_groups', 'g_order', 'INTEGER'); $GLOBALS['FORUM_DB']->add_table_field('f_groups', 'g_rank_image_pri_only', 'BINARY', 1); $GLOBALS['FORUM_DB']->add_table_field('f_groups', 'g_open_membership', 'BINARY', 0); $GLOBALS['FORUM_DB']->add_table_field('f_groups', 'g_is_private_club', 'BINARY', 0); $GLOBALS['FORUM_DB']->add_table_field('f_posts', 'p_skip_sig', 'BINARY', 0); $GLOBALS['FORUM_DB']->add_table_field('f_topics', 't_sunk', 'BINARY', 0); $GLOBALS['FORUM_DB']->add_table_field('f_multi_moderations', 'mm_sink_state', '?BINARY', NULL); $GLOBALS['FORUM_DB']->add_table_field('f_multi_moderations', 'mm_title_suffix', 'SHORT_TEXT'); $GLOBALS['FORUM_DB']->add_table_field('f_warnings', 'w_is_warning', 'BINARY', 1); $GLOBALS['FORUM_DB']->add_table_field('f_warnings', 'p_silence_from_topic', '?AUTO_LINK'); $GLOBALS['FORUM_DB']->add_table_field('f_warnings', 'p_silence_from_forum', '?AUTO_LINK'); $GLOBALS['FORUM_DB']->add_table_field('f_warnings', 'p_probation', 'INTEGER', 0); $GLOBALS['FORUM_DB']->add_table_field('f_warnings', 'p_banned_ip', 'IP'); $GLOBALS['FORUM_DB']->add_table_field('f_warnings', 'p_charged_points', 'INTEGER', 0); $GLOBALS['FORUM_DB']->add_table_field('f_warnings', 'p_banned_member', 'BINARY', 0); $GLOBALS['FORUM_DB']->add_table_field('f_warnings', 'p_changed_usergroup_from', '?GROUP'); } if (is_null($upgrade_from) || $upgrade_from < 3.0) { add_config_option('COPPA_ENABLED', 'is_on_coppa', 'tick', 'return \'0\';', 'PRIVACY', 'GENERAL'); add_config_option('FAX_NUMBER', 'privacy_fax', 'line', 'return \'\';', 'PRIVACY', 'GENERAL'); add_config_option('ADDRESS', 'privacy_postal_address', 'text', 'return \'\';', 'PRIVACY', 'GENERAL'); } if (is_null($upgrade_from) || $upgrade_from < 2.6) { add_config_option('INVITES_ENABLED', 'is_on_invites', 'tick', 'return \'0\';', 'SECTION_FORUMS', 'GENERAL'); add_config_option('INVITES_PER_DAY', 'invites_per_day', 'float', 'return \'1\';', 'SECTION_FORUMS', 'GENERAL'); } if (!is_null($upgrade_from) && $upgrade_from < 2.5) { $GLOBALS['FORUM_DB']->add_table_field('f_forums', 'f_redirection', 'SHORT_TEXT'); $GLOBALS['FORUM_DB']->add_table_field('f_forums', 'f_order_sub_alpha', 'BINARY'); $GLOBALS['FORUM_DB']->add_table_field('f_forums', 'f_intro_question', 'LONG_TRANS'); $GLOBALS['FORUM_DB']->add_table_field('f_forums', 'f_intro_answer', 'SHORT_TEXT'); $GLOBALS['FORUM_DB']->add_table_field('f_members', 'm_max_email_attach_size_mb', 'INTEGER', 3); $GLOBALS['FORUM_DB']->add_table_field('f_members', 'm_zone_wide', 'BINARY', 1); $GLOBALS['FORUM_DB']->add_table_field('f_members', 'm_notes', 'LONG_TEXT'); // TODO: remove $GLOBALS['FORUM_DB']->add_table_field('f_emoticons', 'e_use_topics', 'BINARY', 1); $GLOBALS['FORUM_DB']->add_table_field('f_topics', 't_pt_from_category', 'SHORT_TEXT'); $GLOBALS['FORUM_DB']->add_table_field('f_topics', 't_pt_to_category', 'SHORT_TEXT'); $GLOBALS['FORUM_DB']->add_table_field('f_custom_fields', 'cf_show_in_post_previews', 'BINARY', 1); $GLOBALS['FORUM_DB']->add_table_field('f_custom_fields', 'cf_order', 'INTEGER'); $GLOBALS['FORUM_DB']->add_table_field('f_custom_fields', 'cf_only_group', '?GROUP'); $GLOBALS['FORUM_DB']->add_table_field('f_multi_moderations', 'mm_forum_multi_code', 'SHORT_TEXT'); $GLOBALS['FORUM_DB']->alter_table_field('f_topics', 't_emoticon', 'SHORT_TEXT'); $GLOBALS['FORUM_DB']->alter_table_field('f_emoticons', 'e_theme_img_code', 'SHORT_TEXT'); $GLOBALS['FORUM_DB']->promote_text_field_to_comcode('f_forums', 'f_description'); $GLOBALS['FORUM_DB']->alter_table_field('f_members', 'm_pass_hash_salted', 'SHORT_TEXT'); $GLOBALS['FORUM_DB']->drop_if_exists('f_groups'); $GLOBALS['FORUM_DB']->query_delete('f_emoticons'); } if (!is_null($upgrade_from) && $upgrade_from < 3.1) { $GLOBALS['FORUM_DB']->alter_table_field('f_custom_fields', 'cf_only_group', 'LONG_TEXT'); } // If we have the forum installed to this db already, leave if (is_null($upgrade_from) && $not_installed) { uninstall_ocf(); $GLOBALS['FORUM_DB']->create_table('f_emoticons', array('e_code' => '*ID_TEXT', 'e_theme_img_code' => 'SHORT_TEXT', 'e_relevance_level' => 'INTEGER', 'e_use_topics' => 'BINARY', 'e_is_special' => 'BINARY')); $GLOBALS['FORUM_DB']->create_index('f_emoticons', 'relevantemoticons', array('e_relevance_level')); $GLOBALS['FORUM_DB']->create_index('f_emoticons', 'topicemos', array('e_use_topics')); $GLOBALS['FORUM_DB']->create_table('f_custom_fields', array('id' => '*AUTO', 'cf_locked' => 'BINARY', 'cf_name' => 'SHORT_TRANS', 'cf_description' => 'SHORT_TRANS', 'cf_default' => 'LONG_TEXT', 'cf_public_view' => 'BINARY', 'cf_owner_view' => 'BINARY', 'cf_owner_set' => 'BINARY', 'cf_type' => 'ID_TEXT', 'cf_required' => 'BINARY', 'cf_show_in_posts' => 'BINARY', 'cf_show_in_post_previews' => 'BINARY', 'cf_order' => 'INTEGER', 'cf_only_group' => 'LONG_TEXT', 'cf_encrypted' => 'BINARY', 'cf_show_on_join_form' => 'BINARY')); // These don't need to be filled in. We just use default from custom field if they aren't $GLOBALS['FORUM_DB']->create_table('f_member_custom_fields', array('mf_member_id' => '*USER')); //$GLOBALS['FORUM_DB']->create_index('f_member_custom_fields','fields_for_member',array('mf_member_id')); ocf_make_boiler_custom_field('SELF_DESCRIPTION'); //ocf_make_boiler_custom_field('im_aim'); //ocf_make_boiler_custom_field('im_msn'); //ocf_make_boiler_custom_field('im_yahoo'); //ocf_make_boiler_custom_field('im_icq'); //ocf_make_boiler_custom_field('im_jabber'); ocf_make_boiler_custom_field('im_skype'); ocf_make_boiler_custom_field('sn_facebook'); ocf_make_boiler_custom_field('sn_google'); ocf_make_boiler_custom_field('sn_twitter'); ocf_make_boiler_custom_field('interests'); ocf_make_boiler_custom_field('location'); ocf_make_boiler_custom_field('occupation'); ocf_make_boiler_custom_field('staff_notes'); } if (is_null($upgrade_from) || $upgrade_from < 2.6) { $GLOBALS['FORUM_DB']->create_table('f_invites', array('id' => '*AUTO', 'i_inviter' => 'USER', 'i_email_address' => 'SHORT_TEXT', 'i_time' => 'TIME', 'i_taken' => 'BINARY')); } if (is_null($upgrade_from) && $not_installed) { $GLOBALS['FORUM_DB']->create_table('f_group_members', array('gm_group_id' => '*GROUP', 'gm_member_id' => '*USER', 'gm_validated' => 'BINARY')); $GLOBALS['FORUM_DB']->create_index('f_group_members', 'gm_validated', array('gm_validated')); $GLOBALS['FORUM_DB']->create_index('f_group_members', 'gm_member_id', array('gm_member_id')); $GLOBALS['FORUM_DB']->create_index('f_group_members', 'gm_group_id', array('gm_group_id')); $GLOBALS['FORUM_DB']->create_table('f_members', array('id' => '*AUTO', 'm_username' => 'ID_TEXT', 'm_pass_hash_salted' => 'SHORT_TEXT', 'm_pass_salt' => 'SHORT_TEXT', 'm_theme' => 'ID_TEXT', 'm_avatar_url' => 'URLPATH', 'm_validated' => 'BINARY', 'm_validated_email_confirm_code' => 'SHORT_TEXT', 'm_cache_num_posts' => 'INTEGER', 'm_cache_warnings' => 'INTEGER', 'm_join_time' => 'TIME', 'm_timezone_offset' => 'SHORT_TEXT', 'm_primary_group' => 'GROUP', 'm_last_visit_time' => 'TIME', 'm_last_submit_time' => 'TIME', 'm_signature' => 'LONG_TRANS', 'm_is_perm_banned' => 'BINARY', 'm_preview_posts' => 'BINARY', 'm_dob_day' => '?INTEGER', 'm_dob_month' => '?INTEGER', 'm_dob_year' => '?INTEGER', 'm_reveal_age' => 'BINARY', 'm_email_address' => 'SHORT_TEXT', 'm_title' => 'SHORT_TEXT', 'm_photo_url' => 'URLPATH', 'm_photo_thumb_url' => 'URLPATH', 'm_views_signatures' => 'BINARY', 'm_auto_monitor_contrib_content' => 'BINARY', 'm_language' => 'ID_TEXT', 'm_ip_address' => 'IP', 'm_allow_emails' => 'BINARY', 'm_allow_emails_from_staff' => 'BINARY', 'm_notes' => 'LONG_TEXT', 'm_zone_wide' => 'BINARY', 'm_highlighted_name' => 'BINARY', 'm_pt_allow' => 'SHORT_TEXT', 'm_pt_rules_text' => 'LONG_TRANS', 'm_max_email_attach_size_mb' => 'INTEGER', 'm_password_change_code' => 'SHORT_TEXT', 'm_password_compat_scheme' => 'ID_TEXT', 'm_on_probation_until' => '?TIME')); $GLOBALS['FORUM_DB']->create_index('f_members', '#search_user', array('m_username')); $GLOBALS['FORUM_DB']->create_index('f_members', 'user_list', array('m_username')); $GLOBALS['FORUM_DB']->create_index('f_members', 'menail', array('m_email_address')); $GLOBALS['FORUM_DB']->create_index('f_members', 'external_auth_lookup', array('m_pass_hash_salted')); $GLOBALS['FORUM_DB']->create_index('f_members', 'sort_post_count', array('m_cache_num_posts')); $GLOBALS['FORUM_DB']->create_index('f_members', 'm_join_time', array('m_join_time')); $GLOBALS['FORUM_DB']->create_index('f_members', 'whos_validated', array('m_validated')); $GLOBALS['FORUM_DB']->create_index('f_members', 'birthdays', array('m_dob_day', 'm_dob_month')); $GLOBALS['FORUM_DB']->create_index('f_members', 'ftjoin_msig', array('m_signature')); $GLOBALS['FORUM_DB']->create_index('f_members', 'primary_group', array('m_primary_group')); $GLOBALS['FORUM_DB']->create_index('f_members', 'avatar_url', array('m_avatar_url')); // Used for uniform avatar randomisation } if (is_null($upgrade_from) || $upgrade_from < 2.5) { $no_use_topics = array('party' => 1, 'christmas' => 1, 'offtopic' => 1, 'rockon' => 1, 'guitar' => 1, 'sinner' => 1, 'wink' => 1, 'kiss' => 1, 'nod' => 1, 'smile' => 1, 'mellow' => 1, 'whistle' => 1, 'shutup' => 1, 'cyborg' => 1); $core_emoticons = array(':P' => 'cheeky', ":'(" => 'cry', ':dry:' => 'dry', ':$' => 'blush', ';)' => 'wink', 'O_o' => 'blink', ':wub:' => 'wub', ':cool:' => 'cool', ':lol:' => 'lol', ':(' => 'sad', ':)' => 'smile', ':thumbs:' => 'thumbs', ':offtopic:' => 'offtopic', ':|' => 'mellow', ':ninja:' => 'ph34r', ':o' => 'shocked'); $supported_emoticons = array(':rolleyes:' => 'rolleyes', ':D' => 'grin', '^_^' => 'glee', '(K)' => 'kiss', ':S' => 'confused', ':@' => 'angry', ':shake:' => 'shake', ':hand:' => 'hand', ':drool:' => 'drool', ':devil:' => 'devil', ':party:' => 'party', ':constipated:' => 'constipated', ':depressed:' => 'depressed', ':zzz:' => 'zzz', ':whistle:' => 'whistle', ':upsidedown:' => 'upsidedown', ':sick:' => 'sick', ':shutup:' => 'shutup', ':sarcy:' => 'sarcy', ':puppyeyes:' => 'puppyeyes', ':nod:' => 'nod', ':nerd:' => 'nerd', ':king:' => 'king', ':birthday:' => 'birthday', ':cyborg:' => 'cyborg', ':hippie:' => 'hippie', ':ninja2:' => 'ninja2', ':rockon:' => 'rockon', ':sinner:' => 'sinner', ':guitar:' => 'guitar'); $unused_emoticons = array(':christmas:' => 'christmas'); foreach ($core_emoticons as $a => $b) { ocf_make_emoticon($a, 'ocf_emoticons/' . $b, 0, array_key_exists($b, $no_use_topics) ? 0 : 1); } foreach ($supported_emoticons as $a => $b) { ocf_make_emoticon($a, 'ocf_emoticons/' . $b, 1, array_key_exists($b, $no_use_topics) ? 0 : 1); } foreach ($unused_emoticons as $a => $b) { ocf_make_emoticon($a, 'ocf_emoticons/' . $b, 1, array_key_exists($b, $no_use_topics) ? 0 : 1); } $GLOBALS['FORUM_DB']->create_table('f_groups', array('id' => '*AUTO', 'g_name' => 'SHORT_TRANS', 'g_is_default' => 'BINARY', 'g_is_presented_at_install' => 'BINARY', 'g_is_super_admin' => 'BINARY', 'g_is_super_moderator' => 'BINARY', 'g_group_leader' => '?USER', 'g_title' => 'SHORT_TRANS', 'g_promotion_target' => '?GROUP', 'g_promotion_threshold' => '?INTEGER', 'g_flood_control_submit_secs' => 'INTEGER', 'g_flood_control_access_secs' => 'INTEGER', 'g_gift_points_base' => 'INTEGER', 'g_gift_points_per_day' => 'INTEGER', 'g_max_daily_upload_mb' => 'INTEGER', 'g_max_attachments_per_post' => 'INTEGER', 'g_max_avatar_width' => 'INTEGER', 'g_max_avatar_height' => 'INTEGER', 'g_max_post_length_comcode' => 'INTEGER', 'g_max_sig_length_comcode' => 'INTEGER', 'g_enquire_on_new_ips' => 'BINARY', 'g_rank_image' => 'ID_TEXT', 'g_hidden' => 'BINARY', 'g_order' => 'INTEGER', 'g_rank_image_pri_only' => 'BINARY', 'g_open_membership' => 'BINARY', 'g_is_private_club' => 'BINARY')); $GLOBALS['FORUM_DB']->create_index('f_groups', 'ftjoin_gname', array('g_name')); $GLOBALS['FORUM_DB']->create_index('f_groups', 'ftjoin_gtitle', array('g_title')); $GLOBALS['FORUM_DB']->create_index('f_groups', 'is_private_club', array('g_is_private_club')); $GLOBALS['FORUM_DB']->create_index('f_groups', 'is_super_admin', array('g_is_super_admin')); $GLOBALS['FORUM_DB']->create_index('f_groups', 'is_super_moderator', array('g_is_super_moderator')); $GLOBALS['FORUM_DB']->create_index('f_groups', 'is_default', array('g_is_default')); $GLOBALS['FORUM_DB']->create_index('f_groups', 'hidden', array('g_hidden')); $GLOBALS['FORUM_DB']->create_index('f_groups', 'is_presented_at_install', array('g_is_presented_at_install')); $GLOBALS['FORUM_DB']->create_index('f_groups', 'gorder', array('g_order', 'id')); // For the_zone_access table require_code('zones2'); reinstall_module('adminzone', 'admin_permissions'); // Make guest $guest_group = ocf_make_group(do_lang('GUESTS'), 0, 0, 0, do_lang('DESCRIPTION_GUESTS')); // Make admin $administrator_group = ocf_make_group(do_lang('ADMINISTRATORS'), 0, 1, 0, do_lang('DESCRIPTION_ADMINISTRATORS'), 'ocf_rank_images/admin', NULL, NULL, NULL, 0); // Make mod $super_moderator_group = ocf_make_group(do_lang('SUPER_MODERATORS'), 0, 0, 1, do_lang('DESCRIPTION_SUPER_MODERATORS'), 'ocf_rank_images/mod', NULL, NULL, NULL, 0); // Make supermember $super_member_group = ocf_make_group(do_lang('SUPER_MEMBERS'), 0, 0, 0, do_lang('DESCRIPTION_SUPER_MEMBERS'), '', NULL, NULL, NULL, 0); // Make member $member_group_4 = ocf_make_group(do_lang('DEFAULT_RANK_4'), 0, 0, 0, do_lang('DESCRIPTION_MEMBERS'), 'ocf_rank_images/4'); $member_group_3 = ocf_make_group(do_lang('DEFAULT_RANK_3'), 0, 0, 0, do_lang('DESCRIPTION_MEMBERS'), 'ocf_rank_images/3', $member_group_4, 10000); $member_group_2 = ocf_make_group(do_lang('DEFAULT_RANK_2'), 0, 0, 0, do_lang('DESCRIPTION_MEMBERS'), 'ocf_rank_images/2', $member_group_3, 2500); $member_group_1 = ocf_make_group(do_lang('DEFAULT_RANK_1'), 0, 0, 0, do_lang('DESCRIPTION_MEMBERS'), 'ocf_rank_images/1', $member_group_2, 400); $member_group_0 = ocf_make_group(do_lang('DEFAULT_RANK_0'), 0, 0, 0, do_lang('DESCRIPTION_MEMBERS'), 'ocf_rank_images/0', $member_group_1, 100); // Not default because primary is always defaulted to this one // Make probation $probation_group = ocf_make_group(do_lang('PROBATION'), 0, 0, 0, do_lang('DESCRIPTION_PROBATION'), '', NULL, NULL, NULL, 0); } if (is_null($upgrade_from) && $not_installed) { $GLOBALS['FORUM_DB']->create_table('f_categories', array('id' => '*AUTO', 'c_title' => 'SHORT_TEXT', 'c_description' => 'LONG_TEXT', 'c_expanded_by_default' => 'BINARY')); $category_id = ocf_make_category(do_lang('DEFAULT_CATEGORY_TITLE'), ''); $category_id_staff = ocf_make_category(do_lang('STAFF'), ''); $GLOBALS['FORUM_DB']->create_table('f_forums', array('id' => '*AUTO', 'f_name' => 'SHORT_TEXT', 'f_description' => 'LONG_TRANS', 'f_category_id' => '?AUTO_LINK', 'f_parent_forum' => '?AUTO_LINK', 'f_position' => 'INTEGER', 'f_order_sub_alpha' => 'BINARY', 'f_post_count_increment' => 'BINARY', 'f_intro_question' => 'LONG_TRANS', 'f_intro_answer' => 'SHORT_TEXT', 'f_cache_num_topics' => 'INTEGER', 'f_cache_num_posts' => 'INTEGER', 'f_cache_last_topic_id' => '?AUTO_LINK', 'f_cache_last_title' => 'SHORT_TEXT', 'f_cache_last_time' => '?TIME', 'f_cache_last_username' => 'SHORT_TEXT', 'f_cache_last_member_id' => '?USER', 'f_cache_last_forum_id' => '?AUTO_LINK', 'f_redirection' => 'SHORT_TEXT', 'f_order' => 'ID_TEXT', 'f_is_threaded' => 'BINARY')); $GLOBALS['FORUM_DB']->create_index('f_forums', 'cache_num_posts', array('f_cache_num_posts')); // Used to find active forums $GLOBALS['FORUM_DB']->create_index('f_forums', 'subforum_parenting', array('f_parent_forum')); $GLOBALS['FORUM_DB']->create_index('f_forums', 'findnamedforum', array('f_name')); $GLOBALS['FORUM_DB']->create_index('f_forums', 'f_position', array('f_position')); $typical_access = array($guest_group => 4, $administrator_group => 5, $super_moderator_group => 5, $probation_group => 2, $super_member_group => 4, $member_group_0 => 4, $member_group_1 => 4, $member_group_2 => 4, $member_group_3 => 4, $member_group_4 => 4); $staff_post_access = array($guest_group => 1, $administrator_group => 5, $super_moderator_group => 5, $probation_group => 1, $super_member_group => 2, $member_group_0 => 1, $member_group_1 => 1, $member_group_2 => 1, $member_group_3 => 1, $member_group_4 => 1); $staff_access = array($administrator_group => 5, $super_moderator_group => 5); $root_forum = ocf_make_forum(do_lang('ROOT_FORUM'), '', NULL, $staff_post_access, NULL); //ocf_make_forum(do_lang('NEWS'),'',$category_id,$staff_post_access,$root_forum); ocf_make_forum(do_lang('DEFAULT_FORUM_TITLE'), '', $category_id, $typical_access, $root_forum); //ocf_make_forum(do_lang('_FEEDBACK'),'',$category_id,$typical_access,$root_forum); We already have a feedback page ocf_make_forum(do_lang('REPORTED_POSTS_FORUM'), '', $category_id_staff, $staff_access, $root_forum); $trash_forum_id = ocf_make_forum(do_lang('TRASH'), '', $category_id_staff, $staff_access, $root_forum); ocf_make_forum(do_lang('COMMENT_FORUM_NAME'), '', $category_id, $typical_access, $root_forum, 1, 1, 0, '', '', '', 'last_post', 1); if (addon_installed('tickets')) { require_lang('tickets'); ocf_make_forum(do_lang('TICKET_FORUM_NAME'), '', $category_id_staff, $staff_access, $root_forum); } $staff_forum_id = ocf_make_forum(do_lang('STAFF'), '', $category_id_staff, $staff_access, $root_forum); $GLOBALS['FORUM_DB']->create_table('f_topics', array('id' => '*AUTO', 't_pinned' => 'BINARY', 't_sunk' => 'BINARY', 't_cascading' => 'BINARY', 't_forum_id' => '?AUTO_LINK', 't_pt_from' => '?USER', 't_pt_to' => '?USER', 't_pt_from_category' => 'SHORT_TEXT', 't_pt_to_category' => 'SHORT_TEXT', 't_description' => 'SHORT_TEXT', 't_description_link' => 'SHORT_TEXT', 't_emoticon' => 'SHORT_TEXT', 't_num_views' => 'INTEGER', 't_validated' => 'BINARY', 't_is_open' => 'BINARY', 't_poll_id' => '?AUTO_LINK', 't_cache_first_post_id' => '?AUTO_LINK', 't_cache_first_time' => '?TIME', 't_cache_first_title' => 'SHORT_TEXT', 't_cache_first_post' => '?LONG_TRANS', 't_cache_first_username' => 'ID_TEXT', 't_cache_first_member_id' => '?USER', 't_cache_last_post_id' => '?AUTO_LINK', 't_cache_last_time' => '?TIME', 't_cache_last_title' => 'SHORT_TEXT', 't_cache_last_username' => 'ID_TEXT', 't_cache_last_member_id' => '?USER', 't_cache_num_posts' => 'INTEGER')); $GLOBALS['FORUM_DB']->create_index('f_topics', 't_num_views', array('t_num_views')); $GLOBALS['FORUM_DB']->create_index('f_topics', 't_pt_to', array('t_pt_to')); $GLOBALS['FORUM_DB']->create_index('f_topics', 't_pt_from', array('t_pt_from')); $GLOBALS['FORUM_DB']->create_index('f_topics', 't_validated', array('t_validated')); $GLOBALS['FORUM_DB']->create_index('f_topics', 'in_forum', array('t_forum_id')); $GLOBALS['FORUM_DB']->create_index('f_topics', 'topic_order_time', array('t_cache_last_time')); $GLOBALS['FORUM_DB']->create_index('f_topics', 'topic_order_time_2', array('t_cache_first_time')); $GLOBALS['FORUM_DB']->create_index('f_topics', '#t_description', array('t_description')); $GLOBALS['FORUM_DB']->create_index('f_topics', 'descriptionsearch', array('t_description')); $GLOBALS['FORUM_DB']->create_index('f_topics', 'forumlayer', array('t_cache_first_title')); $GLOBALS['FORUM_DB']->create_index('f_topics', 't_cascading', array('t_cascading')); $GLOBALS['FORUM_DB']->create_index('f_topics', 't_cascading_or_forum', array('t_cascading', 't_forum_id')); $GLOBALS['FORUM_DB']->create_index('f_topics', 'topic_order', array('t_cascading', 't_pinned', 't_cache_last_time')); // Ordering for forumview, is picked up over topic_order_3 for just the ordering bit (it seems) $GLOBALS['FORUM_DB']->create_index('f_topics', 'topic_order_2', array('t_forum_id', 't_cascading', 't_pinned', 't_sunk', 't_cache_last_time')); // Total index for forumview, including ordering. Doesn't work on current MySQL. $GLOBALS['FORUM_DB']->create_index('f_topics', 'topic_order_3', array('t_forum_id', 't_cascading', 't_pinned', 't_cache_last_time')); // Total index for forumview, including ordering. Works if disable_sunk is turned on. $GLOBALS['FORUM_DB']->create_index('f_topics', 'ownedtopics', array('t_cache_first_member_id')); // Welcome topic $topic_id = ocf_make_topic($staff_forum_id, '', '', 1, 1, 0, 0, 0, NULL, NULL, false); $GLOBALS['FORUM_DB']->create_table('f_posts', array('id' => '*AUTO', 'p_title' => 'SHORT_TEXT', 'p_post' => 'LONG_TRANS', 'p_ip_address' => 'IP', 'p_time' => 'TIME', 'p_poster' => 'USER', 'p_intended_solely_for' => '?USER', 'p_poster_name_if_guest' => 'ID_TEXT', 'p_validated' => 'BINARY', 'p_topic_id' => 'AUTO_LINK', 'p_cache_forum_id' => '?AUTO_LINK', 'p_last_edit_time' => '?TIME', 'p_last_edit_by' => '?USER', 'p_is_emphasised' => 'BINARY', 'p_skip_sig' => 'BINARY', 'p_parent_id' => '?AUTO_LINK')); $GLOBALS['FORUM_DB']->create_index('f_posts', 'p_validated', array('p_validated')); $GLOBALS['FORUM_DB']->create_index('f_posts', 'in_topic', array('p_topic_id', 'p_time', 'id')); $GLOBALS['FORUM_DB']->create_index('f_posts', 'post_order_time', array('p_time', 'id')); $GLOBALS['FORUM_DB']->create_index('f_posts', 'p_last_edit_time', array('p_last_edit_time')); $GLOBALS['FORUM_DB']->create_index('f_posts', 'posts_by', array('p_poster')); $GLOBALS['FORUM_DB']->create_index('f_posts', 'find_pp', array('p_intended_solely_for')); $GLOBALS['FORUM_DB']->create_index('f_posts', 'search_join', array('p_post')); $GLOBALS['FORUM_DB']->create_index('f_posts', 'postsinforum', array('p_cache_forum_id')); $GLOBALS['FORUM_DB']->create_index('f_posts', 'deletebyip', array('p_ip_address')); } if (is_null($upgrade_from) && $not_installed || !is_null($upgrade_from) && $upgrade_from < 4.0) { $GLOBALS['FORUM_DB']->create_table('f_special_pt_access', array('s_member_id' => '*USER', 's_topic_id' => '*AUTO_LINK')); $GLOBALS['FORUM_DB']->create_table('f_saved_warnings', array('s_title' => '*SHORT_TEXT', 's_explanation' => 'LONG_TEXT', 's_message' => 'LONG_TEXT')); } if (is_null($upgrade_from) && $not_installed || $upgrade_from < 2.5) { $GLOBALS['FORUM_DB']->create_table('f_post_history', array('id' => '*AUTO', 'h_create_date_and_time' => 'TIME', 'h_action_date_and_time' => 'TIME', 'h_owner_member_id' => 'USER', 'h_alterer_member_id' => 'USER', 'h_post_id' => 'AUTO_LINK', 'h_topic_id' => 'AUTO_LINK', 'h_before' => 'LONG_TEXT', 'h_action' => 'ID_TEXT')); $GLOBALS['FORUM_DB']->create_index('f_post_history', 'phistorylookup', array('h_post_id')); $GLOBALS['FORUM_DB']->create_table('f_forum_intro_ip', array('i_forum_id' => '*AUTO_LINK', 'i_ip' => '*IP')); $GLOBALS['FORUM_DB']->create_table('f_forum_intro_member', array('i_forum_id' => '*AUTO_LINK', 'i_member_id' => '*USER')); $GLOBALS['FORUM_DB']->create_table('f_post_templates', array('id' => '*AUTO', 't_title' => 'SHORT_TEXT', 't_text' => 'LONG_TEXT', 't_forum_multi_code' => 'SHORT_TEXT', 't_use_default_forums' => 'BINARY')); ocf_make_post_template(do_lang('DEFAULT_POST_TEMPLATE_bug_title'), do_lang('DEFAULT_POST_TEMPLATE_bug_text'), '', 0); ocf_make_post_template(do_lang('DEFAULT_POST_TEMPLATE_task_title'), do_lang('DEFAULT_POST_TEMPLATE_task_text'), '', 0); ocf_make_post_template(do_lang('DEFAULT_POST_TEMPLATE_fault_title'), do_lang('DEFAULT_POST_TEMPLATE_fault_text'), '', 0); $GLOBALS['FORUM_DB']->create_index('f_posts', '#p_title', array('p_title')); } if (is_null($upgrade_from) && $not_installed) { $GLOBALS['FORUM_DB']->create_table('f_polls', array('id' => '*AUTO', 'po_question' => 'SHORT_TEXT', 'po_cache_total_votes' => 'INTEGER', 'po_is_private' => 'BINARY', 'po_is_open' => 'BINARY', 'po_minimum_selections' => 'INTEGER', 'po_maximum_selections' => 'INTEGER', 'po_requires_reply' => 'BINARY')); $GLOBALS['FORUM_DB']->create_table('f_poll_answers', array('id' => '*AUTO', 'pa_poll_id' => 'AUTO_LINK', 'pa_answer' => 'SHORT_TEXT', 'pa_cache_num_votes' => 'INTEGER')); $GLOBALS['FORUM_DB']->create_table('f_poll_votes', array('pv_poll_id' => '*AUTO_LINK', 'pv_member_id' => '*USER', 'pv_answer_id' => '*AUTO_LINK')); $GLOBALS['FORUM_DB']->create_table('f_multi_moderations', array('id' => '*AUTO', 'mm_name' => 'SHORT_TRANS', 'mm_post_text' => 'LONG_TEXT', 'mm_move_to' => '?INTEGER', 'mm_pin_state' => '?BINARY', 'mm_sink_state' => '?BINARY', 'mm_open_state' => '?BINARY', 'mm_forum_multi_code' => 'SHORT_TEXT', 'mm_title_suffix' => 'SHORT_TEXT')); ocf_make_multi_moderation(do_lang('TRASH'), '', $trash_forum_id, 0, 0, 0); $GLOBALS['FORUM_DB']->create_table('f_warnings', array('id' => '*AUTO', 'w_member_id' => 'USER', 'w_time' => 'TIME', 'w_explanation' => 'LONG_TEXT', 'w_by' => 'USER', 'w_is_warning' => 'BINARY', 'p_silence_from_topic' => '?AUTO_LINK', 'p_silence_from_forum' => '?AUTO_LINK', 'p_probation' => 'INTEGER', 'p_banned_ip' => 'IP', 'p_charged_points' => 'INTEGER', 'p_banned_member' => 'BINARY', 'p_changed_usergroup_from' => '?GROUP')); $GLOBALS['FORUM_DB']->create_index('f_warnings', 'warningsmemberid', array('w_member_id')); $GLOBALS['FORUM_DB']->create_table('f_moderator_logs', array('id' => '*AUTO', 'l_the_type' => 'ID_TEXT', 'l_param_a' => 'SHORT_TEXT', 'l_param_b' => 'SHORT_TEXT', 'l_date_and_time' => 'TIME', 'l_reason' => 'LONG_TEXT', 'l_by' => 'USER')); $GLOBALS['FORUM_DB']->create_table('f_member_known_login_ips', array('i_member_id' => '*USER', 'i_ip' => '*IP', 'i_val_code' => 'SHORT_TEXT')); if (strtoupper(ocp_srv('REQUEST_METHOD')) != 'POST') { exit; } // Needed as YSlow can load as GET's in background and cause horrible results // NB: post_param's will return default's if OCF is being installed but not used yet (e.g. IPB forum driver chosen at installation) // Make guest ocf_make_member(do_lang('GUEST'), '', '', NULL, NULL, NULL, NULL, array(), NULL, $guest_group, 1, time(), time(), '', NULL, '', 0, 1, 1, '', '', '', 1, 0, '', 1, 1, '', NULL, '', false); // Make admin user ocf_make_member(post_param('admin_username', 'admin'), post_param('ocf_admin_password', 'admin'), '', NULL, NULL, NULL, NULL, array(), NULL, $administrator_group, 1, time(), time(), '', 'themes/default/images/ocf_default_avatars/default_set/cool_flare.png', '', 0, 0, 1, '', '', '', 1, 1, '', 1, 1, '', NULL, '', false); // Make test user ocf_make_member('test', post_param('ocf_admin_password', 'admin'), '', NULL, NULL, NULL, NULL, array(), NULL, $member_group_0, 1, time(), time(), '', NULL, '', 0, 0, 1, '', '', '', 1, 0, '', 1, 1, '', NULL, '', false); $GLOBALS['FORUM_DB']->create_table('f_read_logs', array('l_member_id' => '*USER', 'l_topic_id' => '*AUTO_LINK', 'l_time' => 'TIME')); $GLOBALS['FORUM_DB']->create_index('f_read_logs', 'erase_old_read_logs', array('l_time')); ocf_make_post($topic_id, do_lang('DEFAULT_POST_TITLE'), do_lang('DEFAULT_POST_CONTENT'), 0, true, 1, 0, do_lang('SYSTEM'), '127.0.0.1', time(), $GLOBALS['OCF_DRIVER']->get_guest_id(), NULL, NULL, NULL, false, true); } // Permissions have to be done after usergroups if (is_null($upgrade_from)) { // Add privileges global $OCF_TRUE_PERMISSIONS, $OCF_FALSE_PERMISSIONS; foreach ($OCF_TRUE_PERMISSIONS as $permission) { add_specific_permission('SECTION_FORUMS', $permission, true); } foreach ($OCF_FALSE_PERMISSIONS as $permission) { add_specific_permission('SECTION_FORUMS', $permission, false, $permission == 'view_other_pt'); } } if (!is_null($upgrade_from) && $upgrade_from < 3.1) { add_specific_permission('SECTION_FORUMS', 'use_special_emoticons', false); } if (!is_null($upgrade_from) && $upgrade_from < 4.0) { add_specific_permission('SECTION_FORUMS', 'member_maintenance', false); add_specific_permission('SECTION_FORUMS', 'probate_members', false); add_specific_permission('SECTION_FORUMS', 'own_avatars', true); //add_specific_permission('SECTION_FORUMS','decide_comment_type',true); if we add threads add_specific_permission('SECTION_FORUMS', 'control_usergroups', false, true); add_specific_permission('SECTION_FORUMS', 'edit_personal_topic_posts', true); add_specific_permission('SECTION_FORUMS', 'multi_delete_topics', false); add_specific_permission('SECTION_FORUMS', 'show_user_browsing', false); add_specific_permission('SECTION_FORUMS', 'see_hidden_groups', false); add_specific_permission('SECTION_FORUMS', 'pt_anyone', false); } if (!is_null($upgrade_from) && $upgrade_from < 3.0) { add_specific_permission('SECTION_FORUMS', 'view_profiles', true); } if (!is_null($upgrade_from) && $upgrade_from < 2.5) { add_specific_permission('SECTION_FORUMS', 'moderate_personal_topic', false); add_specific_permission('SECTION_FORUMS', 'disable_lost_passwords', false); add_specific_permission('SECTION_FORUMS', 'view_any_profile_field', false); add_specific_permission('SECTION_FORUMS', 'rename_self', true); add_specific_permission('SECTION_FORUMS', 'double_post', false); add_specific_permission('SECTION_FORUMS', 'close_own_topics', false); add_specific_permission('SECTION_FORUMS', 'edit_own_polls', true); add_specific_permission('SECTION_FORUMS', 'warn_members', false); add_specific_permission('SECTION_FORUMS', 'see_warnings', false); add_specific_permission('SECTION_FORUMS', 'see_ip', false); add_specific_permission('SECTION_FORUMS', 'may_choose_custom_title', false); add_specific_permission('SECTION_FORUMS', 'delete_account', false); add_specific_permission('SECTION_FORUMS', 'view_other_pt', false); add_specific_permission('SECTION_FORUMS', 'view_poll_results_before_voting', false); add_specific_permission('SECTION_FORUMS', 'may_unblind_own_poll', true); delete_specific_permission('enquire_on_new_ips'); } }
/** * 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_members($db, $table_prefix, $file_base) { $row_start = 0; $rows = array(); $default_group = get_first_default_group(); do { $rows = $db->query('SELECT u.ID_MEMBER AS \'muid\',u.*,b.* FROM ' . $table_prefix . 'members u LEFT JOIN ' . $table_prefix . 'ban_items b ON u.ID_MEMBER=b.ID_MEMBER WHERE u.ID_MEMBER<>-1 ORDER BY u.ID_MEMBER', 200, $row_start); foreach ($rows as $row) { if (import_check_if_imported('member', strval($row['muid']))) { continue; } $test = $GLOBALS['OCF_DRIVER']->get_member_from_username($row['memberName']); if (!is_null($test)) { import_id_remap_put('member', strval($row['muid']), $test); continue; } $language = 'EN'; $secondary = explode(',', $row['additionalGroups']); $secondary_groups = array(); foreach ($secondary as $g) { if (trim($g) != '') { $g = import_id_remap_get('group', $g, true); if (!is_null($g)) { $secondary_groups[] = intval($g); } } } $primary_group = $row['ID_GROUP']; if ($primary_group == 0) { $primary_group = $row['ID_POST_GROUP']; } if ($primary_group == 0) { $primary_group = $default_group; } else { $primary_group = import_id_remap_get('group', strval($primary_group)); } $custom_fields = array(ocf_make_boiler_custom_field('im_icq') => $row['ICQ'], ocf_make_boiler_custom_field('im_aim') => $row['AIM'], ocf_make_boiler_custom_field('im_msn') => $row['MSN'], ocf_make_boiler_custom_field('im_yahoo') => $row['YIM']); if ($row['websiteUrl'] != '') { $custom_fields[ocf_make_boiler_custom_field('website')] = $row['websiteUrl']; } $signature = $this->fix_links($row['signature'], $db, $table_prefix, $file_base); $validated = 1; $reveal_age = 0; if ($row['birthdate'] != '') { $birthdate = $row['birthdate']; $birthdata = explode('-', $birthdate); $bday_day = isset($birthdata[0]) && $birthdata[0] != '' ? $birthdata[0] : NULL; $bday_month = isset($birthdata[1]) && $birthdata[1] != '' ? $birthdata[1] : NULL; $bday_year = isset($birthdata[2]) && $birthdata[2] != '' ? $birthdata[2] : NULL; } else { list($bday_day, $bday_month, $bday_year) = array(NULL, NULL, NULL); } $views_signatures = 1; $preview_posts = 1; $track_posts = $row['notifyAnnouncements']; $title = ''; // These are done in the members-files stage $avatar_url = ''; $photo_url = ''; $photo_thumb_url = ''; $password = $row['passwd']; $type = 'smf'; $salt = $row['passwordSalt']; if ($row['dateRegistered'] == 0) { $row['dateRegistered'] = time(); } $id_new = ocf_make_member($row['memberName'], $password, $row['emailAddress'], NULL, $bday_day, $bday_month, $bday_year, $custom_fields, strval($row['timeOffset']), $primary_group, $validated, $row['dateRegistered'], $row['lastLogin'], '', $avatar_url, $signature, 0, $preview_posts, $reveal_age, $title, $photo_url, $photo_thumb_url, $views_signatures, $track_posts, $language, $row['instantMessages'], 1, '', '', '', false, $type, $salt, 1); // Fix usergroup leadership $GLOBALS['FORUM_DB']->query_update('f_groups', array('g_group_leader' => $id_new), array('g_group_leader' => -$row['muid'])); import_id_remap_put('member', strval($row['muid']), $id_new); // Set up usergroup membership foreach ($secondary_groups as $s) { ocf_add_member_to_group($id_new, $s, 1); } } $row_start += 200; } while (count($rows) > 0); }
function do_work() { $num_wanted = 100000; require_code('config2'); set_option('post_history_days', '0'); // Needed for a little sanity in recent post retrieval set_value('disable_sunk', '1'); // members (remember to test the username autocompleter, and birthdays) // authors (remember to check author autocompleter and popup author list) // lots of people getting notifications on a forum // lots of people getting notifications on a topic require_code('authors'); require_code('ocf_members_action'); require_code('notifications'); for ($i = $GLOBALS['FORUM_DB']->query_value('f_members', 'COUNT(*)'); $i < $num_wanted; $i++) { $member_id = ocf_make_member(uniqid('', true), uniqid('', true), uniqid('', true) . '@example.com', array(), intval(date('d')), intval(date('m')), intval(date('Y')), array(), NULL, NULL, 1, NULL, NULL, '', NULL, '', 0, 0, 1, '', '', '', 1, 1, NULL, 1, 1, '', NULL, '', false); add_author(random_line(), '', $member_id, random_text(), random_text()); enable_notifications('ocf_topic', 'forum:' . strval(db_get_first_id()), $member_id); enable_notifications('ocf_topic', strval(db_get_first_id()), $member_id); // number of friends to a single member $GLOBALS['SITE_DB']->query_insert('chat_buddies', array('member_likes' => $member_id, 'member_liked' => db_get_first_id() + 1, 'date_and_time' => time()), false, true); } $member_id = db_get_first_id() + 2; // point earn list / gift points to a single member require_code('points2'); for ($j = $GLOBALS['SITE_DB']->query_value('gifts', 'COUNT(*)'); $j < $num_wanted; $j++) { give_points(10, $member_id, mt_rand(db_get_first_id(), min(100, $num_wanted - 1)), random_line(), false, false); } // number of friends of a single member for ($j = intval(floatval($GLOBALS['SITE_DB']->query_value('chat_buddies', 'COUNT(*)')) / 2.0); $j < $num_wanted; $j++) { $GLOBALS['SITE_DB']->query_insert('chat_buddies', array('member_likes' => $member_id, 'member_liked' => $j + db_get_first_id(), 'date_and_time' => time()), false, true); } echo 'done member/authors/points/notifications/friends stuff' . chr(10); if (function_exists('gc_collect_cycles')) { gc_enable(); } // banners require_code('banners2'); for ($i = $GLOBALS['SITE_DB']->query_value('banners', 'COUNT(*)'); $i < $num_wanted; $i++) { add_banner(uniqid('', true), get_logo_url(), random_line(), random_text(), 100, get_base_url(), 3, '', db_get_first_id(), NULL, db_get_first_id() + 1, 1); } echo 'done banner stuff' . chr(10); if (function_exists('gc_collect_cycles')) { gc_enable(); } // comcode pages require_code('files'); require_code('files2'); for ($i = $GLOBALS['SITE_DB']->query_value('comcode_pages', 'COUNT(*)'); $i < $num_wanted; $i++) { $file = uniqid('', true); /*$path=get_custom_file_base().'/site/pages/comcode_custom/'.fallback_lang().'/'.$file.'.txt'; $myfile=fopen($path,'wt'); fwrite($myfile,random_text()); fclose($myfile); sync_file($path); fix_permissions($path);*/ $GLOBALS['SITE_DB']->query_insert('comcode_pages', array('the_zone' => 'site', 'the_page' => $file, 'p_parent_page' => '', 'p_validated' => 1, 'p_edit_date' => NULL, 'p_add_date' => time(), 'p_submitter' => db_get_first_id(), 'p_show_as_edit' => 0)); } echo 'done comcode stuff' . chr(10); if (function_exists('gc_collect_cycles')) { gc_enable(); } // zones require_code('zones2'); require_code('abstract_file_manager'); for ($i = $GLOBALS['SITE_DB']->query_value('zones', 'COUNT(*)'); $i < min($num_wanted, 1000); $i++) { actual_add_zone(uniqid('', true), random_line(), 'start', random_line(), 'default', 0, 0, 0); } echo 'done zone stuff' . chr(10); if (function_exists('gc_collect_cycles')) { gc_enable(); } // calendar events require_code('calendar2'); for ($i = $GLOBALS['SITE_DB']->query_value('calendar_events', 'COUNT(*)'); $i < $num_wanted; $i++) { add_calendar_event(db_get_first_id(), '', NULL, 0, random_line(), random_text(), 1, 1, intval(date('Y')), intval(date('m')), intval(date('d')), 0, 0); } echo 'done event stuff' . chr(10); if (function_exists('gc_collect_cycles')) { gc_enable(); } // chat rooms require_code('chat2'); require_code('chat'); for ($i = $GLOBALS['SITE_DB']->query_value('chat_rooms', 'COUNT(*)'); $i < $num_wanted; $i++) { $room_id = add_chatroom(random_text(), random_line(), mt_rand(db_get_first_id() + 1, $num_wanted - 1), strval(db_get_first_id() + 1), '', '', '', fallback_lang()); } $room_id = db_get_first_id() + 1; // messages in chat room for ($j = $GLOBALS['SITE_DB']->query_value('chat_messages', 'COUNT(*)'); $j < $num_wanted; $j++) { $_message_parsed = insert_lang_comcode(random_text(), 4); $GLOBALS['SITE_DB']->query_insert('chat_messages', array('system_message' => 0, 'ip_address' => '', 'room_id' => $room_id, 'user_id' => db_get_first_id(), 'date_and_time' => time(), 'the_message' => $_message_parsed, 'text_colour' => get_option('chat_default_post_colour'), 'font_name' => get_option('chat_default_post_font'))); } echo 'done chat stuff' . chr(10); if (function_exists('gc_collect_cycles')) { gc_enable(); } // download categories under a subcategory require_code('downloads2'); $subcat_id = add_download_category(random_line(), db_get_first_id(), random_text(), ''); for ($i = $GLOBALS['SITE_DB']->query_value('download_categories', 'COUNT(*)'); $i < $num_wanted; $i++) { add_download_category(random_line(), $subcat_id, random_text(), ''); } // downloads (remember to test content by the single author) require_code('downloads2'); require_code('awards'); $time = time(); for ($i = $GLOBALS['SITE_DB']->query_value('download_downloads', 'COUNT(*)'); $i < $num_wanted; $i++) { $content_id = add_download(db_get_first_id(), random_line(), get_logo_url(), random_text(), 'admin', random_text(), NULL, 1, 1, 1, 1, '', uniqid('', true) . '.jpg', 100, 110, 1); give_award(db_get_first_id(), strval($content_id), $time - $i); } $content_id = db_get_first_id(); $content_url = build_url(array('page' => 'downloads', 'type' => 'entry', 'id' => $content_id), 'site'); for ($j = $GLOBALS['SITE_DB']->query_value('trackbacks', 'COUNT(*)'); $j < $num_wanted; $j++) { // trackbacks $GLOBALS['SITE_DB']->query_insert('trackbacks', array('trackback_for_type' => 'downloads', 'trackback_for_id' => $content_id, 'trackback_ip' => '', 'trackback_time' => time(), 'trackback_url' => '', 'trackback_title' => random_line(), 'trackback_excerpt' => random_text(), 'trackback_name' => random_line())); // ratings $GLOBALS['SITE_DB']->query_insert('rating', array('rating_for_type' => 'downloads', 'rating_for_id' => $content_id, 'rating_member' => $j + 1, 'rating_ip' => '', 'rating_time' => time(), 'rating' => 3)); // posts in a comment topic $GLOBALS['FORUM_DRIVER']->make_post_forum_topic(get_option('comments_forum_name'), 'downloads_' . strval($content_id), get_member(), random_text(), random_line(), '', do_lang('COMMENT'), $content_url->evaluate(), NULL, NULL, 1, 1); } echo 'done download stuff' . chr(10); if (function_exists('gc_collect_cycles')) { gc_enable(); } // forums under a forum (don't test it can display, just make sure the main index still works) require_code('ocf_forums_action'); for ($i = $GLOBALS['FORUM_DB']->query_value('f_forums', 'COUNT(*)'); $i < $num_wanted; $i++) { ocf_make_forum(random_line(), random_text(), db_get_first_id(), array(), db_get_first_id() + 3); } // forum topics require_code('ocf_topics_action'); require_code('ocf_posts_action'); require_code('ocf_forums'); require_code('ocf_topics'); for ($i = intval(floatval($GLOBALS['FORUM_DB']->query_value('f_topics', 'COUNT(*)')) / 2.0); $i < $num_wanted; $i++) { $topic_id = ocf_make_topic(db_get_first_id(), '', '', NULL, 1, 0, 0, 0, NULL, NULL, false); ocf_make_post($topic_id, random_line(), random_text(), 0, true, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, false, false); } // forum posts in a topic require_code('ocf_topics_action'); require_code('ocf_posts_action'); $topic_id = ocf_make_topic(db_get_first_id() + 1, '', '', NULL, 1, 0, 0, 0, NULL, NULL, false); for ($i = intval(floatval($GLOBALS['FORUM_DB']->query_value('f_posts', 'COUNT(*)')) / 3.0); $i < $num_wanted; $i++) { ocf_make_post($topic_id, random_line(), random_text(), 0, true, 0, 0, NULL, NULL, NULL, mt_rand(db_get_first_id(), $num_wanted - 1), NULL, NULL, NULL, false, false); } echo 'done forum stuff' . chr(10); if (function_exists('gc_collect_cycles')) { gc_enable(); } // clubs require_code('ocf_groups_action'); require_code('ocf_groups'); for ($i = $GLOBALS['FORUM_DB']->query_value('f_groups', 'COUNT(*)'); $i < $num_wanted; $i++) { ocf_make_group(random_line(), 0, 0, 0, random_line(), '', NULL, NULL, NULL, 5, 0, 70, 50, 100, 100, 30000, 700, 25, 1, 0, 0, 0, $i, 1, 0, 1); } echo 'done club stuff' . chr(10); if (function_exists('gc_collect_cycles')) { gc_enable(); } // galleries under a subcategory require_code('galleries2'); $xsubcat_id = uniqid('', true); add_gallery($xsubcat_id, random_line(), random_text(), '', '', 'root'); for ($i = $GLOBALS['SITE_DB']->query_value('galleries', 'COUNT(*)'); $i < $num_wanted; $i++) { add_gallery(uniqid('', true), random_line(), random_text(), '', '', $xsubcat_id); } // images require_code('galleries2'); for ($i = $GLOBALS['SITE_DB']->query_value('images', 'COUNT(*)'); $i < $num_wanted; $i++) { add_image('', 'root', random_text(), get_logo_url(), get_logo_url(), 1, 1, 1, 1, ''); } // videos / validation queue require_code('galleries2'); for ($i = $GLOBALS['SITE_DB']->query_value('videos', 'COUNT(*)'); $i < $num_wanted; $i++) { add_video('', 'root', random_text(), get_logo_url(), get_logo_url(), 0, 1, 1, 1, '', 0, 0, 0); } echo 'done galleries stuff' . chr(10); if (function_exists('gc_collect_cycles')) { gc_enable(); } // newsletter subscribers require_code('newsletter'); for ($i = $GLOBALS['SITE_DB']->query_value('newsletter', 'COUNT(*)'); $i < $num_wanted; $i++) { basic_newsletter_join(uniqid('', true) . '@example.com'); } echo 'done newsletter stuff' . chr(10); if (function_exists('gc_collect_cycles')) { gc_enable(); } // polls (remember to test poll archive) require_code('polls'); for ($i = $GLOBALS['SITE_DB']->query_value('poll', 'COUNT(*)'); $i < $num_wanted; $i++) { $poll_id = add_poll(random_line(), random_line(), random_line(), random_line(), random_line(), random_line(), random_line(), random_line(), random_line(), random_line(), random_line(), 10, 0, 0, 0, 0, ''); } // votes on a poll $poll_id = db_get_first_id(); for ($j = $GLOBALS['SITE_DB']->query_value('poll_votes', 'COUNT(*)'); $j < $num_wanted; $j++) { $cast = mt_rand(1, 6); $ip = uniqid('', true); $GLOBALS['SITE_DB']->query_insert('poll_votes', array('v_poll_id' => $poll_id, 'v_voter_id' => 2, 'v_voter_ip' => $ip, 'v_vote_for' => $cast)); } echo 'done polls stuff' . chr(10); if (function_exists('gc_collect_cycles')) { gc_enable(); } // quizzes require_code('quiz'); for ($i = $GLOBALS['SITE_DB']->query_value('quizzes', 'COUNT(*)'); $i < $num_wanted; $i++) { add_quiz(random_line(), 0, random_text(), random_text(), random_text(), '', 0, time(), NULL, 3, 300, 'SURVEY', 1, '1) Some question'); } echo 'done quizzes stuff' . chr(10); if (function_exists('gc_collect_cycles')) { gc_enable(); } // successful searches (to test the search recommender) // ACTUALLY: I have manually verified the code, it is an isolated portion // cedi pages (do a long descendant tree for some, and orphans for others) // cedi posts (remember to test cedi changes screen) require_code('cedi'); for ($i = $GLOBALS['SITE_DB']->query_value('seedy_pages', 'COUNT(*)'); $i < $num_wanted; $i++) { $page_id = cedi_add_page(random_line(), random_text(), '', 1); cedi_add_post($page_id, random_text(), 1, NULL, false); } echo 'done cedi stuff' . chr(10); if (function_exists('gc_collect_cycles')) { gc_enable(); } // iotds require_code('iotds'); for ($i = $GLOBALS['SITE_DB']->query_value('iotd', 'COUNT(*)'); $i < $num_wanted; $i++) { add_iotd(get_logo_url(), random_line(), random_text(), get_logo_url(), 1, 0, 0, 0, ''); } echo 'done iotd stuff' . chr(10); if (function_exists('gc_collect_cycles')) { gc_enable(); } // logged hack attempts for ($i = $GLOBALS['SITE_DB']->query_value('hackattack', 'COUNT(*)'); $i < $num_wanted; $i++) { $GLOBALS['SITE_DB']->query_insert('hackattack', array('url' => get_base_url(), 'data_post' => '', 'user_agent' => '', 'referer' => '', 'user_os' => '', 'the_user' => db_get_first_id(), 'date_and_time' => time(), 'ip' => uniqid('', true), 'reason' => 'ASCII_ENTITY_URL_HACK', 'reason_param_a' => '', 'reason_param_b' => '')); } // logged hits in one day require_code('site'); for ($i = $GLOBALS['SITE_DB']->query_value('stats', 'COUNT(*)'); $i < $num_wanted; $i++) { log_stats('/testing' . uniqid('', true), mt_rand(100, 2000)); } echo 'done logs stuff' . chr(10); if (function_exists('gc_collect_cycles')) { gc_enable(); } // blogs and news entries (remember to test both blogs [categories] list, and a list of all news entries) require_code('news'); for ($i = $GLOBALS['SITE_DB']->query_value('news', 'COUNT(*)'); $i < $num_wanted; $i++) { add_news(random_line(), random_text(), 'admin', 1, 1, 1, 1, '', random_text(), NULL, NULL, NULL, db_get_first_id() + $i); } echo 'done news stuff' . chr(10); if (function_exists('gc_collect_cycles')) { gc_enable(); } // support tickets require_code('tickets'); require_code('tickets2'); for ($i = intval(floatval($GLOBALS['FORUM_DB']->query_value('f_topics', 'COUNT(*)')) / 2.0); $i < $num_wanted; $i++) { ticket_add_post(mt_rand(db_get_first_id(), $num_wanted - 1), uniqid('', true), db_get_first_id(), random_line(), random_text(), '', ''); } echo 'done tickets stuff' . chr(10); if (function_exists('gc_collect_cycles')) { gc_enable(); } // catalogues require_code('catalogues2'); $root_id = db_get_first_id(); for ($i = $GLOBALS['SITE_DB']->query_value('catalogues', 'COUNT(*)'); $i < $num_wanted; $i++) { $catalogue_name = uniqid('', true); $root_id = actual_add_catalogue($catalogue_name, random_line(), random_text(), mt_rand(0, 3), 1, '', 30); } // catalogue categories under a subcategory (remember to test all catalogue views: atoz, index, and root cat) $catalogue_name = 'products'; $subcat_id = actual_add_catalogue_category($catalogue_name, random_line(), random_text(), '', $root_id); for ($j = $GLOBALS['SITE_DB']->query_value('catalogue_categories', 'COUNT(*)'); $j < $num_wanted; $j++) { actual_add_catalogue_category($catalogue_name, random_line(), random_text(), '', $subcat_id); } echo 'done catalogue stuff' . chr(10); if (function_exists('gc_collect_cycles')) { gc_enable(); } // items in ecommerce store require_code('catalogues2'); $cat_id = $GLOBALS['SITE_DB']->query_value('catalogue_categories', 'MIN(id)', array('c_name' => 'products')); $fields = collapse_1d_complexity('id', $GLOBALS['SITE_DB']->query_select('catalogue_fields', array('id'), array('c_name' => 'products'))); for ($i = $GLOBALS['SITE_DB']->query_value('catalogue_entries', 'COUNT(*)'); $i < $num_wanted; $i++) { $map = array($fields[0] => random_line(), $fields[1] => uniqid('', true), $fields[2] => '1.0', $fields[3] => '1', $fields[4] => '0', $fields[5] => '1', $fields[6] => '0%', $fields[7] => get_logo_url(), $fields[8] => '2.0', $fields[9] => random_text()); $pid = actual_add_catalogue_entry($cat_id, 1, '', 1, 1, 1, $map); unset($map); } // outstanding ecommerce orders $pid = $GLOBALS['SITE_DB']->query_value('catalogue_entries', 'MIN(id)', array('c_name' => 'products')); require_code('shopping'); for ($j = $GLOBALS['SITE_DB']->query_value('shopping_cart', 'COUNT(*)'); $j < $num_wanted; $j++) { $product_det = array('product_id' => $pid, 'product_name' => $fields[0], 'product_code' => $fields[1], 'price' => $fields[2], 'tax' => preg_replace('#[^\\d\\.]#', '', $fields[6]), 'description' => $fields[9], 'quantity' => mt_rand(1, 20), 'product_type' => 'catalogue_items', 'product_weight' => $fields[8]); $GLOBALS['SITE_DB']->query_insert('shopping_cart', array('session_id' => mt_rand(0, 1000000), 'ordered_by' => mt_rand(db_get_first_id() + 1, $num_wanted - 1), 'product_id' => $product_det['product_id'], 'product_name' => $product_det['product_name'], 'product_code' => $product_det['product_code'], 'quantity' => $product_det['quantity'], 'price' => round(floatval($product_det['price']), 2), 'price_pre_tax' => $product_det['tax'], 'product_description' => $product_det['description'], 'product_type' => $product_det['product_type'], 'product_weight' => $product_det['product_weight'], 'is_deleted' => 0)); } for ($j = $GLOBALS['SITE_DB']->query_value('shopping_order', 'COUNT(*)'); $j < $num_wanted; $j++) { $order_id = $GLOBALS['SITE_DB']->query_insert('shopping_order', array('c_member' => mt_rand(db_get_first_id() + 1, $num_wanted - 1), 'session_id' => mt_rand(0, 1000000), 'add_date' => time(), 'tot_price' => '123.00', 'order_status' => 'ORDER_STATUS_awaiting_payment', 'notes' => '', 'purchase_through' => 'purchase_module', 'transaction_id' => '', 'tax_opted_out' => 0), true); $GLOBALS['SITE_DB']->query_insert('shopping_order_details', array('p_id' => 123, 'p_name' => random_line(), 'p_code' => 123, 'p_type' => 'catalogue_items', 'p_quantity' => 1, 'p_price' => '12.00', 'order_id' => $order_id, 'dispatch_status' => '', 'included_tax' => '1.00')); } echo 'done store stuff' . chr(10); if (function_exists('gc_collect_cycles')) { gc_enable(); } echo '{{DONE}}' . chr(10); }
/** * 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_members($db, $table_prefix, $file_base) { $row_start = 0; $rows = array(); do { $rows = $db->query('SELECT * FROM ' . $table_prefix . 'users u LEFT JOIN ' . $table_prefix . 'banlist b ON u.user_id=b.ban_userid WHERE u.user_type<>2 ORDER BY u.user_id', 200, $row_start); foreach ($rows as $row) { if (import_check_if_imported('member', strval($row['user_id']))) { continue; } $test = $GLOBALS['OCF_DRIVER']->get_member_from_username($row['username']); if (!is_null($test)) { import_id_remap_put('member', strval($row['user_id']), $test); continue; } $language = ''; if ($row['user_lang'] != '') { switch ($language) { case 'english': $language = 'EN'; break; } } $primary_group = import_id_remap_get('group', strval($row['group_id'])); $rows2 = $db->query('SELECT * FROM ' . $table_prefix . 'user_group WHERE user_id=' . strval((int) $row['user_id']), 200, $row_start); $secondary_groups = array(); foreach ($rows2 as $row2) { if ($row2['group_id'] != $row['group_id']) { $g = import_id_remap_get('group', strval($row2['group_id']), true); if (!is_null($g)) { $secondary_groups[] = array($g, $row2['user_pending']); } } } $custom_fields = array(ocf_make_boiler_custom_field('im_icq') => $row['user_icq'], ocf_make_boiler_custom_field('im_aim') => $row['user_aim'], ocf_make_boiler_custom_field('im_msn') => $row['user_msnm'], ocf_make_boiler_custom_field('im_yahoo') => $row['user_yim'], ocf_make_boiler_custom_field('interests') => $row['user_interests'], ocf_make_boiler_custom_field('location') => $row['user_from'], ocf_make_boiler_custom_field('occupation') => $row['user_occ']); if ($row['user_website'] != '') { $custom_fields[ocf_make_boiler_custom_field('website')] = strlen($row['user_website']) > 0 ? '[url]' . $row['user_website'] . '[/url]' : ''; } $signature = $this->fix_links($row['user_sig'], $row['user_sig_bbcode_uid'], $db, $table_prefix); $validated = 1; $reveal_age = 0; if (strpos($row['user_birthday'], '-') === false) { list($bday_day, $bday_month, $bday_year) = array(NULL, NULL, NULL); } else { $bday = explode('-', $row['user_birthday']); list($bday_day, $bday_month, $bday_year) = array(intval(trim($bday[0])), intval(trim($bday[1])), intval(trim($bday[2]))); } $views_signatures = 1; $preview_posts = 1; $track_posts = $row['user_notify']; $title = ''; // These are done in the members-files stage $avatar_url = ''; $photo_url = ''; $photo_thumb_url = ''; $password = $row['user_password']; $type = 'phpbb3'; $salt = ''; $id_new = ocf_make_member($row['username'], $password, $row['user_email'], NULL, $bday_day, $bday_month, $bday_year, $custom_fields, strval($row['user_timezone']), $primary_group, $validated, $row['user_regdate'], $row['user_lastvisit'], '', $avatar_url, $signature, !is_null($row['ban_id']) ? 1 : 0, $preview_posts, $reveal_age, $title, $photo_url, $photo_thumb_url, $views_signatures, $track_posts, $language, 1, $row['user_allow_massemail'], '', '', '', false, $type, $salt, 1); // CPF values $cpf_rows = collapse_2d_complexity('field_name', 'field_type', $db->query('SELECT field_name,field_type FROM ' . $table_prefix . 'profile_fields f')); $rows2 = $db->query('SELECT * FROM ' . $table_prefix . 'profile_fields_data WHERE user_id=' . strval((int) $row['user_id']), 1); $row2 = array(); if (array_key_exists(0, $rows2)) { foreach ($rows2[0] as $key => $val) { if (substr($key, 0, 3) == 'pf_') { if (is_null($val)) { if ($cpf_rows[substr($key, 3)] == FIELD_INT) { $val = NULL; } elseif ($cpf_rows[substr($key, 3)] == FIELD_BOOL) { $val = NULL; } elseif ($cpf_rows[substr($key, 3)] == FIELD_DATE) { $val = NULL; } else { $val = ''; } } $row2['field_' . strval(import_id_remap_get('cpf', substr($key, 3)))] = $val; } } $GLOBALS['FORUM_DB']->query_update('f_member_custom_fields', $row2, array('mf_member_id' => $id_new), '', 1); } // Fix usergroup leadership $GLOBALS['FORUM_DB']->query_update('f_groups', array('g_group_leader' => $id_new), array('g_group_leader' => -$row['user_id'])); import_id_remap_put('member', strval($row['user_id']), $id_new); // Set up usergroup membership foreach ($secondary_groups as $s) { list($group, $userpending) = $s; ocf_add_member_to_group($id_new, $group, 1 - $userpending); } } $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_ocf_members($db, $table_prefix, $file_base) { $row_start = 0; $rows = array(); do { $rows = $db->query('SELECT u.uid AS \'muid\',u.*,b.* FROM ' . $table_prefix . 'users u LEFT JOIN ' . $table_prefix . 'banned b ON u.uid=b.uid WHERE u.uid<>-1 ORDER BY u.uid', 200, $row_start); foreach ($rows as $row) { if (import_check_if_imported('member', strval($row['muid']))) { continue; } $test = $GLOBALS['OCF_DRIVER']->get_member_from_username($row['username']); if (!is_null($test)) { import_id_remap_put('member', strval($row['muid']), $test); continue; } $language = ''; if ($row['language'] != '') { switch ($language) { case 'english': default: $language = 'EN'; break; } } $primary_group = $row['usergroup']; $_secondary_groups = explode(',', $row['additionalgroups']); $secondary_groups = array(); foreach ($_secondary_groups as $_sec_group) { $sec_group = import_id_remap_get('group', $_sec_group, true); if (!is_null($sec_group)) { $secondary_groups[] = $sec_group; } } //array_map('intval',); $primary_group = import_id_remap_get('group', strval($row['usergroup'])); if ($row['usergroup'] == 4) { $secondary_groups[] = db_get_first_id() + 1; } $custom_fields = array(ocf_make_boiler_custom_field('im_icq') => $row['icq'], ocf_make_boiler_custom_field('im_aim') => $row['aim'], ocf_make_boiler_custom_field('im_msn') => $row['msn'], ocf_make_boiler_custom_field('im_yahoo') => $row['yahoo']); if ($row['website'] != '') { $custom_fields[ocf_make_boiler_custom_field('website')] = strlen($row['website']) > 0 ? '[url]' . $row['website'] . '[/url]' : ''; } $signature = $this->fix_links($row['signature'], $db, $table_prefix); $validated = 1; $reveal_age = 0; if ($row['birthday'] != '') { $birthdate = date('Y-m-d', strtotime($row['birthday'])); $birthdata = array_map('intval', explode('-', $birthdate)); $bday_day = isset($birthdata[0]) && $birthdata[0] != 0 ? $birthdata[0] : NULL; $bday_month = isset($birthdata[1]) && $birthdata[1] != 0 ? $birthdata[1] : NULL; $bday_year = isset($birthdata[2]) && $birthdata[2] != 0 ? $birthdata[2] : NULL; } else { list($bday_day, $bday_month, $bday_year) = array(NULL, NULL, NULL); } $views_signatures = 1; $preview_posts = 1; $track_posts = $row['allownotices']; $title = $row['usertitle']; $title = @html_entity_decode($title, ENT_QUOTES, get_charset()); // These are done in the members-files stage $avatar_url = ''; $photo_url = ''; $photo_thumb_url = ''; $password = $row['password']; $type = 'md5'; $salt = $row['salt']; $id_new = ocf_make_member($row['username'], $password, $row['email'], NULL, $bday_day, $bday_month, $bday_year, $custom_fields, strval($row['timezone']), $primary_group, $validated, $row['regdate'], $row['lastvisit'], '', $avatar_url, $signature, $row['lifted'] > time() ? 1 : 0, $preview_posts, $reveal_age, $title, $photo_url, $photo_thumb_url, $views_signatures, $track_posts, $language, $row['receivepms'], $row['receivepms'], '', '', '', false, $type, $salt, 1); // Fix usergroup leadership $GLOBALS['FORUM_DB']->query_update('f_groups', array('g_group_leader' => $id_new), array('g_group_leader' => -$row['muid'])); import_id_remap_put('member', strval($row['muid']), $id_new); // Set up usergroup membership foreach ($secondary_groups as $s) { ocf_add_member_to_group($id_new, $s, 1); } } $row_start += 200; } while (count($rows) > 0); }
/** * Standard aed_module add actualiser. * * @return ID_TEXT The ID of the entry added */ function add_actualisation() { $username = post_param('username'); $member_id = $GLOBALS['FORUM_DRIVER']->get_member_from_username($username); if (is_null($member_id)) { require_code('ocf_member_action'); $member_id = ocf_make_member($username, uniqid('', true), '', array(), NULL, NULL, NULL, array(), NULL, NULL, 1, NULL, NULL, '', NULL, '', 0, 0, 1, '', '', '', 1, 1, NULL, 1, 1, '', NULL, '', false); } $request = get_booking_request_from_form(); $request = save_booking_form_to_db($request, array(), $member_id); // Find $i by loading all member requests and finding which one this is contained in $request = get_member_booking_request($member_id); foreach ($request as $i => $r) { foreach ($r['_rows'] as $row) { if ($row['id'] == $request[0]['_rows'][0]['id']) { break 2; } } } return strval($member_id) . '_' . strval($i); }
/** * 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_members($db, $table_prefix, $file_base) { $row_start = 0; $rows = array(); $default_group = get_first_default_group(); do { $rows = $db->query('SELECT * FROM ' . $table_prefix . 'members WHERE id_member<>-1 ORDER BY id_member', 200, $row_start); foreach ($rows as $row) { if (import_check_if_imported('member', strval($row['id_member']))) { continue; } $test = $GLOBALS['OCF_DRIVER']->get_member_from_username($row['member_name']); if (!is_null($test)) { import_id_remap_put('member', strval($row['id_member']), $test); continue; } $language = 'EN'; $secondary = explode(',', $row['additional_groups']); $secondary_groups = array(); foreach ($secondary as $g) { if (trim($g) != '') { $g = import_id_remap_get('group', $g, true); if (!is_null($g)) { $secondary_groups[] = intval($g); } } } $primary_group = $row['id_group']; if ($primary_group == 0) { $primary_group = $row['id_post_group']; } if ($primary_group == 0) { $primary_group = $default_group; } else { $primary_group = import_id_remap_get('group', strval($primary_group)); } $custom_fields = array(ocf_make_boiler_custom_field('im_icq') => $row['icq'], ocf_make_boiler_custom_field('im_aim') => $row['aim'], ocf_make_boiler_custom_field('im_msn') => $row['msn'], ocf_make_boiler_custom_field('im_yahoo') => $row['yim']); if ($row['website_url'] != '') { $custom_fields[ocf_make_boiler_custom_field('website')] = $row['website_url']; } $signature = str_replace(array('[html]', '[/html]'), array('', ''), html_to_comcode($row['signature'])); $signature = $this->fix_links($signature, $db, $table_prefix, $file_base); $validated = 1; $reveal_age = 0; if ($row['birthdate'] != '') { $birthdate = $row['birthdate']; $birthdata = explode('-', $birthdate); $bday_day = isset($birthdata[0]) && $birthdata[0] != '' ? $birthdata[0] : NULL; $bday_month = isset($birthdata[1]) && $birthdata[1] != '' ? $birthdata[1] : NULL; $bday_year = isset($birthdata[2]) && $birthdata[2] != '' ? $birthdata[2] : NULL; } else { list($bday_day, $bday_month, $bday_year) = array(NULL, NULL, NULL); } $views_signatures = 1; $preview_posts = 1; $track_posts = $row['notify_announcements']; $title = ''; // These are done in the members-files stage $avatar_url = ''; $photo_url = ''; $photo_thumb_url = ''; $password = $row['passwd']; $type = 'smf'; $salt = $row['password_salt']; $allow_emails = intval($row['instant_messages']) > 0 ? 1 : 0; if ($row['date_registered'] == 0) { $row['date_registered'] = time(); } $id_new = ocf_make_member($row['member_name'], $password, $row['email_address'], NULL, $bday_day, $bday_month, $bday_year, $custom_fields, $row['time_offset'] == 0 ? '' : strval($row['time_offset']), $primary_group, $validated, $row['date_registered'], $row['last_login'], '', $avatar_url, $signature, 0, $preview_posts, $reveal_age, $title, $photo_url, $photo_thumb_url, $views_signatures, $track_posts, $language, $allow_emails, 1, '', '', '', false, $type, $salt, 1); //cpf stuff $cpf_rows = $db->query('SELECT id_field, col_name FROM ' . $table_prefix . 'custom_fields'); foreach ($cpf_rows as $cpf_row) { $cpf_id = import_id_remap_get('cpf', strval($cpf_row['id_field'])); if (!($cpf_value = $db->query('SELECT value FROM ' . $table_prefix . 'themes WHERE id_member=' . $row['id_member'] . ' AND variable=\'' . $cpf_row['col_name'] . '\''))) { continue; } $value = isset($cpf_value[0]['value']) ? $cpf_value[0]['value'] : ''; ocf_set_custom_field($id_new, $cpf_id, $value); } // Fix usergroup leadership $GLOBALS['FORUM_DB']->query_update('f_groups', array('g_group_leader' => $id_new), array('g_group_leader' => $row['id_member'])); import_id_remap_put('member', strval($row['id_member']), $id_new); // Set up usergroup membership foreach ($secondary_groups as $s) { ocf_add_member_to_group($id_new, $s, 1); } } $row_start += 200; } while (count($rows) > 0); }
/** * The actualiser for importing a CSV file. * * @return tempcode The UI */ function _import_csv() { $title = get_page_title('IMPORT_MEMBER_CSV'); disable_php_memory_limit(); // Even though we split into chunks, PHP does leak memory :( $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/import_csv'; if (function_exists('set_time_limit')) { @set_time_limit(0); } require_lang('ocf'); require_code('ocf_members_action'); $default_password = post_param('default_password'); $num_added = 0; $num_edited = 0; $done = 0; $headings = $this->_get_csv_headings(); $all_cpfs = $GLOBALS['FORUM_DB']->query_select('f_custom_fields', array('id', 'cf_default', 'cf_type', 'cf_name'), NULL, 'ORDER BY cf_order'); foreach ($all_cpfs as $i => $c) { $c['text_original'] = get_translated_text($c['cf_name'], $GLOBALS['FORUM_DB']); $all_cpfs[$i] = $c; $headings[$c['text_original']] = NULL; } $_all_groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(false, false, true); $all_groups = array_flip($_all_groups); $all_members = collapse_2d_complexity('id', 'm_username', $GLOBALS['FORUM_DB']->query_select('f_members', array('id', 'm_username'))); $all_members_flipped = array_flip($all_members); // Import require_code('uploads'); if (is_swf_upload(true) || array_key_exists('file', $_FILES) && is_uploaded_file($_FILES['file']['tmp_name'])) { $_csv_data = array(); $fixed_contents = unixify_line_format(file_get_contents($_FILES['file']['tmp_name'])); $myfile = @fopen($_FILES['file']['tmp_name'], 'wb'); if ($myfile !== false) { fwrite($myfile, $fixed_contents); fclose($myfile); } $myfile = fopen($_FILES['file']['tmp_name'], 'rb'); $del = ','; $csv_header = fgetcsv($myfile, 102400, $del); if ($csv_header === false) { warn_exit(do_lang_tempcode('NO_DATA_IMPORTED')); } if (count($csv_header) == 1 && strpos($csv_header[0], ';') !== false) { $del = ';'; rewind($myfile); $csv_header = fgetcsv($myfile, 102400, $del); } while (($csv_line = fgetcsv($myfile, 102400, $del)) !== false) { $line = array(); foreach ($csv_header as $i => $h) { $extracted_value = trim(unixify_line_format(array_key_exists($i, $csv_line) ? $csv_line[$i] : '')); if (strpos($h, ':') !== false) { $parts = explode(':', $h, 2); $h = trim($parts[0]); if ($extracted_value != '') { $extracted_value = $parts[1] . ': ' . $extracted_value; } } if (array_key_exists($h, $line)) { if ($extracted_value != '') { $line[$h] .= ($line[$h] != '' ? chr(10) : '') . $extracted_value; } } else { $line[$h] = $extracted_value; } } if (!array_key_exists('Username', $line) || $line['Username'] == '') { // Can we auto-generate it $forename = NULL; if (array_key_exists('Forenames', $line)) { $forename = $line['Forenames']; } if (array_key_exists('Forename', $line)) { $forename = $line['Forename']; } if (array_key_exists('First name', $line)) { $forename = $line['First name']; } if (array_key_exists('First Name', $line)) { $forename = $line['First Name']; } $surname = NULL; if (array_key_exists('Surname', $line)) { $surname = $line['Surname']; } if (array_key_exists('Last name', $line)) { $surname = $line['Last name']; } if (array_key_exists('Last Name', $line)) { $surname = $line['Last Name']; } if (!is_null($forename) || !is_null($surname)) { // Can we get a year too? $year = ''; foreach ($line as $tl_key => $tl_val) { if (substr($tl_key, 0, 4) == 'Year') { $year = $tl_val; break; } } if (strlen($year) == 4 && (substr($year, 0, 2) == '19' || substr($year, 0, 2) == '20')) { $year = substr($year, 2); } // Tidy up forename $_forename = preg_replace('#[^\\w]#', '', preg_replace('#[\\s\\.].*#', '', $forename)); // Tidy up surname (last bit strips like 'OBE') $_surname = preg_replace('#[^\\w]#', '', trim(preg_replace('#\\s*[A-Z\\d][A-Z\\d]+#', '', $surname))); // Put it together $line['Username'] = ucfirst($_forename) . ucfirst($_surname) . $year; } else { continue; // This field is needed } } $username = $line['Username']; $linked_id = NULL; if (array_key_exists('ID', $line)) { $linked_id = $line['ID'] != '' && array_key_exists(intval($line['ID']), $all_members) ? intval($line['ID']) : NULL; } if (is_null($linked_id)) { $linked_id = array_key_exists($username, $all_members_flipped) ? $all_members_flipped[$username] : NULL; } $new_member = is_null($linked_id); $email_address_key = 'E-mail address'; if (array_key_exists('Email address', $line)) { $email_address_key = 'Email address'; } if (array_key_exists('E-mail Address', $line)) { $email_address_key = 'E-mail Address'; } if (array_key_exists('Email Address', $line)) { $email_address_key = 'Email Address'; } if (array_key_exists('E-mail', $line)) { $email_address_key = 'E-mail'; } if (array_key_exists('Email', $line)) { $email_address_key = 'Email'; } $dob_key = 'Date of birth'; if (array_key_exists('Date Of Birth', $line)) { $dob_key = 'Date Of Birth'; } if (array_key_exists('DOB', $line)) { $dob_key = 'DOB'; } // If it's an edited member, add in their existing CSV details, so that if it's a partial merge it'll still work without deleting anything! if (!$new_member) { $member_groups = $GLOBALS['FORUM_DB']->query_select('f_group_members', array('gm_member_id', 'gm_group_id'), array('gm_validated' => 1, 'gm_member_id' => $linked_id)); $member_cpfs = list_to_map('mf_member_id', $GLOBALS['FORUM_DB']->query_select('f_member_custom_fields', array('*'), array('mf_member_id' => $linked_id), '', 1)); $this_record = $this->_get_csv_member_record($member_cpfs, $GLOBALS['FORUM_DRIVER']->get_member_row($linked_id), $_all_groups, $headings, $all_cpfs, $member_groups); // Remember "+" in PHP won't overwrite existing keys if (!array_key_exists($email_address_key, $line)) { unset($this_record['E-mail address']); } if (!array_key_exists($dob_key, $line)) { unset($this_record['Date of birth']); } $line += $this_record; } // Set up member row if (array_key_exists('Password', $line) && $line['Password'] != '') { $parts = explode('/', $line['Password']); $password = $parts[0]; $salt = array_key_exists(1, $parts) ? $parts[1] : NULL; $password_compatibility_scheme = array_key_exists(2, $parts) ? $parts[2] : NULL; } else { $password = NULL; $salt = NULL; $password_compatibility_scheme = NULL; } $matches = array(); if (array_key_exists($email_address_key, $line)) { $email_address = $line[$email_address_key]; } else { $email_address = NULL; } if (preg_match('#^([^\\s]*)\\s+\\(.*\\)$#', $email_address, $matches) != 0) { $email_address = $matches[1]; } if (preg_match('#^.*\\s+<(.*)>$#', $email_address, $matches) != 0) { $email_address = $matches[1]; } if (array_key_exists($dob_key, $line)) { $parts = explode('/', $line[$dob_key]); $dob_day = array_key_exists(2, $parts) ? intval($parts[2]) : NULL; $dob_month = array_key_exists(1, $parts) ? intval($parts[1]) : NULL; $dob_year = array_key_exists(0, $parts) ? intval($parts[0]) : NULL; } else { $dob_day = NULL; $dob_month = NULL; $dob_year = NULL; } $validated = array_key_exists('Validated', $line) ? strtoupper($line['Validated']) == 'YES' || $line['Validated'] == '1' || strtoupper($line['Validated']) == 'Y' || strtoupper($line['Validated']) == 'ON' ? 1 : 0 : 1; if (array_key_exists('Join time', $line)) { if (strpos($line['Join time'], '-') !== false) { $parts = explode('-', $line['Join time']); } else { $parts = explode('/', $line['Join time']); } if (!array_key_exists(1, $parts)) { $parts[1] = '1'; } if (!array_key_exists(2, $parts)) { $parts[2] = '1'; } if (strlen($parts[2]) != 4) { $join_time = mktime(0, 0, 0, intval($parts[1]), intval($parts[2]), intval($parts[0])); // yy(yy)-mm-dd } else { $join_time = mktime(0, 0, 0, intval($parts[1]), intval($parts[0]), intval($parts[2])); // dd-mm-yyyy } if ($join_time > time()) { $join_time = time(); } // Fixes MySQL out of range error that could happen } else { $join_time = NULL; } $avatar_url = array_key_exists('Avatar', $line) ? $line['Avatar'] : ''; if (!is_null($avatar_url)) { if (substr($avatar_url, 0, strlen(get_base_url() . '/')) == get_base_url() . '/') { $avatar_url = substr($avatar_url, strlen(get_base_url() . '/')); } } $signature = array_key_exists('Signature', $line) ? $line['Signature'] : ''; $is_perm_banned = array_key_exists('Banned', $line) ? strtoupper($line['Banned']) == 'YES' || $line['Banned'] == '1' || strtoupper($line['Banned']) == 'Y' || strtoupper($line['Banned']) == 'ON' ? 1 : 0 : 0; $reveal_age = array_key_exists('Reveal age', $line) ? strtoupper($line['Reveal age']) == 'YES' || $line['Reveal age'] == '1' || strtoupper($line['Reveal age']) == 'Y' || strtoupper($line['Reveal age']) == 'ON' ? 1 : 0 : 0; $language = array_key_exists('Language', $line) ? $line['Language'] : ''; $allow_emails = array_key_exists('Accept member e-mails', $line) ? strtoupper($line['Accept member e-mails']) == 'YES' || $line['Accept member e-mails'] == '1' || strtoupper($line['Accept member e-mails']) == 'Y' || strtoupper($line['Accept member e-mails']) == 'ON' ? 1 : 0 : 0; $allow_emails_from_staff = array_key_exists('Opt-in', $line) ? strtoupper($line['Opt-in']) == 'YES' || $line['Opt-in'] == '1' || strtoupper($line['Opt-in']) == 'Y' || strtoupper($line['Opt-in']) == 'ON' ? 1 : 0 : 0; $primary_group = NULL; $groups = NULL; if (array_key_exists('Usergroup', $line)) { $parts = explode('/', $line['Usergroup']); foreach ($parts as $p) { if (!array_key_exists($p, $all_groups)) { require_code('ocf_groups_action'); $g_id = ocf_make_group($p, 0, 0, 0, ''); $all_groups[$p] = $g_id; $_group_edit_url = build_url(array('page' => 'admin_ocf_groups', 'type' => '_ed', 'id' => $g_id), get_module_zone('admin_ocf_groups')); $group_edit_url = $_group_edit_url->evaluate(); attach_message(do_lang_tempcode('MEMBER_IMPORT_GROUP_ADDED', escape_html($p), escape_html($group_edit_url)), 'inform'); } } $primary_group = $all_groups[$parts[0]]; unset($parts[0]); $groups = array(); foreach ($parts as $p) { $groups[] = $all_groups[$p]; } } $photo_url = array_key_exists('Photo', $line) ? $line['Photo'] : ''; if ($photo_url != '') { require_code('images'); $photo_thumb_url = 'uploads/ocf_photos_thumbs/' . uniqid('', true) . '.png'; convert_image($photo_url, $photo_thumb_url, -1, -1, intval(get_option('thumb_width')), false); } else { $photo_thumb_url = ''; } $custom_fields = array(); foreach ($all_cpfs as $cpf) { $custom_fields[$cpf['id']] = array_key_exists($cpf['text_original'], $line) ? $line[$cpf['text_original']] : $cpf['cf_default']; if (!array_key_exists($cpf['text_original'], $line) && $cpf['cf_type'] == 'list') { $parts = explode($custom_fields[$cpf['id']], '|'); $custom_fields[$cpf['id']] = $parts[0]; } if ($cpf['cf_type'] == 'integer') { $custom_fields[$cpf['id']] = intval($custom_fields[$cpf['id']]); } elseif ($cpf['cf_type'] == 'tick') { $custom_fields[$cpf['id']] = strtoupper($custom_fields[$cpf['id']]) == 'YES' || strtoupper($custom_fields[$cpf['id']]) == 'Y' || strtoupper($custom_fields[$cpf['id']]) == 'ON' || $custom_fields[$cpf['id']] == '1' ? 1 : 0; } elseif ($cpf['cf_type'] == 'short_text' || $cpf['cf_type'] == 'short_trans') { $custom_fields[$cpf['id']] = substr(str_replace(chr(10), ', ', str_replace(',' . chr(10), chr(10), $custom_fields[$cpf['id']])), 0, 255); } elseif ($cpf['cf_type'] == 'long_text' || $cpf['cf_type'] == 'long_trans') { //$custom_fields[$cpf['id']]=$custom_fields[$cpf['id']]; } elseif ($cpf['cf_type'] == 'float') { if (preg_match('#^(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\\n(\\d\\d\\d\\d)$#', $custom_fields[$cpf['id']]) != 0) { $parts = explode(chr(10), $custom_fields[$cpf['id']], 2); $month_lookup = array('Jan' => 0.1, 'Feb' => 0.2, 'Mar' => 0.3, 'Apr' => 0.4, 'May' => 0.5, 'Jun' => 0.6, 'Jul' => 0.7, 'Aug' => 0.8, 'Sep' => 0.9, 'Oct' => 0.1, 'Nov' => 0.11, 'Dec' => 0.12); $custom_fields[$cpf['id']] = floatval($parts[1]) + $month_lookup[$parts[0]]; } else { $custom_fields[$cpf['id']] = floatval($custom_fields[$cpf['id']]); } } unset($line[$cpf['text_original']]); } foreach (array_keys($headings) as $h) { unset($line[$h]); } unset($line[$email_address_key]); unset($line[$dob_key]); foreach ($line as $h => $f) { $cf_id = ocf_make_custom_field($h, 0, '', '', 0, 0, 0, 0, 'long_text'); $_cpf_edit_url = build_url(array('page' => 'admin_ocf_customprofilefields', 'type' => '_ed', 'id' => $cf_id), get_module_zone('admin_ocf_customprofilefields')); $cpf_edit_url = $_cpf_edit_url->evaluate(); attach_message(do_lang_tempcode('MEMBER_IMPORT_CPF_ADDED', escape_html($h), escape_html($cpf_edit_url)), 'inform'); $custom_fields[$cf_id] = $f; $all_cpfs[] = array('id' => $cf_id, 'cf_default' => '', 'text_original' => $h, 'cf_type' => 'short_line'); } if ($new_member) { if (is_null($password)) { $password = $default_password; } if (is_null($salt)) { $salt = ''; } if (is_null($password_compatibility_scheme)) { $password_compatibility_scheme = ''; } $linked_id = ocf_make_member($username, $password, is_null($email_address) ? '' : $email_address, $groups, $dob_day, $dob_month, $dob_year, $custom_fields, NULL, $primary_group, $validated, $join_time, NULL, '', $avatar_url, $signature, $is_perm_banned, get_option('default_preview_guests') == '1' ? 1 : 0, $reveal_age, '', $photo_url, $photo_thumb_url, 1, 1, $language, $allow_emails, $allow_emails_from_staff, '', NULL, '', false, $password_compatibility_scheme, $salt, 1, NULL, NULL, 0, '*', ''); $all_members[$linked_id] = $username; $all_members_flipped[$username] = $linked_id; $num_added++; } else { $old_username = $GLOBALS['OCF_DRIVER']->get_member_row_field($linked_id, 'm_username'); if ($old_username == $username) { $username = NULL; } ocf_edit_member($linked_id, $email_address, NULL, $dob_day, $dob_month, $dob_year, NULL, $primary_group, $custom_fields, NULL, $reveal_age, NULL, NULL, $language, $allow_emails, $allow_emails_from_staff, $validated, $username, $password, NULL, NULL, NULL, NULL, NULL, $join_time, $avatar_url, $signature, $is_perm_banned, $photo_url, $photo_thumb_url, $salt, $password_compatibility_scheme, true); $num_edited++; } $done++; } fclose($myfile); } else { warn_exit(do_lang_tempcode('IMPROPERLY_FILLED_IN_UPLOAD')); } if ($done == 0) { warn_exit(do_lang_tempcode('NO_DATA_IMPORTED')); } breadcrumb_set_parents(array(array('_SEARCH:admin_ocf_join:menu', do_lang_tempcode('MEMBERS')), array('_SEARCH:admin_ocf_join:import_csv', do_lang_tempcode('IMPORT_MEMBER_CSV')))); breadcrumb_set_self(do_lang_tempcode('DONE')); return inform_screen($title, do_lang_tempcode('NUM_MEMBERS_IMPORTED', escape_html(integer_format($num_added)), escape_html(integer_format($num_edited)))); }
/** * 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_members($db, $table_prefix, $file_base) { $default_group = get_first_default_group(); $row_start = 0; $rows = array(); do { $rows = $db->query('SELECT * FROM ' . $table_prefix . 'users u ORDER BY u.id', 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; } $language = ''; if ($row['language'] != '') { switch ($language) { case 'english': default: $language = 'EN'; break; } } //$primary_group=$default_group; $primary_group = import_id_remap_get('group', strval($row['u_member_group']), true); if (is_null($primary_group)) { $primary_group = $default_group; } $secondary_groups = array(); $custom_fields = array(ocf_make_boiler_custom_field('im_icq') => $row['icq'], ocf_make_boiler_custom_field('im_aim') => $row['aim'], ocf_make_boiler_custom_field('im_msn') => $row['msn'], ocf_make_boiler_custom_field('im_yahoo') => $row['yim'], ocf_make_boiler_custom_field('location') => $row['location']); if ($row['www'] != '') { $custom_fields[ocf_make_boiler_custom_field('website')] = strlen($row['www']) > 0 ? '[url]' . $row['www'] . '[/url]' : ''; } $signature = $this->fix_links($row['sig'], $db, $table_prefix, $file_base); $validated = $row['act_status']; $reveal_age = $row['birth_date'] != '' ? 1 : 0; $bits = explode('-', $row['birth_date']); if ($reveal_age == 1 && count($bits) == 3) { list($bday_day, $bday_month, $bday_year) = $bits; } else { list($bday_day, $bday_month, $bday_year) = array(0, 0, 0); } $views_signatures = 1; $preview_posts = 1; $track_posts = $row['pm_notify']; $title = $row['customtitle']; $title = @html_entity_decode($title, ENT_QUOTES, get_charset()); // These are done in the members-files stage $avatar_url = $row['avatar']; $photo_url = $row['ppic']; $photo_thumb_url = ''; $password = $row['password']; $type = 'aef'; $salt = $row['salt']; $id_new = ocf_make_member($row['username'], $password, $row['email'], NULL, $bday_day, $bday_month, $bday_year, $custom_fields, strval($row['timezone']), $primary_group, $validated, $row['r_time'], $row['lastlogin_1'], '', $avatar_url, $signature, $row['temp_ban'] != 0 ? 1 : 0, $preview_posts, $reveal_age, $title, $photo_url, $photo_thumb_url, $views_signatures, $track_posts, $language, 1, 1, '', '', '', false, $type, $salt, 1); // Fix group leadership $GLOBALS['FORUM_DB']->query_update('f_groups', array('g_group_leader' => $id_new), array('g_group_leader' => -$row['id'])); 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); } } } } } } }
/** * 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_members($db, $table_prefix, $file_base) { $row_start = 0; $rows = array(); do { $rows = $db->query('SELECT * FROM ' . $table_prefix . 'users ORDER BY user_id', 200, $row_start); foreach ($rows as $row) { if (import_check_if_imported('member', strval($row['user_id']))) { continue; } $test = $GLOBALS['OCF_DRIVER']->get_member_from_username($row['user_name']); if (!is_null($test)) { import_id_remap_put('member', strval($row['user_id']), $test); continue; } $language = ''; if ($row['user_language'] != '') { switch ($language) { case 'english': $language = 'EN'; break; } } $primary_group = import_id_remap_get('group', $row['user_group_id']); $secondary_groups = array(); $custom_fields = array(ocf_make_boiler_custom_field('im_icq') => $row['user_icq'], ocf_make_boiler_custom_field('im_aim') => $row['user_aim'], ocf_make_boiler_custom_field('im_msn') => $row['user_msnm'], ocf_make_boiler_custom_field('im_yahoo') => $row['user_ym'], ocf_make_boiler_custom_field('interests') => $row['user_interests'], ocf_make_boiler_custom_field('location') => $row['user_city'] . ',' . $row['user_region'] . ',' . $row['user_country'], ocf_make_boiler_custom_field('occupation') => $row['user_occupation']); if ($row['user_homepage'] != '') { $custom_fields[ocf_make_boiler_custom_field('website')] = strlen($row['user_homepage']) > 0 ? '[url]' . $row['user_homepage'] . '[/url]' : ''; } $signature = $this->fix_links($row['user_signature'], $db, $table_prefix, $file_base); $validated = $row['user_activation_key'] == '' ? 1 : 0; $reveal_age = 0; $exp = explode('-', $row['user_birthday']); list($bday_day, $bday_month, $bday_year) = array($exp[2], $exp[1], $exp[0]); $views_signatures = 1; $preview_posts = 1; $title = ''; $photo_url = ''; $photo_thumb_url = ''; $avatar_url = $row['user_avatar']; if (substr($avatar_url, 0, strlen('images/avatars/galleries/')) == 'images/avatars/galleries/') { $avatar_url = str_replace('images/avatars/galleries/', 'themes/default/images/ocf_default_avatars/', $avatar_url); } else { $avatar_url = str_replace('images/avatars/', 'uploads/ocf_avatars/', $avatar_url); } $password = $row['user_password']; $type = 'md5'; $salt = ''; $id_new = ocf_make_member($row['user_name'], $password, $row['user_email'], NULL, $bday_day, $bday_month, $bday_year, $custom_fields, NULL, $primary_group, $validated, strtotime($row['user_joined']), strtotime($row['user_joined']), '', $avatar_url, $signature, 0, $preview_posts, $reveal_age, $title, $photo_url, $photo_thumb_url, $views_signatures, 0, $language, 1, $row['user_admin_emails'], '', '', '', false, $type, $salt, 1); // Fix usergroup leadership $GLOBALS['FORUM_DB']->query_update('f_groups', array('g_group_leader' => $id_new), array('g_group_leader' => -$row['user_id'])); import_id_remap_put('member', strval($row['user_id']), $id_new); // Set up usergroup membership foreach ($secondary_groups as $s) { list($group, $userpending) = $s; ocf_add_member_to_group($id_new, $group, 1 - $userpending); } // OCP fields foreach ($row as $field => $val) { if (substr($val, 0, 4) == 'ocp_') { $GLOBALS['OCF_DRIVER']->set_custom_field($id_new, $field, substr($val, 4)); } } } $row_start += 200; } while (count($rows) > 0); }
/** * Actualise the join form. * * @param boolean Whether to handle CAPTCHA (if enabled at all) * @param boolean Whether to ask for intro messages (if enabled at all) * @param boolean Whether to check for invites (if enabled at all) * @param boolean Whether to check email-address restrictions (if enabled at all) * @param boolean Whether to require staff confirmation (if enabled at all) * @param boolean Whether to force email address validation (if enabled at all) * @param boolean Whether to do COPPA checks (if enabled at all) * @param boolean Whether to instantly log the user in * @return array A tuple: Messages to show (currently nothing else in tuple) */ function ocf_join_actual($captcha_if_enabled = true, $intro_message_if_enabled = true, $invites_if_enabled = true, $one_per_email_address_if_enabled = true, $confirm_if_enabled = true, $validate_if_enabled = true, $coppa_if_enabled = true, $instant_login = false) { ocf_require_all_forum_stuff(); require_css('ocf'); require_code('ocf_members_action'); require_code('ocf_members_action2'); // Read in data $username = trim(post_param('username')); ocf_check_name_valid($username, NULL, NULL, true); // Adjusts username if needed $password = trim(post_param('password')); $password_confirm = trim(post_param('password_confirm')); if ($password != $password_confirm) { warn_exit(make_string_tempcode(escape_html(do_lang('PASSWORD_MISMATCH')))); } $confirm_email_address = post_param('email_address_confirm', NULL); $email_address = trim(post_param('email_address')); if (!is_null($confirm_email_address)) { if (trim($confirm_email_address) != $email_address) { warn_exit(make_string_tempcode(escape_html(do_lang('EMAIL_ADDRESS_MISMATCH')))); } } require_code('type_validation'); if (!is_valid_email_address($email_address)) { warn_exit(do_lang_tempcode('INVALID_EMAIL_ADDRESS')); } if ($invites_if_enabled) { if (get_option('is_on_invites') == '1') { $test = $GLOBALS['FORUM_DB']->query_value_null_ok('f_invites', 'i_inviter', array('i_email_address' => $email_address, 'i_taken' => 0)); if (is_null($test)) { warn_exit(do_lang_tempcode('NO_INVITE')); } } $GLOBALS['FORUM_DB']->query_update('f_invites', array('i_taken' => 1), array('i_email_address' => $email_address, 'i_taken' => 0), '', 1); } $dob_day = post_param_integer('dob_day', NULL); $dob_month = post_param_integer('dob_month', NULL); $dob_year = post_param_integer('dob_year', NULL); $reveal_age = post_param_integer('reveal_age', 0); $timezone = post_param('timezone', get_users_timezone()); $language = post_param('language', get_site_default_lang()); $allow_emails = post_param_integer('allow_emails', 0); $allow_emails_from_staff = post_param_integer('allow_emails_from_staff', 0); $groups = ocf_get_all_default_groups(true); // $groups will contain the built in default primary group too (it is not $secondary_groups) $primary_group = post_param_integer('primary_group', NULL); if ($primary_group !== NULL && !in_array($primary_group, $groups)) { // Check security $test = $GLOBALS['FORUM_DB']->query_value('f_groups', 'g_is_presented_at_install', array('id' => $primary_group)); if ($test == 1) { $groups = ocf_get_all_default_groups(false); // Get it so it does not include the built in default primary group $groups[] = $primary_group; // And add in the *chosen* primary group } else { $primary_group = NULL; } } else { $primary_group = NULL; } if ($primary_group === NULL) { $primary_group = get_first_default_group(); } $custom_fields = ocf_get_all_custom_fields_match($groups, NULL, NULL, NULL, NULL, NULL, NULL, 0, true); $actual_custom_fields = ocf_read_in_custom_fields($custom_fields); // Check that the given address isn't already used (if one_per_email_address on) $member_id = NULL; if ($one_per_email_address_if_enabled) { if (get_option('one_per_email_address') == '1') { $test = $GLOBALS['FORUM_DB']->query_select('f_members', array('id', 'm_username'), array('m_email_address' => $email_address), '', 1); if (array_key_exists(0, $test)) { if ($test[0]['m_username'] != $username) { $reset_url = build_url(array('page' => 'lostpassword', 'email_address' => $email_address), get_module_zone('lostpassword')); warn_exit(do_lang_tempcode('EMAIL_ADDRESS_IN_USE', escape_html(get_site_name()), escape_html($reset_url->evaluate()))); } $member_id = $test[0]['id']; } } } if ($captcha_if_enabled) { if (addon_installed('captcha')) { require_code('captcha'); enforce_captcha(); } } if (addon_installed('ldap')) { require_code('ocf_ldap'); if (ocf_is_ldap_member_potential($username)) { warn_exit(do_lang_tempcode('DUPLICATE_JOIN_AUTH')); } } // Add member $skip_confirm = get_option('skip_email_confirm_join') == '1'; if (!$confirm_if_enabled) { $skip_confirm = true; } $validated_email_confirm_code = $skip_confirm ? '' : strval(mt_rand(1, 32000)); $require_new_member_validation = get_option('require_new_member_validation') == '1'; if (!$validate_if_enabled) { $require_new_member_validation = false; } $coppa = get_option('is_on_coppa') == '1' && utctime_to_usertime(time() - mktime(0, 0, 0, $dob_month, $dob_day, $dob_year)) / 31536000.0 < 13.0; if (!$coppa_if_enabled) { $coppa = false; } $validated = $require_new_member_validation || $coppa ? 0 : 1; if (is_null($member_id)) { $member_id = ocf_make_member($username, $password, $email_address, $groups, $dob_day, $dob_month, $dob_year, $actual_custom_fields, $timezone, $primary_group, $validated, time(), time(), '', NULL, '', 0, get_option('default_preview_guests') == '1' ? 1 : 0, $reveal_age, '', '', '', 1, get_value('no_auto_notifications') === '1' ? 0 : 1, $language, $allow_emails, $allow_emails_from_staff, '', get_ip_address(), $validated_email_confirm_code, true, '', ''); } // Send confirm mail if (!$skip_confirm) { $zone = get_module_zone('join'); if ($zone != '') { $zone .= '/'; } $_url = build_url(array('page' => 'join', 'type' => 'step4', 'email' => $email_address, 'code' => $validated_email_confirm_code), $zone, NULL, false, false, true); $url = $_url->evaluate(); $_url_simple = build_url(array('page' => 'join', 'type' => 'step4'), $zone, NULL, false, false, true); $url_simple = $_url_simple->evaluate(); $redirect = get_param('redirect', ''); if ($redirect != '') { $url .= '&redirect=' . ocp_url_encode($redirect); } $message = do_lang('OCF_SIGNUP_TEXT', comcode_escape(get_site_name()), comcode_escape($url), array($url_simple, $email_address, $validated_email_confirm_code), $language); require_code('mail'); if (!$coppa) { mail_wrap(do_lang('CONFIRM_EMAIL_SUBJECT', get_site_name(), NULL, NULL, $language), $message, array($email_address), $username, '', '', 3, NULL, false, NULL, false, false, false, 'MAIL', true); } } // Send COPPA mail if ($coppa) { $fields_done = do_lang('THIS_WITH_COMCODE', do_lang('USERNAME'), $username) . "\n\n"; foreach ($custom_fields as $custom_field) { if ($custom_field['cf_type'] != 'upload') { $fields_done .= do_lang('THIS_WITH_COMCODE', $custom_field['trans_name'], post_param('custom_' . $custom_field['id'] . '_value')) . "\n"; } } $_privacy_url = build_url(array('page' => 'privacy'), '_SEARCH', NULL, false, false, true); $privacy_url = $_privacy_url->evaluate(); $message = do_lang('COPPA_MAIL', comcode_escape(get_option('site_name')), comcode_escape(get_option('privacy_fax')), array(comcode_escape(get_option('privacy_postal_address')), comcode_escape($fields_done), comcode_escape($privacy_url)), $language); require_code('mail'); mail_wrap(do_lang('COPPA_JOIN_SUBJECT', $username, get_site_name(), NULL, $language), $message, array($email_address), $username); } // Send 'validate this member' notification if ($require_new_member_validation) { require_code('notifications'); $_validation_url = build_url(array('page' => 'members', 'type' => 'view', 'id' => $member_id), get_module_zone('members'), NULL, false, false, true, 'tab__edit'); $validation_url = $_validation_url->evaluate(); $message = do_lang('VALIDATE_NEW_MEMBER_MAIL', comcode_escape($username), comcode_escape($validation_url), comcode_escape(strval($member_id)), get_site_default_lang()); dispatch_notification('ocf_member_needs_validation', NULL, do_lang('VALIDATE_NEW_MEMBER_SUBJECT', $username, NULL, NULL, get_site_default_lang()), $message, NULL, A_FROM_SYSTEM_PRIVILEGED); } // Send new member notification require_code('notifications'); $_member_url = build_url(array('page' => 'members', 'type' => 'view', 'id' => $member_id), get_module_zone('members'), NULL, false, false, true); $member_url = $_member_url->evaluate(); $message = do_lang('NEW_MEMBER_NOTIFICATION_MAIL', comcode_escape($username), comcode_escape(get_site_name()), array(comcode_escape($member_url), comcode_escape(strval($member_id))), get_site_default_lang()); dispatch_notification('ocf_new_member', NULL, do_lang('NEW_MEMBER_NOTIFICATION_MAIL_SUBJECT', $username, get_site_name(), NULL, get_site_default_lang()), $message, NULL, A_FROM_SYSTEM_PRIVILEGED); // Intro post if ($intro_message_if_enabled) { $forum_id = get_option('intro_forum_id'); if ($forum_id != '') { if (!is_numeric($forum_id)) { $_forum_id = $GLOBALS['FORUM_DB']->query_value_null_ok('f_forums', 'id', array('f_name' => $forum_id)); if (is_null($_forum_id)) { $forum_id = strval(db_get_first_id()); } else { $forum_id = strval($_forum_id); } } $intro_title = post_param('intro_title', ''); $intro_post = post_param('intro_post', ''); if ($intro_post != '') { require_code('ocf_topics_action'); if ($intro_title == '') { $intro_title = do_lang('INTRO_POST_DEFAULT', $username); } $topic_id = ocf_make_topic(intval($forum_id)); require_code('ocf_posts_action'); ocf_make_post($topic_id, $intro_title, $intro_post, 0, true, NULL, 0, NULL, NULL, NULL, $member_id); } } } // Alert user to situation $message = new ocp_tempcode(); if ($coppa) { if (!$skip_confirm) { $message->attach(do_lang_tempcode('OCF_WAITING_CONFIRM_MAIL')); } $message->attach(do_lang_tempcode('OCF_WAITING_CONFIRM_MAIL_COPPA')); } elseif ($require_new_member_validation) { if (!$skip_confirm) { $message->attach(do_lang_tempcode('OCF_WAITING_CONFIRM_MAIL')); } $message->attach(do_lang_tempcode('OCF_WAITING_CONFIRM_MAIL_VALIDATED', escape_html(get_custom_base_url()))); } elseif ($skip_confirm) { if ($instant_login) { require_code('users_active_actions'); handle_active_login($username); $message->attach(do_lang_tempcode('OCF_LOGIN_AUTO')); } else { $_login_url = build_url(array('page' => 'login', 'redirect' => get_param('redirect', NULL)), get_module_zone('login')); $login_url = $_login_url->evaluate(); $message->attach(do_lang_tempcode('OCF_LOGIN_INSTANT', escape_html($login_url))); } } else { if (!$skip_confirm) { $message->attach(do_lang_tempcode('OCF_WAITING_CONFIRM_MAIL')); } $message->attach(do_lang_tempcode('OCF_WAITING_CONFIRM_MAIL_INSTANT')); } $message = protect_from_escaping($message); return array($message); }