File tree Expand file tree Collapse file tree 5 files changed +79
-1
lines changed Expand file tree Collapse file tree 5 files changed +79
-1
lines changed Original file line number Diff line number Diff line change 1
1
<?php
2
2
if (!isset ($ _FILES ['file ' ])) {
3
- ?>
3
+ ?>
4
4
<html><head><meta http-equiv="content-type" content="text/html; charset=UTF-8" /><title>file sharing</title>
5
5
<style type="text/css">
6
6
a {
24
24
$ newdir = substr (md5 (uniqid ()), 0 , 12 );
25
25
exec ('mkdir ' .$ basedir .'/ ' .$ newdir );
26
26
exec ('mv ' .$ _FILES ['file ' ]['tmp_name ' ].' ' .$ basedir .'/ ' .$ newdir .'/ ' .$ newFName );
27
+ if (isset ($ _REQUEST ['exp ' ])) {
28
+ preg_match ('/^(\d+)([hdwmy]?)$/ ' , $ _REQUEST ['exp ' ], $ matches );
29
+ if ($ matches [1 ] && $ matches [2 ]) {
30
+ switch ($ matches [2 ]) {
31
+ case 'h ' :
32
+ $ hours = $ matches [1 ];
33
+ break ;
34
+ case 'd ' :
35
+ $ hours = 24 * $ matches [1 ];
36
+ break ;
37
+ case 'w ' :
38
+ $ hours = 24 * 7 * $ matches [1 ];
39
+ break ;
40
+ case 'm ' :
41
+ $ hours = 24 * 30.5 * $ matches [1 ];
42
+ break ;
43
+ case 'y ' :
44
+ $ hours = 24 * 365 * $ matches [1 ];
45
+ break ;
46
+ }
47
+ $ expiry = mktime () + ($ hours * 60 * 60 );
48
+ exec ('touch ' .$ basedir .'/ ' .$ newdir .'/expires-at- ' .$ expiry );
49
+ }
50
+ }
27
51
if (stristr ($ _SERVER ['HTTP_USER_AGENT ' ], 'curl ' )) {
28
52
echo "https:// " .$ _SERVER ['HTTP_HOST ' ]."/dl/ " .$ newdir ."/ " .$ newFName ;
29
53
echo "\n" ;
Original file line number Diff line number Diff line change
1
+ FROM alpine:3
2
+
3
+ RUN apk add bash dcron
4
+ RUN mkdir -p /var/logs
5
+
6
+ # 20 minute interval
7
+ ENV EXECUTION_CRON_EXPRESSION */20 * * * *
8
+
9
+ COPY entrypoint.sh /
10
+ COPY run-cron.sh /
11
+ RUN chmod +x /entrypoint.sh
12
+ RUN chmod +x /run-cron.sh
13
+ ENTRYPOINT ["/entrypoint.sh" ]
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ trap ' exit 0' SIGTERM | tee -a /var/logs/cron.log
4
+
5
+ cat > crontab.tmp << EOF
6
+ $EXECUTION_CRON_EXPRESSION /run-cron.sh $@ | tee -a /var/logs/cron.log
7
+ # An empty line is required at the end of this file for a valid cron file.
8
+ EOF
9
+
10
+ crontab " crontab.tmp"
11
+ rm -f " crontab.tmp"
12
+ /usr/sbin/crond -L /var/logs/cron.log
13
+ tail -n 5000 -f /var/logs/cron.log
Original file line number Diff line number Diff line change
1
+ #! /bin/bash -eux
2
+
3
+ DL_DIR=/var/www/dl
4
+
5
+ if [ ! -d ${DL_DIR} ]; then
6
+ exit 0
7
+ fi
8
+
9
+ CURRENT_TS=$( date ' +%s' )
10
+ find " ${DL_DIR} " -type f -name " expires-at-*" | while read expires_file; do
11
+ # /var/www/dl/c1984d98fcc6/expires-at-1585729013
12
+ TS=$( basename ${expires_file} | sed -E ' s/^expires-at-(\d+)$/\1/g' )
13
+ if [ $( echo ${TS} | grep -q ' ^\d\+$' ) -gt 0 ]; then
14
+ continue ;
15
+ fi
16
+ if (( CURRENT_TS > TS )) ; then
17
+ echo -en $( date -d @${CURRENT_TS} )
18
+ echo -en " > "
19
+ echo -en $( date -d @${TS} )
20
+ echo " >> DELETING $( dirname ${expires_file} ) "
21
+ rm -r $( dirname ${expires_file} )
22
+ fi
23
+ done
Original file line number Diff line number Diff line change @@ -11,3 +11,8 @@ services:
11
11
- file_storage:/var/www/dl
12
12
ports :
13
13
- 127.0.0.1:8023:80
14
+ cron :
15
+ build : cron/
16
+ restart : unless-stopped
17
+ volumes_from :
18
+ - server
You can’t perform that action at this time.
0 commit comments