/**
  * bad_behavior
  */
 public function bad_behavior()
 {
     // Calls inward to Bad Behavor itself.
     require_once BB2_CWD . "/bad-behavior/version.inc.php";
     require_once BB2_CWD . "/bad-behavior/core.inc.php";
     bb2_start(bb2_read_settings());
 }
Ejemplo n.º 2
0
function bb2_insert_head()
{
    global $bb2_javascript;
    echo $bb2_javascript;
}
// Display stats? This is optional.
function bb2_insert_stats($force = false)
{
    $settings = bb2_read_settings();
    if ($force || $settings['display_stats']) {
        $blocked = bb2_db_query("SELECT COUNT(*) FROM " . $settings['log_table'] . " WHERE `key` NOT LIKE '00000000'");
        if ($blocked !== FALSE) {
            echo sprintf('<p><a href="http://www.bad-behavior.ioerror.us/">%1$s</a> %2$s <strong>%3$s</strong> %4$s</p>', __('Bad Behavior'), __('has blocked'), $blocked[0]["COUNT(*)"], __('access attempts in the last 7 days.'));
        }
    }
}
// Return the top-level relative path of wherever we are (for cookies)
// You should provide in $url the top-level URL for your site.
function bb2_relative_path()
{
    //$url = parse_url(get_bloginfo('url'));
    //return $url['path'] . '/';
    return '/';
}
// Calls inward to Bad Behavor itself.
require_once BB2_CWD . "/bad-behavior/version.inc.php";
require_once BB2_CWD . "/bad-behavior/core.inc.php";
bb2_install();
// FIXME: see above
bb2_start(bb2_read_settings());
Ejemplo n.º 3
0
// installation
function bb2_install()
{
    $settings = bb2_read_settings();
    if ($settings['is_installed'] == false) {
        bb2_db_query(bb2_table_structure($settings['log_table']));
        $settings['is_installed'] = true;
        bb2_write_settings($settings);
    }
}
// Return the top-level relative path of wherever we are (for cookies)
function bb2_relative_path()
{
    $url = parse_url($GLOBALS['settings']['url']);
    if (empty($url['path'])) {
        return '/';
    } else {
        if (substr($url['path'], -1, 1) == '/') {
            return $url['path'];
        } else {
            return $url['path'] . '/';
        }
    }
}
// Start Bad Behavior investigation
require_once BB2_CWD . "/bad-behavior/version.inc.php";
require_once BB2_CWD . "/bad-behavior/core.inc.php";
bb2_install();
$bb2_settings = bb2_read_settings();
bb2_start($bb2_settings);
function bb2_mediawiki_entry()
{
    global $bb2_timer_total;
    $bb2_mtime = explode(" ", microtime());
    $bb2_timer_start = $bb2_mtime[1] + $bb2_mtime[0];
    if (php_sapi_name() != 'cli') {
        require_once BB2_CWD . "/bad-behavior/core.inc.php";
        bb2_install();
        // FIXME: see above
        $settings = bb2_read_settings();
        bb2_start($settings);
    }
    $bb2_mtime = explode(" ", microtime());
    $bb2_timer_stop = $bb2_mtime[1] + $bb2_mtime[0];
    $bb2_timer_total = $bb2_timer_stop - $bb2_timer_start;
}
Ejemplo n.º 5
0
{
    $settings = bb2_read_settings();
    if ($settings['is_installed'] == false && $settings['logging']) {
        bb2_db_query(bb2_table_structure($settings['log_table']));
        $settings['is_installed'] = true;
        bb2_write_settings($settings);
    }
}
// Return the top-level relative path of wherever we are (for cookies)
function bb2_relative_path()
{
    include_once PLOG_CLASS_PATH . "class/config/config.class.php";
    $config =& Config::getConfig();
    $url = parse_url($config->getValue('base_url'));
    if (empty($url['path'])) {
        return '/';
    } else {
        if (substr($url['path'], -1, 1) == '/') {
            return $url['path'];
        } else {
            return $url['path'] . '/';
        }
    }
}
// Start Bad Behavior investigation
require_once BB2_CWD . "/bad-behavior/version.inc.php";
require_once BB2_CWD . "/bad-behavior/core.inc.php";
bb2_install();
$settings = bb2_read_settings();
bb2_start($settings);
Ejemplo n.º 6
0
        unset($bb2_result);
    }
}
// Return the top-level relative path of wherever we are (for cookies)
function bb2_relative_path()
{
    $url = parse_url(get_bloginfo('url'));
    if (array_key_exists('path', $url)) {
        return $url['path'] . '/';
    }
    return '/';
}
// FIXME: figure out what's wrong on 2.0 that this doesn't work
// register_activation_hook(__FILE__, 'bb2_install');
//add_action('activate_bb2/bad-behavior-wordpress.php', 'bb2_install');
add_action('wp_head', 'bb2_insert_head');
add_action('wp_footer', 'bb2_insert_stats');
add_action('wp_insert_comment', 'bb2_capture_spam', 99, 2);
// Calls inward to Bad Behavor itself.
require_once BB2_CWD . "/bad-behavior/core.inc.php";
bb2_install();
// FIXME: see above
if (is_admin() || strstr($_SERVER['PHP_SELF'], 'wp-admin/')) {
    // 1.5 kludge
    #wp_enqueue_script("admin-forms");
    require_once BB2_CWD . "/bad-behavior-wordpress-admin.php";
}
$bb2_result = bb2_start(bb2_read_settings());
$bb2_mtime = explode(" ", microtime());
$bb2_timer_stop = $bb2_mtime[1] + $bb2_mtime[0];
$bb2_timer_total = $bb2_timer_stop - $bb2_timer_start;
Ejemplo n.º 7
0
/**
 * Decide if we are going to enable bad behavior scanning for this user
 *
 * What it does:
 * - Admins and Moderators get a free pass
 * - Optionally existing users with post counts over a limit are bypassed
 * - Others get a humane frisking
 */
