static function urlfor2($apps = array(), $controller = '', $method = '', $args = array(), $absolute = true) { $apps = is_array($apps) ? $apps : array($apps); $domain = Config::Host_getConfigFromPath($apps); $appsdomain = Config::Host_getConfigFromDomain($domain['domain']); $apps = array_slice(array_reverse($apps), 0, 0 - count($appsdomain)); $controller = $controller == 'home' ? '' : $controller; $method = $method == 'index' ? '' : $method; $domain = !is_null(Config::get('app_base_url')) ? Config::get('app_base_url') : strtolower(explode('/', $_SERVER['SERVER_PROTOCOL'])[0]) . '://' . $_SERVER['HTTP_HOST'] . '/'; // traitement apps if (!empty($apps)) { if (is_array($apps)) { $apps = join('/', $apps) . '/'; } else { $apps .= '/'; } } else { $apps = ''; } // traitement controller if (empty($controller)) { if (!empty($args)) { $controller = 'home'; } } // traitement method if (empty($method)) { if (!empty($args)) { $method = 'index'; } } // traitement separateur if (!empty($controller) && !empty($method)) { $separator = '-'; } else { $separator = ''; } // traitement arg if (!empty($args)) { if (is_array($args)) { $args = '/' . join('/', $args); } else { $args = '/' . $args; } } else { $args = ''; } return $domain . $apps . $controller . $separator . $method . $args; }
static function applyHostConfiguration($data) { $apps = $data['apps']; // recupération du chemin "complet" $de = explode('.', $_SERVER['HTTP_HOST']); $host = implode('.', $de); $configFromDomain = Config::Host_getConfigFromDomain($_SERVER['HTTP_HOST']); $apps = array_merge($configFromDomain, $apps); $configFromPath = Config::Host_getConfigFromPath(array_filter($apps)); if (!empty($configFromPath)) { if ($configFromPath['domain'] != $host) { switch ($configFromPath['action']) { case 'forbid': self::throwError(403); break; case 'redirect': $host_apps = Config::Host_getConfigFromDomain($configFromPath['domain']); self::redirectURL(strtolower(explode('/', $_SERVER['SERVER_PROTOCOL'])[0]) . '://' . $configFromPath['domain'] . '/' . Tools::urlfor(array_slice(array_filter($apps), count($host_apps)), $data['controller'] == 'home' ? '' : $data['controller'], $data['method'] == 'index' ? '' : $data['method'], $data['args'], false), true, true); break; case 'none': default: break; } } } return $apps; }