public function onEntry()
 {
     global $cookie_found;
     if (isset($_POST['logTheUserOut'])) {
         unset(Session::sess()->user);
         header('Location: ' . BASEPATH . '/' . DEFAULTPAGE);
         exit;
     } elseif (isset($_POST['logTheUserIn']) && !empty($_POST['userName']) && !empty($_POST['userPass']) && !isset(Session::sess()->user)) {
         $userData = new Data_User(Data_User::LDAP, $_POST['userName'], $_POST['userPass']);
         Session::sess()->user = $userData->getUser();
     }
     if (isset(Session::sess()->user)) {
         Acl::acl()->setRole(Session::sess()->user->role);
     } else {
         Acl::acl()->setRole();
     }
 }
 /**
  * create the loginbox before the content is generated
  *
  * @access public
  * @return void
  */
 public function beforeContent()
 {
     $loginbox = $this->document->getElementById($this->id);
     if ($loginbox) {
         $this->document->addCss('public/css/login.css');
         $loginbox->removeAttribute('style');
         if (isset(Session::sess()->user)) {
             $logoutForm = $this->document->createElement('form');
             $logoutForm->setAttribute('method', 'post');
             $logoutSubmit = $this->document->createElement('input');
             $logoutSubmit->setAttribute('type', 'submit');
             $logoutSubmit->setAttribute('name', 'logTheUserOut');
             $logoutSubmit->setAttribute('value', 'logout');
             $logoutForm->appendChild($logoutSubmit);
             $logoutName = $this->document->createElement('input');
             $logoutName->setAttribute('type', 'text');
             $logoutName->setAttribute('value', 'Welcome: ' . Session::sess()->user->displayName);
             $logoutName->setAttribute('disabled', 'disabled');
             $logoutName->setAttribute('class', 'loggedInMessage');
             $logoutForm->appendChild($logoutName);
             $loginbox->appendChild($logoutForm);
         } else {
             $loginForm = $this->document->createElement('form');
             $loginForm->setAttribute('method', 'post');
             $loginName = $this->document->createElement('input');
             $loginName->setAttribute('type', 'text');
             $loginName->setAttribute('name', 'userName');
             $loginForm->appendChild($loginName);
             $loginPass = $this->document->createElement('input');
             $loginPass->setAttribute('type', 'password');
             $loginPass->setAttribute('name', 'userPass');
             $loginForm->appendChild($loginPass);
             $loginSubmit = $this->document->createElement('input');
             $loginSubmit->setAttribute('type', 'submit');
             $loginSubmit->setAttribute('name', 'logTheUserIn');
             $loginSubmit->setAttribute('value', 'login');
             $loginForm->appendChild($loginSubmit);
             $loginbox->appendChild($loginForm);
         }
     }
 }
