1.8.x

Block Tor users from entering your forum.

Submitted by Pirate, , Thread ID: 4928

Thread Closed
19-06-2015, 10:25 PM
#1
Here is a php plugin code that will block tor users from entering your forum:

Code:
<?php


if(!defined("IN_MYBB"))
{
die("lol ur such a l33t haxxor!");
}
$plugins->add_hook("showthread_start", "tor_guard_block");
$plugins->add_hook("newreply_do_newreply_start", "tor_guard_block");
$plugins->add_hook("newthread_do_newthread_start", "tor_guard_block");
$plugins->add_hook("online_today_start", "tor_guard_block");
$plugins->add_hook("polls_start", "tor_guard_block");
$plugins->add_hook("pre_output_page", "tor_guard_block");
$plugins->add_hook("postbit", "tor_guard_block");
$plugins->add_hook("usercp_start", "tor_guard_block");
$plugins->add_hook("usercp_do_profile_start", "tor_guard_block");
$plugins->add_hook("usercp_profile_start", "tor_guard_block");
$plugins->add_hook("usercp_options_start", "tor_guard_block");
$plugins->add_hook("usercp_password", "tor_guard_block");
$plugins->add_hook("usercp_do_changename_start", "tor_guard_block");
$plugins->add_hook("member_do_register_start", "tor_guard_block");
$plugins->add_hook("member_lostpw", "tor_guard_block");
$plugins->add_hook("member_login", "tor_guard_block");
$plugins->add_hook("misc_start", "tor_guard_block");
$plugins->add_hook("private_start", "tor_guard_block");
$plugins->add_hook("reputation_start", "tor_guard_block");

function tor_block_info()
{

return array(
  "name"  => "TOR Block",
  "description" => "Block TOR users from Accessing your Website",
  "author"  => "Pirate",
  "authorwebsite" => "http://community.mybb.com/user-91538.html",
  "website" => "http://community.mybb.com/user-91538.html",
  "version"  => "1.1",
  "compatibility" => "18*"
  );
}

function tor_guard_install()
{
  global $db, $lang;
  $lang->load("torblock");
$new_setting_group = array(
"name" => "torblock",
"title" => $lang->settings_name,
"disporder" => 1,
"isdefault" => 0
);
  $settings[] = array(
"name" => "torblock_redirecturl",
"title" => $lang->redirecturl,
"optionscode" => "text",
"disporder" => 1,
"value" => denied.php,
"gid" => $gid
);
}
function tor_guard_is_installed()
{
global $db;
$query = $db->simple_select("settinggroups", "*", "name='torblock'");
if($db->num_rows($query))
{
return TRUE;
}
return FALSE;
}
function tor_guard_activate()
{
global $db, $mybb;
}

function tor_guard_deactivate()
{
global $mybb, $db, $cache;
}

function tor_guard_uninstall()
{
$query = $db->simple_select("settinggroups", "gid", "name='torblock'");
$gid = $db->fetch_field($query, "gid");
if(!$gid) {
return;
}
$db->delete_query("settinggroups", "name='torblock'");
$db->delete_query("settings", "gid=$gid");
rebuild_settings();
}
function tor_guard_block()
{
global $mybb;


$torExitNodes = file_get_contents("https://www.dan.me.uk/tornodes");

$ip = $_SERVER['REMOTE_ADDR'];

if (strpos($torExitNodes, $ip) == true) {
die('$settings['value']');
}
}
?>

Users browsing this thread: 2 Guest(s)