Skip to content

Instantly share code, notes, and snippets.

@qrwteyrutiyoup
Created January 2, 2015 03:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save qrwteyrutiyoup/0020630dcdcd0ef42eb7 to your computer and use it in GitHub Desktop.
Save qrwteyrutiyoup/0020630dcdcd0ef42eb7 to your computer and use it in GitHub Desktop.
dragon.sh
#!/usr/bin/env bash
# Sensitive information.
username='' # Add your SecureDragon WHMCS user here.
password='' # Add your SecureDragon WHMCS pass here.
# General stuff.
url_login='https://securedragon.net/clients/dologin.php'
url_clientarea='https://securedragon.net/clients/clientarea.php'
url_wyvern=${url_clientarea}'?action=productdetails&id=' # Add the ID here.
cookie='cookie.txt'
args="${1}"
function whmcs_login() {
local token=$(curl -s -c ${cookie} ${url_clientarea} | grep token | cut -d '"' -f 6)
curl -s -b ${cookie} -e ${url_clientarea} -d "token=${token}&username=${username}&password=${password}" ${url_login}
}
function wyvern_bw() {
if [[ ! -f ${cookie} ]] || [[ ${args} = 'login' ]]; then
whmcs_login
fi
curl -s -b ${cookie} ${url_wyvern} | grep 'Bandwidth Usage' | cut -d '>' -f 8 | cut -d '<' -f 1
}
wyvern_bw
# vim:set ts=2 sw=2 et:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment