PluginProbe
wpForo Forum / 1.0.1
wpForo Forum v1.0.1
3.1.6 3.1.5 3.1.4 3.1.2 3.1.1 3.1.0 3.0.9 3.0.8 3.0.7 trunk 1.0.0 1.0.1 1.0.2 1.1.0 1.1.1 1.1.2 1.2.0 1.3.0 1.3.1 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 1.4.13 All 138 releases
wpforo / wpf-includes / wpf-actions.php

wpf-actions.php in wpForo Forum 1.0.1, at wpf-includes/wpf-actions.php

578 lines 22.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 // Exit if accessed directly
3 if( !defined( 'ABSPATH' ) ) exit;
4
5 function wpforo_actions(){
6
7 global $wpforo;
8
9 do_action( 'wpforo_actions' );
10
11 if( isset($_POST['wpfreg']) && !empty($_POST['wpfreg']) && $userid = $wpforo->member->create($_POST['wpfreg'])){
12 wp_redirect( $wpforo->member->get_profile_url( $userid, 'account' ) );
13 exit();
14 }
15
16 if(isset($_POST['wpforologin']) && isset($_POST['log']) && isset($_POST['pwd'])){
17 if ( !is_wp_error( $user = wp_signon() ) ) {
18 $wpf_login_times = get_user_meta($user->ID, '_wpf_login_times', true);
19 if( isset($user->ID) && $wpf_login_times >= 1) {
20 $name = ( isset($user->data->display_name) ) ? $user->data->display_name : '';
21 $wpforo->notice->add( sprintf( 'Welcome back %s!', esc_html($name) ) , 'success');
22 }
23 else{
24 $wpforo->notice->add('Welcome to our Community!', 'success');
25 }
26 (int)$wpf_login_times++;
27 update_user_meta( $user->ID, '_wpf_login_times', $wpf_login_times );
28 wp_redirect( preg_replace('#\?.*$#is', '', wpforo_full_url()) );
29 exit();
30 }else{
31 $args = array();
32 foreach($user->errors as $u_err) $args[] = $u_err[0];
33 $wpforo->notice->add($args, 'error');
34 wp_redirect( wpforo_full_url() );
35 exit();
36 }
37 }
38
39 extract($wpforo->current_object, EXTR_OVERWRITE);
40
41 if( $template == 'profile' && !isset($username) && !isset($userid) ){
42 wp_redirect( WPFORO_BASE_URL );
43 exit();
44 }
45
46 if(isset($_POST['wpforo_member_submit'])){
47 if(isset($_POST['member']['userid']) && $_POST['member']['userid']){
48 wpforo_verify_form();
49
50 if(!$wpforo->perm->user_can_manage_user( $wpforo->current_userid, intval($_POST['member']['userid']))){
51 $wpforo->notice->clear();
52 $wpforo->notice->add('Permission denied', 'error');
53 wp_redirect(wpforo_full_url());
54 exit();
55 }
56
57 $wpforo->member->edit();
58 if( isset($_POST['member']['avatar_type']) && $_POST['member']['avatar_type'] == 'custom' ) $wpforo->member->upload_avatar();
59
60 if( isset($_POST['member']['old_pass'])
61 && isset($_POST['member']['new_pass'])
62 && isset($_POST['member']['re_new_pass'])
63 && $_POST['member']['new_pass'] && $_POST['member']['re_new_pass'] && $_POST['member']['old_pass'] ){
64 if( $_POST['member']['new_pass'] == $_POST['member']['re_new_pass'] ){
65 $old_pass = $_POST['member']['old_pass'];
66 $user_pass = $_POST['member']['user_pass'];
67 $userid = intval($_POST['member']['userid']);
68 $new_pass = $_POST['member']['new_pass'];
69 if ( wp_check_password( $old_pass, $user_pass, $userid) ){
70 wp_set_password( $new_pass, $userid );
71 }else{
72 $wpforo->notice->clear();
73 $wpforo->notice->add('Old password is wrong', 'error');
74 }
75 }else{
76 $wpforo->notice->clear();
77 $wpforo->notice->add('New Passwords do not match', 'error');
78 }
79 }
80
81 $wpforo->member->reset(intval($_POST['member']['userid']));
82 }
83 wp_redirect(wpforo_full_url());
84 exit();
85 }
86
87 if( isset($_POST['topic']['save']) && isset($_REQUEST['topic']['action']) ){
88 if( $_REQUEST['topic']['action'] == 'add' ){
89 wpforo_verify_form();
90 if( $topicid = $wpforo->topic->add() ){
91 wp_redirect( $wpforo->topic->get_topic_url($topicid) );
92 exit();
93 }
94 }elseif( $_REQUEST['topic']['action'] == 'edit' ){
95 wpforo_verify_form();
96 if( $topicid = $wpforo->topic->edit() ){
97 wp_redirect( $wpforo->topic->get_topic_url($topicid) );
98 exit();
99 }
100 }
101 wp_redirect( wpforo_full_url() );
102 exit();
103 }
104
105 if( isset($_POST['post']['save']) ){
106 if( $_POST['post']['save'] != 'move' && isset($_REQUEST['post']['action']) ){
107 if($_REQUEST['post']['action'] == 'add'){
108 wpforo_verify_form();
109 if( $postid = $wpforo->post->add() ){
110 wp_redirect( $wpforo->post->get_post_url( $postid ) );
111 exit();
112 }
113 }elseif($_REQUEST['post']['action'] == 'edit'){
114 wpforo_verify_form();
115 if( $postid = $wpforo->post->edit() ){
116 wp_redirect( $wpforo->post->get_post_url( $postid ) );
117 exit();
118 }
119 }
120 }
121
122 if($_POST['post']['save'] == 'move' && isset($_POST['movetopicid']) && isset($_POST['topic']['forumid'])){
123 wpforo_verify_form();
124 $move_topicid = intval($_POST['movetopicid']);
125 $move_forumid = intval($_POST['topic']['forumid']);
126 $wpforo->topic->move( $move_topicid, $move_forumid );
127 wp_redirect( wpforo_full_url() );
128 exit();
129 }
130
131 wp_redirect( wpforo_full_url() );
132 exit();
133 }
134
135 ## Subscriptions
136 if( isset($_GET['wpforo']) && ($_GET['wpforo'] == 'sbscrbconfirm' || $_GET['wpforo'] == 'unsbscrb') && isset($_GET['key']) && $_GET['key'] ){
137 $sbs_key = sanitize_text_field($_GET['key']);
138 if( $_GET['wpforo'] == 'sbscrbconfirm' ){
139 $wpforo->sbscrb->edit($sbs_key);
140 }else{
141 $wpforo->sbscrb->delete($sbs_key);
142 }
143 wp_redirect( preg_replace('#\?.*$#is', '', wpforo_full_url()) );
144 exit();
145 }
146
147 ## Resolved
148 if( isset($_GET['wpforo']) && $_GET['wpforo'] == 'solved' && $_GET['tid'] ){
149 $topicid = intval($_GET['tid']);
150
151 wp_redirect( preg_replace('#\?.*$#is', '', wpforo_full_url()) );
152 exit();
153 }
154
155 ###############################################################
156 /**
157 *
158 * BACK-END
159 *
160 */
161
162 ##Settings action
163 if( is_admin() && isset($_POST['wpforo_screen_option']['value']) ){
164 if(!current_user_can('administrator')) return;
165 update_option('wpforo_count_per_page', $_POST['wpforo_screen_option']['value']);
166 }
167
168 if( is_admin() && isset($_GET['page']) && $_GET['page'] == 'wpforo-community' && isset($_GET['action']) && $_GET['action'] ){
169 if(!current_user_can('administrator')){
170 $wpforo->notice->add('Permission denied', 'error');
171 wp_redirect(admin_url());
172 exit();
173 }
174 if( $_GET['action'] == 'reset_fstat' && check_admin_referer( 'wpforo_reset_forums_stat' ) ){
175 $forums = $wpforo->db->get_results("SELECT `forumid` FROM " . $wpforo->db->prefix . "wpforo_forums ORDER BY `forumid` ASC", ARRAY_A);
176 if(!empty($forums)){
177 foreach($forums as $forum){
178 $topics = $wpforo->db->get_var( "SELECT COUNT(*) as count FROM `" . $wpforo->db->prefix . "wpforo_topics` WHERE `forumid` = " . intval($forum['forumid']) );
179 $posts = $wpforo->db->get_var( "SELECT COUNT(*) as count FROM `" . $wpforo->db->prefix . "wpforo_posts` WHERE `forumid` = " . intval($forum['forumid']) );
180 $wpforo->db->query("UPDATE `" . $wpforo->db->prefix . "wpforo_forums` SET `topics` = " . intval($topics) . ", `posts` = " . intval($posts) . " WHERE `forumid` = " . intval($forum['forumid']) );
181 }
182 $wpforo->notice->add('Updated Successfully!', 'success');
183 }
184 }
185 if( $_GET['action'] == 'reset_ustat' && check_admin_referer( 'wpforo_reset_users_stat' ) ){
186 $users = $wpforo->db->get_results("SELECT `userid` FROM " . $wpforo->db->prefix . "wpforo_profiles ORDER BY `posts` DESC", ARRAY_A);
187 if(!empty($users)){
188 foreach($users as $user){
189 $questions = $wpforo->member->get_questions_count( $user['userid'] );
190 $answers = $wpforo->member->get_answers_count( $user['userid'] );
191 $posts = $wpforo->member->get_replies_count( $user['userid'] );
192 $question_comments = $wpforo->member->get_question_comments_count( $user['userid'] );
193 $wpforo->db->query("UPDATE `" . $wpforo->db->prefix . "wpforo_profiles`
194 SET `posts` = " . intval($posts) . ", `answers` = " . intval($answers) . ", `comments` = " . intval($question_comments) . ", `questions` = " . intval($questions) . "
195 WHERE `userid` = " . intval( $user['userid'] ) );
196 }
197 $wpforo->notice->add('Updated Successfully!', 'success');
198 }
199 }
200 if( $_GET['action'] == 'reset_phrase_cache' && check_admin_referer( 'wpforo_reset_phrase_cache' ) ){
201 $wpforo->db->query("DELETE FROM " . $wpforo->db->prefix . "options WHERE `option_name` LIKE '%_transient_wpforo_get_phrases_%' OR `option_name` LIKE '%_transient_timeout_wpforo_get_phrases_%'");
202 $wpforo->notice->add('Deleted Successfully!', 'success');
203 }
204 if( $_GET['action'] == 'reset_user_cache' && check_admin_referer( 'wpforo_reset_user_cache' ) ){
205 $wpforo->member->clear_db_cache();
206 $wpforo->notice->add('Deleted Successfully!', 'success');
207 }
208 }
209
210 if( is_admin() && isset($_GET['page']) && $_GET['page'] == 'wpforo-settings' ){
211
212 if(!current_user_can('administrator')){
213 $wpforo->notice->add('Permission denied', 'error');
214 wp_redirect(admin_url());
215 exit();
216 }
217
218 ##General options
219 if( isset($_POST['wpforo_general_options']) ){
220 check_admin_referer( 'wpforo-settings-general' );
221
222 if( isset($_POST['wpforo_use_home_url']) && $_POST['wpforo_use_home_url'] ){
223 update_option('wpforo_use_home_url', 1);
224 }else{
225 update_option('wpforo_use_home_url', 0);
226 }
227
228 if( isset($_POST['wpforo_url']) && $permastruct = utf8_uri_encode( $_POST['wpforo_url'] ) )
229 if( update_option('wpforo_url', site_url('/') . trim($permastruct, '/') . "/")
230 && update_option('wpforo_permastruct', trim($permastruct, '/')) ){
231 $wpforo->notice->add('Forum Base URL successfully updated', 'success');
232 }else{
233 $wpforo->notice->add('Successfully updated', 'success');
234 }
235
236 if( update_option('wpforo_general_options', $_POST['wpforo_general_options']) ){
237 $wpforo->notice->add('General options successfully updated', 'success');
238 }else{
239 $wpforo->notice->add('Successfully updated', 'success');
240 }
241
242 $wpforo->member->clear_db_cache();
243
244 wp_redirect( admin_url( 'admin.php?page=wpforo-settings&tab=general' ) );
245 exit();
246 }
247
248 ##add new lang action
249 if( isset($_FILES['add_lang']) ){
250 check_admin_referer( 'wpforo-settings-language' );
251 $wpforo->phrase->add_lang();
252 wp_redirect( admin_url( 'admin.php?page=wpforo-settings&tab=general' ) );
253 exit();
254 }
255
256 ##Forums
257 if( isset($_POST['wpforo_forum_options']) ){
258 check_admin_referer( 'wpforo-settings-forums' );
259 if( update_option('wpforo_forum_options', $_POST['wpforo_forum_options']) ){
260 $wpforo->notice->add('Forum options successfully updated', 'success');
261 }else{
262 $wpforo->notice->add('Forum options successfully updated, but previous value not changed', 'success');
263 }
264 wp_redirect( admin_url( 'admin.php?page=wpforo-settings&tab=forums' ) );
265 exit();
266 }
267
268 ##Posts
269 if( isset($_POST['wpforo_post_options']) ){
270 check_admin_referer( 'wpforo-settings-posts' );
271 $_POST['wpforo_post_options']['eot_durr'] = intval($_POST['wpforo_post_options']['eot_durr']) * 60;
272 $_POST['wpforo_post_options']['dot_durr'] = intval($_POST['wpforo_post_options']['dot_durr']) * 60;
273 $_POST['wpforo_post_options']['eor_durr'] = intval($_POST['wpforo_post_options']['eor_durr']) * 60;
274 $_POST['wpforo_post_options']['dor_durr'] = intval($_POST['wpforo_post_options']['dor_durr']) * 60;
275 $_POST['wpforo_post_options']['max_upload_size'] = intval(wpforo_human_size_to_bytes($_POST['wpforo_post_options']['max_upload_size'].'M'));
276 if( update_option('wpforo_post_options', $_POST['wpforo_post_options']) ){
277 $wpforo->notice->add('Post options successfully updated', 'success');
278 }else{
279 $wpforo->notice->add('Post options successfully updated, but previous value not changed', 'success');
280 }
281 wp_redirect( admin_url( 'admin.php?page=wpforo-settings&tab=posts' ) );
282 exit();
283 }
284
285 ##Members
286 if( isset($_POST['wpforo_member_options']) ){
287 check_admin_referer( 'wpforo-settings-members' );
288 $_POST['wpforo_member_options']['online_status_timeout'] = intval($_POST['wpforo_member_options']['online_status_timeout']) * 60;
289 if( update_option('wpforo_member_options', $_POST['wpforo_member_options']) ){
290 $wpforo->notice->add('Member options successfully updated', 'success');
291 }else{
292 $wpforo->notice->add('Member options successfully updated, but previous value not changed', 'success');
293 }
294 wp_redirect( admin_url( 'admin.php?page=wpforo-settings&tab=members' ) );
295 exit();
296 }
297
298 ##Features
299 if( isset($_POST['wpforo_features']) ){
300 check_admin_referer( 'wpforo-features' );
301 if( update_option('wpforo_features', $_POST['wpforo_features']) ){
302 $wpforo->notice->add('Features successfully updated', 'success');
303 }else{
304 $wpforo->notice->add('Features successfully updated, but previous value not changed', 'success');
305 }
306 wp_redirect( admin_url( 'admin.php?page=wpforo-settings&tab=features' ) );
307 exit();
308 }
309
310 ##Theme options
311 if( isset($_POST['wpforo_theme_options']) && isset($_POST['wpforo_style_options']) ){
312 check_admin_referer( 'wpforo-settings-styles' );
313 $wpforo->theme_options['style'] = sanitize_text_field($_POST['wpforo_theme_options']['style']);
314 $wpforo->theme_options['styles'] = $_POST['wpforo_theme_options']['styles'];
315 update_option('wpforo_style_options', $_POST['wpforo_style_options']);
316 update_option('wpforo_theme_options', $wpforo->theme_options);
317 $wpforo->notice->add('Theme options successfully updated', 'success');
318 wp_redirect( admin_url( 'admin.php?page=wpforo-settings&tab=styles' ) );
319 exit();
320 }
321
322 ##Subscription
323 if( isset($_POST['wpforo_subscribe_options']) ){
324 check_admin_referer( 'wpforo-settings-emails' );
325 if( update_option('wpforo_subscribe_options', $_POST['wpforo_subscribe_options']) ){
326 $wpforo->notice->add('Subscribe options successfully updated', 'success');
327 }else{
328 $wpforo->notice->add('Subscribe options successfully updated, but previous value not changed', 'success');
329 }
330 wp_redirect( admin_url( 'admin.php?page=wpforo-settings&tab=subscriptions' ) );
331 exit();
332 }
333
334 }
335
336 ### forum action ###
337 if( is_admin() && isset($_GET['page']) && $_GET['page'] == 'wpforo-forums' ){
338
339 if(!current_user_can('administrator')){
340 $wpforo->notice->add('Permission denied', 'error');
341 wp_redirect(admin_url());
342 exit();
343 }
344
345 if( isset($_POST['wpforo_submit']) && isset($_REQUEST['forum']) && isset($_GET['action']) ){
346 check_admin_referer( 'wpforo-forum-addedit' );
347 if( $_GET['action'] == 'add' ){
348 $forumid = $wpforo->forum->add();
349 }elseif( $_GET['action'] == 'edit' && isset($_GET['id']) ){
350 $forumid = $wpforo->forum->edit();
351 }
352 if( isset($forumid) && $forumid ){
353 wp_redirect( admin_url( 'admin.php?page=wpforo-forums&id=' . intval($forumid) . '&action=edit' ) );
354 }else{
355 wp_redirect( wpforo_full_url() );
356 }
357 exit();
358 }
359
360 if(isset($_POST['wpforo_delete']) && $_GET['action'] == 'del'){
361 check_admin_referer( 'wpforo-forum-delete' );
362 $wpforo->forum->delete();
363 wp_redirect( admin_url( 'admin.php?page=wpforo-forums' ) );
364 exit();
365 }
366
367 if(isset($_POST['forums_hierarchy_submit'])){
368 check_admin_referer( 'wpforo-forums-hierarchy' );
369 $wpforo->forum->update_hierarchy();
370 wp_redirect( admin_url( 'admin.php?page=wpforo-forums' ) );
371 exit();
372 }
373 }
374
375 ##Phrases
376 if( is_admin() && isset($_GET['page']) && $_GET['page'] == 'wpforo-phrases' ){
377
378 if(!current_user_can('administrator')){
379 $wpforo->notice->add('Permission denied', 'error');
380 wp_redirect(admin_url());
381 exit();
382 }
383
384 if(isset($_POST['phrase']['save'])){
385 check_admin_referer( 'wpforo-phrases-edit' );
386 $wpforo->phrase->edit();
387 wp_redirect( admin_url( 'admin.php?page=wpforo-phrases' ) );
388 exit();
389 }
390
391 if( isset($_POST['phrase']['add']) && !empty($_POST['phrase']['value']) ){
392 check_admin_referer( 'wpforo-phrase-add' );
393 $wpforo->phrase->add();
394 wp_redirect( admin_url( 'admin.php?page=wpforo-phrases' ) );
395 exit();
396 }
397 }
398
399
400 ##Members
401 if( is_admin() && isset($_GET['page']) && $_GET['page'] == 'wpforo-members' ){
402
403 if( isset( $_GET['action'] ) && $_GET['action'] == 'del' && isset( $_GET['id'] ) && $_GET['id'] ){
404
405 if(!check_admin_referer( 'wpforo_admin_table_action_delete' )){
406 $wpforo->notice->add('Permission denied', 'error');
407 wp_redirect(admin_url());
408 exit();
409 }
410
411 if( !$wpforo->perm->usergroup_can( $wpforo->current_user_groupid , 'dm' ) || !$wpforo->perm->user_can_manage_user( $wpforo->current_userid, intval($_GET['id']) ) ){
412 $wpforo->notice->add('Permission denied for this action', 'error');
413 wp_redirect( admin_url( 'admin.php?page=wpforo-members' ) );
414 exit();
415 }
416
417 $wpforo->member->delete( intval($_GET['id']) );
418 wp_redirect( admin_url( 'admin.php?page=wpforo-members' ) );
419 exit();
420 }
421 }
422
423
424 ##Usergroups
425 if( is_admin() && isset($_GET['page']) && $_GET['page'] == 'wpforo-usergroups' ){
426
427 if(!current_user_can('administrator')){
428 $wpforo->notice->add('Permission denied', 'error');
429 wp_redirect(admin_url());
430 exit();
431 }
432
433 if(isset( $_POST['usergroup']['action'] ) && ( $_POST['usergroup']['action'] == 'add' || $_POST['usergroup']['action'] == 'edit' ) ){
434 check_admin_referer( 'wpforo-usergroup-addedit' );
435 $board_cans = ( isset($_POST['cans']) ? $_POST['cans'] : array() );
436 if( $_POST['usergroup']['action'] == 'add' ){
437 $insert_usergroup_name = sanitize_text_field($_POST['usergroup']['name']);
438 $wpforo->usergroup->add( $insert_usergroup_name, $board_cans );
439 wp_redirect( admin_url( 'admin.php?page=wpforo-usergroups' ) );
440 exit();
441 }elseif( $_POST['usergroup']['action'] == 'edit' ){
442 $insert_usergroup_id = intval($_GET['gid']);
443 $insert_usergroup_name = sanitize_text_field($_POST['usergroup']['name']);
444 $wpforo->usergroup->edit( $insert_usergroup_id, $insert_usergroup_name, $board_cans );
445 wp_redirect( admin_url( 'admin.php?page=wpforo-usergroups' ) );
446 exit();
447 }
448
449 }
450 if(isset($_GET['action']) && $_GET['action']=='del' && isset($_POST['usergroup']['submit']) && $_POST['usergroup']['submit'] == 'Delete'){
451 check_admin_referer( 'wpforo-usergroup-delete' );
452 $wpforo->usergroup->delete();
453 wp_redirect( admin_url( 'admin.php?page=wpforo-usergroups' ) );
454 exit();
455 }
456 }
457
458 ##### Admin Accesses action ######
459 if( is_admin() && isset($_GET['page']) && $_GET['page'] == 'wpforo-settings' && isset($_GET['tab']) && $_GET['tab'] == 'accesses' ){
460
461 if(!current_user_can('administrator')){
462 $wpforo->notice->add('Permission denied', 'error');
463 wp_redirect(admin_url());
464 exit();
465 }
466
467 if( isset( $_POST['access'] ) && $_POST['access']['action'] == 'add' ){
468 check_admin_referer( 'wpforo-access-addedit' );
469 $cans = ( isset($_POST['cans'] ) ? $_POST['cans'] : array() );
470 $insert_access_name = sanitize_text_field($_POST['access']['name']);
471 $wpforo->perm->add( $insert_access_name, $cans );
472 wp_redirect( admin_url( 'admin.php?page=wpforo-settings&tab=accesses' ) );
473 exit();
474 }elseif( isset( $_POST['access'] ) && $_POST['access']['action'] == 'edit' ){
475 check_admin_referer( 'wpforo-access-addedit' );
476 $cans = ( isset($_POST['cans'] ) ? $_POST['cans'] : array() );
477 $insert_access_key = sanitize_text_field($_POST['access']['key']);
478 $insert_access_name = sanitize_text_field($_POST['access']['name']);
479 $wpforo->perm->edit( $insert_access_name, $cans, $insert_access_key );
480 wp_redirect( wpforo_full_url() );
481 exit();
482 }elseif( isset($_GET['action']) && $_GET['action'] == 'del' && isset($_GET['accessid']) ){
483
484 if( !check_admin_referer( 'wpforo_access_delete' )){
485 $wpforo->notice->add('Permission denied', 'error');
486 wp_redirect(admin_url());
487 exit();
488 }
489
490 $insert_access_id = intval($_GET['accessid']);
491 $wpforo->perm->delete( $insert_access_id );
492 wp_redirect( admin_url( 'admin.php?page=wpforo-settings&tab=accesses' ) );
493 exit();
494 }
495 }
496
497 ##Themes
498 if( is_admin() && isset($_GET['page']) && $_GET['page'] == 'wpforo-themes' && isset($_GET['theme']) ){
499
500 if(!current_user_can('administrator')){
501 $wpforo->notice->add('Permission denied', 'error');
502 wp_redirect(admin_url());
503 exit();
504 }
505
506 $theme = sanitize_text_field( $_GET['theme'] );
507 if( $_GET['action'] == 'activate' || $_GET['action'] == 'install' || $_GET['action'] == 'reset' ){
508 if( $_GET['action'] == 'activate' ){
509 $new_theme = get_option( 'wpforo_theme_archive_' . $theme );
510 }
511 elseif( $_GET['action'] == 'install' || $_GET['action'] == 'reset' ){
512 $new_theme = $wpforo->tpl->find_theme( $theme );
513 if( $_GET['action'] == 'reset' ){
514 delete_option( 'wpforo_theme_archive_' . $theme );
515 }
516 }
517 $current_theme = $wpforo->theme_options;
518 if( !empty($new_theme) ){
519 update_option( 'wpforo_theme_options', $new_theme );
520 if( $_GET['action'] != 'reset' ){
521 update_option( 'wpforo_theme_archive_' . $wpforo->theme, $current_theme );
522 }
523 }
524 wp_redirect( admin_url( 'admin.php?page=wpforo-themes' ) );
525 exit();
526 }
527 if( $_GET['action'] == 'delete' ){
528 $remove_dir = WPFORO_THEME_DIR . '/' . $theme;
529 if( is_dir($remove_dir) && strlen($theme) > 0 ){
530 wpforo_remove_directory( $remove_dir );
531 }
532 wp_redirect( admin_url( 'admin.php?page=wpforo-themes' ) );
533 exit();
534 }
535 }
536
537
538 if( isset($_GET['forum']) && $_GET['forum'] && isset($_GET['type']) && $_GET['type'] == 'rss2' ){
539 $forumid = intval($_GET['forum']);
540 $forum = $wpforo->forum->get_forum($forumid);
541 $forum['forumurl'] = $wpforo->forum->get_forum_url($forumid);
542
543 if(isset($_GET['topic']) && $_GET['topic']){
544 $topicid = intval($_GET['topic']);
545 $topic = $wpforo->topic->get_topic($topicid);
546 $topic['topicurl'] = $wpforo->topic->get_topic_url($topicid);
547 $posts = $wpforo->post->get_posts( array( 'topicid' => $topicid, 'row_count' => 10, 'orderby' => 'created', 'order' => 'DESC' ) );
548 foreach($posts as $key => $post){
549 $member = $wpforo->member->get_member($post['userid']);
550 $posts[$key]['description'] = wpforo_text( trim(strip_tags($post['body'])), 190, false );
551 $posts[$key]['content'] = trim($post['body']);
552 $posts[$key]['posturl'] = $wpforo->post->get_post_url($post['postid']);
553 $posts[$key]['author'] = $member['display_name'];
554 }
555 $wpforo->feed->rss2_topic($forum, $topic, $posts);
556 }
557 else{
558 $topics = $wpforo->topic->get_topics( array( 'forumid' => $forumid, 'row_count' => 10, 'orderby' => 'created', 'order' => 'DESC' ) );
559 foreach($topics as $key => $topic){
560 $post = $wpforo->post->get_post($topic['first_postid']);
561 $member = $wpforo->member->get_member($topic['userid']);
562 $topics[$key]['description'] = wpforo_text( trim(strip_tags($post['body'])), 190, false );
563 $topics[$key]['content'] = trim($post['body']);
564 $topics[$key]['topicurl'] = $wpforo->topic->get_topic_url($topic['topicid']);
565 $topics[$key]['author'] = $member['display_name'];
566 }
567 $wpforo->feed->rss2_forum($forum, $topics);
568 }
569 exit();
570 }
571
572
573 do_action( 'wpforo_actions_end' );
574
575 }
576
577
578 ?>