<?php

$db 
sqlite_open("storage.db"); 

if (!
$db) {
    echo 
"db error";
    exit;
}

if (isset(
$_POST['update']) && isset ($_POST['del']) && is_array($del $_POST['del'])) {
    foreach (
$del as $locsqlite_query ($dbsprintf ("DELETE FROM storage WHERE loc = '%s'"$loc));
    
sqlite_query ($db"VACUUM");
}

?>
<html>
<style>
TABLE {
    border-collapse: collapse;
}

TD, TH {
    border: 1px solid #999;
    padding: 5px 8px;
}
</style>

<form method="post" action="?">
<table border=0>
<?php

$res 
sqlite_query($db"SELECT loc, location, heads, LENGTH (fdata) as len FROM storage WHERE 1 ORDER BY location");

while (
$array sqlite_fetch_array($res)) {

    
$heads unserialize ($array['heads']);
    
$ctype 'default';

    if (isset(
$heads['Content-Type'])) {
        
$tmp explode (';'$heads['Content-Type']);
        
$ctype trim($tmp[0]);
    }

    
$strloc strlen($array['location']) < 90 $array['location'] : substr($array['location'], 090) . '...';

    echo 
sprintf ('<tr><td><input type="checkbox" name="del[]" value="%s"></td>'$array['loc']);
    echo 
sprintf ('<td><a href="%s">/%s</a></td><td>%s</td><td>%d</td></tr>'$array['location'], $strloc$ctype$array['len']);
    echo 
"\n";
}

echo 
'</table><div style="margin: 15px"><input type="submit" name="update" value="Delete selected"></div></form>';

sqlite_close ($db);
?>