<?php

/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */

class Agecheck_Customer_Agecheck
{
    var $auth;
    var $redirect;
    var $agecheck;

    /**
     * @access  public
     */
    function execute()
    {
        $log =& LogFactory::getLog();
        $log->debug("Agecheck_Customer_Agecheck", "Agecheck_Customer_Agecheck#execute");

        $pattern = "@^(". URL_ROOT ."|". SSL_URL_ROOT .").*?@i";
        if (preg_match($pattern, urldecode($this->redirect)) && 
            $this->agecheck==1) {
            header("location:". urldecode($this->redirect));
            exit;
        } else if ($this->agecheck==1) {
            $loc = URL_ROOT.dirname($_SERVER["SCRIPT_NAME"]);
            header("location:". $loc);
            exit;
        }

        return 'success';
    }

    function checkAuth()
    {
        return $this->auth->checkAuth();
    }

    function getRedirectUrl() {
        return urldecode($this->redirect);
    }
}
?>
