Help with permissions.

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
Rufert
-


Joined: 15 Aug 2005
Posts: 18

PostPosted: Sun Aug 21, 2005 7:29 pm    Post subject: Help with permissions. Reply with quote

I am trying to find if their is a way to change permissions on a windows system. Here is what i have so far...
Code:
<?php
$user="user";
$to="../../user_files/$user";
$ind="../../user_pages/index/index.php";
mkdir("$to");
fopen("$to","r+");
fopen("$ind","r+");
copy($ind,$to);
fclose();
?>

When trying to use it i get an error that says:
Quote:
Warning: fopen(../../user_files/user) [function.fopen]: failed to open stream: Permission denied in C:\Program Files\Abyss Web Server\htdocs\programs\dev\dev.php on line 7

Warning: copy(../../user_files/user) [function.copy]: failed to open stream: Permission denied in C:\Program Files\Abyss Web Server\htdocs\programs\dev\dev.php on line 9


Any ideas? Let me know. It may be something simple that i'm not seeing
Back to top View user's profile Send private message
MonkeyNation
-


Joined: 05 Feb 2005
Posts: 921
Location: Cardiff

PostPosted: Sun Aug 21, 2005 7:33 pm    Post subject: Re: Help with permissions. Reply with quote

Rufert wrote:
I am trying to find if their is a way to change permissions on a windows system. Here is what i have so far...
Code:
<?php
$user="user";
$to="../../user_files/$user";
$ind="../../user_pages/index/index.php";
mkdir("$to");
fopen("$to","r+");
fopen("$ind","r+");
copy($ind,$to);
fclose();
?>

When trying to use it i get an error that says:
Quote:
Warning: fopen(../../user_files/user) [function.fopen]: failed to open stream: Permission denied in C:\Program Files\Abyss Web Server\htdocs\programs\dev\dev.php on line 7

Warning: copy(../../user_files/user) [function.copy]: failed to open stream: Permission denied in C:\Program Files\Abyss Web Server\htdocs\programs\dev\dev.php on line 9


Any ideas? Let me know. It may be something simple that i'm not seeing


Im not sure PHP might not be giving you the wrong error, but its right click -> security in windows for file permissions assuming you have an OS that supports it and have the service that supports it running.
Giving a folder permissions doesnt allways give its subfolders and files permissions on windows too.
It could be that you're using ../../user_files/$user, would ../user_files/$user not work? (I thought ../ would represent the docroot, too lazy to try.)
_________________
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number
Rufert
-


Joined: 15 Aug 2005
Posts: 18

PostPosted: Sun Aug 21, 2005 7:39 pm    Post subject: Reply with quote

Could you explain a little more? I run windows xp home. what should i change?
only one ../ in this case wouldn't work bc it needs to drop back 2 dir's


Last edited by Rufert on Sun Aug 21, 2005 7:47 pm; edited 1 time in total
Back to top View user's profile Send private message
MonkeyNation
-


Joined: 05 Feb 2005
Posts: 921
Location: Cardiff

PostPosted: Sun Aug 21, 2005 7:47 pm    Post subject: Reply with quote

Rufert wrote:
Could you explain a little more? I run windows xp home. what should i change?



^-- From right clicking on a folder, then properties.
Click everyone, then tick every box under allow.
(And yes I was too lazy to thumbnail that screenshot.)

Otherwise try changing the line I mentioned.
_________________
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number
Rufert
-


Joined: 15 Aug 2005
Posts: 18

PostPosted: Sun Aug 21, 2005 7:49 pm    Post subject: Reply with quote

This may be stupid but i dont have a security tab
Quote:
only one ../ in this case wouldn't work bc it needs to drop back 2 dir's
Back to top View user's profile Send private message
MonkeyNation
-


Joined: 05 Feb 2005
Posts: 921
Location: Cardiff

PostPosted: Sun Aug 21, 2005 7:53 pm    Post subject: Reply with quote

Rufert wrote:
This may be stupid but i dont have a security tab


:S
That means you dont have the service running or it doesnt exist on XP home, either way you shouldnt have that error you have.

For debugging purposes, try...
Code:
<?php
$user="user";
$to="../../user_files/".$user;
$ind="../../user_pages/index/index.php";
mkdir($to) or die("Error location: 1");
fopen($to,"r+") or die("Error location: 2");
fopen($ind,"r+") or die("Error location: 3");
copy($ind,$to) or die("Error location: 4");
fclose();
?>

_________________
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number
MonkeyNation
-


Joined: 05 Feb 2005
Posts: 921
Location: Cardiff

PostPosted: Sun Aug 21, 2005 7:54 pm    Post subject: Reply with quote

Rufert wrote:
This may be stupid but i dont have a security tab
Quote:
only one ../ in this case wouldn't work bc it needs to drop back 2 dir's


Yeah, you edited after I posted and I couldnt be arsed to post again, scrap that only one ../ idea.
_________________
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number
Rufert
-


