有没有人知道我如何能够回应rconresults,如果它不是rconresults来调用rconresults1或rconresults2?目前唯一有效的是echo rconresults();功能在底部,我是新手:P
<?php
define('INCLUDE_CHECK',true);
include("../classes/functions2.php");
include("../classes/functions.php");
require '../classes/q3status.php';
require '../classes/q3rcon.php';
include("rconform.php");
include("rconresults.php");
include("rconresults1.php");
include("rconresults2.php");
$theme = $_COOKIE['currenttheme'];?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"../templates/$theme/style.css\" media=\"screen\" />"; ?>
</head>
<body>
<?php
echo "<div align='center'>";
echo rconform();
echo '<br><a href="javascript:self.close()">close window</a>';
echo "</div>";
echo rconresults();
?>
</body>
</html>
Rconresults调用此文件,我有3个不同的请求
<?php
function rconresults() {
include "../classes/config_inc.php";
$server3 = mysql_real_escape_string($_REQUEST['rconserver']);
$say = mysql_real_escape_string($_REQUEST['say']);
echo "<div align='center'>";
if ($server3 != "") {
$server3 = addslashes($server3);
mysql_connect("$db_host", "$db_user", "$db_pass") or die(mysql_error());
mysql_select_db("$db_database") or die(mysql_error());
$result = mysql_query("select * from {$db_prefix}_servers where `id`='{$server3}'");
if (!$result) {
die("No Server Available with id {$server3}");
}
$fields_num = mysql_num_fields($result);
// store the record of the "example" table into $row
$row = mysql_fetch_array( $result );
// Print out the contents of the entry
$r = new q3rcon($row['ip'], $row['port'], $row['rconpass']);
$data = explode(" ", $say);
if ($data[0] == "clientkick" && count($data) > 2) {
$data = explode(" ", $say, 3);
$r->send_command("".$data[0]." ".$data[1]." \"".$data[2]."\"");
} else {
$r->send_command("say " . $say);
}
$out = $r->get_response();
$out2 = explode("\n", $out);
echo "<table class='container9'><tr><td>";
if ($out == '') {
echo "Command Sent!";
}
foreach($out2 as $line) {
if ($line != '') {
echo "".strip_gtlt(strip_colors($line))."<br>";
}
}
echo "</td></tr></table>";
}
echo "</div>";
}
?>
我觉得你的意思是这个?单击按钮然后重新启动地图?
<?php
function rconform()
{
include("../classes/config_inc.php");
echo "<form method='post' action=''><table class='container8'><tr><td><table width='300'>";
echo "<tr><td colspan='2'><div align='center'><font size='4'><strong>Run RCON Command</strong></font></div></td></tr><tr><td><div align='right'>Server:</div></td><td><div align='left'>";
echo "<select name='rconserver'><option selected='selected'>Select</option>";
mysql_connect("$db_host", "$db_user", "$db_pass") or die(mysql_error());
mysql_select_db("$db_database") or die(mysql_error());
$sql="SELECT * FROM `".$db_prefix."_servers` where `Status`='Online' order by `order` ASC";
$result =mysql_query($sql);
while ($data=mysql_fetch_assoc($result)){
$svname = $data['name'];
$svname = stripslashes($svname);
$svid = $data['id'];
if ($svname == $server3) {
$selected = "selected=\"$svname\"";
} else {
$selected = "";
}
echo "<option value =\"$svid\" $selected>$svname</option>";
}
echo "</select></div></td></tr><tr><td><div align='right'>Console:</div></td><td><div align='left'><input type='text' placeholder='Say something..' name='say'></div></td></tr><tr><td colspan='2'><div align='center'><input type='submit' value='Execute'></div></td></tr></td></tr></form>";
echo "</select></div></td></tr><tr><td><div align='right'>Change Map:</div></td><td><div align='left'><input type='text' placeholder='mp_harbor' name='map'></div></td></tr><tr><td colspan='2'><div align='center'><input type='submit' value='Execute'></div></td></tr></table></td></tr></form>";
echo "</select></div></td></tr><tr><td><div align='right'><input type='submit' value='Restart Map' name='map_restart'></div></td></tr>
</tr>
</table></td></tr></table>
</form>";
}
?>
答案 0 :(得分:1)
这取决于rconresults的回归。
如果它是一个布尔条件,如果它是真的,下面的代码将运行rconresults,如果它是假的则运行rconresults2。
一切都取决于条件。
if ( $_REQUEST['option'] == "rconresults2" ) {
echo rconresults2();
} else {
echo rconresults();
}
更新
答案 1 :(得分:0)
我认为你对如何包含工作感到有点困惑。看来你想要这样的东西:
if (some condition {
include("rconform.php");
} else if (some other condition) {
include("rconresults.php");
} else if ( a different condition) {
include("rconresults1.php");
} else {
include("rconresults2.php");
}
但你没有说出条件是什么。如果你能告诉我们你想要完成的事情,我们可以提供一些指导。