Changed boolval() to manual implementation

boolval() was implemented in PHP5.5, and since we claim to support
PHP5.4, we need to work around this like we do in this commit.