Php photo gallery TWG | JFUploader | TWG Flash upload | WFU | Forum

Get help for TinyWebGallery, the best image gallery. The forum is also home for the Joomla JFUploader, TWG Flash Uploader and the Wordpress flash uploader.
It is currently 28. Mar 2024, 18:07

This forum is readonly now. Please use the new forum if you don't find the answer to your question here. The new forum is at https://www.tinywebgallery.com/blog/forum/


All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: 16. May 2016, 12:45 
Offline

Joined: 16. May 2016, 12:20
Posts: 2
Hallo,

Als fauler Mensch will ich mir zip-Files zum Download aller Bilder einer Galerie automatisch direkt auf dem Server generieren lassen.
Kann man als cron alle 5 Minuten laufen lassen, erzeugt keine nennenswert Last.

Ich habe aber keine Ahnung, ob das auch in shared-Hosting Umgebungen läuft, selbst wenn die crontabs unterstützen...
Der zip-Befehl müsste so auch unter Windows funktionieren, der Rest natürlich nicht;-)

Hier also zur freien Verwendung:
Aufruf /bin/bash addons/generate-zip-picture-archives.txt

Code:
#!/bin/bash
## creates a recursive zip for any picture-folder containing a blank file with name "zip.txt"


installdir=$(dirname $(readlink -f $0) | sed -r 's!/addons/?$!!')
  ## must be installed in addons


## ToDo: get $basedir and $cachedir from php-configs
  basedir="pictures"
  cachedir="cache"
   basedir=$(echo  "$basedir"  | sed -r 's!(^/|/$)!!g')
   cachedir=$(echo "$cachedir" | sed -r 's!(^/|/$)!!g')


ZIP=$(which zip 2>/dev/null)
  [ "$ZIP" = "" ] && echo "zip not installed, exit..." && exit 1


pidfile="$(basename $0).pid.txt"
  # delte orphan pid-files
    find "$installdir/$cachedir" -name "$pidfile" -mmin +30 -delete
  pidfile="$installdir/$cachedir/$pidfile"
    [ -f "$pidfile" ] && exit 0
      touch "$pidfile"


## get all by "zip.txt" file requested zips
  find "$installdir/$basedir" -mindepth 2 -iname zip.txt -print0 | while read -d $'\0' file ; do

    ## generate filename as needed: http://www.tinywebgallery.com/de/faq.php#h19
      zip_name=$(dirname "$file" | sed "s!$installdir/$basedir/!!" | sed 's!/!_!g')
      dir_name=$(dirname "$file")


    cd "$dir_name"

    # -q                quite (bash-mode) / -v : verbose
    # --filesync        update new/changed files, remove removed fiels from zip
    # -r ./*            recursive
    # -n                exclude from compression
    # -x                exclude
      $ZIP "$zip_name.zip" -q \
        --filesync -r ./* \
        -n .jpg:.jpeg:.JPG:.mp3:.mov:.avi:.mpg:.mpeg:.divx:.wmv:.wma:.flv \
        -x *.txt *.TXT *.php *.PHP *.js *.id *.htaccess* *.htp* *.zip *.ZIP *.xml *.htm *.html *.ico *.css \
        *folder.png *folder_top.png *watermark.png *watermark_big.png *back.png

  done


rm -f "$pidfile"
  exit 0


Einzige Lücke: Der zip-Download erfolgt direkt an jedem Login/Passwort vorbei direkt aus dem pictures Ordner. Oder habe ich da eine der vielen Optionen übersehen?

Daniel


Top
 Profile  
 
PostPosted: 16. May 2016, 21:07 
Offline
Site Admin
User avatar

Joined: 1. Aug 2005, 12:53
Posts: 11232
Hallo,

Danke für das Script.

Ich hatte hier nur direkten Download eingeplant. Über die txt Datei kannst du die Dateien an einen anderen Ort schieben und die txt Datei über eine .htaccess schützen.
Ansonsten müsstest du i_downloadmanager.php erweitern.

Gruß, Michael


Top
 Profile  
 
PostPosted: 19. May 2016, 20:09 
Offline

Joined: 16. May 2016, 12:20
Posts: 2
Code:
# udpate, damit es auch mit symlink Ordnern klappt muss ein / ans Ende der beiden finds:
find "$installdir/$cachedir/"
find "$installdir/$basedir/"


Das ganze dynamisch per php zu generieren/streamen oder auch nur zum Download durch php (mit Passwortschutz) zu streamen dürfte für die allermeisten an max_execution_time scheitern.
Man stelle sich ein 10 GB Urlaubsbilder-Zip vor, dass vielleicht ein paar Stunden runter lädt.
max_execution_time müsste man dann für dieses eine php-script auf 0 setzen.
Geht per .htaccess nur global für mindestens den Ordner in dem das Script liegt.

Damit bleibt es eher dabei, dass ohne größeren Aufwand mindestens das zip-File "ungeschützt" abrufbar ist, wenn sich ein "Angreifer" den Link dazu zusammen baut.

Aber dafür ergibt sich daraus vielleicht eine Lösung:
http://www.tinywebgallery.com/de/faq.php#h19

Ich hänge an den Dateinamen noch einen random-hash-Suffix an und hinterlasse den dann alternativen Link zum zip in "<Ordnername>.txt" (txt Dateien sind von der zentralen .htaccess ja eh geschützt).

Update folgt, Daniel


Top
 Profile  
 
PostPosted: 19. May 2016, 21:42 
Offline
Site Admin
User avatar

Joined: 1. Aug 2005, 12:53
Posts: 11232
:).


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 10 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
cron
powered by phpbb | Datenschutz/ Privacy policy