TheUnknown Posted May 27, 2009 Share Posted May 27, 2009 Im attempting to delete install.php off my sever if it exist $installphp = 'install.php'; if (file_exists($installphp)){ $killinstall = "install.php"; mkdir('install.php', 0777); unlink(@$killinstall); } Warning: mkdir() [function.mkdir]: Warning: unlink(install.php) [function.unlink]: Permission denied in permissons are corrent Is there another function that that deletes files of a server besides this one? Quote Link to comment https://forums.phpfreaks.com/topic/159957-delete-install/ Share on other sites More sharing options...
TheUnknown Posted May 27, 2009 Author Share Posted May 27, 2009 mkdir('install.php', 0777); that dont need to be in there sorry Quote Link to comment https://forums.phpfreaks.com/topic/159957-delete-install/#findComment-843663 Share on other sites More sharing options...
Maq Posted May 27, 2009 Share Posted May 27, 2009 Is there another function that that deletes files of a server besides this one? What OS is your server on? Quote Link to comment https://forums.phpfreaks.com/topic/159957-delete-install/#findComment-843664 Share on other sites More sharing options...
Ken2k7 Posted May 27, 2009 Share Posted May 27, 2009 I think you mean chmod('install.php', 0777); Quote Link to comment https://forums.phpfreaks.com/topic/159957-delete-install/#findComment-843666 Share on other sites More sharing options...
TheUnknown Posted May 27, 2009 Author Share Posted May 27, 2009 @ maq well the thing is im making a bulletin board script so it will be compatible with ------------- this code will be ran on tons of sites Quote Link to comment https://forums.phpfreaks.com/topic/159957-delete-install/#findComment-843667 Share on other sites More sharing options...
TheUnknown Posted May 27, 2009 Author Share Posted May 27, 2009 ok this is what i have $installphp = 'install.php'; if (file_exists($installphp)){ $killinstall = "install.php"; chmod('install.php', 0777); unlink(@$killinstall); } i get the same permission error Quote Link to comment https://forums.phpfreaks.com/topic/159957-delete-install/#findComment-843670 Share on other sites More sharing options...
MadTechie Posted May 27, 2009 Share Posted May 27, 2009 also are you trying to do this from inside install.php ? Quote Link to comment https://forums.phpfreaks.com/topic/159957-delete-install/#findComment-843671 Share on other sites More sharing options...
TheUnknown Posted May 27, 2009 Author Share Posted May 27, 2009 No the code is coming from a admin.php file that i wrote that is located in the same directory as install.php Quote Link to comment https://forums.phpfreaks.com/topic/159957-delete-install/#findComment-843672 Share on other sites More sharing options...
Ken2k7 Posted May 27, 2009 Share Posted May 27, 2009 Going back to Maq's question, what OS is your server running? Back when I was using Windows, I had to use chown() to nobody just to delete a file. I don't know why. Quote Link to comment https://forums.phpfreaks.com/topic/159957-delete-install/#findComment-843673 Share on other sites More sharing options...
MadTechie Posted May 28, 2009 Share Posted May 28, 2009 meah.. try this <?php $installphp = dirname(__FILE__).'/install.php'; if (file_exists($installphp)){ chmod($installphp, 0777); $handle = fopen($installphp, 'w+'); fclose($handle); @unlink($installphp); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/159957-delete-install/#findComment-843679 Share on other sites More sharing options...
Maq Posted May 28, 2009 Share Posted May 28, 2009 Going back to Maq's question, what OS is your server running? Back when I was using Windows, I had to use chown() to nobody just to delete a file. I don't know why. He said he wants it to be platform independent: @ maq well the thing is im making a bulletin board script so it will be compatible with ------------- this code will be ran on tons of sites @OP: Do you ever open this file? Because you would have to fclose it first. Quote Link to comment https://forums.phpfreaks.com/topic/159957-delete-install/#findComment-843680 Share on other sites More sharing options...
TheUnknown Posted May 28, 2009 Author Share Posted May 28, 2009 its a linuux poowered server Quote Link to comment https://forums.phpfreaks.com/topic/159957-delete-install/#findComment-843681 Share on other sites More sharing options...
TheUnknown Posted May 28, 2009 Author Share Posted May 28, 2009 Going back to Maq's question, what OS is your server running? Back when I was using Windows, I had to use chown() to nobody just to delete a file. I don't know why. He said he wants it to be platform independent: @ maq well the thing is im making a bulletin board script so it will be compatible with ------------- this code will be ran on tons of sites @OP: Do you ever open this file? Because you would have to fclose it first. fopen is not used in the file that needs deleted so i would assume it dont need closed Please correct me if i said something wrong Quote Link to comment https://forums.phpfreaks.com/topic/159957-delete-install/#findComment-843685 Share on other sites More sharing options...
MadTechie Posted May 28, 2009 Share Posted May 28, 2009 Any luck with the code i posted ? Quote Link to comment https://forums.phpfreaks.com/topic/159957-delete-install/#findComment-843687 Share on other sites More sharing options...
TheUnknown Posted May 28, 2009 Author Share Posted May 28, 2009 @ mad while using your code Warning: chmod() [function.chmod]: Operation not permitted in file remains on the server Quote Link to comment https://forums.phpfreaks.com/topic/159957-delete-install/#findComment-843692 Share on other sites More sharing options...
TheUnknown Posted May 28, 2009 Author Share Posted May 28, 2009 mad i have a question about your code. Im wondering why open it then close the file before the attempt of deletion? Im not saying this is wrong or stupid or correct or border line genius . just curious $handle = fopen($installphp, 'w+'); fclose($handle); Quote Link to comment https://forums.phpfreaks.com/topic/159957-delete-install/#findComment-843697 Share on other sites More sharing options...
MadTechie Posted May 28, 2009 Share Posted May 28, 2009 the file remains but is it empty ? Operation not permitted normally means the account php is running is doesn't have owner access, are you sure the permissions are correct ? EDIT: that basically truncates the file (wipes its contents) also if an error occured their it gives a better idea what the problem could be Quote Link to comment https://forums.phpfreaks.com/topic/159957-delete-install/#findComment-843701 Share on other sites More sharing options...
TheUnknown Posted May 28, 2009 Author Share Posted May 28, 2009 the file remains but is it empty ? Operation not permitted normally means the account php is running is doesn't have owner access, are you sure the permissions are correct ? EDIT: that basically truncates the file (wipes its contents) also if an error occured their it gives a better idea what the problem could be Oh just noticed the file is EMPTY I take it the code is fine and this is a server issue since the install.php file is set to 777? Oh and thanks for the information its understandable for sure Quote Link to comment https://forums.phpfreaks.com/topic/159957-delete-install/#findComment-843707 Share on other sites More sharing options...
MadTechie Posted May 28, 2009 Share Posted May 28, 2009 well read and write works.. if unlink files atleast its empty Quote Link to comment https://forums.phpfreaks.com/topic/159957-delete-install/#findComment-843716 Share on other sites More sharing options...
TheUnknown Posted May 28, 2009 Author Share Posted May 28, 2009 yeah mad thanks I just comment out the chmod and will tell the user to make user install.php is set to 777 Now when the users loads the admin panel the code will delete the data out of install so there will be 0 security issue. Will just be wasted resources if its ran every time and it will run if the install.php is there Quote Link to comment https://forums.phpfreaks.com/topic/159957-delete-install/#findComment-843721 Share on other sites More sharing options...
gizmola Posted May 28, 2009 Share Posted May 28, 2009 Ok, so there's lots of things that could effect this behavior. -What php version? -In the directory in question give us an ls -lath Quote Link to comment https://forums.phpfreaks.com/topic/159957-delete-install/#findComment-843740 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.