Allow WordPress installation URI and blog URI to be different.

git-svn-id: http://svn.automattic.com/wordpress/trunk@1203 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
saxmatt 2004-04-28 07:27:03 +00:00
parent 0a76831fc7
commit 4e4cb4e004
15 changed files with 52 additions and 34 deletions

View File

@ -12,10 +12,10 @@ require('./wp-blog-header.php');
<meta name="generator" content="WordPress <?php bloginfo('version'); ?>" /> <!-- leave this for stats -->
<style type="text/css" media="screen">
@import url( <?php bloginfo('url'); ?>/wp-layout.css );
@import url( <?php echo get_settings('siteurl'); ?>/wp-layout.css );
</style>
<link rel="stylesheet" type="text/css" media="print" href="<?php bloginfo('url'); ?>/print.css" />
<link rel="stylesheet" type="text/css" media="print" href="<?php echo get_settings('siteurl'); ?>/print.css" />
<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="<?php bloginfo('rss2_url'); ?>" />
<link rel="alternate" type="text/xml" title="RSS .92" href="<?php bloginfo('rss_url'); ?>" />
<link rel="alternate" type="application/atom+xml" title="Atom 0.3" href="<?php bloginfo('atom_url'); ?>" />

View File

@ -34,7 +34,7 @@ foreach ($menu as $item) {
}
?>
<li><a href="<?php echo get_settings('siteurl') . '/' . get_settings('blogfilename'); ?>" title="<?php _e('View your site') ?>"><?php _e('View site') ?> &raquo;</a></li>
<li><a href="<?php echo get_settings('home') . '/' . get_settings('blogfilename'); ?>" title="<?php _e('View your site') ?>"><?php _e('View site') ?> &raquo;</a></li>
<li class="last"><a href="<?php echo get_settings('siteurl')
?>/wp-login.php?action=logout" title="<?php _e('Log out of this account') ?>"><?php printf(__('Logout (%s)'), stripslashes($user_nickname)) ?></a></li>
</ul>

View File

@ -46,7 +46,7 @@ include('options-head.php');
<h2><?php _e('General Options') ?></h2>
<form name="form1" method="post" action="options.php">
<input type="hidden" name="action" value="update" />
<input type="hidden" name="action" value="update" /> <input type="hidden" name="page_options" value="'blogname','blogdescription','siteurl','admin_email','users_can_register','new_users_can_blog','gmt_offset','date_format','time_format'" />
<input type="hidden" name="action" value="update" /> <input type="hidden" name="page_options" value="'blogname','blogdescription','siteurl','admin_email','users_can_register','new_users_can_blog','gmt_offset','date_format','time_format','home'" />
<table width="100%" cellspacing="2" cellpadding="5" class="editform">
<tr valign="top">
<th width="33%" scope="row"><?php _e('Weblog title:') ?></th>
@ -59,9 +59,13 @@ include('options-head.php');
<?php _e('In a few words, explain what this weblog is about.') ?></td>
</tr>
<tr valign="top">
<th scope="row"><?php _e('Web address (URI):') ?> </th>
<th scope="row"><?php _e('WordPress address (URI):') ?></th>
<td><input name="siteurl" type="text" id="siteurl" value="<?php echo get_settings('siteurl'); ?>" size="40" class="code" /></td>
</tr>
<tr valign="top">
<th scope="row"><?php _e('Blog address (URI):') ?></th>
<td><input name="home" type="text" id="home" value="<?php echo get_settings('home'); ?>" size="40" class="code" /><br /><?php _e('If you want your blog homepage to be different than the directory you installed WordPress in, enter that address here. '); ?></td>
</tr>
<tr valign="top">
<th scope="row"><?php _e('E-mail address:') ?> </th>
<td><input name="admin_email" type="text" id="admin_email" value="<?php echo get_settings('admin_email'); ?>" size="40" class="code" />

View File

@ -75,14 +75,19 @@ $site_root = str_replace('http://', '', trim(get_settings('siteurl')));
$site_root = preg_replace('|([^/]*)(.*)|i', '$2', $site_root);
if ('/' != substr($site_root, -1)) $site_root = $site_root . '/';
$home_root = str_replace('http://', '', trim(get_settings('home')));
$home_root = preg_replace('|([^/]*)(.*)|i', '$2', $home_root);
if ('/' != substr($home_root, -1)) $home_root = $home_root . '/';
?>
<form action="">
<p>
<textarea rows="5" style="width: 100%;">RewriteEngine On
RewriteBase <?php echo $site_root; ?>
RewriteBase <?php echo $home_root; ?>
<?php
$rewrite = rewrite_rules('', $permalink_structure);
foreach ($rewrite as $match => $query) {
if (strstr($query, 'index.php')) echo 'RewriteRule ^' . $match . ' ' . $home_root . $query . " [QSA]\n";
echo 'RewriteRule ^' . $match . ' ' . $site_root . $query . " [QSA]\n";
}
?>

