Jump to content

automatically create pages.


ohdang888

Recommended Posts

heres my code to automatically create a folder and a index.php in it: but one problem, i'm getting an error of:?

 

 

 

Warning: mkdir() [function.mkdir]: Permission denied in C:\xampp\htdocs\create\index.php on line 13

 

p.s.- i'm eventually going to add a template where it would add this info in certain specified sections of the page

 

 

<html>

<form method="post">

Name of game:<input type="text" size="15" maxlength="30" name="name"/>

<br/>

folder name:<input type="text" size="15" maxlength="30" name="folder"/>

<input type="submit" name="submit" value="Submit"/>

 

 

 

<?php

  $name = $_POST["name"];

  $folder= $_POST["folder"];

  mkdir("/$folder", 0700);// this creates the directory, but i think my permissions are messed up

  $newindex = "index.php";

  $fh1 = fopen($newindex, 'w') or die("can't create file");

  fwrite($fh1,$name);

  fclose($fh1);

?>

Link to comment
Share on other sites

well lets first talk problems

 

first your $folder is an issue you are taking raw post data into it, user could put ./ or ../ and get above where they suppose to.

 

Secondly you don't define a context for the folder, doing so eliminates the above problem $_SERVER['DOCUMENTS_ROOT']."/Content/"; for example will save you injection

 

Now issues

 

you don't ave premission because that folder you are making the folder needs to have the outside world have write access to check that.

Link to comment
Share on other sites

whats a context for the folder?????

 

only i will be using this tool, its just to save me time. so i don't nee dto wrorry about others using this, it will be restricted to all others....

 

so i don;t need to think about the 2nd part? right?

 

 

 

The purpose to asking for help is not to solve this one problem but to prevent future if you make the mistake now you will surely make it in the future.

You should always verify user input even if its yours by some system.  But you real issue is that folder doesn't have premissions set right

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.