1, # English "es" => 1, # Español "de" => 1, # Deutsch "fr" => 1, # Français ); # connect to the database # function db_connect() { # NOTE: modify these variables if your MySQL setup is different # $AUR_db_host = "localhost:/tmp/mysql.sock"; $AUR_db_name = "AUR"; $AUR_db_user = "aur"; # XXX use something better when deploying $AUR_db_pass = "aur"; # XXX use something better when deploying $handle = mysql_pconnect($AUR_db_host, $AUR_db_user, $AUR_db_pass); if (!$handle) { die("Error connecting to AUR database: " . mysql_error()); } mysql_select_db($AUR_db_name, $handle) or die("Error selecting AUR database: " . mysql_error()); return $handle; } # set up the visitor's language # function set_lang() { global $_REQUEST; global $_COOKIE; global $LANG; global $SUPPORTED_LANGS; $update_cookie = 0; if (isset($_REQUEST['setlang'])) { # visitor is requesting a language change # $LANG = $_REQUEST['setlang']; $update_cookie = 1; } elseif (isset($_COOKIE['AURLANG'])) { # If a cookie is set, use that # $LANG = $_COOKIE['AURLANG']; } # TODO query the database if the user is logged in if (!$LANG || !array_key_exists($LANG, $SUPPORTED_LANGS)) { $LANG = "en"; # default to English } if ($update_cookie) { # TODO do we need to set the domain too? I seem to remember some # security concerns about not using domains - but it's not like # we really care if another site can see what language our visitor # was using.... # setcookie("AURLANG", $LANG, 0, "/"); } return; } # common header # function html_header() { print "\n"; print "\n"; print "AUR\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; # Menu items # print " \n"; print " "; print " "; print " \n"; print " \n"; print " \n"; print "
"; print __("%s: An ArchLinux project", array("AUR")); print "
\n"; print " \n"; print " \n"; print " \n"; print " \n"; print " \n"; print "
"; # XXX Can I scale a PNG like this? # print ""; print "ArchLinux User-community Repository
"; # XXX CSS help - a:link, a:visited, etc are defined, but I don't want to # use the defaults. Is this the way to override them? # print "English "; print "Español "; print "Deutsch "; print "Français"; print "
\n"; print "
\n"; print "\n\n"; return; } # common footer # function html_footer($ver="") { print "\n\n"; print "
\n"; print "

\n"; if ($ver) { print "\n"; print "\n"; print "
".$ver."
\n"; } print "\n"; return; } # vim: ts=2 sw=2 noet ft=php ?>