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

Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 

uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 

uid=33(www-data) gid=33(www-data) groups=33(www-data) 

Safe-mode: OFF (not secure)

/var/www/html/ipcam-cctv/include/   drwxr-xr-x
Free 13.08 GB of 57.97 GB (22.56%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


Viewing file:     config.php (5.8 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
    
class config {

        private 
$database;

        private 
$default_keys = array(
            
'vlc_exec'=>'cvlc',
            
'recording_directory'=>'',
            
'pid_directory'=>'',
            
'log_directory'=>'',
            
'lock_directory'=>'',
            
'retry_time_limit'=>'100',
            
'retry_count'=>'3',
            
'sleep_time'=>'10',
            
'camera_log_limit'=>'10000',
            
'recording_file_extension'=>'.mp4',
            
'recording_file_mux'=>'mp4',
            
'transcode_enable'=>'0',
            
'transcode_video_codec'=>'',
            
'transcode_audio_codec'=>'',
            
'transcode_fps'=>'',
            
'transcode_scale'=>'',
            
'transcode_bitrate'=>'',
            
'recording_device_limit'=>'',
            
'recording_mime'=>'video/mp4'
        
);

        public 
$config_data = array();

        function 
__construct(&$database$device false$load_global true) {
            
$this->database $database;

            
// Check global settings
            
$this->check_keys();

            if (
$load_global) {
                
// Load global config
                
$this->load_config();
            }

            
// Load device specific config and override global config values
            
if ($device !== false) {
                
$this->load_config($device);
            }
        }

        private function 
load_config($device false) {
            if (
$device !== false) {
                
$this->database->prepared_query('SELECT `key`, `value` FROM `config` WHERE `device`=?', array('i'), array($device));
            } else {
                
$this->database->query('SELECT `key`, `value` FROM `config` WHERE `device` IS NULL');
            }

            if (isset(
$this->database->result[0])) {
                foreach (
$this->database->result as $cnf) {
                    
$this->config_data[$cnf['key']] = $cnf['value'];
                }
                return 
true;
            }

            return 
false;
        }

        private function 
check_keys() {
            
$this->database->query('SELECT `key` FROM `config` WHERE `device` IS NULL AND `key` IN ("'.implode('","'array_keys($this->default_keys)).'")');

            
$keys = array();
            if (isset(
$this->database->result[0])) {
                foreach (
$this->database->result as $r) {
                    
$keys[] = $r['key'];
                }
            }

            foreach (
$this->default_keys as $k => $v) {
                if (!
in_array($k$keys)) {
                    
$this->database->query('INSERT INTO `config` (`key`, `value`) VALUES ("'.$k.'", "'.$v.'")');
                }
            }
        }

        public static function 
get_key_instances($database$key) {
            if (!
$database->prepared_query('SELECT GROUP_CONCAT(`device`) AS `devices`, `key`, `value` FROM `config` WHERE `key`=? GROUP BY `key`, `value`', array('s'), array($key))) { return false; }
            if (isset(
$database->result[0])) {
                return 
$database->result;
            } else {
                return 
false;
            }
        }

        public static function 
config_dump($database) {
            if (!
$database->query('SELECT DISTINCT `device` FROM `config`')) { return false; }
            if (!isset(
$database->result[0])) { return false; }
            
$devices = array();
            foreach (
$database->result as $r) {
                if (
$r['device'] == '') { $r['device'] = 'GLOBAL'; }
                
$devices[] = $r['device'];
            }
            
$ret = array();
            foreach (
$devices as $d) {
                if (
$d == 'GLOBAL') {
                    if (!
$database->query('SELECT `key`, `value` FROM `config` WHERE `device` IS NULL')) { return false; }
                } else {
                    if (!
$database->query('SELECT `key`, `value` FROM `config` WHERE `device`='.(int)$d)) { return false; }
                }
                if (isset(
$database->result[0])) {
                    
$c = array();
                    foreach (
$database->result as $r) {
                        
$c[$r['key']] = $r['value'];
                    }
                    
$ret[$d] = $c;
                }
            }
            return 
$ret;
        }

        public static function 
set($database$device$key$value) {
            if (
$device === false) {
                if (!
$database->prepared_query('SELECT `id` FROM `config` WHERE `device` IS NULL AND `key`=?', array('s'), array($key))) { return false; }
            } else {
                if (!
$database->prepared_query('SELECT `id` FROM `config` WHERE `device`=? AND `key`=?', array('i''s'), array($device$key))) { return false; }
            }
            if (isset(
$database->result[0])) {
                
$id $database->result[0]['id'];
                if (!
$database->prepared_query('UPDATE `config` SET `value`=? WHERE `id`=?', array('s''i'), array($value$id))) { return false; }
            } else {
                if (
$device === false) {
                    if (!
$database->prepared_query('INSERT INTO `config` (`key`, `value`) VALUES (?, ?)', array('s''s'), array($key$value))) { return false; }
                } else {
                    if (!
$database->prepared_query('INSERT INTO `config` (`device`, `key`, `value`) VALUES (?, ?, ?)', array('i''s''s'), array($device$key$value))) { return false; }
                }
            }
            return 
true;
        }

        public static function 
del($database$device$key) {
            if (
$device === false) {
                if (!
$database->prepared_query('DELETE FROM `config` WHERE `device` IS NULL AND `key`=?', array('s'), array($key))) { return false; }
            } else {
                if (!
$database->prepared_query('DELETE FROM `config` WHERE `device`=? AND `key`=?', array('i''s'), array($device$key))) { return false; }
            }
            return 
true;
        }
    }
?>

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ Read-Only ]

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

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

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