コード例 #1
0
function ameta_cron_unschedule()
{
    /* This should be done once on activation only or once if settings changed, or perhaps only if requested  */
    $network = ausers_job_prefix();
    if (function_exists('wp_clear_scheduled_hook')) {
        wp_clear_scheduled_hook('amr_' . $network . 'regular_reportcacheing');
        $logcache = new adb_cache();
        $text = __('Deactivated any existing regular cacheing of lists', 'amr-users');
        $logcache->log_cache_event($text);
        echo '<pclass="message">' . $text . '</p>';
    }
}
コード例 #2
0
function amr_generate_csv($ulist, $strip_endings, $strip_html = false, $suffix, $wrapper, $delimiter, $nextrow, $tofile = false)
{
    /* get the whole cached file - write to file? but security / privacy ? */
    /* how big */
    $c = new adb_cache();
    $rptid = $c->reportid($ulist);
    $total = $c->get_cache_totallines($rptid);
    $lines = $c->get_cache_report_lines($rptid, 1, $total + 1);
    /* we want the heading line (line1), but not the internal nameslines (line 0) , plus all the data lines, so neeed total + 1 */
    if (isset($lines) and is_array($lines)) {
        $t = count($lines);
    } else {
        $t = 0;
    }
    $csv = '';
    if ($t > 0) {
        if ($strip_endings) {
            foreach ($lines as $k => $line) {
                $csv .= apply_filters('amr_users_csv_line', $line['csvcontent']) . $nextrow;
            }
        } else {
            foreach ($lines as $k => $line) {
                $csv .= $line['csvcontent'] . $nextrow;
            }
        }
        $csv = str_replace('","', $wrapper . $delimiter . $wrapper, $csv);
        /* we already have in std csv - allow for other formats */
        $csv = str_replace($nextrow . '"', $nextrow . $wrapper, $csv);
        $csv = str_replace('"' . $nextrow, $wrapper . $nextrow, $csv);
        if ($csv[0] == '"') {
            $csv[0] = $wrapper;
        }
    }
    if (amr_debug()) {
        echo '<br />In Debug only: Csv setup: Report: ' . $ulist . ' ' . $c->reportname($ulist) . ' ' . sprintf(__('%s lines found, 1 heading line, the rest data.', 'amr-users'), $t);
        $bytes = mb_strlen($csv);
        echo ' Size = ' . amru_convert_mem($bytes) . '<br />';
    }
    if ($tofile) {
        $csvfile = amr_users_to_csv($ulist, $csv, $suffix);
        $csvurl = amr_users_get_csv_link($ulist);
        //return ($csvurl);
        $html = '<br />' . __('Public user list csv file: ', 'amr-users') . '<br />' . $csvurl;
    } else {
        echo '<p>' . sprintf(__('List %s, %s lines, plus heading line'), $ulist, $t) . '</p>';
        $html = amr_csv_form($csv, $suffix);
    }
    return $html;
}
コード例 #3
0
function amrmeta_cache_logs_page()
{
    global $aopt;
    global $amr_nicenames;
    global $pluginpage;
    global $amain;
    //	amr_meta_main_admin_header('Cache Logs');
    amr_meta_admin_headings($plugin_page = '');
    // does the nonce check etc
    $c = new adb_cache();
    if (isset($_POST['trashlog'])) {
        /*  jobs having a problem - allow try again option */
        $c->delete_all_logs();
        //return;
    } else {
        echo alist_trashlogs();
        echo $c->cache_log();
    }
    echo ausers_form_end();
}
コード例 #4
0
function amrmeta_cachestatus_page()
{
    global $aopt;
    global $amr_nicenames;
    global $pluginpage;
    global $amain;
    $c = new adb_cache();
    //	amr_meta_main_admin_header('Cache Status');
    amr_meta_admin_headings($plugin_page = '');
    // does the nonce check etc
    if (isset($_REQUEST['rebuildback'])) {
        echo '<p>' . __('Background cache request received', 'amr-users') . '</p>';
        if (isset($_REQUEST['rebuildreal'])) {
            $ulist = (int) $_REQUEST['rebuildreal'];
            amr_request_cache_with_feedback($ulist);
        } else {
            amr_request_cache_with_feedback();
        }
        return;
    }
    /* then we have a request to kick off run */
    if (isset($_POST['trashlog'])) {
        /*  jobs having a problem - allow try again option */
        $c->delete_all_logs();
        //return;
    } elseif (isset($_POST['trashcache'])) {
        /*  jobs havign a problem - allow try again option */
        $c->clear_all_cache();
        //return;
    } elseif (isset($_POST['trashcachestatus'])) {
        /*  jobs havign a problem - allow try again option */
        amr_trash_the_cache();
        //return;
    }
    $c->cache_status();
    echo alist_rebuild();
    echo alist_trashcache_status();
    echo alist_trashcache();
    echo ausers_form_end();
}
コード例 #5
0
 function cache_status()
 {
     /* show the cache status and offer to rebuild */
     global $wpdb;
     global $amain;
     $problem = false;
     $now = time();
     $dt = new DateTime('now', $this->tz);
     $nowtxt = date_format($dt, 'D, j M Y G:i e');
     if (is_admin()) {
         if (!($amain = ausers_get_option('amr-users-main'))) {
             $amain = ameta_default_main();
         }
         $wpdb->show_errors();
         $sql = 'SELECT DISTINCT reportid AS "rid", COUNT(reportid) AS "lines" FROM ' . $this->table_name . ' GROUP BY reportid';
         $results = $wpdb->get_results($sql, ARRAY_A);
         /* Now e have a summary of what isin the cache table - rid, lines */
         if (is_wp_error($results)) {
             echo '<h2>' . $results->get_error_message() . '</h2>';
             return false;
         } else {
             if (!empty($results)) {
                 //var_dump($results);  var_dump($amain);
                 foreach ($results as $i => $rpt) {
                     $r = intval(substr($rpt['rid'], 5));
                     /* *** skip the 'users' and take the rest */
                     $summary[$r]['rid'] = $rpt['rid'];
                     $summary[$r]['lines'] = $rpt['lines'] - 2;
                     /* as first two liens are headers anyway*/
                     $summary[$r]['name'] = $amain['names'][intval($r)];
                 }
             } else {
                 echo adb_cache::get_error('nocacheany');
                 // attempt a realtime run  NO!!! Don't do this - for large databases that are failing anyway will be no good.
                 //foreach ($amain['names'] as $i => $name) {
                 //	amr_build_user_data_maybe_cache($i);
                 //}
             }
             $status = ausers_get_option('amr-users-cache-status');
             /* Now pickup the record of starts etc reportid, start   and reportid end*/
             if (!empty($status)) {
                 foreach ($status as $rd => $se) {
                     $r = intval(substr($rd, 5));
                     /* *** skip the 'users' and take the rest */
                     if (empty($se['end'])) {
                         $now = time();
                         $diff = $now - $se['start'];
                         if ($diff > 60 * 5) {
                             $problem = true;
                             $summary[$r]['end'] = __('Taking too long, may have been aborted... delete cache status, try again, check server logs and/or memory limit', 'amr-users');
                             delete_transient('amr_users_cache_' . $r);
                             // so another can run
                         } else {
                             $summary[$r]['end'] = sprintf(__('Started %s', 'amr-users'), human_time_diff($now, $se['start']));
                         }
                         $summary[$r]['time_since'] = __('?', 'amr-users');
                         $summary[$r]['time_taken'] = __('?', 'amr-users');
                         $summary[$r]['peakmem'] = __('?', 'amr-users');
                         $summary[$r]['rid'] = $rd;
                         $r = intval(substr($rd, 5));
                         /* *** skip the 'users' and take the rest */
                         $summary[$r]['name'] = $amain['names'][intval($r)];
                     } else {
                         if (empty($se['end'])) {
                             $summary[$r]['end'] = 'In progress';
                         } else {
                             $datetime = new datetime(date('Y-m-d H:i:s', $se['end']));
                             if (empty($tzobj)) {
                                 $tzobj = amr_getset_timezone();
                             }
                             $datetime->setTimezone($tzobj);
                             $summary[$r]['end'] = $datetime->format('D, j M G:i');
                         }
                         //$summary[$r]['end'] = empty($se['end']) ? 'In progress' : date_i18n('D, j M H:i:s',$se['end']);  /* this is in unix timestamp not "our time" , so just say how long ago */
                         $summary[$r]['start'] = date_i18n('D, j M Y H:i:s', $se['start']);
                         /* this is in unix timestamp not "our time" , so just say how long ago */
                         $dt = new DateTime('now', $this->tz);
                         $nowtxt = date_format($dt, 'D, j M Y G:i e');
                         $summary[$r]['time_since'] = human_time_diff($se['end'], time());
                         /* the time that the last cache ended */
                         $summary[$r]['time_taken'] = $se['end'] - $se['start'];
                         /* the time that the last cache ended */
                         $summary[$r]['peakmem'] = $se['peakmem'];
                         $summary[$r]['headings'] = $se['headings'];
                     }
                 }
             } else {
                 if (!empty($summary)) {
                     foreach ($summary as $rd => $rpt) {
                         $summary[$rd]['time_since'] = $summary[$rd]['time_taken'] = $summary[$rd]['end'] = $summary[$rd]['peakmem'] = '';
                     }
                 }
             }
             if (!empty($summary)) {
                 echo PHP_EOL . '<div class="wrap" style="padding-top: 20px;">' . '<h3>' . $nowtxt . '</h3>' . PHP_EOL . '<table class="widefat" style="width:auto; ">' . '<thead><tr><th>' . __('Report Id', 'amr-users') . '</th><th>' . __('Name', 'amr-users') . '</th><th>' . __('Lines', 'amr-users') . '</th><th style="text-align: right;">' . __('Ended?', 'amr-users') . '</th><th style="text-align: right;">' . __('How long ago?', 'amr-users') . '</th><th style="text-align: right;">' . __('Seconds taken', 'amr-users') . '</th><th style="text-align: right;">' . __('Peak Memory', 'amr-users') . '</th><th style="text-align: right;">' . __('Details', 'amr-users') . '</th></tr></thead>';
                 foreach ($summary as $rd => $rpt) {
                     if (!isset($rpt['headings'])) {
                         $rpt['headings'] = ' ';
                     }
                     if (!isset($rpt['lines'])) {
                         $rpt['lines'] = ' ';
                     }
                     if (isset($rpt['rid'])) {
                         echo '<tr>' . '<td>' . $rpt['rid'] . '</td>' . '<td>' . au_view_link($rpt['name'], $rd, '') . '</td>' . '<td align="right">' . $rpt['lines'] . '</td>' . '<td align="right">' . $rpt['end'] . '</td>' . '<td align="right">' . $rpt['time_since'] . '</td>' . '<td align="right">' . $rpt['time_taken'] . '</td>' . '<td align="right">' . $rpt['peakmem'] . '</td>' . '<td align="right">' . $rpt['headings'] . '</td>' . '</tr>';
                     }
                 }
                 echo PHP_EOL . '</table>' . PHP_EOL . '</div><!-- end wrap -->' . PHP_EOL;
             }
         }
     } else {
         echo '<h3>not admin?</h3>';
     }
     if ($problem) {
         $fun = '<a target="_blank" title="' . __('Link to audio file of the astronauts of Apollo 13 reporting a problem.', 'amr-users') . '" href="http://upload.wikimedia.org/wikipedia/commons/1/12/Apollo13-wehaveaproblem_edit_1.ogg" >' . __('Houston, we have a problem', 'amr-users') . '</a>';
         $text = __('The background job\'s may be having problems.', 'amr-users');
         $text .= '<br />' . __('Delete all the cache records and try again', 'amr-users');
         $text .= '<br />' . __('Check the server logs and your php wordpress memory limit.', 'amr-users');
         $text .= '<br />' . __('The TPC memory usage plugin may be useful to assess whether the problem is memory.', 'amr-users');
         $text = $fun . '<br/>' . $text;
         amr_users_message($text);
     }
 }
