public function init() { // Initialize logger and translate actions $this->_logger = Zend_Registry::get("logger"); $this->_translate = Zend_Registry::get("translate"); // set the redirector to ignore the baseurl for redirections $this->_helper->redirector->setPrependBase(false); $this->_eventdispatcher = initializeSFEventDispatcher(); // load the application configuration loadConfig(); $this->view->referer = $this->getRequest()->getHeader('referer'); $this->view->viewurl = $_SERVER['REQUEST_URI']; // debugMessage($this->view->viewurl); // debugMessage($this->getRequest()); $isvalid = false; $host = giveHost($this->view->serverUrl()); // debugMessage($host); $this->view->domain = str_replace('http://', '', strtolower($host)); $subdomain = getSubdomain($this->view->serverUrl()); $this->view->subdomain = strtolower($subdomain); if ($subdomain == "www") { $this->_helper->redirector->gotoUrl('http://' . $host); exit; } // debugMessage('subdomain '.$subdomain); if (!isEmptyString($subdomain) && strtolower($host) == "hrmagic.ug") { $session = SessionWrapper::getInstance(); $session->setVar('companyid', ''); $company = new Company(); if ($company->isRenderable($subdomain)) { $isvalid = true; // debugMessage('valid'); } else { // debugMessage('invalid'); } if ($isvalid) { // if valid subdomain, set id to session $companyid = $company->findByUsername($subdomain); $session->setVar('cid', $companyid); } else { // subdomain not found. redirect to 404 page. $domain = str_replace($subdomain . '.', '', $this->view->serverUrl()); // debugMessage('d is '.$domain); $this->_helper->redirector->gotoUrl(stripUrl($domain) . '/index/error'); } } $url = array('http://www.domain.com', 'http://domain.com', 'https://domain.com', 'www.domain.com', 'domain.com', 'www.domain.com/some/path', 'http://sub.domain.com/domain.com', 'http://sub-domain.domain.net/domain.net', 'sub-domain.third-Level_DomaIN.domain.uk.co/domain.net'); /* foreach ($url as $u) { debugMessage(getSubdomain($u)); } */ // exit(); # set default timezone based on company in session # date_default_timezone_set(getTimeZine()); }
public function construct() { $this->config = Zend_Registry::get('config'); $this->translate = Zend_Registry::get('translate'); //$this->addDateFields(array("datecreated", "lastupdatedate")); $this->eventdispatcher = initializeSFEventDispatcher(); // initialize the logger instance $this->logger = Zend_Registry::get('logger'); }