case 'image/jpeg': case 'image/gif': if (begins($file->realpath(), $_SERVER['DOCUMENT_ROOT'])) { $middle = render_str('foobar/thumbnail', array('src' => replace_prefix($file->realpath(), $_SERVER['DOCUMENT_ROOT'], '/'))); } else { $middle = render_str('foobar/thumbnail', array('src' => 'image.php?' . http_build_query(array('f' => $file->realpath())))); } break; case 'application/zip': $fields = array(new TableField('Name', 'name'), new TableFieldFormat('CRC', 'crc', 'dechex'), new TableFieldFormat('Size', 'size', 'format_bytes'), new TableFieldFormat('Compressed', 'comp_size', 'format_bytes'), new TableField('Method', 'comp_method'), new TableFieldFormat('Time', 'mtime', 'format_date_mysql')); $zip = new ZipArchive(); $zip->open($file->realpath()); $rows = array(); for ($index = 0, $end = $zip->numFiles; $index < $end; ++$index) { $rows[] = new TableRow($zip->statIndex($index), $fields); } $zip->close(); $middle = render_str('foobar/table', compact('fields', 'rows')); break; default: $middle = sprintf('<pre>%s</pre>', htmlspecialchars($file->contents())); break; } } } if (isset($file)) { $breadcrumbs = render_str('foobar/breadcrumbs', compact('file')); } else { $breadcrumbs = null; } render('base', array('html' => "{$breadcrumbs}\n\n{$middle}"));