Re: [PHP] unlink()?
I think it's more likely that a security flaw might be found which allows code other than yours to run. Buffer overflows were notorious for this, as they had the side-effect of running whatever ran outside of their buffer range, so you could in effect get a system with an overflow hole to run whatever code you wanted. Usually a problem like this would be limited to a specific function, but if someone was able to guess correctly that you were using this function then they could potentially form code that exploited it. I'm not an expert on this sort of thing, so what I've just said is how I roughly understand one aspect of the problem. Thanks, Ash Ash: Good enough. Thanks, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] unlink()?
On Sun, 2010-06-06 at 14:08 -0400, tedd wrote: > At 1:02 AM +0100 6/6/10, Ashley Sheridan wrote: > >>On Sat, 2010-06-05 at 18:55 -0400, tedd wrote: > >> > >>Hi gang: > >> > >>Never-mind. > >> > >>I didn't change the parent directory permissions to unlink the file -- duh! > >> > >>tedd > > > >I was just about to mention this! It's one of the bizarre security > >loopholes in Linux. If you have write permissions to a directory but > >not a file within it, you can still delete the file. I believe you > >can change this behaviour with filesystem security mods, but I've > >not tried that. > > > >Ash > > Yes, I've seen where you can delete files within a directory by > changing the directory permissions. > > It's not often that my scripts create/delete files on the server -- > so I'm not up on it as much as I probably should be. > > However to me, it seems overly cautious to require scripts -- that > are already running on the server -- to have the authority (ftp id > and password) to create/delete files. After all, the scripts would > not be there if the person who placed them there didn't have > authority to create and delete files. So, I have to wonder under what > scenario would evil scripts be found/run on the server? > > For example, if anyone was going to create an evil script and place > it on the server, they must have the authority to do that. And if > they had that authority, then they could just as easily add that to > their script and side-step this requirement, right? So, what's the > purpose? > > Cheers, > > tedd > > -- > --- > http://sperling.com http://ancientstones.com http://earthstones.com > I think it's more likely that a security flaw might be found which allows code other than yours to run. Buffer overflows were notorious for this, as they had the side-effect of running whatever ran outside of their buffer range, so you could in effect get a system with an overflow hole to run whatever code you wanted. Usually a problem like this would be limited to a specific function, but if someone was able to guess correctly that you were using this function then they could potentially form code that exploited it. I'm not an expert on this sort of thing, so what I've just said is how I roughly understand one aspect of the problem. Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] unlink()?
At 1:02 AM +0100 6/6/10, Ashley Sheridan wrote: On Sat, 2010-06-05 at 18:55 -0400, tedd wrote: Hi gang: Never-mind. I didn't change the parent directory permissions to unlink the file -- duh! tedd I was just about to mention this! It's one of the bizarre security loopholes in Linux. If you have write permissions to a directory but not a file within it, you can still delete the file. I believe you can change this behaviour with filesystem security mods, but I've not tried that. Ash Yes, I've seen where you can delete files within a directory by changing the directory permissions. It's not often that my scripts create/delete files on the server -- so I'm not up on it as much as I probably should be. However to me, it seems overly cautious to require scripts -- that are already running on the server -- to have the authority (ftp id and password) to create/delete files. After all, the scripts would not be there if the person who placed them there didn't have authority to create and delete files. So, I have to wonder under what scenario would evil scripts be found/run on the server? For example, if anyone was going to create an evil script and place it on the server, they must have the authority to do that. And if they had that authority, then they could just as easily add that to their script and side-step this requirement, right? So, what's the purpose? Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] unlink()?
On Sat, 2010-06-05 at 18:55 -0400, tedd wrote: > Hi gang: > > Never-mind. > > I didn't change the parent directory permissions to unlink the file -- duh! > > Cheers, > > tedd > > --- I asked: > > Hi gang: > > I use unlink() to delete files on my server by using the statement: > > unlink($filename); > > where $filename is the physical path to the file plus file name, such as: > > $filename = '/var/www/vhosts/domain.com/httpdocs/a-dir/a-text.txt'; > > Now, I can read, write, and even create the file -- so I have the > path and permissions correct. But if I unlink() the file and then > examine the contents of the parent directory afterwards, I find the > file remains -- what's up with that? > > This reminds me of the process of deleting files on your local hard > disk, which basically sets the disk-space allocated to the file as > "available for writing" without actually deleting the file. > > So what am I not understanding here? > > Cheers, > > tedd > > -- > --- > http://sperling.com http://ancientstones.com http://earthstones.com > I was just about to mention this! It's one of the bizarre security loopholes in Linux. If you have write permissions to a directory but not a file within it, you can still delete the file. I believe you can change this behaviour with filesystem security mods, but I've not tried that. Thanks, Ash http://www.ashleysheridan.co.uk
[PHP] unlink()?
Hi gang: Never-mind. I didn't change the parent directory permissions to unlink the file -- duh! Cheers, tedd --- I asked: Hi gang: I use unlink() to delete files on my server by using the statement: unlink($filename); where $filename is the physical path to the file plus file name, such as: $filename = '/var/www/vhosts/domain.com/httpdocs/a-dir/a-text.txt'; Now, I can read, write, and even create the file -- so I have the path and permissions correct. But if I unlink() the file and then examine the contents of the parent directory afterwards, I find the file remains -- what's up with that? This reminds me of the process of deleting files on your local hard disk, which basically sets the disk-space allocated to the file as "available for writing" without actually deleting the file. So what am I not understanding here? Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] unlink()?
On 5 June 2010 23:45, tedd wrote: > Hi gang: > > I use unlink() to delete files on my server by using the statement: > > unlink($filename); > > where $filename is the physical path to the file plus file name, such as: > > $filename = '/var/www/vhosts/domain.com/httpdocs/a-dir/a-text.txt'; > > Now, I can read, write, and even create the file -- so I have the path and > permissions correct. But if I unlink() the file and then examine the > contents of the parent directory afterwards, I find the file remains -- > what's up with that? > > This reminds me of the process of deleting files on your local hard disk, > which basically sets the disk-space allocated to the file as "available for > writing" without actually deleting the file. > > So what am I not understanding here? > > Cheers, > > tedd > > -- > --- > http://sperling.com http://ancientstones.com http://earthstones.com > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > What is the result of the unlink()? Enable errors/warnings. -- - Richard Quadling "Standing on the shoulders of some very clever giants!" EE : http://www.experts-exchange.com/M_248814.html EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 ZOPA : http://uk.zopa.com/member/RQuadling -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] unlink()?
Hi gang: I use unlink() to delete files on my server by using the statement: unlink($filename); where $filename is the physical path to the file plus file name, such as: $filename = '/var/www/vhosts/domain.com/httpdocs/a-dir/a-text.txt'; Now, I can read, write, and even create the file -- so I have the path and permissions correct. But if I unlink() the file and then examine the contents of the parent directory afterwards, I find the file remains -- what's up with that? This reminds me of the process of deleting files on your local hard disk, which basically sets the disk-space allocated to the file as "available for writing" without actually deleting the file. So what am I not understanding here? Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] unlink file rights problem
Hi there, I am trying to unlink a file which is inside a folder that is not writable to phps user "www". Of course this failes, but I need to find a solution for it. Backgroud is following: I have pure-ftpd installed where user directories get created by pure-ftpd. Unfortunatelly there seems to be a bug and pure-ftpd does only create the homedirectory folder in 750 mod. My PHP-Script scans this directories every x minutes and processes those files. Upon completinon those files should get deleted, but as the dir is not writable by the user www this failes. The dir looks like this: drwxr-x--- 2 ftpuser ftpgroup 4096 Jan 28 10:18 merlin/ files inside look like this: -rwxrwx--- 1 ftpuser ftpgroup 16868 Jan 28 10:20 test.xml* User www which executes php via cron is inside the group "ftpgroup". Any ideas? I am kind of lost with this one. Thank you for any help! Best regards, Merlin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP unlink Permission Error
On Wed, 2009-01-14 at 07:48 -0500, Alice Wei wrote: > > > Subject: RE: [PHP] PHP unlink Permission Error > > From: a...@ashleysheridan.co.uk > > To: aj...@alumni.iu.edu > > CC: php-general@lists.php.net > > Date: Tue, 13 Jan 2009 17:07:34 + > > > > On Tue, 2009-01-13 at 11:49 -0500, Alice Wei wrote: > > > > > > > > > > > > > Subject: RE: [PHP] PHP unlink Permission Error > > > > From: a...@ashleysheridan.co.uk > > > > To: aj...@alumni.iu.edu > > > > CC: php-general@lists.php.net > > > > Date: Tue, 13 Jan 2009 16:50:31 + > > > > > > > > On Tue, 2009-01-13 at 11:33 -0500, Alice Wei wrote: > > > > > Hi, Ashley: > > > > > > > > > > Sorry. To answer the question from your previous entry, it > looks > > > > > like that my permission could be set and changed for the > folder, > > > but > > > > > when I do it on the "file", I only get 0666. I have the latest > > > code on > > > > > another entry. > > > > > > > > > > Thanks a lot for your help. > > > > > > > > > > Alice > > > > > > > > > > > > > > > > > > > > > > > > > Alice Wei > > > > > > > > > > Indiana University, Master of Information Science > > > > > > > > > > Application Programmer > > > > > ProCure Treatment Centers, Inc. > > > > > 420 N. Walnut St. > > > > > Bloomington, IN 47404 > > > > > > > > > > 812-330-6644 (office) > > > > > 812-219-5708 (mobile) > > > > > > > > > > alice@procurecenters.com(email) > > > > > http://www.procurecenters.com/index.php (web) > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > __ > > > > > Subject: RE: [PHP] PHP unlink Permission Error > > > > > From: a...@ashleysheridan.co.uk > > > > > To: aj...@alumni.iu.edu > > > > > CC: php-general@lists.php.net > > > > > Date: Tue, 13 Jan 2009 16:36:36 + > > > > > > > > > > > > > > > > > > > > No, we tend to bottom-post on this list. It's just how we > roll... > > > > > > > > > > > > > > > Ash > > > > > www.ashleysheridan.co.uk > > > > > > > > > > > > > > > > > > > __ > > > > > Check the weather nationwide with MSN Search Try it now! > > > > > > > > The user that your web server is running under (I'm guessing > apache > > > of > > > > wwwrun) , does this have permission to write to the file. If > not, it > > > > won't be able to set the permissions for it. You may need to > exec > > > out a > > > > sudo command to do it, but I wouldn't recommend this. > > > > > > > > If you need PHP to be able to delete the file, what put it there > in > > > the > > > > first place? > > > > > > > > > > > > Ash > > > > www.ashleysheridan.co.uk > > > > > > > > > > What I am trying to do here is that a user would be pushing a > button > > > so that the data entries would generate an outfile. The only issue > is > > > that the lines would be appended in the file, (I have no issues > with > > > this part writing to the file, no permission errors, etc). > Therefore, > > > before the outfile is generated, I need to have the prexisting > outfile > > > removed and recreated to be written to so that it always stays a > new > > > file for use. > > > > > > This is why this script as you have seen is as it is so that I can > > > constantly check if the file exists, and generate a new file if > there > > > is. > > > In this case, is there something I could do? > > > > > > > > > Thanks in advance. > > > > > > Alice > > > > > > > > > > > > > > > > __
RE: [PHP] PHP unlink Permission Error
> Subject: RE: [PHP] PHP unlink Permission Error> From: > a...@ashleysheridan.co.uk> To: aj...@alumni.iu.edu> CC: > php-general@lists.php.net> Date: Tue, 13 Jan 2009 17:07:34 +> > On Tue, > 2009-01-13 at 11:49 -0500, Alice Wei wrote:> > > > > > > > > Subject: RE: > [PHP] PHP unlink Permission Error> > > From: a...@ashleysheridan.co.uk> > > > To: aj...@alumni.iu.edu> > > CC: php-general@lists.php.net> > > Date: Tue, 13 > Jan 2009 16:50:31 +> > > > > > On Tue, 2009-01-13 at 11:33 -0500, Alice > Wei wrote:> > > > Hi, Ashley:> > > > > > > > Sorry. To answer the question > from your previous entry, it looks> > > > like that my permission could be > set and changed for the folder,> > but> > > > when I do it on the "file", I > only get 0666. I have the latest> > code on> > > > another entry. > > > > > > > > > Thanks a lot for your help.> > > > > > > > Alice> > > > > > > > > > > > > > > > > > > > > Alice Wei> > > > > > > > Indiana University, Master of > Information Science> > > > > > > > Application Programmer > > > > ProCure > Treatment Centers, Inc.> > > > 420 N. Walnut St.> > > > Bloomington, IN > 47404> > > > > > > > 812-330-6644 (office)> > > > 812-219-5708 (mobile)> > > > > > > > > alice@procurecenters.com(email)> > > > > http://www.procurecenters.com/index.php (web) > > > > > > > > > > > > > > > > > > > > > > > > > > > > >> > > __> > > > > Subject: RE: [PHP] PHP unlink Permission Error> > > > From: > a...@ashleysheridan.co.uk> > > > To: aj...@alumni.iu.edu> > > > CC: > php-general@lists.php.net> > > > Date: Tue, 13 Jan 2009 16:36:36 +> > > > > > > > > > > > > > > > > No, we tend to bottom-post on this list. It's > just how we roll...> > > > > > > > > > > > Ash> > > > > www.ashleysheridan.co.uk > > > > > > > > > > > >> > > __> > > > > Check the weather nationwide with MSN Search Try it now!> > > > > > The user > that your web server is running under (I'm guessing apache> > of> > > wwwrun) > , does this have permission to write to the file. If not, it> > > won't be > able to set the permissions for it. You may need to exec> > out a> > > sudo > command to do it, but I wouldn't recommend this.> > > > > > If you need PHP > to be able to delete the file, what put it there in> > the> > > first place?> > > > > > > > > > Ash> > > www.ashleysheridan.co.uk> > > > > > > What I am > trying to do here is that a user would be pushing a button> > so that the > data entries would generate an outfile. The only issue is> > that the lines > would be appended in the file, (I have no issues with> > this part writing to > the file, no permission errors, etc). Therefore,> > before the outfile is > generated, I need to have the prexisting outfile> > removed and recreated to > be written to so that it always stays a new> > file for use. > > > > This is > why this script as you have seen is as it is so that I can> > constantly > check if the file exists, and generate a new file if there> > is. > > In this > case, is there something I could do?> > > > > > Thanks in advance.> > > > > Alice> > > > > > > > > > > __> > > All-in-one security and maintenance for your PC. Get a free 90-day> > trial! > Learn more!> > If your script is writing to the file, and the directory has > 777> permissions, then there should be no trouble deleting the file. If> > that's still a problem, why not each time the file needs to be created> anew, > open the file with a w flag, which will open it for writing, and> will try to > create the file if it doesn't already exist, so you wouldn't> ever need to > delete it at all.> > > Ash> www.ashleysheridan.co.uk> Hi, It is weird, because what is on my code for appending and writing looks like this: $myFile = "testFile.txt"; $fh = fopen($myFile, 'a'); fwrite($fh, $hello); fwrite($fh, "\r\n"); fclose($fh); The file itself gets executed continuously based on the number I have on the loop. And, my file for creating the file, I have shortened it to only 2 lines: $handle = fopen("testFile.txt", "w"); fclose($handle); What is interesting is that the files seem to be working, but the file keeps on getting appended rather than recreated when the my code to "w" the file get executed. I am using this with Actionscript, which calls the first function to open and write the file (or clean up the file), and then do whatever is needed in the second function to append the text to the file. Am I doing anything wrong here? Thanks in advance. _ Use Messenger to talk to your IM friends, even those on Yahoo! http://ideas.live.com/programpage.aspx?versionId=7adb59de-a857-45ba-81cc-685ee3e858fe
Re: [PHP] PHP unlink Permission Error
Alice, I see that you are using windows. For windows only the write permission for the folder and file isn't enough. You need to change the owner ship of the file as well so that u have privilege to delete. Do this , this might work: //Change the owner ship of the file to a non existent user in the system chown($directory."/".$file,666); unlink($directory."/".$file); Thanks, V
RE: [PHP] PHP unlink Permission Error
On Tue, 2009-01-13 at 11:49 -0500, Alice Wei wrote: > > > > > Subject: RE: [PHP] PHP unlink Permission Error > > From: a...@ashleysheridan.co.uk > > To: aj...@alumni.iu.edu > > CC: php-general@lists.php.net > > Date: Tue, 13 Jan 2009 16:50:31 + > > > > On Tue, 2009-01-13 at 11:33 -0500, Alice Wei wrote: > > > Hi, Ashley: > > > > > > Sorry. To answer the question from your previous entry, it looks > > > like that my permission could be set and changed for the folder, > but > > > when I do it on the "file", I only get 0666. I have the latest > code on > > > another entry. > > > > > > Thanks a lot for your help. > > > > > > Alice > > > > > > > > > > > > > > > Alice Wei > > > > > > Indiana University, Master of Information Science > > > > > > Application Programmer > > > ProCure Treatment Centers, Inc. > > > 420 N. Walnut St. > > > Bloomington, IN 47404 > > > > > > 812-330-6644 (office) > > > 812-219-5708 (mobile) > > > > > > alice@procurecenters.com(email) > > > http://www.procurecenters.com/index.php (web) > > > > > > > > > > > > > > > > > > > > > > __ > > > Subject: RE: [PHP] PHP unlink Permission Error > > > From: a...@ashleysheridan.co.uk > > > To: aj...@alumni.iu.edu > > > CC: php-general@lists.php.net > > > Date: Tue, 13 Jan 2009 16:36:36 + > > > > > > > > > > > > No, we tend to bottom-post on this list. It's just how we roll... > > > > > > > > > Ash > > > www.ashleysheridan.co.uk > > > > > > > > > > __ > > > Check the weather nationwide with MSN Search Try it now! > > > > The user that your web server is running under (I'm guessing apache > of > > wwwrun) , does this have permission to write to the file. If not, it > > won't be able to set the permissions for it. You may need to exec > out a > > sudo command to do it, but I wouldn't recommend this. > > > > If you need PHP to be able to delete the file, what put it there in > the > > first place? > > > > > > Ash > > www.ashleysheridan.co.uk > > > > What I am trying to do here is that a user would be pushing a button > so that the data entries would generate an outfile. The only issue is > that the lines would be appended in the file, (I have no issues with > this part writing to the file, no permission errors, etc). Therefore, > before the outfile is generated, I need to have the prexisting outfile > removed and recreated to be written to so that it always stays a new > file for use. > > This is why this script as you have seen is as it is so that I can > constantly check if the file exists, and generate a new file if there > is. > In this case, is there something I could do? > > > Thanks in advance. > > Alice > > > > > __ > All-in-one security and maintenance for your PC. Get a free 90-day > trial! Learn more! If your script is writing to the file, and the directory has 777 permissions, then there should be no trouble deleting the file. If that's still a problem, why not each time the file needs to be created anew, open the file with a w flag, which will open it for writing, and will try to create the file if it doesn't already exist, so you wouldn't ever need to delete it at all. Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP unlink Permission Error
> Subject: RE: [PHP] PHP unlink Permission Error> From: > a...@ashleysheridan.co.uk> To: aj...@alumni.iu.edu> CC: > php-general@lists.php.net> Date: Tue, 13 Jan 2009 16:50:31 +> > On Tue, > 2009-01-13 at 11:33 -0500, Alice Wei wrote:> > Hi, Ashley:> > > > Sorry. To > answer the question from your previous entry, it looks> > like that my > permission could be set and changed for the folder, but> > when I do it on > the "file", I only get 0666. I have the latest code on> > another entry. > > > > > Thanks a lot for your help.> > > > Alice> > > > > > > > > > Alice Wei> > > > > Indiana University, Master of Information Science> > > > Application > Programmer > > ProCure Treatment Centers, Inc.> > 420 N. Walnut St.> > > Bloomington, IN 47404> > > > 812-330-6644 (office)> > 812-219-5708 (mobile)> > > > > alice@procurecenters.com(email)> > > http://www.procurecenters.com/index.php (web) > > > > > > > > > > > > > > > __> > > Subject: RE: [PHP] PHP unlink Permission Error> > From: > a...@ashleysheridan.co.uk> > To: aj...@alumni.iu.edu> > CC: > php-general@lists.php.net> > Date: Tue, 13 Jan 2009 16:36:36 +> > > > > > > > > No, we tend to bottom-post on this list. It's just how we > roll...> > > > > > Ash> > www.ashleysheridan.co.uk > > > > > > > __> > > Check the weather nationwide with MSN Search Try it now!> > The user that > your web server is running under (I'm guessing apache of> wwwrun) , does this > have permission to write to the file. If not, it> won't be able to set the > permissions for it. You may need to exec out a> sudo command to do it, but I > wouldn't recommend this.> > If you need PHP to be able to delete the file, > what put it there in the> first place?> > > Ash> www.ashleysheridan.co.uk> What I am trying to do here is that a user would be pushing a button so that the data entries would generate an outfile. The only issue is that the lines would be appended in the file, (I have no issues with this part writing to the file, no permission errors, etc). Therefore, before the outfile is generated, I need to have the prexisting outfile removed and recreated to be written to so that it always stays a new file for use. This is why this script as you have seen is as it is so that I can constantly check if the file exists, and generate a new file if there is. In this case, is there something I could do? Thanks in advance. Alice _ All-in-one security and maintenance for your PC. Get a free 90-day trial! http://www.windowsonecare.com/purchase/trial.aspx?sc_cid=wl_wlmail
RE: [PHP] PHP unlink Permission Error
On Tue, 2009-01-13 at 11:33 -0500, Alice Wei wrote: > Hi, Ashley: > > Sorry. To answer the question from your previous entry, it looks > like that my permission could be set and changed for the folder, but > when I do it on the "file", I only get 0666. I have the latest code on > another entry. > > Thanks a lot for your help. > > Alice > > > > > Alice Wei > > Indiana University, Master of Information Science > > Application Programmer > ProCure Treatment Centers, Inc. > 420 N. Walnut St. > Bloomington, IN 47404 > > 812-330-6644 (office) > 812-219-5708 (mobile) > > alice@procurecenters.com(email) > http://www.procurecenters.com/index.php (web) > > > > > > > __ > Subject: RE: [PHP] PHP unlink Permission Error > From: a...@ashleysheridan.co.uk > To: aj...@alumni.iu.edu > CC: php-general@lists.php.net > Date: Tue, 13 Jan 2009 16:36:36 + > > > > No, we tend to bottom-post on this list. It's just how we roll... > > > Ash > www.ashleysheridan.co.uk > > > __ > Check the weather nationwide with MSN Search Try it now! The user that your web server is running under (I'm guessing apache of wwwrun) , does this have permission to write to the file. If not, it won't be able to set the permissions for it. You may need to exec out a sudo command to do it, but I wouldn't recommend this. If you need PHP to be able to delete the file, what put it there in the first place? Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP unlink Permission Error
touch foo.txt chmod 000 foo.txt rm foo.txt rm: remove write-protected regular empty file `foo.txt'? So the behaviour is at least partially shell/profile dependent... I have no idea how this would affect PHP unlink, if at all. ymmv naiaa ianasg [*] [*] sg: shell guru -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP unlink Permission Error
Hi, Ashley: Sorry. To answer the question from your previous entry, it looks like that my permission could be set and changed for the folder, but when I do it on the "file", I only get 0666. I have the latest code on another entry. Thanks a lot for your help. Alice Alice Wei Indiana University, Master of Information Science Application Programmer ProCure Treatment Centers, Inc.420 N. Walnut St.Bloomington, IN 47404812-330-6644 (office)812-219-5708 (mobile)alice@procurecenters.com(email)http://www.procurecenters.com/index.php (web) Subject: RE: [PHP] PHP unlink Permission ErrorFrom: a...@ashleysheridan.co.ukto: aj...@alumni.iu.educc: php-gene...@lists.php.netdate: Tue, 13 Jan 2009 16:36:36 +No, we tend to bottom-post on this list. It's just how we roll... Ashwww.ashleysheridan.co.uk _ Check the weather nationwide with MSN Search: Try it now! http://search.msn.com/results.aspx?q=weather&FORM=WLMTAG
Re: [PHP] PHP unlink Permission Error
On Tue, 2009-01-13 at 15:46 +, c...@l-i-e.com wrote: > Not only do you need to check the return value of chmod to see if it worked, > but also, I *think*: > > > > The file withing the directory can have entirely different permissions, and > making the directory world writable won't help that, I don't think... > > > > I could be wrong, and a 000 file in a 777 dir might be unlink-able. You can > test for yourself in a shell as fast as I can. :-) > > > On *nix systems, I believe you only need write permissions to the directory in order to delete files. Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP unlink Permission Error
No, we tend to bottom-post on this list. It's just how we roll... Ash www.ashleysheridan.co.uk
RE: [PHP] PHP unlink Errors
Hi, Apparently my safe mode is off. I tried fiddling with my code by changing the permission of my intended to delete file as in the following: This is the output I get 07770666You don't have the permission I don't get a failure statement in the line: chmod ($fileToRemove, 0777) or die ("permission canonot be set");, how come the permission of this file is still 0666? Thanks in advance. Alice > Date: Tue, 13 Jan 2009 17:06:37 +0100> From: li...@bithub.net> To: > aj...@alumni.iu.edu> CC: php-general@lists.php.net> Subject: Re: [PHP] PHP > unlink Errors> > Do you have php_safe_mode enabled? If's that's the case, try > turning it > off and then run your script again.> Alice Wei wrote:> > Hi, > > > > > I have a snippet below that I would like to delete a file. However, I > keep getting kicked out because of permission errors, when my folder > permission is 0777. > > > > > > > ini_set('display_errors', 1); > error_reporting(E_ALL);> > $curDir = getcwd();> > chmod($curDir,0777) or die > ("Failed to change permission");> > echo substr(sprintf('%o', > fileperms($curDir)), -4); > > > unlink("C:/Inetpub\wwwroot/project/testFile.txt");> > echo > unlink("C:/Inetpub/wwwroot/pproject/testFile.txt"); > > > > ?> > > > > Is it > possible that someone on the list could point out what my possible errors are > to allow this code to be functioning? > > > > Here is the output:> > > > > 0777Warning: unlink(C:/Inetpub\wwwroot/project/testFile.txt) > [function.unlink]: Permission denied in > C:\Inetpub\wwwroot\project\file_write.php on line 9Warning: > unlink(C:/Inetpub/wwwroot/project/testFile.txt) [function.unlink]: Permission > denied in C:\Inetpub\wwwroot\project\file_write.php on line 10> > > > Thanks > in advance. > > > > Alice> > > _> > > All-in-one security and maintenance for your PC. Get a free 90-day trial!> > > http://www.windowsonecare.com/purchase/trial.aspx?sc_cid=wl_wlmail> > > --> > http://bithub.net/> Synchronize, share and backup your files over the web for > free> > http://twitter.com/MarcSteinert> My Twitter feed> ** _ Search from any Web page with powerful protection. Get the FREE Windows Live Toolbar Today! http://get.live.com/toolbar/overview
Re: [PHP] PHP unlink Permission Error
Alice Wei wrote: > Hi, Ashley: > > I thought about it and edited my script to check what permission I had, and > it appears I do have the permission rights, and it actually changed to 0777. > Here is the code: > > ini_set('display_errors', 1); error_reporting(E_ALL); > $curDir = getcwd(); > chmod($curDir,0777) or die ("Failed to change permission"); > echo substr(sprintf('%o', fileperms($curDir)), -4); > unlink("testFile.txt"); > echo unlink("testFile.txt"); > > ?> > > The output: > > 0777Warning: unlink(testFile.txt) [function.unlink]: Permission denied in > C:\Inetpub\wwwroot\project\file_write.php on line 10Warning: > unlink(testFile.txt) [function.unlink]: Permission denied in > C:\Inetpub\wwwroot\project\file_write.php n line 11If this is the case, how > come I don't have the permissions to delete the file? > Thanks again. > > Alice> Subject: Re: [PHP] PHP unlink Permission Error> From: > a...@ashleysheridan.co.uk> To: aj...@alumni.iu.edu> CC: > php-general@lists.php.net> Date: Tue, 13 Jan 2009 14:53:32 +> > On Tue, > 2009-01-13 at 09:42 -0500, Alice Wei wrote:> > Hi, > > > > I have a snippet > of code as follows:> > > > > > > ini_set('display_errors', 1); > error_reporting(E_ALL);> > $curDir = getcwd();> > echo $curDir;> > > chmod($curDir,0777);> > unlink("testFile.txt");> > echo > unlink("testFile.txt"); > > chmod ($curDir,0755);> > ?> > > > > The problem > is that I do not seem to have the correct permissions, even though I seem to > have changed the permissions of the folder to 777 already upon the file > deletion time. This is the output I got:> > > > > C:\Inetpub\wwwroot\projectWarning: unlink(testFile.txt) [function.unlink]: > Permission denied in C:\Inetpub\wwwroot\project\file_write.php on line > 9Warning: unlink(testFile.txt) [function.unlink]: Permission denied in > C:\Inetpub\wwwrootproject\file_write. php on line 10> > > > Could anyone give me some tips on how to resolve this error? Thanks in advance.> > > > Alice> > _> > All-in-one security and maintenance for your PC. Get a free 90-day trial!> > http://www.windowsonecare.com/purchase/trial.aspx?sc_cid=wl_wlmail> > You're using chmod to modify the permissions of the directory, but do> you actually have permissions to modify the permissions? If not, the> chmod will fail without giving an error, and then your unlink will fail> with an error.> > > Ash> www.ashleysheridan.co.uk> > _ > Search from any Web page with powerful protection. Get the FREE Windows Live > Toolbar Today! > http://get.live.com/toolbar/overview Just because you have perms to change the dir and have set the dir to 777 doesn't mean you have perms to delete the file? Who is the owner of the file and what are the perms? -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP unlink Errors
Do you have php_safe_mode enabled? If's that's the case, try turning it off and then run your script again. Alice Wei wrote: Hi, I have a snippet below that I would like to delete a file. However, I keep getting kicked out because of permission errors, when my folder permission is 0777. ini_set('display_errors', 1); error_reporting(E_ALL); $curDir = getcwd(); chmod($curDir,0777) or die ("Failed to change permission"); echo substr(sprintf('%o', fileperms($curDir)), -4); unlink("C:/Inetpub\wwwroot/project/testFile.txt"); echo unlink("C:/Inetpub/wwwroot/pproject/testFile.txt"); ?> Is it possible that someone on the list could point out what my possible errors are to allow this code to be functioning? Here is the output: 0777Warning: unlink(C:/Inetpub\wwwroot/project/testFile.txt) [function.unlink]: Permission denied in C:\Inetpub\wwwroot\project\file_write.php on line 9Warning: unlink(C:/Inetpub/wwwroot/project/testFile.txt) [function.unlink]: Permission denied in C:\Inetpub\wwwroot\project\file_write.php on line 10 Thanks in advance. Alice _ All-in-one security and maintenance for your PC. Get a free 90-day trial! http://www.windowsonecare.com/purchase/trial.aspx?sc_cid=wl_wlmail -- http://bithub.net/ Synchronize, share and backup your files over the web for free http://twitter.com/MarcSteinert My Twitter feed ** -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP unlink Errors
Hi, I have a snippet below that I would like to delete a file. However, I keep getting kicked out because of permission errors, when my folder permission is 0777. Is it possible that someone on the list could point out what my possible errors are to allow this code to be functioning? Here is the output: 0777Warning: unlink(C:/Inetpub\wwwroot/project/testFile.txt) [function.unlink]: Permission denied in C:\Inetpub\wwwroot\project\file_write.php on line 9Warning: unlink(C:/Inetpub/wwwroot/project/testFile.txt) [function.unlink]: Permission denied in C:\Inetpub\wwwroot\project\file_write.php on line 10 Thanks in advance. Alice _ All-in-one security and maintenance for your PC. Get a free 90-day trial! http://www.windowsonecare.com/purchase/trial.aspx?sc_cid=wl_wlmail
Re: [PHP] PHP unlink Permission Error
Not only do you need to check the return value of chmod to see if it worked, but also, I *think*: The file withing the directory can have entirely different permissions, and making the directory world writable won't help that, I don't think... I could be wrong, and a 000 file in a 777 dir might be unlink-able. You can test for yourself in a shell as fast as I can. :-) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP unlink Permission Error
Hi, Ashley: I tried to find your corrected errors, but I cannot seem to find it. Have you sent me an empty reply message by mistake? Alice> Subject: RE: [PHP] PHP unlink Permission Error> From: a...@ashleysheridan.co.uk> To: aj...@alumni.iu.edu> CC: php-general@lists.php.net> Date: Tue, 13 Jan 2009 15:09:44 +> > On Tue, 2009-01-13 at 09:50 -0500, Alice Wei wrote:> > Hi, Ashley:> > > > I thought about it and edited my script to check what permission I> > had, and it appears I do have the permission rights, and it actually> > changed to 0777. Here is the code:> > > > > > > ini_set('display_errors', 1); > > error_reporting(E_ALL);> > $curDir = getcwd();> > chmod($curDir,0777) or die ("Failed to change permission");> > echo substr(sprintf('%o', fileperms($curDir)), -4); > > unlink("testFile.txt");> > echo unlink("testFile.txt"); > > > > ?> > > > > The output:> > > > 0777> > Warning: unlink(testFile.txt) [function.unlink]: Permission denied in> > C:\Inetpub\wwwroot\project\file_write.php on line 10> > > > Warning: unlink(testFile.txt) [function.unlink]: Permission denied in> > C:\Inetpub\wwwroot\project\file_write.php n line 11> > > > If this is the case, how come I don't have the permissions to delete> > the file?> > Thanks again.> > > > Alice> > > > > > > Subject: Re: [PHP] PHP unlink Permission Error> > > From: a...@ashleysheridan.co.uk> > > To: aj...@alumni.iu.edu> > > CC: php-general@lists.php.net> > > Date: Tue, 13 Jan 2009 14:53:32 +> > > > > > On Tue, 2009-01-13 at 09:42 -0500, Alice Wei wrote:> > > > Hi, > > > > > > > > I have a snippet of code as follows:> > > > > > > > > > > > > > > ini_set('display_errors', 1); error_reporting(E_ALL);> > > > $curDir = getcwd();> > > > echo $curDir;> > > > chmod($curDir,0777);> > > > unlink("testFile.txt");> > > > echo unlink("testFile.txt"); > > > > chmod ($curDir,0755);> > > > ?> > > > > > > > > The problem is that I do not seem to have the correct permissions,> > even though I seem to have changed the permissions of the folder to> > 777 already upon the file deletion time. This is the output I got:> > > > > > > > C:\Inetpub\wwwroot\projectWarning: unlink(testFile.txt)> > [function.unlink]: Permission denied in C:\Inetpub\wwwroot\project> > \file_write.php on line 9Warning: unlink(testFile.txt)> > [function.unlink]: Permission denied in C:\Inetpub\wwwrootproject> > \file_write.php on line 10> > > > > > > > Could anyone give me some tips on how to resolve this error?> > Thanks in advance.> > > > > > > > Alice> > > > _> > > > All-in-one security and maintenance for your PC. Get a free 90-day> > trial!> > > > http://www.windowsonecare.com/purchase/trial.aspx?sc_cid=wl_wlmail> > > > > > You're using chmod to modify the permissions of the directory, but> > do> > > you actually have permissions to modify the permissions? If not, the> > > chmod will fail without giving an error, and then your unlink will> > fail> > > with an error.> > > > > > > > > Ash> > > www.ashleysheridan.co.uk> > > > > > > > > > > __> > Search from any Web page with powerful protection. Get the FREE> > Windows Live Toolbar Today! Try it now!> Hmm, is the current working directory the same as the one in which the> file is in? I know it seems like a silly question, but it's often the> silly ones that cause the most trouble!> > > Ash> www.ashleysheridan.co.uk> _ Use Messenger to talk to your IM friends, even those on Yahoo! http://ideas.live.com/programpage.aspx?versionId=7adb59de-a857-45ba-81cc-685ee3e858fe
RE: [PHP] PHP unlink Permission Error
On Tue, 2009-01-13 at 09:50 -0500, Alice Wei wrote: > Hi, Ashley: > > I thought about it and edited my script to check what permission I > had, and it appears I do have the permission rights, and it actually > changed to 0777. Here is the code: > > > ini_set('display_errors', 1); > error_reporting(E_ALL); > $curDir = getcwd(); > chmod($curDir,0777) or die ("Failed to change permission"); > echo substr(sprintf('%o', fileperms($curDir)), -4); > unlink("testFile.txt"); > echo unlink("testFile.txt"); > > ?> > > The output: > > 0777 > Warning: unlink(testFile.txt) [function.unlink]: Permission denied in > C:\Inetpub\wwwroot\project\file_write.php on line 10 > > Warning: unlink(testFile.txt) [function.unlink]: Permission denied in > C:\Inetpub\wwwroot\project\file_write.php n line 11 > > If this is the case, how come I don't have the permissions to delete > the file? > Thanks again. > > Alice > > > > Subject: Re: [PHP] PHP unlink Permission Error > > From: a...@ashleysheridan.co.uk > > To: aj...@alumni.iu.edu > > CC: php-general@lists.php.net > > Date: Tue, 13 Jan 2009 14:53:32 + > > > > On Tue, 2009-01-13 at 09:42 -0500, Alice Wei wrote: > > > Hi, > > > > > > I have a snippet of code as follows: > > > > > > > > > > > ini_set('display_errors', 1); error_reporting(E_ALL); > > > $curDir = getcwd(); > > > echo $curDir; > > > chmod($curDir,0777); > > > unlink("testFile.txt"); > > > echo unlink("testFile.txt"); > > > chmod ($curDir,0755); > > > ?> > > > > > > The problem is that I do not seem to have the correct permissions, > even though I seem to have changed the permissions of the folder to > 777 already upon the file deletion time. This is the output I got: > > > > > > C:\Inetpub\wwwroot\projectWarning: unlink(testFile.txt) > [function.unlink]: Permission denied in C:\Inetpub\wwwroot\project > \file_write.php on line 9Warning: unlink(testFile.txt) > [function.unlink]: Permission denied in C:\Inetpub\wwwrootproject > \file_write.php on line 10 > > > > > > Could anyone give me some tips on how to resolve this error? > Thanks in advance. > > > > > > Alice > > > _ > > > All-in-one security and maintenance for your PC. Get a free 90-day > trial! > > > http://www.windowsonecare.com/purchase/trial.aspx?sc_cid=wl_wlmail > > > > You're using chmod to modify the permissions of the directory, but > do > > you actually have permissions to modify the permissions? If not, the > > chmod will fail without giving an error, and then your unlink will > fail > > with an error. > > > > > > Ash > > www.ashleysheridan.co.uk > > > > > > __ > Search from any Web page with powerful protection. Get the FREE > Windows Live Toolbar Today! Try it now! Hmm, is the current working directory the same as the one in which the file is in? I know it seems like a silly question, but it's often the silly ones that cause the most trouble! Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP unlink Permission Error
Hi, Ashley: I thought about it and edited my script to check what permission I had, and it appears I do have the permission rights, and it actually changed to 0777. Here is the code: The output: 0777Warning: unlink(testFile.txt) [function.unlink]: Permission denied in C:\Inetpub\wwwroot\project\file_write.php on line 10Warning: unlink(testFile.txt) [function.unlink]: Permission denied in C:\Inetpub\wwwroot\project\file_write.php n line 11If this is the case, how come I don't have the permissions to delete the file? Thanks again. Alice> Subject: Re: [PHP] PHP unlink Permission Error> From: a...@ashleysheridan.co.uk> To: aj...@alumni.iu.edu> CC: php-general@lists.php.net> Date: Tue, 13 Jan 2009 14:53:32 +> > On Tue, 2009-01-13 at 09:42 -0500, Alice Wei wrote:> > Hi, > > > > I have a snippet of code as follows:> > > > > > > ini_set('display_errors', 1); error_reporting(E_ALL);> > $curDir = getcwd();> > echo $curDir;> > chmod($curDir,0777);> > unlink("testFile.txt");> > echo unlink("testFile.txt"); > > chmod ($curDir,0755);> > ?> > > > > The problem is that I do not seem to have the correct permissions, even though I seem to have changed the permissions of the folder to 777 already upon the file deletion time. This is the output I got:> > > > C:\Inetpub\wwwroot\projectWarning: unlink(testFile.txt) [function.unlink]: Permission denied in C:\Inetpub\wwwroot\project\file_write.php on line 9Warning: unlink(testFile.txt) [function.unlink]: Permission denied in C:\Inetpub\wwwrootproject\file_write.php on line 10> > > > Could anyone give me some tips on how to resolve this error? Thanks in advance.> > > > Alice> > _> > All-in-one security and maintenance for your PC. Get a free 90-day trial!> > http://www.windowsonecare.com/purchase/trial.aspx?sc_cid=wl_wlmail> > You're using chmod to modify the permissions of the directory, but do> you actually have permissions to modify the permissions? If not, the> chmod will fail without giving an error, and then your unlink will fail> with an error.> > > Ash> www.ashleysheridan.co.uk> _ Search from any Web page with powerful protection. Get the FREE Windows Live Toolbar Today! http://get.live.com/toolbar/overview
Re: [PHP] PHP unlink Permission Error
On Tue, 2009-01-13 at 09:42 -0500, Alice Wei wrote: > Hi, > >I have a snippet of code as follows: > > > ini_set('display_errors', 1); error_reporting(E_ALL); > $curDir = getcwd(); > echo $curDir; > chmod($curDir,0777); > unlink("testFile.txt"); > echo unlink("testFile.txt"); > chmod ($curDir,0755); > ?> > > The problem is that I do not seem to have the correct permissions, even > though I seem to have changed the permissions of the folder to 777 already > upon the file deletion time. This is the output I got: > > C:\Inetpub\wwwroot\projectWarning: unlink(testFile.txt) [function.unlink]: > Permission denied in C:\Inetpub\wwwroot\project\file_write.php on line > 9Warning: unlink(testFile.txt) [function.unlink]: Permission denied in > C:\Inetpub\wwwrootproject\file_write.php on line 10 > > Could anyone give me some tips on how to resolve this error? Thanks in > advance. > > Alice > _ > All-in-one security and maintenance for your PC. Get a free 90-day trial! > http://www.windowsonecare.com/purchase/trial.aspx?sc_cid=wl_wlmail You're using chmod to modify the permissions of the directory, but do you actually have permissions to modify the permissions? If not, the chmod will fail without giving an error, and then your unlink will fail with an error. Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP unlink Permission Error
Hi, I have a snippet of code as follows: The problem is that I do not seem to have the correct permissions, even though I seem to have changed the permissions of the folder to 777 already upon the file deletion time. This is the output I got: C:\Inetpub\wwwroot\projectWarning: unlink(testFile.txt) [function.unlink]: Permission denied in C:\Inetpub\wwwroot\project\file_write.php on line 9Warning: unlink(testFile.txt) [function.unlink]: Permission denied in C:\Inetpub\wwwrootproject\file_write.php on line 10 Could anyone give me some tips on how to resolve this error? Thanks in advance. Alice _ All-in-one security and maintenance for your PC. Get a free 90-day trial! http://www.windowsonecare.com/purchase/trial.aspx?sc_cid=wl_wlmail
Re: [PHP] unlink oddity
> > function saveRecord ($db,$POST) { >$bd = "/absolute_path_to_document_root"; >$fp = "/path_to_files_from_document_root/"; >$ud = $bd . $fp; > $path = $ud.$file; // absolute path to newly named file > if ($fail || !$name || !$temp) continue; > // @unlink($ud.$file); > @move_uploaded_file($temp, $path); > @chmod($path, 0777); Why not just unlink($path) ? It's the same thing but you take 2 variables out of the problem. While you're trying to debug this remove the '@' signs. An error message will be particularly useful. Check your logs if you can, otherwise turn up error reporting and display errors until you work out what's going on. error_reporting(E_ALL); ini_set('display_errors', true); -- Postgresql & php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] unlink oddity
Ok, here is my problem. Using the code below, I am saving a posted form to a database including the files it contains. There is one line commented out.. The unlink command. Without the command, the script works fine and new files Overwrite the old files when uploaded. If, however, I uncomment the unlink line, the new files are still saved and the "if (file_exists($path)) {" line evals to true, but the file disappears after program Execution. The net result of having the unlink command in seems to be that it executes after program termination leaving a record of the successful upload in the database, but no file found on the server where the upload occurred. Does anyone have any idea of why this would be occurring? The php docs for unlink do not talk about delayed execution and other scripts I researched seems to use unlink before the move command with success. Any help would be greatly appreciated. Please reply to: [EMAIL PROTECTED] $name ,'type' => $type ,'size' => $size ,'file' => $file ,'path' => $fp ); $OBJ[$objID] = serialize($dbDAT); } } } } /* All the actual code to save the record in the database has been removed, and a fake if/then statement added. */ If ($record_successfully_created) { Return $newRecordID; } else { Return 0; } } If ($_POST[obj]) saveRecord($db,$_POST); ?>
Re: [PHP] Unlink file older then 7 days
Did you actually READ my previous post that you replied to?... On Wed, July 18, 2007 1:29 am, [EMAIL PROTECTED] wrote: > Ok thanks everyone... > > I need to throw in a wildcard, how would I do that.. I have this so > far. > which dont work. > > $filename = '/home/public_html/client/test/*.txt.asc'; ... [snip] >> I think finding all the .txt.asc files would best be handled by >> http://php.net/glob unless your PHP version is too old and you need >> to >> http://php.net/opendir and http://php.net/readdir to look at each >> file >> in turn... PHP 5: http://php.net/glob PHP 4: http://php.net/opendir http://php.net/readdir -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Unlink file older then 7 days
On Wed, 2007-07-18 at 07:29 +0100, [EMAIL PROTECTED] wrote: > I need to throw in a wildcard, how would I do that.. I have this so far. > which dont work. foreach(glob("*.asc.txt") as $files) { unlink($files); } --Paul All Email originating from UWC is covered by disclaimer http://www.uwc.ac.za/portal/uwc2006/content/mail_disclaimer/index.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Unlink file older then 7 days
Ok thanks everyone... I need to throw in a wildcard, how would I do that.. I have this so far. which dont work. Thankyou - Original Message - From: "Richard Lynch" <[EMAIL PROTECTED]> To: "Stut" <[EMAIL PROTECTED]> Cc: "Suhas Pharkute" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>; Sent: Wednesday, July 18, 2007 2:17 AM Subject: Re: [PHP] Unlink file older then 7 days On Mon, July 16, 2007 8:40 am, Stut wrote: Suhas Pharkute wrote: http://us.php.net/manual/en/function.fileatime.php $filename = 'somefile.txt'; if (file_exists($filename) && fileatime($filename) < (time()-(7*24*60*60)) ) { unlink($filename); } Read docs! You too! The OP wanted a way to "check the age of all files". The fileatime function will return when the file was last accessed. Accessing a file is not usually deemed to affect its age, modifying it is. The filemtime function is what the OP wants. Unless he wants filectime, for when the file was created, even if it's been modified in the past week... "older" could mean that, in some contexts... I think finding all the .txt.asc files would best be handled by http://php.net/glob unless your PHP version is too old and you need to http://php.net/opendir and http://php.net/readdir to look at each file in turn... -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Unlink file older then 7 days
On Mon, July 16, 2007 8:40 am, Stut wrote: > Suhas Pharkute wrote: >> http://us.php.net/manual/en/function.fileatime.php >> >> $filename = 'somefile.txt'; >> if (file_exists($filename) && fileatime($filename) < >> (time()-(7*24*60*60)) ) >> { >>unlink($filename); >> } >> >> Read docs! > > You too! The OP wanted a way to "check the age of all files". The > fileatime function will return when the file was last accessed. > Accessing a file is not usually deemed to affect its age, modifying it > is. The filemtime function is what the OP wants. Unless he wants filectime, for when the file was created, even if it's been modified in the past week... "older" could mean that, in some contexts... I think finding all the .txt.asc files would best be handled by http://php.net/glob unless your PHP version is too old and you need to http://php.net/opendir and http://php.net/readdir to look at each file in turn... -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Unlink file older then 7 days
-Original Message- From: <[EMAIL PROTECTED]> To: Date: Mon, 16 Jul 2007 14:25:47 +0100 Subject: Re: [PHP] Unlink file older then 7 days > How would I use fileatime to check if the file is older then 7 days? > > > > something like: $access = fileatime (c:\path\to\file);//assuming windows server if ((time()-$access)>(7*24*60*60)){ do whatever with old files } off the top of my head. There are other ways to do it. Ray > > >> I have a directory with .txt and .txt.asc files. > >> > >> What I want to do is.. > >> > >> Check the age of all files ending in .txt.asc > >> > >> and if the file *.txt.asc is older then 7 days > >> > >> delete thatfile.txt.asc and also thatfile.txt > >> > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Unlink file older then 7 days
Suhas Pharkute wrote: http://us.php.net/manual/en/function.fileatime.php $filename = 'somefile.txt'; if (file_exists($filename) && fileatime($filename) < (time()-(7*24*60*60)) ) { unlink($filename); } Read docs! You too! The OP wanted a way to "check the age of all files". The fileatime function will return when the file was last accessed. Accessing a file is not usually deemed to affect its age, modifying it is. The filemtime function is what the OP wants. -Stut -- http://stut.net/ On 7/16/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: How would I use fileatime to check if the file is older then 7 days? >> I have a directory with .txt and .txt.asc files. >> >> What I want to do is.. >> >> Check the age of all files ending in .txt.asc >> >> and if the file *.txt.asc is older then 7 days >> >> delete thatfile.txt.asc and also thatfile.txt >> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Unlink file older then 7 days
http://us.php.net/manual/en/function.fileatime.php $filename = 'somefile.txt'; if (file_exists($filename) && fileatime($filename) < (time()-(7*24*60*60)) ) { unlink($filename); } Read docs! Suhas On 7/16/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: How would I use fileatime to check if the file is older then 7 days? >> I have a directory with .txt and .txt.asc files. >> >> What I want to do is.. >> >> Check the age of all files ending in .txt.asc >> >> and if the file *.txt.asc is older then 7 days >> >> delete thatfile.txt.asc and also thatfile.txt >> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Unlink file older then 7 days
[EMAIL PROTECTED] wrote: How would I use fileatime to check if the file is older then 7 days? You want filemtime not fileatime. -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Unlink file older then 7 days
How would I use fileatime to check if the file is older then 7 days? I have a directory with .txt and .txt.asc files. What I want to do is.. Check the age of all files ending in .txt.asc and if the file *.txt.asc is older then 7 days delete thatfile.txt.asc and also thatfile.txt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Unlink file older then 7 days
On Saturday 14 July 2007 9:16:06 pm [EMAIL PROTECTED] wrote: > I have a directory with .txt and .txt.asc files. > > What I want to do is.. > > Check the age of all files ending in .txt.asc > > and if the file *.txt.asc is older then 7 days > > delete thatfile.txt.asc and also thatfile.txt > look at these functions (and also related functions, the bar on the right hand side): http://ca3.php.net/manual/en/function.opendir.php http://ca3.php.net/manual/en/function.fileatime.php http://ca3.php.net/manual/en/function.unlink.php HTH Ray > > Thanks > Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Unlink file older then 7 days
I have a directory with .txt and .txt.asc files. What I want to do is.. Check the age of all files ending in .txt.asc and if the file *.txt.asc is older then 7 days delete thatfile.txt.asc and also thatfile.txt Thanks Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] unlink before imagepng?
On 6/20/07, Brian Dunning <[EMAIL PROTECTED]> wrote: Can do, but I would be calling clearstatcache() very often, many times per second, as often as these graphics are being edited. Would that still be appropriate for the server? I certainly wouldn't use it if I didn't need it. -- Greg Donald http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] unlink before imagepng?
Can do, but I would be calling clearstatcache() very often, many times per second, as often as these graphics are being edited. Would that still be appropriate for the server? On Jun 19, 2007, at 8:07 AM, Greg Donald wrote: On 6/17/07, Brian Dunning <[EMAIL PROTECTED]> wrote: If I write an edited image back to disk using imagepng, is it desirable to first unlink the existing image? It's not required. I notice that it works fine if I don't. Just wondering if there are any pros or cons. Just be sure and call clearstatcache() so your changes show up immediately. -- Greg Donald http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] unlink before imagepng?
On 6/17/07, Brian Dunning <[EMAIL PROTECTED]> wrote: If I write an edited image back to disk using imagepng, is it desirable to first unlink the existing image? It's not required. I notice that it works fine if I don't. Just wondering if there are any pros or cons. Just be sure and call clearstatcache() so your changes show up immediately. -- Greg Donald http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] unlink before imagepng?
If I write an edited image back to disk using imagepng, is it desirable to first unlink the existing image? I notice that it works fine if I don't. Just wondering if there are any pros or cons. - Brian -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] unlink, symlink and caching
> Be sure to include the OS, filesystem type and the configure line > in the report, cause there seems to be something system dependent > causing it since the script you posted earlier worked fine on my > system. Thanks for your help. I appreciate it. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] unlink, symlink and caching
On Thu, Dec 22, 2005 at 02:41:40PM -0700, jgmtfia Mr wrote: > > > I just ran the test with php4 cli and it works correctly. > > > PHP 4.3.10-15 (cli) (built: May 9 2005 08:54:56) > > > > > > But with php5 cli and apache2 module it does not: > > > PHP 5.1.0b3 (cli) (built: Oct 18 2005 16:13:19) > > > PHP 5.1.0 apache module > > > > The versions I ran the tests were on: > > PHP 5.1.0RC5-dev (cli) (built: Nov 17 2005 10:02:23) > > PHP 5.1.2-dev (cli) (built: Dec 19 2005 12:03:32) > > > > > Is this not a bug? > > > > If it still happens on your system with the latest snapshot it > > sounds like it. > > I just downloaded + compiled 5.1.1 and it does have the same problem. > What should be next step be? Probably reporting a bug report at http://bugs.php.net/, i did a quick search but didn't see any open related to this but you might want to search a little harder than I did. Be sure to include the OS, filesystem type and the configure line in the report, cause there seems to be something system dependent causing it since the script you posted earlier worked fine on my system. Curt. -- cat .signature: No such file or directory -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] unlink, symlink and caching
> > I just ran the test with php4 cli and it works correctly. > > PHP 4.3.10-15 (cli) (built: May 9 2005 08:54:56) > > > > But with php5 cli and apache2 module it does not: > > PHP 5.1.0b3 (cli) (built: Oct 18 2005 16:13:19) > > PHP 5.1.0 apache module > > The versions I ran the tests were on: > PHP 5.1.0RC5-dev (cli) (built: Nov 17 2005 10:02:23) > PHP 5.1.2-dev (cli) (built: Dec 19 2005 12:03:32) > > > Is this not a bug? > > If it still happens on your system with the latest snapshot it > sounds like it. I just downloaded + compiled 5.1.1 and it does have the same problem. What should be next step be? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] unlink, symlink and caching
On Thu, Dec 22, 2005 at 08:29:53AM -0700, jgmtfia Mr wrote: > > Thank you for checking on this. > > > > I am using debain stable with a 2.6.14.3 kernel. The filesystem in > > question is ext2 on a 48 MB ramdisk. > > > > I also did the following on another machine using ext2 on a harddisk > > with command line php. > > I just ran the test with php4 cli and it works correctly. > PHP 4.3.10-15 (cli) (built: May 9 2005 08:54:56) > > But with php5 cli and apache2 module it does not: > PHP 5.1.0b3 (cli) (built: Oct 18 2005 16:13:19) > PHP 5.1.0 apache module The versions I ran the tests were on: PHP 5.1.0RC5-dev (cli) (built: Nov 17 2005 10:02:23) PHP 5.1.2-dev (cli) (built: Dec 19 2005 12:03:32) > Is this not a bug? If it still happens on your system with the latest snapshot it sounds like it. Curt. -- cat .signature: No such file or directory -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] unlink, symlink and caching
> Thank you for checking on this. > > I am using debain stable with a 2.6.14.3 kernel. The filesystem in > question is ext2 on a 48 MB ramdisk. > > I also did the following on another machine using ext2 on a harddisk > with command line php. I just ran the test with php4 cli and it works correctly. PHP 4.3.10-15 (cli) (built: May 9 2005 08:54:56) But with php5 cli and apache2 module it does not: PHP 5.1.0b3 (cli) (built: Oct 18 2005 16:13:19) PHP 5.1.0 apache module Is this not a bug? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] unlink, symlink and caching
> > The loop then continues forever with file_exists() returning true, but > > unlink() returns false with the error message "Warning: > > unlink(/config1/C) [function.unlink]: No such file or directory in > > /www/script.php on line 10" > > This might be an issue with the OS or Filessystem. The code > works just fine for me, i dont even need the clearstatcache(). Thank you for checking on this. I am using debain stable with a 2.6.14.3 kernel. The filesystem in question is ext2 on a 48 MB ramdisk. I also did the following on another machine using ext2 on a harddisk with command line php. A -rw-r--r-- 1 user user 91 Dec 21 12:41 test.php */ $FILE = 'C'; while(file_exists($FILE)){ echo "$FILE exists\n"; echo `ls -l C`; if(!unlink($FILE)){ echo "Unable to delete $FILE\n"; echo `ls -l C`; }else{ echo "Deleted $FILE\n"; } echo "\n"; } /* Output: >php5 ./test.php C exists lrwxr-xr-x 1 user user 1 Dec 21 12:59 C -> A Deleted C C exists ls: C: No such file or directory Warning: unlink(C): No such file or directory in /home/user/x/test.php on line 14 Unable to delete C ls: C: No such file or directory C exists ls: C: No such file or directory Warning: unlink(C): No such file or directory in /home/user/x/test.php on line 14 Unable to delete C ls: C: No such file or directory */ ?> This shows that apache is not responsible for the problem. Note also that if I delete A and C within the loop the code works as expected and the loop only executes once. So file_exists() is seeing "A" when I tell it to delete "C" and unlink is seeing "C" as it should. Any ideas where to start to look for the cause of the problem? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] unlink, symlink and caching
On Wed, Dec 21, 2005 at 11:27:23AM -0700, jgmtfia Mr wrote: > I have a directory with the files: > /config/A > /config/B > and > /config/C is a symlink to /config/A. > > Via php I unlink /config/C: > > $FILE = '/config/C'; > while(file_exists($FILE)){ > unlink($FILE); > clearstatcache(); > } > > When run, the first time through the loop $FILE is removed from disk > as it should. > > The loop then continues forever with file_exists() returning true, but > unlink() returns false with the error message "Warning: > unlink(/config1/C) [function.unlink]: No such file or directory in > /www/script.php on line 10" This might be an issue with the OS or Filessystem. The code works just fine for me, i dont even need the clearstatcache(). Curt. -- cat .signature: No such file or directory -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] unlink, symlink and caching
I have a directory with the files: /config/A /config/B and /config/C is a symlink to /config/A. Via php I unlink /config/C: $FILE = '/config/C'; while(file_exists($FILE)){ unlink($FILE); clearstatcache(); } When run, the first time through the loop $FILE is removed from disk as it should. The loop then continues forever with file_exists() returning true, but unlink() returns false with the error message "Warning: unlink(/config1/C) [function.unlink]: No such file or directory in /www/script.php on line 10" If I do this: $FILE = '/config/C'; unlink($FILE); cleanstatcache(); symlink('/config/B', '/config/C'); I get the error message: Warning: symlink() [function.symlink]: File exists in /www/script.php on line 11 However the link had been deleted. The symlink /config/C is read via file_get_contents() before the unlink and relink is performed. I have also done the following: $FILE = '/config/C'; unlink($FILE); `ln -s /config/B /config/C` Which works as expected, the old link is replaced with the new link, however any attempt to open and read from the new link returns the contents of the old file. How would I be able to get the expected behavior from PHP. I expect that the problem has something to do with the symlinks being used. Any assistance is appreciated. PHP Version: 5.1.0 Server API: Apache 2.0 Handler PHP API: 20041225 PHP Extension: 20050922 Zend Extension: 220051025 Apache Version: Apache/2.0.52 (Unix) PHP/5.1.0 Apache API Version: 20020903 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] unlink images
On Saturday 27 November 2004 03:13, Julian wrote: > I would like to delete a set of images right after they are displayed on > the page using unlink. I'm curious to know why you want this. > Unfortunately, with unlink the images are deleted > before they display on the user's browser. Is there a way to do this? Channel your image requests to a php script that: fopen() fpassthru() unlink() Haven't tried it, but in theory it looks like it should work. -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* Talkers are no good doers. -- William Shakespeare, "Henry VI" */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] unlink images
What you may want to try doing is when the script is ran, it goes through a "clean-up" function and deletes everything that it doesn't need for the current execution. Though, realize that if two people hit a page within a few seconds, you may end up deleting some images that the first user is trying to get rid of. You'll have to judge the traffic for yourself and figure out if this is a viable option. Other solutions that I can think of is after the page is ran you update a text file with the names of the images that are to get deleted and just run a cronjob to read this file and delete the files in there. Similarly, you could add the names to a db table with a timestamp and delete all files that are older than a particular time. Many options, but you have to figure out what works best for you. -M > -Original Message- > From: Julian [mailto:[EMAIL PROTECTED] > Sent: Friday, November 26, 2004 2:14 PM > To: [EMAIL PROTECTED] > Subject: [PHP] unlink images > > Hello, > I would like to delete a set of images right after they are > displayed on the page using unlink. Unfortunately, with > unlink the images are deleted before they display on the > user's browser. Is there a way to do this? > > Thank you! > > -- > PHP General Mailing List (http://www.php.net/) To > unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] unlink images
PHP has wonderful capabilities to generate images on the fly, such that they are never stored on disk, perhaps you should look into that as an option, you could even make the code decide who should be able to see the image and who should not. http://www.php.net/manual/en/ref.image.php Warren Vail > -Original Message- > From: Julian [mailto:[EMAIL PROTECTED] > Sent: Friday, November 26, 2004 11:14 AM > To: [EMAIL PROTECTED] > Subject: [PHP] unlink images > > > Hello, > I would like to delete a set of images right after they are > displayed on the > page using unlink. Unfortunately, with unlink the images are > deleted before > they display on the user's browser. Is there a way to do this? > > Thank you! > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] unlink images
Hello, I would like to delete a set of images right after they are displayed on the page using unlink. Unfortunately, with unlink the images are deleted before they display on the user's browser. Is there a way to do this? Thank you! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] unlink() & rmdir() ... Problems.
* Thus wrote Jason Wong: > Please do not top post. > > On Wednesday 25 August 2004 01:31, PHP Junkie wrote: > > Ave, > > > > Nope... Didn't work. Didn't return an error or anything, didn't delete the > > folders either! > > > >> system('rm -rf',$user_dir,$ret_val); > > That should be: > > system("rm -rf $user_dir", $ret_val); Btw, be extra careful what $user_dir is, if somehow it is / you'll delete any file that nobody has permission to; which isn't a good thing. Curt -- First, let me assure you that this is not one of those shady pyramid schemes you've been hearing about. No, sir. Our model is the trapezoid! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] unlink() & rmdir() ... Problems.
On Wednesday 25 August 2004 05:31, John Nichel wrote: > How so? Even if 'nobody' is in the www group, it still wouldn't have > the proper permissions. To be able to delete directories, you need: - 'wx' on the parent directory - 'rx' on the target directory To be able to delete files, you need: - 'wx' on the parent directory - doesn't matter who owns the target files or what their permissions are -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* Everything bows to success, even grammar. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] unlink() & rmdir() ... Problems.
Jason Wong wrote: If Apache is running as nobody/nobody, it does not have permission to delete these directories. The only users who can delete these directories are the respective users, and root. You need to have write permission to delete... drwxr-xr-x3 www www 102 24 Aug 11:09 rjohari In the above, the 'd' means directory, the next three letter are the user's permissions (full, read/write/execute), next three characters (r-x) are the group's permissions (read/execute), and the last three are other's (world) permission (read/execute). The two 'www' are the owner (user) and group. For the directory rjohari, only root and the user www can delete and/or write to this directory. Actually 'nobody' *can* delete both bobkasper and rjohari (but not .DS_Store). How so? Even if 'nobody' is in the www group, it still wouldn't have the proper permissions. [EMAIL PROTECTED] /]# ls -al bob.txt -rw-r--r-- 1 apache apache 6 Aug 24 17:27 bob.txt [EMAIL PROTECTED] /]# su - nobody -bash-2.05b$ rm -f /bob.txt rm: cannot remove `/bob.txt': Permission denied -bash-2.05b$ -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] unlink() & rmdir() ... Problems.
On Wednesday 25 August 2004 02:30, John Nichel wrote: > > This is what I got with ls -al > > > > rahul:/Library/WebServer/Documents/informed-sources.com/imsafm bob$ ls > > -al total 16 > > drwxrwxrwx5 nobody nobody170 24 Aug 13:55 . > > drwxrwxrwx 102 bob unknown 3468 24 Aug 11:23 .. > > -rw-rw-rw-1 bob unknown 6148 24 Aug 13:57 .DS_Store > > drwxr-xr-x3 www www 102 24 Aug 11:05 bobkasper > > > > drwxr-xr-x3 www www 102 24 Aug 11:09 rjohari > > > > Now you see the last 2 folders... "bobkasper" and "rjohari". These are 2 > > users created by the admin. If I delete a user, their corresponding > > folder should be deleted as well, which is what I am trying to achieve. > > But if, let's say, I delete the user "rjohari"... The folder still > > remains. > > > > Thanks for helping... > > If Apache is running as nobody/nobody, it does not have permission to > delete these directories. The only users who can delete these > directories are the respective users, and root. You need to have write > permission to delete... > > drwxr-xr-x3 www www 102 24 Aug 11:09 rjohari > > In the above, the 'd' means directory, the next three letter are the > user's permissions (full, read/write/execute), next three characters > (r-x) are the group's permissions (read/execute), and the last three are > other's (world) permission (read/execute). The two 'www' are the owner > (user) and group. For the directory rjohari, only root and the user www > can delete and/or write to this directory. Actually 'nobody' *can* delete both bobkasper and rjohari (but not .DS_Store). -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* Thrashing is just virtual crashing. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] unlink() & rmdir() ... Problems.
The reason this works is because you are doing a recursive remove of the directory. The PHP rmdir() does not remove a directory with contents in it. If you modify your script so that it walks the users directory and removes each file and subdirectory then it would probally have worked correctly. I would have mentioned this earlier but I have been away from email for the past day or so. -William On Tue, 24 Aug 2004 14:32:43 -0400, PHP Junkie <[EMAIL PROTECTED]> wrote: > Ave, > > IT WORKS!!! > I guess it was the syntax which was the problem! Finally it works!! > > system("rm -rf $user_dir", $ret_val); > > Works perfectly... Removes folder! > > Thanks a TON! > > > > > On 8/24/04 2:04 PM, "Jason Wong" <[EMAIL PROTECTED]> wrote: > > > Please do not top post. > > > > On Wednesday 25 August 2004 01:31, PHP Junkie wrote: > >> Ave, > >> > >> Nope... Didn't work. Didn't return an error or anything, didn't delete the > >> folders either! > > > system('rm -rf',$user_dir,$ret_val); > > > > That should be: > > > > system("rm -rf $user_dir", $ret_val); > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] unlink() & rmdir() ... Problems.
Please stop top posting. On Wednesday 25 August 2004 02:20, PHP Junkie wrote: > Apache to the best of my knowledge runs as "nobody" by default and since I > didn't change any settings, it is probably running as "nobody". Instead of speculating, find out for certain by using phpinfo(). -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* Lonesome? Like a change? Like a new job? Like excitement? Like to meet new and interesting people? JUST SCREW-UP ONE MORE TIME!!! */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] unlink() & rmdir() ... Problems.
Ave, IT WORKS!!! I guess it was the syntax which was the problem! Finally it works!! system("rm -rf $user_dir", $ret_val); Works perfectly... Removes folder! Thanks a TON! On 8/24/04 2:04 PM, "Jason Wong" <[EMAIL PROTECTED]> wrote: > Please do not top post. > > On Wednesday 25 August 2004 01:31, PHP Junkie wrote: >> Ave, >> >> Nope... Didn't work. Didn't return an error or anything, didn't delete the >> folders either! > system('rm -rf',$user_dir,$ret_val); > > That should be: > > system("rm -rf $user_dir", $ret_val); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] unlink() & rmdir() ... Problems.
Ave, IT WORKS!!! I guess it was the syntax which was the problem! Finally it works!! system("rm -rf $user_dir", $ret_val); Works perfectly... Removes folder! Thanks a TON! On 8/24/04 2:04 PM, "Jason Wong" <[EMAIL PROTECTED]> wrote: > Please do not top post. > > On Wednesday 25 August 2004 01:31, PHP Junkie wrote: >> Ave, >> >> Nope... Didn't work. Didn't return an error or anything, didn't delete the >> folders either! > system('rm -rf',$user_dir,$ret_val); > > That should be: > > system("rm -rf $user_dir", $ret_val); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] unlink() & rmdir() ... Problems.
PHP Junkie wrote: Ave, Apache to the best of my knowledge runs as "nobody" by default and since I didn't change any settings, it is probably running as "nobody". This is what I got with ls -al rahul:/Library/WebServer/Documents/informed-sources.com/imsafm bob$ ls -al total 16 drwxrwxrwx5 nobody nobody170 24 Aug 13:55 . drwxrwxrwx 102 bob unknown 3468 24 Aug 11:23 .. -rw-rw-rw-1 bob unknown 6148 24 Aug 13:57 .DS_Store drwxr-xr-x3 www www 102 24 Aug 11:05 bobkasper > drwxr-xr-x3 www www 102 24 Aug 11:09 rjohari Now you see the last 2 folders... "bobkasper" and "rjohari". These are 2 users created by the admin. If I delete a user, their corresponding folder should be deleted as well, which is what I am trying to achieve. But if, let's say, I delete the user "rjohari"... The folder still remains. Thanks for helping... If Apache is running as nobody/nobody, it does not have permission to delete these directories. The only users who can delete these directories are the respective users, and root. You need to have write permission to delete... drwxr-xr-x3 www www 102 24 Aug 11:09 rjohari In the above, the 'd' means directory, the next three letter are the user's permissions (full, read/write/execute), next three characters (r-x) are the group's permissions (read/execute), and the last three are other's (world) permission (read/execute). The two 'www' are the owner (user) and group. For the directory rjohari, only root and the user www can delete and/or write to this directory. -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] unlink() & rmdir() ... Problems.
Ave, Apache to the best of my knowledge runs as "nobody" by default and since I didn't change any settings, it is probably running as "nobody". This is what I got with ls -al rahul:/Library/WebServer/Documents/informed-sources.com/imsafm bob$ ls -al total 16 drwxrwxrwx5 nobody nobody170 24 Aug 13:55 . drwxrwxrwx 102 bob unknown 3468 24 Aug 11:23 .. -rw-rw-rw-1 bob unknown 6148 24 Aug 13:57 .DS_Store drwxr-xr-x3 www www 102 24 Aug 11:05 bobkasper drwxr-xr-x3 www www 102 24 Aug 11:09 rjohari Now you see the last 2 folders... "bobkasper" and "rjohari". These are 2 users created by the admin. If I delete a user, their corresponding folder should be deleted as well, which is what I am trying to achieve. But if, let's say, I delete the user "rjohari"... The folder still remains. Thanks for helping... On 8/24/04 1:49 PM, "John Nichel" <[EMAIL PROTECTED]> wrote: > PHP Junkie wrote: >> Ave, >> >> Nope... Didn't work. Didn't return an error or anything, didn't delete the >> folders either! > > If you cannot delete via the php functions or via system calls, then you > have a permission problem. > > What user/group is Apache running as? > > What is the output of 'ls -al' for the files you're looking to delete? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] unlink() & rmdir() ... Problems.
Please do not top post. On Wednesday 25 August 2004 01:31, PHP Junkie wrote: > Ave, > > Nope... Didn't work. Didn't return an error or anything, didn't delete the > folders either! > >> system('rm -rf',$user_dir,$ret_val); That should be: system("rm -rf $user_dir", $ret_val); -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* So much depends upon a red wheel barrow glazed with rain water beside the white chickens. -- William Carlos Williams, "The Red Wheel Barrow" */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] unlink() & rmdir() ... Problems.
PHP Junkie wrote: Ave, Nope... Didn't work. Didn't return an error or anything, didn't delete the folders either! If you cannot delete via the php functions or via system calls, then you have a permission problem. What user/group is Apache running as? What is the output of 'ls -al' for the files you're looking to delete? -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] unlink() & rmdir() ... Problems.
Ave, Trust me I do... I double checked it actually.. On 8/24/04 1:41 PM, "Richard Whitney" <[EMAIL PROTECTED]> wrote: > Dumb question - are you sure you got the path right? > i.e. /home/public_html/rest/of/your/path > > On Tue, 24 Aug 2004 13:31:06 -0400, PHP Junkie <[EMAIL PROTECTED]> wrote: >> >> Ave, >> >> Nope... Didn't work. Didn't return an error or anything, didn't delete the >> folders either! >> >> >> >> >> On 8/23/04 8:21 PM, "Richard Whitney" <[EMAIL PROTECTED]> wrote: >> >>> Let me clarify: >>> >>> system() is like working in a shell >>> rm -rf forces removal of the directory $file_dir, which you define >>> befiorehand >>> $ret_val displays to you what happened. if you tget nothing, it did not >>> work. >>> >>> HTH! >>> >>> Richard >>> >>> On Mon, 23 Aug 2004 16:24:23 -0400, PHP Junkie <[EMAIL PROTECTED]> wrote: Ave, Richard... What exactly did you mean by this? system('rm -rf',$user_dir,$ret_val); I don't understand. On 8/23/04 12:11 PM, "Richard Whitney" <[EMAIL PROTECTED]> wrote: > system('rm -rf',$user_dir,$ret_val); > > On Mon, 23 Aug 2004 11:57:35 -0400, PHP Junkie <[EMAIL PROTECTED]> > wrote: >> Ave, >> >> I do not really know what the problem is because I don't get an error, >> and >> in fact my scripts execute fine... Except that, niether is the directory >> deleted, nor is the file deleted. Only corresponding database entries are >> deleted which I specify in my SQL code. >> >> There are 2 different functions in 2 separate places in my File Manager. >> 1 function deletes the User including his Folder >> The other deletes a particular file. >> >> The code I'm using to delete the User & his Folder is: >> >> > if($delete_user) { >> $db = mysql_connect("localhost","usr","pwd"); >> mysql_select_db("mydb",$db); >> $sql = "DELETE FROM user where login = '$user'"; >> $result = mysql_query($sql) or die("There is a problem."); >> $sql2 = "DELETE FROM file where login = '$user'"; >> $result2 = mysql_query($sql2) or die("There is a problem."); >> rmdir (imsafm/$user); >> echo "User $user deleted."; >> } >> ?> >> >> The name of Folder of a user is the same as his Login. >> Anyhow... The above code doesn¹t generate any error, and in fact does >> delete >> the database entries from the table... But it doesn¹t remove the user¹s >> directory. Why is that? >> >> Similarly, this is the code for deleting the file: >> >> > $db = mysql_connect("localhost","usr","pwd"); >> mysql_select_db("mydb",$db); >> $sql = "DELETE FROM file where ID = '$ID'"; >> $result = mysql_query($sql) or DIE("Cannot Do!"); >> unlink($P/$F); >> echo "File Deleted"; >> ?> >> >> Again, no error... The entries in the table get deleted.. But file >> remains >> in the directory. >> >> Any suggestions? >> >> > >>> >> >> > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] unlink() & rmdir() ... Problems.
Ave, Nope... Didn't work. Didn't return an error or anything, didn't delete the folders either! On 8/23/04 8:21 PM, "Richard Whitney" <[EMAIL PROTECTED]> wrote: > Let me clarify: > > system() is like working in a shell > rm -rf forces removal of the directory $file_dir, which you define befiorehand > $ret_val displays to you what happened. if you tget nothing, it did not work. > > HTH! > > Richard > > On Mon, 23 Aug 2004 16:24:23 -0400, PHP Junkie <[EMAIL PROTECTED]> wrote: >> Ave, >> >> Richard... What exactly did you mean by this? >> >> system('rm -rf',$user_dir,$ret_val); >> >> I don't understand. >> >> >> >> >> On 8/23/04 12:11 PM, "Richard Whitney" <[EMAIL PROTECTED]> wrote: >> >>> system('rm -rf',$user_dir,$ret_val); >>> >>> On Mon, 23 Aug 2004 11:57:35 -0400, PHP Junkie <[EMAIL PROTECTED]> wrote: Ave, I do not really know what the problem is because I don't get an error, and in fact my scripts execute fine... Except that, niether is the directory deleted, nor is the file deleted. Only corresponding database entries are deleted which I specify in my SQL code. There are 2 different functions in 2 separate places in my File Manager. 1 function deletes the User including his Folder The other deletes a particular file. The code I'm using to delete the User & his Folder is: >>> if($delete_user) { $db = mysql_connect("localhost","usr","pwd"); mysql_select_db("mydb",$db); $sql = "DELETE FROM user where login = '$user'"; $result = mysql_query($sql) or die("There is a problem."); $sql2 = "DELETE FROM file where login = '$user'"; $result2 = mysql_query($sql2) or die("There is a problem."); rmdir (imsafm/$user); echo "User $user deleted."; } ?> The name of Folder of a user is the same as his Login. Anyhow... The above code doesn¹t generate any error, and in fact does delete the database entries from the table... But it doesn¹t remove the user¹s directory. Why is that? Similarly, this is the code for deleting the file: >>> $db = mysql_connect("localhost","usr","pwd"); mysql_select_db("mydb",$db); $sql = "DELETE FROM file where ID = '$ID'"; $result = mysql_query($sql) or DIE("Cannot Do!"); unlink($P/$F); echo "File Deleted"; ?> Again, no error... The entries in the table get deleted.. But file remains in the directory. Any suggestions? >>> >> >> > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] unlink() & rmdir() ... Problems.
Ave, Richard... What exactly did you mean by this? system('rm -rf',$user_dir,$ret_val); I don't understand. On 8/23/04 12:11 PM, "Richard Whitney" <[EMAIL PROTECTED]> wrote: > system('rm -rf',$user_dir,$ret_val); > > On Mon, 23 Aug 2004 11:57:35 -0400, PHP Junkie <[EMAIL PROTECTED]> wrote: >> Ave, >> >> I do not really know what the problem is because I don't get an error, and >> in fact my scripts execute fine... Except that, niether is the directory >> deleted, nor is the file deleted. Only corresponding database entries are >> deleted which I specify in my SQL code. >> >> There are 2 different functions in 2 separate places in my File Manager. >> 1 function deletes the User including his Folder >> The other deletes a particular file. >> >> The code I'm using to delete the User & his Folder is: >> >> > if($delete_user) { >> $db = mysql_connect("localhost","usr","pwd"); >> mysql_select_db("mydb",$db); >> $sql = "DELETE FROM user where login = '$user'"; >> $result = mysql_query($sql) or die("There is a problem."); >> $sql2 = "DELETE FROM file where login = '$user'"; >> $result2 = mysql_query($sql2) or die("There is a problem."); >> rmdir (imsafm/$user); >> echo "User $user deleted."; >> } >> ?> >> >> The name of Folder of a user is the same as his Login. >> Anyhow... The above code doesn¹t generate any error, and in fact does delete >> the database entries from the table... But it doesn¹t remove the user¹s >> directory. Why is that? >> >> Similarly, this is the code for deleting the file: >> >> > $db = mysql_connect("localhost","usr","pwd"); >> mysql_select_db("mydb",$db); >> $sql = "DELETE FROM file where ID = '$ID'"; >> $result = mysql_query($sql) or DIE("Cannot Do!"); >> unlink($P/$F); >> echo "File Deleted"; >> ?> >> >> Again, no error... The entries in the table get deleted.. But file remains >> in the directory. >> >> Any suggestions? >> >> > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] unlink() & rmdir() ... Problems.
On Tuesday 24 August 2004 01:55, PHP Junkie wrote: > I do have the original permission set to CHMOD 777 thus the uploads are > working fine. > > I had presumed that anything uploaded by the server is owned by it thus I > wouldn't have to interfere with the permissions thereafter... But somehow > that doesn't seem to be working out. > > I did actually set the permissions for group "nobody" to 'Read & Write'... > But I'm still there. The Files or Folders are not getting deleted. In order for a user to delete a file they must have: 1) 'x' permission for all directories in the path 2) 'wx' permission for the directory containing the file NB the permissions on the files themselves are irrelevant. -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* The meta-Turing test counts a thing as intelligent if it seeks to devise and apply Turing tests to objects of its own creation. -- Lew Mammel, Jr. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] unlink() & rmdir() ... Problems.
On Tuesday 24 August 2004 02:32, John Nichel wrote: > Jason Wong wrote > > > phpinfo() is your friend. > > I thought phpinfo() was *MY* friend??? ;) Don't worry it's a one-to-many relationship. -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* Women reason with the heart and are much less often wrong than men who reason with the head. -- DeLescure */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] unlink() & rmdir() ... Problems.
I guess phpinfo() is *OUR* friend!! Great guy! Although I'd be happier if my files & folders started getting deleted with the script, which still ain't happening. On 8/23/04 2:32 PM, "John Nichel" <[EMAIL PROTECTED]> wrote: > Jason Wong wrote >> phpinfo() is your friend. >> > > I thought phpinfo() was *MY* friend??? ;) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] unlink() & rmdir() ... Problems.
Jason Wong wrote phpinfo() is your friend. I thought phpinfo() was *MY* friend??? ;) -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] unlink() & rmdir() ... Problems.
On Tuesday 24 August 2004 00:34, PHP Junkie wrote: > How do I find out which user/group my web server is running as? > I'm running an Apache Web Server on my Power MAC G5 (Mac OS X) machine. > I can change the user/group permissions... But which user/group does the > web server use? phpinfo() is your friend. -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* Absence diminishes mediocre passions and increases great ones, as the wind blows out candles and fans fires. -- La Rochefoucauld */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] unlink() & rmdir() ... Problems.
Ave, I do have the original permission set to CHMOD 777 thus the uploads are working fine. I had presumed that anything uploaded by the server is owned by it thus I wouldn't have to interfere with the permissions thereafter... But somehow that doesn't seem to be working out. I did actually set the permissions for group "nobody" to 'Read & Write'... But I'm still there. The Files or Folders are not getting deleted. Ave. On 8/23/04 1:41 PM, "Jonathan Haddad" <[EMAIL PROTECTED]> wrote: > the chmod 666 sets the exisiting files to be edited by the server. > anything that's uploaded by the server is owned by it, and thusly can be > edited. > > as a side note, you'd have to chmod 777 the directory to be edited if > you want uploads to work. > > PHP Junkie wrote: > >> Ave, >> >> Well here's my situation... >> You see the File Manager allows users to Upload files ... Once a user >> uploads the file... It resides in a particular folder on my server. Users >> will be constantly uploading, downloading, deleting files. I can't possibly >> CHMOD 777 all the time... >> >> My question is... If I select the "nobody" group for the base folder where >> the files are stored & created... Will all the directories & files which are >> created later by the users using the website therein have the permissions to >> be deleted, if I set the permissions to read & write on that base folder? >> >> Thanks. >> >> >> >> >> On 8/23/04 12:48 PM, "Jay Blanchard" <[EMAIL PROTECTED]> >> wrote: >> >> >> >>> [snip] >>> How do I find out which user/group my web server is running as? >>> I'm running an Apache Web Server on my Power MAC G5 (Mac OS X) machine. >>> I can change the user/group permissions... But which user/group does the >>> web >>> server use? >>> [/snip] >>> >>> For security reasons Apache typically runs as "nobody" >>> >>> >>> >>> >> >> >> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] unlink() & rmdir() ... Problems.
the chmod 666 sets the exisiting files to be edited by the server. anything that's uploaded by the server is owned by it, and thusly can be edited. as a side note, you'd have to chmod 777 the directory to be edited if you want uploads to work. PHP Junkie wrote: Ave, Well here's my situation... You see the File Manager allows users to Upload files ... Once a user uploads the file... It resides in a particular folder on my server. Users will be constantly uploading, downloading, deleting files. I can't possibly CHMOD 777 all the time... My question is... If I select the "nobody" group for the base folder where the files are stored & created... Will all the directories & files which are created later by the users using the website therein have the permissions to be deleted, if I set the permissions to read & write on that base folder? Thanks. On 8/23/04 12:48 PM, "Jay Blanchard" <[EMAIL PROTECTED]> wrote: [snip] How do I find out which user/group my web server is running as? I'm running an Apache Web Server on my Power MAC G5 (Mac OS X) machine. I can change the user/group permissions... But which user/group does the web server use? [/snip] For security reasons Apache typically runs as "nobody" -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] unlink() & rmdir() ... Problems.
Ave, Well here's my situation... You see the File Manager allows users to Upload files ... Once a user uploads the file... It resides in a particular folder on my server. Users will be constantly uploading, downloading, deleting files. I can't possibly CHMOD 777 all the time... My question is... If I select the "nobody" group for the base folder where the files are stored & created... Will all the directories & files which are created later by the users using the website therein have the permissions to be deleted, if I set the permissions to read & write on that base folder? Thanks. On 8/23/04 12:48 PM, "Jay Blanchard" <[EMAIL PROTECTED]> wrote: > [snip] > How do I find out which user/group my web server is running as? > I'm running an Apache Web Server on my Power MAC G5 (Mac OS X) machine. > I can change the user/group permissions... But which user/group does the > web > server use? > [/snip] > > For security reasons Apache typically runs as "nobody" > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] unlink() & rmdir() ... Problems.
PHP Junkie wrote: Ave, How do I find out which user/group my web server is running as? I'm running an Apache Web Server on my Power MAC G5 (Mac OS X) machine. I can change the user/group permissions... But which user/group does the web server use? Default setup? Probably nobody/nobody. Check your httpd.conf (at least for Apache 1.3.x, I don't know where it's set for Apache 2). Read up on user/group on the Apache website. http://httpd.apache.org -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] unlink() & rmdir() ... Problems.
PHP probably does not have permission to change those files. chmod 777 and it should work. However now those files are writable by anyone. If you're on a shared server there could be problems later. Jon PHP Junkie wrote: Ave, I do not really know what the problem is because I don't get an error, and in fact my scripts execute fine... Except that, niether is the directory deleted, nor is the file deleted. Only corresponding database entries are deleted which I specify in my SQL code. There are 2 different functions in 2 separate places in my File Manager. 1 function deletes the User including his Folder The other deletes a particular file. The code I'm using to delete the User & his Folder is: User $user deleted."; } ?> The name of Folder of a user is the same as his Login. Anyhow... The above code doesn¹t generate any error, and in fact does delete the database entries from the table... But it doesn¹t remove the user¹s directory. Why is that? Similarly, this is the code for deleting the file: File Deleted"; ?> Again, no error... The entries in the table get deleted.. But file remains in the directory. Any suggestions? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] unlink() & rmdir() ... Problems.
[snip] How do I find out which user/group my web server is running as? I'm running an Apache Web Server on my Power MAC G5 (Mac OS X) machine. I can change the user/group permissions... But which user/group does the web server use? [/snip] For security reasons Apache typically runs as "nobody" -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] unlink() & rmdir() ... Problems.
Ave, How do I find out which user/group my web server is running as? I'm running an Apache Web Server on my Power MAC G5 (Mac OS X) machine. I can change the user/group permissions... But which user/group does the web server use? Thanks. On 8/23/04 12:08 PM, "John Nichel" <[EMAIL PROTECTED]> wrote: > PHP Junkie wrote: >> Again, no error... The entries in the table get deleted.. But file remains >> in the directory. >> >> Any suggestions? > > Neither of these functions return an error. They will return false on > failure. Does the user/group which your web server is running as have > permission to remove these files/directories? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] unlink() & rmdir() ... Problems.
PHP Junkie wrote: Again, no error... The entries in the table get deleted.. But file remains in the directory. Any suggestions? Neither of these functions return an error. They will return false on failure. Does the user/group which your web server is running as have permission to remove these files/directories? -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] unlink() & rmdir() ... Problems.
Ave, I do not really know what the problem is because I don't get an error, and in fact my scripts execute fine... Except that, niether is the directory deleted, nor is the file deleted. Only corresponding database entries are deleted which I specify in my SQL code. There are 2 different functions in 2 separate places in my File Manager. 1 function deletes the User including his Folder The other deletes a particular file. The code I'm using to delete the User & his Folder is: User $user deleted."; } ?> The name of Folder of a user is the same as his Login. Anyhow... The above code doesn¹t generate any error, and in fact does delete the database entries from the table... But it doesn¹t remove the user¹s directory. Why is that? Similarly, this is the code for deleting the file: File Deleted"; ?> Again, no error... The entries in the table get deleted.. But file remains in the directory. Any suggestions?
Re: [PHP] unlink(), is it suppose to delete file???
Yea, got that. Fixed hte problem. Thanks "Miroslav Hudak" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > This could happpen when the file is open by another process,... then > file is deleted, but filename is still there until the file is not free > of any open filedescriptors... I don't know exactly what processes > happens in kernel when deleting the file, but it's something like > that... and it could result in your problem... > > m. > > Scott Fletcher wrote: > > > I have a file that was 25 KB and I use the unlink() to remove the file. > > When I rechecked it, I found that the file is still there but it's filesize > > is 0 KB. Is unlink() suppose to remove the file or what?? > > > > FletchSOD > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] unlink(), why doesn't it delete the file????
See my other post on this one. I don't know, maybe a bug in M$ Outlook or something. (Whistling and looking away from the issues) :-) "Jay Blanchard" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] [snip] I have a file that was 25 KB and I use the unlink() to remove the file. When I rechecked it, I found that the file is still there but it's filesize is 0 KB. Is unlink() suppose to remove the file or what?? [/snip] You do not say what your OS is, but I just tested on Linux and BSD and it 'removed' the file. Why did you post this twice?? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] unlink(), why doesn't it delete the file????
[snip] I have a file that was 25 KB and I use the unlink() to remove the file. When I rechecked it, I found that the file is still there but it's filesize is 0 KB. Is unlink() suppose to remove the file or what?? [/snip] You do not say what your OS is, but I just tested on Linux and BSD and it 'removed' the file. Why did you post this twice?? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] unlink(), is it suppose to delete file???
This could happpen when the file is open by another process,... then file is deleted, but filename is still there until the file is not free of any open filedescriptors... I don't know exactly what processes happens in kernel when deleting the file, but it's something like that... and it could result in your problem... m. Scott Fletcher wrote: I have a file that was 25 KB and I use the unlink() to remove the file. When I rechecked it, I found that the file is still there but it's filesize is 0 KB. Is unlink() suppose to remove the file or what?? FletchSOD -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] unlink(), is it suppose to delete file???
I have a file that was 25 KB and I use the unlink() to remove the file. When I rechecked it, I found that the file is still there but it's filesize is 0 KB. Is unlink() suppose to remove the file or what?? FletchSOD -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] unlink(), why doesn't it delete the file????
I have a file that was 25 KB and I use the unlink() to remove the file. When I rechecked it, I found that the file is still there but it's filesize is 0 KB. Is unlink() suppose to remove the file or what?? FletchSOD -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php unlink a file - is it possible?
Unless you change the permissions of the file, the run the FTP as nobody, run apache as the ftp user, run apache as root (can't believe I even said that... blasphemy!), etc., it shouldn't be possible. If you find a way to do it w/out any of the above, I'd suggest you email the Apache Software Foundation and/or the FTP software people, as well as [EMAIL PROTECTED], [EMAIL PROTECTED], etc. That being said, would it be feasible to set up a cron job to do this w/ the PHP CLI running as an appropriatly privledged user? On Wednesday 08 October 2003 08:11 pm, Alex Shi wrote: > Hi, > > How can have a php script unlink/delete a file uploaded via FTP? > Usually a ftp-uploaded file belongs to the ftp user, and a php > script is running by apache/nobody. Seems like there shouldn't > be any way to do this...OK, my situation is that I want a php script > to this: it can move bulk uploaded (ftp) file to certain directories > and then remove the original files, something just like a "move". > If anyone knows on how to "move" or "delete" a file, please give > me a hand. Thanks in advance! > > Alex -- Evan Nemerson [EMAIL PROTECTED] -- "Who controls the past controls the future. Who controls the present controls the past." -George Orwell -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php unlink a file - is it possible?
Hi, How can have a php script unlink/delete a file uploaded via FTP? Usually a ftp-uploaded file belongs to the ftp user, and a php script is running by apache/nobody. Seems like there shouldn't be any way to do this...OK, my situation is that I want a php script to this: it can move bulk uploaded (ftp) file to certain directories and then remove the original files, something just like a "move". If anyone knows on how to "move" or "delete" a file, please give me a hand. Thanks in advance! Alex -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] unlink problem... please help...
At 16:42 26-2-03, you wrote: $result=unlink('$dir_to_upload/$row->Photo'); what do you get when you echo echo htmlspecialchars('$dir_to_upload/$row->Photo'); and do you use the full file path? Images accept relative links but in my experience PHP's file handling functions want the full path. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] unlink problem... please help...
At 16:42 26.02.2003, Jøran Sørbø spoke out and said: [snip] >Hi! >Ive tried to change the script sometimes now and it still dont work... >i still get the error Warning: unlink() failed (No such file or directory) >and it wont remove the data form the database > >$dir_to_upload is defined in config.php wich is included... >it works just fine to display image using echo "src='$dir_to_upload/$row->Photo'> >$Photo is defined in the following tag in the form name='Photo' value='Photo?>'> > > >the variable $id is defined in the following tag in the form type=hidden name='id' value='ID?>'> [snip] There are also errors in how you format the filename passed to unlink(), and in formatting the SQL statement - see below. Do yourself a favour and make the following modification to your script and look at the output: if (isset($delimage)) { $file = "$dir_to_upload/{$row->Photo}"; $sql = "update product set Photo='nothing', miniPhoto='nothing', " . "picture='0' where ID='$id'"; echo "unlink($file);query($sql);"; $result=unlink($file); $result=mysql_query($sql) or die -- >O Ernest E. Vogelsinger (\) ICQ #13394035 ^ http://www.vogelsinger.at/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] unlink problem... please help...
Hi! Ive tried to change the script sometimes now and it still dont work... i still get the error Warning: unlink() failed (No such file or directory) and it wont remove the data form the database $dir_to_upload is defined in config.php wich is included... it works just fine to display image using echo " $Photo is defined in the following tag in the form the variable $id is defined in the following tag in the form the code i use is: the delete function and update database... // -- delete image - if (isset($delimage)) { $result=unlink('$dir_to_upload/$row->Photo'); $result=mysql_query(" update product set Photo='nothing', miniPhoto='nothing', picture='0' where ID='$id' ") or die (mysql_error(). " : ".mysql_errno()); if ( ($result) != 1) print "Sorry,can't delete the image "; else { print "Image was deleted sucsessfully.If you want to upload a new image do it now,overwise close the window"; } } //- end delete image --- the code to use it... picture == '1') echo " "; else echo "Det er ikke laggt ut no bilde til dette produktet. Klikk her for å legge til bilde "; ?> but when i execute this, i get the following error... Warning: unlink() failed (No such file or directory) in one_product.php on line 178 You have an error in your SQL syntax near '= ' at line 6 : 1064 can anyone please help me with this?? I would also like som help regarding unlinking multiple images... So that it deletes both the original photo and the thumbnail... Best regards, Jøran Sørbø :: Norway "Ernest E Vogelsinger" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] At 16:03 26.02.2003, Jøran Sørbø spoke out and said: [snip] > if (isset($delimage)) > { > >$result=unlink('$dir_to_upload/$Photo'); > > $result=mysql_query(" >update product set > Photo='nothing', > miniPhoto='nothing', > picture='0' > where ID=$id > ") or die (mysql_error(). " : ".mysql_errno()); > > if ( ($result) != 1) > print "Sorry,can't delete the image "; >else >{ > print "Image was deleted sucsessfully.If you want to upload a >new image do it now,overwise close the window"; > } > > } > >but when i execute this, i get the following error... > >Warning: unlink() failed (No such file or directory) in one_product.php on >line 178 >You have an error in your SQL syntax near '= ' at line 6 : 1064 [snip] 1) You do not define $dir_to_upload, nor $Photo (at least in your example) - this would lead to $result=unlink('/'); hence error 1. 2) You don't define the variable $id (at least in your example), so the SQL statement would read "update product set " . "Photo='nothing', miniPhoto='nothing', picture='0' " . "where ID=" hence error 2 (after "ID="). If these values are available on a global level, you must declare them global within your function. -- >O Ernest E. Vogelsinger (\) ICQ #13394035 ^ http://www.vogelsinger.at/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] unlink problem... please help...
At 16:03 26.02.2003, Jøran Sørbø spoke out and said: [snip] > if (isset($delimage)) > { > >$result=unlink('$dir_to_upload/$Photo'); > > $result=mysql_query(" >update product set > Photo='nothing', > miniPhoto='nothing', > picture='0' > where ID=$id > ") or die (mysql_error(). " : ".mysql_errno()); > > if ( ($result) != 1) > print "Sorry,can't delete the image "; >else >{ > print "Image was deleted sucsessfully.If you want to upload a >new image do it now,overwise close the window"; > } > > } > >but when i execute this, i get the following error... > >Warning: unlink() failed (No such file or directory) in one_product.php on >line 178 >You have an error in your SQL syntax near '= ' at line 6 : 1064 [snip] 1) You do not define $dir_to_upload, nor $Photo (at least in your example) - this would lead to $result=unlink('/'); hence error 1. 2) You don't define the variable $id (at least in your example), so the SQL statement would read "update product set " . "Photo='nothing', miniPhoto='nothing', picture='0' " . "where ID=" hence error 2 (after "ID="). If these values are available on a global level, you must declare them global within your function. -- >O Ernest E. Vogelsinger (\) ICQ #13394035 ^ http://www.vogelsinger.at/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] unlink problem... please help...
Hi! Im developing a site using php and mysql and need som help... The site is a simple company site and it gets products, pictures etc from the database... Everyhing worls great except deleting product images from the database, and unlink them from the directory... the code i use is: the delete function and update database... // -- delete image - if (isset($delimage)) { $result=unlink('$dir_to_upload/$Photo'); $result=mysql_query(" update product set Photo='nothing', miniPhoto='nothing', picture='0' where ID=$id ") or die (mysql_error(). " : ".mysql_errno()); if ( ($result) != 1) print "Sorry,can't delete the image "; else { print "Image was deleted sucsessfully.If you want to upload a new image do it now,overwise close the window"; } } //- end delete image --- the code to use it... picture == '1') echo " "; else echo "Det er ikke laggt ut no bilde til dette produktet. Klikk her for å legge til bilde "; ?> but when i execute this, i get the following error... Warning: unlink() failed (No such file or directory) in one_product.php on line 178 You have an error in your SQL syntax near '= ' at line 6 : 1064 can anyone please help me with this?? I would also like som help regarding unlinking multiple images... So that it deletes both the original photo and the thumbnail... Best regards, Jøran Sørbø :: Norway -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Fw: [PHP] unlink ($files);
Hi, You can use the backtick operator to delete whatever you have permissions to delete: $directory = "path/*.*"; `rm -rf $directory`; They aren't quotes, they are backticks (to the left of the 1 key on most keyboards). It is very useful for any command line stuff you have permissions to do. Brian Allen [EMAIL PROTECTED] "Paul Nicholson" <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>... > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > Hey, > You can't delete the files all at onceyou have to delete them one by one > or use this function that will remove full directories. > - - > function force_rmdirs($dir) { > $dh = opendir($dir); > while(false !== ($file = readdir($dh))) { > if($file != '.' && $file != '..') { > $path = $dir .'/'. $file; > if(is_dir($path)) { > force_rmdirs($path); > } else { > unlink($path); > } > } > } > closedir($dh ); > return rmdir($dir); > } > - - > HTH! > ~Paul > > On Wednesday 08 January 2003 12:29 am, [EMAIL PROTECTED] wrote: > > Ok, Jason, here's another one! > > > > I think I've read how to delete a file. > > I need to delete 25 files, then do a rmdir(blah); > > > > Line 16: $directory = "path/*.*"; > > Warning: Unlink failed (No such file or directory) in > > /mnt/ls6/17/169//htdocs/2003/_admin/del_listing_action.php on line > > 16 > > > > Warning: RmDir failed (File exists) in > > /mnt/ls6/17/169//htdocs/2003/_admin/del_listing_action.php on line > > 17 > > > > Thanks > > - -- > ~Paul Nicholson > Design Specialist @ WebPower Design > [EMAIL PROTECTED] > www.webpowerdesign.net > "The webthe way you want it!" > > > "It said uses Windows 98 or better, so I loaded Linux!" > Registered Linux User #183202 using Register Linux System # 81891 > -BEGIN PGP SIGNATURE- > Version: GnuPG v1.0.6 (GNU/Linux) > Comment: For info see http://www.gnupg.org > > iD8DBQE+G8/JDyXNIUN3+UQRAmd/AJ42CW5HDYEQ1dvf/m5CLynoqGekwgCdE5T2 > rxlRjVBaFNIhQGFQc38ylks= > =mJq1 > -END PGP SIGNATURE- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php