MyBB Community Forums

Full Version: Plugin Offer
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
Couple of questions...

1) Is there something special I need to do to turn this into a usable mod?

2) Should it have a specific filename or be packaged a certain way? (Zip file, plain text, etc)

3) The code may need one tweak, and that would be a the addition of a field to allow a user to enter an API Key. An API Key lets the user query the BotScout database more often than an anonymous user. (API Keys are free, there is no charge for them.) The API Key is a string of 15 to 20 alphanumeric characters.

(2011-03-07, 01:38 AM)MrMike Wrote: [ -> ]Couple of questions...

1) Is there something special I need to do to turn this into a usable mod?

2) Should it have a specific filename or be packaged a certain way? (Zip file, plain text, etc)

3) The code may need one tweak, and that would be a the addition of a field to allow a user to enter an API Key. An API Key lets the user query the BotScout database more often than an anonymous user. (API Keys are free, there is no charge for them.) The API Key is a string of 15 to 20 alphanumeric characters.

The php file just needs to be zipped before uploading to the mods database, also a guid will be added, it's pretty straight forward and explained when uploading the mod. As for the API key, I will add that when I get a chance, won't be hard.
Super. I'll hold off on posting it until then (it wouldn't be much use without an API key). Thank you!


(2011-03-07, 02:39 AM)Jammerx2 Wrote: [ -> ]The php file just needs to be zipped before uploading to the mods database, also a guid will be added, it's pretty straight forward and explained when uploading the mod. As for the API key, I will add that when I get a chance, won't be hard.

This will be pretty useful! I am looking forward to using this plugin!
Any progress on this, Jammerx2? I've had a couple of people email me on the BotScout site asking how to integrate BotScout with myBB. I've directed them to this thread in the hopes they might find what they need.
Sorry, I've just been doing other things. I'll do it now.

Edit:

Ok, this should work.

<?php

$plugins->add_hook('datahandler_user_validate', 'botscout_validate');

function botscout_info()
{
	return array(
		'name'			=> 'Bot Scout',
		'description'	=> 'BotScout is a free anti-bot, anti-spam service.',
		'website'		=> 'http://www.botscout.com/',
		'author'		=> 'MrMike',
		'authorsite'	=> 'http://www.botscout.com/',
		'version'		=> '1.0',
		'guid'        => 'Replace this with the given guid.'
	);
}

function botscout_activate()
{
	global $db, $mybb;

	$botscout_group = array(
		"gid"			=> "NULL",
		"name"			=> "botscout",
		"title" =>"Bot Scout Settings",
		"description"	=> "Settings for the Bot Scout plugin.",
		"disporder"		=> "1234567890",
		"isdefault"		=> "no",
	);

	$db->insert_query("settinggroups", $botscout_group);
	$gid = $db->insert_id();

	$botscout_setting = array(
		"sid"			=> "NULL",
		'name'			=> 'botscout_ip',
		'title'			=> 'IP Check',
		'description'	=> 'Check the users IP against the Bot Scout database upon registration.',
		'optionscode'	=> 'yesno',
		'value'			=> '1',
		'disporder'		=> '1',
		'gid'			=> intval($gid),
	);

	$db->insert_query('settings', $botscout_setting);
	
	$botscout_setting = array(
		"sid"			=> "NULL",
		'name'			=> 'botscout_ip_req',
		'title'			=> 'IP Check Complaints',
		'description'	=> 'How many complaints against the ip must be in the database before disallowing the user?',
		'optionscode'	=> 'text',
		'value'			=> '1',
		'disporder'		=> '2',
		'gid'			=> intval($gid),
	);

	$db->insert_query('settings', $botscout_setting);
	
		$botscout_setting = array(
		"sid"			=> "NULL",
		'name'			=> 'botscout_email',
		'title'			=> 'Email Check',
		'description'	=> 'Check the users email against the Bot Scout database upon registration.',
		'optionscode'	=> 'yesno',
		'value'			=> '1',
		'disporder'		=> '3',
		'gid'			=> intval($gid),
	);

	$db->insert_query('settings', $botscout_setting);
	
	$botscout_setting = array(
		"sid"			=> "NULL",
		'name'			=> 'botscout_email_req',
		'title'			=> 'Email Check Complaints',
		'description'	=> 'How many complaints against the email must be in the database before disallowing the user?',
		'optionscode'	=> 'text',
		'value'			=> '1',
		'disporder'		=> '4',
		'gid'			=> intval($gid),
	);

	$db->insert_query('settings', $botscout_setting);
	
	$botscout_setting = array(
		"sid"			=> "NULL",
		'name'			=> 'botscout_username',
		'title'			=> 'Username Check',
		'description'	=> 'Check the users username against the Bot Scout database upon registration.',
		'optionscode'	=> 'yesno',
		'value'			=> '1',
		'disporder'		=> '5',
		'gid'			=> intval($gid),
	);

	$db->insert_query('settings', $botscout_setting);
	
	$botscout_setting = array(
		"sid"			=> "NULL",
		'name'			=> 'botscout_username_req',
		'title'			=> 'Username Check Complaints',
		'description'	=> 'How many complaints against the username must be in the database before disallowing the user?',
		'optionscode'	=> 'text',
		'value'			=> '1',
		'disporder'		=> '6',
		'gid'			=> intval($gid),
	);
	
	$db->insert_query('settings', $botscout_setting);
	
	$botscout_setting = array(
		"sid"			=> "NULL",
		'name'			=> 'botscout_api',
		'title'			=> 'API Key',
		'description'	=> 'Enter your Bot Scout API key here.',
		'optionscode'	=> 'text',
		'value'			=> '',
		'disporder'		=> '7',
		'gid'			=> intval($gid),
	);

	$db->insert_query('settings', $botscout_setting);
	
	rebuild_settings();
}

