Follow us on Twitter!
One mans freedom fighter, another's terrorist.
Wednesday, April 23, 2014
Navigation
Home
HellBoundHackers Main:
HellBoundHackers Find:
HellBoundHackers Information:
Learn
Communicate
Submit
Shop
Challenges
HellBoundHackers Exploit:
HellBoundHackers Programming:
HellBoundHackers Think:
HellBoundHackers Track:
HellBoundHackers Patch:
HellBoundHackers Other:
HellBoundHackers Need Help?
Other
Members Online
Total Online: 22
Guests Online: 19
Members Online: 3

Registered Members: 82885
Newest Member: ConiBE
Latest Articles
View Thread

HellBound Hackers | Computer General | Programming

Author

PHP Files


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 14-01-09 16:49
Okay, I'm using the following code

Code
if (isset($_GET["url"])){
   $getswf = @fopen($_GET["url"], "r");
   if (! $getswf){
      die("Error: Failed to open the file.\n");
      }
   //$filebuffer = @fread($getswf, filesize($_GET["url"]));
   $filebuffer = fread($getswf, (180542));
   fclose($getswf);
   $a = fopen("test", "w");
   fwrite($a, $filebuffer);
   fclose($a);
   }




and When I check the file "test" it's only 9kb, rather than 177kb like the original.. why is this?
The file's size is deffintely 180542.

Also, filesize($_GET["url"]) failed, and I checked the allow_url_fopen was on.

Thanks for any help.


Author

RE: PHP Files


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 14-01-09 17:29
The original file is 177kb with a lot in it.

The new file (duplicate that the program makes) is 9kb.


Author

RE: PHP Files


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 14-01-09 17:32
lol Yes because the content isn't there.

It basically only takes the first 9kb, or so it seems.


Author

RE: PHP Files


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 14-01-09 17:50
Nope. It's making a duplicate, or at least it's supposed to be.


Author

RE: PHP Files


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 14-01-09 18:14
Have you tried using file_get_contents() instead of fread()?


Author

RE: PHP Files


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 14-01-09 19:07
Worked Smile

Thanks mastergamer


Author

RE: PHP Files

GTADarkDude
Member



Posts: 142
Location: The Netherlands
Joined: 23.02.08
Rank:
Newbie
Posted on 14-01-09 19:47
Might be nice to mention why fread() fails here. PHP.net says:
fread() reads up to length bytes from the file pointer referenced by handle . Reading stops as soon as one of the following conditions is met:

* length bytes have been read
* EOF (end of file) is reached
* a packet becomes available (for network streams)
* 8192 bytes have been read (after opening userspace stream)

Pay attention to the last one. However, you can make a loop which keeps reading 8192 bytes until EOF has been reached. Not that that is a smart thing to do. PHP.net states:
If you just want to get the contents of a file into a string, use file_get_contents() as it has much better performance than the code above.



...
- - -
Author

RE: PHP Files


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 15-01-09 01:00
GTADarkDude wrote:
Might be nice to mention why fread() fails here. PHP.net says:
fread() reads up to length bytes from the file pointer referenced by handle . Reading stops as soon as one of the following conditions is met:

* length bytes have been read
* EOF (end of file) is reached
* a packet becomes available (for network streams)
* 8192 bytes have been read (after opening userspace stream)

Pay attention to the last one. However, you can make a loop which keeps reading 8192 bytes until EOF has been reached. Not that that is a smart thing to do. PHP.net states:
If you just want to get the contents of a file into a string, use file_get_contents() as it has much better performance than the code above.

You, sir, just earned 20 CPs for going above and beyond to resolve a question. Grin