#!/bin/bash
URL=https://storage.securvita-bkk.de/transfer/index.php
USERAGENT="Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:14.0) Gecko/20100101 Firefox/14.0.1"
REFERER=${URL}
COOKIEFILE=seccookies.txt
USER=sustainable
#PASSWD=@Sus2012
PASSWD='!sbKP20'
DOWNLOADDIR=%2FKassendaten%2FDaten%20Kasse%20an%20HM
#UPLOADDIR="/Kassendaten/Daten HM an Kasse"
UPLOADDIR="/Daten HM an Kasse"
UPLOADFILE=$1
echo "Sending $UPLOADFILE"

if [ -e index.php ]
then
  rm index.php
fi

# Hole Cookie
#     --no-check-certificate \
#     --keep-session-cookies \
# Hole Cookie
curl --cookie-jar ${COOKIEFILE} \
     --user-agent "${USERAGENT}" \
     --data "option=com_extplorer&action=login&type=extplorer&username=${USER}&password=${PASSWD}&lang=german" \
     -o index.php \
     ${URL}
rm index.php

curl  --cookie-jar ${COOKIEFILE} \
         -b ${COOKIEFILE} \
         --user-agent "${USERAGENT}" \
         --keepalive \
         --tr-encoding \
         --referer "${URL}" \
         -F userfile\[0\]=@${UPLOADFILE} \
         -F overwrite_files=on \
         -F option=com_extporer \
         -F action=upload \
         -F dir="${UPLOADDIR}" \
         -F requestType=xmlhttprequest \
         -F confirm=true \
         ${URL}

