Print

Printed September 8, 2010 from B&T's Tips & Scripts
http://tips-scripts.com


Deleting php.ini files

You can find another Tip on this page for how to create a custom php.ini file.  And another for how to populate directories with your php.ini file in the event your host requires you to have one in each directory with php scripts.  But then if you want to delete all the php.ini files, you may need this script.  It will delete any php.ini file from your main public directory and all subdirectories.

You can download this script as a .txt file.  Remember to rename the file as a .php file.

- - Start Script Here - -
<?php
// this script will delete all your php.ini files
// full path to the location of your home directory
$path "/home/" get_current_user() . "/public_html";
// change nothing below this line
function search($dir) {
  foreach(
scandir($dir) as $filename) {
    if ( 
$filename !== '.' AND $filename !== '..' AND is_dir("$dir/$filename") ) {
      
$path $dir."/".$filename
      
$target $path "/php.ini";
      if (
file_exists($target)) {
        if (
unlink($target)) echo "Deleted - $target <br>"; else echo "<b>Delete failed for $target </b><br>";
      }
      
search($path);
    }
  }
}
$target $path "/php.ini";
if (
file_exists($target)) {
  echo 
"Deleting - $target <br>";
  if (!
unlink($target)) echo "<b>Delete failed for $target </b><br>";
}
search($path);
echo 
"<br>Done.";
?> 

- - End Script Here - -