Пример #1
0
 function _load_data()
 {
     $save = false;
     $data = get_option('plugin_advman');
     if (!empty($data)) {
         if (version_compare($data['settings']['version'], ADVMAN_VERSION, '<')) {
             include_once ADVMAN_LIB . '/Upgrade.php';
             Advman_Upgrade::upgrade_advman($data);
             $save = true;
         }
     } else {
         $data = get_option('plugin_adsensem');
         if (!empty($data)) {
             include_once ADVMAN_LIB . '/Upgrade.php';
             Advman_Upgrade::upgrade_adsensem($data);
             $save = true;
         }
     }
     if (empty($data)) {
         $data['ads'] = array();
         $data['networks'] = array();
         $data['settings'] = array();
         $data['settings']['next_ad_id'] = 1;
         $data['settings']['default-ad'] = '';
         $data['settings']['version'] = ADVMAN_VERSION;
         $data['settings']['openx-sync'] = true;
         $data['settings']['publisher-id'] = md5(uniqid('', true));
         $data['settings']['enable-php'] = false;
         $data['settings']['purge-stats-days'] = 30;
         $data['settings']['stats'] = true;
         $data['stats'] = array();
         $save = true;
     }
     if (!empty($data['stats'])) {
         $oldest = time() - $data['settings']['purge-stats-days'] * 24 * 60 * 60;
         foreach ($data['stats'] as $day => $stat) {
             $ts = strtotime($day);
             if ($ts < $oldest) {
                 unset($data['stats'][$day]);
                 $save = true;
             }
         }
     }
     if ($save) {
         update_option('plugin_advman', $data);
     }
     $this->_map_objects($data);
     return $data;
 }
Пример #2
0
 static function notice_action($action)
 {
     // Activate advertising manager
     if ($action == 'activate advertising-manager') {
         Advman_Admin::remove_notice('activate advertising-manager');
     }
     // Learn more about Adjs beta
     if ($action == 'adjs-beta') {
         if (OX_Tools::sanitize_post_var('advman-notice-confirm-yes')) {
             wp_redirect(admin_url('options-general.php?page=advman-settings'));
         }
         Advman_Admin::remove_notice('adjs-beta');
     }
     // Update shortcodes
     if ($action == 'update_shortcodes') {
         if (OX_Tools::sanitize_post_var('advman-notice-confirm-yes')) {
             include_once ADVMAN_LIB . '/Upgrade.php';
             Advman_Upgrade::update_shortcodes();
             Advman_Admin::add_notice('advman-notice-once', __("Ad shortcodes updated"), false);
         }
         Advman_Admin::remove_notice('update_shortcodes');
     }
 }
Пример #3
0
 static function _get_code(&$ad)
 {
     $code = '';
     switch (strtolower($ad['class'])) {
         case 'ox_plugin_adbrite':
             $code = Advman_Upgrade::_get_code_adbrite($ad);
             break;
         case 'ox_plugin_adgridwork':
             $code = Advman_Upgrade::_get_code_adgridwork($ad);
             break;
         case 'ox_plugin_adpinion':
             $code = Advman_Upgrade::_get_code_adpinion($ad);
             break;
         case 'ox_plugin_adroll':
             $code = Advman_Upgrade::_get_code_adroll($ad);
             break;
         case 'ox_plugin_adsense':
             $code = Advman_Upgrade::_get_code_adsense($ad);
             break;
         case 'ox_plugin_cj':
             $code = Advman_Upgrade::_get_code_cj($ad);
             break;
         case 'ox_plugin_crispads':
             $code = Advman_Upgrade::_get_code_crispads($ad);
             break;
         case 'ox_plugin_openx':
             $code = Advman_Upgrade::_get_code_openx($ad);
             break;
         case 'ox_plugin_shoppingads':
             $code = Advman_Upgrade::_get_code_shoppingads($ad);
             break;
         case 'ox_plugin_widgetbucks':
             $code = Advman_Upgrade::_get_code_widgetbucks($ad);
             break;
         case 'ox_plugin_ypn':
             $code = Advman_Upgrade::_get_code_ypn($ad);
             break;
     }
     if (!empty($code)) {
         $oAd = new $ad['class']();
         $oAd->import_settings($code);
         foreach ($oAd->p as $property => $value) {
             $ad[$property] = $value;
         }
     }
 }
Пример #4
0
 function _load_data()
 {
     $save = false;
     // Load the data into an array
     $data = get_option('plugin_advman');
     // old way of saving data
     if (empty($data)) {
         $data = array();
         // Get settings data
         $d = get_option('plugin_advman_settings');
         if (empty($d)) {
             $d = array('next_ad_id' => 1, 'default-ad' => '', 'version' => ADVMAN_VERSION, 'enable-php' => false, 'purge-stats-days' => 30, 'stats' => true);
             $save = true;
         }
         $data['settings'] = $d;
         // Get ads data
         $d = get_option('plugin_advman_ads');
         if (empty($d)) {
             $d = array();
             $save = true;
         }
         $data['ads'] = $d;
         // Get networks data
         $d = get_option('plugin_advman_networks');
         if (empty($d)) {
             $d = array();
             $save = true;
         }
         $data['networks'] = $d;
         // Get stats data
         $d = get_option('plugin_advman_stats');
         if (empty($d)) {
             $d = array();
             $save = true;
         }
         $data['stats'] = $d;
     }
     if (version_compare($data['settings']['version'], ADVMAN_VERSION, '<')) {
         include_once ADVMAN_LIB . '/Upgrade.php';
         Advman_Upgrade::upgrade_advman($data);
         $save = true;
     }
     if (!empty($data['stats'])) {
         $oldest = time() - $data['settings']['purge-stats-days'] * 24 * 60 * 60;
         foreach ($data['stats'] as $day => $stat) {
             $ts = strtotime($day);
             if ($ts < $oldest) {
                 unset($data['stats'][$day]);
                 $save = true;
             }
         }
     }
     if ($save) {
         update_option('plugin_advman_settings', $data['settings']);
         update_option('plugin_advman_ads', $data['ads']);
         update_option('plugin_advman_networks', $data['networks']);
         update_option('plugin_advman_stats', $data['stats']);
     }
     $this->_map_objects($data);
     return $data;
 }