gpt4 book ai didi

php - 如何执行命令telnet php

转载 作者:可可西里 更新时间:2023-10-31 23:05:26 25 4
gpt4 key购买 nike

我有一个代码可以使用 telnet 连接到 teamspeak 服务器。有人可以帮我发送命令吗?

我的代码:

<?php
$ip = 'localhost';
$result = '';
$fp = fsockopen($ip, 10011);
echo fgets($fp);
fputs($fp,"help");
$result=fread($fp,1024);
fclose($fp);
echo nl2br($result);
?>

我想发送命令“help”

这段代码只返回:

TS3 
Welcome to the TeamSpeak 3 ServerQuery interface, type "help" for a list of commands and "help " for information on a specific command.

最佳答案

像这样:

<?php
$socket = fsockopen("localhost", "10011", $errno, $errstr);

if($socket)
{
echo "Connected <br /><br />";
}
else
{
echo "Connection failed!<br /><br />";
}

fputs($socket, "help \r\n");

$buffer = "";

while(!feof($socket))
{
$buffer .=fgets($socket, 4096);
}

print_r($buffer);
echo "<br /><br /><br />";
var_dump($buffer);

fclose($socket);
?>

我在您的代码中添加了更多内容,这是不可能的

关于php - 如何执行命令telnet php,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23684327/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com