Joined: 15 Aug 2005
Posts: 18

PostPosted: Sun Aug 21, 2005 7:58 pm    Post subject: Reply with quote

Quote:
Warning: fopen(../../user_files/user) [function.fopen]: failed to open stream: Permission denied in C:\Program Files\Abyss Web Server\htdocs\programs\dev\dev2.php on line 6
Error location: 2


That's odd.... Any ideas?

Code:
<?php
$user="user";
$to="../../user_files/".$user;
$ind="../../user_pages/index/index.php";
mkdir($to) or die("Error location: 1");
fopen($to,"r+") or die("Error location: 2");
fopen($ind,"r+") or die("Error location: 3");
copy($ind,$to) or die("Error location: 4");
fclose();
?>
Back to top View user's profile Send private message
MonkeyNation
-


Joined: 05 Feb 2005
Posts: 921
Location: Cardiff

PostPosted: Sun Aug 21, 2005 8:06 pm    Post subject: Reply with quote

Rufert wrote:
Quote:
Warning: fopen(../../user_files/user) [function.fopen]: failed to open stream: Permission denied in C:\Program Files\Abyss Web Server\htdocs\programs\dev\dev2.php on line 6
Error location: 2


That's odd.... Any ideas?

Code:
<?php
$user="user";
$to="../../user_files/".$user;
$ind="../../user_pages/index/index.php";
mkdir($to) or die("Error location: 1");
fopen($to,"r+") or die("Error location: 2");
fopen($ind,"r+") or die("Error location: 3");
copy($ind,$to) or die("Error location: 4");
fclose();
?>


Next try...
Code:
<?php
$user="user";
$to="../../user_files/".$user;
$ind="../../user_pages/index/index.php";
mkdir($to) or die("Error location: 1");
if (file_exists($to)) {
fopen($to,"r+") or die("Error location: 2");
} else {
die("Error location: 5");
}
fopen($ind,"r+") or die("Error location: 3");
copy($ind,$to) or die("Error location: 4");
fclose();
?>

_________________
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number
Rufert
-


Joined: 15 Aug 2005
Posts: 18

PostPosted: Sun Aug 21, 2005 8:10 pm    Post subject: Reply with quote

same error...

Quote:
Warning: fopen(../../user_files/user) [function.fopen]: failed to open stream: Permission denied in C:\Program Files\Abyss Web Server\htdocs\programs\dev\dev2.php on line 7
Error location: 2


Have any more ideas? This is really stupid. Thank you for your help!!
Back to top View user's profile Send private message
Rufert
-


Joined: 15 Aug 2005
Posts: 18

PostPosted: Sun Aug 21, 2005 8:16 pm    Post subject: Reply with quote

What version windows do you run?
Back to top View user's profile Send private message
MonkeyNation
-


Joined: 05 Feb 2005
Posts: 921
Location: Cardiff

PostPosted: Sun Aug 21, 2005 8:28 pm    Post subject: Reply with quote

Rufert wrote:
What version windows do you run?


Sorry, internet cut out for a lil bit then.
XP pro im on, ill try find the service name now for you to try and start.
_________________
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number
Rufert
-


Joined: 15 Aug 2005
Posts: 18

PostPosted: Sun Aug 21, 2005 8:38 pm    Post subject: Reply with quote

Ok, Thanks alot!
Back to top View user's profile Send private message
MonkeyNation
-


Joined: 05 Feb 2005
Posts: 921
Location: Cardiff

PostPosted: Sun Aug 21, 2005 8:39 pm    Post subject: Reply with quote

Rufert wrote:
Ok, Thanks alot!


Well, as far as I knew it was the service entitled "Server", but that isnt started on my machine and I have permissions. Try starting it and see.
_________________
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number
Rufert
-


Joined: 15 Aug 2005
Posts: 18

PostPosted: Sun Aug 21, 2005 8:47 pm    Post subject: Reply with quote

Here's what i'm trying to do, maybe you have a better idea.

When a user signs up their username is sent to the processor page which is the one i'm working on. Then it needs to create a folder with the user's name. Then copy an index page from another directory into the folder just created. I'm up for any ideas. The problem is i need all this to work without me at the computer if you know what i mean. I was wondering if their is a way to copy an entire directory and renameing with the users name to try something diferent becouse the permisions doesnt seem to be working as you see.
Back to top View user's profile Send private message
MonkeyNation
-


Joined: 05 Feb 2005
Posts: 921
Location: Cardiff

PostPosted: Sun Aug 21, 2005 8:54 pm    Post subject: Reply with quote

Rufert wrote:
Here's what i'm trying to do, maybe you have a better idea.

