2021-04-05 11:31:41 +01:00
|
|
|
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
|
|
|
|
|
|
|
|
|
class Debug extends CI_Controller {
|
2023-11-11 09:35:27 +01:00
|
|
|
function __construct()
|
|
|
|
|
{
|
|
|
|
|
parent::__construct();
|
2021-04-05 11:31:41 +01:00
|
|
|
|
|
|
|
|
$this->load->model('user_model');
|
2023-11-11 09:35:27 +01:00
|
|
|
if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* User Facing Links to Backup URLs */
|
|
|
|
|
public function index()
|
|
|
|
|
{
|
2021-04-05 11:31:41 +01:00
|
|
|
$this->load->helper('file');
|
|
|
|
|
|
2023-11-12 15:34:18 +01:00
|
|
|
$this->load->model('MigrationVersion');
|
|
|
|
|
|
|
|
|
|
$data['migration_version'] = $this->MigrationVersion->getMigrationVersion();
|
|
|
|
|
|
2021-04-05 11:31:41 +01:00
|
|
|
// Test writing to backup folder
|
2023-11-11 09:35:27 +01:00
|
|
|
$backup_folder = $this->is_really_writable('backup');
|
|
|
|
|
$data['backup_folder'] = $backup_folder;
|
2021-04-05 11:31:41 +01:00
|
|
|
|
|
|
|
|
// Test writing to updates folder
|
2023-11-11 09:35:27 +01:00
|
|
|
$updates_folder = $this->is_really_writable('updates');
|
|
|
|
|
$data['updates_folder'] = $updates_folder;
|
2021-04-05 11:31:41 +01:00
|
|
|
|
|
|
|
|
// Test writing to uploads folder
|
2023-11-11 09:35:27 +01:00
|
|
|
$uploads_folder = $this->is_really_writable('uploads');
|
|
|
|
|
$data['uploads_folder'] = $uploads_folder;
|
2021-04-05 11:31:41 +01:00
|
|
|
|
2026-01-15 15:40:34 +00:00
|
|
|
// Detect if running inside Docker
|
|
|
|
|
$is_docker = false;
|
|
|
|
|
if (file_exists('/.dockerenv')) {
|
|
|
|
|
$is_docker = true;
|
|
|
|
|
} else if (is_readable('/proc/self/cgroup')) {
|
|
|
|
|
$cgroup = file_get_contents('/proc/self/cgroup');
|
|
|
|
|
$is_docker = (strpos($cgroup, 'docker') !== false || strpos($cgroup, 'kubepods') !== false || strpos($cgroup, 'containerd') !== false);
|
|
|
|
|
}
|
|
|
|
|
$data['is_docker'] = $is_docker;
|
|
|
|
|
|
2023-11-11 09:35:27 +01:00
|
|
|
$data['page_title'] = "Debug";
|
2021-04-05 11:31:41 +01:00
|
|
|
|
2023-11-11 09:35:27 +01:00
|
|
|
$this->load->view('interface_assets/header', $data);
|
2023-11-12 15:41:10 +01:00
|
|
|
$this->load->view('debug/main');
|
2023-11-11 09:35:27 +01:00
|
|
|
$this->load->view('interface_assets/footer');
|
|
|
|
|
}
|
2021-04-05 11:31:41 +01:00
|
|
|
|
2023-11-11 09:35:27 +01:00
|
|
|
private function is_really_writable($folder)
|
|
|
|
|
{
|
|
|
|
|
// Get the absolute path to the folder
|
|
|
|
|
$path = FCPATH . $folder;
|
2021-04-05 11:31:41 +01:00
|
|
|
|
2023-11-11 09:35:27 +01:00
|
|
|
// Check if the folder exists
|
|
|
|
|
if (!file_exists($path)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2021-04-05 11:31:41 +01:00
|
|
|
|
2023-11-11 09:35:27 +01:00
|
|
|
// Check if the folder is writable
|
|
|
|
|
if (is_writable($path)) {
|
|
|
|
|
// Check if the subdirectories are writable (recursive check)
|
|
|
|
|
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path));
|
|
|
|
|
foreach ($iterator as $item) {
|
2023-11-16 09:36:56 +01:00
|
|
|
if ($item->isDir() && basename($item->getPathName()) != '..') {
|
|
|
|
|
if (!is_writable($item->getRealPath())) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-11-11 09:35:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2021-04-05 11:31:41 +01:00
|
|
|
|
2023-11-11 09:35:27 +01:00
|
|
|
return false;
|
|
|
|
|
}
|
2024-05-25 00:30:21 +02:00
|
|
|
|
2024-05-24 16:43:32 +02:00
|
|
|
public function flags() {
|
|
|
|
|
|
|
|
|
|
// load library called DxccFlag
|
|
|
|
|
$this->load->library('DxccFlag');
|
|
|
|
|
|
|
|
|
|
// Call getISO function from DxccFlag library
|
|
|
|
|
$data['flags'] = $this->dxccflag->getISO('33');
|
|
|
|
|
|
|
|
|
|
print_r($data['flags']);
|
|
|
|
|
}
|
2023-11-11 09:35:27 +01:00
|
|
|
}
|