#/bin/bash
#enable OR disable encryption (false/true)
enable_encryptions=false

#insert key from APP. to get the key go to the application in the push notification tab. (64 characters)
key=""

if [ "$enable_encryptions" = true ] ; then
    if [ $# -eq 0 ] ; then echo 'FAIL: Params not defined.' && echo 'Usage: zbxviewer.sh Token Subject Message' && exit 1 ; fi
            title=`echo -n $2 |openssl aes-256-cbc -K $key -iv 0 -base64 -A`
            desc=`echo -n $3 |openssl aes-256-cbc -K $key -iv 0 -base64 -A`
            curl -s -d '{"token":"'$1'", "encrypt":"true", "title":"'$title'", "desc":"'$desc'"}' -H "Content-Type: application/json" -X POST 'https://zbx.vovanys.com/push/sendPush_json.php'
else
    if [ $# -eq 0 ] ; then echo 'FAIL: Params not defined.' && echo 'Usage: zbxviewer.sh Token Subject Message' && exit 1 ; fi
            curl -s -kG "https://zbx.vovanys.com/push/sendPush.php?token=$1&title=$2&desc=$3"
fi
