v2.x > v3.x */ if (version_compare($_advman['version'], '3.0', '<')) { advman_upgrade::v2_x_to_3_0(); $upgraded = true; } if (version_compare($_advman['version'], '3.3.4', '<')) { advman_upgrade::v3_0_to_3_3_4(); $optimiseMsg = true; $upgraded = true; } if (version_compare($_advman['version'], '3.3.8', '<')) { advman_upgrade::v3_3_4_to_3_3_8(); $upgraded = true; } if (version_compare($_advman['version'], '3.3.10', '<')) { advman_upgrade::v3_3_10(); $upgraded = true; } if ($upgraded) { //Write notice, ONLY IF UPGRADE HAS OCCURRED if ($optimiseMsg) { advman::add_notice('optimise','Advertising Manager has been upgraded from Adsense Manager. Enable auto optimisation? (RECOMMENDED)','yn'); } $_advman['version'] = ADVMAN_VERSION; update_option('plugin_adsensem', $_advman); } } function v3_3_10() { global $_advman; if (!empty($_advman['defaults'])) { foreach ($_advman['defaults'] as $n => $default) { $counter = ''; if ($n == 'OX_Adnet_Adsense') { $counter = '3'; } $_advman['defaults'][$n]['counter'] = $counter; } } } function v3_3_4_to_3_3_8() { global $_advman; $_advman['settings']['openx-sync'] = true; $_advman['uuid'] = $viewerId = md5(uniqid('', true)); } function v3_0_to_3_3_4() { global $_advman; $old = $_advman; // New / Old class structure mapping $adnets = array( 'ad_adbrite' => 'OX_Adnet_Adbrite', 'ad_adgridwork' => 'OX_Adnet_Adgridwork', 'ad_adpinion' => 'OX_Adnet_Adpinion', 'ad_adroll' => 'OX_Adnet_Adroll', 'ad_adsense' => 'OX_Adnet_Adsense', 'ad_adsense_ad' => 'OX_Adnet_Adsense', 'ad_adsense_classic' => 'OX_Adnet_Adsense', 'ad_adsense_link' => 'OX_Adnet_Adsense', 'ad_adsense_referral' => 'OX_Adnet_Adsense', 'ad_cj' => 'OX_Adnet_Cj', 'ad_code' => 'OX_Adnet_Html', 'ad_crispads' => 'OX_Adnet_Crispads', 'ad_openx_adserver' => 'OX_Adnet_Openx', 'ad_shoppingads' => 'OX_Adnet_Shoppingads', 'ad_widgetbucks' => 'OX_Adnet_Widgetbucks', 'ad_ypn' => 'OX_Adnet_Ypn', ); // Change defaults to new class structure if (!empty($_advman['defaults'])) { $new = array(); $defaults = $_advman['defaults']; foreach ($defaults as $n => $default) { if (!empty($adnets[$n])) { // Set the new class structure $new[$adnets[$n]] = $_advman['defaults'][$n]; // Set OpenX Market participation if (!isset($new[$adnets[$n]]['openx-market'])) { $new[$adnets[$n]]['openx-market'] = 'no'; } // Set OpenX Market eCPM if (!isset($new[$adnets[$n]]['openx-market-cpm'])) { $new[$adnets[$n]]['openx-market-cpm'] = '0.20'; } // Set Weight if (!isset($new[$adnets[$n]]['weight'])) { $new[$adnets[$n]]['weight'] = '1'; } // Show only to an Author if (!isset($new[$adnets[$n]]['show-author'])) { $new[$adnets[$n]]['show-author'] = 'all'; } // Show only for a Category if (!isset($new[$adnets[$n]]['show-category'])) { $new[$adnets[$n]]['show-category'] = 'all'; } // Set height and width for an ad format if (!empty($new[$adnets[$n]]['adformat']) && ($new[$adnets[$n]]['adformat'] != 'custom')) { list($width, $height) = split('[x]', $new[$adnets[$n]]['adformat']); if (is_numeric($width)) { $new[$adnets[$n]]['width'] = $width; } if (is_numeric($height)) { $new[$adnets[$n]]['height'] = $height; } } } } $_advman['defaults'] = $new; } // Change account IDs to new class structure // We are going to change it to something later, but we need it this way for ad conversions... if (!empty($_advman['account-ids'])) { $new = array(); $accounts = $_advman['account-ids']; foreach ($accounts as $n => $account) { if (!empty($adnets[$n])) { // Set the new class structure $new[$adnets[$n]] = $_advman['account-ids'][$n]; } } $_advman['account-ids'] = $new; } if (!empty($_advman['ads'])) { $new = array(); $id = 1; $ads = $_advman['ads']; // Next, make sure that the classes and properties are ok. foreach ($ads as $n => $ad) { $oldClass = ''; if (get_class($ad) == '__PHP_Incomplete_Class') { $a = null; // Ugly hack - for some reason I cannot call $ad->__PHP_Incomplete_Class_Name directly foreach ($ad as $key => $value) { if ($key == '__PHP_Incomplete_Class_Name') { $class = strtolower($value); $oldClass = $class; if (!empty($adnets[$class])) { $a = new $adnets[$class]; break; } } } if ($a) { foreach ($ad as $key => $value) { switch ($key) { case 'id' : $a->id = $value; break; case 'name' : $a->name = $value; break; case 'p' : $a->p = $value; break; case 'title' : $a->title = $value; break; } } $ad = $a; } } if (empty($ad->id)) { $ad->id = $id; } else { $id = ($ad->id > $id ? $ad->id : $id); } if (empty($ad->name)) { $ad->name = $n; } // Make sure width and height is set correctly $width = $ad->get('width'); $height = $ad->get('height'); if (empty($width) || empty($height)) { $format = $ad->get('adformat'); if ( !empty($format) && ($format != 'custom')) { list($width, $height, $null) = split('[x]', $format); $ad->set('width', $width); $ad->set('height', $height); } } // Make sure that any settings under 'color-url' are now under 'color-link' $colorUrl = $ad->get('color-url'); $colorLink = $ad->get('color-link'); if (!empty($colorUrl) && empty($colorLink)) { $ad->set('color-link', $colorUrl); $ad->set('color-url', null); } // Re-import code because it was not saved in previous versions if ($ad->network != 'OX_Adnet_Html') { $code = call_user_func(array('advman_upgrade', '_render_' . $oldClass), $ad); $ad->import_settings($code); } // Set the new active field $ad->active = true; // Need to set this ad as active in order for this ad to display // Set market optimisation $ad->set('openx-market', false); $ad->set('openx-market-cpm', '0.20'); $ad->set('weight', '1'); // Changed the 'hide link url' field to 'status' (for cj ads) $hideLinkUrl = $ad->get('hide-link-url'); if (!empty($hideLinkUrl)) { $ad->set('status', $hideLinkUrl); $ad->set('hide-link-url', null); } // Got rid of the 'Code Method' field in Crisp Ads $ad->set('codemethod', null); // Get rid of the 'default_ad' field (should be 'default-ad') $ad->set('default_ad', null); $new[$ad->id] = $ad; $id++; } $_advman['ads'] = $new; $_advman['next_ad_id'] = $id; } // Move account IDs inside the ad array if (!empty($_advman['account-ids'])) { foreach ($_advman['account-ids'] as $class => $accountId) { foreach ($_advman['ads'] as $id => $ad) { if ($class == get_class($ad)) { $exitingAccountId = $ad->get('account-id'); if (empty($exitingAccountId)) { $_advman['ads'][$id]->set('account-id', $accountId); } } } } } // Be nice does not exist anymore if (!empty($_advman['be-nice'])) { unset($_advman['be-nice']); } if (!empty($_advman['benice'])) { unset($_advman['benice']); } // Remove the networks node if (!empty($_advman['networks'])) { unset($_advman['networks']); } } function v2_x_to_3_0(){ global $_advman; $old=$_advman; /* VERSION 3.x */ $_advman['ads'] = array(); $_advman['be-nice'] = $old['benice']; $_advman['default-ad'] = $old['defaults']['ad']; $_advman['defaults']=array(); $_advman['defaults']['ad_adsense_classic']=advman_upgrade::_process_v2_x_to_3_0($old['defaults']); $_advman['defaults']['ad_adsense']=$_advman['defaults']['ad_adsense_classic']; /* Copy AdSense account-id to both class/new settings */ $_advman['account-ids']['ad_adsense']=$old['adsense-account']; /* Now all that remains is to convert the ads. In 2.x ads were stored as simply arrays containing the options. To upgrade create new objects using product/slot/etc. info, or for code units run an import cycle. */ if(is_array($old['ads'])){ foreach($old['ads'] as $oname=>$oad){ if($oad['slot']!=''){$type='slot';} else {$type=$oad['product'];} $name=advman_admin::generate_name($oname); switch($type){ /* HTML Code Ads */ case 'code': $ad=advman_admin::import_ad($oad['code']); $_advman['ads'][$name]=$ad; $_advman['ads'][$name]->name=$name; break; /* AdSense Slot Ads */ case 'slot': $ad=new Ad_AdSense(); $_advman['ads'][$name]=$ad; $_advman['ads'][$name]->name=$name; $_advman['ads'][$name]->p=advman_upgrade::_process_v2_x_to_3_0($oad); break; /* AdSense Ad */ case 'ad': $ad=new Ad_AdSense_Ad(); $_advman['ads'][$name]=$ad; $_advman['ads'][$name]->name=$name; $_advman['ads'][$name]->p=advman_upgrade::_process_v2_x_to_3_0($oad); break; case 'link': $ad=new Ad_AdSense_Link(); $_advman['ads'][$name]=$ad; $_advman['ads'][$name]->name=$name; $_advman['ads'][$name]->p=advman_upgrade::_process_v2_x_to_3_0($oad); break; case 'referral': case 'referral-image': case 'referral-text': $ad=new Ad_AdSense_Referral(); $_advman['ads'][$name]=$ad; $_advman['ads'][$name]->name=$name; $_advman['ads'][$name]->p=advman_upgrade::_process_v2_x_to_3_0($oad); break; } } } OX_Tools::sort($_advman['ads']); } function _process_v2_x_to_3_0($old){ $new=$old; /* Additional conversaion required for rearrangement of colors system */ $new['color-border']=$old['colors']['border']; $new['color-title']=$old['colors']['link']; $new['color-bg']=$old['colors']['bg']; $new['color-text']=$old['colors']['text']; $new['color-url']=$old['colors']['url']; /* End color rearrangement */ $new['show-page']=$old['show-post']; /* Adformat codes etc. need to be moved */ switch($old['product']){ case 'ad': if($old['alternate-url']){ $new['alternate-ad']='url'; } else if($old['alternate-color']) { $new['alternate-ad']='color'; } else { $new['alternate-ad']='benice'; } break; case 'link': $new['adformat']=$old['linkformat']; $new['adtype']=$old['linktype']; break; case 'referral': case 'referral-text': $new['adformat']=$old['referralformat']; break; } list($new['width'],$new['height'],$null)=split('[x]',$new['adformat']); //Split to fill width/height information return $new; } function adsense_deluxe_to_3_0() { global $_advman; $deluxe = get_option('acmetech_adsensedeluxe'); foreach ($deluxe['ads'] as $key => $vals) { $ad = advman_admin::import_ad($vals['code']); $name = advman_admin::generate_name($vals['name']); $ad->name = $name; $ad->set('show-home', ($deluxe['enabled_for']['home'] == 1) ? 'yes' : 'no'); $ad->set('show-post', ($deluxe['enabled_for']['posts'] == 1) ? 'yes' : 'no'); $ad->set('show-archive', ($deluxe['enabled_for']['archives'] == 1) ? 'yes' : 'no'); $ad->set('show-page', ($deluxe['enabled_for']['page'] == 1) ? 'yes' : 'no'); $_advman['ads'][$name] = $ad; if ($vals['make_default'] == 1) { $_advman['default-ad'] = $name; } } OX_Tools::sort($_advman['ads']); } function _render_ad_adsense($ad) { global $_advman; $accountId = !empty($_advman['account-ids'][$ad->network]) ? ('pub-' . $_advman['account-ids'][$ad->network]) : ''; $code = '' . "\n"; $code.= '' . "\n"; return $code; } function _render_ad_adbrite($ad) { global $_advman; $accountId = !empty($_advman['account-ids'][$ad->network]) ? $_advman['account-ids'][$ad->network] : ''; $code =''; $code .= '' . "\n"; $code .= ''; $code .= '
Your Ad Here
'; $code .= ''; return $code; } function _render_ad_adgridwork($ad) { global $_advman; $accountId = !empty($_advman['account-ids'][$ad->network]) ? $_advman['account-ids'][$ad->network] : ''; $code ='Free Advertising'; $code.=''; return $code; } function _render_ad_adpinion($ad) { global $_advman; $accountId = !empty($_advman['account-ids'][$ad->network]) ? $_advman['account-ids'][$ad->network] : ''; if($ad->get('width')>$ad->get('height')){$xwidth=18;$xheight=17;} else {$xwidth=0;$xheight=35;} $code =''; $code .= ''; return $code; } function _render_ad_adroll($ad) { global $_advman; $accountId = !empty($_advman['account-ids'][$ad->network]) ? $_advman['account-ids'][$ad->network] : ''; $code =''; $code .= ''; $code .= ''; $code .= ''; $code .= ''; return $code; } function _render_ad_adsense_ad($ad) { global $_advman; $accountId = !empty($_advman['account-ids'][$ad->network]) ? ('pub-' . $_advman['account-ids'][$ad->network]) : ''; $code=''; $code .= '' . "\n"; $code.= '' . "\n"; return $code; } function _render_ad_adsense_link($ad) { global $_advman; $accountId = !empty($_advman['account-ids'][$ad->network]) ? ('pub-' . $_advman['account-ids'][$ad->network]) : ''; $code=''; $code .= '' . "\n"; $code.= '' . "\n"; return $code; } function _render_ad_adsense_referral($ad) { global $_advman; $accountId = !empty($_advman['account-ids'][$ad->network]) ? ('pub-' . $_advman['account-ids'][$ad->network]) : ''; //if($ad===false){$ad=$_advman['ads'][$_advman['default_ad']];} //$ad=advman::merge_defaults($ad); //Apply defaults if($ad->get('product')=='referral-image') { $format = $ad->get('adformat') . '_as_rimg'; } else if($ad->get('product')=='referral-text') { $format = 'ref_text'; } $code=''; $code .= '' . "\n"; $code.= '' . "\n"; return $code; } function _render_ad_cj($ad) { global $_advman; $accountId = !empty($_advman['account-ids'][$ad->network]) ? $_advman['account-ids'][$ad->network] : ''; $cjservers=array( 'www.kqzyfj.com', 'www.tkqlhce.com', 'www.jdoqocy.com', 'www.dpbolvw.net', 'www.lduhtrp.net'); $code = ''; $code .= ''; $code .= 'get('new-window')=='yes'){$code.=' target="_blank" ';} if($ad->get('hide-link')=='yes'){ $code.='onmouseover="window.status=\''; $code.=$ad->get('hide-link-url'); $code.='\';return true;" onmouseout="window.status=\' \';return true;"'; } $code .= '>'; $code .= 'get('width') . '" '; $code .= ' height="' . $ad->get('height') . '" '; $code .= ' alt="' . $ad->get('alt-text') . '" '; $code .= '>'; $code .= ''; return $code; } function _render_ad_crispads($ad) { global $_advman; if ($ad->get('codemethod')=='javascript'){ $code=''; } else { //Iframe $code=''; $code.=''; } return $code; } function _render_ad_shoppingads($ad) { global $_advman; $accountId = !empty($_advman['account-ids'][$ad->network]) ? $_advman['account-ids'][$ad->network] : ''; $code = ' ' . "\n"; return $code; } function _render_ad_widgetbucks($ad) { global $_advman; $code =''; $code .= '
'; $code .= ''; $code .= '
'; return $code; } function _render_ad_ypn($ad) { global $_advman; $accountId = !empty($_advman['account-ids'][$ad->network]) ? $_advman['account-ids'][$ad->network] : ''; $code = ''; $code .= ''; return $code; } } ?>