First Upload

This commit is contained in:
2024-10-26 17:19:34 +00:00
commit 95241c814c
214 changed files with 17501 additions and 0 deletions

619
CHANGELOG.md Normal file
View File

@@ -0,0 +1,619 @@
# Changelog
* now require PHP 7.0.0+
* fix archive-single-item problem
* add header/footer search stop condition
* update languages (`id`, `it`, `pt-br`, `pt-pt`)
* add EXIF-based image rotation
* add `where` to command detection command list
* fix #758
* fix #760
* add `@babel/core` 7.12.10
* add `@babel/preset-env` 7.12.11
* remove `babel-loader`
* update `eslint` to 7.18.0
* update `ghu` to 0.26.0
* update `jsdom` to 16.4.0
* update `kjua` to 0.9.0
* update `lolight` to 1.4.0
* update `marked` to 1.2.7
* update `null-loader` to 4.0.1
* update `scar` to 2.3.0
## v0.29.2 - *2019-03-22*
* update `babel-loader` to 7.1.1
* update `eslint` to 5.15.3
* update `ghu` to 0.13.0
* update `jsdom` to 14.0.0
* update `kjua` to 0.2.0
* update `lolight` to 1.0.0
* update `scar` to 1.2.0
## v0.29.1 - *2019-01-20*
* replace `babel-preset-es2015` with `babel-preset-env`
* update `eslint` to 5.14.1
* update `ghu` to 0.12.0
* update `jsdom` to 9.2.0
* update `kjua` to 0.1.2
* update `lolight` to 0.6.0
* update `marked` to 0.6.1
* update `normalize.css` to 8.0.1
* update `scar` to 1.0.0
## v0.29.0 - *2016-08-12*
* back to cleaner visual experience
* add option to disable sidebar
* add options to filter/search ignore case
* replace PHP `getenv` calls with `$_SERVER` lookups
* add `view.fallbackMode` option to generally serve only fallback mode
* serve fallback mode for text browsers (`curl`, `links`, `lynx`, `w3m`)
* change type `txt-svg` to `img-svg`, no thumbs but preview
* fix a tree indentation glitch
* fix shell command detection on Windows
* fix Piwik anayltics
* fix `.htaccess` auth issues
* fix drag-select on scrollable content
* fix download-all function
* fix audio and video preview loading
* fix thumbnail request issues
* add `rust` type and icon
* add `autoplay` option to audio and video preview
* add `--dereference` to `shell-du` to follow sym links
* remove *Install* section from `README.md`, causes too much trouble
* remove peer5 support
* update build process to use `node 6.0+`, no need for babel now
* replace `jquery-qrcode` with [`kjua`](https://larsjung.de/kjua/)
* replace `prism` with [`lolight`](https://larsjung.de/lolight/)
* move deps to `package.json` (`normalize.css`, `kjua`, `lolight` and `marked`)
* remove `jQuery`
* remove `lodash`
* remove [`modulejs`](https://larsjung.de/modulejs/) for now
* reduce JS code by 60% (~250kb -> ~100kb)
* update languages (`et`, `nl`, `pl`)
## v0.28.0 - *2015-12-19*
* now require PHP 5.5.0+
* change index path to `/_h5ai/public/index.php`
* now only `/_h5ai/public/` needs to be web-accessible
* add support for custom script and style additions
* add options to set font families
* add search
* add ignorecase sorting option to tree
* add wide links in tree view
* add IE edge mode
* add frontend tests
* fix some styles in IE10
* fix preview bottom bar for small screen widths
* lots of code cleanup and refactorings
* change API
* update build process, now uses [`ghu`](https://larsjung.de/ghu/)
* switch from jshint and jscs to [`eslint`](http://eslint.org/)
* update `jQuery` to 2.1.4
* update `lodash` to 3.9.3 (add debounce and trim)
* update `marked` to 0.3.5
* update `modulejs` to 1.13.0
* update `prism` to 2015-12-19
* update h5bp styles to 5.2.0
* update `normalize.css` to 3.0.3
* remove `Moment.js`
## v0.27.0 - *2015-04-06*
* new layout
* add editorconfig
* drop support for IE9 (gets fallback)
* update sidebar settings
* add info sidebar
* add opt-out for click'n'drag selection
* add package name option for single selections
* add initial support for Peer5
* add option to down-sample images for preview
* add option for natural sorting in tree sidebar
* fix problems with files/folders named `0`
* change font from `Ubuntu` to `Roboto` (smaller footprint, clearer for small sizes)
* switch back to Google Fonts
* improve PDF thumbnail quality
* improve drag-select
* improve image preview
* prevent listing `_h5ai` folder and subfolders
* update build process, now uses [`mkr`](https://larsjung.de/mkr/) and [`fQuery`](https://larsjung.de/fquery/)
* update `jQuery` to 2.1.3
* update `jQuery.qrcode` to 0.11.0
* update `Lo-Dash` to 3.6.0
* update `Modernizr` to 2.8.3
* update `modulejs` to 1.4.0
* update `Moment.js` to 2.9.0
* update `Prism` to 2015-04-05
* remove deprecated Google Analytics code
* remove `jQuery.fracs`
* remove `jQuery.scrollpanel`
* remove `jQuery.mousewheel`
* update languages (`af`, `es`, `ja`, `ko`, `ru`, `zh-cn`)
## v0.26.1 - *2014-08-17*
* fix links
## v0.26.0 - *2014-08-16*
* remove True Type fonts
* outsource themes to [h5ai-themes](https://github.com/lrsjng/h5ai-themes)
* add filesize fallback for large files and 32bit PHP
* fix server detection
* add config file tests to info page
* remove JSON shim
* add caching of command checks
* update `jQuery.mousewheel` to 3.1.12
* update `jQuery.qrcode` to 0.8.0
* replace `markdown` with [`marked`](https://github.com/chjj/marked) 0.3.2
* update `modulejs` to 0.4.5
* update `Moment.js` to 2.8.1
* replace `underscore` with [`Lo-Dash`](https://github.com/lodash/lodash) 2.4.1
* replace `SyntaxHighlighter` with [`Prism`](http://prismjs.com) 2014-08-04
## v0.25.2 - *2014-07-01*
* add optional info page protection
* fix `short_open_tag` issues for PHP < 5.4.0
* fix default folder download (`alwaysVisible` option)
* minor fixes
## v0.25.1 - *2014-06-25*
* fix broken paths for filenames containing '+' characters
* fix Google Universal Analytics
* fix file type check
## v0.25.0 - *2014-06-22*
* add sidebar
* add initial theme support
* add icons from [Evolvere Icon Theme](http://franksouza183.deviantart.com/art/Evolvere-Icon-theme-440718295)
* add PHP variant to calc folder sizes
* add scroll position reset on location change (issue [#279](https://github.com/lrsjng/h5ai/issues/279))
* add option to hide unreadable files
* add option where to place folders (top, inplace, bottom)
* add markdown support for custom header and footer files
* add video and audio preview via HTML5 elements (no fallback, works best in Chrome)
* add filter reset on location change
* add option to make download button always visible
* add Google UA support
* extend selectable icon sizes (add 128px, 192px, 256px, 384px)
* improve preview GUI
* disable thumbs in `cache` folder
* fix QR code URI origin (issue [#287](https://github.com/lrsjng/h5ai/issues/287))
* replace PHP backtick operator with `exec`
* remove server side file manipulation extensions `dropbox`, `delete` and `rename`
* update `H5BP` to 4.3.0
* update `jQuery` to 2.1.1
* update `json2.js` to 2014-02-04
* update `markdown-js` to 0.5.0
* update `Modernizr` to 2.8.2
* update `Moment.js` to 2.6.0
* update `Underscore.js` to 1.6.0
* update languages (`bg`, `ko`, `pt`, `sl`, `sv`, `zh-cn`)
## v0.24.1 - *2014-04-09*
* security fixes! (issues [#268](https://github.com/lrsjng/h5ai/issues/268), [#269](https://github.com/lrsjng/h5ai/issues/269))
* fix WinOS command detection
* update languages (`fi`, `fr`, `hi`, `it`, `zh-tw`)
## v0.24.0 - *2013-09-04*
* updates image and text preview
* adds variable icon sizes
* adds optional natural sort of items
* adds optional checkboxes to select items
* adds text preview modes: none, fixed, markdown
* optionally hide folders in main view
* makes use of EXIF thumbnails optional
* fixes file deletion of multiple files
* fixes `setParentFolderLabels = false`
* fixes shell-arg and RegExp escape issues
* cleans code
* updates info page `/_h5ai`
* adds `aiff` to `audio` types
* adds `da` translation by Ronnie Milbo
* updates to `pl` translation by Mark
## v0.23.0 - *2013-07-21*
* removes `aai` mode!
* drops support for IE7+8 (simple fallback, same as no javascript)
* uses History API if available (way faster browsing)
* faster thumbnail generation if EXIF thumbnails available
* adds optional custom headers/footers that are propageted to all subfolders
* optional hide parent folder links
* some fixes on previews
* speeds up packaged downloads
* add line wrap and line highlighting (on hover) to text preview
* new design (colors, images)
* now uses scalable images for the interface
* fixes filter (ignore parent folder, display of `no match`)
* lots of small fixes
* updates `H5BP` to 4.2.0
* updates `jQuery` to 2.0.3
* updates `jQuery.mousewheel` to 3.1.3
* updates `Moment.js` to 2.1.0
* updates `markdown-js` to 0.4.0-9c21acdf08
* updates `json2.js` to 2013-05-26
* adds `uk` translation by Viktor Matveenko
* updates to `pl` translation by Mark
## v0.22.1 - *2012-10-16*
* bug fix concerning API requests in PHP mode
* minor changes in responsive styles
## v0.22 - *2012-10-14*
* general changes h5ai directory layout and configuration
* splits configuration file (`config.json`) into files `options.json`, `types.json` and `langs.json`
* localization now in separate files
* adds auto-refresh
* adds drag'n'drop upload (PHP, experimental)
* adds file deletion (PHP, experimental)
* cleans and improves PHP code
* PHP no longer respects htaccess restrictions (so be careful)
* PHP ignore patterns might include paths now
* improves separation between aai and php mode
* improves performance in aai mode
* adds optional binary prefixes for file sizes
* improves filter: autofocus on keypress, clear on `ESC`
* download packages now packaged relative to current folder
* download package name changable
* splits type `js` into `js` and `json`
* prevents some errors with files > 2GB on 32bit OS
* adds max subfolder size in tree view
* adds ctrl-click file selection
* adds Piwik analytics extension
* temp download packages are now stored in the `cache`-folder and deleted as soon as possible
* updates translations
* adds `he` translation by [Tomer Cohen](https://github.com/tomer)
* updates 3rd party libs
## v0.21 - *2012-08-06*
* fixes misaligned image previews
* adds no JavaScript fallback to PHP version
* fixes duplicate tree entries and empty main views
* adds Google Analytics support (async)
* improves filter (now ignorecase, now only checks if chars in right order)
* adds keyboard support to image preview (space, enter, backspace, left, right, up, down, f, esc)
* adds text file preview and highlighting with [SyntaxHighlighter](http://alexgorbatchev.com/SyntaxHighlighter/) (same keys as img preview)
* adds Markdown preview with [markdown-js](https://github.com/evilstreak/markdown-js)
* adds new type `markdown`
* changes language code `gr` to `el`
* adds localization for filter placeholder
* adds `hu` translation by [Rodolffo](https://github.com/Rodolffo)
* updates to [jQuery.qrcode](https://larsjung.de/qrcode/) 0.2
* updates to [jQuery.scrollpanel](https://larsjung.de/scrollpanel/) 0.1
* updates to [modulejs](https://larsjung.de/modulejs/) 0.2
* updates to [Moment.js](http://momentjs.com) 1.7.0
* updates to [Underscore.js](http://underscorejs.org) 1.3.3
## v0.20 - *2012-05-11*
* adds image preview
* adds thumbnails for video and pdf
* adds support for lighttpd, nginx and cherokee and maybe other webservers with PHP
* adds folder size in PHP version via shell `du`
* fixes some localization problems
* updates info page at `/_h5ai/`
* switches to JSHint
## v0.19 - *2012-04-19*
* adds lots of config options
* changes in `config.js` and `h5ai.htaccess`
* fixes js problems in IE 7+8
* hides broken tree view in IE < 9, adds a message to the footer
* removes hash changes since they break logical browser history
* fixes thumbnail size for portrait images in icon view
* fixes problems with file type recognition
* adds an info page at `/_h5ai/`
* sort order is preserved while browsing
* removes PHP error messages on thumbnail generation
* fixes PHP some problems with packed download
* adds support for tarred downloads
* changes crumb image for folders with an index file
* adds `index.php` to use h5ai in non-Apache environments
* switches from [Datejs](http://www.datejs.com) to [Moment.js](http://momentjs.com)
* adds [underscore.js](http://underscorejs.org)
* fixes mousewheel problems, updates [jQuery.mousewheel](https://github.com/brandonaaron/jquery-mousewheel) to 3.0.6
* updates `lv` translation
* adds `ro` translation by [Jakob Cosoroabă](https://github.com/midday)
* adds `ja` translation by [metasta](https://github.com/metasta)
* adds `nb` translation by [Sindre Sorhus](https://github.com/sindresorhus)
* adds `sr` translation by [vBm](https://github.com/vBm)
* adds `gr` translation by [xhmikosr](https://github.com/xhmikosr)
## v0.18 - *2012-02-24*
* adds optional QRCode display
* adds optional filtering for displayed files and folders
* updates design
* improves zipped download
* adds support for zipped download of htaccess restricted files
* changes h5ai.htaccess
* custom headers/footers are now optional and disabled by default
* fixes problems with folder recognition in the JS version
* fixes include problems in PHP version
* fixes path problems on servers running on Windows in PHP version
* fixes broken links in custom headers/footers while zipped download enabled
* fixes problems with thumbnails for files with single or double quotes in filename
* improves url hashes
* updates year in `LICENSE.TXT`
* updates es translation
* adds `zh-tw` translation by [Yao Wei](https://github.com/medicalwei)
* updates `zh-cn` translation
## v0.17 - *2011-11-28*
* h5ai is now located in `_h5ai` to reduce collisions
* switches from HTML5 Boilerplate reset to normalization
* adds some style changes for small devices
* configuration (options, types, translations) now via `config.js`
* icons for JS version are now configured via `config.js`
* sort order configuration changed
* sorting is now done without page reload
* adds `customHeader` and `customFooter` to `config.js`
* supports restricted folders to some extent
* some style changes on tree and language menu
* fixes total file/folder count in status bar
* adds support for use with userdir (requires some manual changes)
## v0.16 - *2011-11-02*
* sorts translations in `options.js`
* improves HTML head sections
* refactors JavaScript and PHP a lot
* improves/fixes file selection for zipped download
* fixes scrollbar and header/footer link issues (didn't work when zipped download enabled)
* adds support for ctrl-select
* `dateFormat` in `options.js` changed, now affecting JS and PHP version
* `dateFormat` is localizable by adding it to a translation in `options.js`
* PHP version is now configurable via `php/config.php` (set custom doc root and other PHP related things)
* image thumbs and zipped download is disabled by default now, but works fine if PHP is configured
## v0.15.2 - *2011-09-18*
* adds `it` translation by [Salvo Gentile](https://github.com/SalvoGentile) and [Marco Patriarca](https://github.com/Fexys)
* switches build process from scripp to wepp
## v0.15.1 - *2011-09-06*
* fixes security issues with the zipped download feature
* makes zipped download optional (but enabled by default)
## v0.15 - *2011-09-04*
* adds zipped download for selected files
* cleans and refactores
## v0.14.1 - *2011-09-01*
* display meta information in bottom bar (icon view)
* adds `zh-cn` translation by [Dongsheng Cai](https://github.com/dongsheng)
* adds `pl` translation by Radosław Zając
* adds `ru` translation by Богдан Илюхин
## v0.14 - *2011-08-16*
* adds image thumbnails for PHP version
* new option `slideTree` to turn off auto slide in
## v0.13.2 - *2011-08-12*
* changes in `/h5ai/.htaccess` ... PHP configuration ...
## v0.13.1 - *2011-08-12*
* fixes initial tree display
* adds sort order option
* adds/fixes some translations
* adds `lv` translation by Sandis Veinbergs
## v0.13 - *2011-08-06*
* adds PHP implementation! (should work with PHP 5.2+)
* adds new options
* changes layout of the bottom bar to display status information
* adds language selector to the bottom bar
* quotes keys in `options.js` to make it valid json
* changes value of option `lang` from `undefined` to `null`
* adds some new keys to `h5aiLangs`
* adds browser caching rules for css and js
* adds `pt` translation by [Jonnathan](https://github.com/jonnsl)
* adds `bg` translation by George Andonov
## v0.12.3 - *2011-07-30*
* adds `tr` translation by [Batuhan Icoz](https://github.com/batuhanicoz)
## v0.12.2 - *2011-07-30*
* adds `es` translation by Jose David Calderon Serrano
## v0.12.1 - *2011-07-29*
* fixes unchecked use of console.log
## v0.12 - *2011-07-28*
* improves performance
## v0.11 - *2011-07-27*
* changes license to MIT license, see `LICENSE.txt`
## v0.10.2 - *2011-07-26*
* improves tree scrollbar
## v0.10.1 - *2011-07-24*
* fixes problems with ' in links
## v0.10 - *2011-07-24*
* fixes problems with XAMPP on Windows (see `dot.htaccess` comments for instructions)
* fixes tree fade-in-fade-out effect for small displays ([issue #6](https://github.com/lrsjng/h5ai/issues/6))
* adds custom scrollbar to tree ([issue #6](https://github.com/lrsjng/h5ai/issues/6))
* fixes broken links caused by URI encoding/decoding ([issue #9](https://github.com/lrsjng/h5ai/issues/9))
* adds "empty" to localization (hope Google Translate did a good job here)
## v0.9 - *2011-07-18*
* links hover states between crumb, extended view and tree
* fixes size of tree view (now there's a ugly scrollbar, hopefully will be fixed)
* refactores js to improve performance and cleaned code
* adds caching for folder status codes and content
* adds `fr` translation by [Nicolas](https://github.com/Nicosmos)
* adds `nl` translation by [Stefan de Konink](https://github.com/skinkie)
* adds `sv` translation by Oscar Carlsson
## v0.8 - *2011-07-08*
* removes slashes from folder labels
* optionally rename parent folder entries to real folder names, see `options.js`
* long breadcrumbs (multiple rows) no longer hide content
* error folder icons are opaque now
* refactores js a lot (again...)
## v0.7 - *2011-07-07*
* removes shadows
* smarter tree side bar
## v0.6 - *2011-07-05*
* refactores js
* adds localization, see `options.js`
## v0.5.3 - *2011-07-04*
* refactores js
* adds basic options support via `options.js`
* adds comments to `options.js`
* adds optional tree sidebar
## v0.5.2 - *2011-07-02*
* details view adjusts to window width
* links icon for *.gz and *.bz2
## v0.5.1 - *2011-07-01*
* disables tree sidebar for now, since it had unwanted side effects
## v0.5 - *2011-07-01*
* adds tree sidebar
* some refactorings
## v0.4 - *2011-06-27*
* adds better fallback, in case JavaScript is disabled
* rewrites js, fixed middle-button click etc. problems
* refactors css
* sorts, adds and moves icons and images
* updates dot.access
## v0.3.2 - *2011-06-24*
* removes lib versions from file names
* adds 'empty' indicator for icons view
## v0.3.1 - *2011-06-24*
* refactores js
* adds `folderClick` and `fileClick` callback hooks
* fixes .emtpy style
## v0.3 - *2011-06-23*
* includes build stuff, files previously found in the base directory are now located in folder `target`
* styles and scripts are now minified
* adds Modernizr 2.0.4 for future use
* updates jQuery to version 1.6.1
## v0.2.3 - *2011-06-17*
* more refactoring in main.js
## v0.2.2 - *2011-06-16*
* refactores a lot, adds some comments
* includes fixes from [NumEricR](https://github.com/NumEricR)
* adds top/bottom message support, only basicly styled
## v0.2.1 - *2011-06-16*
* fixes croped filenames
* fixes missing .png extension in header
* adds some color to the links
* adds changelog
## v0.2 - *2011-06-15*
* adds icon view

73
README.md Normal file
View File

@@ -0,0 +1,73 @@
# h5ai
[![license][license-img]][github] [![web][web-img]][web] [![github][github-img]][github]
A modern HTTP web server index for Apache httpd, lighttpd, and nginx.
## Important
* Do **not** install any files from the `src` folder, they need to be
preprocessed to work correctly!
* Find a preprocessed package and detailed install instructions on the
[project page][web].
* For bug reports and feature requests please use [issues][github-issues].
## Build
There are installation ready packages for the latest [releases][release] and
[dev builds][develop]. But to build **h5ai** yourself either `git clone` or
download the repository. From within the root folder run the following
commands to find a fresh zipball in folder `build` (tested on linux only,
requires [`node 10.0+`][node] to be installed, might work on other
configurations).
~~~sh
> npm install
> npm run build
~~~
## License
The MIT License (MIT)
Copyright (c) 2020 Lars Jung (https://larsjung.de)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
## References
**h5ai** profits from other projects, all of them licensed under the MIT license
too. Exceptions are some [Material Design icons][material-design-icons] (CC BY 4.0).
[web]: https://larsjung.de/h5ai/
[github]: https://github.com/lrsjng/h5ai
[github-issues]: https://github.com/lrsjng/h5ai/issues
[release]: https://release.larsjung.de/h5ai/
[develop]: https://release.larsjung.de/h5ai/develop/
[node]: https://nodejs.org
[material-design-icons]: https://github.com/google/material-design-icons
[license-img]: https://img.shields.io/badge/license-MIT-a0a060.svg?style=flat-square
[web-img]: https://img.shields.io/badge/web-larsjung.de/h5ai-a0a060.svg?style=flat-square
[github-img]: https://img.shields.io/badge/github-lrsjng/h5ai-a0a060.svg?style=flat-square

157
ghu.js Normal file
View File

@@ -0,0 +1,157 @@
const {resolve, join} = require('path');
const {
ghu, autoprefixer, cssmin, each, ife, includeit, jszip, less, mapfn,
pug, read, remove, run, uglify, watch, webpack, wrap, write
} = require('ghu');
const ROOT = resolve(__dirname);
const SRC = join(ROOT, 'src');
const TEST = join(ROOT, 'test');
const BUILD = join(ROOT, 'build');
const mapper = mapfn.p(SRC, BUILD).s('.less', '.css').s('.pug', '');
const WEBPACK_CFG = {
mode: 'none',
module: {
rules: [
{
test: /\.js$/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
}
},
{
test: /jsdom/,
use: 'null-loader'
}
]
}
};
ghu.defaults('release');
ghu.before(runtime => {
runtime.pkg = Object.assign({}, require('./package.json'));
const res = run.sync(`git rev-list v${runtime.pkg.version}..HEAD`, {silent: true});
if (res.code === 0) {
const hashes = res.stdout.split(/\r?\n/).filter(x => x);
if (hashes.length) {
const counter = ('000' + hashes.length).substr(-3);
const hash = hashes[0].substr(0, 7);
runtime.pkg.version += `+${counter}~${hash}`;
}
}
runtime.comment = `${runtime.pkg.name} v${runtime.pkg.version} - ${runtime.pkg.homepage}`;
runtime.comment_js = `/* ${runtime.comment} */\n`;
runtime.comment_html = `<!-- ${runtime.comment} -->`;
console.log(runtime.comment);
});
ghu.task('force-production', 'ensure :production flag is set', runtime => {
if (!runtime.args.production) {
runtime.args.production = true;
console.log('forcing production mode');
}
});
ghu.task('clean', 'delete build folder', () => {
return remove(BUILD);
});
ghu.task('build:scripts', runtime => {
return read(`${SRC}/_h5ai/public/js/scripts.js`)
.then(webpack(WEBPACK_CFG))
.then(wrap('\n\n// @include "pre.js"\n\n'))
.then(includeit())
.then(ife(() => runtime.args.production, uglify()))
.then(wrap(runtime.comment_js))
.then(write(mapper, {overwrite: true}));
});
ghu.task('build:styles', runtime => {
return read(`${SRC}/_h5ai/public/css/*.less`)
.then(includeit())
.then(less())
.then(autoprefixer())
.then(ife(() => runtime.args.production, cssmin()))
.then(wrap(runtime.comment_js))
.then(write(mapper, {overwrite: true}));
});
ghu.task('build:pages', runtime => {
return read(`${SRC}: **/*.pug, ! **/*.tpl.pug`)
.then(pug({pkg: runtime.pkg}))
.then(wrap('', runtime.comment_html))
.then(write(mapper, {overwrite: true}));
});
ghu.task('build:copy', runtime => {
const mapper_root = mapfn.p(ROOT, join(BUILD, '_h5ai'));
return Promise.all([
read(`${SRC}/**/conf/*.json`)
.then(wrap(runtime.comment_js))
.then(write(mapper, {overwrite: true, cluster: true})),
read(`${SRC}: **, ! **/*.js, ! **/*.less, ! **/*.pug, ! **/conf/*.json`)
.then(each(obj => {
if ((/index\.php$/).test(obj.source)) {
obj.content = obj.content.replace('{{VERSION}}', runtime.pkg.version);
}
}))
.then(write(mapper, {overwrite: true, cluster: true})),
read(`${ROOT}/*.md`)
.then(write(mapper_root, {overwrite: true, cluster: true}))
]);
});
ghu.task('build:tests', ['build:styles'], 'build the test suite', () => {
return Promise.all([
read(`${BUILD}/_h5ai/public/css/styles.css`)
.then(write(`${BUILD}/test/h5ai-styles.css`, {overwrite: true})),
read(`${TEST}/index.html`)
.then(write(`${BUILD}/test/index.html`, {overwrite: true})),
read(`${TEST}: index.js`)
.then(webpack(WEBPACK_CFG))
.then(wrap(`\n\n// @include "${SRC}/**/js/pre.js"\n\n`))
.then(includeit())
.then(write(mapfn.p(TEST, `${BUILD}/test`), {overwrite: true}))
]).then(() => {
console.log(`browse to file://${BUILD}/test/index.html to run the test suite`);
});
});
ghu.task('build', ['build:scripts', 'build:styles', 'build:pages', 'build:copy', 'build:tests'],
'build all updated files, optionally use :production');
ghu.task('deploy', ['build'], 'deploy to a specified path with :dest=/some/path', runtime => {
if (typeof runtime.args.dest !== 'string') {
throw new Error('no destination path (e.g. :dest=/some/path)');
}
console.log(`deploy to ${runtime.args.dest}`);
const mapper_deploy = mapfn.p(BUILD, resolve(runtime.args.dest));
return read(`${BUILD}/_h5ai/**`)
.then(write(mapper_deploy, {overwrite: true, cluster: true}));
});
ghu.task('watch', runtime => {
return watch([SRC, TEST], () => ghu.run(runtime.sequence.filter(x => x !== 'watch'), runtime.args, true));
});
ghu.task('release', ['force-production', 'clean', 'build'], 'create a zipball', runtime => {
const target = join(BUILD, `${runtime.pkg.name}-${runtime.pkg.version}.zip`);
return read(`${BUILD}/_h5ai/**`)
.then(jszip({dir: BUILD, level: 9}))
.then(write(target, {overwrite: true}));
});

7428
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

31
package.json Normal file
View File

@@ -0,0 +1,31 @@
{
"name": "h5ai",
"version": "0.30.0",
"description": "Modern HTTP web server index.",
"homepage": "https://larsjung.de/h5ai/",
"author": "Lars Jung <lrsjng@gmail.com> (https://larsjung.de)",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/lrsjng/h5ai.git"
},
"scripts": {
"lint": "eslint .",
"test": "node test",
"build": "node ghu release",
"precommit": "npm run -s lint && npm run -s test"
},
"devDependencies": {
"@babel/core": "7.12.10",
"@babel/preset-env": "7.12.11",
"eslint": "7.18.0",
"ghu": "0.26.0",
"jsdom": "16.4.0",
"kjua": "0.9.0",
"lolight": "1.4.0",
"marked": "1.2.7",
"normalize.css": "8.0.1",
"null-loader": "4.0.1",
"scar": "2.3.0"
}
}

4
src/.eslintrc Normal file
View File

@@ -0,0 +1,4 @@
---
rules:
no-console: 1
prefer-reflect: 0

165
src/_h5ai/.htaccess Normal file
View File

@@ -0,0 +1,165 @@
## details here: https://github.com/h5bp/server-configs-apache
## SECURITY ###################################################################
DirectoryIndex disabled
FileETag None
ServerSignature Off
# Apache < 2.3
<IfModule !mod_authz_core.c>
Order allow,deny
Deny from all
Satisfy All
</IfModule>
# Apache ≥ 2.3
<IfModule mod_authz_core.c>
Require all denied
</IfModule>
<IfModule mod_headers.c>
Header set X-Content-Type-Options "nosniff"
Header unset ETag
Header unset X-Powered-By
</IfModule>
<IfModule mod_autoindex.c>
Options -Indexes
</IfModule>
## COMPAT #####################################################################
AddDefaultCharset utf-8
<IfModule mod_mime.c>
AddCharset utf-8 .css .html .js .json .php .svg
AddType application/font-woff woff
AddType application/font-woff2 woff2
AddType application/json json
AddType application/javascript js
AddType application/vnd.ms-fontobject eot
AddType application/x-font-ttf ttc ttf
AddType image/jpeg jpeg jpg
AddType image/png png
AddType image/svg+xml svg svgz
AddType image/x-icon ico
AddType font/opentype otf
AddType text/css css
AddType text/html html
</IfModule>
## SPEED ######################################################################
<IfModule mod_expires.c>
ExpiresActive on
ExpiresDefault "access plus 1 month"
ExpiresByType application/json "access plus 0 seconds"
ExpiresByType text/html "access plus 1 minute"
ExpiresByType image/x-icon "access plus 1 week"
ExpiresByType application/javascript "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType image/svg+xml "access plus 1 year"
ExpiresByType text/css "access plus 1 year"
</IfModule>
<IfModule mod_deflate.c>
<IfModule mod_setenvif.c>
<IfModule mod_headers.c>
SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
</IfModule>
</IfModule>
# Apache ≥ 2.3
<IfModule mod_authz_core.c>
# mod_filter as module only available for Apache ≥ 2.3.7
<IfModule mod_filter.c>
AddOutputFilterByType DEFLATE "application/atom+xml" \
"application/javascript" \
"application/json" \
"application/ld+json" \
"application/manifest+json" \
"application/rdf+xml" \
"application/rss+xml" \
"application/schema+json" \
"application/vnd.geo+json" \
"application/vnd.ms-fontobject" \
"application/x-font-ttf" \
"application/x-javascript" \
"application/x-web-app-manifest+json" \
"application/xhtml+xml" \
"application/xml" \
"font/eot" \
"font/opentype" \
"image/bmp" \
"image/svg+xml" \
"image/vnd.microsoft.icon" \
"image/x-icon" \
"text/cache-manifest" \
"text/css" \
"text/html" \
"text/javascript" \
"text/plain" \
"text/vcard" \
"text/vnd.rim.location.xloc" \
"text/vtt" \
"text/x-component" \
"text/x-cross-domain-policy" \
"text/xml"
</IfModule>
</IfModule>
# Apache < 2.3
<IfModule !mod_authz_core.c>
AddOutputFilterByType DEFLATE "application/atom+xml" \
"application/javascript" \
"application/json" \
"application/ld+json" \
"application/manifest+json" \
"application/rdf+xml" \
"application/rss+xml" \
"application/schema+json" \
"application/vnd.geo+json" \
"application/vnd.ms-fontobject" \
"application/x-font-ttf" \
"application/x-javascript" \
"application/x-web-app-manifest+json" \
"application/xhtml+xml" \
"application/xml" \
"font/eot" \
"font/opentype" \
"image/bmp" \
"image/svg+xml" \
"image/vnd.microsoft.icon" \
"image/x-icon" \
"text/cache-manifest" \
"text/css" \
"text/html" \
"text/javascript" \
"text/plain" \
"text/vcard" \
"text/vnd.rim.location.xloc" \
"text/vtt" \
"text/x-component" \
"text/x-cross-domain-policy" \
"text/xml"
</IfModule>
<IfModule mod_mime.c>
AddEncoding gzip gz
AddEncoding gzip svgz
</IfModule>
</IfModule>

9
src/_h5ai/private/cache/README.md vendored Normal file
View File

@@ -0,0 +1,9 @@
# Cache
Private cache.
This directory is used for server side caching. To use caching make this
directory writable for your webserver.
There is no critical data in here. You can savely remove any content. This
will clear the cache.

View File

@@ -0,0 +1,18 @@
{
"lang": "afrikaans",
"dateFormat": "YYYY-MM-DD HH:mm",
"details": "besonderhede",
"download": "aflaai",
"empty": "leeg",
"files": "lêers",
"filter": "filter",
"folders": "gidse",
"grid": "rooster",
"icons": "ikone",
"lastModified": "Laas verander",
"name": "Naam",
"noMatch": "geen resultaat",
"parentDirectory": "Hoër Vlak",
"size": "Grootte"
}

View File

@@ -0,0 +1,18 @@
{
"lang": "български",
"dateFormat": "DD-MM-YYYY HH:mm",
"details": "детайли",
"download": "изтегляне",
"empty": "празна",
"files": "файлове",
"filter": "филтър",
"folders": "директории",
"grid": "мрежа",
"icons": "икони",
"lastModified": "Последна промяна",
"name": "Име",
"noMatch": "няма съвпадение",
"parentDirectory": "Предходна директория",
"size": "Размер"
}

View File

@@ -0,0 +1,18 @@
{
"lang": "čeština",
"dateFormat": "DD.MM.YYYY HH:mm",
"details": "Podrobnosti",
"download": "Stáhnout",
"empty": "Prázdná složka",
"files": "souborů",
"filter": "Filtr",
"folders": "složek",
"grid": "Seznam",
"icons": "Velké ikony",
"lastModified": "Datum změny",
"name": "Název",
"noMatch": "Žádná shoda",
"parentDirectory": "Nadřazený adresář",
"size": "Velikost"
}

View File

@@ -0,0 +1,18 @@
{
"lang": "dansk",
"dateFormat": "DD-MM-YYYY HH:mm",
"details": "detaljer",
"download": "download",
"empty": "tom",
"files": "filer",
"filter": "filter",
"folders": "mapper",
"grid": "grid",
"icons": "ikoner",
"lastModified": "Sidst ændret",
"name": "Navn",
"noMatch": "ingen match",
"parentDirectory": "Overordnet mappe",
"size": "Størrelse"
}

View File

@@ -0,0 +1,22 @@
{
"lang": "deutsch",
"dateFormat": "DD.MM.YYYY HH:mm",
"details": "Details",
"download": "Download",
"empty": "leer",
"files": "Dateien",
"filter": "filtern",
"folders": "Ordner",
"grid": "Gitter",
"icons": "Icons",
"language": "Sprache",
"lastModified": "Geändert",
"name": "Name",
"noMatch": "keine Treffer",
"parentDirectory": "Übergeordnetes Verzeichnis",
"search": "suchen",
"size": "Größe",
"tree": "Baum",
"view": "Ansicht"
}

View File

@@ -0,0 +1,18 @@
{
"lang": "ελληνικά",
"dateFormat": "DD/MM/YYYY HH:mm",
"details": "λεπτομέρειες",
"download": "μεταμόρφωση",
"empty": "κενό",
"files": "αρχεία",
"filter": "φίλτρο",
"folders": "φάκελοι",
"grid": "πλέγμα",
"icons": "εικονίδια",
"lastModified": "Τελευταία τροποποίηση",
"name": "Όνομα",
"noMatch": "κανένα αποτέλεσμα",
"parentDirectory": "Προηγούμενος Κατάλογος",
"size": "Μέγεθος"
}

View File

@@ -0,0 +1,23 @@
/* only here as a reference, these values are the hardcoded defaults */
{
"lang": "english",
"dateFormat": "YYYY-MM-DD HH:mm",
"details": "details",
"download": "download",
"empty": "empty",
"files": "files",
"filter": "filter",
"folders": "folders",
"grid": "grid",
"icons": "icons",
"language": "Language",
"lastModified": "Last modified",
"name": "Name",
"noMatch": "no match",
"parentDirectory": "Parent Directory",
"search": "search",
"size": "Size",
"tree": "Tree",
"view": "View"
}

View File

@@ -0,0 +1,22 @@
{
"lang": "español",
"dateFormat": "DD/MM/YYYY HH:mm",
"details": "Detalles",
"download": "Descargar",
"empty": "vacío",
"files": "Archivos",
"filter": "Filtrar",
"folders": "Directorios",
"grid": "Cuadrícula",
"icons": "Íconos",
"language": "Idioma",
"lastModified": "Última modificación",
"name": "Nombre",
"noMatch": "Sin coincidencias",
"parentDirectory": "Directorio superior",
"search": "buscar",
"size": "Tamaño",
"tree": "Arbol",
"view": "Vista"
}

View File

@@ -0,0 +1,22 @@
{
"lang": "estonian",
"dateFormat": "DD-MM-YYYY HH.mm",
"details": "täpsem info",
"download": "laadi alla",
"empty": "tühi",
"files": "failid",
"filter": "filter",
"folders": "kataloogid",
"grid": "võre",
"icons": "ikoonid",
"language": "Keel",
"lastModified": "Viimati muudetud",
"name": "Nimi",
"noMatch": "ei leitud sobivat",
"parentDirectory": "Emakataloog",
"search": "otsi",
"size": "Suurus",
"tree": "Puu",
"view": "Vaade"
}

View File

@@ -0,0 +1,18 @@
{
"lang": "finnish",
"dateFormat": "DD.MM.YYYY HH:mm",
"details": "tiedot",
"download": "lataa",
"empty": "tyhjä",
"files": "tiedostoa",
"filter": "suodata",
"folders": "hakemistoa",
"grid": "ruudukko",
"icons": "ikonit",
"lastModified": "Viimeksi muokattu",
"name": "Nimi",
"noMatch": "ei osumia",
"parentDirectory": "Ylähakemisto",
"size": "Koko"
}

View File

@@ -0,0 +1,22 @@
{
"lang": "français",
"dateFormat": "DD/MM/YYYY HH:mm",
"details": "détails",
"download": "télécharger",
"empty": "vide",
"files": "Fichiers",
"filter": "filtrer",
"folders": "Répertoires",
"grid": "grille",
"icons": "icônes",
"language": "Langue",
"lastModified": "Dernière modification",
"name": "Nom",
"noMatch": "rien trouvé",
"parentDirectory": "Dossier parent",
"search": "rechercher",
"size": "Taille",
"tree": "Arborescence",
"view": "Disposition"
}

View File

@@ -0,0 +1,17 @@
{
"lang": "עברית",
"dateFormat": "DD.MM.YYYY HH:mm",
"details": "פרטים",
"download": "הורדה",
"empty": "ריק",
"files": "קבצים",
"filter": "סינון",
"folders": "תיקיות",
"icons": "צלמיות",
"lastModified": "שינוי אחרון",
"name": "שם",
"noMatch": "אין תוצאות",
"parentDirectory": "תיקיית הורה",
"size": "גודל"
}

View File

@@ -0,0 +1,18 @@
{
"lang": "हिंदी",
"dateFormat": "DD.MM.YYYY HH:mm",
"details": "विस्तार",
"download": "डाउनलोड",
"empty": "खाली",
"files": "फ़ाइलें",
"filter": "फ़िल्टर",
"folders": "फोल्डर",
"grid": "ग्रिड",
"icons": "आइकॉन",
"lastModified": "पिछला परिवर्तन",
"name": "नाम",
"noMatch": "कोई समानता नहीं",
"parentDirectory": "मूल डायरेक्टरी",
"size": "माप"
}

View File

@@ -0,0 +1,18 @@
{
"lang": "hrvatski",
"dateFormat": "YYYY-MM-DD HH:mm",
"details": "detalji",
"download": "preuzmi",
"empty": "prazno",
"files": "datoteka",
"filter": "filter",
"folders": "direktorij(a)",
"grid": "mreža",
"icons": "ikone",
"lastModified": "Posljednja izmjena",
"name": "Naziv",
"noMatch": "nema rezultata",
"parentDirectory": "Natrag",
"size": "Veličina"
}

View File

@@ -0,0 +1,16 @@
{
"lang": "magyar",
"dateFormat": "YYYY-MM-DD HH:mm",
"details": "részletek",
"download": "letöltés",
"empty": "üres",
"files": "fájlok",
"folders": "mappák",
"icons": "ikonok",
"lastModified": "Utoljára módosítva",
"name": "Név",
"noMatch": "nincs találat",
"parentDirectory": "Szülő könyvtár",
"size": "Méret"
}

View File

@@ -0,0 +1,22 @@
{
"lang": "Bahasa Indonesia",
"dateFormat": "DD-MM-YYYY HH:mm",
"details": "rincian",
"download": "unduh",
"empty": "kosong",
"files": "berkas",
"filter": "saring",
"folders": "pelipat",
"grid": "jaring",
"icons": "ikon",
"language": "Bahasa",
"lastModified": "Di modifikasi",
"name": "Nama",
"noMatch": "tidak cocok",
"parentDirectory": "Direktori induk",
"search": "cari",
"size": "Ukuran",
"tree": "Pohon",
"view": "Tampil"
}

View File

@@ -0,0 +1,22 @@
{
"lang": "italiano",
"dateFormat": "DD-MM-YYYY HH:mm",
"details": "dettagli",
"download": "download",
"empty": "vuota",
"files": "file",
"filter": "filtra",
"folders": "cartelle",
"grid": "griglia",
"icons": "icone",
"language": "Linugua",
"lastModified": "Ultima modifica",
"name": "Nome",
"noMatch": "nessun risultato",
"parentDirectory": "Cartella Superiore",
"search": "cerca",
"size": "Dimensione",
"tree": "Albero",
"view": "Vista"
}

View File

@@ -0,0 +1,20 @@
{
"lang": "日本語",
"dateFormat": "YYYY-MM-DD HH:mm",
"details": "詳細",
"download": "ダウンロード",
"empty": "(空)",
"files": "ファイル",
"filter": "フィルター",
"folders": "フォルダー",
"grid": "グリッド",
"icons": "アイコン",
"language": "言語",
"lastModified": "最終変更日時",
"name": "名前",
"noMatch": "一致する項目が見つかりません",
"parentDirectory": "親ディレクトリへ",
"size": "サイズ",
"view": "ビュー"
}

View File

@@ -0,0 +1,22 @@
{
"lang": "한국어",
"dateFormat": "YYYY-MM-DD HH:mm",
"details": "자세히",
"download": "다운로드",
"empty": "빈 폴더",
"files": "파일",
"filter": "필터",
"folders": "폴더",
"grid": "그리드",
"icons": "아이콘",
"language": "언어",
"lastModified": "최근 수정일",
"name": "파일명",
"noMatch": "해당파일이 없습니다.",
"parentDirectory": "상위폴더",
"search": "검색",
"size": "크기",
"tree": "트리",
"view": "보기"
}

View File

@@ -0,0 +1,22 @@
{
"lang": "latviešu",
"dateFormat": "YYYY-MM-DD HH:mm",
"details": "detaļas",
"download": "lejupielādēt",
"empty": "tukšs",
"files": "faili",
"filter": "filtrēt",
"folders": "mapes",
"grid": "režģis",
"icons": "ikonas",
"language": "Valoda",
"lastModified": "Pēdējoreiz modificēts",
"name": "Nosaukums",
"noMatch": "nav sakritības",
"parentDirectory": "Vecākdirektorijs",
"search": "meklēt",
"size": "Izmērs",
"tree": "Koks",
"view": "Skats"
}

View File

@@ -0,0 +1,15 @@
{
"lang": "norwegian",
"details": "detaljer",
"download": "last ned",
"empty": "tom",
"files": "filer",
"folders": "mapper",
"icons": "ikoner",
"lastModified": "Sist endret",
"name": "Navn",
"noMatch": "ingen treff",
"parentDirectory": "Overordnet mappe",
"size": "Størrelse"
}

View File

@@ -0,0 +1,22 @@
{
"lang": "nederlands",
"dateFormat": "YYYY-MM-DD HH:mm",
"details": "details",
"download": "download",
"empty": "leeg",
"files": "bestanden",
"filter": "filter",
"folders": "mappen",
"grid": "grid",
"icons": "iconen",
"language": "Taal",
"lastModified": "Laatste wijziging",
"name": "Naam",
"noMatch": "geen overeenkomst",
"parentDirectory": "Bovenliggende map",
"search": "zoeken",
"size": "Grootte",
"tree": "Boom",
"view": "Bekijk"
}

View File

@@ -0,0 +1,22 @@
{
"lang": "polski",
"dateFormat": "YYYY-MM-DD HH:mm",
"details": "szczegóły",
"download": "pobierz",
"empty": "pusty",
"files": "plików",
"filter": "filtr",
"folders": "folderów",
"grid": "kafelki",
"icons": "ikony",
"language": "Język",
"lastModified": "Ostatnia modyfikacja",
"name": "Nazwa",
"noMatch": "nie znaleziono",
"parentDirectory": "Katalog nadrzędny",
"search": "szukaj",
"size": "Rozmiar",
"tree": "Drzewo",
"view": "Układ"
}

View File

@@ -0,0 +1,22 @@
{
"lang": "português do Brasil",
"dateFormat": "DD-MM-YYYY HH:mm",
"details": "detalhes",
"download": "download",
"empty": "vazio",
"files": "arquivos",
"filter": "filtro",
"folders": "pastas",
"grid": "grade",
"icons": "ícones",
"language": "Idioma",
"lastModified": "Última modificação",
"name": "Nome",
"noMatch": "sem resultados",
"parentDirectory": "Diretório acima",
"search": "pesquisa",
"size": "Tamanho",
"tree": "Árvore",
"view": "Visualização"
}

View File

@@ -0,0 +1,22 @@
{
"lang": "português de Portugal",
"dateFormat": "DD-MM-YYYY HH:mm",
"details": "detalhes",
"download": "descarregar",
"empty": "vazio",
"files": "arquivos",
"filter": "filtro",
"folders": "pastas",
"grid": "grelha",
"icons": "ícones",
"language": "Idioma",
"lastModified": "última modificação",
"name": "Nome",
"noMatch": "sem resultados",
"parentDirectory": "Diretório acima",
"search": "pesquisa",
"size": "Tamanho",
"tree": "Árvore",
"view": "Visualização"
}

View File

@@ -0,0 +1,15 @@
{
"lang": "română",
"details": "detalii",
"download": "descarcă",
"empty": "gol",
"files": "fişiere",
"folders": "dosar",
"icons": "pictograme",
"lastModified": "ultima modificare",
"name": "nume",
"noMatch": "0 rezultate",
"parentDirectory": "dosar părinte",
"size": "mărime"
}

View File

@@ -0,0 +1,20 @@
{
"lang": "русский",
"dateFormat": "YYYY-MM-DD HH:mm",
"details": "Детали",
"download": "Скачать",
"empty": "Пусто",
"files": "Файлы",
"filter": "Фильтр",
"folders": "Папки",
"grid": "Сетка",
"icons": "Иконки",
"language": "Язык",
"lastModified": "Последние изменения",
"name": "Имя",
"noMatch": "Нет совпадений",
"parentDirectory": "Главная директория",
"size": "Размер",
"view": "Вид"
}

View File

@@ -0,0 +1,13 @@
{
"lang": "slovenčina",
"details": "podrobnosti",
"empty": "prázdny",
"files": "súborov",
"folders": "priečinkov",
"icons": "ikony",
"lastModified": "Upravené",
"name": "Názov",
"parentDirectory": "Nadriadený priečinok",
"size": "Velkosť"
}

View File

@@ -0,0 +1,18 @@
{
"lang": "slovenščina",
"dateFormat": "DD. MM. YYYY HH:mm",
"details": "podrobnosti",
"download": "prenesi",
"empty": "prazno",
"files": "datoteke",
"filter": "filter",
"folders": "mape",
"grid": "mreža",
"icons": "ikone",
"lastModified": "Zadnja sprememba",
"name": "Ime",
"noMatch": "ni zadetkov",
"parentDirectory": "Nadrejena mapa",
"size": "Velikost"
}

View File

@@ -0,0 +1,15 @@
{
"lang": "srpski",
"details": "detalji",
"download": "download",
"empty": "prazno",
"files": "fajlovi",
"folders": "direktorijum",
"icons": "ikone",
"lastModified": "Poslednja modifikacija",
"name": "Ime",
"noMatch": "bez poklapanja",
"parentDirectory": "Roditeljski direktorijum",
"size": "Veličina"
}

View File

@@ -0,0 +1,16 @@
{
"lang": "svenska",
"details": "detaljerad",
"download": "ladda ner",
"empty": "tom",
"files": "filer",
"folders": "kataloger",
"grid": "rutnät",
"icons": "ikoner",
"lastModified": "Senast ändrad",
"name": "Filnamn",
"noMatch": "ingen matchning",
"parentDirectory": "Till överordnad mapp",
"size": "Filstorlek"
}

View File

@@ -0,0 +1,14 @@
{
"lang": "türkçe",
"details": "detaylar",
"download": "indir",
"empty": "boş",
"files": "dosyalar",
"folders": "klasörler",
"icons": "ikonlar",
"lastModified": "Son Düzenleme",
"name": "İsim",
"parentDirectory": "Üst Dizin",
"size": "Boyut"
}

View File

@@ -0,0 +1,18 @@
{
"lang": "українська",
"dateFormat": "YYYY-MM-DD HH:mm",
"details": "Деталі",
"download": "Завантажити",
"empty": "Порожньо",
"files": "Файли(ів)",
"filter": "Фільтр",
"folders": "Тек(и)",
"grid": "Гратка",
"icons": "Піктограми",
"lastModified": "Останні зміни",
"name": "Ім'я",
"noMatch": "Немає співпадінь",
"parentDirectory": "Головна тека",
"size": "Розмір"
}

View File

@@ -0,0 +1,23 @@
{
"lang": "简体中文",
"dateFormat": "YYYY-MM-DD HH:mm",
"details": "详情",
"download": "下载",
"empty": "空文件夹",
"files": "文件",
"filter": "过滤",
"folders": "文件夹",
"grid": "网格",
"icons": "图标",
"language": "语言",
"lastModified": "修改时间",
"name": "文件名",
"noMatch": "无匹配项",
"parentDirectory": "父文件夹",
"search": "搜索",
"size": "大小",
"tree": "树形目录",
"view": "视图",
"info": "信息"
}

View File

@@ -0,0 +1,23 @@
{
"lang": "正體中文",
"dateFormat": "YYYY-MM-DD HH:mm",
"details": "詳細資料",
"download": "下載",
"empty": "空資料夾",
"files": "檔案",
"filter": "過濾",
"folders": "資料夾",
"grid": "網格",
"icons": "圖示",
"language": "語言",
"lastModified": "上次修改",
"name": "檔名",
"noMatch": "沒有符合的檔案",
"parentDirectory": "上層目錄",
"search": "搜尋",
"size": "大小",
"tree": "樹形目錄",
"view": "檢視",
"info": "資訊"
}

View File

@@ -0,0 +1,396 @@
{
/*
Password hash.
SHA512 hash of the info page password, the preset password is the empty string.
Online hash generator: http://md5hashing.net/hashing/sha512
*/
"passhash": "cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e",
/*
Resources.
Additional script and style tags added to all pages. Paths not beginning
with "http://", "https://" or "/" will be looked up relative to
"_h5ai/public/ext/" (no check for existence).
- scripts: array of strings
- styles: array of strings
*/
"resources": {
"scripts": [],
"styles": [
"//fonts.googleapis.com/css?family=Ubuntu:300,400,700%7CUbuntu+Mono:400,700"
]
},
/*
General view options.
- binaryPrefix: boolean, set to true uses 1024B=1KiB when formatting file sizes (see http://en.wikipedia.org/wiki/Binary_prefix)
- disableSidebar: boolean, hides sidebar and toggle button
- fallbackMode: boolean, serve fallback mode
- fastBrowsing: boolean, use History API if available (no need to reload the whole page)
- fonts: array of strings, fonts to use in regular context
- fontsMono: array of strings, fonts to use in monopspaced context
- hidden: array of strings, don't list items matching these regular expressions
- hideFolders: boolean, hide all folders in the main view
- hideIf403: boolean, hide files and folders that are not readable by the server
- hideParentFolder: boolean, hide parent folder links in the main view
- maxIconSize: number, max size for icons in the main view
- modes: array of strings, subset of ["details", "grid", "icons"]
the first value indicates the default view mode. If only one value
is given the view mode is fixed and the selector buttons are hidden.
The user selected view mode is also stored local in modern browsers
so that it will be persistent.
- modeToggle: boolean, show a view mode toggle in the toolbar, or "next"
- setParentFolderLabels: boolean, set parent folder labels to real folder names
- sizes: array of numbers
the first value indicates the default view size. If only one value
is given the view size is fixed and the selector buttons are hidden.
The user selected view size is also stored local in modern browsers
so that it will be persistent.
- theme: string, name of one of the folders in "_h5ai/public/images/themes", defaults to "default"
- unmanaged: array of strings, don't manage folders containing one of those files
- unmanagedInNewWindow: boolean, open unmanaged links in new window/tab
*/
"view": {
"binaryPrefix": false,
"disableSidebar": false,
"fallbackMode": false,
"fastBrowsing": true,
"fonts": ["Ubuntu", "Roboto", "Helvetica", "Arial", "sans-serif"],
"fontsMono": ["Ubuntu Mono", "Monaco", "Lucida Sans Typewriter", "monospace"],
"hidden": ["^\\.", "^_h5ai"],
"hideFolders": false,
"hideIf403": true,
"hideParentFolder": false,
"maxIconSize": 40,
"modes": ["details", "grid", "icons"],
"modeToggle": false,
"setParentFolderLabels": true,
"sizes": [20, 40, 60, 80, 100, 140, 180, 220, 260, 300],
"theme": "comity",
"unmanaged": ["index.html", "index.htm", "index.php"],
"unmanagedInNewWindow": false
},
/*** Extensions (in alphabetical order) ***/
/*
Watch and update current folder content.
- interval: number, update interval in milliseconds, at least 1000
*/
"autorefresh": {
"enabled": false,
"interval": 5000
},
/*
Show a clickable breadcrumb.
*/
"crumb": {
"enabled": true
},
/*
Allow customized header and footer files.
First checks for files "_h5ai.header.html" and "_h5ai.footer.html" in the current directory.
If not successful it checks all parent directories (starting in the current directory) for
files "_h5ai.headers.html" and "_h5ai.footers.html".
Note the different filenames: "header" (only current) - "headers" (current and sub directories)!
The file's content will be placed inside a <div/> tag above/below the main content.
If a file's extension is ".md" instead of ".html" its content will be interpreted as markdown.
- stopSearchingAtRoot: boolean, only search for header and footer files until the web root
directory. if `false`, will search for header/footer up the entire directory structure,
even above the web root
*/
"custom": {
"enabled": true,
"stopSearchingAtRoot": true
},
/*
Enable packaged download of selected entries.
To select files the "select"-extension needs to be enabled.
- type: string, "php-tar", "shell-tar" or "shell-zip"
- packageName: string, basename of the download package, null for current filename or foldername
- alwaysVisible: boolean, always show download button (defaults to download the current folder)
*/
"download": {
"enabled": true,
"type": "php-tar",
"packageName": null,
"alwaysVisible": false
},
/*
Allow filtering the displayed files and folders in current folder.
Checks for substrings.
If advanced is enabled it checks entries for right order of characters,
i.e. "ab" matches "ab", "axb", "xaxbx" but not "ba". Space separated
sequences get OR-ed. Searches will be treated as JavaScript regular
expressions if you prefix them with "re:".
- advanced: boolean, use advanced pattern parsing
- debounceTime: number, debounce wait time in milliseconds
- ignorecase: boolean, ignore case
*/
"filter": {
"enabled": false,
"advanced": true,
"debounceTime": 100,
"ignorecase": true
},
/*
Calc the size of folders.
This operation is real slow. The calculated sizes differ slightly for both
calculation types since "php" only adds the file size, while "shell-du"
also adds the sizes for the actual folder files.
- type: string, "php" (sloooow) or "shell-du" (sloow)
*/
"foldersize": {
"enabled": true,
"type": "php"
},
/*
Adds Google Universial Analytics asynchronous tracking code.
see: https://developers.google.com/analytics/devguides/collection/analyticsjs/
- id: string, account ID
*/
"google-analytics-ua": {
"enabled": false,
"id": "UA-000000-0"
},
/*
Enable a generic info side bar.
- show: boolean, initial visible to first time users
- qrcode: boolean, show a QR-Code
- qrColor: string, QR-Code fill color
*/
"info": {
"enabled": true,
"show": false,
"qrcode": true,
"qrFill": "#999",
"qrBack": "#fff"
},
/*
Localization, for example "en", "de" etc. - see "_h5ai/conf/l10n" folder for
possible values. Adjust it to your needs. If lang is not found
it defaults to "en".
- lang: string, default language
- useBroserLang: boolean, try to use browser language
*/
"l10n": {
"enabled": true,
"lang": "en",
"useBrowserLang": true
},
/*
Adds Piwik tracker javascript code.
- baseURL: string, do not include the protocol, e.g. "mydomain.tld/piwik"
- idSite: number
*/
"piwik-analytics": {
"enabled": false,
"baseURL": "some/url",
"idSite": 1
},
/*
Play a audio preview on click.
- autoplay: start playing as soon as ready
- types: array of strings
*/
"preview-aud": {
"enabled": true,
"autoplay": true,
"types": ["aud"]
},
/*
Show an image preview on click.
- types: array of strings
- size: number, sample size, or false for original size
*/
"preview-img": {
"enabled": true,
"size": false,
"types": ["img", "img-bmp", "img-gif", "img-ico", "img-jpg", "img-png", "img-raw", "img-svg"]
},
/*
Show text file preview on click.
Available styles are:
0: floating text
1: fixed width text
2: markdown
3: syntax highlighting
- styles: dict string to int, maps types to styles
*/
"preview-txt": {
"enabled": true,
"styles": {
"txt": 1,
"txt-authors": 1,
"txt-c": 3,
"txt-cpp": 3,
"txt-css": 3,
"txt-diff": 1,
"txt-go": 3,
"txt-h": 3,
"txt-hpp": 3,
"txt-install": 1,
"txt-js": 3,
"txt-json": 3,
"txt-less": 3,
"txt-license": 1,
"txt-log": 1,
"txt-makefile": 1,
"txt-md": 2,
"txt-py": 3,
"txt-rb": 3,
"txt-readme": 1,
"txt-rtf": 1,
"txt-rust": 3,
"txt-script": 3,
"txt-xml": 1
}
},
/*
Play a video preview on click.
- autoplay: start playing as soon as ready
- types: array of strings
*/
"preview-vid": {
"enabled": true,
"autoplay": true,
"types": ["vid-avi", "vid-flv", "vid-mkv", "vid-mov", "vid-mp4", "vid-mpg", "vid-webm"]
},
/*
Allow searching files and folders in and below current folder.
Checks for substrings.
If advanced is enabled it checks entries for right order of characters,
i.e. "ab" matches "ab", "axb", "xaxbx" but not "ba". Space separated
sequences get OR-ed. Searches will be treated as JavaScript regular
expressions if you prefix them with "re:".
- advanced: boolean, use advanced pattern parsing
- debounceTime: number, debounce wait time in milliseconds
- ignorecase: boolean, ignore case
*/
"search": {
"enabled": false,
"advanced": true,
"debounceTime": 300,
"ignorecase": true
},
/*
Make entries selectable.
At the moment only needed for packaged download.
- clickndrag: boolean, allow first mouse button + drag selection
- checkboxes: boolean, show a checkbox on mouse over item
*/
"select": {
"enabled": true,
"clickndrag": true,
"checkboxes": true
},
/*
Default sort order.
"column" and "reverse" are locally stored.
- column: number, 0 for "Name", 1 for "Date", 2 for "Size"
- reverse: boolean, false for ascending, true for descending
- ignorecase: boolean, compare ignorecase
- natural: boolean, use natural sort order
- folders: number, where to place folders, 0 for "top", 1 for "in place", 2 for "bottom"
*/
"sort": {
"enabled": true,
"column": 0,
"reverse": false,
"ignorecase": true,
"natural": true,
"folders": 0
},
/*
Show thumbnails for image files. Needs the "/_h5ai/public/cache" folder to be
writable for the web Server.
- img: array of strings
- mov: array of strings
- doc: array of strings
- delay: number, delay in milliseconds after "dom-ready" before thumb-requesting starts
- size: number, size in pixel of the generated thumbnails
- exif: boolean, use included EXIF thumbs if possible
- chunksize: int, number of thumbs per request
*/
"thumbnails": {
"enabled": true,
"img": ["img-bmp", "img-gif", "img-ico", "img-jpg", "img-png"],
"mov": ["vid-avi", "vid-flv", "vid-mkv", "vid-mov", "vid-mp4", "vid-mpg", "vid-webm"],
"doc": ["x-pdf", "x-ps"],
"delay": 1,
"size": 240,
"exif": false,
"chunksize": 20
},
/*
Replace window title with current breadcrumb.
*/
"title": {
"enabled": true
},
/*
Show a folder tree.
Note that this might affect performance significantly.
- show: boolean, initial visible to first time users
- maxSubfolders: number, max number of subfolders to show in tree
- naturalSort: boolean, use natural sort order for folders
- ignorecase: boolean, sort ignorecase
*/
"tree": {
"enabled": true,
"show": true,
"maxSubfolders": 50,
"naturalSort": true,
"ignorecase": true
}
}

View File

@@ -0,0 +1,75 @@
{
"ar": ["*.tar.bz2", "*.crx"],
"ar-apk": ["*.apk"],
"ar-deb": ["*.deb"],
"ar-gz": ["*.gz", "*.tar.gz", "*.tgz"],
"ar-rar": ["*.rar"],
"ar-rpm": ["*.rpm"],
"ar-tar": ["*.tar"],
"ar-zip": ["*.7z", "*.bz2", "*.jar", "*.lzma", "*.war", "*.z", "*.Z", "*.zip"],
"aud": ["*.aif", "*.aiff", "*.flac", "*.m4a", "*.mid", "*.mp3", "*.mpa", "*.ra", "*.ogg", "*.wav", "*.wma"],
"aud-pls": ["*.m3u", "*.m3u8", "*.pls"],
"bin": ["*.class", "*.o", "*.so"],
"bin-exe": ["*.bat", "*.cmd", "*.exe"],
"img": ["*.xpm"],
"img-bmp": ["*.bmp"],
"img-gif": ["*.gif"],
"img-ico": ["*.ico"],
"img-jpg": ["*.jpg", "*.jpeg"],
"img-png": ["*.png"],
"img-raw": ["*.cr2", "*.nef"],
"img-svg": ["*.svg"],
"img-tiff": ["*.tiff"],
"txt": ["*.text", "*.txt"],
"txt-build": ["*.pom", "build.xml", "pom.xml"],
"txt-c": ["*.c"],
"txt-cpp": ["*.cpp"],
"txt-css": ["*.css"],
"txt-diff": ["*.diff", "*.patch"],
"txt-go": ["*.go"],
"txt-h": ["*.h"],
"txt-html": ["*.htm", "*.html", "*.shtml", "*.xhtml"],
"txt-hpp": ["*.hpp"],
"txt-java": ["*.java"],
"txt-scala": ["*.scala"],
"txt-js": ["*.js"],
"txt-json": ["*.json"],
"txt-less": ["*.less"],
"txt-log": ["*.log", "changelog*"],
"txt-md": ["*.markdown", "*.md"],
"txt-php": ["*.php"],
"txt-py": ["*.py"],
"txt-rb": ["*.rb"],
"txt-rss": ["*.rss"],
"txt-rtf": ["*.rtf"],
"txt-rust": ["*.rs", "*.rlib"],
"txt-script": ["*.conf", "*.bsh", "*.csh", "*.ini", "*.ksh", "*.sh", "*.shar", "*.tcl", "*.zsh"],
"txt-source": [],
"txt-tex": ["*.tex"],
"txt-vcal": ["*.vcal"],
"txt-xml": ["*.xml"],
"vid": [],
"vid-avi": ["*.avi"],
"vid-flv": ["*.flv"],
"vid-mkv": ["*.mkv"],
"vid-mov": ["*.mov"],
"vid-mp4": ["*.mp4", "*.m4v"],
"vid-mpg": ["*.mpg"],
"vid-rm": ["*.rm"],
"vid-swf": ["*.swf"],
"vid-ts": ["*.ts"],
"vid-vob": ["*.vob"],
"vid-webm": ["*.webm"],
"vid-wmv": ["*.wmv"],
"x": [],
"x-bak": ["*.bak", "*~"],
"x-calc": ["*.ods", "*.ots", "*.xlr", "*.xls", "*.xlsx"],
"x-disc": ["*.cue", "*.iso"],
"x-doc": ["*.doc", "*.docx", "*.odm", "*.odt", "*.ott"],
"x-draw": ["*.drw"],
"x-eps": ["*.eps"],
"x-pdf": ["*.pdf"],
"x-pres": ["*.odp", "*.otp", "*.pps", "*.ppt", "*.pptx"],
"x-ps": ["*.ps"],
"x-psd": ["*.psd"]
}

View File

@@ -0,0 +1,45 @@
<?php
class Bootstrap {
private static $autopaths = ['core', 'ext'];
public static function run() {
spl_autoload_register(['Bootstrap', 'autoload']);
putenv('LANG=en_US.UTF-8');
setlocale(LC_CTYPE, 'en_US.UTF-8');
date_default_timezone_set(@date_default_timezone_get());
session_start();
$session = new Session($_SESSION);
$request = new Request($_REQUEST, file_get_contents('php://input'));
$setup = new Setup($request->query_boolean('refresh', false));
$context = new Context($session, $request, $setup);
if ($context->is_api_request()) {
(new Api($context))->apply();
} elseif ($context->is_info_request()) {
$public_href = $setup->get('PUBLIC_HREF');
$x_head_tags = $context->get_x_head_html();
$fallback_mode = false;
require __DIR__ . '/pages/info.php';
} else {
$public_href = $setup->get('PUBLIC_HREF');
$x_head_tags = $context->get_x_head_html();
$fallback_mode = $context->is_fallback_mode();
$fallback_html = (new Fallback($context))->get_html();
require __DIR__ . '/pages/index.php';
}
}
public static function autoload($class_name) {
$filename = 'class-' . strtolower($class_name) . '.php';
foreach (Bootstrap::$autopaths as $path) {
$file = __DIR__ . '/' . $path . '/' . $filename;
if (file_exists($file)) {
require_once $file;
return true;
}
}
}
}

View File

@@ -0,0 +1,110 @@
<?php
class Api {
private $context;
private $request;
private $setup;
public function __construct($context) {
$this->context = $context;
$this->request = $context->get_request();
$this->setup = $context->get_setup();
}
public function apply() {
$action = $this->request->query('action');
$supported = ['download', 'get', 'login', 'logout'];
Util::json_fail(Util::ERR_UNSUPPORTED, 'unsupported action', !in_array($action, $supported));
$methodname = 'on_' . $action;
$this->$methodname();
}
private function on_download() {
Util::json_fail(Util::ERR_DISABLED, 'download disabled', !$this->context->query_option('download.enabled', false));
$as = $this->request->query('as');
$type = $this->request->query('type');
$base_href = $this->request->query('baseHref');
$hrefs = $this->request->query('hrefs', '');
$archive = new Archive($this->context);
set_time_limit(0);
session_write_close();
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="' . $as . '"');
header('Connection: close');
$ok = $archive->output($type, $base_href, $hrefs);
Util::json_fail(Util::ERR_FAILED, 'packaging failed', !$ok);
exit;
}
private function on_get() {
$response = [];
foreach (['langs', 'options', 'types'] as $name) {
if ($this->request->query_boolean($name, false)) {
$methodname = 'get_' . $name;
$response[$name] = $this->context->$methodname();
}
}
if ($this->request->query_boolean('setup', false)) {
$response['setup'] = $this->setup->to_jsono($this->context->is_admin());
}
if ($this->request->query_boolean('theme', false)) {
$theme = new Theme($this->context);
$response['theme'] = $theme->get_icons();
}
if ($this->request->query('items', false)) {
$href = $this->request->query('items.href');
$what = $this->request->query_numeric('items.what');
$response['items'] = $this->context->get_items($href, $what);
}
if ($this->request->query('custom', false)) {
Util::json_fail(Util::ERR_DISABLED, 'custom disabled', !$this->context->query_option('custom.enabled', false));
$href = $this->request->query('custom');
$custom = new Custom($this->context);
$response['custom'] = $custom->get_customizations($href);
}
if ($this->request->query('l10n', false)) {
Util::json_fail(Util::ERR_DISABLED, 'l10n disabled', !$this->context->query_option('l10n.enabled', false));
$iso_codes = $this->request->query_array('l10n');
$iso_codes = array_filter($iso_codes);
$response['l10n'] = $this->context->get_l10n($iso_codes);
}
if ($this->request->query('search', false)) {
Util::json_fail(Util::ERR_DISABLED, 'search disabled', !$this->context->query_option('search.enabled', false));
$href = $this->request->query('search.href');
$pattern = $this->request->query('search.pattern');
$ignorecase = $this->request->query_boolean('search.ignorecase', false);
$search = new Search($this->context);
$response['search'] = $search->get_items($href, $pattern, $ignorecase);
}
if ($this->request->query('thumbs', false)) {
Util::json_fail(Util::ERR_DISABLED, 'thumbnails disabled', !$this->context->query_option('thumbnails.enabled', false));
Util::json_fail(Util::ERR_UNSUPPORTED, 'thumbnails not supported', !$this->setup->get('HAS_PHP_JPEG'));
$thumbs = $this->request->query_array('thumbs');
$response['thumbs'] = $this->context->get_thumbs($thumbs);
}
Util::json_exit($response);
}
private function on_login() {
$pass = $this->request->query('pass');
Util::json_exit(['asAdmin' => $this->context->login_admin($pass)]);
}
private function on_logout() {
Util::json_exit(['asAdmin' => $this->context->logout_admin()]);
}
}

View File

@@ -0,0 +1,304 @@
<?php
class Context {
private static $DEFAULT_PASSHASH = 'cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e';
private static $AS_ADMIN_SESSION_KEY = 'AS_ADMIN';
private static $L10N_ISO_CODES = array(
'af', 'bg', 'cs', 'da', 'de', 'el', 'en', 'es', 'et', 'fi', 'fr', 'he',
'hi', 'hr', 'hu', 'id', 'it', 'ja','ko', 'lv', 'nb', 'nl', 'pl',
'pt-br', 'pt-pt', 'ro', 'ru', 'sk', 'sl', 'sr', 'sv', 'tr', 'uk',
'zh-cn', 'zh-tw'
);
private $session;
private $request;
private $setup;
private $options;
private $passhash;
public function __construct($session, $request, $setup) {
$this->session = $session;
$this->request = $request;
$this->setup = $setup;
$this->options = Json::load($this->setup->get('CONF_PATH') . '/options.json');
$this->passhash = $this->query_option('passhash', '');
$this->options['hasCustomPasshash'] = strcasecmp($this->passhash, Context::$DEFAULT_PASSHASH) !== 0;
unset($this->options['passhash']);
}
public function get_session() {
return $this->session;
}
public function get_request() {
return $this->request;
}
public function get_setup() {
return $this->setup;
}
public function get_options() {
return $this->options;
}
public function query_option($keypath = '', $default = null) {
return Util::array_query($this->options, $keypath, $default);
}
public function get_types() {
return Json::load($this->setup->get('CONF_PATH') . '/types.json');
}
public function login_admin($pass) {
$this->session->set(Context::$AS_ADMIN_SESSION_KEY, strcasecmp(hash('sha512', $pass), $this->passhash) === 0);
return $this->session->get(Context::$AS_ADMIN_SESSION_KEY);
}
public function logout_admin() {
$this->session->set(Context::$AS_ADMIN_SESSION_KEY, false);
return $this->session->get(Context::$AS_ADMIN_SESSION_KEY);
}
public function is_admin() {
return $this->session->get(Context::$AS_ADMIN_SESSION_KEY);
}
public function is_api_request() {
return strtolower($this->setup->get('REQUEST_METHOD')) === 'post';
}
public function is_info_request() {
return Util::starts_with($this->setup->get('REQUEST_HREF') . '/', $this->setup->get('PUBLIC_HREF'));
}
public function is_text_browser() {
return preg_match('/curl|links|lynx|w3m/i', $this->setup->get('HTTP_USER_AGENT')) === 1;
}
public function is_fallback_mode() {
return $this->query_option('view.fallbackMode', false) || $this->is_text_browser();
}
public function to_href($path, $trailing_slash = true) {
$rel_path = substr($path, strlen($this->setup->get('ROOT_PATH')));
$parts = explode('/', $rel_path);
$encoded_parts = [];
foreach ($parts as $part) {
if ($part != '') {
$encoded_parts[] = rawurlencode($part);
}
}
return Util::normalize_path($this->setup->get('ROOT_HREF') . implode('/', $encoded_parts), $trailing_slash);
}
public function to_path($href) {
$rel_href = substr($href, strlen($this->setup->get('ROOT_HREF')));
return Util::normalize_path($this->setup->get('ROOT_PATH') . '/' . rawurldecode($rel_href));
}
public function is_hidden($name) {
// always hide
if ($name === '.' || $name === '..') {
return true;
}
foreach ($this->query_option('view.hidden', []) as $re) {
$re = Util::wrap_pattern($re);
if (preg_match($re, $name)) {
return true;
}
}
return false;
}
public function read_dir($path) {
$names = [];
if (is_dir($path)) {
foreach (scandir($path) as $name) {
if (
$this->is_hidden($name)
|| $this->is_hidden($this->to_href($path) . $name)
|| (!is_readable($path . '/' . $name) && $this->query_option('view.hideIf403', false))
) {
continue;
}
$names[] = $name;
}
}
return $names;
}
public function is_managed_href($href) {
return $this->is_managed_path($this->to_path($href));
}
public function is_managed_path($path) {
if (!is_dir($path) || strpos($path, '../') !== false || strpos($path, '/..') !== false || $path === '..') {
return false;
}
if (strpos($path, $this->setup->get('PUBLIC_PATH')) === 0) {
return false;
}
if (strpos($path, $this->setup->get('PRIVATE_PATH')) === 0) {
return false;
}
foreach ($this->query_option('view.unmanaged', []) as $name) {
if (file_exists($path . '/' . $name)) {
return false;
}
}
while ($path !== $this->setup->get('ROOT_PATH')) {
if (@is_dir($path . '/_h5ai/private/conf')) {
return false;
}
$parent_path = Util::normalize_path(dirname($path));
if ($parent_path === $path) {
return false;
}
$path = $parent_path;
}
return true;
}
public function get_current_path() {
$current_href = Util::normalize_path($this->setup->get('REQUEST_HREF'), true);
$current_path = $this->to_path($current_href);
if (!is_dir($current_path)) {
$current_path = Util::normalize_path(dirname($current_path), false);
}
return $current_path;
}
public function get_items($href, $what) {
if (!$this->is_managed_href($href)) {
return [];
}
$cache = [];
$folder = Item::get($this, $this->to_path($href), $cache);
// add content of subfolders
if ($what >= 2 && $folder !== null) {
foreach ($folder->get_content($cache) as $item) {
$item->get_content($cache);
}
$folder = $folder->get_parent($cache);
}
// add content of this folder and all parent folders
while ($what >= 1 && $folder !== null) {
$folder->get_content($cache);
$folder = $folder->get_parent($cache);
}
uasort($cache, ['Item', 'cmp']);
$result = [];
foreach ($cache as $p => $item) {
$result[] = $item->to_json_object();
}
return $result;
}
public function get_langs() {
$langs = [];
$l10n_path = $this->setup->get('CONF_PATH') . '/l10n';
if (is_dir($l10n_path)) {
if ($dir = opendir($l10n_path)) {
while (($file = readdir($dir)) !== false) {
if (Util::ends_with($file, '.json')) {
$translations = Json::load($l10n_path . '/' . $file);
$langs[basename($file, '.json')] = $translations['lang'];
}
}
closedir($dir);
}
}
ksort($langs);
return $langs;
}
public function get_l10n($iso_codes) {
$results = [];
foreach ($iso_codes as $iso_code) {
if (!in_array($iso_code, Context::$L10N_ISO_CODES)) {
continue;
}
$file = $this->setup->get('CONF_PATH') . '/l10n/' . $iso_code . '.json';
$results[$iso_code] = Json::load($file);
$results[$iso_code]['isoCode'] = $iso_code;
}
return $results;
}
public function get_thumbs($requests) {
$hrefs = [];
foreach ($requests as $req) {
$thumb = new Thumb($this);
$hrefs[] = $thumb->thumb($req['type'], $req['href'], $req['width'], $req['height']);
}
return $hrefs;
}
private function prefix_x_head_href($href) {
if (preg_match('@^(https?://|/)@i', $href)) {
return $href;
}
return $this->setup->get('PUBLIC_HREF') . 'ext/' . $href;
}
private function get_fonts_html() {
$fonts = $this->query_option('view.fonts', []);
$fonts_mono = $this->query_option('view.fontsMono', []);
$html = '<style class="x-head">';
if (sizeof($fonts) > 0) {
$html .= '#root,input,select{font-family:"' . implode('","', $fonts) . '"!important}';
}
if (sizeof($fonts_mono) > 0) {
$html .= 'pre,code{font-family:"' . implode('","', $fonts_mono) . '"!important}';
}
$html .= '</style>';
return $html;
}
public function get_x_head_html() {
$scripts = $this->query_option('resources.scripts', []);
$styles = $this->query_option('resources.styles', []);
$html = '';
foreach ($styles as $href) {
$html .= '<link rel="stylesheet" href="' . $this->prefix_x_head_href($href) . '" class="x-head">';
}
foreach ($scripts as $href) {
$html .= '<script src="' . $this->prefix_x_head_href($href) . '" class="x-head"></script>';
}
$html .= $this->get_fonts_html();
return $html;
}
}

View File

@@ -0,0 +1,54 @@
<?php
class Fallback {
private $context;
public function __construct($context) {
$this->context = $context;
}
public function get_html($path = null) {
if (!$path) {
$path = $this->context->get_current_path();
}
$fallback_images_href = $this->context->get_setup()->get('PUBLIC_HREF') . 'images/fallback/';
$cache = [];
$folder = Item::get($this->context, $path, $cache);
$items = $folder->get_content($cache);
uasort($items, ['Item', 'cmp']);
$html = '<table>';
$html .= '<tr>';
$html .= '<th class="fb-i"></th>';
$html .= '<th class="fb-n"><span>Name</span></th>';
$html .= '<th class="fb-d"><span>Last modified</span></th>';
$html .= '<th class="fb-s"><span>Size</span></th>';
$html .= '</tr>';
if ($folder->get_parent($cache)) {
$html .= '<tr>';
$html .= '<td class="fb-i"><img src="' . $fallback_images_href . 'folder-parent.png" alt="folder-parent"/></td>';
$html .= '<td class="fb-n"><a href="..">Parent Directory</a></td>';
$html .= '<td class="fb-d"></td>';
$html .= '<td class="fb-s"></td>';
$html .= '</tr>';
}
foreach ($items as $item) {
$type = $item->is_folder ? 'folder' : 'file';
$html .= '<tr>';
$html .= '<td class="fb-i"><img src="' . $fallback_images_href . $type . '.png" alt="' . $type . '"/></td>';
$html .= '<td class="fb-n"><a href="' . $item->href . '">' . basename($item->path) . '</a></td>';
$html .= '<td class="fb-d">' . date('Y-m-d H:i', $item->date) . '</td>';
$html .= '<td class="fb-s">' . ($item->size !== null ? intval($item->size / 1000) . ' KB' : '' ) . '</td>';
$html .= '</tr>';
}
$html .= '</table>';
return $html;
}
}

View File

@@ -0,0 +1,96 @@
<?php
class Filesize {
private static $cache = [];
public static function getSize($path, $withFoldersize, $withDu) {
$fs = new Filesize();
return $fs->size($path, $withFoldersize, $withDu);
}
public static function getCachedSize($path, $withFoldersize, $withDu) {
if (array_key_exists($path, Filesize::$cache)) {
return Filesize::$cache[$path];
}
$size = Filesize::getSize($path, $withFoldersize, $withDu);
Filesize::$cache[$path] = $size;
return $size;
}
private function __construct() {}
private function read_dir($path) {
$paths = [];
if (is_dir($path)) {
foreach (scandir($path) as $name) {
if ($name !== '.' && $name !== '..') {
$paths[] = $path . '/' . $name;
}
}
}
return $paths;
}
private function php_filesize($path, $recursive = false) {
// if (PHP_INT_SIZE < 8) {
// }
$size = @filesize($path);
if (!is_dir($path) || !$recursive) {
return $size;
}
foreach ($this->read_dir($path) as $p) {
$size += $this->php_filesize($p, true);
}
return $size;
}
private function exec($cmdv) {
$cmd = implode(' ', array_map('escapeshellarg', $cmdv));
$lines = [];
$rc = null;
exec($cmd, $lines, $rc);
return $lines;
}
private function exec_du_all($paths) {
$cmdv = array_merge(['du', '-sbL'], $paths);
$lines = $this->exec($cmdv);
$sizes = [];
foreach ($lines as $line) {
$parts = preg_split('/[\s]+/', $line, 2);
$size = intval($parts[0], 10);
$path = $parts[1];
$sizes[$path] = $size;
}
return $sizes;
}
private function exec_du($path) {
$sizes = $this->exec_du_all([$path]);
return $sizes[$path];
}
private function size($path, $withFoldersize = false, $withDu = false) {
if (is_file($path)) {
return $this->php_filesize($path);
}
if (is_dir($path) && $withFoldersize) {
if ($withDu) {
return $this->exec_du($path);
}
return $this->php_filesize($path, true);
}
return null;
}
}

View File

@@ -0,0 +1,91 @@
<?php
class Item {
public static function cmp($item1, $item2) {
if ($item1->is_folder && !$item2->is_folder) {
return -1;
}
if (!$item1->is_folder && $item2->is_folder) {
return 1;
}
return strcasecmp($item1->path, $item2->path);
}
public static function get($context, $path, &$cache) {
if (!Util::starts_with($path, $context->get_setup()->get('ROOT_PATH'))) {
return null;
}
if (is_array($cache) && array_key_exists($path, $cache)) {
return $cache[$path];
}
$item = new Item($context, $path);
if (is_array($cache)) {
$cache[$path] = $item;
}
return $item;
}
public $context;
public $path;
public $href;
public $date;
public $size;
public $is_folder;
public $is_content_fetched;
private function __construct($context, $path) {
$this->context = $context;
$this->path = Util::normalize_path($path, false);
$this->is_folder = is_dir($this->path);
$this->href = $context->to_href($this->path, $this->is_folder);
$this->date = @filemtime($this->path);
$this->size = Util::filesize($context, $this->path);
$this->is_content_fetched = false;
}
public function to_json_object() {
$obj = [
'href' => $this->href,
'time' => $this->date * 1000, // seconds (PHP) to milliseconds (JavaScript)
'size' => $this->size
];
if ($this->is_folder) {
$obj['managed'] = $this->context->is_managed_href($this->href);
$obj['fetched'] = $this->is_content_fetched;
}
return $obj;
}
public function get_parent(&$cache) {
$parent_path = Util::normalize_path(dirname($this->path), false);
if ($parent_path !== $this->path && Util::starts_with($parent_path, $this->context->get_setup()->get('ROOT_PATH'))) {
return Item::get($this->context, $parent_path, $cache);
}
return null;
}
public function get_content(&$cache) {
$items = [];
if (!$this->context->is_managed_href($this->href)) {
return $items;
}
$files = $this->context->read_dir($this->path);
foreach ($files as $file) {
$item = Item::get($this->context, $this->path . '/' . $file, $cache);
$items[$item->path] = $item;
}
$this->is_content_fetched = true;
return $items;
}
}

View File

@@ -0,0 +1,65 @@
<?php
class Json {
const SINGLE = 1;
const MULTI = 2;
public static function load($path) {
if (!is_readable($path)) {
return [];
}
$json = file_get_contents($path);
return Json::decode($json);
}
public static function save($path, $obj) {
$json = json_encode($obj);
return file_put_contents($path, $json) !== false;
}
private static function decode($json) {
$json = Json::strip($json);
return json_decode($json, true);
}
private static function strip($commented_json) {
$insideString = false;
$insideComment = false;
$json = '';
for ($i = 0, $len = strlen($commented_json); $i < $len; $i += 1) {
$char = $commented_json[$i];
$charchar = $char . @$commented_json[$i + 1];
$prevChar = @$commented_json[$i - 1];
if (!$insideComment && $char === '"' && $prevChar !== "\\") {
$insideString = !$insideString;
}
if ($insideString) {
$json .= $char;
} elseif (!$insideComment && $charchar === '//') {
$insideComment = Json::SINGLE;
$i += 1;
} elseif (!$insideComment && $charchar === '/*') {
$insideComment = Json::MULTI;
$i += 1;
} elseif (!$insideComment) {
$json .= $char;
} elseif ($insideComment === Json::SINGLE && $charchar === "\r\n") {
$insideComment = false;
$json .= $charchar;
$i += 1;
} elseif ($insideComment === Json::SINGLE && $char === "\n") {
$insideComment = false;
$json .= $char;
} elseif ($insideComment === Json::MULTI && $charchar === '*/') {
$insideComment = false;
$i += 1;
}
}
return $json;
}
}

View File

@@ -0,0 +1,28 @@
<?php
class Logger {
private static $start;
private static $prev;
private static function time() {
return microtime(true) * 1000; // sec * 1000 = ms
}
public static function init() {
self::$start = self::time();
self::$prev = self::$start;
register_shutdown_function(function () { Logger::log('shutdown'); });
Logger::log('--------------------------------');
}
public static function log($message=null, $obj=null) {
$now = self::time();
$message = number_format($now - self::$start, 3) . ' ' . number_format($now - self::$prev, 3) . ' ' . $message;
@error_log($message . ' ' . var_export($obj, true));
self::$prev = $now;
}
}
Logger::init();

View File

@@ -0,0 +1,38 @@
<?php
class Request {
private $params;
public function __construct($params, $body) {
$data = json_decode($body, true);
$this->params = $data !== null ? $data : $params;
}
public function query($keypath = '', $default = Util::NO_DEFAULT) {
$value = Util::array_query($this->params, $keypath, Util::NO_DEFAULT);
if ($value === Util::NO_DEFAULT) {
Util::json_fail(Util::ERR_MISSING_PARAM, 'parameter \'' . $keypath . '\' is missing', $default === Util::NO_DEFAULT);
return $default;
}
return $value;
}
public function query_boolean($keypath = '', $default = Util::NO_DEFAULT) {
$value = $this->query($keypath, $default);
return filter_var($value, FILTER_VALIDATE_BOOLEAN);
}
public function query_numeric($keypath = '', $default = Util::NO_DEFAULT) {
$value = $this->query($keypath, $default);
Util::json_fail(Util::ERR_ILLIGAL_PARAM, 'parameter \'' . $keypath . '\' is not numeric', !is_numeric($value));
return intval($value, 10);
}
public function query_array($keypath = '', $default = Util::NO_DEFAULT) {
$value = $this->query($keypath, $default);
Util::json_fail(Util::ERR_ILLIGAL_PARAM, 'parameter \'' . $keypath . '\' is no array', !is_array($value));
return $value;
}
}

View File

@@ -0,0 +1,20 @@
<?php
class Session {
private static $KEY_PREFIX = '__H5AI__';
private $store;
public function __construct(&$store) {
$this->store = &$store;
}
public function set($key, $value) {
$key = Session::$KEY_PREFIX . $key;
$this->store[$key] = $value;
}
public function get($key, $default = null) {
$key = Session::$KEY_PREFIX . $key;
return array_key_exists($key, $this->store) ? $this->store[$key] : $default;
}
}

View File

@@ -0,0 +1,188 @@
<?php
class Setup {
private $store;
private $refresh;
public function __construct($refresh = false) {
$this->store = [];
$this->refresh = $refresh;
$this->add_globals_and_envs();
$this->add_php_checks();
$this->add_app_metadata();
$this->add_server_metadata_and_check();
$this->add_paths();
$this->add_sys_cmd_checks();
}
private function set($key, $value) {
if (array_key_exists($key, $this->store)) {
Logger::log('setup key already taken', [
'key' => $key,
'value' => $value,
'found' => $this->store[$key]
]);
exit;
}
if (!is_string($value) && !is_bool($value)) {
Logger::log('setup value neither string nor boolean', [
'key' => $key,
'value' => $value
]);
exit;
}
$this->store[$key] = $value;
}
public function get($key) {
if (!array_key_exists($key, $this->store)) {
Logger::log('setup key not found', ['key' => $key]);
exit;
}
return $this->store[$key];
}
private function add_globals_and_envs() {
$this->set('PHP_VERSION', PHP_VERSION);
$this->set('MIN_PHP_VERSION', MIN_PHP_VERSION);
$this->set('PHP_ARCH', (PHP_INT_SIZE * 8) . '-bit');
$this->set('REQUEST_METHOD', $_SERVER['REQUEST_METHOD']);
$this->set('REQUEST_HREF', parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH));
$this->set('SCRIPT_NAME', $_SERVER['SCRIPT_NAME']);
$this->set('SERVER_SOFTWARE', $_SERVER['SERVER_SOFTWARE']);
$this->set('HTTP_USER_AGENT', $_SERVER['HTTP_USER_AGENT']);
}
private function add_php_checks() {
$this->set('HAS_PHP_EXIF', function_exists('exif_thumbnail'));
$has_php_jpeg = false;
if (function_exists('gd_info')) {
$infos = gd_info();
$has_php_jpeg = array_key_exists('JPEG Support', $infos) && $infos['JPEG Support'];
}
$this->set('HAS_PHP_JPEG', $has_php_jpeg);
}
private function add_app_metadata() {
$this->set('NAME', 'h5ai');
$this->set('VERSION', H5AI_VERSION);
$this->set('FILE_PREFIX', '_h5ai');
}
private function add_server_metadata_and_check() {
$server_software = $this->get('SERVER_SOFTWARE');
$server_name = null;
$server_version = null;
if ($server_software && preg_match('#^(.*?)(?:/(.*?))?(?: |$)#', strtolower($server_software), $matches)) {
$server_name = $matches[1];
$server_version = count($matches) > 2 ? $matches[2] : '';
}
$this->set('SERVER_NAME', $server_name);
$this->set('SERVER_VERSION', $server_version);
$this->set('HAS_SERVER', in_array($server_name, ['apache', 'lighttpd', 'nginx', 'cherokee']));
}
private function add_paths() {
$script_name = $this->get('SCRIPT_NAME');
if ($this->get('SERVER_NAME') === 'lighttpd') {
$script_name = preg_replace('#^.*?//#', '/', $script_name);
}
$this->set('H5AI_HREF', Util::normalize_path(dirname(dirname($script_name)), true));
$this->set('H5AI_PATH', Util::normalize_path(dirname(dirname(dirname(dirname(__FILE__)))), false));
$this->set('ROOT_HREF', Util::normalize_path(dirname($this->get('H5AI_HREF')), true));
$this->set('ROOT_PATH', Util::normalize_path(dirname($this->get('H5AI_PATH')), false));
$this->set('PUBLIC_HREF', Util::normalize_path($this->get('H5AI_HREF') . '/public/', true));
$this->set('PUBLIC_PATH', Util::normalize_path($this->get('H5AI_PATH') . '/public/', false));
$this->set('INDEX_HREF', Util::normalize_path($this->get('PUBLIC_HREF') . '/index.php', false));
$this->set('CACHE_PUB_HREF', Util::normalize_path($this->get('PUBLIC_HREF') . '/cache', true));
$this->set('CACHE_PUB_PATH', Util::normalize_path($this->get('PUBLIC_PATH') . '/cache', false));
$this->set('HAS_WRITABLE_CACHE_PUB', @is_writable($this->get('CACHE_PUB_PATH')));
$this->set('PRIVATE_PATH', Util::normalize_path($this->get('H5AI_PATH') . '/private', false));
$this->set('CONF_PATH', Util::normalize_path($this->get('PRIVATE_PATH') . '/conf', false));
$this->set('CACHE_PRV_PATH', Util::normalize_path($this->get('PRIVATE_PATH') . '/cache', false));
$this->set('HAS_WRITABLE_CACHE_PRV', @is_writable($this->get('CACHE_PRV_PATH')));
}
private function add_sys_cmd_checks() {
$cmds_cache_path = Util::normalize_path($this->get('CACHE_PRV_PATH') . '/cmds.json', false);
$cmds = Json::load($cmds_cache_path);
if (sizeof($cmds) === 0 || $this->refresh) {
$cmds['command'] = Util::exec_0('command -v command');
$cmds['which'] = Util::exec_0('which which') || Util::exec_0('which which.exe');
$cmds['where'] = Util::exec_0('where where.exe');
$cmd = false;
if ($cmds['command']) {
$cmd = 'command -v';
} elseif ($cmds['which']) {
$cmd = 'which';
} elseif ($cmds['where']) {
$cmd = 'where';
}
foreach (['avconv', 'convert', 'du', 'ffmpeg', 'gm', 'tar', 'zip'] as $c) {
$cmds[$c] = ($cmd !== false) && (Util::exec_0($cmd . ' ' . $c) || Util::exec_0($cmd . ' ' . $c . '.exe'));
}
Json::save($cmds_cache_path, $cmds);
}
foreach ($cmds as $c => $has) {
$this->set('HAS_CMD_' . strtoupper($c), $has);
}
}
public function to_jsono($as_admin = false) {
$keys = [
'PUBLIC_HREF',
'ROOT_HREF'
];
if ($as_admin) {
$keys = array_merge($keys, [
'VERSION',
'PHP_VERSION',
'MIN_PHP_VERSION',
'PHP_ARCH',
'HAS_PHP_EXIF',
'HAS_PHP_JPEG',
'SERVER_NAME',
'SERVER_VERSION',
'HAS_SERVER',
'INDEX_HREF',
'HAS_WRITABLE_CACHE_PUB',
'HAS_WRITABLE_CACHE_PRV',
'HAS_CMD_AVCONV',
'HAS_CMD_CONVERT',
'HAS_CMD_DU',
'HAS_CMD_FFMPEG',
'HAS_CMD_GM',
'HAS_CMD_TAR',
'HAS_CMD_ZIP'
]);
}
$jsono = ['AS_ADMIN' => $as_admin];
foreach ($keys as $key) {
$jsono[$key] = $this->get($key);
}
return $jsono;
}
}

View File

@@ -0,0 +1,32 @@
<?php
class Theme {
private static $EXTENSIONS = ['svg', 'png', 'jpg'];
private $context;
public function __construct($context) {
$this->context = $context;
}
public function get_icons() {
$public_path = $this->context->get_setup()->get('PUBLIC_PATH');
$theme = $this->context->query_option('view.theme', '-NONE-');
$theme_path = $public_path . '/images/themes/' . $theme;
$icons = [];
if (is_dir($theme_path)) {
if ($dir = opendir($theme_path)) {
while (($name = readdir($dir)) !== false) {
$path_parts = pathinfo($name);
if (in_array(@$path_parts['extension'], Theme::$EXTENSIONS)) {
$icons[$path_parts['filename']] = $theme . '/' . $name;
}
}
closedir($dir);
}
}
return $icons;
}
}

View File

@@ -0,0 +1,89 @@
<?php
class Util {
const ERR_MISSING_PARAM = 'ERR_MISSING_PARAM';
const ERR_ILLIGAL_PARAM = 'ERR_ILLIGAL_PARAM';
const ERR_FAILED = 'ERR_FAILED';
const ERR_DISABLED = 'ERR_DISABLED';
const ERR_UNSUPPORTED = 'ERR_UNSUPPORTED';
const NO_DEFAULT = 'NO_*@+#?!_DEFAULT';
const RE_DELIMITER = '@';
public static function normalize_path($path, $trailing_slash = false) {
$path = preg_replace('#[\\\\/]+#', '/', $path);
return preg_match('#^(\w:)?/$#', $path) ? $path : (rtrim($path, '/') . ($trailing_slash ? '/' : ''));
}
public static function json_exit($obj = []) {
header('Content-type: application/json;charset=utf-8');
echo json_encode($obj);
exit;
}
public static function json_fail($err, $msg = '', $cond = true) {
if ($cond) {
Util::json_exit(['err' => $err, 'msg' => $msg]);
}
}
public static function array_query($array, $keypath = '', $default = Util::NO_DEFAULT) {
$value = $array;
$keys = array_filter(explode('.', $keypath));
foreach ($keys as $key) {
if (!is_array($value) || !array_key_exists($key, $value)) {
return $default;
}
$value = $value[$key];
}
return $value;
}
public static function starts_with($sequence, $head) {
return substr($sequence, 0, strlen($head)) === $head;
}
public static function ends_with($sequence, $tail) {
$len = strlen($tail);
return $len === 0 ? true : substr($sequence, -$len) === $tail;
}
public static function wrap_pattern($pattern) {
return Util::RE_DELIMITER . str_replace(Util::RE_DELIMITER, '\\' . Util::RE_DELIMITER, $pattern) . Util::RE_DELIMITER;
}
public static function passthru_cmd($cmd) {
$rc = null;
passthru($cmd, $rc);
return $rc;
}
public static function exec_cmdv($cmdv) {
if (!is_array($cmdv)) {
$cmdv = func_get_args();
}
$cmd = implode(' ', array_map('escapeshellarg', $cmdv));
$lines = [];
$rc = null;
exec($cmd, $lines, $rc);
return implode("\n", $lines);
}
public static function exec_0($cmd) {
$lines = [];
$rc = null;
try {
@exec($cmd, $lines, $rc);
return $rc === 0;
} catch (Exception $e) {}
return false;
}
public static function filesize($context, $path) {
$withFoldersize = $context->query_option('foldersize.enabled', false);
$withDu = $context->get_setup()->get('HAS_CMD_DU') && $context->query_option('foldersize.type', null) === 'shell-du';
return Filesize::getCachedSize($path, $withFoldersize, $withDu);
}
}

View File

@@ -0,0 +1,188 @@
<?php
class Archive {
const NULL_BYTE = "\0";
private static $SEGMENT_SIZE = 16777216; // 1024 * 1024 * 16 = 16MiB
private static $TAR_PASSTHRU_CMD = 'cd [ROOTDIR] && tar --no-recursion -c -- [DIRS] [FILES]';
private static $ZIP_PASSTHRU_CMD = 'cd [ROOTDIR] && zip - -- [FILES]';
private $context;
private $base_path;
private $dirs;
private $files;
public function __construct($context) {
$this->context = $context;
}
public function output($type, $base_href, $hrefs) {
$this->base_path = $this->context->to_path($base_href);
if (!$this->context->is_managed_path($this->base_path)) {
return false;
}
$this->dirs = [];
$this->files = [];
$this->add_hrefs($hrefs);
if (count($this->dirs) === 0 && count($this->files) === 0) {
if ($type === 'php-tar') {
$this->add_dir($this->base_path, '/');
} else {
$this->add_dir($this->base_path, '.');
}
}
if ($type === 'php-tar') {
return $this->php_tar($this->dirs, $this->files);
} elseif ($type === 'shell-tar') {
return $this->shell_cmd(Archive::$TAR_PASSTHRU_CMD);
} elseif ($type === 'shell-zip') {
return $this->shell_cmd(Archive::$ZIP_PASSTHRU_CMD);
}
return false;
}
private function shell_cmd($cmd) {
$cmd = str_replace('[ROOTDIR]', escapeshellarg($this->base_path), $cmd);
$cmd = str_replace('[DIRS]', count($this->dirs) ? implode(' ', array_map('escapeshellarg', $this->dirs)) : '', $cmd);
$cmd = str_replace('[FILES]', count($this->files) ? implode(' ', array_map('escapeshellarg', $this->files)) : '', $cmd);
try {
Util::passthru_cmd($cmd);
} catch (Exeption $err) {
return false;
}
return true;
}
private function php_tar($dirs, $files) {
$filesizes = [];
$total_size = 512 * count($dirs);
foreach (array_keys($files) as $real_file) {
$size = filesize($real_file);
$filesizes[$real_file] = $size;
$total_size += 512 + $size;
if ($size % 512 != 0) {
$total_size += 512 - ($size % 512);
}
}
header('Content-Length: ' . $total_size);
foreach ($dirs as $real_dir => $archived_dir) {
echo $this->php_tar_header($archived_dir, 0, @filemtime($real_dir . DIRECTORY_SEPARATOR . '.'), 5);
}
foreach ($files as $real_file => $archived_file) {
$size = $filesizes[$real_file];
echo $this->php_tar_header($archived_file, $size, @filemtime($real_file), 0);
$this->print_file($real_file);
if ($size % 512 != 0) {
echo str_repeat(Archive::NULL_BYTE, 512 - ($size % 512));
}
}
return true;
}
private function php_tar_header($filename, $size, $mtime, $type) {
$name = substr(basename($filename), -99);
$prefix = substr(Util::normalize_path(dirname($filename)), -154);
if ($prefix === '.') {
$prefix = '';
}
$header =
str_pad($name, 100, Archive::NULL_BYTE) // filename [100]
. '0000755' . Archive::NULL_BYTE // file mode [8]
. '0000000' . Archive::NULL_BYTE // uid [8]
. '0000000' . Archive::NULL_BYTE // gid [8]
. str_pad(decoct($size), 11, '0', STR_PAD_LEFT) . Archive::NULL_BYTE // file size [12]
. str_pad(decoct($mtime), 11, '0', STR_PAD_LEFT) . Archive::NULL_BYTE // file modification time [12]
. ' ' // checksum [8]
. str_pad($type, 1) // file type [1]
. str_repeat(Archive::NULL_BYTE, 100) // linkname [100]
. 'ustar' . Archive::NULL_BYTE // magic [6]
. '00' // version [2]
. str_repeat(Archive::NULL_BYTE, 80) // uname, gname, defmajor, devminor [32 + 32 + 8 + 8]
. str_pad($prefix, 155, Archive::NULL_BYTE) // filename [155]
. str_repeat(Archive::NULL_BYTE, 12); // fill [12]
assert(strlen($header) === 512);
// checksum
$checksum = array_sum(array_map('ord', str_split($header)));
$checksum = str_pad(decoct($checksum), 6, '0', STR_PAD_LEFT) . Archive::NULL_BYTE . ' ';
$header = substr_replace($header, $checksum, 148, 8);
return $header;
}
private function print_file($file) {
// Send file content in segments to not hit PHP's memory limit (default: 128M)
if ($fd = fopen($file, 'rb')) {
while (!feof($fd)) {
print fread($fd, Archive::$SEGMENT_SIZE);
@ob_flush();
@flush();
}
fclose($fd);
}
}
private function add_hrefs($hrefs) {
if (!is_array($hrefs)) {
$hrefs = array($hrefs);
}
foreach ($hrefs as $href) {
if (trim($href) === '') {
continue;
}
$href = Util::normalize_path($href, false);
$d = dirname($href);
$n = basename($href);
if ($this->context->is_managed_href($d) && !$this->context->is_hidden($n)) {
$real_file = $this->context->to_path($href);
$archived_file = preg_replace('!^' . preg_quote(Util::normalize_path($this->base_path, true)) . '!', '', $real_file);
if (is_dir($real_file)) {
$this->add_dir($real_file, $archived_file);
} else {
$this->add_file($real_file, $archived_file);
}
}
}
}
private function add_file($real_file, $archived_file) {
if (is_readable($real_file)) {
$this->files[$real_file] = $archived_file;
}
}
private function add_dir($real_dir, $archived_dir) {
if ($this->context->is_managed_path($real_dir)) {
$this->dirs[$real_dir] = $archived_dir;
$files = $this->context->read_dir($real_dir);
foreach ($files as $file) {
$real_file = $real_dir . '/' . $file;
$archived_file = $archived_dir . '/' . $file;
if (is_dir($real_file)) {
$this->add_dir($real_file, $archived_file);
} else {
$this->add_file($real_file, $archived_file);
}
}
}
}
}

View File

@@ -0,0 +1,73 @@
<?php
class Custom {
private static $EXTENSIONS = ['html', 'md'];
private $context;
public function __construct($context) {
$this->context = $context;
}
private function read_custom_file($path, $name, &$content, &$type) {
$file_prefix = $this->context->get_setup()->get('FILE_PREFIX');
foreach (Custom::$EXTENSIONS as $ext) {
$file = $path . '/' . $file_prefix . '.' . $name . '.' . $ext;
if (is_readable($file)) {
$content = file_get_contents($file);
$type = $ext;
return;
}
}
}
public function get_customizations($href) {
if (!$this->context->query_option('custom.enabled', false)) {
return [
'header' => ['content' => null, 'type' => null],
'footer' => ['content' => null, 'type' => null]
];
}
$root_path = $this->context->get_setup()->get('FILE_PREFIX');
$path = $this->context->to_path($href);
$header = null;
$header_type = null;
$footer = null;
$footer_type = null;
$this->read_custom_file($path, 'header', $header, $header_type);
$this->read_custom_file($path, 'footer', $footer, $footer_type);
while ($header === null || $footer === null) {
if ($header === null) {
$this->read_custom_file($path, 'headers', $header, $header_type);
}
if ($footer === null) {
$this->read_custom_file($path, 'footers', $footer, $footer_type);
}
if ($path === $root_path) {
break;
}
$parent_path = Util::normalize_path(dirname($path));
if ($parent_path === $path) {
break;
}
// Stop once we reach the root
if (
$this->context->query_option('custom.stopSearchingAtRoot', true) &&
$path === $this->context->get_setup()->get('ROOT_PATH')
) {
break;
}
$path = $parent_path;
}
return [
'header' => ['content' => $header, 'type' => $header_type],
'footer' => ['content' => $footer, 'type' => $footer_type]
];
}
}

View File

@@ -0,0 +1,40 @@
<?php
class Search {
private $context;
public function __construct($context) {
$this->context = $context;
}
public function get_paths($root, $pattern = null, $ignorecase = false) {
$paths = [];
if ($pattern && $this->context->is_managed_path($root)) {
$re = Util::wrap_pattern($pattern);
if ($ignorecase) {
$re .= 'i';
}
$names = $this->context->read_dir($root);
foreach ($names as $name) {
$path = $root . '/' . $name;
if (preg_match($re, @basename($path))) {
$paths[] = $path;
}
if (@is_dir($path)) {
$paths = array_merge($paths, $this->get_paths($path, $pattern, $ignorecase));
}
}
}
return $paths;
}
public function get_items($href, $pattern = null, $ignorecase = false) {
$cache = [];
$root = $this->context->to_path($href);
$paths = $this->get_paths($root, $pattern, $ignorecase);
$items = array_map(function ($path) {
return Item::get($this->context, $path, $cache)->to_json_object();
}, $paths);
return $items;
}
}

View File

@@ -0,0 +1,253 @@
<?php
class Thumb {
private static $FFMPEG_CMDV = ['ffmpeg', '-ss', '0:00:10', '-i', '[SRC]', '-an', '-vframes', '1', '[DEST]'];
private static $AVCONV_CMDV = ['avconv', '-ss', '0:00:10', '-i', '[SRC]', '-an', '-vframes', '1', '[DEST]'];
private static $CONVERT_CMDV = ['convert', '-density', '200', '-quality', '100', '-strip', '[SRC][0]', '[DEST]'];
private static $GM_CONVERT_CMDV = ['gm', 'convert', '-density', '200', '-quality', '100', '[SRC][0]', '[DEST]'];
private static $THUMB_CACHE = 'thumbs';
private $context;
private $setup;
private $thumbs_path;
private $thumbs_href;
public function __construct($context) {
$this->context = $context;
$this->setup = $context->get_setup();
$this->thumbs_path = $this->setup->get('CACHE_PUB_PATH') . '/' . Thumb::$THUMB_CACHE;
$this->thumbs_href = $this->setup->get('CACHE_PUB_HREF') . Thumb::$THUMB_CACHE;
if (!is_dir($this->thumbs_path)) {
@mkdir($this->thumbs_path, 0755, true);
}
}
public function thumb($type, $source_href, $width, $height) {
$source_path = $this->context->to_path($source_href);
if (!file_exists($source_path) || Util::starts_with($source_path, $this->setup->get('CACHE_PUB_PATH'))) {
return null;
}
$capture_path = $source_path;
if ($type === 'img') {
$capture_path = $source_path;
} elseif ($type === 'mov') {
if ($this->setup->get('HAS_CMD_AVCONV')) {
$capture_path = $this->capture(Thumb::$AVCONV_CMDV, $source_path);
} elseif ($this->setup->get('HAS_CMD_FFMPEG')) {
$capture_path = $this->capture(Thumb::$FFMPEG_CMDV, $source_path);
}
} elseif ($type === 'doc') {
if ($this->setup->get('HAS_CMD_CONVERT')) {
$capture_path = $this->capture(Thumb::$CONVERT_CMDV, $source_path);
} elseif ($this->setup->get('HAS_CMD_GM')) {
$capture_path = $this->capture(Thumb::$GM_CONVERT_CMDV, $source_path);
}
}
return $this->thumb_href($capture_path, $width, $height);
}
private function thumb_href($source_path, $width, $height) {
if (!file_exists($source_path)) {
return null;
}
$name = 'thumb-' . sha1($source_path) . '-' . $width . 'x' . $height . '.jpg';
$thumb_path = $this->thumbs_path . '/' . $name;
$thumb_href = $this->thumbs_href . '/' . $name;
if (!file_exists($thumb_path) || filemtime($source_path) >= filemtime($thumb_path)) {
$image = new Image();
$et = false;
if ($this->setup->get('HAS_PHP_EXIF') && $this->context->query_option('thumbnails.exif', false) === true && $height != 0) {
$et = @exif_thumbnail($source_path);
}
if($et !== false) {
file_put_contents($thumb_path, $et);
$image->set_source($thumb_path);
$image->normalize_exif_orientation($source_path);
} else {
$image->set_source($source_path);
}
$image->thumb($width, $height);
$image->save_dest_jpeg($thumb_path, 80);
}
return file_exists($thumb_path) ? $thumb_href : null;
}
private function capture($cmdv, $source_path) {
if (!file_exists($source_path)) {
return null;
}
$capture_path = $this->thumbs_path . '/capture-' . sha1($source_path) . '.jpg';
if (!file_exists($capture_path) || filemtime($source_path) >= filemtime($capture_path)) {
foreach ($cmdv as &$arg) {
$arg = str_replace('[SRC]', $source_path, $arg);
$arg = str_replace('[DEST]', $capture_path, $arg);
}
Util::exec_cmdv($cmdv);
}
return file_exists($capture_path) ? $capture_path : null;
}
}
class Image {
private $source_file;
private $source;
private $width;
private $height;
private $type;
private $dest;
public function __construct($filename = null) {
$this->source_file = null;
$this->source = null;
$this->width = null;
$this->height = null;
$this->type = null;
$this->dest = null;
$this->set_source($filename);
}
public function __destruct() {
$this->release_source();
$this->release_dest();
}
public function set_source($filename) {
$this->release_source();
$this->release_dest();
if (is_null($filename)) {
return;
}
$this->source_file = $filename;
list($this->width, $this->height, $this->type) = @getimagesize($this->source_file);
if (!$this->width || !$this->height) {
$this->source_file = null;
$this->width = null;
$this->height = null;
$this->type = null;
return;
}
$this->source = imagecreatefromstring(file_get_contents($this->source_file));
}
public function save_dest_jpeg($filename, $quality = 80) {
if (!is_null($this->dest)) {
@imagejpeg($this->dest, $filename, $quality);
@chmod($filename, 0775);
}
}
public function release_dest() {
if (!is_null($this->dest)) {
@imagedestroy($this->dest);
$this->dest = null;
}
}
public function release_source() {
if (!is_null($this->source)) {
@imagedestroy($this->source);
$this->source_file = null;
$this->source = null;
$this->width = null;
$this->height = null;
$this->type = null;
}
}
public function thumb($width, $height) {
if (is_null($this->source)) {
return;
}
$src_r = 1.0 * $this->width / $this->height;
if ($height == 0) {
if ($src_r >= 1) {
$height = 1.0 * $width / $src_r;
} else {
$height = $width;
$width = 1.0 * $height * $src_r;
}
if ($width > $this->width) {
$width = $this->width;
$height = $this->height;
}
}
$ratio = 1.0 * $width / $height;
if ($src_r <= $ratio) {
$src_w = $this->width;
$src_h = $src_w / $ratio;
$src_x = 0;
} else {
$src_h = $this->height;
$src_w = $src_h * $ratio;
$src_x = 0.5 * ($this->width - $src_w);
}
$width = intval($width);
$height = intval($height);
$src_x = intval($src_x);
$src_w = intval($src_w);
$src_h = intval($src_h);
$this->dest = imagecreatetruecolor($width, $height);
$icol = imagecolorallocate($this->dest, 255, 255, 255);
imagefill($this->dest, 0, 0, $icol);
imagecopyresampled($this->dest, $this->source, 0, 0, $src_x, 0, $width, $height, $src_w, $src_h);
}
public function rotate($angle) {
if (is_null($this->source) || ($angle !== 90 && $angle !== 180 && $angle !== 270)) {
return;
}
$this->source = imagerotate($this->source, $angle, 0);
if ( $angle === 90 || $angle === 270 ) {
list($this->width, $this->height) = [$this->height, $this->width];
}
}
public function normalize_exif_orientation($exif_source_file = null) {
if (is_null($this->source) || !function_exists('exif_read_data')) {
return;
}
if ($exif_source_file === null) {
$exif_source_file = $this->source_file;
}
$exif = exif_read_data($exif_source_file);
switch (@$exif['Orientation']) {
case 3:
$this->rotate(180);
break;
case 6:
$this->rotate(270);
break;
case 8:
$this->rotate(90);
break;
}
}
}

View File

@@ -0,0 +1,8 @@
extends ./page.tpl.pug
block init
- var title = `index - powered by h5ai v${pkg.version} (${pkg.homepage})`
- var module = 'index'
block body
div#fallback <?= $fallback_html; ?>

View File

@@ -0,0 +1,10 @@
extends ./page.tpl.pug
block init
- var title = `h5ai info page - v${pkg.version}`
- var module = 'info'
block body
div#content
h1#header
a(href=pkg.homepage) h5ai

View File

@@ -0,0 +1,30 @@
block init
<?php header('Content-type: text/html;charset=utf-8'); ?>
doctype html
html(class='no-js', lang='en')
head
meta(charset='utf-8')
meta(http-equiv='x-ua-compatible', content='ie=edge')
title #{title}
meta(name='description', content=title)
meta(name='viewport', content='width=device-width, initial-scale=1')
link(rel='shortcut icon', href!='<?= $public_href; ?>images/favicon/favicon-16-32.ico')
link(rel='apple-touch-icon-precomposed', type='image/png', href!='<?= $public_href; ?>images/favicon/favicon-152.png')
link(rel='stylesheet', href!='<?= $public_href; ?>css/styles.css')
<?php if (!$fallback_mode) { ?>
script(src!='<?= $public_href; ?>js/scripts.js', data-module=module)
<?php } ?>
<?= $x_head_tags; ?>
body#root(class=module)
div#fallback-hints
<?php if (!$fallback_mode) { ?>
span.noJsMsg Works best with JavaScript enabled!
span.noBrowserMsg Works best in #[a(href='http://browsehappy.com') modern browsers]!
<?php } ?>
span.backlink #[a(href=pkg.homepage, title=`h5ai v${pkg.version} - ${pkg.description}`) powered by h5ai]
block body

View File

@@ -0,0 +1,13 @@
## make this folder accessible
# Apache < 2.3
<IfModule !mod_authz_core.c>
Order allow,deny
Allow from all
Satisfy All
</IfModule>
# Apache ≥ 2.3
<IfModule mod_authz_core.c>
Require all granted
</IfModule>

9
src/_h5ai/public/cache/README.md vendored Normal file
View File

@@ -0,0 +1,9 @@
# Cache
Public cache.
This directory is used for server side caching. To use caching make this
directory writable for your webserver.
There is no critical data in here. You can savely remove any content. This
will clear the cache.

View File

@@ -0,0 +1,46 @@
@col-red-500: #f44336;
@col-green-500: #4caf50;
@col-blue-400: #42a5f5;
@col-pink-a200: #ff4081;
@col-white: #ffffff;
@col-grey-50: #fafafa;
@col-grey-100: #f5f5f5;
@col-grey-300: #e0e0e0;
@col-grey-700: #616161;
@col-grey-900: #212121;
@col-text-primary-black: rgba(0,0,0,0.87);
@col-text-secondary-black: rgba(0,0,0,0.54);
@col-text-disabled-black: rgba(0,0,0,0.26);
@col-divider-black: rgba(0,0,0,0.12);
@col-text-primary-white: rgba(255,255,255,1.0);
@col-text-secondary-white: rgba(255,255,255,0.7);
@col-text-disabled-white: rgba(255,255,255,0.3);
@col-divider-white: rgba(255,255,255,0.12);
@col-text-selected: @col-text-primary-white;
@col-back-selected: @col-blue-400;
@col-text-native-selection: @col-text-primary-white;
@col-back-native-selection: @col-pink-a200;
@col-text: @col-text-primary-black;
@col-back: @col-white;
@col-back-paper: @col-white;
@col-back-panel: @col-grey-50;
@col-text-hover: @col-blue-400;
@col-back-hover: rgba(0,0,0,0.03);
@col-border: rgba(0,0,0,0.05);
@col-border-strong: rgba(0,0,0,0.15);
@col-border-stronger: rgba(0,0,0,0.3);
@col-okay: @col-green-500;
@col-error: @col-red-500;
@col-link: @col-blue-400;
@col-link-hover: @col-grey-900;
@col-range-back: @col-grey-300;
@col-range-thumb: @col-grey-700;

View File

@@ -0,0 +1,72 @@
#cm-overlay {
position: fixed;
left: 0;
top: 0;
right: 0;
bottom: 0;
overflow: hidden;
z-index: 200;
.cm-panel {
.popup;
.rounded;
display: block;
position: absolute;
left: 100px;
top: 100px;
color: @col-text;
background: @col-back-paper;
z-index: 10;
overflow: auto;
min-width: 200px;
ul {
margin: 0;
padding: 0;
list-style: none;
text-align: left;
}
}
.cm-label {
padding: 8px 16px;
white-space: nowrap;
font-weight: bold;
}
.cm-entry {
padding: 8px 16px;
white-space: nowrap;
cursor: pointer;
&:hover {
color: @col-text-hover;
background: @col-back-hover;
}
}
.cm-icon {
position: relative;
top: -2px;
img {
width: 20px;
height: 20px;
}
&.no-icon {
opacity: 0;
}
}
.cm-text {
margin: 0 0 0 12px;
}
.cm-sep {
height: 1px;
margin: 8px 0;
padding: 0;
border-top: 1px solid rgba(0,0,0,0.08);
}
}

View File

@@ -0,0 +1,54 @@
#crumbbar {
overflow: hidden;
height: 48px;
font-size: 16px;
padding: 0 8px;
// border-left: 1px solid rgba(0,0,0,0.05);
a, a:active, a:visited {
color: @col-text;
cursor: pointer;
text-decoration: none;
&.active {
font-weight: bold;
}
&:hover {
color: @col-text-hover;
}
&:focus {
outline: 0;
}
}
.crumb {
.eased-transition;
display: inline-block;
}
.sep {
width: 24px;
height: 24px;
padding: 12px 0;
line-height: 48px;
display: inline-block;
vertical-align: top;
}
.crumb:first-of-type .sep {
width: 0;
}
.label {
line-height: 48px;
display: inline-block;
vertical-align: top;
padding: 0 8px;
}
.hint {
width: 20px;
height: 20px;
padding: 16px 0 0 0;
line-height: 48px;
display: inline-block;
vertical-align: top;
position: relative;
top: -2px;
}
}

View File

@@ -0,0 +1,19 @@
#content-header, #content-footer {
margin: 16px;
padding: 8px;
color: @col-text;
a, a:active, a:visited {
color: @col-link;
text-decoration: none;
cursor: pointer;
&:hover {
color: @col-link-hover;
}
}
h1, h2, h3, h4, h5, h6, p {
margin: 0.1em 0;
}
}

View File

@@ -0,0 +1,27 @@
#filter {
input {
display: none;
border: none;
font-size: 16px;
color: @col-text;
background: transparent;
outline: 0;
width: 160px;
padding: 0 12px 0 4px;
line-height: 48px;
vertical-align: top;
}
&.active {
input {
display: inline-block;
}
}
&.pending {
input {
color: @col-text-disabled-black;
}
}
}

View File

@@ -0,0 +1,54 @@
#info {
overflow: auto;
flex: 0 0 auto;
order: 99;
padding: 32px 32px 32px 48px;
white-space: nowrap;
overflow-x: hidden;
width: 240px;
.icon {
width: 240px;
height: 180px;
img {
.rounded;
display: block;
overflow: hidden;
margin: 0 auto;
width: 180px;
height: 180px;
}
.thumb {
width: 240px;
}
}
.block {
border-top: 1px solid @col-border;
border-bottom: 1px solid @col-border;
margin: 0 0 24px 0;
padding: 24px 0;
}
.label {
font-size: 16px;
margin-bottom: 16px;
}
.time, .size, .content {
line-height: 20px;
height: 20px;
}
.qrcode {
margin: 0 auto;
width: 200px;
img {
display: block;
}
}
}

View File

@@ -0,0 +1,8 @@
#pv-content-aud {
.raised;
position: absolute;
max-width: 100%;
max-height: 100%;
}

View File

@@ -0,0 +1,29 @@
#pv-content-img {
.raised;
@check-white: #f8f8f8;
@check-black: #e8e8e8;
position: absolute;
image-orientation: from-image;
max-width: 100%;
max-height: 100%;
background-color: @check-white;
background-image:
-webkit-linear-gradient(45deg, @check-black 25%, transparent 25%, transparent 75%, @check-black 75%, @check-black),
-webkit-linear-gradient(45deg, @check-black 25%, transparent 25%, transparent 75%, @check-black 75%, @check-black);
background-size: 60px 60px;
background-position: 0 0, 30px 30px;
&.loading {
opacity: 0.5;
margin-top: 32px;
width: 240px;
height: 240px;
border-radius: 1000px;
overflow: hidden;
}
}

View File

@@ -0,0 +1,36 @@
#pv-content-txt {
.raised;
box-sizing: border-box;
max-width: 960px;
text-align: left;
background: @col-back-paper;
margin: 0 auto;
padding: 8px;
overflow: auto;
a, a:active, a:visited {
color: #2080FF;
text-decoration: none;
cursor: pointer;
&:hover {
color: #68A9FF;
}
}
}
pre#pv-content-txt {
code {
line-height: 1.2em;
}
}
div#pv-content-txt {
font-size: 1.1em;
padding: 8px 24px;
code {
color: #008200;
}
}

View File

@@ -0,0 +1,13 @@
#pv-content-vid {
.raised;
position: absolute;
max-width: 100%;
max-height: 100%;
}
#pv-content-vid:-webkit-full-screen {
top: auto !important;
left: auto !important;
}

View File

@@ -0,0 +1,148 @@
#pv-overlay {
position: fixed;
left: 0;
top: 0;
right: 0;
bottom: 0;
z-index: 100;
background: rgba(0,0,0,0.5);
transition: background-color 0.3s ease-in-out;
text-align: center;
}
#pv-overlay.fullscreen {
background: @col-grey-900;
}
#pv-container {
position: absolute;
}
#pv-spinner {
position: absolute;
.back {
width: 240px;
height: 240px;
margin: -120px -120px;
border-radius: 120px;
opacity: 0.5;
overflow: hidden;
}
.spinner {
width: 100px;
height: 100px;
margin: -50px -50px;
}
}
#pv-prev-area, #pv-next-area {
position: absolute;
top: 50%;
cursor: pointer;
img {
.eased-transition;
display: block;
width: 48px;
height: 48px;
margin: -36px 0;
padding: 12px;
opacity: 0.5;
}
&:hover {
img {
.raised;
opacity: 1;
background: rgba(27,27,27,0.8);
}
}
}
#pv-prev-area {
left: 0;
img {
border-radius: 0 8px 8px 0;
padding-left: 48px;
}
}
#pv-next-area {
right: 0;
img {
border-radius: 8px 0 0 8px;
padding-right: 48px;
}
}
#pv-buttons {
list-style: none;
list-style-image: none;
margin: 0;
padding: 0;
img {
position: relative;
width: 24px;
height: 24px;
padding: 12px
}
.bar-label {
.eased-transition;
display: block;
color: @col-text-primary-white;
height: 48px;
line-height: 48px;
padding: 0 12px;
opacity: 0.7;
}
.bar-button {
.eased-transition;
display: block;
line-height: 48px;
opacity: 0.7;
cursor: pointer;
&:hover {
opacity: 1.0;
background: rgba(255,255,255,0.1);
}
}
.bar-left {
float: left;
}
.bar-right {
float: right;
}
}
#pv-bottombar {
.raised;
position: fixed;
z-index: 5;
left: 0;
right: 0;
bottom: 0;
background: rgb(27,27,27);
height: 48px;
}
#pv-overlay.fullscreen {
#pv-bottombar {
opacity: 0.5;
}
}
@media only screen and (max-width: 700px) {
#pv-prev-area, #pv-next-area {
display: none !important;
}
}

View File

@@ -0,0 +1,27 @@
#search {
input {
display: none;
border: none;
font-size: 16px;
color: @col-text;
background: transparent;
outline: 0;
width: 160px;
padding: 0 12px 0 4px;
line-height: 48px;
vertical-align: top;
}
&.active {
input {
display: inline-block;
}
}
&.pending {
input {
color: @col-text-disabled-black;
}
}
}

View File

@@ -0,0 +1,75 @@
#selection-rect {
position: absolute;
left: 0;
top: 0;
z-index: 2;
border: 1px dashed @col-border-strong;
background: rgba(0,0,0,0.1);
}
html.drag-select, html.drag-select * {
cursor: move !important;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
#view .item:hover {
box-shadow: none !important;
}
}
#view {
.selector {
display: none;
position: absolute;
left: 0;
top: 0;
width: 22px;
height: 22px;
background: @col-back-selected;
cursor: pointer;
border-radius: 0 0 2px 0;
opacity: 0.6;
&:hover {
opacity: 0.8;
}
img {
width: 100%;
height: 100%;
}
}
.item:hover .selector {
display: block;
}
.item.selected:not(.selecting),
.item.selecting:not(.selected) {
color: @col-text-selected;
background: @col-back-selected;
.selector {
display: block;
opacity: 1;
}
&:hover {
color: @col-text-selected;
background: @col-back-selected;
}
}
.no-match {
display: none;
margin-top: 36px;
text-align: center;
color: @col-border;
font-size: 5em;
font-weight: bold;
}
}

View File

@@ -0,0 +1,84 @@
#tree {
overflow: auto;
flex: 0 0 auto;
order: 1;
padding: 32px 32px 32px 16px;
white-space: nowrap;
max-width: 250px;
overflow-x: hidden;
a, a:active, a.visited {
display: block;
margin-left: 20px;
padding: 3px 0;
text-decoration: none;
color: @col-text;
&:hover {
color: @col-text-hover;
}
}
.active > a {
font-weight: bold;
}
.indicator {
display: block;
float: left;
padding: 3px 0;
position: relative;
top: -2px;
cursor: pointer;
img {
// .eased-transition;
width: 20px;
height: 20px;
zoom: 1;
}
}
.item {
clear: left;
&.open > .indicator img {
transform: rotate(90deg);
}
&.unknown > .indicator {
opacity: 0.3;
}
&.none > .indicator {
opacity: 0;
cursor: inherit;
}
&.unknown > .content, &.none > .content, &.closed > .content {
display: none;
}
}
.icon {
position: relative;
top: -2px;
img {
width: 20px;
height: 20px;
}
}
.label {
margin: 0 0 0 4px;
}
.content {
margin: 0;
padding: 0 0 0 20px;
}
.summary {
color: @col-text-disabled-black;
padding: 0 0 0 8px;
}
}

View File

@@ -0,0 +1,5 @@
@font-family: "Ubuntu", "Roboto", "Helvetica", "Arial", "sans-serif";
@font-weight: normal;
@font-size: 13px;
@font-family-mono: "Ubuntu Mono", "Monaco", "Lucida Sans Typewriter", "monospace";
@font-size-mono: 15px;

View File

@@ -0,0 +1,108 @@
#root.info {
#content {
flex: 1 1 auto;
order: 50;
color: @col-text;
text-align: center;
}
code {
margin: 0 0.2em;
padding: 2px 4px;
border-radius: 4px;
letter-spacing: 0.05em;
background: @col-back-panel;
border: 1px solid @col-border;
font-size: 0.9em;
}
#header a {
.eased-transition;
font-size: 4em;
font-weight: 300;
margin: 0.8em 0 0 0;
color: @col-text;
text-decoration: none;
&:hover {
color: @col-text-hover;
}
}
#support {
margin: 24px auto;
padding: 18px 0 6px 0;
width: 292px;
background: @col-back-panel;
border: 1px solid @col-border;
border-radius: 4px;
input[type="image"] {
border: 0;
width: 100px;
padding: 12px 48px;
}
}
#pass {
.el-input;
display: inline-block;
margin: 8px;
padding: 0 12px;
line-height: 28px;
width: 200px;
vertical-align: top;
}
#login, #logout {
.el-button;
display: inline-block;
margin: 8px;
padding: 0 12px;
line-height: 28px;
vertical-align: top;
}
#hint {
margin: 12px auto;
width: 320px;
}
#tests {
display: inline-block;
text-align: left;
list-style-type: none;
margin: 48px 0;
padding: 0;
.test {
background: @col-back-paper;
margin: 12px 0 0 0;
padding: 8px 12px 12px 12px;
border-bottom: 1px solid @col-border;
}
.label {
display: inline-block;
width: 250px;
font-size: 1.4em;
}
.result {
display: inline-block;
width: 250px;
text-align: right;
font-size: 1.4em;
font-weight: bold;
&.passed {
color: @col-okay;
}
&.failed {
color: @col-error;
}
}
.info {
margin: 4px 0 0 0;
}
}
}

View File

@@ -0,0 +1,29 @@
::-moz-selection {
color: @col-text-native-selection;
background: @col-back-native-selection;
text-shadow: none;
}
::selection {
color: @col-text-native-selection;
background: @col-back-native-selection;
text-shadow: none;
}
*:focus {
outline: none;
}
code, pre {
font-family: @font-family-mono;
font-size: @font-size-mono;
font-weight: @font-weight;
color: @col-text;
}
audio, canvas, iframe, img, svg, video {
vertical-align: middle;
}
textarea {
resize: vertical;
}

View File

@@ -0,0 +1,79 @@
.hidden {
display: none !important;
}
.invisible {
visibility: hidden;
}
.clearfix:before,
.clearfix:after {
content: " ";
display: table;
}
.clearfix:after {
clear: both;
}
.raised {
box-shadow: 0 1px 10px 0 rgba(0,0,0,0.5);
}
.popup {
box-shadow: 0 1px 20px 0 rgba(0,0,0,0.5);
}
.rounded {
border-radius: 2px;
}
.clear-appearance {
-moz-appearance: none;
-ms-appearance: none;
-webkit-appearance: none;
}
.eased-transition {
transition: all 0.2s ease-in-out;
}
.flex-base {
display: flex;
flex-wrap: nowrap;
justify-content: flex-start;
align-content: flex-start;
align-items: stretch;
}
.flex-column {
.flex-base;
flex-direction: column;
}
.flex-row {
.flex-base;
flex-direction: row;
}
.el-button {
.rounded;
.eased-transition;
color: @col-text-primary-white;
background: @col-blue-400;
cursor: pointer;
text-decoration: none;
&:hover {
.raised;
}
}
.el-input {
.rounded;
.clear-appearance;
background: @col-back-paper;
border: none;
outline: none;
background: @col-back-panel;
border: 1px solid @col-border;
}

View File

@@ -0,0 +1,37 @@
@media only screen and (max-width: 700px) {
#crumbbar {
.crumb:not(.active) {
display: none;
}
.crumb.active .sep {
width: 0;
}
}
#view.view-details {
// .header .label, .item .label {
// margin-right: 80px !important;
// }
// .header .date, .item .date {
// display: none;
// }
}
#tree, #info {
display: none !important;
}
}
@media print {
*,
*:before,
*:after,
*:first-letter,
*:first-line {
background: transparent !important;
color: #000 !important;
box-shadow: none !important;
text-shadow: none !important;
}
#toolbar, #sidebar, #tree, #info {
display: none !important;
}
}

View File

@@ -0,0 +1,6 @@
#content {
overflow: auto;
flex: 1 1 auto;
order: 50;
position: relative;
}

View File

@@ -0,0 +1,115 @@
#fallback {
display: none;
max-width: 960px;
margin: 16px auto;
padding: 32px 16px;
table {
display: block;
width: 100%;
border-collapse: collapse;
background: @col-back-paper;
}
th, td {
padding: 6px;
text-align: left;
border: none;
border-bottom: 1px solid #f0f0f0;
}
th {
color: #aaa;
font-weight: normal;
line-height: 36px;
}
td {
overflow: hidden;
white-space: nowrap;
}
a, a:active, a:visited {
display: block;
color: inherit;
text-decoration: none;
cursor: pointer;
&:hover {
color: @col-text-hover;
}
}
.fb-i {
width: 20px;
padding-left: 12px;
img {
width: 20px;
height: 20px;
position: relative;
top: -1px;
}
}
.fb-n {
width: 682px;
max-width: 682px;
}
.fb-d {
text-align: right;
width: 160px;
min-width: 160px;
}
.fb-s {
text-align: right;
width: 70px;
min-width: 70px;
padding-right: 12px;
}
}
#fallback-hints {
display: none;
overflow: hidden;
text-align: right;
background: @col-back-panel;
border-bottom: 1px solid @col-border;
a, a:active, a:visited {
.eased-transition;
display: inline-block;
line-height: 48px;
color: @col-text-secondary-black;
text-decoration: none;
outline: 0;
&:hover {
color: @col-text-hover;
}
}
.backlink {
margin: 0 16px;
}
.noJsMsg, .noBrowserMsg {
display: none;
margin: 0 16px;
color: @col-error;
}
}
html.no-js, html.no-browser {
#root {
position: static;
overflow: auto;
}
#fallback, #fallback-hints {
display: block;
}
}
html.no-js .noJsMsg {
display: inline !important;
}
html.no-browser .noBrowserMsg {
display: inline !important;
}

View File

@@ -0,0 +1,7 @@
#mainrow {
.flex-row;
flex: 1 1 auto;
order: 50;
height: 0; // non-webkit fix;
}

View File

@@ -0,0 +1,13 @@
#notification {
position: fixed;
left: 50%;
width: 200px;
margin-left: -100px;
z-index: 100;
padding: 3px 6px 6px 6px;
color: @col-text-primary-white;
background: rgba(0,0,0,0.2);
border-radius: 0 0 4px 4px;
text-align: center;
overflow: hidden;
}

