Add HTTPS support, fixes #1372

git-svn-id: http://svn.automattic.com/wordpress/trunk@3041 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
matt 2005-11-11 01:21:28 +00:00
parent 7c20f40c39
commit 41775561d5
5 changed files with 12 additions and 9 deletions

View File

@ -6,7 +6,8 @@ if (!file_exists('../wp-config.php'))
require_once('../wp-config.php');
require_once('./upgrade-functions.php');
$guessurl = str_replace('/wp-admin/install.php?step=2', '', 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) );
$schema = ( isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ) ? 'https://' : 'http://';
$guessurl = str_replace('/wp-admin/install.php?step=2', '', $schema . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) );
if (isset($_GET['step']))
$step = $_GET['step'];

View File

@ -150,7 +150,8 @@ CREATE TABLE $wpdb->usermeta (
function populate_options() {
global $wpdb;
$guessurl = preg_replace('|/wp-admin/.*|i', '', 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
$schema = ( isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ) ? 'https://' : 'http://';
$guessurl = preg_replace('|/wp-admin/.*|i', '', $schema . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
add_option('siteurl', $guessurl, __('WordPress web address'));
add_option('blogname', __('My Weblog'), __('Blog title'));
add_option('blogdescription', __('Just another WordPress weblog'), __('Short tagline'));

View File

@ -823,7 +823,7 @@ function make_url_footnote($content) {
$link_url = $matches[2][$i];
$link_text = $matches[4][$i];
$content = str_replace($link_match, $link_text.' '.$link_number, $content);
$link_url = (strtolower(substr($link_url,0,7)) != 'http://') ? get_settings('home') . $link_url : $link_url;
$link_url = ((strtolower(substr($link_url,0,7)) != 'http://')||(strtolower(substr($link_url,0,7)) != 'https://')) ? get_settings('home') . $link_url : $link_url;
$links_summary .= "\n".$link_number.' '.$link_url;
}
$content = strip_tags($content);

View File

@ -11,9 +11,10 @@ header('Content-Type: '.get_bloginfo('html_type').'; charset='.get_bloginfo('cha
if ( defined('RELOCATE') ) { // Move flag is set
if ( isset( $_SERVER['PATH_INFO'] ) && ($_SERVER['PATH_INFO'] != $_SERVER['PHP_SELF']) )
$_SERVER['PHP_SELF'] = str_replace( $_SERVER['PATH_INFO'], '', $_SERVER['PHP_SELF'] );
if ( dirname('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']) != get_settings('siteurl') )
update_option('siteurl', dirname('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']) );
$schema = ( isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ) ? 'https://' : 'http://';
if ( dirname($schema . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']) != get_settings('siteurl') )
update_option('siteurl', dirname($schema . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']) );
}
switch($action) {

View File

@ -324,7 +324,7 @@ class wp_xmlrpc_server extends IXR_Server {
/* warning: here we make the assumption that the weblog's URI is on the same server */
$filename = get_settings('home') . '/';
$filename = preg_replace('#http://.+?/#', $_SERVER['DOCUMENT_ROOT'].'/', $filename);
$filename = preg_replace('#https?://.+?/#', $_SERVER['DOCUMENT_ROOT'].'/', $filename);
$f = fopen($filename, 'r');
$content = fread($f, filesize($filename));
@ -359,7 +359,7 @@ class wp_xmlrpc_server extends IXR_Server {
/* warning: here we make the assumption that the weblog's URI is on the same server */
$filename = get_settings('home') . '/';
$filename = preg_replace('#http://.+?/#', $_SERVER['DOCUMENT_ROOT'].'/', $filename);
$filename = preg_replace('#https?://.+?/#', $_SERVER['DOCUMENT_ROOT'].'/', $filename);
if ($f = fopen($filename, 'w+')) {
fwrite($f, $content);
@ -1147,7 +1147,7 @@ class wp_xmlrpc_server extends IXR_Server {
$error_code = -1;
// Check if the page linked to is in our site
$pos1 = strpos($pagelinkedto, str_replace('http://', '', str_replace('www.', '', get_settings('home'))));
$pos1 = strpos($pagelinkedto, str_replace(array('http://www.','http://','https://www.','https://'), '', get_settings('home')));
if( !$pos1 )
return new IXR_Error(0, 'Is there no link to us?');