Adds unique keys to prevent duplicates.

Now user1 can't follow user2 twice at the database level, instead of the application level. The same goes for upvoting, starring, setting a parent post, etc. Also changed instances of array_map(intval... to array_map('intval'... to support more versions of php. Fixes other small errors as well.