forked from github/kensanata.oddmuse
Replace GetRemoteHost with $q->remote_addr()
This commit is contained in:
@@ -39,7 +39,7 @@ sub AdminPowerDelete {
|
||||
} else {
|
||||
print $q->p(GetPageLink($id) . ' ' . T('deleted'));
|
||||
WriteRcLog($id, Ts('Deleted %s', $id), 0, $Page{revision},
|
||||
GetParam('username', ''), GetRemoteHost(), $Page{languages},
|
||||
GetParam('username', ''), $q->remote_addr(), $Page{languages},
|
||||
GetCluster($Page{text}));
|
||||
}
|
||||
# Regenerate index on next request
|
||||
@@ -88,10 +88,10 @@ sub AdminPowerRename {
|
||||
# RecentChanges
|
||||
OpenPage($new);
|
||||
WriteRcLog($id, Ts('Renamed to %s', $new), 0, $Page{revision},
|
||||
GetParam('username', ''), GetRemoteHost(), $Page{languages},
|
||||
GetParam('username', ''), $q->remote_addr(), $Page{languages},
|
||||
GetCluster($Page{text}));
|
||||
WriteRcLog($new, Ts('Renamed from %s', $id), 0, $Page{revision},
|
||||
GetParam('username', ''), GetRemoteHost(), $Page{languages},
|
||||
GetParam('username', ''), $q->remote_addr(), $Page{languages},
|
||||
GetCluster($Page{text}));
|
||||
print $q->p(Tss('Renamed %1 to %2.', GetPageLink($id), GetPageLink($new)));
|
||||
ReleaseLock();
|
||||
|
||||
@@ -29,7 +29,7 @@ sub BanQuickNewUserIsBanned {
|
||||
if (not $rule
|
||||
and $SurgeProtection # need surge protection
|
||||
and GetParam('title')) {
|
||||
my $name = GetParam('username', GetRemoteHost());
|
||||
my $name = GetParam('username', $q->remote_addr());
|
||||
my @entries = @{$RecentVisitors{$name}};
|
||||
# $entry[0] is $Now after AddRecentVisitor
|
||||
my $ts = $entries[1];
|
||||
|
||||
@@ -28,7 +28,7 @@ push(@MyInitVariables, \&DraftInit);
|
||||
sub DraftInit {
|
||||
if (GetParam('Draft', '')) {
|
||||
SetParam('action', 'draft') ; # Draft button used
|
||||
} elsif (-f "$DraftDir/" . GetParam('username', GetRemoteHost()) # draft exists
|
||||
} elsif (-f "$DraftDir/" . GetParam('username', $q->remote_addr()) # draft exists
|
||||
and $FooterNote !~ /action=draft/) { # take care of mod_perl persistence
|
||||
$FooterNote = $q->p(ScriptLink('action=draft', T('Recover Draft'))) . $FooterNote;
|
||||
}
|
||||
@@ -38,7 +38,7 @@ $Action{draft} = \&DoDraft;
|
||||
|
||||
sub DoDraft {
|
||||
my $id = shift;
|
||||
my $draft = $DraftDir . '/' . GetParam('username', GetRemoteHost());
|
||||
my $draft = $DraftDir . '/' . GetParam('username', $q->remote_addr());
|
||||
if ($id) {
|
||||
my $text = GetParam('text', '');
|
||||
ReportError(T('No text to save'), '400 BAD REQUEST') unless $text;
|
||||
|
||||
@@ -47,6 +47,6 @@ sub LogWrite {
|
||||
my $rule = shift;
|
||||
my $id = $OpenPageName || GetId();
|
||||
AppendStringToFile($BannedFile,
|
||||
join("\t", TimeToW3($Now), GetRemoteHost(), $id, $rule)
|
||||
join("\t", TimeToW3($Now), $q->remote_addr(), $id, $rule)
|
||||
. "\n");
|
||||
}
|
||||
|
||||
@@ -36,10 +36,10 @@ $Action{$SelfBan} = \&DoSelfBan;
|
||||
|
||||
sub DoSelfBan {
|
||||
my $date = &TimeToText($Now);
|
||||
my $str = '^' . quotemeta(GetRemoteHost());
|
||||
my $str = '^' . quotemeta($q->remote_addr());
|
||||
OpenPage($BannedHosts);
|
||||
Save ($BannedHosts, $Page{text} . "\n\nself-ban on $date\n $str",
|
||||
Ts("Self-ban by %s", GetRemoteHost()), 1); # minor edit
|
||||
Ts("Self-ban by %s", $q->remote_addr()), 1); # minor edit
|
||||
ReportError(T("You have banned your own IP."));
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ sub OpenProxyNewDoEdit {
|
||||
|
||||
sub BanOpenProxy {
|
||||
my ($force) = @_;
|
||||
my $ip = GetRemoteHost();
|
||||
my $ip = $q->remote_addr();
|
||||
my $limit = 60*60*24*30; # rescan after 30 days
|
||||
# Only check each IP address once a month
|
||||
my %proxy = split(/\s+/, ReadFile($OpenProxies));
|
||||
|
||||
@@ -252,7 +252,7 @@ sub ReCaptchaCheckAnswer {
|
||||
eval "use Captcha::reCAPTCHA";
|
||||
my $result = Captcha::reCAPTCHA->new()->check_answer(
|
||||
$ReCaptchaPrivateKey,
|
||||
GetRemoteHost(),
|
||||
$q->remote_addr(),
|
||||
GetParam('recaptcha_challenge_field'),
|
||||
GetParam('recaptcha_response_field')
|
||||
);
|
||||
|
||||
@@ -425,7 +425,7 @@ sub StaticNewDoRollback {
|
||||
} elsif (!UserCanEdit($id, 1)) {
|
||||
print Ts('Editing not allowed for %s.', $id), $q->br();
|
||||
} else {
|
||||
Save($id, $text, Ts('Rollback to %s', TimeToText($to)), $minor, ($Page{host} ne GetRemoteHost()));
|
||||
Save($id, $text, Ts('Rollback to %s', TimeToText($to)), $minor, ($Page{host} ne $q->remote_addr()));
|
||||
StaticDeleteFile($id);
|
||||
print Ts('%s rolled back', GetPageLink($id)), ($ts ? ' ' . Ts('to %s', TimeToText($to)) : ''), $q->br();
|
||||
}
|
||||
|
||||
16
wiki.pl
16
wiki.pl
@@ -2087,7 +2087,7 @@ sub DoRollback {
|
||||
} elsif (not UserIsEditor() and my $rule = BannedContent($text)) {
|
||||
print Ts('Rollback of %s would restore banned content.', $id), $rule, $q->br();
|
||||
} else {
|
||||
Save($id, $text, Ts('Rollback to %s', TimeToText($to)), $minor, ($Page{host} ne GetRemoteHost()));
|
||||
Save($id, $text, Ts('Rollback to %s', TimeToText($to)), $minor, ($Page{host} ne $q->remote_addr()));
|
||||
print Ts('%s rolled back', GetPageLink($id)), ($ts ? ' ' . Ts('to %s', TimeToText($to)) : ''), $q->br();
|
||||
}
|
||||
}
|
||||
@@ -2180,10 +2180,6 @@ sub ScriptLinkDiff {
|
||||
return ScriptLink($action, $text, 'diff');
|
||||
}
|
||||
|
||||
sub GetRemoteHost {
|
||||
return $ENV{REMOTE_ADDR};
|
||||
}
|
||||
|
||||
sub GetAuthor {
|
||||
my ($host, $username) = @_;
|
||||
return $username . ' ' . Ts('from %s', $host) if $username and $host;
|
||||
@@ -3199,7 +3195,7 @@ sub UserCanEdit {
|
||||
|
||||
sub UserIsBanned {
|
||||
return 0 if GetParam('action', '') eq 'password'; # login is always ok
|
||||
my $host = GetRemoteHost();
|
||||
my $host = $q->remote_addr();
|
||||
foreach (split(/\n/, GetPageContent($BannedHosts))) {
|
||||
if (/^\s*([^#]\S+)/) { # all lines except empty lines and comments, trim whitespace
|
||||
my $regexp = $1;
|
||||
@@ -3563,7 +3559,7 @@ sub Replace {
|
||||
};
|
||||
if (s/$from/$replacement->()/gei) { # allows use of backreferences
|
||||
push (@result, $id);
|
||||
Save($id, $_, $from . ' → ' . $to, 1, ($Page{host} ne GetRemoteHost()));
|
||||
Save($id, $_, $from . ' → ' . $to, 1, ($Page{host} ne $q->remote_addr()));
|
||||
}
|
||||
}
|
||||
ReleaseLock();
|
||||
@@ -3642,7 +3638,7 @@ sub DoPost {
|
||||
if ($oldrev) { # the first author (no old revision) is not considered to be "new"
|
||||
# prefer usernames for potential new author detection
|
||||
$newAuthor = 1 if not $Page{username} or $Page{username} ne GetParam('username', '');
|
||||
$newAuthor = 1 if not GetRemoteHost() or not $Page{host} or GetRemoteHost() ne $Page{host};
|
||||
$newAuthor = 1 if not $q->remote_addr() or not $Page{host} or $q->remote_addr() ne $Page{host};
|
||||
}
|
||||
my $oldtime = $Page{ts};
|
||||
my $myoldtime = GetParam('oldtime', ''); # maybe empty!
|
||||
@@ -3716,7 +3712,7 @@ sub AddComment {
|
||||
sub Save { # call within lock, with opened page
|
||||
my ($id, $new, $summary, $minor, $upload) = @_;
|
||||
my $user = GetParam('username', '');
|
||||
my $host = GetRemoteHost();
|
||||
my $host = $q->remote_addr();
|
||||
my $revision = $Page{revision} + 1;
|
||||
my $old = $Page{text};
|
||||
my $olddiff = $Page{'diff-major'} == '1' ? $Page{'diff-minor'} : $Page{'diff-major'};
|
||||
@@ -3944,7 +3940,7 @@ sub DoDebug {
|
||||
|
||||
sub DoSurgeProtection {
|
||||
return unless $SurgeProtection;
|
||||
my $name = GetParam('username', GetRemoteHost());
|
||||
my $name = GetParam('username', $q->remote_addr());
|
||||
return unless $name;
|
||||
ReadRecentVisitors();
|
||||
AddRecentVisitor($name);
|
||||
|
||||
Reference in New Issue
Block a user