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()); }
/** * Load site data */ $SITE = new Site(); define('BASE_DIR', $SITE->base_dir); //FIXME: (Re)move //$SITE->settings['language'] = 'en'; //Settings::changeSetting('language', 'select', google::languages($CONFIG->Site->languages)); /* * Initialize controller */ $Controller = new Controller(); /* * Load current user */ __autoload('User'); $USER = $Controller->{(string) NOBODY}(OVERRIDE); $USER = $Controller->currentUser; /** * Fire up template engine and ask the requested object to do it's thing * * @var Templates: Object handling the connection with the templates */ $Templates = new Templates(); Installer::check(); /** * Find current subdomain */ //FIXME: move: !! define('SUBDOMAIN', getSubdomain()); $CONFIG->Subdomains->setType('Top_domain', 'text');