Changeset 707649
- Timestamp:
- 05/03/2013 09:37:09 PM (13 years ago)
- Location:
- admangler
- Files:
-
- 11 edited
- 2 copied
-
tags/0.0.10.Aplha (copied) (copied from admangler/trunk)
-
tags/0.0.10.Aplha/adMangler.class.php (modified) (20 diffs)
-
tags/0.0.10.Aplha/adMangler.php (modified) (1 diff)
-
tags/0.0.10.Aplha/adManglerWidget.class.php (modified) (2 diffs)
-
tags/0.0.10.Aplha/trunk (copied) (copied from admangler/trunk)
-
tags/0.0.10.Aplha/trunk/adMangler.class.php (modified) (20 diffs)
-
tags/0.0.10.Aplha/trunk/adMangler.php (modified) (1 diff)
-
tags/0.0.10.Aplha/trunk/adManglerWidget.class.php (modified) (2 diffs)
-
tags/0.0.10.Aplha/trunk/readme.txt (modified) (3 diffs)
-
trunk/adMangler.class.php (modified) (20 diffs)
-
trunk/adMangler.php (modified) (1 diff)
-
trunk/adManglerWidget.class.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
admangler/tags/0.0.10.Aplha/adMangler.class.php
r363418 r707649 1 1 <?php 2 3 2 class AdMangler 4 3 { 5 function AdMangler() 6 { 4 var $codeVersion = null; 5 var $dbVersion = null; 6 7 function __construct($codeVersion=null, $dbVersion=null) 8 { 9 if ( !is_null($dbVersion) && !is_null($codeVersion) ) 10 { 11 if ( is_null($this->dbVersion) ) 12 $this->dbVersion = $dbVersion; 13 if ( is_null($this->codeVersion) ) 14 $this->codeVersion = $codeVersion; 15 } 16 7 17 global $wpdb; 8 18 $this->adsTable = $wpdb->prefix."AdMangler_ads"; … … 10 20 $this->usersTable = $wpdb->prefix."AdMangler_users"; 11 21 $this->positionsTable = $wpdb->prefix."AdMangler_positions"; 22 23 // Generate the Admin Menu 24 if ( is_admin() ) 25 { 26 //register_activation_hook(__FILE__, array($this, "activate")); 27 add_action('admin_menu', array($this, 'admin_menu')); 28 wp_enqueue_script('admanglertooltip', '/' . PLUGINDIR . '/admangler/js/tooltip.js'); 29 } 30 31 add_filter('the_content', array($this, 'filter_the_content')); 32 add_shortcode('AdMangler', array($this, 'short_code_helper')); 33 add_shortcode('admangler', array($this, 'short_code_helper')); 34 35 add_action('init', array($this, 'register_widgets'), 1); 12 36 } // End function AdMangler 13 37 14 function AdminMenu() 15 { 16 add_menu_page('AdMangler Settings', 'AdMangler', 9, __FILE__, array($this, 'CreateAdminPage'), '/'. PLUGINDIR . '/admangler/images/logo.gif'); 17 //add_submenu_page(__FILE__, 'AdMangler Settings', 'Settings', 9, 'settings', array($this, 'CreateAdminPage')); 18 add_submenu_page(__FILE__, 'AdMangler Settings', 'Banners', 9, 'banners', array($this, 'CreateAdminPage')); 19 } // End function AdminMenu 20 21 function Activate() 22 { 23 global $wpdb; 24 // Plugin database table version 25 $db_version = "0.0.7"; // You must increment this if we change the database other wise leave it alone 26 $sql[] = "CREATE TABLE ".$wpdb->prefix."AdMangler_ads ( 27 id INT(11) NOT NULL AUTO_INCREMENT, 28 advertiser VARCHAR(256) COLLATE utf8_bin NOT NULL DEFAULT 'admin', 29 width INT(11) NOT NULL, 30 height INT(11) NOT NULL, 31 active BOOL NOT NULL DEFAULT 0, 32 approved BOOL NOT NULL DEFAULT 0, 33 base BOOL NOT NULL DEFAULT 0, 34 type VARCHAR(5) COLLATE utf8_bin NOT NULL DEFAULT 'image', 35 code TEXT COLLATE utf8_bin, 36 href VARCHAR(256) character set utf8 collate utf8_bin NOT NULL default 'http://www.webternals.com/projects/admangler/', 37 src VARCHAR(256) NOT NULL default 'http://www.webternals.com/images/no-image.png', 38 UNIQUE KEY id (id) 39 );"; 40 41 $sql[] = "CREATE TABLE ".$wpdb->prefix."AdMangler_positions ( 42 ad_ID INT(11) NOT NULL, 43 page_ID INT(11) NOT NULL, 44 page_exclusive INT(1) NOT NULL DEFAULT 0, 45 custom_slot INT(1) NOT NULL DEFAULT 0, 46 slot INT(11) NOT NULL DEFAULT 0, 47 slot_exclusive INT(1) NOT NULL DEFAULT 0 48 );"; 49 50 $sql[] = "CREATE TABLE ".$wpdb->prefix."AdMangler_settings ( 51 id INT(11) NOT NULL AUTO_INCREMENT, 52 name VARCHAR(256) COLLATE utf8_bin NOT NULL, 53 value VARCHAR(256) COLLATE utf8_bin NOT NULL, 54 UNIQUE KEY id (id), 55 PRIMARY KEY name (name) 56 );"; 57 58 $sql[] = "CREATE TABLE ".$wpdb->prefix."AdMangler_users ( 59 id INT(11) NOT NULL AUTO_INCREMENT, 60 username VARCHAR(256) COLLATE utf8_bin NOT NULL, 61 password VARCHAR(256) COLLATE utf8_bin NOT NULL, 62 email VARCHAR(256) COLLATE utf8_bin NOT NULL, 63 credits FLOAT(10,2), 64 active BOOL DEFAULT 0, 65 confirm VARCHAR(256) COLLATE utf8_bin, 66 UNIQUE KEY id (id), 67 PRIMARY KEY username (username) 68 );"; 69 38 function admin_menu() 39 { 40 add_menu_page('AdMangler Settings', 'AdMangler', 9, __FILE__, array($this, 'create_admin_page'), '/'. PLUGINDIR . '/admangler/images/logo.gif'); 41 //add_submenu_page(__FILE__, 'AdMangler Settings', 'Settings', 9, 'settings', array($this, 'create_admin_page')); 42 add_submenu_page(__FILE__, 'AdMangler Settings', 'Banners', 9, 'banners', array($this, 'create_admin_page')); 43 } // End function admin_menu 44 45 function activate() 46 { 47 ob_start(); 48 global $wpdb; 70 49 // Installed plugin database table version 71 $installed_ver = get_option('AdMangler_db_version'); 50 $installed_version = get_option('AdMangler_db_version'); 51 if ( false === $installed_version ) 52 $installed_version = '0.0.0'; 72 53 73 54 // If the database has changed, update the structure while preserving data 74 if (empty($installed_ver) || $db_version != $installed_ver) 75 { 55 if ( version_compare( $installed_version, $this->dbVersion, '<') ) 56 { 57 // Plugin database table version 58 $sql[] = "CREATE TABLE ".$wpdb->prefix."AdMangler_ads ( 59 id INT(11) NOT NULL AUTO_INCREMENT, 60 advertiser VARCHAR(256) COLLATE utf8_bin NOT NULL DEFAULT 'admin', 61 width INT(11) NOT NULL, 62 height INT(11) NOT NULL, 63 active BOOL NOT NULL DEFAULT 0, 64 approved BOOL NOT NULL DEFAULT 0, 65 base BOOL NOT NULL DEFAULT 0, 66 type VARCHAR(5) COLLATE utf8_bin NOT NULL DEFAULT 'image', 67 code TEXT COLLATE utf8_bin, 68 href VARCHAR(256) character set utf8 collate utf8_bin NOT NULL default 'http://www.webternals.com/projects/admangler/', 69 src VARCHAR(256) NOT NULL default 'http://www.webternals.com/images/no-image.png', 70 UNIQUE KEY id (id) 71 );"; 72 73 $sql[] = "CREATE TABLE ".$wpdb->prefix."AdMangler_positions ( 74 ad_ID INT(11) NOT NULL, 75 page_ID INT(11) NOT NULL, 76 page_exclusive INT(1) NOT NULL DEFAULT 0, 77 custom_slot INT(1) NOT NULL DEFAULT 0, 78 slot INT(11) NOT NULL DEFAULT 0, 79 slot_exclusive INT(1) NOT NULL DEFAULT 0 80 );"; 81 82 $sql[] = "CREATE TABLE ".$wpdb->prefix."AdMangler_settings ( 83 id INT(11) NOT NULL AUTO_INCREMENT, 84 name VARCHAR(256) COLLATE utf8_bin NOT NULL, 85 value VARCHAR(256) COLLATE utf8_bin NOT NULL, 86 UNIQUE KEY id (id), 87 PRIMARY KEY name (name) 88 );"; 89 90 $sql[] = "CREATE TABLE ".$wpdb->prefix."AdMangler_users ( 91 id INT(11) NOT NULL AUTO_INCREMENT, 92 username VARCHAR(256) COLLATE utf8_bin NOT NULL, 93 password VARCHAR(256) COLLATE utf8_bin NOT NULL, 94 email VARCHAR(256) COLLATE utf8_bin NOT NULL, 95 credits FLOAT(10,2), 96 active BOOL DEFAULT 0, 97 confirm VARCHAR(256) COLLATE utf8_bin, 98 UNIQUE KEY id (id), 99 PRIMARY KEY username (username) 100 );"; 101 76 102 require_once ABSPATH . "wp-admin/includes/upgrade.php"; 77 103 foreach($sql as $temp) 78 104 dbDelta($temp); 79 105 if (get_option('AdMangler_db_version')) 80 update_option('AdMangler_db_version', $db_version); 106 { 107 update_option('AdMangler_db_version', $this->dbVersion); 108 } 81 109 else 82 add_option('AdMangler_db_version', $db_version); 83 } 84 self::SendStatistics(); 110 { 111 add_option('AdMangler_db_version', $this->dbVersion); 112 } 113 114 } 115 $this->send_statistics(); 116 //file_put_contents(dirname(__FILE__)."/log.txt", var_export($this, true), FILE_APPEND); 85 117 return true; 86 } // End function Activate87 88 function ConfirmRegistration()118 } // End function activate 119 120 function confirm_registration() 89 121 { 90 122 global $wpdb; … … 93 125 return true; 94 126 return false; 95 } // End function ConfirmRegistration()96 97 function CreateAdminPage()127 } // End function confirm_registration() 128 129 function create_admin_page() 98 130 { 99 131 echo "<div class=\"wrap\"><h2>AdMangler Admin</h2>"; … … 111 143 } 112 144 echo "</div>"; 113 } // End function CreateAdminPage114 115 function FilterTheContent($content)145 } // End function create_admin_page 146 147 function filter_the_content($content) 116 148 { 117 149 global $wpdb; … … 121 153 foreach ($results as $banner) 122 154 { 123 $content = str_replace("[AdMangler:".$banner->width."x".$banner->height."]", $this-> GetAds($banner->width, $banner->height), $content);124 } 125 $content = str_replace('[AdMangler: Panel]', $this->Panel(), $content);155 $content = str_replace("[AdMangler:".$banner->width."x".$banner->height."]", $this->get_ads($banner->width, $banner->height), $content); 156 } 157 $content = str_replace('[AdMangler:panel]', $this->panel(), $content); 126 158 return $content; 127 } // End function FilterTheContent128 129 function FormatAd($banner)159 } // End function filter_the_content 160 161 function format_ad($banner) 130 162 { 131 163 switch($banner->type) … … 138 170 } 139 171 return $code; 140 } //End function FormatAd141 142 function GetAdById($id, $return)172 } //End function format_ad 173 174 function get_ad_by_id($id, $return) 143 175 { 144 176 global $wpdb; 145 177 $sql = "SELECT type,code,href,src,width,height FROM $this->adsTable WHERE id=".intval($id); 146 178 $row = $wpdb->get_row($sql); 147 $str = $this-> FormatAd($row);179 $str = $this->format_ad($row); 148 180 149 181 if ($return) return $str; else echo $str; 150 } // End function GetAdById151 152 function GetAd($options = array('width'=>null,'height'=>null,'pageID'=>null,'position'=>null,'return'=>true))182 } // End function get_ad_by_id 183 184 function get_ad($options = array('width'=>null,'height'=>null,'pageID'=>null,'position'=>null,'return'=>true)) 153 185 { 154 186 global $wpdb; … … 208 240 $banner = array_shift($this->banners[$width."x".$height][0]); 209 241 array_push($this->banners[$width."x".$height][0], $banner); 210 $str = $this-> FormatAd($banner);242 $str = $this->format_ad($banner); 211 243 if ($return) return $str; else echo $str; 212 244 exit(1); … … 239 271 $banner = array_shift($this->banners[$width."x".$height][1]); 240 272 array_push($this->banners[$width."x".$height][1], $banner); 241 $str = $this-> FormatAd($banner);273 $str = $this->format_ad($banner); 242 274 if ($return) return $str; else echo $str; 243 275 exit(1); … … 270 302 $banner = array_shift($this->banners[$width."x".$height][2]); 271 303 array_push($this->banners[$width."x".$height][2], $banner); 272 $str = $this-> FormatAd($banner);304 $str = $this->format_ad($banner); 273 305 if ($return) return $str; else echo $str; 274 306 exit(1); … … 301 333 $banner = array_shift($this->banners[$width."x".$height][3]); 302 334 array_push($this->banners[$width."x".$height][3], $banner); 303 $str = $this-> FormatAd($banner);335 $str = $this->format_ad($banner); 304 336 if ($return) return $str; else echo $str; 305 337 exit(1); … … 312 344 } 313 345 314 function GetAds($width=468, $height=60, $return=true)346 function get_ads($width=468, $height=60, $return=true) 315 347 { 316 348 global $wpdb; … … 337 369 $banner = array_shift($this->banners[$width."x".$height]); 338 370 array_push($this->banners[$width."x".$height], $banner); 339 $str = $this-> FormatAd($banner);371 $str = $this->format_ad($banner); 340 372 341 373 if ($return) return $str; else echo $str; 342 } // End function GetAds343 344 function Login()374 } // End function get_ads 375 376 function login() 345 377 { 346 378 global $wpdb; … … 355 387 } 356 388 return false; 357 } // End function Login()358 359 function Logout()389 } // End function login() 390 391 function logout() 360 392 { 361 393 unset($_SESSION['AdMangler']); 362 394 return true; 363 } // End function Logout364 365 function Panel()395 } // End function logout 396 397 function panel() 366 398 { 367 399 $action = (isset($_GET['action'])) ? $_GET['action'] : 'login'; … … 373 405 } // End PublicForm 374 406 375 function Register()407 function register() 376 408 { 377 409 global $wpdb; … … 393 425 } 394 426 return false; 395 } // End function Login()396 397 function RegisterWidgets()427 } // End function login() 428 429 function register_widgets() 398 430 { 399 431 register_widget('AdManglerWidget'); // This adds the Widget to the backend 400 432 } 401 433 402 function ResetPassword()434 function reset_password() 403 435 { 404 436 global $wpdb; … … 407 439 return true; 408 440 return false; 409 } // End function ResetPassword()410 411 function ShortCodeHandler($atts, $content=null, $code="")441 } // End function reset_password() 442 443 function short_code_helper($atts, $content=null, $code="") 412 444 { 413 445 // $atts ::= array of attributes … … 422 454 423 455 if (!isset($atts['type'])) 424 return $this-> GetAd($atts);425 else if (isset($atts['type']) && 0 == strcmp($atts['type'], " Panel"))426 return $this-> Panel();456 return $this->get_ad($atts); 457 else if (isset($atts['type']) && 0 == strcmp($atts['type'], "panel")) 458 return $this->panel(); 427 459 else 428 460 return ""; 429 461 } 430 462 431 function SetConfirmationKey()463 function set_confirmation_key() 432 464 { 433 465 global $wpdb; … … 442 474 } 443 475 return false; 444 } // End function SetConfirmationKey() 445 446 function SendStatistics($url=null) 476 } // End function set_confirmation_key() 477 478 function set_db_version( $version = "0.0.0" ) 479 { 480 $this->dbVersion = $version; 481 } 482 483 function set_code_version( $version = "0.0.0" ) 484 { 485 $this->codeVersion = $version; 486 } 487 488 function send_statistics($url=null) 447 489 { 448 490 if (in_array ('curl', get_loaded_extensions())) … … 480 522 } 481 523 482 function ValidConfirmationKey()524 function valid_confirmation_key() 483 525 { 484 526 global $wpdb; … … 487 529 return true; 488 530 return false; 489 } // End function ValidConfirmationKey()531 } // End function valid_confirmation_key() 490 532 491 533 } // End class AdMangler -
admangler/tags/0.0.10.Aplha/adMangler.php
r630284 r707649 4 4 Plugin URI: http://www.webternals.com/projects/admangler/ 5 5 Description: Display, sell, and manage ad space on your Wordpress powered site with AdMangler. 6 Version: 0.0. 9.4.Alpha6 Version: 0.0.10.Alpha 7 7 Author: Webternals, LLC - Allen Sanford 8 8 Author URI: http://www.webternals.com/ 9 9 */ 10 /** 11 * 12 * DO NOT FORGET TO SET THE VERSIONS in adMangler.class.php if they change 13 * Both DB and CLASS 14 * 15 * */ 16 17 18 $codeVersion = '0.0.10.Alpha'; 19 $dbVersion = '0.0.8'; 10 20 11 21 if (!session_id()) 12 22 session_start(); 13 23 14 // Check for class include and activ ete the class24 // Check for class include and activate the class 15 25 if (!class_exists('AdMangler')) 16 26 { 17 27 require_once(dirname(__FILE__).'/adMangler.class.php'); 18 $adMangler = new AdMangler( );28 $adMangler = new AdMangler( $codeVersion, $dbVersion ); 19 29 require_once(dirname(__FILE__).'/adManglerWidget.class.php'); 20 30 } // End if (!class_exists('AdMangler') 21 31 22 //Setup actions, hooks and filters 23 if (isset($adMangler)) 24 { 25 // Generate the Admin Menu 26 if ( is_admin() ) 27 { 28 // Activation function 29 register_activation_hook(__FILE__, array('AdMangler', 'Activate')); 30 add_action('admin_menu', array($adMangler, 'AdminMenu')); 31 wp_enqueue_script('admanglertooltip', '/' . PLUGINDIR . '/admangler/js/tooltip.js'); 32 } 33 else 34 { 35 add_filter('the_content', array($adMangler, 'FilterTheContent')); 36 add_shortcode('AdMangler', array($adMangler, 'ShortCodeHandler')); 37 add_shortcode('admangler', array($adMangler, 'ShortCodeHandler')); 38 } 39 add_action('init', array('AdMangler', 'RegisterWidgets'), 1); 40 wp_enqueue_script("jquery"); 41 wp_enqueue_script('jquery.validate', '/' . PLUGINDIR . '/admangler/js/jquery.validate.min.js'); 42 43 } // End if (isset($adMangler)) 32 // Must be activated here and like this. will not work in the constructor for some reason. 33 register_activation_hook(__FILE__, array($adMangler, "activate")); 34 35 wp_enqueue_script("jquery"); 36 wp_enqueue_script('jquery.validate', '/' . PLUGINDIR . '/admangler/js/jquery.validate.min.js'); 44 37 ?> -
admangler/tags/0.0.10.Aplha/adManglerWidget.class.php
r293001 r707649 3 3 { 4 4 5 function AdManglerWidget()5 function __construct() 6 6 { 7 7 parent::WP_Widget(false, $name = 'AdMangler Widget'); … … 24 24 25 25 global $adMangler; 26 $content = $adMangler-> GetAd($options); // Here we get the post's excerpt26 $content = $adMangler->get_ad($options); // Here we get the post's excerpt 27 27 ?> 28 28 <?php echo $before_widget; ?> -
admangler/tags/0.0.10.Aplha/trunk/adMangler.class.php
r363418 r707649 1 1 <?php 2 3 2 class AdMangler 4 3 { 5 function AdMangler() 6 { 4 var $codeVersion = null; 5 var $dbVersion = null; 6 7 function __construct($codeVersion=null, $dbVersion=null) 8 { 9 if ( !is_null($dbVersion) && !is_null($codeVersion) ) 10 { 11 if ( is_null($this->dbVersion) ) 12 $this->dbVersion = $dbVersion; 13 if ( is_null($this->codeVersion) ) 14 $this->codeVersion = $codeVersion; 15 } 16 7 17 global $wpdb; 8 18 $this->adsTable = $wpdb->prefix."AdMangler_ads"; … … 10 20 $this->usersTable = $wpdb->prefix."AdMangler_users"; 11 21 $this->positionsTable = $wpdb->prefix."AdMangler_positions"; 22 23 // Generate the Admin Menu 24 if ( is_admin() ) 25 { 26 //register_activation_hook(__FILE__, array($this, "activate")); 27 add_action('admin_menu', array($this, 'admin_menu')); 28 wp_enqueue_script('admanglertooltip', '/' . PLUGINDIR . '/admangler/js/tooltip.js'); 29 } 30 31 add_filter('the_content', array($this, 'filter_the_content')); 32 add_shortcode('AdMangler', array($this, 'short_code_helper')); 33 add_shortcode('admangler', array($this, 'short_code_helper')); 34 35 add_action('init', array($this, 'register_widgets'), 1); 12 36 } // End function AdMangler 13 37 14 function AdminMenu() 15 { 16 add_menu_page('AdMangler Settings', 'AdMangler', 9, __FILE__, array($this, 'CreateAdminPage'), '/'. PLUGINDIR . '/admangler/images/logo.gif'); 17 //add_submenu_page(__FILE__, 'AdMangler Settings', 'Settings', 9, 'settings', array($this, 'CreateAdminPage')); 18 add_submenu_page(__FILE__, 'AdMangler Settings', 'Banners', 9, 'banners', array($this, 'CreateAdminPage')); 19 } // End function AdminMenu 20 21 function Activate() 22 { 23 global $wpdb; 24 // Plugin database table version 25 $db_version = "0.0.7"; // You must increment this if we change the database other wise leave it alone 26 $sql[] = "CREATE TABLE ".$wpdb->prefix."AdMangler_ads ( 27 id INT(11) NOT NULL AUTO_INCREMENT, 28 advertiser VARCHAR(256) COLLATE utf8_bin NOT NULL DEFAULT 'admin', 29 width INT(11) NOT NULL, 30 height INT(11) NOT NULL, 31 active BOOL NOT NULL DEFAULT 0, 32 approved BOOL NOT NULL DEFAULT 0, 33 base BOOL NOT NULL DEFAULT 0, 34 type VARCHAR(5) COLLATE utf8_bin NOT NULL DEFAULT 'image', 35 code TEXT COLLATE utf8_bin, 36 href VARCHAR(256) character set utf8 collate utf8_bin NOT NULL default 'http://www.webternals.com/projects/admangler/', 37 src VARCHAR(256) NOT NULL default 'http://www.webternals.com/images/no-image.png', 38 UNIQUE KEY id (id) 39 );"; 40 41 $sql[] = "CREATE TABLE ".$wpdb->prefix."AdMangler_positions ( 42 ad_ID INT(11) NOT NULL, 43 page_ID INT(11) NOT NULL, 44 page_exclusive INT(1) NOT NULL DEFAULT 0, 45 custom_slot INT(1) NOT NULL DEFAULT 0, 46 slot INT(11) NOT NULL DEFAULT 0, 47 slot_exclusive INT(1) NOT NULL DEFAULT 0 48 );"; 49 50 $sql[] = "CREATE TABLE ".$wpdb->prefix."AdMangler_settings ( 51 id INT(11) NOT NULL AUTO_INCREMENT, 52 name VARCHAR(256) COLLATE utf8_bin NOT NULL, 53 value VARCHAR(256) COLLATE utf8_bin NOT NULL, 54 UNIQUE KEY id (id), 55 PRIMARY KEY name (name) 56 );"; 57 58 $sql[] = "CREATE TABLE ".$wpdb->prefix."AdMangler_users ( 59 id INT(11) NOT NULL AUTO_INCREMENT, 60 username VARCHAR(256) COLLATE utf8_bin NOT NULL, 61 password VARCHAR(256) COLLATE utf8_bin NOT NULL, 62 email VARCHAR(256) COLLATE utf8_bin NOT NULL, 63 credits FLOAT(10,2), 64 active BOOL DEFAULT 0, 65 confirm VARCHAR(256) COLLATE utf8_bin, 66 UNIQUE KEY id (id), 67 PRIMARY KEY username (username) 68 );"; 69 38 function admin_menu() 39 { 40 add_menu_page('AdMangler Settings', 'AdMangler', 9, __FILE__, array($this, 'create_admin_page'), '/'. PLUGINDIR . '/admangler/images/logo.gif'); 41 //add_submenu_page(__FILE__, 'AdMangler Settings', 'Settings', 9, 'settings', array($this, 'create_admin_page')); 42 add_submenu_page(__FILE__, 'AdMangler Settings', 'Banners', 9, 'banners', array($this, 'create_admin_page')); 43 } // End function admin_menu 44 45 function activate() 46 { 47 ob_start(); 48 global $wpdb; 70 49 // Installed plugin database table version 71 $installed_ver = get_option('AdMangler_db_version'); 50 $installed_version = get_option('AdMangler_db_version'); 51 if ( false === $installed_version ) 52 $installed_version = '0.0.0'; 72 53 73 54 // If the database has changed, update the structure while preserving data 74 if (empty($installed_ver) || $db_version != $installed_ver) 75 { 55 if ( version_compare( $installed_version, $this->dbVersion, '<') ) 56 { 57 // Plugin database table version 58 $sql[] = "CREATE TABLE ".$wpdb->prefix."AdMangler_ads ( 59 id INT(11) NOT NULL AUTO_INCREMENT, 60 advertiser VARCHAR(256) COLLATE utf8_bin NOT NULL DEFAULT 'admin', 61 width INT(11) NOT NULL, 62 height INT(11) NOT NULL, 63 active BOOL NOT NULL DEFAULT 0, 64 approved BOOL NOT NULL DEFAULT 0, 65 base BOOL NOT NULL DEFAULT 0, 66 type VARCHAR(5) COLLATE utf8_bin NOT NULL DEFAULT 'image', 67 code TEXT COLLATE utf8_bin, 68 href VARCHAR(256) character set utf8 collate utf8_bin NOT NULL default 'http://www.webternals.com/projects/admangler/', 69 src VARCHAR(256) NOT NULL default 'http://www.webternals.com/images/no-image.png', 70 UNIQUE KEY id (id) 71 );"; 72 73 $sql[] = "CREATE TABLE ".$wpdb->prefix."AdMangler_positions ( 74 ad_ID INT(11) NOT NULL, 75 page_ID INT(11) NOT NULL, 76 page_exclusive INT(1) NOT NULL DEFAULT 0, 77 custom_slot INT(1) NOT NULL DEFAULT 0, 78 slot INT(11) NOT NULL DEFAULT 0, 79 slot_exclusive INT(1) NOT NULL DEFAULT 0 80 );"; 81 82 $sql[] = "CREATE TABLE ".$wpdb->prefix."AdMangler_settings ( 83 id INT(11) NOT NULL AUTO_INCREMENT, 84 name VARCHAR(256) COLLATE utf8_bin NOT NULL, 85 value VARCHAR(256) COLLATE utf8_bin NOT NULL, 86 UNIQUE KEY id (id), 87 PRIMARY KEY name (name) 88 );"; 89 90 $sql[] = "CREATE TABLE ".$wpdb->prefix."AdMangler_users ( 91 id INT(11) NOT NULL AUTO_INCREMENT, 92 username VARCHAR(256) COLLATE utf8_bin NOT NULL, 93 password VARCHAR(256) COLLATE utf8_bin NOT NULL, 94 email VARCHAR(256) COLLATE utf8_bin NOT NULL, 95 credits FLOAT(10,2), 96 active BOOL DEFAULT 0, 97 confirm VARCHAR(256) COLLATE utf8_bin, 98 UNIQUE KEY id (id), 99 PRIMARY KEY username (username) 100 );"; 101 76 102 require_once ABSPATH . "wp-admin/includes/upgrade.php"; 77 103 foreach($sql as $temp) 78 104 dbDelta($temp); 79 105 if (get_option('AdMangler_db_version')) 80 update_option('AdMangler_db_version', $db_version); 106 { 107 update_option('AdMangler_db_version', $this->dbVersion); 108 } 81 109 else 82 add_option('AdMangler_db_version', $db_version); 83 } 84 self::SendStatistics(); 110 { 111 add_option('AdMangler_db_version', $this->dbVersion); 112 } 113 114 } 115 $this->send_statistics(); 116 //file_put_contents(dirname(__FILE__)."/log.txt", var_export($this, true), FILE_APPEND); 85 117 return true; 86 } // End function Activate87 88 function ConfirmRegistration()118 } // End function activate 119 120 function confirm_registration() 89 121 { 90 122 global $wpdb; … … 93 125 return true; 94 126 return false; 95 } // End function ConfirmRegistration()96 97 function CreateAdminPage()127 } // End function confirm_registration() 128 129 function create_admin_page() 98 130 { 99 131 echo "<div class=\"wrap\"><h2>AdMangler Admin</h2>"; … … 111 143 } 112 144 echo "</div>"; 113 } // End function CreateAdminPage114 115 function FilterTheContent($content)145 } // End function create_admin_page 146 147 function filter_the_content($content) 116 148 { 117 149 global $wpdb; … … 121 153 foreach ($results as $banner) 122 154 { 123 $content = str_replace("[AdMangler:".$banner->width."x".$banner->height."]", $this-> GetAds($banner->width, $banner->height), $content);124 } 125 $content = str_replace('[AdMangler: Panel]', $this->Panel(), $content);155 $content = str_replace("[AdMangler:".$banner->width."x".$banner->height."]", $this->get_ads($banner->width, $banner->height), $content); 156 } 157 $content = str_replace('[AdMangler:panel]', $this->panel(), $content); 126 158 return $content; 127 } // End function FilterTheContent128 129 function FormatAd($banner)159 } // End function filter_the_content 160 161 function format_ad($banner) 130 162 { 131 163 switch($banner->type) … … 138 170 } 139 171 return $code; 140 } //End function FormatAd141 142 function GetAdById($id, $return)172 } //End function format_ad 173 174 function get_ad_by_id($id, $return) 143 175 { 144 176 global $wpdb; 145 177 $sql = "SELECT type,code,href,src,width,height FROM $this->adsTable WHERE id=".intval($id); 146 178 $row = $wpdb->get_row($sql); 147 $str = $this-> FormatAd($row);179 $str = $this->format_ad($row); 148 180 149 181 if ($return) return $str; else echo $str; 150 } // End function GetAdById151 152 function GetAd($options = array('width'=>null,'height'=>null,'pageID'=>null,'position'=>null,'return'=>true))182 } // End function get_ad_by_id 183 184 function get_ad($options = array('width'=>null,'height'=>null,'pageID'=>null,'position'=>null,'return'=>true)) 153 185 { 154 186 global $wpdb; … … 208 240 $banner = array_shift($this->banners[$width."x".$height][0]); 209 241 array_push($this->banners[$width."x".$height][0], $banner); 210 $str = $this-> FormatAd($banner);242 $str = $this->format_ad($banner); 211 243 if ($return) return $str; else echo $str; 212 244 exit(1); … … 239 271 $banner = array_shift($this->banners[$width."x".$height][1]); 240 272 array_push($this->banners[$width."x".$height][1], $banner); 241 $str = $this-> FormatAd($banner);273 $str = $this->format_ad($banner); 242 274 if ($return) return $str; else echo $str; 243 275 exit(1); … … 270 302 $banner = array_shift($this->banners[$width."x".$height][2]); 271 303 array_push($this->banners[$width."x".$height][2], $banner); 272 $str = $this-> FormatAd($banner);304 $str = $this->format_ad($banner); 273 305 if ($return) return $str; else echo $str; 274 306 exit(1); … … 301 333 $banner = array_shift($this->banners[$width."x".$height][3]); 302 334 array_push($this->banners[$width."x".$height][3], $banner); 303 $str = $this-> FormatAd($banner);335 $str = $this->format_ad($banner); 304 336 if ($return) return $str; else echo $str; 305 337 exit(1); … … 312 344 } 313 345 314 function GetAds($width=468, $height=60, $return=true)346 function get_ads($width=468, $height=60, $return=true) 315 347 { 316 348 global $wpdb; … … 337 369 $banner = array_shift($this->banners[$width."x".$height]); 338 370 array_push($this->banners[$width."x".$height], $banner); 339 $str = $this-> FormatAd($banner);371 $str = $this->format_ad($banner); 340 372 341 373 if ($return) return $str; else echo $str; 342 } // End function GetAds343 344 function Login()374 } // End function get_ads 375 376 function login() 345 377 { 346 378 global $wpdb; … … 355 387 } 356 388 return false; 357 } // End function Login()358 359 function Logout()389 } // End function login() 390 391 function logout() 360 392 { 361 393 unset($_SESSION['AdMangler']); 362 394 return true; 363 } // End function Logout364 365 function Panel()395 } // End function logout 396 397 function panel() 366 398 { 367 399 $action = (isset($_GET['action'])) ? $_GET['action'] : 'login'; … … 373 405 } // End PublicForm 374 406 375 function Register()407 function register() 376 408 { 377 409 global $wpdb; … … 393 425 } 394 426 return false; 395 } // End function Login()396 397 function RegisterWidgets()427 } // End function login() 428 429 function register_widgets() 398 430 { 399 431 register_widget('AdManglerWidget'); // This adds the Widget to the backend 400 432 } 401 433 402 function ResetPassword()434 function reset_password() 403 435 { 404 436 global $wpdb; … … 407 439 return true; 408 440 return false; 409 } // End function ResetPassword()410 411 function ShortCodeHandler($atts, $content=null, $code="")441 } // End function reset_password() 442 443 function short_code_helper($atts, $content=null, $code="") 412 444 { 413 445 // $atts ::= array of attributes … … 422 454 423 455 if (!isset($atts['type'])) 424 return $this-> GetAd($atts);425 else if (isset($atts['type']) && 0 == strcmp($atts['type'], " Panel"))426 return $this-> Panel();456 return $this->get_ad($atts); 457 else if (isset($atts['type']) && 0 == strcmp($atts['type'], "panel")) 458 return $this->panel(); 427 459 else 428 460 return ""; 429 461 } 430 462 431 function SetConfirmationKey()463 function set_confirmation_key() 432 464 { 433 465 global $wpdb; … … 442 474 } 443 475 return false; 444 } // End function SetConfirmationKey() 445 446 function SendStatistics($url=null) 476 } // End function set_confirmation_key() 477 478 function set_db_version( $version = "0.0.0" ) 479 { 480 $this->dbVersion = $version; 481 } 482 483 function set_code_version( $version = "0.0.0" ) 484 { 485 $this->codeVersion = $version; 486 } 487 488 function send_statistics($url=null) 447 489 { 448 490 if (in_array ('curl', get_loaded_extensions())) … … 480 522 } 481 523 482 function ValidConfirmationKey()524 function valid_confirmation_key() 483 525 { 484 526 global $wpdb; … … 487 529 return true; 488 530 return false; 489 } // End function ValidConfirmationKey()531 } // End function valid_confirmation_key() 490 532 491 533 } // End class AdMangler -
admangler/tags/0.0.10.Aplha/trunk/adMangler.php
r630284 r707649 4 4 Plugin URI: http://www.webternals.com/projects/admangler/ 5 5 Description: Display, sell, and manage ad space on your Wordpress powered site with AdMangler. 6 Version: 0.0. 9.4.Alpha6 Version: 0.0.10.Alpha 7 7 Author: Webternals, LLC - Allen Sanford 8 8 Author URI: http://www.webternals.com/ 9 9 */ 10 /** 11 * 12 * DO NOT FORGET TO SET THE VERSIONS in adMangler.class.php if they change 13 * Both DB and CLASS 14 * 15 * */ 16 17 18 $codeVersion = '0.0.10.Alpha'; 19 $dbVersion = '0.0.8'; 10 20 11 21 if (!session_id()) 12 22 session_start(); 13 23 14 // Check for class include and activ ete the class24 // Check for class include and activate the class 15 25 if (!class_exists('AdMangler')) 16 26 { 17 27 require_once(dirname(__FILE__).'/adMangler.class.php'); 18 $adMangler = new AdMangler( );28 $adMangler = new AdMangler( $codeVersion, $dbVersion ); 19 29 require_once(dirname(__FILE__).'/adManglerWidget.class.php'); 20 30 } // End if (!class_exists('AdMangler') 21 31 22 //Setup actions, hooks and filters 23 if (isset($adMangler)) 24 { 25 // Generate the Admin Menu 26 if ( is_admin() ) 27 { 28 // Activation function 29 register_activation_hook(__FILE__, array('AdMangler', 'Activate')); 30 add_action('admin_menu', array($adMangler, 'AdminMenu')); 31 wp_enqueue_script('admanglertooltip', '/' . PLUGINDIR . '/admangler/js/tooltip.js'); 32 } 33 else 34 { 35 add_filter('the_content', array($adMangler, 'FilterTheContent')); 36 add_shortcode('AdMangler', array($adMangler, 'ShortCodeHandler')); 37 add_shortcode('admangler', array($adMangler, 'ShortCodeHandler')); 38 } 39 add_action('init', array('AdMangler', 'RegisterWidgets'), 1); 40 wp_enqueue_script("jquery"); 41 wp_enqueue_script('jquery.validate', '/' . PLUGINDIR . '/admangler/js/jquery.validate.min.js'); 42 43 } // End if (isset($adMangler)) 32 // Must be activated here and like this. will not work in the constructor for some reason. 33 register_activation_hook(__FILE__, array($adMangler, "activate")); 34 35 wp_enqueue_script("jquery"); 36 wp_enqueue_script('jquery.validate', '/' . PLUGINDIR . '/admangler/js/jquery.validate.min.js'); 44 37 ?> -
admangler/tags/0.0.10.Aplha/trunk/adManglerWidget.class.php
r293001 r707649 3 3 { 4 4 5 function AdManglerWidget()5 function __construct() 6 6 { 7 7 parent::WP_Widget(false, $name = 'AdMangler Widget'); … … 24 24 25 25 global $adMangler; 26 $content = $adMangler-> GetAd($options); // Here we get the post's excerpt26 $content = $adMangler->get_ad($options); // Here we get the post's excerpt 27 27 ?> 28 28 <?php echo $before_widget; ?> -
admangler/tags/0.0.10.Aplha/trunk/readme.txt
r630284 r707649 4 4 Tags: Ads 5 5 Requires at least: 2.8.2 6 Tested up to: 3. 1.07 Stable Tag: 0.0. 9.4.Alpha6 Tested up to: 3.5.1 7 Stable Tag: 0.0.10.Alpha 8 8 9 9 Display, sell, and manage ad space on your Wordpress powered site with AdMangler. … … 48 48 1. Upload `admangler.zip` or `admangler.tgz` to the `/wp-content/plugins/` directory and extract the contents. 49 49 1. Activate the plugin through the 'Plugins' menu in WordPress. 50 1. Template File Usage : <?php do_shortcode('[AdMangler width="468" height="60" position="1"]'); ?>50 1. Template File Usage (Do not use position 0 as its results are not what you expect): <?php do_shortcode('[AdMangler width="468" height="60" position="1"]'); ?> 51 51 1. Wordpess ShortCodes for pages and posts: [AdMangler width="468" height="60"] 52 52 1. (Not Yet Working) To display the AdMangler Front-end panel you will need to create an empty page and place the following tag in that page: [AdMangler type="Panel"] 53 1. (Deprecated): Place `<?php global $adMangler; ?>` near the top of any template file you plan to use the $adMangler object.54 1. (Deprecated): Place `<?php $adMangler->GetAd(array('width'=>486,'height'=>60,'return'=>false)); ?>` to call an Ad.55 1. (Deprecated): Place `<?php $adMangler->GetAds(<width>, <height>, false); ?>` ex: `<?php $adMangler->GetAds(468, 60, false); ?>`.56 1. (Deprecated): Alternativly you can place [AdMangler:`<width>`x`<height>`] ex: [AdMangler:468x60] inside any page or post where you wish your ad to show.57 1. (Deprecated): To display the AdMangler Front-end panel you will need to create an empty page and place the following tag in that page: [AdMangler:Panel]58 53 59 54 == Frequently Asked Questions == 60 61 = (Deprecated): When I try to use the $adMangler object to display ads it errors out, what is the deal? =62 (Deprecated): You may need to explicitly tell PHP to use the global $adMangler object like so `<?php global $adMangler; ?>`63 55 64 56 … … 69 61 70 62 == Changelog == 63 64 = 0.0.10.Alpha = 65 * Fixed bug in activation code. 66 * Cleaned up a few method names 67 * Moved some into the code to the __construct method 71 68 72 69 = 0.0.9.4.Alpha = -
admangler/trunk/adMangler.class.php
r363418 r707649 1 1 <?php 2 3 2 class AdMangler 4 3 { 5 function AdMangler() 6 { 4 var $codeVersion = null; 5 var $dbVersion = null; 6 7 function __construct($codeVersion=null, $dbVersion=null) 8 { 9 if ( !is_null($dbVersion) && !is_null($codeVersion) ) 10 { 11 if ( is_null($this->dbVersion) ) 12 $this->dbVersion = $dbVersion; 13 if ( is_null($this->codeVersion) ) 14 $this->codeVersion = $codeVersion; 15 } 16 7 17 global $wpdb; 8 18 $this->adsTable = $wpdb->prefix."AdMangler_ads"; … … 10 20 $this->usersTable = $wpdb->prefix."AdMangler_users"; 11 21 $this->positionsTable = $wpdb->prefix."AdMangler_positions"; 22 23 // Generate the Admin Menu 24 if ( is_admin() ) 25 { 26 //register_activation_hook(__FILE__, array($this, "activate")); 27 add_action('admin_menu', array($this, 'admin_menu')); 28 wp_enqueue_script('admanglertooltip', '/' . PLUGINDIR . '/admangler/js/tooltip.js'); 29 } 30 31 add_filter('the_content', array($this, 'filter_the_content')); 32 add_shortcode('AdMangler', array($this, 'short_code_helper')); 33 add_shortcode('admangler', array($this, 'short_code_helper')); 34 35 add_action('init', array($this, 'register_widgets'), 1); 12 36 } // End function AdMangler 13 37 14 function AdminMenu() 15 { 16 add_menu_page('AdMangler Settings', 'AdMangler', 9, __FILE__, array($this, 'CreateAdminPage'), '/'. PLUGINDIR . '/admangler/images/logo.gif'); 17 //add_submenu_page(__FILE__, 'AdMangler Settings', 'Settings', 9, 'settings', array($this, 'CreateAdminPage')); 18 add_submenu_page(__FILE__, 'AdMangler Settings', 'Banners', 9, 'banners', array($this, 'CreateAdminPage')); 19 } // End function AdminMenu 20 21 function Activate() 22 { 23 global $wpdb; 24 // Plugin database table version 25 $db_version = "0.0.7"; // You must increment this if we change the database other wise leave it alone 26 $sql[] = "CREATE TABLE ".$wpdb->prefix."AdMangler_ads ( 27 id INT(11) NOT NULL AUTO_INCREMENT, 28 advertiser VARCHAR(256) COLLATE utf8_bin NOT NULL DEFAULT 'admin', 29 width INT(11) NOT NULL, 30 height INT(11) NOT NULL, 31 active BOOL NOT NULL DEFAULT 0, 32 approved BOOL NOT NULL DEFAULT 0, 33 base BOOL NOT NULL DEFAULT 0, 34 type VARCHAR(5) COLLATE utf8_bin NOT NULL DEFAULT 'image', 35 code TEXT COLLATE utf8_bin, 36 href VARCHAR(256) character set utf8 collate utf8_bin NOT NULL default 'http://www.webternals.com/projects/admangler/', 37 src VARCHAR(256) NOT NULL default 'http://www.webternals.com/images/no-image.png', 38 UNIQUE KEY id (id) 39 );"; 40 41 $sql[] = "CREATE TABLE ".$wpdb->prefix."AdMangler_positions ( 42 ad_ID INT(11) NOT NULL, 43 page_ID INT(11) NOT NULL, 44 page_exclusive INT(1) NOT NULL DEFAULT 0, 45 custom_slot INT(1) NOT NULL DEFAULT 0, 46 slot INT(11) NOT NULL DEFAULT 0, 47 slot_exclusive INT(1) NOT NULL DEFAULT 0 48 );"; 49 50 $sql[] = "CREATE TABLE ".$wpdb->prefix."AdMangler_settings ( 51 id INT(11) NOT NULL AUTO_INCREMENT, 52 name VARCHAR(256) COLLATE utf8_bin NOT NULL, 53 value VARCHAR(256) COLLATE utf8_bin NOT NULL, 54 UNIQUE KEY id (id), 55 PRIMARY KEY name (name) 56 );"; 57 58 $sql[] = "CREATE TABLE ".$wpdb->prefix."AdMangler_users ( 59 id INT(11) NOT NULL AUTO_INCREMENT, 60 username VARCHAR(256) COLLATE utf8_bin NOT NULL, 61 password VARCHAR(256) COLLATE utf8_bin NOT NULL, 62 email VARCHAR(256) COLLATE utf8_bin NOT NULL, 63 credits FLOAT(10,2), 64 active BOOL DEFAULT 0, 65 confirm VARCHAR(256) COLLATE utf8_bin, 66 UNIQUE KEY id (id), 67 PRIMARY KEY username (username) 68 );"; 69 38 function admin_menu() 39 { 40 add_menu_page('AdMangler Settings', 'AdMangler', 9, __FILE__, array($this, 'create_admin_page'), '/'. PLUGINDIR . '/admangler/images/logo.gif'); 41 //add_submenu_page(__FILE__, 'AdMangler Settings', 'Settings', 9, 'settings', array($this, 'create_admin_page')); 42 add_submenu_page(__FILE__, 'AdMangler Settings', 'Banners', 9, 'banners', array($this, 'create_admin_page')); 43 } // End function admin_menu 44 45 function activate() 46 { 47 ob_start(); 48 global $wpdb; 70 49 // Installed plugin database table version 71 $installed_ver = get_option('AdMangler_db_version'); 50 $installed_version = get_option('AdMangler_db_version'); 51 if ( false === $installed_version ) 52 $installed_version = '0.0.0'; 72 53 73 54 // If the database has changed, update the structure while preserving data 74 if (empty($installed_ver) || $db_version != $installed_ver) 75 { 55 if ( version_compare( $installed_version, $this->dbVersion, '<') ) 56 { 57 // Plugin database table version 58 $sql[] = "CREATE TABLE ".$wpdb->prefix."AdMangler_ads ( 59 id INT(11) NOT NULL AUTO_INCREMENT, 60 advertiser VARCHAR(256) COLLATE utf8_bin NOT NULL DEFAULT 'admin', 61 width INT(11) NOT NULL, 62 height INT(11) NOT NULL, 63 active BOOL NOT NULL DEFAULT 0, 64 approved BOOL NOT NULL DEFAULT 0, 65 base BOOL NOT NULL DEFAULT 0, 66 type VARCHAR(5) COLLATE utf8_bin NOT NULL DEFAULT 'image', 67 code TEXT COLLATE utf8_bin, 68 href VARCHAR(256) character set utf8 collate utf8_bin NOT NULL default 'http://www.webternals.com/projects/admangler/', 69 src VARCHAR(256) NOT NULL default 'http://www.webternals.com/images/no-image.png', 70 UNIQUE KEY id (id) 71 );"; 72 73 $sql[] = "CREATE TABLE ".$wpdb->prefix."AdMangler_positions ( 74 ad_ID INT(11) NOT NULL, 75 page_ID INT(11) NOT NULL, 76 page_exclusive INT(1) NOT NULL DEFAULT 0, 77 custom_slot INT(1) NOT NULL DEFAULT 0, 78 slot INT(11) NOT NULL DEFAULT 0, 79 slot_exclusive INT(1) NOT NULL DEFAULT 0 80 );"; 81 82 $sql[] = "CREATE TABLE ".$wpdb->prefix."AdMangler_settings ( 83 id INT(11) NOT NULL AUTO_INCREMENT, 84 name VARCHAR(256) COLLATE utf8_bin NOT NULL, 85 value VARCHAR(256) COLLATE utf8_bin NOT NULL, 86 UNIQUE KEY id (id), 87 PRIMARY KEY name (name) 88 );"; 89 90 $sql[] = "CREATE TABLE ".$wpdb->prefix."AdMangler_users ( 91 id INT(11) NOT NULL AUTO_INCREMENT, 92 username VARCHAR(256) COLLATE utf8_bin NOT NULL, 93 password VARCHAR(256) COLLATE utf8_bin NOT NULL, 94 email VARCHAR(256) COLLATE utf8_bin NOT NULL, 95 credits FLOAT(10,2), 96 active BOOL DEFAULT 0, 97 confirm VARCHAR(256) COLLATE utf8_bin, 98 UNIQUE KEY id (id), 99 PRIMARY KEY username (username) 100 );"; 101 76 102 require_once ABSPATH . "wp-admin/includes/upgrade.php"; 77 103 foreach($sql as $temp) 78 104 dbDelta($temp); 79 105 if (get_option('AdMangler_db_version')) 80 update_option('AdMangler_db_version', $db_version); 106 { 107 update_option('AdMangler_db_version', $this->dbVersion); 108 } 81 109 else 82 add_option('AdMangler_db_version', $db_version); 83 } 84 self::SendStatistics(); 110 { 111 add_option('AdMangler_db_version', $this->dbVersion); 112 } 113 114 } 115 $this->send_statistics(); 116 //file_put_contents(dirname(__FILE__)."/log.txt", var_export($this, true), FILE_APPEND); 85 117 return true; 86 } // End function Activate87 88 function ConfirmRegistration()118 } // End function activate 119 120 function confirm_registration() 89 121 { 90 122 global $wpdb; … … 93 125 return true; 94 126 return false; 95 } // End function ConfirmRegistration()96 97 function CreateAdminPage()127 } // End function confirm_registration() 128 129 function create_admin_page() 98 130 { 99 131 echo "<div class=\"wrap\"><h2>AdMangler Admin</h2>"; … … 111 143 } 112 144 echo "</div>"; 113 } // End function CreateAdminPage114 115 function FilterTheContent($content)145 } // End function create_admin_page 146 147 function filter_the_content($content) 116 148 { 117 149 global $wpdb; … … 121 153 foreach ($results as $banner) 122 154 { 123 $content = str_replace("[AdMangler:".$banner->width."x".$banner->height."]", $this-> GetAds($banner->width, $banner->height), $content);124 } 125 $content = str_replace('[AdMangler: Panel]', $this->Panel(), $content);155 $content = str_replace("[AdMangler:".$banner->width."x".$banner->height."]", $this->get_ads($banner->width, $banner->height), $content); 156 } 157 $content = str_replace('[AdMangler:panel]', $this->panel(), $content); 126 158 return $content; 127 } // End function FilterTheContent128 129 function FormatAd($banner)159 } // End function filter_the_content 160 161 function format_ad($banner) 130 162 { 131 163 switch($banner->type) … … 138 170 } 139 171 return $code; 140 } //End function FormatAd141 142 function GetAdById($id, $return)172 } //End function format_ad 173 174 function get_ad_by_id($id, $return) 143 175 { 144 176 global $wpdb; 145 177 $sql = "SELECT type,code,href,src,width,height FROM $this->adsTable WHERE id=".intval($id); 146 178 $row = $wpdb->get_row($sql); 147 $str = $this-> FormatAd($row);179 $str = $this->format_ad($row); 148 180 149 181 if ($return) return $str; else echo $str; 150 } // End function GetAdById151 152 function GetAd($options = array('width'=>null,'height'=>null,'pageID'=>null,'position'=>null,'return'=>true))182 } // End function get_ad_by_id 183 184 function get_ad($options = array('width'=>null,'height'=>null,'pageID'=>null,'position'=>null,'return'=>true)) 153 185 { 154 186 global $wpdb; … … 208 240 $banner = array_shift($this->banners[$width."x".$height][0]); 209 241 array_push($this->banners[$width."x".$height][0], $banner); 210 $str = $this-> FormatAd($banner);242 $str = $this->format_ad($banner); 211 243 if ($return) return $str; else echo $str; 212 244 exit(1); … … 239 271 $banner = array_shift($this->banners[$width."x".$height][1]); 240 272 array_push($this->banners[$width."x".$height][1], $banner); 241 $str = $this-> FormatAd($banner);273 $str = $this->format_ad($banner); 242 274 if ($return) return $str; else echo $str; 243 275 exit(1); … … 270 302 $banner = array_shift($this->banners[$width."x".$height][2]); 271 303 array_push($this->banners[$width."x".$height][2], $banner); 272 $str = $this-> FormatAd($banner);304 $str = $this->format_ad($banner); 273 305 if ($return) return $str; else echo $str; 274 306 exit(1); … … 301 333 $banner = array_shift($this->banners[$width."x".$height][3]); 302 334 array_push($this->banners[$width."x".$height][3], $banner); 303 $str = $this-> FormatAd($banner);335 $str = $this->format_ad($banner); 304 336 if ($return) return $str; else echo $str; 305 337 exit(1); … … 312 344 } 313 345 314 function GetAds($width=468, $height=60, $return=true)346 function get_ads($width=468, $height=60, $return=true) 315 347 { 316 348 global $wpdb; … … 337 369 $banner = array_shift($this->banners[$width."x".$height]); 338 370 array_push($this->banners[$width."x".$height], $banner); 339 $str = $this-> FormatAd($banner);371 $str = $this->format_ad($banner); 340 372 341 373 if ($return) return $str; else echo $str; 342 } // End function GetAds343 344 function Login()374 } // End function get_ads 375 376 function login() 345 377 { 346 378 global $wpdb; … … 355 387 } 356 388 return false; 357 } // End function Login()358 359 function Logout()389 } // End function login() 390 391 function logout() 360 392 { 361 393 unset($_SESSION['AdMangler']); 362 394 return true; 363 } // End function Logout364 365 function Panel()395 } // End function logout 396 397 function panel() 366 398 { 367 399 $action = (isset($_GET['action'])) ? $_GET['action'] : 'login'; … … 373 405 } // End PublicForm 374 406 375 function Register()407 function register() 376 408 { 377 409 global $wpdb; … … 393 425 } 394 426 return false; 395 } // End function Login()396 397 function RegisterWidgets()427 } // End function login() 428 429 function register_widgets() 398 430 { 399 431 register_widget('AdManglerWidget'); // This adds the Widget to the backend 400 432 } 401 433 402 function ResetPassword()434 function reset_password() 403 435 { 404 436 global $wpdb; … … 407 439 return true; 408 440 return false; 409 } // End function ResetPassword()410 411 function ShortCodeHandler($atts, $content=null, $code="")441 } // End function reset_password() 442 443 function short_code_helper($atts, $content=null, $code="") 412 444 { 413 445 // $atts ::= array of attributes … … 422 454 423 455 if (!isset($atts['type'])) 424 return $this-> GetAd($atts);425 else if (isset($atts['type']) && 0 == strcmp($atts['type'], " Panel"))426 return $this-> Panel();456 return $this->get_ad($atts); 457 else if (isset($atts['type']) && 0 == strcmp($atts['type'], "panel")) 458 return $this->panel(); 427 459 else 428 460 return ""; 429 461 } 430 462 431 function SetConfirmationKey()463 function set_confirmation_key() 432 464 { 433 465 global $wpdb; … … 442 474 } 443 475 return false; 444 } // End function SetConfirmationKey() 445 446 function SendStatistics($url=null) 476 } // End function set_confirmation_key() 477 478 function set_db_version( $version = "0.0.0" ) 479 { 480 $this->dbVersion = $version; 481 } 482 483 function set_code_version( $version = "0.0.0" ) 484 { 485 $this->codeVersion = $version; 486 } 487 488 function send_statistics($url=null) 447 489 { 448 490 if (in_array ('curl', get_loaded_extensions())) … … 480 522 } 481 523 482 function ValidConfirmationKey()524 function valid_confirmation_key() 483 525 { 484 526 global $wpdb; … … 487 529 return true; 488 530 return false; 489 } // End function ValidConfirmationKey()531 } // End function valid_confirmation_key() 490 532 491 533 } // End class AdMangler -
admangler/trunk/adMangler.php
r630284 r707649 4 4 Plugin URI: http://www.webternals.com/projects/admangler/ 5 5 Description: Display, sell, and manage ad space on your Wordpress powered site with AdMangler. 6 Version: 0.0. 9.4.Alpha6 Version: 0.0.10.Alpha 7 7 Author: Webternals, LLC - Allen Sanford 8 8 Author URI: http://www.webternals.com/ 9 9 */ 10 /** 11 * 12 * DO NOT FORGET TO SET THE VERSIONS in adMangler.class.php if they change 13 * Both DB and CLASS 14 * 15 * */ 16 17 18 $codeVersion = '0.0.10.Alpha'; 19 $dbVersion = '0.0.8'; 10 20 11 21 if (!session_id()) 12 22 session_start(); 13 23 14 // Check for class include and activ ete the class24 // Check for class include and activate the class 15 25 if (!class_exists('AdMangler')) 16 26 { 17 27 require_once(dirname(__FILE__).'/adMangler.class.php'); 18 $adMangler = new AdMangler( );28 $adMangler = new AdMangler( $codeVersion, $dbVersion ); 19 29 require_once(dirname(__FILE__).'/adManglerWidget.class.php'); 20 30 } // End if (!class_exists('AdMangler') 21 31 22 //Setup actions, hooks and filters 23 if (isset($adMangler)) 24 { 25 // Generate the Admin Menu 26 if ( is_admin() ) 27 { 28 // Activation function 29 register_activation_hook(__FILE__, array('AdMangler', 'Activate')); 30 add_action('admin_menu', array($adMangler, 'AdminMenu')); 31 wp_enqueue_script('admanglertooltip', '/' . PLUGINDIR . '/admangler/js/tooltip.js'); 32 } 33 else 34 { 35 add_filter('the_content', array($adMangler, 'FilterTheContent')); 36 add_shortcode('AdMangler', array($adMangler, 'ShortCodeHandler')); 37 add_shortcode('admangler', array($adMangler, 'ShortCodeHandler')); 38 } 39 add_action('init', array('AdMangler', 'RegisterWidgets'), 1); 40 wp_enqueue_script("jquery"); 41 wp_enqueue_script('jquery.validate', '/' . PLUGINDIR . '/admangler/js/jquery.validate.min.js'); 42 43 } // End if (isset($adMangler)) 32 // Must be activated here and like this. will not work in the constructor for some reason. 33 register_activation_hook(__FILE__, array($adMangler, "activate")); 34 35 wp_enqueue_script("jquery"); 36 wp_enqueue_script('jquery.validate', '/' . PLUGINDIR . '/admangler/js/jquery.validate.min.js'); 44 37 ?> -
admangler/trunk/adManglerWidget.class.php
r293001 r707649 3 3 { 4 4 5 function AdManglerWidget()5 function __construct() 6 6 { 7 7 parent::WP_Widget(false, $name = 'AdMangler Widget'); … … 24 24 25 25 global $adMangler; 26 $content = $adMangler-> GetAd($options); // Here we get the post's excerpt26 $content = $adMangler->get_ad($options); // Here we get the post's excerpt 27 27 ?> 28 28 <?php echo $before_widget; ?> -
admangler/trunk/readme.txt
r630284 r707649 4 4 Tags: Ads 5 5 Requires at least: 2.8.2 6 Tested up to: 3. 1.07 Stable Tag: 0.0. 9.4.Alpha6 Tested up to: 3.5.1 7 Stable Tag: 0.0.10.Alpha 8 8 9 9 Display, sell, and manage ad space on your Wordpress powered site with AdMangler. … … 48 48 1. Upload `admangler.zip` or `admangler.tgz` to the `/wp-content/plugins/` directory and extract the contents. 49 49 1. Activate the plugin through the 'Plugins' menu in WordPress. 50 1. Template File Usage : <?php do_shortcode('[AdMangler width="468" height="60" position="1"]'); ?>50 1. Template File Usage (Do not use position 0 as its results are not what you expect): <?php do_shortcode('[AdMangler width="468" height="60" position="1"]'); ?> 51 51 1. Wordpess ShortCodes for pages and posts: [AdMangler width="468" height="60"] 52 52 1. (Not Yet Working) To display the AdMangler Front-end panel you will need to create an empty page and place the following tag in that page: [AdMangler type="Panel"] 53 1. (Deprecated): Place `<?php global $adMangler; ?>` near the top of any template file you plan to use the $adMangler object.54 1. (Deprecated): Place `<?php $adMangler->GetAd(array('width'=>486,'height'=>60,'return'=>false)); ?>` to call an Ad.55 1. (Deprecated): Place `<?php $adMangler->GetAds(<width>, <height>, false); ?>` ex: `<?php $adMangler->GetAds(468, 60, false); ?>`.56 1. (Deprecated): Alternativly you can place [AdMangler:`<width>`x`<height>`] ex: [AdMangler:468x60] inside any page or post where you wish your ad to show.57 1. (Deprecated): To display the AdMangler Front-end panel you will need to create an empty page and place the following tag in that page: [AdMangler:Panel]58 53 59 54 == Frequently Asked Questions == 60 61 = (Deprecated): When I try to use the $adMangler object to display ads it errors out, what is the deal? =62 (Deprecated): You may need to explicitly tell PHP to use the global $adMangler object like so `<?php global $adMangler; ?>`63 55 64 56 … … 69 61 70 62 == Changelog == 63 64 = 0.0.10.Alpha = 65 * Fixed bug in activation code. 66 * Cleaned up a few method names 67 * Moved some into the code to the __construct method 71 68 72 69 = 0.0.9.4.Alpha =
Note: See TracChangeset
for help on using the changeset viewer.