| @@ -1,132 +1,42 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | // Exit if accessed directly |
| 3 | 3 | if( !defined( 'ABSPATH' ) ) exit; |
| 4 | 4 | |
| 5 | -function wpforo_verify_form( $mode = 'full' ){ | |
| 6 | - if( $mode == 'nonce' || $mode == 'full'){ | |
| 7 | - if(!isset($_POST['wpforo_form']) || !wp_verify_nonce( $_POST['wpforo_form'], 'wpforo_verify_form' )) { | |
| 8 | - wpforo_phrase('Sorry, something wrong with your data.'); | |
| 9 | - exit(); | |
| 10 | - } | |
| 11 | - } | |
| 12 | - if( $mode == 'ref' || $mode == 'full'){ | |
| 13 | - if( !isset($_SERVER['HTTP_REFERER']) || !$_SERVER['HTTP_REFERER'] ) { | |
| 14 | - exit('Error 2252 | Please contact to forum admin.'); | |
| 15 | - } | |
| 16 | - $ref = $_SERVER['HTTP_REFERER']; | |
| 17 | - $url = get_bloginfo('url'); | |
| 18 | - $ref_domain = trim(strtolower(parse_url($ref, PHP_URL_HOST))); | |
| 19 | - $web_domain = trim(strtolower(parse_url($url, PHP_URL_HOST))); | |
| 20 | - if( $ref_domain != $web_domain ){ | |
| 21 | - exit('Error 2253 | Please contact to forum admin.'); | |
| 22 | - } | |
| 23 | - } | |
| 5 | +function wpforo_verify_form(){ | |
| 6 | + if(!isset($_POST['wpforo_form']) || !wp_verify_nonce( $_POST['wpforo_form'], 'wpforo_verify_form' )) { wpforo_phrase('Sorry, something wrong with your data.'); exit(); } | |
| 24 | 7 | } |
| 25 | 8 | |
| 26 | -function wpforo_home_url($str = '', $echo = false, $absolute = true){ | |
| 9 | +function is_wpforo_page(){ | |
| 27 | 10 | global $wpforo; |
| 11 | + if(isset($wpforo->current_object) && $wpforo->current_object['template'] && !is_admin()) return true; | |
| 12 | + return false; | |
| 13 | +} | |
| 28 | 14 | |
| 29 | - if( strpos($str, 'http') === 0 ){ | |
| 30 | - $base_url = preg_replace('#/?\?.*$#isu', '', wpforo_home_url()); | |
| 31 | - $base_url = preg_replace('#index\.php/?#isu', '', $base_url, 1); | |
| 32 | - $str = preg_replace('#index\.php/?#isu', '', $str, 1); | |
| 33 | - $str = preg_replace('#^'.preg_quote( rtrim($base_url, '/\\') ).'/?#isu', '', $str, 1); | |
| 34 | - } | |
| 35 | - $str = trim(WPFORO_BASE_PERMASTRUCT, '/\\') . '/' . trim($str, '/\\'); | |
| 36 | - | |
| 37 | - if( $absolute ){ | |
| 38 | - $url = $wpforo->user_trailingslashit( home_url($str) ); | |
| 39 | - //-START- check is url maybe wordpress home | |
| 40 | - $maybe_home_url = trim( preg_replace('#/?index\.php/?(\?.*)?$#isu', '', $url), '/\\' ); | |
| 41 | - $home_url = trim( home_url(), '/\\' ); | |
| 42 | - if( $maybe_home_url == $home_url ){ | |
| 43 | - $url = preg_replace('#index\.php/?#isu', '', $url, 1); | |
| 44 | - $url = $wpforo->user_trailingslashit($url); | |
| 15 | +function is_wpforo_home(){ | |
| 16 | + global $wpforo; | |
| 17 | + $wp_object = get_queried_object(); | |
| 18 | + $wpf_page = get_option('wpforo_pageid'); | |
| 19 | + if(!empty($wp_object) && isset($wpf_page) && !is_admin()){ | |
| 20 | + if(isset($wp_object->ID) && $wp_object->ID == $wpf_page ){ | |
| 21 | + $current_wpforo = trim( wpforo_full_url(), '/'); | |
| 22 | + $current_wppage = trim( WPFORO_BASE_URL, '/'); | |
| 23 | + if($current_wpforo == $current_wppage){ | |
| 24 | + return true; | |
| 25 | + } | |
| 26 | + else{ | |
| 27 | + return false; | |
| 28 | + } | |
| 45 | 29 | } |
| 46 | - //-END- check is url maybe wordpress home | |
| 30 | + else{ | |
| 31 | + return false; | |
| 32 | + } | |
| 47 | 33 | } |
| 48 | 34 | else{ |
| 49 | - echo $url = $wpforo->user_trailingslashit( $str ); | |
| 35 | + return false; | |
| 50 | 36 | } |
| 51 | - | |
| 52 | - if(!$echo) return $url; | |
| 53 | - echo $url; | |
| 54 | 37 | } |
| 55 | 38 | |
| 56 | -function wpforo_is_ajax(){ | |
| 57 | - if( defined('DOING_AJAX') && DOING_AJAX ) return TRUE; | |
| 58 | - return FALSE; | |
| 59 | -} | |
| 60 | - | |
| 61 | -function wpforo_is_admin(){ | |
| 62 | - if( is_admin() && !wpforo_is_ajax() ) return TRUE; | |
| 63 | - return FALSE; | |
| 64 | -} | |
| 65 | - | |
| 66 | -function is_wpforo_page($url = ''){ | |
| 67 | - if( wpforo_is_admin() ) return FALSE; | |
| 68 | - if(!$url) $url = wpforo_get_request_uri(); | |
| 69 | - if( is_wpforo_exclude_url($url) ) return FALSE; | |
| 70 | - if( is_wpforo_shortcode_page() ) return TRUE; | |
| 71 | - return is_wpforo_url($url); | |
| 72 | -} | |
| 73 | - | |
| 74 | -function is_wpforo_exclude_url($url = ''){ | |
| 75 | - global $wpforo; | |
| 76 | - if(!$url) $url = wpforo_get_request_uri(); | |
| 77 | - $url = urldecode($url); | |
| 78 | - $url = preg_replace('#/page/\d*/?$#isu', '', $url); | |
| 79 | - | |
| 80 | - if( $wpforo->use_home_url && $wpforo->excld_urls ){ | |
| 81 | - if( !$current_url = wpforo_get_url_query_vars_str($url) ) return FALSE; | |
| 82 | - $expld = array_filter( explode("\n", $wpforo->excld_urls) ); | |
| 83 | - foreach( $expld as $excld_url ){ | |
| 84 | - $excld_url = urldecode($excld_url); | |
| 85 | - if( strpos($excld_url, home_url('/')) === FALSE ) continue; | |
| 86 | - $excld_url = wpforo_get_url_query_vars_str($excld_url); | |
| 87 | - if( $excld_url && strtolower($current_url) == strtolower($excld_url) ) return TRUE; | |
| 88 | - } | |
| 89 | - } | |
| 90 | - | |
| 91 | - return FALSE; | |
| 92 | -} | |
| 93 | - | |
| 94 | -function is_wpforo_url($url = ''){ | |
| 95 | - if( wpforo_is_admin() ) return FALSE; | |
| 96 | - if(!$url) $url = wpforo_get_request_uri(); | |
| 97 | - global $wpforo; | |
| 98 | - | |
| 99 | - if( $wpforo->use_home_url ) return TRUE; | |
| 100 | - | |
| 101 | - $current_url = wpforo_get_url_query_vars_str($url); | |
| 102 | - | |
| 103 | - if( $wpforo->permastruct && strpos($current_url, $wpforo->permastruct) !== FALSE | |
| 104 | - && strpos($current_url, $wpforo->permastruct) == 0 | |
| 105 | - && !wpforo_is_admin() ) return TRUE; | |
| 106 | - | |
| 107 | - return FALSE; | |
| 108 | -} | |
| 109 | - | |
| 110 | -function is_wpforo_shortcode_page(){ | |
| 111 | - if( wpforo_is_admin() ) return FALSE; | |
| 112 | - global $wpforo, $post; | |
| 113 | - if( $post && isset($post->post_content) && has_shortcode( $post->post_content, 'wpforo' ) && !is_wpforo_url() ) return TRUE; | |
| 114 | - return FALSE; | |
| 115 | -} | |
| 116 | - | |
| 117 | -function wpforo_get_url_query_vars_str($url = ''){ | |
| 118 | - if(!$url) $url = wpforo_get_request_uri(); | |
| 119 | - | |
| 120 | - $home_url = preg_replace( '#/?\?.*$#isu', '', home_url('/') ); | |
| 121 | - $current_url = preg_replace('#https?://[^/\?]+/?#isu', '', $url); | |
| 122 | - $site_url = preg_replace('#https?://[^/\?]+/?#isu', '', $home_url); | |
| 123 | - $current_url = preg_replace( '#^/?'.preg_quote($site_url).'(?:/?index\.php/?)?#isu', '' , $current_url, 1 ); | |
| 124 | - $current_url = preg_replace('#^[\r\n\t\s\0/]*(.*?)[\r\n\t\s\0/]*$#isu', '$1', $current_url); | |
| 125 | - | |
| 126 | - return $current_url; | |
| 127 | -} | |
| 128 | - | |
| 129 | 39 | function wpforo_feature( $option, $wpforo = NULL ){ |
| 130 | 40 | if( empty($wpforo) ) global $wpforo; |
| 131 | 41 | if( isset($wpforo->features[$option]) && $wpforo->features[$option] ){ |
| 132 | 42 | return true; |
| @@ -135,36 +45,19 @@ | ||
| 135 | 45 | return false; |
| 136 | 46 | } |
| 137 | 47 | } |
| 138 | 48 | |
| 139 | -function wpforo_dir_size($directory) { | |
| 140 | - $size = 0; | |
| 141 | - if(class_exists('RecursiveIteratorIterator') && class_exists('RecursiveDirectoryIterator')){ | |
| 142 | - foreach(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)) as $file) $size+=$file->getSize(); | |
| 143 | - return $size; | |
| 49 | +function wpforo_add_notice( $phrase_key ){ | |
| 50 | + global $wpforo; | |
| 51 | + $wpforo_noticies = $wpforo->notices; | |
| 52 | + if( is_array($wpforo_noticies) && !empty( $wpforo_noticies ) ){ | |
| 53 | + $wpforo_noticies[] = $phrase_key; | |
| 54 | + update_option( 'wpforo_notices', array_unique( $wpforo_noticies ) ); | |
| 55 | + }else{ | |
| 56 | + update_option( 'wpforo_notices', array( $phrase_key )); | |
| 144 | 57 | } |
| 145 | - else{ | |
| 146 | - return 0; | |
| 147 | - } | |
| 148 | 58 | } |
| 149 | 59 | |
| 150 | -function wpforo_make_hidden_fields_from_url($url = '', $echo = true){ | |
| 151 | - if( !$url ) $url = wpforo_get_request_uri(); | |
| 152 | - | |
| 153 | - $return = ''; | |
| 154 | - if( $url_query = parse_url($url, PHP_URL_QUERY) ){ | |
| 155 | - parse_str($url_query, $url_query_arr); | |
| 156 | - if( !empty($url_query_arr) ){ | |
| 157 | - foreach ($url_query_arr as $key => $value) { | |
| 158 | - $return .= '<input type="hidden" name="'.$key.'" value="'.$value.'">'; | |
| 159 | - } | |
| 160 | - } | |
| 161 | - } | |
| 162 | - | |
| 163 | - if( !$echo ) return $return; | |
| 164 | - echo $return; | |
| 165 | -} | |
| 166 | - | |
| 167 | 60 | ################################################################################# |
| 168 | 61 | /** |
| 169 | 62 | * Returns merged arguments array from defined and default arguments. |
| 170 | 63 | * |
| @@ -232,17 +125,14 @@ | ||
| 232 | 125 | } |
| 233 | 126 | } |
| 234 | 127 | |
| 235 | 128 | |
| 236 | -function wpforo_get_request_uri($with_port = FALSE, $get_referer_when_ajax = TRUE){ | |
| 237 | - if( $get_referer_when_ajax && wpforo_is_ajax() ){ | |
| 238 | - if( isset($_SERVER['HTTP_REFERER']) ){ return $_SERVER['HTTP_REFERER']; } | |
| 239 | - } | |
| 240 | - $s = empty($_SERVER["HTTPS"]) ? '' : ($_SERVER["HTTPS"] == "on") ? "s" : ""; | |
| 129 | +function wpforo_full_url(){ | |
| 130 | + $s = empty($_SERVER["HTTPS"]) ? '' : ($_SERVER["HTTPS"] == "on") ? "s" : ""; | |
| 241 | 131 | $sp = strtolower($_SERVER["SERVER_PROTOCOL"]); |
| 242 | 132 | $protocol = substr($sp, 0, strpos($sp, "/")) . $s; |
| 243 | 133 | $port = ($_SERVER["SERVER_PORT"] == "80") ? "" : (":".$_SERVER["SERVER_PORT"]); |
| 244 | - return $protocol . "://" . $_SERVER['HTTP_HOST'] . ($with_port ? $port : '') . $_SERVER['REQUEST_URI']; | |
| 134 | + return $protocol . "://" . $_SERVER['SERVER_NAME'] . $port . $_SERVER['REQUEST_URI']; | |
| 245 | 135 | } |
| 246 | 136 | |
| 247 | 137 | |
| 248 | 138 | function wpforo_arr_group_by($array, $key_by){ |
| @@ -269,12 +159,11 @@ | ||
| 269 | 159 | * @param array action buttons ( full posible values $actions = array( 'edit', 'delete', 'view' ); ) |
| 270 | 160 | * |
| 271 | 161 | * @return echo html table |
| 272 | 162 | */ |
| 273 | -function wpforo_create_form_table($varname, $primary_key, $fields = array(), $search_fields = array(), $filter_fields = array(), $actions = array(), $bulk_actions = array() ){ | |
| 163 | +function wpforo_create_form_table($varname, $primary_key, $fields = array(), $search_fields = array(), $filter_fields = array(), $actions = array() ){ | |
| 274 | 164 | |
| 275 | 165 | if(empty($actions)) $actions = array( 'edit', 'delete', 'view' ); |
| 276 | - if(empty($bulk_actions)) $bulk_actions = array( 'del' ); | |
| 277 | 166 | |
| 278 | 167 | if(!empty($fields)) : |
| 279 | 168 | global $wpdb; |
| 280 | 169 | global $wpforo; |
| @@ -282,14 +171,11 @@ | ||
| 282 | 171 | $args = array(); |
| 283 | 172 | |
| 284 | 173 | if(isset($_GET['s']) && $_GET['s'] != '') $args['include'] = $wpforo->$varname->search(sanitize_text_field($_GET['s']), $search_fields); |
| 285 | 174 | if(isset($_GET['orderby'])) $args['orderby'] = sanitize_text_field($_GET['orderby']); |
| 286 | - if(isset($_GET['order'])) $args['order'] = sanitize_text_field($_GET['order']); | |
| 175 | + if(isset($_GET['order'])) $args['order'] = intval($_GET['order']); | |
| 287 | 176 | if(isset($_GET['forumid']) && $_GET['forumid'] != 0) $args['forumid'] = intval($_GET['forumid']); |
| 288 | 177 | if(isset($_GET['groupid']) && $_GET['groupid'] != 0) $args['groupid'] = intval($_GET['groupid']); |
| 289 | - if(isset($_GET['member_status']) && $_GET['member_status']) $args['status'] = (array) sanitize_text_field($_GET['member_status']); | |
| 290 | - if(isset($_GET['phrase_package']) && $_GET['phrase_package']) $args['package'] = (array) sanitize_text_field($_GET['phrase_package']); | |
| 291 | - if(isset($_GET['langid']) && $_GET['langid']) $args['langid'] = intval($_GET['langid']); | |
| 292 | 178 | if(isset($_GET['userid']) && $_GET['userid'] != 0) $args['userid'] = intval($_GET['userid']); |
| 293 | 179 | $paged = isset($_GET['paged']) ? intval($_GET['paged']) : 1; |
| 294 | 180 | |
| 295 | 181 | $args['offset'] = ($paged - 1) * get_option('wpforo_count_per_page'); |
| @@ -302,11 +188,8 @@ | ||
| 302 | 188 | $func = 'get_'.$varname.'s'; |
| 303 | 189 | } |
| 304 | 190 | |
| 305 | 191 | $items_count = 0; |
| 306 | - if( $varname == 'member' && !isset($_GET['member_status']) ){ | |
| 307 | - $args['status'] = array('active'); | |
| 308 | - } | |
| 309 | 192 | |
| 310 | 193 | $items = $wpforo->$varname->$func($args, $items_count); |
| 311 | 194 | |
| 312 | 195 | if(isset($args['include']) && empty($args['include'])){ |
| @@ -349,42 +232,17 @@ | ||
| 349 | 232 | |
| 350 | 233 | |
| 351 | 234 | <div class="wpforo-search-box"> |
| 352 | 235 | <form name="search" id="srch" action="<?php echo admin_url( 'admin.php' ) ?>" method="GET"> |
| 353 | - <?php if( !empty($_GET) ) : ?> | |
| 354 | - <?php foreach ($_GET as $get_key => $get) : ?> | |
| 355 | - <input type="hidden" name="<?php echo $get_key ?>" value="<?php echo $get ?>"/> | |
| 356 | - <?php endforeach ?> | |
| 357 | - <?php endif ?> | |
| 358 | - <label class="screen-reader-text" for="post-search-input">Search <?php echo esc_attr(ucfirst($varname)); ?>s:</label> | |
| 359 | - <input type="search" id="post-search-input" name="s" value="<?php echo ( isset($_GET['s']) ? esc_attr(sanitize_text_field($_GET['s'])) : '' ) ?>"> | |
| 360 | - <input type="submit" name="" id="search-submit" class="button" value="Search <?php echo esc_attr(ucfirst($varname)); ?>s"> | |
| 236 | + <input type="hidden" name="page" value="wpforo-<?php echo esc_attr($varname); ?>s"/> | |
| 237 | + <label class="screen-reader-text" for="post-search-input">Search <?php echo esc_attr(ucfirst($varname)); ?>s:</label> | |
| 238 | + <input type="search" id="post-search-input" name="s" value="<?php echo ( isset($_GET['s']) ? esc_attr(sanitize_text_field($_GET['s'])) : '' ) ?>"> | |
| 239 | + <input type="submit" name="" id="search-submit" class="button" value="Search <?php echo esc_attr(ucfirst($varname)); ?>s"> | |
| 361 | 240 | </form> |
| 362 | 241 | </div> |
| 363 | - <?php if($varname == 'moderation'): ?> | |
| 364 | - <?php | |
| 365 | - $total = $wpforo->post->get_count(); | |
| 366 | - $up_total = (!isset($_GET['filter_by_status']) || (isset($_GET['filter_by_status']) && $_GET['filter_by_status'] == 1 )) ? $items_count : ($total - $items_count); | |
| 367 | - $ap_total = ((isset($_GET['filter_by_status']) && $_GET['filter_by_status'] == 0 )) ? $items_count : ($total - $items_count); | |
| 368 | - ?> | |
| 369 | - <ul class="subsubsub" style="margin:-25px 0px 5px 0px;"> | |
| 370 | - <li><a href="<?php echo admin_url( 'admin.php' ) ?>?page=wpforo-moderations&filter_by_status=1" <?php if( !isset($_GET['filter_by_status']) || (isset($_GET['filter_by_status']) && $_GET['filter_by_status'] == 1 ) ) echo 'class="current"' ?>><?php _e('Unapproved', 'wpforo'); ?> <span class="count">(<?php echo intval($up_total); ?>)</span></a> |</li> | |
| 371 | - <li><a href="<?php echo admin_url( 'admin.php' ) ?>?page=wpforo-moderations&filter_by_status=0" <?php if( (isset($_GET['filter_by_status']) && $_GET['filter_by_status'] == 0 ) ) echo 'class="current"' ?>><?php _e('Published', 'wpforo'); ?> <span class="count">(<?php echo intval($ap_total); ?>)</span></a></li> | |
| 372 | - </ul> | |
| 373 | - <?php elseif($varname == 'member' && (!isset($_GET['groupid']) || (isset($_GET['groupid']) && !$_GET['groupid'])) ): ?> | |
| 374 | - <?php | |
| 375 | - $total = $wpforo->member->get_count(); | |
| 376 | - $up_total = (!isset($_GET['member_status']) || (isset($_GET['member_status']) && $_GET['member_status'] == 'active' )) ? $items_count : ($total - $items_count); | |
| 377 | - $ap_total = ((isset($_GET['member_status']) && $_GET['member_status'] == 'banned' )) ? $items_count : ($total - $items_count); | |
| 378 | - ?> | |
| 379 | - <ul class="subsubsub" style="margin:-25px 0px 5px 0px;"> | |
| 380 | - <li><a href="<?php echo admin_url( 'admin.php' ) ?>?page=wpforo-members&member_status=active" <?php if( !isset($_GET['member_status']) || (isset($_GET['member_status']) && $_GET['member_status'] == 'active' ) ) echo 'class="current"' ?>><?php _e('Active', 'wpforo'); ?> <span class="count">(<?php echo intval($up_total); ?>)</span></a> |</li> | |
| 381 | - <li><a href="<?php echo admin_url( 'admin.php' ) ?>?page=wpforo-members&member_status=banned" <?php if( (isset($_GET['member_status']) && $_GET['member_status'] == 'banned' ) ) echo 'class="current"' ?>><?php _e('Banned', 'wpforo'); ?> <span class="count">(<?php echo intval($ap_total); ?>)</span></a></li> | |
| 382 | - </ul> | |
| 383 | - <?php endif; ?> | |
| 384 | 242 | |
| 385 | 243 | <form name="items" id="items" action="<?php echo admin_url( 'admin.php' ) ?>" method="GET"> |
| 386 | - <?php wp_nonce_field( 'bulk_action_'.$varname ); ?> | |
| 244 | + | |
| 387 | 245 | <input type="hidden" name="ids" /> |
| 388 | 246 | <input type="hidden" name="page" value="wpforo-<?php echo esc_attr($varname); ?>s"/> |
| 389 | 247 | |
| 390 | 248 | <div class="tablenav top"> |
| @@ -391,11 +249,13 @@ | ||
| 391 | 249 | |
| 392 | 250 | <div class="alignleft actions"> |
| 393 | 251 | <select name="action"> |
| 394 | 252 | <option value="-1" selected="selected"><?php _e('Bulk Actions', 'wpforo'); ?></option> |
| 395 | - <?php foreach( $bulk_actions as $bulk_action ) : ?> | |
| 396 | - <option value="<?php echo $bulk_action ?>"><?php _e($bulk_action, 'wpforo'); ?></option> | |
| 397 | - <?php endforeach ?> | |
| 253 | + <?php if($varname == 'phrase') : ?> | |
| 254 | + <option value="edit"><?php _e('Edit', 'wpforo'); ?></option> | |
| 255 | + <?php else : ?> | |
| 256 | + <option value="del"><?php _e('Delete', 'wpforo'); ?></option> | |
| 257 | + <?php endif ?> | |
| 398 | 258 | </select> |
| 399 | 259 | <input type="button" onclick="wpforo_doaction()" id="doaction" class="button action" value="<?php _e('Apply', 'wpforo'); ?>"> |
| 400 | 260 | </div> |
| 401 | 261 | <div class="alignleft actions"> |
| @@ -401,25 +261,24 @@ | ||
| 401 | 261 | <div class="alignleft actions"> |
| 402 | 262 | |
| 403 | 263 | <?php if(!empty($filter_fields)) : ?> |
| 404 | 264 | <?php foreach($filter_fields as $filter_field) : ?> |
| 405 | - <?php if($filter_field == 'forumid'){ ?> | |
| 265 | + <?php if($filter_field == 'forumid') : ?> | |
| 406 | 266 | |
| 407 | 267 | <select name="<?php echo esc_attr($filter_field) ?>"> |
| 408 | 268 | <option value="0"><?php _e('Show all forums', 'wpforo'); ?></option> |
| 409 | 269 | <?php $wpforo->forum->tree('select_box'); ?> |
| 410 | 270 | </select> |
| 411 | - | |
| 412 | - <?php }elseif($filter_field == 'langid'){ ?> | |
| 413 | 271 | |
| 272 | + <?php elseif($filter_field == 'langid') : ?> | |
| 273 | + | |
| 414 | 274 | <select name="<?php echo esc_attr($filter_field) ?>"> |
| 415 | 275 | <?php $wpforo->phrase->show_lang_list() ?> |
| 416 | 276 | </select> |
| 417 | - | |
| 418 | - <?php }elseif($filter_field == 'groupid'){ ?> | |
| 419 | 277 | |
| 278 | + <?php elseif($filter_field == 'groupid') : ?> | |
| 279 | + | |
| 420 | 280 | <select name="<?php echo esc_attr($filter_field) ?>"> |
| 421 | - <option value="0"><?php _e('filter by group', 'wpforo') ?></option> | |
| 422 | 281 | <?php foreach($wpforo->usergroup->get_usergroups() as $group) : ?> |
| 423 | 282 | <?php if( $group['groupid'] != 4 ) : ?> |
| 424 | 283 | <option value="<?php echo esc_attr($group['groupid']) ?>" <?php echo ( isset($_GET['groupid']) && $_GET['groupid'] == $group['groupid'] ? 'selected' : '' ) ?>><?php echo esc_html($group['name']) ?></option> |
| 425 | 284 | <?php endif ?> |
| @@ -425,70 +284,10 @@ | ||
| 425 | 284 | <?php endif ?> |
| 426 | 285 | <?php endforeach; ?> |
| 427 | 286 | </select> |
| 428 | 287 | |
| 429 | - <?php }elseif( $varname == 'member' && $filter_field == 'status' ){ | |
| 430 | - $sql = "SELECT DISTINCT `status` as statuses FROM `" . $wpforo->db->prefix . "wpforo_profiles`"; | |
| 431 | - if( $statuses = $wpforo->db->get_col($sql) ){ ?> | |
| 432 | - <select name="member_status"> | |
| 433 | - <option value="0"><?php _e('filter by status', 'wpforo') ?></option> | |
| 434 | - | |
| 435 | - <?php foreach( $statuses as $status ) : ?> | |
| 436 | - <option value="<?php echo esc_attr($status) ?>" <?php echo ( isset($_GET['member_status']) && $_GET['member_status'] == $status ? 'selected' : '' ) ?>><?php echo esc_html($status) ?></option> | |
| 437 | - <?php endforeach; ?> | |
| 438 | - | |
| 439 | - </select> | |
| 440 | - | |
| 441 | - <?php | |
| 442 | - } | |
| 443 | - | |
| 444 | - }elseif( $varname == 'phrase' && $filter_field == 'package' ){ | |
| 445 | - | |
| 446 | - $sql = "SELECT DISTINCT `package` as packages FROM `" . $wpforo->db->prefix . "wpforo_phrases`"; | |
| 447 | - if( $packages = $wpforo->db->get_col($sql) ){ ?> | |
| 448 | - <select name="phrase_package"> | |
| 449 | - <option value="0"><?php _e('filter by package', 'wpforo') ?></option> | |
| 450 | - | |
| 451 | - <?php foreach( $packages as $package ) : ?> | |
| 452 | - <option value="<?php echo esc_attr($package) ?>" <?php echo ( isset($_GET['phrase_package']) && $_GET['phrase_package'] == $package ? 'selected' : '' ) ?>><?php echo esc_html($package) ?></option> | |
| 453 | - <?php endforeach; ?> | |
| 454 | - | |
| 455 | - </select> | |
| 456 | - | |
| 457 | - <?php | |
| 458 | - } | |
| 459 | - | |
| 460 | - }elseif( $varname == 'moderation' ){ | |
| 461 | - $filter_by_status = intval( ( isset($_GET['filter_by_status']) ? $_GET['filter_by_status'] : 1 ) ); | |
| 462 | - | |
| 463 | - if($filter_field == 'status'){ | |
| 464 | - if( $statuses = $wpforo->moderation->post_statuses ) : ?> | |
| 465 | - <select name="filter_by_status"> | |
| 466 | - | |
| 467 | - <?php foreach ($statuses as $key => $status) : ?> | |
| 468 | - <option value="<?php echo esc_attr($key) ?>" <?php echo ( $filter_by_status == $key ? 'selected' : '' ) ?>><?php echo esc_html( $status ) ?></option> | |
| 469 | - <?php endforeach; ?> | |
| 470 | - | |
| 471 | - </select> | |
| 472 | - <?php | |
| 473 | - endif; | |
| 474 | - }elseif($filter_field == 'userid'){ | |
| 475 | - $sql = "SELECT DISTINCT `userid` FROM `".$wpforo->db->prefix."wpforo_posts` WHERE `status` = $filter_by_status"; | |
| 476 | - if( $userids = $wpforo->db->get_col($sql) ) : ?> | |
| 477 | - <select name="filter_by_userid"> | |
| 478 | - <option value="0"><?php _e('filter by user', 'wpforo') ?></option> | |
| 479 | - | |
| 480 | - <?php foreach ($userids as $userid) : $user = $wpforo->member->get_member($userid); ?> | |
| 481 | - <option value="<?php echo esc_attr($userid) ?>" <?php echo ( isset($_GET['filter_by_userid']) && $_GET['filter_by_userid'] == $userid ? 'selected' : '' ) ?>><?php echo esc_html( wpforo_make_dname($user['display_name'], $user['user_nicename']) ) ?></option> | |
| 482 | - <?php endforeach; ?> | |
| 483 | - | |
| 484 | - </select> | |
| 485 | - <?php | |
| 486 | - endif; | |
| 487 | - } | |
| 488 | - | |
| 489 | - } ?> | |
| 490 | - | |
| 288 | + <?php endif; ?> | |
| 289 | + | |
| 491 | 290 | <?php endforeach; ?> |
| 492 | 291 | |
| 493 | 292 | <input type="submit" name="" id="post-query-submit" class="button" value="Filter"> |
| 494 | 293 | |
| @@ -499,14 +298,14 @@ | ||
| 499 | 298 | <span class="pagination-links"> |
| 500 | 299 | <?php if( !isset($_GET['paged']) || $_GET['paged'] <= 2 ) : ?> |
| 501 | 300 | <span class="tablenav-pages-navspan">«</span> |
| 502 | 301 | <?php else : ?> |
| 503 | - <a class="first-page" title="Go to the first page" href="<?php echo esc_url(preg_replace('#(\&*paged\=[^\&]*)#is', '', wpforo_get_request_uri())); ?>">«</a> | |
| 302 | + <a class="first-page" title="Go to the first page" href="<?php echo esc_url(preg_replace('#(\&*paged\=[^\&]*)#is', '', wpforo_full_url())); ?>">«</a> | |
| 504 | 303 | <?php endif ?> |
| 505 | 304 | <?php if( !isset($_GET['paged']) || $_GET['paged'] <= 1 ) : ?> |
| 506 | 305 | <span class="tablenav-pages-navspan">‹</span> |
| 507 | 306 | <?php else : ?> |
| 508 | - <a class="prev-page" title="Go to the previous page" href="<?php echo esc_url(preg_replace('#(\&*paged\=[^\&]*)#is', '', wpforo_get_request_uri())); ?>&paged=<?php echo !isset($_GET['paged']) || $_GET['paged'] <= 1 ? 1 : $_GET['paged'] - 1 ?>">‹</a> | |
| 307 | + <a class="prev-page" title="Go to the previous page" href="<?php echo esc_url(preg_replace('#(\&*paged\=[^\&]*)#is', '', wpforo_full_url())); ?>&paged=<?php echo !isset($_GET['paged']) || $_GET['paged'] <= 1 ? 1 : $_GET['paged'] - 1 ?>">‹</a> | |
| 509 | 308 | <?php endif ?> |
| 510 | 309 | |
| 511 | 310 | <span class="paging-input"><input class="current-page" title="Current page" type="text" name="paged" value="<?php echo isset($_GET['paged']) ? intval($_GET['paged']) : 1 ?>" size="1"> of <span class="total-pages"><?php echo intval($pages_count) ?></span></span> |
| 512 | 311 | |
| @@ -512,14 +311,14 @@ | ||
| 512 | 311 | |
| 513 | 312 | <?php if( isset($_GET['paged']) && $_GET['paged'] >= $pages_count ) : ?> |
| 514 | 313 | <span class="tablenav-pages-navspan">›</span> |
| 515 | 314 | <?php else : ?> |
| 516 | - <a class="next-page" title="Go to the next page" href="<?php echo esc_url(preg_replace('#(\&*paged\=[^\&]*)#is', '', wpforo_get_request_uri())); ?>&paged=<?php echo (isset($_GET['paged']) ? ( $_GET['paged'] >= $pages_count ? intval($pages_count) : intval($_GET['paged']) + 1 ) : (!isset($_GET['paged']) ? 2 : intval($_GET['paged']) + 1)) ?>">›</a> | |
| 315 | + <a class="next-page" title="Go to the next page" href="<?php echo esc_url(preg_replace('#(\&*paged\=[^\&]*)#is', '', wpforo_full_url())); ?>&paged=<?php echo (isset($_GET['paged']) ? ( $_GET['paged'] >= $pages_count ? intval($pages_count) : intval($_GET['paged']) + 1 ) : (!isset($_GET['paged']) ? 2 : intval($_GET['paged']) + 1)) ?>">›</a> | |
| 517 | 316 | <?php endif ?> |
| 518 | 317 | <?php if( (isset($_GET['paged']) && $_GET['paged'] >= $pages_count - 1) || 1 >= $pages_count - 1 ) : ?> |
| 519 | 318 | <span class="tablenav-pages-navspan">»</span> |
| 520 | 319 | <?php else : ?> |
| 521 | - <a class="last-page" title="Go to the last page" href="<?php echo esc_url(preg_replace('#(\&*paged\=[^\&]*)#is', '', wpforo_get_request_uri())); ?>&paged=<?php echo intval($pages_count) ?>">»</a></span> | |
| 320 | + <a class="last-page" title="Go to the last page" href="<?php echo esc_url(preg_replace('#(\&*paged\=[^\&]*)#is', '', wpforo_full_url())); ?>&paged=<?php echo intval($pages_count) ?>">»</a></span> | |
| 522 | 321 | <?php endif ?> |
| 523 | 322 | </div> <br class="clear"> |
| 524 | 323 | |
| 525 | 324 | </div> |
| @@ -531,10 +330,10 @@ | ||
| 531 | 330 | <label class="screen-reader-text" for="cb-select-all-1"><?php _e('Select All', 'wpforo') ?></label><input id="cb-select-all-1" type="checkbox" onclick="wpforo_check_uncheck_all(this.checked)"> |
| 532 | 331 | </th> |
| 533 | 332 | <?php foreach($fields as $key => $field) : ?> |
| 534 | 333 | <th scope="col" <?php if($key===0) echo ' style="width:30%"' ?> id="<?php echo esc_attr(sanitize_text_field($field)) ?>" class="manage-column column-<?php echo esc_attr(sanitize_text_field($field)) ?> <?php echo isset($_GET['order']) ? ($_GET['orderby'] == $field ? 'sorted ' : '') . $_GET['order'] : 'sortable asc' ?>"> |
| 535 | - <a href="<?php echo esc_url(preg_replace('#(\&*orderby\=[^\&]*\&*order\=[^\&]*)#is', '', wpforo_get_request_uri())); ?>&orderby=<?php echo esc_attr(sanitize_text_field($field)) ?>&order=<?php echo isset($_GET['order']) ? ( $_GET['order'] == 'asc' ? 'desc' : 'asc' ) : 'asc' ?>"> | |
| 536 | - <span><?php if($field == 'is_first_post'){ _e('Type', 'wpforo'); }else{ echo sanitize_text_field(str_replace('_', ' ', wpforo_phrase( $field, false ))); } ?></span> | |
| 334 | + <a href="<?php echo esc_url(preg_replace('#(\&*orderby\=[^\&]*\&*order\=[^\&]*)#is', '', wpforo_full_url())); ?>&orderby=<?php echo esc_attr(sanitize_text_field($field)) ?>&order=<?php echo isset($_GET['order']) ? ( $_GET['order'] == 'asc' ? 'desc' : 'asc' ) : 'asc' ?>"> | |
| 335 | + <span><?php echo sanitize_text_field(str_replace('_', ' ', wpforo_phrase( $field, false ))) ?></span> | |
| 537 | 336 | <span class="sorting-indicator"></span> |
| 538 | 337 | </a> |
| 539 | 338 | </th> |
| 540 | 339 | <?php endforeach; ?> |
| @@ -548,9 +347,9 @@ | ||
| 548 | 347 | </th> |
| 549 | 348 | <?php foreach($fields as $key => $field) : ?> |
| 550 | 349 | <th scope="col" <?php if($key===0) echo ' style="width:30%"' ?> id="<?php echo esc_attr($field) ?>" class="manage-column column-<?php echo esc_attr($field) ?> <?php echo isset($_GET['order']) ? ($_GET['orderby'] == $field ? 'sorted ' : '') . $_GET['order'] : 'sortable asc' ?>"> |
| 551 | 350 | <a href="<?php echo admin_url( 'admin.php?page=wpforo-' . esc_attr(sanitize_text_field($varname)) . 's&orderby=' . esc_attr(sanitize_text_field($field)) . '&order=' . ( isset($_GET['order']) ? ( $_GET['order'] == 'asc' ? 'desc' : 'asc' ) : 'asc' ) ) ?>"> |
| 552 | - <span><?php if($field == 'is_first_post'){ _e('Type', 'wpforo'); }else{ echo sanitize_text_field(str_replace('_', ' ', wpforo_phrase( $field, false ))); } ?></span> | |
| 351 | + <span><?php echo esc_html(sanitize_text_field(str_replace('_', ' ', wpforo_phrase( $field, false )))) ?></span> | |
| 553 | 352 | <span class="sorting-indicator"></span> |
| 554 | 353 | </a> |
| 555 | 354 | </th> |
| 556 | 355 | <?php endforeach; ?> |
| @@ -578,11 +377,9 @@ | ||
| 578 | 377 | <?php |
| 579 | 378 | if($varname == 'member'){ |
| 580 | 379 | $url = $url_user = admin_url( 'user-edit.php?user_id=' . intval($item[$primary_key])); |
| 581 | 380 | $url_profile = $wpforo->$varname->get_profile_url($item[$primary_key], 'account'); |
| 582 | - }elseif($varname == 'moderation'){ | |
| 583 | - $url = $wpforo->post->get_post_url($item[$primary_key]); | |
| 584 | - }else{ | |
| 381 | + }else{ | |
| 585 | 382 | $url = admin_url( 'admin.php?page=wpforo-'. $varname .'s&id='.$item[$primary_key] .'&action=edit' ); |
| 586 | 383 | } |
| 587 | 384 | ?> |
| 588 | 385 | <td class="post-<?php echo esc_attr($item[$field]) ?> page-<?php echo esc_attr($item[$field]) ?> column-<?php echo esc_attr($item[$field]) ?>"> |
| @@ -601,60 +398,38 @@ | ||
| 601 | 398 | <div class="row-actions"> |
| 602 | 399 | <?php foreach($actions as $act_key => $action) : ?> |
| 603 | 400 | <?php switch($action) : |
| 604 | 401 | case 'edit': ?> |
| 605 | - <span class="edit"><a href="<?php echo esc_url($url); ?>" title="Edit this item"><?php _e('edit', 'wpforo'); ?></a></span> | |
| 606 | - <?php if( $act_key != ( count($actions) - 1 ) ) echo " | "; ?> | |
| 402 | + <span class="edit"><a href="<?php echo esc_url($url); ?>" title="Edit this item"><?php wpforo_phrase('edit'); ?></a></span> | |
| 607 | 403 | <?php break; |
| 608 | 404 | case 'edit_user': ?> |
| 609 | - <span class="edit"><a href="<?php echo esc_url($url_user); ?>"><?php _e('edit user', 'wpforo'); ?></a></span> | |
| 610 | - <?php if( $act_key != ( count($actions) - 1 ) ) echo " | "; ?> | |
| 405 | + <span class="edit"><a href="<?php echo esc_url($url_user); ?>"><?php wpforo_phrase('edit user'); ?></a></span> | |
| 611 | 406 | <?php break; |
| 612 | 407 | case 'edit_profile': ?> |
| 613 | - <span class="edit"><a href="<?php echo esc_url($url_profile); ?>"><?php _e('edit profile', 'wpforo'); ?></a></span> | |
| 614 | - <?php if( $act_key != ( count($actions) - 1 ) ) echo " | "; ?> | |
| 408 | + <span class="edit"><a href="<?php echo esc_url($url_profile); ?>"><?php wpforo_phrase('edit profile'); ?></a></span> | |
| 615 | 409 | <?php break; |
| 616 | - case 'ban': if($item['userid'] == $wpforo->current_userid) break; ?> | |
| 617 | - <?php $ban_url = wp_nonce_url( admin_url( 'admin.php?page=wpforo-' . esc_attr(sanitize_text_field($varname)) . 's&id=' . intval($item[$primary_key]) . '&action=' . ($item['status'] == 'banned' ? 'unban' : 'ban') ), 'wpforo_admin_table_action_ban' ); ?> | |
| 618 | - <span class="trash"><a class="submitban" title="<?php echo ($item['status'] == 'banned' ? __('unban user', 'wpforo') : __('ban user', 'wpforo') ) ?>" onclick="return confirm('<?php echo ($item['status'] == 'banned' ? __('Are you sure, you want to unban this user?', 'wpforo') : __('Are you sure, you want to ban this user?', 'wpforo') ) ?>');" href="<?php echo esc_url($ban_url); ?>"><?php echo ($item['status'] == 'banned' ? __('unban user', 'wpforo') : __('ban user', 'wpforo') ) ?></a></span> | |
| 619 | - <?php if( $act_key != ( count($actions) - 1 ) ) echo " | "; ?> | |
| 620 | - <?php break; | |
| 621 | 410 | case 'delete': ?> |
| 622 | 411 | <?php $delete_url = wp_nonce_url( admin_url( 'admin.php?page=wpforo-' . esc_attr(sanitize_text_field($varname)) . 's&id=' . intval($item[$primary_key]) . '&action=del' ), 'wpforo_admin_table_action_delete' ); ?> |
| 623 | - <span class="trash"><a class="submitdelete" title="<?php _e('Delete this item', 'wpforo') ?>" onclick="return confirm('<?php _e('Are you sure you whant to DELETE this item?', 'wpforo') ?>');" href="<?php echo esc_url($delete_url); ?>"><?php _e('delete', 'wpforo'); ?></a></span> | |
| 624 | - <?php if( $act_key != ( count($actions) - 1 ) ) echo " | "; ?> | |
| 625 | - <?php break; | |
| 626 | - case 'approve': ?> | |
| 627 | - <?php $approve_url = wp_nonce_url( admin_url( 'admin.php?page=wpforo-' . esc_attr(sanitize_text_field($varname)) . 's&id=' . intval($item[$primary_key]) . '&action='.( !$item['status'] ? 'un' : '' ).'approve' ), 'wpforo_admin_table_action_approve' ); ?> | |
| 628 | - <span class="vim-u"><a class="vim-u" title="<?php echo ( !$item['status'] ? __('unapprove this item', 'wpforo') : __('Approve this item', 'wpforo') ) ?>" href="<?php echo esc_url($approve_url); ?>"><?php echo ( !$item['status'] ? __('unapprove', 'wpforo') : __('approve', 'wpforo') ); ?></a></span> | |
| 629 | - <?php if( $act_key != ( count($actions) - 1 ) ) echo " | "; ?> | |
| 630 | - <?php break; | |
| 631 | - case 'user_delete': if($item['userid'] == $wpforo->current_userid) break; ?> | |
| 632 | - <?php $delete_url = wp_nonce_url( "users.php?action=delete&user=".intval($item[$primary_key]), 'bulk-users' ) ?> | |
| 633 | - <span class="trash"><a class="submitdelete" title="<?php _e('Delete this item', 'wpforo') ?>" onclick="return confirm('<?php _e('Are you sure you whant to DELETE this item?', 'wpforo') ?>');" href="<?php echo esc_url($delete_url); ?>"><?php _e('delete', 'wpforo'); ?></a></span> | |
| 634 | - <?php if( $act_key != ( count($actions) - 1 ) ) echo " | "; ?> | |
| 412 | + <span class="trash"><a class="submitdelete" title="<?php _e('Delete this item', 'wpforo') ?>" onclick="return confirm('<?php _e('Are you sure you whant to DELETE this item?', 'wpforo') ?>');" href="<?php echo esc_url($delete_url); ?>"><?php wpforo_phrase('delete'); ?></a></span> | |
| 635 | 413 | <?php break; |
| 636 | 414 | case 'view': ?> |
| 637 | 415 | <?php |
| 638 | - if( $varname == 'member' ){ | |
| 639 | - $fn_name = "get_profile_url"; | |
| 640 | - $item_id = $item['ID']; | |
| 641 | - }elseif($varname == 'moderation'){ | |
| 642 | - $fn_name = "get_view_url"; | |
| 643 | - $item_id = $item['postid']; | |
| 644 | - }else{ | |
| 645 | - $fn_name = "get_".$varname."_url"; | |
| 646 | - $item_id = $item[$varname.'id']; | |
| 647 | - } | |
| 416 | + if($varname != 'member'){ | |
| 417 | + $fn_name = "get_".$varname."_url"; | |
| 418 | + $item_id = $item[$varname.'id']; | |
| 419 | + }else{ | |
| 420 | + $fn_name = "get_profile_url"; | |
| 421 | + $item_id = $item['ID']; | |
| 422 | + } | |
| 648 | 423 | ?> |
| 649 | 424 | <span class="view"> |
| 650 | - <a href="<?php echo esc_url($wpforo->$varname->$fn_name($item_id)) ?>" target="_blank" title="<?php echo esc_attr( __('view', 'wpforo')); ?> “<?php echo esc_attr($varname) ?>”" rel="permalink"> | |
| 651 | - <?php _e('view', 'wpforo'); ?> | |
| 425 | + <a href="<?php echo esc_url($wpforo->$varname->$fn_name($item_id)) ?>" title="<?php echo esc_attr(wpforo_phrase('view', false)); ?> “<?php echo esc_attr($varname) ?>”" rel="permalink"> | |
| 426 | + <?php wpforo_phrase('view'); ?> | |
| 652 | 427 | </a> |
| 653 | 428 | </span> |
| 654 | - <?php if( $act_key != ( count($actions) - 1 ) ) echo " | "; ?> | |
| 655 | 429 | <?php break; |
| 656 | 430 | endswitch ?> |
| 431 | + <?php if( $act_key != ( count($actions) - 1 ) ) echo " | "; ?> | |
| 657 | 432 | <?php endforeach ?> |
| 658 | 433 | </div> |
| 659 | 434 | </td> |
| 660 | 435 | <?php else : ?> |
| @@ -661,20 +436,14 @@ | ||
| 661 | 436 | <td class="<?php echo esc_attr($item[$field]) ?> column-<?php echo esc_attr($item[$field]) ?>"> |
| 662 | 437 | <?php if($field == 'forumid') : ?> |
| 663 | 438 | <?php $data = $wpforo->forum->get_forum($item[$field]); echo esc_html($data['title']); ?> |
| 664 | 439 | <?php elseif($field == 'userid') : ?> |
| 665 | - <?php if(isset($item['name'])): ?> | |
| 666 | - <?php $data = wpforo_member($item); echo esc_html(wpforo_make_dname($data['display_name'], $data['user_nicename'])); ?> | |
| 667 | - <?php else: ?> | |
| 668 | - <?php $data = $wpforo->member->get_member($item[$field]); echo esc_html(wpforo_make_dname($data['display_name'], $data['user_nicename'])); ?> | |
| 669 | - <?php endif; ?> | |
| 440 | + <?php $data = $wpforo->member->get_member($item[$field]); echo esc_html($data['user_login']); ?> | |
| 670 | 441 | <?php elseif($field == 'groupid') : ?> |
| 671 | 442 | <?php $data = $wpforo->usergroup->get_usergroup($item[$field]); echo esc_html($data['name']); ?> |
| 672 | 443 | <?php elseif($field == 'rank') : ?> |
| 673 | 444 | <div class="author-rating"><div class="bar wpfw-<?php echo esc_attr($wpforo->member->rating_level($item['posts'])); ?> wpfbg-4"></div></div> |
| 674 | - <?php elseif($field == 'is_first_post') : ?> | |
| 675 | - <b><?php echo strtoupper( ( $item[$field] ? __('Topic', 'wpforo') : __('Post', 'wpforo') ) ) ?></b> | |
| 676 | - <?php else : ?> | |
| 445 | + <?php else : ?> | |
| 677 | 446 | <?php wpfo($item[$field], true, 'esc_html') ?> |
| 678 | 447 | <?php endif; ?> |
| 679 | 448 | </td> |
| 680 | 449 | |
| @@ -693,11 +462,13 @@ | ||
| 693 | 462 | <div class="tablenav bottom"> |
| 694 | 463 | <div class="alignleft actions"> |
| 695 | 464 | <select name="action2"> |
| 696 | 465 | <option value="-1" selected="selected"><?php _e('Bulk Actions', 'wpforo') ?></option> |
| 697 | - <?php foreach( $bulk_actions as $bulk_action ) : ?> | |
| 698 | - <option value="<?php echo $bulk_action ?>"><?php _e($bulk_action, 'wpforo'); ?></option> | |
| 699 | - <?php endforeach ?> | |
| 466 | + <?php if($varname == 'phrase') : ?> | |
| 467 | + <option value="edit"><?php _e('Edit', 'wpforo') ?></option> | |
| 468 | + <?php else : ?> | |
| 469 | + <option value="del"><?php _e('Delete', 'wpforo') ?></option> | |
| 470 | + <?php endif ?> | |
| 700 | 471 | </select> |
| 701 | 472 | <input type="button" onclick="wpforo_doaction()" id="doaction2" class="button action" value="Apply"> |
| 702 | 473 | </div> |
| 703 | 474 | <div class="alignleft actions"></div> |
| @@ -705,14 +476,14 @@ | ||
| 705 | 476 | <span class="pagination-links"> |
| 706 | 477 | <?php if( !isset($_GET['paged']) || $_GET['paged'] <= 2 ) : ?> |
| 707 | 478 | <span class="tablenav-pages-navspan">«</span> |
| 708 | 479 | <?php else : ?> |
| 709 | - <a class="first-page" title="Go to the first page" href="<?php echo esc_url(preg_replace('#(\&*paged\=[^\&]*)#is', '', wpforo_get_request_uri())); ?>">«</a> | |
| 480 | + <a class="first-page" title="Go to the first page" href="<?php echo esc_url(preg_replace('#(\&*paged\=[^\&]*)#is', '', wpforo_full_url())); ?>">«</a> | |
| 710 | 481 | <?php endif ?> |
| 711 | 482 | <?php if( !isset($_GET['paged']) || $_GET['paged'] <= 1 ) : ?> |
| 712 | 483 | <span class="tablenav-pages-navspan">‹</span> |
| 713 | 484 | <?php else : ?> |
| 714 | - <a class="prev-page" title="Go to the previous page" href="<?php echo esc_url(preg_replace('#(\&*paged\=[^\&]*)#is', '', wpforo_get_request_uri())); ?>&paged=<?php echo !isset($_GET['paged']) || $_GET['paged'] <= 1 ? 1 : intval($_GET['paged']) - 1 ?>">‹</a> | |
| 485 | + <a class="prev-page" title="Go to the previous page" href="<?php echo esc_url(preg_replace('#(\&*paged\=[^\&]*)#is', '', wpforo_full_url())); ?>&paged=<?php echo !isset($_GET['paged']) || $_GET['paged'] <= 1 ? 1 : intval($_GET['paged']) - 1 ?>">‹</a> | |
| 715 | 486 | <?php endif ?> |
| 716 | 487 | |
| 717 | 488 | <span class="paging-input"><input class="current-page" title="Current page" type="text" name="paged" value="<?php echo isset($_GET['paged']) ? intval($_GET['paged']) : 1 ?>" size="1"> of <span class="total-pages"><?php echo intval($pages_count) ?></span></span> |
| 718 | 489 | |
| @@ -718,14 +489,14 @@ | ||
| 718 | 489 | |
| 719 | 490 | <?php if( isset($_GET['paged']) && $_GET['paged'] >= $pages_count ) : ?> |
| 720 | 491 | <span class="tablenav-pages-navspan">›</span> |
| 721 | 492 | <?php else : ?> |
| 722 | - <a class="next-page" title="Go to the next page" href="<?php echo esc_url(preg_replace('#(\&*paged\=[^\&]*)#is', '', wpforo_get_request_uri())); ?>&paged=<?php echo (isset($_GET['paged']) ? ( $_GET['paged'] >= $pages_count ? intval($pages_count) : intval($_GET['paged']) + 1 ) : (!isset($_GET['paged']) ? 2 : intval($_GET['paged']) + 1)) ?>">›</a> | |
| 493 | + <a class="next-page" title="Go to the next page" href="<?php echo esc_url(preg_replace('#(\&*paged\=[^\&]*)#is', '', wpforo_full_url())); ?>&paged=<?php echo (isset($_GET['paged']) ? ( $_GET['paged'] >= $pages_count ? intval($pages_count) : intval($_GET['paged']) + 1 ) : (!isset($_GET['paged']) ? 2 : intval($_GET['paged']) + 1)) ?>">›</a> | |
| 723 | 494 | <?php endif ?> |
| 724 | 495 | <?php if( (isset($_GET['paged']) && $_GET['paged'] >= $pages_count - 1) || 1 >= $pages_count - 1 ) : ?> |
| 725 | 496 | <span class="tablenav-pages-navspan">»</span> |
| 726 | 497 | <?php else : ?> |
| 727 | - <a class="last-page" title="Go to the last page" href="<?php echo esc_url(preg_replace('#(\&*paged\=[^\&]*)#is', '', wpforo_get_request_uri())); ?>&paged=<?php echo intval($pages_count) ?>">»</a></span> | |
| 498 | + <a class="last-page" title="Go to the last page" href="<?php echo esc_url(preg_replace('#(\&*paged\=[^\&]*)#is', '', wpforo_full_url())); ?>&paged=<?php echo intval($pages_count) ?>">»</a></span> | |
| 728 | 499 | <?php endif ?> |
| 729 | 500 | </div> <br class="clear"> |
| 730 | 501 | </div> |
| 731 | 502 | </form> |
| @@ -797,10 +568,8 @@ | ||
| 797 | 568 | } |
| 798 | 569 | |
| 799 | 570 | |
| 800 | 571 | function wpforo_text( $text, $length, $echo = TRUE ){ |
| 801 | - $text = preg_replace('#(?:[^\'\"]|^)(https?://[^\s\'\"<>]+)(?:[^\'\"]|$)#isu', '', $text); | |
| 802 | - $text = preg_replace('#\[attach[^\[\]]*\][^\[\]]*\[/attach\]#isu', '', $text); | |
| 803 | 572 | $text = strip_tags($text); |
| 804 | 573 | if(function_exists('mb_substr')){ |
| 805 | 574 | if($echo){ |
| 806 | 575 | echo trim( mb_substr( $text, 0, $length, get_option('blog_charset') ) . ( ( function_exists('mb_strlen') ? mb_strlen( $text, get_option('blog_charset') ) : strlen($text) ) > $length ? '...' : '' ) ); |
| @@ -834,27 +603,8 @@ | ||
| 834 | 603 | echo '</h2>'; |
| 835 | 604 | } |
| 836 | 605 | } |
| 837 | 606 | |
| 838 | -function wpforo_admin_tools_tabs( $tabs, $current = 'antispam', $subtab = FALSE, $sub_current = 'antispam' ) { | |
| 839 | - if(!empty($tabs)){ | |
| 840 | - $class_attr = $subtab ? 'vert_tab' : ''; | |
| 841 | - echo '<h2 class="nav-tab-wrapper ' . esc_attr($class_attr) . '">'; | |
| 842 | - foreach( $tabs as $tab => $name ){ | |
| 843 | - $class = ( $tab == $current || ($subtab && $tab == $sub_current ) ) ? ' nav-tab-active' : ''; | |
| 844 | - $sub = $subtab ? '&subtab='.esc_attr($tab) : ''; | |
| 845 | - $class = esc_attr($class); | |
| 846 | - $class_attr = $class_attr; | |
| 847 | - $current = esc_attr($current); | |
| 848 | - $tab = esc_attr($tab); | |
| 849 | - $sub = esc_attr($sub); | |
| 850 | - $name = esc_html($name); | |
| 851 | - echo "<a class='nav-tab$class $class_attr' href='?page=wpforo-tools&tab=". ($subtab ? $current : $tab ) ."$sub' style='float:left'>$name</a>"; | |
| 852 | - } | |
| 853 | - echo '</h2>'; | |
| 854 | - } | |
| 855 | -} | |
| 856 | - | |
| 857 | 607 | function wpforo_content_filter( $content ){ |
| 858 | 608 | $content = apply_filters('wpforo_body_text_filter', $content); |
| 859 | 609 | $content = preg_replace('#([^\'\"]|^)(https?://[^\s\'\"<>]+\.(?:jpg|jpeg|png|gif|ico|svg|bmp|tiff))([^\'\"]|$)#isu', '$1 <a class="wpforo-auto-embeded-link" href="$2" target="_blank"><img class="wpforo-auto-embeded-image" src="$2"/></a> $3', $content); |
| 860 | 610 | $content = preg_replace('#([^\'\"]|^)(https?://[^\s\'\"<>]+)([^\'\"]|$)#isu', '$1 <a class="wpforo-auto-embeded-link" href="$2" target="_blank">$2</a> $3', $content); |
| @@ -865,31 +615,24 @@ | ||
| 865 | 615 | $content = str_replace($match[0], '<pre'.$match[1].'>'.$match[2].'</pre>', $content); |
| 866 | 616 | } |
| 867 | 617 | } |
| 868 | 618 | $content = preg_replace('#(<a[^<>]*>[^<>]*)<a[^<>]*class=[\'"]wpforo-auto-embeded-link[\'"][^<>]*href=[\'"]([^\'"]*)[\'"][^<>]*>[^<>]*</a>([^<>]*</a>)#isu', '$1$2$3', $content); |
| 869 | - $content = apply_filters('wpforo_content_filter', $content); | |
| 870 | 619 | return wpautop($content); |
| 871 | 620 | } |
| 872 | 621 | |
| 873 | -function wpforo_remove_links( $content ){ | |
| 874 | - return preg_replace('#([^\'\"]|^)(https?://[^\s\'\"<>]+)([^\'\"]|$)#isu', '$1 [' . wpforo_phrase('removed link', false) . '] $3', $content); | |
| 622 | +add_action('wp_ajax_wpf_admin_notice_ajax', 'wpf_admin_notice_ajax_hide'); | |
| 623 | +function wpf_admin_notice_ajax_hide(){ | |
| 624 | + global $wpforo; | |
| 625 | + $wpforo_noticies = $wpforo->notices; | |
| 626 | + $phrase = esc_html($_POST['phrase']); | |
| 627 | + if(($key = array_search($phrase, $wpforo_noticies)) !== false) { | |
| 628 | + unset($wpforo_noticies[$key]); | |
| 629 | + update_option( 'wpforo_notices', $wpforo_noticies ); | |
| 630 | + echo $phrase; | |
| 631 | + } | |
| 632 | + exit; | |
| 875 | 633 | } |
| 876 | 634 | |
| 877 | -add_filter('wpforo_content_filter', 'wpforo_nofollow_tag', 20); | |
| 878 | -function wpforo_nofollow_tag( $content ){ | |
| 879 | - $content = preg_replace_callback('|<a[^><]*href=[\'\"]+([^\'\"]+)[\'\"]+[^><]*>.+?</a>|is', 'wpforo_nofollow', $content); | |
| 880 | - return $content; | |
| 881 | -} | |
| 882 | -function wpforo_nofollow($match){ | |
| 883 | - $url = get_bloginfo('url'); | |
| 884 | - $parse = parse_url($url); | |
| 885 | - if( isset($match[0]) ) $link = $match[0]; | |
| 886 | - if( isset($match[1]) && strpos($match[1], $parse['host']) === FALSE ){ | |
| 887 | - $link = preg_replace('|(<a[^><]+)>|is', '$1 rel="nofollow">', $match[0]); | |
| 888 | - } | |
| 889 | - return $link; | |
| 890 | -} | |
| 891 | - | |
| 892 | 635 | add_action('wpforo_bottom_hook', 'wpforo_page_logging'); |
| 893 | 636 | function wpforo_page_logging(){ |
| 894 | 637 | global $wpforo; |
| 895 | 638 | $data = $wpforo->current_object; |
| @@ -906,9 +649,9 @@ | ||
| 906 | 649 | $sql = "INSERT INTO ". $wpforo->db->prefix ."wpforo_views( `userid` , `topicid` , `created` ) VALUES ( '".intval($current_user_id)."', " . intval($data['topicid']) . ", '" . esc_sql($current_time) . "' ) "; |
| 907 | 650 | $wpforo->db->query($sql); |
| 908 | 651 | $wpforo->db->query("UPDATE `".$wpforo->db->prefix."wpforo_topics` SET `views` = `views` + 1 WHERE `topicid` = " . intval($data['topicid'])); |
| 909 | 652 | }else{ |
| 910 | - $sql = "UPDATE ". $wpforo->db->prefix ."wpforo_views SET `created` = " . intval($current_time) . " WHERE `userid` = " . intval($current_user_id) . " AND `topicid` = " . intval($data['topicid']); | |
| 653 | + $sql = "UPDATE ". $wpforo->db->prefix ."wpforo_views SET `created` = '" . esc_sql($current_time) . "' WHERE `userid` = " . intval($current_user_id) . " AND `topicid` = " . intval($data['topicid']); | |
| 911 | 654 | $wpforo->db->query($sql); |
| 912 | 655 | if( $current_time - $view['created'] > 86400 ){ |
| 913 | 656 | $wpforo->db->query("UPDATE `".$wpforo->db->prefix."wpforo_topics` SET `views` = `views` + 1 WHERE `topicid` = " . intval($data['topicid'])); |
| 914 | 657 | } |
| @@ -982,19 +725,16 @@ | ||
| 982 | 725 | } |
| 983 | 726 | } |
| 984 | 727 | |
| 985 | 728 | function wpforo_human_filesize($bytes, $decimals = 2) { |
| 986 | - $size = array('B','KB','MB','GB','TB','PB','EB','ZB','YB'); | |
| 729 | + $size = array('B','kB','MB','GB','TB','PB','EB','ZB','YB'); | |
| 987 | 730 | $factor = floor((strlen($bytes) - 1) / 3); |
| 988 | 731 | return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . ' ' . @$size[$factor]; |
| 989 | 732 | } |
| 990 | 733 | |
| 991 | 734 | function wpforo_date($date, $type = 'ago', $echo = true ) { |
| 992 | - if(is_numeric($date)) $date = date_i18n( 'Y-m-d H:i:s', $date); | |
| 993 | - | |
| 994 | 735 | global $wpforo; |
| 995 | 736 | $d = $date; |
| 996 | - $sep = ' '; | |
| 997 | 737 | $timestamp = strtotime($date); |
| 998 | 738 | $timezone_string = get_option('timezone_string'); |
| 999 | 739 | $current_offset = get_option('gmt_offset'); |
| 1000 | 740 | if(!is_string($type)) $type = 'ago'; |
| @@ -1023,22 +763,16 @@ | ||
| 1023 | 763 | } |
| 1024 | 764 | |
| 1025 | 765 | if( class_exists('DateTime') && class_exists('DateTimeZone') && $timezone_string ){ |
| 1026 | 766 | $dt = new DateTime("now", new DateTimeZone($timezone_string)); |
| 1027 | - if( method_exists($dt, 'setTimestamp') ) $dt->setTimestamp($timestamp); //DateTime::setTimestamp() available in PHP 5.3 and higher versions | |
| 767 | + $dt->setTimestamp($timestamp); | |
| 1028 | 768 | if( $type == 'human' ){ |
| 1029 | 769 | $d = human_time_diff($timestamp); |
| 1030 | 770 | } |
| 1031 | 771 | elseif( $type == 'ago' ){ |
| 1032 | - $d = human_time_diff($timestamp) . ' '; | |
| 1033 | - $d = sprintf( wpforo_phrase('%s ago', false, false), $d ); | |
| 772 | + $d = human_time_diff($timestamp) . ' ' . wpforo_phrase('ago', false, false); | |
| 1034 | 773 | } |
| 1035 | 774 | else{ |
| 1036 | - if( wpforo_feature('wp-date-format', $wpforo) ){ | |
| 1037 | - $date_format = get_option('date_format'); | |
| 1038 | - $time_format = get_option('time_format'); | |
| 1039 | - $type = $date_format . $sep . $time_format; | |
| 1040 | - } | |
| 1041 | 775 | $d = date_i18n($type, strtotime($dt->format('Y-m-d H:i:s'))); |
| 1042 | 776 | } |
| 1043 | 777 | } |
| 1044 | 778 | else{ |
| @@ -1046,17 +780,11 @@ | ||
| 1046 | 780 | if( $type == 'human' ){ |
| 1047 | 781 | $d = human_time_diff($timestamp); |
| 1048 | 782 | } |
| 1049 | 783 | elseif( $type == 'ago' ){ |
| 1050 | - $d = human_time_diff($timestamp) . ' '; | |
| 1051 | - $d = sprintf( wpforo_phrase('%s ago', false, false), $d ); | |
| 784 | + $d = human_time_diff($timestamp) . ' ' . wpforo_phrase('ago', false, false); | |
| 1052 | 785 | } |
| 1053 | 786 | else{ |
| 1054 | - if( wpforo_feature('wp-date-format', $wpforo) ){ | |
| 1055 | - $date_format = get_option('date_format'); | |
| 1056 | - $time_format = get_option('time_format'); | |
| 1057 | - $type = $date_format . $sep . $time_format; | |
| 1058 | - } | |
| 1059 | 787 | $d = date_i18n( $type, $timestamp); |
| 1060 | 788 | } |
| 1061 | 789 | } |
| 1062 | 790 | |
| @@ -1067,8 +795,9 @@ | ||
| 1067 | 795 | return $d; |
| 1068 | 796 | } |
| 1069 | 797 | } |
| 1070 | 798 | |
| 799 | + | |
| 1071 | 800 | function wpforo_write_file( $new_file, $content ){ |
| 1072 | 801 | $return = array( 'error' => false, 'file' => '' ); |
| 1073 | 802 | $ifp = @fopen( $new_file, 'wb' ); |
| 1074 | 803 | if ( ! $ifp ) { |
| @@ -1095,15 +824,11 @@ | ||
| 1095 | 824 | if( !$fp ){ |
| 1096 | 825 | return false; |
| 1097 | 826 | } |
| 1098 | 827 | else{ |
| 1099 | - $size = @filesize($file); | |
| 1100 | - if( isset($size) && $size > 0 ){ | |
| 1101 | - $file_data = fread( $fp, $size ); | |
| 1102 | - fclose( $fp ); | |
| 1103 | - return $file_data; | |
| 1104 | - } | |
| 1105 | - return false; | |
| 828 | + $file_data = fread( $fp, filesize($file) ); | |
| 829 | + fclose( $fp ); | |
| 830 | + return $file_data; | |
| 1106 | 831 | } |
| 1107 | 832 | } |
| 1108 | 833 | |
| 1109 | 834 | ################################################################################ |
| @@ -1132,14 +857,11 @@ | ||
| 1132 | 857 | * @param string directory name |
| 1133 | 858 | * |
| 1134 | 859 | */ |
| 1135 | 860 | function wpforo_remove_directory( $directory ) { |
| 1136 | - $directory_ns = trim( $directory, '/') . '/'; | |
| 1137 | - $directory_ws = '/' . trim( $directory, '/') . '/'; | |
| 1138 | - $glob = glob( $directory_ns . '/*' ); | |
| 1139 | - if( empty($glob) ) $glob = glob( $directory_ws . '/*' ); | |
| 1140 | - foreach( $glob as $item ) { | |
| 1141 | - if( is_dir( $item ) ){ | |
| 861 | + $directory = trim( $directory, '/') . '/'; | |
| 862 | + foreach( glob( $directory . '/*' ) as $item ) { | |
| 863 | + if( is_dir( $item ) ){ | |
| 1142 | 864 | wpforo_remove_directory( $item ); |
| 1143 | 865 | } |
| 1144 | 866 | else{ |
| 1145 | 867 | unlink( $item ); |
| @@ -1146,9 +868,8 @@ | ||
| 1146 | 868 | } |
| 1147 | 869 | } |
| 1148 | 870 | return rmdir( $directory ); |
| 1149 | 871 | } |
| 1150 | - | |
| 1151 | 872 | ################################################################################# |
| 1152 | 873 | /** |
| 1153 | 874 | * Converts bytes to KB, MB, GB |
| 1154 | 875 | * |
| @@ -1205,16 +926,14 @@ | ||
| 1205 | 926 | } |
| 1206 | 927 | |
| 1207 | 928 | |
| 1208 | 929 | function wpforo_print_number($n, $echo = false) { |
| 1209 | - $x = str_replace(",","",$n); | |
| 1210 | - $x = intval($x); | |
| 1211 | - $n = 0 + $x; | |
| 930 | + $n = (0+str_replace(",","",$n)); | |
| 1212 | 931 | if(!is_numeric($n)) return false; |
| 1213 | - if($n>1000000000000) return round(($n/1000000000000),1).' '.str_replace('{number}', '', wpforo_phrase('{number}T',false)); | |
| 1214 | - else if($n>1000000000) return round(($n/1000000000),1).' '.str_replace('{number}', '', wpforo_phrase('{number}B',false)); | |
| 1215 | - else if($n>1000000) return round(($n/1000000),1).' '.str_replace('{number}', '', wpforo_phrase('{number}M',false)); | |
| 1216 | - else if($n>10000) return round(($n/1000),1).' '.str_replace('{number}', '', wpforo_phrase('{number}K',false)); | |
| 932 | + if($n>1000000000000) return round(($n/1000000000000),1).' '.wpforo_phrase('{number}T',false); | |
| 933 | + else if($n>1000000000) return round(($n/1000000000),1).' '.wpforo_phrase('{number}B',false); | |
| 934 | + else if($n>1000000) return round(($n/1000000),1).' '.wpforo_phrase('{number}M',false); | |
| 935 | + else if($n>10000) return round(($n/1000),1).' '.wpforo_phrase('{number}K',false); | |
| 1217 | 936 | if($echo){ |
| 1218 | 937 | echo number_format($n); |
| 1219 | 938 | } |
| 1220 | 939 | else{ |
| @@ -1222,11 +941,9 @@ | ||
| 1222 | 941 | } |
| 1223 | 942 | } |
| 1224 | 943 | |
| 1225 | 944 | function wpforo_bigintval($value) { |
| 1226 | - if(!is_array($value)) { | |
| 1227 | - $value = trim($value); | |
| 1228 | - } | |
| 945 | + $value = trim($value); | |
| 1229 | 946 | if (ctype_digit($value)) { |
| 1230 | 947 | return $value; |
| 1231 | 948 | } |
| 1232 | 949 | $value = preg_replace("/[^0-9](.*)$/", '', $value); |
| @@ -1288,308 +1005,8 @@ | ||
| 1288 | 1005 | 'strong' => array()); |
| 1289 | 1006 | } |
| 1290 | 1007 | else{ |
| 1291 | 1008 | $allowed_html = wp_kses_allowed_html( $key ); |
| 1292 | - if( $key == 'user_description' ){ | |
| 1293 | - $allowed_html['img'] = array( 'alt' => array(), 'align' => array(), 'border' => array(), 'height' => array(), 'hspace' => array(), 'longdesc' => array(), 'vspace' => array(), 'src' => array(), 'usemap' => array(), 'width' => array()); | |
| 1294 | - } | |
| 1295 | - else{ | |
| 1296 | - global $allowedposttags; | |
| 1297 | - $allowed_html = wpforo_parse_args($allowed_html, $allowedposttags); | |
| 1298 | - | |
| 1299 | - $allowed_html['a']['data-gallery'] = array(); | |
| 1300 | - $allowed_html['a']['download'] = array(); | |
| 1301 | - $allowed_html['iframe']['width'] = array(); | |
| 1302 | - $allowed_html['iframe']['height'] = array(); | |
| 1303 | - $allowed_html['iframe']['src'] = array(); | |
| 1304 | - $allowed_html['iframe']['frameborder'] = array(); | |
| 1305 | - $allowed_html['iframe']['allowfullscreen'] = array(); | |
| 1306 | - $allowed_html['embed']['flashVars'] = array(); | |
| 1307 | - $allowed_html['embed']['src'] = array(); | |
| 1308 | - $allowed_html['embed']['width'] = array(); | |
| 1309 | - $allowed_html['embed']['height'] = array(); | |
| 1310 | - $allowed_html['embed']['wmode'] = array(); | |
| 1311 | - $allowed_html['embed']['allowFullScreen'] = array(); | |
| 1312 | - $allowed_html['embed']['allowScriptAccess'] = array(); | |
| 1313 | - $allowed_html['embed']['name'] = array(); | |
| 1314 | - $allowed_html['embed']['pluginspage'] = array(); | |
| 1315 | - $allowed_html['embed']['type'] = array(); | |
| 1316 | - $allowed_html['blockquote']['class'] = TRUE; | |
| 1317 | - $allowed_html['blockquote']['data-width'] = TRUE; | |
| 1318 | - $allowed_html['p']['lang'] = TRUE; | |
| 1319 | - $allowed_html['p']['dir'] = TRUE; | |
| 1320 | - | |
| 1321 | - } | |
| 1322 | 1009 | } |
| 1323 | - | |
| 1324 | - | |
| 1325 | 1010 | return wp_kses( $string, $allowed_html ); |
| 1326 | 1011 | } |
| 1327 | - | |
| 1328 | -function wpforo_deep_merge($default, $current = array()){ | |
| 1329 | - foreach($default as $k => $v){ | |
| 1330 | - if(!empty($v) && is_array($v)){ | |
| 1331 | - foreach($v as $kk => $vv){ | |
| 1332 | - if(!empty($vv) && is_array($vv)){ | |
| 1333 | - foreach($vv as $kkk => $vvv){ | |
| 1334 | - if(!empty($vvv) && is_array($vvv)){ | |
| 1335 | - foreach($vvv as $kkkk => $vvvv){ | |
| 1336 | - if(!empty($vvv) && is_array($vvv)){ | |
| 1337 | - //Stop on 5th level | |
| 1338 | - } | |
| 1339 | - else{ | |
| 1340 | - if(isset($current[$k][$kk][$kkk][$kkkk])) $default[$k][$kk][$kkk][$kkkk] = $current[$k][$kk][$kkk][$kkkk]; | |
| 1341 | - } | |
| 1342 | - } | |
| 1343 | - } | |
| 1344 | - else{ | |
| 1345 | - if(isset($current[$k][$kk][$kkk])) $default[$k][$kk][$kkk] = $current[$k][$kk][$kkk]; | |
| 1346 | - } | |
| 1347 | - } | |
| 1348 | - } | |
| 1349 | - else{ | |
| 1350 | - if(isset($current[$k][$kk])) $default[$k][$kk] = $current[$k][$kk]; | |
| 1351 | - } | |
| 1352 | - } | |
| 1353 | - } | |
| 1354 | - else{ | |
| 1355 | - if(isset($current[$k])) $default[$k] = $current[$k]; | |
| 1356 | - } | |
| 1357 | - } | |
| 1358 | - return $default; | |
| 1359 | -} | |
| 1360 | - | |
| 1361 | - | |
| 1362 | -function wpforo_is_image($e){ | |
| 1363 | - $is_image = false; | |
| 1364 | - $e = strtolower($e); | |
| 1365 | - if( $e == 'jpg' || $e == 'jpeg' || $e == 'png' || $e == 'gif' ){ | |
| 1366 | - $is_image = true; | |
| 1367 | - } | |
| 1368 | - return $is_image; | |
| 1369 | -} | |
| 1370 | - | |
| 1371 | - | |
| 1372 | -function get_wpf_option( $key ){ | |
| 1373 | - global $wpdb; | |
| 1374 | - $value = get_option($key); | |
| 1375 | - if( $value ){ | |
| 1376 | - $value = maybe_unserialize( $value ); | |
| 1377 | - } | |
| 1378 | - else{ | |
| 1379 | - $value = $wpdb->get_var("SELECT `option_value` FROM `".$wpdb->prefix."options` WHERE `option_name` = '". esc_sql($key) . "'"); | |
| 1380 | - if(is_serialized( $value )) { | |
| 1381 | - $check = @unserialize($value); | |
| 1382 | - if( !$check ) $value = wpforo_fixSerializedArray($value); | |
| 1383 | - if( !$value && $value !== 0 ) return NULL; | |
| 1384 | - } | |
| 1385 | - } | |
| 1386 | - return $value; | |
| 1387 | -} | |
| 1388 | - | |
| 1389 | -/** | |
| 1390 | -* Extract what remains from an unintentionally truncated serialized string | |
| 1391 | -* $data contains your original array (or what remains of it). | |
| 1392 | -* @param string The serialized array | |
| 1393 | -*/ | |
| 1394 | -function wpforo_fixSerializedArray($serialized){ | |
| 1395 | - $tmp = preg_replace('/^a:\d+:\{/', '', $serialized); | |
| 1396 | - return wpforo_fixSerializedArray_R($tmp); | |
| 1397 | -} | |
| 1398 | -/** | |
| 1399 | -* The recursive function that does all of the heavy lifing. Do not call directly. | |
| 1400 | -* @param string The broken serialzized array | |
| 1401 | -* @return string Returns the repaired string | |
| 1402 | -*/ | |
| 1403 | -function wpforo_fixSerializedArray_R(&$broken){ | |
| 1404 | - $data = array(); | |
| 1405 | - $index = NULL; | |
| 1406 | - $len = strlen($broken); | |
| 1407 | - $i = 0; | |
| 1408 | - while(strlen($broken)) { | |
| 1409 | - $i++; | |
| 1410 | - if ($i > $len) { break; } | |
| 1411 | - if (substr($broken, 0, 1) == '}') { | |
| 1412 | - $broken = substr($broken, 1); return $data; | |
| 1413 | - } | |
| 1414 | - else{ | |
| 1415 | - $bite = substr($broken, 0, 2); | |
| 1416 | - switch($bite) { | |
| 1417 | - case 's:': | |
| 1418 | - $re = '/^s:\d+:"([^\"]*)";/'; | |
| 1419 | - if (preg_match($re, $broken, $m)){ | |
| 1420 | - if ($index === NULL){ $index = $m[1]; } | |
| 1421 | - else{$data[$index] = $m[1]; $index = NULL;} | |
| 1422 | - $broken = preg_replace($re, '', $broken); | |
| 1423 | - } | |
| 1424 | - break; | |
| 1425 | - case 'i:': | |
| 1426 | - $re = '/^i:(\d+);/'; | |
| 1427 | - if (preg_match($re, $broken, $m)){ | |
| 1428 | - if ($index === NULL){$index = (int) $m[1]; } | |
| 1429 | - else{$data[$index] = (int) $m[1]; $index = NULL; } | |
| 1430 | - $broken = preg_replace($re, '', $broken); | |
| 1431 | - } | |
| 1432 | - break; | |
| 1433 | - case 'b:': | |
| 1434 | - $re = '/^b:[01];/'; | |
| 1435 | - if (preg_match($re, $broken, $m)){ | |
| 1436 | - $data[$index] = (bool) $m[1]; $index = NULL; $broken = preg_replace($re, '', $broken); | |
| 1437 | - } | |
| 1438 | - break; | |
| 1439 | - case 'a:': | |
| 1440 | - $re = '/^a:\d+:\{/'; | |
| 1441 | - if (preg_match($re, $broken, $m)){ | |
| 1442 | - $broken = preg_replace('/^a:\d+:\{/', '', $broken); $data[$index] = wpforo_fixSerializedArray_R($broken); $index = NULL; | |
| 1443 | - } | |
| 1444 | - break; | |
| 1445 | - case 'N;': | |
| 1446 | - $broken = substr($broken, 2); $data[$index] = NULL; $index = NULL; | |
| 1447 | - break; | |
| 1448 | - } | |
| 1449 | - } | |
| 1450 | - } | |
| 1451 | - return $data; | |
| 1452 | -} | |
| 1453 | - | |
| 1454 | -function wpforo_insert_to_media_library( $attach_path, $title = '' ){ | |
| 1455 | - if( wpforo_feature('attach-media-lib') ){ | |
| 1456 | - if(!$attach_path ) return 0; | |
| 1457 | - $attach_fname = basename($attach_path); | |
| 1458 | - if(!$title) $title = $attach_fname; | |
| 1459 | - require_once(ABSPATH . 'wp-admin/includes/media.php'); | |
| 1460 | - require_once(ABSPATH . 'wp-admin/includes/file.php'); | |
| 1461 | - require_once(ABSPATH . 'wp-admin/includes/image.php'); | |
| 1462 | - $wp_upload_dir = wp_upload_dir(); | |
| 1463 | - $filetype = wp_check_filetype( $attach_fname, NULL ); | |
| 1464 | - $attachment = array( 'guid' => $attach_path, 'post_mime_type' => $filetype['type'], 'post_title' => $title, 'post_content' => '', 'post_status' => 'inherit'); | |
| 1465 | - $attach_id = wp_insert_attachment( $attachment, $attach_path ); | |
| 1466 | - add_filter( 'intermediate_image_sizes', 'wpforo_attachment_sizes' ); | |
| 1467 | - $attach_data = wp_generate_attachment_metadata( $attach_id, $attach_path ); | |
| 1468 | - wp_update_attachment_metadata( $attach_id, $attach_data ); | |
| 1469 | - remove_filter( 'intermediate_image_sizes', 'wpforo_attachment_sizes' ); | |
| 1470 | - return $attach_id; | |
| 1471 | - } | |
| 1472 | -} | |
| 1473 | - | |
| 1474 | -function wpforo_attachment_sizes( $sizes ){ | |
| 1475 | - return array('thumbnail'); | |
| 1476 | -} | |
| 1477 | - | |
| 1478 | -function wpforo_debug( $wpforo ){ | |
| 1479 | - if( wpforo_feature('debug-mode', $wpforo) ) : ?> | |
| 1480 | - <div id="wpforo-debug" style="display:none"> | |
| 1481 | - <h4>Current Object</h4> | |
| 1482 | - <p><?php @print_r($wpforo->current_object); ?></p> | |
| 1483 | - <h4>Super Globals</h4> | |
| 1484 | - <p>Requests: <?php print_r($_REQUEST); ?></p> | |
| 1485 | - <p>Server: <?php print_r($_REQUEST); ?></p> | |
| 1486 | - <h4>Options and Features</h4> | |
| 1487 | - <textarea style="width:500px; height:300px;"><?php echo @ 'permastruct: ' . $wpforo->permastruct . "\r\n"; | |
| 1488 | - echo @ 'use_home_url: ' . $wpforo->use_home_url . "\r\n"; | |
| 1489 | - echo @ 'url: ' . wpforo_home_url() . "\r\n"; | |
| 1490 | - @print_r($wpforo->general_options) . "\r\n"; | |
| 1491 | - echo @ 'pageid:' . $wpforo->pageid . "\r\n"; | |
| 1492 | - echo @ 'default_groupid: ' . $wpforo->default_groupid . "\r\n"; | |
| 1493 | - @print_r($wpforo->usergroup_cans) . "\r\n"; | |
| 1494 | - @print_r($wpforo->forum_options) . "\r\n"; | |
| 1495 | - @print_r($wpforo->forum_cans) . "\r\n"; | |
| 1496 | - @print_r($wpforo->post_options) . "\r\n"; | |
| 1497 | - @print_r($wpforo->member_options) . "\r\n"; | |
| 1498 | - @print_r($wpforo->subscribe_options) . "\r\n"; | |
| 1499 | - @print_r($wpforo->features) . "\r\n"; | |
| 1500 | - @print_r($wpforo->style_options) . "\r\n"; | |
| 1501 | - @print_r($wpforo->theme_options) . "\r\n"; | |
| 1502 | - @print_r($wpforo->theme) . "\r\n"; | |
| 1503 | - ?> | |
| 1504 | - </textarea> | |
| 1505 | - </div> | |
| 1506 | - <?php | |
| 1507 | - endif; | |
| 1508 | -} | |
| 1509 | - | |
| 1510 | -function wpforo_hook( $name, $args = array() ){ | |
| 1511 | - do_action( $name, $args ); | |
| 1512 | -} | |
| 1513 | - | |
| 1514 | -################################################################################# | |
| 1515 | -/** | |
| 1516 | - * Cleans forum cache | |
| 1517 | - * | |
| 1518 | - * @since 1.2.1 | |
| 1519 | - * | |
| 1520 | - * @param integer Item ID (e.g.: $topicid or $postid) | (!) ID is 0 on dome actions (e.g.: delete actions) | |
| 1521 | - * @param string Item View / Template (e.g.: 'forum', 'topic', 'post', 'user', 'widget', etc...) | |
| 1522 | - * | |
| 1523 | - * @return NULL | |
| 1524 | - */ | |
| 1525 | -function wpforo_clean_cache( $id = 0, $template = 'all' ){ | |
| 1526 | - global $wpforo; | |
| 1527 | - $pageid = url_to_postid( $_SERVER['REQUEST_URI'] ); | |
| 1528 | - do_action( 'wpforo_clean_cache_start', $id, $template ); | |
| 1529 | - if( $pageid ){ | |
| 1530 | - $page = get_post( $pageid ); | |
| 1531 | - clean_post_cache( $page ); | |
| 1532 | - } | |
| 1533 | - $wpforo->statistic('update'); | |
| 1534 | - do_action( 'wpforo_clean_cache', $id, $template ); | |
| 1535 | - $wpforo->cache->clean( $id, $template ); | |
| 1536 | - do_action( 'wpforo_clean_cache_end', $id, $template ); | |
| 1537 | -} | |
| 1538 | - | |
| 1539 | -function wpforo_db_check( $args = array() ){ | |
| 1540 | - global $wpdb; | |
| 1541 | - $check = trim($args['check']); | |
| 1542 | - $col = esc_sql(trim($args['col'])); | |
| 1543 | - $table = esc_sql(trim($args['table'])); | |
| 1544 | - | |
| 1545 | - if( $check == 'table_exists' ){ | |
| 1546 | - return $wpdb->get_var("SHOW TABLES LIKE '" . $table . "';"); | |
| 1547 | - } | |
| 1548 | - | |
| 1549 | - if( $check == 'col_exists' ){ | |
| 1550 | - return $wpdb->get_var("SHOW COLUMNS FROM `" . $table . "` LIKE '" . $col . "';"); | |
| 1551 | - } | |
| 1552 | - | |
| 1553 | - if( $check == 'key_exists' ){ | |
| 1554 | - $col = $wpdb->get_row("SHOW COLUMNS FROM `" . $table . "` LIKE '" . $col . "';", ARRAY_A); | |
| 1555 | - return $col['Key']; | |
| 1556 | - } | |
| 1557 | - | |
| 1558 | - if( $check == 'default_value' ){ | |
| 1559 | - $col = $wpdb->get_row("SHOW COLUMNS FROM `" . $table . "` LIKE '" . $col . "';", ARRAY_A); | |
| 1560 | - return $col['Default']; | |
| 1561 | - } | |
| 1562 | - | |
| 1563 | - if( $check == 'col_type' ){ | |
| 1564 | - $col = $wpdb->get_row("SHOW COLUMNS FROM `" . $table . "` LIKE '" . $col . "';", ARRAY_A); | |
| 1565 | - return $col['Type']; | |
| 1566 | - } | |
| 1567 | -} | |
| 1568 | - | |
| 1569 | -function wpforo_is_owner( $userid ){ | |
| 1570 | - global $wpforo; | |
| 1571 | - if( !empty($wpforo) ){ | |
| 1572 | - if( isset($wpforo->current_userid) && $wpforo->current_userid ){ | |
| 1573 | - if( $userid == $wpforo->current_userid ) return true; | |
| 1574 | - } | |
| 1575 | - } | |
| 1576 | - return false; | |
| 1577 | -} | |
| 1578 | - | |
| 1579 | -function wpforo_make_dname($display_name, $user_nicename){ | |
| 1580 | - $display_name = trim($display_name); | |
| 1581 | - $user_nicename = trim($user_nicename); | |
| 1582 | - return ( $display_name ? esc_html($display_name) : esc_html(urldecode($user_nicename)) ); | |
| 1583 | -} | |
| 1584 | - | |
| 1585 | -function wpfor_strlen( $string ){ | |
| 1586 | - if(!$string) return 0; | |
| 1587 | - if(function_exists('mb_strlen')){ | |
| 1588 | - return mb_strlen($string); | |
| 1589 | - } | |
| 1590 | - else{ | |
| 1591 | - return strlen($string); | |
| 1592 | - } | |
| 1593 | -} | |
| 1594 | - | |
| 1595 | 1012 | ?> |