Skip to content

Commit

Permalink
Implement http_host / new localized url processing.
Browse files Browse the repository at this point in the history
  • Loading branch information
mark0263 committed Oct 29, 2015
1 parent 90ca074 commit 6099e2b
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 30 deletions.
18 changes: 9 additions & 9 deletions private/system/lib-syndication.php
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ function SYND_getFeedContentPerTopic( $tid, $limit, &$link, &$update, $contentLe
}
}

$storylink = COM_buildUrl( $_CONF['site_url']
$storylink = COM_buildUrl( $_CONF['http_host']
. '/article.php?story=' . $row['sid'] );
$extensionTags = PLG_getFeedElementExtensions('article', $row['sid'], $feedType, $feedVersion, $tid, $fid);
if( $_CONF['trackback_enabled'] && ($feedType == 'RSS') && ($row['trackbackcode'] >= 0)) {
Expand Down Expand Up @@ -305,7 +305,7 @@ function SYND_getFeedContentPerTopic( $tid, $limit, &$link, &$update, $contentLe
$content[] = $article;
}
}
$link = $_CONF['site_url'] . '/index.php?topic=' . $tid;
$link = $_CONF['http_host'] . '/index.php?topic=' . $tid;
$update = implode( ',', $sids );

return $content;
Expand Down Expand Up @@ -394,7 +394,7 @@ function SYND_getFeedContentAll($frontpage_only, $limit, &$link, &$update, $cont
}
}

$storylink = COM_buildUrl( $_CONF['site_url'] . '/article.php?story='.$row['sid'] );
$storylink = COM_buildUrl( $_CONF['http_host'] . '/article.php?story='.$row['sid'] );
$extensionTags = PLG_getFeedElementExtensions('article', $row['sid'], $feedType, $feedVersion, $fid, ($frontpage_only ? '::frontpage' : '::all'));
if( $_CONF['trackback_enabled'] && ($feedType == 'RSS') && ($row['trackbackcode'] >= 0)) {
$trbUrl = TRB_makeTrackbackUrl( $row['sid'] );
Expand All @@ -420,7 +420,7 @@ function SYND_getFeedContentAll($frontpage_only, $limit, &$link, &$update, $cont
$content[] = $article;
}

$link = $_CONF['site_url'];
$link = $_CONF['http_host'];
$update = implode( ',', $sids );

return $content;
Expand Down Expand Up @@ -458,11 +458,11 @@ function SYND_updateFeed( $fid )
if ($A['feedlogo'] != '' ) {
$image = new FeedImage();
$image->title = $A['title'];
$image->url = $_CONF['site_url'] . $A['feedlogo'];
$image->link = $_CONF['site_url'];
$image->url = $_CONF['http_host'] . $A['feedlogo'];
$image->link = $_CONF['http_host'];
$rss->image = $image;
}
$rss->link = $_CONF['site_url'];
$rss->link = $_CONF['http_host'];
if ( !empty( $A['filename'] )) {
$filename = $A['filename'];
} else {
Expand Down Expand Up @@ -512,7 +512,7 @@ function SYND_updateFeed( $fid )
}
}
if (empty($link)) {
$link = $_CONF['site_url'];
$link = $_CONF['http_host'];
}

$rss->editor = $_CONF['site_mail'];
Expand Down Expand Up @@ -576,7 +576,7 @@ function SYND_getFeedUrl( $feedfile = '' )
global $_CONF;

$feedpath = SYND_getFeedPath();
$url = substr_replace ($feedpath, $_CONF['site_url'], 0,
$url = substr_replace ($feedpath, $_CONF['http_host'], 0,
strlen ($_CONF['path_html']) - 1);
$url .= $feedfile;

Expand Down
2 changes: 1 addition & 1 deletion private/system/lib-widgets.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ function WIDGET_autotranslations($header=0) {
$retval .= 'hl=' . $key; // 2 character language code of google header bar (usually the same as tl below)
$retval .= '&sl=' . $_CONF['rdf_language']; // default language of your site
$retval .= '&tl=' . $key; // 2 character language code to translate site into (usually should be the same as hl above)
$retval .= '&u=' . urlencode($_CONF['site_url'] . '?r=' . $randID); // address of your site appends a random string so Google won't cache the translated page
$retval .= '&u=' . urlencode($_CONF['http_host'] . '?r=' . $randID); // address of your site appends a random string so Google won't cache the translated page
$retval .= '"><img src="' . $_CONF['site_url'] . '/images/speck.gif" alt="'.$language.'" title="'.$language.'" /></a></li>';
}
}
Expand Down
35 changes: 27 additions & 8 deletions public_html/lib-common.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,24 @@ function all_stripslashes($var)
$_CONF = $config->get_config('Core');
if ( $_CONF['cookiesecure']) @ini_set('session.cookie_secure','1');

