unlink()

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
php3ch0
Forum Contributor
Posts: 212
Joined: Sun Nov 13, 2005 7:35 am
Location: Folkestone, Kent, UK

unlink()

Post by php3ch0 »

Can you use unlink() to delete the file it was called in or will this file be open read only?
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

You can on Windows.

Code: Select all

<?php

	unlink("unlink.php");

?>
User avatar
php3ch0
Forum Contributor
Posts: 212
Joined: Sun Nov 13, 2005 7:35 am
Location: Folkestone, Kent, UK

Post by php3ch0 »

I take it that you cant on linux. My server is running linux.
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

php3ch0 wrote:I take it that you cant on linux. My server is running linux.
I get a permission denied error on Linux. I take it you're writing an install script?
User avatar
php3ch0
Forum Contributor
Posts: 212
Joined: Sun Nov 13, 2005 7:35 am
Location: Folkestone, Kent, UK

Post by php3ch0 »

Yes I need it to delete itseslf after installing.
Corvin Gröning
Forum Newbie
Posts: 16
Joined: Tue May 03, 2005 1:02 pm

Post by Corvin Gröning »

Why you don't do it like in other install scripts? Simply display a message that the actual file should be deleted because of security issues...
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

What Ive seen other scripts do is check for the existance of the install files prior to allowing the execution of any code.

Code: Select all

if (file_exists('/installation/install.php')) {
   die ('Please delete the .... because.. security.. blah');
}
User avatar
php3ch0
Forum Contributor
Posts: 212
Joined: Sun Nov 13, 2005 7:35 am
Location: Folkestone, Kent, UK

Post by php3ch0 »

That will definately work. I was hoping to do it automatically to save any extra work for the user.

Thanks people
Post Reply