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()); }
if ($v == 1) { //Validate url $l1 = filter_var($l1, FILTER_SANITIZE_URL); $l2 = filter_var($l2, FILTER_SANITIZE_URL); if (filter_var($l1, FILTER_VALIDATE_URL) === false || filter_var($l2, FILTER_VALIDATE_URL) === false) { die(print_r("Invalid URL(s).", true)); } $l1v = str_replace('www.', '', parse_url($l1, PHP_URL_HOST)); $l2v = str_replace('www.', '', parse_url($l2, PHP_URL_HOST)); function giveHost($host_with_subdomain) { $array = explode(".", $host_with_subdomain); return (array_key_exists(count($array) - 2, $array) ? $array[count($array) - 2] : "") . "." . $array[count($array) - 1]; } $l1v = giveHost($l1v); $l2v = giveHost($l2v); //var_dump($wl); //var_dump($l1); //var_dump($l2); //var_dump($l1v); //var_dump($l2v); if (!in_array($l1v, $wl) || !in_array($l2v, $wl)) { die(print_r("Blocked URL(s).", true)); } //Generate function gen() { chdir("l"); if (!file_exists($dir)) { chdir("../"); $g = array('\'', '"', '\\', '\\;', '\\$', '\\>', '\\<');