prasathmani / tinyfilemanager

Single-file PHP file manager, browser and manage your files efficiently and easily with tinyfilemanager
https://tinyfilemanager.github.io
GNU General Public License v3.0
4.88k stars 1.66k forks source link

Rename doesnt work #1139

Closed Sewixer closed 6 months ago

Sewixer commented 8 months ago

Hi, i made few functions about the directory users and so on and it works fine. But one and only problem is with renaming files or folders in root directory. If the folder has file i can rename it. Nothing pops up when i click the rename button in root directory. This is my code which contains the users and directories. Could you please help me? ` $soubor = 'studenti.txt'; // Kontrola existence souboru if (file_exists($soubor)) { // Čtení obsahu souboru do pole $radky = file($soubor, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);

// Inicializace pole pro ukládání přihlašovacích údajů
$auth_users = array();

foreach ($radky as $radek) {
    // Rozdělení řádku na jméno a heslo
    list($jmeno, $heslo) = explode(', ', $radek);
    $heslo = rtrim($heslo, ';');
    // Přidání záznamu do pole $auth_users
    $auth_users[trim($jmeno)] = trim(password_hash($heslo, PASSWORD_DEFAULT));
}

// Získání posledního klíče v poli
$posledni_klice = array_keys($auth_users);
$posledni_klic = end($posledni_klice);

}

// Readonly users // e.g. array('users', 'guest', ...) $readonly_users = array( 'user'

);

// Global readonly, including when auth is not being used $global_readonly = false;

// user specific directories // array('Username' => 'Directory path', 'Username2' => 'Directory path', ...) //$directories_users = array('jirka' => $_SERVER['DOCUMENT_ROOT'].'/skola/jirka');

// Kontrola existence souboru

// Kontrola existence souboru if (file_exists($soubor)) { // Čtení obsahu souboru do pole $jmena = file($soubor, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);

// Vytvoření pole pro ukládání cest k adresářům
$directories_users = array();
foreach ($jmena as $jmeno) {
    // Použití regulárního výrazu pro extrakci jména
    preg_match('/^([^\s,]+)/', $jmeno, $matches);

    // Kontrola, zda složka existuje
    $user_directory = $_SERVER['DOCUMENT_ROOT'] . '/skola/' . $matches[1];
    if (!empty($matches[1]) && !is_dir($user_directory)) {
        // Pokud složka neexistuje, vytvoříme ji
        mkdir($user_directory, 0777, true);
    }

    // Přidání záznamu do pole $directories_users
    if (!empty($matches[1])) {
        $directories_users[$matches[1]] = $user_directory;
    }

}

}/* // Přečtení obsahu souboru do pole $lines = file($filename, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);

// Projdeme každý řádek a vytvoříme uživatelské složky foreach ($lines as $line) { // Rozdělíme řádek na jméno a heslo list($username, $password) = explode(', ', trim($line));

// Vytvoření cesty k uživatelské složce
$userDirectory = $_SERVER['DOCUMENT_ROOT'] . '/skola/' . $username;

// Vytvoření složky, pokud neexistuje
if (!file_exists($userDirectory)) {
    // Zkuste také měnit oprávnění na složku pomocí chmod, pokud máte problémy s přístupem
    mkdir($userDirectory, 0755, true);

}

// Zde můžete provést další operace, například zápis hesla do souboru, atd.

} */ // Enable highlight.js (https://highlightjs.org/) on view's page $use_highlightjs = true;

// highlight.js style // for dark theme use 'ir-black' $highlightjs_style = 'vs';

// Enable ace.js (https://ace.c9.io/) on view's page $edit_files = true;

// Default timezone for date() and time() // Doc - http://php.net/manual/en/timezones.php $default_timezone = 'Etc/UTC'; // UTC

// Root path for file manager // use absolute path of directory i.e: '/var/www/folder' or $_SERVER['DOCUMENT_ROOT'].'/folder' $root_path = $_SERVER['DOCUMENT_ROOT'] . '/';

// Root url for links in file manager.Relative to $http_host. Variants: '', 'path/to/subfolder' // Will not working if $root_path will be outside of server document root $root_url = ''; `

f-o-n commented 7 months ago

Just faced the same issue. I was using the 2.5.0 release which was checking the root directory to be a valid string, but it's empty. So either change line 3887 from function rename(e, t) { if (e && t) { ... to function rename(e, t) { if (t) { ...

Or just use the latest 2.5.3 from the repo