When a user signs up their username is sent to the processor page which is the one i'm working on. Then it needs to create a folder with the user's name. Then copy an index page from another directory into the folder just created. I'm up for any ideas. The problem is i need all this to work without me at the computer if you know what i mean. I was wondering if their is a way to copy an entire directory and renameing with the users name to try something diferent becouse the permisions doesnt seem to be working as you see.


I get you, ill actually do some physical testing to see if that sorta thing works on my system tomrrow, but I just cant be arsed today =/
_________________
Back to top View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number
Rufert
-


Joined: 15 Aug 2005
Posts: 18

PostPosted: Sun Aug 21, 2005 8:58 pm    Post subject: Reply with quote

Ok, thanks. I'll let you know what i find out.
_________________
Back to top View user's profile Send private message
Anonymoose
-


Joined: 09 Sep 2003
Posts: 2192

PostPosted: Sun Aug 21, 2005 11:50 pm    Post subject: Reply with quote

XP Home does not have an accessible security tab, unless you are running as the main Administrator in Safe Mode. This is one of the differences between Home and Pro.
_________________

"Invent an idiot proof webserver and they'll invent a better idiot..."
Back to top View user's profile Send private message
Rufert
-


Joined: 15 Aug 2005
Posts: 18

PostPosted: Mon Aug 22, 2005 1:43 am    Post subject: Reply with quote

Thanks, thats what i figured. I tried to change it in safe mode but when i tried again i still got the same error.
Anyone have any ideas let me know!
_________________
Back to top View user's profile Send private message
Anonymoose
-


Joined: 09 Sep 2003
Posts: 2192

PostPosted: Mon Aug 22, 2005 8:44 am    Post subject: Reply with quote

What exactly are you trying to achieve? I'm no PHP guru, so I can't read your script too well. It may be that the easiest way would be to use system calls to shell out to the attrib DOS/console command if all you're trying to do is change the read only flag, or cacls if you are trying to change detailed security permissions.

Is your drive formatted to FAT32 or NTFS?
_________________

"Invent an idiot proof webserver and they'll invent a better idiot..."
Back to top View user's profile Send private message
Rufert
-


Joined: 15 Aug 2005
Posts: 18

PostPosted: Mon Aug 22, 2005 4:39 pm    Post subject: Reply with quote

Rufert wrote:
Here's what i'm trying to do, maybe you have a better idea.

When a user signs up their username is sent to the processor page which is the one i'm working on. Then it needs to create a folder with the user's name. Then copy an index page from another directory into the folder just created. I'm up for any ideas. The problem is i need all this to work without me at the computer if you know what i mean. I was wondering if their is a way to copy an entire directory and renameing with the users name to try something diferent becouse the permisions doesnt seem to be working as you see.


The problem is is when i try the script i get a permission error. SO... I'm trying to find a way to set the permissions for the directory when or roght after it is created.....Automaticaly

>NTFS<
_________________
Back to top View user's profile Send private message
Anonymoose
-


Joined: 09 Sep 2003
Posts: 2192

PostPosted: Mon Aug 22, 2005 5:10 pm    Post subject: Reply with quote

Looking at line 6 / error 2, isn't your problem that you are trying to open a directory for direct access, rather than a file? There are no file operations which can be performed on a directory, only the contents...
_________________

"Invent an idiot proof webserver and they'll invent a better idiot..."
Back to top View user's profile Send private message
Rufert
-


Joined: 15 Aug 2005
Posts: 18

PostPosted: Mon Aug 22, 2005 5:59 pm    Post subject: Reply with quote

Even without that line i still get a permissions error with the copy:
Code:
Warning: copy(../../user_files/bloo) [function.copy]: failed to open stream: Permission denied in C:\Program Files\Abyss Web Server\htdocs\programs\dev\dev.php on line 7


Code:
<?php
$user="bloo";
$to="../../user_files/$user";
$ind="../../user_pages/index/index.php";
mkdir("$to");
fopen("$ind","r+");
copy($ind,$to);
fclose();
?>

_________________
Back to top View user's profile Send private message
AbyssUnderground
-


Joined: 31 Dec 2004
Posts: 3855

PostPosted: Mon Aug 22, 2005 6:40 pm    Post subject: Reply with quote

Are you sure php isnt in safe mode? this could affect it.
_________________
Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk
Back to top View user's profile Send private message Visit poster's website
Rufert
-


Joined: 15 Aug 2005
Posts: 18

PostPosted: Mon Aug 22, 2005 6:52 pm    Post subject: Reply with quote

I'm not sure how to check for that or change it?
_________________
Back to top View user's profile Send private message
AbyssUnderground
-


Joined: 31 Dec 2004
Posts: 3855

PostPosted: Mon Aug 22, 2005 8:27 pm    Post subject: Reply with quote

find your php.ini its usually in c:\windows\php.ini or c:\php\php.ini in my case. Check for safe mode option and make sure it is false/off/no.
_________________
Andy (AbyssUnderground) (previously The Inquisitor)
www.abyssunderground.co.uk
Back to top View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group