Cloudlog/application/controllers/Debug.php

68 wiersze
2.1 KiB
PHP
Czysty Zwykły widok Historia

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Debug extends CI_Controller {
2023-11-11 08:35:27 +00:00
function __construct()
{
parent::__construct();
$this->load->model('user_model');
2023-11-11 08:35:27 +00: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()
{
$this->load->helper('file');
2023-11-12 14:34:18 +00:00
$this->load->model('MigrationVersion');
$data['migration_version'] = $this->MigrationVersion->getMigrationVersion();
// Test writing to backup folder
2023-11-11 08:35:27 +00:00
$backup_folder = $this->is_really_writable('backup');
$data['backup_folder'] = $backup_folder;
// Test writing to updates folder
2023-11-11 08:35:27 +00:00
$updates_folder = $this->is_really_writable('updates');
$data['updates_folder'] = $updates_folder;
// Test writing to uploads folder
2023-11-11 08:35:27 +00:00
$uploads_folder = $this->is_really_writable('uploads');
$data['uploads_folder'] = $uploads_folder;
2023-11-11 08:35:27 +00:00
$data['page_title'] = "Debug";
2023-11-11 08:35:27 +00:00
$this->load->view('interface_assets/header', $data);
2023-11-12 14:41:10 +00:00
$this->load->view('debug/main');
2023-11-11 08:35:27 +00:00
$this->load->view('interface_assets/footer');
}
2023-11-11 08:35:27 +00:00
private function is_really_writable($folder)
{
// Get the absolute path to the folder
$path = FCPATH . $folder;
2023-11-11 08:35:27 +00:00
// Check if the folder exists
if (!file_exists($path)) {
return false;
}
2023-11-11 08:35:27 +00: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) {
if ($item->isDir() && basename($item->getPathName()) != '..') {
if (!is_writable($item->getRealPath())) {
return false;
}
}
2023-11-11 08:35:27 +00:00
}
return true;
}
2023-11-11 08:35:27 +00:00
return false;
}
}