Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Q
question2answer
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
outils
question2answer
Commits
ce5a5fce
Commit
ce5a5fce
authored
9 years ago
by
Scott
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Optimize qa_is_ip_blocked
10x faster with many blocked IPs
parent
3fc51a92
dev
…
3113-openbar-authentification
3241-delete-all-the-question
3242-password-removed
3414-no-change-mail
3414-stop-mail-send
main
v1.8.6
v1.8.5
v1.8.4
v1.8.3
v1.8.2
v1.8.1
v1.8.0
v1.8.0-beta2
v1.8.0-beta1
No related merge requests found
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
12 deletions
+25
-12
limits.php
qa-include/app/limits.php
+20
-8
qa-base.php
qa-include/qa-base.php
+5
-4
No files found.
qa-include/app/limits.php
View file @
ce5a5fce
...
...
@@ -134,20 +134,32 @@
}
/**
* Determine whether the requesting IP address has been blocked from write operations.
* @return bool
*/
function
qa_is_ip_blocked
()
/*
Return whether the requesting IP address has been blocked from write operations
*/
{
if
(
qa_to_override
(
__FUNCTION__
))
{
$args
=
func_get_args
();
return
qa_call_override
(
__FUNCTION__
,
$args
);
}
$blockipclauses
=
qa_block_ips_explode
(
qa_opt
(
'block_ips_write'
))
;
global
$qa_curr_ip_blocked
;
foreach
(
$blockipclauses
as
$blockipclause
)
if
(
qa_block_ip_match
(
qa_remote_ip_address
(),
$blockipclause
))
return
true
;
// return cached value early
if
(
isset
(
$qa_curr_ip_blocked
))
return
$qa_curr_ip_blocked
;
return
false
;
$qa_curr_ip_blocked
=
false
;
$blockipclauses
=
qa_block_ips_explode
(
qa_opt
(
'block_ips_write'
));
$ip
=
qa_remote_ip_address
();
foreach
(
$blockipclauses
as
$blockipclause
)
{
if
(
qa_block_ip_match
(
$ip
,
$blockipclause
))
{
$qa_curr_ip_blocked
=
true
;
break
;
}
}
return
$qa_curr_ip_blocked
;
}
...
...
This diff is collapsed.
Click to expand it.
qa-include/qa-base.php
View file @
ce5a5fce
...
...
@@ -1048,14 +1048,15 @@
}
/**
* Determine the remote IP address of the user accessing the site.
* @return mixed String representing IP if it's available, or null otherwise.
*/
function
qa_remote_ip_address
()
/*
Return the remote IP address of the user accessing the site, if it's available, or null otherwise
*/
{
if
(
qa_to_override
(
__FUNCTION__
))
{
$args
=
func_get_args
();
return
qa_call_override
(
__FUNCTION__
,
$args
);
}
return
@
$_SERVER
[
'REMOTE_ADDR'
]
;
return
isset
(
$_SERVER
[
'REMOTE_ADDR'
])
?
$_SERVER
[
'REMOTE_ADDR'
]
:
null
;
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment