//用户点击CANCEL,取消提交
if($cancel) $action="";
//上传文件处理
if($upload) 
{
copy($userfile,$basedir.$wdir.$userfile_name); 
$lastaction = "上传文件到 $basedir$wdir";
html_header();
displaydir();
echo $html_ender;
exit;
}
################################################################################
//开始处理actions
switch ($action)
{
//没有$action变量则显示初始页面
case "":
$lastaction = "$basedir";
html_header();
displaydir();
echo $html_ender;
break;
//回根目录
case "root":
    $wdir="/";
$lastaction = "$basedir";
html_header();
displaydir();
echo $html_ender;
break;
//改变目录
case "chdr":
$wdir=$file."/";
$lastaction = "$basedir$wdir";
html_header();
displaydir();
echo $html_ender;
break;
// 改动的对象
case "touch":
touch($basedir.$touchfile);
$lastaction = "Touched $touchfile";
html_header();
displaydir();
echo $html_ender;
break;
//调试报表
case "bugreport":
if ($send)
{
  $lastaction = "Bug reported. Thank you!";
html_header();
mail("[email protected]","Bug report","Name: $name \nVersion: $version \n\nProblem: $problem");
echo "<h3><a href=\"$PHP_SELF?action=help&wdir=$wdir\">Back to help</a></h3>";
}
else
{
$lastaction = "Bug report form";
html_header();
?>
<table>
<form action="<? echo "$PHP_SELF?action=bugreport&wdir=$wdir&send=1"; ?>" method="POST">
<tr>
<td>Your name:</td>
<td><input name="name" size="24" maxlength="30"></td>
</tr><tr>
<td>Your email adress:</td>
<td><input name="email" size="24" maxlength="30"></td>
</tr><tr>
<td>Description of problem(s):</td>
<td><textarea name="problem" cols="30" rows="5"></textarea></td>
</tr><tr>
<td colspan="2" align="center"><input type="submit" value="Send"></td>
</tr>
</table>
<?
}
echo $html_ender;
break;
//删除文件或目录
case "del":
//用户确认删除
if ($confirm)
{

//删除对象是目录
if(is_dir($basedir.$file))
{
rmdir($basedir.$file);
}
//删除对象是文件
else
{
exec("delete $basedir.$file");
//unlink($basedir.$file);
}
$lastaction = "删除 $file";
html_header();
displaydir();
}
//显示删除提示
else
{
$lastaction = "确实要删除<br>$file吗?";
html_header();
echo "<center><b><font size =\"5\" face=\"arial, helvetica\"><A HREF=\"$PHP_SELF?action=del&wdir=$wdir&file=$file&confirm=1\">YES!</A></font><br>";
echo "<p><font size =\"5\" face=\"arial, helvetica\"><A HREF=\"$PHP_SELF?wdir=$wdir\">NO!</A></font><br><b></center>";
}
echo $html_ender;
break;
//改变权限属性
case "chmod":
//用户确认
      if ($confirm)
{
$level = "0";
$level .= $owner;
$level .= $group;
$level .= $public;
$showlevel = $level;
$level=octdec($level);
chmod($basedir.$file,$level);
$lastaction = "改变属性 $file to $showlevel";
html_header();
displaydir();
}
//提示
else
{
$lastaction = "改变属性$file";
html_header();
echo "<font face=\"arial, helvetica\"><center><h4>Current level: ";
printf("%o", (fileperms($basedir.$file)) & 0777);
echo "</h4><FORM METHOD=\"POST\" ACTION=\"$PHP_SELF\">\n";
function selections()
{
echo "<option value=\"0\">0 - No permissions";
echo "<option value=\"1\">1 - Execute";
echo "<option value=\"2\">2 - Write ";
echo "<option value=\"3\">3 - Execute & Write";
echo "<option value=\"4\">4 - Read";
echo "<option value=\"5\">5 - Execute & Read";
echo "<option value=\"6\">6 - Write & Read";
echo "<option value=\"7\">7 - Write, Execute & Read";
echo "</select>";
}
echo "<p><h4>Owner<br>";
echo "<select name=\"owner\">";
selections();
echo "<p>Group<br>";
echo "<select name=\"group\">";
selections();
echo "<p>Public<br>";
echo "<select name=\"public\">";
selections();
echo "</h4>";
echo "<p>";
echo "<INPUT TYPE=\"SUBMIT\" NAME=\"confirm\" VALUE=\"Change\">\n";
echo "<INPUT TYPE=\"SUBMIT\" NAME=\"cancel\" VALUE=\"Cancel\">\n";
echo "<INPUT TYPE=\"HIDDEN\" NAME=\"action\" VALUE=\"chmod\">\n";
echo "<INPUT TYPE=\"HIDDEN\" NAME=\"file\" VALUE=\"$file\">";
echo "<INPUT TYPE=\"HIDDEN\" NAME=\"wdir\" VALUE=\"$wdir\">";
echo "</FORM>";
echo "</center>";
}
echo $html_ender;
break;
//移动文件
case "move":
//用户确认对象重命名、移动或复制
if($confirm && $newfile)
  {
//对象存在
     if(file_exists($basedir.$newfile))
{
$lastaction = "Destination file already exists. Aborted.";
}
else
{
if($do == copy)
{
copy($basedir.$file,$basedir.$newfile);
$lastaction = "Copied\n$file to $newfile";
}
else
{
rename($basedir.$file,$basedir.$newfile);
$lastaction = "Moved/renamed\n$file to $newfile";
}
}
html_header();
displaydir();
     echo $html_ender;
}
//提示
else
{
$lastaction = "Moving/renaming or copying<br>$file";
html_header();
echo "<FORM METHOD=\"POST\" ACTION=\"$PHP_SELF\">\n";
echo "<select name=\"do\">";
echo "<option value=\"copy\">Copy";
echo "<option value=\"move\">Move/rename";
echo "</select> ";
echo "($file)";
echo "<h4>To</h4>";
echo "<INPUT TYPE=\"TEXT\" NAME=\"newfile\" value=\"$file\" size=\"40\">\n";
echo "<INPUT TYPE=\"HIDDEN\" NAME=\"wdir\" VALUE=\"$wdir\">\n";
echo "<INPUT TYPE=\"HIDDEN\" NAME=\"action\" VALUE=\"move\">\n";
echo "<INPUT TYPE=\"HIDDEN\" NAME=\"file\" VALUE=\"$file\">\n";
echo "<p>";
echo "<INPUT TYPE=\"SUBMIT\" NAME=\"confirm\" VALUE=\"Do\">\n";
echo "<INPUT TYPE=\"SUBMIT\" NAME=\"cancel\" VALUE=\"Cancel\">\n";
echo "</FORM>";
echo $html_ender;
}
break;
//编辑文件
case "edit": //用户编辑完毕,返回主页面
if($confirm && $file)
    {
     $lastaction = "Edited $file";
html_header();
$fp=fopen($basedir.$file,"w");
     fputs($fp,stripslashes($code));
     fclose($fp);
displaydir();
}
//在textarea显示文件内容
else
{
$lastaction = "Editing $file";
html_header();
echo "<FORM METHOD=\"POST\" ACTION=\"$PHP_SELF\">\n";
echo "<INPUT TYPE=\"HIDDEN\" NAME=\"file\" VALUE=\"$file\">\n";
echo "<INPUT TYPE=\"HIDDEN\" NAME=\"action\" VALUE=\"edit\">\n";
echo "<INPUT TYPE=\"HIDDEN\" NAME=\"wdir\" VALUE=\"$wdir\">\n";
$fp=fopen($basedir.$file,"r");
$contents=fread($fp,filesize($basedir.$file));
echo "<TEXTAREA NAME=\"code\" rows=\"$textrows\" cols=\"$textcols\">\n";
echo htmlspecialchars($contents);
echo "</TEXTAREA><BR>\n";
echo "<center><INPUT TYPE=\"SUBMIT\" NAME=\"confirm\" VALUE=\"Save\">\n";
echo "<INPUT TYPE=\"SUBMIT\" NAME=\"cancel\" VALUE=\"Cancel\"></center><BR>\n";
echo "</FORM>";
}
echo $html_ender;
break;
//显示文件
case "show": //以文本格式显示文件
$filelocation = $wdir.$file;
$lastaction = "$basedir$file";
html_header();
//如果是图片则显示
if($image == "1")
{
echo "<center><img src=\"$file\"></center>";
}
//如果是文本,显示.
else
{
show_source($basedir.$file);
}
echo $html_ender;
break;
//创建新目录
case "mkdir": //如果该目录已经存在. 
if(file_exists($basedir.$wdir.$mkdirfile))
{
$lastaction = "$basedir$wdir$mkdirfile allready exists.";
html_header();
}
//否则则创建
else
{
$lastaction = "Created the directory $wdir$mkdirfile";
html_header();
mkdir($basedir.$wdir.$mkdirfile,0750);
}
displaydir();
echo $html_ender;
break;
//生成新文件
case "createfile":
$filelocation = $wdir.$file;
//编辑完毕,返回.
if($done == "1")
    {
$lastaction = "Created $file";
html_header();
$fp=fopen($basedir.$filelocation,"w");
fputs($fp,stripslashes($code));
fclose($fp);
displaydir();
}
else
{
    //如果文件已经存在
    if(file_exists($basedir.$filelocation))
    {
    $lastaction = "$file already exists.";
html_header();
displaydir();
}
else
{
$lastaction = "Creating $file";
html_header();
echo "<FORM METHOD=\"POST\" ACTION=\"$PHP_SELF\">\n";
echo "<INPUT TYPE=\"HIDDEN\" NAME=\"file\" VALUE=\"$file\">\n";
echo "<INPUT TYPE=\"HIDDEN\" NAME=\"action\" VALUE=\"createfile\">\n";
echo "<INPUT TYPE=\"HIDDEN\" NAME=\"wdir\" VALUE=\"$wdir\">\n";
echo "<INPUT TYPE=\"HIDDEN\" NAME=\"done\" VALUE=\"1\">\n";
echo "<TEXTAREA NAME=\"code\" rows=\"$textrows\" cols=\"$textcols\">\n";
//用户选用Web页面
if(isset($html))
{
echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n\n";
echo "<html>\n";
echo "<head>\n\n";
echo " <title>Untitled</title>\n";
echo "</head>\n";
echo "<body>\n\n\n\n";
echo "</body>\n";
echo "</html>";
}
echo "</TEXTAREA><BR>\n";
echo "<center><INPUT TYPE=\"SUBMIT\" NAME=\"confirm\" VALUE=\"Create\">\n";
echo "<INPUT TYPE=\"SUBMIT\" NAME=\"cancel\" VALUE=\"Cancel\"></center><BR>\n";
echo "</FORM>";
}
}
echo $html_ender;
break;
}
?>
我每次填写的值, 没有生效,  点按钮, 也没有发生跳转。