コード例 #6
0
function amr_check_for_upgrades()
{
    // NB must be in order of the oldest changes first // called from ausers_get_option
    // should already have values then - and will not be new ?
    global $amain, $aopt;
    if (empty($amain)) {
        $amain = ausers_get_option('amr-users-main');
    }
    //if (WP_DEBUG) echo '<div class="message">Debug mode: check doing upgrade check </div>';
    // must be in admin and be admin
    if (!is_admin() or !current_user_can('manage_options')) {
        return;
    }
    // handle a series of updates in order
    if (!isset($amain['version'])) {
        $amain['version'] = '0';
    }
    // really old?
    if (version_compare($amain['version'], AUSERS_VERSION, '=')) {
        return;
    }
    // if same version, don't repeat check
    $prev = $amain['version'];
    echo PHP_EOL . '<div class="updated"><p>';
    // closing div at end
    printf(__('Previous version was %s. ', 'amr-users'), $prev);
    _e('New version activated. ', 'amr-users');
    _e('We may need to process some updates.... checking now... ', 'amr-users');
    // do old changes first - user may not have updated for a while....
    if (!isset($amain['version']) or version_compare($amain['version'], '3.1', '<')) {
        // convert old options from before 3.1
        echo '<br />';
        printf(__('Prev version less than %s', 'amr-users'), '3.1.');
        if (!isset($amain['csv_text'])) {
            $amain['csv_text'] = '<img src="' . plugins_url('amr-users/images/file_export.png') . '" alt="' . __('Csv', 'amr-users') . '"/>';
        }
        if (!isset($amain['refresh_text'])) {
            $amain['refresh_text'] = '<img src="' . plugins_url('amr-users/images/rebuild.png') . '" alt="' . __('Refresh user list cache', 'amr-users') . '"/>';
        }
        ausers_update_option('amr-users-main', $amain);
        echo '<br />' . __('Image links updated.', 'amr-users');
        echo '</p>';
    }
    //
    if (!isset($amain['version']) or version_compare($amain['version'], '3.3.1', '<')) {
        // check for before 3.3.1
        echo '<br />';
        printf(__('Prev version less than %s', 'amr-users'), '3.3.1.');
        $c = new adb_cache();
        $c->deactivate();
        if (!ameta_cache_enable() or !ameta_cachelogging_enable()) {
            echo '<h2>' . __('Problem creating amr user DB tables', 'amr-users') . '</h2>';
        }
        echo '<br />';
        _e('Cacheing tables recreated.', 'amr-users');
    }
    //
    if (!isset($amain['version']) or version_compare($amain['version'], '3.3.6', '<')) {
        // check for before 3.3.6,
        echo '<br />';
        printf(__('Prev version less than %s', 'amr-users'), '3.3.6. ');
        echo '</p>' . __('Minor sub option name change for avatar size', 'amr-users') . '</p>';
        if (!empty($amain['avatar-size'])) {
            $amain['avatar_size'] = $amain['avatar-size'];
        } else {
            $amain['avatar_size'] = '16';
        }
        unset($amain['avatar-size']);
        ausers_update_option('amr-users-main', $amain);
    }
    // 3.4.4  July 2012
    if (!isset($amain['version']) or version_compare($amain['version'], '3.4.4', '<')) {
        // check for before 3.3.,
        echo '<br />';
        printf(__('Prev version less than %s', 'amr-users'), '3.4.4 ');
        echo '<p><b>' . __('New Pagination option default to yes for all lists.', 'amr-users') . '</b></p>';
        if (!isset($amain['show_pagination'])) {
            foreach ($amain['names'] as $i => $n) {
                $amain['show_pagination'][$i] = true;
            }
        }
    }
    $amain['version'] = AUSERS_VERSION;
    ausers_update_option('amr-users-main', $amain);
    // was 'amr-users-no-lists'
    echo '<p>' . __('Finished Update Checks', 'amr-users') . ' ';
    echo ' <a href="http://wordpress.org/extend/plugins/amr-users/changelog/">' . __('Please read the changelog', 'amr-users') . '</a>';
    echo '</p>' . PHP_EOL;
    echo '<br />' . __('As a precaution we will now rebuild the nice names.', 'amr-users');
    echo '<br />' . __('Relax .... you won\'t lose anything.', 'amr-users');
    ameta_rebuildnicenames();
    echo '</div><!-- end updated -->' . PHP_EOL;
}
コード例 #7
0
function amr_build_user_data_maybe_cache($ulist = '1')
{
    //returns the lines of data, including the headings
    global $amr_refreshed_heading;
    // seems heading not used right when we are filtering. workaround for now.
    /* Get the fields to use for the chosen list type */
    global $aopt, $amrusers_fieldfiltering;
    global $amain;
    global $wp_post_types;
    global $time_start;
    global $cache;
    global $amr_current_list;
    $amr_current_list = $ulist;
    if (get_transient('amr_users_cache_' . $ulist)) {
        track_progress('Stop - run for ' . $ulist . ' in progress already according to transient');
        return false;
    }
    //else track_progress('Set in progress flag for '.$ulist);
    set_transient('amr_users_cache_' . $ulist, true, 10);
    // 10 seconds allowed for now
    $network = ausers_job_prefix();
    //	track_progress('Getting data for network='.$network);
    register_shutdown_function('amr_shutdown');
    set_time_limit(360);
    // should we make this an option....
    $time_start = microtime(true);
    ameta_options();
    $date_format = get_option('date_format');
    $time_format = get_option('time_format');
    add_filter('pub_priv_sql_capability', 'amr_allow_count');
    // checked by the get_posts_by_author_sql
    if (!isset($amrusers_fieldfiltering)) {
        $amrusers_fieldfiltering = false;
    }
    if (function_exists('amr_check_for_realtime_filtering')) {
        amr_check_for_realtime_filtering($ulist);
    }
    if (empty($aopt['list'][$ulist])) {
        track_progress('No configuration for list ' . $ulist);
        return false;
    }
    $l = $aopt['list'][$ulist];
    /* *get the config  with any additional filtering */
    $rptid = amr_rptid($ulist);
    if (!$amrusers_fieldfiltering) {
        // then do cache stuff
        /* now record the cache attempt  */
        $cache = new adb_cache();
        $r = $cache->clear_cache($rptid);
        //		If (!($r)) echo '<br />Cache does not exist or not cleared for '.$rptid;
        $r = $cache->record_cache_start($rptid, $amain['names'][$ulist]);
        //		If (!($r)) echo '<br />Cache start not recorded '.$rptid;
        //		$cache->log_cache_event(sprintf(__('Started cacheing report %s','amr-users'),$rptid));
    }
    // end cache
    //track_progress('before get all users needed');
    $list = amr_get_alluserdata($ulist);
    /* keyed by user id, and only the non excluded main fields and the ones that we asked for  */
    $total = count($list);
    //track_progress('after get all user data'.$total);
    $head = '';
    $tablecaption = '';
    if ($total > 0) {
        if (isset($l['selected']) and count($l['selected']) > 0) {
            $head .= PHP_EOL . '<div class="wrap" style ="clear: both; text-align: center; font-size:largest;"><!-- heading wrap -->' . PHP_EOL . '<strong>' . $amain['names'][$ulist] . '</strong>';
            /* to look like wordpress */
            $tablecaption .= '<caption> ' . $amain['names'][$ulist] . '</caption>';
            $head .= '<ul class="report_explanation" style="list-style-type:none;">';
            /* check for filtering */
            if (isset($l['excluded']) and count($l['excluded']) > 0) {
                /* do headings */
                $head .= '<li><em>' . __('Excluding where:', 'amr-users') . '</em> ';
                foreach ($l['excluded'] as $k => $ex) {
                    if (is_array($ex)) {
                        $head .= ' ' . agetnice($k) . '=' . implode(__(' or ', 'amr-users'), $ex) . ',';
                    } else {
                        $head .= ' ' . agetnice($k) . '=' . $ex . ', ';
                    }
                    if (empty($list)) {
                        return;
                    }
                    foreach ($list as $iu => $user) {
                        if (isset($user[$k])) {
                            /* then we need to check the values and exclude the whole user if necessary  */
                            if (is_array($ex)) {
                                if (in_array($user[$k], $ex)) {
                                    unset($list[$iu]);
                                }
                            } else {
                                if ($user[$k] == $ex) {
                                    unset($list[$iu]);
                                }
                            }
                        }
                    }
                }
                $head = rtrim($head, ',');
                $head .= '</li>';
            }
            if (isset($l['excludeifblank']) and count($l['excludeifblank']) > 0) {
                $head .= '<li><em>' . __('Exclude if blank:', 'amr-users') . '</em> ';
                foreach ($l['excludeifblank'] as $k => $tf) {
                    $head .= ' ' . agetnice($k) . ',';
                    if (empty($list)) {
                        return;
                    }
                    foreach ($list as $iu => $user) {
                        /* now check each user */
                        if (empty($user[$k])) {
                            /* if does not exists or empty then we need to check the values and exclude the whole user if necessary  */
                            unset($list[$iu]);
                        }
                    }
                }
                $head = rtrim($head, ',');
                $head .= '</li>';
            }
            //if (WP_DEBUG) track_progress('after excluding users:'.count($list));
            if (isset($l['includeonlyifblank']) and count($l['includeonlyifblank']) > 0) {
                $head .= '<li><em>' . __('Include only if blank:', 'amr-users') . '</em> ';
                foreach ($l['includeonlyifblank'] as $k => $tf) {
                    $head .= ' ' . agetnice($k) . ',';
                    if (empty($list)) {
                        return;
                    }
                    foreach ($list as $iu => $user) {
                        /* now check each user */
                        if (!empty($user[$k])) {
                            /* if does not exists or empty then we need to check the values and exclude the whole user if necessary  */
                            unset($list[$iu]);
                        }
                    }
                }
                $head = rtrim($head, ',');
                $head .= '</li>';
            }
            //if (WP_DEBUG) track_progress('after checking include if blank:'.count($list));
            if (isset($l['included']) and count($l['included']) > 0) {
                $head .= '<li><em>' . __('Including where:', 'amr-users') . '</em> ';
                foreach ($l['included'] as $k => $in) {
                    //if (WP_DEBUG) {echo '<br />Check include:'.$k;var_dump($in);}
                    $inc = implode(__(' or ', 'amr-users'), $in);
                    $head .= ' ' . agetnice($k) . '=' . $inc . ',';
                    //if (WP_DEBUG) {echo '<br />'.$head;}
                    if (!empty($list)) {
                        foreach ($list as $iu => $user) {
                            /* for each user */
                            if (isset($user[$k])) {
                                /* then we need to check the values and include the user if a match */
                                // user[k] could be csv multiple values
                                // inclusions an array, so need to do a like? or a
                                $is_in = false;
                                //if (WP_DEBUG) {echo '<br />Check user:'******',');
                $head .= '</li>';
            }
            //if (WP_DEBUG) {	track_progress('after checking includes '.count($list));//echo '<br />'.$head;				}
            if (isset($l['sortby']) and count($l['sortby']) > 0) {
                $head .= '<li class="sort"><em>' . __(' Cache sorted by: ', 'amr-users') . '</em>';
                /* class used to replace in the front end sort info */
                asort($l['sortby']);
                // sort the sortbys first, so that $cols is in right order
                $cols = array();
                foreach ($l['sortby'] as $sbyi => $sbyv) {
                    if (isset($l['sortdir'][$sbyi])) {
                        //$cols[$sbyi] = array(SORT_DESC);  20111214
                        $cols[$sbyi] = SORT_DESC;
                    } else {
                        //$cols[$sbyi] =  array(SORT_ASC);  20111214
                        $cols[$sbyi] = SORT_ASC;
                    }
                    $head .= agetnice($sbyi) . ',';
                }
                //track_progress('after sortby '.$ulist);
                $head = rtrim($head, ',');
                $head .= '</li>';
                //track_progress('before msort cols =  '.count($cols));
                if (!empty($cols)) {
                    $list = auser_multisort($list, $cols);
                }
                //track_progress('after msort '.$ulist);
            }
            unset($cols);
            if (empty($list)) {
                $tot = 0;
            } else {
                $tot = count($list);
            }
            //track_progress('after sorting '.$tot.' users');
            if ($tot === $total) {
                $text = sprintf(__('All %1s Users processed.', 'amr-users'), $total);
            } else {
                $text = sprintf(__('%1s Users processed from total of %2s', 'amr-users'), $tot, $total);
            }
            //$tottext = 	sprintf(__('%1s records in list', 'amr-users'), $tot);
            $head .= '<li class="selected">' . $text . '</li>';
            $head .= '</ul>' . PHP_EOL . '</div><!-- heading wrap -->' . PHP_EOL;
            //if (WP_DEBUG) {echo '<br />'.$head;}
            $html = $head;
            if (empty($amr_refreshed_heading)) {
                $amr_refreshed_heading = $head;
            } else {
                $amr_refreshed_heading = $head . $amr_refreshed_heading;
            }
            $html = $head;
            $count = 0;
            //now make the fields into columns
            if ($tot > 0) {
                //if (empty($list)) echo '<br />1What happened list is empty ';
                if (!empty($l['grouping'][1])) {
                    $grouping_field = $l['grouping'][1];
                }
                $sel = $l['selected'];
                asort($sel);
                /* get the selected fields in the display  order requested */
                foreach ($sel as $s2 => $sv) {
                    if ($sv > 0) {
                        $sel2[$s2] = $sv;
                    }
                }
                // here we can jump in and save the filter values, if we are NOT already doing a real timefilter
                // if do filtering , then build up filter for values now
                if (!$amrusers_fieldfiltering and function_exists('amr_save_filter_fieldvalues')) {
                    $combofields = amr_get_combo_fields($ulist);
                    if (empty($list)) {
                        echo '<br />What happened list is empty ';
                    }
                    amr_save_filter_fieldvalues($ulist, $list, $combofields);
                }
                /* get the col headings ----------------------------*/
                $lines[0] = amr_build_cols($sel2);
                // tech headings
                $lines[1] = amr_build_col_headings($sel2);
                // the headings lines
                foreach ($lines[1] as $jj => $kk) {
                    if (empty($kk)) {
                        $lines[1][$jj] = '""';
                    } else {
                        $lines[1][$jj] = '"' . str_replace('"', '""', $kk) . '"';
                    }
                    /* Note for csv any quote must be doubleqouoted */
                }
                if (!$amrusers_fieldfiltering) {
                    // then do cache stuff
                    /* cache the col headings ----------------------------*/
                    //$csv = implode (",", $iline);
                    $cache->cache_report_line($rptid, 0, $lines[0]);
                    /* cache the internal column headings */
                    //					$cols = amr_users_get_column_headings  ($ulist, $line, $iline);
                    //$csv = implode (",", $line);
                    $cache->cache_report_line($rptid, 1, $lines[1]);
                    /* cache the column headings */
                    //unset($cols);
                    //unset($line);unset($iline);
                    unset($lines);
                    //track_progress('before cacheing list');
                }
                $count = 1;
                if (!empty($list)) {
                    foreach ($list as $j => $u) {
                        //if (WP_DEBUG) echo '<br />Building list add: '.$j; var_dump($u);;
                        $count = $count + 1;
                        unset($line);
                        if (!empty($u['ID'])) {
                            $line[0] = $u['ID'];
                        } else {
                            $line[0] = '';
                        }
                        foreach ($sel2 as $is => $v) {
                            /* defines the column order */
                            $colno = (int) $v;
                            if (!isset($u[$is])) {
                                $value = '';
                            } else {
                                $value = $u[$is];
                            }
                            /* unfortunately for fields, this must be done here */
                            if (!empty($value)) {
                                if (!empty($l['before'][$is])) {
                                    $value = html_entity_decode($l['before'][$is]) . $value;
                                }
                                if (!empty($l['after'][$is])) {
                                    $value = $value . html_entity_decode($l['after'][$is]);
                                }
                            }
                            if (!empty($line[$colno])) {
                                $line[$colno] .= $value;
                            } else {
                                $line[$colno] = $value;
                            }
                        }
                        if (function_exists('ausers_build_format_column')) {
                            // code to call extra function added as per andy.bounsall request, not yet fully tested by me
                            foreach ($line as $colno => $value) {
                                $line[$colno] = ausers_build_format_column($ulist, $colno, $value);
                            }
                        }
                        /* ******  PROBLEM - ok now? must be at end*/
                        /* *** amr - can we save the grouping field value similar to the index maybe ? */
                        if (!empty($grouping_field) and !empty($u[$grouping_field])) {
                            $line[99998] = $u[$grouping_field];
                        }
                        //							else
                        //								$line[99998] = '';
                        // save the index value if have it
                        if (!empty($u['index'])) {
                            $line[99999] = $u['index'];
                        } else {
                            $line[99999] = '';
                        }
                        $lines[$count] = $line;
                        unset($line);
                    }
                }
                if (empty($lines)) {
                    echo '<br / >Problem - no lines';
                }
                //else if (WP_DEBUG) {echo '<br />'; var_dump($lines);}
                unset($list);
                // do not need list, we got the lines now
                if (!$amrusers_fieldfiltering) {
                    // then do cache stuff
                    $cache->cache_report_lines($rptid, 2, $lines);
                }
            } else {
                $html .= sprintf(__('No users found for list %s', 'amr-users'), $ulist);
            }
        } else {
            $html .= '<h2 style="clear:both; ">' . sprintf(__('No fields chosen for display in settings for list %s', 'amr-users'), $ulist) . '</h2>';
        }
    } else {
        $html .= __('No users in database! - que pasar?', 'amr-users');
    }
    unset($s);
    //track_progress('nearing end');
    if (!$amrusers_fieldfiltering) {
        // if we are not just doing a real time filtering where we will not have full data then do cache stuff
        $cache->record_cache_end($rptid, $count - 1);
        $cache->record_cache_peakmem($rptid);
        $cache->record_cache_headings($rptid, $html);
        $time_end = microtime(true);
        $time = $time_end - $time_start;
        $cache->log_cache_event('<em>' . sprintf(__('Completed %s in %s microseconds', 'amr-users'), $rptid, number_format($time, 2)) . '</em>');
    }
    if (!empty($amain['public'][$ulist])) {
        // returns url if set to go to file
        $csvurl = amr_generate_csv($ulist, true, false, 'csv', '"', ',', chr(13) . chr(10), true);
    }
    delete_transient('amr_users_cache_' . $ulist);
    // so another can run
    //track_progress('Release in progress flag for '.$ulist);
    delete_transient('amr-users-html-for-list-' . $ulist);
    // to force use of new one
    // we built up the html when filtering, but then trashed again ?
    if (!empty($lines)) {
        return $lines;
    } else {
        return false;
    }
}
コード例 #8
0
function amr_users_deactivation()
{
    global $amain;
    if (function_exists('wp_clear_scheduled_hook')) {
        wp_clear_scheduled_hook('amr_regular_reportcacheing');
        foreach ($amain['names'] as $i => $name) {
            wp_clear_scheduled_hook('amr_reportcacheing', array('report' => $i));
        }
    }
    $c = new adb_cache();
    $c->deactivate();
}
コード例 #9
0
function amr_meta_reset()
{
    global $aopt;
    global $amain;
    global $amr_nicenames, $ausersadminurl;
    if (ausers_delete_option('amr-users')) {
        echo '<h2>' . __('Deleting number of lists and names in database', 'amr-users') . '</h2>';
    }
    //	else echo '<h3>'.__('Error deleting number of lists and names in database.','amr-users').'</h3>';
    if (ausers_delete_option('amr-users-main')) {
        echo '<h2>' . __('Deleting all main settings in database', 'amr-users') . '</h2>';
    }
    //	else echo '<h3>'.__('Error deleting all lists settings in database','amr-users').'</h3>';
    if (ausers_delete_option('amr-users-nicenames')) {
        echo '<h2>' . __('Deleting all nice name settings in database', 'amr-users') . '</h2>';
    }
    if (ausers_delete_option('amr-users-nicenames-excluded')) {
        echo '<h2>' . __('Deleting all nice name exclusion settings in database', 'amr-users') . '</h2>';
    }
    if (ausers_delete_option('amr-users-show-in-wplist')) {
        echo '<h2>' . __('Deleting the show in wp list settings', 'amr-users') . '</h2>';
    }
    //	else echo '<h3>'.__('Error deleting all lists settings in database','amr-users').'</h3>';
    if (ausers_delete_option('amr-users-cache-status')) {
        echo '<h2>' . __('Deleting cache status in database', 'amr-users') . '</h2>';
    }
    if (ausers_delete_option('amr-users-original-keys')) {
        echo '<h2>' . __('Deleting original keys mapping in database', 'amr-users') . '</h2>';
    }
    if (ausers_delete_option('amr-users-custom-headings')) {
        echo '<h2>' . __('Deleting custom-headings in database', 'amr-users') . '</h2>';
    }
    if (ausers_delete_option('amr-users-filtering')) {
        echo '<h2>' . __('Deleting amr-users-filtering in database', 'amr-users') . '</h2>';
    }
    if (ausers_delete_option('amr-users-prefixes-in-use')) {
        echo '<h2>' . __('Deleting amr-users-prefixes-in-use in database', 'amr-users') . '</h2>';
    }
    $c = new adb_cache();
    //$c->clear_all_cache();
    $c->deactivate();
    echo '<h2>' . __('All cached listings cleared.', 'amr-users') . '</h2>';
    unset($aopt);
    unset($amain);
    unset($amr_nicenames);
    echo '<h2><a href="' . $ausersadminurl . '?page=ameta-admin-general.php&tab=fields' . '">' . __('Click to find your user fields again.', 'amr-users') . '</a></h2>';
    die;
}
コード例 #10
0
function amr_get_csv_lines($ulist)
{
    /* get the whole cached file - write to file? but security / privacy ? */
    /* how big */
    $c = new adb_cache();
    $rptid = $c->reportid($ulist);
    //$total = $c->get_cache_totallines ($rptid );  // nlr should rather pass 0 to get all
    $lines = $c->get_cache_report_lines($rptid, 0, 0);
    if (empty($lines)) {
        return false;
    }
    // 20140722 no headings lines at moment either
    $headinglines = $c->get_column_headings($rptid);
    array_unshift($lines, $headinglines[1]);
    //$lines = $c->get_cache_report_lines($rptid,0,$total);
    /* we want the heading line (line1), but not the internal nameslines (line 0) , 
    	plus all the data lines, so neeed total + 1 */
    return $lines;
}
コード例 #11
0
function alist_one($type = 'user', $ulist = 1, $options)
{
    //options  can be headings, csv, show_search, show_perpage
    /* Get the fields to use for the chosen list type */
    global $aopt, $amain, $amrusers_fieldfiltering, $amr_current_list, $amr_search_result_count;
    global $amr_refreshed_heading;
    if (empty($aopt['list'][$ulist])) {
        printf(__('No such list: %s', 'amr-users'), $ulist);
        return;
    }
    $l = $aopt['list'][$ulist];
    /* *get the config */
    do_action('amr-add-criteria-to-list', $ulist);
    // allows one to force criteria into the request field for example (eg: show only logged in user)
    $transient_suffix = amr_check_use_transient($ulist, $options);
    if ($transient_suffix) {
        // no filters, no search, no sort, nothing special happening
        //if (WP_DEBUG) echo '<br />using transient: '.$transient_suffix.'<br />';
        $html = get_transient('amr-users-html-for-list-' . $transient_suffix);
        if (!empty($html)) {
            if (current_user_can('administrator')) {
                echo '<br /><a href="' . add_query_arg('refresh', '1') . '" title="' . __('Note to logged in admin only: Now using temporary saved html (transient) for frontend.  Click to refresh.', 'amr-users') . '">!</a>';
            }
            return $html;
        }
    }
    $caption = '';
    $sortedbynow = '';
    if (empty($amain['list_rows_per_page'][$ulist])) {
        $amain['list_rows_per_page'][$ulist] = $amain['rows_per_page'];
    }
    $rowsperpage = amr_rows_per_page($amain['list_rows_per_page'][$ulist]);
    // will check request
    //  use $options as our 'request' input so shortcode parameters will work.
    // allow _REQUEST to override $options
    /*$request_override_allowed = array(
    		'filter',
    		'fieldvaluefilter',
    		'fieldnamefilter',
    		'sort'); */
    foreach ($_REQUEST as $param => $value) {
        // we do not know the column names, so jsut transfer all?
        $options[$param] = $value;
    }
    // figure out what we are doing - searching, filtering -------------------------------------------------------
    $search = '';
    if (!empty($options['su'])) {
        $search = strip_tags($options['su']);
    } elseif (isset($_REQUEST['clear_filtering'])) {
        // we do not need these then
        unset($_REQUEST['fieldnamefilter']);
        unset($_REQUEST['fieldvaluefilter']);
        unset($_REQUEST['filter']);
        //do we neeed to unset the individual cols? maybe not
    }
    $amrusers_fieldfiltering = false;
    if (!empty($options['filter'])) {
        //if (WP_DEBUG) {echo '<h1>Filtering</h1>';}
        foreach (array('fieldnamefilter', 'fieldvaluefilter') as $i => $filtertype) {
            if (isset($options[$filtertype])) {
                //if (WP_DEBUG) {echo '<br />doing: '.$filtertype;}
                foreach ($options[$filtertype] as $i => $col) {
                    if (empty($options[$col])) {
                        //ie showing all
                        unset($options[$filtertype][$i]);
                        unset($options[$col]);
                    } else {
                        $amrusers_fieldfiltering = true;
                    }
                    // set as we are maybe doing realtime filtering flag
                }
            }
        }
    }
    $c = new adb_cache();
    $rptid = $c->reportid($ulist, $type);
    if ($amrusers_fieldfiltering) {
        $lines = amr_build_user_data_maybe_cache($ulist);
        // since we are filtering, we will run realtime, but not save, else we would lose the normal report
        if (empty($lines)) {
            return;
        }
        $totalitems = count($lines);
        //if (WP_DEBUG) echo '<br /> field filtering & $totalitems='.$totalitems;
    } else {
        if (!$c->cache_exists($rptid) or isset($options['refresh'])) {
            if (amr_debug()) {
                _e('If debug only: Either refresh requested OR no cache exists.  A rebuild will be initiated .... ', 'amr-users');
            }
            $success = amr_try_build_cache_now($c, $ulist, $rptid);
            //$lines = amr_build_user_data_maybe_cache($ulist);
            $totalitems = $c->get_cache_totallines($rptid);
            //now need the lines, but first, paging check will tell us how many
            $amrusers_fieldfiltering = false;
            // already done if it must be
        } else {
            $totalitems = $c->get_cache_totallines($rptid);
        }
    }
    //---------- setup paging variables
    if ($totalitems < 1) {
        _e('No lines found.', 'amr-users');
        echo amr_users_get_refresh_link($ulist);
        return;
    }
    if ($rowsperpage > $totalitems) {
        $rowsperpage = $totalitems;
    }
    $lastpage = ceil($totalitems / $rowsperpage);
    if (!empty($_REQUEST['listpage'])) {
        // if we requested a page MUST use that
        $page = (int) $_REQUEST['listpage'];
    } else {
        // is a random page stipulated ?
        if (isset($options['show_randompage'])) {
            // allows a random page
            $page = rand(1, $lastpage);
        } else {
            // else.....start at the very beginning, a very good place to start...
            $page = 1;
        }
    }
    if ($page > $lastpage) {
        $page = $lastpage;
    }
    if ($page == 1) {
        $start = 1;
    } else {
        $start = 1 + ($page - 1) * $rowsperpage;
    }
    $shuffle = false;
    if (!empty($options['shuffle'])) {
        $shuffle = true;
    }
    $filtercol = array();
    //------------------------------------------------------------------------------------------		get the data
    if (!$amrusers_fieldfiltering) {
        // because already have lines if were doing field level filtering
        $headinglines = $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($headinglines[0]['csvcontent'], ',', '"', '\\');
        } else {
            $icols = str_getcsv($headinglines[0]['csvcontent'], ',', '"', '\\');
        }
        $icols = array_unique($icols);
        //since may end up with two indices, eg if filtering and grouping by same value
        if (!defined('str_getcsv')) {
            $cols = amr_str_getcsv($headinglines[1]['csvcontent'], '","', '"', '\\');
        } else {
            $cols = str_getcsv($headinglines[1]['csvcontent'], ',', '"', '\\');
        }
        if (isset($options['filter']) or !empty($options['sort']) or !empty($options['su'])) {
            $lines = amr_get_lines_to_array($c, $rptid, 2, $totalitems + 1, $icols, $shuffle);
        } else {
            if (isset($options['start_empty'])) {
                $lines = array();
                $totalitems = 0;
            } else {
                $lines = amr_get_lines_to_array($c, $rptid, $start + 1, $rowsperpage, $icols, $shuffle);
            }
        }
    } else {
        // we are field filtering
        unset($lines[0]);
        // the tech lines and the headings line
        unset($lines[1]);
        $totalitems = count($lines);
        // must be here, only reset for field filtering
        $s = $l['selected'];
        asort($s);
        /* get the selected fields in the display  order requested */
        $cols = amr_build_col_headings($s);
        $icols = amr_build_cols($s);
        foreach ($lines as $i => $j) {
            $lines[$i] = amr_convert_indices($j, $icols);
        }
    }
    //------------------------------------------------------------------------------------------		display time filter check
    if (isset($options['filter'])) {
        // then we are filtering
        //if (amr_debug()) {
        //	var_dump($options['filter']);
        //	echo '<br />Check for filtering at display time <br />'; var_dump($icols);
        //	}
        foreach ($icols as $cindex => $col) {
            if (!empty($options[$col])) {
                if (!(isset($options['fieldnamefilter']) and in_array($col, $options['fieldnamefilter'])) and !(isset($options['fieldvaluefilter']) and in_array($col, $options['fieldvaluefilter']))) {
                    $filtercol[$col] = esc_attr($options[$col]);
                }
            }
        }
        if (!empty($options['index'])) {
            $filtercol['index'] = strip_tags($options['index']);
        }
        if (false and !$amrusers_fieldfiltering and empty($filtercol) and current_user_can('manage_options')) {
            //NO LONGER REQUIRED, keep for debug only helpful maybe message nlr or perhaps only if by url?  But could be trying own html? and be confused
            echo '<p>';
            _e('This Message shows to admin only!', 'amr-users');
            echo '<br />';
            _e('Filter requested.', 'amr-users');
            _e('Maybe you chose "show all", which is OKAY... or are attempting some own html or link ? .', 'amr-users');
            echo '<br />';
            _e('No valid filter column given.', 'amr-users');
            echo '<br />';
            _e('Column filter Usage is :', 'amr-users');
            echo '<br /><strong>';
            echo '?filter=hide&column_name=value<br />';
            echo '?filter=show&column_name=value</br> ';
            echo '?filter=1&column_name=value';
            echo '</strong></br> ';
            _e('Note: Hide only works if the column is currently being displayed.', 'amr-users');
            _e('For this list, expecting column_name to be one of ', 'amr-users');
            echo '<br />' . implode('<br />', $icols) . '<br />';
            echo '</p>';
        }
        if (!empty($filtercol)) {
            // for each of the filter columns that are not field filters
            foreach ($filtercol as $fcol => $value) {
                //if (amr_debug()) {echo '<hr>Apply filters for field "'.$fcol. '" against... '.$value; }
                foreach ($lines as $i => $line) {
                    //if (WP_DEBUG) {echo '<br>line=';  var_dump($line);}
                    if ($value === '*') {
                        if (empty($line[$fcol])) {
                            unset($lines[$i]);
                        } else {
                        }
                    } elseif ($value === '-') {
                        if (!empty($line[$fcol])) {
                            unset($lines[$i]);
                        } else {
                        }
                    } elseif (empty($line[$fcol])) {
                        unset($lines[$i]);
                    } else {
                        if ($fcol == 'ID') {
                            // id can have  filtering  - allows link to profile page
                            if (!($line[$fcol] == $value)) {
                                /// amr ??
                                unset($lines[$i]);
                            }
                        } else {
                            if (!strstr($line[$fcol], $value)) {
                                // fuzzy filtering - hmm why - maybe not???
                                // is it to avoid situation where value may have spaces before/after ???
                                unset($lines[$i]);
                            }
                        }
                    }
                    //else if (!($line[$fcol] == $value)) {  strisstr will catch these ?
                    //}
                    if ($options['filter'] == 'hide') {
                        unset($lines[$i][$fcol]);
                    }
                }
                // if hiding, delete that column
                if ($options['filter'] == 'hide') {
                    foreach ($icols as $cindex => $col) {
                        if ($fcol == $col) {
                            unset($icols[$cindex]);
                            unset($cols[$cindex]);
                        }
                    }
                }
                // end delete col
                //if (WP_DEBUG) echo '<br />Lines left '.count($lines);
            }
            //-----------------------------------------------------------------------------
            $amr_search_result_count = count($lines);
            $totalitems = $amr_search_result_count;
            // slice the right section of the returned values based on rowsperpage and currentpage
            // update the paging variables
            if ($amr_search_result_count > 0 and $rowsperpage > $amr_search_result_count) {
                $rowsperpage = $amr_search_result_count;
            }
            $lastpage = ceil($amr_search_result_count / $rowsperpage);
            if ($page > $lastpage) {
                $page = $lastpage;
            }
            if ($page == 1) {
                $start = 1;
            } else {
                $start = 1 + ($page - 1) * $rowsperpage;
            }
        }
        //echo '<br />count lines = '.$amr_search_result_count. ' '.$start. ' '. $rowsperpage;
        $lines = array_slice($lines, $start - 1, $rowsperpage, true);
    }
    //end if
    //------------------------------------------------------------------------------------------	 check for sort or search
    if (!empty($options['sort']) or !empty($search)) {
        /* then we want to sort, so have to fetch ALL the lines first and THEN sort.  Keep page number in case workingthrough the list  ! */
        // if searching also want all the lines first so can search within and do pagination correctly
        if ($lines) {
            $linesunsorted = amr_check_for_sort_request($lines);
            $linesunsorted = array_values($linesunsorted);
            /* reindex as our indexing is stuffed and splice will not work properly */
            //if (!empty($search)) $totalitems = count($linesunsorted);	//save total here before splice
            $lines = array_splice($linesunsorted, $start - 1, $rowsperpage);
            unset($linesunsorted);
            // free up memory?
            /* now fix the cache headings*/
            $sortedbynow = '';
            if (!empty($options['sort'])) {
                foreach ($icols as $i => $t) {
                    if ($t == $options['sort']) {
                        $sortedbynow = strip_tags($cols[$i]);
                    }
                }
                $sortedbynow = '<li><em>' . __('Sorted by:', 'amr-users') . '</em>' . $sortedbynow . '</li><li class="sort">';
            }
        }
    }
    //------------------------------------------------------------------------------------------------------------------finished filtering and sorting
    //var_dump($lines);
    $html = amr_display_final_list($lines, $icols, $cols, $page, $rowsperpage, $totalitems, $caption, $search, $ulist, $c, $filtercol, $sortedbynow, $options);
    if ($transient_suffix) {
        // ie no filters, no search, no sort, nothing special happening
        $expiration = empty($amain['transient_expiration']) ? 60 : $amain['transient_expiration'];
        //allow setting later
        set_transient('amr-users-html-for-list-' . $transient_suffix, $html, $expiration);
        track_progress('Transient set for html for list ' . $transient_suffix);
    }
    return $html;
}
コード例 #12
0
function amr_rebuildwarning($list)
{
    $logcache = new adb_cache();
    if ($logcache->cache_in_progress($logcache->reportid($list, 'user'))) {
        $text = sprintf(__('Cache of %s already in progress', 'amr-users'), $list);
        $logcache->log_cache_event($text);
        echo $text;
        return;
    } else {
        $text = $logcache->cache_already_scheduled($list);
        if (!empty($text)) {
            $new_text = __('Report ', 'amr-users') . $list . ': ' . $text;
            $logcache->log_cache_event($new_text);
            amr_users_message($new_text);
            //return;	 - let it run anyway
        }
    }
    echo alist_rebuildreal($list);
    return;
}
コード例 #13
-1
function amr_handle_copy_delete()
{
    global $amain, $aopt;
    if (!current_user_can('administrator')) {
        _e('Inadequate access', 'amr-users');
        return;
    }
    if (isset($_GET['copylist'])) {
        $source = (int) $_REQUEST['copylist'];
        if (!isset($amain['names'][$source])) {
            echo 'Error copying list ' . $source;
        }
        $next = 1;
        // get the current max index
        foreach ($amain['names'] as $j => $name) {
            $next = max($next, $j);
        }
        $next = $next + 1;
        //
        foreach ($amain as $j => $setting) {
            if (is_array($setting)) {
                echo '<br />copying ' . $j . ' from list ' . $source;
                if (!empty($amain[$j][$source])) {
                    $amain[$j][$next] = $amain[$j][$source];
                }
            }
        }
        $amain['names'][$next] .= __(' - copy', 'amr-users');
        $amain['no-lists'] = count($amain['names']);
        if (!empty($aopt['list'][$source])) {
            echo '<br />copying settings from list ' . $source;
            $aopt['list'][$next] = $aopt['list'][$source];
        }
        ausers_update_option('amr-users-main', $amain);
        ausers_update_option('amr-users', $aopt);
    } elseif (isset($_GET['deletelist'])) {
        $source = (int) $_REQUEST['deletelist'];
        if (!isset($amain['names'][$source])) {
            amr_users_message(sprintf(__('Error deleting list %S', 'amr-users'), $source));
        } else {
            foreach ($amain as $j => $setting) {
                if (is_array($setting)) {
                    //if (WP_DEBUG) echo '<br />deleting '.$j.' from list '.$source;
                    if (isset($amain[$j][$source])) {
                        unset($amain[$j][$source]);
                    }
                }
            }
        }
        $amain['no-lists'] = count($amain['names']);
        if (!empty($aopt['list'][$source])) {
            unset($aopt['list'][$source]);
        }
        $acache = new adb_cache();
        $acache->clear_cache($acache->reportid($source));
        ausers_update_option('amr-users-main', $amain);
        ausers_update_option('amr-users', $aopt);
        amr_users_message(__('List and the cache deleted.', 'amr-users'));
    }
}