Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
eterban
Project
Project
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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
eterban
Commits
4cfb9f45
Commit
4cfb9f45
authored
Jul 20, 2026
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
web: report undelivered unban requests
parent
a9efc009
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
74 additions
and
82 deletions
+74
-82
ban.php
ban-internal-server/data/www/ban.php
+2
-22
unban.php
ban-internal-server/data/www/unban.php
+35
-19
ban.php
ban-server/data/www/ban.php
+2
-22
unban.php
ban-server/data/www/unban.php
+35
-19
No files found.
ban-internal-server/data/www/ban.php
View file @
4cfb9f45
//Где сменить IP-адреса серверов
<?php
$ip
=
$_SERVER
[
'REMOTE_ADDR'
];
echo
"You are banned!, Your IP:
$ip
<br>"
;
$settings
=
'/etc/eterban/settings.ini'
;
$ini_array
=
parse_ini_file
(
"
$settings
"
);
$host_redis
=
$ini_array
[
'redis_server'
];
$redis
=
new
Redis
;
$redis
->
pconnect
(
$host_redis
,
6379
);
$key
=
$redis
->
get
(
$ip
);
?>
<button
onclick=
"unban()"
>
Unban
</button>
<button
onclick=
"unban()"
>
Unban
</button>
<script
type=
"text/javascript"
src=
"//cdnjs.cloudflare.com/ajax/libs/jquery/2.2.0/jquery.js"
></script>
<script>
<script>
function
unban
(){
function
unban
(){
/*$.get("unban.php?&key=
<?php
echo
$key
;
?>
", function(data, status){
window
.
location
.
href
=
"unban.php"
;
});*/
window
.
location
.
href
=
"unban.php?key=
<?php
echo
$key
;
?>
"
;
}
}
</script>
</script>
\ No newline at end of file
ban-internal-server/data/www/unban.php
View file @
4cfb9f45
<?php
<?php
$ip
=
$_SERVER
[
'REMOTE_ADDR'
];
header
(
'Content-Type: text/html; charset=utf-8'
);
$old_addr
=
$_SERVER
[
'HTTP_REFERER'
];
$settings
=
'/etc/eterban/settings.ini'
;
$ip
=
$_SERVER
[
'REMOTE_ADDR'
]
??
''
;
$ini_array
=
parse_ini_file
(
"
$settings
"
);
$settings
=
parse_ini_file
(
'/etc/eterban/settings.ini'
);
//print_r($ini_array);
$host_redis
=
is_array
(
$settings
)
?
(
$settings
[
'redis_server'
]
??
''
)
:
''
;
//print_r($ini_array['redis_server']);
$hostname
=
is_array
(
$settings
)
?
(
$settings
[
'hostname'
]
??
''
)
:
''
;
$host_redis
=
$ini_array
[
'redis_server'
];
//print_r($host_redis);
if
(
!
filter_var
(
$ip
,
FILTER_VALIDATE_IP
)
||
empty
(
$host_redis
))
{
$hostname
=
$ini_array
[
'hostname'
];
http_response_code
(
503
);
if
(
empty
(
$hostname
))
{
error_log
(
'eterban: invalid client IP or Redis configuration for web unban'
);
$hostname
=
gethostname
();
exit
(
'Unban service is temporarily unavailable.'
);
//print_r ($hostname);
}
}
$redis
=
new
Redis
();
if
(
empty
(
$hostname
))
{
$redis
->
pconnect
(
$host_redis
,
6379
);
$hostname
=
gethostname
();
$redis
->
publish
(
'unban'
,
$ip
);
}
$redis
->
publish
(
'by'
,
$ip
.
" was unblocked by
$hostname
"
);
$redis
->
close
();
try
{
echo
"Wait 5 seconds, please"
$redis
=
new
Redis
();
if
(
!
$redis
->
connect
(
$host_redis
,
6379
,
2.5
))
{
throw
new
RedisException
(
'connection failed'
);
}
$subscribers
=
$redis
->
publish
(
'unban'
,
$ip
);
if
(
$subscribers
<
1
)
{
throw
new
RedisException
(
'no Redis subscribers'
);
}
$redis
->
publish
(
'by'
,
$ip
.
' was unblocked by '
.
$hostname
);
$redis
->
close
();
}
catch
(
RedisException
$error
)
{
http_response_code
(
503
);
error_log
(
'eterban: web unban request was not delivered: '
.
$error
->
getMessage
());
exit
(
'Unban service is temporarily unavailable. Please contact an administrator.'
);
}
echo
'Unban request accepted. Wait 5 seconds, please.'
;
?>
?>
<script>
<script>
function
update
()
function
update
()
...
...
ban-server/data/www/ban.php
View file @
4cfb9f45
//Где сменить IP-адреса серверов
<?php
$ip
=
$_SERVER
[
'REMOTE_ADDR'
];
echo
"You are banned!, Your IP:
$ip
<br>"
;
$settings
=
'/etc/eterban/settings.ini'
;
$ini_array
=
parse_ini_file
(
"
$settings
"
);
$host_redis
=
$ini_array
[
'redis_server'
];
$redis
=
new
Redis
;
$redis
->
pconnect
(
$host_redis
,
6379
);
$key
=
$redis
->
get
(
$ip
);
?>
<button
onclick=
"unban()"
>
Unban
</button>
<button
onclick=
"unban()"
>
Unban
</button>
<script
type=
"text/javascript"
src=
"//cdnjs.cloudflare.com/ajax/libs/jquery/2.2.0/jquery.js"
></script>
<script>
<script>
function
unban
(){
function
unban
(){
/*$.get("unban.php?&key=
<?php
echo
$key
;
?>
", function(data, status){
window
.
location
.
href
=
"unban.php"
;
});*/
window
.
location
.
href
=
"unban.php?key=
<?php
echo
$key
;
?>
"
;
}
}
</script>
</script>
\ No newline at end of file
ban-server/data/www/unban.php
View file @
4cfb9f45
<?php
<?php
$ip
=
$_SERVER
[
'REMOTE_ADDR'
];
header
(
'Content-Type: text/html; charset=utf-8'
);
$old_addr
=
$_SERVER
[
'HTTP_REFERER'
];
$settings
=
'/etc/eterban/settings.ini'
;
$ip
=
$_SERVER
[
'REMOTE_ADDR'
]
??
''
;
$ini_array
=
parse_ini_file
(
"
$settings
"
);
$settings
=
parse_ini_file
(
'/etc/eterban/settings.ini'
);
//print_r($ini_array);
$host_redis
=
is_array
(
$settings
)
?
(
$settings
[
'redis_server'
]
??
''
)
:
''
;
//print_r($ini_array['redis_server']);
$hostname
=
is_array
(
$settings
)
?
(
$settings
[
'hostname'
]
??
''
)
:
''
;
$host_redis
=
$ini_array
[
'redis_server'
];
//print_r($host_redis);
if
(
!
filter_var
(
$ip
,
FILTER_VALIDATE_IP
)
||
empty
(
$host_redis
))
{
$hostname
=
$ini_array
[
'hostname'
];
http_response_code
(
503
);
if
(
empty
(
$hostname
))
{
error_log
(
'eterban: invalid client IP or Redis configuration for web unban'
);
$hostname
=
gethostname
();
exit
(
'Unban service is temporarily unavailable.'
);
//print_r ($hostname);
}
}
$redis
=
new
Redis
();
if
(
empty
(
$hostname
))
{
$redis
->
pconnect
(
$host_redis
,
6379
);
$hostname
=
gethostname
();
$redis
->
publish
(
'unban'
,
$ip
);
}
$redis
->
publish
(
'by'
,
$ip
.
" was unblocked by
$hostname
"
);
$redis
->
close
();
try
{
echo
"Wait 5 seconds, please"
$redis
=
new
Redis
();
if
(
!
$redis
->
connect
(
$host_redis
,
6379
,
2.5
))
{
throw
new
RedisException
(
'connection failed'
);
}
$subscribers
=
$redis
->
publish
(
'unban'
,
$ip
);
if
(
$subscribers
<
1
)
{
throw
new
RedisException
(
'no Redis subscribers'
);
}
$redis
->
publish
(
'by'
,
$ip
.
' was unblocked by '
.
$hostname
);
$redis
->
close
();
}
catch
(
RedisException
$error
)
{
http_response_code
(
503
);
error_log
(
'eterban: web unban request was not delivered: '
.
$error
->
getMessage
());
exit
(
'Unban service is temporarily unavailable. Please contact an administrator.'
);
}
echo
'Unban request accepted. Wait 5 seconds, please.'
;
?>
?>
<script>
<script>
function
update
()
function
update
()
...
...
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