END; $submenuitems = array(); $fd = fopen('menu', 'r'); $items = 0; while ($line = trim(fgets($fd))) { if ($line == ">") { do { $line = trim(fgets($fd)); if ($line == "<") break; if ($name == $active) $submenuitems[] = $line; } while (!feof($fd)); } else { $tokens = explode("\t", $line); $name = $tokens[0]; $lname = $name; for ($i = 1; $i < count($tokens); ++$i) { $pair = explode('*', $tokens[$i]); if ($pair[0] == get_lang()) { $lname = $pair[1]; break; } } $url = trim(fgets($fd)); print " $lname\n"; ++$items; } } fclose($fd); print <<  END; $_gc = $_GET; $_gc['lang'] = get_lang() == 'en' ? 'se' : 'en'; $switch_lang_url = "${SERVER['PHP_SELF']}"; $c = '?'; foreach ($_gc as $key => $value) { $switch_lang_url .= "$c$key=$value"; $c = "&"; } print " " . (get_lang() == 'en' ? 'Byt till svenska' : 'Switch to English') . "\n \n"; if (count($submenuitems) > 0) { print << END; for ($i = 0; $i < count($submenuitems); $i += 2) { $tokens = explode("\t", $submenuitems[$i]); $name = $tokens[0]; $lname = $name; for ($j = 1; $j < count($tokens); ++$j) { $pair = explode('*', $tokens[$j]); if ($pair[0] == get_lang()) { $lname = $pair[1]; break; } } print " \n"; } print << 
" . $lname . "
END; } print " \n"; } function print_header($title) { if (isset($_GET['lang'])) { $lang = $_GET['lang']; setcookie('lang', $lang); } else if (isset($_COOKIE['lang'])) { $lang = $_COOKIE['lang']; } else { $lang = 'se'; setcookie('lang', $lang); } print << $title END; } function print_footer() { print <<

Valid HTML 4.01! Valid CSS!

These pages are © 2005 Lars Luthman, you may copy and distribute them in any medium as long as this notice is preserved.

No software patents!

END; } function get_lang() { if (isset($_GET['lang'])) return $_GET['lang']; else if (isset($_COOKIE['lang'])) return $_COOKIE['lang']; return 'se'; } function ls($lang) { if (get_lang() != $lang) print ""; } function no_en() { if (get_lang() == 'en') { print '

This page is not available in English.' . '

'; } } function no_se() { if (get_lang() == 'se') { print '

Den här sidan är inte ' . 'tillgänglig på svenska.

'; } } ?>