예제 #1
0
function amr_events_get_license_data($l)
{
    global $wp_version;
    $license = trim(get_option($l . '-license-key'));
    $api_params = array('edd_action' => 'check_license', 'license' => $license, 'item_name' => urlencode($l), 'url' => home_url());
    // Call the custom API.
    $response = wp_remote_get(add_query_arg($api_params, AMR_EVENTS_STORE_URL), array('timeout' => 15, 'sslverify' => false));
    if (is_wp_error($response)) {
        return false;
    }
    $license_data = json_decode(wp_remote_retrieve_body($response));
    if ($license_data->license == 'site_inactive') {
        // deactivated remotely at host site?
        delete_option($l . '-license-status', $license_data->license);
        amr_flag_error(sprintf(__('%s at this site is inactive at remote host', 'amr-events'), $license_data->item_name));
    }
    return $license_data;
}
/** ----------------------------------------------------------------------------------- */
function amr_get_next_level_keys($q)
{
    /*  get all user data and attempt to extract out any object values into arrays for listing  */
    global $wpdb, $orig_mk;
    if (!($orig_mk = ausers_get_option('amr-users-original-keys'))) {
        $orig_mk = array();
    }
    $all = $wpdb->get_results($q, ARRAY_A);
    //	print_r ($all);
    if (is_wp_error($all)) {
        amr_flag_error($all);
        return;
    }
    if (!is_array($all)) {
        return;
    }
    echo '<br /><h3>' . sprintf(__('You have %u distinct meta key / meta value records. ', 'amr-users'), count($all)) . '</h3>';
    _e('...Deserialising and rationalising...looking for new fields.', 'amr-users');
    foreach ($all as $i2 => $v2) {
        /* array of meta key, meta value*/
        /* Exclude non useful stuff */
        //			print_r ($v2);
        $mk = $v2['meta_key'];
        $mv = $v2['meta_value'];
        if (!amr_excluded_userkey($mk)) {
            if (!empty($mv)) {
                $temp = maybe_unserialize($mv);
                $temp = objectToArray($temp);
                /* *must do all so can cope with incomplete objects */
                $key = str_replace(' ', '_', $mk);
                /* html does not like spaces in the names*/
                if (is_array($temp)) {
                    foreach ($temp as $i3 => $v3) {
                        if (is_array($v3) and function_exists('amr_dig_deeper')) {
                            // *** needs work still
                            //if (WP_DEBUG) echo'<br /> ** go down a level for '.$i3;
                            $key2 = $key . '_' . str_replace(' ', '_', $mk);
                            /* html does not like spaces in the names*/
                            $subkeys = amr_get_next_level_down($mk, $key2, $v3);
                            //if (WP_DEBUG) echo '<br /> **** got back '.$subkeys;
                            $keys = array_merge($keys, $subkeys);
                        } else {
                            $mkey = $key . '-' . str_replace(' ', '_', $i3);
                            /* html does not like spaces in the names*/
                            $keys[$mkey] = $mkey;
                            if (!isset($orig_mk[$mkey])) {
                                $orig_mk[$mkey] = $mk;
                                echo '<br />' . __('Added complex meta to report DB: ', 'amr-users') . $mkey;
                            } else {
                                //echo ' &#10003;'.$mkey;
                            }
                        }
                    }
                } else {
                    $keys[$key] = $key;
                    if (empty($orig_mk[$key])) {
                        $orig_mk[$key] = $mk;
                        echo '<br />' . __('Added meta to report DB: ', 'amr-users') . $key;
                    } else {
                        //echo ' &#10003;'.$key;
                    }
                }
            } else {
                if (!isset($keys[$mk])) {
                    //if (!isset ($orig_mk[$key])) {
                    $keys[$mk] = $mk;
                    $orig_mk[$mk] = $mk;
                    // same same
                    echo '<br />' . __('Added to report DB: ', 'amr-users') . $mk;
                }
            }
        }
    }
    unset($all);
    //if (WP_DEBUG) {echo '<br />In Debug Only: Original keys mapping: '; var_dump($orig_mk);}
    ausers_update_option('amr-users-original-keys', $orig_mk);
    echo '<br />';
    //if (WP_DEBUG) {echo '<br />For Debug: Merged keys'; var_dump($keys);}
    return $keys;
}
function amr_get_usermasterfields()
{
    global $wpdb, $wp_version;
    if (version_compare($wp_version, '3.3', '<')) {
        $main_fields = array('ID', 'user_login', 'user_nicename', 'user_email', 'user_url', 'user_registered', 'user_status', 'display_name');
        // unlikley to use for selection normally?
    } else {
        // wp may have added some fields
        $q = 'SELECT DISTINCT(COLUMN_NAME) FROM information_schema.COLUMNS WHERE TABLE_NAME = "' . $wpdb->users . '"';
        $all = $wpdb->get_results($q, ARRAY_N);
        //if (WP_DEBUG) {echo '<br/> found in info schema : ';var_dump($all);}
        if (is_wp_error($all)) {
            amr_flag_error($all);
            die;
        }
        foreach ($all as $i => $arr) {
            $main_fields[$i] = array_shift($arr);
        }
    }
    $excluded_nicenames = array('user_pass', 'user_activation_key', 'user_status');
    /*	if (!($excluded_nicenames = ausers_get_option('amr-users-nicenames-excluded')))   //NOT RELEVNAT HERE
    		$excluded_nicenames = array(
    			'user_pass', 
    			'user_activation_key', 
    			'user_status');
    */
    foreach ($main_fields as $i => $f) {
        if (isset($excluded_nicenames[$f])) {
            unset($main_fields[$i]);
        }
    }
    return $main_fields;
}
예제 #4
0
function alist_one_widget($type = 'user', $i = 1, $do_headings = false, $do_csv = false, $max = 10)
{
    /* a widget version of alist one*/
    /* Get the fields to use for the chosen list type */
    global $aopt;
    global $amain;
    $c = new adb_cache();
    $rptid = $c->reportid($i, $type);
    $line = $c->get_cache_report_lines($rptid, '0', '2');
    /* get the internal heading names  for internal plugin use only */
    /* get the user defined heading names */
    if (!defined('str_getcsv')) {
        $icols = amr_str_getcsv($line[0]['csvcontent'], ',', '"', '\\');
    } else {
        $icols = str_getcsv($line[0]['csvcontent'], ',', '"', '\\');
    }
    //		if (!defined('str_getcsv')) $cols = amr_str_getcsv( $line[1]['csvcontent'], '","','"','\\');
    //		else $cols = str_getcsv( $line[1]['csvcontent'], ',','"','\\');
    foreach ($icols as $ic => $cv) {
        /* use the icols as our controlling array, so that we have the internal field names */
        $v = $cols[$ic];
        $html .= '<th>' . $v . '</th>';
    }
    $hhtml = '<thead><tr>' . $html . '</tr></thead>';
    /* setup the html for the table headings */
    $fhtml = '<tfoot><tr>' . $html . '</tr>' . '</tfoot>';
    /* setup the html for the table headings */
    $html = '';
    $totalitems = $c->get_cache_totallines($rptid);
    $lines = $c->get_cache_report_lines($rptid, $start + 1, $max);
    if (!($lines > 0)) {
        amr_flag_error($c->get_error('numoflists'));
        return false;
    }
    foreach ($lines as $il => $l) {
        $id = $lineitems[0];
        /*  *** pop the first one - this should always be the id */
        $user = amr_get_userdata($id);
        unset($linehtml);
        foreach ($icols as $ic => $c) {
            /* use the icols as our controlling array, so that we have the internal field names */
            $v = $lineitems[$ic];
            $linehtml .= '<td>' . amr_format_user_cell($c, $v, $user) . '</td>';
        }
        $html .= PHP_EOL . '<tr>' . $linehtml . '</tr>';
    }
    $html = '<table>' . $hhtml . $fhtml . '<tbody>' . $html . '</tbody></table>';
    return $html;
}
예제 #5
0
function amrmeta_validate_names()
{
    /*  the names of lists */
    global $amain;
    if (is_array($_POST['name'])) {
        foreach ($_POST['name'] as $i => $n) {
            /* for each list */
            $amain['names'][$i] = $n;
        }
        return true;
    } else {
        amr_flag_error(adb_cache::get_error('nonamesarray'));
        return false;
    }
}