|
From: FlorinCB <ory...@us...> - 2008-12-18 03:41:50
|
Update of /cvsroot/mxbb/mx_contact/includes In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv5333/includes Modified Files: functions_contact.php functions_newsletter.php Log Message: some fixes Index: functions_newsletter.php =================================================================== RCS file: /cvsroot/mxbb/mx_contact/includes/functions_newsletter.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** functions_newsletter.php 4 Oct 2008 08:03:19 -0000 1.1 --- functions_newsletter.php 18 Dec 2008 03:41:45 -0000 1.2 *************** *** 87,90 **** --- 87,143 ---- } + /** + * Generate board url (example: http://www.example.com/mxp3/) + * @param bool $without_script_path if set to true the script path gets not appended (example: http://www.example.com) + */ + function generate_contact_url($without_script_path = false) + { + global $board_config, $mx_user, $_SERVER; + + $server_name = $mx_user->host; + $server_port = (!empty($_SERVER['SERVER_PORT'])) ? (int) $_SERVER['SERVER_PORT'] : (int) getenv('SERVER_PORT'); + + // Forcing server vars is the only way to specify/override the protocol + if ($board_config['force_server_vars'] || !$server_name) + { + $server_protocol = ($board_config['server_protocol']) ? $board_config['server_protocol'] : (($board_config['cookie_secure']) ? 'https://' : 'http://'); + $server_name = $board_config['server_name']; + $server_port = (int) $board_config['server_port']; + $script_path = $board_config['script_path']; + + $url = $server_protocol . $server_name; + } + else + { + // Do not rely on cookie_secure, users seem to think that it means a secured cookie instead of an encrypted connection + $cookie_secure = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 1 : 0; + $url = (($cookie_secure) ? 'https://' : 'http://') . $server_name; + + $script_path = $mx_user->page['root_script_path']; + } + + if ($server_port && (($board_config['cookie_secure'] && $server_port <> 443) || (!$board_config['cookie_secure'] && $server_port <> 80))) + { + // HTTP HOST can carry a port number (we fetch $mx_user->host, but for old versions this may be true) + if (strpos($server_name, ':') === false) + { + $url .= ':' . $server_port; + } + } + + if (!$without_script_path) + { + $url .= $script_path; + } + + // Strip / from the end + if (substr($url, -1, 1) == '/') + { + $url = substr($url, 0, -1); + } + + return $url; + } + if (!function_exists('htmlspecialchars_decode')) { Index: functions_contact.php =================================================================== RCS file: /cvsroot/mxbb/mx_contact/includes/functions_contact.php,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** functions_contact.php 18 Dec 2008 03:37:53 -0000 1.3 --- functions_contact.php 18 Dec 2008 03:41:45 -0000 1.4 *************** *** 96,151 **** } - /** - * Generate board url (example: http://www.example.com/phpBB) - * @param bool $without_script_path if set to true the script path gets not appended (example: http://www.example.com) - */ - function generate_contact_url($without_script_path = false) - { - global $board_config, $mx_user, $_SERVER; - - $server_name = $mx_user->host; - $server_port = (!empty($_SERVER['SERVER_PORT'])) ? (int) $_SERVER['SERVER_PORT'] : (int) getenv('SERVER_PORT'); - - // Forcing server vars is the only way to specify/override the protocol - if ($board_config['force_server_vars'] || !$server_name) - { - $server_protocol = ($board_config['server_protocol']) ? $board_config['server_protocol'] : (($board_config['cookie_secure']) ? 'https://' : 'http://'); - $server_name = $board_config['server_name']; - $server_port = (int) $board_config['server_port']; - $script_path = $board_config['script_path']; - - $url = $server_protocol . $server_name; - } - else - { - // Do not rely on cookie_secure, users seem to think that it means a secured cookie instead of an encrypted connection - $cookie_secure = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 1 : 0; - $url = (($cookie_secure) ? 'https://' : 'http://') . $server_name; - - $script_path = $mx_user->page['root_script_path']; - } - - if ($server_port && (($board_config['cookie_secure'] && $server_port <> 443) || (!$board_config['cookie_secure'] && $server_port <> 80))) - { - // HTTP HOST can carry a port number (we fetch $mx_user->host, but for old versions this may be true) - if (strpos($server_name, ':') === false) - { - $url .= ':' . $server_port; - } - } - - if (!$without_script_path) - { - $url .= $script_path; - } - - // Strip / from the end - if (substr($url, -1, 1) == '/') - { - $url = substr($url, 0, -1); - } - - return $url; - } - ?> \ No newline at end of file --- 96,98 ---- |