Created
April 18, 2013 17:40
-
-
Save shrink/5414695 to your computer and use it in GitHub Desktop.
Poor quality, hacked together code I wrote a long time ago, for someone that wants to see how whitelist.mcf.li works.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); | |
class Banlists_model extends CI_Model | |
{ | |
function __construct() | |
{ | |
parent::__construct(); | |
} | |
/* | |
* pass: username | |
* return: bancount, bans, score = 0 | |
*/ | |
function mcbanscom($username) | |
{ | |
$apikey = "HIDDEN"; | |
$url = "http://api.mcbans.com/v2/$apikey"; | |
$lookup = array("player" => $username, "admin" => "citricsquid", "exec" => "playerLookup"); | |
$api_lookup = curl_init(); | |
curl_setopt($api_lookup, CURLOPT_USERAGENT, "whitelist.mcf.li -- citricsquid"); | |
curl_setopt($api_lookup, CURLOPT_URL, $url); | |
curl_setopt($api_lookup, CURLOPT_POST, 1); | |
curl_setopt($api_lookup, CURLOPT_POSTFIELDS, $lookup); | |
curl_setopt($api_lookup, CURLOPT_RETURNTRANSFER, TRUE); | |
$api_return = curl_exec($api_lookup); | |
if(!$api_return) | |
return array("bancount" => false, "banlist" => false, "score" => false, "status" => "0", "output" => "Unknown Result"); | |
$api_response = json_decode($api_return, true); | |
$banlist = array_merge($api_response["global"], $api_response["local"]); | |
$status = ($api_response["total"] > 0) ? 2 : 1; | |
$output = ($api_response["total"] > 0) ? $api_response["total"]." bans :(" : "No bans found"; | |
return array("bancount" => $api_response["total"], "banlist" => $banlist, "score" => $api_response["reputation"], "status" => $status,"output" => $output); | |
} | |
function mcbouncercom($username) | |
{ | |
$apikey = "HIDDEN"; | |
$url = "http://www.mcbouncer.com/api/getBans/$apikey/$username"; | |
$api_lookup = curl_init(); | |
curl_setopt($api_lookup, CURLOPT_USERAGENT, "whitelist.mcf.li -- citricsquid"); | |
curl_setopt($api_lookup, CURLOPT_URL, $url); | |
curl_setopt($api_lookup, CURLOPT_RETURNTRANSFER, TRUE); | |
$api_return = curl_exec($api_lookup); | |
if(!$api_return) | |
return array("bancount" => false, "banlist" => false, "score" => false, "status" => "0", "output" => "Unknown Result"); | |
$api_response = json_decode($api_return, true); | |
$status = ($api_response["totalcount"] > 0) ? 2 : 1; | |
$output = ($api_response["totalcount"] > 0) ? $api_response["totalcount"]." bans :(" : "No bans found"; | |
return array("bancount" => $api_response["totalcount"], "banlist" => $api_response["data"], "score" => 0, "status" => $status, "output" => $output); | |
} | |
function glizerde($username) | |
{ | |
// this one doesn't seem to have a ban list? So I'll, uh, guess based on reputation? | |
// If reputation is <0 == bad person??? | |
// Will have to note this in the description | |
$url = "http://www.glizer.de/usrnotes/index.php?data=$username"; | |
$api_lookup = curl_init(); | |
curl_setopt($api_lookup, CURLOPT_USERAGENT, "whitelist.mcf.li -- citricsquid"); | |
curl_setopt($api_lookup, CURLOPT_URL, $url); | |
curl_setopt($api_lookup, CURLOPT_RETURNTRANSFER, TRUE); | |
$api_return = curl_exec($api_lookup); | |
// too many edge cases for me to do this properly | |
preg_match('%<tr><td><b>Global Repuation</b>:</td><td>(.*?) \((.*?)\)</td></tr>%sm', $api_return, $reputation); | |
if(!$api_return) | |
return array("bancount" => false, "banlist" => false, "score" => false, "status" => "0", "output" => "Unknown Result"); | |
$status = 1; | |
$output = "No bans found"; | |
$score = 0; | |
if(isset($reputation[2])) | |
{ | |
$status = ($reputation[2] > 0) ? 1 : 2; | |
$output = $reputation[2]." reputation"; | |
$score = $reputation[2]; | |
} | |
return array("bancount" => false, "banlist" => false, "score" => $score, "status" => $status, "output" => $output); | |
} | |
function minebanscom($username) | |
{ | |
$url = "http://minebans.com/view_player.html?player_name=$username"; | |
$api_lookup = curl_init(); | |
curl_setopt($api_lookup, CURLOPT_USERAGENT, "whitelist.mcf.li -- citricsquid"); | |
curl_setopt($api_lookup, CURLOPT_URL, $url); | |
curl_setopt($api_lookup, CURLOPT_RETURNTRANSFER, TRUE); | |
$api_return = curl_exec($api_lookup); | |
preg_match("%<div class=\"section_head\"><span>(.*?)'s Bans</span></div>%sm", $api_return, $bans); | |
if(!$api_return) | |
return array("bancount" => false, "banlist" => false, "score" => false, "status" => "0", "output" => "Unknown Result"); | |
$status = 1; | |
$output = "No bans"; | |
if(isset($bans[1])) | |
{ | |
$status = ($bans[1]) ? 2 : 1; | |
$output = ($bans[1]) ? 'Bans found! :(' : 'No bans'; | |
} | |
return array("bancount" => false, "banlist" => false, "score" => false, "status" => $status, "output" => $output); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment