get('id')); $path = trim(utils::get('path')) ? $files->getPath(utils::get('path')) : ''; $msg = utils::get('msg') ?: false; if (!empty($_GET['view']) && ($file = $files->getPath(utils::get('view')))) { $tpl->assign('view', basename($file)); $tpl->assign('file', $file); $tpl->assign('breadcrumbs', $files->getBreadcrumbs(dirname($file))); $tpl->assign('url', utils::getJournalDatasURL($journal->get('id'), 'documents') . 'images/' . $file); } elseif ($file = utils::get('delete')) { $csrf_key = md5('delete_file_'.$path.'/'.$file); if (utils::post('confirm_delete')) { if (!utils::CSRF_check($csrf_key)) { $msg = 'OTHER'; } else { $files->deleteFile($path, $file); utils::redirect('/ecrire/images.php?path='.rawurlencode($path)); } } $tpl->assign('delete', $file); $tpl->assign('csrf_key', $csrf_key); $tpl->assign('thumb', $files->getThumb($path, $file)); } elseif (!empty($_GET['rmdir']) && ($dir = $files->getPath(utils::get('rmdir')))) { $csrf_key = 'rmdir_'.md5(utils::get('rmdir')); if (utils::post('rmdir')) { if (!utils::CSRF_check($csrf_key)) { $msg = 'OTHER'; } else { $parent_dir = $files->deleteDir($dir); if ($parent_dir !== false) { utils::redirect('/ecrire/images.php?path='.rawurlencode($parent_dir).'&msg=RMDIR_OK'); } else { $msg = 'RMDIR_FAIL'; } } } $tpl->assign('csrf_key', $csrf_key); $tpl->assign('rmdir', $dir); } else { if (trim(utils::post('mkdir'))) { if (!utils::CSRF_check('mkdir_'.$path)) { $msg = 'OTHER'; } else { if ($r = $files->createDir($path, utils::post('mkdir'))) { if ($r === true) { $msg = 'MKDIR_EXISTS'; } else { utils::redirect('/ecrire/images.php?path='.rawurlencode($r)); } } else { $msg = 'MKDIR_FAIL'; } } } elseif (trim(utils::post('upload'))) { if (!utils::CSRF_check('upload_'.$path)) { $msg = 'OTHER'; } else { try { if (!empty($_FILES['upload_file'])) { $r = $files->uploadFile($path, $_FILES['upload_file']); } elseif (isset($_POST['upload_file']['content'])) { $r = $files->uploadFile($path, $_POST['upload_file'], true); } else { $r = false; } if ($r) { utils::redirect('/ecrire/images.php?path='.rawurlencode($path)); } else { $msg = 'UPLOAD_FAIL'; } } catch (userException $e) { $msg = 'UPLOAD_FAIL'; $tpl->assign('msg_error', $e->getMessage()); } } } if (!$path) { $tpl->assign('quota_max', LENCRIER_QUOTA_FILES); $tpl->assign('quota_used', round($files->getUsedQuota() / 1024 / 1024, 2)); } $list = $files->getList($path); if ($list === false) { $msg = 'NOTFOUND'; } else { $path_link = $path; if ($path) { $path_link .= '/'; $breadcrumbs = $files->getBreadcrumbs($path); array_shift($breadcrumbs); $tpl->assign('breadcrumbs', $breadcrumbs); $tpl->assign('parent', $files->getParent($path)); } $tpl->assign('list', $list); $tpl->assign('path_link', $path_link); } $tpl->assign('path', $path); $tpl->assign('max_file_size', utils::getMaxFileSize()); } $tpl->assign('msg', $msg); if (isset($_GET['browse'])) { // Utilisé pour le choix d'image dans le visuel assisté if (isset($_GET['select'])) { $tpl->assign('select', '&select'); } else { $tpl->assign('select', false); } $tpl->display('ecrire/images_browser.tpl'); } else { $tpl->display('ecrire/images.tpl'); } ?>