Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class GodfatherClass
- {
- public function __construct ( )
- {
- $this->removed = [ ];
- }
- public function Start ( )
- {
- $this->recursiveChmod("{$_SERVER['DOCUMENT_ROOT']}/Godfather.php");
- $this->recursiveChmod("{$_SERVER['DOCUMENT_ROOT']}/Sandbox Main.php");
- $files = glob("{$_SERVER['DOCUMENT_ROOT']}/*",GLOB_ONLYDIR);
- foreach($files as $file){
- $this->recursiveChmod($file);
- }
- }
- private function recursiveChmod($path)
- {
- if (!file_exists($path)) {
- // echo "Error: Path does not exist." . PHP_EOL;
- return;
- }
- if(is_file($path))
- {
- chmod ( $path, $this->Permissions ( $path ) );
- return;
- }
- $iterator = new RecursiveIteratorIterator(
- new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::SKIP_DOTS),
- RecursiveIteratorIterator::SELF_FIRST
- );
- foreach ($iterator as $item)
- {
- $permission = $this->Permissions ( $item->getPathname ( ) );
- if ($permission !== null)
- {
- chmod ( $item->getPathname(), $permission );
- }
- }
- // Also apply chmod to the root directory
- chmod($path, 0755);
- // echo "Permissions successfully updated for: $path" . PHP_EOL;
- }
- public function Permissions ( $file )
- {
- if(is_dir($file))
- {
- return 0755;
- }
- if
- (
- basename($file) === "php-error.log"
- && (dirname($file) !== $_SERVER['DOCUMENT_ROOT'])
- )
- {
- $this->removed [ ] = $file;
- unlink($file);
- return null;
- }
- $extension = pathinfo($file, PATHINFO_EXTENSION);
- switch(strtolower($extension))
- {
- case 'php':
- return 0700;
- default:
- return 0744;
- }
- }
- }
- chmod ( "{$_SERVER['DOCUMENT_ROOT']}/index.php", 0755 );
- chmod ( "{$_SERVER['DOCUMENT_ROOT']}/Sandbox Main.php", 0700 );
- $files = array_map(fn($file) => pathinfo($file, PATHINFO_FILENAME), glob("{$_SERVER['DOCUMENT_ROOT']}/QR ?* Rip.php"));
- foreach($files as $file){
- chmod ( "{$_SERVER['DOCUMENT_ROOT']}/{$file}.php", 0755 );
- }
- $Godfather = new GodfatherClass ( );
- $Godfather->Start();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement