Plugin Directory

Changeset 707649


Ignore:
Timestamp:
05/03/2013 09:37:09 PM (13 years ago)
Author:
webternals
Message:

AdMangler Version 0.0.10.Aplha

Location:
admangler
Files:
11 edited
2 copied

Legend:

Unmodified
Added
Removed
  • admangler/tags/0.0.10.Aplha/adMangler.class.php

    r363418 r707649  
    11<?php
    2 
    32    class AdMangler
    43    {
    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           
    717            global $wpdb;
    818            $this->adsTable = $wpdb->prefix."AdMangler_ads";
     
    1020            $this->usersTable = $wpdb->prefix."AdMangler_users";
    1121            $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);
    1236        } // End function AdMangler
    1337
    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;
    7049            // 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';
    7253
    7354            // 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
    76102                require_once ABSPATH . "wp-admin/includes/upgrade.php";
    77103                foreach($sql as $temp)
    78104                    dbDelta($temp);
    79105                if (get_option('AdMangler_db_version'))
    80                     update_option('AdMangler_db_version', $db_version);
     106                {
     107                    update_option('AdMangler_db_version', $this->dbVersion);
     108                }
    81109                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);
    85117            return true;
    86         } // End function Activate
    87 
    88         function ConfirmRegistration()
     118        } // End function activate
     119
     120        function confirm_registration()
    89121        {
    90122            global $wpdb;
     
    93125                return true;
    94126            return false;
    95         } // End function ConfirmRegistration()
    96 
    97         function CreateAdminPage()
     127        } // End function confirm_registration()
     128
     129        function create_admin_page()
    98130        {
    99131            echo "<div class=\"wrap\"><h2>AdMangler Admin</h2>";
     
    111143            }
    112144            echo "</div>";
    113         } // End function CreateAdminPage
    114 
    115         function FilterTheContent($content)
     145        } // End function create_admin_page
     146
     147        function filter_the_content($content)
    116148        {
    117149            global $wpdb;
     
    121153            foreach ($results as $banner)
    122154            {
    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);
    126158            return $content;
    127         } // End function FilterTheContent
    128 
    129         function FormatAd($banner)
     159        } // End function filter_the_content
     160
     161        function format_ad($banner)
    130162        {
    131163            switch($banner->type)
     
    138170            }
    139171            return $code;
    140         } //End function FormatAd
    141 
    142         function GetAdById($id, $return)
     172        } //End function format_ad
     173
     174        function get_ad_by_id($id, $return)
    143175        {
    144176            global $wpdb;
    145177            $sql = "SELECT type,code,href,src,width,height FROM $this->adsTable WHERE id=".intval($id);
    146178            $row = $wpdb->get_row($sql);
    147             $str = $this->FormatAd($row);
     179            $str = $this->format_ad($row);
    148180
    149181            if ($return) return $str; else echo $str;
    150         } // End function GetAdById
    151 
    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))
    153185        {
    154186            global $wpdb;
     
    208240                $banner = array_shift($this->banners[$width."x".$height][0]);
    209241                array_push($this->banners[$width."x".$height][0], $banner);
    210                 $str = $this->FormatAd($banner);
     242                $str = $this->format_ad($banner);
    211243                if ($return) return $str; else echo $str;
    212244                exit(1);
     
    239271                $banner = array_shift($this->banners[$width."x".$height][1]);
    240272                array_push($this->banners[$width."x".$height][1], $banner);
    241                 $str = $this->FormatAd($banner);
     273                $str = $this->format_ad($banner);
    242274                if ($return) return $str; else echo $str;
    243275                exit(1);
     
    270302                $banner = array_shift($this->banners[$width."x".$height][2]);
    271303                array_push($this->banners[$width."x".$height][2], $banner);
    272                 $str = $this->FormatAd($banner);
     304                $str = $this->format_ad($banner);
    273305                if ($return) return $str; else echo $str;
    274306                exit(1);
     
    301333                $banner = array_shift($this->banners[$width."x".$height][3]);
    302334                array_push($this->banners[$width."x".$height][3], $banner);
    303                 $str = $this->FormatAd($banner);
     335                $str = $this->format_ad($banner);
    304336                if ($return) return $str; else echo $str;
    305337                exit(1);
     
    312344        }
    313345
    314         function GetAds($width=468, $height=60, $return=true)
     346        function get_ads($width=468, $height=60, $return=true)
    315347        {
    316348            global $wpdb;
     
    337369            $banner = array_shift($this->banners[$width."x".$height]);
    338370            array_push($this->banners[$width."x".$height], $banner);
    339             $str = $this->FormatAd($banner);
     371            $str = $this->format_ad($banner);
    340372
    341373            if ($return) return $str; else echo $str;
    342         } // End function GetAds
    343        
    344         function Login()
     374        } // End function get_ads
     375       
     376        function login()
    345377        {
    346378            global $wpdb;
     
    355387            }
    356388            return false;
    357         } // End function Login()
    358        
    359         function Logout()
     389        } // End function login()
     390       
     391        function logout()
    360392        {
    361393            unset($_SESSION['AdMangler']);
    362394            return true;
    363         } // End function Logout
    364 
    365         function Panel()
     395        } // End function logout
     396
     397        function panel()
    366398        {
    367399            $action = (isset($_GET['action'])) ? $_GET['action'] : 'login';
     
    373405        } // End PublicForm
    374406       
    375         function Register()
     407        function register()
    376408        {
    377409            global $wpdb;
     
    393425            }
    394426            return false;
    395         } // End function Login()
    396        
    397         function RegisterWidgets()
     427        } // End function login()
     428       
     429        function register_widgets()
    398430        {
    399431            register_widget('AdManglerWidget'); // This adds the Widget to the backend
    400432        }
    401433       
    402         function ResetPassword()
     434        function reset_password()
    403435        {
    404436            global $wpdb;
     
    407439                return true;
    408440            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="")
    412444        {
    413445            // $atts    ::= array of attributes
     
    422454           
    423455            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();
    427459            else
    428460                return "";
    429461        }       
    430462
    431         function SetConfirmationKey()
     463        function set_confirmation_key()
    432464        {
    433465            global $wpdb;
     
    442474            }
    443475            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)
    447489        {
    448490            if  (in_array  ('curl', get_loaded_extensions()))
     
    480522        }
    481523       
    482         function ValidConfirmationKey()
     524        function valid_confirmation_key()
    483525        {
    484526            global $wpdb;
     
    487529                return true;
    488530            return false;
    489         } // End function ValidConfirmationKey()
     531        } // End function valid_confirmation_key()
    490532
    491533    } // End class AdMangler
  • admangler/tags/0.0.10.Aplha/adMangler.php

    r630284 r707649  
    44        Plugin URI: http://www.webternals.com/projects/admangler/
    55        Description: Display, sell, and manage ad space on your Wordpress powered site with AdMangler.
    6         Version: 0.0.9.4.Alpha
     6        Version: 0.0.10.Alpha
    77        Author: Webternals, LLC - Allen Sanford
    88        Author URI: http://www.webternals.com/
    99    */
     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';
    1020
    1121    if (!session_id())
    1222        session_start();
    1323
    14     // Check for class include and activete the class
     24    // Check for class include and activate the class
    1525    if (!class_exists('AdMangler'))
    1626    {
    1727        require_once(dirname(__FILE__).'/adMangler.class.php');
    18         $adMangler = new AdMangler();
     28        $adMangler = new AdMangler( $codeVersion, $dbVersion );
    1929        require_once(dirname(__FILE__).'/adManglerWidget.class.php');
    2030    } // End if (!class_exists('AdMangler')
    2131
    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');
    4437?>
  • admangler/tags/0.0.10.Aplha/adManglerWidget.class.php

    r293001 r707649  
    33    {
    44 
    5         function AdManglerWidget()
     5        function __construct()
    66        {
    77            parent::WP_Widget(false, $name = 'AdMangler Widget');   
     
    2424
    2525            global $adMangler;
    26             $content = $adMangler->GetAd($options); // Here we get the post's excerpt
     26            $content = $adMangler->get_ad($options); // Here we get the post's excerpt
    2727            ?>
    2828              <?php echo $before_widget; ?>
  • admangler/tags/0.0.10.Aplha/trunk/adMangler.class.php

    r363418 r707649  
    11<?php
    2 
    32    class AdMangler
    43    {
    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           
    717            global $wpdb;
    818            $this->adsTable = $wpdb->prefix."AdMangler_ads";
     
    1020            $this->usersTable = $wpdb->prefix."AdMangler_users";
    1121            $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);
    1236        } // End function AdMangler
    1337
    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;
    7049            // 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';
    7253
    7354            // 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
    76102                require_once ABSPATH . "wp-admin/includes/upgrade.php";
    77103                foreach($sql as $temp)
    78104                    dbDelta($temp);
    79105                if (get_option('AdMangler_db_version'))
    80                     update_option('AdMangler_db_version', $db_version);
     106                {
     107                    update_option('AdMangler_db_version', $this->dbVersion);
     108                }
    81109                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);
    85117            return true;
    86         } // End function Activate
    87 
    88         function ConfirmRegistration()
     118        } // End function activate
     119
     120        function confirm_registration()
    89121        {
    90122            global $wpdb;
     
    93125                return true;
    94126            return false;
    95         } // End function ConfirmRegistration()
    96 
    97         function CreateAdminPage()
     127        } // End function confirm_registration()
     128
     129        function create_admin_page()
    98130        {
    99131            echo "<div class=\"wrap\"><h2>AdMangler Admin</h2>";
     
    111143            }
    112144            echo "</div>";
    113         } // End function CreateAdminPage
    114 
    115         function FilterTheContent($content)
     145        } // End function create_admin_page
     146
     147        function filter_the_content($content)
    116148        {
    117149            global $wpdb;
     
    121153            foreach ($results as $banner)
    122154            {
    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);
    126158            return $content;
    127         } // End function FilterTheContent
    128 
    129         function FormatAd($banner)
     159        } // End function filter_the_content
     160
     161        function format_ad($banner)
    130162        {
    131163            switch($banner->type)
     
    138170            }
    139171            return $code;
    140         } //End function FormatAd
    141 
    142         function GetAdById($id, $return)
     172        } //End function format_ad
     173
     174        function get_ad_by_id($id, $return)
    143175        {
    144176            global $wpdb;
    145177            $sql = "SELECT type,code,href,src,width,height FROM $this->adsTable WHERE id=".intval($id);
    146178            $row = $wpdb->get_row($sql);
    147             $str = $this->FormatAd($row);
     179            $str = $this->format_ad($row);
    148180
    149181            if ($return) return $str; else echo $str;
    150         } // End function GetAdById
    151 
    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))
    153185        {
    154186            global $wpdb;
     
    208240                $banner = array_shift($this->banners[$width."x".$height][0]);
    209241                array_push($this->banners[$width."x".$height][0], $banner);
    210                 $str = $this->FormatAd($banner);
     242                $str = $this->format_ad($banner);
    211243                if ($return) return $str; else echo $str;
    212244                exit(1);
     
    239271                $banner = array_shift($this->banners[$width."x".$height][1]);
    240272                array_push($this->banners[$width."x".$height][1], $banner);
    241                 $str = $this->FormatAd($banner);
     273                $str = $this->format_ad($banner);
    242274                if ($return) return $str; else echo $str;
    243275                exit(1);
     
    270302                $banner = array_shift($this->banners[$width."x".$height][2]);
    271303                array_push($this->banners[$width."x".$height][2], $banner);
    272                 $str = $this->FormatAd($banner);
     304                $str = $this->format_ad($banner);
    273305                if ($return) return $str; else echo $str;
    274306                exit(1);
     
    301333                $banner = array_shift($this->banners[$width."x".$height][3]);
    302334                array_push($this->banners[$width."x".$height][3], $banner);
    303                 $str = $this->FormatAd($banner);
     335                $str = $this->format_ad($banner);
    304336                if ($return) return $str; else echo $str;
    305337                exit(1);
     
    312344        }
    313345
    314         function GetAds($width=468, $height=60, $return=true)
     346        function get_ads($width=468, $height=60, $return=true)
    315347        {
    316348            global $wpdb;
     
    337369            $banner = array_shift($this->banners[$width."x".$height]);
    338370            array_push($this->banners[$width."x".$height], $banner);
    339             $str = $this->FormatAd($banner);
     371            $str = $this->format_ad($banner);
    340372
    341373            if ($return) return $str; else echo $str;
    342         } // End function GetAds
    343        
    344         function Login()
     374        } // End function get_ads
     375       
     376        function login()
    345377        {
    346378            global $wpdb;
     
    355387            }
    356388            return false;
    357         } // End function Login()
    358        
    359         function Logout()
     389        } // End function login()
     390       
     391        function logout()
    360392        {
    361393            unset($_SESSION['AdMangler']);
    362394            return true;
    363         } // End function Logout
    364 
    365         function Panel()
     395        } // End function logout
     396
     397        function panel()
    366398        {
    367399            $action = (isset($_GET['action'])) ? $_GET['action'] : 'login';
     
    373405        } // End PublicForm
    374406       
    375         function Register()
     407        function register()
    376408        {
    377409            global $wpdb;
     
    393425            }
    394426            return false;
    395         } // End function Login()
    396        
    397         function RegisterWidgets()
     427        } // End function login()
     428       
     429        function register_widgets()
    398430        {
    399431            register_widget('AdManglerWidget'); // This adds the Widget to the backend
    400432        }
    401433       
    402         function ResetPassword()
     434        function reset_password()
    403435        {
    404436            global $wpdb;
     
    407439                return true;
    408440            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="")
    412444        {
    413445            // $atts    ::= array of attributes
     
    422454           
    423455            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();
    427459            else
    428460                return "";
    429461        }       
    430462
    431         function SetConfirmationKey()
     463        function set_confirmation_key()
    432464        {
    433465            global $wpdb;
     
    442474            }
    443475            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)
    447489        {
    448490            if  (in_array  ('curl', get_loaded_extensions()))
     
    480522        }
    481523       
    482         function ValidConfirmationKey()
     524        function valid_confirmation_key()
    483525        {
    484526            global $wpdb;
     
    487529                return true;
    488530            return false;
    489         } // End function ValidConfirmationKey()
     531        } // End function valid_confirmation_key()
    490532
    491533    } // End class AdMangler
  • admangler/tags/0.0.10.Aplha/trunk/adMangler.php

    r630284 r707649  
    44        Plugin URI: http://www.webternals.com/projects/admangler/
    55        Description: Display, sell, and manage ad space on your Wordpress powered site with AdMangler.
    6         Version: 0.0.9.4.Alpha
     6        Version: 0.0.10.Alpha
    77        Author: Webternals, LLC - Allen Sanford
    88        Author URI: http://www.webternals.com/
    99    */
     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';
    1020
    1121    if (!session_id())
    1222        session_start();
    1323
    14     // Check for class include and activete the class
     24    // Check for class include and activate the class
    1525    if (!class_exists('AdMangler'))
    1626    {
    1727        require_once(dirname(__FILE__).'/adMangler.class.php');
    18         $adMangler = new AdMangler();
     28        $adMangler = new AdMangler( $codeVersion, $dbVersion );
    1929        require_once(dirname(__FILE__).'/adManglerWidget.class.php');
    2030    } // End if (!class_exists('AdMangler')
    2131
    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');
    4437?>
  • admangler/tags/0.0.10.Aplha/trunk/adManglerWidget.class.php

    r293001 r707649  
    33    {
    44 
    5         function AdManglerWidget()
     5        function __construct()
    66        {
    77            parent::WP_Widget(false, $name = 'AdMangler Widget');   
     
    2424
    2525            global $adMangler;
    26             $content = $adMangler->GetAd($options); // Here we get the post's excerpt
     26            $content = $adMangler->get_ad($options); // Here we get the post's excerpt
    2727            ?>
    2828              <?php echo $before_widget; ?>
  • admangler/tags/0.0.10.Aplha/trunk/readme.txt

    r630284 r707649  
    44Tags: Ads
    55Requires at least: 2.8.2
    6 Tested up to: 3.1.0
    7 Stable Tag: 0.0.9.4.Alpha
     6Tested up to: 3.5.1
     7Stable Tag: 0.0.10.Alpha
    88
    99Display, sell, and manage ad space on your Wordpress powered site with AdMangler.
     
    48481. Upload `admangler.zip` or `admangler.tgz` to the `/wp-content/plugins/` directory and extract the contents.
    49491. Activate the plugin through the 'Plugins' menu in WordPress.
    50 1. Template File Usage: <?php do_shortcode('[AdMangler width="468" height="60" position="1"]'); ?>
     501. 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"]'); ?>
    51511. Wordpess ShortCodes for pages and posts: [AdMangler width="468" height="60"]
    52521. (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]
    5853
    5954== 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; ?>`
    6355
    6456
     
    6961
    7062== 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
    7168
    7269= 0.0.9.4.Alpha =
  • admangler/trunk/adMangler.class.php

    r363418 r707649  
    11<?php
    2 
    32    class AdMangler
    43    {
    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           
    717            global $wpdb;
    818            $this->adsTable = $wpdb->prefix."AdMangler_ads";
     
    1020            $this->usersTable = $wpdb->prefix."AdMangler_users";
    1121            $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);
    1236        } // End function AdMangler
    1337
    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;
    7049            // 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';
    7253
    7354            // 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
    76102                require_once ABSPATH . "wp-admin/includes/upgrade.php";
    77103                foreach($sql as $temp)
    78104                    dbDelta($temp);
    79105                if (get_option('AdMangler_db_version'))
    80                     update_option('AdMangler_db_version', $db_version);
     106                {
     107                    update_option('AdMangler_db_version', $this->dbVersion);
     108                }
    81109                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);
    85117            return true;
    86         } // End function Activate
    87 
    88         function ConfirmRegistration()
     118        } // End function activate
     119
     120        function confirm_registration()
    89121        {
    90122            global $wpdb;
     
    93125                return true;
    94126            return false;
    95         } // End function ConfirmRegistration()
    96 
    97         function CreateAdminPage()
     127        } // End function confirm_registration()
     128
     129        function create_admin_page()
    98130        {
    99131            echo "<div class=\"wrap\"><h2>AdMangler Admin</h2>";
     
    111143            }
    112144            echo "</div>";
    113         } // End function CreateAdminPage
    114 
    115         function FilterTheContent($content)
     145        } // End function create_admin_page
     146
     147        function filter_the_content($content)
    116148        {
    117149            global $wpdb;
     
    121153            foreach ($results as $banner)
    122154            {
    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);
    126158            return $content;
    127         } // End function FilterTheContent
    128 
    129         function FormatAd($banner)
     159        } // End function filter_the_content
     160
     161        function format_ad($banner)
    130162        {
    131163            switch($banner->type)
     
    138170            }
    139171            return $code;
    140         } //End function FormatAd
    141 
    142         function GetAdById($id, $return)
     172        } //End function format_ad
     173
     174        function get_ad_by_id($id, $return)
    143175        {
    144176            global $wpdb;
    145177            $sql = "SELECT type,code,href,src,width,height FROM $this->adsTable WHERE id=".intval($id);
    146178            $row = $wpdb->get_row($sql);
    147             $str = $this->FormatAd($row);
     179            $str = $this->format_ad($row);
    148180
    149181            if ($return) return $str; else echo $str;
    150         } // End function GetAdById
    151 
    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))
    153185        {
    154186            global $wpdb;
     
    208240                $banner = array_shift($this->banners[$width."x".$height][0]);
    209241                array_push($this->banners[$width."x".$height][0], $banner);
    210                 $str = $this->FormatAd($banner);
     242                $str = $this->format_ad($banner);
    211243                if ($return) return $str; else echo $str;
    212244                exit(1);
     
    239271                $banner = array_shift($this->banners[$width."x".$height][1]);
    240272                array_push($this->banners[$width."x".$height][1], $banner);
    241                 $str = $this->FormatAd($banner);
     273                $str = $this->format_ad($banner);
    242274                if ($return) return $str; else echo $str;
    243275                exit(1);
     
    270302                $banner = array_shift($this->banners[$width."x".$height][2]);
    271303                array_push($this->banners[$width."x".$height][2], $banner);
    272                 $str = $this->FormatAd($banner);
     304                $str = $this->format_ad($banner);
    273305                if ($return) return $str; else echo $str;
    274306                exit(1);
     
    301333                $banner = array_shift($this->banners[$width."x".$height][3]);
    302334                array_push($this->banners[$width."x".$height][3], $banner);
    303                 $str = $this->FormatAd($banner);
     335                $str = $this->format_ad($banner);
    304336                if ($return) return $str; else echo $str;
    305337                exit(1);
     
    312344        }
    313345
    314         function GetAds($width=468, $height=60, $return=true)
     346        function get_ads($width=468, $height=60, $return=true)
    315347        {
    316348            global $wpdb;
     
    337369            $banner = array_shift($this->banners[$width."x".$height]);
    338370            array_push($this->banners[$width."x".$height], $banner);
    339             $str = $this->FormatAd($banner);
     371            $str = $this->format_ad($banner);
    340372
    341373            if ($return) return $str; else echo $str;
    342         } // End function GetAds
    343        
    344         function Login()
     374        } // End function get_ads
     375       
     376        function login()
    345377        {
    346378            global $wpdb;
     
    355387            }
    356388            return false;
    357         } // End function Login()
    358        
    359         function Logout()
     389        } // End function login()
     390       
     391        function logout()
    360392        {
    361393            unset($_SESSION['AdMangler']);
    362394            return true;
    363         } // End function Logout
    364 
    365         function Panel()
     395        } // End function logout
     396
     397        function panel()
    366398        {
    367399            $action = (isset($_GET['action'])) ? $_GET['action'] : 'login';
     
    373405        } // End PublicForm
    374406       
    375         function Register()
     407        function register()
    376408        {
    377409            global $wpdb;
     
    393425            }
    394426            return false;
    395         } // End function Login()
    396        
    397         function RegisterWidgets()
     427        } // End function login()
     428       
     429        function register_widgets()
    398430        {
    399431            register_widget('AdManglerWidget'); // This adds the Widget to the backend
    400432        }
    401433       
    402         function ResetPassword()
     434        function reset_password()
    403435        {
    404436            global $wpdb;
     
    407439                return true;
    408440            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="")
    412444        {
    413445            // $atts    ::= array of attributes
     
    422454           
    423455            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();
    427459            else
    428460                return "";
    429461        }       
    430462
    431         function SetConfirmationKey()
     463        function set_confirmation_key()
    432464        {
    433465            global $wpdb;
     
    442474            }
    443475            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)
    447489        {
    448490            if  (in_array  ('curl', get_loaded_extensions()))
     
    480522        }
    481523       
    482         function ValidConfirmationKey()
     524        function valid_confirmation_key()
    483525        {
    484526            global $wpdb;
     
    487529                return true;
    488530            return false;
    489         } // End function ValidConfirmationKey()
     531        } // End function valid_confirmation_key()
    490532
    491533    } // End class AdMangler
  • admangler/trunk/adMangler.php

    r630284 r707649  
    44        Plugin URI: http://www.webternals.com/projects/admangler/
    55        Description: Display, sell, and manage ad space on your Wordpress powered site with AdMangler.
    6         Version: 0.0.9.4.Alpha
     6        Version: 0.0.10.Alpha
    77        Author: Webternals, LLC - Allen Sanford
    88        Author URI: http://www.webternals.com/
    99    */
     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';
    1020
    1121    if (!session_id())
    1222        session_start();
    1323
    14     // Check for class include and activete the class
     24    // Check for class include and activate the class
    1525    if (!class_exists('AdMangler'))
    1626    {
    1727        require_once(dirname(__FILE__).'/adMangler.class.php');
    18         $adMangler = new AdMangler();
     28        $adMangler = new AdMangler( $codeVersion, $dbVersion );
    1929        require_once(dirname(__FILE__).'/adManglerWidget.class.php');
    2030    } // End if (!class_exists('AdMangler')
    2131
    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');
    4437?>
  • admangler/trunk/adManglerWidget.class.php

    r293001 r707649  
    33    {
    44 
    5         function AdManglerWidget()
     5        function __construct()
    66        {
    77            parent::WP_Widget(false, $name = 'AdMangler Widget');   
     
    2424
    2525            global $adMangler;
    26             $content = $adMangler->GetAd($options); // Here we get the post's excerpt
     26            $content = $adMangler->get_ad($options); // Here we get the post's excerpt
    2727            ?>
    2828              <?php echo $before_widget; ?>
  • admangler/trunk/readme.txt

    r630284 r707649  
    44Tags: Ads
    55Requires at least: 2.8.2
    6 Tested up to: 3.1.0
    7 Stable Tag: 0.0.9.4.Alpha
     6Tested up to: 3.5.1
     7Stable Tag: 0.0.10.Alpha
    88
    99Display, sell, and manage ad space on your Wordpress powered site with AdMangler.
     
    48481. Upload `admangler.zip` or `admangler.tgz` to the `/wp-content/plugins/` directory and extract the contents.
    49491. Activate the plugin through the 'Plugins' menu in WordPress.
    50 1. Template File Usage: <?php do_shortcode('[AdMangler width="468" height="60" position="1"]'); ?>
     501. 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"]'); ?>
    51511. Wordpess ShortCodes for pages and posts: [AdMangler width="468" height="60"]
    52521. (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]
    5853
    5954== 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; ?>`
    6355
    6456
     
    6961
    7062== 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
    7168
    7269= 0.0.9.4.Alpha =
Note: See TracChangeset for help on using the changeset viewer.