Nimien mukaan, Tunnisteiden mukaan, Koon mukaan
4.0 kt | ||
. | 12.0 kt | |
dvbsnoop-MUX3-pid16 | 39.2 kt | |
dvbtextsubs-0.2.tar | gz | 31.1 kt |
Eeee-selva | eml | 1.7 kt |
epgsearch-error | txt | 5.2 kt |
fi | po | 6.2 kt |
filestream | php~ | 0.8 kt |
glibc-gij-apparent-memleak-patch | diff | 1.9 kt |
graphedit011008 | zip | 430.5 kt |
index | php | 1.5 kt |
index | php~ | 1.5 kt |
keymap | 10.0 kt | |
kone-lspci | 1.6 kt | |
kuunteluportit | txt | 4.7 kt |
Sivun koodi:
<html>
<head>
<title>Skriblesort</title>
</head>
<body>
<h2>Sorting example for Skrible</h2>
<p><a href="?sort=nimi">Nimien mukaan</a>, <a href="?sort=ext">Tunnisteiden mukaan</a>, <a href="?sort=koko">Koon mukaan</a></p>
<table>
<?php
$sortinki = "nimi";
if (in_array($_GET["sort"], array("nimi", "ext", "koko")))
$sortinki = $_GET["sort"];
function omacomp($a, $b) {
global $sortinki;
switch ($sortinki) {
default:
case "nimi":
$res = strnatcasecmp($a['nimi'], $b['nimi']);
break;
case "ext":
$res = strnatcasecmp($a['ext'], $b['ext']);
break;
case "koko":
$res = $a['koko'] < $b['koko'] ? -1 : ($a['koko'] > $b['koko'] ? 1 : 0);
break;
}
if ($res)
return $res;
$res = ($sortinki != "nimi") ? strnatcasecmp($a['nimi'], $b['nimi']) : 0;
if ($res)
return $res;
return strnatcasecmp($a['ext'], $b['ext']);
}
function split_name($vidfile) {
$loc = strrpos($vidfile, ".");
if ($loc === false)
return array($vidfile, "");
return array(substr($vidfile, 0, $loc), substr($vidfile, $loc+1));
}
$dvid = opendir(".");
$files = array();
while(($vidfile = readdir($dvid)) !== false) {
list($nimi, $ext) = split_name($vidfile);
$files[] = array("nimi" => $nimi, "koko" => filesize($vidfile), "ext" => $ext);
}
usort($files, "omacomp");
foreach($files as $file) {
echo '<tr><td>'.$file['nimi'].'</td><td>'.$file['ext'].'</td><td>'.sprintf('%01.1f',$file['koko']/1024).' kt</td></tr>';
}
?>
</table>
<p><strong>Sivun koodi:</strong></p>
<?php
highlight_file(__FILE__);
?>
</body>
</html>