!C99Shell v. 2.1 [PHP 8 Update] [02.02.2022]!

Software: Apache/2.4.53 (Unix) OpenSSL/1.1.1o PHP/7.4.29 mod_perl/2.0.12 Perl/v5.34.1. PHP/7.4.29 

uname -a: Linux vps-2738122-x 4.15.0-213-generic #224-Ubuntu SMP Mon Jun 19 13:30:12 UTC 2023 x86_64 

uid=1(daemon) gid=1(daemon) grupos=1(daemon) 

Safe-mode: OFF (not secure)

/opt/apex_tdfonline/php/3ros/wsf/wso2/DataServices/   drwxr-xr-x
Free 13.18 GB of 61.93 GB (21.29%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Feedback    Self remove    Logout    


Viewing file:     DSDBExecutor.php (6.77 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
/**
 * Class DSDBExecutor
 * for database execution
 */
class DSDBExecutor {
    private 
$dsn;
    private 
$username;
    private 
$password;

    public function 
__construct($config) {
        
$dsn "";
        
// setting db engine
        
if($config == NULL || !is_array($config)) {
            
DSUtils::error_log(__FILE____LINE__
                    
"Missing configuraiton: config is not provided");
        }
        else {

            
            
// user can give the dsn directly
            
if(array_key_exists(DS_DSN$config) &&
                
$config[DS_DSN] != NULL) {
                
$dsn $config[DS_DSN];
            }
            else {
                if(
array_key_exists(DS_DB_ENGINE$config) &&
                    
$config[DS_DB_ENGINE] != NULL) {
                    
$dsn .= $config[DS_DB_ENGINE]. ":";
                }
                else {
                    
DSUtils::error_log(__FILE____LINE__
                            
"Missing configuraiton: database engine is not provided");
                }

                
// setting db name
                
if(array_key_exists(DS_DBNAME$config) &&
                    
$config[DS_DBNAME] != NULL) {
                    
$dsn .= DS_DBNAME"="$config[DS_DBNAME]. ";";
                }
                else {
                    
DSUtils::error_log(__FILE____LINE__
                            
"Missing configuraiton: database name is not provided");
                }

                
// setting db name
                
if(array_key_exists(DS_DBHOST$config) &&
                    
$config[DS_DBHOST] != NULL) {
                    
$dsn .= DS_HOST"="$config[DS_DBHOST];
                }
                else {
                    
DSUtils::error_log(__FILE____LINE__
                            
"Missing configuraiton: database host is not provided");
                }

                
// setting db port
                
if(array_key_exists(DS_DBPORT$config) &&
                    
$config[DS_DBPORT] != NULL) {
                    
$dsn .= ":"$config[DS_DBPORT];
                }

            }
            
$this->dsn $dsn;

            
// setting username
            
if(array_key_exists(DS_USERNAME$config) &&
                
$config[DS_USERNAME] != NULL) {
                
$this->username $config[DS_USERNAME];
            }
            else if(
array_key_exists(DS_DSN$config) &&
                
$config[DS_DSN] != NULL) {
                
//user name can be in the dsn..
            
}
            else {
                
DSUtils::error_log(__FILE____LINE__
                        
"Missing configuraiton: database username is not provided");
            }

            
// setting password 
            
if(array_key_exists(DS_PASSWORD$config) &&
                
$config[DS_PASSWORD] != NULL) {
                
$this->password $config[DS_PASSWORD];
            }
        }
    }

    
/**
     * execute the query and return the data
     *
     * @param string $sql_query  sql query to invoke
     * @param array $params input parameter array
     * @return array of results
     */
    
public function execute_query($sql_query$params) {
        
        
//create the connection..
        
$dbh $this->db_connect();
        if(!
$dbh) {
            throw new 
WSFault("Sender""Connection to the database failed");
        }

        
//handle the query
        
if($params != NULL && is_array($params) && count($params) > 0) {
            
$response_info $this->handle_prepared_stmt_query($dbh$sql_query$params);
        }
        else {
            
$response_info $this->handle_query($dbh$sql_query$params);
        }

        return 
$response_info;
    }
    
    
/**
     * create the DBO object for the user configuration
     *
     * @return DBO Object
     */
    
private function db_connect() {
        try {
            
$dbh = new PDO($this->dsn$this->username$this->password);
        }
        catch (
PDOException $e) {
            
DSUtils::error_log(__FILE____LINE__"Database connection failed: ".$e->getMessage().
                    
"".$this->dsn", ".$this->username);
            throw new 
WSFault("Sender"$e->getMessage());
  
        }
        return 
$dbh;
    }

    
/**
     * Handles the prepared statment
     *
     * @param DBO object $dbh
     * @param string $sql_query
     * @param array $params
     * @return array the response information
     */
    
private function handle_prepared_stmt_query($dbh$sql_query$params) {
        
        
// create the prepared statement
        
if($stmt $dbh->prepare($sql_query))
        {
            try {
                
$stmt->execute($params);
            } catch(
PDOExection $e) {
                
DSUtils::error_log(__FILE____LINE__,
                        
"Database execution failed: ".$e->getMessage()."");
                throw new 
WSFault("Sender""Failed to access Data");
            }
            
            
$results $stmt->fetchAll();

            return 
$results;
        }
        else
        { 
            
DSUtils::error_log(__FILE____LINE__,
                       
"Error occured while setting the prepared statment");
            throw new 
WSFault("Sender""Failed in accessing database");
        }
        return 
$results;
    }
 
    
/**
     * Handles the direct quires which doesn't requries prepared statments
     *
     * @param PDO object $dbh
     * @return array of response information
     */
    
private function handle_query($dbh$sql_query) {

        
//simple execute the query
        
if($stmt$dbh->query($sql_query)) {
            
$results $stmt->fetchAll();
        }
        else { 
            
DSUtils::error_log(__FILE____LINE__,
                       
"Error occured while setting the prepared statment: $sql_query");
            throw new 
WSFault("Sender""Failed in accessing database");
        }

        return 
$results;
    }

    
/**
     * retrieve column database from the table
     * @param string $sql_query the meta data return about
     * @param array $params input parameters
     * @return array of meta data
     */
     
public function get_result_meta_info($sql_query$params) {
 
        
//create the connection..
        
$dbh $this->db_connect();
        if(!
$dbh) {
            throw new 
WSFault("Sender""Connection to the database failed");
        }

        
// create the prepared statement
        
$response_info = array();
        if(
$stmt $dbh->prepare($sql_query)) {
            
$stmt->execute($params);
            
$column_count $stmt->columnCount();
            for(
$i 0$i $column_count$i ++) {
                
$meta_data $stmt->getColumnMeta($i);
                
$column_type $meta_data[DS_DB_NATIVE_TYPE];
                
$column_name $meta_data[DS_DB_NAME];
                
$response_info[$column_name] = $column_type;
            }
        }
        return 
$response_info;       
     }
}
?>

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ Read-Only ]

:: Make Dir ::
 
[ Read-Only ]
:: Make File ::
 
[ Read-Only ]

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

--[ c99shell v. 2.1 [PHP 8 Update] [02.02.2022] maintained byC99Shell Github | Generation time: 0.5915 ]--