中国IT资源网 设为首页
加入收藏
网站建设
您当前的位置:中国IT资源网 -> 文章 -> 设计学院 -> 网页制作 -> 文章内容
 利用 QQWry.Dat 实现 IP 地址高效检索( PHP XML-RPC 接口)
在前面利用 QQWry.Dat 实现 IP 地址高效检索(PHP) 和 利用 QQWry.Dat 实现 IP 地址高效检索(PHP 共享内存版)的基础上,我们只需再写一点儿代码,就可以实现一个 PHP XML-RPC 的查询接口了。

下面是有用共享内存版实现的程序:

<?php
include('xmlrpc.inc.php');
include('xmlrpcs.inc.php');
include('iplocation.inc.php');

function iplocation_xmlrpc($params) {
$ipval = $params->getParam(0);
$ip = $ipval->scalarval();
$iplocation = & IpLocation::getInstance();
$location = $iplocation->getlocation($ip);
if (function_exists('iconv')) {
$location['country'] = iconv("GBK", "UTF-8", $location['country']);
$location['area'] = iconv("GBK", "UTF-8", $location['area']);
}
else if (function_exists('mb_convert_encoding')) {
$location['country'] = mb_convert_encoding($location['country'], "UTF-8", "GBK");
$location['area'] = mb_convert_encoding($location['area'], "UTF-8", "GBK");
}
else {
return new xmlrpcresp(0, $xmlrpcerruser, "Can't convert the result to the correct encode.");
}
return new xmlrpcresp(new xmlrpcval(array(
"ip" => new xmlrpcval($location['ip'], "string"),
"beginip" => new xmlrpcval($location['beginip'], "string"),
"endip" => new xmlrpcval($location['endip'], "string"),
"country" => new xmlrpcval($location['country'], "string"),
"area" => new xmlrpcval($location['area'], 'string')), "struct"));
}

new xmlrpc_server(array('iplocation' =>
array('function' => 'iplocation_xmlrpc',
'signature' => array(array('struct', 'string')),
'docstring' => 'Return the location of the ip or domain name.'))
);

?>


有了这个 XML-RPC 服务器,我们就可以在任何程序中去调用它了


评论】【打印】【 】【关闭
  弹出窗口总结收集(续) 
  利用 QQWry.Dat 实现 IP 地址高效检索(PHP 共享内存版)
 
关于本站 - 网站帮助 - 广告合作 - 下载声明 - 友情连接 - 网站地图 - 在线投稿

中国IT资源网版权所有
Copyright © 2002-2006 Gz235.Com All Rights Reserved
中华人民共和国电信与信息服务业务经营许可证编号 粤ICP备05022918号
本站在线服务QQ:105754049 程序定制:105754049 广告受理/投搞/投诉:105754049
本站所提供的程序均来自于 Internet(下载后首先检测是否有毒),仅供学习使用。因其产生的一切问题本站不负任何责任