|
rwapa |
2013/2/24 |
|
f4tnk |
2013/2/20 |
|
pvtt02 |
2013/2/18 |
|
etembassy |
2013/2/4 |
|
franck0768 |
2013/2/2 |
|
essig |
2013/1/29 |
|
redcherry |
2013/1/19 |
|
francois |
2012/11/18 |
|
flaggada |
2012/11/18 |
|
fefos |
2012/11/16 |
<?php
define('XORTIFY_JSON_API', 'http://xortify.chronolabs.coop/json/');
if (!class_exists('Services_JSON'))
include_once('/pear/JSON.php');
define('XOOPS_JSON_LIB', 'PHPJSON');
if (!function_exists("xortify_obj2array")) {
function xortify_obj2array($objects) {
$ret = array();
foreach($objects as $key => $value) {
if (is_a($value, 'stdClass')) {
$ret[$key] = xortify_obj2array((array)$value);
} elseif (is_array($value)) {
$ret[$key] = xortify_obj2array($value);
} else {
$ret[$key] = $value;
}
}
return $ret;
}
}
if (!function_exists("getIPData")) {
function getIPData($ip=false){
$ret = array();
if (is_object($GLOBALS['xoopsUser'])) {
$ret['uid'] = $GLOBALS['xoopsUser']->getVar('uid');
$ret['uname'] = $GLOBALS['xoopsUser']->getVar('uname');
$ret['email'] = $GLOBALS['xoopsUser']->getVar('email');
} else {
$ret['uid'] = 0;
$ret['uname'] = $_REQUEST['uname'];
$ret['email'] = $_REQUEST['email'];
}
if (!$ip) {
if ($_SERVER["HTTP_X_FORWARDED_FOR"] != ""){
$ip = (string)$_SERVER["HTTP_X_FORWARDED_FOR"];
$ret['is_proxied'] = true;
$proxy_ip = $_SERVER["REMOTE_ADDR"];
$ret['network-addy'] = @gethostbyaddr($ip);
$ret['long'] = @ip2long($ip);
if (is_ipv6($ip)) {
$ret['ip6'] = $ip;
$ret['proxy-ip6'] = $proxy_ip;
} else {
$ret['ip4'] = $ip;
$ret['proxy-ip4'] = $proxy_ip;
}
}else{
$ret['is_proxied'] = false;
$ip = (string)$_SERVER["REMOTE_ADDR"];
$ret['network-addy'] = @gethostbyaddr($ip);
$ret['long'] = @ip2long($ip);
if (is_ipv6($ip)) {
$ret['ip6'] = $ip;
} else {
$ret['ip4'] = $ip;
}
}
} else {
$ret['is_proxied'] = false;
$ret['network-addy'] = @gethostbyaddr($ip);
$ret['long'] = @ip2long($ip);
if (is_ipv6($ip)) {
$ret['ip6'] = $ip;
} else {
$ret['ip4'] = $ip;
}
}
$ret['made'] = time();
return $ret;
}
}
if (!function_exists("is_ipv6")) {
function is_ipv6($ip = "")
{
if ($ip == "")
return false;
if (substr_count($ip,":") > 0){
return true;
} else {
return false;
}
}
}
class JSONXortifyExchange {
var $json_client;
var $json_xoops_username = '';
var $json_xoops_password = '';
var $refresh = 600;
var $json = '';
function __construct()
{
$this->JSONXortifyExchange ();
}
function JSONXortifyExchange () {
$configs['xortify_username'] = 'user';
$configs['xortify_password'] = 'pass';
$configs['xortify_records'] = 1200;
$this->json = new Services_JSON();
$this->json_xoops_username = $configs['xortify_username'];
$this->json_xoops_password = $configs['xortify_password'];
$this->refresh = $configs['xortify_records'];
}
function sendBan($comment, $category_id = 2, $ip=false) {
$ipData = getIPData($ip);
switch (XOOPS_JSON_LIB){
default:
case "PHPJSON":
$data = file_get_contents(XORTIFY_JSON_API.'?ban='.urlencode($this->json->encode( array( "username" => $this->json_xoops_username,
"password" => $this->json_xoops_password,
"bans" => array( 0 => array_merge(
$ipData,
array('category_id' => $category_id)
)
),
"comments" => array( 0 => array( 'uname' => $this->json_xoops_username,
"comment" => $comment
)
)
))));
$result = xortify_obj2array($this->json->decode($data));
break;
}
return $result;
}
function checkBan($ipdate) {
switch (XOOPS_JSON_LIB){
default:
case "PHPJSON":
$data = file_get_contents(XORTIFY_JSON_API.'?banned='.urlencode($this->json->encode( array( "username" => $this->json_xoops_username,
"password" => $this->json_xoops_password,
"ipdata" => $ipdata
))));
$result = xortify_obj2array($this->json->decode($data));
break;
}
return $result;
}
function checkUnban($ipdate) {
switch (XOOPS_JSON_LIB){
default:
case "PHPJSON":
$data = file_get_contents(XORTIFY_JSON_API.'?unbanned='.urlencode($this->json->encode( array( "username" => $this->json_xoops_username,
"password" => $this->json_xoops_password,
"ipdata" => $ipdata
))));
$result = xortify_obj2array($this->json->decode($data));
break;
}
return $result;
}
function checkSFSBans($ipdata) {
switch (XOOPS_JSON_LIB){
default:
case "PHPJSON":
$data = file_get_contents(XORTIFY_JSON_API.'?checksfsbans='.urlencode($this->json->encode(
array( "username" => $this->json_xoops_username,
"password" => $this->json_xoops_password,
"ipdata" => array_merge($ipdata, array('category_id' => $category_id))
))));
$result = xortify_obj2array($this->json->decode($data));
break;
}
return $result;
}
function checkPHPBans($ipdata) {
switch (XOOPS_JSON_LIB){
default:
case "PHPJSON":
$data = file_get_contents(XORTIFY_JSON_API.'?checkphpbans='.urlencode($this->json->encode(
array( "username" => $this->json_xoops_username,
"password" => $this->json_xoops_password,
"ipdata" => $ipdata
))));
$result = xortify_obj2array($this->json->decode($data));
break;
}
return $result;
}
function retrieveBans() {
switch (XOOPS_JSON_LIB){
default:
case "PHPJSON":
$data = file_get_contents(XORTIFY_JSON_API.'?bans='.urlencode($this->json->encode(array("username"=> $this->json_xoops_username, "password"=> $this->json_xoops_password, "records"=> $this->refresh))));
$result = xortify_obj2array($this->json->decode($data));
break;
}
return $result;
}
function retrieveUnbans() {
switch (XOOPS_JSON_LIB){
default:
case "PHPJSON":
$data = file_get_contents(XORTIFY_JSON_API.'?unbans='.urlencode($this->json->encode(array("username"=> $this->json_xoops_username, "password"=> $this->json_xoops_password, "records"=> $this->refresh))));
$result = xortify_obj2array($this->json->decode($data));
break;
}
return $result;
}
function sendSpider($spider) {
switch (XOOPS_JSON_LIB){
case "PHPJSON":
$data = file_get_contents(XORTIFY_JSON_API.'?spider='.urlencode($this->json->encode(array("username" => $this->json_xoops_username, "password" => $this->json_xoops_password, "spider" => $spider ))));
$result = xortify_obj2array($this->json->decode($data));
break;
}
return $result;
}
function sendStatistic($statistic) {
switch (XOOPS_JSON_LIB){
case "PHPJSON":
$data = file_get_contents(XORTIFY_JSON_API.'?spiderstat='.urlencode($this->json->encode(array("username" => $this->json_xoops_username, "password" => $this->json_xoops_password, "statistic" => $statistic ))));
$result = xortify_obj2array($this->json->decode($data));
break;
}
return $result;
}
function getSpiders() {
switch (XOOPS_JSON_LIB){
case "PHPJSON":
$data = file_get_contents(XORTIFY_JSON_API.'?spiders='.urlencode($this->json->encode(array( "username" => $this->json_xoops_username, "password" => $this->json_xoops_password ))));
$result = xortify_obj2array($this->json->decode($data));
break;
}
return $result['robots'];
}
function getSEOLinks() {
switch (XOOPS_JSON_LIB){
case "PHPJSON":
$data = file_get_contents(XORTIFY_JSON_API.'?seolinks='.urlencode($this->json->encode(array( "username" => $this->json_xoops_username, "password" => $this->json_xoops_password ))));
$result = xortify_obj2array($this->json->decode($data));;
break;
}
return $result['seolinks'];
}
}
?>