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: 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);
?>

 

Link to comment
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";

Link to comment
Share on other sites

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?

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.