Use the php function ini_set() to override php.ini settings. So to turn globals off you could use ini_set('register_globals', 'Off')
// In mainfile.php
// change this line
define('XOOPS_URL', 'https: //www.example.org');
// to the following
$port = $HTTP_SERVER_VARS['SERVER_PORT'];
if($port == "443"){
define('XOOPS_URL', 'https: //www.example.org');
} else {
define('XOOPS_URL', 'http: //www.example.org');
}