Beispiel #1
0
 /**
  * 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);
         }
     }
 }
Beispiel #2
0
    /**
     * 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);
    }
Beispiel #3
0
 /**
  * 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);
             }
         }
     }
 }
Beispiel #4
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);
 }
Beispiel #5
0
 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);
     }
 }