Jump to content

<?php fopen($_GET[‘I am a noob!’], ‘w’); ?>


pedrwvargas

Recommended Posts

Hey guys! I'm new in this community and also new to php.

So I'm building my personal and very unsafe "cloud" and here's the first problem:

 

What I want to do is: when typing http://x.com/docs/?new=file.txt, create a file in that directory (docs/file.txt).

 

Here's my very simple code (docs/index.php):

<?php
fopen($_GET[‘new’], ‘w’);
?>

And here's the error I get:

Warning: fopen(): Filename cannot be empty in /home/u344093746/public_html/p/s/docs/index.php on line 2

I've already changed permissions for the directory docs/

 

Thanks in advance!*

 

*Mind my English, I'm Spanish. Soz if I make you get a lil bit confused...

Link to comment
Share on other sites

“Very unsafe” is an understatement. This is malware. It allows anybody to (over)write arbitrary files at arbitrary locations, because you blindly accept any path. Unless you want to demonstrate how easily bad software can be compromised (which is already well-known), you're doing it wrong.

 

Then your code is full of typographic quotes which PHP cannot process. Appearently you use something like Microsoft Word instead of an actual code editor to write your programs.

Link to comment
Share on other sites

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.