From: <chr...@us...> - 2018-02-09 12:37:41
|
Revision: 13324 http://sourceforge.net/p/xoops/svn/13324 Author: chronolabscoop Date: 2018-02-09 12:37:38 +0000 (Fri, 09 Feb 2018) Log Message: ----------- Internet WhoIS Services REST API - Version 2.2.11! Modified Paths: -------------- *.xoops.org (Subdomain APIs & Sites)/whois.xoops.org/class/cache/file.php *.xoops.org (Subdomain APIs & Sites)/whois.xoops.org/class/whois.php *.xoops.org (Subdomain APIs & Sites)/whois.xoops.org/include/common.php *.xoops.org (Subdomain APIs & Sites)/whois.xoops.org/include/functions.php *.xoops.org (Subdomain APIs & Sites)/whois.xoops.org/include/version.php Modified: *.xoops.org (Subdomain APIs & Sites)/whois.xoops.org/class/cache/file.php =================================================================== --- *.xoops.org (Subdomain APIs & Sites)/whois.xoops.org/class/cache/file.php 2018-02-09 11:51:55 UTC (rev 13323) +++ *.xoops.org (Subdomain APIs & Sites)/whois.xoops.org/class/cache/file.php 2018-02-09 12:37:38 UTC (rev 13324) @@ -101,12 +101,12 @@ */ public function init($settings = array()) { - if (!is_dir(API_VAR_PATH . '/' . parse_url(API_URL, PHP_URL_HOST))) - mkdir(API_VAR_PATH . '/' . parse_url(API_URL, PHP_URL_HOST), 0777, true); - + if (!is_dir(API_TRUST_PATH . DS . parse_url(API_URL, PHP_URL_HOST) . DS . 'cache')) + mkdir(API_TRUST_PATH . DS . parse_url(API_URL, PHP_URL_HOST) . DS . 'cache', 0777, true); + parent::init($settings); $defaults = array( - 'path' => API_VAR_PATH . '/' . parse_url(API_URL, PHP_URL_HOST), + 'path' => API_TRUST_PATH . DS . parse_url(API_URL, PHP_URL_HOST) . DS . 'cache', 'extension' => '.php', 'prefix' => 'api_', 'lock' => false, Modified: *.xoops.org (Subdomain APIs & Sites)/whois.xoops.org/class/whois.php =================================================================== --- *.xoops.org (Subdomain APIs & Sites)/whois.xoops.org/class/whois.php 2018-02-09 11:51:55 UTC (rev 13323) +++ *.xoops.org (Subdomain APIs & Sites)/whois.xoops.org/class/whois.php 2018-02-09 12:37:38 UTC (rev 13324) @@ -19,7 +19,9 @@ * @description Whois API Service REST */ -include_once dirname(__FILE__).'/apiserver.php'; +require_once __DIR__ . DS . 'apiserver.php'; +require_once __DIR__ . DS . 'cache' . DS . 'apicache.php'; + /** * API Server Class Factory * @@ -220,32 +222,12 @@ /** * @var array $g_tld TLD's Sub-main Nodes Buffer */ - var $g_tld = array( - 'biz','com','edu','gov','info','int','mil','name','net','org','aero','asia','cat','coop','jobs','mobi','museum','pro','tel','travel', - 'arpa','root','berlin','bzh','cym','gal','geo','kid','kids','lat','mail','nyc','post','sco','web','xxx', - 'nato', 'example','invalid','localhost','test','bitnet','csnet','ip','local','onion','uucp','co'); + var $g_tld = array(); /** * @var array $c_tld TLD's Country Nodes Buffer */ - var $c_tld = array( - // active - 'ac','ad','ae','af','ag','ai','al','am','an','ao','aq','ar','as','at','au','aw','ax','az', - 'ba','bb','bd','be','bf','bg','bh','bi','bj','bm','bn','bo','br','bs','bt','bw','by','bz', - 'ca','cc','cd','cf','cg','ch','ci','ck','cl','cm','cn','co','cr','cu','cv','cx','cy','cz', - 'de','dj','dk','dm','do','dz','ec','ee','eg','er','es','et','eu','fi','fj','fk','fm','fo', - 'fr','ga','gd','ge','gf','gg','gh','gi','gl','gm','gn','gp','gq','gr','gs','gt','gu','gw', - 'gy','hk','hm','hn','hr','ht','hu','id','ie','il','im','in','io','iq','ir','is','it','je', - 'jm','jo','jp','ke','kg','kh','ki','km','kn','kr','kw','ky','kz','la','lb','lc','li','lk', - 'lr','ls','lt','lu','lv','ly','ma','mc','md','mg','mh','mk','ml','mm','mn','mo','mp','mq', - 'mr','ms','mt','mu','mv','mw','mx','my','mz','na','nc','ne','nf','ng','ni','nl','no','np', - 'nr','nu','nz','om','pa','pe','pf','pg','ph','pk','pl','pn','pr','ps','pt','pw','py','qa', - 're','ro','ru','rw','sa','sb','sc','sd','se','sg','sh','si','sk','sl','sm','sn','sr','st', - 'sv','sy','sz','tc','td','tf','tg','th','tj','tk','tl','tm','tn','to','tr','tt','tv','tw', - 'tz','ua','ug','uk','us','uy','uz','va','vc','ve','vg','vi','vn','vu','wf','ws','ye','yu', - 'za','zm','zw', - // inactive - 'eh','kp','me','rs','um','bv','gb','pm','sj','so','yt','su','tp','bu','cs','dd','zr'); + var $c_tld = array(); /** * __construct() @@ -267,6 +249,48 @@ $_SESSION['whois']['queries']['number'] = 0; $_SESSION['whois']['queries']['time'] = time()+3600; } + + if (!is_array($this->c_tld = APICache::read('networking-fallout-nodes')) || count($this->c_tld) == 0) + { + $this->c_tld = array_keys(eval('?>'.getURIData(API_STRATA_API_URL."/v2/fallout/raw.api", 120, 120).'<?php')); + APICache::write('networking-fallout-nodes', $this->c_tld, 3600 * 24 * 7 * mt_rand(2, 9) * mt_rand(2, 9)); + } + + if (!is_array($this->g_tld = APICache::read('networking-strata-nodes')) || count($this->g_tld) == 0) + { + $this->g_tld = array_keys(eval('?>'.getURIData(API_STRATA_API_URL."/v2/strata/raw.api", 120, 120).'<?php')); + APICache::write('networking-strata-nodes', $this->g_tld, 3600 * 24 * 7 * mt_rand(2, 9) * mt_rand(2, 9)); + } + + $services = $this->_domain_whoisservers; + if (!is_array($this->_domain_whoisservers = APICache::read('networking-whois-servers')) || count($this->_domain_whoisservers) == 0) + { + set_time_limit(3600 * 4.75); + foreach(APICache::read('networking-whois-servers-buffer') as $realm => $service) + $services[$realm] = $service; + + foreach($this->c_tld as $ctld) + { + if (!isset($services[$ctld])) + if ($service = $this->findWhoisService($ctld)) + $services[$ctld] = $service; + } + foreach($this->g_tld as $gtld) + { + if (!isset($services[$gtld])) + if ($service = $this->findWhoisService($gtld)) + $services[$gtld] = $service; + foreach($this->c_tld as $ctld) + { + if (!isset($services[$gtld.'.'.$ctld])) + if ($service = $this->findWhoisService($gtld.'.'.$ctld)) + $services[$gtld.'.'.$ctld] = $service; + } + } + APICache::write('networking-whois-servers', $this->_domain_whoisservers = $services, 3600 * 24 * 7 * mt_rand(2, 9) * mt_rand(2, 9)); + APICache::write('networking-whois-servers-buffer', $this->_domain_whoisservers = $services, 3600 * 24 * 7 * mt_rand(2, 9) * mt_rand(2, 9) * mt_rand(2, 9)); + } + die(print_r($this->_domain_whoisservers, true)); } /** @@ -286,6 +310,22 @@ session_commit(); } + /** + * Locates Whois Service with resource + * + * @param string $tld + * @return string|boolean + */ + private function findWhoisService($tld = '') + { + $uris = array('whois.nic.'.$tld, 'whois.'.$tld.'nic.'.$tld, 'whois.'.$tld.'nic.net.'.$tld); + foreach($uris as $uri) + { + if ($this->validateIPv4(gethostbyname($uri))) + return $uri; + } + return false; + } /** * lookupIP() Modified: *.xoops.org (Subdomain APIs & Sites)/whois.xoops.org/include/common.php =================================================================== --- *.xoops.org (Subdomain APIs & Sites)/whois.xoops.org/include/common.php 2018-02-09 11:51:55 UTC (rev 13323) +++ *.xoops.org (Subdomain APIs & Sites)/whois.xoops.org/include/common.php 2018-02-09 12:37:38 UTC (rev 13324) @@ -24,6 +24,7 @@ /** * Include files with definitions */ +include_once __DIR__ . DS . 'constants.php'; include_once __DIR__ . DS . 'functions.php'; include_once __DIR__ . DS . 'version.php'; include_once __DIR__ . DS . 'license.php'; Modified: *.xoops.org (Subdomain APIs & Sites)/whois.xoops.org/include/functions.php =================================================================== --- *.xoops.org (Subdomain APIs & Sites)/whois.xoops.org/include/functions.php 2018-02-09 11:51:55 UTC (rev 13323) +++ *.xoops.org (Subdomain APIs & Sites)/whois.xoops.org/include/functions.php 2018-02-09 12:37:38 UTC (rev 13324) @@ -293,6 +293,73 @@ } } + +if (!function_exists("getURIData")) { + + /* function yonkURIData() + * + * Get a supporting domain system for the API + * @author Simon Roberts (Chronolabs) si...@la... + * + * @return float() + */ + function getURIData($uri = '', $timeout = 25, $connectout = 25, $post = array(), $headers = array()) + { + if (!function_exists("curl_init")) + { + die("Install PHP Curl Extension ie: $ sudo apt-get install php-curl -y"); + } + $GLOBALS['php-curl'][md5($uri)] = array(); + if (!$btt = curl_init($uri)) { + return false; + } + if (count($post)==0 || empty($post)) + curl_setopt($btt, CURLOPT_POST, false); + else { + $uploadfile = false; + foreach($post as $field => $value) + if (substr($value , 0, 1) == '@' && !file_exists(substr($value , 1, strlen($value) - 1))) + unset($post[$field]); + else + $uploadfile = true; + curl_setopt($btt, CURLOPT_POST, true); + curl_setopt($btt, CURLOPT_POSTFIELDS, http_build_query($post)); + + if (!empty($headers)) + foreach($headers as $key => $value) + if ($uploadfile==true && substr($value, 0, strlen('Content-Type:')) == 'Content-Type:') + unset($headers[$key]); + if ($uploadfile==true) + $headers[] = 'Content-Type: multipart/form-data'; + } + if (count($headers)==0 || empty($headers)) + curl_setopt($btt, CURLOPT_HEADER, false); + else { + curl_setopt($btt, CURLOPT_HEADER, true); + curl_setopt($btt, CURLOPT_HTTPHEADER, $headers); + } + curl_setopt($btt, CURLOPT_CONNECTTIMEOUT, $connectout); + curl_setopt($btt, CURLOPT_TIMEOUT, $timeout); + curl_setopt($btt, CURLOPT_RETURNTRANSFER, true); + curl_setopt($btt, CURLOPT_VERBOSE, false); + curl_setopt($btt, CURLOPT_SSL_VERIFYHOST, false); + curl_setopt($btt, CURLOPT_SSL_VERIFYPEER, false); + $data = curl_exec($btt); + $GLOBALS['php-curl'][md5($uri)]['http']['posts'] = $post; + $GLOBALS['php-curl'][md5($uri)]['http']['headers'] = $headers; + $GLOBALS['php-curl'][md5($uri)]['http']['code'] = curl_getinfo($btt, CURLINFO_HTTP_CODE); + $GLOBALS['php-curl'][md5($uri)]['header']['size'] = curl_getinfo($btt, CURLINFO_HEADER_SIZE); + $GLOBALS['php-curl'][md5($uri)]['header']['value'] = curl_getinfo($btt, CURLINFO_HEADER_OUT); + $GLOBALS['php-curl'][md5($uri)]['size']['download'] = curl_getinfo($btt, CURLINFO_SIZE_DOWNLOAD); + $GLOBALS['php-curl'][md5($uri)]['size']['upload'] = curl_getinfo($btt, CURLINFO_SIZE_UPLOAD); + $GLOBALS['php-curl'][md5($uri)]['content']['length']['download'] = curl_getinfo($btt, CURLINFO_CONTENT_LENGTH_DOWNLOAD); + $GLOBALS['php-curl'][md5($uri)]['content']['length']['upload'] = curl_getinfo($btt, CURLINFO_CONTENT_LENGTH_UPLOAD); + $GLOBALS['php-curl'][md5($uri)]['content']['type'] = curl_getinfo($btt, CURLINFO_CONTENT_TYPE); + curl_close($btt); + return $data; + } +} + if (!class_exists("XmlDomConstruct")) { /** * class XmlDomConstruct Modified: *.xoops.org (Subdomain APIs & Sites)/whois.xoops.org/include/version.php =================================================================== --- *.xoops.org (Subdomain APIs & Sites)/whois.xoops.org/include/version.php 2018-02-09 11:51:55 UTC (rev 13323) +++ *.xoops.org (Subdomain APIs & Sites)/whois.xoops.org/include/version.php 2018-02-09 12:37:38 UTC (rev 13324) @@ -29,5 +29,5 @@ /** * Define API version */ -define('API_VERSION', 'WHOIS Services API 2.1.11'); +define('API_VERSION', 'WhoIS REST Services API 2.2.11'); define('API_TYPE', 'whois'); |