|
From: FlorinCB <ory...@us...> - 2008-12-18 03:23:42
|
Update of /cvsroot/mxbb/mx_contact/includes In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv3914 Modified Files: functions_contact.php Log Message: new function Index: functions_contact.php =================================================================== RCS file: /cvsroot/mxbb/mx_contact/includes/functions_contact.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** functions_contact.php 12 Dec 2007 18:41:44 -0000 1.1 --- functions_contact.php 18 Dec 2008 03:23:06 -0000 1.2 *************** *** 25,34 **** } ! if(!$userdata['session_logged_in']) { $remove = $HTTP_GET_VARS['delete']; redirect($module_root_path . "login.$phpEx?redirect=index.$phpEx&delete=$remove", true); } ! elseif($userdata['user_level'] != ADMIN) { mx_message_die(GENERAL_ERROR, $lang['Not_Authorised']); // lang_main.php --- 25,34 ---- } ! if(!$mx_userdata['session_logged_in']) { $remove = $HTTP_GET_VARS['delete']; redirect($module_root_path . "login.$phpEx?redirect=index.$phpEx&delete=$remove", true); } ! elseif($mx_userdata['user_level'] != ADMIN) { mx_message_die(GENERAL_ERROR, $lang['Not_Authorised']); // lang_main.php *************** *** 96,98 **** --- 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 |