205 Commits
v2 ... v3

Author SHA1 Message Date
Chris
56dccd98b1 updated counter 2025-07-12 11:40:29 +02:00
Chris
02cf90ec7b added github link 2025-07-12 11:35:46 +02:00
Chris
6b4293fc3b added passthrough and updated documentation a bit 2025-07-12 11:30:36 +02:00
Chris
653cb2f7ac serve mp4s directly 2025-07-09 20:17:47 +02:00
Chris
b918ad613f listen on all domains 2025-07-09 18:30:36 +02:00
Chris
1dfdb4b0b2 x-accell working 2025-07-09 17:44:36 +02:00
Chris
9cd543d351 enable caching 2025-07-09 17:05:53 +02:00
Chris
4b61e46d7f typo and conversion updates 2025-06-03 08:22:34 +02:00
Chris
2611761b2b added hidden meta-rebuild function 2025-05-20 15:52:20 +02:00
Chris
c306befc84 added dev redis mount 2025-05-20 14:08:53 +02:00
Chris
61991a97af added redis startup and db folder 2025-05-20 14:07:02 +02:00
Chris
9beddcfd16 added admin panel with stats and logs 2025-05-20 13:59:42 +02:00
Chris
c3c34efa13 preparations for admin panel 2025-05-18 22:30:53 +02:00
Christian Haschek
e8bfb14947 typo and array syntax 2025-05-18 20:16:28 +02:00
Chris
a4d6f72609 added simple redis hashing 2025-05-18 17:12:34 +02:00
Christian Haschek
900377e658 updated readme and template 2025-05-18 13:36:34 +02:00
Christian Haschek
607c411aea added redis server to docker image if caching is not disabled 2025-05-18 13:24:35 +02:00
Chris
54b237a522 reids preparation 2025-05-18 12:31:50 +02:00
Chris
b7f5b09011 log sanity 2025-05-18 11:28:50 +02:00
Chris
e0a3bcd2b7 cleanup 2025-05-18 10:46:12 +02:00
Chris
6f1719fa78 added logging, updated theme and included info on the landing page 2025-05-18 10:36:29 +02:00
Chris
7344e8e06a url and base64 geht 2025-05-17 22:13:16 +02:00
Chris
ca01107379 cleanup 2025-05-17 21:27:20 +02:00
Chris
c02a25439e fixed text controller for v3 2025-05-17 21:27:15 +02:00
Chris
419f5a19d1 added debug info and docker compose 2025-05-17 18:15:09 +02:00
Chris
5c6b17bcca rewrite phase 2 - new api partially implemented 2025-05-17 17:29:25 +02:00
Chris
956368e444 v3 preparations 2025-05-06 14:18:36 +02:00
Chris
815895a524 Merge branch 'master' of https://github.com/HaschekSolutions/pictshare 2025-05-06 13:42:07 +02:00
Chris
de764c105c cf ip forward 2025-05-05 20:15:39 +02:00
Christian Haschek
749e7f193f Merge pull request #159 from YellingTree/patch-1
Change Input field to password type
2024-11-10 16:17:30 +01:00
Nixie
2cda214f86 Change Input field to password type
Change the input box for UPLOAD_CODE from type 'text' to type 'password' to hide the upload code while on-screen and signal to browsers to prompt to save the code in their password managers
2024-10-30 13:35:09 -04:00
Christian Haschek
f62b30d696 Merge pull request #154 from metalefty/fork-me
Fix dead image reference to "Fork me on GitHub"
2024-04-21 09:02:35 +02:00
Koichiro Iwao
b07a68bb45 Put gh-fork-ribbon locally for GDPR compliance 2024-04-20 21:32:46 +09:00
Koichiro Iwao
2b0dc071a0 Fix dead image reference to "Fork me on GitHub"
Switched to CSS implementation hosted on cdsjs.com. It should be
more permanent than githubusercontent.com.

Resolves: #153
2024-04-20 21:27:01 +09:00
Christian Haschek
f2cf56ceaa Merge pull request #155 from metalefty/passing-null
Fix for deprecated features in PHP 8.1
2024-04-15 13:04:39 +02:00
Koichiro Iwao
783f996e77 Fix for deprecated features in PHP 8.1
Deprecated: strpos(): Passing null to parameter #1 ($haystack) of type string

