PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > php.general > How to determine if file is writable and deletable
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
How to determine if file is writable and deletable

Réponse
 
LinkBack Outils de la discussion
Vieux 07/05/2008, 17h16   #1
Al
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut How to determine if file is writable and deletable

I need to determine if a file is truly deletable by a php script, Deleting permissions seem to be
the same as writing, they probably have the same criteria.

is_writable() seems to virtually useless in most cases. It doesn't take into account the directory
ownership/permissions; which, best I can tell, is the real determining factor.

I've resorted to having to determine the directory's ownership and then compare the directory's
rights with the owner's and then the other ['world'].

E.g., Assume my script was loaded with ftp, so it's ownership is the site-name, and I want the scrip
to be able to determine if it can delete a file. Thus, the file in question must have its "other"
permissions include write.

Surely, there must be an easier way.

Thanks, Al........
  Réponse avec citation
Vieux 07/05/2008, 17h20   #2
Aschwin Wesselius
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] How to determine if file is writable and deletable

Al wrote:
> I need to determine if a file is truly deletable by a php script,
> Deleting permissions seem to be the same as writing, they probably
> have the same criteria.
>
> is_writable() seems to virtually useless in most cases. It doesn't
> take into account the directory ownership/permissions; which, best I
> can tell, is the real determining factor.
>
> I've resorted to having to determine the directory's ownership and
> then compare the directory's rights with the owner's and then the
> other ['world'].
>
> E.g., Assume my script was loaded with ftp, so it's ownership is the
> site-name, and I want the scrip to be able to determine if it can
> delete a file. Thus, the file in question must have its "other"
> permissions include write.
>
> Surely, there must be an easier way.
>
> Thanks, Al........
>

Hi,

Maybe this is what you need:

http://nl.php.net/manual/en/function.fileperms.php
--

Aschwin Wesselius

/'What you would like to be done to you, do that to the other....'/

  Réponse avec citation
Vieux 07/05/2008, 17h24   #3
Al
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] How to determine if file is writable and deletable

You are missing the point of my question. I don't have a problem reading the permissions. They do
not solely determine whether a file can be deleted.

Aschwin Wesselius wrote:
> Al wrote:
>> I need to determine if a file is truly deletable by a php script,
>> Deleting permissions seem to be the same as writing, they probably
>> have the same criteria.
>>
>> is_writable() seems to virtually useless in most cases. It doesn't
>> take into account the directory ownership/permissions; which, best I
>> can tell, is the real determining factor.
>>
>> I've resorted to having to determine the directory's ownership and
>> then compare the directory's rights with the owner's and then the
>> other ['world'].
>>
>> E.g., Assume my script was loaded with ftp, so it's ownership is the
>> site-name, and I want the scrip to be able to determine if it can
>> delete a file. Thus, the file in question must have its "other"
>> permissions include write.
>>
>> Surely, there must be an easier way.
>>
>> Thanks, Al........
>>

> Hi,
>
> Maybe this is what you need:
>
> http://nl.php.net/manual/en/function.fileperms.php

  Réponse avec citation
Vieux 07/05/2008, 19h00   #4
robinv@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] How to determine if file is writable and deletable

On 07/05/2008, Al <news@ridersite.org> wrote:
> I need to determine if a file is truly deletable by a php script, Deleting
> permissions seem to be
> the same as writing, they probably have the same criteria.


You're not writing to the file, you're unlinking it from the
containing directory, so it's the directory's permissions that matter,
not the file's.

All you really need to do is check that the directory is_writable()

is_writable(dirname($filename));

-robin
  Réponse avec citation
Vieux 07/05/2008, 19h06   #5
Thiago Pojda
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut RES: [PHP] How to determine if file is writable and deletable

If it's not, what else can? I got curious.


Regards,
Thiago Henrique Pojda

-----Mensagem original-----
De: Al [mailto:news@ridersite.org]
Enviada em: quarta-feira, 7 de maio de 2008 12:25
Para: php-general@lists.php.net
Assunto: Re: [php] How to determine if file is writable and deletable

You are missing the point of my question. I don't have a problem reading the
permissions. They do
not solely determine whether a file can be deleted.

Aschwin Wesselius wrote:
> Al wrote:
>> I need to determine if a file is truly deletable by a php script,
>> Deleting permissions seem to be the same as writing, they probably
>> have the same criteria.
>>
>> is_writable() seems to virtually useless in most cases. It doesn't
>> take into account the directory ownership/permissions; which, best I
>> can tell, is the real determining factor.
>>
>> I've resorted to having to determine the directory's ownership and
>> then compare the directory's rights with the owner's and then the
>> other ['world'].
>>
>> E.g., Assume my script was loaded with ftp, so it's ownership is the
>> site-name, and I want the scrip to be able to determine if it can
>> delete a file. Thus, the file in question must have its "other"
>> permissions include write.
>>
>> Surely, there must be an easier way.
>>
>> Thanks, Al........
>>

