Пример #1
0
 function setUp()
 {
     parent::setUp();
     require_code('ocf_moderation');
     require_code('ocf_moderation_action');
     require_code('ocf_moderation_action2');
     $this->establish_admin_session();
     $this->warn_id = ocf_make_warning(1, 'nothing', NULL, NULL, 1, NULL, NULL, 0, '', 0, 0, NULL);
     // Test the forum was actually created
     $this->assertTrue('nothing' == $GLOBALS['FORUM_DB']->query_value('f_warnings', 'w_explanation ', array('id' => $this->warn_id)));
 }
Пример #2
0
 /**
  * Standard import function.
  *
  * @param  object			The DB connection to import from
  * @param  string			The table prefix the target prefix is using
  * @param  PATH			The base directory we are importing from
  */
 function import_ocf_warnings($db, $table_prefix, $file_base)
 {
     if ($this->on_same_msn($file_base)) {
         return;
     }
     $rows = $db->query('SELECT * FROM ' . $table_prefix . 'f_warnings');
     foreach ($rows as $row) {
         $member_id = import_id_remap_get('member', $row['w_member_id'], true);
         $by = import_id_remap_get('member', $row['w_by'], true);
         if (is_null($member_id)) {
             continue;
         }
         if (is_null($by)) {
             $by = $GLOBALS['FORUM_DRIVER']->get_guest_id();
         }
         $silence_from_topic = array_key_exists('w_silence_from_topic', $row) ? import_id_remap_get('topic', $row['w_silence_from_topic'], true) : NULL;
         if (is_null($silence_from_topic)) {
             $silence_from_topic = NULL;
         }
         $silence_from_forum = array_key_exists('w_silence_from_forum', $row) ? import_id_remap_get('forum', $row['w_silence_from_forum'], true) : NULL;
         if (is_null($silence_from_forum)) {
             $silence_from_forum = NULL;
         }
         $changed_usergroup_from = array_key_exists('w_changed_usergroup_from', $row) ? import_id_remap_get('group', $row['w_changed_usergroup_from'], true) : NULL;
         if (is_null($changed_usergroup_from)) {
             $changed_usergroup_from = NULL;
         }
         ocf_make_warning($member_id, $row['w_explanation'], $by, $row['w_time'], array_key_exists('w_is_warning', $row) ? $row['w_is_warning'] : 1, $silence_from_topic, $silence_from_forum, array_key_exists('w_probation', $row) ? $row['w_probation'] : 0, array_key_exists('w_banned_ip', $row) ? $row['w_banned_ip'] : '', array_key_exists('w_charged_points', $row) ? $row['w_charged_points'] : 0, array_key_exists('w_banned_member', $row) ? $row['w_banned_member'] : 0, $changed_usergroup_from);
     }
 }
Пример #3
0
 /**
  * Standard import function.
  *
  * @param  object			The DB connection to import from
  * @param  string			The table prefix the target prefix is using
  * @param  PATH			The base directory we are importing from
  */
 function import_ocf_warnings($db, $table_prefix, $file_base)
 {
     $rows = $db->query('SELECT * FROM ' . $table_prefix . 'warnings');
     foreach ($rows as $row) {
         $member_id = import_id_remap_get('member', $row['user_id'], true);
         $by = db_get_first_id() + 1;
         if (is_null($member_id)) {
             continue;
         }
         $post_id = import_id_remap_get('post', $row['post_id'], true);
         $explanation = is_null($post_id) ? '' : do_lang('IMPORT_WARNING_CONVERT', strval($post_id));
         ocf_make_warning($member_id, $explanation, $by, $row['warning_time'], 1);
     }
     $rows = $db->query('SELECT * FROM ' . $table_prefix . 'banlist WHERE ban_end>' . strval(time()));
     foreach ($rows as $row) {
         $member_id = import_id_remap_get('member', $row['ban_userid'], true);
         if (is_null($member_id)) {
             continue;
         }
         $GLOBALS['FORUM_DB']->query_update('f_members', array('m_on_probation_until' => $row['ban_end']), array('id' => $member_id));
     }
 }
Пример #4
0
 /**
  * Standard import function.
  *
  * @param  object			The DB connection to import from
  * @param  string			The table prefix the target prefix is using
  * @param  PATH			The base directory we are importing from
  */
 function import_ocf_warnings($db, $table_prefix, $file_base)
 {
     $select = '*';
     if (either_param('importer') == 'ipb2') {
         $select = 'wlog_id AS id,wlog_mid,wlog_notes,wlog_date,wlog_addedby,wlog_contact_content';
     }
     $rows = $db->query('SELECT ' . $select . ' FROM ' . $table_prefix . 'warn_logs');
     foreach ($rows as $row) {
         if (import_check_if_imported('warning', strval($row['id']))) {
             continue;
         }
         $member_id = import_id_remap_get('member', strval($row['wlog_mid']), true);
         if (is_null($member_id)) {
             continue;
         }
         $by = import_id_remap_get('member', strval($row['wlog_addedby']));
         $id_new = ocf_make_warning($member_id, @html_entity_decode($row['wlog_contact_content'], ENT_QUOTES, get_charset()), $by, $row['wlog_date']);
         import_id_remap_put('warning', strval($row['id']), $id_new);
     }
 }
Пример #5
0
 /**
  * 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);
 }