Show sourcecode
The following files exists in this folder. Click to view.
excercise_autolist.php
exercises/
exercises.php
img/
incl/
index-no-include.php
index.php
source.php
style/
viewsource.php
excercise_autolist.php
44 lines UTF-8 Windows (CRLF)
<!DOCTYPE html>
<html lang="sv">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Övningar Webbsrvprg</title>
<link rel="stylesheet" href="../webbutv2/css/css_index.css">
</head>
<body>
<h1>Övningar Webbsrvprg</h1>
<div id="lists">
<?php
$dirPath = __DIR__ . DIRECTORY_SEPARATOR . 'exercises';
$folderCount = 0;
$fileCount = 0;
foreach (scandir($dirPath) as $folderName) {
if ($folderName === '.' || $folderName === '..') continue;
$folderPath = $dirPath . DIRECTORY_SEPARATOR . $folderName;
if (is_dir($folderPath)) {
echo " <div class=\"card\">\n";
echo " <h2>" . strtoupper(htmlspecialchars($folderName)) . "</h2>\n";
echo " <ul>\n";
$folderCount++;
foreach (scandir($folderPath) as $fileName) {
if ($fileName === '.' || $fileName === '..') continue;
$filePath = $folderPath . DIRECTORY_SEPARATOR . $fileName;
if (is_file($filePath)) {
$relativePath = 'exercises/' . $folderName . '/' . $fileName;
echo " <li><a href=\"" . htmlspecialchars($relativePath) . "\">" . htmlspecialchars($fileName) . "</a></li>\n";
$fileCount++;
}
}
echo " </ul>\n";
echo " </div>\n";
}
}
?>
</div>
<p>Added <?php echo $folderCount; ?> folders and <?php echo $fileCount; ?> files.</p>
</body>
</html>