From 75df9edb8c923313fd6a1f9f3ced318014e32337 Mon Sep 17 00:00:00 2001 From: ewilly Date: Wed, 23 Mar 2016 19:30:43 +0100 Subject: [PATCH] Initial commit --- README.md | 5 +- conf/nginx.conf | 23 + manifest.json | 80 + scripts/backup | 19 + scripts/install | 109 + scripts/remove | 8 + scripts/restore | 11 + scripts/upgrade | 41 + sources/LICENCE.md | 201 ++ sources/changelog.md | 131 + sources/config.php | 55 + sources/contributors.md | 9 + sources/core/.htaccess | 4 + sources/core/Array2feed.php | 76 + sources/core/GET_POST_admin_data.php | 367 +++ sources/core/auto_dropzone.php | 469 ++++ sources/core/auto_restrict.php | 723 ++++++ sources/core/auto_thumb.php | 97 + sources/core/commands_GET_vars.php | 132 + sources/core/core.php | 1205 +++++++++ sources/core/core.php.zip | Bin 0 -> 12796 bytes sources/core/js/VanillaJS.js | 328 +++ sources/core/js/audio.js | 24 + sources/core/js/audiojs.swf | Bin 0 -> 1644 bytes sources/core/js/blazy.js | 6 + sources/core/js/lightbox.js | 72 + sources/core/js/m3uStreamPlayer.js | 143 + sources/core/js/marked.js | 6 + sources/core/js/micromarkdown.js | 10 + sources/core/js/playlist.js | 40 + sources/core/js/qr.js | 760 ++++++ sources/core/js/scrolltotop.js | 94 + sources/core/js/sorttable.js | 495 ++++ sources/core/listfiles.php | 228 ++ sources/core/markdown.php | 509 ++++ sources/core/share.php | 197 ++ sources/core/templates.php | 71 + sources/core/test.html | 2298 +++++++++++++++++ sources/index.php | 37 + sources/locale/de.php | 292 +++ sources/locale/en.php | 355 +++ sources/locale/es.php | 338 +++ sources/locale/fr.php | 343 +++ sources/readme.md | 60 + sources/templates/default/admin.php | 266 ++ sources/templates/default/css/admin.css | 139 + sources/templates/default/css/dialog.css | 154 ++ .../templates/default/css/edit_profiles.css | 13 + sources/templates/default/css/editor.css | 34 + sources/templates/default/css/font/bozon.eot | Bin 0 -> 17140 bytes sources/templates/default/css/font/bozon.svg | 108 + sources/templates/default/css/font/bozon.ttf | Bin 0 -> 16984 bytes sources/templates/default/css/font/bozon.woff | Bin 0 -> 10312 bytes .../templates/default/css/font/bozon.woff2 | Bin 0 -> 8692 bytes .../templates/default/css/font/fontello.eot | Bin 0 -> 12604 bytes .../templates/default/css/font/fontello.svg | 36 + .../templates/default/css/font/fontello.ttf | Bin 0 -> 12436 bytes .../templates/default/css/font/fontello.woff | Bin 0 -> 6860 bytes sources/templates/default/css/footer.css | 26 + sources/templates/default/css/gallery.css | 33 + sources/templates/default/css/header.css | 282 ++ sources/templates/default/css/home.css | 82 + sources/templates/default/css/icons.css | 99 + sources/templates/default/css/ini.css | 149 ++ sources/templates/default/css/lightbox.css | 85 + sources/templates/default/css/list.css | 322 +++ sources/templates/default/css/lock.css | 27 + sources/templates/default/css/login.css | 53 + sources/templates/default/css/markdown.css | 425 +++ sources/templates/default/css/mobile.css | 55 + .../templates/default/css/music_player.css | 205 ++ sources/templates/default/css/pen.css | 175 ++ sources/templates/default/css/share.css | 51 + sources/templates/default/css/stats.css | 77 + sources/templates/default/css/style.php | 90 + sources/templates/default/css/users_page.css | 124 + sources/templates/default/css/userslist.css | 34 + sources/templates/default/edit_profiles.php | 56 + sources/templates/default/editor.php | 77 + sources/templates/default/favicon.png | Bin 0 -> 2993 bytes sources/templates/default/footer.php | 23 + sources/templates/default/footer_markdown.php | 5 + sources/templates/default/header.php | 111 + sources/templates/default/header_markdown.php | 19 + sources/templates/default/home.php | 77 + .../default/img/admin/fil_ariane_home.png | Bin 0 -> 337 bytes .../default/img/admin/menu_download_url.png | Bin 0 -> 600 bytes .../templates/default/img/admin/menu_file.png | Bin 0 -> 229 bytes .../templates/default/img/admin/menu_icon.png | Bin 0 -> 159 bytes .../templates/default/img/admin/menu_link.png | Bin 0 -> 498 bytes .../templates/default/img/admin/menu_list.png | Bin 0 -> 170 bytes .../templates/default/img/admin/menu_move.png | Bin 0 -> 296 bytes .../default/img/admin/menu_new_folder.png | Bin 0 -> 386 bytes .../templates/default/img/admin/move_file.png | Bin 0 -> 481 bytes .../default/img/admin/move_folder.png | Bin 0 -> 331 bytes .../templates/default/img/admin/previous.png | Bin 0 -> 545 bytes .../default/img/admin/shared_folder.png | Bin 0 -> 1121 bytes sources/templates/default/img/admin/space.png | Bin 0 -> 353 bytes sources/templates/default/img/barb.png | Bin 0 -> 176 bytes sources/templates/default/img/barw.png | Bin 0 -> 170 bytes .../templates/default/img/dialog/required.png | Bin 0 -> 648 bytes .../templates/default/img/extensions/css.png | Bin 0 -> 1182 bytes .../templates/default/img/extensions/doc.png | Bin 0 -> 2016 bytes .../templates/default/img/extensions/exe.png | Bin 0 -> 2726 bytes .../templates/default/img/extensions/html.png | Bin 0 -> 1139 bytes .../templates/default/img/extensions/js.png | Bin 0 -> 1135 bytes .../templates/default/img/extensions/mp3.png | Bin 0 -> 938 bytes .../templates/default/img/extensions/mp4.png | Bin 0 -> 1028 bytes .../templates/default/img/extensions/pdf.png | Bin 0 -> 1487 bytes .../templates/default/img/extensions/php.png | Bin 0 -> 1147 bytes .../templates/default/img/extensions/swf.png | Bin 0 -> 1877 bytes .../templates/default/img/extensions/txt.png | Bin 0 -> 1363 bytes .../default/img/extensions/unknown.png | Bin 0 -> 867 bytes .../templates/default/img/extensions/xls.png | Bin 0 -> 1887 bytes .../templates/default/img/extensions/zip.png | Bin 0 -> 2691 bytes sources/templates/default/img/folder.png | Bin 0 -> 456 bytes .../templates/default/img/footer/github.png | Bin 0 -> 1714 bytes sources/templates/default/img/ghost.png | Bin 0 -> 165 bytes .../default/img/header/file_tree.png | Bin 0 -> 694 bytes sources/templates/default/img/header/home.png | Bin 0 -> 318 bytes .../templates/default/img/header/locked.png | Bin 0 -> 309 bytes .../templates/default/img/header/log_file.png | Bin 0 -> 294 bytes sources/templates/default/img/header/logo.png | Bin 0 -> 2995 bytes .../templates/default/img/header/logout.png | Bin 0 -> 296 bytes .../default/img/header/miniupload.png | Bin 0 -> 438 bytes .../templates/default/img/header/new_pass.png | Bin 0 -> 434 bytes .../templates/default/img/header/new_user.png | Bin 0 -> 449 bytes .../default/img/header/regen_tree.png | Bin 0 -> 786 bytes .../templates/default/img/header/search.png | Bin 0 -> 399 bytes .../default/img/header/text_editor.png | Bin 0 -> 509 bytes sources/templates/default/img/header/user.png | Bin 0 -> 354 bytes .../templates/default/img/header/users.png | Bin 0 -> 580 bytes sources/templates/default/img/home/burn.png | Bin 0 -> 2889 bytes sources/templates/default/img/home/design.png | Bin 0 -> 4726 bytes .../templates/default/img/home/error_link.png | Bin 0 -> 2535 bytes sources/templates/default/img/home/locked.png | Bin 0 -> 2376 bytes .../templates/default/img/home/logo_agpl.png | Bin 0 -> 26264 bytes .../templates/default/img/home/logo_css.png | Bin 0 -> 4913 bytes .../templates/default/img/home/logo_html.png | Bin 0 -> 4908 bytes .../templates/default/img/home/logo_js.png | Bin 0 -> 4339 bytes .../templates/default/img/home/logo_php.png | Bin 0 -> 4616 bytes sources/templates/default/img/home/nodb.png | Bin 0 -> 3381 bytes sources/templates/default/img/home/qrcode.png | Bin 0 -> 3859 bytes sources/templates/default/img/home/renew.png | Bin 0 -> 3445 bytes .../templates/default/img/home/smartphone.png | Bin 0 -> 2541 bytes sources/templates/default/img/home/tosend.png | Bin 0 -> 3997 bytes .../templates/default/img/home/toshare.png | Bin 0 -> 5571 bytes .../default/img/home/unzipfolder.png | Bin 0 -> 4059 bytes sources/templates/default/img/home/users.png | Bin 0 -> 3840 bytes .../templates/default/img/home/zipfolder.png | Bin 0 -> 3094 bytes .../templates/default/img/lightbox/close.png | Bin 0 -> 493 bytes .../default/img/lightbox/close_white.png | Bin 0 -> 857 bytes .../default/img/lightbox/loading.gif | Bin 0 -> 1859 bytes .../templates/default/img/lightbox/next.png | Bin 0 -> 1527 bytes .../templates/default/img/lightbox/prev.png | Bin 0 -> 1446 bytes sources/templates/default/img/list/burn.png | Bin 0 -> 409 bytes .../default/img/list/download_folder.png | Bin 0 -> 385 bytes sources/templates/default/img/list/edit.png | Bin 0 -> 509 bytes sources/templates/default/img/list/eye.png | Bin 0 -> 365 bytes sources/templates/default/img/list/folder.png | Bin 0 -> 305 bytes sources/templates/default/img/list/link.png | Bin 0 -> 498 bytes sources/templates/default/img/list/locked.png | Bin 0 -> 309 bytes sources/templates/default/img/list/move.png | Bin 0 -> 296 bytes sources/templates/default/img/list/qrcode.png | Bin 0 -> 505 bytes sources/templates/default/img/list/rename.png | Bin 0 -> 383 bytes sources/templates/default/img/list/renew.png | Bin 0 -> 381 bytes .../default/img/list/shared_folder.png | Bin 0 -> 1115 bytes sources/templates/default/img/list/trash.png | Bin 0 -> 2897 bytes sources/templates/default/img/list/users.png | Bin 0 -> 580 bytes .../templates/default/img/player-graphics.png | Bin 0 -> 1542 bytes sources/templates/default/img/stats/trash.png | Bin 0 -> 2897 bytes sources/templates/default/img/video.png | Bin 0 -> 5358 bytes sources/templates/default/info.md | 1 + sources/templates/default/login.php | 91 + sources/templates/default/stats.php | 109 + .../default/templates/dialog_delete.html | 17 + .../templates/dialog_download_url.html | 17 + .../default/templates/dialog_link.html | 13 + .../default/templates/dialog_move.html | 18 + .../default/templates/dialog_new_folder.html | 16 + .../default/templates/dialog_password.html | 18 + .../default/templates/dialog_qrcode.html | 10 + .../default/templates/dialog_rename.html | 17 + .../default/templates/dialog_share.html | 18 + .../templates/default/templates/lightbox.html | 11 + .../default/templates/links_file_icon.html | 14 + .../default/templates/links_file_list.html | 21 + .../default/templates/links_folder_icon.html | 16 + .../default/templates/links_folder_list.html | 13 + .../default/templates/links_image_icon.html | 15 + .../default/templates/links_image_list.html | 13 + .../default/templates/move_file_icon.html | 8 + .../default/templates/move_file_list.html | 14 + .../default/templates/move_folder_icon.html | 10 + .../default/templates/move_folder_list.html | 15 + .../default/templates/move_image_icon.html | 8 + .../default/templates/move_image_list.html | 13 + .../templates/default/templates/read_m3u.html | 9 + .../default/templates/view_file_icon.html | 15 + .../default/templates/view_file_list.html | 15 + .../default/templates/view_folder_icon.html | 15 + .../default/templates/view_folder_list.html | 15 + .../default/templates/view_image_icon.html | 14 + .../default/templates/view_image_list.html | 14 + .../templates/view_shared_folder_icon.html | 12 + .../templates/view_shared_folder_list.html | 11 + sources/templates/default/users.php | 105 + 207 files changed, 14723 insertions(+), 1 deletion(-) create mode 100644 conf/nginx.conf create mode 100644 manifest.json create mode 100644 scripts/backup create mode 100644 scripts/install create mode 100644 scripts/remove create mode 100644 scripts/restore create mode 100644 scripts/upgrade create mode 100644 sources/LICENCE.md create mode 100644 sources/changelog.md create mode 100644 sources/config.php create mode 100644 sources/contributors.md create mode 100644 sources/core/.htaccess create mode 100644 sources/core/Array2feed.php create mode 100644 sources/core/GET_POST_admin_data.php create mode 100644 sources/core/auto_dropzone.php create mode 100644 sources/core/auto_restrict.php create mode 100644 sources/core/auto_thumb.php create mode 100644 sources/core/commands_GET_vars.php create mode 100644 sources/core/core.php create mode 100644 sources/core/core.php.zip create mode 100644 sources/core/js/VanillaJS.js create mode 100644 sources/core/js/audio.js create mode 100644 sources/core/js/audiojs.swf create mode 100644 sources/core/js/blazy.js create mode 100644 sources/core/js/lightbox.js create mode 100644 sources/core/js/m3uStreamPlayer.js create mode 100644 sources/core/js/marked.js create mode 100644 sources/core/js/micromarkdown.js create mode 100644 sources/core/js/playlist.js create mode 100644 sources/core/js/qr.js create mode 100644 sources/core/js/scrolltotop.js create mode 100644 sources/core/js/sorttable.js create mode 100644 sources/core/listfiles.php create mode 100644 sources/core/markdown.php create mode 100644 sources/core/share.php create mode 100644 sources/core/templates.php create mode 100644 sources/core/test.html create mode 100644 sources/index.php create mode 100644 sources/locale/de.php create mode 100644 sources/locale/en.php create mode 100644 sources/locale/es.php create mode 100644 sources/locale/fr.php create mode 100644 sources/readme.md create mode 100644 sources/templates/default/admin.php create mode 100644 sources/templates/default/css/admin.css create mode 100644 sources/templates/default/css/dialog.css create mode 100644 sources/templates/default/css/edit_profiles.css create mode 100644 sources/templates/default/css/editor.css create mode 100644 sources/templates/default/css/font/bozon.eot create mode 100644 sources/templates/default/css/font/bozon.svg create mode 100644 sources/templates/default/css/font/bozon.ttf create mode 100644 sources/templates/default/css/font/bozon.woff create mode 100644 sources/templates/default/css/font/bozon.woff2 create mode 100644 sources/templates/default/css/font/fontello.eot create mode 100644 sources/templates/default/css/font/fontello.svg create mode 100644 sources/templates/default/css/font/fontello.ttf create mode 100644 sources/templates/default/css/font/fontello.woff create mode 100644 sources/templates/default/css/footer.css create mode 100644 sources/templates/default/css/gallery.css create mode 100644 sources/templates/default/css/header.css create mode 100644 sources/templates/default/css/home.css create mode 100644 sources/templates/default/css/icons.css create mode 100644 sources/templates/default/css/ini.css create mode 100644 sources/templates/default/css/lightbox.css create mode 100644 sources/templates/default/css/list.css create mode 100644 sources/templates/default/css/lock.css create mode 100644 sources/templates/default/css/login.css create mode 100644 sources/templates/default/css/markdown.css create mode 100644 sources/templates/default/css/mobile.css create mode 100644 sources/templates/default/css/music_player.css create mode 100644 sources/templates/default/css/pen.css create mode 100644 sources/templates/default/css/share.css create mode 100644 sources/templates/default/css/stats.css create mode 100644 sources/templates/default/css/style.php create mode 100644 sources/templates/default/css/users_page.css create mode 100644 sources/templates/default/css/userslist.css create mode 100644 sources/templates/default/edit_profiles.php create mode 100644 sources/templates/default/editor.php create mode 100644 sources/templates/default/favicon.png create mode 100644 sources/templates/default/footer.php create mode 100644 sources/templates/default/footer_markdown.php create mode 100644 sources/templates/default/header.php create mode 100644 sources/templates/default/header_markdown.php create mode 100644 sources/templates/default/home.php create mode 100644 sources/templates/default/img/admin/fil_ariane_home.png create mode 100644 sources/templates/default/img/admin/menu_download_url.png create mode 100644 sources/templates/default/img/admin/menu_file.png create mode 100644 sources/templates/default/img/admin/menu_icon.png create mode 100644 sources/templates/default/img/admin/menu_link.png create mode 100644 sources/templates/default/img/admin/menu_list.png create mode 100644 sources/templates/default/img/admin/menu_move.png create mode 100644 sources/templates/default/img/admin/menu_new_folder.png create mode 100644 sources/templates/default/img/admin/move_file.png create mode 100644 sources/templates/default/img/admin/move_folder.png create mode 100644 sources/templates/default/img/admin/previous.png create mode 100644 sources/templates/default/img/admin/shared_folder.png create mode 100644 sources/templates/default/img/admin/space.png create mode 100644 sources/templates/default/img/barb.png create mode 100644 sources/templates/default/img/barw.png create mode 100644 sources/templates/default/img/dialog/required.png create mode 100644 sources/templates/default/img/extensions/css.png create mode 100644 sources/templates/default/img/extensions/doc.png create mode 100644 sources/templates/default/img/extensions/exe.png create mode 100644 sources/templates/default/img/extensions/html.png create mode 100644 sources/templates/default/img/extensions/js.png create mode 100644 sources/templates/default/img/extensions/mp3.png create mode 100644 sources/templates/default/img/extensions/mp4.png create mode 100644 sources/templates/default/img/extensions/pdf.png create mode 100644 sources/templates/default/img/extensions/php.png create mode 100644 sources/templates/default/img/extensions/swf.png create mode 100644 sources/templates/default/img/extensions/txt.png create mode 100644 sources/templates/default/img/extensions/unknown.png create mode 100644 sources/templates/default/img/extensions/xls.png create mode 100644 sources/templates/default/img/extensions/zip.png create mode 100644 sources/templates/default/img/folder.png create mode 100644 sources/templates/default/img/footer/github.png create mode 100644 sources/templates/default/img/ghost.png create mode 100644 sources/templates/default/img/header/file_tree.png create mode 100644 sources/templates/default/img/header/home.png create mode 100644 sources/templates/default/img/header/locked.png create mode 100644 sources/templates/default/img/header/log_file.png create mode 100644 sources/templates/default/img/header/logo.png create mode 100644 sources/templates/default/img/header/logout.png create mode 100644 sources/templates/default/img/header/miniupload.png create mode 100644 sources/templates/default/img/header/new_pass.png create mode 100644 sources/templates/default/img/header/new_user.png create mode 100644 sources/templates/default/img/header/regen_tree.png create mode 100644 sources/templates/default/img/header/search.png create mode 100644 sources/templates/default/img/header/text_editor.png create mode 100644 sources/templates/default/img/header/user.png create mode 100644 sources/templates/default/img/header/users.png create mode 100644 sources/templates/default/img/home/burn.png create mode 100644 sources/templates/default/img/home/design.png create mode 100644 sources/templates/default/img/home/error_link.png create mode 100644 sources/templates/default/img/home/locked.png create mode 100644 sources/templates/default/img/home/logo_agpl.png create mode 100644 sources/templates/default/img/home/logo_css.png create mode 100644 sources/templates/default/img/home/logo_html.png create mode 100644 sources/templates/default/img/home/logo_js.png create mode 100644 sources/templates/default/img/home/logo_php.png create mode 100644 sources/templates/default/img/home/nodb.png create mode 100644 sources/templates/default/img/home/qrcode.png create mode 100644 sources/templates/default/img/home/renew.png create mode 100644 sources/templates/default/img/home/smartphone.png create mode 100644 sources/templates/default/img/home/tosend.png create mode 100644 sources/templates/default/img/home/toshare.png create mode 100644 sources/templates/default/img/home/unzipfolder.png create mode 100644 sources/templates/default/img/home/users.png create mode 100644 sources/templates/default/img/home/zipfolder.png create mode 100644 sources/templates/default/img/lightbox/close.png create mode 100644 sources/templates/default/img/lightbox/close_white.png create mode 100644 sources/templates/default/img/lightbox/loading.gif create mode 100644 sources/templates/default/img/lightbox/next.png create mode 100644 sources/templates/default/img/lightbox/prev.png create mode 100644 sources/templates/default/img/list/burn.png create mode 100644 sources/templates/default/img/list/download_folder.png create mode 100644 sources/templates/default/img/list/edit.png create mode 100644 sources/templates/default/img/list/eye.png create mode 100644 sources/templates/default/img/list/folder.png create mode 100644 sources/templates/default/img/list/link.png create mode 100644 sources/templates/default/img/list/locked.png create mode 100644 sources/templates/default/img/list/move.png create mode 100644 sources/templates/default/img/list/qrcode.png create mode 100644 sources/templates/default/img/list/rename.png create mode 100644 sources/templates/default/img/list/renew.png create mode 100644 sources/templates/default/img/list/shared_folder.png create mode 100644 sources/templates/default/img/list/trash.png create mode 100644 sources/templates/default/img/list/users.png create mode 100644 sources/templates/default/img/player-graphics.png create mode 100644 sources/templates/default/img/stats/trash.png create mode 100644 sources/templates/default/img/video.png create mode 100644 sources/templates/default/info.md create mode 100644 sources/templates/default/login.php create mode 100644 sources/templates/default/stats.php create mode 100644 sources/templates/default/templates/dialog_delete.html create mode 100644 sources/templates/default/templates/dialog_download_url.html create mode 100644 sources/templates/default/templates/dialog_link.html create mode 100644 sources/templates/default/templates/dialog_move.html create mode 100644 sources/templates/default/templates/dialog_new_folder.html create mode 100644 sources/templates/default/templates/dialog_password.html create mode 100644 sources/templates/default/templates/dialog_qrcode.html create mode 100644 sources/templates/default/templates/dialog_rename.html create mode 100644 sources/templates/default/templates/dialog_share.html create mode 100644 sources/templates/default/templates/lightbox.html create mode 100644 sources/templates/default/templates/links_file_icon.html create mode 100644 sources/templates/default/templates/links_file_list.html create mode 100644 sources/templates/default/templates/links_folder_icon.html create mode 100644 sources/templates/default/templates/links_folder_list.html create mode 100644 sources/templates/default/templates/links_image_icon.html create mode 100644 sources/templates/default/templates/links_image_list.html create mode 100644 sources/templates/default/templates/move_file_icon.html create mode 100644 sources/templates/default/templates/move_file_list.html create mode 100644 sources/templates/default/templates/move_folder_icon.html create mode 100644 sources/templates/default/templates/move_folder_list.html create mode 100644 sources/templates/default/templates/move_image_icon.html create mode 100644 sources/templates/default/templates/move_image_list.html create mode 100644 sources/templates/default/templates/read_m3u.html create mode 100644 sources/templates/default/templates/view_file_icon.html create mode 100644 sources/templates/default/templates/view_file_list.html create mode 100644 sources/templates/default/templates/view_folder_icon.html create mode 100644 sources/templates/default/templates/view_folder_list.html create mode 100644 sources/templates/default/templates/view_image_icon.html create mode 100644 sources/templates/default/templates/view_image_list.html create mode 100644 sources/templates/default/templates/view_shared_folder_icon.html create mode 100644 sources/templates/default/templates/view_shared_folder_list.html create mode 100644 sources/templates/default/users.php diff --git a/README.md b/README.md index c81af09..46c8c1c 100644 --- a/README.md +++ b/README.md @@ -1 +1,4 @@ -# bozon_ynh \ No newline at end of file +# BoZoN package for YunoHost + +* [BoZoN website](http://bozon.pw) +* [YunoHost website](https://yunohost.org/) diff --git a/conf/nginx.conf b/conf/nginx.conf new file mode 100644 index 0000000..074f145 --- /dev/null +++ b/conf/nginx.conf @@ -0,0 +1,23 @@ +location YNH_EXAMPLE_PATH { + # Path to source + alias YNH_EXAMPLE_ALIAS ; + if ($scheme = http) { + rewrite ^ https://$server_name$request_uri? permanent; + } + client_max_body_size 10G; + # Example PHP configuration + index index.php; + try_files $uri $uri/ index.php; + location ~ [^/]\.php(/|$) { + fastcgi_split_path_info ^(.+?\.php)(/.*)$; + fastcgi_pass unix:/var/run/php5-fpm.sock; + fastcgi_index index.php; + include fastcgi_params; + fastcgi_param REMOTE_USER $remote_user; + fastcgi_param PATH_INFO $fastcgi_path_info; + fastcgi_param SCRIPT_FILENAME $request_filename; + } + + # Include SSOWAT user panel. + include conf.d/yunohost_panel.conf.inc; +} diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..f4e928c --- /dev/null +++ b/manifest.json @@ -0,0 +1,80 @@ +{ + "name": "BoZoN", + "id": "bozon", + "description": { + "en": "Minimalist Drag & drop file sharing app", + "fr": "Application minimaliste de partage de fichiers" + }, + "url": "http://bozon.pw", + "license": "free", + "developer": { + "name": "ewilly", + "email": "ewilly@neuf.fr" + }, + "multi_instance": "false", + "services": [ + "nginx", + "php5-fpm" + ], + "arguments": { + "install" : [ + { + "name": "domain", + "type": "domain", + "ask": { + "en": "Choose a domain for BoZoN", + "fr": "Choisissez un domaine pour BoZoN" + }, + "example": "domain.org" + }, + { + "name": "path", + "type": "path", + "ask": { + "en": "Choose a path for BoZoN", + "fr": "Choisissez un chemin pour BoZoN" + }, + "example": "/bozon", + "default": "/bozon" + }, + { + "name": "admin", + "type": "user", + "ask": { + "en": "Choose an admin user for BoZoN", + "fr": "Choisissez un administrateur pour BoZoN" + }, + "example": "homer" + }, + { + "name": "password", + "type": "password", + "ask": { + "en": "Choose an admin password for BoZoN", + "fr": "Choisissez un mot de passe administrateur pour BoZoN" + }, + "example": "super_secret_password" + }, + { + "name": "public_site", + "ask": { + "en": "Should this application be public ?", + "fr": "Est-ce que cette application doit être visible publiquement ?" + }, + "choices": ["Yes", "No"], + "default": "Yes" + }, + { + "name": "default_lang", + "ask": { + "en": "Default language", + "fr": "Langue par défaut" + }, + "choices": ["de","en","es","fr","it","nl","pl","pt","po","ro","ru"], + "default": "en" + } + + + ] + } +} diff --git a/scripts/backup b/scripts/backup new file mode 100644 index 0000000..74de43b --- /dev/null +++ b/scripts/backup @@ -0,0 +1,19 @@ +#! /bin/bash + +# causes the shell to exit if any subcommand or pipeline returns a non-zero status +set -e + +app=bozon +app_path=/var/www/$app +data_path=/home/yunohost.app/$app +save_path=$1 + +# Backup sources & data + sudo mkdir -p $save_path/data + sudo cp -R $app_path $save_path + sudo cp -R $data_path $save_path/data + +# Copy Nginx and YunoHost parameters to make the script "standalone" + sudo cp -a /etc/yunohost/apps/$app/. save_path/yunohost + domain=$(sudo yunohost app setting $app domain) + sudo cp -a /etc/nginx/conf.d/$domain.d/$app.conf save_path/nginx.conf diff --git a/scripts/install b/scripts/install new file mode 100644 index 0000000..6dd9895 --- /dev/null +++ b/scripts/install @@ -0,0 +1,109 @@ +#! /bin/bash + +app=bozon + +#retrieve arguments +domain=$1 +path=$2 +admin=$3 +password=$4 +is_public=$5 +default_lang=$6 + +# Remove trailing slash +[ "$path" != "/" ] && path=${path%/} + +# Check domain/path availability +sudo yunohost app checkurl $domain$path -a $app +if [[ ! $? -eq 0 ]]; then + exit 1 +fi + +# Check user +sudo yunohost user list --json | grep -q "\"username\": \"$admin\"" +if [[ ! $? -eq 0 ]]; then + echo "Wrong user" + exit 1 +fi + +# Save app settings +sudo yunohost app setting $app admin -v "$admin" +sudo yunohost app setting $app is_public -v "$is_public" +sudo yunohost app setting $app domain -v "$domain" +sudo yunohost app setting $app path -v "$path" + +#create path for copying +final_path=/var/www/$app +sudo mkdir -p $final_path +data_path=/home/yunohost.app/$app +sudo mkdir -p $data_path + +#copy files to final folder and set permissions +sudo cp -R ../sources/* $final_path/ +sudo find $final_path -type f -name ".htaccess" | xargs sudo rm + +#setup permissions +sudo chown -R root: $final_path +sudo find $final_path -type f | xargs sudo chmod 644 +sudo find $final_path -type d | xargs sudo chmod 755 +sudo chown -R www-data: $data_path +sudo find $data_path -type f | xargs sudo chmod 644 +sudo find $data_path -type d | xargs sudo chmod 755 + +#configure nginx settings +folder_path=${path%/} +sudo sed -i "s@YNH_EXAMPLE_PATH@$path@g" ../conf/nginx.conf +# If path is only / (without subfolder), add trailing slash to alias +alias_path=$final_path +[ "$path" == '/' ] && alias_path=$alias_path'/' +sudo sed -i "s@YNH_EXAMPLE_ALIAS@$alias_path@g" ../conf/nginx.conf +sudo sed -i "s@YNH_EXAMPLE_FOLDER@$folder_path@g" ../conf/nginx.conf +sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf + +#temporary set public accessible +sudo yunohost app setting $app unprotected_uris -v "/" + +# Restart services +sudo service nginx reload +sudo yunohost app ssowatconf + +#temporary add domain name to /etc/hosts +sudo sed -i "1 i\127.0.0.1 $domain #bozon_hosts" /etc/hosts + +#make request to install app +#get the html page +curl_path=$([ "$path" == "/" ] || echo $path) +#curl -kL -o install_page.html https://$domain$curl_path/index.php?p=admin >/dev/null 2>&1 + + +#get the token for form validation +#token=$(cat install_page.html | grep "input" | grep "token" | tail -1 | cut -d' ' -f3 | cut -d'"' -f2) +#send http POST values +#curl -k -X POST \ + --data-urlencode "default_lang=$default_lang" \ + --data-urlencode "install=Installer" \ + --data-urlencode "name=$admin" \ + --data-urlencode "login=$admin" \ + --data-urlencode "pwd=$password" \ + --data-urlencode "pwd2=$password" \ + --data-urlencode "token=$token" \ + https://$domain$curl_path/index.php?p=admin > /dev/null 2>&1 + +#remove domain name from /etc/hosts +sudo sed -i "/#bozon_hosts/d" /etc/hosts + +# If app is private, remove url to SSOWat conf from skipped_uris +if [ "$is_public" = "No" ]; +then + sudo yunohost app setting $app unprotected_uris -d +fi + +#adding admin to the allowed users +sudo yunohost app addaccess $app -u $admin + +#allow only allowed users to access admin panel +#sudo yunohost app setting bozon protected_uris -v "/core/admin/" + +# Restart services +sudo service nginx reload +sudo yunohost app ssowatconf diff --git a/scripts/remove b/scripts/remove new file mode 100644 index 0000000..496b789 --- /dev/null +++ b/scripts/remove @@ -0,0 +1,8 @@ +#! /bin/bash + +app=bozon +domain=$(sudo yunohost app setting $app domain) + +sudo rm -rf /var/www/$app +sudo rm -rf /home/yunohost.app/$app +sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf diff --git a/scripts/restore b/scripts/restore new file mode 100644 index 0000000..7ed81fa --- /dev/null +++ b/scripts/restore @@ -0,0 +1,11 @@ +#! /bin/bash + +app=bozon +app_path=/var/www/$app +data_path=/home/yunohost.app/$app +save_path=$1 + +sudo mv $save_path $app_path +sudo mv $app_path/data $data_path +sudo rm -rf $app_path/data +sudo chown -R www-data: $data_path diff --git a/scripts/upgrade b/scripts/upgrade new file mode 100644 index 0000000..8b759ed --- /dev/null +++ b/scripts/upgrade @@ -0,0 +1,41 @@ +#! /bin/bash + +app=bozon + +#retrieve arguments +domain=$(sudo yunohost app setting $app domain) +path=$(sudo yunohost app setting $app path) +admin=$(sudo yunohost app setting $app admin) +is_public=$(sudo yunohost app setting $app is_public) + + +# Remove trailing "/" for next commands +path=${path%/} + +# Copy source files +final_path=/var/www/$app +sudo mkdir -p $final_path +sudo cp -a ../sources/* $final_path +sudo find $final_path -type f -name ".htaccess" | xargs sudo rm +sudo rm $final_path/install.php + +sudo chown -R root: $final_path +sudo chown -R www-data: $final_path/data +sudo find $final_path -type f | xargs sudo chmod 644 +sudo find $final_path -type d | xargs sudo chmod 755 + + +#configure nginx settings +sudo sed -i "s@YNH_EXAMPLE_PATH@$path@g" ../conf/nginx.conf +sudo sed -i "s@YNH_EXAMPLE_ALIAS@$final_path@g" ../conf/nginx.conf +sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf + +# If app is public, add url to SSOWat conf as skipped_uris +if [ "$is_public" = "Yes" ]; +then + sudo yunohost app setting $app unprotected_uris -v "/" +fi + +# Restart services +sudo service nginx reload +sudo yunohost app ssowatconf diff --git a/sources/LICENCE.md b/sources/LICENCE.md new file mode 100644 index 0000000..6b80c84 --- /dev/null +++ b/sources/LICENCE.md @@ -0,0 +1,201 @@ + + Copyright (C) 2016 bronco@warriordudimanche.net + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + + + +#GNU AFFERO GENERAL PUBLIC LICENSE + +##Version 3, 19 November 2007 + +###Copyright © 2007 Free Software Foundation, Inc. +Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. + +##Preamble + +The GNU Affero General Public License is a free, copyleft license for software and other kinds of works, specifically designed to ensure cooperation with the community in the case of network server software. + +The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, our General Public Licenses are intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. + +When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. + +Developers that use our General Public Licenses protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License which gives you legal permission to copy, distribute and/or modify the software. + +A secondary benefit of defending all users' freedom is that improvements made in alternate versions of the program, if they receive widespread use, become available for other developers to incorporate. Many developers of free software are heartened and encouraged by the resulting cooperation. However, in the case of software used on network servers, this result may fail to come about. The GNU General Public License permits making a modified version and letting the public access it on a server without ever releasing its source code to the public. + +The GNU Affero General Public License is designed specifically to ensure that, in such cases, the modified source code becomes available to the community. It requires the operator of a network server to provide the source code of the modified version running there to the users of that server. Therefore, public use of a modified version, on a publicly accessible server, gives the public access to the source code of the modified version. + +An older license, called the Affero General Public License and published by Affero, was designed to accomplish similar goals. This is a different license, not a version of the Affero GPL, but Affero has released a new version of the Affero GPL which permits relicensing under this license. + +The precise terms and conditions for copying, distribution and modification follow. + +##TERMS AND CONDITIONS + +0. Definitions. +"This License" refers to version 3 of the GNU Affero General Public License. + +"Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. + +"The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. + +To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. + +A "covered work" means either the unmodified Program or a work based on the Program. + +To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. + +To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. + +An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. + +1. Source Code. +The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. + +A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. + +The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. + +The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. + +The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. + +The Corresponding Source for a work in source code form is that same work. + +2. Basic Permissions. +All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. + +You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. + +Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. + +3. Protecting Users' Legal Rights From Anti-Circumvention Law. +No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. + +When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. + +4. Conveying Verbatim Copies. +You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. + +You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. + +5. Conveying Modified Source Versions. +You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: + +a) The work must carry prominent notices stating that you modified it, and giving a relevant date. +b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". +c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. +d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. +A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. + +6. Conveying Non-Source Forms. +You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: + +a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. +b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. +c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. +d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. +e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. +A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. + +A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. + +"Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. + +If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). + +The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. + +Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. + +7. Additional Terms. +"Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. + +When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. + +Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: + +a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or +b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or +c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or +d) Limiting the use for publicity purposes of names of licensors or authors of the material; or +e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or +f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. +All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. + +If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. + +Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. + +8. Termination. +You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). + +However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. + +Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. + +Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. + +9. Acceptance Not Required for Having Copies. +You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. + +10. Automatic Licensing of Downstream Recipients. +Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. + +An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. + +You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. + +11. Patents. +A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". + +A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. + +Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. + +In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. + +If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. + +If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. + +A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. + +Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. + +12. No Surrender of Others' Freedom. +If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. + +13. Remote Network Interaction; Use with the GNU General Public License. +Notwithstanding any other provision of this License, if you modify the Program, your modified version must prominently offer all users interacting with it remotely through a computer network (if your version supports such interaction) an opportunity to receive the Corresponding Source of your version by providing access to the Corresponding Source from a network server at no charge, through some standard or customary means of facilitating copying of software. This Corresponding Source shall include the Corresponding Source for any work covered by version 3 of the GNU General Public License that is incorporated pursuant to the following paragraph. + +Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the work with which it is combined will remain governed by version 3 of the GNU General Public License. + +14. Revised Versions of this License. +The Free Software Foundation may publish revised and/or new versions of the GNU Affero General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU Affero General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU Affero General Public License, you may choose any version ever published by the Free Software Foundation. + +If the Program specifies that a proxy can decide which future versions of the GNU Affero General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. + +Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. + +15. Disclaimer of Warranty. +THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + +16. Limitation of Liability. +IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +17. Interpretation of Sections 15 and 16. +If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. + +END OF TERMS AND CONDITIONS \ No newline at end of file diff --git a/sources/changelog.md b/sources/changelog.md new file mode 100644 index 0000000..0bdb464 --- /dev/null +++ b/sources/changelog.md @@ -0,0 +1,131 @@ + +# Version history +## New in 2.4 +- optimisation : reduce slow down when folder tree contains a huge amount of files (tested with more than 30,000 files ^^ thx to Cyrille) +- optimisation : reduce regen base use to reduce useless files scans (even for zip to folder option) +- Added : volume option for playlist +- Enhancement : unzipping file on server creates a new folder +- Added : zip and download selection of files and folders +- Added : in public access to a folder can now fold/unfold the folders. +- Added : a regen base button for the admins who use FTP access instead of the bozon's upload (adds the new IDs, removes the old one and rebuilds the tree) +- Added : a temp cleaning procedure +- Added : a $default_temp_folder variable in config.php +- Added : a load more button in admin list files (for those who save thousands of files in the same directory ^^ wink to Cyrille (again)) +- Added : a config variable to choose between two click on file options. +- Enhancement : change some js functions to use my own vanillajs lib +- Enhancement : share button will no longer appear when there's only one user +- Enhancement : Some little changes in the design +- Bugfix : the locked folder now works again correctly +- Added : language choice is now saved in the user profile +- Added : three status for users (admin/user/guest). The first user created is now superadmin. +- Enhancement : the drag and drop fallback now accepts multiselection +- Added : a markdown editor to quickly create a new document and share it or edit a text file (still a beta feature but it works) +- Enhancement : users page is now available only if there's more than one user +- Enhancement : users page design +- Enhancement : change png icons to webfont (thx fontello ^^) 56k -> 9k \o/ +- Enhancement : change users management page (tabs instead of dialog boxes) +- Added : Superadmin can now change the user's password +- Added : brand new profiles rights managing; now, you can create new profiles and allow acces to specific parts of the app to those profiles. +- Added : . and .. in file list +- Added : download a zip from a shared folder on visitor's access +- Added : config variable to allow or not rss/json/download from user shared access +- Added : warnings if required libs are not installed; however, bozon can work without those libs (some functions will be disabled) and if you want to disable those warnings, go to config.php and set $disable_non_installed_libs_warning to true +- Bugfix : encoding accents problems +- Bugfix : refresh needed when adding or deleting a user +- Added : config variable to use lightbox or new tab to open images/txt etc +- Enhancement : lightbox +- Bugfix : shared links works again +- Enhancement/Bugfix : when you renew a shared folder id, the id will change in the shared file or will be removed from it (see $remove_item_from_users_share_when_renew_id in config.php) + + +## New in 2.3b +- Added : folder size limit for users (if there's no limit, the free space icon will not display) +- Added : display free space in user's folder (this information will not display if admin or if allowed free space is set to 0) +- Added : display folder size +- Added : lazy load for gallery http://dinbror.dk/blazy/ +- Added : a minimalist lightbox +- Bugfixes : links lost when moving a file/folder, video name in gallery mode... +- Enhancement : brand new html/css structure by Eauland. +- Enhancement : new table based file list +- Added : some information on homepage +- Added : qrcode on share page +- Added : playlist audio. If a folder only contains mp3/ogg, it'll be shared as a playlist +- Added : a shortcut to share link in links mode +- Added : an icon to go directly to a gallery or a playlist in file mode +- Changed : the dropzone is now hidden by default: click on upload button or drag a file on it to reveal the dropzone +- Added : an option to easily change the colors: just change the values in template/default/css/styles.php ! +- Changed : color +- Removed : old time forgotten javascript in stats.php +- Added : scrolltotop from Cyril MAGUIRE +- Added : download from url allows to specify a local filename +- Added : a required state for important fields in dialog boxes +- Bugfix : remove exif error on thumb generation +- Added : sorting filelist by name or size +- Enhancement : A burn mode id stays in burn mode when accessed by the connected owner (id will be burned only if not connected or not owner) +- Bugfix : security bug +- Added : multiselection to delete files/folders + +## New in 2.2beta +- Added : double check for the password on profile creation +- Added : password change for user connected +- Added : markdown display for md files +- Added : qrcode to easily get a share on smartphone +- Added : secured rss feed for log file +- Added : share folders between users \o/ +- Added : changes on files/folders only allowed to the owner +- Bugfixes: htaccess problems, catching distant file path problem, some css problems + +## New in 2.1 +### /!\ Read carefully to avoid data loss ! +- added a top bar menu +- added a minimalist auto gallery function: when a folder contains only images, it will be displayed as a gallery for the user. +- bug fix on rss feed and share links +- Added multiuser capacity ! Now, the admin (the first user) can create new users. Each user has his own separated upload folder. +- Added a import script: beacause of multiuser change, the ID file, the upload folder, the users data has a new format... +If you're upgrading from 2.0 or less, keep only private and upload folders, install bozon. +When you first start, it will ask you if you want to import previous data. + +## New in 2.0 beta +- major changes in bozon's structure: all is called from index page +- real home page +- major design improvements: lighter, no more menu etc. +- bugfixes +- all pages'files are now in the template folder (easier to modify) +- html files replace the variable template (easier for designers ;-) +- language files are now seperated in a locale folder +- language can now also be changed in user mode (not only admin) +- default language: set at browser default if not specified in config + +## New in 1.7.5b +- added a function to erase no longuer used ids +- bugfix with file with accent on first char: a basename function bug ! oO + +## New in 1.7.5 +- change in the templates: templates are now html files, easier to modify +- added the mode in the file list's title. + + +## New in 1.7.4 +bug fixes (thx to chatainsim on Github) +- #56: problem deleting a folder +- #53: error deleting files you just uploaded +- #55: password protection problem when a password is used for several files (caution, this fix is not compatible with old password protection) +- disapearing files and folders until page is refreshed. +- my blog's URL removed (too «hasbeen»: wink to eauland ;-) + + +## New in 1.7.3 +- some bugs fixed (rename bug, home icon bug) +- little changes on resolutions below 600 (switch from icon to list view) +- added handheld rule for media queries + + +## New in 1.7.2 +- new list layout (change layout in config or in menu) +- change theme with get variable theme=xxx +- + +## New in 1.7 +* serious security enhancement by Oros ( https://www.ecirtam.net / https://github.com/Oros42 ) (Thanks a lot for this huge job !) +* add: a link to clear stats +* BEWARE! Because of the new data & files structure, all previous generated IDs will no longer be valid. diff --git a/sources/config.php b/sources/config.php new file mode 100644 index 0000000..6d2eaba --- /dev/null +++ b/sources/config.php @@ -0,0 +1,55 @@ + \ No newline at end of file diff --git a/sources/contributors.md b/sources/contributors.md new file mode 100644 index 0000000..548f8e1 --- /dev/null +++ b/sources/contributors.md @@ -0,0 +1,9 @@ +## Contributors + +- [aledeg](https://github.com/aledeg) +- [ankerfest](https://github.com/ankerfest) +- [eauland](https://github.com/eauland) +- [Oros42](https://github.com/Oros42) + +## Special thanks +- [Cyrille Borne](https://github.com/cborne) (http://www.cyrille-borne.com): without your comments, issues reporting and enhancement ideas this app would never have been so complete ;-) diff --git a/sources/core/.htaccess b/sources/core/.htaccess new file mode 100644 index 0000000..ebe8b76 --- /dev/null +++ b/sources/core/.htaccess @@ -0,0 +1,4 @@ +Order Allow,Deny + +Allow from all + diff --git a/sources/core/Array2feed.php b/sources/core/Array2feed.php new file mode 100644 index 0000000..44aa550 --- /dev/null +++ b/sources/core/Array2feed.php @@ -0,0 +1,76 @@ + array + # for rss type feed, each item must have the 'title', 'description', 'pubDate' and 'link' keys + # for atom type feed, info must have the 'title', 'id', 'updated, 'link' & 'content' keys +function makeRSSdate($date=NULL){// format DD-MM-YY HH:MM => rfc2822 (rss compatible) + if ($date){ + date_default_timezone_set('Europe/Paris'); + $time = strtotime($date); + return date("r", $time); + } +} +function no_nl($string){$tab = array( CHR(13) => " ", CHR(10) => " " ); return strtr($string,$tab); } +function array2feed($array=null){ + + + if (!$array){return false;} + if (empty($array['infos']['type'])){$array['infos']['type']='rss';}else{$array['infos']['type']=strtolower($array['infos']['type']);} + if (empty($array['infos']['description'])){$array['infos']['description']='';} + $r="\n";$t="\t"; + $tpl=array('rss'=>array(),'atom'=>array()); + $tpl['rss']['header']=''.$r.'' + .$r.$t.''.$r; + $tpl['atom']['header']=''.$r; + $tpl['rss']['footer']=$t.''.$r; + $tpl['atom']['footer']=''.$r; + $tpl['rss']['content-type']='Content-Type: application/rss+xml; charset=utf-8'; + $tpl['atom']['content-type']='Content-Type: application/atom+xml; charset=utf-8'; + + header($tpl[$array['infos']['type']]['content-type']); + $feed=$tpl[$array['infos']['type']]['header']; + //create the feed's info content + foreach($array['infos'] as $key=>$value){ + if ($array['infos']['type']=='atom'){ // ATOM + if ($key=='link'){$feed.=$t.$t.''.$r;} + elseif ($key=='author'){$feed.=$t.$t.''.$value.''.$r;} + elseif ($key=='licence'){$feed.=$t.$t.'<'.$key.' href="'.$value.'" rel="license"/>'.$r;} // in atom feed, licence is the link to the licence type + elseif ($key!='version'&&$key!='type'){$feed.=$t.$t.'<'.$key.'>'.$value.''.$r;} + }else{ // RSS + if ($key!='version'&&$key!='type'){$feed.=$t.$t.'<'.$key.'>'.$value.''.$r;} + } + } + + //then the items content + foreach ($array['items'] as $item){ + if ($array['infos']['type']=='atom'){ $feed.=$t.$t.$t.''.$r;}else{$feed.=$t.$t.$t.''.$r;} + foreach($item as $key=>$value){ + if ($array['infos']['type']=='atom'){ // ATOM + if ($key=='link'){$feed.=$t.$t.$t.$t.''.$r;} + elseif ($key=='content'){$feed.=$t.$t.$t.$t.''.htmlspecialchars($value).''.$r;} + elseif (!empty($value)){$feed.=$t.$t.$t.$t.'<'.$key.'>'.no_nl($value).''.$r;} + }else{ // RSS + if ($key=='pubDate'||$key=='title'||$key=='link'){$feed.=$t.$t.$t.$t.'<'.$key.'>'.htmlspecialchars($value).''.$r;} + elseif ($key=='date'){} + elseif($key=='guid'){ $feed.=$t.$t.$t.$t.''.$r;} + elseif(!empty($value)){$feed.=$t.$t.$t.$t.'<'.$key.'>'.$r;} + } + } + if ($array['infos']['type']=='atom'){ $feed.=$t.$t.$t.''.$r;}else{$feed.=$t.$t.$t.''.$r;} + } + + + $feed.=$tpl[$array['infos']['type']]['footer']; + echo $feed; +} +?> \ No newline at end of file diff --git a/sources/core/GET_POST_admin_data.php b/sources/core/GET_POST_admin_data.php new file mode 100644 index 0000000..c053fce --- /dev/null +++ b/sources/core/GET_POST_admin_data.php @@ -0,0 +1,367 @@ +'.$file.' '.e('is not writable',false).'';} + } + } + + # regen tree + if (isset($_GET['regen'])){ + $ids=updateIDs($ids,$_GET['regen']); + header('location:index.php?p=admin&token='.TOKEN); + exit; + } + + # unzip: convert zip file to folder + if (!empty($_GET['unzip']) && trim($_GET['unzip'])!==false && $_SESSION['zip']){ + $id=$_GET['unzip']; + $zipfile=id2file($id); + $folder=str_ireplace('.zip','',_basename($zipfile)); + $id=new_folder($folder); + $destination=id2file($id); + unzip($zipfile,$destination); + $sdi=array_flip($ids); + $unzipped_content=recursive_glob($destination); + foreach ($unzipped_content as $item){ + if (empty($sdi[$item])){$ids[uniqid(true)]=$item;} + } + store($ids); + //$ids=updateIDs($ids,$id); + header('location:index.php?p=admin&token='.TOKEN); + exit; + } + + # renew file id + if (!empty($_GET['renew']) && trim($_GET['renew'])!==false&&is_owner($_GET['renew'])){ + $old_id=$_GET['renew']; + $path=id2file($old_id); + unset($ids[$old_id]); + $new_id=addID($path,$ids); + # change in share folder + + if (is_dir($path)){ + $shares=load_folder_share(); + $save=false; + foreach ($shares as $user=>$data){ + if (!empty($data[$old_id])){ + if (!$remove_item_from_users_share_when_renew_id){ + $shares[$user][$new_id]=$data[$old_id]; + } + unset($shares[$user][$old_id]);$save=true; + } + } + if ($save){save_folder_share($shares);} + } + header('location:index.php?p=admin&token='.TOKEN); + exit; + } + + # create burn after acces state + if (!empty($_GET['burn']) && trim($_GET['burn'])!==false&&is_owner($_GET['burn'])){ + $id_to_burn=$_GET['burn']; + $path=id2file($id_to_burn); + unset($ids[$id_to_burn]); + if ($id_to_burn[0]!='*'){ + $ids['*'.$id_to_burn]=$path; + }else{ + $ids[str_replace('*','',$id_to_burn)]=$path; + } + store($ids); + header('location:index.php?p=admin&token='.TOKEN); + exit; + } + + # subfolder path + if (!empty($_GET['path']) && trim($_GET['path'])!==false){ + $path=$_GET['path']; + if($path=='/'){ + $path=''; + } + if(check_path($path)){ + $_SESSION['current_path']=$path; + } + header('location:index.php?p=admin&token='.TOKEN); + exit; + } + + # search/filter + if (!empty($_GET['filter'])){ + $_SESSION['filter']=$_GET['filter']; + }else{ + $_SESSION['filter']=''; + } + + # file mode + if (!empty($_GET['mode'])){ + $_SESSION['mode']=$_GET['mode']; + }elseif (empty($_SESSION['mode'])){ + $_SESSION['mode']='view'; + } + + # create a new subfolder + if (!empty($_GET['newfolder'])){ + $folder=$_GET['newfolder']; + if(check_path($folder)){ + $tree=add_branch($folder,new_folder($folder)); # $path,$id + header('location:index.php?p=admin&msg='.$folder.' '.e('created',false).'&token='.TOKEN); + exit; + } + + } + + # get file from url + if (!empty($_GET['url'])&&$_GET['url']!='' && $_SESSION['curl']){ + if ($content=file_curl_contents($_GET['url'])){ + if (empty($_GET['filename'])){ + $basename=_basename($_GET['url']); + }else{ + $basename=no_special_char($_GET['filename']); + } + + $folder_path=$_SESSION['upload_root_path'].$_SESSION['upload_user_path'].$_SESSION['current_path'].'/'; + $filename=$folder_path.$basename; + if(is_file($filename)){ + $filename=$folder_path.rename_item($filename,$folder_path); + } + file_put_contents($filename,$content); + + $tree=add_branch($filename,addID($filename)); + header('location:index.php?p=admin&token='.TOKEN); + exit; + }else{$message.='
'.e('Problem accessing remote file.',false).'
';} + } + + # delete SINGLE file/folder + if (!empty($_GET['del'])&&$_GET['del']!=''&&is_owner($_GET['del'])){ + $tree=delete_file_or_folder($_GET['del'],$ids,$tree); + header('location:index.php?p=admin&token='.TOKEN); + exit; + } + + # rename file/folder + if (!empty($_GET['id'])&&!empty($_GET['newname'])&&is_owner($_GET['id'])){ + $oldfile=id2file($_GET['id']); + $path=dirname($oldfile).'/'; + $newfile=$path.no_special_char($_GET['newname']); + if ($newfile!=$oldfile && check_path($newfile)){ + # if newname exists, change newname + if(is_file($newfile) || is_dir($newfile)){aff($newfile.' '.$oldfile); + $newfile=$path.rename_item(_basename($newfile),$path); + } + if (is_dir($oldfile)){ + # for folders, must change the path in all sub items + $old=$oldfile; + $old.='/'; + foreach($ids as $id=>$path){ + if (strpos($path,$old)!==false){$ids[$id]=str_replace($old, $newfile.'/', $path);} + } + + }; + $ids[$_GET['id']]=$newfile; + store($ids); + rename($oldfile,$newfile); + if (is_file(get_thumbs_name($oldfile))){rename(get_thumbs_name($oldfile),get_thumbs_name($newfile));} + $tree=rename_branch($newfile,$oldfile,$_GET['id'],$_SESSION['login'],$tree); + } + + header('location:index.php?p=admin&token='.TOKEN); + exit; + } + + # zip and download a folder + if (!empty($_GET['zipfolder']) && $_SESSION['zip']){ + $folder=id2file($_GET['zipfolder']); + if (!is_dir($_SESSION['temp_folder'])){mkdir($_SESSION['temp_folder']);} + $zipfile=$_SESSION['temp_folder'].return_owner($_GET['zipfolder']).'-'._basename($folder).'.zip'; + zip($folder,$zipfile); + header('location: '.$zipfile); + exit; + } + + ###################################################################### + # $_POST DATA + ###################################################################### + # Move file folder + if (!empty($_POST['file'])&&!empty($_POST['destination'])){ + # init + $destination=$to=$_POST['destination']; + $file=$_POST['file'];$me=_basename($file); + if($destination=='/'){ $destination=''; } + if($file=='/'){ $file=''; } + $file_with_path=$_SESSION['upload_root_path'].$_SESSION['upload_user_path'].$file; + $destination=$_SESSION['upload_root_path'].$_SESSION['upload_user_path'].$destination; + + if (check_path($file) && check_path($destination)){ + if (is_file($file_with_path)){$file=$file_with_path;} + $file=$file_with_path; + $file=stripslashes($file); + $destination_temp = addslash_if_needed($destination)._basename($file); + # if file/folder exists in destination folder, change name + if(is_file($destination_temp) || is_dir($destination_temp)){ + $destination_temp=addslash_if_needed($destination).rename_item(_basename($file),$destination); + } + $destination=$destination_temp; + + if (!is_dir(dirname('thumbs/'.$destination))){ + mkdir(dirname('thumbs/'.$destination),0744, true); + } + @rename(get_thumbs_name($file_with_path),get_thumbs_name($destination)); + + if (is_file($file_with_path)){ + # change path in id + $id=file2id($file_with_path); + $ids=unstore(); + $ids[$id]=$destination; + store($ids); + rename($file_with_path,$destination); + $tree=rename_branch($destination,$file_with_path,$id,$_SESSION['login'],$tree); + }elseif(is_dir($file_with_path)){ + # change path in id and all files/folders in the moved folder + $id=file2id($file_with_path); + $ids=unstore(); + $ids[$id]=$destination; + $destination=$destination.'/'; + $file=$file.'/'; + foreach($ids as $id=>$path){ + if (strpos($path, $file)!==false){$ids[$id]=str_replace($file,$destination, $path);} + } + store($ids); + rename($file_with_path,$destination); + $tree=rename_branch($destination,$file_with_path,$id,$_SESSION['login'],$tree); + } + + } + + header('location:index.php?p=admin&msg='.$me.' '.e('moved to',false).' '.$to.'&token='.TOKEN); + exit; + } + + # Delete multiselection + if (!empty($_POST['item']) && !empty($_POST['multiselect_command']) && $_POST['multiselect_command']=='delete'){ + foreach ($_POST['item'] as $key => $item) { + if (is_owner($item)){ + $tree=delete_file_or_folder($item,$ids); + } + } + header('location:index.php?p=admin&token='.TOKEN); + exit; + } + + # zip multiselection + if (!empty($_POST['item']) && !empty($_POST['multiselect_command']) && $_POST['multiselect_command']=='zip' && $_SESSION['zip']){ + $zipfile=$_SESSION['temp_folder'].'Bozon_pack'.date('d-m-Y h-i-s').'.zip'; + $file_list=array(); + foreach ($_POST['item'] as $key => $item) { + $file_list[]=id2file($item); + } + if (!is_dir($_SESSION['temp_folder'])){mkdir($_SESSION['temp_folder']);} + zip($file_list,$zipfile); + header('location: '.$zipfile); + exit; + } + + # Lock folder with password + if (!empty($_POST['password'])&&!empty($_POST['id'])&&is_owner($_POST['id'])){ + $id=$_POST['id']; + $file=id2file($id); + $password=blur_password($_POST['password']); + # turn normal share id into password hashed id + $ids=unstore(); + unset($ids[$id]); + $ids[$password.$id]=$file; + store($ids); + + header('location:index.php?p=admin&token='.TOKEN); + exit; + } + + # Handle folder share with users + if (!empty($_GET['users'])&&!empty($_GET['share'])&&is_owner($_GET['share'])){ + $folder_id=$_GET['share']; + $users=$auto_restrict['users']; + unset($users[$_SESSION['login']]); + $shared_with=load_folder_share(); + $sent=array_flip($_GET['users']); + foreach ($users as $login=>$data){ + if (isset($sent[$login])){ + # User checked: add share + $shared_with[$login][$folder_id]=array('folder'=>id2file($folder_id),'from'=>$_SESSION['login']); + }else{ + # User not checked: remove share if exists + if (isset($shared_with[$login][$folder_id])){unset($shared_with[$login][$folder_id]);} + } + } + save_folder_share($shared_with); + header('location:index.php?p=admin&token='.TOKEN); + exit; + } + + # Handle users rights + if (isset($_POST['user_right'])&&is_allowed('change status rights')){ + foreach($_POST['user_right'] as $key=>$user_nb){ + $users_rights[$_POST['user_name'][$key]]=$user_nb; + } + save_users_rights($users_rights); + header('location:index.php?p=users&token='.TOKEN.'&msg='.e('Changes saved',false)); + exit; + } + + # Handle superadmin request for users pass change + if (isset($_POST['user_pass'])&&is_allowed('change passes')){ + foreach($_POST['user_pass'] as $key=>$pass){ + if (!empty($_POST['user_pass'][$key])&&!empty($_POST['user_name'][$key])){ + $auto_restrict['users'][$_POST['user_name'][$key]]['pass'] = hash('sha512', $auto_restrict['users'][$_POST['user_name'][$key]]['salt'].$pass); + } + } + save_users(); + header('location:index.php?p=edit_profiles&token='.TOKEN.'&msg='.e('Changes saved',false)); + exit; + } + + # Handle profile's rights change + if (isset($_POST['profile_name'])&&is_allowed('change user status')){ + $rights=array(); + foreach($_POST['profile_name'] as $num=>$profile){ + if (!empty($_POST[$num])){ + foreach($_POST[$num] as $allowed){$rights[$profile][$allowed]=1;} + }else{$rights[$profile]=array();} + } + save($_SESSION['profiles_rights_file'],$rights); + header('location:index.php?p=edit_profiles&token='.TOKEN.'&msg='.e('Changes saved',false)); + exit; + } + + # Editor + if (isset($_POST['editor_content'])&&!empty($_POST['editor_filename'])&&is_allowed('markdown editor')){ + $extension=pathinfo($_POST['editor_filename'],PATHINFO_EXTENSION); + if (empty($extension)){$_POST['editor_filename'].='.md';} + $file=no_special_char($_POST['editor_filename']); + $path=addslash_if_needed($_SESSION['upload_root_path'].$_SESSION['upload_user_path'].$_SESSION['current_path']); + if (is_file($path.$file)&&!isset($_POST['overwrite'])){$file=rename_item($file,$path);} + file_put_contents($path.$file, $_POST['editor_content']); + if (!isset($_POST['overwrite'])){ + $id=addID($path.$file); + $tree=add_branch($path.$file,$id,$_SESSION['login'],$tree); + } + header('location:index.php?p=admin&token='.TOKEN.'&msg='.$_POST['editor_filename'].' '.e('Changes saved',false)); + exit; + } + + if ($_FILES&&is_allowed('upload')){include('core/auto_dropzone.php');exit();} +?> \ No newline at end of file diff --git a/sources/core/auto_dropzone.php b/sources/core/auto_dropzone.php new file mode 100644 index 0000000..cdfa26f --- /dev/null +++ b/sources/core/auto_dropzone.php @@ -0,0 +1,469 @@ +'path/to/', + 'dropzone_text'=>'D&D here !', + 'dropzone_id'=>'drop_images', + 'dropzone_class'=>'drop_images', + 'forbidden_filetypes'=>'exe,php', + 'use_style'=>true, // false if you're using an css file + ); + + 'destination_filepath' key:'destination_filepath'=>"$_SESSION['upload_root_path']/" (with ending slash) + if not specified, the destination folder will be destination/ (created on the first start) + you also can set specific paths for each mime type like that + 'destination_filepath'=>array('gif'=>'path/to/gif/','png'=>'path/to/png/' ... ) + + 'forbidden_filetypes' key: restrict allowed filetypes (separated with ,) + ---------------------------------------------- + +* this is the default config +*/ + +// Configuration +$phpini=ini_get_all(); +$default_config=array( + 'forbidden_filetypes'=>'php', + 'allow_unknown_filetypes'=>$allow_unknown_filetypes, + 'use_style'=>false, // false if you're using a external css file + 'auto_refresh_after_upload'=>true, // auto refresh page after uploading files (except on errors) + 'max_length'=>2048, // Mo (see php.ini if changes doesn't work [post_max_size / upload_max_filesize]) + 'dropzone_text'=>e('Drop your files here or click to select a local file',false), + 'dropzone_id'=>'dropArea', + 'dropzone_class'=>'dropArea', + 'destination_filepath'=>$_SESSION['current_path'].'/', // this can be an array like 'jpg'=>'upload/jpeg/' or a string 'destination/' + 'my_filepath'=>'index.php'//$_SERVER['SCRIPT_NAME'], +); + +foreach($default_config as $key=>$val){ + // create or complete config var + if(!isset($auto_dropzone[$key])){ $auto_dropzone[$key]=$auto_dropzone[$key]=$val;} + + // has config changed ? + if (!isset($_SESSION[$key]) || $auto_dropzone[$key]!=$_SESSION[$key]){ $_SESSION[$key]=$auto_dropzone[$key];} +} + +if (!is_array($auto_dropzone['destination_filepath'])&&!is_dir($_SESSION['upload_root_path'].$_SESSION['upload_user_path'].$auto_dropzone['destination_filepath'])){ + mkdir($_SESSION['upload_root_path'].$_SESSION['upload_user_path'].$auto_dropzone['destination_filepath'],0744);file_put_contents($_SESSION['upload_root_path'].$_SESSION['upload_user_path'].$auto_dropzone['destination_filepath'].'index.html',''); +} + +// Handle the unit (M/G) in max post/upload size +$ini_max_upload=$phpini['upload_max_filesize']['global_value']; +if (strpos($ini_max_upload,'G')!=false){$ini_max_upload=intval($ini_max_upload*1024);} +else{$ini_max_upload=intval($ini_max_upload);} +$ini_max_post=$phpini['post_max_size']['global_value']; +if (strpos($ini_max_post,'G')!=false){$ini_max_post=intval($ini_max_post*1024);} +else{$ini_max_post=intval($ini_max_post);} + +$max=min($auto_dropzone['max_length'],$ini_max_upload,$ini_max_post); +$_SESSION['max_size']=$max; +$file_length_error=e('Error, max filelength:',false).' '.$max.' Mo'; +$file_format_error=e(': Error, forbidden file format !',false); + +$auto_dropzone_error=false; + +// uploading files +if (!empty($_FILES)){ + + // HANDLE UPLOAD + function bytesToSize1024($bytes, $precision = 2) { + if (!empty($bytes)){ + $unit = array('B','KB','MB'); + return @round($bytes / pow(1024, ($i = floor(log($bytes, 1024)))), $precision).' '.$unit[$i]; + }else{return false;} + } + function error2msg($e){ + if ($e>0&&$e<7){ + $errors=array( + 1=>e('The file to big for the server\'s config',false), + 2=>e('The file to big for this page',false), + 3=>e('There was a problem during upload (file was truncated)',false), + 4=>e('No file upload',false), + 5=>e('No temp folder',false), + 6=>e('Write error on server',false), + ); + return $errors[$e]; + }else if ($e>7){return true;} + else{return false;} + } + function secure($file){ + return preg_replace('#(.+)\.php#i','$1.SPHP',$file); + } + + if (isset($_FILES['myfile']) && strtolower($_FILES['myfile']['name'])!="index.html") { + $sFileName = secure($_FILES['myfile']['name']); + $sFileType = $_FILES['myfile']['type']; + $sFileSize = intval(bytesToSize1024($_FILES['myfile']['size'], 1)); + $sFileError = error2msg($_FILES['myfile']['error']); + $sFileExt = pathinfo($_SESSION['upload_root_path'].$_SESSION['upload_user_path'].$sFileName,PATHINFO_EXTENSION); + + ######################################################################### + # ADDED FOR BOZON + ######################################################################### + if (!function_exists('folder_fit')){include($path_core.'core.php');} + if (!folder_fit(null,$_FILES['myfile']['size'],$_SESSION['login'])){ + # uploaded file doesn't fit in user's folder + if (!isset($_SESSION['ERRORS'])){$_SESSION['ERRORS']='';} + $error='
  • + '.$sFileName.' + ['.$sFileType.', + '.$sFileSize.'] '.e('The file doesn\'t fit',false).' +
  • '; + $_SESSION['ERRORS'].=$error; + exit($error); + } + ######################################################################### + + $ok='
  • + '.$sFileName.' + ['.$sFileType.', + '.$sFileSize.'] [OK] +
  • '; + $notok='
  • + '.$sFileName.' + ['.$sFileType.', + '.$sFileSize.'] '.e('Upload error',false).' +
  • '; + if ( + is_array($auto_dropzone['destination_filepath']) + &&!empty($auto_dropzone['destination_filepath'][$sFileExt]) + &&is_dir($_SESSION['upload_root_path'].$_SESSION['upload_user_path'].$auto_dropzone['destination_filepath'][$sFileExt]) + ){ + $sFileName = $auto_dropzone['destination_filepath'][$sFileExt].$sFileName; + echo $ok; + rename($_FILES['myfile']['tmp_name'], $_SESSION['upload_root_path'].$_SESSION['upload_user_path'].$sFileName ); + chmod($_SESSION['upload_root_path'].$_SESSION['upload_user_path'].$sFileName,0644); + }elseif( + is_array($auto_dropzone['destination_filepath']) + &&!empty($auto_dropzone['destination_filepath'][$sFileExt]) + &&!is_dir($_SESSION['upload_root_path'].$_SESSION['upload_user_path'].$auto_dropzone['destination_filepath'][$sFileExt]) + || + is_string($auto_dropzone['destination_filepath']) + &&!is_dir($_SESSION['upload_root_path'].$_SESSION['upload_user_path'].$auto_dropzone['destination_filepath']) + ){ + //local upload dir error + echo '
  • Upload path problem with '.$sFileName.'
  • '; + + }elseif($sFileError){ + // file upload error + echo '
  • '.$sFileName.': '.$sFileError.'
  • '; + + } elseif(is_dir($_SESSION['upload_root_path'].$_SESSION['upload_user_path'].$auto_dropzone['destination_filepath'])){ + $file=$sFileName; + $sFileName = $auto_dropzone['destination_filepath'].$sFileName; + if (is_file($_SESSION['upload_root_path'].$_SESSION['upload_user_path'].$sFileName)){ + $newfilename=rename_item($file,$_SESSION['upload_root_path'].$_SESSION['upload_user_path'].$auto_dropzone['destination_filepath']); + echo '
  • '.$file.' => '.$newfilename.'
  • '; + $sFileName=$auto_dropzone['destination_filepath'].$newfilename; + } + echo $ok; + rename($_FILES['myfile']['tmp_name'], $_SESSION['upload_root_path'].$_SESSION['upload_user_path'].$sFileName ); + chmod($_SESSION['upload_root_path'].$_SESSION['upload_user_path'].$sFileName,0644); + $id=addID($_SESSION['upload_root_path'].$_SESSION['upload_user_path'].$sFileName); + $tree=add_branch($_SESSION['upload_root_path'].$_SESSION['upload_user_path'].$sFileName,$id,$_SESSION['login'],$tree); + } + } else { + echo $notok; + } + exit(); +}else{ + // GENERATE DROPZONE + if ($auto_dropzone['use_style']){ + echo ' + + '; + } +?> +
    + + + + diff --git a/sources/core/auto_restrict.php b/sources/core/auto_restrict.php new file mode 100644 index 0000000..b17c681 --- /dev/null +++ b/sources/core/auto_restrict.php @@ -0,0 +1,723 @@ + to the form or to repeat a previously generated token, in case of various forms in a same page) + * - easyly secure sensitive actions adding admin password in your form (just add , auto_restrict will exit if password is not correct) + * - secure post and get data + * - add function to ask password for sensitive/superadmin actions... + * + * + * + * Verrouille l'accès à une page + * Il suffit d'inclure ce fichier pour bloquer l'accès... + * gestion de l'expiration de session, + * gestion de la connexion et de la déconnexion. + * gestion des différences entre le domaine referer et le domaine sur lequel le script est hébergé (si différent -> pas ok) + * gestion du bannissement des adresses ip en cas de bruteforcing ou de referer anormal + * gestion des tokens de sécurisation à ajouter aux forms en une commande ; le script se charge seul de vérifier le token + * génération aléatoire de la clé de cryptage + * sécurisation par mot de passe sur les actions sensibles (il suffit d'ajouter à un formulaire pour qu'auto_restrict bloque en cas de mauvais mot de passe) + * + * Améliorations eventuelles: + * ajouter un fichier log de connexion + * + * + * ajout 4.2 : + * ajout du statut (superadmin/admin/user) et de la langue (pour bozon) + * ajout 4.1 : + * ajout du double check de passe et du changement de mdp + * ajout 4.0 : + * ajout du support multi utilisateur + */ + @session_start(); + # ------------------------------------------------------------------ + # default config: initialisation + # ------------------------------------------------------------------ + # you can modify this config before the include('auto_restrict.php'); + if (!isset($auto_restrict['error_msg'])){ $auto_restrict['error_msg']='Erreur - impossible de se connecter.';}# utilisé si on ne veut pas rediriger + if (!isset($auto_restrict['cookie_name'])){ $auto_restrict['cookie_name']='BoZoN';}# nom du cookie + if (!isset($auto_restrict['session_expiration_delay'])){ $auto_restrict['session_expiration_delay']=90;}#minutes + if (!isset($auto_restrict['cookie_expiration_delay'])){ $auto_restrict['cookie_expiration_delay']=365;}#days + if (!isset($auto_restrict['IP_banned_expiration_delay'])){ $auto_restrict['IP_banned_expiration_delay']=90;}#seconds + if (!isset($auto_restrict['max_security_issues_before_ban'])){ $auto_restrict['max_security_issues_before_ban']=5;} + if (!isset($auto_restrict['just_die_on_errors'])){ $auto_restrict['just_die_on_errors']=true;}# end script immediately instead of include loginform in case of user not logged; + if (!isset($auto_restrict['just_die_if_not_logged'])){ $auto_restrict['just_die_if_not_logged']=false;}# end script immediately instead of include loginform in case of banished ip or referer problem; + if (!isset($auto_restrict['tokens_expiration_delay'])){ $auto_restrict['tokens_expiration_delay']=7200;}#seconds + if (!isset($auto_restrict['kill_tokens_after_use'])){ $auto_restrict['kill_tokens_after_use']=false;}#false to allow the token to survive after it was used (for a form with multiple submits, like a preview button) + if (!isset($auto_restrict['use_GET_tokens_too'])){ $auto_restrict['use_GET_tokens_too']=true;} + if (!isset($auto_restrict['use_ban_IP_on_token_errors'])){ $auto_restrict['use_ban_IP_on_token_errors']=false;} + if (!isset($auto_restrict['redirect_error'])){ $auto_restrict['redirect_error']='index.php';}# si précisé, pas de message d'erreur + if (!isset($auto_restrict['redirect_success'])){ $auto_restrict['redirect_success']='index.php?p=admin&token='.returnToken();} + if (!isset($auto_restrict['domain'])){ $auto_restrict['domain']=$_SERVER['SERVER_NAME'];} + if (!isset($auto_restrict['POST_striptags'])){ $auto_restrict['POST_striptags']=false;}# if true, all $_POST data will be strip_taged + if (!isset($auto_restrict['GET_striptags'])){ $auto_restrict['GET_striptags']=false;}# if true, all $_GET data will be strip_taged + if (!isset($auto_restrict['root'])){ $auto_restrict['root']='.';} + if (!isset($auto_restrict['path_from_root'])){ $auto_restrict['path_from_root']='';} + if (!isset($auto_restrict['add_remove_user_admin_only'])){ $auto_restrict['add_remove_user_admin_only']=true;}# only admin can add or remove a user (admin is the first user) + if (!empty($_SERVER['HTTP_REFERER'])){ $auto_restrict['referer']=returndomain($_SERVER['HTTP_REFERER']);}else{$auto_restrict['referer']='';} + $auto_restrict['path_to_my_folder']=$auto_restrict['root'].$auto_restrict['path_from_root'].'/'; + $auto_restrict['path_to_files']=$auto_restrict['path_to_my_folder'].$default_private; + # ------------------------------------------------------------------ + # secure $_POST & $_GET data + # ------------------------------------------------------------------ + if ($auto_restrict['POST_striptags']){$_POST=array_map('strip_tags',$_POST);} + if ($auto_restrict['GET_striptags']){$_GET=array_map('strip_tags',$_GET);} + + # ------------------------------------------------------------------ + # create cookie token folder + # ------------------------------------------------------------------ + + if (!is_dir($auto_restrict['path_to_files'])){mkdir($auto_restrict['path_to_files'],0700);chmod($auto_restrict['path_to_files'],0700);} + if (!is_dir($auto_restrict['path_to_files'])){echo '
    auto_restrict error: cannot create the '.$auto_restrict['path_to_files'].' folder
    ';} + elseif (!is_writable($auto_restrict['path_to_files'])){echo '
    auto_restrict error: token folder is not writeable
    ';} + elseif (!is_file($auto_restrict['path_to_files'].'/.htaccess')){file_put_contents($auto_restrict['path_to_files'].'/.htaccess', 'deny from all');} + + # ------------------------------------------------------------------ + # checks auto_restrict's data file : include or create + # ------------------------------------------------------------------ + if(file_exists($auto_restrict['path_to_files'].'/auto_restrict_data.php')){ + include($auto_restrict['path_to_files'].'/auto_restrict_data.php'); + }else{ + $auto_restrict['system_salt']=generate_salt(512); + $ret="\n"; + file_put_contents($auto_restrict['path_to_files'].'/auto_restrict_data.php', ''); + } + + # ------------------------------------------------------------------ + # checks auto_restrict's users file : include or redirect to login page if no $_POST + # ------------------------------------------------------------------ + if(file_exists($auto_restrict['path_to_files'].'/auto_restrict_users.php')){ + # if file exists, include it + include($auto_restrict['path_to_files'].'/auto_restrict_users.php'); + complete_if_needed(); + + + }else if(!isset($_POST['pass'])){ + # problem with files during a session + if (isset($_SESSION['login'])){ + session_destroy(); + } + # or redirect to login form + safe_redirect('index.php?p=login'); + exit; + } + + + # ------------------------------------------------------------------ + # Sets a global token to use it later + # ------------------------------------------------------------------ + define('TOKEN',returnToken()); + + # ------------------------------------------------------------------ + # New user request: add it, save and return to login page + # ------------------------------------------------------------------ + if(!empty($_POST['pass'])&&!empty($_POST['confirm'])&&isset($_POST['creation'])&&!empty($_POST['login'])&&empty($_POST['admin_password'])){ + if (!isset($auto_restrict['users'])){$auto_restrict['users']=array();} + $index=count($auto_restrict['users']); + $login=strip_tags($_POST['login']); + if (login_exists($login)){safe_redirect('index.php?p=login&newuser&error=1&token='.returnToken());} + if ($_POST['pass']!=$_POST['confirm']){safe_redirect('index.php?p=login&newuser&error=3&token='.returnToken());} + $auto_restrict['users'][$index]['login'] = $login; + $auto_restrict['users'][$index]['encryption_key'] = md5(uniqid('', true)); + $auto_restrict['users'][$index]['salt'] = generate_salt(512); + $auto_restrict['users'][$index]['lang'] = $_SESSION['language']; + $auto_restrict['users'][$index]['status'] = ''; + $auto_restrict['users'][$index]['pass'] = hash('sha512', $auto_restrict['users'][$index]['salt'].$_POST['pass']); + + if (!save_users()){exit('
    auto_restrict: problem saving users
    ');} + safe_redirect('index.php?p=admin&msg='.e('Account created:',false).$login.'&token='.returnToken()); + exit; + } + + + # ------------------------------------------------------------------ + # Change password request + # ------------------------------------------------------------------ + if(!empty($_POST['pass'])&&!empty($_POST['confirm'])&&!empty($_POST['admin_password'])){ + + if ($auto_restrict['users'][$_SESSION['login']]['pass']!==hash('sha512', $auto_restrict['users'][$_SESSION['login']]['salt'].$_POST['admin_password'])){ + safe_redirect('index.php?p=login&change_password&error=4&token='.returnToken()); + exit; + } + if ($_POST['pass']!=$_POST['confirm']){ + safe_redirect('index.php?p=login&newuser&error=3&token='.returnToken()); + exit; + } + $auto_restrict['users'][$_SESSION['login']]['pass']=hash('sha512', $auto_restrict['users'][$_SESSION['login']]['salt'].$_POST['pass']); + if (save_users()){safe_redirect('index.php?p=admin&msg='.e('New password saved for ',false).$_SESSION['login'].'&token='.returnToken());} + else{safe_redirect('index.php?p=admin&msg='.e('Error saving new password for ',false).$_SESSION['login'].'&token='.returnToken());} + } + # ------------------------------------------------------------------ + # load banned ip + # ------------------------------------------------------------------ + if (is_file($auto_restrict['path_to_files'].'/'.$auto_restrict["banned_ip_filename"])){include($auto_restrict['path_to_files'].'/'.$auto_restrict["banned_ip_filename"]);} + # ------------------------------------------------------------------ + + # ------------------------------------------------------------------ + # user tries to login + # ------------------------------------------------------------------ + if (isset($_POST['login'])&&isset($_POST['pass'])&&empty($_POST['confirm'])&&empty($_POST['creation'])){ + $ok=log_user($_POST['login'],$_POST['pass']); + if (!$ok){safe_redirect('index.php?p=login&error=2');} + elseif (isset($_POST['cookie'])){ + set_cookie(); + } + # ------------------------------------------------------------------ + # redirect if needed + # ------------------------------------------------------------------ + if (!empty($auto_restrict['redirect_success'])){ + if (strpos($auto_restrict['redirect_success'], '&token=')!==false){ + safe_redirect($auto_restrict['redirect_success'].'&token='.returnToken()); + }else{ + safe_redirect($auto_restrict['redirect_success']); + } + } + } + + # ------------------------------------------------------------------ + # user wants to logout (?logout $_GET var) + # ------------------------------------------------------------------ + if (isset($_GET['deconnexion'])||isset($_GET['logout'])){@session_destroy();delete_cookie();exit_redirect();} + # ------------------------------------------------------------------ + + + # ------------------------------------------------------------------ + # No admin connected -> login + # ------------------------------------------------------------------ + if (empty($_SESSION['id_user'])||empty($_SESSION['login'])||empty($_SESSION['expire'])){ + if (!empty($_GET['p'])&&$_GET['p']!='login'){safe_redirect('index.php?p=login');} + } + + # ------------------------------------------------------------------ + # if here, there's no login/logout process. + # Check referrer, ip + # session duration... + # on problem, out ! + # ------------------------------------------------------------------ + if (!is_ok()){ + @session_destroy(); + if (!$auto_restrict['just_die_if_not_logged']){ + safe_redirect('index.php?p=login'); + } else { + echo $auto_restrict['error_msg']; + } + exit(); + } + # ------------------------------------------------------------------ + + + + # ------------------------------------------------------------------ + # if here, there was no security problem. + # Now, if there is an admin password post data, + # it means that the submitted form is a secured one: + # check if password is correct (if not => ban ip and stop here) + # ------------------------------------------------------------------ + + if (isset($_POST['admin_password'])){ + $pass=hash('sha512', $auto_restrict["salt"].$_POST['admin_password']); + if ($auto_restrict['pass']!=$pass){ + add_banned_ip(); + death('The admin password is wrong... too bad !'); + } + + } + + # ------------------------------------------------------------------ + # users list form requests + # ------------------------------------------------------------------ + # Erase a user account + if (isset($_POST['user_key'])&&is_user_admin()){ + foreach($_POST['user_key'] as $user_nb){ + if (isset($auto_restrict['users'][$user_nb])){ + unset($auto_restrict['users'][$user_nb]); + # ADDED FOR BOZON + rrmdir($_SESSION['upload_root_path'].$user_nb); + } + } + if (!empty($auto_restrict['users'])){ + save_users(); + # ADDED FOR BOZON + safe_redirect('index.php?p=users&token='.TOKEN.'&msg='.e('Changes saved',false)); + exit; + } + else{ + unlink($auto_restrict['path_to_files'].'/auto_restrict_users.php'); + exit_redirect(); + } + } + + + # ------------------------------------------------------------------ + # change user status + # ------------------------------------------------------------------ + if (isset($_POST['users_status'])&&is_user_admin()){ + unset($_POST['users_status']); + unset($_POST['token']); + foreach($_POST as $user=>$status){ + if (!empty($user)){$auto_restrict['users'][$user]['status']=$status;} + } + save_users(); + # ADDED FOR BOZON + safe_redirect('index.php?p=users&token='.TOKEN.'&msg='.e('Changes saved',false)); + } + + # ------------------------------------------------------------------ + # save user language if change BOZON CHANGE + # ------------------------------------------------------------------ + if (empty($auto_restrict['users'][$_SESSION['login']]['lang'])||$_SESSION['language']!=$auto_restrict['users'][$_SESSION['login']]['lang']){ + $auto_restrict['users'][$_SESSION['login']]['lang']=$_SESSION['language']; + save_users(); + } + + + # ------------------------------------------------------------------ + # crypt functions + # form http:#www.info-3000.com/phpmysql/cryptagedecryptage.php + # ------------------------------------------------------------------ + function GenerationCle($Texte,$CleDEncryptage) + { + $CleDEncryptage = md5($CleDEncryptage); + $Compteur=0; + $VariableTemp = ""; + for ($Ctr=0;$Ctr$user){ + $data.= $ret.'# user : '.$user['login'].$ret + .'$auto_restrict["users"]["'.$user['login'].'"]["login"]='.var_export($user['login'],true).';'.$ret + .'$auto_restrict["users"]["'.$user['login'].'"]["encryption_key"]='.var_export($user['encryption_key'],true).';'.$ret + .'$auto_restrict["users"]["'.$user['login'].'"]["salt"] = '.var_export($user['salt'],true).';'.$ret + .'$auto_restrict["users"]["'.$user['login'].'"]["pass"] = '.var_export($user['pass'],true).';'.$ret + .'$auto_restrict["users"]["'.$user['login'].'"]["status"]='.var_export($user['status'],true).';'.$ret + .'$auto_restrict["users"]["'.$user['login'].'"]["lang"]='.var_export($user['lang'],true).';'.$ret; + } + + $data.=$ret.'?>'; + $r=file_put_contents($auto_restrict['path_to_files'].'/auto_restrict_users.php', $data); + sleep(0.5); + return $r; + } + + function complete_if_needed(){ + global $auto_restrict,$default_language;$save=false; + if (!$auto_restrict){return false;} + $indexes_to_check=array( # 'var' => 'default value', + 'lang'=>$default_language, + ); + $first=first($auto_restrict['users']); + foreach ($auto_restrict['users'] as $user=>$data){ + foreach ($indexes_to_check as $index=>$default_value){ + if (empty($data[$index])){ + $auto_restrict['users'][$user][$index]=$default_value;$save=true; + } + if (empty($data['status'])){ + $auto_restrict['users'][$user]['status']=create_status($user,$first);$save=true; + }elseif($data['status']!='superadmin'&&$data['login']==$first['login']){ + $auto_restrict['users'][$user]['status']='superadmin';$save=true;# force first status to superadmin + } + } + } + + if ($save){save_users();return true;} + return false; + } + function create_status($user=null,$first=''){ + global $auto_restrict; + if (!$user){return false;} + if (count($auto_restrict['users'])==1){ return 'superadmin';} + elseif ($user==$first['login']){ return 'superadmin';} + else{return 'user';} + } + + function login_exists($login=null){ + global $auto_restrict; + if (empty($login)){return false;} + foreach ($auto_restrict['users'] as $key=>$user){ + if ($user['login']==$login){return true;} + } + return false; + } + + function id_user(){ + $id=$_SERVER['REMOTE_ADDR']; + $id.='-'.$_SERVER['HTTP_USER_AGENT']; + $id.='-'.session_id(); + return $id; + } + + + + function is_ok(){ + # check tokens, session vars, ip, referrer, cookie etc + # in case of problem, destroy session and redirect + global $auto_restrict; + $expired=false; + if (!isset($_SESSION['id_user'])){return false;} + # fatal problem + if (!checkReferer()){return death('
    You are definitely NOT from here !
    ');} + if (!checkIP()){return death('
    Hey... you were banished, fuck off !
    ');} + if (!checkToken()){return death('
    Invalid token
    ');} + + # + if (checkCookie()){return true;} + + if ($_SESSION['expire']'.$msg.'

    ');}else{return false;}} + function is_user_admin(){ + global $auto_restrict; + if ($auto_restrict['add_remove_user_admin_only']==false){return true;} + if (!empty($_SESSION['status'])){ + if ($_SESSION['status']=='admin'||$_SESSION['status']=='superadmin'){return true;} + }else{ + $first=first($auto_restrict['users']); + if (!empty($_SESSION['login'])&&$_SESSION['login']==$first['login']){return true;} + if (!empty($_SESSION['login'])&&isset($auto_restrict['users'][$_SESSION['login']]['status'])&&$auto_restrict['users'][$_SESSION['login']]['status']=='admin'){return true;} + } + return false; + } + function log_user($login_donne,$pass_donne){ + # create session vars + $save=false; + global $auto_restrict,$default_language; + if (empty($default_language)){$default_language='en';} + session_destroy();session_start(); + foreach ($auto_restrict['users'] as $key=>$user){ + if ($user['login']===$login_donne && $user['pass']===hash('sha512', $user["salt"].$pass_donne)){ + $_SESSION['id_user']=chiffre(id_user(),$user['encryption_key']); + $_SESSION['login']=$user['login']; + $_SESSION['expire']=time()+(60*$auto_restrict['session_expiration_delay']); + $admin=first($auto_restrict['users']); + $_SESSION['status']=$user['status']; + $_SESSION['language']=$user['lang']; + if ($save){save_users();} + return true; + } + } + if ($login_donne!='dis'&&$pass_donne!='connect'){ + add_banned_ip(); + }else{exit_redirect();} + return false; + } + + function exit_redirect(){ + global $auto_restrict; + @session_unset(); + @session_destroy(); + delete_cookie(); + if ($auto_restrict['redirect_error']&&$auto_restrict['redirect_error']!=''){ + safe_redirect($auto_restrict['redirect_error']); + }else{exit($auto_restrict['error_msg']);} + } + function generate_salt($length=256){ + $salt=''; + for($i=1;$i<=$length;$i++){ + $salt.=chr(mt_rand(35,126)); + } + return $salt; + } + + function set_cookie(){ + # create cookie and token file + global $auto_restrict; + $token_cookie=hash('sha512',$auto_restrict['system_salt'].md5(preg_replace('#[^a-zA-Z]#','',uniqid(true)))); + $time=time()+$auto_restrict['cookie_expiration_delay']*1440; + setcookie($auto_restrict['cookie_name'],$token_cookie,$time); + file_put_contents($auto_restrict['path_to_files'].'/'.$token_cookie,$time,0666); + chmod($auto_restrict['path_to_files'].'/'.$token_cookie,0666); + } + function delete_cookie(){ + # delete cookie and token cookie file + global $auto_restrict; + @$token_cookie_file=$_COOKIE[$auto_restrict['cookie_name']]; + setcookie($auto_restrict['cookie_name'],'',time()+1); + @unlink($auto_restrict['path_to_files'].'/'.$token_cookie_file); + } + function checkCookie(){ + # test cookie token file security access + global $auto_restrict; + + if (!isset($_COOKIE[$auto_restrict['cookie_name']])){return false;} # no cookie ? + $cookie_token_file=$auto_restrict['path_to_files'].'/'.$_COOKIE[$auto_restrict['cookie_name']]; + if (!is_file($cookie_token_file)){return false;} # no cookie token file ? + if (file_get_contents($cookie_token_file)