/** * Standard modular run function for CRON hooks. Searches for tasks to perform. */ function run() { //if (!addon_installed('octhief')) return; require_lang('insults'); // ensure it is done once per week $time = time(); $last_time = intval(get_value('last_insult_time')); if ($last_time > time() - 24 * 60 * 60) { return; } // run it once a day set_value('last_insult_time', strval($time)); // how many points a correct response will give $_insult_points = get_option('insult_points', true); if (is_null($_insult_points)) { // add option and default value if not installed yet require_code('database_action'); add_config_option('INSULT_POINTS', 'insult_points', 'integer', 'return \'10\';', 'POINTS', 'INSULT_TITLE'); } $insult_points = isset($_insult_points) && is_numeric($_insult_points) ? intval($_insult_points) : 10; // who to insult? $selected_members = $GLOBALS['FORUM_DB']->query('SELECT id FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_members WHERE id <> ' . strval($GLOBALS['FORUM_DRIVER']->get_guest_id()) . ' ORDER BY RAND( ) ', 2, NULL, true); $selected_member1 = isset($selected_members[0]['id']) && $selected_members[0]['id'] > 0 ? $selected_members[0]['id'] : 0; $selected_member2 = isset($selected_members[1]['id']) && $selected_members[1]['id'] > 0 ? $selected_members[1]['id'] : 0; // send insult to picked members if ($selected_member1 != 0 && $selected_member2 != 0) { $get_insult = ''; if (is_file(get_file_base() . '/text_custom/' . user_lang() . '/insults.txt')) { $insults = file(get_file_base() . '/text_custom/' . user_lang() . '/insults.txt'); $insults_array = array(); foreach ($insults as $insult) { $x = explode('=', $insult); $insults_array[] = $x[0]; } $rand_key = array_rand($insults_array, 1); $rand_key = is_array($rand_key) ? $rand_key[0] : $rand_key; $get_insult = $insults_array[$rand_key]; } if ($get_insult != '') { global $SITE_INFO; $insult_pt_topic_post = do_lang('INSULT_EXPLANATION', get_site_name(), $get_insult, $insult_points); $subject = do_lang('INSULT_PT_TOPIC', $GLOBALS['FORUM_DRIVER']->get_username($selected_member2), $GLOBALS['FORUM_DRIVER']->get_username($selected_member1)); require_code('ocf_topics_action'); $topic_id = ocf_make_topic(NULL, $subject, '', 1, 1, 0, 0, 0, $selected_member2, $selected_member1, true, 0, NULL, ''); require_code('ocf_posts_action'); $post_id = ocf_make_post($topic_id, $subject, $insult_pt_topic_post, 0, true, 1, 0, do_lang('SYSTEM'), NULL, NULL, $GLOBALS['FORUM_DRIVER']->get_guest_id(), NULL, NULL, NULL, false, true, NULL, true, $subject, 0, NULL, true, true, true); require_code('ocf_topics_action2'); send_pt_notification($post_id, $subject, $topic_id, $selected_member2, $selected_member1); } } }
function setUp() { parent::setUp(); require_code('ocf_topics'); require_code('ocf_posts'); require_code('ocf_forums'); require_code('ocf_posts_action'); require_code('ocf_posts_action2'); require_code('ocf_posts_action3'); require_code('ocf_topics_action'); require_code('ocf_topics_action2'); $this->establish_admin_session(); $this->topic_id = ocf_make_topic(db_get_first_id(), 'Test'); $this->post_id = ocf_make_post($this->topic_id, $title = 'welcome', $post = 'welcome to the posts', $skip_sig = 0, $is_starter = false, $validated = NULL, $is_emphasised = 0, $poster_name_if_guest = NULL, $ip_address = NULL, $time = NULL, $poster = NULL, $intended_solely_for = NULL, $last_edit_time = NULL, $last_edit_by = NULL, $check_permissions = true, $update_cacheing = true, $forum_id = NULL, $support_attachments = true, $topic_title = '', $sunk = 0, $id = NULL, $anonymous = false, $skip_post_checks = false, $is_pt = false); // Test the forum was actually created $this->assertTrue('welcome' == $GLOBALS['FORUM_DB']->query_value('f_posts', 'p_title ', array('id' => $this->post_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_topics($db, $table_prefix, $file_base) { $row_start = 0; $rows = array(); do { $rows = $db->query("SELECT message_id,user_id_from,user_id_to,subject,state,message,date_time FROM " . $table_prefix . "messages AS M INNER JOIN " . $table_prefix . "users AS U ON U.id=M.user_id_from AND U.id=M.user_id_to AND U.usertype='Super Administrator'", 200, $row_start); foreach ($rows as $row) { if (import_check_if_imported('topic', strval($row['message_id']))) { continue; } $forum_id = NULL; $pt_from = import_id_remap_get('member', strval($row['user_id_from'])); $pt_to = import_id_remap_get('member', strval($row['user_id_to'])); $subject = html_to_comcode($row['subject']); $message = html_to_comcode($row['message']); $id_new = ocf_make_topic($forum_id, $subject, '', 1, $row['state'] == 1 ? 0 : 1, 0, 0, 0, $pt_from, $pt_to, false, 0); $datetimearr = explode(' ', $row['date_time']); $datearr = explode('-', $datetimearr[0]); $timearr = explode(':', $datetimearr[1]); $date = intval($datearr[2]); $month = intval($datearr[1]); $year = intval($datearr[0]); $hour = intval($timearr[0]); $min = intval($timearr[1]); $sec = intval($timearr[2]); $time = mktime($hour, $min, $sec, $month, $date, $year); ocf_make_post($id_new, $subject, $message, 0, true, 1, 0, NULL, NULL, $time, $pt_from); import_id_remap_put('topic', strval($row['message_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'); } }
/** * Move posts from one topic to another. * * @param AUTO_LINK The ID of the source topic. * @param AUTO_LINK The ID of the destination topic. * @param array A list of post IDs to move. * @param LONG_TEXT The reason for this action. * @param ?AUTO_LINK The forum the destination topic is in (NULL: find from DB). * @param boolean Whether to delete the topic if all posts in it have been moved. * @param ?SHORT_TEXT The title for the new topic (NULL: work out / irrelevant). * @return boolean Whether the topic was deleted. */ function ocf_move_posts($from_topic_id, $to_topic_id, $posts, $reason, $to_forum_id = NULL, $delete_if_empty = false, $title = NULL) { if (is_null($to_topic_id)) { if (is_null($to_forum_id)) { fatal_exit(do_lang_tempcode('INTERNAL_ERROR')); } require_code('ocf_topics_action'); $to_topic_id = ocf_make_topic($to_forum_id); if (!is_null($title) && count($posts) != 0) { $GLOBALS['FORUM_DB']->query_update('f_posts', array('p_title' => $title), array('id' => $posts[0]), '', 1); } } // Info about source $from_info = $GLOBALS['FORUM_DB']->query_select('f_topics', array('t_forum_id'), array('id' => $from_topic_id)); if (!array_key_exists(0, $from_info)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $from_forum_id = $from_info[0]['t_forum_id']; $to_info = $GLOBALS['FORUM_DB']->query_select('f_topics', array('t_forum_id'), array('id' => $to_topic_id)); if (!array_key_exists(0, $to_info)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $to_forum_id = $to_info[0]['t_forum_id']; $or_list = ''; foreach ($posts as $post) { if ($or_list != '') { $or_list .= ' OR '; } $or_list .= 'id=' . strval((int) $post); } // Check access if (!ocf_may_moderate_forum($from_forum_id)) { access_denied('I_ERROR'); } $_postdetails = $GLOBALS['FORUM_DB']->query('SELECT p_cache_forum_id,p_intended_solely_for,p_validated FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_posts WHERE ' . $or_list); $num_posts_counted = 0; foreach ($_postdetails as $post) { if (is_null($post['p_intended_solely_for']) && $post['p_validated'] == 1) { $num_posts_counted++; } if ($post['p_cache_forum_id'] != $from_forum_id) { fatal_exit(do_lang_tempcode('INTERNAL_ERROR')); } } $GLOBALS['FORUM_DB']->query('UPDATE ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_posts SET p_cache_forum_id=' . strval((int) $to_forum_id) . ', p_topic_id=' . strval((int) $to_topic_id) . ' WHERE ' . $or_list); // Update cacheing require_code('ocf_posts_action2'); ocf_force_update_topic_cacheing($from_topic_id, -$num_posts_counted, true, true); ocf_force_update_topic_cacheing($to_topic_id, $num_posts_counted, true, true); if (!is_null($from_forum_id) && !is_null($to_topic_id) && $from_forum_id != $to_topic_id) { if ($from_forum_id != $to_forum_id) { require_code('ocf_forums_action2'); ocf_force_update_forum_cacheing($from_forum_id, 0, -$num_posts_counted); ocf_force_update_forum_cacheing($to_forum_id, 0, $num_posts_counted); // Update member post counts if we've switched between post-count countable forums $post_count_info = $GLOBALS['FORUM_DB']->query('SELECT id,f_post_count_increment FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_forums WHERE id=' . strval((int) $from_forum_id) . ' OR id=' . strval((int) $to_forum_id), 2); if ($post_count_info[0]['id'] == $from_forum_id) { $from = $post_count_info[0]['f_post_count_increment']; $to = $post_count_info[1]['f_post_count_increment']; } else { $from = $post_count_info[1]['f_post_count_increment']; $to = $post_count_info[0]['f_post_count_increment']; } if ($from != $to) { $sql = 'SELECT p_poster FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_posts WHERE (' . $or_list . ')'; if (addon_installed('unvalidated')) { $sql .= ' AND p_validated=1'; } $_member_post_counts = collapse_1d_complexity('p_poster', $GLOBALS['FORUM_DB']->query($sql)); $member_post_counts = array_count_values($_member_post_counts); foreach ($member_post_counts as $member_id => $member_post_count) { if ($to == 0) { $member_post_count = -$member_post_count; } ocf_force_update_member_post_count($member_id, $member_post_count); } } } } $test = $delete_if_empty ? $GLOBALS['FORUM_DB']->query_value('f_posts', 'COUNT(*)', array('p_topic_id' => $from_topic_id)) : 1; if ($test == 0) { $num_view_count = 0; $num_view_count += $GLOBALS['FORUM_DB']->query_value('f_topics', 't_num_views', array('id' => $from_topic_id)); $num_view_count += $GLOBALS['FORUM_DB']->query_value('f_topics', 't_num_views', array('id' => $to_topic_id)); $GLOBALS['FORUM_DB']->query_update('f_topics', array('t_num_views' => $num_view_count), array('id' => $to_topic_id), '', 1); require_code('ocf_topics_action'); require_code('ocf_topics_action2'); ocf_delete_topic($from_topic_id, do_lang('MOVE_POSTS')); return true; } else { // Make informative post $me_link = '[page="' . get_module_zone('members') . '" type="view" id="' . strval(get_member()) . '" caption="' . $GLOBALS['OCF_DRIVER']->get_username(get_member()) . '"]members[/page]'; $topic_title = $GLOBALS['FORUM_DB']->query_value('f_topics', 't_cache_first_title', array('id' => $to_topic_id)); $lang = do_lang('INLINE_POSTS_MOVED_MESSAGE', $me_link, integer_format(count($posts)), array('[page="' . get_module_zone('topicview') . '" id="' . strval($to_topic_id) . '" caption="' . str_replace('"', '\\"', str_replace('[', '\\[', $topic_title)) . '"]topicview[/page]')); ocf_make_post($from_topic_id, '', $lang, 0, false, 1, 1, NULL, NULL, $GLOBALS['FORUM_DB']->query_value('f_posts', 'p_time', array('id' => $posts[0])) + 1, NULL, NULL, NULL, NULL, false); require_code('ocf_general_action2'); ocf_mod_log_it('MOVE_POSTS', strval($to_topic_id), strval(count($posts)), $reason); if (!is_null($from_forum_id)) { ocf_decache_ocp_blocks($from_forum_id); } if (!is_null($to_forum_id)) { ocf_decache_ocp_blocks($to_forum_id); } return false; } return false; // should never get here }
/** * 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_personal_topics($db, $table_prefix, $file_base) { $rows = $db->query('SELECT * FROM ' . $table_prefix . 'pm p LEFT JOIN ' . $table_prefix . 'pm_texts t ON p.pm_id=t.pm_id ORDER BY pm_date_time'); // Group them up into what will become topics $groups = array(); $done = array(); foreach ($rows as $row) { // Do some fiddling around for duplication if ($row['pm_from'] > $row['pm_to']) { $a = $row['pm_to']; $b = $row['pm_from']; } else { $a = $row['pm_from']; $b = $row['pm_to']; } $row['pm_subject'] = str_replace('Re: ', '', $row['pm_subject']); if ($row['pm_subject'] == '') { $row['pm_subject'] = do_lang('NONE'); } if (!array_key_exists(strval($a) . ':' . strval($b) . ':' . $row['pm_date_time'], $done)) { $groups[strval($a) . ':' . strval($b) . ':' . $row['pm_subject']][] = $row; $done[strval($a) . ':' . strval($b) . ':' . $row['pm_date_time']] = 1; } } // Import topics foreach ($groups as $group) { $row = $group[0]; if (import_check_if_imported('pt', strval($row['pm_id']))) { continue; } // Create topic $from_id = import_id_remap_get('member', strval($row['pm_from']), true); if (is_null($from_id)) { $from_id = $GLOBALS['OCF_DRIVER']->get_guest_id(); } $to_id = import_id_remap_get('member', strval($row['pm_to']), true); if (is_null($to_id)) { $to_id = $GLOBALS['OCF_DRIVER']->get_guest_id(); } $topic_id = ocf_make_topic(NULL, '', '', 1, 1, 0, 0, 0, $from_id, $to_id, false); $first_post = true; foreach ($group as $_postdetails) { if ($first_post) { $title = $row['pm_subject']; } else { $title = ''; } $pos = strpos($_postdetails['pm_text'], '_____Original Message_____'); if ($pos !== false) { $_postdetails['pm_text'] = substr($_postdetails['pm_text'], 0, $pos); } $post = $this->fix_links($_postdetails['pm_text'], $db, $table_prefix, $file_base); $validated = 1; $from_id = import_id_remap_get('member', strval($_postdetails['pm_from']), true); if (is_null($from_id)) { $from_id = $GLOBALS['OCF_DRIVER']->get_guest_id(); } $poster_name_if_guest = $GLOBALS['OCF_DRIVER']->get_username($from_id); $ip_address = '127.0.0.1'; $time = strtotime($_postdetails['pm_date_time']); $poster = $from_id; $last_edit_time = NULL; $last_edit_by = NULL; ocf_make_post($topic_id, $title, $post, 0, $first_post, $validated, 0, $poster_name_if_guest, $ip_address, $time, $poster, NULL, $last_edit_time, $last_edit_by, false, false, NULL, false); $first_post = false; } import_id_remap_put('pt', strval($row['pm_id']), $topic_id); } }
/** * Send out a notification to a member. * * @param MEMBER Member to send to * @param integer Listening setting * @param ID_TEXT The notification code to use * @param ?SHORT_TEXT The category within the notification code (NULL: none) * @param SHORT_TEXT Message subject (in Comcode) * @param LONG_TEXT Message body (in Comcode) * @param integer The member ID doing the sending. Either a USER or a negative number (e.g. A_FROM_SYSTEM_UNPRIVILEGED) * @param integer The message priority (1=urgent, 3=normal, 5=low) * @range 1 5 * @param boolean Whether to NOT CC to the CC address * @return boolean New $no_cc setting */ function _dispatch_notification_to_member($to_member_id, $setting, $notification_code, $code_category, $subject, $message, $from_member_id, $priority, $no_cc) { // Fish out some general details of the sender $to_name = $GLOBALS['FORUM_DRIVER']->get_username($to_member_id); $from_email = ''; $from_name = ''; if (!is_null($from_member_id) && $from_member_id >= 0) { /*$from_email=$GLOBALS['FORUM_DRIVER']->get_member_email_address($from_member_id); No; we can't disclose email addresses, so notifications will all be emailed from system if ($from_email=='') $from_email=''; $from_name=$GLOBALS['FORUM_DRIVER']->get_username($from_member_id);*/ } $db = substr($notification_code, 0, 4) == 'ocf_' ? $GLOBALS['FORUM_DB'] : $GLOBALS['SITE_DB']; // If none-specified, we'll need to be clever now if ($setting == A__STATISTICAL) { $setting = _find_member_statistical_notification_type($to_member_id); } $needs_manual_cc = true; $message_to_send = $message; // May get tweaked, if we have some kind of error to explain, etc // Send according to the listen setting... if (_notification_setting_available(A_INSTANT_SMS, $to_member_id)) { if (($setting & A_INSTANT_SMS) != 0) { $wrapped_message = do_lang('NOTIFICATION_SMS_COMPLETE_WRAP', $subject, $message_to_send); // Lang string may be modified to include {2}, but would cost more. Default just has {1}. require_code('sms'); $successes = sms_wrap($wrapped_message, array($to_member_id)); if ($successes == 0) { $setting = $setting | A_INSTANT_EMAIL; // Make sure it also goes to email then $message_to_send = do_lang('INSTEAD_OF_SMS', $message); } } } if (_notification_setting_available(A_INSTANT_EMAIL, $to_member_id)) { if (($setting & A_INSTANT_EMAIL) != 0) { $to_email = $GLOBALS['FORUM_DRIVER']->get_member_email_address($to_member_id); if ($to_email != '') { $wrapped_subject = do_lang('NOTIFICATION_EMAIL_SUBJECT_WRAP', $subject, comcode_escape(get_site_name())); $wrapped_message = do_lang('NOTIFICATION_EMAIL_MESSAGE_WRAP', $message_to_send, comcode_escape(get_site_name())); mail_wrap($wrapped_subject, $wrapped_message, array($to_email), $to_name, $from_email, $from_name, $priority, NULL, $no_cc, $from_member_id < 0 ? $GLOBALS['FORUM_DRIVER']->get_guest_id() : $from_member_id, $from_member_id == A_FROM_SYSTEM_PRIVILEGED, false); $needs_manual_cc = false; $no_cc = true; // Don't CC again } } } if (_notification_setting_available(A_DAILY_EMAIL_DIGEST, $to_member_id)) { if (($setting & A_DAILY_EMAIL_DIGEST) != 0 || ($setting & A_WEEKLY_EMAIL_DIGEST) != 0 || ($setting & A_MONTHLY_EMAIL_DIGEST) != 0) { foreach (array(A_DAILY_EMAIL_DIGEST, A_WEEKLY_EMAIL_DIGEST, A_MONTHLY_EMAIL_DIGEST) as $frequency) { if (($setting & $frequency) != 0) { $GLOBALS['SITE_DB']->query_insert('digestives_tin', array('d_subject' => $subject, 'd_message' => $message, 'd_from_member_id' => $from_member_id, 'd_to_member_id' => $to_member_id, 'd_priority' => $priority, 'd_no_cc' => $no_cc ? 1 : 0, 'd_date_and_time' => time(), 'd_notification_code' => substr($notification_code, 0, 80), 'd_code_category' => is_null($code_category) ? '' : $code_category, 'd_frequency' => $frequency)); $GLOBALS['SITE_DB']->query_insert('digestives_consumed', array('c_member_id' => $to_member_id, 'c_frequency' => $frequency, 'c_time' => time()), false, true); } } $needs_manual_cc = false; } } if (_notification_setting_available(A_INSTANT_PT, $to_member_id)) { if (($setting & A_INSTANT_PT) != 0) { require_code('ocf_topics_action'); require_code('ocf_posts_action'); $wrapped_subject = do_lang('NOTIFICATION_PT_SUBJECT_WRAP', $subject); $wrapped_message = do_lang('NOTIFICATION_PT_MESSAGE_WRAP', $message_to_send); // NB: These are posted by Guest (system) although the display name is set to the member triggering. This is intentional to stop said member getting unexpected replies. $topic_id = ocf_make_topic(NULL, $wrapped_subject, 'ocf_topic_modifiers/announcement', 1, 1, 0, 0, 0, db_get_first_id(), $to_member_id, false, 0, NULL, ''); ocf_make_post($topic_id, $wrapped_subject, $wrapped_message, 0, true, 1, 0, $from_member_id < 0 ? do_lang('SYSTEM') : $from_name, NULL, NULL, db_get_first_id(), NULL, NULL, NULL, false, true, NULL, true, $wrapped_subject, 0, NULL, true, true, true, $from_member_id == A_FROM_SYSTEM_PRIVILEGED); } } // Send to staff CC address regardless if (!$no_cc && $needs_manual_cc) { $no_cc = true; // Don't CC again $to_email = get_option('cc_address'); if ($to_email != '') { mail_wrap($subject, $message, array($to_email), $to_name, $from_email, $from_name, $priority, NULL, true, $from_member_id < 0 ? NULL : $from_member_id, $from_member_id == A_FROM_SYSTEM_PRIVILEGED, false); } } return $no_cc; }
/** * Makes a post in the specified forum, in the specified topic according to the given specifications. If the topic doesn't exist, it is created along with a spacer-post. * Spacer posts exist in order to allow staff to delete the first true post in a topic. Without spacers, this would not be possible with most forum systems. They also serve to provide meta information on the topic that cannot be encoded in the title (such as a link to the content being commented upon). * * @param object Link to the real forum driver * @param SHORT_TEXT The forum name * @param SHORT_TEXT The topic identifier (usually <content-type>_<content-id>) * @param MEMBER The member ID * @param LONG_TEXT The post title * @param LONG_TEXT The post content in Comcode format * @param string The topic title; must be same as content title if this is for a comment topic * @param string This is put together with the topic identifier to make a more-human-readable topic title or topic description (hopefully the latter and a $content_title title, but only if the forum supports descriptions) * @param ?URLPATH URL to the content (NULL: do not make spacer post) * @param ?TIME The post time (NULL: use current time) * @param ?IP The post IP address (NULL: use current members IP address) * @param ?BINARY Whether the post is validated (NULL: unknown, find whether it needs to be marked unvalidated initially). This only works with the OCF driver. * @param ?BINARY Whether the topic is validated (NULL: unknown, find whether it needs to be marked unvalidated initially). This only works with the OCF driver. * @param boolean Whether to skip post checks * @param SHORT_TEXT The name of the poster * @param ?AUTO_LINK ID of post being replied to (NULL: N/A) * @param boolean Whether the reply is only visible to staff * @param ?ID_TEXT DO NOT send notifications to: The notification code (NULL: no restriction) * @param ?SHORT_TEXT DO NOT send notifications to: The category within the notification code (NULL: none / no restriction) * @return array Topic ID (may be NULL), and whether a hidden post has been made */ function _helper_make_post_forum_topic($this_ref, $forum_name, $topic_identifier, $member_id, $post_title, $post, $content_title, $topic_identifier_encapsulation_prefix, $content_url, $time, $ip, $validated, $topic_validated, $skip_post_checks, $poster_name_if_guest, $parent_id, $staff_only, $no_notify_for__notification_code, $no_notify_for__code_category) { if (is_null($time)) { $time = time(); } if (is_null($ip)) { $ip = get_ip_address(); } require_code('comcode_check'); check_comcode($post, NULL, false, NULL, true); require_code('ocf_topics'); require_code('ocf_posts'); //require_code('ocf_forums'); require_lang('ocf'); require_code('ocf_posts_action'); require_code('ocf_posts_action2'); if (!is_integer($forum_name)) { $forum_id = $this_ref->forum_id_from_name($forum_name); if (is_null($forum_id)) { warn_exit(do_lang_tempcode('MISSING_FORUM', escape_html($forum_name))); } } else { $forum_id = (int) $forum_name; } $topic_id = $this_ref->find_topic_id_for_topic_identifier($forum_name, $topic_identifier); $update_caching = false; $support_attachments = false; if (!running_script('stress_test_loader') && get_page_name() != 'admin_import') { $update_caching = true; $support_attachments = true; } if (is_null($topic_id)) { $is_starter = true; require_code('ocf_topics_action'); $topic_id = ocf_make_topic($forum_id, $topic_identifier_encapsulation_prefix . ': #' . $topic_identifier, '', $topic_validated, 1, 0, 0, 0, NULL, NULL, false, 0, NULL, $content_url); if (strpos($topic_identifier, ':') !== false) { // Sync comment_posted ones to also monitor the forum ones; no need for opposite way as comment ones already trigger forum ones $start = 0; $max = 300; require_code('notifications'); $ob = _get_notification_ob_for_code('comment_posted'); do { list($members, $possibly_has_more) = $ob->list_members_who_have_enabled('comment_posted', $topic_identifier, NULL, $start, $max); foreach ($members as $to_member_id => $setting) { enable_notifications('ocf_topic', strval($topic_id), $to_member_id); } $start += $max; } while ($possibly_has_more); } // Make spacer post if (!is_null($content_url)) { $spacer_title = $content_title; $home_link = hyperlink($content_url, escape_html($content_title)); $spacer_post = '[semihtml]' . do_lang('SPACER_POST', $home_link->evaluate(), '', '', get_site_default_lang()) . '[/semihtml]'; ocf_make_post($topic_id, $spacer_title, $spacer_post, 0, true, 1, 0, do_lang('SYSTEM'), $ip, $time, db_get_first_id(), NULL, NULL, NULL, false, $update_caching, $forum_id, $support_attachments, $content_title, 0, NULL, false, false, false, false); $is_starter = false; } $is_new = true; } else { $is_starter = false; $is_new = false; } $GLOBALS['LAST_TOPIC_ID'] = $topic_id; $GLOBALS['LAST_TOPIC_IS_NEW'] = $is_new; if ($post == '') { return array(NULL, false); } ocf_check_post($post, $topic_id, $member_id); $poster_name = $poster_name_if_guest; if ($poster_name == '') { $poster_name = $this_ref->get_username($member_id); } $post_id = ocf_make_post($topic_id, $post_title, $post, 0, $is_starter, $validated, 0, $poster_name, $ip, $time, $member_id, $staff_only ? $GLOBALS['FORUM_DRIVER']->get_guest_id() : NULL, NULL, NULL, false, $update_caching, $forum_id, $support_attachments, $content_title, 0, NULL, false, $skip_post_checks, false, false, $parent_id); $GLOBALS['LAST_POST_ID'] = $post_id; if ($is_new) { // Broken cache now for the rest of this page view - fix by flushing global $TOPIC_IDENTIFIERS_TO_IDS; $TOPIC_IDENTIFIERS_TO_IDS = array(); } // Send out notifications $_url = build_url(array('page' => 'topicview', 'type' => 'findpost', 'id' => $post_id), 'forum', NULL, false, false, true, 'post_' . strval($post_id)); $url = $_url->evaluate(); ocf_send_topic_notification($url, $topic_id, $forum_id, $member_id, $is_new, $post, $content_title, NULL, false, $no_notify_for__notification_code, $no_notify_for__code_category); $is_hidden = false; if (!running_script('stress_test_loader') && get_page_name() != 'admin_import') { $validated_actual = $this_ref->connection->query_value('f_posts', 'p_validated', array('id' => $post_id)); if ($validated_actual == 0) { require_code('site'); attach_message(do_lang_tempcode('SUBMIT_UNVALIDATED'), 'inform'); $is_hidden = true; } } return array($topic_id, $is_hidden); }
/** * 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_reported_posts_forum($db, $table_prefix, $file_base) { $rows = $db->query('SELECT * FROM ' . $table_prefix . 'reports'); foreach ($rows as $row) { $forum_id = $GLOBALS['FORUM_DRIVER']->forum_id_from_name(get_option('reported_posts_forum')); if (is_null($forum_id)) { warn_exit(do_lang_tempcode('NO_REPORTED_POST_FORUM')); } $post_id = import_id_remap_get('post', strval($row['post_id']), true); if (is_null($post_id)) { continue; } $user_id = import_id_remap_get('post', strval($row['user_id']), true); if (is_null($user_id)) { continue; } $post_info = $GLOBALS['SITE_DB']->query_select('f_posts', array('*'), array('id' => $post_id), '', 1); $topic_info = $GLOBALS['SITE_DB']->query_select('f_topics', array('*'), array('id' => $post_info[0]['p_topic_id']), '', 1); $post_title = @html_entity_decode($post_info[0]['p_title'], ENT_QUOTES); if ($post_title == '') { $post_title = $post_title[0]['t_cache_first_title']; } $poster = $post_info[0]['p_poster_name_if_guest']; $member = $GLOBALS['FORUM_DRIVER']->get_username($user_id); if (is_null($member)) { $member = do_lang('UNKNOWN'); } $title = do_lang('REPORTED_POST_TITLE', $post_title); $topic_id = ocf_make_topic($forum_id, $title, '', $row['topic_approved'], $row['report_closed'] == 1 ? 0 : 1, 0, 0, 0, NULL, NULL, false); $post = do_template('OCF_REPORTED_POST', array('POST_ID' => strval($post_id), 'MEMBER' => $member, 'TOPIC_NAME' => $topic_info[0]['t_cache_first_title'], 'POST' => $row['report_text'], 'POSTER' => $poster)); ocf_make_post($topic_id, $title, $post->evaluate(), 0, true, 1, 0, $member, NULL, $row['report_time'], NULL, NULL, NULL, NULL, false, true, NULL, true, $title, 0, NULL, false, $forum_id); } }
/** * The actualiser to restore a deleted post. * * @return tempcode The UI */ function restore() { check_specific_permission('restore_content_history'); $title = get_page_title('POST_HISTORY'); $id = get_param_integer('h_id'); $post = $GLOBALS['FORUM_DB']->query_select('f_post_history', array('*'), array('id' => $id), '', 1); if (!array_key_exists(0, $post)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $post = $post[0]; require_code('ocf_posts_action'); require_code('ocf_posts_action2'); $owner_username = $GLOBALS['FORUM_DRIVER']->get_username($post['h_owner_member_id']); if (is_null($owner_username)) { $owner_username = do_lang('UNKNOWN'); } ocf_make_post($post['h_topic_id'], '', $post['h_before'], 0, false, 1, 0, $owner_username, NULL, $post['h_create_date_and_time'], $post['h_owner_member_id'], NULL, time(), get_member(), false, true); $url = build_url(array('page' => '_SELF', 'type' => 'misc'), '_SELF', NULL, true); return redirect_screen($title, $url, do_lang_tempcode('SUCCESS')); }
/** * Standard aed_module add actualiser. * * @return ID_TEXT The entry added */ function add_actualisation() { $explanation = post_param('explanation'); $member_id = post_param_integer('member_id'); $message = post_param('message', ''); $username = $GLOBALS['FORUM_DRIVER']->get_username($member_id); if (is_null($username)) { warn_exit(do_lang_tempcode('_USER_NO_EXIST', escape_html($username))); } $save = post_param('save'); if ($save != '') { $GLOBALS['FORUM_DB']->query_delete('f_saved_warnings', array('s_title' => $save), '', 1); $GLOBALS['FORUM_DB']->query_insert('f_saved_warnings', array('s_title' => $save, 's_explanation' => $explanation, 's_message' => $message)); } // Send PT if ($message != '') { require_code('ocf_topics_action'); require_code('ocf_topics_action2'); require_code('ocf_posts_action'); require_code('ocf_posts_action2'); $_title = do_lang('NEW_WARNING_TO_YOU'); $pt_topic_id = ocf_make_topic(NULL, '', '', 1, 1, 0, 0, 0, get_member(), $member_id); $post_id = ocf_make_post($pt_topic_id, $_title, $message, 0, true, 1, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, false); send_pt_notification($post_id, $_title, $pt_topic_id, $member_id); } // Topic silencing $silence_from_topic = post_param_integer('topic_id', NULL); if (!is_null($silence_from_topic)) { $_silence_from_topic = get_input_date('silence_from_topic'); $GLOBALS['SITE_DB']->query_delete('msp', array('member_id' => $member_id, 'specific_permission' => 'submit_lowrange_content', 'the_page' => '', 'module_the_name' => 'topics', 'category_name' => strval($silence_from_topic))); } else { $_silence_from_topic = NULL; } if (!is_null($_silence_from_topic)) { $GLOBALS['SITE_DB']->query_insert('msp', array('active_until' => $_silence_from_topic, 'member_id' => $member_id, 'specific_permission' => 'submit_lowrange_content', 'the_page' => '', 'module_the_name' => 'topics', 'category_name' => strval($silence_from_topic), 'the_value' => '0')); } else { $silence_from_topic = NULL; } // Forum silencing $silence_from_forum = post_param_integer('forum_id', NULL); if (!is_null($silence_from_forum)) { $GLOBALS['SITE_DB']->query_delete('msp', array('member_id' => $member_id, 'specific_permission' => 'submit_lowrange_content', 'the_page' => '', 'module_the_name' => 'forums', 'category_name' => strval($silence_from_forum))); $GLOBALS['SITE_DB']->query_delete('msp', array('member_id' => $member_id, 'specific_permission' => 'submit_midrange_content', 'the_page' => '', 'module_the_name' => 'forums', 'category_name' => strval($silence_from_forum))); $_silence_from_forum = get_input_date('silence_from_forum'); } else { $_silence_from_forum = NULL; } if (!is_null($_silence_from_forum)) { $GLOBALS['SITE_DB']->query_insert('msp', array('active_until' => $_silence_from_forum, 'member_id' => $member_id, 'specific_permission' => 'submit_lowrange_content', 'the_page' => '', 'module_the_name' => 'forums', 'category_name' => strval($silence_from_forum), 'the_value' => '0')); $GLOBALS['SITE_DB']->query_insert('msp', array('active_until' => $_silence_from_forum, 'member_id' => $member_id, 'specific_permission' => 'submit_midrange_content', 'the_page' => '', 'module_the_name' => 'forums', 'category_name' => strval($silence_from_forum), 'the_value' => '0')); } else { $silence_from_forum = NULL; } // Probation $probation = post_param_integer('probation', 0); if (has_specific_permission(get_member(), 'probate_members')) { if ($probation != 0) { $on_probation_until = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id, 'm_on_probation_until'); if (is_null($on_probation_until) || $on_probation_until < time()) { $on_probation_until = time(); } $on_probation_until += $probation * 60 * 60 * 24; $GLOBALS['FORUM_DB']->query_update('f_members', array('m_on_probation_until' => $on_probation_until), array('id' => $member_id), '', 1); } } // Ban member if (has_specific_permission(get_member(), 'member_maintenance')) { $banned_member = post_param_integer('banned_member', 0); if ($banned_member == 1) { $GLOBALS['FORUM_DB']->query_update('f_members', array('m_is_perm_banned' => 1), array('id' => $member_id), '', 1); } } else { $banned_member = 0; } // IP ban $banned_ip = ''; if (addon_installed('securitylogging')) { if (has_actual_page_access(get_member(), 'admin_ipban')) { $_banned_ip = post_param_integer('banned_ip', 0); if ($_banned_ip == 1) { $banned_ip = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id, 'm_ip_address'); require_code('failure'); add_ip_ban($banned_ip); } } } // Change group $changed_usergroup_from = NULL; if (has_specific_permission(get_member(), 'member_maintenance')) { $__changed_usergroup_from = post_param('changed_usergroup_from'); if ($__changed_usergroup_from == '') { $_changed_usergroup_from = NULL; } else { $_changed_usergroup_from = intval($__changed_usergroup_from); } if (!is_null($_changed_usergroup_from) && $_changed_usergroup_from != -1) { $changed_usergroup_from = $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id, 'm_primary_group'); $GLOBALS['FORUM_DB']->query_update('f_members', array('m_primary_group' => $_changed_usergroup_from), array('id' => $member_id), '', 1); } } // Prepare to charge points (used in ocf_make_warning) $charged_points = post_param_integer('charged_points', 0); // Make the warning $warning_id = ocf_make_warning($member_id, $explanation, NULL, NULL, post_param_integer('is_warning', 0), $silence_from_topic, $silence_from_forum, $probation, $banned_ip, $charged_points, $banned_member, $changed_usergroup_from); // Charge points if (addon_installed('points')) { if (has_actual_page_access(get_member(), 'admin_points')) { if ($charged_points != 0) { require_code('points2'); charge_member($member_id, $charged_points, do_lang('FOR_PUNISHMENT', strval($warning_id))); } } } return strval($warning_id); }
function actualiser() { $title = get_page_title('REPORT_CONTENT'); // Test CAPTCHA if (addon_installed('captcha')) { require_code('captcha'); enforce_captcha(); } require_code('content'); $content_type = post_param('content_type'); // Equates to a content_meta_aware hook $content_id = post_param('content_id'); if (!is_null($GLOBALS['SITE_DB']->query_value_null_ok('reported_content', 'r_counts', array('r_session_id' => get_session_id(), 'r_content_type' => $content_type, 'r_content_id' => $content_id)))) { warn_exit(do_lang_tempcode('ALREADY_REPORTED_CONTENT')); } list($content_title, , $cma_info, $content_url) = content_get_details($content_type, $content_id); // Create reported post... $forum_id = $GLOBALS['FORUM_DRIVER']->forum_id_from_name(get_option('reported_posts_forum')); if (is_null($forum_id)) { warn_exit(do_lang_tempcode('ocf:NO_REPORTED_POST_FORUM')); } // See if post already reported... $post = post_param('post'); $anonymous = post_param_integer('anonymous', 0); $topic_id = $GLOBALS['FORUM_DB']->query_value_null_ok('f_topics t LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_posts p ON p.id=t.t_cache_first_post_id', 't.id', array('p.p_title' => $content_title, 't.t_forum_id' => $forum_id)); require_code('ocf_topics_action'); require_code('ocf_topics_action2'); require_code('ocf_posts_action'); require_code('ocf_posts_action2'); if (!is_null($topic_id)) { // Already a topic $new_topic = false; } else { $topic_id = ocf_make_topic($forum_id, '', '', 1, 1, 0, 0, 0, NULL, NULL, false); $new_topic = true; } $topic_title = do_lang('REPORTED_CONTENT_TITLE', $content_title); $post_id = ocf_make_post($topic_id, $content_title, $post, 0, $new_topic, 1, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, false, true, $forum_id, true, $topic_title, 0, NULL, $anonymous == 1); decache('main_staff_checklist'); // Add to reported_content table $GLOBALS['SITE_DB']->query_insert('reported_content', array('r_session_id' => get_session_id(), 'r_content_type' => $content_type, 'r_content_id' => $content_id, 'r_counts' => 1)); // If hit threshold, mark down r_counts and unvalidate the content $count = $GLOBALS['SITE_DB']->query_value('reported_content', 'COUNT(*)', array('r_content_type' => $content_type, 'r_content_id' => $content_id, 'r_counts' => 1)); if ($count >= intval(get_option('reported_times'))) { // Mark as unvalidated if (isset($cma_info['validated_field']) && strpos($cma_info['table'], '(') === false) { $db = $GLOBALS[substr($cma_info['table'], 0, 2) == 'f_' ? 'FORUM_DB' : 'SITE_DB']; $db->query_update($cma_info['table'], array($cma_info['validated_field'] => 0), array($cma_info['id_field'] => $cma_info['id_field_numeric'] ? intval($content_id) : $content_id)); } $GLOBALS['SITE_DB']->query_update('reported_content', array('r_counts' => 0), array('r_content_type' => $content_type, 'r_content_id' => $content_id)); } // Done $_url = post_param('url', '', true); if ($_url != '') { $content_url = make_string_tempcode($_url); } require_code('templates_redirect_screen'); return redirect_screen($title, $content_url, do_lang_tempcode('SUCCESS')); }
/** * Perform a multi moderation. * * @param AUTO_LINK The ID of the multi moderation we are performing. * @param AUTO_LINK The ID of the topic we are performing the multi moderation on. * @param LONG_TEXT The reason for performing the multi moderation (may be blank). * @param LONG_TEXT The post text for a post to be added to the topic (blank: do not add a post). * @param BINARY Whether the post is marked emphasised. * @param BINARY Whether to skip showing the posters signature in the post. */ function ocf_perform_multi_moderation($id, $topic_id, $reason, $post_text = '', $is_emphasised = 1, $skip_sig = 0) { $topic_details = $GLOBALS['FORUM_DB']->query_select('f_topics', array('t_forum_id', 't_cache_first_title', 't_cache_first_post_id'), array('id' => $topic_id), '', 1); if (!array_key_exists(0, $topic_details)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $from = $topic_details[0]['t_forum_id']; if (!ocf_may_perform_multi_moderation($from)) { access_denied('I_ERROR'); } $mm = $GLOBALS['FORUM_DB']->query_select('f_multi_moderations', array('*'), array('id' => $id)); if (!array_key_exists(0, $mm)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } require_code('ocfiltering'); $idlist = ocfilter_to_idlist_using_db($mm[0]['mm_forum_multi_code'], 'id', 'f_forums', 'f_forums', 'f_parent_forum', 'f_parent_forum', 'id', true, true, $GLOBALS['FORUM_DB']); if (!in_array($from, $idlist)) { warn_exit(do_lang_tempcode('MM_APPLY_TWICE')); } $pin_state = $mm[0]['mm_pin_state']; $open_state = $mm[0]['mm_open_state']; $sink_state = $mm[0]['mm_sink_state']; $move_to = $mm[0]['mm_move_to']; $title_suffix = $mm[0]['mm_title_suffix']; //$post_text=$mm[0]['mm_post_text']; We'll allow user to specify the post_text, with this as a default $update_array = array(); if (!is_null($pin_state)) { $update_array['t_pinned'] = $pin_state; } if (!is_null($sink_state)) { $update_array['t_sunk'] = $sink_state; } if (!is_null($open_state)) { $update_array['t_is_open'] = $open_state; } if ($title_suffix != '') { $new_title = $topic_details[0]['t_cache_first_title'] . ' [' . $title_suffix . ']'; $update_array['t_cache_first_title'] = $new_title; $GLOBALS['FORUM_DB']->query_update('f_posts', array('p_title' => $new_title), array('id' => $topic_details[0]['t_cache_first_post_id']), '', 1); } if (count($update_array) != 0) { $GLOBALS['FORUM_DB']->query_update('f_topics', $update_array, array('id' => $topic_id), '', 1); } if (!is_null($move_to)) { require_code('ocf_topics_action'); require_code('ocf_topics_action2'); ocf_move_topics($from, $move_to, array($topic_id)); } if ($post_text != '') { require_code('ocf_posts_action'); require_code('ocf_posts_action2'); require_code('ocf_topics_action'); require_code('ocf_topics_action2'); ocf_make_post($topic_id, '', $post_text, $skip_sig, false, 1, $is_emphasised); $forum_id = is_null($move_to) ? $from : $move_to; handle_topic_ticket_reply($forum_id, $topic_id, $topic_details[0]['t_cache_first_title'], $post_text); } require_code('ocf_general_action2'); ocf_mod_log_it('PERFORM_MULTI_MODERATION', strval($id), strval($topic_id), $reason); }
function run($ob, $query, $max, $start, $fail_ok, $get_insert_id, $ret) { if (running_script('stress_test_loader')) { return; } if (get_page_name() == 'admin_import') { return; } if (!isset($GLOBALS['FORUM_DB'])) { return; } if ($GLOBALS['IN_MINIKERNEL_VERSION'] == 1) { return; } //if (strpos($query,$GLOBALS['FORUM_DB']->get_table_prefix().'f_members')!==false && strpos($query,'BY RAND')==false) // to test without registration if (strpos($query, 'INTO ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_members') !== false) { load_user_stuff(); if (method_exists($GLOBALS['FORUM_DRIVER'], 'forum_layer_initialise')) { $GLOBALS['FORUM_DRIVER']->forum_layer_initialise(); } global $FORCE_INVISIBLE_GUEST, $MEMBER_CACHED, $SESSION_CACHE; $FORCE_INVISIBLE_GUEST = false; $MEMBER_CACHED = NULL; if (!isset($SESSION_CACHE) || !is_array($SESSION_CACHE)) { $SESSION_CACHE = array(); } $mentor_usergroup = get_option('mentor_usergroup', true); if (is_null($mentor_usergroup)) { return; } require_code('ocf_topics'); require_code('ocf_forums'); require_code('ocf_topics_action'); require_code('ocf_posts_action'); require_code('ocf_topics_action2'); require_code('ocf_posts_action2'); require_code('ocf_members'); require_code('ocf_members2'); require_lang('ocbestbuddy'); $mentor_usergroup_id = 0; //0 ? $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(); foreach ($groups as $group_id => $group) { if ($group == $mentor_usergroup) { $mentor_usergroup_id = $group_id; } } $random_mentor = $GLOBALS['FORUM_DB']->query('SELECT id FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_members m LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_group_members g ON (g.gm_member_id=m.id AND gm_validated=1) WHERE gm_group_id=' . strval($mentor_usergroup_id) . ' OR m_primary_group=' . strval($mentor_usergroup_id) . ' ORDER BY RAND( ) LIMIT 1', NULL, NULL, true); $mentor_id = isset($random_mentor[0]['id']) && !is_null($random_mentor[0]['id']) ? $random_mentor[0]['id'] : 0; if ($mentor_id == 0) { return; } $member_id = $ret; $time = time(); $GLOBALS['SITE_DB']->query_delete('chat_buddies', array('member_likes' => $mentor_id, 'member_liked' => $member_id), '', 1); // Just in case page refreshed $GLOBALS['SITE_DB']->query_insert('chat_buddies', array('member_likes' => $mentor_id, 'member_liked' => $member_id, 'date_and_time' => $time)); $GLOBALS['SITE_DB']->query_delete('members_mentors', array('member_id' => $member_id, 'mentor_id' => $mentor_id), '', 1); // Just in case page refreshed $GLOBALS['SITE_DB']->query_insert('members_mentors', array('member_id' => $member_id, 'mentor_id' => $mentor_id)); log_it('MAKE_BUDDY', strval($mentor_id), strval($member_id)); $subject = do_lang('MENTOR_PT_TOPIC', $GLOBALS['FORUM_DRIVER']->get_username($mentor_id), $GLOBALS['FORUM_DRIVER']->get_username($member_id)); $topic_id = ocf_make_topic(NULL, $subject, '', 1, 1, 0, 0, 0, $mentor_id, $member_id, false, 0, NULL, ''); $post_id = ocf_make_post($topic_id, $subject, do_lang('MENTOR_PT_TOPIC_POST', $GLOBALS['FORUM_DRIVER']->get_username($mentor_id), $GLOBALS['FORUM_DRIVER']->get_username($member_id), get_site_name()), 0, true, 1, 0, NULL, NULL, NULL, $mentor_id, NULL, NULL, NULL, false, true, NULL, true, $subject, 0, NULL, true, true, true); send_pt_notification($post_id, $subject, $topic_id, $member_id, $mentor_id); send_pt_notification($post_id, $subject, $topic_id, $mentor_id, $member_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_personal_topics($db, $table_prefix, $old_base_dir) { $rows = $db->query('SELECT * FROM ' . $table_prefix . 'messages WHERE vid<>\'sent\' ORDER BY msg_date'); // Group them up into what will become topics $groups = array(); foreach ($rows as $row) { if ($row['from_id'] > $row['recipient_id']) { $a = $row['recipient_id']; $b = $row['from_id']; } else { $a = $row['from_id']; $b = $row['recipient_id']; } $title = str_replace('Re: ', '', $row['title']); $title = str_replace('RE: ', '', $title); $title = str_replace('Re:', '', $title); $title = str_replace('RE:', '', $title); $groups[strval($a) . ':' . strval($b) . ':' . @html_entity_decode($title, ENT_QUOTES, get_charset())][] = $row; } // Import topics foreach ($groups as $group) { $row = $group[0]; if (import_check_if_imported('pt', strval($row['msg_id']))) { continue; } // Create topic $from_id = import_id_remap_get('member', strval($row['from_id']), true); if (is_null($from_id)) { $from_id = $GLOBALS['OCF_DRIVER']->get_guest_id(); } $to_id = import_id_remap_get('member', strval($row['recipient_id']), true); if (is_null($to_id)) { $to_id = $GLOBALS['OCF_DRIVER']->get_guest_id(); } $topic_id = ocf_make_topic(NULL, '', '', 1, 1, 0, 0, 0, $from_id, $to_id, false); $first_post = true; foreach ($group as $_postdetails) { if ($first_post) { $title = @html_entity_decode($row['title'], ENT_QUOTES, get_charset()); } else { $title = ''; } $post = $this->clean_ipb_post($_postdetails['message']); $validated = 1; $from_id = import_id_remap_get('member', strval($_postdetails['from_id']), true); if (is_null($from_id)) { $from_id = $GLOBALS['OCF_DRIVER']->get_guest_id(); } $poster_name_if_guest = $GLOBALS['OCF_DRIVER']->get_member_row_field($from_id, 'm_username'); $ip_address = $GLOBALS['OCF_DRIVER']->get_member_row_field($from_id, 'm_ip_address'); $time = $_postdetails['msg_date']; $poster = $from_id; $last_edit_time = NULL; $last_edit_by = NULL; ocf_make_post($topic_id, $title, $post, 0, $first_post, $validated, 0, $poster_name_if_guest, $ip_address, $time, $poster, NULL, $last_edit_time, $last_edit_by, false, false, NULL, false); $first_post = false; } import_id_remap_put('pt', strval($row['msg_id']), $topic_id); } }
/** * The actualiser to add a reply. * * @return tempcode The UI */ function _add_reply() { if (addon_installed('captcha')) { require_code('captcha'); enforce_captcha(); } require_code('attachments2'); require_code('ocf_posts_action'); require_code('ocf_posts_action2'); $invited_members = array(); $topic_id = either_param_integer('topic_id', -1); // Posting into an existing topic? $forum_id = post_param_integer('forum_id', -1); // New topic in existing forum? (NB: -2 represents reported posts forum) $member_id = post_param_integer('member_id', -1); // Send TOPIC to specific member? Could be Private Topic (topic_id==-1, forum_id==-1), or personal post (topic_id!=-1, forum_id==-1) $parent_id = either_param_integer('parent_id', NULL); if ($member_id == -1) { $member_username = post_param('to_member_id_0', ''); if ($member_username != '') { $member_id = $GLOBALS['FORUM_DRIVER']->get_member_from_username($member_username); if (is_null($member_id)) { warn_exit(do_lang_tempcode('_USER_NO_EXIST', $member_username)); } } foreach ($_POST as $key => $_invited_member) { if (substr($key, 0, 13) != 'to_member_id_') { continue; } if ($key == 'to_member_id_0') { continue; } if ($_invited_member == '') { continue; } if (get_magic_quotes_gpc()) { $_invited_member = stripslashes($_invited_member); } $invited_member = $GLOBALS['FORUM_DRIVER']->get_member_from_username($_invited_member); if (is_null($invited_member)) { attach_message(do_lang_tempcode('_USER_NO_EXIST', $_invited_member), 'warn'); } else { $invited_members[] = intval($invited_member); } } } $validated = post_param_integer('validated', post_param_integer('_validated', 0)); $is_emphasised = post_param_integer('is_emphasised', 0); $skip_sig = post_param_integer('skip_sig', 0); $post = post_param('post'); $title = post_param('title', NULL); if (is_null($title)) { $title = ''; } $check_permissions = true; $add_poll = post_param_integer('add_poll', 0); $topic_validated = $validated; if ($validated == 1) { $topic_validated = 1 - $add_poll; } // If a topic is gonna have a poll added, it starts unvalidated. Adding the poll will validate it. $anonymous = post_param_integer('anonymous', 0); $poster_name_if_guest = post_param('poster_name_if_guest', NULL); if ($poster_name_if_guest == '') { $poster_name_if_guest = NULL; } if (!is_null($poster_name_if_guest)) { $poster_name_if_guest = trim($poster_name_if_guest); $restricted_usernames = explode(',', get_option('restricted_usernames')); $restricted_usernames[] = do_lang('UNKNOWN'); $restricted_usernames[] = do_lang('SYSTEM'); if (!is_null($GLOBALS['FORUM_DRIVER']->get_member_from_username($poster_name_if_guest))) { $restricted_usernames[] = $poster_name_if_guest; } foreach ($restricted_usernames as $_restricted_username) { $restricted_username = trim($_restricted_username); if ($restricted_username == '') { continue; } if ($poster_name_if_guest == $restricted_username) { $poster_name_if_guest = $poster_name_if_guest . ' (' . do_lang('GUEST') . ')'; break; } } } $new_topic = $topic_id == -1; if (!$new_topic) { $_intended_solely_for = post_param('intended_solely_for', ''); if ($_intended_solely_for == '') { $intended_solely_for = NULL; } else { $intended_solely_for = $GLOBALS['FORUM_DRIVER']->get_member_from_username($_intended_solely_for); if (is_null($intended_solely_for)) { warn_exit(do_lang_tempcode('_USER_NO_EXIST', $_intended_solely_for)); } } } else { $intended_solely_for = NULL; } require_code('ocf_topics_action'); require_code('ocf_topics_action2'); if ($new_topic) { ocf_check_post($post); if ($title == '') { warn_exit(do_lang_tempcode('NO_PARAMETER_SENT', 'title')); } $sunk = post_param_integer('sunk', 0); $topic_title = $title; if ($forum_id == -1) { require_code('ocf_members2'); if (!ocf_may_whisper($member_id)) { warn_exit(do_lang_tempcode('NO_PT_FROM_ALLOW')); } check_specific_permission('use_pt'); $topic_id = ocf_make_topic(NULL, post_param('description', ''), post_param('emoticon', ''), $topic_validated, post_param_integer('open', 0), post_param_integer('pinned', 0), $sunk, post_param_integer('cascading', 0), get_member(), $member_id); $_title = get_page_title('ADD_PERSONAL_TOPIC'); } elseif ($forum_id == -2) { $forum_id = $GLOBALS['FORUM_DRIVER']->forum_id_from_name(get_option('reported_posts_forum')); if (is_null($forum_id)) { warn_exit(do_lang_tempcode('NO_REPORTED_POST_FORUM')); } // See if post already reported... $topic_id = $GLOBALS['FORUM_DB']->query_value_null_ok('f_topics t LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_posts p ON p.id=t.t_cache_first_post_id', 't.id', array('p.p_title' => $title, 't.t_forum_id' => $forum_id)); if (!is_null($topic_id)) { // Already a topic } else { $topic_id = ocf_make_topic($forum_id, '', '', 1, 1, 0, 0, 0, NULL, NULL, false); } $_title = get_page_title('REPORT_POST'); $check_permissions = false; decache('main_staff_checklist'); } else { $topic_id = ocf_make_topic($forum_id, post_param('description', ''), post_param('emoticon', ''), $topic_validated, post_param_integer('open', 0), post_param_integer('pinned', 0), $sunk, post_param_integer('cascading', 0)); $_title = get_page_title('ADD_TOPIC'); if (addon_installed('awards')) { require_code('awards'); handle_award_setting('topic', strval($topic_id)); } } $first_post = true; require_code('fields'); if (has_tied_catalogue('topic')) { save_form_custom_fields('topic', strval($topic_id)); } } else { $_title = get_page_title('ADD_POST'); $first_post = false; $topic_info = $GLOBALS['FORUM_DB']->query_select('f_topics', array('t_cache_first_title', 't_sunk', 't_forum_id', 't_is_open', 't_description'), array('id' => $topic_id), '', 1); if (!array_key_exists(0, $topic_info)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $forum_id = $topic_info[0]['t_forum_id']; $topic_title = $topic_info[0]['t_cache_first_title']; $sunk = $topic_info[0]['t_sunk']; if ($topic_info[0]['t_is_open'] == 0) { $may_moderate_forum = ocf_may_moderate_forum($forum_id); if (!$may_moderate_forum) { warn_exit(do_lang_tempcode('TOPIC_IS_CLOSED')); } } // Moderator reply $new_title = post_param('new_title', NULL); if (!is_null($new_title) && !is_null($forum_id) && ocf_may_moderate_forum($forum_id, get_member())) { $cascading = post_param_integer('cascading', 0); $pinned = post_param_integer('pinned', 0); $sunk = post_param_integer('sunk', 0); $open = post_param_integer('open', 0); $topic_validated = post_param_integer('topic_validated', 0); $to = post_param_integer('to', NULL); $schedule = get_input_date('schedule'); if (!is_null($schedule) && addon_installed('calendar')) { $_intended_solely_for = is_null($intended_solely_for) ? 'NULL' : strval($intended_solely_for); $_postdetailser_name_if_guest = is_null($poster_name_if_guest) ? 'NULL' : '\'' . addslashes($poster_name_if_guest) . '\''; $_first_post = $first_post ? 'true' : 'false'; $__title = is_null($title) ? 'NULL' : '\'' . str_replace(chr(10), '\'.chr(10).\'', addslashes($title)) . '\''; $_postdetails = is_null($post) ? 'NULL' : '\'' . str_replace(chr(10), '\'.chr(10).\'', addslashes($post)) . '\''; $_new_title = is_null($new_title) ? 'NULL' : '\'' . str_replace(chr(10), '\'.chr(10).\'', addslashes($new_title)) . '\''; $schedule_code = <<<END :require_code('ocf_topics_action2'); require_code('ocf_topics_action'); ocf_edit_topic({$topic_id},NULL,NULL,{$validated},{$open},{$pinned},{$sunk},{$cascading},'',{$_new_title}); if (({$to}!={$forum_id}) && (!is_null({$to}))) ocf_move_topics({$forum_id},{$to},array({$topic_id})); \$post_id=ocf_make_post({$topic_id},{$__title},{$_postdetails},{$skip_sig},{$_first_post},{$validated},{$is_emphasised},{$_postdetailser_name_if_guest},NULL,NULL,NULL,{$_intended_solely_for},NULL,NULL,false,true,NULL,true,{$topic_title},{$sunk},NULL,{$anonymous}==1); if (addon_installed('awards')) { require_code('awards'); handle_award_setting('post',strval(\$post_id)); } END; require_code('calendar'); $start_year = post_param_integer('schedule_year'); $start_month = post_param_integer('schedule_month'); $start_day = post_param_integer('schedule_day'); $start_hour = post_param_integer('schedule_hour'); $start_minute = post_param_integer('schedule_minute'); require_code('calendar2'); $event_id = add_calendar_event(db_get_first_id(), '', NULL, 0, do_lang('ADD_POST'), $schedule_code, 3, 0, $start_year, $start_month, $start_day, $start_hour, $start_minute); regenerate_event_reminder_jobs($event_id); $text = do_lang_tempcode('SUCCESS'); $map = array('page' => 'topicview', 'id' => $topic_id, 'type' => 'first_unread'); $test = get_param_integer('kfs' . (is_null($forum_id) ? '' : strval($forum_id)), -1); if ($test != -1 && $test != 0) { $map['kfs' . (is_null($forum_id) ? '' : strval($forum_id))] = $test; } $test = get_param_integer('threaded', -1); if ($test != -1) { $map['threaded'] = $test; } $_url = build_url($map, get_module_zone('topicview')); $url = $_url->evaluate(); $url .= '#first_unread'; $url = get_param('redirect', $url); return redirect_screen($_title, $url, $text); } ocf_edit_topic($topic_id, NULL, NULL, $topic_validated, $open, $pinned, $sunk, $cascading, '', $new_title == '' ? NULL : $new_title); if ($to != $forum_id && !is_null($to)) { ocf_move_topics($forum_id, $to, array($topic_id)); } } } $post_id = ocf_make_post($topic_id, $title, $post, $skip_sig, $first_post, $validated, $is_emphasised, $poster_name_if_guest, NULL, NULL, NULL, $intended_solely_for, NULL, NULL, $check_permissions, true, NULL, true, $topic_title, $sunk, NULL, $anonymous == 1, $forum_id == -1 || is_null($forum_id), $forum_id == -1 || is_null($forum_id), false, $parent_id); if (addon_installed('awards')) { require_code('awards'); handle_award_setting('post', strval($post_id)); } if (!is_null($forum_id) && $anonymous == 0 && $intended_solely_for === NULL) { if (has_actual_page_access($GLOBALS['FORUM_DRIVER']->get_guest_id(), 'forumview') && has_category_access($GLOBALS['FORUM_DRIVER']->get_guest_id(), 'forums', strval($forum_id))) { syndicate_described_activity($first_post ? 'ocf:ACTIVITY_ADD_TOPIC' : 'ocf:ACTIVITY_ADD_POST_IN', $first_post ? $title : $topic_title, '', '', '_SEARCH:topicview:misc:' . strval($topic_id) . '#post_' . strval($post_id), '', '', 'ocf_forum'); } } require_code('fields'); if (has_tied_catalogue('post')) { save_form_custom_fields('post', strval($post_id)); } $validated = $GLOBALS['FORUM_DB']->query_value('f_posts', 'p_validated', array('id' => $post_id)); $rep_post_id = post_param_integer('o_post_id', -1); if ($rep_post_id != -1) { $map = array('page' => 'topicview', 'id' => $rep_post_id, 'type' => 'findpost'); $_url = build_url($map, get_module_zone('topicview')); $url = $_url->evaluate(); $url .= '#post_' . strval($rep_post_id); } else { $map = array('page' => 'topicview', 'id' => $post_id, 'type' => 'findpost'); $test = get_param_integer('kfs' . (is_null($forum_id) ? '' : strval($forum_id)), -1); if ($test != -1 && $test != 0) { $map['kfs' . (is_null($forum_id) ? '' : strval($forum_id))] = $test; } $test = get_param_integer('threaded', -1); if ($test != -1) { $map['threaded'] = $test; } $_url = build_url($map, get_module_zone('topicview')); $url = $_url->evaluate(); if ($validated != 0) { $url .= '#post_' . strval($post_id); } } if ($forum_id >= 0) { $topic_validated = $GLOBALS['FORUM_DB']->query_value('f_topics', 't_validated', array('id' => $topic_id)); if ($topic_validated == 0 && !has_specific_permission(get_member(), 'jump_to_unvalidated')) { $map = array('page' => 'forumview', 'id' => $forum_id); $test = get_param_integer('kfs' . (is_null($forum_id) ? '' : strval($forum_id)), -1); if ($test != -1 && $test != 0) { $map['kfs' . (is_null($forum_id) ? '' : strval($forum_id))] = $test; } $test = get_param_integer('threaded', -1); if ($test != -1) { $map['threaded'] = $test; } $_url = build_url($map, get_module_zone('forumview')); $url = $_url->evaluate(); } } if ($new_topic && $forum_id == -1) { require_code('notifications'); enable_notifications('ocf_topic', strval($topic_id), get_member()); // from enable_notifications('ocf_topic', strval($topic_id), $member_id); // to foreach ($invited_members as $invited_member) { enable_notifications('ocf_topic', strval($topic_id), $invited_member); ocf_invite_to_pt($invited_member, $topic_id); } } if ($anonymous == 1) { log_it('MAKE_ANONYMOUS_POST', strval($post_id), $title); } if (addon_installed('awards')) { require_code('awards'); handle_award_setting('post', strval($post_id)); } if ($forum_id == -1 && $member_id != -1) { send_pt_notification($post_id, $title, $topic_id, $member_id, NULL, $post); } if ($add_poll == 1) { if (post_param_integer('add_poll', 0) == 1) { // Show it worked / Refresh $_url = build_url(array('page' => '_SELF', 'type' => 'add_poll', 'id' => $topic_id, 'try_validate' => 1), '_SELF'); return redirect_screen($_title, $_url, do_lang_tempcode('SUCCESS')); } } if (!$new_topic && $forum_id != -1 && $member_id == -1) { handle_topic_ticket_reply($forum_id, $topic_id, $topic_title, $post); } $text = $validated == 1 ? do_lang_tempcode('SUCCESS') : do_lang_tempcode('SUBMIT_UNVALIDATED'); require_code('autosave'); clear_ocp_autosave(); // Show it worked / Refresh $url = get_param('redirect', $url); return redirect_screen($_title, $url, $text); }
function run($ob, $query, $max, $start, $fail_ok, $get_insert_id, $ret) { if (!isset($GLOBALS['FORUM_DB'])) { return; } if ($GLOBALS['IN_MINIKERNEL_VERSION'] == 1) { return; } if ($GLOBALS['BOOTSTRAPPING'] == 1) { return; } //if (strpos($query,$GLOBALS['FORUM_DB']->get_table_prefix().'f_members')!==false && strpos($query,'BY RAND')==false) // to test without registration if (strpos($query, 'INTO ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_posts') !== false) { require_code('permissions'); load_user_stuff(); if (method_exists($GLOBALS['FORUM_DRIVER'], 'forum_layer_initialise')) { $GLOBALS['FORUM_DRIVER']->forum_layer_initialise(); } global $FORCE_INVISIBLE_GUEST, $MEMBER_CACHED; $FORCE_INVISIBLE_GUEST = false; $MEMBER_CACHED = NULL; $poster_id = get_member(); $post = post_param('post', ''); $posted_data = $GLOBALS['FORUM_DB']->query('SELECT * FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_posts WHERE id= ' . strval($ret) . ' ', 1, NULL, true); $topic_id = isset($posted_data[0]['p_topic_id']) && $posted_data[0]['p_topic_id'] > 0 ? $posted_data[0]['p_topic_id'] : 0; $first_post_data = $GLOBALS['FORUM_DB']->query('SELECT * FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_posts WHERE p_topic_id= ' . strval($topic_id) . ' ORDER BY p_time,id', 1, NULL, true); $first_post = $first_post_data[0]['p_post']; $first_post = get_translated_text($first_post); $_insult = explode('[b]', $first_post); $insult = isset($_insult[1]) && strlen($_insult[1]) > 0 ? $_insult[1] : ''; $_insult = explode('[/b]', $insult); $insult = isset($_insult[0]) && strlen($_insult[0]) > 0 ? $_insult[0] : ''; //old code that uses quotes //$insult=explode('"',$first_post); //$insult=(isset($insult[1]) && strlen($insult[1])>0)?$insult[1]:''; if ($insult != '') { $get_reply = ''; if (is_file(get_file_base() . '/text_custom/' . user_lang() . '/insults.txt')) { $insults = file(get_file_base() . '/text_custom/' . user_lang() . '/insults.txt'); $insults_array = array(); foreach ($insults as $insult_item) { $x = explode('=', $insult_item); if (isset($x[0]) && strlen($x[0]) > 0 && isset($x[1]) && strlen($x[1]) > 0) { $insults_array[trim($x[0])] = trim($x[1]); } } $get_reply = isset($insults_array[$insult]) ? $insults_array[$insult] : ''; } if ($get_reply != '') { //get PT $pt = $GLOBALS['FORUM_DB']->query('SELECT * FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_topics WHERE id= ' . strval($topic_id) . ' ', 1, NULL, true); $to_member = isset($pt[0]['t_pt_to']) && $pt[0]['t_pt_to'] > 0 ? $pt[0]['t_pt_to'] : 0; if ($to_member == $poster_id) { //start comparing insult reply and the post if (levenshtein(trim(strtolower($post)), trim(strtolower($get_reply))) < intval(0.1 * strlen($get_reply))) { $_insult_points = get_option('insult_points', true); $insult_points = isset($_insult_points) && intval($_insult_points) > 0 ? intval($_insult_points) : 10; // give points require_code('points2'); require_lang('insults'); $rows = $GLOBALS['FORUM_DB']->query('SELECT g.id FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'gifts g LEFT JOIN ' . get_table_prefix() . 'translate t ON t.id=g.reason WHERE t.text_original LIKE "' . db_encode_like('%' . $insult . '%') . '" AND g.gift_to=' . strval($poster_id), 1, NULL, true); //if the member doesn't get reward yet, give him/her his award if (!isset($rows[0]['id'])) { system_gift_transfer(do_lang('SUCCESSFULLY_SUGGESTED_COMEBACK') . ' (' . $insult . ')', intval($insult_points), $poster_id); require_code('ocf_posts_action'); $congratulations_post = do_lang('CONGRATULATIONS_WON'); //Congratulations that is the correct response ocf_make_post($topic_id, '', $congratulations_post, 0, true, 1, 0, do_lang('SYSTEM'), NULL, NULL, $GLOBALS['FORUM_DRIVER']->get_guest_id(), $poster_id, NULL, NULL, false, true, NULL, true, '', 0, NULL, false, true, 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_posts($db, $table_prefix, $file_base) { if ($this->on_same_msn($file_base)) { return; } global $STRICT_FILE, $TOPIC_FORUM_CACHE; $TOPIC_FORUM_CACHE = array(); $row_start = 0; $rows = array(); do { $rows = $db->query('SELECT * FROM ' . $table_prefix . 'f_posts ORDER BY id', 200, $row_start); foreach ($rows as $row) { if (import_check_if_imported('post', strval($row['id']))) { continue; } $member_id = import_id_remap_get('member', strval($row['p_poster']), true); if (is_null($member_id)) { $member_id = db_get_first_id(); } $topic_id = import_id_remap_get('topic', strval($row['p_topic_id']), true); if (is_null($topic_id)) { continue; } // This speeds up addition... using the cache can reduce about 7/8 of a query per post on average if (array_key_exists($topic_id, $TOPIC_FORUM_CACHE)) { $forum_id = $TOPIC_FORUM_CACHE[$topic_id]; } else { $forum_id = $GLOBALS['FORUM_DB']->query_value_null_ok('f_topics', 't_forum_id', array('id' => $topic_id)); $TOPIC_FORUM_CACHE[$topic_id] = $forum_id; } $last_edit_by = $row['p_last_edit_by']; if (!is_null($last_edit_by)) { $last_edit_by = import_id_remap_get('member', strval($last_edit_by), true); } $intended_solely_for = $row['p_intended_solely_for']; if (!is_null($intended_solely_for)) { $intended_solely_for = import_id_remap_get('member', strval($intended_solely_for), true); if (is_null($intended_solely_for)) { $intended_solely_for = -1; } } $id = get_param_integer('keep_preserve_ids', 0) == 0 ? NULL : $row['id']; $id_new = ocf_make_post($topic_id, $row['p_title'], $this->get_lang_string($db, $row['p_post']), 0, false, $row['p_validated'], $row['p_is_emphasised'], $row['p_poster_name_if_guest'], $row['p_ip_address'], $row['p_time'], $member_id, $intended_solely_for, $row['p_last_edit_time'], $last_edit_by, false, false, $forum_id, false, '', 0, $id, false, true); import_id_remap_put('post', strval($row['id']), $id_new); } $row_start += 200; } while (count($rows) > 0); $this->_import_review_supplement($db, $table_prefix, 'post', 'post'); $this->_import_catalogue_entry_linkage($db, $table_prefix, 'post', 'post'); }
/** * Standard modular run function for CRON hooks. Searches for tasks to perform. */ function run() { //if (!addon_installed('octhief')) return; require_code('ocf_topics_action2'); require_code('points'); require_lang('octhief'); // ensure it is done once per week $time = time(); $last_time = intval(get_value('last_thieving_time')); if ($last_time > time() - 24 * 60 * 60 * 7) { return; } set_value('last_thieving_time', strval($time)); $octhief_type = get_option('octhief_type', true); $octhief_type = isset($octhief_type) && strlen($octhief_type) > 0 ? $octhief_type : 'Members that are inactive, but has lots points'; $_octhief_number = get_option('octhief_number', true); $octhief_number = isset($_octhief_number) && is_numeric($_octhief_number) ? intval($_octhief_number) : 1; $_octhief_points = get_option('octhief_points', true); $octhief_points = isset($_octhief_points) && is_numeric($_octhief_points) ? intval($_octhief_points) : 10; $octhief_group = get_option('octhief_group', true); $octhief_group = isset($octhief_group) && strlen($octhief_group) > 0 ? $octhief_group : 'Member'; // start determining the various cases if ($octhief_type == "Members that are inactive, but has lots points") { $all_members = $GLOBALS['FORUM_DRIVER']->get_top_posters(1000); $points = array(); foreach ($all_members as $member) { $id = $GLOBALS['FORUM_DRIVER']->pname_id($member); $signin_time = $member['m_last_visit_time']; $points[$signin_time] = array('points' => available_points($id), 'id' => $id); } ksort($points); //print_r($points); $octhief_number = count($points) > $octhief_number ? $octhief_number : count($points); $theft_count = 0; foreach ($points as $member) { $theft_count++; if ($theft_count > $octhief_number) { break; } // start stealing require_code('points2'); require_lang('octhief'); $total_points = $member['points']; $octhief_points = $octhief_points < $total_points ? $octhief_points : $total_points; $give_to_member = $GLOBALS['FORUM_DB']->query('SELECT id FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_members WHERE id <> ' . strval($GLOBALS['FORUM_DRIVER']->get_guest_id()) . ' AND id <> ' . strval($member['id']) . ' ORDER BY RAND( ) ', 1, NULL, true); $give_to_member = isset($give_to_member[0]['id']) && $give_to_member[0]['id'] > 0 ? $give_to_member[0]['id'] : 0; // get THIEF points charge_member($member['id'], $octhief_points, do_lang('THIEF_GET') . ' ' . strval($octhief_points) . ' point(-s) from you.'); if ($give_to_member > 0) { system_gift_transfer(do_lang('THIEF_GAVE_YOU') . ' ' . strval($octhief_points) . ' point(-s)', $octhief_points, $give_to_member); require_code('ocf_topic_action'); require_code('ocf_posts_action'); $subject = do_lang('THIEF_PT_TOPIC', strval($octhief_points), $GLOBALS['FORUM_DRIVER']->get_username($member['id']), $GLOBALS['FORUM_DRIVER']->get_username($give_to_member)); $topic_id = ocf_make_topic(NULL, $subject, '', 1, 1, 0, 0, 0, $member['id'], $give_to_member, false, 0, NULL, ''); $post_id = ocf_make_post($topic_id, $subject, do_lang('THIEF_PT_TOPIC_POST'), 0, true, 1, 0, NULL, NULL, NULL, $give_to_member, NULL, NULL, NULL, false, true, NULL, true, $subject, 0, NULL, true, true, true); send_pt_notification($post_id, $subject, $topic_id, $give_to_member, $GLOBALS['FORUM_DRIVER']->pname_id($member)); send_pt_notification($post_id, $subject, $topic_id, $GLOBALS['FORUM_DRIVER']->pname_id($member), $give_to_member); } } } elseif ($octhief_type == "Members that are rich") { $all_members = $GLOBALS['FORUM_DRIVER']->get_top_posters(100); $points = array(); foreach ($all_members as $member) { $id = $GLOBALS['FORUM_DRIVER']->pname_id($member); $points[$id] = available_points($id); } arsort($points); $octhief_number = count($points) > $octhief_number ? $octhief_number : count($points); $theft_count = 0; foreach ($points as $member_id => $av_points) { $theft_count++; if ($theft_count > $octhief_number) { break; } // start stealing require_code('points2'); require_lang('octhief'); $total_points = $av_points; $octhief_points = $octhief_points < $total_points ? $octhief_points : $total_points; $give_to_member = $GLOBALS['FORUM_DB']->query('SELECT id FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_members WHERE id <> ' . strval($GLOBALS['FORUM_DRIVER']->get_guest_id()) . ' AND id <> ' . strval($member_id) . ' ORDER BY RAND( ) ', 1, NULL, true); $give_to_member = isset($give_to_member[0]['id']) && $give_to_member[0]['id'] > 0 ? $give_to_member[0]['id'] : 0; // get THIEF points charge_member($member_id, $octhief_points, do_lang('THIEF_GET') . ' ' . strval($octhief_points) . ' point(-s) from you.'); if ($give_to_member > 0) { system_gift_transfer(do_lang('THIEF_GAVE_YOU') . ' ' . strval($octhief_points) . ' point(-s)', $octhief_points, $give_to_member); require_code('ocf_topic_action'); require_code('ocf_posts_action'); $subject = do_lang('THIEF_PT_TOPIC', strval($octhief_points)); $topic_id = ocf_make_topic(NULL, $subject, '', 1, 1, 0, 0, 0, $member_id, $give_to_member, false, 0, NULL, ''); $post_id = ocf_make_post($topic_id, $subject, do_lang('THIEF_PT_TOPIC_POST'), 0, true, 1, 0, NULL, NULL, NULL, $give_to_member, NULL, NULL, NULL, false, true, NULL, true, $subject, 0, NULL, true, true, true); send_pt_notification($post_id, $subject, $topic_id, $give_to_member, $member); send_pt_notification($post_id, $subject, $topic_id, $member, $give_to_member); } } } elseif ($octhief_type == "Members that are random") { $random_members = $GLOBALS['FORUM_DB']->query('SELECT id FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_members WHERE id <> ' . strval($GLOBALS['FORUM_DRIVER']->get_guest_id()) . ' ORDER BY RAND( ) ', $octhief_number, NULL, true); $octhief_number = count($random_members) > $octhief_number ? $octhief_number : count($random_members); foreach ($random_members as $member) { // start stealing require_code('points2'); require_lang('octhief'); $total_points = available_points($member['id']); $octhief_points = $octhief_points < $total_points ? $octhief_points : $total_points; $give_to_member = $GLOBALS['FORUM_DB']->query('SELECT id FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_members WHERE id <> ' . strval($GLOBALS['FORUM_DRIVER']->get_guest_id()) . ' AND id <> ' . strval($member['id']) . ' ORDER BY RAND( ) ', 1, NULL, true); $give_to_member = isset($give_to_member[0]['id']) && $give_to_member[0]['id'] > 0 ? $give_to_member[0]['id'] : 0; // get THIEF points charge_member($member['id'], $octhief_points, do_lang('THIEF_GET') . ' ' . strval($octhief_points) . ' point(-s) from you.'); if ($give_to_member != 0) { system_gift_transfer(do_lang('THIEF_GAVE_YOU') . ' ' . strval($octhief_points) . ' point(-s)', $octhief_points, $give_to_member); require_code('ocf_topic_action'); require_code('ocf_posts_action'); $subject = do_lang('THIEF_PT_TOPIC', strval($octhief_points)); $topic_id = ocf_make_topic(NULL, $subject, '', 1, 1, 0, 0, 0, $member['id'], $give_to_member, false, 0, NULL, ''); $post_id = ocf_make_post($topic_id, $subject, do_lang('THIEF_PT_TOPIC_POST'), 0, true, 1, 0, NULL, NULL, NULL, $give_to_member, NULL, NULL, NULL, false, true, NULL, true, $subject, 0, NULL, true, true, true); send_pt_notification($post_id, $subject, $topic_id, $give_to_member, $member); send_pt_notification($post_id, $subject, $topic_id, $member, $give_to_member); } } } elseif ($octhief_type == "Members that are in a certain usergroup") { $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(); $group_id = 0; foreach ($groups as $id => $group) { if ($octhief_group == $group) { $group_id = $id; } } require_code('ocf_groups2'); $members = ocf_get_group_members_raw($group_id); $octhief_number = count($members) > $octhief_number ? $octhief_number : count($members); $members_to_steal_ids = array_rand($members, $octhief_number); if ($octhief_number == 1) { $members_to_steal_ids = array('0' => $members_to_steal_ids); } foreach ($members_to_steal_ids as $member_rand_key) { // start stealing require_code('points2'); require_lang('octhief'); //echo $members[$member_rand_key]; $total_points = available_points($members[$member_rand_key]); $octhief_points = $octhief_points < $total_points ? $octhief_points : $total_points; $give_to_member = $GLOBALS['FORUM_DB']->query('SELECT id FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_members WHERE id <> ' . strval($GLOBALS['FORUM_DRIVER']->get_guest_id()) . ' AND id <> ' . strval($members[$member_rand_key]) . ' ORDER BY RAND( ) ', 1, NULL, true); $give_to_member = isset($give_to_member[0]['id']) && $give_to_member[0]['id'] > 0 ? $give_to_member[0]['id'] : 0; // get THIEF points charge_member($members[$member_rand_key], $octhief_points, do_lang('THIEF_GET') . ' ' . strval($octhief_points) . ' point(-s) from you.'); if ($give_to_member != 0) { system_gift_transfer(do_lang('THIEF_GAVE_YOU') . ' ' . strval($octhief_points) . ' point(-s)', $octhief_points, $give_to_member); require_code('ocf_topics_action'); $subject = do_lang('THIEF_PT_TOPIC', strval($octhief_points)); $topic_id = ocf_make_topic(NULL, $subject, '', 1, 1, 0, 0, 0, $members[$member_rand_key], $give_to_member, false, 0, NULL, ''); require_code('ocf_posts_action'); $post_id = ocf_make_post($topic_id, $subject, do_lang('THIEF_PT_TOPIC_POST'), 0, true, 1, 0, NULL, NULL, NULL, $give_to_member, NULL, NULL, NULL, false, true, NULL, true, $subject, 0, NULL, true, true, true); require_code('ocf_topics_action2'); send_pt_notification($post_id, $subject, $topic_id, $give_to_member, $octhief_number); send_pt_notification($post_id, $subject, $topic_id, $octhief_number, $give_to_member); } } } }
/** * 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_personal_topics($db, $table_prefix, $old_base_dir) { $rows = $db->query('SELECT * FROM ' . $table_prefix . 'pm p ORDER BY pm_time'); // Group them up into what will become topics $groups = array(); foreach ($rows as $row) { // Do some fiddling around for duplication if ($row['pm_from'] > $row['pm_to']) { $a = $row['pm_to']; $b = $row['pm_from']; } else { $a = $row['pm_from']; $b = $row['pm_to']; } $row['pm_subject'] = str_replace('Re: ', '', $row['pm_subject']); $groups[strval($a) . ':' . strval($b) . ':' . $row['pm_subject']][] = $row; } // Import topics foreach ($groups as $group) { $row = $group[0]; if (import_check_if_imported('pt', strval($row['pmid']))) { continue; } // Create topic $from_id = import_id_remap_get('member', strval($row['pm_from']), true); if (is_null($from_id)) { $from_id = $GLOBALS['OCF_DRIVER']->get_guest_id(); } $to_id = import_id_remap_get('member', strval($row['pm_to']), true); if (is_null($to_id)) { $to_id = $GLOBALS['OCF_DRIVER']->get_guest_id(); } $topic_id = ocf_make_topic(NULL, '', '', 1, 1, 0, 0, 0, $from_id, $to_id, false); $first_post = true; foreach ($group as $_post) { if ($first_post) { $title = $row['pm_subject']; } else { $title = ''; } $title = @html_entity_decode($title, ENT_QUOTES, get_charset()); $post = $this->fix_links($_post['pm_body'], $db, $table_prefix, $old_base_dir); $validated = 1; $from_id = import_id_remap_get('member', strval($_post['pm_from']), true); if (is_null($from_id)) { $from_id = $GLOBALS['OCF_DRIVER']->get_guest_id(); } $poster_name_if_guest = $GLOBALS['OCF_DRIVER']->get_username($from_id); $ip_address = ''; $time = $_post['pm_time']; $poster = $from_id; $last_edit_time = NULL; $last_edit_by = NULL; ocf_make_post($topic_id, $title, $post, 0, $first_post, $validated, 0, $poster_name_if_guest, $ip_address, $time, $poster, NULL, $last_edit_time, $last_edit_by, false, false, NULL, false); $first_post = false; } import_id_remap_put('pt', strval($row['pmid']), $topic_id); } }
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_personal_topics($db, $table_prefix, $old_base_dir) { $rows = $db->query('SELECT * FROM ' . $table_prefix . 'pm p LEFT JOIN ' . $table_prefix . 'pmtext t ON p.pmtextid=t.pmtextid WHERE folderid<>-1 AND title NOT LIKE \'' . db_encode_like('Sent: %') . '\' ORDER BY dateline'); // Group them up into what will become topics $groups = array(); foreach ($rows as $row) { // Do some fiddling around for duplication if ($row['fromuserid'] > $row['userid']) { $a = $row['userid']; $b = $row['fromuserid']; } else { $a = $row['fromuserid']; $b = $row['userid']; } $row['title'] = str_replace('Re: ', '', $row['title']); $groups[strval($a) . ':' . strval($b) . ':' . $row['title']][] = $row; } // Import topics foreach ($groups as $group) { $row = $group[0]; if (import_check_if_imported('pt', strval($row['pmid']))) { continue; } // Create topic $from_id = import_id_remap_get('member', strval($row['fromuserid']), true); if (is_null($from_id)) { $from_id = $GLOBALS['OCF_DRIVER']->get_guest_id(); } $to_id = import_id_remap_get('member', strval($row['userid']), true); if (is_null($to_id)) { $to_id = $GLOBALS['OCF_DRIVER']->get_guest_id(); } $topic_id = ocf_make_topic(NULL, '', $this->convert_topic_emoticon($row['iconid']), 1, 1, 0, 0, 0, $from_id, $to_id, false); $first_post = true; foreach ($group as $_postdetails) { if ($first_post) { $title = $row['title']; } else { $title = ''; } $post = $this->fix_links($_postdetails['message'], $db, $table_prefix); $validated = 1; $from_id = import_id_remap_get('member', strval($_postdetails['fromuserid']), true); if (is_null($from_id)) { $from_id = $GLOBALS['OCF_DRIVER']->get_guest_id(); } $poster_name_if_guest = $_postdetails['fromusername']; $ip_address = $GLOBALS['OCF_DRIVER']->get_member_row_field($from_id, 'm_ip_address'); $time = $_postdetails['dateline']; $poster = $from_id; $last_edit_time = NULL; $last_edit_by = NULL; ocf_make_post($topic_id, $title, $post, 0, $first_post, $validated, 0, $poster_name_if_guest, $ip_address, $time, $poster, NULL, $last_edit_time, $last_edit_by, false, false, NULL, false); $first_post = false; } import_id_remap_put('pt', strval($row['pmid']), $topic_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_posts($db, $table_prefix, $file_base) { global $STRICT_FILE; $row_start = 0; $rows = array(); do { $rows = $db->query('SELECT * FROM ' . $table_prefix . 'posts ORDER BY pid', 200, $row_start); foreach ($rows as $row) { if (get_param_integer('keep_import_test', 0) == 1 && $row['new_topic'] == 0) { continue; } if (import_check_if_imported('post', strval($row['pid']))) { continue; } $topic_id = import_id_remap_get('topic', strval($row['topic_id']), true); if (is_null($topic_id)) { import_id_remap_put('post', strval($row['pid']), -1); continue; } $member_id = import_id_remap_get('member', strval($row['author_id']), true); if (is_null($member_id)) { $member_id = db_get_first_id(); } // This speeds up addition... using the cache can reduce about 7/8 of a query per post on average global $TOPIC_FORUM_CACHE; if (array_key_exists($topic_id, $TOPIC_FORUM_CACHE)) { $forum_id = $TOPIC_FORUM_CACHE[$topic_id]; } else { $forum_id = $GLOBALS['FORUM_DB']->query_value_null_ok('f_topics', 't_forum_id', array('id' => $topic_id)); if (is_null($forum_id)) { continue; } $TOPIC_FORUM_CACHE[$topic_id] = $forum_id; } $title = ''; if ($row['new_topic'] == 1) { $topics = $db->query('SELECT * FROM ' . $table_prefix . 'topics WHERE tid=' . strval($row['topic_id'])); $title = strip_tags(@html_entity_decode($topics[0]['title'], ENT_QUOTES, get_charset())); } elseif (!is_null($row['post_title'])) { $title = @html_entity_decode($row['post_title'], ENT_QUOTES, get_charset()); } ocf_over_msn(); $post = html_to_comcode($this->clean_ipb_post_2($row['post'])); ocf_over_local(); $last_edit_by = NULL; if (!is_null($row['edit_name'])) { $last_edit_by = $GLOBALS['OCF_DRIVER']->get_member_from_username(@html_entity_decode($row['edit_name'], ENT_QUOTES, get_charset())); } if (either_param('importer') == 'ipb2') { $post = str_replace('style_emoticons/<#EMO_DIR#>', '[/html]{$BASE_URL}[html]/data/legacy_emoticons', $post); $end = 0; while (($pos = strpos($post, '[right]')) !== false) { $e_pos = strpos($post, '[/right]', $pos); if ($e_pos === false) { break; } $end = $e_pos + strlen('[/right]'); $segment = substr($post, $pos, $end - $pos); global $LAX_COMCODE; $temp = $LAX_COMCODE; $LAX_COMCODE = true; $_comcode = comcode_to_tempcode($segment, $member_id); $LAX_COMCODE = $temp; $comcode = $_comcode->evaluate(); $comcode = str_replace($comcode, get_base_url(), '{$BASE_URL}'); $post = substr($post, 0, $pos) . $comcode . substr($post, $end); } } $id_new = ocf_make_post($topic_id, $title, $post, 0, $row['new_topic'] == 1, 1 - $row['queued'], 0, @html_entity_decode($row['author_name'], ENT_QUOTES, get_charset()), $row['ip_address'], $row['post_date'], $member_id, NULL, $row['edit_time'], $last_edit_by, false, false, $forum_id, false); import_id_remap_put('post', strval($row['pid']), $id_new); } $row_start += 200; } while (count($rows) > 0); }
/** * Invite a member to a PT. * * @param MEMBER Member getting access * @param AUTO_LINK The topic */ function ocf_invite_to_pt($member_id, $topic_id) { $topic_info = $GLOBALS['FORUM_DB']->query_select('f_topics', array('*'), array('id' => $topic_id), '', 1); if (!array_key_exists(0, $topic_info)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } if ($topic_info[0]['t_pt_from'] != get_member() && $topic_info[0]['t_pt_to'] != get_member() && !has_specific_permission(get_member(), 'view_other_pt')) { warn_exit(do_lang_tempcode('INTERNAL_ERROR')); } if ($topic_info[0]['t_pt_from'] == $member_id || $topic_info[0]['t_pt_to'] == $member_id) { warn_exit(do_lang_tempcode('NO_INVITE_SENSE')); } $test = $GLOBALS['FORUM_DB']->query_value_null_ok('f_special_pt_access', 's_member_id', array('s_member_id' => $member_id, 's_topic_id' => $topic_id)); if (!is_null($test)) { warn_exit(do_lang_tempcode('NO_INVITE_SENSE_ALREADY')); } $GLOBALS['FORUM_DB']->query_insert('f_special_pt_access', array('s_member_id' => $member_id, 's_topic_id' => $topic_id)); $current_username = $GLOBALS['FORUM_DRIVER']->get_username(get_member()); $_topic_url = build_url(array('page' => 'topicview', 'type' => 'view', 'id' => $topic_id), get_module_zone('topicview'), NULL, false, false, true); $topic_url = $_topic_url->evaluate(); $topic_title = $topic_info[0]['t_cache_first_title']; require_code('ocf_posts_action'); $post = do_lang('INVITED_TO_PT', $GLOBALS['FORUM_DRIVER']->get_username($member_id), $current_username); ocf_make_post($topic_id, '', $post, 0, false, 1, 1, do_lang('SYSTEM'), NULL, NULL, db_get_first_id(), NULL, NULL, NULL, false); require_code('notifications'); $subject = do_lang('INVITED_TO_TOPIC_SUBJECT', get_site_name(), $topic_title, get_lang($member_id)); $mail = do_lang('INVITED_TO_TOPIC_BODY', get_site_name(), comcode_escape($topic_title), array(comcode_escape($current_username), $topic_url), get_lang($member_id)); dispatch_notification('ocf_topic_invite', NULL, $subject, $mail, array($member_id)); }
/** * 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); }