解决方案 »

  1.   

    register_global = ON??????
    ==================echo "<INPUT TYPE=\"SUBMIT\" NAME=\"confirm\" VALUE=\"Change\">\n";
    echo "<INPUT TYPE=\"SUBMIT\" NAME=\"cancel\" VALUE=\"Cancel\">\n";
    随便点哪个SUBMIT,$_POST['confirm'],$_POST['cancel']都会有值的。
      

  2.   

    <?
    // HTML文档开始
    print("<HTML>\n");
    // 编写头文件
    print("<HEAD>\n");
    print("<TITLE>");
    print("查看句中单词的个数");
    print("</TITLE>\n");
    print("</HEAD>\n");
    // 编写HTML主体
    print("<BODY>\n");
    /*
    ** 如果得到提交的语句则执行下面的语句
    */
    if(isset($sentence))
    {
    print("<B>得到的语句:</B>");
    print("$sentence<BR><BR>\n");
    $separators = " ";
    //得到每个单词
    for($token = strtok($sentence, $separators);
    $token;
    $token = strtok($separators))
    {
    // 计算每个单词
    $word_count[$token]++;
    $total++;
    }
    //分成数组
    arsort($word_count);
    print("<B>找到$total 个单词</B>\n");
    print("<UL>\n");
    while(list($key, $value) = each($word_count))
    {
    print("<LI>$key ($value)\n");
    }
    print("</UL>\n");
    } print("<FORM ACTION=\"77.php\">\n");
    print("<INPUT NAME=\"sentence\" SIZE=\"10\">\n");
    print("<INPUT TYPE=\"submit\" VALUE=\"提交\">\n");
    print("</FORM>\n");
    print("</BODY>\n");
    // End HTML document
    print("</HTML>\n");
    ?>不好意思, 这个简单一些