ref.  https://www.php.net/manual/en/migration81.deprecated.php#migration81.deprecated.core.null-not-nullable-internal
2024-03-07 22:47:39 +09:00
Christian Haschek
17dfb43abd Merge pull request #151 from HaschekSolutions/dependabot/composer/lib/aws/aws-sdk-php-3.288.1
Bump aws/aws-sdk-php from 3.33.4 to 3.288.1 in /lib
2023-12-22 07:53:12 +01:00
dependabot[bot]
1693bcaa78 Bump aws/aws-sdk-php from 3.33.4 to 3.288.1 in /lib
Bumps [aws/aws-sdk-php](https://github.com/aws/aws-sdk-php) from 3.33.4 to 3.288.1.
- [Release notes](https://github.com/aws/aws-sdk-php/releases)
- [Commits](https://github.com/aws/aws-sdk-php/compare/3.33.4...3.288.1)

---
updated-dependencies:
- dependency-name: aws/aws-sdk-php
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-22 00:27:17 +00:00
Chris
bc1eca4014 wrong project 2023-11-13 10:30:25 +01:00
Chris
fc9a7d3072 Merge branch 'master' of https://github.com/HaschekSolutions/pictshare 2023-11-13 10:27:47 +01:00
Chris
67fba8e66b updated CI to include versions 2023-11-13 10:27:40 +01:00
Christian Haschek
7f18a193d4 Update core.php
added override for host if it doesn't contain a port
2023-11-04 18:14:55 +01:00
Christian Haschek
090f452585 fixed start.sh 2023-11-04 18:01:43 +01:00
Chris
819c25374c silent rollout of split data dir 2023-11-03 16:48:12 +01:00
Chris
2388f68d5d preparations for dynamic data directories 2023-11-02 23:20:05 +01:00
Chris
3fe84a63a4 Merge branch 'master' of https://github.com/HaschekSolutions/pictshare 2023-11-02 20:23:16 +01:00
Chris
774c8e0112 disable follow to avoid CVEs 2023-11-02 20:23:01 +01:00
Christian Haschek
63132e1cfb Create SECURITY.md 2023-11-02 16:44:00 +01:00
Chris
d349ee8fc6 added check for private ip range 2023-11-02 08:14:25 +01:00
Chris
5c3ee9e159 preparations for queue-rendering 2023-10-15 20:31:01 +02:00
Chris
cea501d854 more minot php8 warning fixes 2023-10-15 20:30:12 +02:00
Chris
a1bc5b5fa5 minor warning adjustments 2023-10-15 20:17:56 +02:00
Chris
d3d5d1c385 Upgraded to php8.2 🎉🎉🎉 2023-09-14 10:42:35 +02:00
Chris
f000404d5a hardcoded registries and fixed typos 2023-09-13 08:40:34 +02:00
Chris
c777cd62ab missed docker.io url 2023-09-13 08:32:47 +02:00
Chris
06a524ca2f mussing var 2023-09-13 08:32:10 +02:00
Chris
2712946287 changed pipeline so it's also pushed to docker hub 2023-09-13 08:26:42 +02:00
Chris
fffcb13ac9 fixed conversion bug 2023-09-07 17:55:25 +02:00
Chris
307243a5bf only add when upload coede is configured 2023-09-07 17:45:04 +02:00
Chris
61acb5420b implemented UPLOAD_CODE variable
If configured, needs a code as POST/GET variable for every upload. Also adds a input field to the main template
2023-09-06 15:57:15 +02:00
Chris
cccb80de03 remove dynamic extensions 2023-09-06 15:35:12 +02:00
Chris
d0deb6f6c9 noo need to convert anymore since it's the right header now 2023-09-03 10:38:45 +02:00
Chris
e551ef2bb2 added json header closes #146 2023-09-03 10:35:13 +02:00
Chris
21aa1fbb7d added identicons 2023-09-03 10:34:35 +02:00
Chris
4c1124da07 finally removed the static s3php files and replaced with composer 2023-09-03 10:09:43 +02:00
Chris
19d7cb060e added support for dynamic content controllers
Also implemented a placeholder generator to showcase it
2023-08-26 22:39:08 +02:00
Chris
c90a716d45 ALWAYS_WEBP now also for PNG 2023-08-26 11:55:00 +02:00
Chris
4fbf8b31a2 fixed missing config generator 2023-08-25 21:53:55 +02:00
Chris
422c17eb65 Added new setting to force JPGs sent as WebP if supported by the client 2023-08-24 23:09:59 +02:00
Christian Haschek
70cdcf5dcf Merge pull request #150 from beabee-communityrm/feat/jpeg-orientation
Add JPEG EXIF orientation rotation
2023-08-24 21:35:29 +02:00
Will Franklin
7b4b27098d Add support for flipping images too 2023-08-24 16:48:44 +01:00
Will Franklin
2362af1e8c Fix docker build instructions 2023-08-24 15:41:32 +01:00
Will Franklin
28f5677247 Rotate JPEG images if they have an Orientation tag 2023-08-24 15:41:24 +01:00
Christian Haschek
8c2702be96 Merge pull request #147 from gabe565/svg-logo
Add SVG logo
2023-04-17 11:03:30 +02:00
Gabe Cook
452db23c57 Use SVG logo in readme and tweak formatting 2023-04-15 16:45:52 -05:00
Gabe Cook
c6baa6edfa Add SVG logo 2023-04-15 16:45:41 -05:00
Christian Haschek
74ccf9f626 updated info on new docker container source 2023-03-23 09:52:23 +01:00
Christian Haschek
56f89d5610 upgraded login action tag to avoid deprecation 2023-03-23 09:26:43 +01:00
Christian Haschek
0ea4b3c160 is this a magic variable? let's find out 2023-03-22 23:01:41 +01:00
Christian Haschek
93d78d44fe make image name lowercase otherwise will faild github build 2023-03-22 22:57:29 +01:00
Christian Haschek
7dac978d16 dynamic image name based on envs 2023-03-22 22:53:47 +01:00
Christian Haschek
312f18ade2 move to github repository - check 2023-03-22 22:50:13 +01:00
Chris H
cb2d17411c small undefined variable bug fixed 2023-01-16 10:28:54 +01:00
Chris H
9a4a20fb41 typo . fixes #142 2023-01-13 09:01:37 +01:00
Christian Haschek
72394f17ba Merge pull request #140 from FN-Florian/master
Add S3_REDGION varaible
2022-06-27 08:19:06 +02:00
FN-Florian
240c7359a8 Update s3.controller.php 2022-06-27 00:08:24 +02:00
FN-Florian
9d8d5f3d36 Update start.sh 2022-06-27 00:07:32 +02:00
FN-Florian
25b39bbd86 Update CONFIG.md 2022-06-25 23:56:31 +02:00
FN-Florian
4964967524 Update DOCKER.md 2022-06-25 23:55:06 +02:00
FN-Florian
bfb43ab856 Update s3.controller.php
add S3_REGION variable
2022-06-20 08:50:13 +02:00
Christian Haschek
03464199ee Merge pull request #138 from quonic/master
Adds PowerShell script for Greenshot on Windows
2022-05-12 08:10:49 +02:00
Christian Haschek
96e73e2baf Merge branch 'master' into master 2022-05-12 08:10:37 +02:00
Christian Haschek
6ad94f2063 added php function for uploading 2022-05-04 22:46:59 +02:00
Jim Caten
45b2e11729 Adds window style Hidden to PowerShell script 2022-04-21 02:15:26 -05:00
Jim Caten
c7f8f37c62 Adds PowerShell script for Greenshot
Curl is needed as Invoke-WebRequest and Invoke-RestMethod don't like uploading files easily. Curl simplifies the process down to one line of code.
2022-04-21 02:07:01 -05:00
Christian Haschek
6f540ad27e added copy url button closes #112 2022-03-08 22:23:57 +01:00
Christian Haschek
ef1a1ecaff disable debug output 2022-02-23 19:19:53 +01:00
Christian Haschek
be5f601866 disable upload timeout so big uploads wont fail 2022-02-23 19:19:38 +01:00
Christian Haschek
45d933ebf0 fixing gui-upload filesize bug 2022-02-23 19:11:33 +01:00
Christian Haschek
a145ca88cc was meant to strpos 2022-02-19 10:53:26 +01:00
Christian Haschek
cf0effd0e8 allowing for multiple comma separated CIDR ranges 2022-02-19 10:47:07 +01:00
Christian Haschek
8ee26e6922 added small ip debug info output 2022-02-19 10:38:50 +01:00
Christian Haschek
9d1a4db4d2 updated cloudflare ips 2022-02-19 10:36:54 +01:00
Christian Haschek
adb1c468cd added ipv6 support in ALLOWED_SUBNET variable 2022-02-19 08:56:29 +01:00
Christian Haschek
d6f3b7b5df Merge branch 'master' of github.com:HaschekSolutions/pictshare 2022-01-31 10:01:56 +01:00
Christian Haschek
33b08f378d added libz 2022-01-31 10:01:54 +01:00
Christian Haschek
31d2712733 added demo gif again 2022-01-31 09:19:24 +01:00
Christian Haschek
9200d3d93c added setting and possible fix for passive mode. fixes #135 probably 2022-01-24 15:23:38 +01:00
Christian Haschek
b669e69511 if p1 was done then don't ask the server for every individual file again 2021-11-24 23:30:37 +01:00
Christian Haschek
f0cfdeb650 fixed build bug 2021-11-22 12:46:35 +01:00
Christian Haschek
99d9542b80 fixed typo that caused 500 error 2021-11-22 12:43:50 +01:00
Christian Haschek
b65186f77f removed static ffmpeg binary and updated readme files 2021-11-22 11:48:01 +01:00
Christian Haschek
3ee37fe3a2 updates that make life easier on ARM or low memory devices 2021-11-20 23:08:47 +01:00
Christian Haschek
5ecf80bce1 fixed dockerfile path 2021-11-20 01:48:51 +01:00
Christian Haschek
5a5c4a0334 building for arm and x64 now (if it works) 2021-11-20 01:47:17 +01:00
Christian Haschek
7c7358af9c only save one tag per day 2021-11-20 01:25:43 +01:00
Christian Haschek
ebc4ebda03 automatic tags are now yyyymmddhhmmss 2021-11-20 01:21:08 +01:00
Christian Haschek
a4dc4366ba new path for stored files in docker container!!! 2021-11-11 23:42:33 +01:00
Christian Haschek
ea40ffbc46 Unified docker building process. & more updates
- automatic builds
- automated tags on docker
- no more auto update (update your docker containers)
- auto not removed of mp4 anymore
- bug fixes

also closes #85 and closes #124
2021-11-11 23:39:12 +01:00
Christian Haschek
9a7fadb231 streamlined hash detection 2021-11-11 19:17:21 +01:00
Christian Haschek
199f162fdf Merge pull request #128 from ranjit-git/master
Update core.php
2021-06-18 07:46:51 +02:00
ranjit-git
70c06cfa5c Update core.php 2021-06-11 10:15:46 +05:30
Christian Haschek
520099be96 Merge pull request #126 from vikbez/patch-1
"file" command is required
2021-05-22 09:26:58 +02:00
Romain Gay
5cf9b86868 "file" command is required 2021-05-21 22:35:24 +02:00
Christian Haschek
03d4875e92 Update README.md
new hit count
2021-04-23 08:55:50 +02:00
Christian Haschek
726c77effb only use finfo on windows. fixes #125 2021-03-10 08:30:02 +01:00
Christian Haschek
68de83b46a fixed ftp delete 2021-01-19 11:27:21 +01:00
Christian Haschek
77d4023f00 missing part for last fix 2020-07-27 09:40:30 +02:00
Christian Haschek
0119368376 catching non-configured subnet bug 2020-07-15 20:36:55 +02:00
Chris
166ff1da1b fixed filter examples 2020-06-23 12:11:57 +02:00
Chris
7727fc9ea4 filters already implemented 2020-06-23 12:06:24 +02:00
Chris
8de53d1ea7 added warning message if upload forbidden instead of just 401 error 2020-06-23 09:26:39 +02:00
Chris
0250b6a577 slicker check for upload permissions, included http response code 2020-06-23 09:17:49 +02:00
Chris
e13f4816fb allowing multiple ip ranges in checking function 2020-06-15 10:47:57 +02:00
Chris
75784174fa extended subnet access control 2020-06-15 10:38:07 +02:00
Chris
6d504f3a48 added support for cloudflare IP logging 2020-06-11 01:16:55 +02:00
Chris
3a6c987347 allow rendering of existing files 2020-06-11 01:05:11 +02:00
Chris
5861e73848 implemented dynamic content controller loading, enabling whitelisting of content types. closes #87 2020-06-06 13:27:47 +02:00
Chris
a2b7feb6f9 changed to oneliner 2020-06-06 11:53:22 +02:00
Chris
dce00906ec added URI fallback. This enables pictshare to be run directly from "php -S localhost:8000" 2020-06-06 11:52:34 +02:00
Chris
ceffa04b6e implemented tag and last-modified for images. closes #119 2020-06-03 00:38:05 +02:00
Chris
984246912c added possibility to have a notice displayed on the upload form 2020-05-31 19:03:59 +02:00
Chris
3a8ac33dd1 updated encryption md 2020-05-31 17:43:28 +02:00
Chris
7e28024d32 added pasting of images. closes #117 2020-05-13 16:09:57 +02:00
Chris
b149fe88cb added integrations and updated readme 2020-01-13 01:01:56 +01:00
Chris
3a27592d58 fixed queue 2020-01-13 00:31:19 +01:00
Chris
80e210af86 implemented simple queue of hashes that were not successfully uploaded to a storage container 2020-01-13 00:28:44 +01:00
Chris
220a3103fa cleaning of unused scripts 2020-01-13 00:28:23 +01:00
Chris
6ec765024e fixed dev output 2020-01-12 13:38:27 +01:00
Chris
6c556e921f added ftp_ssl support (not sftp!) 2020-01-11 15:20:38 +01:00
Chris
3a90787091 use passive mode by default 2020-01-11 02:40:11 +01:00
Chris
c4087c1e84 fixed bug that wouldnt allow creation of folders name 0 2020-01-11 02:32:53 +01:00
Chris
76c0f6cec1 allow skipping of phase 1 2020-01-11 02:19:08 +01:00
Chris
f01b685820 changed ftp server storage to distribute evenly across directories 2020-01-11 01:54:59 +01:00
Chris
e022227617 typo 2020-01-10 14:32:46 +01:00
Chris
2fc56d438d easier on the eyes 2020-01-10 14:30:07 +01:00
Chris
fb50f23e19 added new storage controller (FTP) and updated config 2020-01-10 14:25:26 +01:00
Chris
40c53173ca updated readme for config info 2020-01-10 12:45:01 +01:00
Chris
30c78ab7da increased default key polls 2020-01-08 22:47:05 +01:00
Chris
5e59d7e80d forgot dev flag on s3 controller 2020-01-08 10:36:57 +01:00
Chris
dd0d274ab1 debug var 2020-01-08 10:31:07 +01:00
Chris
3c7e8bea7c better loop 2020-01-08 10:28:44 +01:00
Chris
1a46209bfe with class name it's easier 2020-01-08 09:28:30 +01:00
Chris
ad04aeb5b6 for status messages 2020-01-08 09:10:43 +01:00
Chris
bbb0b5b111 sync script changed to pull first then push 2020-01-08 00:08:10 +01:00
Chris
a19d0a3d48 sync script added and fixed some controllers 2020-01-07 22:13:29 +01:00
Chris
63fe1b3edd readme link fixed again 2020-01-07 19:08:02 +01:00
Chris
b9e42d0f31 fixed link 2020-01-07 19:07:22 +01:00
Chris
021fbad811 Added encryption based on Libsodium 2020-01-07 19:05:22 +01:00
Chris
6cab15f8e7 added example config setting 2020-01-05 03:13:04 +01:00
Chris
f863045fcf S3/Minio storage controller Support 2020-01-05 03:11:41 +01:00
Christian Haschek
87fa55eae8 Merge pull request #98 from dessalines/master
Add docker-compose.yml
2019-11-07 11:29:04 +01:00
Dessalines
6806e4a15a Add docker-compose.yml
Fixes #93
2019-09-23 13:32:33 -07:00
Chris
82f97479ff Merge branch 'master' of https://github.com/HaschekSolutions/pictshare 2019-08-21 21:06:08 +02:00
Chris
75124102cb added docker shields 2019-08-21 21:05:48 +02:00
Christian Haschek
515e034d91 Merge pull request #86 from thomasjsn/master
Add commandline alias examples and modifiers documentation
2019-03-08 14:04:43 +01:00
Thomas Jensen
2a628e7d7a layout changes to modifiers documentation 2019-03-08 09:50:46 +01:00
Thomas Jensen
8e3cf866a6 add modifisers documentation 2019-03-08 09:48:02 +01:00
Thomas Jensen
6adb557693 Add commandline alias examples 2019-03-08 09:46:35 +01:00
Christian Haschek
c178f3af44 Merge pull request #84 from rumkit/client-subnet-filter
Client subnet filter
2019-02-20 17:18:14 +01:00
Anton Mitsengendler
8da3573ffb added client subnet filter 2019-02-20 17:12:06 +03:00
Chris
5f5b836a22 added base64 readme 2019-01-14 20:42:14 +01:00
Chris
17974088bc dont need to redeclare 2019-01-12 13:41:14 +01:00
Chris
4d5d57df8a fixed altfolder for v2 2019-01-12 13:38:00 +01:00
Christian Haschek
71df6a54c4 Update README.md 2018-12-30 23:40:13 +01:00
Christian Haschek
4a5e29e7c1 Update README.md 2018-12-30 23:37:08 +01:00
Christian Haschek
9d2bf6a931 Update README.md 2018-12-30 23:34:24 +01:00
Christian Haschek
66eebd1445 Update README.md 2018-12-30 23:25:34 +01:00
Christian Haschek
38f6b1c22f Update README.md 2018-12-30 23:24:46 +01:00
Christian Haschek
263f0b762b Update README.md 2018-12-30 23:24:34 +01:00
Christian Haschek
9f9449a58d Update README.md 2018-12-30 23:23:07 +01:00
Christian Haschek
1cb8e28be7 Update README.md 2018-12-30 23:21:25 +01:00
Christian Haschek
37e0ae26f8 Update SCALING.md 2018-12-30 22:50:29 +01:00
Chris
d41e06efa0 clarification 2018-12-30 19:29:51 +01:00
Chris
772860e186 updated readme for image filters 2018-12-30 19:28:29 +01:00
Chris
5cc690bbee added filters 2018-12-30 19:24:56 +01:00
Chris
b2a7c778d8 added new api and updated readme 2018-12-30 12:50:52 +01:00
Chris
771ec3305e typo 2018-12-29 11:17:00 +01:00
Chris
f4cea4ce08 added dependencies thanks to #79 2018-12-29 11:15:55 +01:00
Chris
66570c54d8 more features 2018-12-28 20:48:30 +01:00
Chris
ee0000bf59 hint hint ;D 2018-12-28 20:45:22 +01:00
Chris
5d6b57cabc fixed but which prevented files form being deleted 2018-12-28 18:06:31 +01:00
Chris
b3e777baa3 not dev anymore 2018-12-27 19:40:13 +01:00
Chris
fb25657d2f Merge branch 'v2' 2018-12-27 19:04:54 +01:00
Christian Haschek
3e6cfdfed6 Merge pull request #78 from HaschekSolutions/v2
V2
2018-12-27 18:54:46 +01:00
219 changed files with 6433 additions and 3884 deletions

8
.dockerignore Normal file
View File

@@ -0,0 +1,8 @@
src/inc/config.inc.php
data/*
logs/*
tmp/*
src/lib/vendor
.git
.github
.vscode

59
.github/workflows/build-docker.yml vendored Normal file
View File

@@ -0,0 +1,59 @@
name: ci
on:
push:
tags:
- "v*.*.*"
pull_request:
branches:
- "master"
jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
# list of Docker images to use as base name for tags
images: |
hascheksolutions/pictshare
ghcr.io/hascheksolutions/pictshare
# generate Docker tags based on the following events/attributes
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Login to GHCR
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
file: docker/Dockerfile
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

3
.gitignore vendored
View File

@@ -1 +1,2 @@
test.php
notice.txt
.vscode

View File

@@ -1,9 +0,0 @@
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?url=$1 [QSA,PT,L]
</IfModule>

1
CHANGELOG.md Normal file
View File

@@ -0,0 +1 @@
-> See https://github.com/HaschekSolutions/pictshare/tags

35
DEV.md Normal file
View File

@@ -0,0 +1,35 @@
# Folder structure
All uploads will be created as folders with the name of the file in the `./data` directory.
```
data/
data/<file_name>/
data/<file_name>/<file_name> # the actual file eg abc1
data/<file_name>/meta.json # file containing the metadata
```
## Metadata file
The metadata file will contain data like in the following example:
```json
{
"mime": "image\/jpeg",
"size": 504921,
"size_human": "493.09 KB",
"original_filename": "PXL_20250511_122019042-POP_OUT.jpg",
"hash": "0gfmeo.jpg",
"sha1": "7dc14ad3f0c273ce0188aeef19a6104e81ba67dd",
"uploaded": 1747557347,
"ip": "::1",
"useragent": "Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/136.0.0.0 Safari\/537.36",
"delete_code": "z94fd5tyto1u2bww23kec0f52irb7x49",
"delete_url": "http:\/\/localhost:8080\/delete_z94fd5tyto1u2bww23kec0f52irb7x49\/0gfmeo.jpg",
"remote_port": "35856"
}
```
# Redis index
If redis caching is enabled, this structure will be created on the fly:
- cache:byurl:<url> => <content controller>;<file_name> # cached response
- served:<file_name> => number of views # view count

830
LICENSE
View File

@@ -1,201 +1,693 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
PictShare - Self-hosted media sharing platform
Copyright (c) 2025 Haschek Solutions
https://github.com/HaschekSolutions/pictshare
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
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.
1. Definitions.
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.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
Commercial licensing:
---------------------
This project is also available under a commercial license for organizations
that do not wish to comply with the terms of the AGPLv3.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
For proprietary licensing, partnership opportunities, or other inquiries,
please contact:
📧 office@haschek.solutions
🌐 https://haschek.solutions
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
SPDX-License-Identifier: AGPL-3.0-or-later
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
GNU AFFERO GENERAL PUBLIC LICENSE
Version 3, 19 November 2007
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
Preamble
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
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.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
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.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
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.
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
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.
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
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.
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
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.
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
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.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
The precise terms and conditions for copying, distribution and
modification follow.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
TERMS AND CONDITIONS
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
0. Definitions.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
"This License" refers to version 3 of the GNU Affero General Public License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
"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.
END OF TERMS AND CONDITIONS
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.
APPENDIX: How to apply the Apache License to your work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
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.
Copyright 2015 Christian Haschek (HASCHEK SOLUTIONS)
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.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
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.
http://www.apache.org/licenses/LICENSE-2.0
1. Source Code.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
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
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
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.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If your software can interact with users remotely through a computer
network, you should also make sure that it provides a way for users to
get its source. For example, if your program is a web application, its
interface could display a "Source" link that leads users to an archive
of the code. There are many ways you could offer source, and different
solutions will be better for different programs; see section 13 for the
specific requirements.
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU AGPL, see
<http://www.gnu.org/licenses/>.

View File

@@ -1,42 +1,97 @@
# PictShare v2
---
[![Apache License](https://img.shields.io/badge/license-Apache-blue.svg?style=flat)](https://github.com/HaschekSolutions/pictshare/blob/master/LICENSE)
<p align="center">
<a href="" rel="noopener">
<img height=200px src="./css/imgs/logo/logo.svg" alt="PictShare logo">
</a>
</p>
# This is the development branch for Version 2 do not use in production
Test site: https://dev.pictshare.net/ (only sometimes on)
<h1 align="center">PictShare v3</h1>
<h3 align="center">Caution: Pictshare v3 may not be fully compatible with previous Pictshare versions!</h3>
<h4 align="center">https://pictshare.net</h4>
<div align="center">
![](https://img.shields.io/badge/php-8.2%2B-brightgreen.svg)
[![](https://img.shields.io/docker/pulls/hascheksolutions/pictshare?color=brightgreen)](https://hub.docker.com/r/hascheksolutions/pictshare)
![](https://github.com/hascheksolutions/pictshare/actions/workflows/build-docker.yml/badge.svg)
[![Apache License](https://img.shields.io/badge/license-Apache-brightgreen.svg?style=flat)](https://github.com/HaschekSolutions/pictshare/blob/master/LICENSE)
![Hits](https://hits.deltapapa.io/github/HaschekSolutions/pictshare.svg)
[![](https://img.shields.io/github/stars/HaschekSolutions/pictshare.svg?label=Stars&style=social)](https://github.com/HaschekSolutions/pictshare)
#### Host your own `images` `gifs` `mp4s` `text bins` and stay in control
</div>
-----------------------------------------
<center>
<p align="center">
<img src="https://www.pictshare.net/39928d8239.gif" alt="PictShare demo">
</p>
Table of contents
=================
* [Quick Start](#quickstart)
* [Breaking changes in v3](#breaking-changes-in-v3)
* [Features](#features)
* [Installation](/rtfm/INSTALL.md)
* [Configuration](/rtfm/CONFIG.md)
* [Docker](/rtfm/DOCKER.md)
* [API](/rtfm/API.md)
* [Addons/Integration](/rtfm/INTEGRATIONS.md)
* [Development status](#development-status)
* [Addons and integration](/rtfm/INTEGRATIONS.md)
* [Development roadmap](#development-roadmap)
---
## New Features in v2
## Quickstart
```bash
docker run -d -p 8080:80 --name=pictshare ghcr.io/hascheksolutions/pictshare
```
Then open http://localhost:8080 in your browser
## Breaking changes in v3
#### Dropped configuration options
- TITLE
- UPLOAD_FORM_LOCATION
- ALLOW_BLOATING
#### File name in URL
In Picthsare v3 we have changed the requirement for the image to be the last part of the URL. While with older PictShare Versions you could put the file name at any place of the URL, we now require the last part of the URL to be the file name.
- before: https://pictshare.net/roate-left/1234.png/800x600/
- now: https://pictshare.net/roate-left/600x600/1234.png
#### API changes
The API has been moved to a more consistant and RESTful design. The API documentation has been updated to reflect these changes.
## New Features
- Generate identicons based on strings in the URL [example1](https://pictshare.net/identicon/example1) [example2](https://pictshare.net/identicon/example2)
- Generate placeholder images by specifying the size in the URL. [example](https://pictshare.net/placeholder/555x250/color-white-blue)
- Added support for external storage
- [Encryption of files in external storage](/rtfm/ENCRYPTION.md)
- Added text hosting (like pastebin)
- Added URL shortening
- Added WebP to images (and conversion from jpg,png to webp)
- Added WebP to images (and automatic conversion from jpg, png to webp if the requesting browser supports it)
- Massive code rework. Actually we designed it from the ground up to be more modular and easier to debug
## Breaking changes in v2
- [New API system](/rtfm/API.md). Only single file uploads now via /api/upload.php (POST var name is "file"). [read more..](/rtfm/API.md)
- Data directory renamed from ```upload``` to ```data```
- Backblaze support dropped for now because we didn't need it anymore as ALT_FOLDER is more flexible. If soneone needs it, it can easily be implemented via adding a new storage controller. We're happy to accept pull requests
# Features
- Selfhostable
- [Simple upload API](/rtfm/API.md)
- 100% file based - no database needed
- [Scalable hosting](/rtfm/SCALING.md)
- Many [Filters](/rtfm/IMAGEFILTERS.md) for images
- GIF to MP4 conversion
- JPG, PNG to WEBP conversion
- MP4 resizing
- PictShare removes all exif data so you can upload photos from your phone and all GPS tags and camera model info get wiped
- Change and resize your uploads just by editing the URL
- Change and resize your images and videos just by editing the URL
- Duplicates don't take up space. If the exact same file is uploaded twice, the second upload will link to the first
- Many [configuration options](/rtfm/CONFIG.md)
- Full control over your data. Delete images with individual and global delete codes
@@ -67,17 +122,17 @@ Read [here](/rtfm/CONFIG.md) what those options do
- [x] MASTER_DELETE_CODE
- [x] MASTER_DELETE_IP
- [x] UPLOAD_FORM_LOCATION
- [x] S3 Backend
- [x] UPLOAD_CODE
- [ ] UPLOAD_QUOTA
- [ ] UPLOAD_CODE
- [ ] LOW_PROFILE
- [ ] IMAGE_CHANGE_CODE
- [ ] MAX_RESIZED_IMAGES
- [ ] ALLOW_BLOATING
- [ ] BACKBLAZE
### Image hosting
- [X] Resizing
- [ ] Filters
- [x] Resizing
- [x] Filters
- [x] Gif to mp4 conversion
- [x] Upload of images
@@ -102,4 +157,4 @@ Read [here](/rtfm/CONFIG.md) what those options do
This is a [HASCHEK SOLUTIONS](https://haschek.solutions) project
[![HS logo](https://pictshare.net/css/imgs/hs_logo.png)](https://haschek.solutions)
[![HS logo](https://pictshare.net/css/imgs/hs_logo.png)](https://haschek.solutions)

11
SECURITY.md Normal file
View File

@@ -0,0 +1,11 @@
# Security Policy
## Supported Versions
PictShare uses rolling releases so the latest version is the only supported one.
## Reporting a Vulnerability
Reports can be made as issues in this repo or in confidence via christian@haschek.at
Pull requests welcome

11
TODO.md Normal file
View File

@@ -0,0 +1,11 @@
# Todos
- [ ] Caching in Redis for already handled URLs so it doesn't need to go through the whole algorithm again
- [ ] View stats in redis
- [ ] Keep track of deleted (and therefore forbidden) hashes
- [ ] Store list in Storage Controllers as well
- [ ] Add a way for users to report content
- [ ] Review reports
- [ ] Delete content if needed in a way that the user can't reupload it
- [ ] Add a way to delete content that is older than X days
- [ ] Bruteforce protection for admin login

Binary file not shown.

11
configs/php.ini Normal file
View File

@@ -0,0 +1,11 @@
upload_max_filesize = 100M
post_max_size = 100M
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
log_errors = On
display_errors = Off
display_startup_errors = Off
max_execution_time = 300 ; 5 minutes
max_input_time = 300 ; time to parse input data (e.g. POST)

File diff suppressed because one or more lines are too long

2
data/.gitignore vendored
View File

@@ -1,4 +1,2 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

55
docker-compose-dev.yml Normal file
View File

@@ -0,0 +1,55 @@
version: '3.9'
services:
pictshare:
build:
context: .
dockerfile: docker/Dockerfile
environment:
- URL=http://localhost:8080/
- MAX_UPLOAD_SIZE=1000
# Security settings
- ADMIN_PASSWORD=test # password for the admin panel. if empty, admin panel is disabled
- ALLOWED_SUBNET= #IP address or subnet mask to allow upload to the server
- CONTENTCONTROLLERS= # limit uploaded file types
- MASTER_DELETE_CODE= # code to delete all files
- MASTER_DELETE_IP= # IP address to delete all files even without delete code
- UPLOAD_FORM_LOCATION= # moves the upload form from / to whatever you set here
- UPLOAD_CODE= # if set, requires this code to upload files via api or web
# image settings settings
- ALLOW_BLOATING=false
- JPEG_COMPRESSION=
- PNG_COMPRESSION=
- ALWAYS_WEBP=false # if true, will always serve webp images if the request included the capability
# alternate folder. all uploads will also be copied to this folder
- ALT_FOLDER=
# s3 settings
- S3_BUCKET=
- S3_ACCESS_KEY=
- S3_SECRET_KEY=
- S3_ENDPOINT=
- S3_REGION=
# FTP settings
- FTP_SERVER=
- FTP_PORT=
- FTP_USER=
- FTP_PASS=
- FTP_PASSIVEMODE=
- FTP_SSL=
- FTP_BASEDIR=
# encryption settings
- ENCRYPTION_KEY=
# logging settings
- LOG_VIEWS=true
# caching
- REDIS_CACHING=true
- REDIS_SERVER=localhost
- REDIS_PORT=6379
ports:
- 8080:80
volumes:
- ./data:/app/public/data
- ./logs:/app/public/logs
- ./src:/app/public/src
- ./web:/app/public/web
- ./tmp:/app/public/tmp
- ./tmp/redis:/var/lib/redis

50
docker-compose.yml Normal file
View File

@@ -0,0 +1,50 @@
version: '3.9'
services:
pictshare:
image: 'HaschekSolutions/pictshare:3'
environment:
- URL=http://localhost:8080/
- MAX_UPLOAD_SIZE=20 #in MB
# Security settings
- ADMIN_PASSWORD= # password for the admin panel. if empty, admin panel is disabled
- ALLOWED_SUBNET= #IP address or subnet mask to allow upload and access to the admin panel
- CONTENTCONTROLLERS= # limit uploaded file types
- MASTER_DELETE_CODE= # code to delete all files
- MASTER_DELETE_IP= # IP address to delete all files even without delete code
- UPLOAD_FORM_LOCATION= # moves the upload form from / to whatever you set here
- UPLOAD_CODE= # if set, requires this code to upload files via api or web
# image settings settings
- ALLOW_BLOATING=false
- JPEG_COMPRESSION=
- PNG_COMPRESSION=
- ALWAYS_WEBP=false # if true, will always serve webp images if the request included the capability
# alternate folder. all uploads will also be copied to this folder
- ALT_FOLDER=
# s3 settings
- S3_BUCKET=
- S3_ACCESS_KEY=
- S3_SECRET_KEY=
- S3_ENDPOINT=
- S3_REGION=
# FTP settings
- FTP_SERVER=
- FTP_PORT=
- FTP_USER=
- FTP_PASS=
- FTP_PASSIVEMODE=
- FTP_SSL=
- FTP_BASEDIR=
# encryption settings
- ENCRYPTION_KEY=
# logging settings
- LOG_VIEWS=false
# caching
- REDIS_CACHING=true
- REDIS_SERVER=localhost
- REDIS_PORT=6379
ports:
- 8080:80
volumes:
- ./data:/app/public/data
- ./logs:/app/public/logs
- ./redis:/var/lib/redis # can be commeted out if REDIS_CACHING is set to false

35
docker/Dockerfile Normal file
View File

@@ -0,0 +1,35 @@
FROM dunglas/frankenphp:php8.4-alpine
RUN apk add --no-cache bash socat file ffmpeg redis
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer
WORKDIR /app/public
RUN install-php-extensions redis exif gd
ADD docker/rootfs/Caddyfile /etc/caddy/Caddyfile
# Add php.ini
ADD configs/php.ini /usr/local/etc/php/php.ini
# Prepare app tree
ADD . /app/public/.
ADD docker/rootfs/start.sh /etc/start.sh
RUN chmod +x /etc/start.sh
# Composer intall
WORKDIR /app/public/src/lib
RUN composer install --no-dev --no-interaction --no-progress --optimize-autoloader
WORKDIR /app/public/
# Volumes to mount
#VOLUME /var/lib/influxdb
VOLUME /app/public/data
VOLUME /app/public/logs
EXPOSE 80
ENTRYPOINT ["/etc/start.sh"]

28
docker/rootfs/Caddyfile Normal file
View File

@@ -0,0 +1,28 @@
{
frankenphp
}
:80 {
log
encode zstd br gzip
root web/
#request_header X-Sendfile-Type x-accel-redirect
#request_header X-Accel-Mapping ../data=/data
intercept {
@sendfile header X-Accel-Redirect *
handle_response @sendfile {
root data/
rewrite * {resp.header.X-Accel-Redirect}
method * GET
header -X-Accel-Redirect
file_server
}
}
php_server {
try_files {path} index.php
}
}

97
docker/rootfs/start.sh Normal file
View File

@@ -0,0 +1,97 @@
#!/bin/bash
######### functions
_maxUploadSize() {
echo "[i] Setting uploadsize to ${MAX_UPLOAD_SIZE}M"
sed -i "/post_max_size/c\post_max_size=${MAX_UPLOAD_SIZE}M" /usr/local/etc/php/php.ini
sed -i "/upload_max_filesize/c\upload_max_filesize=${MAX_UPLOAD_SIZE}M" /usr/local/etc/php/php.ini
# set error reporting no notices, no warnings
sed -i "/^error_reporting/c\error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT & ~E_WARNING & ~E_NOTICE" /usr/local/etc/php/php.ini
MAX_RAM=$((MAX_UPLOAD_SIZE + 30)) # 30megs more than the upload size
echo "[i] Also changing memory limit of PHP to ${MAX_RAM}M"
sed -i -e "s/128M/${MAX_RAM}M/g" /usr/local/etc/php/php.ini
sed -i "/memory_limit/c\memory_limit=${MAX_RAM}M" /usr/local/etc/php/php.ini
}
_filePermissions() {
echo "[i] Setting file permissions"
}
_buildConfig() {
echo "<?php"
echo "define('URL', '${URL:-}');"
echo "define('TITLE', '${TITLE:-PictShare}');"
echo "define('ALLOWED_SUBNET', '${ALLOWED_SUBNET:-}');"
echo "define('CONTENTCONTROLLERS', '${CONTENTCONTROLLERS:-}');"
echo "define('MASTER_DELETE_CODE', '${MASTER_DELETE_CODE:-}');"
echo "define('MASTER_DELETE_IP', '${MASTER_DELETE_IP:-}');"
echo "define('UPLOAD_CODE', '${UPLOAD_CODE:-}');"
echo "define('LOG_UPLOADER', ${LOG_UPLOADER:-false});"
echo "define('MAX_RESIZED_IMAGES',${MAX_RESIZED_IMAGES:--1});"
echo "define('SHOW_ERRORS', ${SHOW_ERRORS:-false});"
echo "define('JPEG_COMPRESSION', ${JPEG_COMPRESSION:-90});"
echo "define('PNG_COMPRESSION', ${PNG_COMPRESSION:-6});"
echo "define('ALT_FOLDER', '${ALT_FOLDER:-}');"
echo "define('S3_BUCKET', '${S3_BUCKET:-}');"
echo "define('S3_ACCESS_KEY', '${S3_ACCESS_KEY:-}');"
echo "define('S3_SECRET_KEY', '${S3_SECRET_KEY:-}');"
echo "define('S3_ENDPOINT', '${S3_ENDPOINT:-}');"
echo "define('S3_REGION', '${S3_REGION:-}');"
echo "define('FTP_SERVER', '${FTP_SERVER:-}');"
echo "define('FTP_PORT', ${FTP_PORT:-21});"
echo "define('FTP_USER', '${FTP_USER:-}');"
echo "define('FTP_PASS', '${FTP_PASS:-}');"
echo "define('FTP_PASSIVEMODE', ${FTP_PASSIVEMODE:-true});"
echo "define('FTP_SSL', ${FTP_SSL:-false});"
echo "define('FTP_BASEDIR', '${FTP_BASEDIR:-}');"
echo "define('ENCRYPTION_KEY', '${ENCRYPTION_KEY:-}');"
echo "define('FFMPEG_BINARY', '${FFMPEG_BINARY:-/usr/bin/ffmpeg}');"
echo "define('ALWAYS_WEBP', ${ALWAYS_WEBP:-false});"
echo "define('ALLOWED_DOMAINS', '${ALLOWED_DOMAINS:-}');"
echo "define('SPLIT_DATA_DIR', ${SPLIT_DATA_DIR:-false});"
echo "define('LOG_VIEWS', ${LOG_VIEWS:-false});"
echo "define('REDIS_CACHING', ${REDIS_CACHING:-true});"
echo "define('REDIS_SERVER', '${REDIS_SERVER:-/run/redis/redis.sock}');"
echo "define('REDIS_PORT', ${REDIS_PORT:-6379});"
echo "define('ADMIN_PASSWORD', '${ADMIN_PASSWORD:-}');"
}
# starting redis
if [[ ${REDIS_CACHING:=true} == true ]]; then
echo "[i] Redis steps"
# tell redis how often to save
## save <seconds> <changes>
echo " [+] Configuring Redis save intervals"
echo "save 60 100" >> /etc/redis.conf # every minute if at least 100 keys changed
echo "save 300 10" >> /etc/redis.conf # every 5 minutes if at least 10 keys changed
echo "save 600 1" >> /etc/redis.conf # every 10 minutes if at least 1 key changed
# Trap SIGTERM and SIGINT signals to save Redis data before shutdown
trap "echo 'Stopping Redis'; redis-cli save; redis-cli shutdown; exit" TERM INT
redis-server /etc/redis.conf --daemonize yes
fi
######### main
echo 'Starting Pictshare'
cd /app/public/
if [[ ${MAX_UPLOAD_SIZE:=100} =~ ^[0-9]+$ ]]; then
_maxUploadSize
fi
# run _filePermissions function unless SKIP_FILEPERMISSIONS is set to true
if [[ ${SKIP_FILEPERMISSIONS:=false} != true ]]; then
_filePermissions
fi
echo ' [+] Creating config'
_buildConfig > src/inc/config.inc.php
frankenphp run --config /etc/caddy/Caddyfile

View File

@@ -1,501 +0,0 @@
<?php
spl_autoload_register('autoload');
//disable output buffering
if (ob_get_level()) ob_end_clean();
error_reporting(E_ALL & ~E_NOTICE);
if(!defined('FFMPEG_BINARY'))
define('FFMPEG_BINARY',ROOT.DS.'bin'.DS.'ffmpeg');
/**
* The Architect function is the main controller
* who will decide what to do with any given URL
* by feeding it to the other controllers
*/
function architect($url)
{
//let's get the parts of the URL as array
//and clean out the empty elements
$u = array_filter(explode('/', $url));
//if there is no info in the URL, don't even bother checking with the controllers
//just show the site
if( ( (!defined('UPLOAD_FORM_LOCATION') || (defined('UPLOAD_FORM_LOCATION') && !UPLOAD_FORM_LOCATION)) && count($u)==0) || (defined('UPLOAD_FORM_LOCATION') && UPLOAD_FORM_LOCATION && '/'.implode('/',$u)==UPLOAD_FORM_LOCATION) )
{
renderTemplate('main');
return;
}
//check all elements for a valid hash
$hash = false;
foreach($u as $el)
{
if(isExistingHash($el))
{
$hash = $el;
break;
}
// if we don't have a hash yet but the element looks like it could be a hash
if($hash === false && mightBeAHash($el))
{
if(!$sc)
$sc = getStorageControllers();
foreach($sc as $contr)
{
$c = new $contr();
if($c->isEnabled()===true && $c->hashExists($el))
{
$c->pullFile($el);
$hash = $el;
break; // we brake here because we already have the file. no need to check other storage controllers
}
}
}
}
//we didn't find a hash. send error 404
if($hash===false)
{
http_response_code(404);
die("404");
}
else
{
//ok we have a valid hash.
//is the user requesting this file to be deleted?
foreach($u as $el)
{
if(startsWith($el,'delete_'))
{
$code = substr($el,7);
//@todo: allow MASTER_DELETE_IP to be CIDR range or coma separated
if(getDeleteCodeOfHash($hash)==$code || (defined('MASTER_DELETE_CODE') && MASTER_DELETE_CODE==$code ) || (defined('MASTER_DELETE_IP') && MASTER_DELETE_IP==getUserIP()) )
{
deleteHash($hash);
exit($hash.' deleted successfully');
}
}
}
//Now let's check the extension to find out which controller will be handling this request
$extension = pathinfo($hash, PATHINFO_EXTENSION);
//First, check if URL is an image
if(in_array($extension,(new ImageController)->getRegisteredExtensions()))
{
(new ImageController())->handleHash($hash,$u);
}
//or, a url
else if(in_array($extension,(new UrlController)->getRegisteredExtensions()))
{
var_dump("Url");
}
//or, a text
else if(in_array($extension,(new TextController)->getRegisteredExtensions()))
{
(new TextController())->handleHash($hash,$u);
}
//or, a video
else if(in_array($extension,(new VideoController)->getRegisteredExtensions()))
{
(new VideoController())->handleHash($hash,$u);
}
//very odd. We know it's a valid hash but no controller says it's one of their kids
//oh well
else
{
var_dump("odd err");
}
}
//var_dump($u);
}
function getNewHash($type,$length=10)
{
while(1)
{
$hash = getRandomString($length).'.'.$type;
if(!isExistingHash($hash)) return $hash;
$length++;
}
}
function isExistingHash($hash)
{
return is_dir(ROOT.DS.'data'.DS.$hash);
}
function mightBeAHash($string)
{
$len = strlen($string);
$dot = strpos($string,'.');
if(substr_count($string,'.')!=1) return false;
if(!$dot) return false;
$afterdot = substr($string,$dot+1);
//@todo: maybe pull all allowed types and compare to afterdot
return ($afterdot && strlen($afterdot)>=2 && strlen($afterdot)<=5 );
}
function autoload($className)
{
if (file_exists(ROOT . DS . 'content-controllers' . DS . strtolower($className) . '.php'))
require_once(ROOT . DS . 'content-controllers' . DS . strtolower($className) . '.php');
if (file_exists(ROOT . DS . 'interfaces' . DS . strtolower($className) . '.interface.php'))
require_once(ROOT . DS . 'interfaces' . DS . strtolower($className) . '.interface.php');
}
function renderTemplate($template,$vars=false)
{
if(is_array($vars))
extract($vars);
include_once(ROOT.DS.'templates'.DS.$template.'.html');
}
function getExtensionOfFilename($file)
{
return pathinfo($file, PATHINFO_EXTENSION);
}
function sizeStringToWidthHeight($size)
{
if(!$size || !isSize($size)) return false;
if(!is_numeric($size))
$size = explode('x',$size);
if(is_array($size))
{
$maxwidth = $size[0];
$maxheight = $size[1];
}
else if($size)
{
$maxwidth = $size;
$maxheight = $size;
}
return array('width'=>$maxwidth,'height'=>$maxheight);
}
//
// from: https://stackoverflow.com/questions/25975943/php-serve-mp4-chrome-provisional-headers-are-shown-request-is-not-finished-ye
//
function serveFile($filename, $filename_output = false, $mime = 'application/octet-stream')
{
$buffer_size = 8192;
$expiry = 90; //days
if(!file_exists($filename))
{
throw new Exception('File not found: ' . $filename);
}
if(!is_readable($filename))
{
throw new Exception('File not readable: ' . $filename);
}
header_remove('Cache-Control');
header_remove('Pragma');
$byte_offset = 0;
$filesize_bytes = $filesize_original = filesize($filename);
header('Accept-Ranges: bytes', true);
header('Content-Type: ' . $mime, true);
header("Content-Disposition: inline;");
// Content-Range header for byte offsets
if (isset($_SERVER['HTTP_RANGE']) && preg_match('%bytes=(\d+)-(\d+)?%i', $_SERVER['HTTP_RANGE'], $match))
{
$byte_offset = (int) $match[1];//Offset signifies where we should begin to read the file
if (isset($match[2]))//Length is for how long we should read the file according to the browser, and can never go beyond the file size
{
$filesize_bytes = min((int) $match[2], $filesize_bytes - $byte_offset);
}
header("HTTP/1.1 206 Partial content");
header(sprintf('Content-Range: bytes %d-%d/%d', $byte_offset, $filesize_bytes - 1, $filesize_original)); ### Decrease by 1 on byte-length since this definition is zero-based index of bytes being sent
}
$byte_range = $filesize_bytes - $byte_offset;
header('Content-Length: ' . $byte_range);
header('Expires: ' . date('D, d M Y H:i:s', time() + 60 * 60 * 24 * $expiry) . ' GMT');
$buffer = '';
$bytes_remaining = $byte_range;
$handle = fopen($filename, 'r');
if(!$handle)
{
throw new Exception("Could not get handle for file: " . $filename);
}
if (fseek($handle, $byte_offset, SEEK_SET) == -1)
{
throw new Exception("Could not seek to byte offset %d", $byte_offset);
}
while ($bytes_remaining > 0)
{
$chunksize_requested = min($buffer_size, $bytes_remaining);
$buffer = fread($handle, $chunksize_requested);
$chunksize_real = strlen($buffer);
if ($chunksize_real == 0)
{
break;
}
$bytes_remaining -= $chunksize_real;
echo $buffer;
flush();
}
}
function sanatizeString($string)
{
return preg_replace("/[^a-zA-Z0-9._\-]+/", "", $string);
}
function renderSize($byte)
{
if($byte < 1024) {
$result = round($byte, 2). ' Byte';
}elseif($byte < pow(1024, 2)) {
$result = round($byte/1024, 2).' KB';
}elseif($byte >= pow(1024, 2) and $byte < pow(1024, 3)) {
$result = round($byte/pow(1024, 2), 2).' MB';
}elseif($byte >= pow(1024, 3) and $byte < pow(1024, 4)) {
$result = round($byte/pow(1024, 3), 2).' GB';
}elseif($byte >= pow(1024, 4) and $byte < pow(1024, 5)) {
$result = round($byte/pow(1024, 4), 2).' TB';
}elseif($byte >= pow(1024, 5) and $byte < pow(1024, 6)) {
$result = round($byte/pow(1024, 5), 2).' PB';
}elseif($byte >= pow(1024, 6) and $byte < pow(1024, 7)) {
$result = round($byte/pow(1024, 6), 2).' EB';
}
return $result;
}
function getTypeOfFile($url)
{
$fi = new finfo(FILEINFO_MIME);
$type = $fi->buffer(file_get_contents($url, false, null, -1, 1024));
// on linux use the "file" command or it will handle everything as octet-stream
if(strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN' && startsWith($type,'application/octet-stream'))
{
$content_type = exec("file -bi " . escapeshellarg($url));
if($content_type && $content_type!=$type && strpos($content_type,'/')!==false && strpos($content_type,';')!==false)
$type = $content_type;
}
if(startsWith($type,'text')) return 'text';
$arr = explode(';', trim($type));
if(count($arr)>1)
{
$a2 = explode('/', $arr[0]);
$type = $a2[1];
}
else
{
$a2 = explode('/', $type);
$type = $a2[1];
}
if($type=='octet-stream' && (new VideoController())->isProperMP4($url)) return 'mp4';
if($type=='mp4' && !(new VideoController())->isProperMP4($url))
return false;
return $type;
}
function isFolderWritable($dir){return is_writable($dir);}
function getRandomString($length=32, $keyspace = '0123456789abcdefghijklmnopqrstuvwxyz')
{
$str = '';
$max = mb_strlen($keyspace, '8bit') - 1;
for ($i = 0; $i < $length; ++$i) {
$str .= $keyspace[rand(0, $max)];
}
return $str;
}
function startsWith($haystack,$needle)
{
$length = strlen($needle);
return (substr($haystack,0,$length) === $needle);
}
function endswith($string, $test) {
$strlen = strlen($string);
$testlen = strlen($test);
if ($testlen > $strlen) return false;
return substr_compare($string, $test, $strlen - $testlen, $testlen) === 0;
}
function getUserIP()
{
$client = @$_SERVER['HTTP_CLIENT_IP'];
$forward = @$_SERVER['HTTP_X_FORWARDED_FOR'];
$remote = $_SERVER['REMOTE_ADDR'];
if(strpos($forward,','))
{
$a = explode(',',$forward);
$forward = trim($a[0]);
}
if(filter_var($forward, FILTER_VALIDATE_IP))
{
$ip = $forward;
}
elseif(filter_var($client, FILTER_VALIDATE_IP))
{
$ip = $client;
}
else
{
$ip = $remote;
}
return $ip;
}
// checks the list of uploaded files for this hash
function sha1Exists($sha1)
{
$handle = fopen(ROOT.DS.'data'.DS.'sha1.csv', "r");
if ($handle) {
while (($line = fgets($handle)) !== false) {
if(substr($line,0,40)==$sha1) return trim(substr($line,41));
}
fclose($handle);
}
return false;
}
//adds new sha to the hash list
function addSha1($hash,$sha1)
{
if(sha1Exists($sha1)) return;
$fp = fopen(ROOT.DS.'data'.DS.'sha1.csv','a');
fwrite($fp,"$sha1;$hash\n");
fclose($fp);
return true;
}
function isSize($var)
{
if(is_numeric($var)) return true;
$a = explode('x',$var);
if(count($a)!=2 || !is_numeric($a[0]) || !is_numeric($a[1])) return false;
return true;
}
function getStorageControllers()
{
$controllers = array();
if ($handle = opendir(ROOT.DS.'storage-controllers')) {
while (false !== ($entry = readdir($handle))) {
if ($entry != "." && $entry != "..") {
if(endswith($entry,'.controller.php'))
{
$controllers[] = ucfirst(substr($entry,0,-15)).'Storage';
include_once(ROOT.DS.'storage-controllers'.DS.$entry);
}
}
}
closedir($handle);
}
return $controllers;
}
function getAllContentControllers()
{
$controllers = array();
if ($handle = opendir(ROOT.DS.'content-controllers')) {
while (false !== ($entry = readdir($handle))) {
if ($entry != "." && $entry != "..") {
if(is_dir(ROOT.DS.'content-controllers'.DS.$entry) && file_exists(ROOT.DS.'content-controllers'.DS.$entry.DS."$entry.controller.php"))
{
$controllers[] = ucfirst($entry).'Controller';
include_once(ROOT.DS.'content-controllers'.DS.$entry.DS."$entry.controller.php");
}
}
}
closedir($handle);
}
return $controllers;
}
function getAllContentFiletypes()
{
$types = array();
$controllers = getAllContentControllers(true);
foreach($controllers as $c)
{
$types = array_merge($types,(new $c)->getRegisteredExtensions());
}
return $types;
}
function rrmdir($dir) {
if (is_dir($dir)) {
$objects = scandir($dir);
foreach ($objects as $object) {
if ($object != "." && $object != "..") {
if (is_dir($dir."/".$object))
rrmdir($dir."/".$object);
else
unlink($dir."/".$object);
}
}
rmdir($dir);
}
}
function storeFile($srcfile,$hash,$deleteoriginal=false)
{
if(is_dir(ROOT.DS.'data'.DS.$hash) && file_exists(ROOT.DS.'data'.DS.$hash.DS.$hash)) return;
mkdir(ROOT.DS.'data'.DS.$hash);
$file = ROOT.DS.'data'.DS.$hash.DS.$hash;
copy($srcfile, $file);
if($deleteoriginal===true)
unlink($srcfile);
addSha1($hash,sha1_file($file));
//creating a delete code
$deletecode = getRandomString(32);
$fh = fopen(ROOT.DS.'data'.DS.$hash.DS.'deletecode', 'w');
fwrite($fh, $deletecode);
fclose($fh);
if(defined('LOG_UPLOADER') && LOG_UPLOADER)
{
$fh = fopen(ROOT.DS.'data'.DS.'uploads.csv', 'a');
fwrite($fh, time().';'.$url.';'.$hash.';'.getUserIP()."\n");
fclose($fh);
}
}
function getDeleteCodeOfHash($hash)
{
return file_get_contents(ROOT.DS.'data'.DS.$hash.DS.'deletecode');
}
function deleteHash($hash)
{
//delete all local images
rrmdir(ROOT.DS.'data'.DS.$hash);
//tell every storage controller to delete theirs as well
$sc = getStorageControllers();
foreach($sc as $contr)
{
$c = new $contr();
if($c->isEnabled()===true && $c->hashExists($el))
{
$c->deleteFile($el);
}
}
}

View File

@@ -1,14 +0,0 @@
<?php
/**
* All settings that are uncommented are mandatory
* Others optional
*/
//Use a specific domain for links presented to the user
//Format: https://your.domain.name/
// MUST HAVE TAILING /
define('URL','https://dev.pictshare.net/');
//define('JPEG_COMPRESSION', 90);
//define('FFMPEG_BINARY','');
//define('ALT_FOLDER','/ftp/pictshare');

View File

@@ -1,21 +0,0 @@
<?php
// basic path definitions
define('DS', DIRECTORY_SEPARATOR);
define('ROOT', dirname(__FILE__));
//loading default settings if exist
if(!file_exists(ROOT.DS.'inc'.DS.'config.inc.php'))
exit('Rename /inc/example.config.inc.php to /inc/config.inc.php first!');
include_once(ROOT.DS.'inc'.DS.'config.inc.php');
//loading core and controllers
include_once(ROOT.DS.'inc'.DS.'core.php');
require_once(ROOT . DS . 'content-controllers' . DS. 'image'. DS . 'image.controller.php');
require_once(ROOT . DS . 'content-controllers' . DS. 'text'. DS . 'text.controller.php');
require_once(ROOT . DS . 'content-controllers' . DS. 'url'. DS . 'url.controller.php');
require_once(ROOT . DS . 'content-controllers' . DS. 'video'. DS . 'video.controller.php');
//send the URL to the architect. It'll know what to do
$url = $_GET['url'];
architect($url);

2377
js/bootstrap.js vendored

File diff suppressed because it is too large Load Diff

7
js/bootstrap.min.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,19 +0,0 @@
Dropzone.autoDiscover = false;
$(function() {
var myDropzone = new Dropzone("#dropzone");
myDropzone.on("success", function(file,response) {
console.log("raw response: "+response);
if(response==null || response =="null")
$("#uploadinfo").append("<div class='alert alert-danger' role='alert'><strong>Error uploading "+file.name+"</strong><br/>Reason is unknown :(</div>")
else
{
var o = JSON.parse(response);
if(o.status=='ok')
$("#uploadinfo").append("<div class='alert alert-success' role='alert'><strong>"+file.name+"</strong> uploaded as <a target='_blank' href='/"+o.hash+"'>"+o.hash+"</a><br/>URL: <a target='_blank' href='"+o.url+"'>"+o.url+"</a></div>")
else if(o.status=='err')
$("#uploadinfo").append("<div class='alert alert-danger' role='alert'><strong>Error uploading "+file.name+"</strong><br/>Reason: "+o.reason+"</div>")
console.log(o)
}
});
})

2
logs/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
*
!.gitignore

View File

@@ -1,15 +1,15 @@
# API
## upload.php
# upload
- URL https://pictshare.net/api/upload.php
- URL https://pictshare.net/api/upload
- Method: POST file
- Post var name: file
- Answer type: JSON
If the upload was successful answer will look like this
```
```json
{
"status":"ok",
"hash":"y1b6hr.jpg",
@@ -19,7 +19,7 @@ If the upload was successful answer will look like this
If there is an error the server will answer with status:err and a reason
```
```json
{
"status":"err",
"reason":"Unsupported filetype"
@@ -30,21 +30,117 @@ If there is an error the server will answer with status:err and a reason
1. Uploading a file called test.jpg via curl
```curl -F "file=@test.jpg" https://pictshare.net/api/upload.php```
```curl -F "file=@test.jpg" https://pictshare.net/api/upload```
Answer from the server:
```{"status":"ok","hash":"y1b6hr.jpg","url":"https://pictshare.net/y1b6hr.jpg"}```
```json
{"status":"ok","hash":"y1b6hr.jpg","url":"https://pictshare.net/y1b6hr.jpg"}
```
2. Uploading a file called test.jpg via curl and requesting a custom hash
2. Uploading from the commandline using alias, requires `jq` package for json response decoding
```curl -F "file=@test.jpg" -F "hash=helloworld.jpg" https://pictshare.net/api/upload.php```
Put this in your `.bashrc` or `.zshrc`:
```
pict () {
curl -s -F "file=@${1:--}" https://pictshare.net/api/upload | jq -r '.url';
}
```
Usage:
```
$ cat path/to/image.jpg | pict
```
Repsonse:
```
https://pictshare.net/y1b6hr.jpg
```
# geturl.php
- URL https://pictshare.net/api/geturl.php
- Method: GET
- Var name: url
- Answer type: JSON
Upload content by providing a link to the content. If the link points to a website, the HTML of the page is uploaded as a text bin.
```json
{
"status":"ok",
"hash":"y1b6hr.jpg",
"url":"https://pictshare.net/y1b6hr.jpg",
"delete_code": "aqxqlv3kqokxd15xpkqp8zjljpqerveu",
"delete_url": "https://pictshare.net/delete_aqxqlv3kqokxd15xpkqp8zjljpqerveu/2mr2va.txt"
}
```
If there is an error the server will answer with status:err and a reason
```json
{
"status":"err",
"reason":"Unsupported filetype"
}
```
### Examples
1. Uploading the HTML of xkcd.com
```curl -s https://pictshare.net/api/geturl.php?url=https://xkcd.com```
Answer from the server:
```{"status":"ok","hash":"helloworld.jpg","url":"https://pictshare.net/helloworld.jpg"}```
```json
{
"status": "ok",
"hash": "2mr2va.txt",
"url": "https://pictshare.net/2mr2va.txt",
"filetype": "text",
"delete_code": "aqxqlv3kqokxd15xpkqp8zjljpqerveu",
"delete_url": "https://pictshare.net/delete_aqxqlv3kqokxd15xpkqp8zjljpqerveu/2mr2va.txt"
}
```
2. Uploading a Video from Imgur
```curl https://pictshare.net/api/geturl.php?url=https://i.imgur.com/qQstLQt.mp4```
Answer from the server:
```json
{
"status": "ok",
"hash": "u0ni1m.mp4",
"url": "https://pictshare.net/u0ni1m.mp4",
"filetype": "mp4",
"delete_code": "aqxqlv3kqokxd15xpkqp8zjljpqerveu",
"delete_url": "https://pictshare.net/delete_aqxqlv3kqokxd15xpkqp8zjljpqerveu/u0ni1m.mp4"
}
```
3. Uploading from the commandline using alias, requires `jq` package for json response decoding
Put this in your `.bashrc` or `.zshrc`:
```
pictget () {
curl -s "hhttps://pictshare.net/api/geturl.php?url=$1" | jq -r '.url';
}
```
Usage:
```
$ pictget https://i.imgur.com/qQstLQt.mp4
```
Repsonse:
```
https://pictshare.net/u0ni1m.mp4
```
---
## pasetebin.php
# pasetebin.php
- URL https://pictshare.net/api/pastebin.php
- Method: POST/GET text
- Post var name: api_paste_code
@@ -56,7 +152,54 @@ This API can be used to directly post text. Server responds with the URL to the
Creating a new text bin that ready "Hello World"
```url -F "api_paste_code=Hello World" https://pictshare.net/api/pastebin.php```
```curl -F "api_paste_code=Hello World" https://pictshare.net/api/pastebin.php```
Answer from the server:
```https://pictshare.net/vekjy4e5rr.txt```
```https://pictshare.net/vekjy4e5rr.txt```
# info.php
- URL https://pictshare.net/api/info.php
- Method: POST/GET text
- Query var name: hash
- Answer: JSON
This API will get information about any given hash.
## Example
```curl https://pictshare.net/api/info.php?hash=9k3rbw.mp4```
Answer from the server:
```json
{
"status": "ok",
"hash": "9k3rbw.mp4",
"size_bytes": 2513225,
"size_interpreted": "2.4 MB",
"type": "video/mp4",
"type_interpreted": "mp4"
}
```
# base64.php
- URL https://pictshare.net/api/upload
- Query var name: base64
- Answer: JSON
## Example
Upload local image "test.jpg" to pictshare
```(echo -n "base64="; echo -n "data:image/jpeg;base64,$(base64 -w 0 test.jpg)") | curl --data @- https://pictshare.net/api/upload```
```json
{
"status": "ok",
"hash": "lpl119.jpg",
"url": "https://dev.pictshare.net/lpl119.jpg",
"filetype": "jpeg",
"delete_code": "z0e1mdo8szxnauspxp2f080e4wd4ycf2",
"delete_url": "https://dev.pictshare.net/delete_z0e1mdo8szxnauspxp2f080e4wd4ycf2/lpl119.jpg"
}
```

View File

@@ -1,9 +1,14 @@
# Configuration
PictShare can be configured using a single file: `inc/config.inc.php`
In this file you can set the following options. For a simple working example config file check out [/inc/example.config.inc.php](/inc/example.config.inc.php)
# Config options
|Option | value type | What it does|
|--- | --- | ---|
| URL | string | Sets the URL that will be shown to users for each upload. Must be set and must have tailing slash. eg: http://pictshare.local/ |
| ALT_FOLDER | string | All uploaded files will be copied to this location. This location can be a mounted network share (eg NFS or FTP, etc). If a file is not found in the normal upload direcotry, ALT_FOLDER will be checked. [more info about scaling PictShare](/rtfm/SCALING.md) |
| LOG_UPLOADER | bool | If set to true, all IP addresses of uploaders will be stored in /data/uploads.csv |
| FFMPEG_BINARY | string | If you installed ffmpeg on your machine, you can set the binary path here. This allows devices like the Raspberry Pi to be used with PictShare although I wouldn't recommend it because of the sloooooow conversion speed |
| PNG_COMPRESSION | int | 0 (no compression) to 9 (best compression) Note that for PNGs the compression doesn't affect the quality of the image, just the en/decode speed and file size |
@@ -12,6 +17,83 @@
| MASTER_DELETE_CODE | string | If set, this code will be accepted to delete any image by adding "delete_yourmasterdeletecode" to any image |
| MASTER_DELETE_IP | IP addr | If set, allows deletion of image no matter what delete code you provided if request is coming from this single IP |
| UPLOAD_FORM_LOCATION | string | If set, will only show the upload form if this url is requested. eg if you set it to /secret/upload then you only see the form if you go to http://your.pictshare.server/secret/upload but bare in mind that the uploads [via API](/rtfm/API.md) will still work for anyone|
| ALLOWED_SUBNET | IPv4 or IPv6 CIDR | If set, will limit uploads to IPs that match this CIDR |
| ALWAYS_WEBP | bool | If set to `true`, JPGs will always be served as WebP, if the client supports it (if `image/webp` is in header `HTTP_ACCEPT`) |
| UPLOAD_CODE | string | If set, all uploads require this code via GET or POST variable "uploadcode" to succeed |
| REDIS_SERVER (NOT IMPLEMENTED) | IP | If you define a REDIS server IP here, it will enable you to use the FFMPEG Worker |
| UPLOAD_QUOTA (NOT IMPLEMENTED) | int | Size in MB. If set, will only allow uploads if combined size of uploads on Server is smaller than this value. Does not account for ALT_FOLDER data and resized versions of original uploads won't be added to calculation |
| UPLOAD_CODE (NOT IMPLEMENTED | string | If set, all uploads require this code via GET or POST variable "uploadcode" or upload will fail |
| MAX_RESIZED_IMAGES (NOT IMPLEMENTED | string | If set, limits count of resized images/videos per file on server |
| MAX_RESIZED_IMAGES (NOT IMPLEMENTED ) | string | If set, limits count of resized images/videos per file on server |
| LOG_VIEWS | bool | If set, will log all views into the ./logs/app.log. Pretty resource heavy, only use for debugging purposes |
| REDIS_CACHING | bool | true by default, Used to cache URL to file mapping. If set to false, PictShare will not use Redis for caching. This is not recommended as it will slow down the server significantly |
| REDIS_SERVER | string | IP address of the Redis server. If set, PictShare will use this server for caching. If not set, PictShare will use the default Redis server on localhost |
# Content controllers
PictShare is not limited to handling just images. Various content types including txt,mp4 and even url shortenings are supported.
By default all of these are enabled but if you only need one or more, you can whitelist them and all others won't be accessible.
|Option | value type | What it does|
|--- | --- | ---|
| CONTENTCONTROLLERS | CSV string | If set, will whitelist content controllers for your instance. Must be uppercase and can be comma separated. Example: Only Pictures: `IMAGE`, Pictures and Videos: `IMAGE,VIDEO` |
Available values for the `CONTENTCONTROLLERS` setting are:
- IMAGE
- TEXT
- VIDEO
- URL
# Storage controllers
PictShare has an extention system that allows handling of multiple storage solutions or backends. If a requested file is not found locally, PictShare will ask all configured storage controllers if they have it, then download and serve it to the user.
If you want data on your external storage to be **encrypted**, you can set the following config setting. En/decryption is done automatically on up/download.
|Option | value type | What it does|
|--- | --- | ---|
|ENCRYPTION_KEY | base64 string | The key used to encrypt/decrypt files stored in storage controllers. See [/rtfm/ENCRYPTION.md](/rtfm/ENCRYPTION.md) for setup guide |
### Alternative Folder
The ALT_FOLDER option will copy every uploaded file from PictShare to a local path of your choice. This can be used to allow two instances of PictShare to serve the same data. Eg. you can mount a NFS share on your server and configure the ALT_FOLDER variable to point to that folder. All images are then stored on the NFS as well as your PictShare server.
|Option | value type | What it does|
|--- | --- | ---|
| ALT_FOLDER | string | All uploaded files will be copied to this location. This location can be a mounted network share (eg NFS or FTP, etc). If a file is not found in the normal upload direcotry, ALT_FOLDER will be checked. [more info about scaling PictShare](/rtfm/SCALING.md) |
### S3 (compatible) storage
You can also store all uploaded files on S3 or S3 compatible storage like [Minio](https://min.io/). This can also be used to scale your PictShare instance and have multiple distributed servers to serve the same files.
|Option | value type | What it does|
|--- | --- | ---|
|S3_BUCKET | string | Name of your [S3 bucket](https://aws.amazon.com/s3/) |
|S3_ACCESS_KEY | string | Access key for your bucket|
|S3_SECRET_KEY | string | Secret key for your bucket |
|S3_ENDPOINT | URL | Server URL. If you're using S3 compatible software like [Minio](https://min.io/) you can enter the URL here |
|S3_REGION | string | Region of your bucket |
### FTP
Oldschool, insecure and not that fast. But if you use it in combination with [Encryption](/rtfm/ENCRYPTION.md) this could be OK I guess. I don't judge.
This probably requires the php-ftp package but on some platforms it's included in the php-common package.
|Option | value type | What it does|
|--- | --- | ---|
|FTP_SERVER | string | IP or hostname of your FTP Server |
|FTP_PORT | int | Port number of your FTP Server. Defaults to 21 |
|FTP_SSL | bool | If your FTP server supports SSL-FTP (note: not sFTP! not the same), set it to true |
|FTP_USER | string | FTP Username |
|FTP_PASS | string | FTP Password |
|FTP_BASEDIR | string | Base path where files will be stored. Must end with / eg `/web/pictshare/` |
|FTP_PASSIVEMODE | bool | Wether to use passive mode or not. If you have troubles with uploading, switch this setting maybe |
# FFMPEG Worker
For faster video en/transcoding there is a php script called `/tools/ffmpeg_worker.php` which is a CLI application looping every second, checking the REDIS Queue for encoding tasks.
This way the rendering queue is detached from php-fpm since PHP can't have threaded workloads and it will make sure a encoding task like resizing of a video won't block the rest of the site from functioning.
For the FFMPEG Worker to be enabled, the config option `REDIS_SERVER` must be set to the IP Address of a redis server.

View File

@@ -1,32 +1,81 @@
# Docker
The fastest way to deploy PictShare is via the [official Docker repo](https://hub.docker.com/r/hascheksolutions/pictshare/)
- [Source code & more examples](https://github.com/HaschekSolutions/PictShare-Docker)
The fastest way to deploy PictShare is via the [official Docker package](https://github.com/HaschekSolutions/pictshare/pkgs/container/pictshare)
```bash
docker run -d -p 80:80 -e "TITLE=My own PictShare" -e "URL=http://localhost/" hascheksolutions/pictshare
docker run -d -p 80:80 -e "TITLE=My own PictShare" -e "URL=http://localhost/" hascheksolutions/pictshare:2
```
[![Docker setup](http://www.pictshare.net/b65dea2117.gif)](https://www.pictshare.net/8a1dec0973.mp4)
### Docker Compose With Prebuild Image by hascheksolutions
## Usage
Run container by docker-compose:
- First, install docker compose:
[Docker official docs](https://docs.docker.com/compose/install/)
- Pull docker-compose file:
### Building it
```bash
wget https://raw.githubusercontent.com/HaschekSolutions/pictshare/master/docker-compose.yml
```
- Edit docker-compose file:
```bash
vi docker-compose.yml
```
- Run container by docker-compose:
```bash
docker-compose up
docker build -t pictshare -f docker/Dockerfile .
```
By using this compose file, you should know that:
- Will make a directory "volumes" in the same directory where compose file is.
- Change `AUTOUPDATE` to false from true by defalt.
- And...it is highly recommended to build your own image.
### Quick start
```bash
docker run -d -p 80:80 --name=pictshare hascheksolutions/pictshare:2
```
### Persistent data
```bash
mkdir /data/pictshareuploads
chown 1000 -R /data/pictshareuploads
docker run -d -v /data/pictshareuploads:/var/www/data -p 80:80 --name=pictshare hascheksolutions/pictshare:2
```
### Persistent data with increased max upload size
```bash
mkdir /data/pictshareuploads
chown 1000 -R /data/pictshareuploads
docker run -d -e "MAX_UPLOAD_SIZE=1024" -v /data/pictshareuploads:/var/www/data -p 80:80 --name=pictshare hascheksolutions/pictshare:2
```
### Development
Using these commands it will mount the current directory in the docker container so you can develop locally without building after each change.
```bash
docker build -t pictshare -f docker/Dockerfile .
docker run -it --rm --name pictshare-dev -p 8080:80 -v $(pwd):/var/www -v $(pwd)/data:/var/www/data -e "URL=http://localhost:8080/" -e "SKIP_FILEPERMISSIONS=true" pictshare
```
## ENV Variables
There are some ENV variables that only apply to the Docker image
- MAX_UPLOAD_SIZE (int | size in MB that will be used for nginx. default 50)
Every other variable can be referenced against the [default PictShare configuration file](https://github.com/HaschekSolutions/pictshare/blob/master/inc/example.config.inc.php).
- TITLE (string | Title of the page)
- URL (string | URL that will be linked to new uploads)
- PNG_COMPRESSION (int | 0-9 how much compression is used. note that this never affects quality. default: 6)
- JPEG_COMPRESSION (int | 0-100 how high should the quality be? More is better. default: 90)
- MASTER_DELETE_CODE (string | code if added to any url, will delete the image)
- MASTER_DELETE_IP (string | ip which can delete any image)
- ALLOWED_SUBNET (CIDR IP range (can be comma separated) | IP subnets which are allowed to upload files)
- ALLOW_BLOATING (true/false | can images be bloated to higher resolutions than the originals)
- UPLOAD_CODE (string | Code that has to be supplied via POST or GET, to upload an image)
- UPLOAD_FORM_LOCATION (string | absolute path where upload gui will be shown)
- LOW_PROFILE (string | won't display error messages on failed uploads)
- IMAGE_CHANGE_CODE (string | code if provided, needs to be added to image to apply filter/rotation/etc)
- LOG_UPLOADER (true/false | log IPs of uploaders)
- MAX_RESIZED_IMAGES (int | how many versions of a single image may exist? -1 for infinite)
- SHOW_ERRORS (true/false | show upload/size/server errors?)
- SKIP_FILEPERMISSIONS (true/false | enables/disables fixing file permissions on start. default is false)
- ALWAYS_WEBP (true/false | Always tries to server JPGs as WEBp if the client supports it. Default is false)
- ALT_FOLDER (path to a folder where all hashes will be copied to and looked for offsite backup via nfs for example)
- S3_BUCKET (string | Name of your S3 bucket)
- S3_ACCESS_KEY (string | Access Key for your Bucket)
- S3_SECRET_KEY (string | Secrety Key)
- S3_REGION (string | S3 bucket region)
- S3_ENDPOINT (url | If you are using a selfhosted version of S3 like Minio, put your URL here)
- ENCRYPTION_KEY (string | If you want to use encryption for storage controllers, put your encryption key here. [Read more](https://github.com/HaschekSolutions/pictshare/blob/master/rtfm/ENCRYPTION.md))
- FTP_SERVER (string | IP or hostname of your FTP Server )
- FTP_PORT (int | Port of your FTP server (defaults to 21) )
- FTP_SSL (true/false | If FTP server supports SSL-FTP (not sFTP, thats not the same!))
- FTP_USER (string | FTP Username)
- FTP_PASS (string | FTP Password)
- FTP_BASEDIR (string | Base path where files will be stored. Must end with / eg `/web/pictshare/`)
- CONTENTCONTROLLERS (CSV string | If set, will whitelist content controllers for your instance. Must be uppercase and can be comma separated. Example: Only Pictures: `IMAGE`, Pictures and Videos: `IMAGE,VIDEO`)

37
rtfm/ENCRYPTION.md Normal file
View File

@@ -0,0 +1,37 @@
# Encryption
As of Jan. 2020 you can set up an encryption key in your config which will encrypt all images stored on [external storage](/rtfm/CONFIG.md#storage-controllers)
The files on the PictShare server are not encrypted, only the ones on external storage providers, eg if you want to use S3 as storage.
## Dependencies
To be able to use encryption you'll need the following extensions:
- mb-string (`apt-get install php-mbstring`)
- libsodium (`apt-get install php-libsodium`)
Since only files on [storage controllers](/rtfm/CONFIG.md#storage-controllers) are encrypted, you'll need to configure at least one.
## Preparation
First you'll need to generate a key and encode it in base64.
The easiest way to get it would be to run this command:
`php -r "echo base64_encode(sodium_crypto_secretstream_xchacha20poly1305_keygen());"`
This will output something like `SSdoJvp10ZvOY5v+vAcprxQKjNX1AzD52cAnFwr6yXc=`
Now put this output in your /inc/config.inc.php like this:
`define('ENCRYPTION_KEY','SSdoJvp10ZvOY5v+vAcprxQKjNX1AzD52cAnFwr6yXc=');`
**Warning: If you change or lose the ENCRYPTION_KEY, all encrypted data will be unrecoverably lost**
# How it works
If you have everything running you can upload a new image and it will get encrypted and uploaded to your storage container(s). This means you could even host on untrusted servers/buckets since nobody without the key will be able to decrypt it.
If you have uploaded a few files and see them on your storage container (eg S3) you'll notice the file has the '.enc' extension.
When you now wipe your PictShare instances local data folder and request the file again via the URL, the storage controller will pull the encrypted file, decrypt it and save it locally (unencrypted)

39
rtfm/IMAGEFILTERS.md Normal file
View File

@@ -0,0 +1,39 @@
# Filters for images
If the value field is defined you can use it like this: ```filtername_value```. eg: https://pictshare.net/pixelate_10/4qylps.jpg
Click on the images to see them in full size
| Filter | Value | Example image |
| --- | --- | --- |
| pixelate | 1-100 | [![](https://pictshare.net/pixelate/150/4qylps.jpg)](https://pictshare.net/pixelate/4qylps.jpg) |
| blur | 1-6 | [![](https://pictshare.net/blur/150/4qylps.jpg)](https://pictshare.net/blur/4qylps.jpg) |
| sepia | | [![](https://pictshare.net/sepia/150/4qylps.jpg)](https://pictshare.net/sepia/4qylps.jpg) |
| sepia2 | | [![](https://pictshare.net/sepia2/150/4qylps.jpg)](https://pictshare.net/sepia2/4qylps.jpg) |
| sharpen | | [![](https://pictshare.net/sharpen/150/4qylps.jpg)](https://pictshare.net/sharpen/4qylps.jpg) |
| emboss | | [![](https://pictshare.net/emboss/150/4qylps.jpg)](https://pictshare.net/emboss/4qylps.jpg) |
| cool | | [![](https://pictshare.net/cool/150/4qylps.jpg)](https://pictshare.net/cool/4qylps.jpg) |
| light | | [![](https://pictshare.net/light/150/4qylps.jpg)](https://pictshare.net/light/4qylps.jpg) |
| aqua | | [![](https://pictshare.net/aqua/150/4qylps.jpg)](https://pictshare.net/aqua/4qylps.jpg) |
| fuzzy | | [![](https://pictshare.net/fuzzy/150/4qylps.jpg)](https://pictshare.net/fuzzy/4qylps.jpg) |
| boost | | [![](https://pictshare.net/boost/150/4qylps.jpg)](https://pictshare.net/boost/4qylps.jpg) |
| boost2 | | [![](https://pictshare.net/boost2/150/4qylps.jpg)](https://pictshare.net/boost2/4qylps.jpg) |
| gray | | [![](https://pictshare.net/gray/150/4qylps.jpg)](https://pictshare.net/gray/4qylps.jpg) |
| antique | | [![](https://pictshare.net/antique/150/4qylps.jpg)](https://pictshare.net/antique/4qylps.jpg) |
| blackwhite | | [![](https://pictshare.net/blackwhite/150/4qylps.jpg)](https://pictshare.net/blackwhite/4qylps.jpg) |
| vintage | | [![](https://pictshare.net/vintage/150/4qylps.jpg)](https://pictshare.net/vintage/4qylps.jpg) |
| concentrate| | [![](https://pictshare.net/concentrate/150/4qylps.jpg)](https://pictshare.net/concentrate/4qylps.jpg) |
| hermajesty | | [![](https://pictshare.net/hermajesty/150/4qylps.jpg)](https://pictshare.net/hermajesty/4qylps.jpg) |
| everglow | | [![](https://pictshare.net/everglow/150/4qylps.jpg)](https://pictshare.net/everglow/4qylps.jpg) |
| freshblue | | [![](https://pictshare.net/freshblue/150/4qylps.jpg)](https://pictshare.net/freshblue/4qylps.jpg) |
| tender | | [![](https://pictshare.net/tender/150/4qylps.jpg)](https://pictshare.net/tender/4qylps.jpg) |
| dream | | [![](https://pictshare.net/dream/150/4qylps.jpg)](https://pictshare.net/dream/4qylps.jpg) |
| frozen | | [![](https://pictshare.net/frozen/150/4qylps.jpg)](https://pictshare.net/frozen/4qylps.jpg) |
| forest | | [![](https://pictshare.net/forest/150/4qylps.jpg)](https://pictshare.net/forest/4qylps.jpg) |
| rain | | [![](https://pictshare.net/rain/150/4qylps.jpg)](https://pictshare.net/rain/4qylps.jpg) |
| orangepeel | | [![](https://pictshare.net/orangepeel/150/4qylps.jpg)](https://pictshare.net/orangepeel/4qylps.jpg) |
| darken | | [![](https://pictshare.net/darken/150/4qylps.jpg)](https://pictshare.net/darken/4qylps.jpg) |
| summer | | [![](https://pictshare.net/summer/150/4qylps.jpg)](https://pictshare.net/summer/4qylps.jpg) |
| retro | | [![](https://pictshare.net/retro/150/4qylps.jpg)](https://pictshare.net/retro/4qylps.jpg) |
| country | | [![](https://pictshare.net/country/150/4qylps.jpg)](https://pictshare.net/country/4qylps.jpg) |
| washed | | [![](https://pictshare.net/washed/150/4qylps.jpg)](https://pictshare.net/washed/4qylps.jpg) |

View File

@@ -2,24 +2,29 @@
PictShare is written to be run on a linux server with PHP 7 and nginx. We tried to support Windows for some time but ever since we started integrating ffmpeg for MP4 hosting we ditched Windows.
- Make sure you have PHP7 GD libraries installed: ```apt-get install php-gd```
- Unpack the [PictShare zip](https://github.com/chrisiaut/pictshare/archive/master.zip)
It's highly recommended t hat you use [the official Docker container](https://github.com/HaschekSolutions/pictshare/pkgs/container/pictshare) so you don't have to do any manual setup. But if you know what you're doing, you can set it up yourself.
- Make sure you have all PHP7 libraries installed (note on some systems the packages are not called php7-* but just php-* also on some systems php7-mbstring is called php7-mb): ```apt-get install php7-exif php7-gd php7-json php7-openssl php7-fileinfo php7-mbstring php7-mcrypt```
- Run `composer install` from the `/lib` directory
- If you are not using windows, make sure your os have the ```file``` command working: ```apt-get install file```
- Unpack the [PictShare zip](https://github.com/hascheksolutions/pictshare/archive/master.zip)
- Rename /inc/example.config.inc.php to /inc/config.inc.php
- ```chmod +x bin/ffmpeg``` if you want to be able to use mp4 uploads
- The provided ffmpeg binary (bin/ffmpeg) is from [here](http://johnvansickle.com/ffmpeg/) and it's a 64bit linux executable. If you need a different one, load yours and overwrite the one provided or if you have ffmpeg installed on the server you can use the config var ```FFMPEG_BINARY``` to tell PictShare where to look for the binary
- If you want to be able to use mp4 uploads you need to supply your own FFMPEG binary or use the installed one on your distro useing the config var ```FFMPEG_BINARY```. For example it should point to `/usr/bin/ffmpeg` if you installed ffmpeg through your package manager
- Since default upload sizes will be 2M in PHP you should edit your php.ini and change ```upload_max_filesize``` and ```post_max_size``` to a larger value
- (optional) You can and should put a [nginx](https://www.nginx.com/) proxy before the Apache server. That thing is just insanely fast with static content like images.
- (optional) You can and should use [nginx](https://www.nginx.com/) as your web server. Check [/docker/rootfs/nginx.conf] for an example on how the nginx config should look like
- (optional) To secure your traffic I'd highly recommend getting an [SSL Cert](https://letsencrypt.org/) for your server if you don't already have one.
## Upgrading
- Just re-download the [PictShare zip](https://github.com/chrisiaut/pictshare/archive/master.zip) file and extract and overwrite existing pictshare files. Uploads and config won't be affected.
- Check if your ```/inc/config.inc.php``` file has all settings required by the ```/inc/example.config.inc.php``` since new options might get added in new versions
- On docker just `docker pull hascheksolutions/pictshare:2` and run the newer image
- Manual upgrade:
- Just re-download the [PictShare zip](https://github.com/hascheksolutions/pictshare/archive/master.zip) file and extract and overwrite existing pictshare files. Uploads and config won't be affected.
- Check if your ```/inc/config.inc.php``` file has all settings required by the ```/inc/example.config.inc.php``` since new options might get added in new versions
```bash
# to be run from the directory where your pictshare directory sits in
git clone https://github.com/chrisiaut/pictshare.git temp
git clone https://github.com/hascheksolutions/pictshare.git temp
cp -r temp/* pictshare/.
rm -rf temp
```
@@ -59,4 +64,4 @@ server {
}
}
```
```

View File

@@ -2,5 +2,141 @@
- [Pastebinit](/rtfm/PASTEBINIT.md)
- Chrome Browser extension: https://chrome.google.com/webstore/detail/pictshare-1-click-imagesc/mgomffcdpnohakmlhhjmiemlolonpafc
- Source: https://github.com/chrisiaut/PictShare-Chrome-extension
- Plugin to upload images with ShareX: https://github.com/ShareX/CustomUploaders/blob/master/pictshare.net.sxcu
- Source: https://github.com/hascheksolutions/PictShare-Chrome-extension
- Plugin to upload images with ShareX: https://github.com/ShareX/CustomUploaders/blob/master/pictshare.net.sxcu
# Upload from CLI
Requirements:
- curl (apt-get install curl)
- jq (apt-get install jq)
```bash
#!/bin/bash
# filename: pictshare.sh
# usage: ./pictshare.sh /path/to/image.jpg
result=$(curl -s -F "file=@${1}" https://pictshare.net/api/upload.php | jq -r .url)
echo $result
```
# Screenshot to pictshare (linux)
This script will create a screenshot (you can choose the area), uploads it to PictShare, copies the raw image to your clipborad and opens the image on PictShare in Chrome
Requirements:
- curl (apt-get install curl)
- jq (apt-get install jq)
- screenshooter (apt-get install xfce4-screenshooter)
```bash
#!/bin/bash
# filename: screenshot2pictshare.sh
# usage: ./screenshot2pictshare.sh
if [[ $# -eq 0 ]] ; then
xfce4-screenshooter -r -o $0
exit 0
fi
result=$(curl -s -F "file=@${1}" https://pictshare.net/api/upload.php | jq -r .url)
xclip -selection clipboard -t image/png -i $1
google-chrome $result
```
# Screenshot to pictshare (windows)
This script will upload a screenshot from [Greenshot](https://getgreenshot.org/) to PictShare with the help of a PowerShell script.
Requirements:
- curl (choco install curl)
- [PowerShell 7](https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-windows)
Configure Greenshot:
- Settings -> Output
- Storage location: C:\Temp\
- Filename pattern: GreenShot
- Image format: jpg
Create a new External command, under Settings -> Plugins -> Click on External command Plugin -> Configure -> New
- Name: what ever you want here
- Command: find and point to pwsh.exe
- Argument: -w Hidden -F Path\to\this\script -Address consto.com
Create a PowerShell script with the code below.
Feel free to change "C:\Temp\GreenShot.jpg" and "C:\Temp\pictshare_posts.json" to match your needs.
pictshare_posts.json is useful for logging and automating deleting old uploads.
```powershell
#Requires -Version 7
param (
# Change the base url to match your Pictshare server
[Parameter(Mandatory)][string]$Address,
# Change path of where you expect the jpg file to be
[string]$File = "C:\Temp\GreenShot.jpg",
# Log file of all requests
[string]$LogFile = "C:\Temp\pictshare_posts.json",
# Use http and not https
[switch]$IsNotHttps,
# Do not save url to upload to the clipboard
[switch]$NoSaveToClipboard
)
begin {
$Protocol = if ($IsNotHttps){
"http:"
}else{
"https:"
}
}
process {
# Upload screenshot
$Response = $(curl -s -F "file=@$File" $Protocol//$Address/api/upload.php) | ConvertFrom-Json
if ($Response.status -like "ok") {
if ($NoSaveToClipboard){
# Don't save url to clipboard
}else{
Set-Clipboard -Value $Response.url
}
}
# Output response back from the pictshare server
if($Response){
$Response | ConvertTo-Json | Out-File -FilePath $LogFile -Append
}
}
end {}
# PHP
```php
/*
* @param $path string Path to the file that should be uploaded
* @param $hash string Optional. File name we want on pictshare for the file
*/
function pictshareUploadImage($path,$hash=false)
{
if(!file_exists($path)) return false;
$request = curl_init('https://pictshare.net/api/upload.php');
curl_setopt($request, CURLOPT_POST, true);
curl_setopt(
$request,
CURLOPT_POSTFIELDS,
array(
'file' => curl_file_create($path),
'hash'=>$hash
));
// output the response
curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
$json = json_decode(curl_exec($request).PHP_EOL,true);
// close the session
curl_close($request);
return $json;
}
```

34
rtfm/MODIFIERS.md Normal file
View File

@@ -0,0 +1,34 @@
## Images
### Resize
```
/800x600/d8c01b45a6.png
```
width x height
### Rotate
```
/upside|left|right/d8c01b45a6.png
```
* `upside`: 180°
* `left`: 90°
* `right`: -90°
### WebP conversion
```
/webp/d8c01b45a6.jpeg
```
### Gif to mp4
```
/mp4/d8c01b45a6.gif
```
### Filters
```
/filter/d8c01b45a6.png
```
[See available filters](IMAGEFILTERS.md)

View File

@@ -1,6 +1,6 @@
# How to scale PictShare
If your library is huge then you might want to think about scaling your instances. Pictshare (v2+) was rebuilt with scaling in mind but instead of built-in scaling features we use a smarter system
If your library is huge then you might want to think about scaling your instances. Pictshare (v2+) was rebuilt with scaling in mind but instead of built-in scaling features we rely on OS level solutions.
# The "ALT_FOLDER" setting
You can set the config var ```ALT_FOLDER``` to point to a directory on the same server where pictshare will look for content and put new uploads.
@@ -9,4 +9,46 @@ This allows you to have a shared or even a mounted ftp/nfs folder that will act
The main site https://pictshare.net uses this technique to scale across many servers in multiple countries.
Using this method you can have multiple servers for the same domain (with a reverse proxy)
Using this method you can have multiple servers for the same domain (with a reverse proxy)
# Fast, read only instances
PictShare needs strong hardware for video conversion but using smart Nginx configurations you can host an instance on a weak but fast server and relay all uploads to another server with stronger hardware running PictShare
**Example Nginx config for a small VPS that relay all uploads to a faster but private server**
```
server {
listen 80;
server_name your.awesome.domain.name;
client_max_body_size 50M; # Set the max file upload size. This needs to be equal or larger than the size you specified in your php.ini
root /var/www/pictshare; # or where ever you put it
index index.php;
location / {
try_files $uri $uri/ /index.php?url=$request_uri;
}
# Magic begins here. Since all uploads have to be made via some script in the /api/ folder we can just redirect
# these requests to another server that doesn't need to be public facing
location ^~ /api/ {
proxy_pass http://10.12.0.3/; #set to the hostname or ip or url of the powerful server
include /etc/nginx/proxy_params;
}
location ~ \.php {
fastcgi_pass unix:/var/run/php/php7.3-fpm.sock; #may be slightly different depending on your php version
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
}
location ~ /(data|tmp|bin|content-controllers|inc|interfaces|storage-controllers|templates|tools) {
deny all;
return 404;
}
}
```

View File

@@ -3,6 +3,8 @@
define('DS', DIRECTORY_SEPARATOR);
define('ROOT', dirname(__FILE__).'/..');
header('Content-Type: application/json; charset=utf-8');
//loading default settings if exist
if(!file_exists(ROOT.DS.'inc'.DS.'config.inc.php'))
exit('Rename /inc/example.config.inc.php to /inc/config.inc.php first!');
@@ -10,13 +12,16 @@ include_once(ROOT.DS.'inc'.DS.'config.inc.php');
//loading core and controllers
include_once(ROOT . DS . 'inc' . DS. 'core.php');
require_once(ROOT . DS . 'content-controllers' . DS. 'image'. DS . 'image.controller.php');
require_once(ROOT . DS . 'content-controllers' . DS. 'text'. DS . 'text.controller.php');
require_once(ROOT . DS . 'content-controllers' . DS. 'url'. DS . 'url.controller.php');
require_once(ROOT . DS . 'content-controllers' . DS. 'video'. DS . 'video.controller.php');
//load external things if existing
if(file_exists(ROOT.'/lib/vendor/autoload.php'))
require ROOT.'/lib/vendor/autoload.php';
loadAllContentControllers();
// check if client has permission to upload
executeUploadPermission();
// check write permissions first
if(!isFolderWritable(ROOT.DS.'data'))
if(!isFolderWritable(getDataDir()))
exit(json_encode(array('status'=>'err','reason'=>'Data directory not writable')));
else if(!isFolderWritable(ROOT.DS.'tmp'))
exit(json_encode(array('status'=>'err','reason'=>'Temp directory not writable')));
@@ -33,14 +38,15 @@ if($_REQUEST['base64'])
base64ToFile($data, $tmpfile);
//get the file type
$type = getTypeOfFile($tmpfile);
//check for duplicates
$sha1 = sha1_file($tmpfile);
$ehash = sha1Exists($sha1);
if($ehash && file_exists(ROOT.DS.'data'.DS.$ehash.DS.$ehash))
exit(json_encode(array('status'=>'ok','hash'=>$ehash,'filetype'=>$type,'url'=>URL.$ehash)));
if($ehash && file_exists(getDataDir().DS.$ehash.DS.$ehash))
exit(json_encode(array('status'=>'ok','hash'=>$ehash,'filetype'=>$type,'url'=>getURL().$ehash)));
@@ -74,16 +80,10 @@ if($_REQUEST['base64'])
if(getDeleteCodeOfHash($answer['hash']))
{
$answer['delete_code'] = getDeleteCodeOfHash($answer['hash']);
$answer['delete_url'] = URL.'delete_'.getDeleteCodeOfHash($answer['hash']).'/'.$answer['hash'];
$answer['delete_url'] = getURL().'delete_'.getDeleteCodeOfHash($answer['hash']).'/'.$answer['hash'];
}
// Lets' check all storage controllers and tell them that a new file was uploaded
$sc = getStorageControllers();
foreach($sc as $contr)
{
if((new $contr())->isEnabled()===true)
(new $contr())->pushFile($answer['hash']);
}
storageControllerUpload($answer['hash']);
}
echo json_encode($answer);

View File

@@ -3,6 +3,8 @@
define('DS', DIRECTORY_SEPARATOR);
define('ROOT', dirname(__FILE__).'/..');
header('Content-Type: application/json; charset=utf-8');
//loading default settings if exist
if(!file_exists(ROOT.DS.'inc'.DS.'config.inc.php'))
exit('Rename /inc/example.config.inc.php to /inc/config.inc.php first!');
@@ -10,13 +12,16 @@ include_once(ROOT.DS.'inc'.DS.'config.inc.php');
//loading core and controllers
include_once(ROOT . DS . 'inc' . DS. 'core.php');
require_once(ROOT . DS . 'content-controllers' . DS. 'image'. DS . 'image.controller.php');
require_once(ROOT . DS . 'content-controllers' . DS. 'text'. DS . 'text.controller.php');
require_once(ROOT . DS . 'content-controllers' . DS. 'url'. DS . 'url.controller.php');
require_once(ROOT . DS . 'content-controllers' . DS. 'video'. DS . 'video.controller.php');
//load external things if existing
if(file_exists(ROOT.'/lib/vendor/autoload.php'))
require ROOT.'/lib/vendor/autoload.php';
loadAllContentControllers();
// check if client has permission to upload
executeUploadPermission();
// check write permissions first
if(!isFolderWritable(ROOT.DS.'data'))
if(!isFolderWritable(getDataDir()))
exit(json_encode(array('status'=>'err','reason'=>'Data directory not writable')));
else if(!isFolderWritable(ROOT.DS.'tmp'))
exit(json_encode(array('status'=>'err','reason'=>'Temp directory not writable')));
@@ -25,6 +30,9 @@ $hash = sanatizeString(trim($_REQUEST['hash']))?sanatizeString(trim($_REQUEST['h
$url = trim($_REQUEST['url']);
if(checkURLForPrivateIPRange($url))
exit(json_encode(array('status'=>'err','reason'=>'Private IP range')));
if(!$url || !startsWith($url, 'http'))
exit(json_encode(array('status'=>'err','reason'=>'Invalid URL')));
@@ -34,15 +42,23 @@ else if(remote_filesize($url)*0.000001 > 20)
$name = basename($url);
$tmpfile = ROOT.DS.'tmp'.DS.$name;
file_put_contents($tmpfile,file_get_contents($url));
$context = stream_context_create(
array(
"http" => array(
"follow_location" => false,
),
)
);
file_put_contents($tmpfile,file_get_contents($url, false, $context));
$type = getTypeOfFile($tmpfile);
//check for duplicates
$sha1 = sha1_file($tmpfile);
$ehash = sha1Exists($sha1);
if($ehash && file_exists(ROOT.DS.'data'.DS.$ehash.DS.$ehash))
exit(json_encode(array('status'=>'ok','hash'=>$ehash,'filetype'=>$type,'url'=>URL.$ehash)));
if($ehash && file_exists(getDataDir().DS.$ehash.DS.$ehash))
exit(json_encode(array('status'=>'ok','hash'=>$ehash,'filetype'=>$type,'url'=>getURL().$ehash)));
//cross check filetype for controllers
//
@@ -74,17 +90,11 @@ if($answer['hash'] && $answer['status']=='ok')
if(getDeleteCodeOfHash($answer['hash']))
{
$answer['delete_code'] = getDeleteCodeOfHash($answer['hash']);
$answer['delete_url'] = URL.'delete_'.getDeleteCodeOfHash($answer['hash']).'/'.$answer['hash'];
$answer['delete_url'] = getURL().'delete_'.getDeleteCodeOfHash($answer['hash']).'/'.$answer['hash'];
}
// Lets' check all storage controllers and tell them that a new file was uploaded
$sc = getStorageControllers();
foreach($sc as $contr)
{
if((new $contr())->isEnabled()===true)
(new $contr())->pushFile($answer['hash']);
}
storageControllerUpload($answer['hash']);
}
if($answer['hash'] && $answer['status']=='ok')
@@ -95,30 +105,13 @@ if($answer['hash'] && $answer['status']=='ok')
if(getDeleteCodeOfHash($answer['hash']))
{
$answer['delete_code'] = getDeleteCodeOfHash($answer['hash']);
$answer['delete_url'] = URL.'delete_'.getDeleteCodeOfHash($answer['hash']).'/'.$answer['hash'];
$answer['delete_url'] = getURL().'delete_'.getDeleteCodeOfHash($answer['hash']).'/'.$answer['hash'];
}
// Lets' check all storage controllers and tell them that a new file was uploaded
$sc = getStorageControllers();
foreach($sc as $contr)
{
if((new $contr())->isEnabled()===true)
(new $contr())->pushFile($answer['hash']);
}
storageControllerUpload($answer['hash']);
}
echo json_encode($answer);
function remote_filesize($url) {
static $regex = '/^Content-Length: *+\K\d++$/im';
if (!$fp = @fopen($url, 'rb'))
return false;
if (
isset($http_response_header) &&
preg_match($regex, implode("\n", $http_response_header), $matches)
)
return (int)$matches[0];
return strlen(stream_get_contents($fp));
}

53
src/api/info.php Normal file
View File

@@ -0,0 +1,53 @@
<?php
// basic path definitions
define('DS', DIRECTORY_SEPARATOR);
define('ROOT', dirname(__FILE__).'/..');
header('Content-Type: application/json; charset=utf-8');
//loading default settings if exist
if(!file_exists(ROOT.DS.'inc'.DS.'config.inc.php'))
exit('Rename /inc/example.config.inc.php to /inc/config.inc.php first!');
include_once(ROOT.DS.'inc'.DS.'config.inc.php');
//loading core and controllers
include_once(ROOT . DS . 'inc' . DS. 'core.php');
//load external things if existing
if(file_exists(ROOT.'/lib/vendor/autoload.php'))
require ROOT.'/lib/vendor/autoload.php';
if($_REQUEST['ip']=='pls') exit(getUserIP());
loadAllContentControllers();
$hash = $_REQUEST['hash'];
if(!isExistingHash($hash))
{
exit(json_encode(array('status'=>'err','reason'=>'File not found')));
}
else
{
$answer = getInfoAboutHash($hash);
$answer['status'] = 'ok';
exit(json_encode($answer));
}
function getInfoAboutHash($hash)
{
$file = getDataDir().DS.$hash.DS.$hash;
if(!file_exists($file))
return array('status'=>'err','reason'=>'File not found');
$size = filesize($file);
$size_hr = renderSize($size);
$content_type = exec("file -bi " . escapeshellarg($file));
if($content_type && strpos($content_type,'/')!==false && strpos($content_type,';')!==false)
{
$type = $content_type;
$c = explode(';',$type);
$type = $c[0];
}
return array('hash'=>$hash,'size_bytes'=>$size,'size_interpreted'=>$size_hr,'type'=>$type,'type_interpreted'=>getTypeOfFile($file));
}

View File

@@ -10,10 +10,18 @@ include_once(ROOT.DS.'inc'.DS.'config.inc.php');
//loading core and controllers
include_once(ROOT . DS . 'inc' . DS. 'core.php');
require_once(ROOT . DS . 'content-controllers' . DS. 'text'. DS . 'text.controller.php');
//load external things if existing
if(file_exists(ROOT.'/lib/vendor/autoload.php'))
require ROOT.'/lib/vendor/autoload.php';
$controllers = loadAllContentControllers();
if(!in_array('TextController',$controllers))
exit(json_encode(array('status'=>'err','reason'=>'Text controller not enabled')));
// check if client has permission to upload
executeUploadPermission();
// check write permissions first
if(!isFolderWritable(ROOT.DS.'data'))
if(!isFolderWritable(getDataDir()))
exit(json_encode(array('status'=>'err','reason'=>'Data directory not writable')));
else if(!isFolderWritable(ROOT.DS.'tmp'))
exit(json_encode(array('status'=>'err','reason'=>'Temp directory not writable')));
@@ -29,11 +37,11 @@ if($_REQUEST['api_paste_code'])
$sha1 = sha1_file($tmpfile);
$sha_hash = sha1Exists($sha1);
if($sha_hash)
exit(URL.$sha_hash);
exit(getURL().$sha_hash);
$answer = (new TextController())->handleUpload($tmpfile,$hash);
if($answer['hash'] && $answer['status']=='ok')
addSha1($answer['hash'],$sha1);
echo URL.$hash;
echo getURL().$hash;
}

View File

@@ -1,7 +1,9 @@
<?php
// basic path definitions
define('DS', DIRECTORY_SEPARATOR);
define('ROOT', dirname(__FILE__).'/..');
define('ROOT', dirname(__FILE__).DS.'..');
header('Content-Type: application/json; charset=utf-8');
//loading default settings if exist
if(!file_exists(ROOT.DS.'inc'.DS.'config.inc.php'))
@@ -10,18 +12,24 @@ include_once(ROOT.DS.'inc'.DS.'config.inc.php');
//loading core and controllers
include_once(ROOT . DS . 'inc' . DS. 'core.php');
require_once(ROOT . DS . 'content-controllers' . DS. 'image'. DS . 'image.controller.php');
require_once(ROOT . DS . 'content-controllers' . DS. 'text'. DS . 'text.controller.php');
require_once(ROOT . DS . 'content-controllers' . DS. 'url'. DS . 'url.controller.php');
require_once(ROOT . DS . 'content-controllers' . DS. 'video'. DS . 'video.controller.php');
//load external things if existing
if(file_exists(ROOT.'/lib/vendor/autoload.php'))
require ROOT.'/lib/vendor/autoload.php';
$allowedcontentcontrollers = loadAllContentControllers();
// check write permissions first
if(!isFolderWritable(ROOT.DS.'data'))
if(!isFolderWritable(getDataDir()))
exit(json_encode(array('status'=>'err','reason'=>'Data directory not writable')));
else if(!isFolderWritable(ROOT.DS.'tmp'))
exit(json_encode(array('status'=>'err','reason'=>'Temp directory not writable')));
$hash = sanatizeString(trim($_REQUEST['hash']))?sanatizeString(trim($_REQUEST['hash'])):false;
// check if client has permission to upload
executeUploadPermission();
if(isset($_REQUEST['hash']))
$hash = sanatizeString(trim($_REQUEST['hash']));
else
$hash = false;
// check for POST upload
if ($_FILES['file']["error"] == UPLOAD_ERR_OK)
@@ -32,27 +40,23 @@ if ($_FILES['file']["error"] == UPLOAD_ERR_OK)
//check for duplicates
$sha1 = sha1_file($_FILES['file']["tmp_name"]);
$ehash = sha1Exists($sha1);
if($ehash && file_exists(ROOT.DS.'data'.DS.$ehash.DS.$ehash))
exit(json_encode(array('status'=>'ok','hash'=>$ehash,'filetype'=>$type,'url'=>URL.$ehash)));
if($ehash && file_exists(getDataDir().DS.$ehash.DS.$ehash))
exit(json_encode(array('status'=>'ok','hash'=>$ehash,'filetype'=>$type,'url'=>getURL().$ehash)));
//cross check filetype for controllers
//
//image?
if(in_array($type,(new ImageController)->getRegisteredExtensions()))
foreach($allowedcontentcontrollers as $cc)
{
$answer = (new ImageController())->handleUpload($_FILES['file']['tmp_name'],$hash);
}
//or, a text
else if($type=='text')
{
$answer = (new TextController())->handleUpload($_FILES['file']['tmp_name'],$hash);
}
//or, a video
else if(in_array($type,(new VideoController)->getRegisteredExtensions()))
{
$answer = (new VideoController())->handleUpload($_FILES['file']['tmp_name'],$hash);
if(in_array($type,(new $cc)->getRegisteredExtensions()))
{
$answer = (new $cc())->handleUpload($_FILES['file']['tmp_name'],$hash);
break;
}
}
if(!$answer)
$answer = array('status'=>'err','reason'=>'Unsupported filetype: '.$type,'filetype'=>$type);
@@ -65,17 +69,11 @@ if ($_FILES['file']["error"] == UPLOAD_ERR_OK)
if(getDeleteCodeOfHash($answer['hash']))
{
$answer['delete_code'] = getDeleteCodeOfHash($answer['hash']);
$answer['delete_url'] = URL.'delete_'.getDeleteCodeOfHash($answer['hash']).'/'.$answer['hash'];
$answer['delete_url'] = getURL().'delete_'.getDeleteCodeOfHash($answer['hash']).'/'.$answer['hash'];
}
// Lets' check all storage controllers and tell them that a new file was uploaded
$sc = getStorageControllers();
foreach($sc as $contr)
{
if((new $contr())->isEnabled()===true)
(new $contr())->pushFile($answer['hash']);
}
storageControllerUpload($answer['hash']);
}
echo json_encode($answer);

View File

@@ -0,0 +1,38 @@
<?php
use Bitverse\Identicon\Identicon;
use Bitverse\Identicon\Color\Color;
use Bitverse\Identicon\Generator\RingsGenerator;
use Bitverse\Identicon\Preprocessor\MD5Preprocessor;
class IdenticonController implements ContentController
{
public const ctype = 'dynamic';
//returns all extensions registered by this type of content
public function getRegisteredExtensions(){return array('identicon');}
public function handleHash($hash,$url,$path=false)
{
unset($url[array_search('identicon',$url)]);
$url = array_values($url);
$generator = new RingsGenerator();
$generator->setBackgroundColor(Color::parseHex('#EEEEEE'));
$identicon = new Identicon(new MD5Preprocessor(), $generator);
$icon = $identicon->getIcon($url[0]);
header('Content-type: image/svg+xml');
echo $icon;
}
public function handleUpload($tmpfile,$hash=false,$passthrough=false)
{
return array('status'=>'err','hash'=>$hash,'reason'=>'Cannot upload to Identicons');
}
}

View File

@@ -0,0 +1,278 @@
<?php
function getFilters()
{
return get_class_methods('Filter');
}
class Filter {
public function sepia($im,$val) {
imagefilter($im, IMG_FILTER_GRAYSCALE);
imagefilter($im, IMG_FILTER_COLORIZE, 100, 50, 0);
return $im;
}
public function sepia2($im,$val) {
imagefilter($im, IMG_FILTER_GRAYSCALE);
imagefilter($im, IMG_FILTER_BRIGHTNESS, -10);
imagefilter($im, IMG_FILTER_CONTRAST, -20);
imagefilter($im, IMG_FILTER_COLORIZE, 60, 30, -15);
return $im;
}
public function sharpen($im,$val) {
$gaussian = array(
array(1.0, 1.0, 1.0),
array(1.0, -7.0, 1.0),
array(1.0, 1.0, 1.0)
);
imageconvolution($im, $gaussian, 1, 4);
return $im;
}
public function emboss($im,$val) {
$gaussian = array(
array(-2.0, -1.0, 0.0),
array(-1.0, 1.0, 1.0),
array(0.0, 1.0, 2.0)
);
imageconvolution($im, $gaussian, 1, 5);
return $im;
}
public function cool($im,$val) {
imagefilter($im, IMG_FILTER_MEAN_REMOVAL);
imagefilter($im, IMG_FILTER_CONTRAST, -50);
return $im;
}
public function light($im,$val) {
imagefilter($im, IMG_FILTER_BRIGHTNESS, 10);
imagefilter($im, IMG_FILTER_COLORIZE, 100, 50, 0, 10);
return $im;
}
public function aqua($im,$val) {
imagefilter($im, IMG_FILTER_COLORIZE, 0, 70, 0, 30);
return $im;
}
public function fuzzy($im,$val) {
$gaussian = array(
array(1.0, 1.0, 1.0),
array(1.0, 1.0, 1.0),
array(1.0, 1.0, 1.0)
);
imageconvolution($im, $gaussian, 9, 20);
return $im;
}
public function boost($im,$val) {
imagefilter($im, IMG_FILTER_CONTRAST, -35);
imagefilter($im, IMG_FILTER_BRIGHTNESS, 10);
return $im;
}
public function boost2($im,$val) {
imagefilter( $im, IMG_FILTER_CONTRAST, -35);
imagefilter( $im, IMG_FILTER_COLORIZE, 25, 25, 25);
return $im;
}
public function gray($im,$val) {
imagefilter($im, IMG_FILTER_CONTRAST, -60);
imagefilter($im, IMG_FILTER_GRAYSCALE);
return $im;
}
public function antique($im,$val) {
imagefilter($im, IMG_FILTER_BRIGHTNESS, 0);
imagefilter($im, IMG_FILTER_CONTRAST, -30);
imagefilter($im, IMG_FILTER_COLORIZE, 75, 50, 25);
return $im;
}
public function blackwhite($im,$val) {
imagefilter($im, IMG_FILTER_GRAYSCALE);
imagefilter($im, IMG_FILTER_BRIGHTNESS, 10);
imagefilter($im, IMG_FILTER_CONTRAST, -20);
return $im;
}
public function vintage($im,$val) {
imagefilter($im, IMG_FILTER_BRIGHTNESS, 10);
imagefilter($im, IMG_FILTER_GRAYSCALE);
imagefilter($im, IMG_FILTER_COLORIZE, 40, 10, -15);
return $im;
}
public function concentrate($im,$val) {
imagefilter($im, IMG_FILTER_GAUSSIAN_BLUR);
imagefilter($im, IMG_FILTER_SMOOTH, -10);
return $im;
}
public function hermajesty($im,$val) {
imagefilter($im, IMG_FILTER_BRIGHTNESS, -10);
imagefilter($im, IMG_FILTER_CONTRAST, -5);
imagefilter($im, IMG_FILTER_COLORIZE, 80, 0, 60);
return $im;
}
public function everglow($im,$val) {
imagefilter($im, IMG_FILTER_BRIGHTNESS, -30);
imagefilter($im, IMG_FILTER_CONTRAST, -5);
imagefilter($im, IMG_FILTER_COLORIZE, 30, 30, 0);
return $im;
}
public function freshblue($im,$val) {
imagefilter($im, IMG_FILTER_CONTRAST, -5);
imagefilter($im, IMG_FILTER_COLORIZE, 20, 0, 80, 60);
return $im;
}
public function tender($im,$val) {
imagefilter($im, IMG_FILTER_CONTRAST, 5);
imagefilter($im, IMG_FILTER_COLORIZE, 80, 20, 40, 50);
imagefilter($im, IMG_FILTER_COLORIZE, 0, 40, 40, 100);
imagefilter($im, IMG_FILTER_SELECTIVE_BLUR);
return $im;
}
public function dream($im,$val) {
imagefilter($im, IMG_FILTER_COLORIZE, 150, 0, 0, 50);
imagefilter($im, IMG_FILTER_NEGATE);
imagefilter($im, IMG_FILTER_COLORIZE, 0, 50, 0, 50);
imagefilter($im, IMG_FILTER_NEGATE);
imagefilter($im, IMG_FILTER_GAUSSIAN_BLUR);
return $im;
}
public function frozen($im,$val) {
imagefilter($im, IMG_FILTER_BRIGHTNESS, -15);
imagefilter($im, IMG_FILTER_COLORIZE, 0, 0, 100, 50);
imagefilter($im, IMG_FILTER_COLORIZE, 0, 0, 100, 50);
imagefilter($im, IMG_FILTER_GAUSSIAN_BLUR);
return $im;
}
public function forest($im,$val) {
imagefilter($im, IMG_FILTER_COLORIZE, 0, 0, 150, 50);
imagefilter($im, IMG_FILTER_NEGATE);
imagefilter($im, IMG_FILTER_COLORIZE, 0, 0, 150, 50);
imagefilter($im, IMG_FILTER_NEGATE);
imagefilter($im, IMG_FILTER_SMOOTH, 10);
return $im;
}
public function rain($im,$val) {
imagefilter($im, IMG_FILTER_GAUSSIAN_BLUR);
imagefilter($im, IMG_FILTER_MEAN_REMOVAL);
imagefilter($im, IMG_FILTER_NEGATE);
imagefilter($im, IMG_FILTER_COLORIZE, 0, 80, 50, 50);
imagefilter($im, IMG_FILTER_NEGATE);
imagefilter($im, IMG_FILTER_SMOOTH, 10);
return $im;
}
public function orangepeel($im,$val) {
imagefilter($im, IMG_FILTER_COLORIZE, 100, 20, -50, 20);
imagefilter($im, IMG_FILTER_SMOOTH, 10);
imagefilter($im, IMG_FILTER_BRIGHTNESS, -10);
imagefilter($im, IMG_FILTER_CONTRAST, 10);
imagegammacorrect($im, 1, 1.2 );
return $im;
}
public function darken($im,$val) {
imagefilter($im, IMG_FILTER_GRAYSCALE);
imagefilter($im, IMG_FILTER_BRIGHTNESS, -50);
return $im;
}
public function summer($im,$val) {
imagefilter($im, IMG_FILTER_COLORIZE, 0, 150, 0, 50);
imagefilter($im, IMG_FILTER_NEGATE);
imagefilter($im, IMG_FILTER_COLORIZE, 25, 50, 0, 50);
imagefilter($im, IMG_FILTER_NEGATE);
return $im;
}
public function retro($im,$val) {
imagefilter($im, IMG_FILTER_GRAYSCALE);
imagefilter($im, IMG_FILTER_COLORIZE, 100, 25, 25, 50);
return $im;
}
public function country($im,$val) {
imagefilter($im, IMG_FILTER_BRIGHTNESS, -30);
imagefilter($im, IMG_FILTER_COLORIZE, 50, 50, 50, 50);
imagegammacorrect($im, 1, 0.3);
return $im;
}
public function washed($im,$val) {
imagefilter($im, IMG_FILTER_BRIGHTNESS, 30);
imagefilter($im, IMG_FILTER_NEGATE);
imagefilter($im, IMG_FILTER_COLORIZE, -50, 0, 20, 50);
imagefilter($im, IMG_FILTER_NEGATE );
imagefilter($im, IMG_FILTER_BRIGHTNESS, 10);
imagegammacorrect($im, 1, 1.2);
return $im;
}
public function pixelate($im,$val) {
if($val==null) $val = 10;
imagefilter($im,IMG_FILTER_PIXELATE,$val);
return $im;
}
public function blur($im,$blurFactor)
{
if(!$blurFactor)
$blurFactor = 3;
if($blurFactor>6)
$blurFactor = 6;
else if($blurFactor<0)
$blurFactor = 0;
// blurFactor has to be an integer
$blurFactor = round($blurFactor);
$originalWidth = imagesx($im);
$originalHeight = imagesy($im);
$smallestWidth = ceil($originalWidth * pow(0.5, $blurFactor));
$smallestHeight = ceil($originalHeight * pow(0.5, $blurFactor));
// for the first run, the previous image is the original input
$prevImage = $im;
$prevWidth = $originalWidth;
$prevHeight = $originalHeight;
// scale way down and gradually scale back up, blurring all the way
for($i = 0; $i < $blurFactor; $i += 1)
{
// determine dimensions of next image
$nextWidth = $smallestWidth * pow(2, $i);
$nextHeight = $smallestHeight * pow(2, $i);
// resize previous image to next size
$nextImage = imagecreatetruecolor($nextWidth, $nextHeight);
imagecopyresized($nextImage, $prevImage, 0, 0, 0, 0,
$nextWidth, $nextHeight, $prevWidth, $prevHeight);
// apply blur filter
imagefilter($nextImage, IMG_FILTER_GAUSSIAN_BLUR);
// now the new image becomes the previous image for the next step
$prevImage = $nextImage;
$prevWidth = $nextWidth;
$prevHeight = $nextHeight;
}
// scale back to original size and blur one more time
imagecopyresized($im, $nextImage,
0, 0, 0, 0, $originalWidth, $originalHeight, $nextWidth, $nextHeight);
imagefilter($im, IMG_FILTER_GAUSSIAN_BLUR);
// clean up
imagedestroy($prevImage);
// return result
return $im;
}
}

View File

@@ -10,10 +10,20 @@
class ImageController implements ContentController
{
public const ctype = 'static';
public $mimes = array(
'image/gif',
'image/jpeg',
'image/png',
'image/bmp',
'image/webp',
'image/x-icon'
);
//returns all extensions registered by this type of content
public function getRegisteredExtensions(){return array('png','bmp','gif','jpg','jpeg','x-png','webp');}
public function handleUpload($tmpfile,$hash=false)
public function handleUpload($tmpfile,$hash=false,$passthrough=false)
{
$type = exif_imagetype($tmpfile); //http://www.php.net/manual/en/function.exif-imagetype.php
switch($type)
@@ -24,8 +34,43 @@ class ImageController implements ContentController
case 17: $ext = 'ico';break; // ico
case 18: $ext = 'webp';break; // webp
case 2: //we clean up exif data of JPGs so GPS and other data is removed
case 2:
//we clean up exif data of JPGs so GPS and other data is removed
$res = imagecreatefromjpeg($tmpfile);
// rotate based on EXIF Orientation
$exif = exif_read_data($tmpfile);
if (!empty($exif['Orientation'])) {
switch ($exif['Orientation']) {
case 2:
imageflip($res, IMG_FLIP_HORIZONTAL);
case 1:
// Nothing to do
break;
case 4:
imageflip($res, IMG_FLIP_HORIZONTAL);
// Also rotate
case 3:
$res = imagerotate($res, 180, 0);
break;
case 5:
imageflip($res, IMG_FLIP_VERTICAL);
// Also rotate
case 6:
$res = imagerotate($res, -90, 0);
break;
case 7:
imageflip($res, IMG_FLIP_VERTICAL);
// Also rotate
case 8:
$res = imagerotate($res, 90, 0);
break;
}
}
imagejpeg($res, $tmpfile, (defined('JPEG_COMPRESSION')?JPEG_COMPRESSION:90));
$ext = 'jpg';
break;
@@ -46,14 +91,16 @@ class ImageController implements ContentController
return array('status'=>'err','hash'=>$hash,'reason'=>'Custom hash already exists');
}
storeFile($tmpfile,$hash,true);
if($passthrough===false)
storeFile($tmpfile,$hash,true);
return array('status'=>'ok','hash'=>$hash,'url'=>URL.$hash);
return array('status'=>'ok','hash'=>$hash,'url'=>getURL().$hash);
}
public function handleHash($hash,$url)
public function handleHash($hash,$url,$path=false)
{
$path = ROOT.DS.'data'.DS.$hash.DS.$hash;
if($path===false)
$path = getDataDir().DS.$hash.DS.$hash;
$type = getExtensionOfFilename($hash);
//get all our sub files where all the good functions lie
@@ -64,14 +111,31 @@ class ImageController implements ContentController
//don't do this if it's a gif because PHP can't handle animated gifs
if($type!='gif')
{
$filters = getFilters();
foreach($url as $u)
{
if(isSize($u))
$modifiers['size'] = $u;
else if(isRotation($u))
$modifiers['rotation'] = $u;
else // check for filters
{
foreach($filters as $filter)
{
if(startsWith($u,$filter) && ($u==$filter || startsWith($u,$filter.'_')))
{
$a = explode('_',$u);
$value = $a[1];
if(is_numeric($value))
$modifiers['filters'][] = array('filter'=>$filter,'value'=>$value);
else
$modifiers['filters'][] = array('filter'=>$filter);
}
}
}
}
if(in_array('webp',$url) && $type!='webp')
if( (in_array('webp',$url) && $type!='webp') || ( $this->shouldAlwaysBeWebp() && ($type=='jpg' || $type=='png') ) )
$modifiers['webp'] = true;
if(in_array('forcesize',$url) && $modifiers['size'])
$modifiers['forcesize'] = true;
@@ -89,8 +153,9 @@ class ImageController implements ContentController
//so if we take all parameters in key=>value form and hash it
//we get one nice little hash for every eventuality
$modhash = md5(http_build_query($modifiers,'',','));
$newpath = ROOT.DS.'data'.DS.$hash.DS.$modhash.'_'.$hash;
$newpath = dirname($path).DS.$modhash.'_'.$hash;
$im = $this->getObjOfImage($path);
$f = new Filter();
if(!file_exists($newpath))
{
@@ -98,6 +163,15 @@ class ImageController implements ContentController
{
switch($mod)
{
case 'filters':
foreach($val as $fd)
{
$filter = $fd['filter'];
$value = $fd['value'];
$im = $f->$filter($im,$value);
}
break;
case 'size':
($modifiers['forcesize']?forceResize($im,$val):resize($im,$val));
break;
@@ -111,7 +185,7 @@ class ImageController implements ContentController
break;
case 'mp4':
$mp4path = ROOT.DS.'data'.DS.$hash.DS.$hash.'mp4';
$mp4path = dirname($path).DS.$hash.'mp4';
if(!file_exists($mp4path))
$this->gifToMP4($path,$mp4path);
$path = $mp4path;
@@ -127,8 +201,8 @@ class ImageController implements ContentController
}
header ("Content-type: image/jpeg");
readfile($preview);
serveFile($preview);
exit;
}
else if(in_array('download',$url))
{
@@ -140,14 +214,15 @@ class ImageController implements ContentController
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($path));
readfile($path);
serveFile($path);
exit;
}
}
else
{
$data = array('url'=>implode('/',$url),'hash'=>$hash,'filesize'=>renderSize(filesize($path)));
renderTemplate('video',$data);
return renderTemplate('video.html.php',$data);
}
break;
}
@@ -155,32 +230,48 @@ class ImageController implements ContentController
$this->saveObjOfImage($im,$newpath,$type);
}
else if($modifiers['webp'])
{
$type = 'webp';
}
$path = $newpath;
}
switch($type)
{
case 'jpeg':
case 'jpg':
header ("Content-type: image/jpeg");
readfile($path);
header ("Last-Modified: ".gmdate('D, d M Y H:i:s ', filemtime($path)) . 'GMT');
header ("ETag: $hash");
header('Cache-control: public, max-age=31536000');
serveFile($path);
break;
case 'png':
header ("Content-type: image/png");
readfile($path);
header ("Last-Modified: ".gmdate('D, d M Y H:i:s ', filemtime($path)) . 'GMT');
header ("ETag: $hash");
header('Cache-control: public, max-age=31536000');
serveFile($path);
break;
case 'gif':
header ("Content-type: image/gif");
readfile($path);
header ("Last-Modified: ".gmdate('D, d M Y H:i:s ', filemtime($path)) . 'GMT');
header ("ETag: $hash");
header('Cache-control: public, max-age=31536000');
serveFile($path);
break;
case 'webp':
header ("Content-type: image/webp");
readfile($path);
header ("Last-Modified: ".gmdate('D, d M Y H:i:s ', filemtime($path)) . 'GMT');
header ("ETag: $hash");
header('Cache-control: public, max-age=31536000');
serveFile($path);
break;
}
}
@@ -206,22 +297,46 @@ class ImageController implements ContentController
function saveObjOfImage($im,$path,$type)
{
$tmppath = '/tmp/'.getNewHash($type,12);
switch($type)
{
case 'jpeg':
case 'jpg':
imagejpeg($im,$path,(defined('JPEG_COMPRESSION')?JPEG_COMPRESSION:90));
imagejpeg($im,$tmppath,(defined('JPEG_COMPRESSION')?JPEG_COMPRESSION:90));
break;
case 'png':
imagepng($im,$path,(defined('PNG_COMPRESSION')?PNG_COMPRESSION:6));
imagepng($im,$tmppath,(defined('PNG_COMPRESSION')?PNG_COMPRESSION:6));
break;
case 'webp':
imagewebp($im,$path,(defined('WEBP_COMPRESSION')?WEBP_COMPRESSION:80));
imagepalettetotruecolor($im);
imagealphablending($im, true);
imagewebp($im,$tmppath,(defined('WEBP_COMPRESSION')?WEBP_COMPRESSION:80));
break;
}
return $im;
if(file_exists($tmppath) && filesize($tmppath)>0)
{
rename($tmppath,$path);
return $im;
}
else
{
return false;
}
}
function shouldAlwaysBeWebp()
{
//sanity check
if(!$_SERVER['HTTP_ACCEPT']) return false;
if(defined('ALWAYS_WEBP') && ALWAYS_WEBP && strpos( $_SERVER['HTTP_ACCEPT'], 'image/webp' ) !== false )
return true;
else
return false;
}
}

View File

@@ -91,14 +91,14 @@ function rotate(&$im,$direction)
if ($height > $width)
{
$ratio = $maxheight / $height;
$newheight = $maxheight;
$newwidth = $width * $ratio;
$newheight = intval($maxheight);
$newwidth = intval($width * $ratio) ;
}
else
{
$ratio = $maxwidth / $width;
$newwidth = $maxwidth;
$newheight = $height * $ratio;
$newwidth = intval($maxwidth) ;
$newheight = intval($height * $ratio);
}
$newimg = imagecreatetruecolor($newwidth,$newheight);

View File

@@ -0,0 +1,52 @@
<?php
class PlaceholderController implements ContentController
{
public const ctype = 'dynamic';
//returns all extensions registered by this type of content
public function getRegisteredExtensions(){return array('placeholder');}
public function handleHash($hash,$url,$path=false)
{
$path = getDataDir().DS.$hash.DS.$hash;
include_once(dirname(__FILE__).DS.'placeholdergenerator.php');
$pg = new PlaceholderGenerator();
foreach($url as $u)
{
if(isSize($u))
$modifiers['size'] = $u;
if(startsWith($u,'color-'))
{
$u = substr($u,6);
$colors = explode('-',$u);
foreach($colors as $c)
if(isColor($c))
$modifiers['colors'][] = (ctype_xdigit($c)?$c:color_name_to_hex($c));
if(count($modifiers['colors'])>4)
$modifiers['colors'] = array_slice($modifiers['colors'],0,4);
}
}
$img = $pg->generateImage($modifiers);
$img = $pg->gradient($img, $modifiers['colors']);
$img = $pg->addSizeText($img,$modifiers);
header ("Content-type: image/jpeg");
header ("ETag: $hash");
header('Cache-control: public, max-age=31536000');
imagejpeg($img,null,(defined('JPEG_COMPRESSION')?JPEG_COMPRESSION:90));
}
public function handleUpload($tmpfile,$hash=false,$passthrough=false)
{
return array('status'=>'err','hash'=>$hash,'reason'=>'Cannot upload to placeholder image');
}
}

View File

@@ -0,0 +1,88 @@
<?php
class PlaceholderGenerator {
function generateImage($modifiers)
{
$size = ($modifiers['size']?:'800x600');
$sd = sizeStringToWidthHeight($size);
$width = $sd['width'];
$height = $sd['height'];
$im = imagecreatetruecolor($width, $height);
return $im;
}
function addSizeText($im,$modifiers)
{
$size = imagesx($im).'x'.imagesy($im);
$text = $size;
//add the size as text in the center of the image
$textcolor = imagecolorallocate($im, 0, 0, 0);
$font = dirname(__FILE__).DS.'fonts/RonysiswadiArchitect5-1GErv.ttf';
//calculate the size of the text to make sure it will alway be visible
$fontsize = 20;
$textsize = imagettfbbox($fontsize, 0, $font, $text);
$scaleX = imagesx($im) / ($textsize[2] - $textsize[0] + 25);
$scaleY = imagesy($im) / ($textsize[1] - $textsize[7] + 25);
$scale = min($scaleX,$scaleY);
$fontsize = 20 * $scale;
$textsize = imagettfbbox($fontsize, 0, $font, $text);
$textwidth = $textsize[2] - $textsize[0];
$textheight = $textsize[1] - $textsize[7];
if($textwidth > imagesx($im) || $textheight > imagesy($im))
return $im;
$x = intval((imagesx($im) - $textwidth) / 2);
$y = intval((imagesy($im) - $textheight) / 2 + $textheight);
imagettftext($im, $fontsize, 0, $x, $y, $textcolor, $font, $text);
return $im;
}
function gradient($im, $c) {
$w = imagesx($im);
$h = imagesy($im);
if(!$c[0]) $c = ['ffffff','ffffff','ffffff','ffffff'];
else if(!$c[1]) $c = [$c[0],$c[0],$c[0],$c[0]];
else if(!$c[2]) $c = [$c[0],$c[0],$c[1],$c[1]];
else if(!$c[3]) $c = [$c[0],$c[1],$c[2],$c[0]];
for($i=0;$i<=3;$i++) {
$c[$i]=$this->hex2rgb($c[$i]);
}
$rgb=$c[0]; // start with top left color
for($x=0;$x<=$w;$x++) { // loop columns
for($y=0;$y<=$h;$y++) { // loop rows
// set pixel color
$col=imagecolorallocate($im,intval($rgb[0]),intval($rgb[1]),intval($rgb[2]));
imagesetpixel($im,$x-1,$y-1,$col);
// calculate new color
for($i=0;$i<=2;$i++) {
$rgb[$i]=
$c[0][$i]*(($w-$x)*($h-$y)/($w*$h)) +
$c[1][$i]*($x *($h-$y)/($w*$h)) +
$c[2][$i]*(($w-$x)*$y /($w*$h)) +
$c[3][$i]*($x *$y /($w*$h));
}
}
}
return $im;
}
function hex2rgb($hex)
{
$rgb[0]=hexdec(substr($hex,0,2));
$rgb[1]=hexdec(substr($hex,2,2));
$rgb[2]=hexdec(substr($hex,4,2));
return($rgb);
}
}

View File

@@ -2,12 +2,20 @@
class TextController implements ContentController
{
//returns all extensions registered by this type of content
public function getRegisteredExtensions(){return array('txt');}
public const ctype = 'static';
public function handleHash($hash,$url)
public $mimes = [
'text/plain',
'text/csv',
'text/tab-separated-values',
];
//returns all extensions registered by this type of content
public function getRegisteredExtensions(){return array('txt','text','csv');}
public function handleHash($hash,$url,$path=false)
{
$path = ROOT.DS.'data'.DS.$hash.DS.$hash;
$path = getDataDir().DS.$hash.DS.$hash;
if(in_array('raw',$url))
{
@@ -24,15 +32,15 @@ class TextController implements ContentController
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($path));
readfile($path);
serveFile($path);
exit;
}
}
else
renderTemplate('text',array('hash'=>$hash,'content'=>htmlentities(file_get_contents($path))));
return renderTemplate('text.html.php',array('hash'=>$hash,'content'=>htmlentities(file_get_contents($path))));
}
public function handleUpload($tmpfile,$hash=false)
public function handleUpload($tmpfile,$hash=false,$passthrough=false)
{
if($hash===false)
{
@@ -46,13 +54,14 @@ class TextController implements ContentController
return array('status'=>'err','hash'=>$hash,'reason'=>'Custom hash already exists');
}
storeFile($tmpfile,$hash,true);
if($passthrough===false)
storeFile($tmpfile,$hash,true);
return array('status'=>'ok','hash'=>$hash,'url'=>URL.$hash);
return array('status'=>'ok','hash'=>$hash,'url'=>getURL().$hash);
}
function getTypeOfText($hash)
{
return file_get_contents(ROOT.DS.'data'.DS.$hash.DS.'type');
return file_get_contents(getDataDir().DS.$hash.DS.'type');
}
}

View File

@@ -2,8 +2,10 @@
class UrlController implements ContentController
{
public const ctype = 'static';
//returns all extensions registered by this type of content
public function getRegisteredExtensions(){return array('url');}
public function handleHash($hash,$url){}
public function handleUpload($tmpfile,$hash=false){}
public function handleHash($hash,$url,$path=false){}
public function handleUpload($tmpfile,$hash=false,$passthrough=false){}
}

View File

@@ -2,12 +2,20 @@
class VideoController implements ContentController
{
public const ctype = 'static';
public $mimes = [
'video/mp4',
'video/x-m4v',
];
//returns all extensions registered by this type of content
public function getRegisteredExtensions(){return array('mp4');}
public function handleHash($hash,$url)
public function handleHash($hash,$url,$path=false)
{
$path = ROOT.DS.'data'.DS.$hash.DS.$hash;
if($path===false)
$path = getDataDir().DS.$hash.DS.$hash;
//@todo: - resize by changing $path
@@ -19,7 +27,7 @@ class VideoController implements ContentController
{
$s = sizeStringToWidthHeight($size);
$width = $s['width'];
$newpath = ROOT.DS.'data'.DS.$hash.DS.$width.'_'.$hash;
$newpath = getDataDir().DS.$hash.DS.$width.'_'.$hash;
if(!file_exists($newpath))
$this->resize($path,$newpath,$width);
$path = $newpath;
@@ -37,8 +45,8 @@ class VideoController implements ContentController
}
header ("Content-type: image/jpeg");
readfile($preview);
serveFile($preview);
}
else if(in_array('download',$url))
{
@@ -50,18 +58,19 @@ class VideoController implements ContentController
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($path));
readfile($path);
serveFile($path);
exit;
}
}
else
{
$data = array('url'=>implode('/',$url),'hash'=>$hash,'filesize'=>renderSize(filesize($path)));
renderTemplate('video',$data);
return renderTemplate('video.html.php',$data);
}
}
public function handleUpload($tmpfile,$hash=false)
public function handleUpload($tmpfile,$hash=false,$passthrough=false)
{
if($hash===false)
$hash = getNewHash('mp4',6);
@@ -72,68 +81,27 @@ class VideoController implements ContentController
return array('status'=>'err','hash'=>$hash,'reason'=>'Custom hash already exists');
}
storeFile($tmpfile,$hash,true);
if($passthrough===false)
{
$file = storeFile($tmpfile,$hash,true);
if(!$this->rightEncodedMP4($file))
system("nohup php ".ROOT.DS.'tools'.DS.'re-encode_mp4.php force '.$hash." > /dev/null 2> /dev/null &");
if(!$this->rightEncodedMP4($file))
system("nohup php ".ROOT.DS.'tools'.DS.'re-encode_mp4.php force '.$hash." > /dev/null 2> /dev/null &");
}
return array('status'=>'ok','hash'=>$hash,'url'=>URL.$hash);
return array('status'=>'ok','hash'=>$hash,'url'=>getURL().$hash);
}
//via gist: https://gist.github.com/codler/3906826
function serveMP4($path,$hash)
{
if ($fp = fopen($path, "rb"))
{
$size = filesize($path);
$length = $size;
$start = 0;
$end = $size - 1;
header('Content-type: video/mp4');
header("Accept-Ranges: 0-$length");
if (isset($_SERVER['HTTP_RANGE'])) {
$c_start = $start;
$c_end = $end;
list(, $range) = explode('=', $_SERVER['HTTP_RANGE'], 2);
if (strpos($range, ',') !== false) {
header('HTTP/1.1 416 Requested Range Not Satisfiable');
header("Content-Range: bytes $start-$end/$size");
exit;
}
if ($range == '-') {
$c_start = $size - substr($range, 1);
} else {
$range = explode('-', $range);
$c_start = $range[0];
$c_end = (isset($range[1]) && is_numeric($range[1])) ? $range[1] : $size;
}
$c_end = ($c_end > $end) ? $end : $c_end;
if ($c_start > $c_end || $c_start > $size - 1 || $c_end >= $size) {
header('HTTP/1.1 416 Requested Range Not Satisfiable');
header("Content-Range: bytes $start-$end/$size");
exit;
}
$start = $c_start;
$end = $c_end;
$length = $end - $start + 1;
fseek($fp, $start);
header('HTTP/1.1 206 Partial Content');
}
header("Content-Range: bytes $start-$end/$size");
header("Content-Length: ".$length);
$buffer = 1024 * 8;
while(!feof($fp) && ($p = ftell($fp)) <= $end) {
if ($p + $buffer > $end) {
$buffer = $end - $p + 1;
}
set_time_limit(0);
echo fread($fp, $buffer);
flush();
}
fclose($fp);
exit();
} else die('file not found');
header('Content-type: video/mp4');
header ("Last-Modified: ".gmdate('D, d M Y H:i:s ', filemtime($path)) . 'GMT');
header ("ETag: ".sha1_file($path));
header('Cache-control: public, max-age=31536000');
serveFile($path);
exit();
}
function isProperMP4($filename)

302
src/inc/api.class.php Normal file
View File

@@ -0,0 +1,302 @@
<?php
class API
{
private $url;
public function __construct($url)
{
$this->url = $url;
}
public function act()
{
try {
$this->checkPermissions();
} catch (Exception $e) {
return array('status' => 'err', 'reason' => $e->getMessage());
}
return match ($this->url[0]) {
'passthrough' => $this->passthrough(),
'upload' => $this->upload(),
'delete' => $this->delete(),
'info' => $this->info(),
'debug' => $this->debug(),
default => array('status' => 'err', 'reason' => 'Unknown API call', 'hint' => 'Check https://github.com/HaschekSolutions/pictshare/blob/master/rtfm/API.md for more information'),
};
}
public function passthrough(){
$type = $this->url[1];
array_shift($this->url); //remove the first element which is 'passthrough'
array_shift($this->url); //remove the second element which is the type so now what's left is the modifiers
$tmpfile = $_FILES['file']['tmp_name'] ?? false;
if (!$tmpfile || !is_file($tmpfile))
{
header('HTTP/1.1 400 Bad Request');
return array('status' => 'err', 'reason' => 'No file uploaded');
}
$tmp_target = $tmpfile;
//$tmp_target = ROOT.DS.'tmp'.DS.'pt-'.md5(rand(1,9999)).basename($_FILES['file']['name']);
//move_uploaded_file($tmpfile, $tmp_target);
switch($type) {
case 'image':
$controller = new ImageController();
$upload = $controller->handleUpload($tmp_target, false, true); //only to validate the file
if ($upload['status'] == 'ok') {
$controller->handleHash($upload['hash'], $this->url, $tmp_target);
unlink($tmp_target); //remove the temporary file
exit();
}
else {
header('HTTP/1.1 400 Bad Request');
return $upload; //error
}
break;
default:
return array('status' => 'err', 'reason' => 'Unknown passthrough type');
}
}
public function debug()
{
$data = array(
'server_name' => $_SERVER['SERVER_NAME'],
'server_addr' => $_SERVER['SERVER_ADDR'],
'remote_addr' => $_SERVER['REMOTE_ADDR'],
'remote_port' => $_SERVER['REMOTE_PORT'],
'HTTP_CF_CONNECTING_IP' => $_SERVER['HTTP_CF_CONNECTING_IP'],
'HTTP_CLIENT_IP' => $_SERVER['HTTP_CLIENT_IP'],
'HTTP_X_FORWARDED_FOR' => $_SERVER['HTTP_X_FORWARDED_FOR'],
);
return $data;
}
public function upload()
{
try {
$this->checkUploaderPermissions();
} catch (Exception $e) {
return array('status' => 'err', 'reason' => $e->getMessage());
}
//check if uploader has privided a requested hash name
if (isset($_REQUEST['hash']))
$hash = sanatizeString(trim($_REQUEST['hash']));
else
$hash = false;
//check if we should get a file from a remote URL
if ($_REQUEST['url']) {
$url = trim(rawurldecode($_REQUEST['url']));
if (checkURLForPrivateIPRange($url)) {
addToLog(getUserIP() . " tried to get us to download a file from: " . $url . " but it is in a private IP range");
return ['status' => 'err', 'reason' => 'Private IP range'];
}
if (!$url || !startsWith($url, 'http')) {
addToLog(getUserIP() . " tried to get us to download a file from: " . $url . " but it is not a valid URL");
return ['status' => 'err', 'reason' => 'Invalid URL'];
} else if ($this->remote_filesize($url) * 0.000001 > 20) //@todo: dynamic max size
{
addToLog(getUserIP() . " tried to get us to download a file from: " . $url . " but it is too big");
return ['status' => 'err', 'reason' => 'File too big. 20MB max'];
}
$name = basename($url);
$tmpfile = ROOT . DS . 'tmp' . DS . $name;
$context = stream_context_create(
[
"http" => [
"follow_location" => false,
],
]
);
file_put_contents($tmpfile, file_get_contents($url, false, $context));
return $this->handleFile($tmpfile, $hash, $url);
}
else if (isset($_REQUEST['base64'])) {
$data = $_REQUEST['base64'];
$format = $_REQUEST['format'];
$tmpfile = ROOT . DS . 'tmp' . DS . md5(rand(0, 10000) . time()) . time();
$this->base64ToFile($data, $tmpfile);
return $this->handleFile($tmpfile, $hash);
}
if (!isset($_FILES['file']) || !is_array($_FILES['file']))
return ['status' => 'err', 'reason' => 'No file uploaded'];
if ($_FILES['file']["error"] == UPLOAD_ERR_OK) {
return $this->handleFile($_FILES['file']["tmp_name"], $hash, $_FILES['file']['name']);
} else {
addToLog(getUserIP() . " tried to upload a file with the SHA1: " . $_FILES['file']['name'] . " (" . $_FILES['file']['type'] . ") but the upload failed with error code: " . $_FILES['file']["error"] . " (" . $this->uploadErrorMessage($_FILES['file']["error"]) . ")");
return ['status' => 'err', 'reason' => 'Upload error: ' . $this->uploadErrorMessage($_FILES['file']["error"])];
}
}
private function handleFile($tmpfile, $hash = false, $originalname = false)
{
//get the file type
$size = filesize($tmpfile);
$type = getFileMimeType($tmpfile);
//check for duplicates
$sha1 = sha1_file($tmpfile);
$ehash = sha1Exists($sha1);
if ($ehash && file_exists(getDataDir() . DS . $ehash . DS . $ehash))
return [
'status' => 'ok',
'hash' => $ehash,
'filetype' => $type,
'url' => getURL() . $ehash,
'duplicate' => true,
];
//check naughty list (previously deleted files)
if ($this->isFileInNaughtyList($sha1)) {
addToLog(getUserIP() . " tried to upload a file with the SHA1: " . $sha1 . " (" . $type . ", original name:" . $originalname . ") but it was previously deleted and therefore on the naughty list");
return ['status' => 'err', 'reason' => 'File is in the naughty list'];
}
$answer = false;
foreach (loadAllContentControllers() as $cc) {
$cc = new $cc();
if ($cc->mimes && in_array($type, $cc->mimes)) {
$answer = $cc->handleUpload($tmpfile, $hash);
break;
}
}
if (!$answer) {
addToLog(getUserIP() . " tried to upload a file with the SHA1: " . $sha1 . " (" . $type . ", original name:" . $originalname . ") but the file type is not supported");
return ['status' => 'err', 'reason' => 'Unsupported mime type: ' . $type];
} else if ($answer['hash'] && $answer['status'] == 'ok') {
$delcode = getRandomString(32);
$meta = [
'mime' => $type,
'size' => $size,
'size_human' => renderSize($size),
'original_filename' => $originalname,
'hash' => $answer['hash'],
'sha1' => $sha1,
'uploaded' => time(),
'ip' => getUserIP(),
'useragent' => $_SERVER['HTTP_USER_AGENT'],
'delete_code' => $delcode,
'delete_url' => getURL() . 'delete_' . $delcode . '/' . $answer['hash'],
'remote_port' => $_SERVER['REMOTE_PORT'],
];
addToLog(getUserIP() . " uploaded " . $answer['hash'] . " (" . $type . ")");
updateMetaData($answer['hash'], $meta);
addSha1($answer['hash'], $sha1);
//upload to all configured storage controllers
storageControllerUpload($answer['hash']);
return [
'status' => 'ok',
'hash' => $answer['hash'],
'filetype' => $type,
'url' => getURL() . $answer['hash'],
'delete_code' => $delcode,
'delete_url' => getURL() . 'delete_' . $delcode . '/' . $answer['hash'],
];
} else {
addToLog(getUserIP() . " tried to upload a file with the SHA1: " . $sha1 . " (" . $type . ", original name:" . $originalname . ") but the upload failed. Probably in the handleUpload method of the content controller " . get_class($cc));
return ['status' => 'err', 'reason' => 'Strange error during upload'];
}
}
public function checkPermissions()
{
// check write permissions first
if (!isFolderWritable(getDataDir()))
throw new Exception('Data directory not writable');
else if (!isFolderWritable(ROOT . DS . 'tmp'))
throw new Exception('Temp directory not writable');
}
public function checkUploaderPermissions()
{
if (defined('ALLOWED_SUBNET') && ALLOWED_SUBNET != '' && !isIPInRange(getUserIP(), ALLOWED_SUBNET)) {
throw new Exception('Access denied');
} else if (defined('UPLOAD_CODE') && UPLOAD_CODE != '') {
if (!isset($_REQUEST['uploadcode']) || $_REQUEST['uploadcode'] != UPLOAD_CODE) {
throw new Exception('Incorrect upload code specified - Access denied');
}
}
}
public function isFileInNaughtyList($sha1)
{
$naughtyList = getDataDir() . DS . 'naughty.csv';
if (!file_exists($naughtyList)) touch($naughtyList);
$handle = fopen($naughtyList, "r");
if ($handle) {
while (($line = fgets($handle)) !== false) {
if (substr($line, 0, 40) === $sha1) return true;
}
fclose($handle);
}
return false;
}
public function uploadErrorMessage(int $errorCode): string
{
switch ($errorCode) {
case UPLOAD_ERR_OK:
return 'There is no error, the file uploaded successfully.';
case UPLOAD_ERR_INI_SIZE:
return 'The uploaded file exceeds the upload_max_filesize directive in php.ini.';
case UPLOAD_ERR_FORM_SIZE:
return 'The uploaded file exceeds the MAX_FILE_SIZE directive specified in the HTML form.';
case UPLOAD_ERR_PARTIAL:
return 'The uploaded file was only partially uploaded.';
case UPLOAD_ERR_NO_FILE:
return 'No file was uploaded.';
case UPLOAD_ERR_NO_TMP_DIR:
return 'Missing a temporary folder.';
case UPLOAD_ERR_CANT_WRITE:
return 'Failed to write file to disk.';
case UPLOAD_ERR_EXTENSION:
return 'A PHP extension stopped the file upload.';
default:
return 'Unknown upload error.';
}
}
function remote_filesize($url) {
static $regex = '/^Content-Length: *+\K\d++$/im';
if (!$fp = @fopen($url, 'rb'))
return false;
if (
isset($http_response_header) &&
preg_match($regex, implode("\n", $http_response_header), $matches)
)
return (int)$matches[0];
return strlen(stream_get_contents($fp));
}
function base64ToFile($base64_string, $output_file)
{
$data = explode(',', $base64_string);
$data = $data[1];
$data = str_replace(' ','+',$data);
$data = base64_decode($data);
$ifp = fopen( $output_file, 'wb' );
fwrite( $ifp, $data );
fclose( $ifp );
}
}

1247
src/inc/core.php Normal file

File diff suppressed because it is too large Load Diff

85
src/inc/encryption.php Normal file
View File

@@ -0,0 +1,85 @@
<?php
class Encryption{
/**
* $key must have been generated at some point with: random_bytes(SODIUM_CRYPTO_SECRETBOX_KEYBYTES)
*/
function encryptText($text,$key)
{
$nonce = random_bytes(SODIUM_CRYPTO_SECRETBOX_NONCEBYTES);
$ciphertext = sodium_crypto_secretbox($text, $nonce, $key);
$encoded = base64_encode($nonce . $ciphertext);
return $encoded;
}
/**
* $key must have been generated at some point with: random_bytes(SODIUM_CRYPTO_SECRETBOX_KEYBYTES)
*/
function decryptText($encoded,$key)
{
$decoded = base64_decode($encoded);
$nonce = mb_substr($decoded, 0, SODIUM_CRYPTO_SECRETBOX_NONCEBYTES, '8bit');
$ciphertext = mb_substr($decoded, SODIUM_CRYPTO_SECRETBOX_NONCEBYTES, null, '8bit');
$plaintext = sodium_crypto_secretbox_open($ciphertext, $nonce, $key);
return $plaintext;
}
/**
* $key must have been generated at some point with: sodium_crypto_secretstream_xchacha20poly1305_keygen();
*/
function encryptFile($infile,$enc_outfile,$key)
{
$chunk_size = 4096;
$fd_in = fopen($infile, 'rb');
$fd_out = fopen($enc_outfile, 'wb');
list($stream, $header) = sodium_crypto_secretstream_xchacha20poly1305_init_push($key);
fwrite($fd_out, $header);
$tag = SODIUM_CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_TAG_MESSAGE;
do {
$chunk = fread($fd_in, $chunk_size);
if (feof($fd_in)) {
$tag = SODIUM_CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_TAG_FINAL;
}
$encrypted_chunk = sodium_crypto_secretstream_xchacha20poly1305_push($stream, $chunk, '', $tag);
fwrite($fd_out, $encrypted_chunk);
} while ($tag !== SODIUM_CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_TAG_FINAL);
fclose($fd_out);
fclose($fd_in);
}
/**
* $key must have been generated at some point with: sodium_crypto_secretstream_xchacha20poly1305_keygen();
*/
function decryptFile($enc_infile,$outfile,$key)
{
$fd_in = fopen($enc_infile, 'rb');
$fd_out = fopen($outfile, 'wb');
$chunk_size = 4096;
$header = fread($fd_in, SODIUM_CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_HEADERBYTES);
$stream = sodium_crypto_secretstream_xchacha20poly1305_init_pull($header, $key);
do {
$chunk = fread($fd_in, $chunk_size + SODIUM_CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_ABYTES);
list($decrypted_chunk, $tag) = sodium_crypto_secretstream_xchacha20poly1305_pull($stream, $chunk);
fwrite($fd_out, $decrypted_chunk);
} while (!feof($fd_in) && $tag !== SODIUM_CRYPTO_SECRETSTREAM_XCHACHA20POLY1305_TAG_FINAL);
$ok = feof($fd_in);
fclose($fd_out);
fclose($fd_in);
if (!$ok) {
die('Invalid/corrupted input');
}
}
}

View File

@@ -0,0 +1,25 @@
<?php
/**
* All settings that are uncommented are mandatory
* Others optional
*
* For all possible config options, check https://github.com/HaschekSolutions/pictshare/blob/master/rtfm/CONFIG.md
* or /rtfm/CONFIG.md in your installation
*/
//Use a specific domain for links presented to the user
//Format: https://your.domain.name/
// MUST HAVE TAILING /
define('URL','https://dev.pictshare.net/');
//define('JPEG_COMPRESSION', 90);
//define('FFMPEG_BINARY','');
//define('ALT_FOLDER','/ftp/pictshare');
//define('ALLOWED_SUBNET','192.168.0.0/24');
//S3 settings
//
//define('S3_BUCKET','bucketname');
//define('S3_ACCESS_KEY','');
//define('S3_SECRET_KEY','');
//define('S3_ENDPOINT','http://localhost:9000'); //optional, only if you're using S3 compatible storage like Minio

View File

@@ -6,6 +6,14 @@
interface ContentController
{
/**
* When implementing a new content controller, you must specify a constant with the name of "ctype"
* This constant will be used to distinguish static controllers (which have files on disk) from dynamic ones (which don't, like the placeholder controller)
*
* Possible values: 'static' or 'dynamic'
*/
//const ctype = 'static';
/** This method will return all file extensions that will be associated with this content type
* for example 'pdf' but it could be anything really. You just need a way later to confirm that a type is what it says it is
*
@@ -23,7 +31,7 @@ interface ContentController
* @param string $hash the hash (with extension eg '5saB2.pdf') of the file this controller will work with
* @param array $url contains all URL elements exploded with '/' so you can do your magic.
*/
public function handleHash($hash,$url);
public function handleHash($hash,$url,$path=false);
/** This method will be called if the upload script detects the content of a newly uploaded file as one of the
* extensions registered at "getRegisteredExtensions".
@@ -33,5 +41,5 @@ interface ContentController
* @param string $tmpfile is the location on disk of the temp file that was uploaded. It is your job to put it somewhere, your handleHash method will find it again
* @param array $hash (optional) if you want your upload to have a certain hash then add it here. This allows for user chosen hashes
*/
public function handleUpload($tmpfile,$hash=false);
public function handleUpload($tmpfile,$hash=false,$passthrough=false);
}

View File

@@ -26,6 +26,14 @@ interface StorageController
*/
function hashExists($hash);
/**
* Returns an array of all items in this storage controller
*
* @return array
*/
function getItems();
/**
* If a file does exist in this storage system, then this method should
* get the file and put it in the default data directory
@@ -34,20 +42,21 @@ interface StorageController
* a folder that you might have to create first before putting the file in
*
* @param string $hash is the hash of the file that should be pulled from this storage system
* @param string $location is the location where the downloaded file should be placed
*
* @return bool true if successful
*/
function pullFile($hash);
function pullFile($hash,$location);
/**
* Whenever a new file is uploaded this method will be called
* You should then upload it or do whatever your storage system is meant to do with new files
*
* @param string $hash is the hash of the new file. The file path of this file is always ROOT.DS.'data'.DS.$hash.DS.$hash
* @param string $hash is the hash of the new file. The file path of this file is always getDataDir().DS.$hash.DS.$hash
*
* @return bool true if successful
*/
function pushFile($hash);
function pushFile($source,$hash);
/**
* If deletion of a file is requested, this method is called

1
src/lib/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
vendor/

6
src/lib/composer.json Normal file
View File

@@ -0,0 +1,6 @@
{
"require": {
"aws/aws-sdk-php": "^3.33",
"bitverse/identicon": "^1.1"
}
}

956
src/lib/composer.lock generated Normal file
View File

@@ -0,0 +1,956 @@
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "55774a7c38a82a511932ca4321acb7f8",
"packages": [
{
"name": "aws/aws-crt-php",
"version": "v1.2.7",
"source": {
"type": "git",
"url": "https://github.com/awslabs/aws-crt-php.git",
"reference": "d71d9906c7bb63a28295447ba12e74723bd3730e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/awslabs/aws-crt-php/zipball/d71d9906c7bb63a28295447ba12e74723bd3730e",
"reference": "d71d9906c7bb63a28295447ba12e74723bd3730e",
"shasum": ""
},
"require": {
"php": ">=5.5"
},
"require-dev": {
"phpunit/phpunit": "^4.8.35||^5.6.3||^9.5",
"yoast/phpunit-polyfills": "^1.0"
},
"suggest": {
"ext-awscrt": "Make sure you install awscrt native extension to use any of the functionality."
},
"type": "library",
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"Apache-2.0"
],
"authors": [
{
"name": "AWS SDK Common Runtime Team",
"email": "aws-sdk-common-runtime@amazon.com"
}
],
"description": "AWS Common Runtime for PHP",
"homepage": "https://github.com/awslabs/aws-crt-php",
"keywords": [
"amazon",
"aws",
"crt",
"sdk"
],
"support": {
"issues": "https://github.com/awslabs/aws-crt-php/issues",
"source": "https://github.com/awslabs/aws-crt-php/tree/v1.2.7"
},
"time": "2024-10-18T22:15:13+00:00"
},
{
"name": "aws/aws-sdk-php",
"version": "3.343.13",
"source": {
"type": "git",
"url": "https://github.com/aws/aws-sdk-php.git",
"reference": "eb50d111a09ef39675358e74801260ac129ee346"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/eb50d111a09ef39675358e74801260ac129ee346",
"reference": "eb50d111a09ef39675358e74801260ac129ee346",
"shasum": ""
},
"require": {
"aws/aws-crt-php": "^1.2.3",
"ext-json": "*",
"ext-pcre": "*",
"ext-simplexml": "*",
"guzzlehttp/guzzle": "^7.4.5",
"guzzlehttp/promises": "^2.0",
"guzzlehttp/psr7": "^2.4.5",
"mtdowling/jmespath.php": "^2.8.0",
"php": ">=8.1",
"psr/http-message": "^2.0"
},
"require-dev": {
"andrewsville/php-token-reflection": "^1.4",
"aws/aws-php-sns-message-validator": "~1.0",
"behat/behat": "~3.0",
"composer/composer": "^2.7.8",
"dms/phpunit-arraysubset-asserts": "^0.4.0",
"doctrine/cache": "~1.4",
"ext-dom": "*",
"ext-openssl": "*",
"ext-pcntl": "*",
"ext-sockets": "*",
"phpunit/phpunit": "^5.6.3 || ^8.5 || ^9.5",
"psr/cache": "^2.0 || ^3.0",
"psr/simple-cache": "^2.0 || ^3.0",
"sebastian/comparator": "^1.2.3 || ^4.0 || ^5.0",
"symfony/filesystem": "^v6.4.0 || ^v7.1.0",
"yoast/phpunit-polyfills": "^2.0"
},
"suggest": {
"aws/aws-php-sns-message-validator": "To validate incoming SNS notifications",
"doctrine/cache": "To use the DoctrineCacheAdapter",
"ext-curl": "To send requests using cURL",
"ext-openssl": "Allows working with CloudFront private distributions and verifying received SNS messages",
"ext-sockets": "To use client-side monitoring"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.0-dev"
}
},
"autoload": {
"files": [
"src/functions.php"
],
"psr-4": {
"Aws\\": "src/"
},
"exclude-from-classmap": [
"src/data/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"Apache-2.0"
],
"authors": [
{
"name": "Amazon Web Services",
"homepage": "http://aws.amazon.com"
}
],
"description": "AWS SDK for PHP - Use Amazon Web Services in your PHP project",
"homepage": "http://aws.amazon.com/sdkforphp",
"keywords": [
"amazon",
"aws",
"cloud",
"dynamodb",
"ec2",
"glacier",
"s3",
"sdk"
],
"support": {
"forum": "https://github.com/aws/aws-sdk-php/discussions",
"issues": "https://github.com/aws/aws-sdk-php/issues",
"source": "https://github.com/aws/aws-sdk-php/tree/3.343.13"
},
"time": "2025-05-16T18:24:39+00:00"
},
{
"name": "bitverse/identicon",
"version": "1.1.1",
"source": {
"type": "git",
"url": "https://github.com/bitverseio/identicon.git",
"reference": "65a50a5a8bd86b3591795937f9652b2e9075626c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/bitverseio/identicon/zipball/65a50a5a8bd86b3591795937f9652b2e9075626c",
"reference": "65a50a5a8bd86b3591795937f9652b2e9075626c",
"shasum": ""
},
"require": {
"php": ">=5.4.0"
},
"require-dev": {
"phpunit/phpunit": "^5.0"
},
"type": "library",
"autoload": {
"psr-0": {
"": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Kuba Birecki",
"email": "kuba.birecki@bitverse.io"
}
],
"description": "A PHP library for generating identicons.",
"support": {
"issues": "https://github.com/bitverseio/identicon/issues",
"source": "https://github.com/bitverseio/identicon/tree/master"
},
"time": "2015-11-01T21:19:42+00:00"
},
{
"name": "guzzlehttp/guzzle",
"version": "7.9.3",
"source": {
"type": "git",
"url": "https://github.com/guzzle/guzzle.git",
"reference": "7b2f29fe81dc4da0ca0ea7d42107a0845946ea77"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/7b2f29fe81dc4da0ca0ea7d42107a0845946ea77",
"reference": "7b2f29fe81dc4da0ca0ea7d42107a0845946ea77",
"shasum": ""
},
"require": {
"ext-json": "*",
"guzzlehttp/promises": "^1.5.3 || ^2.0.3",
"guzzlehttp/psr7": "^2.7.0",
"php": "^7.2.5 || ^8.0",
"psr/http-client": "^1.0",
"symfony/deprecation-contracts": "^2.2 || ^3.0"
},
"provide": {
"psr/http-client-implementation": "1.0"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.8.2",
"ext-curl": "*",
"guzzle/client-integration-tests": "3.0.2",
"php-http/message-factory": "^1.1",
"phpunit/phpunit": "^8.5.39 || ^9.6.20",
"psr/log": "^1.1 || ^2.0 || ^3.0"
},
"suggest": {
"ext-curl": "Required for CURL handler support",
"ext-intl": "Required for Internationalized Domain Name (IDN) support",
"psr/log": "Required for using the Log middleware"
},
"type": "library",
"extra": {
"bamarni-bin": {
"bin-links": true,
"forward-command": false
}
},
"autoload": {
"files": [
"src/functions_include.php"
],
"psr-4": {
"GuzzleHttp\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Graham Campbell",
"email": "hello@gjcampbell.co.uk",
"homepage": "https://github.com/GrahamCampbell"
},
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
},
{
"name": "Jeremy Lindblom",
"email": "jeremeamia@gmail.com",
"homepage": "https://github.com/jeremeamia"
},
{
"name": "George Mponos",
"email": "gmponos@gmail.com",
"homepage": "https://github.com/gmponos"
},
{
"name": "Tobias Nyholm",
"email": "tobias.nyholm@gmail.com",
"homepage": "https://github.com/Nyholm"
},
{
"name": "Márk Sági-Kazár",
"email": "mark.sagikazar@gmail.com",
"homepage": "https://github.com/sagikazarmark"
},
{
"name": "Tobias Schultze",
"email": "webmaster@tubo-world.de",
"homepage": "https://github.com/Tobion"
}
],
"description": "Guzzle is a PHP HTTP client library",
"keywords": [
"client",
"curl",
"framework",
"http",
"http client",
"psr-18",
"psr-7",
"rest",
"web service"
],
"support": {
"issues": "https://github.com/guzzle/guzzle/issues",
"source": "https://github.com/guzzle/guzzle/tree/7.9.3"
},
"funding": [
{
"url": "https://github.com/GrahamCampbell",
"type": "github"
},
{
"url": "https://github.com/Nyholm",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/guzzlehttp/guzzle",
"type": "tidelift"
}
],
"time": "2025-03-27T13:37:11+00:00"
},
{
"name": "guzzlehttp/promises",
"version": "2.2.0",
"source": {
"type": "git",
"url": "https://github.com/guzzle/promises.git",
"reference": "7c69f28996b0a6920945dd20b3857e499d9ca96c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/promises/zipball/7c69f28996b0a6920945dd20b3857e499d9ca96c",
"reference": "7c69f28996b0a6920945dd20b3857e499d9ca96c",
"shasum": ""
},
"require": {
"php": "^7.2.5 || ^8.0"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.8.2",
"phpunit/phpunit": "^8.5.39 || ^9.6.20"
},
"type": "library",
"extra": {
"bamarni-bin": {
"bin-links": true,
"forward-command": false
}
},
"autoload": {
"psr-4": {
"GuzzleHttp\\Promise\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Graham Campbell",
"email": "hello@gjcampbell.co.uk",
"homepage": "https://github.com/GrahamCampbell"
},
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
},
{
"name": "Tobias Nyholm",
"email": "tobias.nyholm@gmail.com",
"homepage": "https://github.com/Nyholm"
},
{
"name": "Tobias Schultze",
"email": "webmaster@tubo-world.de",
"homepage": "https://github.com/Tobion"
}
],
"description": "Guzzle promises library",
"keywords": [
"promise"
],
"support": {
"issues": "https://github.com/guzzle/promises/issues",
"source": "https://github.com/guzzle/promises/tree/2.2.0"
},
"funding": [
{
"url": "https://github.com/GrahamCampbell",
"type": "github"
},
{
"url": "https://github.com/Nyholm",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/guzzlehttp/promises",
"type": "tidelift"
}
],
"time": "2025-03-27T13:27:01+00:00"
},
{
"name": "guzzlehttp/psr7",
"version": "2.7.1",
"source": {
"type": "git",
"url": "https://github.com/guzzle/psr7.git",
"reference": "c2270caaabe631b3b44c85f99e5a04bbb8060d16"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/psr7/zipball/c2270caaabe631b3b44c85f99e5a04bbb8060d16",
"reference": "c2270caaabe631b3b44c85f99e5a04bbb8060d16",
"shasum": ""
},
"require": {
"php": "^7.2.5 || ^8.0",
"psr/http-factory": "^1.0",
"psr/http-message": "^1.1 || ^2.0",
"ralouphie/getallheaders": "^3.0"
},
"provide": {
"psr/http-factory-implementation": "1.0",
"psr/http-message-implementation": "1.0"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.8.2",
"http-interop/http-factory-tests": "0.9.0",
"phpunit/phpunit": "^8.5.39 || ^9.6.20"
},
"suggest": {
"laminas/laminas-httphandlerrunner": "Emit PSR-7 responses"
},
"type": "library",
"extra": {
"bamarni-bin": {
"bin-links": true,
"forward-command": false
}
},
"autoload": {
"psr-4": {
"GuzzleHttp\\Psr7\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Graham Campbell",
"email": "hello@gjcampbell.co.uk",
"homepage": "https://github.com/GrahamCampbell"
},
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
},
{
"name": "George Mponos",
"email": "gmponos@gmail.com",
"homepage": "https://github.com/gmponos"
},
{
"name": "Tobias Nyholm",
"email": "tobias.nyholm@gmail.com",
"homepage": "https://github.com/Nyholm"
},
{
"name": "Márk Sági-Kazár",
"email": "mark.sagikazar@gmail.com",
"homepage": "https://github.com/sagikazarmark"
},
{
"name": "Tobias Schultze",
"email": "webmaster@tubo-world.de",
"homepage": "https://github.com/Tobion"
},
{
"name": "Márk Sági-Kazár",
"email": "mark.sagikazar@gmail.com",
"homepage": "https://sagikazarmark.hu"
}
],
"description": "PSR-7 message implementation that also provides common utility methods",
"keywords": [
"http",
"message",
"psr-7",
"request",
"response",
"stream",
"uri",
"url"
],
"support": {
"issues": "https://github.com/guzzle/psr7/issues",
"source": "https://github.com/guzzle/psr7/tree/2.7.1"
},
"funding": [
{
"url": "https://github.com/GrahamCampbell",
"type": "github"
},
{
"url": "https://github.com/Nyholm",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/guzzlehttp/psr7",
"type": "tidelift"
}
],
"time": "2025-03-27T12:30:47+00:00"
},
{
"name": "mtdowling/jmespath.php",
"version": "2.8.0",
"source": {
"type": "git",
"url": "https://github.com/jmespath/jmespath.php.git",
"reference": "a2a865e05d5f420b50cc2f85bb78d565db12a6bc"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/jmespath/jmespath.php/zipball/a2a865e05d5f420b50cc2f85bb78d565db12a6bc",
"reference": "a2a865e05d5f420b50cc2f85bb78d565db12a6bc",
"shasum": ""
},
"require": {
"php": "^7.2.5 || ^8.0",
"symfony/polyfill-mbstring": "^1.17"
},
"require-dev": {
"composer/xdebug-handler": "^3.0.3",
"phpunit/phpunit": "^8.5.33"
},
"bin": [
"bin/jp.php"
],
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.8-dev"
}
},
"autoload": {
"files": [
"src/JmesPath.php"
],
"psr-4": {
"JmesPath\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Graham Campbell",
"email": "hello@gjcampbell.co.uk",
"homepage": "https://github.com/GrahamCampbell"
},
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
}
],
"description": "Declaratively specify how to extract elements from a JSON document",
"keywords": [
"json",
"jsonpath"
],
"support": {
"issues": "https://github.com/jmespath/jmespath.php/issues",
"source": "https://github.com/jmespath/jmespath.php/tree/2.8.0"
},
"time": "2024-09-04T18:46:31+00:00"
},
{
"name": "psr/http-client",
"version": "1.0.3",
"source": {
"type": "git",
"url": "https://github.com/php-fig/http-client.git",
"reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/http-client/zipball/bb5906edc1c324c9a05aa0873d40117941e5fa90",
"reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90",
"shasum": ""
},
"require": {
"php": "^7.0 || ^8.0",
"psr/http-message": "^1.0 || ^2.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\Http\\Client\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "https://www.php-fig.org/"
}
],
"description": "Common interface for HTTP clients",
"homepage": "https://github.com/php-fig/http-client",
"keywords": [
"http",
"http-client",
"psr",
"psr-18"
],
"support": {
"source": "https://github.com/php-fig/http-client"
},
"time": "2023-09-23T14:17:50+00:00"
},
{
"name": "psr/http-factory",
"version": "1.1.0",
"source": {
"type": "git",
"url": "https://github.com/php-fig/http-factory.git",
"reference": "2b4765fddfe3b508ac62f829e852b1501d3f6e8a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/http-factory/zipball/2b4765fddfe3b508ac62f829e852b1501d3f6e8a",
"reference": "2b4765fddfe3b508ac62f829e852b1501d3f6e8a",
"shasum": ""
},
"require": {
"php": ">=7.1",
"psr/http-message": "^1.0 || ^2.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\Http\\Message\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "https://www.php-fig.org/"
}
],
"description": "PSR-17: Common interfaces for PSR-7 HTTP message factories",
"keywords": [
"factory",
"http",
"message",
"psr",
"psr-17",
"psr-7",
"request",
"response"
],
"support": {
"source": "https://github.com/php-fig/http-factory"
},
"time": "2024-04-15T12:06:14+00:00"
},
{
"name": "psr/http-message",
"version": "2.0",
"source": {
"type": "git",
"url": "https://github.com/php-fig/http-message.git",
"reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/http-message/zipball/402d35bcb92c70c026d1a6a9883f06b2ead23d71",
"reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71",
"shasum": ""
},
"require": {
"php": "^7.2 || ^8.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\Http\\Message\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "https://www.php-fig.org/"
}
],
"description": "Common interface for HTTP messages",
"homepage": "https://github.com/php-fig/http-message",
"keywords": [
"http",
"http-message",
"psr",
"psr-7",
"request",
"response"
],
"support": {
"source": "https://github.com/php-fig/http-message/tree/2.0"
},
"time": "2023-04-04T09:54:51+00:00"
},
{
"name": "ralouphie/getallheaders",
"version": "3.0.3",
"source": {
"type": "git",
"url": "https://github.com/ralouphie/getallheaders.git",
"reference": "120b605dfeb996808c31b6477290a714d356e822"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822",
"reference": "120b605dfeb996808c31b6477290a714d356e822",
"shasum": ""
},
"require": {
"php": ">=5.6"
},
"require-dev": {
"php-coveralls/php-coveralls": "^2.1",
"phpunit/phpunit": "^5 || ^6.5"
},
"type": "library",
"autoload": {
"files": [
"src/getallheaders.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Ralph Khattar",
"email": "ralph.khattar@gmail.com"
}
],
"description": "A polyfill for getallheaders.",
"support": {
"issues": "https://github.com/ralouphie/getallheaders/issues",
"source": "https://github.com/ralouphie/getallheaders/tree/develop"
},
"time": "2019-03-08T08:55:37+00:00"
},
{
"name": "symfony/deprecation-contracts",
"version": "v3.5.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/deprecation-contracts.git",
"reference": "74c71c939a79f7d5bf3c1ce9f5ea37ba0114c6f6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/74c71c939a79f7d5bf3c1ce9f5ea37ba0114c6f6",
"reference": "74c71c939a79f7d5bf3c1ce9f5ea37ba0114c6f6",
"shasum": ""
},
"require": {
"php": ">=8.1"
},
"type": "library",
"extra": {
"thanks": {
"url": "https://github.com/symfony/contracts",
"name": "symfony/contracts"
},
"branch-alias": {
"dev-main": "3.5-dev"
}
},
"autoload": {
"files": [
"function.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "A generic function and convention to trigger deprecation notices",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/deprecation-contracts/tree/v3.5.1"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2024-09-25T14:20:29+00:00"
},
{
"name": "symfony/polyfill-mbstring",
"version": "v1.32.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-mbstring.git",
"reference": "6d857f4d76bd4b343eac26d6b539585d2bc56493"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/6d857f4d76bd4b343eac26d6b539585d2bc56493",
"reference": "6d857f4d76bd4b343eac26d6b539585d2bc56493",
"shasum": ""
},
"require": {
"ext-iconv": "*",
"php": ">=7.2"
},
"provide": {
"ext-mbstring": "*"
},
"suggest": {
"ext-mbstring": "For best performance"
},
"type": "library",
"extra": {
"thanks": {
"url": "https://github.com/symfony/polyfill",
"name": "symfony/polyfill"
}
},
"autoload": {
"files": [
"bootstrap.php"
],
"psr-4": {
"Symfony\\Polyfill\\Mbstring\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony polyfill for the Mbstring extension",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"mbstring",
"polyfill",
"portable",
"shim"
],
"support": {
"source": "https://github.com/symfony/polyfill-mbstring/tree/v1.32.0"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2024-12-23T08:48:59+00:00"
}
],
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": [],
"platform-dev": [],
"plugin-api-version": "2.6.0"
}

View File

@@ -0,0 +1,59 @@
<?php
class AltfolderStorage implements StorageController
{
function isEnabled()
{
return (defined('ALT_FOLDER') && ALT_FOLDER && is_dir(ALT_FOLDER));
}
function hashExists($hash)
{
$altname=ALT_FOLDER.DS.$hash;
return file_exists($altname);
}
function getItems($dev=false)
{
$rii = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(ALT_FOLDER.DS));
$files = array();
foreach ($rii as $file) {
if ($file->isDir())
continue;
$files[] = $file->getFilename();
}
return $files;
}
function pullFile($hash,$location)
{
$altname=ALT_FOLDER.DS.$hash;
if(file_exists($altname))
{
copy($altname,$location);
}
}
function pushFile($source,$hash)
{
$altname=ALT_FOLDER.DS.$hash;
if(!$this->hashExists($hash))
{
copy($source,$altname);
return true;
}
return false;
}
function deleteFile($hash)
{
$altname=ALT_FOLDER.DS.$hash;
if(file_exists($altname))
{
unlink($altname);
}
}
}

View File

@@ -0,0 +1,145 @@
<?php
class FTPStorage implements StorageController
{
private $connection;
private $login;
function __destruct()
{
if($this->connection)
ftp_close($this->connection);
}
function connect()
{
if(!$this->connection)
{
if(defined('FTP_SSL') && FTP_SSL === true)
$this->connection = ftp_ssl_connect(FTP_SERVER, ((defined('FTP_SSL') && is_numeric(FTP_PORT))?FTP_PORT:21) );
else
$this->connection = ftp_connect(FTP_SERVER, ((defined('FTP_SSL') && is_numeric(FTP_PORT))?FTP_PORT:21) );
}
if($this->connection && !$this->login)
{
$this->login = ftp_login($this->connection, FTP_USER, FTP_PASS);
if( (defined('FTP_PASSIVEMODE') && FTP_PASSIVEMODE === true) || !defined('FTP_PASSIVEMODE') )
{
ftp_set_option($this->connection, FTP_USEPASVADDRESS, false);
ftp_pasv($this->connection, TRUE);
}
else
ftp_pasv($this->connection, false);
}
// Was the connection successful?
if ((!$this->connection) || (!$this->login)) {
$this->connection = false;
return false;
}
return true;
}
function isEnabled()
{
return (defined('FTP_SERVER') && FTP_SERVER &&
defined('FTP_USER') && FTP_USER &&
defined('FTP_PASS') && FTP_PASS);
}
function hashExists($hash)
{
if(!$this->connect()) return null;
$subdir = $this->hashToDir($hash);
$ftpfilepath = FTP_BASEDIR.$subdir.'/'.$hash;
if(@ftp_chdir($this->connection, FTP_BASEDIR.$subdir))
return (ftp_size($this->connection,$ftpfilepath)>0?true:false);
return false;
}
function getItems($dev=false)
{
if(!$this->connect()) return false;
return $this->ftp_list_files_recursive(FTP_BASEDIR,$dev);
}
function pullFile($hash,$location)
{
if(!$this->connect()) return false;
$subdir = $this->hashToDir($hash);
$ftpfilepath = FTP_BASEDIR.$subdir.'/'.$hash;
return ftp_get($this->connection, $location, $ftpfilepath, FTP_BINARY);
}
function pushFile($source,$hash)
{
if(!$this->connect()) return false;
$subdir = $this->hashToDir($hash);
$ftpfilepath = FTP_BASEDIR.$subdir.'/'.$hash;
$this->ftp_mksubdirs($subdir);
return ftp_put($this->connection, $ftpfilepath, $source, FTP_BINARY);
}
function deleteFile($hash)
{
if(!$this->connect()) return false;
$subdir = $this->hashToDir($hash);
$ftpfilepath = FTP_BASEDIR.$subdir.'/'.$hash;
return (ftp_delete($this->connection,$ftpfilepath)?true:false);
}
function hashToDir($hash)
{
$md5 = md5($hash);
$dir = $md5[0].'/'.$md5[1].'/'.$md5[2];
return $dir;
}
function ftp_mksubdirs($ftpath)
{
if(!$this->connect()) return false;
@ftp_chdir($this->connection, FTP_BASEDIR);
$parts = array_filter(explode('/',$ftpath), function($value) {
return ($value !== null && $value !== false && $value !== '');
});
foreach($parts as $part){
$part = strval($part);
if(!@ftp_chdir($this->connection, $part)){
ftp_mkdir($this->connection, $part);
ftp_chdir($this->connection, $part);
}
}
}
function ftp_list_files_recursive($path,$dev=false)
{
if(!$this->connect()) return false;
$items = ftp_mlsd($this->connection, $path);
$result = array();
if(is_array($items))
foreach ($items as $item)
{
$name = $item['name'];
$type = $item['type'];
$filepath = $path.'/'. $name;
if ($type == 'dir')
{
$result =
array_merge($result, $this->ftp_list_files_recursive($filepath,$dev));
}
else if(mightBeAHash($name) || endswith($name,'.enc'))
{
$result[] = $name;
if($dev===true) echo " Got $name \r";
}
}
return $result;
}
}

View File

@@ -0,0 +1,108 @@
<?php
/**
* Config needed
*
* S3_BUCKET
* S3_ACCESS_KEY
* S3_SECRET_KEY
* (optional) S3_ENDPOINT
*/
class S3Storage implements StorageController
{
private $s3;
function connect(){
$this->s3 = new Aws\S3\S3Client([
'version' => 'latest',
'region' => (defined('S3_REGION') && S3_REGION ?S3_REGION:'us-east-1'),
'endpoint' => S3_ENDPOINT,
'use_path_style_endpoint' => true,
'credentials' => [
'key' => S3_ACCESS_KEY,
'secret' => S3_SECRET_KEY,
],
]);
}
function isEnabled()
{
return (defined('S3_BUCKET') && S3_BUCKET);
}
function hashExists($hash)
{
if(!$this->s3)$this->connect();
return $this->s3->doesObjectExist(S3_BUCKET,$hash);
}
function getItems($dev=false)
{
if(!$this->s3)$this->connect();
$KeyCount = 9999;
$keys = 100; //the amount of keys we'll receive per request. 1000 max but that times out sometimes
$lastkey = false;
$count = 0;
$items = array();
while($KeyCount>=$keys)
{
$objects = $this->s3->listObjectsV2([
'Bucket' => S3_BUCKET,
'MaxKeys'=> $keys,
'StartAfter'=>($lastkey?$lastkey:'')
]);
++$count;
foreach ($objects['Contents'] as $object){
$lastkey = $object['Key'];
$items[] = $lastkey;
}
if($dev===true) echo " Got ".($count*$keys)." files \r";
$KeyCount = $objects['KeyCount'];
}
return $items;
}
function pullFile($hash,$location)
{
if(!$this->s3)$this->connect();
if(!$this->hashExists($hash)) return false;
$this->s3->getObject([
'Bucket' => S3_BUCKET,
'Key' => $hash,
'SaveAs' => $location
]);
return true;
}
function pushFile($source,$hash)
{
if(!$this->s3)$this->connect();
$this->s3->putObject([
'Bucket' => S3_BUCKET,
'Key' => $hash,
'SourceFile' => $source
]);
return true;
}
function deleteFile($hash)
{
if(!$this->s3)$this->connect();
$this->s3->deleteObject([
'Bucket' => S3_BUCKET,
'Key' => $hash
]);
}
}

View File

@@ -0,0 +1,25 @@
<h2>Admin Panel</h2>
<?php if (!$_SESSION['admin']) { ?>
<form method="post" action="/admin">
<div class="input-group mb-3">
<input type="password" class="form-control" name="password" placeholder="Password" aria-label="Password" aria-describedby="btn-addn">
<button class="btn btn-outline-secondary" type="submit" id="btn-addn">Login</button>
</div>
</form>
<?php } ?>
<?php if ($_SESSION['admin']) { ?>
<div class="alert alert-success" role="alert">You are logged in as admin</div>
<form method="post" action="/admin">
<button type="submit" name="logout" class="btn btn-danger">Logout</button>
</form>
<ul class="nav">
<li class="nav-item">
<a class="nav-link" aria-current="page" href="/admin/stats">Stats</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/admin/logs">Logs</a>
</li>
</ul>
<?php } ?>

View File

@@ -0,0 +1,15 @@
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="/admin">Admin</a></li>
<li class="breadcrumb-item"><a href="/admin/logs">Logs</a></li>
<li class="breadcrumb-item active" aria-current="page"><?=$type?></li>
</ol>
</nav>
<h1><?= ucfirst($type) ?></h1>
<pre>
<code><?php foreach($logs as $log):
echo $log;
endforeach; ?></code>
</pre>

View File

@@ -0,0 +1,10 @@
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="/admin">Admin</a></li>
<li class="breadcrumb-item active" aria-current="page">Logs</li>
</ol>
</nav>
<a class="btn btn-primary" href="/admin/logs/app">General App logs</a>
<a class="btn btn-primary" href="/admin/logs/views">Views</a>
<a class="btn btn-primary" href="/admin/logs/error">Errors</a>

View File

@@ -0,0 +1,41 @@
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="/admin">Admin</a></li>
<li class="breadcrumb-item active" aria-current="page">Stats</li>
</ol>
</nav>
<h1>Stats</h1>
<div class="table-responsive">
<table class="table table-hover" data-toggle="table" data-search="true">
<thead>
<tr>
<th scope="col" data-sortable="true">Hash</th>
<th scope="col" data-sortable="true">Views</th>
<th scope="col" data-sortable="true">Original Filename</th>
<th scope="col" data-sortable="true">MIME type</th>
<th scope="col" data-sortable="true">Created at</th>
<th scope="col" data-sortable="true">Uploader IP</th>
<?php if(defined('LOG_VIEWS') && LOG_VIEWS==true): ?>
<th scope="col" data-sortable="true">List views</th>
<?php endif; ?>
</tr>
</thead>
<tbody>
<?php foreach($stats['hashes'] as $hash => $data): ?>
<tr>
<th scope="row"><a href="/<?=$hash?>"><?=$hash?></a></th>
<td><?=$data['views']?:0?></td>
<td><?=$data['metadata']['original_filename']?></td>
<td><?=$data['metadata']['mime']?></td>
<td><?=$data['metadata']['uploaded']?date("Y-m-d H:i",$data['metadata']['uploaded']):''?></td>
<td><?=$data['metadata']['ip']?></td>
<?php if(defined('LOG_VIEWS') && LOG_VIEWS==true): ?>
<td scope="col" data-sortable="true"><a class="btn btn-secondary" href="/admin/logs/views/<?=$hash?>">View logs</a></td>
<?php endif; ?>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>

View File

@@ -0,0 +1,75 @@
<!DOCTYPE html>
<html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>PictShare - the smart CDN</title>
<!-- Bootstrap -->
<link href="/css/bootstrap.min.css" rel="stylesheet">
<!-- PictShare overwrites -->
<link href="/css/pictshare.css" rel="stylesheet">
<link href="/css/dropzone.css" rel="stylesheet">
<link href="/css/bootstrap-table.min.css" rel="stylesheet">
<link href="/css/hljs-dracula.css" rel="stylesheet">
<!-- github-fork-ribbon-css
https://simonwhitaker.github.io/github-fork-ribbon-css/ -->
<link href="/css/gh-fork-ribbon.min.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<script>
var maxUploadFileSize = <?php echo (int)(ini_get('upload_max_filesize')); ?>
</script>
<meta name="description" content="Free image sharing, linking and tracking">
<meta name="keywords" content="image, share, hosting, free">
<meta name="robots" content="index, follow">
<meta name="copyright" content="Haschek Solutions">
<meta name="language" content="EN,DE">
<meta name="author" content="Haschek Solutions">
<meta name="distribution" content="global">
<meta name="rating" content="general">
</HEAD>
<BODY>
<div class="container" id="headcontainer">
<div class="row">
<div class="col-md-8">
<a href="/"><img src="/css/imgs/logo/horizontalv3.png" /></a>
</div>
</div>
</div>
<div id="main" class="container hv-100">
<?=$main;?>
</div>
<div class="footer">
<div class="container text-center">
<p>created by <a href="https://haschek.solutions" target="_blank"><img height="30" src="/css/imgs/hs_logo.png" /></a> - <a href="https://github.com/HaschekSolutions/pictshare" target="_blank">GitHub</a></p>
</div>
</div>
<script src="/js/jquery.min.js"></script>
<script src="/js/bootstrap.bundle.min.js"></script>
<script src="/js/bootstrap-table.min.js"></script>
<script src="/js/dropzone.js"></script>
<script src="/js/highlight.pack.js"></script>
<script src="/js/pictshare.js"></script>
</BODY>
</HTML>

181
src/templates/main.html.php Normal file
View File

@@ -0,0 +1,181 @@
<?php
if (file_exists(ROOT . DS . 'notice.txt'))
echo '<div class="alert alert-warning" role="alert">' . file_get_contents(ROOT . DS . 'notice.txt') . '</div>';
?>
<div class="well">
<?php if ($forbidden === true) { ?>
<h2>Upload forbidden</h2>
<p>Due to configured restrictions, you are not allowed to upload files at this time</p>
<?php } else { ?>
<div id="uploadinfo"></div>
<p>
Max Upload size: <?= (int)(ini_get('upload_max_filesize')) ?>MB / File<br />
Allowed file types: <?= implode(', ', getAllContentFiletypes()) ?>
<?php
if (defined('UPLOAD_CODE') && UPLOAD_CODE != ''): ?>
<br>Upload Code: <input type="password" id="uploadcode" />
<?php endif; ?>
</p>
<form class="dropzone well" id="dropzone" method="post" action="/api/upload" enctype="multipart/form-data">
<div class="fallback">
<input name="file" type="file" multiple />
</div>
</form>
<?php } ?>
</div>
<h2 id="api" class="section-heading">Using PictShare</h2>
<div class="row">
<div class="col-6">
<h3>Basics</h3>
<p>
When you upload an image you'll get a link like this:
<pre><code class="url"><?= getURL() ?>abcef123.jpg</code></pre>
You can modify the size of the image by adding a size parameter to the URL. For example this will render the image in 800x600:
<pre><code class="url"><?= getURL() ?>800x600/abcef123.jpg</code></pre>
</p>
<p>
If you want to force the size to really be 800x600, you can use the "forcesize" parameter. It will still keep the aspect ratio but zoom in as needed to fit the dimensions
<pre><code class="url"><?= getURL() ?>800x600/forcesize/abcef123.jpg</code></pre>
</p>
<p>There are many more of these <a target="_blank" href="https://github.com/HaschekSolutions/pictshare/blob/master/rtfm/MODIFIERS.md">modifiers</a> and even <a target="_blank" href="https://github.com/HaschekSolutions/pictshare/blob/master/rtfm/IMAGEFILTERS.md">filters</a> available</p>
</div>
</div>
<hr class="no-print border border-primary border-2 opacity-50">
<h2 id="api" class="section-heading">Using the API</h2>
<div class="row">
<div class="col-6">
<h2>Basics</h2>
<p>
All API calls are done via GET or POST requests. The API will return JSON encoded data.
</p>
Base URL
<pre><code class="url"><?= getURL() ?>api</code></pre>
</div>
<div class="col-6">
<h2>Error handling</h2>
When the status is err there will always be a field "reason" that explains what went wrong.
<pre><code class="json">
{
"status": "err",
"reason": "File not a valid image"
}
</code></pre>
</div>
<div class="w-100">
<hr />
</div>
<div class="col-6">
<h2>Uploading an image</h2>
API call
<pre><code class="url">/upload</code></pre>
<p>You can post a file using the POST variable <span class="badge text-bg-secondary">file</span></p>
CURL example
<pre><code class="bash">curl -s -F "file=@myphoto.jpg" "<?= getURL() ?>api/upload"</code></pre>
Output
<pre><code class="json">
{
"status": "ok",
"hash": "7eli4d.jpg",
"filetype": "image/jpeg",
"url": "http://localhost:8080/7eli4d.jpg",
"delete_code": "jxgat3wze8lmn9sqwxy4x32p2xm7211g",
"delete_url": "http://localhost:8080/delete_jxgat3wze8lmn9sqwxy4x32p2xm7211g/7eli4d.jpg"
}</code></pre>
</div>
<div class="col-6">
<h2>Grabbing a URL</h2>
API call
<pre><code class="url">/upload?url=<span class="badge text-bg-secondary">url of image</span></code></pre>
<p>You can specify a URL in the POST or GET variable <span class="badge text-bg-secondary">url</span>
that the call will try to download and process.</p>
CURL example
<pre><code class="bash">curl -s "<?= getURL() ?>api/upload?url=https://pictshare.net/d2j1e1.png</code></pre>
Output
<pre><code class="json">
{
"status": "ok",
"hash": "ysj455.webp",
"filetype": "image/webp",
"url": "http://localhost:8080/ysj455.webp",
"delete_code": "4l0w04l4s42xddt2s5mrj1wikxz11l5z",
"delete_url": "http://localhost:8080/delete_4l0w04l4s42xddt2s5mrj1wikxz11l5z/ysj455.webp"
}
</code></pre>
</div>
<div class="w-100">
<hr />
</div>
<div class="col-6">
<h2>Uploading Base64 encoded content</h2>
<p>It's also possible to upload supported files via Base64 strings by providing the <span class="badge text-bg-secondary">base64</span> http parameter</p>
API call
<pre><code class="url">/upload/?base64=<span class="badge text-bg-secondary">base64 encoded string</span></code></pre>
CURL example
<pre><code class="bash">(echo -n "base64="; echo -n "data:image/jpeg;base64,$(base64 -w 0 Screenshot3.jpg)") | curl --data @- <?= getURL() ?>api/upload</code></pre>
Output
<pre><code class="json">
{
"status": "ok",
"hash": "5e6alk.jpg",
"filetype": "image/jpeg",
"url": "http://localhost:8080/5e6alk.jpg",
"delete_code": "7ha2b5ccvsuvdd3qdnegzb2zqa9zxb5t",
"delete_url": "http://localhost:8080/delete_7ha2b5ccvsuvdd3qdnegzb2zqa9zxb5t/5e6alk.jpg"
}</code></pre>
</div>
<div class="col-6">
<h2>On-the-fly modifications to images</h2>
<p>You can modify images on-the-fly (without saving them to the server) by specifying additional parameters in the API call to use Pictshare to "clean up" or "normalize" images uploaded to your app. The passthrough endpoint allows you to use the normal image modifiers in the URL. It won't save the image on the Server and will respond with the modified image directly.</p>
API call
<pre><code class="url">/passthrough/image/[modifiers]</code></pre>
<p>For example to force an uploaded image to 400x400 and have it grayscale you can do this:</p>
CURL example
<pre><code class="bash">curl -s -F "file=@myphoto.jpg" "<?= getURL() ?>api/passthrough/image/400x400/forcesize/gray" > result.jpg</code></pre>
If the status code is anything other than "200", it will return an error message in JSON format.
<pre><code class="json">
{
"status": "err",
"reason": "Not a valid image"
}</code></pre>
If the status code is "200", it will return the modified image directly.
</div>
</div>

View File

@@ -0,0 +1,93 @@
<!doctype html>
<html>
<head>
<title><?= (defined('TITLE')?TITLE:'PictShare image hosting'); ?></title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<meta name="copyright" content="Copyright <?= date("Y"); ?> PictShare" />
<meta id="viewport" name="viewport" content="width=<?= $width ?>, user-scalable=yes" />
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<style type="text/css">
*{margin:0px;padding:0px;}
</style>
<link rel="alternate" type="application/json+oembed" href="<?= URL; ?>backend.php?a=oembed&t=json&url=<?= rawurlencode(URL.$hash); ?>" title="PictShare" />
<link rel="canonical" href="<?= URL.$hash; ?>" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta property="og:site_name" content="<?= (defined('TITLE')?TITLE:'PictShare mp4 hosting'); ?>" />
<meta property="og:url" content="<?= URL.$hash; ?>" />
<meta property="og:title" content="<?= (defined('TITLE')?TITLE:'PictShare mp4 hosting'); ?> MP4" />
<meta property="og:type" content="video.other" />
<meta property="og:image" content="<?= URL.'preview/'.$hash; ?>" />
<meta property="og:image:width" content="<?= $width ?>" />
<meta property="og:image:height" content="<?= $height ?>" />
<meta property="og:description" content="MP4 Video" />
<meta property="og:video" content="<?= URL.$hash; ?>" />
<meta property="og:video:secure_url" content="<?= URL.$hash; ?>" />
<meta property="og:video:type" content="application/x-shockwave-flash" />
<meta property="og:video:width" content="<?= $width ?>" />
<meta property="og:video:height" content="<?= $height ?>" />
<meta property="og:video:type" content="video/mp4" />
<meta property="og:video:width" content="<?= $width ?>" />
<meta property="og:video:height" content="<?= $height ?>" />
</head>
<body id="body">
<div id="container">
<video id="video" poster="<?= URL.$url.'/preview/'.$hash; ?>" preload="auto" autoplay="autoplay" controls muted="muted" loop="loop" webkit-playsinline>
<source src="<?= URL.$url.'/raw' ?>" type="video/mp4">
<?php
if(file_exists(getDataDir().DS.$hash.DS.'webm_1.'.$hash)):?>
<source src="<?= URL.'raw/webm/'.$hash ?>" type="video/webm">
<?php endif;
if(file_exists(getDataDir().DS.$hash.DS.'ogg_1.'.$hash)):?>
<source src="<?= URL.'raw/ogg/'.$hash ?>" type="video/ogg">
<?php endif;
?>
</video>
</div>
<small><?= $filesize; ?> <a href="<?= URL.$url.'/raw' ?>">Raw</a> <a href="<?= URL.$url.'/download' ?>">Download</a></a></small>
<script>
var hadToResizeW = false;
var hadToResizeH = false;
var video = document.getElementById('video');
video.addEventListener('click',function(){
video.play();
},false);
var $video = $('video'),
$window = $(window);
//check video size as soon as the page has finished loading
jQuery(window).load(function () {
resizeMe();
});
//if the windows size has changed, check video sizes again
$(window).resize(function(){
resizeMe();
}).resize();
function resizeMe()
{
if($window.width() < $video.width() || hadToResizeW===true)
{
hadToResizeW = true;
$video.width($window.width());
}
if($window.height() < $video.height() || hadToResizeH===true)
{
hadToResizeH = true;
$video.height($window.height());
}
}
</script>
</body>
</html>

View File

@@ -1,43 +0,0 @@
<?php
class AltfolderStorage implements StorageController
{
function isEnabled()
{
return (defined('ALT_FOLDER') && ALT_FOLDER && is_dir(ALT_FOLDER));
}
function hashExists($hash)
{
$altname=ALT_FOLDER.DS.$hash;
return file_exists($altname);
}
function pullFile($hash)
{
$altname=ALT_FOLDER.DS.$hash;
if(file_exists($altname))
{
storeFile($altname,$hash,false);
}
}
function pushFile($hash)
{
$altname=ALT_FOLDER.DS.$hash;
$orig = ROOT.DS.'data'.DS.$hash.DS.$hash;
if(file_exists($orig) && !$this->hashExists($hash))
{
copy($orig,$altname);
}
}
function deleteFile($hash)
{
$altname=ALT_FOLDER.DS.$hash;
if(file_exists($altname))
{
unlink($altname);
}
}
}

View File

@@ -1,66 +0,0 @@
<!DOCTYPE html>
<!--[if IEMobile 7 ]> <html class="no-js iem7"> <![endif]-->
<!--[if (gt IEMobile 7)|!(IEMobile)]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title><?php echo (defined('TITLE')?TITLE:'PictShare image hosting'); ?></title>
<!-- Bootstrap -->
<link href="/css/bootstrap.min.css" rel="stylesheet">
<!-- PictShare overwrites -->
<link href="/css/pictshare.css" rel="stylesheet">
<link href="/css/dropzone.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<meta name="description" content="Free image sharing, linking and tracking">
<meta name="keywords" content="image, share, hosting, free">
<meta name="robots" content="index, follow">
<meta name="copyright" content="Haschek Solutions">
<meta name="language" content="EN,DE">
<meta name="author" content="Haschek Solutions">
<meta name="distribution" content="global">
<meta name="rating" content="general">
</HEAD>
<BODY><a href="https://github.com/HaschekSolutions/pictshare"><img style="position: absolute; top: 0; left: 0; border: 0;" src="https://camo.githubusercontent.com/82b228a3648bf44fc1163ef44c62fcc60081495e/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f6c6566745f7265645f6161303030302e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_left_red_aa0000.png"></a>
<div class="container" id="headcontainer">
<div class="row">
<div class="col-md-8">
<a href="/"><img src="/css/imgs/logo/horizontal3.png" /></a>
<div class="well">
<div id="uploadinfo"></div>
<p>
<?php
echo "Max Upload size: ". (int)(ini_get('upload_max_filesize'))."MB / File<br/>";
echo "Allowed file types: ". implode(', ',getAllContentFiletypes());
?>
</p>
<form class="dropzone well" id="dropzone" method="post" action="/api/upload.php" enctype="multipart/form-data">
<div class="fallback">
<input name="file" type="file" multiple />
</div>
</form>
</div>
</div>
</div>
<footer>(c)<?php echo date("y");?> by<br/><a href="https://haschek.solutions" target="_blank"><img height="30" src="/css/imgs/hs_logo.png" /></a></footer>
</div>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="/js/bootstrap.min.js"></script>
<script src="/js/dropzone.js"></script>
<script src="/js/pictshare.js"></script>
</BODY>
</HTML>

View File

@@ -1,91 +0,0 @@
<!doctype html>
<html>
<head>
<title><?php echo (defined('TITLE')?TITLE:'PictShare image hosting'); ?></title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<meta name="copyright" content="Copyright <?php echo date("Y"); ?> PictShare" />
<meta id="viewport" name="viewport" content="width=<?php echo $width ?>, user-scalable=yes" />
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<style type="text/css">
*{margin:0px;padding:0px;}
</style>
<link rel="alternate" type="application/json+oembed" href="<?php echo URL; ?>backend.php?a=oembed&t=json&url=<?php echo rawurlencode(URL.$hash); ?>" title="PictShare" />
<link rel="canonical" href="<?php echo URL.$hash; ?>" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta property="og:site_name" content="<?php echo (defined('TITLE')?TITLE:'PictShare mp4 hosting'); ?>" />
<meta property="og:url" content="<?php echo URL.$hash; ?>" />
<meta property="og:title" content="<?php echo (defined('TITLE')?TITLE:'PictShare mp4 hosting'); ?> MP4" />
<meta property="og:type" content="video.other" />
<meta property="og:image" content="<?php echo URL.'preview/'.$hash; ?>" />
<meta property="og:image:width" content="<?php echo $width ?>" />
<meta property="og:image:height" content="<?php echo $height ?>" />
<meta property="og:description" content="MP4 Video" />
<meta property="og:video" content="<?php echo URL.$hash; ?>" />
<meta property="og:video:secure_url" content="<?php echo URL.$hash; ?>" />
<meta property="og:video:type" content="application/x-shockwave-flash" />
<meta property="og:video:width" content="<?php echo $width ?>" />
<meta property="og:video:height" content="<?php echo $height ?>" />
<meta property="og:video:type" content="video/mp4" />
<meta property="og:video:width" content="<?php echo $width ?>" />
<meta property="og:video:height" content="<?php echo $height ?>" />
</head>
<body id="body">
<div id="container">
<video id="video" poster="<?php echo URL.$url.'/preview/'.$hash; ?>" preload="auto" autoplay="autoplay" controls muted="muted" loop="loop" webkit-playsinline>
<source src="<?php echo URL.$url.'/raw' ?>" type="video/mp4">
<?php
if(file_exists(ROOT.DS.'data'.DS.$hash.DS.'webm_1.'.$hash))
echo '<source src="'.URL.'raw/webm/'.$hash.'" type="video/webm">'."\n";
if(file_exists(ROOT.DS.'data'.DS.$hash.DS.'ogg_1.'.$hash))
echo '<source src="'.URL.'raw/ogg/'.$hash.'" type="video/ogg">'."\n";
?>
</video>
</div>
<small><?php echo $filesize; ?> <a href="<?php echo URL.$url.'/raw' ?>">Raw</a> <a href="<?php echo URL.$url.'/download' ?>">Download</a></a></small>
<script>
var hadToResizeW = false;
var hadToResizeH = false;
var video = document.getElementById('video');
video.addEventListener('click',function(){
video.play();
},false);
var $video = $('video'),
$window = $(window);
//check video size as soon as the page has finished loading
jQuery(window).load(function () {
resizeMe();
});
//if the windows size has changed, check video sizes again
$(window).resize(function(){
resizeMe();
}).resize();
function resizeMe()
{
if($window.width() < $video.width() || hadToResizeW===true)
{
hadToResizeW = true;
$video.width($window.width());
}
if($window.height() < $video.height() || hadToResizeH===true)
{
hadToResizeH = true;
$video.height($window.height());
}
}
</script>
</body>
</html>

0
tmp/.gitignore vendored Normal file → Executable file
View File

View File

@@ -1,99 +0,0 @@
<?php
/*
* Alternative folder upload
* This tool copies all raw images/videos/gifs to the defined ALT_FOLDER location
* This will create a copy in the location. The location can be a mounted external server like CIFS or sshfs
* This will allow you to store a backup of your images on some other server
*
*/
if(php_sapi_name() !== 'cli') exit('This script can only be called via CLI');
error_reporting(E_ALL & ~E_DEPRECATED & ~E_STRICT & ~E_NOTICE);
define('DS', DIRECTORY_SEPARATOR);
define('ROOT', dirname(__FILE__).DS.'..');
include_once(ROOT.DS.'inc/config.inc.php');
include_once(ROOT.DS.'inc/core.php');
if(!defined('ALT_FOLDER') || !ALT_FOLDER)
die("[X] Error: You should define the ALT_FOLDER config in your inc/config.inc.php first");
$pm = new PictshareModel();
if(in_array('sim',$argv))
{
echo "[!!!!] SIMULATION MODE. Nothing will be uploaded [!!!!] \n\n";
$sim = true;
}
else $sim = false;
//gather local data
echo "[i] Looping through local files\n";
$dir = ROOT.DS.'data'.DS;
$dh = opendir($dir);
$localfiles = array();
$allhashes=0;$allsize=0;
$skips=0;$skipsize=0;
$copied=0;$copysize=0;
$errors=0;$errorsize=0;
while (false !== ($hash = readdir($dh))) {
if($hash=='.'||$hash=='..') continue;
$img = $dir.$hash.DS.$hash;
if(!file_exists($img)) continue;
$info = strtolower(pathinfo($img, PATHINFO_EXTENSION));
$thissize = filesize($img);
$type = $pm->isTypeAllowed($info);
++$allhashes;
$allsize+=$thissize;
if($type)
{
if(file_exists(ALT_FOLDER.DS.$hash))
{
echo " [!] Skipping existing $hash \n";
++$skips;
$skipsize+=$thissize;
}
else
{
++$copied;
$copysize+=$thissize;
echo "[i] Copying $hash to ".ALT_FOLDER.DS.$hash." \r";
if($sim===false)
copy($img,ALT_FOLDER.DS.$hash);
}
}
else
{
++$errors;
$errorsize+=$thissize;
echo " [X] ERROR $hash not allowed format: $info \n";
}
}
echo "\n[i] Done\n";
echo "\n----------- STATS ----------\n\n";
echo " All files found:\t$allhashes\t".renderSize($allsize)."\n";
echo " Copied files:\t$copied\t".renderSize($copysize)."\n";
echo " Skipped files:\t$skips\t".renderSize($skipsize)."\n";
echo " Erroneous files:\t$errors\t".renderSize($errorsize)."\n";
echo "\n";
function renderSize($bytes, $precision = 2) {
$units = array('B', 'KB', 'MB', 'GB', 'TB');
$bytes = max($bytes, 0);
$pow = floor(($bytes ? log($bytes) : 0) / log(1024));
$pow = min($pow, count($units) - 1);
// Uncomment one of the following alternatives
$bytes /= pow(1024, $pow);
// $bytes /= (1 << (10 * $pow));
return round($bytes, $precision) . ' ' . $units[$pow];
}

View File

@@ -1,91 +0,0 @@
<?php
/*
* Backblaze uploader
* This tool uploads all local images to backblaze if they don't exist yet
* You can use this to backup your images to backblaze or set it up as your data source for scaling
*
*/
if(php_sapi_name() !== 'cli') exit('This script can only be called via CLI');
error_reporting(E_ALL & ~E_DEPRECATED & ~E_STRICT & ~E_NOTICE);
define('DS', DIRECTORY_SEPARATOR);
define('ROOT', dirname(__FILE__).DS.'..');
include_once(ROOT.DS.'inc/config.inc.php');
include_once(ROOT.DS.'inc/core.php');
include_once(ROOT.DS.'classes/backblaze.php');
$pm = new PictshareModel();
if(in_array('sim',$argv))
{
echo "[!!!!] SIMULATION MODE. Nothing will be uploaded [!!!!] \n\n";
$sim = true;
}
else $sim = false;
if(in_array('recentlyrendered',$argv))
{
echo "[O] Will only upload if the image was recently viewed. Recently meaning now minus one year \n\n";
$recentonly = true;
}
else $recentonly = false;
$b = new Backblaze();
echo "[i] Loading file list from Backblaze ..";
$remotefiles = $b->getAllFilesInBucket();
echo " done. Got ".count($remotefiles)." files\n";
$uploadsize = 0;
//gather local data
$dir = ROOT.DS.'data'.DS;
$dh = opendir($dir);
$localfiles = array();
echo "[i] Loading local files ..";
while (false !== ($filename = readdir($dh))) {
$img = $dir.$filename.DS.$filename;
if(!file_exists($img)) continue;
$type = strtolower(pathinfo($img, PATHINFO_EXTENSION));
$type = $pm->isTypeAllowed($type);
if($type)
{
if($recentonly===true)
{
$recent = @file_get_contents($dir.$filename.DS.'last_rendered.txt');
if(!$recent || (time()-$recent) > 3600*24*365) continue;
}
$localfiles[] = $filename;
}
}
echo " done. Got ".count($localfiles)." files\n";
echo "[i] Checking if there are local files that are not remote\n";
foreach($localfiles as $hash)
{
if(!$remotefiles[$hash])
{
echo " [!] $hash not found on BB. Uploading...";
if($sim!==true)
$b->upload($hash);
$uploadsize+=filesize($dir.$hash.DS.$hash);
echo " done.\tUploaded so far: ".renderSize($uploadsize)."\n";
}
}
function renderSize($bytes, $precision = 2) {
$units = array('B', 'KB', 'MB', 'GB', 'TB');
$bytes = max($bytes, 0);
$pow = floor(($bytes ? log($bytes) : 0) / log(1024));
$pow = min($pow, count($units) - 1);
// Uncomment one of the following alternatives
$bytes /= pow(1024, $pow);
// $bytes /= (1 << (10 * $pow));
return round($bytes, $precision) . ' ' . $units[$pow];
}

View File

@@ -1,97 +0,0 @@
<?php
/*
* Cleanup
* This script cleans up all uploads and only leaves the original files
* So if you have an image and it was converted to change sizes, these files are deleted
* And will be re-created next time they are requested
*
* usage: php cleanup.php [sim]
*
* Params:
* sim => Just simulate everything, don't actually delete
*/
if(php_sapi_name() !== 'cli') exit('This script can only be called via CLI');
error_reporting(E_ALL & ~E_DEPRECATED & ~E_STRICT & ~E_NOTICE);
define('DS', DIRECTORY_SEPARATOR);
define('ROOT', dirname(__FILE__).DS.'..');
include_once(ROOT.DS.'inc/config.inc.php');
include_once(ROOT.DS.'inc/core.php');
$pm = new PictshareModel();
if(in_array('sim',$argv))
{
echo "[!!!!] SIMULATION MODE. Nothing will be deleted [!!!!] \n\n";
$sim = true;
}
else $sim = false;
$dir = ROOT.DS.'data'.DS;
$dh = opendir($dir);
$localfiles = array();
if(in_array('noskip',$argv))
{
echo "Won't skip existing files\n\n";
$allowskipping = false;
}
else
$allowskipping = true;
//making sure ffmpeg is executable
system("chmod +x ".ROOT.DS.'bin'.DS.'ffmpeg');
echo "[i] Finding local mp4 files ..";
while (false !== ($filename = readdir($dh))) {
$img = $dir.$filename.DS.$filename;
if(!file_exists($img)) continue;
$type = strtolower(pathinfo($img, PATHINFO_EXTENSION));
$type = $pm->isTypeAllowed($type);
if($type)
$localfiles[] = $filename;
}
if(count($localfiles)==0) exit('No files found'."\n");
echo " done. Got ".count($localfiles)." folders\n";
$sumsize = 0;
echo "[i] Looking for files to clean up\n";
foreach($localfiles as $hash)
{
$dir = ROOT.DS.'data'.DS.$hash.DS;
$dh = opendir($dir);
while (false !== ($filename = readdir($dh))) {
if(!is_file($dir.$filename) || $filename==$hash || $filename == 'last_rendered.txt')
continue;
echo "[$hash] $filename";
$sumsize+=filesize($dir.$filename);
if(!$sim)
unlink($dir.$filename);
echo "\t".(file_exists($dir.$filename)?'NOT DELETED':'DELETED')."\n";
}
}
echo "\n[!] Finished! Deleted ".renderSize($sumsize)."\n";
function renderSize($bytes, $precision = 2) {
$units = array('B', 'KB', 'MB', 'GB', 'TB');
$bytes = max($bytes, 0);
$pow = floor(($bytes ? log($bytes) : 0) / log(1024));
$pow = min($pow, count($units) - 1);
// Uncomment one of the following alternatives
$bytes /= pow(1024, $pow);
// $bytes /= (1 << (10 * $pow));
return round($bytes, $precision) . ' ' . $units[$pow];
}

46
tools/cron.php Normal file
View File

@@ -0,0 +1,46 @@
<?php
if(php_sapi_name() !== 'cli') exit('This script can only be called via CLI');
error_reporting(E_ALL & ~E_DEPRECATED & ~E_STRICT & ~E_NOTICE);
ini_set('memory_limit', -1);
define('DS', DIRECTORY_SEPARATOR);
define('ROOT', dirname(__FILE__).DS.'..');
include_once(ROOT.DS.'inc/config.inc.php');
include_once(ROOT.DS.'inc/core.php');
switch($argv[1])
{
case 'uploadqueue':
uploadqueue();
break;
default:
exit("[ERR] Command not found. Available commands are: uploadqueue");
}
function uploadqueue()
{
$queuefile = ROOT.DS.'tmp'.DS.'controllerqueue.txt';
if(!file_exists($queuefile))
exit("[i] File does not exist (nothing to upload)\n");
$queue = file($queuefile);
if(count($queue)<1)
exit("[i] Nothing to upload\n");
$newqueue = array();
foreach($queue as $hash)
{
$hash = trim($hash);
echo " [i] Checking $hash\n";
$hash = trim($hash);
if(isExistingHash($hash)) //check if hash is still on server
{
echo " [$hash] still exists locally. Uploading.. ";
$success = storageControllerUpload($hash); // and retry the upload
echo ($success===true?' => SUCCESS. Removing from queue':'FAILED. Will be re-added to queue')."\n";
if(!$success)
$newqueue[]=$hash;
}
}
file_put_contents($queuefile,implode("\n",$newqueue));
}

2
tools/ffmpeg_worker.php Normal file
View File

@@ -0,0 +1,2 @@
<?php

View File

@@ -31,7 +31,7 @@ require_once(ROOT . DS . 'content-controllers' . DS. 'video'. DS . 'video.contro
if(!defined('FFMPEG_BINARY')||FFMPEG_BINARY=='' || !FFMPEG_BINARY) exit('Error: FFMPEG_BINARY not defined, no clue where to look');
$vc = new VideoController();
$dir = ROOT.DS.'data'.DS;
$dir = getDataDir().DS;
$dh = opendir($dir);
$localfiles = array();
@@ -57,7 +57,7 @@ if(in_array('altfolder',$argv) && defined('ALT_FOLDER') && ALT_FOLDER && is_dir(
echo "\n [i] $filename is ..\t";
$valid = $vc->rightEncodedMP4($vid);
$tmp = ROOT.DS.'tmp'.DS.$hash;
$cmd = FFMPEG_BINARY." -loglevel panic -y -i $vid -vcodec libx264 -an -profile:v baseline -level 3.0 -pix_fmt yuv420p -vf \"scale=trunc(iw/2)*2:trunc(ih/2)*2\" $tmp && cp $tmp $img";
$cmd = FFMPEG_BINARY." -loglevel panic -y -i $vid -vcodec libx264 -profile:v baseline -level 3.0 -pix_fmt yuv420p -vf \"scale=trunc(iw/2)*2:trunc(ih/2)*2\" $tmp && cp $tmp $img";
echo ($valid?'Valid'."\n":'Not valid => Converting..');
if(!$valid)
{
@@ -69,9 +69,6 @@ if(in_array('altfolder',$argv) && defined('ALT_FOLDER') && ALT_FOLDER && is_dir(
}
}
//making sure ffmpeg is executable
system("chmod +x ".ROOT.DS.'bin'.DS.'ffmpeg');
if(count($localfiles)==0)
{
echo "[i] Finding local mp4 files\n";
@@ -106,7 +103,7 @@ foreach($localfiles as $hash)
{
$mp4 = $dir.$hash.DS.$hash;
$tmp = ROOT.DS.'tmp'.DS.$hash;
$cmd = FFMPEG_BINARY." -loglevel panic -y -i $mp4 -vcodec libx264 -an -profile:v baseline -level 3.0 -pix_fmt yuv420p -vf \"scale=trunc(iw/2)*2:trunc(ih/2)*2\" $tmp && cp $tmp $mp4";
$cmd = FFMPEG_BINARY." -loglevel panic -y -i $mp4 -vcodec libx264 -profile:v baseline -level 3.0 -pix_fmt yuv420p -vf \"scale=trunc(iw/2)*2:trunc(ih/2)*2\" $tmp && cp $tmp $mp4";
echo " [i] Converting '$hash'";
system($cmd);
if(defined('ALT_FOLDER') && ALT_FOLDER && is_dir(ALT_FOLDER))

View File

@@ -4,7 +4,7 @@ define('ROOT', dirname(__FILE__).DS.'..');
echo "[i] Starting recreation of hashes.csv\n";
$dir = ROOT.DS.'data'.DS;
$dir = getDataDir().DS;
$dh = opendir($dir);
$fp = fopen($dir.'hashes.csv','w');

View File

@@ -22,7 +22,7 @@ include_once(ROOT.DS.'inc/core.php');
$pm = new PictshareModel();
$dir = ROOT.DS.'data'.DS;
$dir = getDataDir().DS;
$dh = opendir($dir);
$localfiles = array();
@@ -34,9 +34,6 @@ if(in_array('noskip',$argv))
else
$allowskipping = true;
//making sure ffmpeg is executable
system("chmod +x ".ROOT.DS.'bin'.DS.'ffmpeg');
echo "[i] Finding local mp4 files ..";
while (false !== ($filename = readdir($dh))) {
$img = $dir.$filename.DS.$filename;

View File

@@ -0,0 +1,168 @@
<?php
/*
* Storage controller sync
* This tool copies syncs local files to storage controllers
*
*/
if(php_sapi_name() !== 'cli') exit('This script can only be called via CLI');
error_reporting(E_ALL & ~E_DEPRECATED & ~E_STRICT & ~E_NOTICE);
ini_set('memory_limit', -1);
define('DS', DIRECTORY_SEPARATOR);
define('ROOT', dirname(__FILE__).DS.'..');
include_once(ROOT.DS.'inc/config.inc.php');
include_once(ROOT.DS.'inc/core.php');
$dir = getDataDir().DS;
$sc = getStorageControllers();
$count = 0;
$controllers = array();
$filehashes = [];
foreach($sc as $contr)
{
if((new $contr())->isEnabled()===true)
{
$controllers[] = new $contr();
echo "[i] Found storage controller ".get_class($controllers[(count($controllers)-1)])."\n";
}
}
if(count($controllers)==0)
die("[X] Error: You should define at least one storage controller in your inc/config.inc.php first");
if(in_array('sim',$argv))
{
echo "[!!!!] SIMULATION MODE. Nothing will be uploaded [!!!!] \n\n";
$sim = true;
}
else $sim = false;
$enc=false;
if(defined('ENCRYPTION_KEY') && ENCRYPTION_KEY)
{
$enc = new Encryption;
echo "[i] Encryption key found. Will encrypt on Storage controllers\n";
}
if(!in_array('p2',$argv))
{
echo "[i] PHASE 1\n";
echo " [P1] Files from Storage controllers will be downloaded if they don't exist localy\n";
sleep(1);
foreach($controllers as $contr)
{
echo " [P1] Collecting list of items from ".get_class($contr)."..\n";
$controllerfiles = $contr->getItems(true);
echo "\n done. Got ".count($controllerfiles)." files\n";
if($controllerfiles)
foreach($controllerfiles as $cfile)
{
if(endswith($cfile,'.enc'))
$hash = substr($cfile,0,-4);
else $hash = $cfile;
$filehashes[$contr][] = $hash;
if(!is_dir($dir.$hash) || !file_exists($dir.$hash.DS.$hash)) //file only on storage controller. Will download
{
echo " [P1] $hash is not on the Server but on ".get_class($contr)."\n";
if($enc && endswith($cfile,'.enc')) // if its encrypted and we can decrypt, then do it
{
if($sim!==true)
{
$contr->pullFile($cfile,ROOT.DS.'tmp'.DS.$cfile);
$enc->decryptFile(ROOT.DS.'tmp'.DS.$cfile, ROOT.DS.'tmp'.DS.$hash,base64_decode(ENCRYPTION_KEY));
storeFile(ROOT.DS.'tmp'.DS.$hash,$hash,true);
unlink(ROOT.DS.'tmp'.DS.$cfile);
}
}
else{ //otherwise just get the file
if($sim!==true){
$contr->pullFile($hash,ROOT.DS.'tmp'.DS.$hash);
storeFile(ROOT.DS.'tmp'.DS.$hash,$hash,true);
}
}
}
}
}
echo "\n ----------- END OF PHASE 1 -----------\n\n";
}
else echo "[i] Skipping Phase 1\n";
echo "[i] PHASE 2\n";
echo " [P2] Local files are synced to all storage controllers\n";
sleep(2);
echo " [P2] Looping through local files\n";
$dh = opendir($dir);
$localfiles = array();
$allhashes=0;$allsize=0;
$skips=0;$skipsize=0;
$copied=0;$copysize=0;
$errors=0;$errorsize=0;
$uploaded=0;$uploadsize=0;
while (false !== ($hash = readdir($dh))) {
if($hash=='.'||$hash=='..') continue;
$img = $dir.$hash.DS.$hash;
if(!file_exists($img)) continue;
$thissize = filesize($img);
if(!isExistingHash($hash))
continue;
$allhashes++;
$allsize+=$thissize;
$realhash = ($enc===false?$hash:$hash.'.enc');
foreach($controllers as $contr)
{
if( (count($filehashes[$contr]) > 0 && !in_array($hash,$filehashes[$contr])) || !$contr->hashExists($realhash) )
{
//if($sim!==true)
if(defined('ENCRYPTION_KEY') && ENCRYPTION_KEY && !$contr->hashExists($hash.'.enc')) //ok so we got an encryption key which means we'll upload the encrypted file
{
echo " [P2] Controller '".get_class($contr)."' doesn't have $hash. Encrypting and uploading.. ";
$encryptedfile = $img.'.enc';
if($sim!==true)
{
$enc->encryptFile($img,$encryptedfile,base64_decode(ENCRYPTION_KEY));
$uploadsize+=filesize($encryptedfile);
$contr->pushFile($encryptedfile,$hash.'.enc');
unlink($encryptedfile);
}
}
else
{
echo " [P2] Controller '".get_class($contr)."' doesn't have $hash. Uploading unencrypted.. ";
if($sim!==true)
$contr->pushFile($img,$hash);
$uploadsize+=$thissize;
}
echo "done\n";
$uploaded++;
}
}
}
closedir($dh);
echo "\n[i] Done\n";
echo "\n----------- STATS ----------\n\n";
echo " All files found:\t$allhashes\t".renderSize($allsize)."\n";
echo " Copied files:\t$copied\t".renderSize($copysize)."\n";
echo " Skipped files:\t$skips\t".renderSize($skipsize)."\n";
echo " Erroneous files:\t$errors\t".renderSize($errorsize)."\n";
echo "\n";

10
web/css/bootstrap-table.min.css vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

6
web/css/bootstrap.min.css vendored Normal file

File diff suppressed because one or more lines are too long

5
web/css/gh-fork-ribbon.min.css vendored Normal file
View File

@@ -0,0 +1,5 @@
/*!
* "Fork me on GitHub" CSS ribbon v0.2.3 | MIT License
* https://github.com/simonwhitaker/github-fork-ribbon-css
*/.github-fork-ribbon{width:12.1em;height:12.1em;position:absolute;overflow:hidden;top:0;right:0;z-index:9999;pointer-events:none;font-size:13px;text-decoration:none;text-indent:-999999px}.github-fork-ribbon.fixed{position:fixed}.github-fork-ribbon:active,.github-fork-ribbon:hover{background-color:rgba(0,0,0,0)}.github-fork-ribbon:after,.github-fork-ribbon:before{position:absolute;display:block;width:15.38em;height:1.54em;top:3.23em;right:-3.23em;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;-webkit-transform:rotate(45deg);-moz-transform:rotate(45deg);-ms-transform:rotate(45deg);-o-transform:rotate(45deg);transform:rotate(45deg)}.github-fork-ribbon:before{content:"";padding:.38em 0;background-color:#a00;background-image:-webkit-gradient(linear,left top,left bottom,from(rgba(0,0,0,0)),to(rgba(0,0,0,.15)));background-image:-webkit-linear-gradient(top,rgba(0,0,0,0),rgba(0,0,0,.15));background-image:-moz-linear-gradient(top,rgba(0,0,0,0),rgba(0,0,0,.15));background-image:-ms-linear-gradient(top,rgba(0,0,0,0),rgba(0,0,0,.15));background-image:-o-linear-gradient(top,rgba(0,0,0,0),rgba(0,0,0,.15));background-image:linear-gradient(to bottom,rgba(0,0,0,0),rgba(0,0,0,.15));-webkit-box-shadow:0 .15em .23em 0 rgba(0,0,0,.5);-moz-box-shadow:0 .15em .23em 0 rgba(0,0,0,.5);box-shadow:0 .15em .23em 0 rgba(0,0,0,.5);pointer-events:auto}.github-fork-ribbon:after{content:attr(data-ribbon);color:#fff;font:700 1em "Helvetica Neue",Helvetica,Arial,sans-serif;line-height:1.54em;text-decoration:none;text-shadow:0 -.08em rgba(0,0,0,.5);text-align:center;text-indent:0;padding:.15em 0;margin:.15em 0;border-width:.08em 0;border-style:dotted;border-color:#fff;border-color:rgba(255,255,255,.7)}.github-fork-ribbon.left-bottom,.github-fork-ribbon.left-top{right:auto;left:0}.github-fork-ribbon.left-bottom,.github-fork-ribbon.right-bottom{top:auto;bottom:0}.github-fork-ribbon.left-bottom:after,.github-fork-ribbon.left-bottom:before,.github-fork-ribbon.left-top:after,.github-fork-ribbon.left-top:before{right:auto;left:-3.23em}.github-fork-ribbon.left-bottom:after,.github-fork-ribbon.left-bottom:before,.github-fork-ribbon.right-bottom:after,.github-fork-ribbon.right-bottom:before{top:auto;bottom:3.23em}.github-fork-ribbon.left-top:after,.github-fork-ribbon.left-top:before,.github-fork-ribbon.right-bottom:after,.github-fork-ribbon.right-bottom:before{-webkit-transform:rotate(-45deg);-moz-transform:rotate(-45deg);-ms-transform:rotate(-45deg);-o-transform:rotate(-45deg);transform:rotate(-45deg)}
/*# sourceMappingURL=gh-fork-ribbon.min.css.map */

View File

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

View File

Before

Width:  |  Height:  |  Size: 54 KiB

After

Width:  |  Height:  |  Size: 54 KiB

View File

Before

Width:  |  Height:  |  Size: 57 KiB

After

Width:  |  Height:  |  Size: 57 KiB

View File

Before

Width:  |  Height:  |  Size: 43 KiB

After

Width:  |  Height:  |  Size: 43 KiB

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