Advertisement
jargon

NG2

Sep 26th, 2022
1,089
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.46 KB | Cybersecurity | 0 0
  1. <?php
  2.  
  3. $NG2=new NG2('../NG2PRIVATE/BootImage');
  4.  
  5. Class NG2
  6. {
  7.     public string   $DefaultBootPath    =   '';
  8.     public string   $BootPath           =   '';
  9.     public string   $BootImage          =   '';
  10.        
  11.     public function __construct
  12.     (
  13.         string $argBootPath='../NG2PRIVATE/BootImage'
  14.     )
  15.     {
  16.         $this->MkPath($argBootPath);   
  17.         $this->BootImage='[NUL]';
  18.        
  19.         $this->BootPath=
  20.             implode
  21.             (
  22.                 '/',
  23.                 [
  24.                     $argBootPath,
  25.                     'NG2Setup.json'
  26.                 ]
  27.             );
  28.  
  29.         if
  30.         (
  31.             is_file
  32.             (
  33.                 $this->BootPath
  34.             )
  35.         )
  36.         {
  37.             $this->BootImage=
  38.                 file_get_contents
  39.                 (
  40.                     $this->BootPath
  41.                 );
  42.         }
  43.        
  44.         var_dump($this->BootPath);
  45.         var_dump($this->BootImage);
  46.     }
  47.  
  48.     public function MkPath(string $argPath='')
  49.     {
  50.            
  51.         if(substr($argPath,0,strlen($_SERVER['DOCUMENT_ROOT']))===$_SERVER['DOCUMENT_ROOT'])
  52.         {
  53.             $argPath=substr($argPath,strlen($_SERVER['DOCUMENT_ROOT']));
  54.         }
  55.        
  56.         while(substr($argPath,0,2)==='//')
  57.         {
  58.             $argPath=substr($argPath,1);
  59.         }
  60.  
  61.         $parts=
  62.             explode
  63.             (
  64.                 '/',
  65.                 $argPath
  66.             );
  67.  
  68.         $p=[];
  69.         $p[]=$_SERVER['DOCUMENT_ROOT'];
  70.        
  71.         $path='';
  72.        
  73.         for($index=0;$index<count($parts);$index++)
  74.         {
  75.             if($parts[$index]!==$_SERVER['DOCUMENT_ROOT'])
  76.             {
  77.                 $p[]=$parts[$index];
  78.                 $path=
  79.                     implode
  80.                     (
  81.                         '/',
  82.                         $p
  83.                     );
  84.                
  85.                 if(!is_file($path) and !is_dir($path) and (strlen($path)!==0))
  86.                 {
  87.                     mkdir
  88.                     (
  89.                         $path
  90.                     );
  91.                 }
  92.             }
  93.         }
  94.     }
  95.  
  96.     function Boot()
  97.     {
  98.         $this->boot
  99.     }
  100. }
  101.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement