Follow us on Twitter!
Society leans ever heavily on computers, if you have the power to take out computers you can take out society. - cubeman372
Monday, April 21, 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: 27
Guests Online: 24
Members Online: 3

Registered Members: 82855
Newest Member: icepeter
Latest Articles
View Thread

HellBound Hackers | Computer General | Programming

Author

PHP error

t0xikc0mputer
Member



Posts: 112
Location: t0xik waste dump
Joined: 07.01.11
Rank:
Newbie
Posted on 11-02-11 01:18
Hello all,

First off, before anything pertaining to this topic, I do, in fact know that there was an article posted by techb with the exact same title. I do not care, it is a PHP error, and so that shall be the title.

Now for the real problem:

I was dickin around with php and was experimenting with the

Code
$ip = $_SERVER['REMOTE_ADDR'];




thing. I put some code up on my website

Code
<?php
$date = date("d-m-y / H:i:s");
$ip = $_SERVER['REMOTE_ADDR'];
$file = fopen("logs.txt", "a+");
$text = $date."<br />".$ip."<br />---<br /><br />";
fwrite($file, $text);
fclose($file);
?>




to try and (as a test) track the ips of the visitors. (Just for experimental, and educational purposes of course) ;) I expected it to work, because that syntax, is (as far as I know) to the letter from w3schools. Now I know they don't have the best PHP tutorials in the world, but I at least expect their syntax to be correct. The problem is that it came up with the below error:

Warning: fopen(logs.txt) [function.fopen]: failed to open stream: Permission denied in ****************


and then


Warning: fwrite(): supplied argument is not a valid stream resource in ****************


Warning: fclose(): supplied argument is not a valid stream resource in ****************


Now, as far as I know, the second two errors were caused by the first error, and I believe that if the first one were fixed the other two would go away. Also, this script was supposed to create a 'logs.txt' file, as there was no existing one. (although I am pretty sure that pre-creating one would not solve the problem)

I use 000webhost.com, any idea why this might happen, and how to fix it?

Thanks,

t0xik

Also, for ynori7's sake, I did google it to see what I could find out, but nothing helpful came up.




Edited by t0xikc0mputer on 11-02-11 01:31
Author

RE: PHP error


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 11-02-11 01:25
t0xikc0mputer wrote:
Now, as far as I know, the second two errors were caused by the first error

No, they came to be because you supplied $fopen instead of $file.


Author

RE: PHP error

t0xikc0mputer
Member



Posts: 112
Location: t0xik waste dump
Joined: 07.01.11
Rank:
Newbie
Posted on 11-02-11 01:29
COM wrote:
t0xikc0mputer wrote:
Now, as far as I know, the second two errors were caused by the first error

No, they came to be because you supplied $fopen instead of $file.


Fixed it and it still comes up with same error.




Edited by t0xikc0mputer on 11-02-11 01:31
Author

RE: PHP error


Member

Your avatar

Posts:
Location:
Joined: 01.01.70
Rank:
Guest
Posted on 11-02-11 01:34
t0xikc0mputer wrote:
fixed and it still comes up with same error.

Of course it does, you never got a valid stream resource since you couldn't open the file for writing and didn't have any error checking to not try to write to it in such a case.
Just set the permissions of whatever directory you're in so that you can write to it. And also, if you're going to write that much code for something like that, at least throw some error checking in the script.


Author

RE: PHP error

t0xikc0mputer
Member



Posts: 112
Location: t0xik waste dump
Joined: 07.01.11
Rank:
Newbie
Posted on 11-02-11 01:56
COM wrote:
t0xikc0mputer wrote:
fixed and it still comes up with same error.

Of course it does, you never got a valid stream resource since you couldn't open the file for writing and didn't have any error checking to not try to write to it in such a case.
Just set the permissions of whatever directory you're in so that you can write to it. And also, if you're going to write that much code for something like that, at least throw some error checking in the script.


I don't really need error checking, I am just fooling around, but if I was using this for real, I would. The errors are all gone, as I have modded the public directory to 777, but when I check the logs.txt file, it appears blank.

EDIT: Now, I have tried to mod the logs.txt file itself to 777, but it says
Could not change perms: operation not permitted





Edited by t0xikc0mputer on 11-02-11 02:00
Author

RE: PHP error

GTADarkDude
Member



Posts: 142
Location: The Netherlands
Joined: 23.02.08
Rank:
Newbie
Posted on 12-02-11 13:00
Just try "chmod o+w ./log.txt"

You should never want to chmod anything to xx7 anyway. Read up about *nix file permissions. ( http://en.wikipedia.org/wiki/Filesystem_permissions )


...
- - -