The error is that you cannot pass variables as default argument values (see https://www.php.net/manual/en/functions.arguments.php).
In line 53:
function get_geoip_country_code($ip = $_SERVER["REMOTE_ADDR"]) {
should be changed to something like:
function get_geoip_country_code($ip = NULL) {
if (is_null($ip)) {
$ip = $_SERVER["REMOTE_ADDR"];
}
Also note that there is a missing closing parenthesis in all your realpath
calls.