Saturday, July 6, 2013

Vanilla forums: Batch Decline participants

Our Forum in Kenya was spammed. I had decidd to use vanillaforums as the forum software (a choice I'm not so sure about anymore).

I decided to set the registration as "approval by moderator", which meant that the spam bots were filtered into a "Applicants queue". After ~2-3 weeks the applicant list was 5 thousand.

Clicking each one was not feasible. So I wrote this javascript:

if (typeof String.prototype.startsWith != 'function') {
    "use strict";
    String.prototype.startsWith = function (str){
        return this.slice(0, str.length) == str;

var time_wait = 0,
    string_check = '[url=http://',
    action = 'decline',
    forum_url = '',
    pause_time = 10000;
$('[type=checkbox]').each(function () {
    "use strict";
    var curelem = $(this),
        parent_group = curelem.parent().parent().children(),
        request_text = $(parent_group[1]).children()[2].textContent,
        key = $($(parent_group[2]).children()[0]).attr("href").split("/").reverse()[0];

    var user_call = function (id, action, time, key) {
        console.log("val = " + id + ", time_wait = " + time);
        window.setTimeout(function () {
                url: 'http://' + forum_url + '/user/' + action + '/' + id + '/' + key,
                type: 'POST',
        }, time);

    if (request_text.startsWith(string_check)) {
        user_call(curelem.val(), action, time_wait, key);
        time_wait = time_wait + pause_time;

This will go through and fire off an ajax call, which will decline each user. It does this in increments of 10 seconds.

It had to be 10 seconds, because with around 5 thousand applicants, the list was 3M. (I've used up ~2G on our host, just from trying to load this applicants page).

I've created a ticket about this issue:

In the meantime if you dont' feel like waiting the 10 seconds, and want to edit php:
Open up 'applications/dashboard/controllers/class.usercontroller.php'
Find 'public function Decline'
The last line of the function is
change this to
$Action = $this->Form->GetValue('Submit');

With this change, the calls took ~400ms, so I changed time (in the script) to 1000.

This worked for me in Vanilla Forums v2.0.18.8