Php 缓存有问题吗?

Php 缓存有问题吗?,php,caching,Php,Caching,我正在尝试为Teamspeak 3安装一个webviewer(一个VoIP程序),但我确实遇到了一些问题。首先,官方网站在一个月前就已经停止了支持,所以很遗憾我不能问他们 当我第一次进入webviewer页面时,一切似乎都很好。但是,如果我刷新页面,它将变为白色并加载,直到我得到: PHP Fatal error: Maximum execution time of 30 seconds exceeded in C:\Users\[...]\TSQuery.class.php on line

我正在尝试为Teamspeak 3安装一个webviewer(一个VoIP程序),但我确实遇到了一些问题。首先,官方网站在一个月前就已经停止了支持,所以很遗憾我不能问他们

当我第一次进入webviewer页面时,一切似乎都很好。但是,如果我刷新页面,它将变为白色并加载,直到我得到:

PHP Fatal error:  Maximum execution time of 30 seconds exceeded in C:\Users\[...]\TSQuery.class.php on line 414
下面是该文件的第414行:

    $ret .= fgets($this->connection, 8096);
以及整个功能:

private function send_raw($text)
{
    $i = -1;
    $ret = '';
    if ($this->connection === NULL)
    {
        $this->open_new_connection();
    }
    stream_set_timeout($this->connection, 0, 300000);
    fputs($this->connection, $text);

    do
    {
        $ret .= fgets($this->connection, 8096);
    }
    while (strstr($ret, "error id=") === false);

    return $ret;
}
public function use_by_port($port)
{
    if (is_numeric($port))
    {

        $resp = $this->send_cmd("use port=" . $port);
        if ($resp['error']['id'] === 0)
        {
            $this->cachepath .= $port . "/";
        }
        return $resp;
    }
    return false;
}
我在我的webhost上尝试了这一点,并将脚本移动到安装VoIP的同一台服务器上(认为主机可能导致了一些问题),但没有什么不同

当我把脚本作为iframe放在我的webhost上并重新加载页面两次时,整个站点就会崩溃

Service Unavailable
The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.
Apache Server at www.site.com Port 80
但回到我自己的服务器,我时不时地(1/10左右的负载)会得到:

这是第85行:

$this->cachepath .= $port . "/";
以及整个功能:

private function send_raw($text)
{
    $i = -1;
    $ret = '';
    if ($this->connection === NULL)
    {
        $this->open_new_connection();
    }
    stream_set_timeout($this->connection, 0, 300000);
    fputs($this->connection, $text);

    do
    {
        $ret .= fgets($this->connection, 8096);
    }
    while (strstr($ret, "error id=") === false);

    return $ret;
}
public function use_by_port($port)
{
    if (is_numeric($port))
    {

        $resp = $this->send_cmd("use port=" . $port);
        if ($resp['error']['id'] === 0)
        {
            $this->cachepath .= $port . "/";
        }
        return $resp;
    }
    return false;
}
有什么想法吗

谢谢

do
{
    $ret .= fgets($this->connection, 8096);
}
while (strstr($ret, "error id=") === false);
上面的代码的意思是:在没有第一次出现“error\u id=”的情况下进行连接(is false)。这意味着如果没有发生错误,它将以无限循环的方式进行连接,我相信这就是您获得超时的原因

更新:

我会跳过do/while,改为这样做:

if(!$this->connection) return false;

$output = fgets($this->connection, 8096);
fputs($this->connection, $text);
fclose($this->connection);

if (substr($output, 0, 4) == '1 OK') return true;

return false;

你不觉得用一个已经停止使用的工具开始学习和工作是一个坏主意吗?不,不。我在很多网站上看到过这个工具,我知道它应该可以工作。它最后一次更新是在5月3日,所以它并不完全过时或过时。啊哈。我想把do while转换成if语句(保持相同的条件)?你觉得怎么样?好吧,我的建议阻止了冰冻,但它几乎没有装载任何东西。除非你有任何建议,否则我想我将不得不尝试不同的解决方案。我想我会跳过do/while部分,检查返回值。检查我的更新。谢谢更新!我不确定你是想让我替换整个函数还是只替换循环。无论哪种方式,我似乎都遇到了一个错误:PHP警告:fgets():26不是有效的流资源-对于fputs()和fclose(),同样的错误。