View File

@ -798,6 +798,11 @@ function upgrade_110() {
$wpdb->query("INSERT INTO $tableoptions (option_name, option_type, option_value, option_admin_level) VALUES ('comment_max_links', 3, '5', 8)");
}
// Option for different blog URL
if(!$wpdb->get_var("SELECT option_id FROM $tableoptions WHERE option_name = 'home'")) {
$wpdb->query("INSERT INTO $tableoptions (option_name, option_type, option_value, option_admin_level) VALUES ('home', 3, '', 8)");
}
// Delete unused options
$unusedoptions = array ('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file');
foreach ($unusedoptions as $option) :

View File

@ -18,7 +18,7 @@ require ('wp-blog-header.php');
</head>
<body id="commentspopup">
<h1 id="header"><a href="<?php echo get_settings('siteurl'); ?>" title="<?php echo get_settings('blogname'); ?>"><?php echo get_settings('blogname'); ?></a></h1>
<h1 id="header"><a href="<?php echo get_settings('home'); ?>" title="<?php echo get_settings('blogname'); ?>"><?php echo get_settings('blogname'); ?></a></h1>
<h2 id="comments">Replying to Comment:</h2>
<?php

View File

@ -57,7 +57,7 @@ function get_search_query_terms($engine = 'google') {
}
function is_referer_search_engine($engine = 'google') {
$siteurl = get_settings('siteurl');
$siteurl = get_settings('home');
$referer = urldecode($_SERVER['HTTP_REFERER']);
//echo "referer is: $referer<br />";
if ( ! $engine ) {

View File

@ -224,7 +224,7 @@ function get_usernumposts($userid) {
function url_to_postid($url = '') {
global $wpdb, $tableposts;
$siteurl = get_settings('siteurl');
$siteurl = get_settings('home');
// Take a link like 'http://example.com/blog/something'
// and extract just the '/something':
$uri = preg_replace("#$siteurl#i", '', $url);
@ -310,6 +310,8 @@ function get_settings($setting) {
$settings = $cache_settings;
}
if ('home' == $setting && '' == $settings->home) return $settings->siteurl;
if (!isset($settings->$setting)) {
return false;
} else {
@ -325,6 +327,8 @@ function get_alloptions() {
// "When trying to design a foolproof system,
// never underestimate the ingenuity of the fools :)"
if ('siteurl' == $option->option_name) $option->option_value = preg_replace('|/+$|', '', $option->option_value);
if ('home' == $option->option_name) $option->option_value = preg_replace('|/+$|', '', $option->option_value);
$all_options->{$option->option_name} = $option->option_value;
}
}
@ -531,7 +535,7 @@ include_once (ABSPATH . WPINC . '/class-xmlrpcs.php');
$f = new xmlrpcmsg('weblogUpdates.ping',
array(new xmlrpcval(get_settings('blogname'), 'string'),
new xmlrpcval(get_settings('siteurl') ,'string')));
new xmlrpcval(get_settings('home') ,'string')));
$c = new xmlrpc_client($path, $server, 80);
$r = $c->send($f);
@ -636,7 +640,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('siteurl') . $link_url : $link_url;
$link_url = (strtolower(substr($link_url,0,7)) != 'http://') ? get_settings('home') . $link_url : $link_url;
$links_summary .= "\n".$link_number.' '.$link_url;
}
$content = strip_tags($content);
@ -917,7 +921,7 @@ function getRemoteFile($host,$path) {
function pingGeoURL($blog_ID) {
$ourUrl = get_settings('siteurl') ."/index.php?p=".$blog_ID;
$ourUrl = get_settings('home') ."/index.php?p=".$blog_ID;
$host="geourl.org";
$path="/ping/?p=".$ourUrl;
getRemoteFile($host,$path);

View File

@ -82,13 +82,13 @@ function get_author_link($echo = false, $author_id, $author_nicename) {
$permalink_structure = get_settings('permalink_structure');
if ('' == $permalink_structure) {
$file = get_settings('siteurl') . '/' . get_settings('blogfilename');
$file = get_settings('home') . '/' . get_settings('blogfilename');
$link = $file.$querystring_start.'author'.$querystring_equal.$auth_ID;
} else {
if ('' == $author_nicename) $author_nicename = $cache_userdata[$author_id]->author_nicename;
// Get any static stuff from the front
$front = substr($permalink_structure, 0, strpos($permalink_structure, '%'));
$link = get_settings('siteurl') . $front . 'author/';
$link = get_settings('home') . $front . 'author/';
$link .= $author_nicename . '/';
}

View File

@ -21,13 +21,13 @@ function get_category_link($echo = false, $category_id, $category_nicename) {
$permalink_structure = get_settings('permalink_structure');
if ('' == $permalink_structure) {
$file = get_settings('siteurl') . '/' . get_settings('blogfilename');
$file = get_settings('home') . '/' . get_settings('blogfilename');
$link = $file.$querystring_start.'cat'.$querystring_equal.$cat_ID;
} else {
if ('' == $category_nicename) $category_nicename = $cache_categories[$category_id]->category_nicename;
// Get any static stuff from the front
$front = substr($permalink_structure, 0, strpos($permalink_structure, '%'));
$link = get_settings('siteurl') . $front . 'category/';
$link = get_settings('home') . $front . 'category/';
if ($parent=$cache_categories[$category_id]->category_parent) $link .= get_category_parents($parent, FALSE, '/', TRUE);
$link .= $category_nicename . '/';
}
@ -187,7 +187,7 @@ function dropdown_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_
global $tablecategories, $tableposts, $tablepost2cat, $wpdb;
global $pagenow;
global $querystring_start, $querystring_equal, $querystring_separator;
if (($file == 'blah') || ($file == '')) $file = get_settings('siteurl') . '/' . get_settings('blogfilename');
if (($file == 'blah') || ($file == '')) $file = get_settings('home') . '/' . get_settings('blogfilename');
if (!$selected) $selected=$cat;
$sort_column = 'cat_'.$sort_column;
@ -259,7 +259,7 @@ function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_orde
global $querystring_start, $querystring_equal, $querystring_separator;
// Optiondates now works
if ('' == $file) {
$file = get_settings('siteurl') . '/' . get_settings('blogfilename');
$file = get_settings('home') . '/' . get_settings('blogfilename');
}
if (intval($categories)==0){
$sort_column = 'cat_'.$sort_column;

View File

@ -26,14 +26,14 @@ function get_bloginfo($show='') {
if ('' != get_settings('permalink_structure')) {
$do_perma = 1;
$feed_url = get_settings('siteurl') . '/feed';
$comment_feed_url = get_settings('siteurl') . '/comments/feed';
$feed_url = get_settings('home') . '/feed';
$comment_feed_url = get_settings('home') . '/comments/feed';
}
switch($show) {
case 'url':
case 'siteurl':
$output = get_settings('siteurl');
$output = get_settings('home');
break;
case 'description':
$output = get_settings('blogdescription');
@ -279,7 +279,7 @@ function get_archives($type='', $limit='', $format='html', $before = '', $after
$arc_week = get_weekstartend($arcresult->yyyymmdd, get_settings('start_of_week'));
$arc_week_start = date_i18n($archive_week_start_date_format, $arc_week['start']);
$arc_week_end = date_i18n($archive_week_end_date_format, $arc_week['end']);
$url = sprintf('%s/%s%sm%s%s%sw%s%d', get_settings('siteurl'), get_settings('blogfilename'), $querystring_start,
$url = sprintf('%s/%s%sm%s%s%sw%s%d', get_settings('home'), get_settings('blogfilename'), $querystring_start,
$querystring_equal, $arc_year, $querystring_separator,
$querystring_equal, $arcresult->week);
$text = $arc_week_start . $archive_week_separator . $arc_week_end;

View File

@ -63,9 +63,9 @@ function get_permalink($id=false) {
$post->post_name,
$post->ID
);
return get_settings('siteurl') . str_replace($rewritecode, $rewritereplace, get_settings('permalink_structure'));
return get_settings('home') . str_replace($rewritecode, $rewritereplace, get_settings('permalink_structure'));
} else { // if they're not using the fancy permalink option
return get_settings('siteurl') . '/' . get_settings('blogfilename').$querystring_start.'p'.$querystring_equal.$post->ID;
return get_settings('home') . '/' . get_settings('blogfilename').$querystring_start.'p'.$querystring_equal.$post->ID;
}
} else { // if an ID is given
$idpost = $wpdb->get_row("SELECT post_date, post_name FROM $tableposts WHERE ID = $id");
@ -78,9 +78,9 @@ function get_permalink($id=false) {
$idpost->post_name,
$id
);
return get_settings('siteurl') . str_replace($rewritecode, $rewritereplace, get_settings('permalink_structure'));
return get_settings('home') . str_replace($rewritecode, $rewritereplace, get_settings('permalink_structure'));
} else {
return get_settings('siteurl') . '/' . get_settings('blogfilename').$querystring_start.'p'.$querystring_equal.$id;
return get_settings('home') . '/' . get_settings('blogfilename').$querystring_start.'p'.$querystring_equal.$id;
}
}
}
@ -97,9 +97,9 @@ function get_month_link($year, $month) {
$monthlink = str_replace('%year%', $year, $monthlink);
$monthlink = str_replace('%monthnum%', zeroise(intval($month), 2), $monthlink);
$monthlink = str_replace('%post_id%', '', $monthlink);
return get_settings('siteurl') . $monthlink;
return get_settings('home') . $monthlink;
} else {
return get_settings('siteurl') .'/'. get_settings('blogfilename') .$querystring_start.'m'.$querystring_equal.$year.zeroise($month, 2);
return get_settings('home') .'/'. get_settings('blogfilename') .$querystring_start.'m'.$querystring_equal.$year.zeroise($month, 2);
}
}
@ -117,9 +117,9 @@ function get_day_link($year, $month, $day) {
$daylink = str_replace('%monthnum%', zeroise(intval($month), 2), $daylink);
$daylink = str_replace('%day%', zeroise(intval($day), 2), $daylink);
$daylink = str_replace('%post_id%', '', $daylink);
return get_settings('siteurl') . $daylink;
return get_settings('home') . $daylink;
} else {
return get_settings('siteurl') .'/'. get_settings('blogfilename') .$querystring_start.'m'.$querystring_equal.$year.zeroise($month, 2).zeroise($day, 2);
return get_settings('home') .'/'. get_settings('blogfilename') .$querystring_start.'m'.$querystring_equal.$year.zeroise($month, 2).zeroise($day, 2);
}
}

View File

@ -373,7 +373,7 @@ function next_posts($max_page = 0) { // original by cfactor at cooltux.org
if (!$paged) $paged = 1;
$nextpage = intval($paged) + 1;
if (!$max_page || $max_page >= $nextpage) {
echo get_settings('siteurl') .'/'.$pagenow.$querystring_start.
echo get_settings('home') .'/'.$pagenow.$querystring_start.
($qstr == '' ? '' : $qstr.$querystring_separator) .
'paged'.$querystring_equal.$nextpage;
}
@ -425,7 +425,7 @@ function previous_posts() { // original by cfactor at cooltux.org
}
$nextpage = intval($paged) - 1;
if ($nextpage < 1) $nextpage = 1;
echo get_settings('siteurl') .'/'.$pagenow.$querystring_start.
echo get_settings('home') .'/'.$pagenow.$querystring_start.
($qstr == '' ? '' : $qstr.$querystring_separator) .
'paged'.$querystring_equal.$nextpage;
}

View File

@ -280,7 +280,7 @@ default:
<div id="login">
<p>
<a href="<?php echo get_settings('siteurl'); ?>" title="<?php _e('Are you lost?') ?>"><?php _e('Back to blog?') ?></a><br />
<a href="<?php echo get_settings('home'); ?>" title="<?php _e('Are you lost?') ?>"><?php _e('Back to blog?') ?></a><br />
<?php if (get_settings('users_can_register')) { ?>
<a href="<?php echo get_settings('siteurl'); ?>/wp-register.php" title="<?php _e('Register to be an author') ?>"><?php _e('Register?') ?></a><br />
<?php } ?>

2
wp.php
View File

@ -15,7 +15,7 @@ require_once("wp-blog-header.php");
<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
</head>
<body>
<h1 id="header"><a href="<?php echo get_settings('siteurl'); ?>" title="<?php bloginfo('name'); ?>"><?php bloginfo('name'); ?></a></h1>
<h1 id="header"><a href="<?php echo get_settings('home'); ?>" title="<?php bloginfo('name'); ?>"><?php bloginfo('name'); ?></a></h1>
<!-- // loop start -->
<?php foreach ($posts as $post) { start_wp(); ?>