// reset URL
$purl = parse_url($_CONF['site_url']);
$url_scheme = $purl['scheme'];
$url_host = $purl['host'];
$url_path = isset($purl['path']) ? $purl['path'] : '';

$_CONF['site_url'] = $url_path;
$_CONF['http_host'] = $url_scheme.'://'.$url_host;

$admin_purl = parse_url($_CONF['site_admin_url']);
$admin_url_scheme = $admin_purl['scheme'];
$admin_url_host = $admin_purl['host'];
$admin_url_path = isset($admin_purl['path']) ? $admin_purl['path'] : '';

$_CONF['site_admin_url'] = $admin_url_path;
$_CONF['admin_http_host'] = $url_scheme.'://'.$admin_url_host;


@date_default_timezone_set('America/Chicago');

if (isset($_CONF['bb2_enabled']) && $_CONF['bb2_enabled']) {
Expand Down Expand Up @@ -3431,8 +3449,8 @@ function COM_emailUserTopics()
$T->set_var('site_name',$_CONF['site_name']);
$TT->set_var('site_name',$_CONF['site_name']);

$T->set_var('remove_msg',sprintf($LANG08[36],$_CONF['site_name'],$_CONF['site_url']));
$TT->set_var('remove_msg',sprintf($LANG08[37],$_CONF['site_name'],$_CONF['site_url']));
$T->set_var('remove_msg',sprintf($LANG08[36],$_CONF['site_name'],$_CONF['http_host']));
$TT->set_var('remove_msg',sprintf($LANG08[37],$_CONF['site_name'],$_CONF['http_host']));

for( $y = 0; $y < $nsrows; $y++ ) {
// Loop through stories building the requested email message
Expand All @@ -3456,7 +3474,7 @@ function COM_emailUserTopics()
$story->_username = $output['username'];
$story->_fullname = $output['fullname'];
}
$story_url = COM_buildUrl( $_CONF['site_url'] . '/article.php?story=' . $S['sid'] );
$story_url = COM_buildUrl( $_CONF['http_host'] . '/article.php?story=' . $S['sid'] );
$title = COM_undoSpecialChars( $S['title'] );
if ( $_CONF['contributedbyline'] == 1 ) {
if ( empty( $authors[$S['uid']] )) {
Expand Down Expand Up @@ -5274,10 +5292,10 @@ function COM_getCurrentURL()
$first_slash = strpos( $_CONF['site_url'], '/' );
if ( $first_slash === false ) {
// special case - assume it's okay
$thisUrl = $_CONF['site_url'] . $document_uri;
$thisUrl = $_CONF['http_host'] . $document_uri;
} else if ( $first_slash + 1 == strrpos( $_CONF['site_url'], '/' )) {
// site is in the document root
$thisUrl = $_CONF['site_url'] . $document_uri;
$thisUrl = $_CONF['http_host'] . $document_uri;
} else {
// extract server name first
$pos = strpos( $_CONF['site_url'], '/', $first_slash + 2 );
Expand Down Expand Up @@ -5308,6 +5326,7 @@ function COM_getCurrentURL()
if ( $firstslash === false ) {
// special case - assume it's okay
$thisUrl = $_CONF['site_url'] . $requestUri;
$thisUrl = $_CONF['http_host'] . $requestUri;
} else if ( $firstslash + 1 == strrpos( $_CONF['site_url'], '/' )) {
// site is in the document root
$thisUrl = $_CONF['site_url'] . $requestUri;
Expand Down Expand Up @@ -5560,9 +5579,9 @@ function COM_createImage($url, $alt = "", $attr = array())

$retval = '';

if (strpos($url, 'http://') !== 0 && strpos($url,'https://') !== 0 ) {
$url = $_CONF['layout_url'] . $url;
}
// if (strpos($url, 'http://') !== 0 && strpos($url,'https://') !== 0 ) {
// $url = $_CONF['layout_url'] . $url;
// }
$attr_str = 'src="' . $url . '"';

foreach ($attr as $key => $value) {
Expand Down
6 changes: 3 additions & 3 deletions public_html/profiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ function mailstory ($sid, $to, $toemail, $from, $fromemail, $shortmsg,$html=0)

$dt = new Date('now',$_USER['tzid']);

$storyurl = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $sid);
$storyurl = COM_buildUrl($_CONF['http_host'] . '/article.php?story=' . $sid);
if ($_CONF['url_rewrite']) {
$retURL = $storyurl . '?msg=85';
} else {
Expand Down Expand Up @@ -392,11 +392,11 @@ function mailstory ($sid, $to, $toemail, $from, $fromemail, $shortmsg,$html=0)
}
if ($A['commentcode'] == 0) { // comments allowed
$mailtext .= $LANG08[24] . LB
. COM_buildUrl ($_CONF['site_url'] . '/article.php?story='
. COM_buildUrl ($_CONF['http_host'] . '/article.php?story='
. $sid . '#comments');
} else { // comments not allowed - just add the story's URL
$mailtext .= $LANG08[33] . LB
. COM_buildUrl ($_CONF['site_url'] . '/article.php?story='
. COM_buildUrl ($_CONF['http_host'] . '/article.php?story='
. $sid);
}

Expand Down
18 changes: 9 additions & 9 deletions public_html/users.php
Original file line number Diff line number Diff line change
Expand Up @@ -449,10 +449,10 @@ function requestpassword ($username, $msg = 0)
DB_change ($_TABLES['users'], 'pwrequestid', "$reqid",'uid', (int) $A['uid']);

$mailtext = sprintf ($LANG04[88], $username);
$mailtext .= $_CONF['site_url'] . '/users.php?mode=newpwd&uid=' . $A['uid'] . '&rid=' . $reqid . "\n\n";
$mailtext .= $_CONF['http_host'] . '/users.php?mode=newpwd&uid=' . $A['uid'] . '&rid=' . $reqid . "\n\n";
$mailtext .= $LANG04[89];
$mailtext .= "{$_CONF['site_name']}\n";
$mailtext .= "{$_CONF['site_url']}\n";
$mailtext .= "{$_CONF['http_host']}\n";

$subject = $_CONF['site_name'] . ': ' . $LANG04[16];
if ($_CONF['site_mail'] !== $_CONF['noreply_mail']) {
Expand Down Expand Up @@ -540,20 +540,20 @@ function requesttoken ($uid, $msg = 0)
echo COM_refresh ($_CONF['site_url'] . '/index.php?msg=48');
}
$verification_id = USER_createActivationToken($uid,$A['username']);
$activation_link = $_CONF['site_url'].'/users.php?mode=verify&vid='.$verification_id.'&u='.$uid;
$activation_link = $_CONF['http_host'].'/users.php?mode=verify&vid='.$verification_id.'&u='.$uid;
$mailtext = $LANG04[168] . $_CONF['site_name'] . ".\n\n";
$mailtext .= $LANG04[170] . "\n\n";
$mailtext .= "----------------------------\n";
$mailtext .= $LANG04[2] . ': ' . $A['username'] ."\n";
$mailtext .= $LANG04[171] .': ' . $_CONF['site_url'] ."\n";
$mailtext .= $LANG04[171] .': ' . $_CONF['http_host'] ."\n";
$mailtext .= "----------------------------\n\n";
$mailtext .= sprintf($LANG04[172],($_SYSTEM['verification_token_ttl']/3600)) . "\n\n";
$mailtext .= $activation_link . "\n\n";
$mailtext .= $LANG04[173] . "\n\n";
$mailtext .= $LANG04[174] . "\n\n";
$mailtext .= "--\n";
$mailtext .= $_CONF['site_name'] . "\n";
$mailtext .= $_CONF['site_url'] . "\n";
$mailtext .= $_CONF['http_host'] . "\n";

$subject = $_CONF['site_name'] . ': ' . $LANG04[16];
if ($_CONF['site_mail'] !== $_CONF['noreply_mail']) {
Expand Down Expand Up @@ -1364,10 +1364,10 @@ function _userGetnewtoken()
// which we are requesting information from.
header('Location: ' . $consumer->handle_request(
$server_id, $server_url,
oidUtil::append_args($_CONF['site_url'] . '/users.php',
oidUtil::append_args($_CONF['http_host'] . '/users.php',
array('openid_login' => '1',
'open_id' => $identity_url)), // Return to.
$_CONF['site_url'], // Trust root.
$_CONF['http_host'], // Trust root.
null,
"email,nickname,fullname")); // Required fields.
exit;
Expand Down Expand Up @@ -1416,7 +1416,7 @@ function _userGetnewtoken()

$consumer = new OAuthConsumer($service);

$callback_url = $_CONF['site_url'] . '/users.php?oauth_login=' . $service;
$callback_url = $_CONF['http_host'] . '/users.php?oauth_login=' . $service;

$consumer->setRedirectURL($callback_url);
$oauth_userinfo = $consumer->authenticate_user();
Expand Down Expand Up @@ -1461,7 +1461,7 @@ function _userGetnewtoken()
}
}
COM_resetSpeedlimit('login');

// @CHECK
// we are now fully logged in, let's see if there is someplace we need to go....
if (!empty($_SERVER['HTTP_REFERER'])
&& (strstr($_SERVER['HTTP_REFERER'], '/users.php') === false)
Expand Down

0 comments on commit 6099e2b

Please sign in to comment.