-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> 
nickb
  • 59,313
  • 13
  • 108
  • 143
user2398999
  • 1
  • 1
  • 1

2 Answers2

2

Your problem is in here . Check if you have these folders or not. anyway your code is not good

  $dir = (mkdir(`folder/$new`));
   $d = new couty();
   $d->write(`$dir/$new.php`,$c);
Yogus
  • 2,307
  • 5
  • 20
  • 38
0

Few things I would do

  1. Rename your variables from $d, $a, $c to meaningful names - > $new_directory, $output_filename, etc
  2. Check that $new is infact a valid name.
  3. Check that mkdir creates the directory successfully.
  4. Add error handling for all situations in which it fails.

Could be, or might happen in the future:

$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 
Dory Zidon
  • 10,497
  • 2
  • 25
  • 39