-6
<?PHP

class couty{
   public function write ($a,$b){

       @session_start();
       if(!(isset($_SESSION[`login`]) && $_SESSION[`login`] != ``)){
         echo "you must Logged in to create a PHP file";
       }
       else{
            file_put_contents($a,$b);
            exit;
       }
}
}

$c = `<!DOCTYPE HTML><HTML>
<head><title></title></head>
<body></body>
</HTML>`;

if($_SERVER[`REQUEST_METHOD`] == `POST`){
   $new = trim($_POST[`coutyv`]);
   $dir = (mkdir(`folder/$new`));
   $d = new couty();
   $d->write(`$dir/$new.php`,$c);
}
?>
<form method = `post` action = ``>
<input type = `text` name = `coutyv`/>
<input type = `submit` name = `submit`/>
</form> 
4

2 回答 2

2

你的问题在这里。检查您是否有这些文件夹。反正你的代码不好

  $dir = (mkdir(`folder/$new`));
   $d = new couty();
   $d->write(`$dir/$new.php`,$c);
于 2013-05-19T14:38:14.520 回答
0

我会做的几件事

  1. 将变量从 $d、$a、$c 重命名为有意义的名称 - > $new_directory、$output_filename 等
  2. 检查 $new 实际上是一个有效的名称。
  3. 检查 mkdir 是否成功创建目录。
  4. 为所有失败的情况添加错误处理。

将来可能发生或可能发生:

$dir = (mkdir(`folder/$new`));  <--- $new might be bad / folder might be bad / call might fail
$d->write(`$dir/$new.php`,$c);  <--- maybe the $dir/$new.php generated a bad path.

// future potential errors:
$new = trim($_POST[`coutyv`]); <---- new might not exist, might be invalid, contain invalid 
于 2013-05-19T14:44:17.150 回答