Jump to content

Problem writing to a folder in my server...


Drags111

Recommended Posts

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:

 

layoutst0.png

 

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: [email protected]";

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 [email protected]."; 
mail($_POST['email'], "Account Created!", $body, $headers);
?>

 

Link to comment
https://forums.phpfreaks.com/topic/76883-problem-writing-to-a-folder-in-my-server/
Share on other sites

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";

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.