function loadBadBehavior()
{
    global $modSettings, $user_info, $bb2_results;
    // Bad Behavior Enabled?
    if (!empty($modSettings['badbehavior_enabled'])) {
        require_once EXTDIR . '/bad-behavior/badbehavior-plugin.php';
        $bb_run = true;
        // We may want to give some folks a hallway pass
        if (!$user_info['is_guest']) {
            if (!empty($user_info['is_mod']) || !empty($user_info['is_admin'])) {
                $bb_run = false;
            } elseif (!empty($modSettings['badbehavior_postcount_wl']) && $modSettings['badbehavior_postcount_wl'] < 0) {
                $bb_run = false;
            } elseif (!empty($modSettings['badbehavior_postcount_wl']) && $modSettings['badbehavior_postcount_wl'] > 0 && $user_info['posts'] > $modSettings['badbehavior_postcount_wl']) {
                $bb_run = false;
            }
        }
        // Put on the sanitary gloves, its time for a patdown !
        if ($bb_run === true) {
            $bb2_results = bb2_start(bb2_read_settings());
            addInlineJavascript(bb2_insert_head());
        }
    }
}
 /**
  * Do the magic
  */
 function handle_start(&$event, $param)
 {
     require_once BB2_CWD . "/bad-behavior/version.inc.php";
     require_once BB2_CWD . "/bad-behavior/core.inc.php";
     bb2_start(array('log_table' => 'badbehaviour', 'display_stats' => true, 'strict' => false, 'verbose' => false, 'skipblackhole' => $this->getConf('skipblackhole')));
 }
Ejemplo n.º 9
0
function bb2_mediawiki_entry()
{
    global $bb2_timer_total;
    $bb2_mtime = explode(" ", microtime());
    $bb2_timer_start = $bb2_mtime[1] + $bb2_mtime[0];
    if (php_sapi_name() != 'cli') {
        bb2_install();
        // FIXME: see above
        $settings = bb2_read_settings();
        // FIXME: Need to make this multi-DB compatible eventually
        $dbr = wfGetDB(DB_SLAVE);
        if (get_class($dbr) != "DatabaseMysql") {
            $settings['logging'] = false;
        }
        bb2_start($settings);
    }
    $bb2_mtime = explode(" ", microtime());
    $bb2_timer_stop = $bb2_mtime[1] + $bb2_mtime[0];
    $bb2_timer_total = $bb2_timer_stop - $bb2_timer_start;
}