Permalink
Browse files

Merge pull request #23 from jdarwood007/master

Add https support to repair_settings.php

Published on download page
  • Loading branch information...
2 parents 4a88fc2 + 22b07e6 commit 0ae829871329b5e86deb149e8c619f261aae6795 @jdarwood007 jdarwood007 committed on GitHub Jan 7, 2017
Showing with 8 additions and 15 deletions.
  1. +8 −15 repair_settings.php
View
@@ -5,7 +5,7 @@
*
* @package SMF
* @author Simple Machines
- * @copyright 2016 Simple Machines
+ * @copyright 2017 Simple Machines
* @license http://www.simplemachines.org/about/smf/license.php BSD
*
* @version 2.1
@@ -112,16 +112,6 @@
if (!empty($db_type) && isset($txt['db_' . $db_type]))
$txt['database_settings'] = $txt['db_' . $db_type] . ' ' . $txt['database_settings'];
-//Remove this file, maybe?
-if (isset($_POST['remove_file']))
-{
- @unlink(__FILE__);
-
- // Redirect to index.php.
- header('Location: http://' . (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT']) . dirname($_SERVER['PHP_SELF']) . '/index.php');
- exit;
-}
-
if (isset($_POST['submit']))
set_settings();
@@ -291,13 +281,16 @@ function initialize_inputs()
$_POST[$k] = addcslashes($v, '\'\\');
}
+ // Https?
+ $context['schema'] = isset($_SERVER['HTTPS']) || (isset($_SERVER['REQUEST_SCHEME']) && strtolower($_SERVER['REQUEST_SCHEME']) == 'https') ? 'https' : 'http';
+
// This is really quite simple; if ?delete is on the URL, delete the installer...
- if (isset($_GET['delete']))
+ if (isset($_GET['delete']) || isset($_POST['remove_file']))
{
@unlink(__FILE__);
// Now just redirect to a blank.gif...
- header('Location: http://' . (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT']) . dirname($_SERVER['PHP_SELF']) . '/Themes/default/images/blank.gif');
+ header('Location: ' . $context['schema'] . '://' . (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT']) . dirname($_SERVER['PHP_SELF']) . '/index.php');
exit;
}
@@ -518,8 +511,8 @@ function show_settings()
// Let's assume we don't want to change the current theme
$settings['theme_default'] = 0;
- $host = empty($_SERVER['HTTP_HOST']) ? $_SERVER['SERVER_NAME'] . (empty($_SERVER['SERVER_PORT']) || $_SERVER['SERVER_PORT'] == '80' ? '' : ':' . $_SERVER['SERVER_PORT']) : $_SERVER['HTTP_HOST'];
- $url = 'http://' . $host . substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['PHP_SELF'], '/'));
+ $host = empty($_SERVER['HTTP_HOST']) ? $_SERVER['SERVER_NAME'] . (empty($_SERVER['SERVER_PORT']) || $_SERVER['SERVER_PORT'] == '80' || ($_SERVER['SERVER_PORT'] == '443' && $context['schema'] == 'https') ? '' : ':' . $_SERVER['SERVER_PORT']) : $_SERVER['HTTP_HOST'];
+ $url = $context['schema'] . '://' . $host . substr($_SERVER['PHP_SELF'], 0, strrpos($_SERVER['PHP_SELF'], '/'));
$known_settings['path_url_settings']['boardurl'][2] = $url;
$known_settings['path_url_settings']['boarddir'][2] = dirname(__FILE__);

0 comments on commit 0ae8298

Please sign in to comment.