# +---------------------------------------------------+
# Function to ask and set MalwarePatrol Receipt Key
# +---------------------------------------------------+
function func_ask-malwarepatrol() {
  func_echo-header
  echo -e "$green[eFa]$clean - Set MalwarePatrol Receipt Key"
  echo -e ""
  echo -e "$green[eFa]$clean This option will allow you to set the MalwarePatrol "
  echo -e "$green[eFa]$clean receipt key for a MalwarePatrol subscription."
  echo -e ""
  CURRENTMPRECEIPT=$(grep "^malwarepatrol_receipt_code=" /etc/clamav-unofficial-sigs/user.conf | awk -F'=' '{print $2}' | tr -d '"')
  echo -e "Current MalwarePatrol Receipt Key: $CURRENTMPRECEIPT"
  echo -e ""

  while [ "1" == "1" ]
    do  
      echo -e "Choose an option:"
      echo -e "1) Modify receipt key"
      echo -e ""
      echo -e "e) Return to main menu"
      echo -e ""
      echo -e -n "$green[eFa]$clean : "
      local choice
      read choice
      case $choice in
                1) 
                 FLAG=1
                  while [ $FLAG -eq 1 ]
                    do
                      echo ""
                      echo -e -n "$green[eFa]$clean Enter your new MalwarePatrol Receipt Key: "
                      read MPRECEIPT
                      if [[ $MPRECEIPT =~ [A-Za-z0-9]+ ]]; then 
                        if [[ -z $(grep ^malwarepatrol_receipt_code /etc/clamav-unofficial-sigs/user.conf) ]]; then
                          sed -i "/^#malwarepatrol_receipt_code=/ c\malwarepatrol_receipt_code=\"$MPRECEIPT\"" /etc/clamav-unofficial-sigs/user.conf
                        else
                          sed -i "/^malwarepatrol_receipt_code=/ c\malwarepatrol_receipt_code=\"$MPRECEIPT\"" /etc/clamav-unofficial-sigs/user.conf
                        fi
                        echo -e "$green[eFa]$clean MalwarePatrol Receipt key set"
                        FLAG=0
                      elif [[ -z $MPRECEIPT ]]; then
                        if [[ -n $(grep ^malwarepatrol_receipt_code /etc/clamav-unofficial-sigs/user.conf) ]]; then
                          sed -i "/^malwarepatrol_receipt_code=/ c\malwarepatrol_receiptcode=\"\"" /etc/clamav-unofficial-sigs/user.conf
                        fi
                        echo -e "$green[eFa]$clean MalwarePatrol Receipt key erased."
                        FLAG=0
                      else
                        echo -e "$red[ERROR]$clean Invalid receipt key.  Key must be alphanumeric and not contain special characters."
                      fi   
                    done 
                    pause
                    return ;;
                e) return ;;
                *) echo -e "Error \"$choice\" is not an option..." && pause
      esac
    done
}