<?php
defined('_VALID_MOS') or die('仁羲曙 頑頜羨粵.');
// ensure user has access to this function
if (!($acl->acl_check( 'administration', 'edit', 'users', $my->usertype, 'components', 'all' ) |
$acl->acl_check( 'administration', 'edit', 'users', $my->usertype, 'components', 'com_ping' )))
mosRedirect( 'index2.php', _NOT_AUTH );
require_once( $mainframe->getPath( 'admin_html' ) );
$act = mosGetParam( $_REQUEST, 'act', '' );
switch($act)
{
case "ping":
ping();
break;
case "edit":
editServers();
break;
case "save":
saveServers();
break;
case "saveok":
echo "Servers list are saved.";
break;
}
function pingServer($URL)
{
global $mosConfig_sitename,$mosConfig_live_site;
$parse = parse_url($URL);
if(!isset($parse['host'])) return false;
$host = $parse['host'];
$port = isset($parse['port'])?$parse['port']:80;
$uri = isset($parse['path'])?$parse['path']:'/';
$fp=fsockopen($host,$port,$errno,$errstr);
if(!$fp)
{ return array(-1,"Cannot open connection: $errstr ($errno)<br />\n"); }
$sitetitle = $mosConfig_sitename;
$siteurl = $mosConfig_live_site.'/';
$data = "<?xml version=\"1.0\"?>\r\n
<methodCall>\r\n
<methodName>weblogUpdates.ping</methodName>\r\n
<params>\r\n
<param>\r\n
<value>$sitetitle</value>\r\n
</param>\r\n
<param>\r\n
<value>$siteurl</value>\r\n
</param>\r\n
</params>\r\n
</methodCall>";
$len = strlen($data);
$out = "POST $uri HTTP/1.0\r\n";
$out .= "User-Agent: Joomla! Ping/1.0\r\n";
$out .= "Host: $host\r\n";
$out .= "Content-Type: text/xml\r\n";
$out .= "Content-length: $len\r\n\r\n";
$out .= $data;
fwrite($fp, $out);
$response = '';
while(!feof($fp)) $response.=fgets($fp, 128);
fclose($fp);
$lines=explode("\r\n",$response);
$firstline=$lines[0];
if(!ereg("HTTP/1.[01] 200 OK",$firstline))
{ return array(-1,$firstline); }
while($lines[0]!='') array_shift($lines);
array_shift($lines);
$lines=strip_tags(implode(' ',$lines));
$n=preg_match(
'|<member>\s*<name>flerror</name>\s*<value>\s*<boolean>([^<]*)</boolean>\s*</value>\s*</member>|i',
$response, $matches);
if(0==$n)
{ return array(-1,$lines); }
$flerror=$matches[1];
$n=preg_match(
'|<member>\s*<name>message</name>\s*<value>\s*<string>([^<]*)</string>\s*</value>\s*</member>|i',
$response, $matches);
if(0==$n)
{ return array(-1,$lines); }
$message=$matches[1];
return array($flerror,$message);
}
function ping()
{
global $database, $my, $mainframe;
set_time_limit(0);
echo '<p align="left" style="text-align:left">';
$query = "SELECT url"
."\n FROM #__ping_servers"
."\n LIMIT 1";
$database->setQuery( $query );
$urls = $database->loadResult();
if ($database->getErrorNum()) {
echo "<script> alert('".$database->getErrorMsg()."'); window.history.go(-1); </script>\n";
return false;
}
$urllist = split( "\r\n", $urls );
foreach ( $urllist as $url )
{
$response=pingServer($url);
HTML_Ping::ShowResponse($url,$response[0],$response[1]);
}
echo '</p>';
}
function editServers()
{
global $database;
$query = "SELECT url"
."\n FROM #__ping_servers"
."\n LIMIT 1";
$database->setQuery( $query );
$urls = $database->loadResult();
if ($database->getErrorNum()) {
echo "<script> alert('".$database->getErrorMsg()."'); window.history.go(-1); </script>\n";
return false;
}
HTML_Ping::EditServers( $urls );
}
function saveServers()
{
global $database,$option;
$urls=($_POST['urls']);
$query = "UPDATE #__ping_servers"
."\n SET url = '".$urls."'"
."\n WHERE ( id=1 )";
$database->setQuery( $query );
if (!$database->query()) {
echo "<script> alert('".$database->getErrorMsg()."'); window.history.go(-1); </script>\n";
exit();
}
mosRedirect( 'index2.php?option='. $option . '&act=saveok' );
}
?>

weixin_42651887
- 粉丝: 119
最新资源
- 2023年Python程序设计试题库.doc
- 2023年南京电大数据库系统概论考核要求.doc
- 物联网技术在小学信息技术教学中的应用.docx
- [精选]网络时代的人力资源管理体系解析.pptx
- JavaCS架构的企业管理软件设计银行管理系统的设计与开发毕业设计(DOC毕业论文).doc
- 2021-2022年收藏的精品资料软件测试工程师笔试试题大集合.doc
- 《网络营销与策划》试卷A答案..doc
- PKPM系列软件在结构设计中的应用与探讨讲义.ppt
- 2021-2022收藏资料卢丹——单片机的交通灯控制的设计.doc
- 通信行业:2021中国5G产业全景图谱报告.pdf
- 【安全工程】电气工程及其自动化的问题及措施.docx
- 2021-2022收藏的精品资料操作系统期末考试答案.doc
- C语言程序说课ppt课件(1).ppt
- PHP-filemtime()-函数.doc
- “公安保密宣传教育系列”-计算机及网络.ppt
- 《Ms.Liu's-Great-Idea》Buying-and-Selling-PPT免费课件【品质课件PPT】.pptx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈


