Hacking and spamming are two separate issues.
The protection against hacking is to always upgrade the program promptly when a new version is released.
Two defenses against spamming (spam posts) are
1) Don't allow guests to post. Require registration first.
2) Use a CAPTCHA on the registration form so robots can't register.