Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle ip behind proxies #914

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
fc33876
move IP detection function to more global location
michield Jul 10, 2021
98ad57f
replace (almost) all REMOTE_ADDR with getClientIP(), so that it conti…
michield Jul 10, 2021
66bf671
Merge branch 'master' into handle_IP_behind_proxies
michield Oct 17, 2021
8676f77
cache the ip address found
michield Oct 20, 2021
02faef6
tidy up
michield Oct 20, 2021
dcff53c
detect proxy in hostname
michield Dec 13, 2022
bb458e6
Merge branch 'main' into handle_IP_behind_proxies
michield Dec 13, 2022
27c00fb
Allow config to set ADMIN_WWWROOT and USER_WWWROOT to bypass the URL …
michield Jul 27, 2023
3771d43
Merge branch 'main' into handle_IP_behind_proxies
michield Jul 27, 2023
a26eccf
add section to config_extended about the new values
michield Jul 27, 2023
0b472cd
fix publicBaseUrl initialisation, as functions and vars are not avail…
michield Jul 30, 2023
e5a17ad
default to http:// to make CI pass
michield Jul 30, 2023
b7e3265
define new global vars for user and admin base urls
michield Aug 28, 2023
d853540
keep the URL config method as before, but override the config when fe…
michield Aug 28, 2023
da74e1a
use new global adminBaseUrl
michield Aug 28, 2023
66a1a78
use intermediate config var for initialisation of the config URLs
michield Aug 28, 2023
7a36207
use new global adminBaseUrl
michield Aug 28, 2023
6cbfdec
update pageroot only when not set, and add explanation in config_exte…
michield Sep 4, 2023
a1e9bc3
fix some more links with the new global var
michield Sep 4, 2023
0b36b40
remove obsolete line
michield Sep 4, 2023
0dadc39
fix typo
michield Sep 4, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# file that keeps track of the latest tag in cvs and the corresponding version
# this automates publishing a new version, when it's tagged
# if you don't understand this, don't worry. You don't need this file
VERSION=3.6.13
VERSION=3.6.14-dev
6 changes: 5 additions & 1 deletion public_html/lists/admin/actions/import2.php
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest create a global variable $adminBaseUrl similar to $publicBaseUrl so that this and several others can be simplified to

$history_entry = $adminBaseUrl.'/?page=user&id='.$userid."\n\n";

Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,11 @@
$some = 1;
}

$history_entry = $GLOBALS['admin_scheme'].'://'.getConfig('website').$GLOBALS['adminpages'].'/?page=user&id='.$userid."\n\n";
if (defined('ADMIN_WWWROOT')) {
$history_entry = ADMIN_WWWROOT.'/?page=user&id='.$userid."\n\n";
} else {
$history_entry = $GLOBALS['admin_scheme'].'://'.getConfig('website').$GLOBALS['adminpages'].'/?page=user&id='.$userid."\n\n";
}
reset($_SESSION['import_attribute']);
// var_dump($_SESSION);exit;
if ($new || (!$new && $_SESSION['overwrite'] == 'yes')) {
Expand Down
23 changes: 16 additions & 7 deletions public_html/lists/admin/actions/processqueue.php
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$progressUrl = $GLOBALS['admin_scheme'].'://'.hostName().$GLOBALS['adminpages'].'/?page=messages&tab=active';

Not sure why hostName() is used here but it can get replaced by using a new variable $adminBaseUrl

Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,8 @@ function finish($flag, $message, $script_stage)

// If plugins have not sent the report, send it the default way
if (!$reportSent) {
$messageWithIntro = s('The following events occured while processing the message queue:')."\n".$message;
$messageWithIntroAndFooter = $messageWithIntro."\n\n".s('To stop receiving these reports read:').' https://resources.phplist.com/system/config/send_queue_processing_report'."\n\n";
$messageWithIntro = '<br/>'.s('The following events occured while processing the message queue:')."<br/>\n".$message;
$messageWithIntroAndFooter = $messageWithIntro."<br/>\n<br/>\n".s('To stop receiving these reports read:').' https://resources.phplist.com/system/config/send_queue_processing_report'."\n\n";
sendReport($subject, $messageWithIntroAndFooter);
}
}
Expand Down Expand Up @@ -458,7 +458,7 @@ function processQueueOutput($message, $logit = 1, $target = 'summary')
flush();
}

