From 270c2c8f8b84a58f996b701a3123df49bdc8381a Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Sun, 12 Oct 2014 13:05:40 +0000 Subject: [PATCH] changed config/config.php to add ['REQUEST_PROTOCOL']. changed the subversion repository anchor to have the trailing slash --- codepot/etc/codepot.ini.in | 11 +++++++++-- codepot/src/codepot/config/config.php | 8 ++++++++ codepot/src/codepot/views/project_home.php | 2 +- codepot/src/index.php | 14 ++++---------- 4 files changed, 22 insertions(+), 13 deletions(-) diff --git a/codepot/etc/codepot.ini.in b/codepot/etc/codepot.ini.in index 20e73551..3a2bc2c4 100644 --- a/codepot/etc/codepot.ini.in +++ b/codepot/etc/codepot.ini.in @@ -86,9 +86,16 @@ api_base_url = "http://127.0.0.1" ; https://${SERVER_NAME}/svn. ; You may specify multiple URLs separated with a comma as shown below: ; "http://${SERVER_NAME}/svn, https://${SERVER_NAME}/svn" -; REQUEST_PROTOCOL is resolved to either http or https. +; All specified URLs are shown in the repository list of the project overview +; page. +; You may use various items available in $_SERVER when composing the URL. +; For example, ${HTTP_HOST} maps to $_SERVER{'HTTP_HOST'}. +; Additionally, $_SERVER{'REQUEST_PROTOCOL'} added by config/config.php +; can be referenced with ${REQUEST_PROTOCOL} and it is resolved to either +; http or https. ;------------------------------------------------------------------------------ -svn_base_url = "${REQUEST_PROTOCOL}://${SERVER_NAME}:${SERVER_PORT}/svn" +;svn_base_url = "${REQUEST_PROTOCOL}://${SERVER_NAME}:${SERVER_PORT}/svn" +svn_base_url = "${REQUEST_PROTOCOL}://${HTTP_HOST}/svn" ;------------------------------------------------------------------------------ ; Login model to use. diff --git a/codepot/src/codepot/config/config.php b/codepot/src/codepot/config/config.php index d69f6b0c..dd4c70e8 100644 --- a/codepot/src/codepot/config/config.php +++ b/codepot/src/codepot/config/config.php @@ -17,17 +17,25 @@ if (isset($_SERVER['HTTP_X_FORWARDED_PROTO'])) { /* set to https if the first X-Forwarded-Proto is https */ if (array_search ("https", array_map ('strtolower', preg_split("/[\s,]+/", $_SERVER['HTTP_X_FORWARDED_PROTO']))) === 0) + { $config['base_url'] = 'https'; + $_SERVER['REQUEST_PROTOCOL'] = 'https'; + } else + { $config['base_url'] = 'http'; + $_SERVER['REQUEST_PROTOCOL'] = 'http'; + } } else if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') { $config['base_url'] = 'https'; + $_SERVER['REQUEST_PROTOCOL'] = 'https'; } else { $config['base_url'] = 'http'; + $_SERVER['REQUEST_PROTOCOL'] = 'http'; } $config['base_url'] .= "://{$_SERVER['HTTP_HOST']}"; diff --git a/codepot/src/codepot/views/project_home.php b/codepot/src/codepot/views/project_home.php index a7be748b..08baf2a2 100644 --- a/codepot/src/codepot/views/project_home.php +++ b/codepot/src/codepot/views/project_home.php @@ -120,7 +120,7 @@ foreach ($urls as $url) $url = trim($url); if ($url == '') continue; print '
  • '; - print anchor ($this->converter->expand($url,$_SERVER) . "/{$project->id}"); + print anchor ($this->converter->expand($url,$_SERVER) . "/{$project->id}/"); print '
  • '; } ?> diff --git a/codepot/src/index.php b/codepot/src/index.php index 1a787f57..3aed01cc 100644 --- a/codepot/src/index.php +++ b/codepot/src/index.php @@ -46,6 +46,10 @@ define('APPPATH', $application_folder.'/'); */ if (CODEPOT_HTTPS_COMPULSORY) { + // this option is not affected by X-Forwared-Proto or other similar headers. + // this option mandates SSL over the direct connection to the origin server. + // it doesn't care if the client is using SSL when the connection is relayed + // by intermediate proxy servers. if (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != 'on') { /* force https except api calls */ @@ -63,16 +67,6 @@ if (CODEPOT_HTTPS_COMPULSORY) } } -/* -|--------------------------------------------------------------- -| EXTRA INFORMATION -|--------------------------------------------------------------- -*/ -if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') - $_SERVER['REQUEST_PROTOCOL'] = 'https'; -else - $_SERVER['REQUEST_PROTOCOL'] = 'http'; - /* |--------------------------------------------------------------- | LOAD THE FRONT CONTROLLER