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
7597bced
Commit
7597bced
authored
Jan 15, 2019
by
Scott
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Controller: IP page
parent
4234de91
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
161 additions
and
153 deletions
+161
-153
page.php
qa-include/app/page.php
+3
-1
Ip.php
qa-src/Controllers/User/Ip.php
+158
-152
No files found.
qa-include/app/page.php
View file @
7597bced
...
@@ -438,7 +438,6 @@ function qa_page_routing()
...
@@ -438,7 +438,6 @@ function qa_page_routing()
'feedback'
=>
'pages/feedback.php'
,
'feedback'
=>
'pages/feedback.php'
,
'forgot'
=>
'pages/forgot.php'
,
'forgot'
=>
'pages/forgot.php'
,
'hot/'
=>
'pages/hot.php'
,
'hot/'
=>
'pages/hot.php'
,
'ip/'
=>
'pages/ip.php'
,
'login'
=>
'pages/login.php'
,
'login'
=>
'pages/login.php'
,
'logout'
=>
'pages/logout.php'
,
'logout'
=>
'pages/logout.php'
,
'messages/'
=>
'pages/messages.php'
,
'messages/'
=>
'pages/messages.php'
,
...
@@ -474,6 +473,9 @@ function qa_routing_config()
...
@@ -474,6 +473,9 @@ function qa_routing_config()
$router
->
addRoute
(
'user-blocked'
,
'get'
,
'users/blocked'
,
'\Q2A\Controllers\User\UsersList'
,
'blocked'
);
$router
->
addRoute
(
'user-blocked'
,
'get'
,
'users/blocked'
,
'\Q2A\Controllers\User\UsersList'
,
'blocked'
);
$router
->
addRoute
(
'user-new'
,
'get'
,
'users/new'
,
'\Q2A\Controllers\User\UsersList'
,
'newest'
);
$router
->
addRoute
(
'user-new'
,
'get'
,
'users/new'
,
'\Q2A\Controllers\User\UsersList'
,
'newest'
);
$router
->
addRoute
(
'user-special'
,
'get'
,
'users/special'
,
'\Q2A\Controllers\User\UsersList'
,
'special'
);
$router
->
addRoute
(
'user-special'
,
'get'
,
'users/special'
,
'\Q2A\Controllers\User\UsersList'
,
'special'
);
$router
->
addRoute
(
'ip'
,
'get'
,
'ip/{str}'
,
'\Q2A\Controllers\User\Ip'
,
'address'
);
$router
->
addRoute
(
'ip'
,
'post'
,
'ip/{str}'
,
'\Q2A\Controllers\User\Ip'
,
'address'
);
}
}
...
...
qa-
include/pages/i
p.php
→
qa-
src/Controllers/User/I
p.php
View file @
7597bced
...
@@ -3,9 +3,6 @@
...
@@ -3,9 +3,6 @@
Question2Answer by Gideon Greenspan and contributors
Question2Answer by Gideon Greenspan and contributors
http://www.question2answer.org/
http://www.question2answer.org/
Description: Controller for page showing recent activity for an IP address
This program is free software; you can redistribute it and/or
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
as published by the Free Software Foundation; either version 2
...
@@ -19,213 +16,222 @@
...
@@ -19,213 +16,222 @@
More about this license: http://www.question2answer.org/license.php
More about this license: http://www.question2answer.org/license.php
*/
*/
if
(
!
defined
(
'QA_VERSION'
))
{
// don't allow this page to be requested directly from browser
namespace
Q2A\Controllers\User
;
header
(
'Location: ../../'
);
exit
;
}
require_once
QA_INCLUDE_DIR
.
'db/selects.php'
;
use
Q2A\Auth\NoPermissionException
;
require_once
QA_INCLUDE_DIR
.
'app/format.php'
;
/**
* Controller for page showing recent activity for an IP address
*/
class
Ip
extends
\Q2A\Controllers\BaseController
{
public
function
__construct
()
{
require_once
QA_INCLUDE_DIR
.
'db/selects.php'
;
require_once
QA_INCLUDE_DIR
.
'app/format.php'
;
$ip
=
qa_request_part
(
1
);
// picked up from qa-page.php
parent
::
__construct
();
if
(
filter_var
(
$ip
,
FILTER_VALIDATE_IP
)
===
false
)
}
return
include
QA_INCLUDE_DIR
.
'qa-page-not-found.php'
;
public
function
address
(
$ip
)
{
if
(
filter_var
(
$ip
,
FILTER_VALIDATE_IP
)
===
false
)
return
include
QA_INCLUDE_DIR
.
'qa-page-not-found.php'
;
// Find recently (hidden, queued or not) questions, answers, comments and edits for this IP
$userid
=
qa_get_logged_in_userid
();
// Find recently (hidden, queued or not) questions, answers, comments and edits for this IP
list
(
$qs
,
$qs_queued
,
$qs_hidden
,
$a_qs
,
$a_queued_qs
,
$a_hidden_qs
,
$c_qs
,
$c_queued_qs
,
$c_hidden_qs
,
$edit_qs
)
=
$userid
=
qa_get_logged_in_userid
();
qa_db_select_with_pending
(
qa_db_qs_selectspec
(
$userid
,
'created'
,
0
,
null
,
$ip
,
false
),
qa_db_qs_selectspec
(
$userid
,
'created'
,
0
,
null
,
$ip
,
'Q_QUEUED'
),
qa_db_qs_selectspec
(
$userid
,
'created'
,
0
,
null
,
$ip
,
'Q_HIDDEN'
,
true
),
qa_db_recent_a_qs_selectspec
(
$userid
,
0
,
null
,
$ip
,
false
),
qa_db_recent_a_qs_selectspec
(
$userid
,
0
,
null
,
$ip
,
'A_QUEUED'
),
qa_db_recent_a_qs_selectspec
(
$userid
,
0
,
null
,
$ip
,
'A_HIDDEN'
,
true
),
qa_db_recent_c_qs_selectspec
(
$userid
,
0
,
null
,
$ip
,
false
),
qa_db_recent_c_qs_selectspec
(
$userid
,
0
,
null
,
$ip
,
'C_QUEUED'
),
qa_db_recent_c_qs_selectspec
(
$userid
,
0
,
null
,
$ip
,
'C_HIDDEN'
,
true
),
qa_db_recent_edit_qs_selectspec
(
$userid
,
0
,
null
,
$ip
,
false
)
);
list
(
$qs
,
$qs_queued
,
$qs_hidden
,
$a_qs
,
$a_queued_qs
,
$a_hidden_qs
,
$c_qs
,
$c_queued_qs
,
$c_hidden_qs
,
$edit_qs
)
=
qa_db_select_with_pending
(
qa_db_qs_selectspec
(
$userid
,
'created'
,
0
,
null
,
$ip
,
false
),
qa_db_qs_selectspec
(
$userid
,
'created'
,
0
,
null
,
$ip
,
'Q_QUEUED'
),
qa_db_qs_selectspec
(
$userid
,
'created'
,
0
,
null
,
$ip
,
'Q_HIDDEN'
,
true
),
qa_db_recent_a_qs_selectspec
(
$userid
,
0
,
null
,
$ip
,
false
),
qa_db_recent_a_qs_selectspec
(
$userid
,
0
,
null
,
$ip
,
'A_QUEUED'
),
qa_db_recent_a_qs_selectspec
(
$userid
,
0
,
null
,
$ip
,
'A_HIDDEN'
,
true
),
qa_db_recent_c_qs_selectspec
(
$userid
,
0
,
null
,
$ip
,
false
),
qa_db_recent_c_qs_selectspec
(
$userid
,
0
,
null
,
$ip
,
'C_QUEUED'
),
qa_db_recent_c_qs_selectspec
(
$userid
,
0
,
null
,
$ip
,
'C_HIDDEN'
,
true
),
qa_db_recent_edit_qs_selectspec
(
$userid
,
0
,
null
,
$ip
,
false
)
);
// Check we have permission to view this page, and whether we can block or unblock IPs
if
(
qa_user_maximum_permit_error
(
'permit_anon_view_ips'
))
{
// Check we have permission to view this page, and whether we can block or unblock IPs
$qa_content
=
qa_content_prepare
();
$qa_content
[
'error'
]
=
qa_lang_html
(
'users/no_permission'
);
return
$qa_content
;
}
$blockable
=
qa_user_level_maximum
()
>=
QA_USER_LEVEL_MODERATOR
;
// allow moderator in one category to block across all categories
if
(
qa_user_maximum_permit_error
(
'permit_anon_view_ips'
))
{
throw
new
NoPermissionException
;
}
$blockable
=
qa_user_level_maximum
()
>=
QA_USER_LEVEL_MODERATOR
;
// allow moderator in one category to block across all categories
// Perform blocking or unblocking operations as appropriate
if
(
qa_clicked
(
'doblock'
)
||
qa_clicked
(
'dounblock'
)
||
qa_clicked
(
'dohideall'
))
{
// Perform blocking or unblocking operations as appropriate
if
(
!
qa_check_form_security_code
(
'ip-'
.
$ip
,
qa_post_text
(
'code'
)))
$pageerror
=
qa_lang_html
(
'misc/form_security_again'
);
elseif
(
$blockable
)
{
if
(
qa_clicked
(
'doblock'
)
||
qa_clicked
(
'dounblock'
)
||
qa_clicked
(
'dohideall'
))
{
if
(
qa_clicked
(
'doblock'
))
{
if
(
!
qa_check_form_security_code
(
'ip-'
.
$ip
,
qa_post_text
(
'code'
)))
$oldblocked
=
qa_opt
(
'block_ips_write'
);
$pageerror
=
qa_lang_html
(
'misc/form_security_again'
);
qa_set_option
(
'block_ips_write'
,
(
strlen
(
$oldblocked
)
?
(
$oldblocked
.
' , '
)
:
''
)
.
$ip
);
qa_report_event
(
'ip_block'
,
$userid
,
qa_get_logged_in_handle
(),
qa_cookie_get
(),
array
(
elseif
(
$blockable
)
{
'ip'
=>
$ip
,
if
(
qa_clicked
(
'doblock'
))
{
));
$oldblocked
=
qa_opt
(
'block_ips_write'
);
qa_set_option
(
'block_ips_write'
,
(
strlen
(
$oldblocked
)
?
(
$oldblocked
.
' , '
)
:
''
)
.
$ip
);
qa_redirect
(
qa_request
());
qa_report_event
(
'ip_block'
,
$userid
,
qa_get_logged_in_handle
(),
qa_cookie_get
(),
array
(
}
'ip'
=>
$ip
,
));
if
(
qa_clicked
(
'dounblock'
))
{
qa_redirect
(
qa_request
());
require_once
QA_INCLUDE_DIR
.
'app/limits.php'
;
}
$blockipclauses
=
qa_block_ips_explode
(
qa_opt
(
'block_ips_write'
));
if
(
qa_clicked
(
'dounblock'
))
{
require_once
QA_INCLUDE_DIR
.
'app/limits.php'
;
foreach
(
$blockipclauses
as
$key
=>
$blockipclause
)
{
$blockipclauses
=
qa_block_ips_explode
(
qa_opt
(
'block_ips_write'
));
if
(
qa_block_ip_match
(
$ip
,
$blockipclause
))
unset
(
$blockipclauses
[
$key
]);
}
qa_set_option
(
'block_ips_write'
,
implode
(
' , '
,
$blockipclauses
));
foreach
(
$blockipclauses
as
$key
=>
$blockipclause
)
{
if
(
qa_block_ip_match
(
$ip
,
$blockipclause
))
unset
(
$blockipclauses
[
$key
]);
}
qa_report_event
(
'ip_unblock'
,
$userid
,
qa_get_logged_in_handle
(),
qa_cookie_get
(),
array
(
qa_set_option
(
'block_ips_write'
,
implode
(
' , '
,
$blockipclauses
));
'ip'
=>
$ip
,
));
qa_redirect
(
qa_request
());
qa_report_event
(
'ip_unblock'
,
$userid
,
qa_get_logged_in_handle
(),
qa_cookie_get
(),
array
(
}
'ip'
=>
$ip
,
));
if
(
qa_clicked
(
'dohideall'
)
&&
!
qa_user_maximum_permit_error
(
'permit_hide_show'
))
{
qa_redirect
(
qa_request
());
// allow moderator in one category to hide posts across all categories if they are identified via IP page
}
require_once
QA_INCLUDE_DIR
.
'db/admin.php'
;
if
(
qa_clicked
(
'dohideall'
)
&&
!
qa_user_maximum_permit_error
(
'permit_hide_show'
))
{
require_once
QA_INCLUDE_DIR
.
'app/posts.php'
;
// allow moderator in one category to hide posts across all categories if they are identified via IP page
$postids
=
qa_db_get_ip_visible_postids
(
$ip
);
require_once
QA_INCLUDE_DIR
.
'db/admin.php'
;
require_once
QA_INCLUDE_DIR
.
'app/posts.php'
;
foreach
(
$postids
as
$postid
)
$postids
=
qa_db_get_ip_visible_postids
(
$ip
);
qa_post_set_status
(
$postid
,
QA_POST_STATUS_HIDDEN
,
$userid
);
qa_redirect
(
qa_request
());
}
}
}
foreach
(
$postids
as
$postid
)
qa_post_set_status
(
$postid
,
QA_POST_STATUS_HIDDEN
,
$userid
);
// Combine sets of questions and get information for users
qa_redirect
(
qa_request
());
}
}
}
$questions
=
qa_any_sort_by_date
(
array_merge
(
$qs
,
$qs_queued
,
$qs_hidden
,
$a_qs
,
$a_queued_qs
,
$a_hidden_qs
,
$c_qs
,
$c_queued_qs
,
$c_hidden_qs
,
$edit_qs
));
$usershtml
=
qa_userids_handles_html
(
qa_any_get_userids_handles
(
$questions
));
// Combine sets of questions and get information for users
$hostname
=
gethostbyaddr
(
$ip
);
$questions
=
qa_any_sort_by_date
(
array_merge
(
$qs
,
$qs_queued
,
$qs_hidden
,
$a_qs
,
$a_queued_qs
,
$a_hidden_qs
,
$c_qs
,
$c_queued_qs
,
$c_hidden_qs
,
$edit_qs
)
);
$usershtml
=
qa_userids_handles_html
(
qa_any_get_userids_handles
(
$questions
));
// Prepare content for theme
$hostname
=
gethostbyaddr
(
$ip
);
$qa_content
=
qa_content_prepare
();
$qa_content
[
'title'
]
=
qa_lang_html_sub
(
'main/ip_address_x'
,
qa_html
(
$ip
));
// Prepare content for theme
$qa_content
[
'error'
]
=
@
$pageerror
;
$qa_content
[
'form'
]
=
array
(
$qa_content
=
qa_content_prepare
();
'tags'
=>
'method="post" action="'
.
qa_self_html
()
.
'"'
,
'style'
=>
'wide'
,
$qa_content
[
'title'
]
=
qa_lang_html_sub
(
'main/ip_address_x'
,
qa_html
(
$ip
));
$qa_content
[
'error'
]
=
@
$pageerror
;
'fields'
=>
array
(
$qa_content
[
'form'
]
=
array
(
'host'
=>
array
(
'tags'
=>
'method="post" action="'
.
qa_self_html
()
.
'"'
,
'type'
=>
'static'
,
'label'
=>
qa_lang_html
(
'misc/host_name'
),
'value'
=>
qa_html
(
$hostname
),
),
),
'hidden'
=>
array
(
'style'
=>
'wide'
,
'code'
=>
qa_get_form_security_code
(
'ip-'
.
$ip
),
),
);
'fields'
=>
array
(
'host'
=>
array
(
'type'
=>
'static'
,
'label'
=>
qa_lang_html
(
'misc/host_name'
),
'value'
=>
qa_html
(
$hostname
),
),
),
if
(
$blockable
)
{
'hidden'
=>
array
(
require_once
QA_INCLUDE_DIR
.
'app/limits.php'
;
'code'
=>
qa_get_form_security_code
(
'ip-'
.
$ip
),
),
);
$blockipclauses
=
qa_block_ips_explode
(
qa_opt
(
'block_ips_write'
));
$matchclauses
=
array
();
foreach
(
$blockipclauses
as
$blockipclause
)
{
if
(
$blockable
)
{
if
(
qa_block_ip_match
(
$ip
,
$blockipclause
))
require_once
QA_INCLUDE_DIR
.
'app/limits.php'
;
$matchclauses
[]
=
$blockipclause
;
}
if
(
count
(
$matchclauses
))
{
$blockipclauses
=
qa_block_ips_explode
(
qa_opt
(
'block_ips_write'
));
$qa_content
[
'form'
][
'fields'
][
'status'
]
=
array
(
$matchclauses
=
array
();
'type'
=>
'static'
,
'label'
=>
qa_lang_html
(
'misc/matches_blocked_ips'
),
'value'
=>
qa_html
(
implode
(
"
\n
"
,
$matchclauses
),
true
),
);
$qa_content
[
'form'
][
'buttons'
][
'unblock'
]
=
array
(
foreach
(
$blockipclauses
as
$blockipclause
)
{
'tags'
=>
'name="dounblock"'
,
if
(
qa_block_ip_match
(
$ip
,
$blockipclause
))
'label'
=>
qa_lang_html
(
'misc/unblock_ip_button'
),
$matchclauses
[]
=
$blockipclause
;
);
}
if
(
count
(
$questions
)
&&
!
qa_user_maximum_permit_error
(
'permit_hide_show'
))
if
(
count
(
$matchclauses
))
{
$qa_content
[
'form'
][
'buttons'
][
'hideall'
]
=
array
(
$qa_content
[
'form'
][
'fields'
][
'status'
]
=
array
(
'tags'
=>
'name="dohideall" onclick="qa_show_waiting_after(this, false);"'
,
'type'
=>
'static'
,
'label'
=>
qa_lang_html
(
'misc/hide_all_ip_button'
),
'label'
=>
qa_lang_html
(
'misc/matches_blocked_ips'
),
);
'value'
=>
qa_html
(
implode
(
"
\n
"
,
$matchclauses
),
true
),
);
$qa_content
[
'form'
][
'buttons'
][
'unblock'
]
=
array
(
'tags'
=>
'name="dounblock"'
,
'label'
=>
qa_lang_html
(
'misc/unblock_ip_button'
),
);
if
(
count
(
$questions
)
&&
!
qa_user_maximum_permit_error
(
'permit_hide_show'
))
$qa_content
[
'form'
][
'buttons'
][
'hideall'
]
=
array
(
'tags'
=>
'name="dohideall" onclick="qa_show_waiting_after(this, false);"'
,
'label'
=>
qa_lang_html
(
'misc/hide_all_ip_button'
),
);
}
else
{
$qa_content
[
'form'
][
'buttons'
][
'block'
]
=
array
(
'tags'
=>
'name="doblock"'
,
'label'
=>
qa_lang_html
(
'misc/block_ip_button'
),
);
}
}
}
else
{
$qa_content
[
'form'
][
'buttons'
][
'block'
]
=
array
(
'tags'
=>
'name="doblock"'
,
'label'
=>
qa_lang_html
(
'misc/block_ip_button'
),
);
}
}
$qa_content
[
'q_list'
][
'qs'
]
=
array
();
$qa_content
[
'q_list'
][
'qs'
]
=
array
();
if
(
count
(
$questions
))
{
$qa_content
[
'q_list'
][
'title'
]
=
qa_lang_html_sub
(
'misc/recent_activity_from_x'
,
qa_html
(
$ip
));
if
(
count
(
$questions
))
{
foreach
(
$questions
as
$question
)
{
$qa_content
[
'q_list'
][
'title'
]
=
qa_lang_html_sub
(
'misc/recent_activity_from_x'
,
qa_html
(
$ip
));
$htmloptions
=
qa_post_html_options
(
$question
);
$htmloptions
[
'tagsview'
]
=
false
;
$htmloptions
[
'voteview'
]
=
false
;
$htmloptions
[
'ipview'
]
=
false
;
$htmloptions
[
'answersview'
]
=
false
;
$htmloptions
[
'viewsview'
]
=
false
;
$htmloptions
[
'updateview'
]
=
false
;
foreach
(
$questions
as
$question
)
{
$htmlfields
=
qa_any_to_q_html_fields
(
$question
,
$userid
,
qa_cookie_get
(),
$usershtml
,
null
,
$htmloptions
);
$htmloptions
=
qa_post_html_options
(
$question
);
$htmloptions
[
'tagsview'
]
=
false
;
$htmloptions
[
'voteview'
]
=
false
;
$htmloptions
[
'ipview'
]
=
false
;
$htmloptions
[
'answersview'
]
=
false
;
$htmloptions
[
'viewsview'
]
=
false
;
$htmloptions
[
'updateview'
]
=
false
;
$htmlfields
=
qa_any_to_q_html_fields
(
$question
,
$userid
,
qa_cookie_get
(),
$usershtml
,
null
,
$htmloptions
);
if
(
isset
(
$htmlfields
[
'what_url'
]))
// link directly to relevant content
$htmlfields
[
'url'
]
=
$htmlfields
[
'what_url'
];
if
(
isset
(
$htmlfields
[
'what_url'
]))
// link directly to relevant content
$hasother
=
isset
(
$question
[
'opostid'
]);
$htmlfields
[
'url'
]
=
$htmlfields
[
'what_url'
];
$hasother
=
isset
(
$question
[
'opostid'
]);
if
(
$question
[
$hasother
?
'ohidden'
:
'hidden'
]
&&
!
isset
(
$question
[
$hasother
?
'oupdatetype'
:
'updatetype'
]))
{
$htmlfields
[
'what_2'
]
=
qa_lang_html
(
'main/hidden'
);
if
(
$question
[
$hasother
?
'ohidden'
:
'hidden'
]
&&
!
isset
(
$question
[
$hasother
?
'oupdatetype'
:
'updatetype'
]))
{
if
(
@
$htmloptions
[
'whenview'
])
{
$htmlfields
[
'what_2'
]
=
qa_lang_html
(
'main/hidden'
);
$updated
=
@
$question
[
$hasother
?
'oupdated'
:
'updated'
];
if
(
isset
(
$updated
))
$htmlfields
[
'when_2'
]
=
qa_when_to_html
(
$updated
,
@
$htmloptions
[
'fulldatedays'
]);
}
}
if
(
@
$htmloptions
[
'whenview'
])
{
$qa_content
[
'q_list'
][
'qs'
][]
=
$htmlfields
;
$updated
=
@
$question
[
$hasother
?
'oupdated'
:
'updated'
];
if
(
isset
(
$updated
))
$htmlfields
[
'when_2'
]
=
qa_when_to_html
(
$updated
,
@
$htmloptions
[
'fulldatedays'
]);
}
}
}
$qa_content
[
'q_list'
][
'qs'
][]
=
$htmlfields
;
}
else
}
$qa_content
[
'q_list'
][
'title'
]
=
qa_lang_html_sub
(
'misc/no_activity_from_x'
,
qa_html
(
$ip
));
}
else
$qa_content
[
'q_list'
][
'title'
]
=
qa_lang_html_sub
(
'misc/no_activity_from_x'
,
qa_html
(
$ip
));
return
$qa_content
;
return
$qa_content
;
}
}
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