View File

@@ -0,0 +1,18 @@
#root {
.flex-column;
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
overflow: hidden;
background: @col-back;
line-height: 1.4;
}
#root, input, select {
font-family: @font-family;
font-size: @font-size;
font-weight: @font-weight;
color: @col-text;
}

View File

@@ -0,0 +1,120 @@
#sidebar {
overflow-x: hidden;
overflow-y: auto;
flex: 0 0 auto;
order: 0;
background: @col-back-panel;
border-right: 1px solid @col-border;
padding: 16px;
position: absolute;
top: 48px;
min-height: 100%;
z-index: 1;
.block {
display: block;
margin: 0 0 24px 0;
width: 168px;
h1 {
font-size: 1em;
margin: 2px 0 6px 0;
}
}
.button {
.rounded;
.eased-transition;
display: inline-block;
margin: 4px;
color: @col-text;
cursor: pointer;
&:hover {
background: @col-back-hover;
}
&.active {
background: rgba(0,0,0,0.03);
box-shadow: inset 0 0 4px 0 rgba(0,0,0,0.4);
}
img {
width: 24px;
height: 24px;
padding: 12px;
}
}
.select {
.rounded;
background: transparent;
overflow: hidden;
outline: 0;
width: 160px;
margin: 4px;
line-height: 48px;
}
input, select {
.clear-appearance;
background: transparent;
width: 100%;
border: 0 solid #000;
cursor: pointer;
outline: 0;
&:hover {
background: @col-back-hover;
}
}
select {
width: 187px;
padding: 0 8px;
height: 48px;
line-height: 48px;
}
input[type='range'] {
.rounded;
width: 144px;
margin: 4px;
padding: 8px;
vertical-align: middle;
height: 32px;
line-height: 32px;
}
.range-track {
.clear-appearance;
border-width: 0;
border-radius: 20px;
background: @col-range-back;
height: 6px;
}
.range-thumb {
.clear-appearance;
border-width: 0;
border-radius: 20px;
background: @col-range-thumb;
width: 16px;
height: 16px;
}
input[type='range']::-webkit-slider-runnable-track { .range-track; }
input[type='range']::-moz-range-track { .range-track; }
input[type='range']::-ms-track { .range-track; }
input[type='range']::-ms-fill-lower { .range-track; }
input[type='range']::-ms-fill-upper { .range-track; }
input[type='range']::-webkit-slider-thumb { .range-thumb; margin-top: -5px; }
input[type='range']::-moz-range-thumb { .range-thumb; }
input[type='range']::-ms-thumb { .range-thumb; }
#view-size {
display: block;
}
}