$report .= "\n$infostring $message";
$report .= "<br/>\n$infostring $message";
if ($logit) {
logEvent($message);
}
Expand Down Expand Up @@ -715,10 +715,14 @@ function sendEmailTest($messageid, $email)
if (!empty($msgdata['notify_start']) && !isset($msgdata['start_notified'])) {
$notifications = explode(',', $msgdata['notify_start']);
foreach ($notifications as $notification) {
if (defined('ADMIN_WWWROOT')) {
$progressUrl = ADMIN_WWWROOT.'/?page=messages&amp;tab=active';
} else {
$progressUrl = $GLOBALS['admin_scheme'].'://'.hostName().$GLOBALS['adminpages'].'/?page=messages&amp;tab=active';
}
sendMail($notification, s('Campaign started'),
s('phplist has started sending the campaign with subject %s', $msgdata['subject'])."\n\n".
s('to view the progress of this campaign, go to %s://%s', $GLOBALS['admin_scheme'],
hostName().$GLOBALS['adminpages'].'/?page=messages&amp;tab=active'));
s('to view the progress of this campaign, go to %s',$progressUrl));
}
Sql_Query(sprintf('insert ignore into %s (name,id,data) values("start_notified",%d,now())',
$GLOBALS['tables']['messagedata'], $messageid));
Expand Down Expand Up @@ -1369,10 +1373,15 @@ function sendEmailTest($messageid, $email)
if (!empty($msgdata['notify_end']) && !isset($msgdata['end_notified'])) {
$notifications = explode(',', $msgdata['notify_end']);
foreach ($notifications as $notification) {
if (defined('ADMIN_WWWROOT')) {
$resultsUrl = ADMIN_WWWROOT.'/?page=statsoverview&id='.$messageid;
} else {
$resultsUrl = $GLOBALS['admin_scheme'].'://'.hostName().$GLOBALS['adminpages'].'/?page=statsoverview&id='.$messageid;
}
sendMail($notification, s('Message campaign finished'),

s('phpList has finished sending the campaign with subject %s', $msgdata['subject'])."\n\n".
s('to view the statistics of this campaign, go to %s://%s', $GLOBALS['admin_scheme'],
getConfig('website').$GLOBALS['adminpages'].'/?page=statsoverview&id='.$messageid)
s('to view the statistics of this campaign, go to %s',$resultsUrl )
);
}
Sql_Query(sprintf('insert ignore into %s (name,id,data) values("end_notified",%d,now())',
Expand Down
8 changes: 7 additions & 1 deletion public_html/lists/admin/connect.php
Original file line number Diff line number Diff line change
Expand Up @@ -1496,6 +1496,8 @@ function hostName()
{
if (HTTP_HOST) {
return HTTP_HOST;
} elseif (!empty($_SERVER['X_FORWARDED_FOR'])) {
return $_SERVER['X_FORWARDED_FOR'];
} elseif (!empty($_SERVER['HTTP_HOST'])) {
return $_SERVER['HTTP_HOST'];
} else {
Expand All @@ -1507,7 +1509,11 @@ function hostName()
function Redirect($page)
{
$website = hostName();
header('Location: '.$GLOBALS['admin_scheme'].'://'.$website.$GLOBALS['adminpages']."/?page=$page");
if (defined('ADMIN_WWWROOT')) {
header('Location: '.ADMIN_WWWROOT."/?page=$page");
} else {
header('Location: '.$GLOBALS['admin_scheme'].'://'.$website.$GLOBALS['adminpages']."/?page=$page");
}
exit;
}

Expand Down
30 changes: 17 additions & 13 deletions public_html/lists/admin/defaultconfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@

$envHost = getEnv('HOSTNAME');
$envPort = getEnv('PORT');
if (isset($_SERVER['HTTP_HOST'])) {
if (defined('USER_WWWROOT')) {
$domainParts = parse_url(USER_WWWROOT);
$D_website = $domainParts['host'];
if ($domainParts['port'] != 80 && $domainParts['port'] != 443) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$domainParts['port'] will be set only if a port was in the URL. But it seems simpler just to include whatever is in the URL, even if is one of the standard port numbers

if (isset($domainParts['port')) {
    $D_website .= ":".$domainParts['port'];
}

$D_website .= ":".$domainParts['port'];
}
} elseif (isset($_SERVER['HTTP_HOST'])) {
$D_website = $_SERVER['HTTP_HOST'];
} elseif (isset($_SERVER['SERVER_NAME'])) {
$D_website = $_SERVER['SERVER_NAME'];
Expand All @@ -41,7 +47,9 @@
if (preg_match("#^www\.(.*)#i", $D_domain, $regs)) {
$D_domain = $regs[1];
}

if (preg_match("#(.*):(\d+)#i", $D_domain, $regs)) {
$D_domain = $regs[1];
}
// for starters, you want to leave this line as it is.
$default_config = array(

Expand Down Expand Up @@ -299,7 +307,7 @@

// the location of your subscribe script
'subscribeurl' => array(
'value' => $GLOBALS['public_scheme']."://[WEBSITE]$pageroot/?p=subscribe",
'value' => $publicBaseUrl."/?p=subscribe",
'description' => s('URL where subscribers can sign up'),
'type' => 'url',
'allowempty' => 0,
Expand All @@ -308,7 +316,7 @@

// the location of your unsubscribe script:
'unsubscribeurl' => array(
'value' => $GLOBALS['public_scheme']."://[WEBSITE]$pageroot/?p=unsubscribe",
'value' => $publicBaseUrl."/?p=unsubscribe",
'description' => s('URL where subscribers can unsubscribe'),
'type' => 'url',
'allowempty' => 0,
Expand All @@ -318,7 +326,7 @@
//0013076: Blacklisting posibility for unknown users
// the location of your blacklist script:
'blacklisturl' => array(
'value' => $GLOBALS['public_scheme']."://[WEBSITE]$pageroot/?p=donotsend",
'value' => $publicBaseUrl."/?p=donotsend",
'description' => s('URL where unknown users can unsubscribe (do-not-send-list)'),
'type' => 'url',
'allowempty' => 0,
Expand All @@ -327,7 +335,7 @@

// the location of your confirm script:
'confirmationurl' => array(
'value' => $GLOBALS['public_scheme']."://[WEBSITE]$pageroot/?p=confirm",
'value' => $publicBaseUrl."/?p=confirm",
'description' => s('URL where subscribers have to confirm their subscription'),
'type' => 'text',
'allowempty' => 0,
Expand All @@ -336,7 +344,7 @@

// url to change their preferences
'preferencesurl' => array(
'value' => $GLOBALS['public_scheme']."://[WEBSITE]$pageroot/?p=preferences",
'value' => $publicBaseUrl."/?p=preferences",
'description' => s('URL where subscribers can update their details'),
'type' => 'text',
'allowempty' => 0,
Expand All @@ -345,7 +353,7 @@

// url to change their preferences
'forwardurl' => array(
'value' => $GLOBALS['public_scheme']."://[WEBSITE]$pageroot/?p=forward",
'value' => $publicBaseUrl."/?p=forward",
'description' => s('URL for forwarding messages'),
'type' => 'text',
'allowempty' => 0,
Expand All @@ -354,7 +362,7 @@

// url to download vcf card
'vcardurl' => array(
'value' => $GLOBALS['public_scheme']."://[WEBSITE]$pageroot/?p=vcard",
'value' => $publicBaseUrl."/?p=vcard",
'description' => s('URL for downloading vcf card'),
'type' => 'text',
'allowempty' => 0,
Expand All @@ -369,10 +377,6 @@
'category' => 'subscription',
),

// the location of your subscribe script
//"subscribe_baseurl" => array("http://[WEBSITE]$pageroot/",
// "Base URL for public pages","text"),

// the subject of the message
'subscribesubject' => array(
'value' => s('Request for confirmation'),
Expand Down
10 changes: 1 addition & 9 deletions public_html/lists/admin/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -602,14 +602,6 @@ function mb_strtolower($string)
}
}

/*
if (USEFCK) {
$imgdir = getenv("DOCUMENT_ROOT").$GLOBALS["pageroot"].'/'.FCKIMAGES_DIR.'/';
if (!is_dir($imgdir) || !is_writeable ($imgdir)) {
Warn("The FCK image directory does not exist, or is not writable");
}
}
*/

/*
*
Expand Down Expand Up @@ -708,7 +700,7 @@ function mb_strtolower($string)
}

if (WARN_ABOUT_PHP_SETTINGS && !$GLOBALS['commandline']) {
if (strpos(getenv('REQUEST_URI'), $pageroot.'/admin') !== 0) {
if (!defined('USER_WWWROOT') && strpos(getenv('REQUEST_URI'), $pageroot.'/admin') !== 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (!defined('USER_WWWROOT') && strpos(getenv('REQUEST_URI'), $pageroot.'/admin') !== 0) {

This test is of the admin URL not the public URL, but should it still be a valid test when ADMIN_WWWROOT is used?

When using the new USER_WWWROOT and ADMIN_WWWROOT Which value should $pageroot in config.php be set to?

Warn(s(
'The pageroot in your config "%s" does not match the current location "%s". Check your config file.',
$pageroot,
Expand Down
17 changes: 12 additions & 5 deletions public_html/lists/admin/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@
define('NOTIFY_SPAM', 1);
}
if (!defined('CLICKTRACK_LINKMAP')) {
define('CLICKTRACK_LINKMAP', 0);
define('CLICKTRACK_LINKMAP', false);
}
if (!defined('SIGN_WITH_HMAC')) {
define('SIGN_WITH_HMAC', false);
Expand Down Expand Up @@ -713,13 +713,20 @@
$attachment_repository = $tmpdir;
}

if (isset($pageroot)) {
if ($pageroot == '/') {
$pageroot = '';
}
if (defined('USER_WWWROOT')) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (defined('USER_WWWROOT')) {
  $pageroot = USER_WWWROOT;
  $publicBaseUrl = USER_WWWROOT;
} else {

$pageroot is only the path, not the whole URL. But I am not sure that is should be used, as there is ambiguity as to which path is meant - the public or admin. Hiding it with the $publicBaseUrl and $adminBaseUrl variables should mean that it is no longer used.

$pageroot = USER_WWWROOT;
$publicBaseUrl = USER_WWWROOT;
} else {
if (isset($pageroot)) {
if ($pageroot == '/') {
$pageroot = '';
}
} else {
$pageroot = '/lists';
}
$publicBaseUrl = "http://[WEBSITE]$pageroot";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't work for creating link tracking URLs because the variable doesn't have placeholders replaced

$publicBaseUrl = "http://[WEBSITE]$pageroot";

It does work for creating the user tracking image URL because the img element is added to the message before placeholders are replaced.

I suggest moving the handling of USER_WWWROOT to a point where getConfig() can be called to get the WEBSITE. Maybe at the start of defaultconfig.php, where a similar $adminBaseUrl can be set.

It should use the public scheme which is set earlier $public_scheme

}

// as the "admin" in adminpages is hardcoded, don't put it in the config file
$adminpages = $GLOBALS['pageroot'].'/admin';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is using $pageroot taken from the public URL but it is used to create URLs for admin pages. Related to the previous comment.


Expand Down
6 changes: 5 additions & 1 deletion public_html/lists/admin/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,11 @@ function sendAdminPasswordToken($adminId)
$emailBody = $GLOBALS['I18N']->get('Hello').' '.$adminName."\n\n";
$emailBody .= $GLOBALS['I18N']->get('You have requested a new password for phpList.')."\n\n";
$emailBody .= $GLOBALS['I18N']->get('To enter a new one, please visit the following link:')."\n\n";
$emailBody .= sprintf('%s://%s/?page=login&token=%s', $GLOBALS['admin_scheme'], $urlroot, $key)."\n\n";
if (defined('ADMIN_WWWROOT')) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the wrong way around, but should be replaced by using a single variable.

$emailBody .= sprintf('%s://%s/?page=login&token=%s', $GLOBALS['admin_scheme'], $urlroot, $key)."\n\n";
} else {
$emailBody .= sprintf('%s/?page=login&token=%s',ADMIN_WWWROOT, $key)."\n\n";
}
$emailBody .= $GLOBALS['I18N']->get('You have 24 hours left to change your password. After that, your token won\'t be valid.');

if (sendMail($email, $GLOBALS['I18N']->get('New password'), "\n\n".$emailBody, '', '', true)) {
Expand Down
13 changes: 11 additions & 2 deletions public_html/lists/admin/processbounces.php
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,11 @@ function processMessages($link, $max = 3000)
if ($row['user']) {
$userdata = Sql_Fetch_Array_Query("select * from {$tables['user']} where id = ".$row['user']);
}
$report_linkroot = $GLOBALS['admin_scheme'].'://'.$GLOBALS['website'].$GLOBALS['adminpages'];
if (defined('ADMIN_WWWROOT')) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one too is the wrong way around.

$report_linkroot = $GLOBALS['admin_scheme'].'://'.$GLOBALS['website'].$GLOBALS['adminpages'];
} else {
$report_linkroot = ADMIN_WWWROOT;
}

Sql_Query(sprintf('update %s set count = count + 1 where id = %d',
$GLOBALS['tables']['bounceregex'], $rule['id']));
Expand Down Expand Up @@ -797,7 +801,12 @@ function processMessages($link, $max = 3000)
Sql_Query(sprintf('update %s set confirmed = 0 where id = %d', $tables['user'], $user[0]));
$email_req = Sql_Fetch_Row_Query(sprintf('select email from %s where id = %d', $tables['user'],
$user[0]));
$unsubscribed_users .= $email_req[0]."\t\t($cnt)\t\t".$GLOBALS['scheme'].'://'.getConfig('website').$GLOBALS['adminpages'].'/?page=user&amp;id='.$user[0].PHP_EOL;
$unsubscribed_users .= $email_req[0]."\t\t($cnt)\t\t";
if (defined('ADMIN_WWWROOT')) {
$unsubscribed_users .= ADMIN_WWWROOT.'/?page=user&amp;id='.$user[0].PHP_EOL;
} else {
$unsubscribed_users .= $GLOBALS['scheme'].'://'.getConfig('website').$GLOBALS['adminpages'].'/?page=user&amp;id='.$user[0].PHP_EOL;
}
$unsubscribed = 1;
}
if (BLACKLIST_EMAIL_ON_BOUNCE && $cnt >= BLACKLIST_EMAIL_ON_BOUNCE) {
Expand Down
24 changes: 11 additions & 13 deletions public_html/lists/admin/sendemaillib.php
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

    $clicktrack_root = sprintf('%s://%s/lt.php', $GLOBALS['public_scheme'], $website.$GLOBALS['pageroot']);

This needs to change to use $publicBaseUrl .

Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ function sendEmail($messageid, $email, $hash, $htmlpref = 0, $rssitems = array()
You can configure how the credits are added to your pages and emails in your
config file.

Michiel Dethmers, phpList Ltd 2003 - 2013
Michiel Dethmers, phpList Ltd 2003 - 2023
*/
if (!EMAILTEXTCREDITS) {
$html['signature'] = $PoweredByImage; //'<div align="center" id="signature"><a href="https://www.phplist.com"><img src="powerphplist.png" width=88 height=31 title="Powered by PHPlist" alt="Powered by PHPlist" border="0" /></a></div>';
Expand Down Expand Up @@ -427,15 +427,15 @@ function sendEmail($messageid, $email, $hash, $htmlpref = 0, $rssitems = array()
if (ALWAYS_ADD_USERTRACK) {
if (stripos($htmlmessage, '</body>')) {
$htmlmessage = str_replace('</body>',
'<img src="'.$GLOBALS['public_scheme'].'://'.$website.$GLOBALS['pageroot'].'/ut.php?u='.$hash.'&amp;m='.$messageid.'" width="1" height="1" border="0" alt="" /></body>',
'<img src="'.$GLOBALS['publicBaseUrl'].'/ut.php?u='.$hash.'&amp;m='.$messageid.'" width="1" height="1" border="0" alt="" /></body>',
$htmlmessage);
} else {
$htmlmessage .= '<img src="'.$GLOBALS['public_scheme'].'://'.$website.$GLOBALS['pageroot'].'/ut.php?u='.$hash.'&amp;m='.$messageid.'" width="1" height="1" border="0" alt="" />';
$htmlmessage .= '<img src="'.$GLOBALS['publicBaseUrl'].'/ut.php?u='.$hash.'&amp;m='.$messageid.'" width="1" height="1" border="0" alt="" />';
}
} else {
//# can't use str_replace or str_ireplace, because those replace all, and we only want to replace one
$htmlmessage = preg_replace('/\[USERTRACK\]/i',
'<img src="'.$GLOBALS['public_scheme'].'://'.$website.$GLOBALS['pageroot'].'/ut.php?u='.$hash.'&amp;m='.$messageid.'" width="1" height="1" border="0" alt="" />',
'<img src="'.$GLOBALS['publicBaseUrl'].'/ut.php?u='.$hash.'&amp;m='.$messageid.'" width="1" height="1" border="0" alt="" />',
$htmlmessage, 1);
}
// make sure to only include usertrack once, otherwise the stats would go silly
Expand Down Expand Up @@ -544,16 +544,16 @@ function sendEmail($messageid, $email, $hash, $htmlpref = 0, $rssitems = array()
$masked = preg_replace('/=$/', '', $masked);
$masked = urlencode($masked);
if (SIGN_WITH_HMAC) {
$masked .= '&amp;hm='.hash_hmac(HASH_ALGO, sprintf('%s://%s/lt.php?tid=%s', $GLOBALS['public_scheme'], $website.$GLOBALS['pageroot'], $masked), HMACKEY);
$masked .= '&amp;hm='.hash_hmac(HASH_ALGO, sprintf('%s/lt.php?tid=%s', $GLOBALS['publicBaseUrl'], $masked), HMACKEY);
}

## this may need removing, CLICKTRACK_LINKMAP is badly documented, so slightly unclear how this works
if (!CLICKTRACK_LINKMAP) {
$newlink = sprintf('<a %shref="%s://%s/lt.php?tid=%s" %s>%s</a>', $links[1][$i],
$GLOBALS['public_scheme'], $website.$GLOBALS['pageroot'], $masked, $links[4][$i],
$newlink = sprintf('<a %shref="%s/lt.php?tid=%s" %s>%s</a>', $links[1][$i],
$GLOBALS['publicBaseUrl'], $masked, $links[4][$i],
$links[5][$i]);
} else {
$newlink = sprintf('<a %shref="%s://%s%s" %s>%s</a>', $links[1][$i], $GLOBALS['public_scheme'],
$website.CLICKTRACK_LINKMAP, $masked, $links[4][$i], $links[5][$i]);
$newlink = sprintf('<a %shref="%s%s" %s>%s</a>', $links[1][$i], $GLOBALS['publicBaseUrl'].CLICKTRACK_LINKMAP, $masked, $links[4][$i], $links[5][$i]);
}
$htmlmessage = str_replace($links[0][$i], $newlink, $htmlmessage);
}
Expand Down Expand Up @@ -588,13 +588,11 @@ function sendEmail($messageid, $email, $hash, $htmlpref = 0, $rssitems = array()
}

if (!CLICKTRACK_LINKMAP) {
$newlinks[$linkUUID] = sprintf('%s://%s/lt.php?tid=%s', $GLOBALS['public_scheme'],
$website.$GLOBALS['pageroot'], $masked);
$newlinks[$linkUUID] = sprintf('%s/lt.php?tid=%s', $GLOBALS['publicBaseUrl'], $masked);
} else {
$newlinks[$linkUUID] = sprintf('%s://%s%s', $GLOBALS['public_scheme'], $website.CLICKTRACK_LINKMAP,
$newlinks[$linkUUID] = sprintf('%s%s', $GLOBALS['publicBaseUrl'].CLICKTRACK_LINKMAP,
$masked);
}

$textmessage = str_replace($links[1][$i], '[%%%'.$linkUUID.'%%%]', $textmessage);
}
}
Expand Down