if (VER_EXT !== '') {
    error_reporting(E_ALL);
    ini_set('display_errors', 'On');
}
define('DEFAULTPAGE', 'home');
define('BASEPATH', str_replace("\\", "/", str_replace(realpath($_SERVER['DOCUMENT_ROOT']), '', realpath('./'))));
// }}}
// {{{ AUTOLOADER
function autoload($classname)
{
    if (!class_exists($classname, false)) {
        $classPath = str_replace('_', '/', $classname) . '.php';
        if (file_exists('site/' . $classPath)) {
            @(include 'site/' . $classPath);
        } elseif (file_exists('core/' . $classPath)) {
            @(include 'core/' . $classPath);
        }
    }
}
spl_autoload_register('autoload');
// }}}
// {{{ SESSION
Session::sess();
// }}}
// {{{ DETECT AJAX
if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
    define('AJAX', true);
} else {
    define('AJAX', false);
}
// }}}
 public function sendmail()
 {
     if (isset(Session::sess()->canSendMail) && Session::sess()->canSendMail == 'yes') {
         unset(Session::sess()->canSendMail);
         if (isset(Session::sess()->mailSend)) {
             unset(Session::sess()->mailSend);
         }
         Session::sess()->mailSend = new stdClass();
         if (isset($_POST['sendMail']) && $_POST['sendMail'] == 'verzend') {
             if (!empty($_POST['naam'])) {
                 Session::sess()->mailSend->name = $_POST['naam'];
             }
             if (!empty($_POST['tel']) && is_numeric($_POST['tel'])) {
                 Session::sess()->mailSend->tel = $_POST['tel'];
             }
             if (!empty($_POST['email']) && Utils::validEmailAddress($_POST['email'])) {
                 Session::sess()->mailSend->email = $_POST['email'];
             }
             if (!empty($_POST['bericht'])) {
                 Session::sess()->mailSend->message = $_POST['bericht'];
             }
             if (isset(Session::sess()->mailSend->name) && isset(Session::sess()->mailSend->tel) && isset(Session::sess()->mailSend->email) && isset(Session::sess()->mailSend->message)) {
                 $mailHersteldienst = '*****@*****.**';
                 //send the mail
                 $toHerst = array();
                 $toClient = array();
                 $toHerst['to'] = $mailHersteldienst;
                 $toHerst['from'] = Session::sess()->mailSend->email;
                 $toHerst['subject'] = 'info hersteldienst Devolder';
                 $toHerst['message'] = 'info aanvraag hersteldienst devolder' . "\n" . '-------------------------------------------------------------------------------' . "\n\n" . 'van   : ' . Session::sess()->mailSend->name . "\n" . 'email : ' . Session::sess()->mailSend->email . "\n" . 'tel   : ' . Session::sess()->mailSend->tel . "\n" . "\n\n" . wordwrap(Session::sess()->mailSend->message, 79) . "\n\n" . '-------------------------------------------------------------------------------' . "\n" . 'Audio Video Ktv Hersteldienst Luc Devolder' . "\n" . 'Pieter Paul Rubensstraat 11' . "\n" . '8020 Oostkamp' . "\n" . 'tel : +32 (0)50 82 49 19' . "\n" . 'btw : BE 0673 150 504' . "\n" . 'www.hersteldienst-devolder.be';
                 $toHerst['header'] = 'FROM: ' . Session::sess()->mailSend->email . "\r\n" . 'Reply-To: ' . Session::sess()->mailSend->email . "\r\n" . 'X-Mailer: HersteldienstDevolder';
                 $toClient['to'] = $toHerst['from'];
                 $toClient['from'] = $toHerst['to'];
                 $toClient['subject'] = $toHerst['subject'];
                 $toClient['message'] = $toHerst['message'];
                 $toClient['header'] = 'FROM: ' . $mailHersteldienst . "\r\n" . 'Reply-To: ' . $mailHersteldienst . "\r\n" . 'X-Mailer: HersteldienstDevolder';
                 if (mail($toHerst['to'], $toHerst['subject'], $toHerst['message'], $toHerst['header']) && mail($toClient['to'], $toClient['subject'], $toClient['message'], $toClient['header'])) {
                     unset(Session::sess()->mailSend);
                     header('Location: ' . $this->basepath . 'contact');
                 } else {
                     if ($this->pageType == IPages::XHTML) {
                         $this->document->setTitleAppend($this->document->getTitleAppend() . ' - email');
                         $title = $this->document->createElement('h1', 'Email');
                         $this->content->appendChild($title);
                         $sorry = $this->document->createElement('p', 'Het verzenden van de mail is mislukt, probeer nog eens opnieuw');
                         $sorry->setAttribute('class', 'error message');
                         $this->content->appendChild($sorry);
                     }
                 }
             } else {
                 header('Location: ' . $this->basepath . 'contact/email');
             }
         }
     } else {
         if ($this->pageType == IPages::XHTML) {
             $this->document->setTitleAppend($this->document->getTitleAppend() . ' - email');
             $title = $this->document->createElement('h1', 'Email');
             $this->content->appendChild($title);
             $sorry = $this->document->createElement('p', 'Sorry maar u kan geen mail verzenden, controlleer of u alle correcte stappen hebt doorlopen om een mail te versturen naar Hersteldienst Devolder');
             $sorry->setAttribute('class', 'error message');
             $this->content->appendChild($sorry);
         }
     }
 }