Version Description
| 08.03.2017 =
wpForo v1.2.0 Release Summary
- Added: wpForo Spam Control - New User
- Added: New Dashboard subMenu - Forums > Tools > Antispam
- Antispam: Possible Spam Attachments - lists suspected files
- Antispam: New Registered Users control and restrictions
- Antispam: Min number of posts to be able attach files
- Antispam: Min number of posts to be able post links
- Antispam: Restricts New Users to attach risky file extensions
- Antispam: Integration with Akismet
- Added: wpForo Spam Control - Topics & Posts
- Added: New Dashboard subMenu - Forums > Moderation
- Antispam: Makes topics/posts unapproved if spam is suspected
- Antispam: Topic moderation through dashboard Approve/Unapprove/Delete
- Antispam: Bans new registered users if spam content is detected
- Antispam: New Forum Access - "Can pass moderation"
- Added: RTL Font-Awesome
- Added: Swedish Translation (sv_SE) by Mathias Persson
- Fixed Bug: Don't allow empty topics and posts
- Fixed Bug: Post Link URL problem (pagination part in URL)
- Fixed Bug: Notice: Undefined index: set in .../class-template.php
IMPORTANT:
- Once wpForo is updated, please navigate to Dashboard > Forums > Tools admin page and check the "Possible Spam Attachments" section. We detected massive spam file uploading cases in non-protected forums. Spammers delete topics and posts but uploaded spam files are still in your file system, most of those PDF files. Please delete all suspected PDF files listed in this section. More Info...
- To load old customized colors please refresh forum page twice.
- If you have a Cache Plugin, please delete all caches after wpForo update.
- If you use CDN and found some issue please purge it.
Download this release
Release Info
Developer | Tomdever |
Plugin | ![]() |
Version | 1.2.0 |
Comparing to | |
See all releases |
Code changes from version 1.1.2 to 1.2.0
- readme.txt +36 -15
- wpf-admin/admin.php +25 -2
- wpf-admin/css/admin.css +17 -1
- wpf-admin/member.php +1 -1
- wpf-admin/moderation.php +22 -0
- wpf-admin/phrase.php +1 -1
- wpf-admin/themes.php +1 -1
- wpf-admin/tools-tabs/antispam.php +182 -0
- wpf-admin/tools-tabs/cleanup.php +19 -0
- wpf-admin/tools.php +37 -0
- wpf-admin/xml/english.xml +11 -2
- wpf-includes/class-members.php +49 -0
- wpf-includes/class-moderation.php +381 -0
- wpf-includes/class-permissions.php +52 -4
- wpf-includes/class-posts.php +129 -26
- wpf-includes/class-template.php +48 -27
- wpf-includes/class-topics.php +117 -22
- wpf-includes/class-usergroups.php +1 -1
- wpf-includes/functions-installation.php +55 -12
- wpf-includes/functions-template.php +6 -4
- wpf-includes/functions.php +131 -25
- wpf-includes/wpf-actions.php +131 -4
- wpf-includes/wpf-hooks.php +110 -95
- wpf-includes/wpf-phrases.php +14 -2
- wpf-languages/wpforo-he_IL.mo +0 -0
- wpf-languages/wpforo-he_IL.po +3299 -3207
- wpf-languages/wpforo-sv_SE.mo +0 -0
- wpf-languages/wpforo-sv_SE.po +3447 -0
- wpf-languages/wpforo.pot +318 -49
- wpf-themes/classic/.gitignore +0 -1
- wpf-themes/classic/colors.css +2 -1
- wpf-themes/classic/layouts/1/post.php +1 -1
- wpf-themes/classic/layouts/2/post.php +1 -0
- wpf-themes/classic/layouts/3/post.php +1 -0
- wpf-themes/classic/style-rtl.css +4 -2
- wpf-themes/classic/style.css +4 -2
- wpf-themes/classic/styles/css.php +2 -1
- wpforo.php +7 -3
readme.txt
CHANGED
@@ -1,17 +1,17 @@
|
|
1 |
-
=== Forum - wpForo ===
|
2 |
Contributors: gVectors Team
|
3 |
Tags: forum, community, discussion, bulletin board, question and answers, qa, support, foro, forums
|
4 |
Requires at least: 4.1
|
5 |
Tested up to: 4.7
|
6 |
-
Stable tag: 1.
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
10 |
-
|
11 |
|
12 |
== Description ==
|
13 |
|
14 |
-
|
15 |
|
16 |
<blockquote>
|
17 |
Community and Demo: http://wpforo.com/community/ <br/>
|
@@ -34,6 +34,7 @@ Complete Question & Answers discussion board for professional support and for co
|
|
34 |
* | German (de_DE) by Markus Herrmann
|
35 |
* | Spanish (es_ES) Poncho Camacho
|
36 |
* | Spanish (Mexico) (es_MX) Poncho Camacho
|
|
|
37 |
* | Persian (fa_IR) by wpforo.ir
|
38 |
* | Hebrew (he_IL) Gal Zilberman
|
39 |
* | Japanese (JA_ja) by Seg Way
|
@@ -138,6 +139,37 @@ wpForo Support Forum: <http://wpforo.com/community/>
|
|
138 |
|
139 |
== Changelog ==
|
140 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
141 |
|
142 |
= 1.1.2 | 26.02.2017 =
|
143 |
|
@@ -173,17 +205,6 @@ wpForo Support Forum: <http://wpforo.com/community/>
|
|
173 |
* Fixed Bug: Undefined variable: size_da in .../dashboard.php on line 182
|
174 |
* Fixed Bug: SSL Problem
|
175 |
|
176 |
-
IMPORTANT:
|
177 |
-
|
178 |
-
- To load old customized colors please refresh forum page twice.
|
179 |
-
- If you have a Cache Plugin, please delete all caches after wpForo update.
|
180 |
-
- If you use CDN and found some issue please purge it.
|
181 |
-
- If you have custom forum template, please update these template files:
|
182 |
-
* profile.php
|
183 |
-
* members.php
|
184 |
-
* layouts/1/post.php
|
185 |
-
* layouts/2/post.php
|
186 |
-
|
187 |
|
188 |
= 1.1.1 | 20.12.2016 =
|
189 |
|
1 |
+
=== Forum - wpForo ===
|
2 |
Contributors: gVectors Team
|
3 |
Tags: forum, community, discussion, bulletin board, question and answers, qa, support, foro, forums
|
4 |
Requires at least: 4.1
|
5 |
Tested up to: 4.7
|
6 |
+
Stable tag: 1.2.0
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
10 |
+
wpForo comes with everything you need to run an efficient and professional community. Powerful and beautiful forum plugin with unique features
|
11 |
|
12 |
== Description ==
|
13 |
|
14 |
+
Forum wpForo is a new generation of WordPress forum plugins made by [gVectors Team](http://gvectors.com/). Everything you need to run an efficient and professional community. Powerful and beautiful bulletin board with unique features.
|
15 |
|
16 |
<blockquote>
|
17 |
Community and Demo: http://wpforo.com/community/ <br/>
|
34 |
* | German (de_DE) by Markus Herrmann
|
35 |
* | Spanish (es_ES) Poncho Camacho
|
36 |
* | Spanish (Mexico) (es_MX) Poncho Camacho
|
37 |
+
* | Swedish (sv_SE) by Mathias Persson
|
38 |
* | Persian (fa_IR) by wpforo.ir
|
39 |
* | Hebrew (he_IL) Gal Zilberman
|
40 |
* | Japanese (JA_ja) by Seg Way
|
139 |
|
140 |
== Changelog ==
|
141 |
|
142 |
+
= 1.2.0 | 08.03.2017 =
|
143 |
+
|
144 |
+
[wpForo v1.2.0 Release Summary](http://wpforo.com/community/wpforo-announcements/wpforo-1-2-0-is-released/)
|
145 |
+
|
146 |
+
* Added: wpForo Spam Control - New User
|
147 |
+
* Added: New Dashboard subMenu - Forums > Tools > Antispam
|
148 |
+
* Antispam: Possible Spam Attachments - lists suspected files
|
149 |
+
* Antispam: New Registered Users control and restrictions
|
150 |
+
* Antispam: Min number of posts to be able attach files
|
151 |
+
* Antispam: Min number of posts to be able post links
|
152 |
+
* Antispam: Restricts New Users to attach risky file extensions
|
153 |
+
* Antispam: Integration with [Akismet](https://wordpress.org/plugins/akismet/)
|
154 |
+
* Added: wpForo Spam Control - Topics & Posts
|
155 |
+
* Added: New Dashboard subMenu - Forums > Moderation
|
156 |
+
* Antispam: Makes topics/posts unapproved if spam is suspected
|
157 |
+
* Antispam: Topic moderation through dashboard Approve/Unapprove/Delete
|
158 |
+
* Antispam: Bans new registered users if spam content is detected
|
159 |
+
* Antispam: New Forum Access - "Can pass moderation"
|
160 |
+
* Added: RTL Font-Awesome
|
161 |
+
* Added: Swedish Translation (sv_SE) by Mathias Persson
|
162 |
+
* Fixed Bug: Don't allow empty topics and posts
|
163 |
+
* Fixed Bug: Post Link URL problem (pagination part in URL)
|
164 |
+
* Fixed Bug: Notice: Undefined index: set in .../class-template.php
|
165 |
+
|
166 |
+
IMPORTANT:
|
167 |
+
|
168 |
+
- Once wpForo is updated, please navigate to Dashboard > Forums > Tools admin page and check the "Possible Spam Attachments" section. We detected massive spam file uploading cases in non-protected forums. Spammers delete topics and posts but uploaded spam files are still in your file system, most of those PDF files. Please delete all suspected PDF files listed in this section. [More Info](http://wpforo.com/community/wpforo-announcements/wpforo-1-2-0-is-released/)...
|
169 |
+
- To load old customized colors please refresh forum page twice.
|
170 |
+
- If you have a Cache Plugin, please delete all caches after wpForo update.
|
171 |
+
- If you use CDN and found some issue please purge it.
|
172 |
+
|
173 |
|
174 |
= 1.1.2 | 26.02.2017 =
|
175 |
|
205 |
* Fixed Bug: Undefined variable: size_da in .../dashboard.php on line 182
|
206 |
* Fixed Bug: SSL Problem
|
207 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
208 |
|
209 |
= 1.1.1 | 20.12.2016 =
|
210 |
|
wpf-admin/admin.php
CHANGED
@@ -5,6 +5,17 @@
|
|
5 |
|
6 |
function wpforo_add_menu(){
|
7 |
global $wpforo;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
$position = ( isset($wpforo->general_options['menu_position']) && $wpforo->general_options['menu_position'] > 0 ) ? $wpforo->general_options['menu_position'] : 23;
|
9 |
if( $wpforo->current_user_groupid == 1 ||
|
10 |
$wpforo->current_user_groupid == 2 ||
|
@@ -12,11 +23,13 @@
|
|
12 |
( $wpforo->perm->usergroup_can('cf') &&
|
13 |
$wpforo->perm->usergroup_can('ef') &&
|
14 |
$wpforo->perm->usergroup_can('df') )
|
15 |
-
) add_menu_page(__('Dashboard', 'wpforo'), __('Forums', 'wpforo
|
16 |
if( $wpforo->current_user_groupid == 1 || $wpforo->current_user_groupid == 2 ) add_submenu_page('wpforo-community', __('Dashboard', 'wpforo'), __('Dashboard', 'wpforo'), 'read', 'wpforo-community', 'wpforo_toplevel_page' );
|
17 |
if( $wpforo->perm->usergroup_can('cf') && $wpforo->perm->usergroup_can('ef') && $wpforo->perm->usergroup_can('df') ) add_submenu_page('wpforo-community', __('Forums', 'wpforo'), __('Forums', 'wpforo'), 'read', 'wpforo-forums', 'wpforo_forum_menu');
|
18 |
if( $wpforo->current_user_groupid == 1 ) add_submenu_page('wpforo-community', __('Settings', 'wpforo'), __('Settings', 'wpforo'), 'read', 'wpforo-settings', 'wpforo_settings');
|
19 |
-
if( $wpforo->
|
|
|
|
|
20 |
if( $wpforo->current_user_groupid == 1 ) add_submenu_page('wpforo-community', __('Usergroups', 'wpforo'), __('Usergroups', 'wpforo'), 'read', 'wpforo-usergroups', 'wpforo_usergroups_menu');
|
21 |
if( $wpforo->current_user_groupid == 1 ) add_submenu_page('wpforo-community', __('Phrases', 'wpforo'), __('Phrases', 'wpforo'), 'read', 'wpforo-phrases', 'wpforo_phrases');
|
22 |
if( $wpforo->current_user_groupid == 1 ) add_submenu_page('wpforo-community', __('Themes', 'wpforo'), __('Themes', 'wpforo'), 'read', 'wpforo-themes', 'wpforo_themes');
|
@@ -69,4 +82,14 @@
|
|
69 |
global $wpforo;
|
70 |
require( WPFORO_DIR . '/wpf-admin/addons.php' );
|
71 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
?>
|
5 |
|
6 |
function wpforo_add_menu(){
|
7 |
global $wpforo;
|
8 |
+
|
9 |
+
$wpforo->moderation->spam_attachment();
|
10 |
+
|
11 |
+
$all_count = 0;
|
12 |
+
$mod_count = $wpforo->post->unapproved_count(); $mod_count_num = intval($mod_count);
|
13 |
+
$mod_count = ( $mod_count ) ? ' <span class="awaiting-mod count-1"><span class="pending-count">' . intval($mod_count) . '</span></span> ' : '' ;
|
14 |
+
$ban_count = $wpforo->member->banned_count(); $ban_count_num = intval($ban_count);
|
15 |
+
$ban_count = ( $ban_count ) ? ' <span class="awaiting-mod count-1"><span class="pending-count">' . intval($ban_count) . '</span></span> ' : '' ;
|
16 |
+
$all_count = $mod_count_num + $ban_count_num;
|
17 |
+
$all_count = ( $all_count ) ? ' <span class="awaiting-mod count-1"><span class="pending-count">' . intval($all_count) . '</span></span> ' : '' ;
|
18 |
+
|
19 |
$position = ( isset($wpforo->general_options['menu_position']) && $wpforo->general_options['menu_position'] > 0 ) ? $wpforo->general_options['menu_position'] : 23;
|
20 |
if( $wpforo->current_user_groupid == 1 ||
|
21 |
$wpforo->current_user_groupid == 2 ||
|
23 |
( $wpforo->perm->usergroup_can('cf') &&
|
24 |
$wpforo->perm->usergroup_can('ef') &&
|
25 |
$wpforo->perm->usergroup_can('df') )
|
26 |
+
) add_menu_page(__('Dashboard', 'wpforo'), __('Forums', 'wpforo') . $all_count , 'read', 'wpforo-community', 'wpforo_toplevel_page', 'dashicons-format-chat', $position);
|
27 |
if( $wpforo->current_user_groupid == 1 || $wpforo->current_user_groupid == 2 ) add_submenu_page('wpforo-community', __('Dashboard', 'wpforo'), __('Dashboard', 'wpforo'), 'read', 'wpforo-community', 'wpforo_toplevel_page' );
|
28 |
if( $wpforo->perm->usergroup_can('cf') && $wpforo->perm->usergroup_can('ef') && $wpforo->perm->usergroup_can('df') ) add_submenu_page('wpforo-community', __('Forums', 'wpforo'), __('Forums', 'wpforo'), 'read', 'wpforo-forums', 'wpforo_forum_menu');
|
29 |
if( $wpforo->current_user_groupid == 1 ) add_submenu_page('wpforo-community', __('Settings', 'wpforo'), __('Settings', 'wpforo'), 'read', 'wpforo-settings', 'wpforo_settings');
|
30 |
+
if( $wpforo->current_user_groupid == 1 ) add_submenu_page('wpforo-community', __('Tools', 'wpforo'), __('Tools', 'wpforo'), 'read', 'wpforo-tools', 'wpforo_tools');
|
31 |
+
if( $wpforo->perm->usergroup_can('aum') ) add_submenu_page('wpforo-community', __('Moderation', 'wpforo'), __('Moderation' , 'wpforo') . $mod_count, 'read', 'wpforo-moderations', 'wpforo_moderations');
|
32 |
+
if( $wpforo->perm->usergroup_can('vm') ) add_submenu_page('wpforo-community', __('Members', 'wpforo'), __('Members', 'wpforo') . $ban_count, 'read', 'wpforo-members', 'wpforo_member_menu');
|
33 |
if( $wpforo->current_user_groupid == 1 ) add_submenu_page('wpforo-community', __('Usergroups', 'wpforo'), __('Usergroups', 'wpforo'), 'read', 'wpforo-usergroups', 'wpforo_usergroups_menu');
|
34 |
if( $wpforo->current_user_groupid == 1 ) add_submenu_page('wpforo-community', __('Phrases', 'wpforo'), __('Phrases', 'wpforo'), 'read', 'wpforo-phrases', 'wpforo_phrases');
|
35 |
if( $wpforo->current_user_groupid == 1 ) add_submenu_page('wpforo-community', __('Themes', 'wpforo'), __('Themes', 'wpforo'), 'read', 'wpforo-themes', 'wpforo_themes');
|
82 |
global $wpforo;
|
83 |
require( WPFORO_DIR . '/wpf-admin/addons.php' );
|
84 |
}
|
85 |
+
|
86 |
+
function wpforo_tools(){
|
87 |
+
global $wpforo;
|
88 |
+
require( WPFORO_DIR . '/wpf-admin/tools.php' );
|
89 |
+
}
|
90 |
+
|
91 |
+
function wpforo_moderations(){
|
92 |
+
global $wpforo;
|
93 |
+
require( WPFORO_DIR . '/wpf-admin/moderation.php' );
|
94 |
+
}
|
95 |
?>
|
wpf-admin/css/admin.css
CHANGED
@@ -221,4 +221,20 @@
|
|
221 |
.wpforo-addons .wpforo-addon-block .addon-button{ margin-bottom:10px;}
|
222 |
.wpforo-addons .wpforo-addon-block .note-installed { padding:10px 20px; background:#fff; border: 1px solid #ddd; box-shadow: 0 3px 3px rgba(0, 0, 0, 0.04); color:#2396D3; font-size:14px; margin-top:20px; }
|
223 |
|
224 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
221 |
.wpforo-addons .wpforo-addon-block .addon-button{ margin-bottom:10px;}
|
222 |
.wpforo-addons .wpforo-addon-block .note-installed { padding:10px 20px; background:#fff; border: 1px solid #ddd; box-shadow: 0 3px 3px rgba(0, 0, 0, 0.04); color:#2396D3; font-size:14px; margin-top:20px; }
|
223 |
|
224 |
+
/**************************/
|
225 |
+
/* TOOLS ******************/
|
226 |
+
/**************************/
|
227 |
+
#wpf-admin-wrap .wpf-tool-box { border:1px solid #ddd; min-height:350px; float:left; margin-right:1%; margin-bottom:10px; padding:10px 10px 20px 10px; box-sizing:border-box; width:100%;}
|
228 |
+
#wpf-admin-wrap .wpf-tool-box h3{ margin:0px; font-weight:normal; border-bottom:1px dotted #ccc; padding-bottom:5px;}
|
229 |
+
#wpf-admin-wrap .wpf-tool-box th{ padding:1px 5px 5px 5px; font-size:13px; text-align:left; font-weight:400; line-height:16px; border-bottom:1px solid #EDEDED;}
|
230 |
+
#wpf-admin-wrap .wpf-tool-box td{ padding:1px 5px 5px 5px; border-bottom:1px solid #EDEDED;}
|
231 |
+
#wpf-admin-wrap .wpf-tool-box.wpf-spam-attach.right-box { width:52%; min-width:500px;max-height:300px; overflow-y:auto; }
|
232 |
+
#wpf-admin-wrap .wpf-tool-box.wpf-spam-attach.left-box { width:45%; min-width:300px;}
|
233 |
+
#wpf-admin-wrap .wpf-tool-box.wpf-spam-attach .wpf-spam-attach-dir{ color:#4742C5; display:block; text-align:right; }
|
234 |
+
#wpf-admin-wrap .wpf-tool-box.wpf-spam-attach tr:nth-child(even){ background:#EDEDED;}
|
235 |
+
#wpf-admin-wrap .wpf-tool-box.wpf-spam-attach .wpf-spam-item{}
|
236 |
+
#wpf-admin-wrap .wpf-tool-box.wpf-spam-attach .wpf-actions{}
|
237 |
+
@media screen and (max-width:1250px) {
|
238 |
+
#wpf-admin-wrap .wpf-tool-box.wpf-spam-attach.left-box { width:100%; min-width:100%; min-height:none; max-height:none!important;}
|
239 |
+
#wpf-admin-wrap .wpf-tool-box.wpf-spam-attach.right-box { width:100%; min-width:100%; min-height:none; max-height:none!important;}
|
240 |
+
}
|
wpf-admin/member.php
CHANGED
@@ -7,7 +7,7 @@
|
|
7 |
<div id="wpf-admin-wrap" class="wrap">
|
8 |
<?php wpforo_screen_option() ?>
|
9 |
<div id="icon-users" class="icon32"><br></div>
|
10 |
-
<h2 style="padding:30px 0px 0px 0px;line-height: 20px;"><?php _e('Members', 'wpforo'); ?></h2>
|
11 |
<?php $wpforo->notice->show(FALSE) ?>
|
12 |
<?php if(!isset( $_GET['action'] ) || ( isset( $_GET['action']) && $_GET['action'] == -1 ) ) : ?>
|
13 |
<?php
|
7 |
<div id="wpf-admin-wrap" class="wrap">
|
8 |
<?php wpforo_screen_option() ?>
|
9 |
<div id="icon-users" class="icon32"><br></div>
|
10 |
+
<h2 style="padding:30px 0px 0px 0px;line-height: 20px; margin-bottom:15px;"><?php _e('Members', 'wpforo'); ?></h2>
|
11 |
<?php $wpforo->notice->show(FALSE) ?>
|
12 |
<?php if(!isset( $_GET['action'] ) || ( isset( $_GET['action']) && $_GET['action'] == -1 ) ) : ?>
|
13 |
<?php
|
wpf-admin/moderation.php
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// Exit if accessed directly
|
3 |
+
if( !defined( 'ABSPATH' ) ) exit;
|
4 |
+
if( !current_user_can('administrator') ) exit;
|
5 |
+
?>
|
6 |
+
|
7 |
+
<div id="wpf-admin-wrap" class="wrap" style="margin-top: 0px">
|
8 |
+
<?php wpforo_screen_option() ?>
|
9 |
+
<div id="icon-users" class="icon32"><br></div>
|
10 |
+
<h2 style="padding:30px 0px 0px 0px;line-height: 20px; margin-bottom:15px;"><?php _e('Topic and Post Moderation', 'wpforo'); ?></h2>
|
11 |
+
<?php $wpforo->notice->show(FALSE) ?>
|
12 |
+
<?php
|
13 |
+
if( !((isset($_GET['action']) && $_GET['action'] != '-1') || (isset($_GET['action2']) && $_GET['action2'] != '-1')) ){
|
14 |
+
$fields = array( 'title', 'is_first_post', 'userid', 'created' );
|
15 |
+
$search_fields = array( 'title', 'body' );
|
16 |
+
$filter_fields = array( 'status', 'userid' );
|
17 |
+
$actions = array('view', 'approve', 'delete');
|
18 |
+
$bulk_actions = array('approve', 'unapprove', 'del');
|
19 |
+
wpforo_create_form_table( 'moderation', 'postid', $fields, $search_fields, $filter_fields, $actions, $bulk_actions);
|
20 |
+
}
|
21 |
+
?>
|
22 |
+
</div>
|
wpf-admin/phrase.php
CHANGED
@@ -7,7 +7,7 @@
|
|
7 |
<div id="wpf-admin-wrap" class="wrap" style="margin-top: 0px">
|
8 |
<?php wpforo_screen_option() ?>
|
9 |
<div id="icon-users" class="icon32"><br></div>
|
10 |
-
<h2 style="padding:30px 0px 0px 0px;line-height: 20px;"><?php _e('Front-end Phrases', 'wpforo'); ?> <a href="<?php echo admin_url( 'admin.php?page=wpforo-phrases&action=add' ) ?>" class="add-new-h2"><?php wpforo_phrase('add_new') ?></a></h2>
|
11 |
<?php $wpforo->notice->show(FALSE) ?>
|
12 |
<?php
|
13 |
if( !((isset($_GET['action']) && $_GET['action'] != '-1') || (isset($_GET['action2']) && $_GET['action2'] != '-1')) ){
|
7 |
<div id="wpf-admin-wrap" class="wrap" style="margin-top: 0px">
|
8 |
<?php wpforo_screen_option() ?>
|
9 |
<div id="icon-users" class="icon32"><br></div>
|
10 |
+
<h2 style="padding:30px 0px 0px 0px;line-height: 20px; margin-bottom:15px;"><?php _e('Front-end Phrases', 'wpforo'); ?> <a href="<?php echo admin_url( 'admin.php?page=wpforo-phrases&action=add' ) ?>" class="add-new-h2"><?php wpforo_phrase('add_new') ?></a></h2>
|
11 |
<?php $wpforo->notice->show(FALSE) ?>
|
12 |
<?php
|
13 |
if( !((isset($_GET['action']) && $_GET['action'] != '-1') || (isset($_GET['action2']) && $_GET['action2'] != '-1')) ){
|
wpf-admin/themes.php
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
?>
|
6 |
|
7 |
<div id="wpf-admin-wrap" class="wrap wpforo-themes">
|
8 |
-
<h2 style="padding:20px 0px 0px 0px;line-height: 20px;">
|
9 |
<?php _e('Forum Themes', 'wpforo'); ?>
|
10 |
<a href="<?php echo admin_url( 'admin.php?page=wpforo-themes&action=add' ) ?>" class="add-new-h2" style="margin-left:10px; display:none;"><?php _e('Add New', 'wpforo'); ?></a>
|
11 |
</h2>
|
5 |
?>
|
6 |
|
7 |
<div id="wpf-admin-wrap" class="wrap wpforo-themes">
|
8 |
+
<h2 style="padding:20px 0px 0px 0px;line-height: 20px; margin-bottom:15px;">
|
9 |
<?php _e('Forum Themes', 'wpforo'); ?>
|
10 |
<a href="<?php echo admin_url( 'admin.php?page=wpforo-themes&action=add' ) ?>" class="add-new-h2" style="margin-left:10px; display:none;"><?php _e('Add New', 'wpforo'); ?></a>
|
11 |
</h2>
|
wpf-admin/tools-tabs/antispam.php
ADDED
@@ -0,0 +1,182 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// Exit if accessed directly
|
3 |
+
if( !defined( 'ABSPATH' ) ) exit;
|
4 |
+
if( !current_user_can('administrator') ) exit;
|
5 |
+
?>
|
6 |
+
|
7 |
+
<?php if( !isset( $_GET['action'] ) ): ?>
|
8 |
+
|
9 |
+
<?php if (!class_exists('Akismet')): ?>
|
10 |
+
<div style="width:94%; clear:both; margin:0px 0 15px 0; text-align:center; line-height:22px; font-size:14px; color:#D35206; border:1px dotted #ccc; padding:10px 20px 10px 20px;; background:#F7F5F5;">
|
11 |
+
<a href="https://wordpress.org/plugins/akismet/" target="_blank">Akismet</a> <?php _e('is not installed! For an advanced Spam Control please install Akismet antispam plugin, it works well with wpForo Spam Control system. Akismet is already integrated with wpForo. It\'ll help to filter posts and protect forum against spam attacks.', 'wpforo'); ?>
|
12 |
+
</div>
|
13 |
+
<?php else: ?>
|
14 |
+
|
15 |
+
<?php endif; ?>
|
16 |
+
|
17 |
+
<form action="" method="POST" class="validate">
|
18 |
+
<?php wp_nonce_field( 'wpforo-tools-antispam' ); ?>
|
19 |
+
<div class="wpf-tool-box wpf-spam-attach right-box">
|
20 |
+
<h3>
|
21 |
+
<?php _e('Spam Control', 'wpforo'); ?>
|
22 |
+
<p class="wpf-info"><?php _e('Some useful options to limit just registered users and minimize spam. This control don\'t affect users whose Usergroup has "Can edit member" and "Can pass moderation" permissions.', 'wpforo'); ?></p>
|
23 |
+
</h3>
|
24 |
+
<div style="margin-top:10px; clear:both;">
|
25 |
+
<table style="width:100%;">
|
26 |
+
<tbody>
|
27 |
+
<tr>
|
28 |
+
<th><label><?php _e('Enable wpForo Spam Control','wpforo'); ?>:</label></th>
|
29 |
+
<td>
|
30 |
+
<div class="wpf-switch-field">
|
31 |
+
<input id="spam_filter_yes" type="radio" name="wpforo_tools_antispam[spam_filter]" value="1" <?php wpfo_check($wpforo->tools_antispam['spam_filter'], 1); ?>/><label for="spam_filter_yes"><?php _e('Yes','wpforo'); ?></label>
|
32 |
+
<input id="spam_filter_no" type="radio" name="wpforo_tools_antispam[spam_filter]" value="0" <?php wpfo_check($wpforo->tools_antispam['spam_filter'], 0); ?>/><label for="spam_filter_no"><?php _e('No','wpforo'); ?></label>
|
33 |
+
</div>
|
34 |
+
</td>
|
35 |
+
</tr>
|
36 |
+
<tr>
|
37 |
+
<th><label><?php _e('Ban user when spam is suspicted','wpforo'); ?>:</label></th>
|
38 |
+
<td>
|
39 |
+
<div class="wpf-switch-field">
|
40 |
+
<input id="spam_user_ban_yes" type="radio" name="wpforo_tools_antispam[spam_user_ban]" value="1" <?php wpfo_check($wpforo->tools_antispam['spam_user_ban'], 1); ?>/><label for="spam_user_ban_yes"><?php _e('Yes','wpforo'); ?></label>
|
41 |
+
<input id="spam_user_ban_no" type="radio" name="wpforo_tools_antispam[spam_user_ban]" value="0" <?php wpfo_check($wpforo->tools_antispam['spam_user_ban'], 0); ?>/><label for="spam_user_ban_no"><?php _e('No','wpforo'); ?></label>
|
42 |
+
</div>
|
43 |
+
</td>
|
44 |
+
</tr>
|
45 |
+
<tr style="visibility:hidden;">
|
46 |
+
<th><label><?php _e('Notify via email when new user is banned','wpforo'); ?>:</label></th>
|
47 |
+
<td>
|
48 |
+
<div class="wpf-switch-field">
|
49 |
+
<input id="spam_user_ban_notification_yes" type="radio" name="wpforo_tools_antispam[spam_user_ban_notification]" value="1" <?php wpfo_check($wpforo->tools_antispam['spam_user_ban_notification'], 1); ?>/><label for="spam_user_ban_notification_yes"><?php _e('Yes','wpforo'); ?></label>
|
50 |
+
<input id="spam_user_ban_notification_no" type="radio" name="wpforo_tools_antispam[spam_user_ban_notification]" value="0" <?php wpfo_check($wpforo->tools_antispam['spam_user_ban_notification'], 0); ?>/><label for="spam_user_ban_notification_no"><?php _e('No','wpforo'); ?></label>
|
51 |
+
</div>
|
52 |
+
</td>
|
53 |
+
</tr>
|
54 |
+
<tr>
|
55 |
+
<th><label ><?php _e('Spam Suspicion Level for Topics', 'wpforo'); ?></label></th>
|
56 |
+
<td><input type="number" min="0" max="100" name="wpforo_tools_antispam[spam_filter_level_topic]" value="<?php wpfo($wpforo->tools_antispam['spam_filter_level_topic']) ?>" class="wpf-field" /></td>
|
57 |
+
</tr>
|
58 |
+
<tr>
|
59 |
+
<th><label ><?php _e('Spam Suspicion Level for Posts', 'wpforo'); ?></label></th>
|
60 |
+
<td><input type="number" min="0" max="100" name="wpforo_tools_antispam[spam_filter_level_post]" value="<?php wpfo($wpforo->tools_antispam['spam_filter_level_post']) ?>" class="wpf-field" /></td>
|
61 |
+
</tr>
|
62 |
+
<?php if (class_exists('Akismet')): ?>
|
63 |
+
<tr>
|
64 |
+
<td colspan="2" style="color:#fff; background:#7C9B2E; font-size:20px; padding:10px 10px; text-align:center; font-family:'Lucida Grande', 'Lucida Sans Unicode'"><strong>A·kis·met</strong> <?php _e(' is enabled','wpforo'); ?></td>
|
65 |
+
</tr>
|
66 |
+
<?php endif; ?>
|
67 |
+
</tbody>
|
68 |
+
</table>
|
69 |
+
</div>
|
70 |
+
</div>
|
71 |
+
<div class="wpf-tool-box wpf-spam-attach left-box">
|
72 |
+
<h3>
|
73 |
+
<?php _e('New Registered User', 'wpforo'); ?>
|
74 |
+
<p class="wpf-info"><?php _e('Some useful options to limit just registered users and minimize spam. These options don\'t affect users whose Usergroup has "Can edit member" and "Can pass moderation" permissions.', 'wpforo'); ?></p>
|
75 |
+
</h3>
|
76 |
+
<div style="margin-top:10px; clear:both;">
|
77 |
+
<table style="width:100%;">
|
78 |
+
<tbody>
|
79 |
+
<tr>
|
80 |
+
<th style="width:65%;">
|
81 |
+
<label ><?php _e('User is New (under hard spam control) during', 'wpforo'); ?></label>
|
82 |
+
</th>
|
83 |
+
<td><?php _e('first', 'wpforo'); ?> <input type="number" min="0" name="wpforo_tools_antispam[new_user_max_posts]" value="<?php wpfo($wpforo->tools_antispam['new_user_max_posts']) ?>" class="wpf-field" style="width:50px;" /> <?php _e('posts', 'wpforo'); ?></td>
|
84 |
+
</tr>
|
85 |
+
<tr>
|
86 |
+
<th style="width:65%;"><label ><?php _e('Min number of posts to be able attach files', 'wpforo'); ?></label></th>
|
87 |
+
<td><input type="number" min="0" name="wpforo_tools_antispam[min_number_post_to_attach]" value="<?php wpfo($wpforo->tools_antispam['min_number_post_to_attach']) ?>" class="wpf-field" style="max-width:80px;" /></td>
|
88 |
+
</tr>
|
89 |
+
<tr>
|
90 |
+
<th><label><?php _e('Min number of posts to be able post links', 'wpforo'); ?></label></th>
|
91 |
+
<td><input type="number" min="0" name="wpforo_tools_antispam[min_number_post_to_link]" value="<?php wpfo($wpforo->tools_antispam['min_number_post_to_link']) ?>" class="wpf-field" style="max-width:80px;" /></td>
|
92 |
+
</tr>
|
93 |
+
<tr>
|
94 |
+
<th colspan="2">
|
95 |
+
<label><?php _e('Do not allow to attach files with following extensions:', 'wpforo'); ?></label>
|
96 |
+
<textarea name="wpforo_tools_antispam[limited_file_ext]" style="width:100%; height:60px; margin-top:10px; color:#666666; background:#fdfdfd;"><?php echo esc_textarea(stripslashes($wpforo->tools_antispam['limited_file_ext'])); ?></textarea></td>
|
97 |
+
</tr>
|
98 |
+
</tbody>
|
99 |
+
</table>
|
100 |
+
</div>
|
101 |
+
</div>
|
102 |
+
<div class="wpf-tool-box wpf-spam-attach right-box" id="spam-files">
|
103 |
+
<?php
|
104 |
+
$site = get_bloginfo('url');
|
105 |
+
$upload_dir = wp_upload_dir();
|
106 |
+
$default_attachments_dir = $upload_dir['basedir'] . '/wpforo/default_attachments/';
|
107 |
+
?>
|
108 |
+
<h3>
|
109 |
+
<?php _e('Possible Spam Attachments', 'wpforo'); ?>
|
110 |
+
<p class="wpf-info"><?php _e('This tool is designed to find attachment which have been uploaded by spammers. The tool checks most common spammer filenames and suggest to delete but you should check one by one and make sure those are spam files before deleting.', 'wpforo'); ?></p>
|
111 |
+
</h3>
|
112 |
+
<div class="wpf-spam-attach-dir"><?php _e('Directory', 'wpforo'); ?>: <?php echo str_replace($site, '', $upload_dir['baseurl']); ?>/wpforo/default_attachments/ </div>
|
113 |
+
<div style="margin-top:10px; clear:both;">
|
114 |
+
<table width="100%" border="0" cellspacing="0" cellpadding="0">
|
115 |
+
<tbody>
|
116 |
+
<?php
|
117 |
+
if(is_dir($default_attachments_dir)):
|
118 |
+
if ($handle = opendir($default_attachments_dir)):
|
119 |
+
while (false !== ($filename = readdir($handle))):
|
120 |
+
$level = 0; $color ='';
|
121 |
+
$file = $default_attachments_dir . '/' . $filename;
|
122 |
+
$extension = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
|
123 |
+
if( $filename == '.' || $filename == '..') continue;
|
124 |
+
if( !$level = $wpforo->moderation->spam_file($filename) ) continue;
|
125 |
+
if( $level == 2 ) $color = 'style="color:#EE9900;"';
|
126 |
+
if( $level == 3 ) $color = 'style="color:#FF0000;"';
|
127 |
+
if( $level == 4 ) $color = 'style="color:#BB0000;"';
|
128 |
+
?>
|
129 |
+
<tr>
|
130 |
+
<td class="wpf-spam-item" <?php echo $color; ?> title="<?php echo $upload_dir['baseurl'] .'/wpforo/default_attachments/'. $filename ?>">
|
131 |
+
<?php if( $wpforo->moderation->spam_file($filename, 'file-open') ): ?>
|
132 |
+
<a href="<?php echo $upload_dir['baseurl'] .'/wpforo/default_attachments/'. $filename ?>" target="_blank" <?php echo $color ?>><?php echo wpforo_text($filename, 50, false); ?></a>
|
133 |
+
<?php else: ?>
|
134 |
+
<?php echo $filename; ?>
|
135 |
+
<?php endif; ?>
|
136 |
+
<?php echo ' (' . strtoupper($extension) . ' | ' . wpforo_human_filesize(filesize($file), 1) . ')'; ?>
|
137 |
+
</td>
|
138 |
+
<td class="wpf-actions"><a href="<?php echo wp_nonce_url( admin_url( 'admin.php?page=wpforo-tools&tab=antispam&action=delete-spam-file&sfname=' . urlencode($filename) ), 'wpforo_tools_antispam_files' ); ?>" title="<?php _e('Delete this file', 'wpforo'); ?>" onclick="return confirm('<?php _e('Are you sure you want to permanently delete this file?', 'wpforo'); ?>');"><?php _e('Delete', 'wpforo'); ?></a></td>
|
139 |
+
</tr>
|
140 |
+
<?php
|
141 |
+
endwhile;
|
142 |
+
closedir($handle);
|
143 |
+
endif;
|
144 |
+
endif;
|
145 |
+
?>
|
146 |
+
<tr style="background:#fff;">
|
147 |
+
<td colspan="2" class="wpf-actions" style="padding-top:20px; text-align:right;">
|
148 |
+
<a href="<?php echo wp_nonce_url( admin_url( 'admin.php?page=wpforo-tools&tab=antispam&action=delete-all&level=1' ), 'wpforo_tools_antispam_files' ); ?>"
|
149 |
+
title="<?php _e('Click to delete Blue marked files', 'wpforo'); ?>"
|
150 |
+
onclick="return confirm('<?php _e('Are you sure you want to delete all BLUE marked files listed here. Please download Wordpress /wp-content/uploads/wpforo/ folder to your local computer before deleting files, this is not undoable.', 'wpforo'); ?>');">
|
151 |
+
<?php _e('Delete All', 'wpforo'); ?>
|
152 |
+
</a> |
|
153 |
+
<a href="<?php echo wp_nonce_url( admin_url( 'admin.php?page=wpforo-tools&tab=antispam&action=delete-all&level=2' ), 'wpforo_tools_antispam_files' ); ?>"
|
154 |
+
title="<?php _e('Click to delete Orange marked files', 'wpforo'); ?>"
|
155 |
+
style="color:#EE9900;"
|
156 |
+
onclick="return confirm('<?php _e('Are you sure you want to delete all ORANGE marked files listed here. Please download Wordpress /wp-content/uploads/wpforo/ folder to your local computer before deleting files, this is not undoable.', 'wpforo'); ?>');">
|
157 |
+
<?php _e('Delete All', 'wpforo'); ?>
|
158 |
+
</a> |
|
159 |
+
<a href="<?php echo wp_nonce_url( admin_url( 'admin.php?page=wpforo-tools&tab=antispam&action=delete-all&level=3' ), 'wpforo_tools_antispam_files' ); ?>"
|
160 |
+
title="<?php _e('Click to delete Red marked files', 'wpforo'); ?>"
|
161 |
+
style="color:#FF0000;"
|
162 |
+
onclick="return confirm('<?php _e('Are you sure you want to delete all RED marked files listed here. Please download Wordpress /wp-content/uploads/wpforo/ folder to your local computer before deleting files, this is not undoable.', 'wpforo'); ?>');">
|
163 |
+
<?php _e('Delete All', 'wpforo'); ?>
|
164 |
+
</a> |
|
165 |
+
<a href="<?php echo wp_nonce_url( admin_url( 'admin.php?page=wpforo-tools&tab=antispam&action=delete-all&level=4' ), 'wpforo_tools_antispam_files' ); ?>"
|
166 |
+
title="<?php _e('Click to delete Dark Red marked files', 'wpforo'); ?>"
|
167 |
+
style="color:#BB0000;"
|
168 |
+
onclick="return confirm('<?php _e('Are you sure you want to delete all DARK RED marked files listed here. Please download Wordpress /wp-content/uploads/wpforo/ folder to your local computer before deleting files, this is not undoable.', 'wpforo'); ?>');">
|
169 |
+
<?php _e('Delete All', 'wpforo'); ?>
|
170 |
+
</a>
|
171 |
+
</td>
|
172 |
+
</tr>
|
173 |
+
</tbody>
|
174 |
+
</table>
|
175 |
+
</div>
|
176 |
+
</div>
|
177 |
+
<div style="clear:both;"></div>
|
178 |
+
<div class="wpforo_settings_foot" style="clear:both; margin-top:20px;">
|
179 |
+
<input type="submit" class="button button-primary" value="<?php _e('Update Options', 'wpforo'); ?>" />
|
180 |
+
</div>
|
181 |
+
</form>
|
182 |
+
<?php endif ?>
|
wpf-admin/tools-tabs/cleanup.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// Exit if accessed directly
|
3 |
+
if( !defined( 'ABSPATH' ) ) exit;
|
4 |
+
if( !current_user_can('administrator') ) exit;
|
5 |
+
?>
|
6 |
+
|
7 |
+
<?php if( !isset( $_GET['action'] ) ): ?>
|
8 |
+
|
9 |
+
<form action="" method="POST" class="validate">
|
10 |
+
<?php wp_nonce_field( 'wpforo-tools-antispam' ); ?>
|
11 |
+
<div style="width:50%; border:1px solid #ddd; background:#fff; padding:10px;">
|
12 |
+
<h3></h3>
|
13 |
+
<div></div>
|
14 |
+
</div>
|
15 |
+
<div class="wpforo_settings_foot" style="clear:both; margin-top:20px;">
|
16 |
+
<input type="submit" class="button button-primary" value="<?php _e('Update Options', 'wpforo'); ?>" />
|
17 |
+
</div>
|
18 |
+
</form>
|
19 |
+
<?php endif ?>
|
wpf-admin/tools.php
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// Exit if accessed directly
|
3 |
+
if( !defined( 'ABSPATH' ) ) exit;
|
4 |
+
if( !current_user_can('administrator') ) exit;
|
5 |
+
?>
|
6 |
+
|
7 |
+
<?php $plugins = true; ?>
|
8 |
+
<div class="wrap"><h2 style="padding:0px 0px 30px 0px;line-height: 20px;"><?php _e('Forum Tools') ?></h2></div>
|
9 |
+
<?php $wpforo->notice->show(FALSE) ?>
|
10 |
+
<?php do_action('wpforo_tools_page_top') ?>
|
11 |
+
<div id="wpf-admin-wrap" class="wrap"><div id="icon-users" class="icon32"><br /></div>
|
12 |
+
<?php
|
13 |
+
$tabs = array(
|
14 |
+
'antispam' => __('Antispam', 'wpforo'),
|
15 |
+
//'cleanup' => __('Cleanup', 'wpforo')
|
16 |
+
);
|
17 |
+
wpforo_admin_tools_tabs( $tabs, ( isset($_GET['tab']) ? $_GET['tab'] : 'antispam' ) );
|
18 |
+
?>
|
19 |
+
<div class="wpf-info-bar" style="padding:1% 2%;">
|
20 |
+
<?php
|
21 |
+
if(isset($_GET['tab'])){
|
22 |
+
switch($_GET['tab']){
|
23 |
+
case 'antispam':
|
24 |
+
include( 'tools-tabs/antispam.php' );
|
25 |
+
break;
|
26 |
+
case 'cleanup':
|
27 |
+
include( 'tools-tabs/cleanup.php' );
|
28 |
+
break;
|
29 |
+
default:
|
30 |
+
include_once( 'tools-tabs/antispam.php' );
|
31 |
+
}
|
32 |
+
}else{
|
33 |
+
include_once( 'tools-tabs/antispam.php' );
|
34 |
+
}
|
35 |
+
?>
|
36 |
+
</div>
|
37 |
+
</div>
|
wpf-admin/xml/english.xml
CHANGED
@@ -364,11 +364,20 @@
|
|
364 |
<phrase name="Welcome back %s!"><![CDATA[Welcome back %s!]]></phrase>
|
365 |
<phrase name="Member Profile"><![CDATA[Member Profile]]></phrase>
|
366 |
<phrase name="Member"><![CDATA[Member]]></phrase>
|
367 |
-
<phrase name="
|
368 |
-
<phrase name="
|
369 |
<phrase name="Private Topic"><![CDATA[Private Topic]]></phrase>
|
370 |
<phrase name="Only Admins and Moderators can see your private topics."><![CDATA[Only Admins and Moderators can see your private topics.]]></phrase>
|
371 |
<phrase name="Forum ID is not detected"><![CDATA[Forum ID is not detected]]></phrase>
|
372 |
<phrase name="You are not permitted to subscribe here"><![CDATA[You are not permitted to subscribe here]]></phrase>
|
373 |
<phrase name="Subscribe to this topic"><![CDATA[Subscribe to this topic]]></phrase>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
374 |
</language>
|
364 |
<phrase name="Welcome back %s!"><![CDATA[Welcome back %s!]]></phrase>
|
365 |
<phrase name="Member Profile"><![CDATA[Member Profile]]></phrase>
|
366 |
<phrase name="Member"><![CDATA[Member]]></phrase>
|
367 |
+
<phrase name="private"><![CDATA[private]]></phrase>
|
368 |
+
<phrase name="public"><![CDATA[public]]></phrase>
|
369 |
<phrase name="Private Topic"><![CDATA[Private Topic]]></phrase>
|
370 |
<phrase name="Only Admins and Moderators can see your private topics."><![CDATA[Only Admins and Moderators can see your private topics.]]></phrase>
|
371 |
<phrase name="Forum ID is not detected"><![CDATA[Forum ID is not detected]]></phrase>
|
372 |
<phrase name="You are not permitted to subscribe here"><![CDATA[You are not permitted to subscribe here]]></phrase>
|
373 |
<phrase name="Subscribe to this topic"><![CDATA[Subscribe to this topic]]></phrase>
|
374 |
+
<phrase name="Awaiting moderation"><![CDATA[Awaiting moderation]]></phrase>
|
375 |
+
<phrase name="Topic first post not found."><![CDATA[Topic first post not found.]]></phrase>
|
376 |
+
<phrase name="Topic first post data not found."><![CDATA[Topic first post data not found.]]></phrase>
|
377 |
+
<phrase name="Done!"><![CDATA[Done!]]></phrase>
|
378 |
+
<phrase name="unapproved"><![CDATA[unapproved]]></phrase>
|
379 |
+
<phrase name="You are not allowed to attach this file type"><![CDATA[You are not allowed to attach this file type]]></phrase>
|
380 |
+
<phrase name="Post is empty"><![CDATA[Post is empty]]></phrase>
|
381 |
+
<phrase name="removed link"><![CDATA[removed link]]></phrase>
|
382 |
+
<phrase name="Submit"><![CDATA[Submit]]></phrase>
|
383 |
</language>
|
wpf-includes/class-members.php
CHANGED
@@ -1134,6 +1134,55 @@ class wpForoMember{
|
|
1134 |
<?php endif;
|
1135 |
}
|
1136 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1137 |
}
|
1138 |
|
1139 |
?>
|
1134 |
<?php endif;
|
1135 |
}
|
1136 |
|
1137 |
+
|
1138 |
+
|
1139 |
+
public function autoban($userid){
|
1140 |
+
if( !$this->wpforo->perm->usergroup_can( 'em' ) ){
|
1141 |
+
$this->wpforo->db->update(
|
1142 |
+
$this->wpforo->db->prefix.'wpforo_profiles',
|
1143 |
+
array('status' => 'banned'),
|
1144 |
+
array('userid' => intval( $userid )),
|
1145 |
+
array('%s'),
|
1146 |
+
array('%d')
|
1147 |
+
);
|
1148 |
+
}
|
1149 |
+
}
|
1150 |
+
|
1151 |
+
public function member_approved_posts( $member = array() ){
|
1152 |
+
if(is_numeric($member)){
|
1153 |
+
if( isset($this->wpforo->current_user['posts']) && $this->wpforo->current_user['posts'] && $member == $this->wpforo->current_userid ){
|
1154 |
+
return $this->wpforo->current_user['posts'];
|
1155 |
+
}
|
1156 |
+
else{
|
1157 |
+
return $this->wpforo->db->get_var( "SELECT COUNT(*) as posts FROM `".$this->wpforo->db->prefix."wpforo_posts` WHERE `status` = 0 AND `userid` = " . intval($member) );
|
1158 |
+
}
|
1159 |
+
}
|
1160 |
+
elseif(is_array($member) && !empty($member)){
|
1161 |
+
return intval($member['posts']);
|
1162 |
+
}
|
1163 |
+
else{
|
1164 |
+
return 0;
|
1165 |
+
}
|
1166 |
+
}
|
1167 |
+
|
1168 |
+
public function current_user_is_new(){
|
1169 |
+
if( $this->wpforo->perm->usergroup_can( 'em' ) ){
|
1170 |
+
//This is an admin or moderator. The number of posts doesn't matter.
|
1171 |
+
return false;
|
1172 |
+
}
|
1173 |
+
else{
|
1174 |
+
$posts = $this->member_approved_posts( $this->wpforo->current_userid );
|
1175 |
+
if ( $posts < $this->wpforo->tools_antispam['new_user_max_posts'] ) {
|
1176 |
+
return true;
|
1177 |
+
}
|
1178 |
+
}
|
1179 |
+
}
|
1180 |
+
|
1181 |
+
function banned_count(){
|
1182 |
+
$count = $this->wpforo->db->get_var("SELECT count(*) FROM `".$this->wpforo->db->prefix."wpforo_profiles` WHERE `status` = 'banned' " );
|
1183 |
+
return $count;
|
1184 |
+
}
|
1185 |
+
|
1186 |
}
|
1187 |
|
1188 |
?>
|
wpf-includes/class-moderation.php
ADDED
@@ -0,0 +1,381 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// Exit if accessed directly
|
3 |
+
if (!defined('ABSPATH')) exit;
|
4 |
+
|
5 |
+
class wpForoModeration
|
6 |
+
{
|
7 |
+
private $wpforo;
|
8 |
+
private $db;
|
9 |
+
public $post_statuses;
|
10 |
+
|
11 |
+
public function __construct($wpforo)
|
12 |
+
{
|
13 |
+
$this->wpforo = $wpforo;
|
14 |
+
$this->db = $wpforo->db;
|
15 |
+
$this->post_statuses = apply_filters('wpforo_post_statuses', array('approved', 'unapproved'));
|
16 |
+
}
|
17 |
+
|
18 |
+
public function init(){
|
19 |
+
if( !$this->wpforo->perm->usergroup_can( 'aup' ) ){
|
20 |
+
add_filter('wpforo_add_topic_data_filter', array(&$this, 'auto_moderate'));
|
21 |
+
add_filter('wpforo_add_topic_data_filter', array(&$this, 'auto_moderate'));
|
22 |
+
}
|
23 |
+
else{
|
24 |
+
if( !$this->wpforo->perm->can_link() ){
|
25 |
+
add_filter('wpforo_add_topic_data_filter', array(&$this, 'remove_links'), 7);
|
26 |
+
add_filter('wpforo_edit_topic_data_filter', array(&$this, 'remove_links'), 7);
|
27 |
+
add_filter('wpforo_add_post_data_filter', array(&$this, 'remove_links'), 7);
|
28 |
+
add_filter('wpforo_edit_post_data_filter', array(&$this, 'remove_links'), 7);
|
29 |
+
}
|
30 |
+
if( $this->wpforo->member->current_user_is_new() ){
|
31 |
+
if (class_exists('Akismet')) {
|
32 |
+
add_filter('wpforo_add_topic_data_filter', array(&$this, 'akismet_topic'), 8);
|
33 |
+
add_filter('wpforo_edit_topic_data_filter', array(&$this, 'akismet_topic'), 8);
|
34 |
+
add_filter('wpforo_add_post_data_filter', array(&$this, 'akismet_post'), 8);
|
35 |
+
add_filter('wpforo_edit_post_data_filter', array(&$this, 'akismet_post'), 8);
|
36 |
+
}
|
37 |
+
if ( $this->wpforo->tools_antispam['spam_filter'] ) {
|
38 |
+
add_filter('wpforo_add_topic_data_filter', array(&$this, 'spam_topic'), 9);
|
39 |
+
add_filter('wpforo_edit_topic_data_filter', array(&$this, 'spam_topic'), 9);
|
40 |
+
add_filter('wpforo_add_topic_data_filter', array(&$this, 'spam_post'), 9);
|
41 |
+
add_filter('wpforo_edit_topic_data_filter', array(&$this, 'spam_post'), 9);
|
42 |
+
add_filter('wpforo_add_post_data_filter', array(&$this, 'spam_post'), 9);
|
43 |
+
add_filter('wpforo_edit_post_data_filter', array(&$this, 'spam_post'), 9);
|
44 |
+
}
|
45 |
+
}
|
46 |
+
add_filter('wpforo_add_topic_data_filter', array(&$this, 'auto_moderate'), 10);
|
47 |
+
add_filter('wpforo_add_post_data_filter', array(&$this, 'auto_moderate'), 10);
|
48 |
+
}
|
49 |
+
}
|
50 |
+
|
51 |
+
public function get_post_status_dname($status)
|
52 |
+
{
|
53 |
+
$status = intval($status);
|
54 |
+
return (isset($this->post_statuses[$status]) ? $this->post_statuses[$status] : $status);
|
55 |
+
}
|
56 |
+
|
57 |
+
public function get_moderations($args, &$items_count = 0)
|
58 |
+
{
|
59 |
+
if (isset($_GET['filter_by_userid']) && wpforo_bigintval($_GET['filter_by_userid'])) $args['userid'] = wpforo_bigintval($_GET['filter_by_userid']);
|
60 |
+
$filter_by_status = intval((isset($_GET['filter_by_status']) ? $_GET['filter_by_status'] : 1));
|
61 |
+
$args['status'] = $filter_by_status;
|
62 |
+
if( !isset($_GET['order']) ) $args['order'] = 'DESC';
|
63 |
+
$posts = $this->wpforo->post->get_posts($args, $items_count);
|
64 |
+
return $posts;
|
65 |
+
}
|
66 |
+
|
67 |
+
public function search($needle, $fields = array())
|
68 |
+
{
|
69 |
+
$posts = $this->wpforo->post->search($needle);
|
70 |
+
$pids = array();
|
71 |
+
foreach ($posts as $post) $pids[] = $post['postid'];
|
72 |
+
return $pids;
|
73 |
+
}
|
74 |
+
|
75 |
+
public function post_approve($postid)
|
76 |
+
{
|
77 |
+
return $this->wpforo->post->status($postid, 0);
|
78 |
+
}
|
79 |
+
|
80 |
+
public function post_unapprove($postid)
|
81 |
+
{
|
82 |
+
return $this->wpforo->post->status($postid, 1);
|
83 |
+
}
|
84 |
+
|
85 |
+
public function get_view_url($arg)
|
86 |
+
{
|
87 |
+
return $this->wpforo->post->get_post_url($arg);
|
88 |
+
}
|
89 |
+
|
90 |
+
public function akismet_topic($item)
|
91 |
+
{
|
92 |
+
$post = array();
|
93 |
+
$post['user_ip'] = (isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : null);
|
94 |
+
$post['user_agent'] = (isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null);
|
95 |
+
$post['referrer'] = (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null);
|
96 |
+
$post['blog'] = get_option('home');
|
97 |
+
$post['blog_lang'] = get_locale();
|
98 |
+
$post['blog_charset'] = get_option('blog_charset');
|
99 |
+
$post['comment_type'] = 'forum-post';
|
100 |
+
|
101 |
+
if (empty($item['forumid'])) {
|
102 |
+
$topic = $this->wpforo->topic->get_topic($item['topicid']);
|
103 |
+
$item['forumid'] = $topic['forumid'];
|
104 |
+
}
|
105 |
+
|
106 |
+
$post['comment_author'] = $this->wpforo->current_user['user_nicename'];
|
107 |
+
$post['comment_author_email'] = $this->wpforo->current_user['user_email'];
|
108 |
+
$post['comment_author_url'] = $this->wpforo->member->get_profile_url($this->wpforo->current_userid);
|
109 |
+
$post['comment_post_modified_gmt'] = current_time('mysql', 1);
|
110 |
+
$post['comment_content'] = $item['title'] . " \r\n " . $item['body'];
|
111 |
+
$post['permalink'] = $this->wpforo->forum->get_forum_url($item['forumid']);
|
112 |
+
|
113 |
+
$response = Akismet::http_post(Akismet::build_query($post), 'comment-check');
|
114 |
+
if ($response[1] == 'true') {
|
115 |
+
$this->ban_for_spam( $this->wpforo->current_userid );
|
116 |
+
$item['status'] = 1;
|
117 |
+
}
|
118 |
+
|
119 |
+
return $item;
|
120 |
+
}
|
121 |
+
|
122 |
+
public function akismet_post($item)
|
123 |
+
{
|
124 |
+
$post = array();
|
125 |
+
$post['user_ip'] = (isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : null);
|
126 |
+
$post['user_agent'] = (isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null);
|
127 |
+
$post['referrer'] = (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null);
|
128 |
+
$post['blog'] = get_option('home');
|
129 |
+
$post['blog_lang'] = get_locale();
|
130 |
+
$post['blog_charset'] = get_option('blog_charset');
|
131 |
+
$post['comment_type'] = 'forum-post';
|
132 |
+
|
133 |
+
$topic = $this->wpforo->topic->get_topic($item['topicid']);
|
134 |
+
|
135 |
+
$post['comment_author'] = $this->wpforo->current_user['user_nicename'];
|
136 |
+
$post['comment_author_email'] = $this->wpforo->current_user['user_email'];
|
137 |
+
$post['comment_author_url'] = $this->wpforo->member->get_profile_url($this->wpforo->current_userid);
|
138 |
+
$post['comment_post_modified_gmt'] = $topic['modified'];
|
139 |
+
$post['comment_content'] = $item['body'];
|
140 |
+
$post['permalink'] = $this->wpforo->topic->get_topic_url($item['topicid']);
|
141 |
+
|
142 |
+
$response = Akismet::http_post(Akismet::build_query($post), 'comment-check');
|
143 |
+
if ($response[1] == 'true') {
|
144 |
+
$this->ban_for_spam( $this->wpforo->current_userid );
|
145 |
+
$item['status'] = 1;
|
146 |
+
}
|
147 |
+
|
148 |
+
return $item;
|
149 |
+
}
|
150 |
+
|
151 |
+
public function spam_attachment(){
|
152 |
+
$upload_dir = wp_upload_dir();
|
153 |
+
$default_attachments_dir = $upload_dir['basedir'] . '/wpforo/default_attachments/';
|
154 |
+
if(is_dir($default_attachments_dir)){
|
155 |
+
if ($handle = opendir($default_attachments_dir)){
|
156 |
+
while (false !== ($filename = readdir($handle))){
|
157 |
+
$file = $default_attachments_dir . '/' . $filename;
|
158 |
+
if( $filename == '.' || $filename == '..') continue;
|
159 |
+
$level = $this->spam_file($filename);
|
160 |
+
if( $level > 2 ){
|
161 |
+
$link = '<a href="' . admin_url('admin.php?page=wpforo-tools&tab=antispam#spam-files') . '"><strong>>></strong></a>';
|
162 |
+
$phrase = '<strong>SPAM! - </strong>' . sprintf( __('Probably spam file attachments have been detected by wpForo Spam Control. Please moderate suspected files here %s', 'wpforo'), $link);
|
163 |
+
$this->wpforo->notice->add( $phrase, 'error' );
|
164 |
+
return true;
|
165 |
+
}
|
166 |
+
}
|
167 |
+
}
|
168 |
+
}
|
169 |
+
return false;
|
170 |
+
}
|
171 |
+
|
172 |
+
public function spam_file( $item, $type = 'file' ){
|
173 |
+
if( !isset($item) || !$item ) return false;
|
174 |
+
$level = 0;
|
175 |
+
$item = strtolower($item);
|
176 |
+
$spam_file_phrases = array(
|
177 |
+
0 => array( 'watch', 'movie'),
|
178 |
+
1 => array( 'download', 'free')
|
179 |
+
);
|
180 |
+
if($type == 'file'){
|
181 |
+
$ext = strtolower(pathinfo($item, PATHINFO_EXTENSION));
|
182 |
+
$ext_risk = array('pdf', 'doc', 'docx', 'txt', 'htm', 'html', 'rtf', 'xml', 'xls', 'xlsx', 'php', 'cgi');
|
183 |
+
$ext_high_risk = array('php', 'cgi', 'exe');
|
184 |
+
if( in_array($ext, $ext_risk) ){
|
185 |
+
$has_post = $this->wpforo->db->get_var( "SELECT `postid` FROM `".$this->wpforo->db->prefix."wpforo_posts` WHERE `body` LIKE '%" . esc_sql( $item ) . "%' LIMIT 1" );
|
186 |
+
foreach($spam_file_phrases as $phrases){
|
187 |
+
foreach($phrases as $phrase){
|
188 |
+
if( strpos($item, $phrase) !== FALSE ){
|
189 |
+
if( !$has_post ){
|
190 |
+
$level = 4; break 2;
|
191 |
+
}
|
192 |
+
else{
|
193 |
+
$level = 2; break 2;
|
194 |
+
}
|
195 |
+
}
|
196 |
+
}
|
197 |
+
}
|
198 |
+
if( !$level ){
|
199 |
+
if( !$has_post ){
|
200 |
+
$level = 3;
|
201 |
+
}
|
202 |
+
else{
|
203 |
+
if( in_array($ext, $ext_high_risk) ){
|
204 |
+
$level = 5;
|
205 |
+
}
|
206 |
+
else{
|
207 |
+
$level = 1;
|
208 |
+
}
|
209 |
+
}
|
210 |
+
}
|
211 |
+
}
|
212 |
+
return $level;
|
213 |
+
}
|
214 |
+
elseif($type == 'file-open'){
|
215 |
+
$ext = strtolower(pathinfo($item, PATHINFO_EXTENSION));
|
216 |
+
$allow_to_open = array('pdf', 'doc', 'docx', 'txt', 'rtf', 'xls', 'xlsx');
|
217 |
+
if( in_array($ext, $allow_to_open) ){
|
218 |
+
return true;
|
219 |
+
}
|
220 |
+
else{
|
221 |
+
return false;
|
222 |
+
}
|
223 |
+
}
|
224 |
+
return 0;
|
225 |
+
}
|
226 |
+
|
227 |
+
public function spam_topic($topic)
|
228 |
+
{
|
229 |
+
if( empty($topic) ) return $topic;
|
230 |
+
if( isset($topic['title']) ){
|
231 |
+
$item = $topic['title'];
|
232 |
+
}
|
233 |
+
else{
|
234 |
+
return $topic;
|
235 |
+
}
|
236 |
+
$len = wpfor_strlen($item);
|
237 |
+
if( $len < 10 ) return $topic;
|
238 |
+
$item = strip_tags($item);
|
239 |
+
$is_similar = false;
|
240 |
+
$topic_args = array( 'userid' => $topic['userid'] );
|
241 |
+
$topics = $this->wpforo->topic->get_topics($topic_args);
|
242 |
+
$sc_level = ( isset($this->wpforo->tools_antispam['spam_filter_level_topic'])) ? intval($this->wpforo->tools_antispam['spam_filter_level_topic']) : 100;
|
243 |
+
if( $sc_level > 100 ) $sc_level = 60; $sc_level = (101 - $sc_level);
|
244 |
+
if( !empty($topics) ){
|
245 |
+
$count = count($topics);
|
246 |
+
$keys[0] = array_rand($topics); if( $count > 1) $keys[1] = array_rand($topics);
|
247 |
+
$check_1 = (isset($keys[0])) ? strip_tags($topics[$keys[0]]['title']) : '';
|
248 |
+
$check_2 = (isset($keys[1])) ? strip_tags($topics[$keys[1]]['title']) : '';
|
249 |
+
if($check_1){ similar_text($item, $check_1, $percent); if( $percent > $sc_level ) $is_similar = true; }
|
250 |
+
if($check_2 && !$is_similar){ similar_text($item, $check_2, $percent); if( $percent > $sc_level ) $is_similar = true; }
|
251 |
+
if( $is_similar ){
|
252 |
+
$this->ban_for_spam( $this->wpforo->current_userid );
|
253 |
+
$topic['status'] = 1;
|
254 |
+
}
|
255 |
+
}
|
256 |
+
return $topic;
|
257 |
+
}
|
258 |
+
|
259 |
+
public function spam_post($post)
|
260 |
+
{
|
261 |
+
if( empty($post) ) return $post;
|
262 |
+
if( isset($post['body']) ){
|
263 |
+
$item = $post['body'];
|
264 |
+
}
|
265 |
+
else{
|
266 |
+
return $post;
|
267 |
+
}
|
268 |
+
|
269 |
+
$len = wpfor_strlen($item);
|
270 |
+
$item = strip_tags($item);
|
271 |
+
$is_similar = false;
|
272 |
+
$post_args = array( 'userid' => $post['userid'] );
|
273 |
+
$posts = $this->wpforo->post->get_posts($post_args);
|
274 |
+
$sc_level = ( isset($this->wpforo->tools_antispam['spam_filter_level_post'])) ? intval($this->wpforo->tools_antispam['spam_filter_level_post']) : 100;
|
275 |
+
if( $sc_level > 100 ) $sc_level = 70; $sc_level = (101 - $sc_level);
|
276 |
+
if( !empty($posts) ){
|
277 |
+
$count = count($posts);
|
278 |
+
$keys[0] = array_rand($posts); if( $count > 1) $keys[1] = array_rand($posts);
|
279 |
+
$check_1 = (isset($keys[0])) ? strip_tags($posts[$keys[0]]['body']) : '';
|
280 |
+
$check_2 = (isset($keys[1])) ? strip_tags($posts[$keys[1]]['body']) : '';
|
281 |
+
if($check_1){ similar_text($item, $check_1, $percent); if( isset($percent) && $percent > $sc_level ) $is_similar = true; }
|
282 |
+
if($check_2 && !$is_similar){ similar_text($item, $check_2, $percent); if( isset($percent) && $percent > $sc_level ) $is_similar = true; }
|
283 |
+
if( $is_similar ){
|
284 |
+
$this->ban_for_spam( $this->wpforo->current_userid );
|
285 |
+
$post['status'] = 1;
|
286 |
+
}
|
287 |
+
}
|
288 |
+
return $post;
|
289 |
+
}
|
290 |
+
|
291 |
+
public function auto_moderate($item){
|
292 |
+
|
293 |
+
if( empty($item) ) return $item;
|
294 |
+
if( $this->wpforo->perm->usergroup_can( 'em' ) ){
|
295 |
+
$item['status'] = 0;
|
296 |
+
return $item;
|
297 |
+
}
|
298 |
+
if( !$this->wpforo->perm->usergroup_can( 'aup' ) ){
|
299 |
+
$item['status'] = 1;
|
300 |
+
return $item;
|
301 |
+
}
|
302 |
+
else{
|
303 |
+
if( $this->wpforo->member->current_user_is_new() ){
|
304 |
+
if( ( isset($item['status']) && $item['status'] == 1 ) || $this->has_unapproved( $this->wpforo->current_userid ) ){
|
305 |
+
$this->set_all_unapproved( $this->wpforo->current_userid );
|
306 |
+
$item['status'] = 1;
|
307 |
+
}
|
308 |
+
}
|
309 |
+
else{
|
310 |
+
if( !$this->has_approved( $this->wpforo->current_userid ) ){
|
311 |
+
$item['status'] = 1;
|
312 |
+
}
|
313 |
+
}
|
314 |
+
}
|
315 |
+
return $item;
|
316 |
+
}
|
317 |
+
|
318 |
+
public function has_approved($user){
|
319 |
+
if( empty($user) ) return false;
|
320 |
+
if( isset($user['ID']) ){
|
321 |
+
$userid = intval($user['ID']);
|
322 |
+
}
|
323 |
+
else{
|
324 |
+
$userid = intval($user);
|
325 |
+
}
|
326 |
+
$has_approved_post = $this->wpforo->db->get_var( "SELECT `postid` FROM `".$this->wpforo->db->prefix."wpforo_posts` WHERE `userid` = '" . intval($userid) . "' AND `status` = 0 LIMIT 1" );
|
327 |
+
if( $has_approved_post ){
|
328 |
+
return true;
|
329 |
+
}
|
330 |
+
else{
|
331 |
+
return false;
|
332 |
+
}
|
333 |
+
}
|
334 |
+
|
335 |
+
public function has_unapproved($user){
|
336 |
+
if( empty($user) ) return false;
|
337 |
+
if( isset($user['ID']) ){
|
338 |
+
$userid = intval($user['ID']);
|
339 |
+
}
|
340 |
+
else{
|
341 |
+
$userid = intval($user);
|
342 |
+
}
|
343 |
+
$has_unapproved_post = $this->wpforo->db->get_var( "SELECT `postid` FROM `".$this->wpforo->db->prefix."wpforo_posts` WHERE `userid` = '" . intval($userid) . "' AND `status` = 1 LIMIT 1" );
|
344 |
+
if( $has_unapproved_post ){
|
345 |
+
return true;
|
346 |
+
}
|
347 |
+
else{
|
348 |
+
return false;
|
349 |
+
}
|
350 |
+
}
|
351 |
+
|
352 |
+
public function ban_for_spam( $userid ){
|
353 |
+
if ( isset($userid) && $this->wpforo->tools_antispam['spam_user_ban'] ) {
|
354 |
+
if( !$this->has_approved( $this->wpforo->current_userid ) ){
|
355 |
+
$this->wpforo->member->autoban( $userid );
|
356 |
+
}
|
357 |
+
}
|
358 |
+
}
|
359 |
+
|
360 |
+
public function set_all_unapproved( $userid ){
|
361 |
+
if ( isset($userid) ) {
|
362 |
+
$this->wpforo->db->update( $this->wpforo->db->prefix."wpforo_topics", array('status' => 1), array('userid' => intval($userid)), array('%d'), array('%d'));
|
363 |
+
$this->wpforo->db->update( $this->wpforo->db->prefix."wpforo_posts", array('status' => 1), array('userid' => intval($userid)), array('%d'), array('%d'));
|
364 |
+
}
|
365 |
+
}
|
366 |
+
|
367 |
+
public function remove_links( $item ){
|
368 |
+
if( isset($item['body']) && $item['body'] ){
|
369 |
+
$item['body'] = preg_replace('/((http|https)\:\/\/)?[a-zA-Z0-9\.\/\?\:@\-_=#]+\.([a-zA-Z0-9\&\.\/\?\:@\-_=#])*/is', ' <span style="color:#aaa;">' . wpforo_phrase('removed link', false, false) . '</span> ', $item['body']);
|
370 |
+
}
|
371 |
+
if( isset($item['title']) && $item['title'] ){
|
372 |
+
if(preg_match('/((http|https)\:\/\/)?[a-zA-Z0-9\.\/\?\:@\-_=#]+\.([a-zA-Z0-9\&\.\/\?\:@\-_=#])*/is', $item['title'] )){
|
373 |
+
$item['title'] = preg_replace('/((http|https)\:\/\/)?[a-zA-Z0-9\.\/\?\:@\-_=#]+\.([a-zA-Z0-9\&\.\/\?\:@\-_=#])*/is', ' -' . wpforo_phrase('removed link', false, false) . '- ', $item['title']);
|
374 |
+
$this->auto_moderate($item);
|
375 |
+
}
|
376 |
+
}
|
377 |
+
return $item;
|
378 |
+
}
|
379 |
+
|
380 |
+
|
381 |
+
}
|
wpf-includes/class-permissions.php
CHANGED
@@ -10,10 +10,12 @@ class wpForoPermissions{
|
|
10 |
|
11 |
function __construct( $wpForo ){
|
12 |
if(!isset($this->wpforo)) $this->wpforo = $wpForo;
|
13 |
-
$
|
14 |
-
|
15 |
-
|
16 |
-
$
|
|
|
|
|
17 |
}
|
18 |
}
|
19 |
}
|
@@ -267,6 +269,52 @@ class wpForoPermissions{
|
|
267 |
return $level;
|
268 |
}
|
269 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
270 |
}
|
271 |
|
272 |
?>
|
10 |
|
11 |
function __construct( $wpForo ){
|
12 |
if(!isset($this->wpforo)) $this->wpforo = $wpForo;
|
13 |
+
if( isset( $this->wpforo->post_options['lang'] ) && $this->wpforo->post_options['lang'] ){
|
14 |
+
$accesses = $this->get_accesses();
|
15 |
+
if(!empty($accesses)){
|
16 |
+
foreach( $accesses as $access ){
|
17 |
+
$this->wpforo->access[$access['access']] = $access;
|
18 |
+
}
|
19 |
}
|
20 |
}
|
21 |
}
|
269 |
return $level;
|
270 |
}
|
271 |
|
272 |
+
|
273 |
+
|
274 |
+
public function can_link(){
|
275 |
+
if( !$this->wpforo->perm->usergroup_can( 'em' ) ){
|
276 |
+
$posts = $this->wpforo->member->member_approved_posts( $this->wpforo->current_userid );
|
277 |
+
$posts = intval($posts);
|
278 |
+
if( isset($this->wpforo->tools_antispam['min_number_post_to_link']) ){
|
279 |
+
$min_posts = intval($this->wpforo->tools_antispam['min_number_post_to_link']);
|
280 |
+
if( $min_posts != 0 ){
|
281 |
+
if ( $posts <= $min_posts ) {
|
282 |
+
return false;
|
283 |
+
}
|
284 |
+
}
|
285 |
+
}
|
286 |
+
}
|
287 |
+
return true;
|
288 |
+
}
|
289 |
+
|
290 |
+
public function can_attach(){
|
291 |
+
if( !$this->wpforo->perm->usergroup_can( 'em' ) ){
|
292 |
+
$posts = $this->wpforo->member->member_approved_posts( $this->wpforo->current_userid );
|
293 |
+
$posts = intval($posts);
|
294 |
+
if( isset($this->wpforo->tools_antispam['min_number_post_to_attach']) ){
|
295 |
+
$min_posts = intval($this->wpforo->tools_antispam['min_number_post_to_attach']);
|
296 |
+
if( $min_posts != 0 ){
|
297 |
+
if ( $posts <= $min_posts ) {
|
298 |
+
return false;
|
299 |
+
}
|
300 |
+
}
|
301 |
+
}
|
302 |
+
}
|
303 |
+
return true;
|
304 |
+
}
|
305 |
+
|
306 |
+
public function can_attach_file_type( $ext = '' ){
|
307 |
+
if( !$this->wpforo->perm->usergroup_can( 'em' ) ){
|
308 |
+
if( isset($this->wpforo->tools_antispam['limited_file_ext']) && $this->wpforo->member->current_user_is_new() ){
|
309 |
+
$expld = explode('|', $this->wpforo->tools_antispam['limited_file_ext'] );
|
310 |
+
if( in_array($ext, $expld) ){
|
311 |
+
return false;
|
312 |
+
}
|
313 |
+
}
|
314 |
+
}
|
315 |
+
return true;
|
316 |
+
}
|
317 |
+
|
318 |
}
|
319 |
|
320 |
?>
|
wpf-includes/class-posts.php
CHANGED
@@ -12,8 +12,10 @@ class wpForoPost{
|
|
12 |
}
|
13 |
|
14 |
public function add( $args = array() ){
|
|
|
15 |
if( empty($args) && empty($_REQUEST['post']) ){ $this->wpforo->notice->add('Reply request error', 'error'); return FALSE; }
|
16 |
if( empty($args) && !empty($_REQUEST['post']) ){ $args = $_REQUEST['post']; $args['body'] = $_REQUEST['postbody']; }
|
|
|
17 |
|
18 |
extract($args, EXTR_OVERWRITE);
|
19 |
|
@@ -31,6 +33,8 @@ class wpForoPost{
|
|
31 |
return FALSE;
|
32 |
}
|
33 |
|
|
|
|
|
34 |
$post = $args;
|
35 |
$post['forumid'] = $forumid = (isset($topic['forumid']) ? intval($topic['forumid']) : 0);
|
36 |
$post['parentid'] = $parentid = (isset($parentid) ? intval($parentid) : 0);
|
@@ -40,6 +44,7 @@ class wpForoPost{
|
|
40 |
$post['userid'] = $userid = ( isset($userid) ? intval($userid) : $this->wpforo->current_userid );
|
41 |
|
42 |
$post = apply_filters('wpforo_add_post_data_filter', $post);
|
|
|
43 |
if(empty($post)) return FALSE;
|
44 |
|
45 |
extract($post, EXTR_OVERWRITE);
|
@@ -51,6 +56,7 @@ class wpForoPost{
|
|
51 |
if(isset($created)) $created = sanitize_text_field($created);
|
52 |
if(isset($userid)) $userid = intval($userid);
|
53 |
if(isset($body)) $body = wpforo_kses(trim($body), 'post');
|
|
|
54 |
|
55 |
do_action( 'wpforo_before_add_post', $post );
|
56 |
|
@@ -65,9 +71,10 @@ class wpForoPost{
|
|
65 |
'title' => stripslashes($title),
|
66 |
'body' => stripslashes($body),
|
67 |
'created' => $created,
|
68 |
-
'modified' => $created
|
|
|
69 |
),
|
70 |
-
array('%d','%d','%d','%d','%s','%s','%s','%s')
|
71 |
)
|
72 |
){
|
73 |
$postid = $this->wpforo->db->insert_id;
|
@@ -101,22 +108,26 @@ class wpForoPost{
|
|
101 |
}
|
102 |
|
103 |
public function edit( $args = array() ){
|
|
|
104 |
if( empty($args) && (!isset($_REQUEST['post']) || empty($_REQUEST['post'])) ) return FALSE;
|
105 |
if( empty($args) && !empty($_REQUEST['post']) ){ $args = $_REQUEST['post']; $args['body'] = $_REQUEST['postbody']; }
|
106 |
|
107 |
-
|
108 |
-
if(empty($args)) return FALSE;
|
109 |
|
110 |
-
|
111 |
-
|
112 |
-
if( !isset($postid) || !$postid || !is_numeric($postid) ){
|
113 |
$this->wpforo->notice->add('Cannot update post data', 'error');
|
114 |
return FALSE;
|
115 |
}
|
|
|
|
|
116 |
|
117 |
-
$
|
|
|
|
|
|
|
|
|
118 |
|
119 |
-
|
120 |
|
121 |
$diff = current_time( 'timestamp', 1 ) - strtotime($post['created']);
|
122 |
if( !($this->wpforo->perm->forum_can('er', $post['forumid']) || ($this->wpforo->current_userid == $post['userid'] && $this->wpforo->perm->forum_can('eor', $post['forumid']) && $diff < $this->wpforo->post_options['eor_durr'])) ){
|
@@ -135,20 +146,22 @@ class wpForoPost{
|
|
135 |
if(isset($created)) $created = sanitize_text_field($created);
|
136 |
if(isset($userid)) $userid = intval($userid);
|
137 |
if(isset($body)) $body = wpforo_kses(trim($body), 'post');
|
|
|
138 |
|
139 |
if( FALSE !== $this->wpforo->db->update(
|
140 |
$this->wpforo->db->prefix."wpforo_posts",
|
141 |
array(
|
142 |
-
'title'
|
143 |
-
'body' => stripslashes($body),
|
144 |
-
'modified' => current_time( 'mysql', 1
|
|
|
145 |
),
|
146 |
array('postid' => $postid),
|
147 |
-
array('%s','%s','%s'),
|
148 |
array('%d')
|
149 |
)
|
150 |
){
|
151 |
-
do_action( 'wpforo_after_edit_post', array( 'postid' => $postid, 'topicid' => $topicid, 'title' => $title, 'body' => $body ) );
|
152 |
|
153 |
$this->wpforo->notice->add('This post successfully edited', 'success');
|
154 |
return $postid;
|
@@ -160,7 +173,7 @@ class wpForoPost{
|
|
160 |
|
161 |
#################################################################################
|
162 |
/**
|
163 |
-
* Delete
|
164 |
*
|
165 |
* Returns true if successfully deleted or false.
|
166 |
*
|
@@ -173,13 +186,19 @@ class wpForoPost{
|
|
173 |
|
174 |
$postid = intval($postid);
|
175 |
|
176 |
-
|
|
|
|
|
177 |
$diff = current_time( 'timestamp', 1 ) - strtotime($post['created']);
|
178 |
if( !($this->wpforo->perm->forum_can('dr', $post['forumid']) || ($this->wpforo->current_userid == $post['userid'] && $this->wpforo->perm->forum_can('dor', $post['forumid']) && $diff < $this->wpforo->post_options['dor_durr'])) ){
|
179 |
$this->wpforo->notice->add('You haven\'t permission to delete post from this forum', 'error');
|
180 |
return FALSE;
|
181 |
}
|
182 |
|
|
|
|
|
|
|
|
|
183 |
if( $this->wpforo->db->delete($this->wpforo->db->prefix . 'wpforo_posts', array( 'postid' => intval($postid) ), array( '%d' )) ){
|
184 |
$last_post = $this->get_posts( array('topicid' => intval($post['topicid']), 'order' => 'DESC', 'row_count' => 1) );
|
185 |
if(is_array($last_post) && !empty($last_post)){
|
@@ -219,8 +238,13 @@ class wpForoPost{
|
|
219 |
}
|
220 |
}
|
221 |
|
222 |
-
$
|
223 |
-
|
|
|
|
|
|
|
|
|
|
|
224 |
}
|
225 |
|
226 |
#################################################################################
|
@@ -247,6 +271,12 @@ class wpForoPost{
|
|
247 |
$post = $this->wpforo->db->get_row($sql, ARRAY_A);
|
248 |
if(!empty($post)) $post['userid'] = intval($post['userid']);
|
249 |
|
|
|
|
|
|
|
|
|
|
|
|
|
250 |
if($cache && isset($postid)){
|
251 |
self::$cache['post'][$postid] = $post;
|
252 |
}
|
@@ -277,7 +307,8 @@ class wpForoPost{
|
|
277 |
'order' => 'ASC', // ASC DESC
|
278 |
'offset' => NULL, // this use when you give row_count
|
279 |
'row_count' => NULL, // 4 or 1 ...
|
280 |
-
|
|
|
281 |
'check_private' => FALSE
|
282 |
);
|
283 |
|
@@ -297,9 +328,22 @@ class wpForoPost{
|
|
297 |
if(!empty($include)) $wheres[] = $table_as_prefix . "`postid` IN(" . implode(', ', array_map('intval', $include)) . ")";
|
298 |
if(!empty($exclude)) $wheres[] = $table_as_prefix . "`postid` NOT IN(" . implode(', ', array_map('intval', $exclude)) . ")";
|
299 |
|
300 |
-
if($topicid
|
301 |
if($parentid != -1) $wheres[] = $table_as_prefix . "`parentid` = " . intval($parentid);
|
302 |
-
if($userid
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
303 |
|
304 |
if( $check_private ){
|
305 |
$sql = "SELECT DISTINCT `".$this->wpforo->db->prefix."wpforo_posts`.*, `".$this->wpforo->db->prefix."wpforo_topics`.`private` FROM `".$this->wpforo->db->prefix."wpforo_posts`, `".$this->wpforo->db->prefix."wpforo_topics`";
|
@@ -342,6 +386,11 @@ class wpForoPost{
|
|
342 |
unset($posts[$key]);
|
343 |
}
|
344 |
}
|
|
|
|
|
|
|
|
|
|
|
345 |
}
|
346 |
}
|
347 |
|
@@ -372,7 +421,7 @@ class wpForoPost{
|
|
372 |
|
373 |
$date_period = intval($date_period);
|
374 |
|
375 |
-
$selects = array('p.`postid`', 't.`topicid`', 't.`private`', 't.`forumid`', 'p.`userid`', 't.`title`', 'p.`created`', 'p.`body`' );
|
376 |
$innerjoins = array('INNER JOIN `'.$this->wpforo->db->prefix.'wpforo_topics` t ON t.`topicid` = p.`topicid`');
|
377 |
$wheres = array();
|
378 |
$orders = array();
|
@@ -432,7 +481,8 @@ class wpForoPost{
|
|
432 |
$posts = $this->wpforo->db->get_results($sql, ARRAY_A);
|
433 |
foreach($posts as $key => $post){
|
434 |
if( !$this->wpforo->perm->forum_can( 'vf', $post['forumid'] ) ) unset($posts[$key]);
|
435 |
-
if( !$this->wpforo->perm->forum_can( 'vp', $post['forumid'] )
|
|
|
436 |
}
|
437 |
return $posts;
|
438 |
}else{
|
@@ -594,14 +644,14 @@ class wpForoPost{
|
|
594 |
}
|
595 |
|
596 |
if( is_array($post) && !empty($post) ){
|
597 |
-
if( $cache && isset(self::$cache['post_url'][$post['topicid']][$post['
|
598 |
-
$position = self::$cache['post_url'][$post['topicid']][$post['
|
599 |
}
|
600 |
$url = WPFORO_BASE_URL . $this->get_forumslug_byid($postid) . '/' . $this->get_topicslug_byid($postid);
|
601 |
if( $post['topicid'] ){
|
602 |
if( !$position ) $position = $this->wpforo->db->get_var("SELECT COUNT(`postid`) FROM `".$this->wpforo->db->prefix."wpforo_posts` WHERE `topicid` = ".intval($post['topicid'])." AND `postid` <= " . ($post['parentid'] ? intval($post['parentid']) : intval($postid) ) . " ORDER BY `postid`");
|
603 |
if($cache && isset($position)){
|
604 |
-
self::$cache['post_url'][$post['topicid']][$post['
|
605 |
}
|
606 |
if( $position <= $this->wpforo->post_options['posts_per_page'] ) return $url . "/#post-" . intval($postid);
|
607 |
$paged = ceil( $position/$this->wpforo->post_options['posts_per_page'] );
|
@@ -638,5 +688,58 @@ class wpForoPost{
|
|
638 |
function get_count(){
|
639 |
return $this->wpforo->db->get_var( "SELECT COUNT(`postid`) FROM `".$this->wpforo->db->prefix."wpforo_posts`" );
|
640 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
641 |
}
|
642 |
?>
|
12 |
}
|
13 |
|
14 |
public function add( $args = array() ){
|
15 |
+
|
16 |
if( empty($args) && empty($_REQUEST['post']) ){ $this->wpforo->notice->add('Reply request error', 'error'); return FALSE; }
|
17 |
if( empty($args) && !empty($_REQUEST['post']) ){ $args = $_REQUEST['post']; $args['body'] = $_REQUEST['postbody']; }
|
18 |
+
if( !isset($args['body']) || !$args['body'] ){ $this->wpforo->notice->add('Post is empty', 'error'); return FALSE; }
|
19 |
|
20 |
extract($args, EXTR_OVERWRITE);
|
21 |
|
33 |
return FALSE;
|
34 |
}
|
35 |
|
36 |
+
do_action( 'wpforo_start_add_post', $args );
|
37 |
+
|
38 |
$post = $args;
|
39 |
$post['forumid'] = $forumid = (isset($topic['forumid']) ? intval($topic['forumid']) : 0);
|
40 |
$post['parentid'] = $parentid = (isset($parentid) ? intval($parentid) : 0);
|
44 |
$post['userid'] = $userid = ( isset($userid) ? intval($userid) : $this->wpforo->current_userid );
|
45 |
|
46 |
$post = apply_filters('wpforo_add_post_data_filter', $post);
|
47 |
+
|
48 |
if(empty($post)) return FALSE;
|
49 |
|
50 |
extract($post, EXTR_OVERWRITE);
|
56 |
if(isset($created)) $created = sanitize_text_field($created);
|
57 |
if(isset($userid)) $userid = intval($userid);
|
58 |
if(isset($body)) $body = wpforo_kses(trim($body), 'post');
|
59 |
+
if(isset($status)) $status = intval($status);
|
60 |
|
61 |
do_action( 'wpforo_before_add_post', $post );
|
62 |
|
71 |
'title' => stripslashes($title),
|
72 |
'body' => stripslashes($body),
|
73 |
'created' => $created,
|
74 |
+
'modified' => $created,
|
75 |
+
'status' => (isset($status) ? $status : 0),
|
76 |
),
|
77 |
+
array('%d','%d','%d','%d','%s','%s','%s','%s', '%d')
|
78 |
)
|
79 |
){
|
80 |
$postid = $this->wpforo->db->insert_id;
|
108 |
}
|
109 |
|
110 |
public function edit( $args = array() ){
|
111 |
+
|
112 |
if( empty($args) && (!isset($_REQUEST['post']) || empty($_REQUEST['post'])) ) return FALSE;
|
113 |
if( empty($args) && !empty($_REQUEST['post']) ){ $args = $_REQUEST['post']; $args['body'] = $_REQUEST['postbody']; }
|
114 |
|
115 |
+
do_action( 'wpforo_start_edit_post', $args );
|
|
|
116 |
|
117 |
+
if( !isset($args['postid']) || !$args['postid'] || !is_numeric($args['postid']) ){
|
|
|
|
|
118 |
$this->wpforo->notice->add('Cannot update post data', 'error');
|
119 |
return FALSE;
|
120 |
}
|
121 |
+
$args['postid'] = intval($args['postid']);
|
122 |
+
if( !$post = $this->get_post($args['postid']) ){ $this->wpforo->notice->add('No Posts found for update', 'error'); return FALSE; }
|
123 |
|
124 |
+
$args['userid'] = $post['userid'];
|
125 |
+
$args['status'] = $post['status'];
|
126 |
+
|
127 |
+
$args = apply_filters('wpforo_edit_post_data_filter', $args);
|
128 |
+
if(empty($args)) return FALSE;
|
129 |
|
130 |
+
extract($args, EXTR_OVERWRITE);
|
131 |
|
132 |
$diff = current_time( 'timestamp', 1 ) - strtotime($post['created']);
|
133 |
if( !($this->wpforo->perm->forum_can('er', $post['forumid']) || ($this->wpforo->current_userid == $post['userid'] && $this->wpforo->perm->forum_can('eor', $post['forumid']) && $diff < $this->wpforo->post_options['eor_durr'])) ){
|
146 |
if(isset($created)) $created = sanitize_text_field($created);
|
147 |
if(isset($userid)) $userid = intval($userid);
|
148 |
if(isset($body)) $body = wpforo_kses(trim($body), 'post');
|
149 |
+
if(isset($status)) $status = intval($status);
|
150 |
|
151 |
if( FALSE !== $this->wpforo->db->update(
|
152 |
$this->wpforo->db->prefix."wpforo_posts",
|
153 |
array(
|
154 |
+
'title' => ( isset($title) ? stripslashes($title) : stripslashes($post['title']) ),
|
155 |
+
'body' => ( (isset($body) && $body) ? stripslashes($body) : stripslashes($post['body']) ),
|
156 |
+
'modified' => current_time( 'mysql', 1 ),
|
157 |
+
'status' => ( isset($status) ? $status : intval($post['status']) ),
|
158 |
),
|
159 |
array('postid' => $postid),
|
160 |
+
array('%s','%s','%s','%d'),
|
161 |
array('%d')
|
162 |
)
|
163 |
){
|
164 |
+
do_action( 'wpforo_after_edit_post', array( 'postid' => $postid, 'topicid' => $topicid, 'title' => $title, 'body' => $body, 'status' => $status ) );
|
165 |
|
166 |
$this->wpforo->notice->add('This post successfully edited', 'success');
|
167 |
return $postid;
|
173 |
|
174 |
#################################################################################
|
175 |
/**
|
176 |
+
* Delete post from DB
|
177 |
*
|
178 |
* Returns true if successfully deleted or false.
|
179 |
*
|
186 |
|
187 |
$postid = intval($postid);
|
188 |
|
189 |
+
if( !$post = $this->get_post($postid) ) return true;
|
190 |
+
if( $post['is_first_post'] ) return $this->wpforo->topic->delete($post['topicid']);
|
191 |
+
|
192 |
$diff = current_time( 'timestamp', 1 ) - strtotime($post['created']);
|
193 |
if( !($this->wpforo->perm->forum_can('dr', $post['forumid']) || ($this->wpforo->current_userid == $post['userid'] && $this->wpforo->perm->forum_can('dor', $post['forumid']) && $diff < $this->wpforo->post_options['dor_durr'])) ){
|
194 |
$this->wpforo->notice->add('You haven\'t permission to delete post from this forum', 'error');
|
195 |
return FALSE;
|
196 |
}
|
197 |
|
198 |
+
//Find and delete default atatchments before deleting post
|
199 |
+
$this->delete_attachments( $postid );
|
200 |
+
|
201 |
+
//Delete post
|
202 |
if( $this->wpforo->db->delete($this->wpforo->db->prefix . 'wpforo_posts', array( 'postid' => intval($postid) ), array( '%d' )) ){
|
203 |
$last_post = $this->get_posts( array('topicid' => intval($post['topicid']), 'order' => 'DESC', 'row_count' => 1) );
|
204 |
if(is_array($last_post) && !empty($last_post)){
|
238 |
}
|
239 |
}
|
240 |
|
241 |
+
if( isset($_GET['page']) && $_GET['page'] == 'wpforo-moderations' ){
|
242 |
+
//Don't check errors
|
243 |
+
}
|
244 |
+
else{
|
245 |
+
$this->wpforo->notice->add('Post delete error', 'error');
|
246 |
+
return FALSE;
|
247 |
+
}
|
248 |
}
|
249 |
|
250 |
#################################################################################
|
271 |
$post = $this->wpforo->db->get_row($sql, ARRAY_A);
|
272 |
if(!empty($post)) $post['userid'] = intval($post['userid']);
|
273 |
|
274 |
+
if( isset($post['status']) && $post['status'] && !wpforo_is_owner($post['userid'])){
|
275 |
+
if( isset($post['forumid']) && $post['forumid'] && !$this->wpforo->perm->forum_can('au', $post['forumid']) ){
|
276 |
+
return array();
|
277 |
+
}
|
278 |
+
}
|
279 |
+
|
280 |
if($cache && isset($postid)){
|
281 |
self::$cache['post'][$postid] = $post;
|
282 |
}
|
307 |
'order' => 'ASC', // ASC DESC
|
308 |
'offset' => NULL, // this use when you give row_count
|
309 |
'row_count' => NULL, // 4 or 1 ...
|
310 |
+
'status' => NULL, // 0 or 1 ...
|
311 |
+
|
312 |
'check_private' => FALSE
|
313 |
);
|
314 |
|
328 |
if(!empty($include)) $wheres[] = $table_as_prefix . "`postid` IN(" . implode(', ', array_map('intval', $include)) . ")";
|
329 |
if(!empty($exclude)) $wheres[] = $table_as_prefix . "`postid` NOT IN(" . implode(', ', array_map('intval', $exclude)) . ")";
|
330 |
|
331 |
+
if(!is_null($topicid)) $wheres[] = $table_as_prefix . "`topicid` = " . intval($topicid);
|
332 |
if($parentid != -1) $wheres[] = $table_as_prefix . "`parentid` = " . intval($parentid);
|
333 |
+
if(!is_null($userid)) $wheres[] = $table_as_prefix . "`userid` = " . intval($userid);
|
334 |
+
if(!is_null($status)) $wheres[] = $table_as_prefix . "`status` = " . intval($status);
|
335 |
+
|
336 |
+
if( isset($forumid) && $forumid ){
|
337 |
+
if( $this->wpforo->perm->forum_can('au', $forumid) ){
|
338 |
+
if(!is_null($status)) $wheres[] = $table_as_prefix . " `status` = " . intval($status);
|
339 |
+
}
|
340 |
+
elseif( isset($this->wpforo->current_userid) && $this->wpforo->current_userid ){
|
341 |
+
$wheres[] = " ( " . $table_as_prefix . "`status` = 0 OR (" . $table_as_prefix . "`status` = 1 AND " . $table_as_prefix . "`userid` = " .intval($this->wpforo->current_userid). ") )";
|
342 |
+
}
|
343 |
+
else{
|
344 |
+
$wheres[] = " " . $table_as_prefix . "`status` = 0";
|
345 |
+
}
|
346 |
+
}
|
347 |
|
348 |
if( $check_private ){
|
349 |
$sql = "SELECT DISTINCT `".$this->wpforo->db->prefix."wpforo_posts`.*, `".$this->wpforo->db->prefix."wpforo_topics`.`private` FROM `".$this->wpforo->db->prefix."wpforo_posts`, `".$this->wpforo->db->prefix."wpforo_topics`";
|
386 |
unset($posts[$key]);
|
387 |
}
|
388 |
}
|
389 |
+
if( isset($post['forumid']) && isset($post['status']) && $post['status'] && !wpforo_is_owner($post['userid']) ){
|
390 |
+
if( !$this->wpforo->perm->forum_can('au', $post['forumid']) ){
|
391 |
+
unset($posts[$key]);
|
392 |
+
}
|
393 |
+
}
|
394 |
}
|
395 |
}
|
396 |
|
421 |
|
422 |
$date_period = intval($date_period);
|
423 |
|
424 |
+
$selects = array('p.`postid`', 't.`topicid`', 't.`private`', 't.`status`', 't.`forumid`', 'p.`userid`', 't.`title`', 'p.`created`', 'p.`body`' );
|
425 |
$innerjoins = array('INNER JOIN `'.$this->wpforo->db->prefix.'wpforo_topics` t ON t.`topicid` = p.`topicid`');
|
426 |
$wheres = array();
|
427 |
$orders = array();
|
481 |
$posts = $this->wpforo->db->get_results($sql, ARRAY_A);
|
482 |
foreach($posts as $key => $post){
|
483 |
if( !$this->wpforo->perm->forum_can( 'vf', $post['forumid'] ) ) unset($posts[$key]);
|
484 |
+
if( $post['private'] && !$this->wpforo->perm->forum_can( 'vp', $post['forumid'] ) ) unset($posts[$key]);
|
485 |
+
if( $post['status'] && !$this->wpforo->perm->forum_can( 'au', $post['forumid'] ) ) unset($posts[$key]);
|
486 |
}
|
487 |
return $posts;
|
488 |
}else{
|
644 |
}
|
645 |
|
646 |
if( is_array($post) && !empty($post) ){
|
647 |
+
if( $cache && isset(self::$cache['post_url'][$post['topicid']][$post['postid']]) ){
|
648 |
+
$position = self::$cache['post_url'][$post['topicid']][$post['postid']];
|
649 |
}
|
650 |
$url = WPFORO_BASE_URL . $this->get_forumslug_byid($postid) . '/' . $this->get_topicslug_byid($postid);
|
651 |
if( $post['topicid'] ){
|
652 |
if( !$position ) $position = $this->wpforo->db->get_var("SELECT COUNT(`postid`) FROM `".$this->wpforo->db->prefix."wpforo_posts` WHERE `topicid` = ".intval($post['topicid'])." AND `postid` <= " . ($post['parentid'] ? intval($post['parentid']) : intval($postid) ) . " ORDER BY `postid`");
|
653 |
if($cache && isset($position)){
|
654 |
+
self::$cache['post_url'][$post['topicid']][$post['postid']] = $position;
|
655 |
}
|
656 |
if( $position <= $this->wpforo->post_options['posts_per_page'] ) return $url . "/#post-" . intval($postid);
|
657 |
$paged = ceil( $position/$this->wpforo->post_options['posts_per_page'] );
|
688 |
function get_count(){
|
689 |
return $this->wpforo->db->get_var( "SELECT COUNT(`postid`) FROM `".$this->wpforo->db->prefix."wpforo_posts`" );
|
690 |
}
|
691 |
+
|
692 |
+
function unapproved_count(){
|
693 |
+
return $this->wpforo->db->get_var( "SELECT COUNT(*) FROM `".$this->wpforo->db->prefix."wpforo_posts` WHERE `status` = 1" );
|
694 |
+
}
|
695 |
+
|
696 |
+
function get_attachment_id( $filename ){
|
697 |
+
$attach_id = $this->wpforo->db->get_var( "SELECT `post_id` FROM `".$this->wpforo->db->prefix."postmeta` WHERE `meta_key` = '_wp_attached_file' AND `meta_value` LIKE '%" . esc_sql($filename) . "' LIMIT 1");
|
698 |
+
return $attach_id;
|
699 |
+
}
|
700 |
+
|
701 |
+
function delete_attachments( $postid ){
|
702 |
+
$post = $this->get_post($postid);
|
703 |
+
if( isset($post['body']) && $post['body'] ){
|
704 |
+
if( preg_match_all('|\/wpforo\/default_attachments\/([^\s\"\]]+)|is', $post['body'], $attachments, PREG_SET_ORDER) ){
|
705 |
+
$upload_dir = wp_upload_dir();
|
706 |
+
$default_attachments_dir = $upload_dir['basedir'] . '/wpforo/default_attachments/';
|
707 |
+
foreach( $attachments as $attachment ){
|
708 |
+
$filename = trim($attachment[1]);
|
709 |
+
$file = $default_attachments_dir . $filename;
|
710 |
+
if( file_exists($file) ){
|
711 |
+
$posts = $this->wpforo->db->get_var( "SELECT COUNT(*) as posts FROM `".$this->wpforo->db->prefix."wpforo_posts` WHERE `body` LIKE '%" . esc_sql( $attachment[0] ) . "%'" );
|
712 |
+
if( is_numeric($posts) && $posts == 1 ){
|
713 |
+
$attachmentid = $this->get_attachment_id( '/' . $filename );
|
714 |
+
if ( !wp_delete_attachment( $attachmentid ) ){
|
715 |
+
@unlink($file);
|
716 |
+
}
|
717 |
+
}
|
718 |
+
}
|
719 |
+
}
|
720 |
+
}
|
721 |
+
}
|
722 |
+
}
|
723 |
+
|
724 |
+
public function status( $postid, $status ){
|
725 |
+
if( !$postid = wpforo_bigintval($postid) ) return false;
|
726 |
+
if( !$post = $this->get_post($postid) ) return false;
|
727 |
+
|
728 |
+
if( $post['is_first_post'] ) return $this->wpforo->topic->status($post['topicid'], $status);
|
729 |
+
|
730 |
+
if( false !== $this->wpforo->db->update(
|
731 |
+
$this->wpforo->db->prefix."wpforo_posts",
|
732 |
+
array( 'status' => intval($status) ),
|
733 |
+
array( 'postid' => $postid ),
|
734 |
+
array( '%d' ),
|
735 |
+
array( '%d' )
|
736 |
+
)){
|
737 |
+
$this->wpforo->notice->add('Done!', 'success');
|
738 |
+
return true;
|
739 |
+
}
|
740 |
+
|
741 |
+
$this->wpforo->notice->add('error: Change Status action', 'error');
|
742 |
+
return false;
|
743 |
+
}
|
744 |
}
|
745 |
?>
|
wpf-includes/class-template.php
CHANGED
@@ -76,24 +76,26 @@ class wpForoTemplate{
|
|
76 |
<input id="t_sticky" name="topic[type]" type="checkbox" value="0">
|
77 |
<i class="fa fa-exclamation fa-0x"></i> <label for="t_sticky" style="padding-bottom:2px; cursor: pointer;"><?php wpforo_phrase('Set Topic Sticky'); ?> </label>
|
78 |
<span class="wpfbs"> | </span>
|
79 |
-
<?php endif ?>
|
80 |
<?php if($this->wpforo->perm->forum_can('p', $forumid) || $this->wpforo->perm->forum_can('op', $forumid)) : ?>
|
81 |
<input id="t_private" name="topic[private]" type="checkbox" value="0">
|
82 |
<i class="fa fa-eye-slash fa-0x"></i> <label for="t_private" style="padding-bottom:2px; cursor: pointer;" title="<?php wpforo_phrase('Only Admins and Moderators can see your private topics.'); ?>"><?php wpforo_phrase('Private Topic'); ?> </label>
|
83 |
<span class="wpfbs"> | </span>
|
84 |
-
<?php endif ?>
|
85 |
-
<?php do_action('wpforo_topic_form_buttons_hook'); ?>
|
86 |
-
<?php if(!defined('WPFOROATTACH_BASENAME') && $this->wpforo->perm->forum_can('a', $forumid)): ?>
|
87 |
-
<div class="wpf-default-attachment" style="padding-top:5px;">
|
88 |
-
<label for="file"><?php wpforo_phrase('Attach file:') ?> </label> <input id="file" type="file" name="attachfile" />
|
89 |
-
<p><?php wpforo_phrase('Maximum allowed file size is'); echo ' ' . wpforo_print_size($this->wpforo->post_options['max_upload_size']); ?></p>
|
90 |
-
</div>
|
91 |
<?php endif; ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
</div>
|
93 |
<?php if( wpforo_feature('subscribe_checkbox_on_post_editor', $this->wpforo) ) : ?>
|
94 |
<div class="wpf-topic-sbs" style="float:left;"><input id="wpf-topic-sbs" type="checkbox" name="wpforo_topic_subs" value="1" <?php echo ( wpforo_feature('subscribe_checkbox_default_status', $this->wpforo) ) ? 'checked="true" ' : ''; ?>/> <label for="wpf-topic-sbs"><?php wpforo_phrase('Subscribe to this topic') ?></label></div>
|
95 |
<?php endif; ?>
|
96 |
-
<input id="formbutton" type="submit" name="topic[save]" class="button button-primary forum_submit" value="<?php wpforo_phrase('
|
97 |
<div class="wpf-clear"></div>
|
98 |
</form>
|
99 |
</div>
|
@@ -198,12 +200,14 @@ class wpForoTemplate{
|
|
198 |
?>
|
199 |
<div class="wpf-extra-fields">
|
200 |
<?php do_action('wpforo_reply_form_buttons_hook'); ?>
|
201 |
-
<?php if
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
|
|
|
|
207 |
</div>
|
208 |
<?php if( wpforo_feature('subscribe_checkbox_on_post_editor', $this->wpforo) ) :
|
209 |
$args = array( "userid" => $this->wpforo->current_userid , "itemid" => intval($topicid), "type" => "topic" );
|
@@ -212,7 +216,7 @@ class wpForoTemplate{
|
|
212 |
<div class="wpf-topic-sbs"><input id="wpf-topic-sbs" type="checkbox" name="wpforo_topic_subs" value="1" <?php echo ( wpforo_feature('subscribe_checkbox_default_status', $this->wpforo) ) ? 'checked="true" ' : ''; ?> /> <label for="wpf-topic-sbs"><?php wpforo_phrase('Subscribe to this topic') ?></label></div>
|
213 |
<?php endif;
|
214 |
endif; ?>
|
215 |
-
<input id="formbutton" type="submit" name="post[save]" class="button button-primary forum_submit" value="<?php wpforo_phrase('
|
216 |
<div class="wpf-clear"></div>
|
217 |
</form>
|
218 |
</div>
|
@@ -386,19 +390,23 @@ class wpForoTemplate{
|
|
386 |
break;
|
387 |
case 'edit':
|
388 |
if($is_closed) break;
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
|
|
|
|
395 |
break;
|
396 |
case 'delete':
|
397 |
-
|
398 |
-
|
399 |
-
$
|
400 |
-
|
401 |
-
|
|
|
|
|
402 |
}
|
403 |
break;
|
404 |
case 'link':
|
@@ -629,6 +637,19 @@ class wpForoTemplate{
|
|
629 |
|
630 |
$icon = array();
|
631 |
$status = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
632 |
if(isset($item['type'])){
|
633 |
|
634 |
if( $type == 'topic' ){
|
76 |
<input id="t_sticky" name="topic[type]" type="checkbox" value="0">
|
77 |
<i class="fa fa-exclamation fa-0x"></i> <label for="t_sticky" style="padding-bottom:2px; cursor: pointer;"><?php wpforo_phrase('Set Topic Sticky'); ?> </label>
|
78 |
<span class="wpfbs"> | </span>
|
79 |
+
<?php endif; ?>
|
80 |
<?php if($this->wpforo->perm->forum_can('p', $forumid) || $this->wpforo->perm->forum_can('op', $forumid)) : ?>
|
81 |
<input id="t_private" name="topic[private]" type="checkbox" value="0">
|
82 |
<i class="fa fa-eye-slash fa-0x"></i> <label for="t_private" style="padding-bottom:2px; cursor: pointer;" title="<?php wpforo_phrase('Only Admins and Moderators can see your private topics.'); ?>"><?php wpforo_phrase('Private Topic'); ?> </label>
|
83 |
<span class="wpfbs"> | </span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
<?php endif; ?>
|
85 |
+
<?php do_action('wpforo_topic_form_buttons_hook'); ?>
|
86 |
+
<?php if( $this->wpforo->perm->can_attach() ): ?>
|
87 |
+
<?php if(!defined('WPFOROATTACH_BASENAME') && $this->wpforo->perm->forum_can('a', $forumid)): ?>
|
88 |
+
<div class="wpf-default-attachment" style="padding-top:5px;">
|
89 |
+
<label for="file"><?php wpforo_phrase('Attach file:') ?> </label> <input id="file" type="file" name="attachfile" />
|
90 |
+
<p><?php wpforo_phrase('Maximum allowed file size is'); echo ' ' . wpforo_print_size($this->wpforo->post_options['max_upload_size']); ?></p>
|
91 |
+
</div>
|
92 |
+
<?php endif; ?>
|
93 |
+
<?php endif; ?>
|
94 |
</div>
|
95 |
<?php if( wpforo_feature('subscribe_checkbox_on_post_editor', $this->wpforo) ) : ?>
|
96 |
<div class="wpf-topic-sbs" style="float:left;"><input id="wpf-topic-sbs" type="checkbox" name="wpforo_topic_subs" value="1" <?php echo ( wpforo_feature('subscribe_checkbox_default_status', $this->wpforo) ) ? 'checked="true" ' : ''; ?>/> <label for="wpf-topic-sbs"><?php wpforo_phrase('Subscribe to this topic') ?></label></div>
|
97 |
<?php endif; ?>
|
98 |
+
<input id="formbutton" type="submit" name="topic[save]" class="button button-primary forum_submit" value="<?php wpforo_phrase('Submit') ?>">
|
99 |
<div class="wpf-clear"></div>
|
100 |
</form>
|
101 |
</div>
|
200 |
?>
|
201 |
<div class="wpf-extra-fields">
|
202 |
<?php do_action('wpforo_reply_form_buttons_hook'); ?>
|
203 |
+
<?php if( $this->wpforo->perm->can_attach() ): ?>
|
204 |
+
<?php if(!defined('WPFOROATTACH_BASENAME') && $this->wpforo->perm->forum_can('a', $forumid)): ?>
|
205 |
+
<div class="wpf-default-attachment">
|
206 |
+
<label for="file"><?php wpforo_phrase('Attach file:') ?> </label> <input id="file" type="file" name="attachfile" />
|
207 |
+
<p><?php wpforo_phrase('Maximum allowed file size is'); echo ' ' . wpforo_print_size($this->wpforo->post_options['max_upload_size']); ?></p>
|
208 |
+
</div>
|
209 |
+
<?php endif; ?>
|
210 |
+
<?php endif; ?>
|
211 |
</div>
|
212 |
<?php if( wpforo_feature('subscribe_checkbox_on_post_editor', $this->wpforo) ) :
|
213 |
$args = array( "userid" => $this->wpforo->current_userid , "itemid" => intval($topicid), "type" => "topic" );
|
216 |
<div class="wpf-topic-sbs"><input id="wpf-topic-sbs" type="checkbox" name="wpforo_topic_subs" value="1" <?php echo ( wpforo_feature('subscribe_checkbox_default_status', $this->wpforo) ) ? 'checked="true" ' : ''; ?> /> <label for="wpf-topic-sbs"><?php wpforo_phrase('Subscribe to this topic') ?></label></div>
|
217 |
<?php endif;
|
218 |
endif; ?>
|
219 |
+
<input id="formbutton" type="submit" name="post[save]" class="button button-primary forum_submit" value="<?php wpforo_phrase('Submit') ?>">
|
220 |
<div class="wpf-clear"></div>
|
221 |
</form>
|
222 |
</div>
|
390 |
break;
|
391 |
case 'edit':
|
392 |
if($is_closed) break;
|
393 |
+
if( !$this->wpforo->member->current_user_is_new() ){
|
394 |
+
$diff = current_time( 'timestamp', 1 ) - strtotime($post['created']);
|
395 |
+
if( $this->wpforo->perm->forum_can( ($is_topic ? 'et' : 'er'), $forumid ) || ($this->wpforo->current_userid == $post['userid'] && $this->wpforo->perm->forum_can( ($is_topic ? 'eot' : 'eor' ), $forumid ) && $diff < $this->wpforo->post_options[($is_topic ? 'eot' : 'eor' ).'_durr'] ) ) {
|
396 |
+
$a = ( $is_topic ) ? 'wpfedittopicpid' : '';
|
397 |
+
$b = ( $is_topic ) ? $postid : $postid;
|
398 |
+
$button_html[] = '<span id="'. esc_attr( $a . $b ) .'" class="wpforo-edit wpf-action"><i class="fa fa-edit fa-0x"></i>' . wpforo_phrase('Edit', false).'</span>';
|
399 |
+
}
|
400 |
+
}
|
401 |
break;
|
402 |
case 'delete':
|
403 |
+
if( !$this->wpforo->member->current_user_is_new() ){
|
404 |
+
$diff = current_time( 'timestamp', 1 ) - strtotime($post['created']);
|
405 |
+
if( $this->wpforo->perm->forum_can( ($is_topic ? 'dt' : 'dr' ), $forumid ) || ($this->wpforo->current_userid == $post['userid'] && $this->wpforo->perm->forum_can( ($is_topic ? 'dot' : 'dor' ), $forumid ) && $diff < $this->wpforo->post_options[($is_topic ? 'dot' : 'dor' ).'_durr']) ){
|
406 |
+
$a = ( $is_topic ) ? 'wpftopicdelete' : 'wpfreplydelete';
|
407 |
+
$b = ( $is_topic ) ? $topicid : $postid;
|
408 |
+
$button_html[] = '<span id="'. esc_attr( $a . $b ) .'" class="wpf-action wpforo-delete"><i class="fa fa-times fa-0x"></i>' . wpforo_phrase('Delete', false).'</span>';
|
409 |
+
}
|
410 |
}
|
411 |
break;
|
412 |
case 'link':
|
637 |
|
638 |
$icon = array();
|
639 |
$status = false;
|
640 |
+
|
641 |
+
if( isset($item['status']) && $item['status'] ){
|
642 |
+
$icon['class'] = 'fa-exclamation-circle';
|
643 |
+
$icon['color'] = 'wpfcl-5';
|
644 |
+
$icon['title'] = wpforo_phrase('Unapproved', false);
|
645 |
+
if($echo) {
|
646 |
+
$status = true; echo ($data == 'icon') ? implode(' ', $icon) : $icon['title'];
|
647 |
+
}
|
648 |
+
else{
|
649 |
+
return ($data == 'icon') ? implode(' ', $icon) : $icon['title'];
|
650 |
+
}
|
651 |
+
}
|
652 |
+
|
653 |
if(isset($item['type'])){
|
654 |
|
655 |
if( $type == 'topic' ){
|
wpf-includes/class-topics.php
CHANGED
@@ -29,6 +29,8 @@ class wpForoTopic{
|
|
29 |
$args['body'] = $_REQUEST['postbody'];
|
30 |
}
|
31 |
|
|
|
|
|
32 |
if( !isset($args['forumid']) || !$args['forumid'] = intval($args['forumid']) ){
|
33 |
$this->wpforo->notice->add('Add Topic error: No forum selected', 'error');
|
34 |
return FALSE;
|
@@ -44,6 +46,8 @@ class wpForoTopic{
|
|
44 |
return FALSE;
|
45 |
}
|
46 |
|
|
|
|
|
47 |
$args['title'] = wpforo_text($args['title'], 250, false);
|
48 |
$args['body'] = (isset($args['body']) ? preg_replace('#</pre>[\r\n\t\s\0]*<pre>#isu', "\r\n", $args['body']) : '' );
|
49 |
$args['slug'] = (isset($args['slug']) && $args['slug']) ? sanitize_title($args['slug']) : ((isset($args['title'])) ? sanitize_title($args['title']) : md5(time()));
|
@@ -52,6 +56,7 @@ class wpForoTopic{
|
|
52 |
$args['userid'] = (isset($args['userid']) ? intval($args['userid']) : $this->wpforo->current_userid );
|
53 |
|
54 |
$args = apply_filters('wpforo_add_topic_data_filter', $args);
|
|
|
55 |
if(empty($args)) return FALSE;
|
56 |
|
57 |
extract($args, EXTR_OVERWRITE);
|
@@ -62,6 +67,7 @@ class wpForoTopic{
|
|
62 |
if(isset($created)) $created = sanitize_text_field($created);
|
63 |
if(isset($userid)) $userid = intval($userid);
|
64 |
if(isset($type)) $type = intval($type);
|
|
|
65 |
if(isset($private)) $private = intval($private);
|
66 |
if(isset($meta_key)) $meta_key = sanitize_text_field($meta_key);
|
67 |
if(isset($meta_desc)) $meta_desc = sanitize_text_field($meta_desc);
|
@@ -81,6 +87,7 @@ class wpForoTopic{
|
|
81 |
'forumid' => $forumid,
|
82 |
'userid' => $userid,
|
83 |
'type' => (isset($type) ? 1 : 0),
|
|
|
84 |
'private' => (isset($private) ? 1 : 0),
|
85 |
'created' => $created,
|
86 |
'modified' => $created,
|
@@ -91,7 +98,7 @@ class wpForoTopic{
|
|
91 |
'meta_desc' => $meta_desc,
|
92 |
'has_attach'=> $has_attach
|
93 |
),
|
94 |
-
array('%s','%s','%d','%d','%d','%d','%s','%s','%d','%d','%d','%s','%s','%d')
|
95 |
)
|
96 |
){
|
97 |
$topicid = $this->wpforo->db->insert_id;
|
@@ -106,9 +113,10 @@ class wpForoTopic{
|
|
106 |
'body' => stripslashes($body),
|
107 |
'created' => $created,
|
108 |
'modified' => $created,
|
109 |
-
'is_first_post' => 1
|
|
|
110 |
),
|
111 |
-
array('%d','%d','%d','%s','%s','%s','%s','%d')
|
112 |
)
|
113 |
){
|
114 |
$first_postid = $this->wpforo->db->insert_id;
|
@@ -145,10 +153,21 @@ class wpForoTopic{
|
|
145 |
}
|
146 |
|
147 |
public function edit( $args = array() ){
|
|
|
148 |
if( empty($args) && empty($_REQUEST['topic']) ) return FALSE;
|
149 |
-
if( !isset($args['topicid']) && isset($_GET['id']) ) $args['topicid'] =
|
150 |
if( empty($args) && !empty($_REQUEST['topic']) ){ $args = $_REQUEST['topic']; $args['body'] = $_REQUEST['postbody']; }
|
151 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
152 |
$args = apply_filters('wpforo_edit_topic_data_filter', $args);
|
153 |
if(empty($args)) return FALSE;
|
154 |
|
@@ -161,6 +180,7 @@ class wpForoTopic{
|
|
161 |
if(isset($created)) $created = sanitize_text_field($created);
|
162 |
if(isset($userid)) $userid = intval($userid);
|
163 |
if(isset($type)) $type = intval($type);
|
|
|
164 |
if(isset($private)) $private = intval($private);
|
165 |
if(isset($meta_key)) $meta_key = sanitize_text_field($meta_key);
|
166 |
if(isset($meta_desc)) $meta_desc = sanitize_text_field($meta_desc);
|
@@ -180,10 +200,6 @@ class wpForoTopic{
|
|
180 |
$title = wpforo_text($title, 250, false);
|
181 |
if(isset($body)) $body = preg_replace('#</pre>[\r\n\t\s\0]*<pre>#isu', "\r\n", $body);
|
182 |
|
183 |
-
if( !$topic = $this->get_topic($topicid) ){
|
184 |
-
$this->wpforo->notice->add('Topic not found.', 'error');
|
185 |
-
return FALSE;
|
186 |
-
}
|
187 |
$diff = current_time( 'timestamp', 1 ) - strtotime($topic['created']);
|
188 |
if( !($this->wpforo->perm->forum_can('et', $topic['forumid']) || ($this->wpforo->current_userid == $topic['userid'] && $this->wpforo->perm->forum_can('eot', $topic['forumid']) && $diff < $this->wpforo->post_options['eot_durr'])) ){
|
189 |
$this->wpforo->notice->add('You have no permission to edit this topic', 'error');
|
@@ -193,25 +209,38 @@ class wpForoTopic{
|
|
193 |
$t_update = $this->wpforo->db->update(
|
194 |
$this->wpforo->db->prefix."wpforo_topics",
|
195 |
array(
|
196 |
-
'title' => stripslashes($title),
|
197 |
'type' => ( isset($type) ? $type : intval($topic['type']) ),
|
|
|
198 |
'private' => ( isset($private) ? $private : intval($topic['private']) ),
|
199 |
-
'has_attach'=> (strpos($body, '[attach]') !== FALSE ? 1 : 0)
|
200 |
),
|
201 |
array( 'topicid' => intval($topicid) ),
|
202 |
-
array( '%s','%d','%d','%d' ),
|
203 |
array( '%d' )
|
204 |
);
|
205 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
206 |
$p_update = $this->wpforo->db->update(
|
207 |
$this->wpforo->db->prefix."wpforo_posts",
|
208 |
array(
|
209 |
-
'title' => stripslashes($title),
|
210 |
-
'body'
|
211 |
'modified' => current_time( 'mysql', 1 ),
|
212 |
-
|
|
|
213 |
array( 'postid' => intval($topic['first_postid']) ),
|
214 |
-
array( '%s', '%s', '%s' ),
|
215 |
array( '%d' )
|
216 |
);
|
217 |
|
@@ -272,9 +301,9 @@ class wpForoTopic{
|
|
272 |
function delete($topicid = 0){
|
273 |
if(!$topicid && isset( $_REQUEST['id'] ) ) $topicid = intval($_REQUEST['id']);
|
274 |
|
275 |
-
|
276 |
$diff = current_time( 'timestamp', 1 ) - strtotime($topic['created']);
|
277 |
-
if( !($this->wpforo->perm->forum_can('dt', $
|
278 |
$this->wpforo->notice->add('You haven\'t permission to delete topic from this forum', 'error');
|
279 |
return FALSE;
|
280 |
}
|
@@ -300,6 +329,10 @@ class wpForoTopic{
|
|
300 |
);
|
301 |
}
|
302 |
|
|
|
|
|
|
|
|
|
303 |
$posts_count = $this->wpforo->db->delete($this->wpforo->db->prefix . 'wpforo_posts', array( 'topicid' => $topicid));
|
304 |
if($this->wpforo->db->delete($this->wpforo->db->prefix . 'wpforo_topics', array( 'topicid' => $topicid))){
|
305 |
$this->wpforo->db->delete(
|
@@ -437,6 +470,12 @@ class wpForoTopic{
|
|
437 |
}
|
438 |
}
|
439 |
|
|
|
|
|
|
|
|
|
|
|
|
|
440 |
if($cache){
|
441 |
self::$cache['topic'][addslashes($topic['slug'])] = $topic;
|
442 |
return self::$cache['topic'][$topic['topicid']] = $topic;
|
@@ -465,6 +504,7 @@ class wpForoTopic{
|
|
465 |
'forumid' => NULL,
|
466 |
'userid' => NULL, // user id in DB
|
467 |
'type' => 0, //0, 1, etc . . .
|
|
|
468 |
'private' => NULL, //0, 1, etc . . .
|
469 |
'orderby' => 'type, topicid', // type, topicid, modified, created
|
470 |
'order' => 'DESC', // ASC DESC
|
@@ -498,7 +538,7 @@ class wpForoTopic{
|
|
498 |
}
|
499 |
|
500 |
if( isset($forumid) && $forumid ){
|
501 |
-
if( $
|
502 |
if(!is_null($private)) $wheres[] = " `private` = " . intval($private);
|
503 |
}
|
504 |
elseif( isset($this->wpforo->current_userid) && $this->wpforo->current_userid ){
|
@@ -509,6 +549,18 @@ class wpForoTopic{
|
|
509 |
}
|
510 |
}
|
511 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
512 |
$sql = "SELECT * FROM `".$this->wpforo->db->prefix."wpforo_topics`";
|
513 |
if(!empty($wheres)){
|
514 |
$sql .= " WHERE " . implode($wheres, " AND ");
|
@@ -530,14 +582,16 @@ class wpForoTopic{
|
|
530 |
if(!empty($forumids) || !$forumid){
|
531 |
$topics = $this->wpforo->db->get_results($sql, ARRAY_A);
|
532 |
foreach($topics as $key => $topic){
|
533 |
-
if( !$this->wpforo->perm->forum_can('vf', $topic['forumid']) ){
|
534 |
-
unset($topics[$key]);
|
535 |
-
}
|
536 |
if( isset($topic['private']) && $topic['private'] && !wpforo_is_owner($topic['userid']) ){
|
537 |
if( !$this->wpforo->perm->forum_can('vp', $topic['forumid']) ){
|
538 |
unset($topics[$key]);
|
539 |
}
|
540 |
}
|
|
|
|
|
|
|
|
|
|
|
541 |
}
|
542 |
return $topics;
|
543 |
}
|
@@ -616,6 +670,12 @@ class wpForoTopic{
|
|
616 |
return FALSE;
|
617 |
}
|
618 |
|
|
|
|
|
|
|
|
|
|
|
|
|
619 |
function is_closed( $topicid ){
|
620 |
$type = $this->wpforo->db->get_var( "SELECT `closed` FROM " . $this->wpforo->db->prefix."wpforo_topics WHERE `topicid` = " . intval($topicid) );
|
621 |
if( $type == 1 ) return TRUE;
|
@@ -702,7 +762,42 @@ class wpForoTopic{
|
|
702 |
function get_count(){
|
703 |
return $this->wpforo->db->get_var( "SELECT COUNT(`topicid`) FROM `".$this->wpforo->db->prefix."wpforo_topics`" );
|
704 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
705 |
|
706 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
707 |
}
|
708 |
?>
|
29 |
$args['body'] = $_REQUEST['postbody'];
|
30 |
}
|
31 |
|
32 |
+
if( !isset($args['body']) || !$args['body'] ){ $this->wpforo->notice->add('Post is empty', 'error'); return FALSE; }
|
33 |
+
|
34 |
if( !isset($args['forumid']) || !$args['forumid'] = intval($args['forumid']) ){
|
35 |
$this->wpforo->notice->add('Add Topic error: No forum selected', 'error');
|
36 |
return FALSE;
|
46 |
return FALSE;
|
47 |
}
|
48 |
|
49 |
+
do_action( 'wpforo_start_add_topic', $args );
|
50 |
+
|
51 |
$args['title'] = wpforo_text($args['title'], 250, false);
|
52 |
$args['body'] = (isset($args['body']) ? preg_replace('#</pre>[\r\n\t\s\0]*<pre>#isu', "\r\n", $args['body']) : '' );
|
53 |
$args['slug'] = (isset($args['slug']) && $args['slug']) ? sanitize_title($args['slug']) : ((isset($args['title'])) ? sanitize_title($args['title']) : md5(time()));
|
56 |
$args['userid'] = (isset($args['userid']) ? intval($args['userid']) : $this->wpforo->current_userid );
|
57 |
|
58 |
$args = apply_filters('wpforo_add_topic_data_filter', $args);
|
59 |
+
|
60 |
if(empty($args)) return FALSE;
|
61 |
|
62 |
extract($args, EXTR_OVERWRITE);
|
67 |
if(isset($created)) $created = sanitize_text_field($created);
|
68 |
if(isset($userid)) $userid = intval($userid);
|
69 |
if(isset($type)) $type = intval($type);
|
70 |
+
if(isset($status)) $status = intval($status);
|
71 |
if(isset($private)) $private = intval($private);
|
72 |
if(isset($meta_key)) $meta_key = sanitize_text_field($meta_key);
|
73 |
if(isset($meta_desc)) $meta_desc = sanitize_text_field($meta_desc);
|
87 |
'forumid' => $forumid,
|
88 |
'userid' => $userid,
|
89 |
'type' => (isset($type) ? 1 : 0),
|
90 |
+
'status' => (isset($status) ? $status : 0),
|
91 |
'private' => (isset($private) ? 1 : 0),
|
92 |
'created' => $created,
|
93 |
'modified' => $created,
|
98 |
'meta_desc' => $meta_desc,
|
99 |
'has_attach'=> $has_attach
|
100 |
),
|
101 |
+
array('%s','%s','%d','%d','%d','%d','%d','%s','%s','%d','%d','%d','%s','%s','%d')
|
102 |
)
|
103 |
){
|
104 |
$topicid = $this->wpforo->db->insert_id;
|
113 |
'body' => stripslashes($body),
|
114 |
'created' => $created,
|
115 |
'modified' => $created,
|
116 |
+
'is_first_post' => 1,
|
117 |
+
'status' => (isset($status) ? $status : 0),
|
118 |
),
|
119 |
+
array('%d','%d','%d','%s','%s','%s','%s','%d','%d')
|
120 |
)
|
121 |
){
|
122 |
$first_postid = $this->wpforo->db->insert_id;
|
153 |
}
|
154 |
|
155 |
public function edit( $args = array() ){
|
156 |
+
|
157 |
if( empty($args) && empty($_REQUEST['topic']) ) return FALSE;
|
158 |
+
if( !isset($args['topicid']) && isset($_GET['id']) ) $args['topicid'] = intval($_GET['id']);
|
159 |
if( empty($args) && !empty($_REQUEST['topic']) ){ $args = $_REQUEST['topic']; $args['body'] = $_REQUEST['postbody']; }
|
160 |
|
161 |
+
do_action( 'wpforo_start_edit_topic', $args );
|
162 |
+
|
163 |
+
if( !$topic = $this->get_topic( $args['topicid'] ) ){
|
164 |
+
$this->wpforo->notice->add('Topic not found.', 'error');
|
165 |
+
return FALSE;
|
166 |
+
}
|
167 |
+
|
168 |
+
$args['status'] = $topic['status'];
|
169 |
+
$args['userid'] = $topic['userid'];
|
170 |
+
|
171 |
$args = apply_filters('wpforo_edit_topic_data_filter', $args);
|
172 |
if(empty($args)) return FALSE;
|
173 |
|
180 |
if(isset($created)) $created = sanitize_text_field($created);
|
181 |
if(isset($userid)) $userid = intval($userid);
|
182 |
if(isset($type)) $type = intval($type);
|
183 |
+
if(isset($status)) $status = intval($status);
|
184 |
if(isset($private)) $private = intval($private);
|
185 |
if(isset($meta_key)) $meta_key = sanitize_text_field($meta_key);
|
186 |
if(isset($meta_desc)) $meta_desc = sanitize_text_field($meta_desc);
|
200 |
$title = wpforo_text($title, 250, false);
|
201 |
if(isset($body)) $body = preg_replace('#</pre>[\r\n\t\s\0]*<pre>#isu', "\r\n", $body);
|
202 |
|
|
|
|
|
|
|
|
|
203 |
$diff = current_time( 'timestamp', 1 ) - strtotime($topic['created']);
|
204 |
if( !($this->wpforo->perm->forum_can('et', $topic['forumid']) || ($this->wpforo->current_userid == $topic['userid'] && $this->wpforo->perm->forum_can('eot', $topic['forumid']) && $diff < $this->wpforo->post_options['eot_durr'])) ){
|
205 |
$this->wpforo->notice->add('You have no permission to edit this topic', 'error');
|
209 |
$t_update = $this->wpforo->db->update(
|
210 |
$this->wpforo->db->prefix."wpforo_topics",
|
211 |
array(
|
212 |
+
'title' => ( isset($title) ? stripslashes($title) : stripslashes($topic['title']) ),
|
213 |
'type' => ( isset($type) ? $type : intval($topic['type']) ),
|
214 |
+
'status' => ( isset($status) ? $status : intval($topic['status']) ),
|
215 |
'private' => ( isset($private) ? $private : intval($topic['private']) ),
|
216 |
+
'has_attach'=> ( isset($body) ? (strpos($body, '[attach]') !== FALSE ? 1 : 0) : $topic['has_attach'] )
|
217 |
),
|
218 |
array( 'topicid' => intval($topicid) ),
|
219 |
+
array( '%s','%d','%d','%d','%d' ),
|
220 |
array( '%d' )
|
221 |
);
|
222 |
|
223 |
+
if( isset($topic['first_postid']) ){
|
224 |
+
if( !$post = $this->wpforo->post->get_post( $topic['first_postid'] ) ){
|
225 |
+
$this->wpforo->notice->add('Topic first post data not found.', 'error');
|
226 |
+
return FALSE;
|
227 |
+
}
|
228 |
+
}
|
229 |
+
else{
|
230 |
+
$this->wpforo->notice->add('Topic first post not found.', 'error');
|
231 |
+
return FALSE;
|
232 |
+
}
|
233 |
+
|
234 |
$p_update = $this->wpforo->db->update(
|
235 |
$this->wpforo->db->prefix."wpforo_posts",
|
236 |
array(
|
237 |
+
'title' => ( isset($title) ? stripslashes($title) : stripslashes($post['title']) ),
|
238 |
+
'body' => ( (isset($body) && $body) ? stripslashes($body) : stripslashes($post['body']) ),
|
239 |
'modified' => current_time( 'mysql', 1 ),
|
240 |
+
'status' => ( isset($status) ? $status : intval($topic['status']) ),
|
241 |
+
),
|
242 |
array( 'postid' => intval($topic['first_postid']) ),
|
243 |
+
array( '%s', '%s', '%s', '%d' ),
|
244 |
array( '%d' )
|
245 |
);
|
246 |
|
301 |
function delete($topicid = 0){
|
302 |
if(!$topicid && isset( $_REQUEST['id'] ) ) $topicid = intval($_REQUEST['id']);
|
303 |
|
304 |
+
if( !$topic = $this->get_topic($topicid) ) return true;
|
305 |
$diff = current_time( 'timestamp', 1 ) - strtotime($topic['created']);
|
306 |
+
if( !($this->wpforo->perm->forum_can('dt', $topic['forumid']) || ($this->wpforo->current_userid == $topic['userid'] && $this->wpforo->perm->forum_can('dot', $topic['forumid']) && $diff < $this->wpforo->post_options['dot_durr'])) ){
|
307 |
$this->wpforo->notice->add('You haven\'t permission to delete topic from this forum', 'error');
|
308 |
return FALSE;
|
309 |
}
|
329 |
);
|
330 |
}
|
331 |
|
332 |
+
//Find and delete default atatchments before deleting post
|
333 |
+
$this->delete_attachments( $topicid );
|
334 |
+
|
335 |
+
//Delete post
|
336 |
$posts_count = $this->wpforo->db->delete($this->wpforo->db->prefix . 'wpforo_posts', array( 'topicid' => $topicid));
|
337 |
if($this->wpforo->db->delete($this->wpforo->db->prefix . 'wpforo_topics', array( 'topicid' => $topicid))){
|
338 |
$this->wpforo->db->delete(
|
470 |
}
|
471 |
}
|
472 |
|
473 |
+
if( isset($topic['status']) && $topic['status'] && !wpforo_is_owner($topic['userid'])){
|
474 |
+
if( isset($topic['forumid']) && $topic['forumid'] && !$this->wpforo->perm->forum_can('au', $topic['forumid']) ){
|
475 |
+
return array();
|
476 |
+
}
|
477 |
+
}
|
478 |
+
|
479 |
if($cache){
|
480 |
self::$cache['topic'][addslashes($topic['slug'])] = $topic;
|
481 |
return self::$cache['topic'][$topic['topicid']] = $topic;
|
504 |
'forumid' => NULL,
|
505 |
'userid' => NULL, // user id in DB
|
506 |
'type' => 0, //0, 1, etc . . .
|
507 |
+
'status' => NULL, //0, 1, etc . . .
|
508 |
'private' => NULL, //0, 1, etc . . .
|
509 |
'orderby' => 'type, topicid', // type, topicid, modified, created
|
510 |
'order' => 'DESC', // ASC DESC
|
538 |
}
|
539 |
|
540 |
if( isset($forumid) && $forumid ){
|
541 |
+
if( $this->wpforo->perm->forum_can('vp', $forumid) ){
|
542 |
if(!is_null($private)) $wheres[] = " `private` = " . intval($private);
|
543 |
}
|
544 |
elseif( isset($this->wpforo->current_userid) && $this->wpforo->current_userid ){
|
549 |
}
|
550 |
}
|
551 |
|
552 |
+
if( isset($forumid) && $forumid ){
|
553 |
+
if( $this->wpforo->perm->forum_can('au', $forumid) ){
|
554 |
+
if(!is_null($status)) $wheres[] = " `status` = " . intval($status);
|
555 |
+
}
|
556 |
+
elseif( isset($this->wpforo->current_userid) && $this->wpforo->current_userid ){
|
557 |
+
$wheres[] = " ( `status` = 0 OR (`status` = 1 AND `userid` = " .intval($this->wpforo->current_userid). ") )";
|
558 |
+
}
|
559 |
+
else{
|
560 |
+
$wheres[] = " `status` = 0";
|
561 |
+
}
|
562 |
+
}
|
563 |
+
|
564 |
$sql = "SELECT * FROM `".$this->wpforo->db->prefix."wpforo_topics`";
|
565 |
if(!empty($wheres)){
|
566 |
$sql .= " WHERE " . implode($wheres, " AND ");
|
582 |
if(!empty($forumids) || !$forumid){
|
583 |
$topics = $this->wpforo->db->get_results($sql, ARRAY_A);
|
584 |
foreach($topics as $key => $topic){
|
|
|
|
|
|
|
585 |
if( isset($topic['private']) && $topic['private'] && !wpforo_is_owner($topic['userid']) ){
|
586 |
if( !$this->wpforo->perm->forum_can('vp', $topic['forumid']) ){
|
587 |
unset($topics[$key]);
|
588 |
}
|
589 |
}
|
590 |
+
if( isset($topic['status']) && $topic['status'] && !wpforo_is_owner($topic['userid']) ){
|
591 |
+
if( !$this->wpforo->perm->forum_can('au', $topic['forumid']) ){
|
592 |
+
unset($topics[$key]);
|
593 |
+
}
|
594 |
+
}
|
595 |
}
|
596 |
return $topics;
|
597 |
}
|
670 |
return FALSE;
|
671 |
}
|
672 |
|
673 |
+
function is_unapproved( $topicid ){
|
674 |
+
$status = $this->wpforo->db->get_var( "SELECT `status` FROM " . $this->wpforo->db->prefix."wpforo_topics WHERE `topicid` = " . intval($topicid) );
|
675 |
+
if( $status == 1 ) return TRUE;
|
676 |
+
return FALSE;
|
677 |
+
}
|
678 |
+
|
679 |
function is_closed( $topicid ){
|
680 |
$type = $this->wpforo->db->get_var( "SELECT `closed` FROM " . $this->wpforo->db->prefix."wpforo_topics WHERE `topicid` = " . intval($topicid) );
|
681 |
if( $type == 1 ) return TRUE;
|
762 |
function get_count(){
|
763 |
return $this->wpforo->db->get_var( "SELECT COUNT(`topicid`) FROM `".$this->wpforo->db->prefix."wpforo_topics`" );
|
764 |
}
|
765 |
+
|
766 |
+
public function status( $topicid, $status ){
|
767 |
+
if( !$topicid = wpforo_bigintval($topicid) ) return false;
|
768 |
+
|
769 |
+
if( false !== $this->wpforo->db->update(
|
770 |
+
$this->wpforo->db->prefix."wpforo_topics",
|
771 |
+
array( 'status' => intval($status) ),
|
772 |
+
array( 'topicid' => $topicid ),
|
773 |
+
array( '%d' ),
|
774 |
+
array( '%d' )
|
775 |
+
)){
|
776 |
+
if( false !== $this->wpforo->db->update(
|
777 |
+
$this->wpforo->db->prefix."wpforo_posts",
|
778 |
+
array( 'status' => intval($status) ),
|
779 |
+
array( 'topicid' => $topicid ),
|
780 |
+
array( '%d' ),
|
781 |
+
array( '%d' )
|
782 |
+
)){
|
783 |
+
$this->wpforo->notice->add('Done!', 'success');
|
784 |
+
return true;
|
785 |
+
}
|
786 |
+
}
|
787 |
+
|
788 |
+
$this->wpforo->notice->add('error: Change Status action', 'error');
|
789 |
+
return false;
|
790 |
+
}
|
791 |
|
792 |
+
public function delete_attachments( $topicid ){
|
793 |
+
$args = array( 'topicid' => $topicid );
|
794 |
+
$posts = $this->wpforo->post->get_posts( $args );
|
795 |
+
if(!empty($posts)){
|
796 |
+
foreach( $posts as $post ){
|
797 |
+
$this->wpforo->post->delete_attachments( $post['postid'] );
|
798 |
+
}
|
799 |
+
}
|
800 |
+
}
|
801 |
+
|
802 |
}
|
803 |
?>
|
wpf-includes/class-usergroups.php
CHANGED
@@ -72,7 +72,7 @@ class wpForoUsergroup{
|
|
72 |
return FALSE;
|
73 |
}
|
74 |
|
75 |
-
function edit( $groupid, $title, $cans ){
|
76 |
|
77 |
if( $groupid == 1 ) return false;
|
78 |
if( !current_user_can('administrator') ){
|
72 |
return FALSE;
|
73 |
}
|
74 |
|
75 |
+
function edit( $groupid, $title, $cans, $description = '' ){
|
76 |
|
77 |
if( $groupid == 1 ) return false;
|
78 |
if( !current_user_can('administrator') ){
|
wpf-includes/functions-installation.php
CHANGED
@@ -170,9 +170,32 @@ function wpforo_activation(){
|
|
170 |
'new_post_notification_email_message' => "Hello [member_name]!<br>\r\n New reply has been posted on your subscribed topic - [topic].\r\n <br><br>\r\n <strong>[reply_title]</strong>\r\n <blockquote >\r\n [reply_desc]\r\n </blockquote>\r\n <br><hr>\r\n If you want to unsubscribe from this topic please use the link below.<br>\r\n [unsubscribe_link]" ,
|
171 |
'report_email_subject' => "Forum Post Report",
|
172 |
'report_email_message' => "<strong>Report details:</strong>\r\n Reporter: [reporter], <br>\r\n Message: [message],<br>\r\n <br>\r\n [post_url]",
|
|
|
|
|
173 |
'update' => '1'
|
174 |
);
|
175 |
wpforo_update_options( 'wpforo_subscribe_options', $subscriptions_options );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
176 |
|
177 |
#################################################################
|
178 |
// Countries ////////////////////////////////////////////////////
|
@@ -322,6 +345,7 @@ function wpforo_activation(){
|
|
322 |
'p' => 'Can set topic private',
|
323 |
'op' => 'Can set own topic private',
|
324 |
'vp' => 'Can view private topic',
|
|
|
325 |
'sv' => 'Can set topic solved',
|
326 |
'osv' => 'Can set own topic solved',
|
327 |
'v' => 'Can vote',
|
@@ -339,27 +363,27 @@ function wpforo_activation(){
|
|
339 |
$cans_n = array('vf' => 0, 'ct' => 0, 'vt' => 0, 'et' => 0, 'dt' => 0,
|
340 |
'cr' => 0, 'vr' => 0, 'er' => 0, 'dr' => 0,
|
341 |
'eot' => 0, 'eor' => 0, 'dot' => 0, 'dor' => 0,
|
342 |
-
'l' => 0, 'r' => 0, 's' => 0, 'p' => 0, 'op' => 0, 'vp' => 0, 'sv' => 0, 'osv' => 0, 'v' => 0, 'a' => 0, 'va' => 0,
|
343 |
'at' => 0, 'oat' => 0, 'cot' => 0, 'mt' => 0);
|
344 |
$cans_r = array('vf' => 1, 'ct' => 0, 'vt' => 1, 'et' => 0, 'dt' => 0,
|
345 |
'cr' => 0, 'vr' => 1, 'er' => 0, 'dr' => 0,
|
346 |
'eot' => 0, 'eor' => 0, 'dot' => 0, 'dor' => 0,
|
347 |
-
'l' => 0, 'r' => 0, 's' => 0, 'p' => 0, 'op' => 0, 'vp' => 0, 'sv' => 0, 'osv' => 0, 'v' => 0, 'a' => 0, 'va' => 1,
|
348 |
'at' => 0, 'oat' => 0, 'cot' => 0, 'mt' => 0); |