<?php
/**
 * A class for restricting controller access by ip.
 *
 * This class interrupts the controllers execution if the user ip is denied. It
 * will render a forbidden page and abort the rest of the execution.
 */
class controller_filter_ip extends controller_filter_bouncer
{
    ////////////////////////////////////////////////////////////////////////////
    // Construct and destruct functions.

    ////////////////////////////////////////////////////////////////////////////
    // Overload functions.

    ////////////////////////////////////////////////////////////////////////////
    // Interface functions.

    /**
     * Executes the filter (pre action).
     *
     * @return boolean True if the rest of the execution is to be aborted, else
     * false.
     */
    public function pre_execute()
    {
        $user = $this->request->REMOTE_ADDR;
        
        if (!$this->is_granted($user))
        {
            $this->forbid();
            return true;
        }
    }

    ////////////////////////////////////////////////////////////////////////////
    // Internal functions.
}