> Hi,
>
> Maybe this is what you need:
>
> http://nl.php.net/manual/en/function.fileperms.php


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




  Réponse avec citation
Vieux 07/05/2008, 22h11   #6
tedd
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] How to determine if file is writable and deletable

At 11:16 AM -0400 5/7/08, Al wrote:
>I need to determine if a file is truly deletable by a php script,
>Deleting permissions seem to be the same as writing, they probably
>have the same criteria.
>
>is_writable() seems to virtually useless in most cases. It doesn't
>take into account the directory ownership/permissions; which, best I
>can tell, is the real determining factor.
>
>I've resorted to having to determine the directory's ownership and
>then compare the directory's rights with the owner's and then the
>other ['world'].
>
>E.g., Assume my script was loaded with ftp, so it's ownership is the
>site-name, and I want the scrip to be able to determine if it can
>delete a file. Thus, the file in question must have its "other"
>permissions include write.
>
>Surely, there must be an easier way.
>
>Thanks, Al........



Perhaps touch might .

http://nl.php.net/manual/en/function.touch.php

Cheers,

tedd


--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
  Réponse avec citation
Vieux 07/05/2008, 22h18   #7
Richard Heyes
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] How to determine if file is writable and deletable

> Perhaps touch might .

Touch my ass.

ROFLMAO

(I've been waiting for years to use that one)

--
Richard Heyes

+----------------------------------------+
| Access SSH with a Windows mapped drive |
| http://www.phpguru.org/sftpdrive |
+----------------------------------------+
  Réponse avec citation
Vieux 07/05/2008, 22h43   #8
tedd
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] How to determine if file is writable and deletable

At 9:18 PM +0100 5/7/08, Richard Heyes wrote:
>>Perhaps touch might .

>
>Touch my ass.
>
>ROFLMAO
>
>(I've been waiting for years to use that one)



It won't work?

Cheers,

tedd

--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
  Réponse avec citation
Vieux 07/05/2008, 22h51   #9
Richard Heyes
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] How to determine if file is writable and deletable

> It won't work?

No idea, it was just a rather poor play on words.

--
Richard Heyes

+----------------------------------------+
| Access SSH with a Windows mapped drive |
| http://www.phpguru.org/sftpdrive |
+----------------------------------------+
  Réponse avec citation
Vieux 12/05/2008, 00h09   #10
Al
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: How to determine if file is writable and deletable

I ended up using posix_access() which is what is_writeable() should be. is_writeable() is virtually
useless.

Al wrote:
> I need to determine if a file is truly deletable by a php script,
> Deleting permissions seem to be the same as writing, they probably have
> the same criteria.
>
> is_writable() seems to virtually useless in most cases. It doesn't take
> into account the directory ownership/permissions; which, best I can
> tell, is the real determining factor.
>
> I've resorted to having to determine the directory's ownership and then
> compare the directory's rights with the owner's and then the other
> ['world'].
>
> E.g., Assume my script was loaded with ftp, so it's ownership is the
> site-name, and I want the scrip to be able to determine if it can delete
> a file. Thus, the file in question must have its "other" permissions
> include write.
>
> Surely, there must be an easier way.
>
> Thanks, Al........

  Réponse avec citation
Vieux 12/05/2008, 03h47   #11
Robert Cummings
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] Re: How to determine if file is writable and deletable


On Sun, 2008-05-11 at 18:09 -0400, Al wrote:
> I ended up using posix_access() which is what is_writeable() should be. is_writeable() is virtually
> useless.


So you're saying is_writeable() shouldn't work on Windows systems? :p
Seems you want is_writeable() to sing AND dance... perhaps too much
expecting.

Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

  Réponse avec citation
Vieux 12/05/2008, 04h49   #12
Shawn McKenzie
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: How to determine if file is writable and deletable

Al wrote:
> I ended up using posix_access() which is what is_writeable() should be.
> is_writeable() is virtually useless.
>
> Al wrote:
>> I need to determine if a file is truly deletable by a php script,
>> Deleting permissions seem to be the same as writing, they probably
>> have the same criteria.
>>
>> is_writable() seems to virtually useless in most cases. It doesn't
>> take into account the directory ownership/permissions; which, best I
>> can tell, is the real determining factor.
>>
>> I've resorted to having to determine the directory's ownership and
>> then compare the directory's rights with the owner's and then the
>> other ['world'].
>>
>> E.g., Assume my script was loaded with ftp, so it's ownership is the
>> site-name, and I want the scrip to be able to determine if it can
>> delete a file. Thus, the file in question must have its "other"
>> permissions include write.
>>
>> Surely, there must be an easier way.
>>
>> Thanks, Al........

Not if you read Robin's post.

-Shawn
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 20h52.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,19063 seconds with 20 queries