Advertwhirl Follow Mobile Sentience ';
private $DonateImage = '
';
private $DonateText = 'Donate ';
private $TwitterFollow = 'Follow Mobile Sentience ';
private $FacebookFollow = '';
private $AdminTabs = array(
'campaigns-tab' => array('name' => 'Campaigns', 'method_base' => 'CampaignListTab'),
'sources-tab' => array('name' => 'Local Ads', 'method_base' => 'SourceListTab'),
'settings-tab' => array('name' => 'Settings', 'method_base' => 'SettingsTab'),
'handbook-tab' => array('name' => 'Tutorials', 'method_base' => 'HandbookTab'),
'support-tab' => array('name' => 'Support', 'method_base' => 'SupportTab'),
'about-tab' => array('name' => 'About', 'method_base' => 'AboutTab')
);
private $AllocationMap = array(
'name' => 'alname-',
'description' => 'aldescription-',
'displayed' => 'alpaneldisplayed-',
'ads' => array(
'advertisement' => 'alad-',
'weight' => 'aladweight-',
'percent-weight' => 'aladpercentweight-'
),
'rulesets' => array(
'id' => 'alrulesetid-',
'rules' => array(
'type' => 'alruletype-',
'author' => 'alruleauthor-',
'posttype' => 'alruleposttype-',
'tag' => 'alruletag-',
'category' => 'alrulecategory-',
'post' => 'alrulepost-',
'page' => 'alrulepage-',
'argname' => 'alruleargumentname-',
'argvalue' => 'alruleargumentvalue-',
'argop' => 'alruleargumentoperator-',
'catid' => 'alrulecategoryid-',
'catop' => 'alrulecategoryoperator-',
'tagid' => 'alruletagid-',
'tagop' => 'alruletagoperator-',
'vpath' => 'alrulevpath-',
'vpathop' => 'alrulevpathoperator-',
'cvarname' => 'alrulecvarname-',
'cvarop' => 'alrulecvaroperator-',
'cvarvalue' => 'alrulecvarvalue-',
'geolocation' => 'alrulegeolocation-',
'geoop' => 'alrulegeoop-',
'geovalue' => 'alrulegeovalue-'
)
)
);
private $RuleTypes = array (
'author' => 'Match an author',
'posttype' => 'Match the post type',
'category' => 'Match a category',
'tag' => 'Match a tag ',
'geoip' => 'Match a location',
'getargument' => 'Match link arguments'
);
private $VirtualThemeRules = array (
'vpath' => 'Match a Virtual Path',
'cvar' => 'Match a Virtual Theme Custom Variable'
);
private $CacheTimes = array(
'0' => 'Never Cache',
'1' => 'Save loaded data for 1 hour',
'24' => 'Save loaded data for 1 day',
'168' => 'Save loaded data for 1 week'
);
private $AdUnitSizes = array(
'Medium Rectangle - (300x250)' => '300x250',
'Large Rectangle - (336x280)' => '336x280',
'Leaderboard - (728x90)' => '728x90',
'Wide Skyscraper - (160x600)' => '160x600',
'Banner - (468x60)' => '468x60',
'Half Banner - (234x60)' => '234x60',
'Skyscraper - (120x600)' => '120x600',
'Vertical Banner - (120x240)' => '120x240',
'Square - (250x250)' => '250x250',
'Small Square - (200x200)' => '200x200',
'Small Rectangle - (180x150)' => '180x150',
'Button - (125x125)' => '125x125',
'(728x15)' => '728x15',
'(468x15)' => '468x15',
'(200x90)' => '200x90',
'(180x90)' => '180x90',
'(160x90)' => '160x90',
'(120x90)' => '120x90'
);
// Protected constructor for singleton
//private function __construct(){
public function __construct(){
/** Uncomment for testing, forces loading of plugin stylesheets and javascripts */
global $pluginversion;
global $pluginname;
$this->version = $pluginversion;
$this->name = $pluginname;
$this->adserv = 'http://www.mobilesentience.com/ads/WordpressPlugins&plugin=' . $this->name . '&pluginversion=' . $this->version . '&where=admin';
$this->pluginFile = __FILE__;
$this->pageURL = '?page=' . $this->getRightMost(__FILE__, 'plugins/');
$this->imagePath = WP_PLUGIN_URL . '/' . str_replace(basename( __FILE__), "", plugin_basename(__FILE__)) . '/images/';
$this->externalAdsPath = str_replace(get_site_url(), '', WP_PLUGIN_URL . '/' . str_replace(basename( __FILE__), "", plugin_basename(__FILE__))) . '/ServeAd.php?campaign=';
if(empty($this->pluginDir)) $this->pluginDir = dirname($this->pluginFile);
$this->libraryPath = $this->pluginDir . '/libs/';
$this->handbookPath = $this->pluginDir . '/handbook.txt';
$this->adsense = new AdsenseStats();
$this->db = new SiteDB();
//Language Setup
$locale = get_locale();
$mo = dirname(__FILE__) . "/languages/" . $this->name . "-".$locale.".mo";
load_textdomain($this->name, $mo);
add_action('init', array(&$this, 'InitializePlugin'));
}
public function ActivatePlugin() {
// Ad the rules for exteranl adds back to .htaccess
$inst = new AdvertwhirlPlugin();
$inst->FlushRewrites();
}
public function DeactivatePlugin() {
/* Remove the shortcodes */
$this->RemoveShortcodes();
/** Register Admin Style Sheet*/
wp_deregister_style('advertwhirl-plugin-admin-css');
/** Register Admin Javascript*/
wp_deregister_script('advertwhirl-plugin-admin-scripts');
// If external ads are set flush the rules to remove the external ad rules
$this->deactivating = true;
$this->FlushRewrites();
}
// Protected cloner for singleton
//private function __clone(){}
public function InitializePlugin(){
if(!$this->initialized){
/* Get plugin data */
global $wp_version;
$this->options = maybe_unserialize(get_option($this->name . "_options"));
/* Hook the actions */
$this->HookActions();
/* Add the shortcodes */
$this->AddShortcodes();
if(gettype($this->options)!="array"){
$this->options = array();
}
if(!isset($this->options['settings']))
$this->options['settings'] = $this->DefaultSettings();
/** This can be removed once everyone is using 1.0.5+ */
if(!isset($this->options['settings']['defaulttab']))
$this->options['settings']['defaulttab'] = 'handbook-tab';
$this->adsense->SetUsername($this->options['settings']['adsense']['username']);
$this->adsense->SetPassword($this->options['settings']['adsense']['password']);
$this->initialized = true;
}
}
private function DefaultSettings(){
$settings = array();
$settings['externalAdsEnabled'] = false;
$settings['adUrlPrefix'] = 'advertwhirl';
$settings['defaulttab'] = 'handbook-tab';
/* Default Settings for Adsense */
$adsenseSettings = array();
$adsenseSettings['username'] = "";
$adsenseSettings['password'] = "";
$adsenseSettings['ads-cache'] = 8640;
$adsenseSettings['stats-cache'] = 8640;
$settings['adsense'] = $adsenseSettings;
$analyticsSettings = array();
$analyticsSettings['enabled'] = false;
$analyticsSettings['username'] = "";
$analyticsSettings['password'] = "";
$analyticsSettings['VariablesEnabled'] = true;
$settings['analytics'] = $analyticsSettings;
return $settings;
}
public function HookActions() {
add_action('admin_menu', array(&$this, 'DisplayAdminMenu')); /* Add the admin menu */
add_action('wp_dashboard_setup', array(&$this, 'AddDashboardWidgets')); /* Add the stats widget to the dashboard */
if(!isset($this->rewriteHooked) || !$this->rewriteHooked){
add_action('generate_rewrite_rules', array(&$this, 'RewriteExternalAds'));
$this->rewriteHooked = true;
}
add_action('admin_init', array(&$this, 'AdminInit'));
// Hooks and filters for auto insertion of ads
//add_filter("the_content", array(&$this, "FilterContent"));
//add_action('wp_head', array(&$this, 'InsertHeaderAds'));
//add_action('wp_footer', array(&$this, 'InsertFooterAds'));
}
public function FilterContent($content){
$type = get_post_type();
$precontent = "";
$postcontent = "";
foreach($this->options['adcampaigns'] as $name => $campaign){
// Insert an add before the content if required
if($campaign['display-ad-before-' . $type . '-content']){
$precontent .= advertwhirl_get_ad($name);
}
if($campaign['display-ad-in-' . $type . '-content']){
// $adsEvery = 10;
// $maxAds = 2;
// $adon = 0; //this is a variable so you don't show ads more than once.
// echo '';
// $tcount = 0; //this is count for number of
blocks
// $paragraphs = explode("
", $content); //Separate the content into
blocks
// foreach($paragraphs as $paragraph) {
// if(preg_match('/
/',$paragraph) == 0 && $tcount % $adsEvery == 0 && $adon < $maxAds){
// $float = $adon % 2 == 0?"float:left":"float:right";
// echo '
';
// advertwhirl_get_ad('Manifesto');
// echo '
';
// $adon++;
// }
// echo $paragraph; //print the
block
// echo "
";
// $tcount++;
// }
// echo '
';
}
// Insert an add after the content if required
if($campaign['display-ad-after-' . $type . '-content']){
$postcontent .= advertwhirl_get_ad($name);
}
}
$content = $precontent . $content . $postcontent;
return $content;
}
public function InsertHeaderAds(){
//echo extra header stuff
}
public function InsertFooterAds(){
//echo extra footer stuff
}
public function AddShortcodes(){
add_shortcode('advertwhirl', array(&$this, 'HandleShortcode_advertwhirl'));
}
public function RemoveShortcodes(){
remove_shortcode('advertwhirl', array(&$this, 'HandleShortcode_advertwhirl'));
}
public function AdminInit(){
foreach(get_option('active_plugins') as $index => $plugin){
if($plugin == 'virtual-theme/VirtualTheme.php'){
$this->virtualThemeInstalled = true;
$this->RuleTypes = array_merge($this->RuleTypes, $this->VirtualThemeRules);
break;
}
}
}
public function FlushRewrites(){
global $wp_rewrite;
if(!isset($this->rewriteHooked) || !$this->rewriteHooked){
add_action('generate_rewrite_rules', array(&$this, 'RewriteExternalAds'));
$this->rewriteHooked = true;
}
$wp_rewrite->flush_rules();
}
public function RewriteExternalAds() {
global $wp_rewrite;
$options = maybe_unserialize(get_option("Advertwhirl_options"));
$prefix = $options['settings']['adUrlPrefix'];
$externalAdsPath = str_replace(get_site_url(), '', WP_PLUGIN_URL . '/' . str_replace(basename( __FILE__), "", plugin_basename(__FILE__))) . '/ServeAd.php?campaign=';
//RewriteRule ^ads/(.*) /wordpress/wp-content/plugins/advertwhirl//ServeAd.php?campaign=$1 [QSA,L]
//RewriteRule ^(vpath)/ads/(.*) /wordpress/wp-content/plugins/advertwhirl//ServeAd.php?campaign=$2&virtualpath=$1 [QSA,L]
if($options['settings']['externalAdsEnabled'] && !$this->deactivating){
$newRules = array(
$prefix . '/(.*)' => $externalAdsPath . '$1'
);
// If Virtual Theme is installed add a rule for each vpath
foreach(get_plugins() as $plugin => $data){
if($plugin == 'virtual-theme/VirtualTheme.php'){
require_once(WP_PLUGIN_DIR . "/" . $plugin);
if(VirtualThemeActive()){
$paths = VirtualTheme::GetVirtualPaths();
foreach($paths as $path){
if(strpos($path, '/') === 0)
$path = substr($path, 1);
$newRules['(' . $path . ')/' . $prefix . '/(.*)'] = $externalAdsPath . '$2&virtualpath=/$1';
}
}
}
}
$wp_rewrite->non_wp_rules = $newRules + $wp_rewrite->non_wp_rules;
}
}
// Get the sole instance of the singleton
//static public function GetInstance(){
// if(self::$instance === null){
// self::$instance = new AdvertwhirlPlugin();
// }
// return self::$instance;
//}
private function GetTechnicalSpecs(){
global $wp_version;
$specs .= "Plugin Specs\n";
$specs = "========================================\n";
$specs .= "Plugin: $this->name\n";
$specs .= "Plugin Version: $this->version\n";
$specs .= "Plugin Directory: $this->pluginDir\n\n";
$specs .= "Server Specs\n";
$specs = "========================================\n";
$specs .= "Server Address: " . $_SERVER['SERVER_ADDR'] . "\n";
$specs .= "Server Name: " . $_SERVER['SERVER_NAME'] . "\n";
$specs .= "Server Software: " . $_SERVER['SERVER_SOFTWARE'] . "\n\n";
$specs .= "Wordpress Specs\n";
$specs = "========================================\n";
$specs .= "Blog Name: " . get_option('blogname') . "\n";
$specs .= "Wordpress Version: $wp_version\n";
$specs .= "Wordpress Siteurl: " . get_option("siteurl") . "\n";
$specs .= "Wordpress Home: " . get_option("home") . "\n";
$specs .= "\tActive Plugins\n";
$specs .= "\t========================================\n";
foreach(get_option('active_plugins') as $index => $plugin){
if(strlen($plugin)>0)
$specs .= "\t$plugin\n";
}
/** PHP Info - @TODO: outputs html and needs to be parsed */
//ob_start();
//phpinfo(INFO_GENERAL or INFO_CONFIGURATION or INFO_MODULES);
//$specs .= ob_get_contents();
//ob_get_clean();
return $specs;
}
function HandleShortcode_advertwhirl($atts, $content = null) {
extract(shortcode_atts(array('campaign' => null), $atts));
if(isset($campaign)){
echo advertwhirl_get_ad($campaign);
}
}
// Add the stats widget to the dashboard
public function AddDashboardWidgets() {
// Add statistics widget to dashboard
if(isset($this->options['settings']['displayDashboard']) && $this->options['settings']['displayDashboard'])
wp_add_dashboard_widget("AdvertwhirlStatsWidget", "Advertwhirl", array(&$this, "DisplayAdvertwhirlStatsWidget"));
}
public function DisplayAdsenseStats(){
$periods = array();
foreach($this->adsense->GetReportPeriods() as $key => $value){
if(isset($this->options['settings']['adsense']['period'][$key])){
$periods[$key] = $this->options['settings']['adsense']['period'][$key];
}else{
$periods[$key] = false;
}
}
$types = array();
foreach($this->adsense->GetReportTypes() as $key => $value){
if(isset($this->options['settings']['adsense']['type'][$key])){
$types[$key] = $this->options['settings']['adsense']['type'][$key];
}else{
$types[$key] = false;
}
}
$categories = array();
foreach($this->adsense->GetAdCategories() as $key => $value){
if(isset($this->options['settings']['adsense']['category'][$key])){
$categories[$key] = $this->options['settings']['adsense']['category'][$key];
}else{
$categories[$key] = false;
}
}
$this->adsense->LoadStats();
$this->adsense->GetStatTables($periods, $types, $categories);
}
public function DisplayAdvertwhirlStatsWidget(){
echo '';
if($this->options['settings']['adsense']['dashboard'])
$this->DisplayAdsenseStats();
echo '
';
}
public function DisplayAdminMenu(){
$this->pluginPage = add_options_page('Advertwhirl Options', 'Advertwhirl', 'manage_options', __FILE__, array(&$this, 'CreateAdminPanel'));
add_action('admin_print_styles-' . $this->pluginPage, array(&$this, 'LinkAdminStylesheet'));
add_action('admin_print_scripts-' . $this->pluginPage, array(&$this, 'LinkAdminScripts'));
}
function LinkAdminStylesheet() {
/** Register plugin admin stylesheet*/
wp_register_style('advertwhirl-plugin-admin-css', plugins_url('css/styles.css', __FILE__), false, $this->version);
/** Enqueue plugin admin stylesheet*/
wp_enqueue_style('advertwhirl-plugin-admin-css');
}
function LinkAdminScripts() {
/** Register plugin admin javascript*/
wp_register_script('advertwhirl-plugin-admin-scripts', plugins_url('advertwhirl.js', __FILE__), false, $this->version);
/** Enqueue plugin admin stylesheet*/
wp_enqueue_script('advertwhirl-plugin-admin-scripts');
}
function DisplayMobileSentienceAd(){
$ad = file_get_contents($this->adserv);
if($ad !== false){
echo '' . $ad . ' ';
}
}
public function DisplayAdminBanner($activeTab){
echo '' . $this->PromoteText . ' ';
}
function ShiftArrayElement(&$a, $index, $delta){
if(isset($a) && is_array($a)){
$nindex = $index + $delta;
if($nindex < 0){
$nindex = 0;
}else if($nindex >= sizeof($a)){
$nindex = sizeof($a) - 1;
}
$tmp = $a[$index];
for($i = $index; $i != $nindex; $i += $delta){
$a[$i] = $a[$i + $delta];
}
$a[$nindex] = $tmp;
}
}
function ExtractPostArray($map, $postfix = ""){
$sets = null;
$i = 0;
$found = true;
while($found){
$set = null;
$found = false;
foreach($map as $dkey => $pkey){
if(is_array($pkey)){
$post = $postfix . $i . '-';
$sub = $this->ExtractPostArray($pkey, $post);
if(isset($sub)){
if(!isset($set)){
$set = array();
}
$set[$dkey] = $sub;
$found = true;
}
}else if(isset($_POST[$pkey . $postfix . $i])){
if(!isset($set)){
$set = array();
}
$set[$dkey] = $_POST[$pkey . $postfix . $i];
$found = true;
}
}
if(isset($set)){
if(!isset($sets)){
$sets = array();
}
$sets[] = $set;
}
$i++;
}
return $sets;
}
function CalculateWeights($campaign, &$allocations){
// Setup weight stats
$success = true;
$totalWeights = 0;
$totalPercents = 0;
foreach($allocations as $index => $allocation){
$percents = array();
foreach($allocation['ads'] as $i => $ad){
$weight = strlen($ad['weight']) > 0?$ad['weight']:0;
$weight = str_replace(' ', '', $weight);
if(is_numeric($weight)){ /* Weight */
$w = intVal($weight);
$totalWeights += $w;
if($w < 0){
$_POST['aladweighterror-' . $index . '-' . $i] = "*Allocations can't have a negative weight";
$success = false;
}else if(isset($ad['percent-weight'])){
unset($ad['percent-weight']);
}
}else if (strpos($weight, '%') !== false){ /* Percent */
$weight = str_replace('%', '', $weight);
$percents["$i"] = floatVal($weight)/100;
if($percents["$i"] < 0){
$_POST['aladweighterror-' . $index . '-' . $i] = "*Allocations can't have a negative weight";
$success = false;
}
$totalPercents += $percents["$i"];
}else{
// set error code
$_POST['aladweighterror-' . $index . '-' . $i] = "*Invalid weight value";
$success = false;
}
}
if($totalPercents > 1 || ($totalPercents == 1 && $totalWeights > 0)){
$_POST['aladweighterror-' . $index] = "*Ad slots over-allocated";
$success = false;
}else if($totalPercents < 1 && $totalWeights == 0){
$_POST['aladweighterror-' . $index] = "*Ad slots under-allocated, percentage only allocations must total 100%";
$success = false;
}
if(!$success)
return $success;
// Calculate percent weights
$weightWithPercents = $totalWeights == 0 && $totalPercents > 0?1000:$totalWeights/(1 - $totalPercents);
$percentWeightsOnly = $totalWeights == 0 && $totalPercents > 0?true:false;
if($percentWeightsOnly){
require_once('libs/Math.php');
if(count($percents) == 1){
$allocation['ads'][$i]['percent-weight'] = intval($w);
}else{
$values = array();
foreach($percents as $i => $percent){
$w = $weightWithPercents * $percent;
$values[] = intval($w);
}
$gcf = get_gcf($values);
foreach($values as $i => $value){
$allocation['ads'][$i]['percent-weight'] = $gcf !== false?$value / $gcf:$value;
}
}
} else{
foreach($percents as $i => $percent){
$w = $weightWithPercents * $percent;
$allocation['ads'][$i]['percent-weight'] = ceil($w);
}
}
}
global $wp_version;
if ($wp_version=="2.6"){
// 2.6 fix, this version unserializes data for some odd reason.
$stats = get_option($this->name . "_stats");
}else{
$stats = get_option($this->name . "_stats");
}
if(!is_array($stats))
$stats = array();
unset($stats['stats']['adcampaigns'][$campaign]['allocations']);
foreach($allocations as $index => $allocation){
$stats['stats']['adcampaigns'][$campaign]['allocations'][$index]['sourceweights'] = array();
foreach($allocation['ads'] as $i => $ad){
$stats['stats']['adcampaigns'][$campaign]['allocations'][$index]['sourceweights'][] = 0;
}
}
update_option($this->name . "_stats", $stats);
return $success;
}
function CampaignListTab_update($tab, $action){
// Check for allocation buttons
$postAllocations = $this->ExtractPostArray($this->AllocationMap);
if(isset($postAllocations) && sizeof($postAllocations) > 0){
$edit = false;
$count = sizeof($postAllocations);
for($i = 0; $i < $count; $i++){
if(isset($_POST['aldown-' . $i])){
$this->ShiftArrayElement($postAllocations, $i, 1);
$edit = true;
}else if(isset($_POST['alup-' . $i])){
$this->ShiftArrayElement($postAllocations, $i, -1);
$edit = true;
}else if(isset($_POST['alremove-' . $i])){
unset($postAllocations[$i]);
$edit = true;
}else if(isset($_POST['add-allocation-source-' . $i])){
$postAllocations[$i]['ads'][] = $this->GetDefaultAllocationAd();
$edit = true;
}else if(isset($_POST['add-allocation-ruleset-' . $i])){
$postAllocations[$i]['rulesets'][] = array();
$postAllocations[$i]['rulesets'][0]['id'] = $i . '-' . sizeof($postAllocations[$i]['rulesets']);
$edit = true;
}
$adcount = sizeof($postAllocations[$i]['ads']);
for($j = 0; $j < $adcount; $j++){
if(isset($_POST['aladremove-' . $i . '-' . $j])){
unset($postAllocations[$i]['ads'][$j]);
$edit = true;
}
}
for($j = 0; $j < sizeof($postAllocations[$i]['rulesets']); $j++){
if(isset($_POST['add-allocation-rule-' . $i . '-' . $j])){
$postAllocations[$i]['rulesets'][$j]['rules'][] = $this->GetDefaultAllocationRule($_POST['new-rule-type-' . $i . '-' . $j]);
$edit = true;
}
$rulecount = sizeof($postAllocations[$i]['rulesets'][$j]['rules']);
for($k = 0; $k < $rulecount; $k++){
if(isset($_POST['alruleremove-' . $i . '-' . $j . '-' . $k])){
unset($postAllocations[$i]['rulesets'][$j]['rules'][$k]);
$edit = true;
}
}
}
}
if($edit){
if(isset($_POST['current-action'])){
$action = $_POST['current-action'];
}
if(isset($_POST['add-set']) && $_POST['add-set']){
$_POST['add'] = true;;
}
if(isset($_POST['edit-set']) && $_POST['edit-set']){
$_POST['edit'] = true;;
}
return $this->CampaignListTab_edit($tab, $action, $postAllocations);
}
}
if(isset($_POST['current-action'])){
$action = $_POST['current-action'];
}
if(isset($_POST['add-set']) && $_POST['add-set']){
$_POST['add'] = true;;
}
if(isset($_POST['edit-set']) && $_POST['edit-set']){
$_POST['edit'] = true;;
}
if(isset($_POST['add-allocation'])){
$postAllocations[] = $this->GetDefaultAllocation();
return $this->CampaignListTab_edit($tab, $action, $postAllocations);
} else if(isset($_POST['add'])){
if(!isset($_POST['name']) || $_POST['name'] == ""){
$_POST['name_error'] = "*Name is a required field";
return $this->CampaignListTab_edit($tab, $action);
}
$name = $_POST['name'];
if(!$this->CalculateWeights($name, $postAllocations)){
return $this->CampaignListTab_edit($tab, $action);
}
$this->options['adcampaigns'][$name]['allocations'] = $postAllocations;
$this->options['adcampaigns'][$name]['description'] = $_POST['description'];
$this->options['adcampaigns'][$name]['adsize'] = $_POST['adsize'];
update_option($this->name . "_options", $this->options);
return $this->CampaignListTab_view($tab, $action);
} else if(isset($_POST['update'])){
if(!isset($_POST['name']) || $_POST['name'] == ""){
$_POST['name_error'] = "*Name is a required field";
return $this->CampaignListTab_edit($tab, $action);
}
$name = $_POST['name'];
if(isset($this->options['adcampaigns'][$name]) && $_POST['origname'] != $name){
$_POST['name_error'] = "*Name must be unique";
return $this->CampaignListTab_edit($tab, $action);
}
if(!$this->CalculateWeights($name, $postAllocations)){
return $this->CampaignListTab_edit($tab, $action);
}
if($_POST['origname'] != $name){
$oname = $_POST['origname'];
unset($this->options['adcampaigns'][$oname]);
}
$this->options['adcampaigns'][$name]['allocations'] = $postAllocations;
$this->options['adcampaigns'][$name]['description'] = $_POST['description'];
$this->options['adcampaigns'][$name]['adsize'] = $_POST['adsize'];
update_option($this->name . "_options", $this->options);
return $this->CampaignListTab_view($tab, $action);
} else if(isset($_POST['delete'])){
if(!isset($_POST['name']) || $_POST['name'] == ""){
return $this->CampaignListTab_view($tab, $action);
}
$name = $_POST['name'];
unset($this->options['adcampaigns'][$name]);
update_option($this->name . "_options", $this->options);
return $this->CampaignListTab_view($tab, $action);
} else if(isset($_POST['cancel'])){
return $this->CampaignListTab_view($tab, $action);
}
}
function GetAllocationRuleForm_author($i, $j, $k, $rule){
$authors = $this->db->GetAuthorsList();
$content .= '
';
foreach($authors as $id => $author){
$selected = $rule['author'] == $id?"selected":"";
$content .= '
' . $author['lastname'] . ', ' . $author['firstname'] . ' ';
}
$content .= '
';
return $content;
}
function GetAllocationRuleForm_posttype($i, $j, $k, $rule){
$content .= '
';
$post_types=get_post_types('','names');
foreach ($post_types as $type ) {
$selected = $rule['posttype'] == $type?"selected":"";
$content .= '
' . $type . ' ';
}
$content .= '
';
return $content;
}
function GetAllocationRuleForm_getargument($i, $j, $k, $rule){
$argumentOperators = array (
'==' => 'is equal to',
'!=' => 'is not equal to',
'>' => 'is greater than',
'<' => 'is less than',
'>=' => 'is greater than or equal to',
'<=' => 'is less than or equal to',
'~=' => 'matches regular expression',
'!~' => 'does not match regular expression',
);
$content .= '
Argument ';
$content .= '
';
foreach ($argumentOperators as $value => $label) {
$selected = $rule['argop'] == $value?"selected":"";
$content .= '
' . $label . ' ';
}
$content .= '
';
return $content;
}
// 'geoip' => 'alrulegeoip-'
function GetAllocationRuleForm_cvar($i, $j, $k, $rule){
$argumentOperators = array (
'==' => 'is equal to',
'!=' => 'is not equal to',
'>' => 'is greater than',
'<' => 'is less than',
'>=' => 'is greater than or equal to',
'<=' => 'is less than or equal to',
'~=' => 'matches regular expression',
'!~' => 'does not match regular expression',
);
if($this->virtualThemeInstalled){
require_once(WP_PLUGIN_DIR . "/virtual-theme/VirtualTheme.php");
$vars = VirtualTheme::GetCustomVariables();
$content .= '
';
foreach($vars as $var){
$selected = $rule['cvarname'] == $var?"selected":"";
$content .= '
' . $var . ' ';
}
$content .= '
';
foreach ($argumentOperators as $op => $label) {
$selected = $rule['cvarop'] == $op?"selected":"";
$content .= '
' . $label . ' ';
}
$content .= '
';
return $content;
}
return "";
}
function GetAllocationRuleForm_geoip($i, $j, $k, $rule){
//http://api.ipinfodb.com/v3/ip-city/?key=0ff0aab59531b725b5da5b874f6acadc4d0ea0b667fe19d94150b9520451e120&ip=71.237.2.63
//OK;;71.237.2.63;US;UNITED STATES;COLORADO;DENVER;80002;39.7761;-105.015;-07:00
$argumentOperators = array (
'==i' => 'is',
'!=i' => 'is not',
'~=' => 'matches regular expression',
'!~' => 'does not match regular expression',
);
$locations = array(
'countryName' => 'Country',
'regionName' => 'State/Province',
'cityName' => 'City',
'zipCode' => 'Postal Code'
);
$content .= '
';
foreach ($locations as $value => $label) {
$selected = $rule['geolocation'] == $value?"selected":"";
$content .= '
' . $label . ' ';
}
$content .= '
';
foreach ($argumentOperators as $value => $label) {
$selected = $rule['geoop'] == $value?"selected":"";
$content .= '
' . $label . ' ';
}
$content .= '
';
return $content;
}
function GetAllocationRuleForm_vpath($i, $j, $k, $rule){
$argumentOperators = array (
'==' => 'is',
'!=' => 'is not',
'~=' => 'matches regular expression',
'!~' => 'does not match regular expression',
);
if($this->virtualThemeInstalled){
require_once(WP_PLUGIN_DIR . "/virtual-theme/VirtualTheme.php");
$content .= '
Virtual Path
';
foreach ($argumentOperators as $op => $label) {
$selected = $rule['vpathop'] == $op?"selected":"";
$content .= '
' . $label . ' ';
}
$content .= '
';
$paths = VirtualTheme::GetVirtualPaths();
foreach($paths as $path){
$selected = $rule['vpath'] == $path?"selected":"";
$content .= '
' . $path . ' ';
}
$content .= '
';
return $content;
}
return "";
}
function GetAllocationRuleForm_tag($i, $j, $k, $rule){
$argumentOperators = array (
'isa' => 'is a',
'isnota' => 'is not a',
);
$content .= '
Post/Page
';
foreach ($argumentOperators as $op => $label) {
$selected = $rule['tagop'] == $op?"selected":"";
$content .= '
' . $label . ' ';
}
$content .= '
';
$tags = get_tags(array('hide_empty' => 0));
foreach($tags as $tag){
$selected = $rule['tagid'] == $tag->term_id?"selected":"";
$content .= '
' . $tag->name . ' ';
}
$content .= '
';
return $content;
}
function GetAllocationRuleForm_category($i, $j, $k, $rule){
$argumentOperators = array (
'isa' => 'is a',
'isnota' => 'is not a',
);
$content .= '
Post/Page
';
foreach ($argumentOperators as $op => $label) {
$selected = $rule['catop'] == $op?"selected":"";
$content .= '
' . $label . ' ';
}
$content .= '
';
$selected = isset($rule['catid'])?$rule['catid']:0;
$content .= wp_dropdown_categories(array('echo' => 0, 'hide_empty' => 0, 'name' => 'alrulecategoryid-' . $i . '-' . $j . '-' . $k, 'hierarchical' => true, 'selected' => $selected));
return $content;
}
function GetAllocationRuleForm($i, $j, $k, $rule){
$func = "GetAllocationRuleForm_" . $rule['type'];
if(method_exists($this, $func)){
$content = '
' . $this->RuleTypes[$rule['type']] . '
';
$content .= call_user_func(array(&$this, $func), $i, $j, $k, $rule);
$content .= '
';
}
return $content;
}
function GetAllocationAdForm($i, $index, $ad, $displayRemove){
if($displayRemove){
$labelWidth = "10%";
$adWidth = "40%";
$weightWidth = "20%";
}else{
$labelWidth = "10%";
$adWidth = "50%";
$weightWidth = "30%";
}
$content .= '
';
return $content;
}
function GetAllocationForm($i, $allocation, $totalAllocations){
// Calculate what buttons if any to display
$displayButtonRow = $totalAllocations > 1;
$displayMoveUp = $i > 0;
$displayMoveDown = $i < $totalAllocations - 1;
$adsupdated = isset($_POST['adsupdated-' . $i])?$_POST['adsupdated-' . $i]:false; /** @todo Verify this can be removed, only refernced here and belore */
$id = $i + 1;
$content = '
Allocation Schedule ' . $id . '
';
return $content;
}
function GetDefaultAllocationRule($type = null){
$rule = array();
$rule['type'] = $type;
$rule['author'] = "";
$rule['posttype'] = "";
$rule['tag'] = "";
$rule['category'] = "";
$rule['post'] = "";
$rule['page'] = "";
return $rule;
}
function GetDefaultAllocationAd(){
$ad = array();
$ad['advertisement'] = "";
$ad['weight'] = "1";
return $ad;
}
function GetDefaultAllocation(){
$allocation = array();
$allocation['name'] = "";
$allocation['description'] = "";
$allocation['ads'][] = $this->GetDefaultAllocationAd();
return $allocation;
}
function CampaignListTab_edit($tab, $action, $postAllocations = null){
$baseurl = $this->pageURL . '&tab=' . $tab . '&action=';
$cancelurl = $this->pageURL . '&tab=' . $tab . '&action=view';
//verify data
$add = isset($_POST['add']);
$addAllocation = isset($_POST['add-allocation']);
$edit = isset($_POST['edit']);
$delete = isset($_POST['delete']);
if ($add){
$title = "Create new ad campaign";
$submitName = "add";
$submitValue = "Save Campaign";
$origname = "";
if(isset($_POST['name'])){
$name = $_POST['name'];
}
if(isset($_POST['description'])){
$description = $_POST['description'];
}
if(isset($_POST['adsize'])){
$adsize = $_POST['adsize'];
}
}else if($edit){
$title = "Edit ad campaign";
$name = $_POST['name'];
$submitName = "update";
$submitValue = "Save Campaign";
if(isset($_POST['origname'])){
$origname = $_POST['origname'];
}else{
$origname = $name;
}
if(isset($_POST['description'])){
$description = $_POST['description'];
}else{
if(isset($_POST['origname'])){
$description = $this->options['adcampaigns'][$origname]['description'];
}else{
$description = $this->options['adcampaigns'][$name]['description'];
}
}
if(isset($_POST['adsize'])){
$adsize = $_POST['adsize'];
}else{
if(isset($_POST['origname'])){
$adsize = $this->options['adcampaigns'][$origname]['adsize'];
}else{
$adsize = $this->options['adcampaigns'][$name]['adsize'];
}
}
} else if($delete){
return $this->CampaignListTab_update($tab, $action);
}
echo
'';
}
function CampaignListTab_view($tab, $action){
// Create the Custom variable list
$baseurl = $this->pageURL . '&tab=' . $tab . '&action=';
echo
'
Name
Description
Action
';
if(isset($this->options['adcampaigns'])){
$i=0;
foreach($this->options['adcampaigns'] as $key => $value){
echo '';
$i++;
}
}
echo'';
}else{
echo '>';
}
if( !isset($this->options['adsources']) && (!isset($this->options['settings']['adsense']['username']) || !isset($this->options['settings']['adsense']['password']))){
$onClick = 'onClick="alert(\'You need to configure an ad source before you can setup a campaign. You can configure your own local ad sources under Ad Sources or import your Adsense Ad Units as ad sources by configuring Adsense in Settings.\'); return false;"';
}
echo '
';
}
function SourceListTab_update($tab, $action){
//verify data
if($_POST['cancel']){
return $this->SourceListTab_view($tab, $action);
}
$add = isset($_POST['add']);
$delete = isset($_POST['delete']) && isset($_POST['name']) && isset($this->options['adsources'][$_POST['name']]);
$update = isset($_POST['edit']) && isset($_POST['name']) && isset($this->options['adsources'][$_POST['name']]);
if ($add){
if(!isset($_POST['name']) || strlen($_POST['name']) < 1 ){
$_POST['name_error'] = '*Name required';
return $this->SourceListTab_edit($tab, $action);
}
if(isset($this->options['adsources'][$_POST['name']])){
$_POST['name_error'] = '*Name must be unique';
return $this->SourceListTab_edit($tab, $action);
}
}
if($delete){
$name = $_POST['name'];
unset($this->options['adsources'][$name]);
update_option($this->name . "_options", $this->options);
echo 'Deleted Source ' . $name . ' ';
}else{
$name = $_POST['name'];
$this->options['adsources'][$name]['adtype'] = $_POST['adtype'];
if($this->options['adsources'][$name]['adtype'] == "url"){
$this->options['adsources'][$name]['url'] = $_POST['url'];
$this->options['adsources'][$name]['wrap_url'] = isset($_POST['wrap_url']);
$this->options['adsources'][$name]['code'] = "";
} else {
$this->options['adsources'][$name]['url'] = "";
$this->options['adsources'][$name]['wrap_url'] = false;
$this->options['adsources'][$name]['code'] = stripslashes($_POST['code']);
}
$this->options['adsources'][$name]['description'] = $_POST['description'];
update_option($this->name . "_options", $this->options);
if($add){
echo 'Added Source ' . $name . ' ';
}else{
echo 'Updated Source ' . $name . ' ';
}
}
$_POST['name'] = '';
$_POST['adtype'] = '';
$_POST['url'] = '';
$_POST['wrap_url'] = '';
$_POST['code'] = '';
$_POST['description'] = '';
//add to options
return $this->SourceListTab_view($tab, $action);
}
function SourceListTab_edit($tab, $action){
$baseurl = $this->pageURL . '&tab=' . $tab . '&action=';
$cancelurl = $this->pageURL . '&tab=' . $tab . '&action=view';
//verify data
$add = isset($_POST['add']);
$edit = isset($_POST['edit']);
$delete = isset($_POST['delete']);
if ($add){
$title = "Create new ad source";
$urlChecked = "checked";
$codeChecked = "";
$displayURL = "";
$displayCode = "none";
$submitName = "add";
$submitValue = "Add Source";
}else if($edit){
$title = "Edit ad source";
$name = $_POST['name'];
$urlChecked = $this->options['adsources'][$name]['adtype'] == "url"?"checked":"";
$codeChecked = $this->options['adsources'][$name]['adtype'] == "inline"?"checked":"";
$displayURL = $this->options['adsources'][$name]['adtype'] == "url"?"":"none";
$displayCode = $this->options['adsources'][$name]['adtype'] == "inline"?"":"none";
$submitName = "edit";
$submitValue = "Edit Source";
$description = $this->options['adsources'][$name]['description'];
$url = $this->options['adsources'][$name]['url'];
$wrapURL = isset($this->options['adsources'][$name]['wrap_url'])?"checked":"";
$code = $this->options['adsources'][$name]['code'];
} else if($delete){
return $this->SourceListTab_update($tab, $action);
}
echo
'';
//add to options
//$this->SourceListTab_view($tab, $action);
}
function SourceListTab_view($tab, $action){
// Create the Custom variable list
$baseurl = $this->pageURL . '&tab=' . $tab . '&action=';
echo
'';
}
function DisplaySettingsGroup($name, $content, $open){
$ps = $open?'':'style="display:none;"';
$chevron = $open?'collapse.gif':'expand.gif';
$id = str_replace(' ', '', $name);
echo '
' . "\n";
}
function GetAdsenseAdminForm(){
$content =
'' . "\n";
return $content;
}
function GetGeneralSettingsAdminForm(){
$fillAllocation = $this->options['settings']['fillEmptyAllocations']?"checked":"";
$displayDashboard = $this->options['settings']['displayDashboard']?"checked":"";
$adsenseDashboard = $this->options['settings']['adsense']['dashboard']?'checked':'';
$externalAdsEnabled = $this->options['settings']['externalAdsEnabled']?"checked":"";
$adUrlPrefix = $this->options['settings']['adUrlPrefix'];
$gaEnabled = $this->options['settings']['analytics']['enabled'] && strlen($this->options['settings']['analytics']['username']) > 0 && strlen($this->options['settings']['analytics']['password']) > 0?"":"disabled";
$gaVariablesEnabled = $this->options['settings']['analytics']['VariablesEnabled']?"checked":"";
$defaultTab = $this->options['settings']['defaulttab'];
$content =
'' . "\n";
return $content;
}
function GetCommissionJunctionAdminForm(){
$content = "Commission Junction integration still under development ";
return $content;
}
function GetGoogleAnalyticsAdminForm(){
$content = "Google Anayltics integration still under development ";
return $content;
}
function SettingsTab_view($tab, $action){
$baseurl = $this->pageURL . '&tab=' . $tab . '&action=';
echo '' . "\n";
/** Panel for general settings */
$groupOpen = true;
$groupName = "General Settings";
$groupContent = $this->GetGeneralSettingsAdminForm();
$this->DisplaySettingsGroup($groupName, $groupContent, $groupOpen);
/** Panel for Adsense settings */
$groupOpen = true;
$groupName = "Adsense Settings";
$groupContent = $this->GetAdsenseAdminForm();
$this->DisplaySettingsGroup($groupName, $groupContent, $groupOpen);
/** Panel for Google Analytics settings */
$groupOpen = false;
$groupName = "Google Anayltics";
$groupContent = $this->GetGoogleAnalyticsAdminForm();
$this->DisplaySettingsGroup($groupName, $groupContent, $groupOpen);
/** Panel for Commission Junction settings */
$groupOpen = false;
$groupName = "Commission Junction";
$groupContent = $this->GetCommissionJunctionAdminForm();
$this->DisplaySettingsGroup($groupName, $groupContent, $groupOpen);
echo ' ' . "\n";
}
function SettingsTab_update($tab, $action){
//verify data
$update = isset($_POST['update']);
$reloadAdsenseAdsCache = isset($_POST['reload-adsense-ads-cache']);
$reloadAdsenseStatsCache = isset($_POST['reload-adsense-stats-cache']);
if ($reloadAdsenseAdsCache){
if(isset($this->options['settings']['adsense']['username']) && isset($this->options['settings']['adsense']['password'])){
$this->adsense->LoadAdUnits(true);
$this->adsense->Logout();
}
}
if ($reloadAdsenseStatsCache){
if(isset($this->options['settings']['adsense']['username']) && isset($this->options['settings']['adsense']['password'])){
$this->adsense->LoadStats(true);
$this->adsense->Logout();
}
}
if ($update){
/** Update Adsense Settings */
$this->options['settings']['adsense']['username'] = $_POST['adsenseUsername'];
$this->adsense->SetUsername($this->options['settings']['adsense']['username']);
if(isset($_POST['adsensePassword']) && strlen($_POST['adsensePassword']) > 1){
$this->options['settings']['adsense']['password'] = $_POST['adsensePassword'];
$this->adsense->SetPassword($this->options['settings']['adsense']['password']);
}
foreach($this->adsense->GetReportPeriods() as $key => $value){
$this->options['settings']['adsense']['period'][$key] = isset($_POST['adsense_report_period_' . $key]);
}
foreach($this->adsense->GetReportTypes() as $key => $value){
$this->options['settings']['adsense']['type'][$key] = isset($_POST['adsense_report_type_' . $key]);
}
foreach($this->adsense->GetAdCategories() as $key => $value){
$this->options['settings']['adsense']['category'][$key] = isset($_POST['adsense_report_category_' . $key]);
}
if(isset($_POST['adsense-ads-cache-time'])){
$this->options['settings']['adsense']['ads-cache'] = $_POST['adsense-ads-cache-time'];
$this->adsense->SetAdsCache($_POST['adsense-ads-cache-time'] * 360);
}
if(isset($_POST['adsense-stats-cache-time'])){
$this->options['settings']['adsense']['stats-cache'] = $_POST['adsense-stats-cache-time'];
$this->adsense->SetStatsCache($_POST['adsense-stats-cache-time'] * 360);
}
/** Update General Settings */
$this->options['settings']['fillEmptyAllocations'] = isset($_POST['fillEmptyAllocations']);
if(isset($_POST['defaultsource']))
$this->options['settings']['defaultsource'] = $_POST['defaultsource'];
if(isset($_POST['defaulttab']))
$this->options['settings']['defaulttab'] = $_POST['defaulttab'];
$this->options['settings']['displayDashboard'] = isset($_POST['displayDashboard']);
$this->options['settings']['adsense']['dashboard'] = isset($_POST['adsenseDashboard']);
if($this->options['settings']['externalAdsEnabled'] != isset($_POST['externalAdsEnabled'])){
$this->options['settings']['externalRulesUpdated'] = true;
} else if($this->options['settings']['adUrlPrefix'] != $_POST['adUrlPrefix']){
$this->options['settings']['externalRulesUpdated'] = true;
}else{
$this->options['settings']['externalRulesUpdated'] = false;
}
$this->options['settings']['externalAdsEnabled'] = isset($_POST['externalAdsEnabled']);
$this->options['settings']['adUrlPrefix'] = $_POST['adUrlPrefix'];
$this->options['settings']['analytics']['VariablesEnabled'] = isset($_POST['gaVariablesEnabled']);
$this->options['settings']['ipinfodbkey'] = $_POST['ipinfodbkey'];
/** Save the updated settings */
update_option($this->name . "_options", $this->options);
if($this->options['settings']['externalRulesUpdated'])
$this->FlushRewrites();
}
//add to options
$this->SettingsTab_view($tab, $action);
}
function DisplayHandbookSection($name, $content){
$open = $name == "Getting Started";
$style = 'style="text-align:left;';
$style .= $open ?'"':'display:none;"';
$chevron = $open?'collapse.gif':'expand.gif';
echo '
' . "\n";
}
function MarkupHandbookSection($section){
$content = '' . "\n";
//$content .= str_replace("\n+", ' ', $section);
$content .= $section;
$content .= '
' . "\n";
return $content;
}
function GetHandbookSections($path){
$handbookText = file_get_contents($path, true);
//split('= section =', $handbookText);
$chunks = preg_split('/<-- ([^>]+) -->/i', $handbookText, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
$sections = array();
for($i = 0; $i < count($chunks); $i++){
$sections[$chunks[$i]] = $this->MarkupHandbookSection($chunks[$i + 1]);
$i++;
}
return $sections;
}
function HandbookTab_view($tab, $action){
$sections = $this->GetHandbookSections($this->handbookPath);
foreach($sections as $name => $content){
if(isset($name) && isset($content))
$this->DisplayHandbookSection($name, $content);
}
}
function AboutTab_view($tab, $action){
echo ' ' . "\n";
echo 'Advertwhirl (pronounced Adver-twhirl) is a wordpress plugin that lets you set up advertising campaigns for your site. Each campaign has 1 or more allocation strategies which can be made active manually or by schedule. Each allocation strategy defines what ad-servers the campaign uses and how ads are rotated between them. Campaigns can be accessed through a shortcode. ' . "\n";
echo 'Example shortcode ' . "\n";
echo '[Âadvertwhirl campaign=CAMPAIGN] ' . "\n";
echo '© Copyright 2011 Mobile Sentience LLC ' . "\n";
echo 'Written by Max Jonathan Spaulding - Mobile Sentience LLC ' . "\n";
echo ' ' . "\n";
echo 'This program is free software; you can redistribute it and/or modify ' . "\n";
echo 'it under the terms of the GNU General Public License as published by ' . "\n";
echo 'the Free Software Foundation; either version 2 of the License, or ' . "\n";
echo '(at your option) any later version. ' . "\n";
echo ' ' . "\n";
echo 'This program is distributed in the hope that it will be useful, ' . "\n";
echo 'but WITHOUT ANY WARRANTY; without even the implied warranty of ' . "\n";
echo 'MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ' . "\n";
echo 'GNU General Public License for more details. ' . "\n";
echo ' ' . "\n";
echo 'You should have received a copy of the GNU General Public License ' . "\n";
echo 'along with this program; if not, write to the Free Software ' . "\n";
echo 'Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ' . "\n";
}
function SupportTab_view($tab, $action){
$defaultSubject = 'Bug Report: ' . $this->name . ' Version ' . $this->version;
$defaultMessage = "\n\n\n\n\n\n" . $this->GetTechnicalSpecs();
include_once($this->libraryPath . "/captcha/shared.php");
include_once($this->libraryPath . "/captcha/captcha_code.php");
$wpf_captcha = new CaptchaCode();
$wpf_code = wpf_str_encrypt($wpf_captcha->generateCode(6));
echo '
Mobile Sentience LLC actively supports Advertwhirl if you have any questions or problems you can fill out the form below. The message is pre-filled with some technical specs which will help us troubleshoot any issues. Mobile Sentience provides all support through a public forum, this helps us manage our support costs as well as providing a searchable reference of past problems and questions that other users of encountered. A great place to start if you have a simple question is to see if it has already been asked and answered on the Advertwhirl Support Forum
' . "\n";
}
function getRightMost($sSrc, $sSrch) {
for ($i = strlen($sSrc); $i >= 0; $i = $i - 1) {
$f = strpos($sSrc, $sSrch, $i);
if ($f !== FALSE) {
return substr($sSrc,$f + strlen($sSrch), strlen($sSrc));
}
}
return $sSrc;
}
public function DisplayAdminTabs($activeTab){
echo '' . "\n";
echo '
' . "\n";
}
public function DisplayAdminContent($tab, $action){
echo '
' . "\n";
echo '
' . "\n";
if(isset($this->AdminTabs[$tab])){
$func = $this->AdminTabs[$tab]['method_base'] . "_" . $action;
if(!method_exists($this, $func)){
$func = $this->AdminTabs[$tab]['method_base'] . "_view";
}
if(method_exists($this, $func)){
call_user_func(array(&$this, $func), $tab, $action);
}
}
echo '
' . "\n";
echo '
' . "\n";
echo '
' . "\n";
}
// Create the administration panel
public function CreateAdminPanel(){
$activeTab = $this->options['settings']['defaulttab'];
if(isset($_GET['tab'])){
if(isset($this->AdminTabs[$_GET['tab']])){
$activeTab = $_GET['tab'];
}
}
$action = "view";
if(isset($_GET['action'])){
$action = $_GET['action'];
}
if(get_option('siteurl') != 'http://www.mobilesentience.com') $this->DisplayMobileSentienceAd();
$this->DisplayAdminBanner($activeTab);
$this->DisplayAdminTabs($activeTab);
$this->DisplayAdminContent($activeTab, $action);
}
}
?>