Elenco file PHP nella cartella:


Sorgente di Visualizza_sorgente.php:

<?php
// Ottieni la lista dei file nella cartella corrente
$files = glob("*.php");

if (!$files) {
    echo "Nessun file PHP trovato nella cartella.";
    exit;
}
?>
<!DOCTYPE html>
<html lang="it">
<head>
  <meta charset="UTF-8">
  <title>Elenco file PHP</title>
  <style>
    body {
      background: #f4f6f9;
      font-family: "Segoe UI", Roboto, Arial, sans-serif;
      margin: 0;
      padding: 20px;
      color: #222;
    }
    h2 {
      margin-top: 0;
      color: #2c3e50;
    }
    ul {
      list-style: none;
      padding: 0;
    }
    li {
      margin: 6px 0;
    }
    a {
      text-decoration: none;
      color: #2563eb;
      font-weight: 500;
      padding: 6px 10px;
      border-radius: 6px;
      transition: background 0.2s, color 0.2s;
    }
    a:hover {
      background: #2563eb;
      color: #fff;
    }
    pre {
      background: #1e293b;
      color: #e2e8f0;
      padding: 16px;
      border-radius: 8px;
      overflow-x: auto;
      font-size: 14px;
      line-height: 1.4em;
    }
    .container {
      max-width: 900px;
      margin: auto;
      background: #fff;
      padding: 20px 30px;
      border-radius: 10px;
      box-shadow: 0 8px 20px rgba(0,0,0,0.08);
    }
    hr {
      border: none;
      border-top: 1px solid #ddd;
      margin: 20px 0;
    }
	
	button {
    display: block;
    width: 100%;
    background: #2a4b8d;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.25s ease;
    margin-top: 10px;		
	}
	
	button: hover {
    background: #4369c7;		
	}
  </style>
</head>
<body>
<div class="container">
<?php
echo "<h2>Elenco file PHP nella cartella:</h2>";
echo "<ul>";
foreach ($files as $file) {
    echo "<li><a href='?view=" . urlencode($file) . "'>$file</a></li>";
}
echo "</ul>";

// Se l'utente clicca su un file, mostra il sorgente
if (isset($_GET['view'])) {
    $file = basename($_GET['view']);
    if (in_array($file, $files)) {
        echo "<hr>";
        echo "<h2>Sorgente di $file:</h2>";
        echo "<pre>" . htmlspecialchars(file_get_contents($file)) . "</pre>";
    } else {
        echo "File non valido.";
    }
}
?>
  <button onclick="document.location='http://smercuri2.alwaysdata.net'">Torna alla Home</button>
</div>
</body>
</html>