不工作的特定Web主机

不工作的特定Web主机

本文介绍了的fsockopen()不工作的特定Web主机?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的一位客户表示,他们的系统使用的fsockopen一个非常简单的脚本()来确定服务器是否在线。他们说,直到最近,它工作得很好在其网站上通过我们,但最近刚刚停止工作,所以我假定这是一个设置。

我首先想到的是,他用它作为TCP和使用IP /端口的游戏服务器,然而他和我自己都证实了脚本来自其他网站的主机工作得很好。

有什么能在我们特别的问题?

使用:的

使用:

不起作用:

下面是code ...

 < PHP    $超时=(使用isset($ _ GET ['超时'])($ _ GET ['超时'< = 0 30:?((int)的$ _ GET ['超时'])):30);    如果(空($ _ GET ['IP'])及和放大器;空($ _ GET ['口'])){
        回声无IP /端口指定。';
    }其他{
        如果(的fsockopen($ _ GET ['IP'],$ _GET ['口'],$的errno,$ errstr,$超时)=== FALSE){
            呼应离线;
        }其他{
            回声在线;
        }
    }


解决方案

这有可能是托管公司已禁用的fsockopen功能或防火墙上的端口无论你想测试出站请求。如果是这样的话,你可以要求他们重新启用功能或解锁端口,但是如果他们不那么你必须比移动到新的主机非常少的追索权。

BTW,没有任何形式的验证,直接使用来自用户的输入($ _GET,$ _ POST等)的数据是一个非常糟糕的主意!

One of our customers said they have a very simple script which uses fsockopen() to determine whether a server is online or not. They said until recently it worked fine on their website through us, but recently just stopped working, so I am assuming it is a setting.

My first thought was that he was using it as TCP and using the IP/Port for a Game Server, however he and myself both confirmed the script worked fine from various other web hosts.

What could be the issue on ours in particular?

Works: http://crazygfl.xfactorservers.com/query.php?ip=www.xfactorservers.com&port=80

Works: http://crazygfl-stats.com/query.php?ip=109.73.163.231&port=27015

Doesn't Work: http://crazygfl.xfactorservers.com/query.php?ip=109.73.163.231&port=27015

Here is the code...

<?php

    $timeout = (isset($_GET['timeout']) ? ($_GET['timeout'] <= 0 ? 30 : ((int)$_GET['timeout'])) : 30);

    if(empty($_GET['ip'])&&empty($_GET['port'])){
        echo 'No IP/Port specified.';
    }else{
        if(fsockopen($_GET['ip'], $_GET['port'], $errno, $errstr, $timeout) === false){
            echo 'offline';
        }else{
            echo 'online';
        }
    }
解决方案

It's possible that the hosting company have disabled the fsockopen function or firewalled outbound requests on whatever port you're trying to test. If that's the case you can ask them to reenable the function or unblock the port, but if they won't then you have very little recourse other than moving to a new host.

BTW, using data directly from user input ($_GET, $_POST, etc) without any kind of validation is an EXTREMELY bad idea!

这篇关于的fsockopen()不工作的特定Web主机?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 09:55