'Bild hochgeladen. Relativer Pfad: '.bratonien_tools_asset_relative_dir().$filename); } function bratonien_tools_delete_asset() { $filename = isset($_POST['asset_file']) ? basename((string)$_POST['asset_file']) : ''; if ($filename === '') { throw new RuntimeException('Keine Datei zum Loeschen ausgewaehlt.'); } $dir = bratonien_tools_asset_absolute_dir(); $target = $dir.$filename; if (!is_file($target)) { throw new RuntimeException('Die Datei wurde nicht gefunden.'); } if (!@unlink($target)) { throw new RuntimeException('Die Datei konnte nicht geloescht werden.'); } return array('message' => 'Bilddatei geloescht: '.$filename); } function bratonien_tools_get_assets() { $dir = bratonien_tools_asset_absolute_dir(); if (!is_dir($dir)) { return array(); } $allowed = array('jpg', 'jpeg', 'png', 'gif', 'webp'); $assets = array(); foreach (scandir($dir) as $file) { if ($file === '.' || $file === '..') { continue; } $absolute = $dir.$file; if (!is_file($absolute)) { continue; } $ext = strtolower(pathinfo($file, PATHINFO_EXTENSION)); if (!in_array($ext, $allowed, true)) { continue; } $info = @getimagesize($absolute); $relative = bratonien_tools_asset_relative_dir().$file; $assets[] = array( 'file' => $file, 'relative' => $relative, 'url' => get_root_url().$relative, 'width' => $info ? (int)$info[0] : 0, 'height' => $info ? (int)$info[1] : 0, 'bytes' => (int)filesize($absolute), ); } usort($assets, function($a, $b) { return strcasecmp($a['file'], $b['file']); }); return $assets; } function bratonien_tools_get_asset_environment() { $absolute = bratonien_tools_asset_absolute_dir(); return array( 'root' => PHPWG_ROOT_PATH, 'relative_dir' => bratonien_tools_asset_relative_dir(), 'absolute_dir' => $absolute, 'exists' => is_dir($absolute), 'writable' => is_dir($absolute) && is_writable($absolute), 'upload_max' => ini_get('upload_max_filesize'), 'post_max' => ini_get('post_max_size'), ); }