Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Pro PHP
| Search | Today's Posts | Mark Forums Read
Pro PHP Advanced PHP coding discussions. Beginning-level questions will be redirected to the Beginning PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 9th, 2004, 08:25 PM
Friend of Wrox
 
Join Date: Nov 2003
Location: , , .
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default Permissions w/o server

Hello,

I am running PHP5 off the command line on WinXP. I do not have a webserver installed.

Basically what my program does is finds a lot of images from a lot of directories and copies them into one directory. It works, except for the Permission Denied error when I use copy().

I know there have been many permissions questions that are simply solved by sharing the folder on the network, but I've tried it and it doesn't work.

Do I need IIS or Apache (or PWS, etc.)?

Thanks in advanced.

Snib

<><
__________________
-Snib - http://www.snibworks.com
Where will you be in 100 years?
 
Old August 10th, 2004, 06:03 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , United Kingdom.
Posts: 256
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'd check both ends of the chain (i.,e. read permissions where you're reading FROM and write permisssion where you're writing TO). What I mean is, your problems could be caused by not being allowed to read some of these files, rather than write them to your target directory. Not sure about Windows XP's "permissions" policy, but logic dictates taht when you run PHP.exe at the commandline, it runs as you, with whatever file and directory-level privilages you, personally, have. How would having a webserver help ;) (Hell, maybe you need to install photoshop, The GIMP and Quicktime, too - maybe that'll help ;)?

Dan
 
Old August 10th, 2004, 08:44 AM
Friend of Wrox
 
Join Date: Nov 2003
Location: , , .
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Dan,

PHP.exe is running as me (I'm absolutely sure), and I am an administrator. The folder I'm writing to, the folder I'm reading from, and even the PHP directory are all "shared over the network" and "network users are allowed to change my files", as Rich suggested in his permissions FAQ.

Quote:
quote:Hell, maybe you need to install photoshop, The GIMP and Quicktime, too - maybe that'll help
LOL. All the solutions to this I've found always remind people to give IIS (or other server) full read/write/execute permissions. I can't get IIS, and I don't have any other server.

Thanks,

Snib

<><
 
Old August 10th, 2004, 09:05 AM
richard.york's Avatar
Wrox Author
Points: 5,506, Level: 31
Points: 5,506, Level: 31 Points: 5,506, Level: 31 Points: 5,506, Level: 31
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Camby, IN, USA.
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

Right, like Dan said check permissions on both sides.

I've heard that IIs has more explicit permissions policies that allow permissions to be dictated in a similar fashion to Linux. Though, I have XP home, so I don't have it to test on.

So, using the sharing feature isn't the only way AFAIK.

Beyond that there's probably an even more advanced method of permissions setting likely involving registry changes, another avenue I haven't explored.

As I have suspected all along, network sharing is likely a hack. I am convinced there is another way to get it done. Let Google be your guide and report back to us with your findings ;).

Regards,
Rich

--
[http://www.smilingsouls.net]
[http://pear.php.net/Mail_IMAP] A PHP/C-Client/PEAR solution for webmail
 
Old August 10th, 2004, 01:08 PM
Friend of Wrox
 
Join Date: Nov 2003
Location: , , .
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Been Googling for an hour or so and found nothing.

I read the warning PHP was giving me more closely, and it seems that it is being denied the right to write to the destination directory (it is shared over the network).

I have also tried accessing the directory by its network name (\\COMPUTERNAME\folder) as well as the normal name (C:\whatever).

Another thing I have been doing is browsing through the Control Panel looking for any permissions-related options, but I found none.

Thanks,

Snib

<><
 
Old August 10th, 2004, 02:23 PM
richard.york's Avatar
Wrox Author
Points: 5,506, Level: 31
Points: 5,506, Level: 31 Points: 5,506, Level: 31 Points: 5,506, Level: 31
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Camby, IN, USA.
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

I take it then, that you are using IIs??

I found this article..
http://support.microsoft.com/default...b;en-us;816117

As far as running PHP from the command line, I'm not sure how those permissions affect that part of it. I assume that writing has to be done through IIs for that to work. I've always had the most luck enabling both network sharing and the 'let network users change my files' feature. Have you both of these enabled?

Hmmmm, not much luck googling. The consensus that I see is that for most apps there is no need to set any sort of permissions, except in the case of PHP which, just guessing here, must not identify itself as an executable attempting to write a file, but rather a network user attempting to write a file, hence why network sharing allows files to be written.

I am sure there is a way around this though, how else could an app like PEAR be written in PHP and itself create directories and files without having need of setting any permissions? Given that PHP can be used in such a way as to not require any modification of permissions for creating directories, files, etc, at this point I'd take a look at already written applications that do this. Have an in depth look at the go-pear.php file, the php file that installs PEAR, should be in your PHP directory.

Regards,
Rich

--
[http://www.smilingsouls.net]
[http://pear.php.net/Mail_IMAP] A PHP/C-Client/PEAR solution for webmail
 
Old August 10th, 2004, 05:50 PM
Friend of Wrox
 
Join Date: Nov 2003
Location: , , .
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Quote:
quote:Originally posted by richard.york
I take it then, that you are using IIs??
Quote:
quote:Originally posted by Snib
I can't get IIS, and I don't have any other server.
Using WinXP Home.

However, something interesting has happened. I have written a test .php file that looks like this:

<?php

$file = fopen("\\\\COMPUTERNAME\\hard drive\\folder\\something.txt","wb+");
fclose($file);

?>

The strange thing is, it works.

Any thoughts?

Snib

<><
 
Old August 10th, 2004, 06:58 PM
Friend of Wrox
 
Join Date: Nov 2003
Location: , , .
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Problem solved using an alternative to copy():

$file = fopen("\\\\COMPUTERNAME\\hard drive\\folder\\to.txt","wb+");

fclose($file);

$file = fopen("\\\\COMPUTERNAME\\hard drive\\folder\\from.txt","r");

$sContents = fread($file,filesize("\\\\COMPUTERNAME\\hard drive\\folder\\from.txt"));

fclose($file);

file_put_contents("\\\\COMPUTERNAME\\hard drive\\folder\\to.txt",$sContents);

It may be slower, but it works and I'm not copying more than a few files.

Comments welcome.

Thanks for the help.

Snib

<><
 
Old August 10th, 2004, 10:53 PM
richard.york's Avatar
Wrox Author
Points: 5,506, Level: 31
Points: 5,506, Level: 31 Points: 5,506, Level: 31 Points: 5,506, Level: 31
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Camby, IN, USA.
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

I wouldn't lose any sleep over not having IIs :).

Were you able to do that without network sharing and all that business? I doubt it's any slower. You're taking extra steps with creating a file handle, but for what you're using it for it sounds fine to me. What is this? A bot?

This is a little cleaner..
Code:
file_put_contents("\\\\COMPUTERNAME\\hard drive\\folder\\to.txt", file_get_contents("\\\\COMPUTERNAME\\hard drive\\folder\\from.txt"));
...or do you have to create the empty file for writing first? From the looks of the manual entry you shouldn't have to create the handle first.

Regards,
Rich

--
[http://www.smilingsouls.net]
[http://pear.php.net/Mail_IMAP] A PHP/C-Client/PEAR solution for webmail
 
Old August 11th, 2004, 06:37 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , United Kingdom.
Posts: 256
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Not having IIS is a bit like not having genital herpes.

You can get IIS to run on XP Home edition, if you really want to, though:
http://groups.google.com/groups?selm...8663173%40news

To quote Redmond, however:

"Windows XP Home Edition does not include or support any
versions (1.0, 2.0, 4.0) of Microsoft Personal Web Server
(PWS). Users that need Web server functionality in a
desktop operating system should use Windows XP Professional."




Similar Threads
Thread Thread Starter Forum Replies Last Post
Setting SQL Server 2000 access permissions / Syste snejsnej SQL Server 2000 1 May 18th, 2006 08:10 AM
VB script permissions on server 2003/IIS sjso VB How-To 0 July 13th, 2005 09:30 AM
Permissions for Web app. files on Web server Jan_Ma Classic ASP Basics 0 June 28th, 2003 02:06 PM
Permissions for Web app. files on server Jan_Ma All Other Wrox Books 0 June 28th, 2003 02:02 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.