. */ require_once('head.php'); function tpl_get_img_for_mimetype($mime) { if ($mime == 'unknown') return 'type_other.png'; list($cat) = explode('/', $mime); switch ($cat) { case 'image': return 'type_image.png'; case 'text': return 'type_text.png'; case 'video': return 'type_video.png'; case 'audio': return 'type_audio.png'; default: return 'type_other.png'; } } function is_mime_editable($mime) { if (substr($mime, 0, 4) == 'text') return true; else return false; } function tpl_get_human_readable_size($size) { $size = round($size / 1024); if ($size > 1024) { return round($size / 1024) . 'Mo'; } else { return $size . 'Ko'; } } $tpl->register_modifier('get_img_for_mimetype', 'tpl_get_img_for_mimetype'); $tpl->register_modifier('get_human_readable_size', 'tpl_get_human_readable_size'); $base = '.'; if (!empty($_GET['base'])) $base = $_GET['base']; if (!empty($_GET['createDir'])) { // TODO: gestion des erreurs $dir = $nk->createDocumentDir($base, $_GET['createDir']); header('Location: ./documents.php?base='.$dir); exit; } if (!empty($_GET['deleteDir']) && !empty($_GET['confirm'])) { // TODO: gestion des erreurs $nk->deleteDocumentDir($_GET['deleteDir']); header('Location: ./documents.php?base='.$_GET['deleteDir']); exit; } if (!empty($_GET['delete']) && !empty($_GET['confirm'])) { // TODO: gestion des erreurs $nk->deleteFile('documents/' . $_GET['delete']); header('Location: ./documents.php?base='.$_GET['delete']); exit; } if (!empty($_GET['rename']) && !empty($_GET['new_name'])) { // TODO: gestion des erreurs $new_name = $nk->renameDocument($_GET['rename'], $_GET['new_name']); header('Location: ./documents.php?base='.$new_name); exit; } if (!empty($_POST['sendFile']) && !empty($_FILES['upload'])) { // TODO: gestion des erreurs $nk->uploadDocument($base, $_FILES['upload']); header('Location: ./documents.php?base='.$base); exit; } $list = $nk->admListDocuments($base); if ($list === false) { header('Location: ./documents.php'); exit; } $tpl->assign('documents', $list); $tpl->assign('base', ($base == '.') ? '' : $base); $tpl->assign('parent', dirname($base)); $tpl->display('documents.tpl'); ?>