function botscout_deactivate()
{
	global $mybb, $db;

	$db->delete_query("settinggroups","name='botscout'");
	$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='botscout_ip'");
	$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='botscout_email'");
	$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='botscout_username'");
	$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='botscout_api'");
	$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='botscout_ip_req'");
	$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='botscout_email_req'");
	$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='botscout_username_req'");
}

function botscout_validate($datahandler) {
global $mybb, $db, $user, $lang;

if($mybb->settings['botscout_email'] == 1)
$XMAIL = "&mail=".urlencode($user['email']);
if($mybb->settings['botscout_ip'] == 1)
$XIP = "&ip=".$user['regip'];
if($mybb->settings['botscout_username'] == 1)
$XNAME = "&name=".urlencode($user['username']);
if($mybb->settings['botscout_api'] != "")
$APIKEY = "&key=".urlencode($mybb->settings['botscout_api']);

$test_string = "http://botscout.com/test/?multi".$XMAIL.$XIP.$XNAME.$APIKEY;

if(function_exists('file_get_contents')){
	$data = file_get_contents($test_string);
}else{
	$ch = curl_init($test_string);
	curl_setopt($ch, CURLOPT_HEADER, 0);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	$data = curl_exec($ch);
	curl_close($ch);
}


$botdata = explode('|', $data); 


if(substr($returned_data, 0,1) == '!'){
	$datahandler->set_error("Error: $returned_data");
}


if($botdata[0] == "Y") {
if($botdata['3'] >= intval($mybb->settings['botscout_ip_req'])) {
$datahandler->set_error($lang->error_banned);
}
if($botdata['5'] >= intval($mybb->settings['botscout_email_req'])) {
$datahandler->set_error('banned_email');
}
if($botdata['7'] >= intval($mybb->settings['botscout_username_req'])) {
$datahandler->set_error('banned_username');
}
}

}

?>

Remember when you go to submit it, replace the guid with the one given to you before putting it in the zip file. Also, as for the ban, the username will be jammerx22 and any ip's associated it, my email was not banned as I was using a banned one for testing purposes.

Edit 2:

Just updated code a bit, forgot something.

Regards,
Jammerx2
(2011-03-10, 12:48 AM)Jammerx2 Wrote: [ -> ]Sorry, I've just been doing other things. I'll do it now.

Thank you very much, Jammerx2!

I have one question. You said:

"Remember when you go to submit it, replace the guid with the one given to you before putting it in the zip file."

I'm not completely sure what the guid is...is this something that mybb will give me to assign to the plugin as an identifier, or...?



(2011-03-10, 02:46 AM)MrMike Wrote: [ -> ]
(2011-03-10, 12:48 AM)Jammerx2 Wrote: [ -> ]Sorry, I've just been doing other things. I'll do it now.

Thank you very much, Jammerx2!

I have one question. You said:

"Remember when you go to submit it, replace the guid with the one given to you before putting it in the zip file."

I'm not completely sure what the guid is...is this something that mybb will give me to assign to the plugin as an identifier, or...?

Basically, you will see what I mean when you submit it here.
Thank you, JammerX2! I'll try to get this uploaded tonight or tomorrow.

A question about the settings code...for example, in this code:
$botscout_setting = array(
    "sid"			=> "NULL",
    'name'			=> 'botscout_username_req',
    'title'			=> 'Username Check Complaints',
    'description'	=> 'How many complaints against the username must be in the BotScout database before disallowing the user?',
    'optionscode'	=> 'text',
    'value'			=> '1',
    'disporder'		=> '6',
    'gid'			=> intval($gid),
);
I'm assuming that the "value" parameter is the default value that the mod setting will show upon installation. Is that correct?
Yes it is, you can edit them to what you want, although for the yesno selections it should be 1 or 0.
Pages: 1 2 3