View File

@@ -0,0 +1,71 @@
#topbar {
.flex-row;
overflow: hidden;
flex: 0 0 auto;
order: 1;
background: @col-back-panel;
border-bottom: 1px solid @col-border;
z-index: 1;
}
#toolbar {
overflow: hidden;
flex: 0 0 auto;
order: 1;
height: 48px;
.tool {
.eased-transition;
display: inline-block;
cursor: pointer;
img {
display: inline-block;
width: 24px;
height: 24px;
padding: 12px;
}
&:hover {
background: @col-back-hover;
}
}
}
#flowbar {
overflow: hidden;
flex: 1 1 auto;
order: 2;
height: 48px;
}
#backlink {
.eased-transition;
display: block;
overflow: hidden;
flex: 0 0 auto;
order: 99;
text-align: center;
padding: 6px 12px;
overflow: hidden;
height: 36px;
&, &:active, &:visited {
color: @col-text-disabled-black;
cursor: pointer;
text-decoration: none;
}
&:hover {
color: @col-text-hover;
background: @col-back-hover;
}
&:focus {
outline: 0;
}
div {
line-height: 18px;
white-space: nowrap;
}
}

View File

@@ -0,0 +1,135 @@
#view.view-details {
.view-details-sized(@size) {
.item {
.label, .date, .size {
line-height: @size + 14px;
}
}
.square {
width: @size;
height: @size;
img {
width: @size;
height: @size;
}
}
.label {
margin: 0 246px 0 (@size + 32px);
}
}
margin: 32px;
.header {
position: relative;
white-space: nowrap;
display: list-item;
border-bottom: 1px solid rgba(0,0,0,0.07);
border-radius: 2px 2px 0 0;
.label, .date, .size {
.eased-transition;
line-height: 24px;
padding: 0px 8px 16px 8px;
opacity: 0.4;
outline: 0;
&:hover {
opacity: 1;
color: @col-text-hover;
}
}
.sort {
display: none;
position: relative;
top: -2px;
width: 20px;
height: 20px;
padding: 0 4px;
}
.ascending .sort {
display: inline;
}
.descending .sort {
display: inline;
transform: rotate(180deg);
zoom: 1;
}
}
.item {
overflow: hidden;
border-bottom: 1px solid rgba(0,0,0,0.07);
&:hover {
.raised;
z-index: 1;
}
&:last-child {
border-radius: 0 0 2px 2px;
}
}
.square {
display: inline-block;
position: absolute;
left: 16px;
top: -1px;
padding: 8px;
.thumb {
.rounded;
box-shadow: 0 0 1px 0 rgba(0,0,0,0.2);
}
}
.label, .date, .size {
padding: 0 8px;
}
.date {
position: absolute;
right: 116px;
top: 0;
}
.size {
position: absolute;
right: 16px;
top: 0;
}
.view-details-sized(16px)
}
#view.view-details {
&.width-0 {
.label {
margin-right: 4px;
}
.date {
display: none;
}
.size {
display: none;
}
}
&.width-1 {
.label {
margin-right: 64px;
}
.date {
display: none;
}
}
}

