Esempio n. 1
0
 function _get_epoch_dataplus_ips()
 {
     // ips
     if (!($epoch_dataplus_ips = get_transient('mgm_epoch_dataplus_ips'))) {
         // init
         $epoch_dataplus_ips = array();
         // check
         if ($ip_list = mgm_remote_get('https://epoch.com/ip_list.php', null, null, 'CONNECT_ERROR')) {
             // check
             if ($ip_list != 'CONNECT_ERROR') {
                 $epoch_dataplus_ips = explode('|', $ip_list);
             }
         }
         // known
         if (empty($epoch_dataplus_ips)) {
             $epoch_dataplus_ips = explode('|', '174.129.249.162|65.17.248.|68.71.103.|184.73.155.222|184.72.56.152|184.72.56.199|184.73.192.230');
         }
         // set cache
         set_transient('mgm_epoch_dataplus_ips', $epoch_dataplus_ips, mgm_time2second('1 DAY'));
         // log
         mgm_log($epoch_dataplus_ips, __FUNCTION__);
     }
     // return
     return $epoch_dataplus_ips;
 }
/**
 * Fetch widget related data from db
 * @param string $type
 *   membership_count/status_count
 * @return array()
 */
function mgm_get_dashboard_widget_data($type)
{
    // Fetch mgm_widget_data from db
    // $data = get_option('mgm_widget_data');
    // use transient to save cron load
    if (!($widget_data = get_transient('mgm_dashboard_widget_data'))) {
        // generate
        $widget_data = mgm_set_dashboard_widget_data();
        // set cache
        set_transient('mgm_dashboard_widget_data', $widget_data, mgm_time2second('1 HOUR'));
    }
    // return asked $type of data
    if (isset($widget_data[$type])) {
        return $widget_data[$type];
    }
    return array();
}