public function addHit($id, $data = [])
    {
        if (!$id) {
            $this->setError('Post ID is required.');
            return false;
        }

        // --------------------------------------------------------------------------

        $oDate                 = Factory::factory('DateTime');
        $hitData               = [];
        $hitData['post_id']    = $id;
        $hitData['user_id']    = empty($data['user_id']) ? null : $data['user_id'];
        $hitData['ip_address'] = $this->input->ipAddress();
        $hitData['created']    = $oDate->format('Y-m-d H:i:s');
        $hitData['referrer']   = empty($data['referrer']) ? null : prep_url(trim($data['referrer']));

        if ($hitData['user_id'] && isAdmin($hitData['user_id'])) {
            $this->setError('Administrators cannot affect the post\'s popularity.');
            return false;
        }

        // --------------------------------------------------------------------------

        /**
         * Registered a hit on this post in the past 5 minutes? Try to prevent abuse
         * of the popularity system.
         */

        $oDb = Factory::service('Database');
        $oDb->where('post_id', $hitData['post_id']);
        $oDb->where('user_id', $hitData['user_id']);
        $oDb->where('ip_address', $hitData['ip_address']);
        $oDb->where('created > "' . $oDate->sub(new \DateInterval('PT5M'))->format('Y-m-d H:i:s') . '"');

        if ($oDb->count_all_results($this->tableHit)) {
            $this->setError('Hit timeout in effect.');
            return false;
        }

        // --------------------------------------------------------------------------

        $oDb->set($hitData);

        if ($oDb->insert($this->tableHit)) {
            return true;
        } else {
            $this->setError('Failed to add hit.');
            return false;
        }
    }