0) $language = $patharray[0]; //eerste is taal else $language = getAcceptLanguage(); define('LANGUAGE', $language); $html->language = $language; //kijk welke pagina op tweede positie van path staat $pagecode = ''; if ($pathcount > 1) $pagecode = $patharray[1]; else { if ($language == 'en') $pagecode = 'welcome'; elseif ($language == 'nl') $pagecode = 'welkom'; elseif ($language == 'de') $pagecode = 'willkommen'; } define('PAGECODE', $pagecode); //if ($pathcount > 2) define('PARAM1', $patharray[2]); //selecteer de juiste page handler $sql = sprintf("SELECT handler, title FROM pages WHERE code=%s AND language=%s LIMIT 1", $db->esc(PAGECODE), $db->esc(LANGUAGE)); if ($result = $db->query($sql)) { if ($row = $result->fetch_row()) { if ($row[0]) { define('PAGETITLE', $row[1]); include_once($row[0]); } } } function getAcceptLanguage() { global $db, $languages; $langs = array(); if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { // break up string into pieces (languages and q factors) preg_match_all('/([a-z]{2}(-[a-z]{2})?)\s*(;\s*q\s*=\s*(1|0\.[0-9]+))?/', $_SERVER['HTTP_ACCEPT_LANGUAGE'], $lang_parse); if (count($lang_parse[1])) { $langs = array_combine($lang_parse[1], $lang_parse[4]); // create a list like "en" => 0.8 // set default to 1 for any without q factor foreach ($langs as $lang => $val) { if ($val === '') $langs[$lang] = 1; } arsort($langs, SORT_NUMERIC);// sort list based on value // look through sorted list and use first one that matches our languages foreach ($langs as $lang => $val) { if (in_array($lang, $languages)) { return $lang; } } } } return 'nl';//default } ?>