-
-
Notifications
You must be signed in to change notification settings - Fork 271
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
base: main
Are you sure you want to change the base?
Changes from 12 commits
fc33876
98ad57f
66bf671
8676f77
02faef6
dcff53c
bb458e6
27c00fb
3771d43
a26eccf
0b472cd
e5a17ad
b7e3265
d853540
da74e1a
66a1a78
7a36207
6cbfdec
a1e9bc3
0b36b40
0dadc39
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Not sure why hostName() is used here but it can get replaced by using a new variable |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
$D_website .= ":".$domainParts['port']; | ||
} | ||
} elseif (isset($_SERVER['HTTP_HOST'])) { | ||
$D_website = $_SERVER['HTTP_HOST']; | ||
} elseif (isset($_SERVER['SERVER_NAME'])) { | ||
$D_website = $_SERVER['SERVER_NAME']; | ||
|
@@ -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( | ||
|
||
|
@@ -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, | ||
|
@@ -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, | ||
|
@@ -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, | ||
|
@@ -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, | ||
|
@@ -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, | ||
|
@@ -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, | ||
|
@@ -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, | ||
|
@@ -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'), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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"); | ||
} | ||
} | ||
*/ | ||
|
||
/* | ||
* | ||
|
@@ -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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This test is of the admin URL not the public URL, but should it still be a valid test when When using the new |
||
Warn(s( | ||
'The pageroot in your config "%s" does not match the current location "%s". Check your config file.', | ||
$pageroot, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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); | ||
|
@@ -713,13 +713,20 @@ | |
$attachment_repository = $tmpdir; | ||
} | ||
|
||
if (isset($pageroot)) { | ||
if ($pageroot == '/') { | ||
$pageroot = ''; | ||
} | ||
if (defined('USER_WWWROOT')) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
$pageroot = USER_WWWROOT; | ||
$publicBaseUrl = USER_WWWROOT; | ||
} else { | ||
if (isset($pageroot)) { | ||
if ($pageroot == '/') { | ||
$pageroot = ''; | ||
} | ||
} else { | ||
$pageroot = '/lists'; | ||
} | ||
$publicBaseUrl = "http://[WEBSITE]$pageroot"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
It does work for creating the user tracking image URL because the 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 It should use the public scheme which is set earlier |
||
} | ||
|
||
// as the "admin" in adminpages is hardcoded, don't put it in the config file | ||
$adminpages = $GLOBALS['pageroot'].'/admin'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is using |
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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')) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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)) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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')) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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'])); | ||
|
@@ -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&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&id='.$user[0].PHP_EOL; | ||
} else { | ||
$unsubscribed_users .= $GLOBALS['scheme'].'://'.getConfig('website').$GLOBALS['adminpages'].'/?page=user&id='.$user[0].PHP_EOL; | ||
} | ||
$unsubscribed = 1; | ||
} | ||
if (BLACKLIST_EMAIL_ON_BOUNCE && $cnt >= BLACKLIST_EMAIL_ON_BOUNCE) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This needs to change to use |
There was a problem hiding this comment.
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