mirror of https://codeberg.org/Sonoj/osamc.de
51 lines
1.2 KiB
PHP
51 lines
1.2 KiB
PHP
|
<?php
|
||
|
|
||
|
function cmpByDate(array $a, array $b) {
|
||
|
return strcmp($a['Date'], $b['Date']);
|
||
|
}
|
||
|
|
||
|
$dirs = array_filter(glob('*'), 'is_dir');
|
||
|
//print_r($dirs);
|
||
|
|
||
|
|
||
|
$projects = array();
|
||
|
foreach($dirs as $projectdir) {
|
||
|
$inifile = $projectdir . "/metadata.ini";
|
||
|
if (file_exists($inifile)) {
|
||
|
$iniAssoArray = parse_ini_file($inifile, false, INI_SCANNER_RAW);
|
||
|
$iniAssoArray["Directory"] = $projectdir;
|
||
|
array_push($projects, $iniAssoArray);
|
||
|
//print_r($iniAssoArray);
|
||
|
//echo $iniAssoArray['Date']."\n";
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
usort($projects, 'cmpByDate');
|
||
|
$projects = array_reverse($projects); //newest first
|
||
|
|
||
|
//print_r($projects);
|
||
|
|
||
|
//Now we have all ini files as PHP arrays, sorted by date, and can build HTML.
|
||
|
|
||
|
|
||
|
$resultHTML = "";
|
||
|
foreach($projects as $proj) {
|
||
|
$block = <<<EOD
|
||
|
<h4><small>$proj[Date]</small><br>
|
||
|
<a href="$proj[Directory]">$proj[PrettyName]</a></h4>
|
||
|
<ul>
|
||
|
<li>$proj[Author], $proj[License]</li>
|
||
|
<li>Permalink: <a href="https://www.osamc.de/archiv/$proj[Directory]">https://www.osamc.de/archiv/$proj[Directory]</a></li>
|
||
|
</ul>
|
||
|
<hr>
|
||
|
\n
|
||
|
EOD;
|
||
|
|
||
|
$resultHTML = $resultHTML . $block;
|
||
|
|
||
|
}
|
||
|
//return $resultHTML;
|
||
|
echo $resultHTML;
|
||
|
?>
|