GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   A Quick PHP Question (https://gfy.com/showthread.php?t=589264)

Tipsy 03-21-2006 04:12 PM

A Quick PHP Question
 
Rather than wading through tutorials I thought someone here could probably give a quick answer. All I need is 4 or 5 lines of php code that checks a directory for a certain file and if present deletes it i.e.

check for file /directory/blah.exe
if blah.exe then delete blah.exe
end

It's for a very quick fix on a server with security issues until the various scripts are fully updated etc which will take 48 hours. To be honest it doesn't even need to be php as long as it can be run via cron.

Any help appreciated. Thanks in advance.

woj 03-21-2006 04:18 PM

just:
rm -f /home/bluh/filename

if file doesn't exist, nothing bad will happen

Brujah 03-21-2006 04:19 PM

if ( file_exists( $filename ) ) {
unlink ( $filename );
}

or you should probably use 'find', to delete all blah.exe from the current directory and below, something like
find . -name 'blah.exe' | xargs rm

Tipsy 03-21-2006 04:20 PM

Thanks and you can tell it's been a long day. That's FAR too obvious.

Fuck it - I'm taking a break as it seems I need one.

Tipsy 03-21-2006 04:33 PM

The simple solution managed it but thanks for the PHP. I have another use for that so it's handy to have :)


All times are GMT -7. The time now is 02:49 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2026, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123