Drags111 Posted November 11, 2007 Share Posted November 11, 2007 Ok, I have a script thats writes 2 files to 2 different folders in my server. I know that usualy, I can just type the location as folder1/file.txt and it would write to folder1. But heres the layout: I want that php file to write to the folders (Folder1 and Folder2). How would I go about doing this? Heres is the script I use and it doesnt work. <?php $contents = "http://www.gma.asssoft.org/Ids/".$_POST['usr'].".txt"; $contents2 = "http://www.gma.asssoft.org/IdPass/".$_POST['pass'].".txt"; $headers = "From: GraphMasterSupport@gmail.com"; file_put_contents($contents, $_POST['ipa']); echo "Successfuly wrote the file: $contents with the ip of: $_POST[ipa] to the system."; file_put_contents($contents2, $_POST['pass']); echo "\nDone.\nSuccessfuly wrote the file: $contents2 with the password of: $_POST[pass] to the system."; $body = "UserID: $usr\nPass: $_POST[pass]\nIP Address Registered: $_POST[ipa]\nThank you for registering to Graph Master! Please email problems to gmerrors@gmail.com."; mail($_POST['email'], "Account Created!", $body, $headers); ?> Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted November 11, 2007 Share Posted November 11, 2007 int file_put_contents ( string filename, mixed data [, int flags [, resource context]] ) you must use filename, not URL. Quote Link to comment Share on other sites More sharing options...
Daukan Posted November 11, 2007 Share Posted November 11, 2007 You should do some validation and sanitation on the post data if you are going to use it in a file path. Quote Link to comment Share on other sites More sharing options...
Drags111 Posted November 11, 2007 Author Share Posted November 11, 2007 i know but usualy i can do this: folder2/file.txt and it works. I know for a fact it does cuz i use it on my other scripts that are in the main top-most folder. Quote Link to comment Share on other sites More sharing options...
Drags111 Posted November 11, 2007 Author Share Posted November 11, 2007 You should do some validation and sanitation on the data if you are going to use it in a file path. what do you mean? Quote Link to comment Share on other sites More sharing options...
Daukan Posted November 11, 2007 Share Posted November 11, 2007 You have post data in the url. Its possible they could run arbitrary code or at the very least enter characters that could cause internal server errors $contents = "http://www.gma.asssoft.org/Ids/".$_POST['usr'].".txt"; $contents2 = "http://www.gma.asssoft.org/IdPass/".$_POST['pass'].".txt"; Quote Link to comment Share on other sites More sharing options...
Drags111 Posted November 11, 2007 Author Share Posted November 11, 2007 no i dont think thats the case. I have an idea so I'm going to try this one more thing. EDIT: also it would work if i could do something like "go up one level" then it would be in the websitefolder and can navigate down. But i dont think thats possible. EDIT 2: I tried something and got this error: Warning: file_put_contents(gma.asssoft.org/Ids/Test.txt) [function.file-put-contents]: failed to open stream: No such file or directory in /home/.monochrome/drags111/gma.asssoft.org/adminonly/reg235246.php on line 6 So basicly, I do need to go up-one-level in the folders so i could be in the main folder and navigate down. Possible? Quote Link to comment Share on other sites More sharing options...
Drags111 Posted November 11, 2007 Author Share Posted November 11, 2007 yah ive been trying tons of things but i cant get it to work. Quote Link to comment Share on other sites More sharing options...
Drags111 Posted November 11, 2007 Author Share Posted November 11, 2007 so, what? is there nothing i can do? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.