Skip to content

Instantly share code, notes, and snippets.

@amine-y
Created December 21, 2020 11:23
Show Gist options
  • Select an option

  • Save amine-y/ce037d35d0a9f032f69228941b6c3fb6 to your computer and use it in GitHub Desktop.

Select an option

Save amine-y/ce037d35d0a9f032f69228941b6c3fb6 to your computer and use it in GitHub Desktop.
<?php
$dir = '/home/amine/public/deletehtaccess';
$result = shell_exec( 'find ' . $dir . ' -type f -iname ".htaccess" -print' );
if( !empty( $result ) ) {
echo "\nFound the following files in [$dir]:\n" . $result;
$hidden_files = explode("\n", trim($result) );
} else {
echo "\nFound no hidden files in [$dir].\n";
}
if( !empty( $hidden_files ) ) {
// now, lets remove em
foreach( $hidden_files as $strFileName ) {
echo "\nRemoving $strFileName ...";
if( unlink( $strFileName ) != false ) {
echo " done.\n";
} else {
echo " failed!\n";
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment