好吧,我制作了一个简单的脚本,将服务器信息打印成PNG图片,它确实有效,但有一些问题。
我使用了一个免费脚本,使用php从源服务器获取变量,然后打印输出,我编辑它以便打印成图片,但不知何故,它不打印播放器和地图值。
这是脚本使用的config.php。
<?php
$servers = array (array ('name' => '[TF2] gameTek Idle Trade Server #1 [NO]',
'ip' => '84.234.160.79',
'port' => 27015),
array ('name' => '[TF2] gameTek Achevments Idle Trade Server #2 [NO]',
'ip' => '84.234.160.79',
'port' => 27017),
array ('name' => '[TF2] gameTek BOT Fun #3 [NO]',
'ip' => '84.234.160.79',
'port' => 27016),
array ('name' => '[TF2] gameTek Achevments Idle Trade Server #5 [DFW]',
'ip' => '50.56.179.18',
'port' => 27015)
);
/*
$cachelifetime = 30;
$cachefile = './cache/servers.html';
*/
$output = '
<p><a href="steam://connect/#ip#:#port#">
<img
src="Generate.php?n=#name#&p=#players#/#maxplayers#&m=#map#" alt="" /></a></p>
';
?>
打印时的输出是
http://teamgamers.net/GetInfoServer/Generate.php?n=[TF2]%20gameTek%20Idle%20Trade%20Server%20#1 [NO]&p=3/32&m=tek_idle_trade_v5
那么,我怎样才能使它完美运行,而不是像现在这样,它只打印服务器名称而不是其余的? 我试过搞清楚,但没有运气。
Generate.php
<?php
$Name = $_GET['n'];
$Players = $_GET['p'];
$Map = $_GET['m'];
$Image = @ImageCreateFromPNG("./Server.png");
$Cord = imagecolorallocate($Image, 255, 255, 255);
imagestring($Image,15,60,7,$Name,14);
imagestring($Image,15,62,37,$Players,14);
imagestring($Image,15,140,37,$Map,14);
header('Content-type: image/png');
imagepng($Image);
?>
答案 0 :(得分:0)
Check out urlencode;基本上,您放入网址的所有内容都需要传递到urlencode,以确保它不包含任何元字符。
$servers = array (array ('name' => urlencode('[TF2] gameTek Idle Trade Server #1 [NO]'),
// and so on...