• Web sitemizin içeriğine ve tüm hizmetlerimize erişim sağlamak için Web sitemize kayıt olmalı ya da giriş yapmalısınız. Web sitemize üye olmak tamamen ücretsizdir.
  • Sohbetokey.com ile canlı okey oynamaya ne dersin? Hem sohbet et, hem mobil okey oyna!
  • Soru mu? Sorun mu? ''Bir Sorum Var?'' sistemimiz aktiftir. Paylaşın beraber çözüm üretelim.

PHP Web Site Dosya Yöneticisi v1.0

TRWE_2012

لِيَغْفِرَ لَكَ اللّٰهُ مَا تَقَدَّمَ مِنْ ذَنْبِك
Moderatör
Üyelik Tarihi
2 Haz 2020
Mesajlar
5,367
MFC Puanı
16,520
Konum
BERTUNA
Ekran Görüntüleri :

KxG41X1.jpeg


TeuVXjM.jpeg


Kod İçeriği :
PHP:
<?php
header('Content-Type: text/html; charset=utf-8'); // Karakter setini UTF-8 olarak ayarlayın
$files = [];
$directory = '';

// Dizin yolu gönderildiğinde
if (isset($_POST['directory'])) {
    $directory = $_POST['directory'];

    // Dizin içeriğini al
    function listFiles($dir) {
        $files = [];
        $items = scandir($dir);
        foreach ($items as $item) {
            if ($item == '.' || $item == '..') continue; // Geçersiz dizinler
            $path = $dir . '/' . $item;
            $size = is_dir($path) ? 0 : filesize($path); // Dizin ise boyut 0
            $sizeFormatted = formatSize($size); // Boyutu formatla
            $files[] = [
                'name' => $item,
                'path' => $path,
                'size' => $sizeFormatted,
                'is_dir' => is_dir($path),
                'children' => is_dir($path) ? listFiles($path) : [] // Alt dizinleri listele
            ];
        }
        return $files;
    }

    // Boyutu formatlamak için fonksiyon
    function formatSize($size) {
        if ($size < 1024) {
            return $size . ' B'; // Bayt
        } elseif ($size < 1024 * 1024) {
            return round($size / 1024, 2) . ' kB'; // Kilobayt
        } else {
            return round($size / (1024 * 1024), 2) . ' MB'; // Megabayt
        }
    }

    // Dizin var mı kontrol et
    if (is_dir($directory)) {
        $files = listFiles($directory);
    } else {
        $error = "Geçersiz dizin yolu.";
    }
}
?>

<!DOCTYPE html>
<html lang="tr">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Dosya Yöneticisi</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 20px;
            background-color: #f4f4f4;
        }
        h1 {
            text-align: center;
        }
        .file-list {
            list-style: none;
            padding: 0;
        }
        .file-list li {
            padding: 10px;
            border-bottom: 1px solid #ddd;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        .file-list li:last-child {
            border-bottom: none;
        }
        button {
            padding: 5px 10px;
            border: none;
            border-radius: 3px;
            cursor: pointer;
            background-color: #007BFF;
            color: white;
        }
        .error {
            color: red;
            text-align: center;
        }
    </style>
</head>
<body>

<div class="file-manager">
    <h1>Dosya Yöneticisi</h1>
    
    <form method="POST">
        <input type="text" name="directory" placeholder="Dizin yolunu girin" value="<?php echo htmlspecialchars($directory, ENT_QUOTES, 'UTF-8'); ?>" required>
        <button type="submit">Listele</button>
    </form>

    <?php if (isset($error)): ?>
        <div class="error"><?php echo htmlspecialchars($error, ENT_QUOTES, 'UTF-8'); ?></div>
    <?php endif; ?>

    <ul class="file-list">
        <?php
        function renderFileList($files) {
            foreach ($files as $file): ?>
                <li>
                    <span><?php echo htmlspecialchars($file['name'], ENT_QUOTES, 'UTF-8'); ?> (<?php echo $file['size']; ?>)</span>
                    <span><?php echo $file['is_dir'] ? 'Klasör' : 'Dosya'; ?></span>
                </li>
                <?php if ($file['is_dir'] && !empty($file['children'])): ?>
                    <ul>
                        <?php renderFileList($file['children']); ?>
                    </ul>
                <?php endif; ?>
            <?php endforeach;
        }
        renderFileList($files);
        ?>
    </ul>
    <button onclick="downloadList()">Bu Listelemeyi Masaüstüne Kaydet</button>
</div>

<script>
    function convertTurkishToEnglish(text) {
        const turkishChars = {
            'ç': 'c',
            'ğ': 'g',
            'ı': 'i',
            'ö': 'o',
            'ş': 's',
            'ü': 'u',
            'Ç': 'C',
            'Ğ': 'G',
            'İ': 'I',
            'Ö': 'O',
            'Ş': 'S',
            'Ü': 'U'
        };

        return text.split('').map(char => turkishChars[char] || char).join('');
    }

    function downloadList() {
        const list = document.querySelector('.file-list').innerHTML; // HTML içeriğini al
        const convertedList = convertTurkishToEnglish(list); // Türkçe karakterleri İngilizce karşıtlarıyla değiştir
        const blob = new Blob([convertedList], { type: 'text/html;charset=utf-8' }); // HTML olarak ayarlayın
        const link = document.createElement('a');
        link.href = window.URL.createObjectURL(blob);
        link.download = 'dosya_listesi.html'; // İndirilecek dosya adı
        document.body.appendChild(link); // Linki body'e ekle
        link.click(); // Linke tıkla
        document.body.removeChild(link); // Linki kaldır
    }
</script>

</body>
</html>

Web Tarayıcı Satırı (yerel bilgisayar) : http://localhost/my_php_template/file_list.php

Güle güle kullanın...
 
emeğine sağlık hocam
Kodlaması tamamen bana aittir.Ne bir alıntı ne de bir çalıntı....Bütün günümü aldı kodlaması (çünkü amatörüm ve deneme-yanılma ile kodlama sorunlarını çözmeye çalışıyorum ve bu durum da bana, baya bir zaman kaybettiriyor) ama sonuçta ortaya güzel ve yararlı çalışmalar çıkıyor.

Diğer .php kod çalışmalarım (hepsi basit ve yararlı ve de bunları kullanmaktayım)

nEQDHfv.jpeg

not:Ekran görüntüsünde, Windows11 altında çalışan İE12 (normalde bunu çalıştıramazsınız ama .vbs betiğin gücü ile imkansızlıklar aşılır.) kend "Büyük Not Defterim (yerel pc üzerinde))
 
Son düzenleme:
Geri
Üst