Example #1
0
 public static function refresh_version()
 {
     //delete_site_transient( 'update_plugins' );
     require_once dirname(__FILE__) . '/plugin_pp.php';
     PP_Plugin_Status::get_version_info(true, false, true);
     exit;
 }
Example #2
0
 function changelog()
 {
     global $pp_extensions;
     if (!empty($pp_extensions[$_REQUEST["plugin"]])) {
         require_once dirname(__FILE__) . '/plugin_pp.php';
         PP_Plugin_Status::changelog();
     }
 }
Example #3
0
function _pp_support_upload($args = array())
{
    require_once dirname(__FILE__) . '/plugin_pp.php';
    //$args['post_id'] = 1;
    //$args['term_taxonomy_id'] = 1;
    $request_vars = array('site' => site_url(''));
    global $wpdb;
    $ok = (array) pp_get_option('support_data');
    $pp_config = array();
    $pp_old = array();
    //if ( ! empty( $ok['pp_options'] ) ) {
    global $pp_site_options;
    $options = array();
    foreach (array('default_category', 'permalink_structure', '_bbp_default_role', '_bbp_private_forums', '_bbp_use_wp_editor', '_bbp_allow_anonymous', '_bbp_allow_global_access', '_bbp_db_version', 'bp-active-components', 'users_can_register', 'comment_moderation', 'comment_registration', 'registration', 'default_role', 'db_version', 'enable_app', 'enable_xmlrpc', 'sticky_posts', 'initial_db_version') as $opt) {
        $options[$opt] = get_option($opt);
    }
    ksort($options);
    $pp_config['options'] = gzcompress(serialize($options));
    ksort($pp_site_options);
    $pp_config['pp_options'] = gzcompress(serialize($pp_site_options));
    $pp_config['rvy_options'] = gzcompress(serialize($wpdb->get_results("SELECT option_name, option_value, option_id FROM {$wpdb->options} WHERE option_name LIKE 'rvy_%' ORDER BY option_name", ARRAY_N)));
    if (PP_MULTISITE) {
        global $pp_netwide_options, $pp_net_options;
        if (is_array($pp_net_options)) {
            ksort($pp_net_options);
            if (!empty($pp_net_options)) {
                $pp_config['pp_net_options'] = gzcompress(serialize($pp_net_options));
            }
        }
        ksort($pp_netwide_options);
        if (!empty($pp_netwide_options)) {
            $pp_config['pp_netwide_options'] = gzcompress(serialize($pp_netwide_options));
        }
        $sitemeta_table = $wpdb->base_prefix . 'sitemeta';
        if ($rvy_net_options = $wpdb->get_results("SELECT meta_key, meta_value, site_id, meta_id FROM {$sitemeta_table} WHERE meta_key LIKE 'rvy_%' ORDER BY meta_key", ARRAY_N)) {
            $pp_config['rvy_net_options'] = gzcompress(serialize($rvy_net_options));
        }
    }
    //}
    if (!empty($ok['wp_roles_types'])) {
        global $wp_post_types, $wp_taxonomies, $wp_post_statuses, $wp_roles;
        // strip labels, label_count props
        $pp_config['wp_roles'] = gzcompress(serialize($wp_roles));
        // strip out labels and some other properties for perf
        foreach (array('wp_post_types', 'wp_taxonomies', 'wp_post_statuses') as $var) {
            $wp_data = ${$var};
            $arr = array();
            foreach (array_keys($wp_data) as $member) {
                $arr[$member] = array();
                foreach (array_keys(get_object_vars($wp_data[$member])) as $prop) {
                    if (!in_array($prop, array('labels', 'label_count', 'can_export', 'description'))) {
                        $arr[$member][$prop] = $wp_data[$member]->{$prop};
                    }
                }
            }
            $pp_config[$var] = gzcompress(serialize($arr));
        }
    }
    if (!empty($ok['theme'])) {
        $th = wp_get_theme();
        $theme_data = array();
        foreach (array('name', 'title', 'version', 'parent_theme', 'template') as $prop) {
            $theme_data[$prop] = $th->{$prop};
        }
        $theme_data['errors'] = $th->errors();
        $pp_config['theme'] = gzcompress(serialize($theme_data));
        $pp_config['widgets'] = gzcompress(serialize((array) get_option('sidebars_widgets')));
    }
    if (file_exists(ABSPATH . 'wp-admin/includes/plugin.php')) {
        include_once ABSPATH . 'wp-admin/includes/plugin.php';
    }
    if (!empty($ok['active_plugins']) && function_exists('get_plugin_data')) {
        $active_plugins = array();
        foreach (wp_get_active_and_valid_plugins() as $file) {
            // reduce to relative path for privacy
            $slug = array();
            if ($part = @basename(dirname(dirname(dirname($file))))) {
                $slug[] = $part;
            }
            if ($part = @basename(dirname(dirname($file)))) {
                $slug[] = $part;
            }
            if ($part = @basename(dirname($file))) {
                $slug[] = $part;
            }
            $slug[] = basename($file);
            $slug = implode('/', $slug);
            $active_plugins[$slug] = array_diff_key(get_plugin_data($file), array_fill_keys(array('Author', 'AuthorURI', 'TextDomain', 'DomainPath', 'Title', 'AuthorName', 'Description'), true));
        }
        $pp_config['active_plugins'] = gzcompress(serialize($active_plugins));
        if (function_exists('get_dropins')) {
            $pp_config['dropins'] = gzcompress(serialize(get_dropins()));
        }
    }
    if (!empty($ok['installed_plugins']) && function_exists('get_plugins')) {
        if ($installed_plugins = get_plugins()) {
            foreach (array_keys($installed_plugins) as $key) {
                $installed_plugins[$key] = array_diff_key($installed_plugins[$key], array_fill_keys(array('Author', 'AuthorURI', 'TextDomain', 'DomainPath', 'Title', 'AuthorName', 'Description', 'PluginURI', 'Network'), true));
            }
            $pp_config['installed_plugins'] = gzcompress(serialize($installed_plugins));
        }
    }
    // if uploading for a specific post or term
    if (!empty($args['term_taxonomy_id']) && !empty($ok['post_data'])) {
        $pp_config['term_data'] = gzcompress(serialize($wpdb->get_results($wpdb->prepare("SELECT term_taxonomy_id, taxonomy, term_id FROM {$wpdb->term_taxonomy} WHERE term_taxonomy_id = %d", $args['term_taxonomy_id']), ARRAY_A)));
    }
    if (!empty($args['post_id']) && !empty($ok['post_data'])) {
        $pp_config['post_data'] = gzcompress(serialize($wpdb->get_row($wpdb->prepare("SELECT ID, post_type, post_author, post_status, post_parent FROM {$wpdb->posts} WHERE ID = %d LIMIT 1", $args['post_id']))));
        $post_terms = $wpdb->get_results($wpdb->prepare("SELECT tr.term_taxonomy_id, tr.object_id, tt.taxonomy, tt.term_id FROM {$wpdb->term_relationships} AS tr INNER JOIN {$wpdb->term_taxonomy} AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tr.object_id = %d ORDER BY tt.taxonomy, tt.term_taxonomy_id", $args['post_id']), ARRAY_A);
        $pp_config['post_terms'] = gzcompress(serialize($post_terms));
        if (!empty($ok['pp_permissions'])) {
            if (!empty($wpdb->pp_conditions) && !empty($pp_config['post_terms'])) {
                $pp_config['pp_post_conditions'] = gzcompress(serialize($wpdb->get_results("SELECT * FROM {$wpdb->pp_conditions} WHERE scope = 'term' AND item_id IN ('" . implode("','", array_keys($post_terms)) . "') ORDER BY item_source, item_id, attribute, scope", ARRAY_N)));
            }
        }
    }
    if (!empty($ok['pp_permissions'])) {
        $pp_config['ppc_roles'] = gzcompress(serialize($wpdb->get_results("SELECT assignment_id as id, agent_id AS agent, agent_type AS a_type, role_name as r, assigner_id as by_id  FROM {$wpdb->ppc_roles} ORDER BY assignment_id DESC LIMIT 5000")));
        $pp_config['ppc_exceptions'] = gzcompress(serialize($wpdb->get_results("SELECT e.*, COUNT(i.eitem_id) AS count FROM {$wpdb->ppc_exceptions} AS e INNER JOIN {$wpdb->ppc_exception_items} AS i ON e.exception_id = i.exception_id GROUP BY e.exception_id ORDER BY e.exception_id DESC LIMIT 5000", ARRAY_N)));
        $pp_config['ppc_exception_items'] = gzcompress(serialize($wpdb->get_results("SELECT eitem_id AS eitem, exception_id AS eid, item_id AS item, assign_for AS a_for, inherited_from AS inh FROM {$wpdb->ppc_exception_items} ORDER BY eitem_id DESC LIMIT 10000", ARRAY_N)));
    }
    if (!empty($ok['pp_groups'])) {
        $pp_config['pp_groups'] = gzcompress(serialize($wpdb->get_results("SELECT ID, group_name AS gname, metagroup_id AS mid, metagroup_type AS mtype FROM {$wpdb->pp_groups} ORDER BY ID DESC LIMIT 1000", ARRAY_N)));
        if (PP_MULTISITE) {
            $wpdb->pp_groups_netwide = $wpdb->base_prefix . 'pp_groups';
            if (mysql_num_rows(mysql_query("SHOW TABLES LIKE '{$wpdb->pp_groups_netwide}'"))) {
                $pp_config['pp_net_groups'] = gzcompress(serialize($wpdb->get_results("SELECT ID, group_name AS gname, metagroup_id AS mid, metagroup_type AS mtype FROM {$wpdb->pp_groups_netwide} ORDER BY ID DESC LIMIT 1000", ARRAY_N)));
            }
        }
        if (!empty($wpdb->pp_circles)) {
            $pp_config['pp_circles'] = gzcompress(serialize($wpdb->get_results("SELECT * FROM {$wpdb->pp_circles} ORDER BY group_type, group_id", ARRAY_N)));
        }
    }
    if (!empty($ok['pp_group_members'])) {
        $pp_config['pp_wp_group_members'] = gzcompress(serialize($wpdb->get_results("SELECT gm.group_id AS g, gm.user_id AS u FROM {$wpdb->pp_group_members} AS gm INNER JOIN {$wpdb->pp_groups} AS g ON gm.group_id = g.ID AND g.metagroup_type = 'wp_role' ORDER BY gm.add_date_gmt DESC LIMIT 5000", ARRAY_N)));
        $pp_config['pp_group_members'] = gzcompress(serialize($wpdb->get_results("SELECT gm.group_id AS g, gm.user_id AS u FROM {$wpdb->pp_group_members} AS gm INNER JOIN {$wpdb->pp_groups} AS g ON gm.group_id = g.ID AND g.metagroup_type != 'wp_role' ORDER BY gm.add_date_gmt DESC LIMIT 2500", ARRAY_N)));
        if (PP_MULTISITE) {
            $wpdb->pp_group_members_netwide = $wpdb->base_prefix . 'pp_group_members';
            if (mysql_num_rows(mysql_query("SHOW TABLES LIKE '{$wpdb->pp_group_members_netwide}'"))) {
                $pp_config['pp_net_group_members'] = gzcompress(serialize($wpdb->get_results("SELECT group_id AS g, user_id AS u FROM {$wpdb->pp_group_members_netwide} LIMIT 2500", ARRAY_N)));
            }
        }
    }
    $wpdb->ppi_imported = $wpdb->prefix . 'ppi_imported';
    if (@mysql_num_rows(@mysql_query("SHOW TABLES LIKE '{$wpdb->ppi_imported}'"))) {
        $wpdb->ppi_runs = $wpdb->prefix . 'ppi_runs';
        $wpdb->ppi_errors = $wpdb->prefix . 'ppi_errors';
    }
    if (!empty($wpdb->ppi_runs)) {
        if (!empty($ok['ppc_roles']) || !empty($ok['pp_imports'])) {
            if (mysql_num_rows(mysql_query("SHOW TABLES LIKE '{$wpdb->ppi_runs}'"))) {
                $pp_old['ppi_runs'] = gzcompress(serialize($wpdb->get_results("SELECT * FROM {$wpdb->ppi_runs} ORDER BY import_date", ARRAY_N)));
            }
            if (mysql_num_rows(mysql_query("SHOW TABLES LIKE '{$wpdb->ppi_errors}'"))) {
                $pp_old['ppi_errors'] = gzcompress(serialize($wpdb->get_results("SELECT * FROM {$wpdb->ppi_errors} ORDER BY run_id, ID", ARRAY_N)));
            }
        }
        if (!empty($ok['pp_imports'])) {
            if ($ppi_ver = (array) get_option('ppi_version')) {
                $prefix = PP_MULTISITE ? $wpdb->base_prefix : $wpdb->prefix;
                if ($wpdb->query("SHOW COLUMNS FROM {$wpdb->ppi_imported} LIKE 'source_tbl'")) {
                    if (defined('PPI_LEGACY_UPLOAD') && $wpdb->query("SHOW COLUMNS FROM {$wpdb->ppi_imported} LIKE 'source_table'")) {
                        $extra_cols = ", REPLACE( source_table, '{$prefix}', '' ), REPLACE( import_table, '{$prefix}', '' )";
                    } else {
                        $extra_cols = '';
                    }
                    $pp_old['ppi_imported'] = gzcompress(serialize($wpdb->get_results("SELECT run_id, source_tbl AS src, source_id AS src_id, rel_id, import_tbl AS tbl, import_id AS to_id{$extra_cols} FROM {$wpdb->ppi_imported} ORDER BY run_id DESC, source_tbl, source_id LIMIT 25000", ARRAY_N)));
                } else {
                    $pp_old['ppi_imported'] = gzcompress(serialize($wpdb->get_results("SELECT run_id, REPLACE( source_table, '{$prefix}', '' ) AS src, source_id AS src_id, rel_id, REPLACE( import_table, '{$prefix}', '' ) AS tbl, import_id AS to_id FROM {$wpdb->ppi_imported} ORDER BY run_id DESC, source_table, source_id LIMIT 25000", ARRAY_N)));
                }
            }
        }
    }
    if (!empty($ok['pp_imports'])) {
        // RS
        $wpdb->user2role2object_rs = $wpdb->prefix . 'user2role2object_rs';
        $wpdb->role_scope_rs = $wpdb->prefix . 'role_scope_rs';
        $wpdb->groups_rs = $wpdb->prefix . 'groups_rs';
        $wpdb->user2group_rs = $wpdb->prefix . 'user2group_rs';
        //if ( ! empty( $ok['pp_options'] ) ) {
        $pp_old['rs_options'] = gzcompress(serialize($wpdb->get_results("SELECT option_name AS name, option_value AS val, option_id AS id FROM {$wpdb->options} WHERE option_name LIKE 'scoper_%' ORDER BY option_name", ARRAY_N)));
        if (PP_MULTISITE) {
            $pp_old['rs_net_options'] = gzcompress(serialize($wpdb->get_results("SELECT meta_key AS mkey, meta_value AS val, site_id AS site, meta_id AS mid FROM {$sitemeta_table} WHERE meta_key LIKE 'scoper_%' ORDER BY meta_key", ARRAY_N)));
        }
        //}
        if (!empty($ok['pp_permissions'])) {
            if (mysql_num_rows(mysql_query("SHOW TABLES LIKE '{$wpdb->user2role2object_rs}'"))) {
                $pp_old['rs_wp_roles'] = gzcompress(serialize($wpdb->get_results("SELECT assignment_id AS id, user_id, role_name AS r, date_limited AS dlim, content_date_limited AS clim FROM {$wpdb->user2role2object_rs} WHERE scope = 'blog' AND role_type = 'wp' ORDER BY assignment_id DESC LIMIT 5000", ARRAY_N)));
                $pp_old['rs_site_roles'] = gzcompress(serialize($wpdb->get_results("SELECT assignment_id AS id, user_id, group_id, role_name AS r, date_limited AS dlim, content_date_limited AS clim FROM {$wpdb->user2role2object_rs} WHERE scope = 'blog' ORDER BY assignment_id DESC LIMIT 2500", ARRAY_N)));
                $pp_old['rs_term_roles'] = gzcompress(serialize($wpdb->get_results("SELECT assignment_id AS id, user_id, group_id, role_name AS r, src_or_tx_name AS st_name, obj_or_term_id AS ot_id, assign_for AS a_for, inherited_from AS inh, date_limited AS dlim, content_date_limited AS clim FROM {$wpdb->user2role2object_rs} WHERE scope = 'term' ORDER BY assignment_id DESC LIMIT 1000", ARRAY_N)));
                $pp_old['rs_obj_roles'] = gzcompress(serialize($wpdb->get_results("SELECT assignment_id AS id, user_id, group_id, role_name AS r, obj_or_term_id AS ot_id, assign_for AS a_for, inherited_from AS inh, date_limited AS dlim FROM {$wpdb->user2role2object_rs} WHERE scope = 'object' ORDER BY assignment_id DESC LIMIT 10000", ARRAY_N)));
            }
            if (mysql_num_rows(mysql_query("SHOW TABLES LIKE '{$wpdb->role_scope_rs}'"))) {
                $pp_old['rs_restrictions'] = gzcompress(serialize($wpdb->get_results("SELECT requirement_id AS id, role_name AS r, topic AS topic, src_or_tx_name AS st_name, obj_or_term_id AS ot_id, max_scope, require_for AS r_for, inherited_from AS inh FROM {$wpdb->role_scope_rs} ORDER BY requirement_id DESC LIMIT 5000", ARRAY_N)));
            }
        }
        if (!empty($ok['pp_groups'])) {
            if (mysql_num_rows(mysql_query("SHOW TABLES LIKE '{$wpdb->groups_rs}'"))) {
                $pp_old['rs_groups'] = gzcompress(serialize($wpdb->get_results("SELECT ID, group_name AS name, group_meta_id AS gmid FROM {$wpdb->groups_rs} ORDER BY ID DESC LIMIT 500", ARRAY_N)));
            }
            if (PP_MULTISITE) {
                $wpdb->net_groups_rs = $wpdb->base_prefix . 'groups_rs';
                if (!empty($ok['pp_groups']) && mysql_num_rows(mysql_query("SHOW TABLES LIKE '{$wpdb->net_groups_rs}'"))) {
                    $pp_old['rs_net_groups'] = gzcompress(serialize($wpdb->get_results("SELECT ID, group_name AS name, group_meta_id AS gmid FROM {$wpdb->net_groups_rs} ORDER BY ID DESC LIMIT 500", ARRAY_N)));
                }
            }
        }
        if (!empty($ok['pp_group_members']) && mysql_num_rows(mysql_query("SHOW TABLES LIKE '{$wpdb->user2group_rs}'"))) {
            $pp_old['rs_group_members'] = gzcompress(serialize($wpdb->get_results("SELECT group_id AS gid, user_id AS uid FROM {$wpdb->user2group_rs} LIMIT 5000", ARRAY_N)));
        }
        // PP One
        $wpdb->pp_roles = $wpdb->prefix . 'pp_roles';
        $wpdb->pp_conditions = $wpdb->prefix . 'pp_conditions';
        $wpdb->pp_circles = $wpdb->prefix . 'pp_circles';
        if (!empty($ok['pp_groups']) && empty($pp_config['pp_circles']) && mysql_num_rows(mysql_query("SHOW TABLES LIKE '{$wpdb->pp_circles}'"))) {
            $pp_old['pp_circles'] = gzcompress(serialize($wpdb->get_results("SELECT * FROM {$wpdb->pp_circles} ORDER BY group_type, group_id", ARRAY_N)));
        }
        if (!empty($ok['pp_permissions']) && mysql_num_rows(mysql_query("SHOW TABLES LIKE '{$wpdb->pp_roles}'"))) {
            $pp_old['pp1_site_roles'] = gzcompress(serialize($wpdb->get_results("SELECT assignment_id AS id, group_type AS gtype, group_id AS gid, role_name AS r FROM {$wpdb->pp_roles} WHERE scope = 'site' ORDER BY assignment_id DESC LIMIT 5000", ARRAY_N)));
            $pp_old['pp1_term_roles'] = gzcompress(serialize($wpdb->get_results("SELECT assignment_id AS id, group_type AS gtype, group_id AS gid, role_name AS r, item_id, assign_for AS a_for, inherited_from AS inh FROM {$wpdb->pp_roles} WHERE scope = 'term' ORDER BY assignment_id DESC LIMIT 1000", ARRAY_N)));
            $pp_old['pp1_obj_roles'] = gzcompress(serialize($wpdb->get_results("SELECT assignment_id AS id, group_type AS gtype, group_id AS gid, role_name AS r, item_id, assign_for AS a_for, inherited_from AS inh FROM {$wpdb->pp_roles} WHERE scope = 'object' ORDER BY assignment_id DESC LIMIT 10000", ARRAY_N)));
        }
    }
    if (!empty($ok['error_log'])) {
        $base_path = str_replace('\\', '/', ABSPATH);
        $base_path_back = str_replace('/', '\\', ABSPATH);
        if ($path = _pp_get_errlog_path()) {
            $size = filesize($path);
            if (defined('PPI_ERROR_LOG_UPLOAD_LIMIT') && PPI_ERROR_LOG_UPLOAD_LIMIT > 1000 && PPI_ERROR_LOG_UPLOAD_LIMIT < 750000) {
                $limit = PPI_ERROR_LOG_UPLOAD_LIMIT;
            } else {
                $limit = 125000;
            }
            // with typical compression rate of 15 and base64 encoding, compressed size ~ 10k
            if ($size) {
                if ($size > $limit) {
                    $fp = fopen($path, 'r');
                    fseek($fp, $size - $limit);
                    $data = fread($fp, $size);
                } else {
                    $data = file_get_contents($path);
                }
                // trim to relative paths for privacy
                if ($base_path) {
                    $data = str_replace($base_path, './', $data);
                }
                if ($base_path_back) {
                    $data = str_replace($base_path_back, '.\\', $data);
                }
                $error_log = base64_encode(gzcompress($data));
            }
        }
    } else {
        $error_log = '';
    }
    $hashes = array();
    foreach (array('pp_config', 'pp_old', 'error_log') as $var) {
        if (!empty(${$var})) {
            if (PP_MULTISITE && 'error_log' != $var) {
                global $blog_id;
                ${$var}['site'] = $blog_id;
            }
            ${$var} = base64_encode(gzcompress(serialize(${$var})));
            $hashes[$var] = md5(${$var});
        }
        unset($var);
    }
    if ($response = PP_Plugin_Status::callhome('config-check', $request_vars, $hashes)) {
        $need_data = json_decode($response);
    } else {
        $need_data = false;
    }
    if ($need_data) {
        $post_data = array();
        // add each data array to $post_data unless config-check did not indicate it is needed
        if (in_array('pp_config', $need_data)) {
            $post_data['pp_config'] = $pp_config;
        }
        if (in_array('pp_old', $need_data)) {
            $post_data['pp_old'] = $pp_old;
        }
        if (in_array('error_log', $need_data)) {
            $post_data['error_log'] = $error_log;
        }
        $response = PP_Plugin_Status::callhome('config-upload', $request_vars, $post_data);
        return $response;
    } else {
        return -1;
    }
}
Example #4
0
function pp_get_extension_info($force_refresh = false)
{
    require_once dirname(__FILE__) . '/admin/plugin_pp.php';
    return PP_Plugin_Status::get_extension_info($force_refresh);
}
    function options_ui()
    {
        global $pp_options_ui;
        $ui = $pp_options_ui;
        // shorten syntax
        $tab = 'install';
        $ppcom_connect = pp_update_info_enabled();
        $use_network_admin = pp_use_network_updates();
        $suppress_updates = $use_network_admin && !is_super_admin();
        $section = 'key';
        // --- UPDATE KEY SECTION ---
        if (!empty($ui->form_options[$tab][$section]) && !$suppress_updates) {
            ?>
			<tr><td scope="row" colspan="2"><span style="font-weight:bold;vertical-align:top"><?php 
            echo $ui->section_captions[$tab][$section];
            ?>
</span>
			<?php 
            global $activated;
            if ($ppcom_connect) {
                require_once dirname(__FILE__) . '/plugin_pp.php';
                PP_Plugin_Status::get_version_info();
            }
            $id = 'support_key';
            $opt_val = pp_get_option($id);
            if (!is_array($opt_val) || count($opt_val) < 2) {
                $activated = false;
                $expired = false;
                $key = '';
            } else {
                $activated = 1 == $opt_val[0];
                $expired = -1 == $opt_val[0];
                $key = $opt_val[1];
            }
            if (isset($opt_val['expire_date_gmt'])) {
                $expire_days = intval((strtotime($opt_val['expire_date_gmt']) - time()) / 86400);
            }
            if ($expired) {
                $class = 'activating';
                $is_err = true;
                $msg = sprintf(__('Your support key has expired. For information on renewal at a discounted rate, <a href="%s">click here</a>.', 'pp'), 'admin.php?page=pp-settings&amp;pp_renewal=1');
            } elseif (!empty($opt_val['expire_date_gmt'])) {
                $class = 'activating';
                if ($expire_days < 30) {
                    $is_err = true;
                }
                if ($expire_days < 1) {
                    $msg = sprintf(__('Your support key (for plugin updates) will expire today. For information on renewal at a discounted rate, <a href="%2$s">click here</a>.', 'pp'), $expire_days, 'admin.php?page=pp-settings&amp;pp_renewal=1');
                } elseif ($expire_days < 30) {
                    $msg = sprintf(__('Your support key (for plugin updates) will expire in %1$s days. For information on renewal at a discounted rate, <a href="%2$s">click here</a>.', 'pp'), $expire_days, 'admin.php?page=pp-settings&amp;pp_renewal=1');
                } else {
                    $class = "activating hidden";
                }
            } elseif (!$activated) {
                $class = 'activating';
                $msg = sprintf(__('Activate your support key to install Pro extensions and access the member support forums. Available at <a href="%s">presspermit.com</a>.', 'pp'), 'http://presspermit.com/' . 'purchase/');
            } else {
                $class = "activating hidden";
                $msg = '';
            }
            ?>
				
				<span style="margin-left:145px;">
					<?php 
            if ($expired && !empty($key)) {
                ?>
						<span class="pp-key-exired"><?php 
                _e("Key Expired", 'pp');
                ?>
</span>
						<button type="button" id="activation-button" name="activation-button" class="button-secondary"><?php 
                _e('Deactivate Key', 'pp');
                ?>
</button>
						<span class="pp-key-exired pp-key-warning"> <?php 
                _e('note: Renewal does not require deactivation. If you do deactivate, re-entry of the support key will be required.', 'pp');
                ?>
</span>
					<?php 
            } else {
                ?>
						<?php 
                if ($activated) {
                    ?>
						<span class="pp-key-active"><?php 
                    _e("Key Activated", 'pp');
                    ?>
</span>
						<?php 
                }
                ?>
						<input name="<?php 
                echo $id;
                ?>
" type="text" id="<?php 
                echo $id;
                ?>
" <?php 
                echo $activated ? ' style="display:none"' : '';
                ?>
 />
						<button type="button" id="activation-button" name="activation-button" class="button-secondary"><?php 
                echo !$activated ? __('Activate Key', 'pp') : __('Deactivate Key', 'pp');
                ?>
</button>
					<?php 
            }
            ?>
					
					<img id="pp_support_waiting" class="waiting" style="display:none;position:relative" src="<?php 
            echo esc_url(admin_url('images/wpspin_light.gif'));
            ?>
" alt="" />
				</span>

				<br />
				
				<span style="margin-left:217px">
					<?php 
            if ($activated) {
                ?>
					<span class="pp-key-active pp-key-warning"> <?php 
                _e('note: If you deactive, re-entry of the support key will be required for re-activation.', 'pp');
                ?>
</span>
					<?php 
            } elseif (!$expired) {
                ?>
					<span class="pp-subtext"> <?php 
                _e('note: Your site URL and version info will be sent to presspermit.com', 'pp');
                ?>
</span>
					<?php 
            }
            ?>
				</span>
				
				<br /><div id="activation-status" class="<?php 
            echo $class;
            ?>
"><?php 
            echo $msg;
            ?>
</div><div id="activation-reload" style="display:none;margin-top:10px"><a href="<?php 
            echo admin_url('admin.php?page=pp-settings');
            ?>
"><?php 
            _e('reload extension links', 'pp');
            ?>
</a></div>
				
				<?php 
            if (!empty($is_err)) {
                ?>
				<div id="activation-error" class="error" style="margin-top:35px"><?php 
                echo $msg;
                ?>
</div>
				<?php 
            }
            ?>
				
				<?php 
            if (!$activated || $expired) {
                require_once dirname(__FILE__) . '/pro-promo_pp.php';
            }
            ?>
			</td></tr>
		<?php 
            do_action('pp_support_key_ui');
            self::footer_js($activated);
        }
        // any options accessable in this section
        $section = 'version';
        // --- VERSION SECTION ---
        if (!empty($ui->form_options[$tab][$section])) {
            ?>
			<tr>
			<th scope="row"><?php 
            echo $ui->section_captions[$tab][$section];
            ?>
</th>
			<td>
			
			<?php 
            if ($ppcom_connect) {
                $update_info = pp_get_all_updates_info(!empty($_REQUEST['pp_refresh_updates']));
            } else {
                $update_info = array();
            }
            //dump($update_info);
            $info_link = '';
            $update_link = '';
            $alert = '';
            if (!$suppress_updates) {
                $wp_plugin_updates = get_site_transient('update_plugins');
                if ($wp_plugin_updates && isset($wp_plugin_updates->response[PPC_BASENAME]) && !empty($wp_plugin_updates->response[PPC_BASENAME]->new_version) && version_compare($wp_plugin_updates->response[PPC_BASENAME]->new_version, PPC_VERSION, '>')) {
                    $slug = 'press-permit-core';
                    $_url = "plugin-install.php?tab=plugin-information&plugin={$slug}&section=changelog&TB_iframe=true&width=600&height=800";
                    $info_url = $use_network_admin ? network_admin_url($_url) : admin_url($_url);
                    $info_link = "<span class='update-message'> &bull; <a href='{$info_url}' class='thickbox'>" . sprintf(__ppw('%s&nbsp;details', 'pp'), $update_info[$slug]['new_version']) . '</a></span>';
                }
            }
            printf(__('Press Permit Core Version: %1$s %2$s', 'pp'), PPC_VERSION, $info_link . $update_link . $alert);
            ?>
			<br />
			<?php 
            printf(__("Database Schema Version: %s", 'pp'), PPC_DB_VERSION);
            ?>
			<br />
			<?php 
            global $wp_version;
            printf(__("WordPress Version: %s", 'pp'), $wp_version);
            ?>
			<br />
			<?php 
            printf(__("PHP Version: %s", 'pp'), phpversion());
            ?>
			<br />
			<?php 
            if (empty($activated) && empty($expired) && !defined('PP_FORCE_PPCOM_INFO')) {
                ?>
				<div style="margin-top:10px">
				<?php 
                $hint = __('Periodically query presspermit.com for available extensions. Your version info will be sent.', 'pp');
                $ui->option_checkbox('ppcom_update_info', $tab, $section, $hint);
                ?>
				</div>
			<?php 
            }
            ?>
			
			</td></tr>
		<?php 
        }
        // any options accessable in this section
        $section = 'extensions';
        // --- EXTENSIONS SECTION ---
        if (!empty($ui->form_options[$tab][$section])) {
            ?>
			<tr><th scope="row"><?php 
            echo $ui->section_captions[$tab][$section];
            if ($ppcom_connect) {
                echo '&nbsp;&nbsp;&bull;&nbsp;&nbsp;<a href="admin.php?page=pp-settings&amp;pp_refresh_updates=1">' . __('refresh', 'pp') . '</a>';
            }
            ?>
</th><td>
			<?php 
            global $pp_extensions;
            $missing = $inactive = array();
            if (pp_get_option('display_hints') && $ppcom_connect) {
                $ext_info = pp_get_extension_info(!empty($_REQUEST['pp_refresh_done']));
                $ext_info->blurb['capability-manager-enhanced'] = __('Create your own WP roles or modify the capabilities defined for any WP Role.', 'pp');
                $ext_info->descript['capability-manager-enhanced'] = __('Create your own WP roles or modify the capabilities defined for any WP Role. Not necessary for all installations, but PP interop is particularly important for bbPress and BuddyPress installations.', 'pp');
            }
            if (!empty($ext_info) && (empty($ext_info->blurb) || empty($ext_info->descript))) {
                unset($ext_info);
            }
            if ($missing = array_diff_key($update_info, $pp_extensions)) {
                unset($missing['press-permit-core']);
                foreach (array_keys($missing) as $slug) {
                    if (0 === validate_plugin("{$slug}/{$slug}.php")) {
                        unset($missing[$slug]);
                        $inactive[$slug] = true;
                    }
                }
            }
            ksort($pp_extensions);
            if ($pp_extensions) {
                $change_log_caption = __('<strong>Change Log</strong> (since your current version)', 'pp');
                ?>
				<h4 style="margin-bottom:2px;margin-top:0"><?php 
                _e('Active Extensions:', 'pp');
                ?>
</h4>
				<table class="pp-extensions">
				<?php 
                foreach ($pp_extensions as $slug => $plugin_info) {
                    $info_link = '';
                    $update_link = '';
                    $alert = '';
                    if (isset($update_info[$slug]) && version_compare($update_info[$slug]['new_version'], $plugin_info->version, '>')) {
                        $_url = "plugin-install.php?tab=plugin-information&plugin={$slug}&TB_iframe=true&width=600&height=800";
                        $info_url = $use_network_admin ? network_admin_url($_url) : admin_url($_url);
                        $info_link = "<span class='update-message'> &bull; <a href='{$info_url}' class='thickbox' title='{$change_log_caption}'>" . sprintf(__ppw('%s&nbsp;details', 'pp'), $update_info[$slug]['new_version']) . '</a></span>';
                        if (!$suppress_updates) {
                            $style = $activated ? '' : "style='display:none'";
                            $url = pp_plugin_update_url($plugin_info->basename, $slug) . '&pp_install=1&TB_iframe=true&height=400';
                            $update_link = "<span class='pp-update-link' {$style}> &bull; <a href='{$url}' class='thickbox' target='_blank'>" . __ppw('update&nbsp;now', 'pp') . '</a></span>';
                            $alert = !empty($update_info[$slug]['alert']) ? " &bull; <span class='pp-red'>{$update_info[$slug]['alert']}</span>" : '';
                        }
                    }
                    ?>
				<tr>
				<td <?php 
                    if ($alert) {
                        echo 'colspan="2"';
                    }
                    ?>
><?php 
                    echo __($plugin_info->label) . ' <span class="pp-gray">' . $plugin_info->version . "</span> {$info_link} {$update_link} {$alert}";
                    ?>
</td>
				<?php 
                    if (!empty($ext_info) && !$alert) {
                        ?>
				<td>
					<?php 
                        if (isset($ext_info->blurb[$slug])) {
                            ?>
					<span class="pp-ext-info" title="<?php 
                            if (isset($ext_info->descript[$slug])) {
                                echo esc_attr($ext_info->descript[$slug]);
                            }
                            ?>
"><?php 
                            echo $ext_info->blurb[$slug];
                            ?>
</span>
					<?php 
                        }
                        ?>
				</td>
				<?php 
                    }
                    ?>
				</tr>
				<?php 
                }
                ?>
				</table>
			<?php 
            }
            if (!defined('CAPSMAN_ENH_VERSION')) {
                if (0 === validate_plugin('capability-manager-enhanced/capsman-enhanced.php') || 0 === validate_plugin('capsman-enhanced/capsman-enhanced.php')) {
                    $inactive['capability-manager-enhanced'] = true;
                } else {
                    $missing['capability-manager-enhanced'] = true;
                }
            }
            ksort($inactive);
            if ($inactive) {
                ?>
			<h4 style="margin-bottom:2px"><?php 
                $url = PP_MULTISITE ? 'network/plugins.php/' : 'plugins.php';
                printf(__('%1$sInactive Extensions%2$s:', 'pp'), "<a href='{$url}'>", '</a>');
                ?>
</h4>
			<table class="pp-extensions">
			<?php 
                foreach (array_keys($inactive) as $slug) {
                    ?>
			<tr>
			<td><?php 
                    echo pp_pretty_slug($slug);
                    ?>
</td>
			<?php 
                    if (!empty($ext_info)) {
                        ?>
				<td>
					<?php 
                        if (isset($ext_info->blurb[$slug])) {
                            ?>
					<span class="pp-ext-info" title="<?php 
                            if (isset($ext_info->descript[$slug])) {
                                echo esc_attr($ext_info->descript[$slug]);
                            }
                            ?>
"><?php 
                            echo $ext_info->blurb[$slug];
                            ?>
</span>
					<?php 
                        }
                        ?>
				</td>
			<?php 
                    }
                    ?>
			</tr>
			<?php 
                }
                ?>
			</table>
			<?php 
            }
            ksort($missing);
            if ($missing) {
                ?>
			<h4 style="margin-bottom:2px"><?php 
                _e('Available Pro Extensions:', 'pp');
                ?>
</h4>
			<table class="pp-extensions">
			<?php 
                foreach (array_keys($missing) as $slug) {
                    if ($need_supplemental_key = isset($update_info[$slug]['key_type']) && 'pp' != $update_info[$slug]['key_type']) {
                        $any_supplemental_key = true;
                    }
                    if ($activated && isset($update_info[$slug]) && !$need_supplemental_key && !$suppress_updates) {
                        $_url = "update.php?action={$slug}&amp;plugin={$slug}&pp_install=1&TB_iframe=true&height=400";
                        $install_url = $use_network_admin ? network_admin_url($_url) : admin_url($_url);
                        $url = wp_nonce_url($install_url, "{$slug}_{$slug}");
                        $install_link = "<span> &bull; <a href='{$url}' class='thickbox' target='_blank'>" . __ppw('install', 'pp') . '</a></span>';
                    } else {
                        $install_link = '';
                    }
                    ?>
			<tr>
			<td><?php 
                    if (!empty($update_info[$slug])) {
                        echo "<a href='http://presspermit.com/extensions/{$slug}'>" . pp_pretty_slug($slug) . '</a>' . $install_link;
                    } else {
                        $caption = ucwords(str_replace('-', ' ', $slug));
                        echo '<span class="plugins update-message"><a href="' . pp_plugin_info_url($slug) . '" class="thickbox" title=" ' . $caption . '">' . str_replace(' ', '&nbsp;', $caption) . '</a></span>';
                    }
                    ?>
</td>
			<?php 
                    if (!empty($ext_info)) {
                        ?>
				<td>
					<?php 
                        if (isset($ext_info->blurb[$slug])) {
                            ?>
					<span class="pp-ext-info" title="<?php 
                            if (isset($ext_info->descript[$slug])) {
                                echo esc_attr($ext_info->descript[$slug]);
                            }
                            ?>
"><?php 
                            echo $ext_info->blurb[$slug];
                            ?>
</span>
					<?php 
                        }
                        ?>
				</td>
			<?php 
                    }
                    ?>
			</tr>
			<?php 
                }
                ?>
			</table>
			<p style="padding-left:15px;">
			<?php 
                if (!$activated) {
                    echo '<span class="pp-red">' . __('To enable one-click installation and update of extensions, please activate your Press Permit Pro support key above.', 'pp') . '<span>';
                } elseif (!empty($any_supplemental_key)) {
                    printf(__('Visit %1$spresspermit.com%2$s for further information on obtaining and installing extensions.', 'pp'), '<a href="http://presspermit.com">', '</a>');
                }
                ?>
			</p>
			
			<?php 
            } elseif (!pp_update_info_enabled()) {
                ?>
				<p style="margin-top:20px"><strong><?php 
                _e('Press Permit Pro extensions supply:', 'pp');
                ?>
</strong></p>
				<ul class="pp-bullet-list">
				<li><?php 
                printf(__('%1$sContent-specific editing permissions, with Edit Flow, Revisionary and Post Forking support%2$s', 'pp'), '<a href="http://presspermit.com/extensions/pp-collaborative-editing">', '</a>');
                ?>
</li>
				<li><?php 
                printf(__('%1$sCustom Post Statuses (for visibility or moderation)%2$s', 'pp'), '<a href="http://presspermit.com/extensions/pp-custom-post-statuses">', '</a>');
                ?>
</li>
				<li><?php 
                printf(__('%1$sCustomize bbPress forum access%2$s', 'pp'), '<a href="http://presspermit.com/extensions/pp-compatibility">', '</a>');
                ?>
</li>
				<li><?php 
                printf(__('%1$sFile URL filtering%2$s', 'pp'), '<a href="http://presspermit.com/extensions/pp-file-url-filter">', '</a>');
                ?>
</li>
				<li><?php 
                printf(__('%1$sRole Scoper import script%2$s', 'pp'), '<a href="http://presspermit.com/extensions/pp-import">', '</a>');
                ?>
</li>
				<li><?php 
                printf(__('%1$s...and more%2$s', 'pp'), '<a href="http://presspermit.com/extensions/">', '</a>');
                ?>
</li>
				</ul>
				<p>
				<?php 
                printf(__('For updated availability, enable the "update info" option above or visit %1$spresspermit.com%2$s.', 'pp'), '<a href="http://presspermit.com/extensions/">', '</a>');
                ?>
</p>
			<?php 
            }
            ?>
			<?php 
            if (!empty($ext_info) && pp_get_option('display_hints')) {
                ?>
			<p><span class="pp-subtext">
			<?php 
                _e('Note: Hover over descriptions for more detail. Press Permit extensions can also be maintained on the Plugins screen.', 'pp');
                ?>
			</span></p>
			<?php 
            }
            ?>
			
			<?php 
            ?>
			</td></tr>
			<?php 
        }
        // any options accessable in this section
        $section = 'help';
        // --- HELP SECTION ---
        if (!empty($ui->form_options[$tab][$section])) {
            ?>
			<tr><th scope="row"><?php 
            echo $ui->section_captions[$tab][$section];
            ?>
</th><td>
			<?php 
            if ($activated) {
                ?>
				<ul class="pp-support-list">
				<li><a href='http://presspermit.com/docs/' target='pp_doc'><?php 
                _e('Press Permit Documentation', 'pp');
                ?>
</a></li>

				<li class="pp-support-forum"><a href="admin.php?page=pp-settings&amp;pp_support_forum=1" target="pp_forum"><?php 
                _e('Press Permit Support Forums', 'pp');
                ?>
</a> <strong>*</strong></li>

				<li class="upload-config"><a href="admin.php?page=pp-settings&amp;pp_upload_config=1"><?php 
                _e('Upload site configuration to presspermit.com now', 'pp');
                ?>
</a> <strong>*</strong> 
				<img id="pp_upload_waiting" class="waiting" style="display:none;position:relative" src="<?php 
                echo esc_url(admin_url('images/wpspin_light.gif'));
                ?>
" alt="" />
				</li>
				</ul>
				
				<div style="text-indent: -10px;padding-left: 10px;margin-top:15px;margin-left:10px"><strong>
				<?php 
                printf(__('%s Site configuration data selected below will be uploaded to presspermit.com:', 'pp'), '<strong>* </strong>');
                ?>
				</strong></div>
				
				<div style="padding-left:22px">
				<?php 
                $ok = (array) pp_get_option('support_data');
                $ok['ver'] = 1;
                $ui->all_options[] = 'support_data';
                $avail = array('ver' => __('Version info for server, WP, bbPress, BuddyPress, PP and all extensions', 'pp'), 'pp_options' => __('PP Settings and related WP Settings', 'pp'), 'theme' => __('Theme name, version and status', 'pp'), 'active_plugins' => __('Activated plugins list', 'pp'), 'installed_plugins' => __('Inactive plugins list', 'pp'), 'wp_roles_types' => __('WordPress Roles, Capabilities, Post Types, Taxonomies and Post Statuses', 'pp'), 'pp_permissions' => __('Role Assignments and Exceptions', 'pp'), 'pp_groups' => __('Group definitions', 'pp'), 'pp_group_members' => __('Group Membership (id only)', 'pp'), 'pp_imports' => __('Role Scoper / PP 1.x Configuration and PP Import Results', 'pp'), 'post_data' => __('Post id, status, author id, parent id, and term ids and taxonomy name (when support accessed from post or term edit form)', 'pp'), 'error_log' => __('PHP Error Log (recent entries, no absolute paths)', 'pp'));
                $ok['ver'] = true;
                $ok['pp_options'] = true;
                ?>
				<div class="support_data">
				<?php 
                foreach ($avail as $key => $caption) {
                    $id = 'support_data_' . $key;
                    $disabled = in_array($key, array('ver', 'pp_options')) ? 'disabled="disabled"' : '';
                    ?>
					<div>
					<label for="<?php 
                    echo $id;
                    ?>
"><input type="checkbox" id="<?php 
                    echo $id;
                    ?>
" name="support_data[<?php 
                    echo $key;
                    ?>
]" value="1" <?php 
                    echo $disabled;
                    checked('1', !empty($ok[$key]), true);
                    ?>
 /> <?php 
                    echo $caption;
                    ?>
</label>
					</div>
				<?php 
                }
                ?>
				</div>
				
				<div>
				<label for="pp_support_data_all"><input type="checkbox" id="pp_support_data_all" value="1" /> <?php 
                _e('(all)', 'pp');
                ?>
</label>
				</div>
				
				<div style="margin-top:10px">
				<?php 
                _e('<strong>note:</strong> user data, absolute paths, database prefix, post title, post content and post excerpt are <strong>never</strong> uploaded', 'pp');
                ?>
				</div>
				
				</div>
				<?php 
            } else {
                ?>
				<div>
				<?php 
                _e('Purchase of a support key enables access to the following resources:', 'pp');
                ?>
				</div>
	
				<ul class="pp-support-list pp-bullet-list">
				<!-- <li><a href='http://presspermit.com/docs/' target='pp_doc'><?php 
                _e('Pro Documentation on presspermit.com', 'pp');
                ?>
</a></li> -->
				<li><a href='http://presspermit.com/forums/' target='pp_forum'><?php 
                _e('Pro Support Forums on presspermit.com', 'pp');
                ?>
</a></li>
				<li><?php 
                _e('Optional uploading of your site configuration to assist troubleshooting', 'pp');
                ?>
</li>
				</ul>
				<?php 
            }
            if (version_compare(PPC_VERSION, '1.0', '<')) {
                echo '<div>';
                _e('Note that these resources may be unavailable or incomplete during the project\'s initial beta phase.', 'pp');
                echo '</div>';
            }
            ?>
			</td></tr>
		<?php 
        }
        // any options accessable in this section
        if (!empty($activated)) {
            $section = 'beta_updates';
            // --- BETA UPDATES SECTION ---
            if (!empty($ui->form_options[$tab][$section]) && !$suppress_updates && $ppcom_connect) {
                ?>
				<tr><th scope="row"><?php 
                echo $ui->section_captions[$tab][$section];
                ?>
</th><td>
				<?php 
                if (preg_match("/dev|alpha|beta|rc/i", PPC_VERSION) && version_compare(PPC_VERSION, '0.9', '>')) {
                    $hint = __('If you have already received a beta update and want to switch back to the current production version, switch off this option and click Update. Then look for an update prompt in the Plugins list.', 'pp');
                } else {
                    $hint = '';
                }
                $ui->option_checkbox('beta_updates', $tab, $section, $hint);
                ?>
				</td></tr>
				<?php 
            }
            // any options accessable in this section
        }
    }