View File

@@ -0,0 +1,50 @@
#view.view-grid {
.view-grid-sized(@size) {
.label {
line-height: @size;
}
.square {
width: @size;
height: @size;
img {
width: @size;
height: @size;
}
}
}
margin: 28px;
.item {
.rounded;
overflow: hidden;
float: left;
margin: 8px;
&:hover {
.raised;
}
}
.square {
display: inline-block;
vertical-align: top;
}
.label {
display: inline-block;
vertical-align: top;
width: 180px;
padding: 0 8px;
}
.date, .size {
display: none;
}
.view-grid-sized(48px);
}

View File

@@ -0,0 +1,53 @@
#view.view-icons {
.view-icons-sized(@size) {
.item {
width: @size * 4/3;
}
.landscape {
width: @size * 4/3;
height: @size;
img {
width: @size;
height: @size;
}
.thumb {
width: @size * 4/3;
}
}
}
margin: 28px;
.item {
.rounded;
overflow: hidden;
float: left;
margin: 8px;
&:hover {
.raised;
}
}
.landscape {
display: block;
background: @col-back-panel;
}
.label {
padding: 0 6px;
line-height: 24px;
text-align: center;
}
.date, .size {
display: none;
}
.view-icons-sized(96px);
}

View File

@@ -0,0 +1,79 @@
#view {
a, a:active, a:visited {
display: block;
color: inherit;
cursor: pointer;
text-decoration: none;
}
ul {
margin: 0;
padding: 0;
list-style: none;
}
.header {
display: none;
}
.item {
position: relative;
white-space: nowrap;
background: @col-back-paper;
&:hover {
color: @col-text-hover;
background: @col-back-panel;
}
}
.folder-parent {
.date, .size {
display: none;
}
}
.icon {
display: none;
text-align: center;
img {
position: relative;
top: 50%;
transform: translateY(-50%);
}
.thumb {
max-width: none;
max-height: none;
}
}
.label {
display: block;
overflow: hidden;
text-align: left;
text-overflow: ellipsis;
}
.date {
text-align: right;
width: 130px;
}
.size {
text-align: right;
width: 80px;
}
#view-hint {
display: block;
margin-top: 36px;
text-align: center;
color: @col-border;
font-size: 5em;
font-weight: bold;
}
}

View File

@@ -0,0 +1,12 @@
@charset "utf-8";
// @include "../../../../node_modules/normalize.css/normalize.css"
// @include "lib/colors.less"
// @include "lib/fonts.less"
// @include "lib/misc.less"
// @include "lib/mixins.less"
// @include "lib/*/*.less"
// @include "lib/responsive.less"

View File

@@ -0,0 +1,4 @@
# Extensions
This directory is used for additional script and style files. You have to add
them manualy to the `resources` section in `_h5ai/private/conf/options.json`.

Binary file not shown.

After

Width:  |  Height:  |  Size: 118 B

Some files were not shown because too many files have changed in this diff Show More