Advertisement
jargon

Godfather.php

Feb 19th, 2025
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.02 KB | Gaming | 0 0
  1. <?php
  2.  
  3. class GodfatherClass
  4. {
  5.     public function __construct ( )
  6.     {
  7.         $this->removed = [ ];
  8.     }
  9.    
  10.     public function Start ( )
  11.     {
  12.         $this->recursiveChmod("{$_SERVER['DOCUMENT_ROOT']}/Godfather.php");
  13.         $this->recursiveChmod("{$_SERVER['DOCUMENT_ROOT']}/Sandbox Main.php");
  14.  
  15.         $files = glob("{$_SERVER['DOCUMENT_ROOT']}/*",GLOB_ONLYDIR);
  16.         foreach($files as $file){
  17.             $this->recursiveChmod($file);
  18.         }
  19.     }
  20.  
  21.     private function recursiveChmod($path)
  22.     {
  23.         if (!file_exists($path)) {
  24.             // echo "Error: Path does not exist." . PHP_EOL;
  25.             return;
  26.         }
  27.        
  28.         if(is_file($path))
  29.         {
  30.             chmod ( $path, $this->Permissions ( $path ) );
  31.             return;
  32.         }
  33.    
  34.         $iterator = new RecursiveIteratorIterator(
  35.             new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::SKIP_DOTS),
  36.             RecursiveIteratorIterator::SELF_FIRST
  37.         );
  38.    
  39.         foreach ($iterator as $item)
  40.         {
  41.             $permission = $this->Permissions ( $item->getPathname ( ) );
  42.            
  43.             if ($permission !== null)
  44.             {
  45.                 chmod ( $item->getPathname(), $permission );
  46.             }
  47.         }
  48.    
  49.         // Also apply chmod to the root directory
  50.         chmod($path, 0755);
  51.         // echo "Permissions successfully updated for: $path" . PHP_EOL;
  52.     }
  53.    
  54.     public function Permissions ( $file )
  55.     {
  56.         if(is_dir($file))
  57.         {
  58.             return 0755;
  59.         }
  60.        
  61.         if
  62.         (
  63.             basename($file) === "php-error.log"
  64.             && (dirname($file) !== $_SERVER['DOCUMENT_ROOT'])
  65.         )
  66.         {
  67.             $this->removed [ ] = $file;
  68.             unlink($file);
  69.             return null;
  70.         }
  71.        
  72.         $extension = pathinfo($file, PATHINFO_EXTENSION);
  73.        
  74.         switch(strtolower($extension))
  75.         {
  76.             case 'php':
  77.                 return 0700;
  78.            
  79.             default:
  80.                 return 0744;
  81.         }
  82.     }
  83. }
  84.  
  85. chmod ( "{$_SERVER['DOCUMENT_ROOT']}/index.php", 0755 );
  86. chmod ( "{$_SERVER['DOCUMENT_ROOT']}/Sandbox Main.php", 0700 );
  87.  
  88. $files = array_map(fn($file) => pathinfo($file, PATHINFO_FILENAME), glob("{$_SERVER['DOCUMENT_ROOT']}/QR ?* Rip.php"));
  89.  
  90. foreach($files as $file){
  91.     chmod ( "{$_SERVER['DOCUMENT_ROOT']}/{$file}.php", 0755 );
  92. }
  93.  
  94. $Godfather = new GodfatherClass ( );
  95. $Godfather->Start();
  96.  
  97. ?>
  98.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement