• Setup a blog with banner ads

This details how to create a blog and how to modify it to support banner ads.

Questions to ask before you start:

  1. blog administrator's username, password, and e-mail address
  2. ServerName (like “www.example.com”)

Step 1 install basic blog

visit  http://ServerName/blog/wp-admin/install.php


See /home/cszcgi/default/wp-banner for copy of the following

Background

  • In the samples below
    • The banner ad images will be in /Blog/ADV/ and then either in Banners_Premier or /Blog/ADV/BannersRotation/ (the absolute address of these rotating banners is put into the database via the manageSite's "Ads" button.
    • Setup is configured for Thematic theme modified by the Thematic Options blog. both of which should be installed.
    • Size is set to 250 for the rotators and 255.
  • Click tracking is mangaged by forward.pl
  • Database for tracking ad views and click throughs will be the same as WP. (see below for structure)
  • Setup is configured for Thematic theme modified by the Thematic Options blog. both of which should be installed.
    • Install copies of thematic and thematic-options by expanding the thematicThemes.tgz file (found in /home/cszcgi/default/wp-banner) into the doc-root/wp-content/themes directory and then activating the thematic-options theme. 
    • Edit the style.css file to set colors etc.
  • In Manage Site there are two programs to support banners managetable.pl and hitreport.pl, this is controlled by the sitename.ph file (see sample below for brensan: brensanblog is the blog name.) blogname.BannerAd.ph ( actually located in the located in manageSite directory.)
  • There are two php modules which are inserted using the Appearance Widgets link in the admin section.  They are entered using text elements.
    • Side php goes into the Sidebar aside as a text element. (see below) The rotating banner bit goes in the Secondary Aside.
    • The primary fixed banner text goes into the 2nd Subsidiary Aside
  • Finally enclosed is the css file modified for option 3c-fixed.css
  • sample footer
    Copyright [the-year], The Brensan Group ©. All Rights Reserved Built on the [theme-link].
  • Set the blog banner using the blog banner upload feature.

TOP↑

Sample primary banner

Top Ad Menu: Tracks 2 special banner's appearences (#8 and #9) in this example

    global $wpdb;
    $hits[0]=8;
    $hits[1]=9;
    foreach ($hits as $bid){
        $ok = $wpdb->query(
        \"INSERT INTO BannerAddResults values(\"
        .$bid.\",DATE_FORMAT(CURRENT_DATE(),\'%Y-%c-01\'), 0,0,now())\"
        );
        $ok = $wpdb->query(
        \"UPDATE BannerAddResults set BaRViews = (BaRViews+1) \"
        .\"where  BaRID = \". $bid .\" and BaRYrMonth = DATE_FORMAT(CURRENT_DATE(),\'%Y-%c-01\')\"
        );
    }
    unset($ok);
    unset($hits);
?>
 >

target=\"_blank\">

target=\"_blank\">

>

TOP↑

Sample rotating banner Sample is set to accept 5 rotating banners

    global $wpdb;
    $maxBanners = 5;
    $sql = \"SELECT `BaID`,`BaImgURL`, rand() a FROM `BannerAd`\"
        . \" where `BaHide` = \'N\' and Date(NOW()) BETWEEN`BaStart` AND `BaStop`\"
        . \" order by a limit \". $maxBanners;

    $result = $wpdb->get_results($sql);
    $c=0;
    foreach ($result as $post) {
        $bannerout =\"           . $post->BaID . \"\' target=\'_blank\'>BaImgURL
           . \"\' width=\'250\' align=\'center\'>

\";
        $hits[$c] = $post->BaID;
        $c++;
        echo $bannerout;
    }
    foreach ($hits as $bid){
        $ok = $wpdb->query(
        \"INSERT INTO BannerAddResults values(\"
        .$bid.\",DATE_FORMAT(CURRENT_DATE(),\'%Y-%c-01\'), 0,0,now())\"
        );
        $ok = $wpdb->query(
        \"UPDATE BannerAddResults set BaRViews = (BaRViews+1) \"
        .\"where  BaRID = \". $bid .\" and BaRYrMonth = DATE_FORMAT(CURRENT_DATE(),\'%Y-%c-01\')\"
        );
    }
    unset($ok);
    unset($c);
    unset($bannerout);
    unset($result);
    unset($post);
    unset($maxBanners);
    unset($sql);
    unset($hits);
?>

TOP↑

Create Banner Tracking Tables

--
-- Table structure for table 'BannerAd'
--

CREATE TABLE IF NOT EXISTS BannerAd (
  BaID bigint(20) unsigned NOT NULL auto_increment COMMENT 'Banner ID',
  BaName varchar(100) collate utf8_bin NOT NULL COMMENT 'Refereance Name',
  BaURL varchar(255) collate utf8_bin NOT NULL COMMENT 'Ad Target URL w/http or https',
  BaImgURL varchar(255) collate utf8_bin NOT NULL COMMENT 'URL of Image for banner',
  BaStart date NOT NULL COMMENT 'Ad starts on this date',
  BaStop date NOT NULL COMMENT 'Banner ends after this date',
  BaHide enum('Y','N') collate utf8_bin NOT NULL default 'N' COMMENT 'Hide Banner, overrides dates',
  PRIMARY KEY  (BaID),
  KEY BaName (BaHide,BaStart,BaStop)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

-- --------------------------------------------------------

--
-- Table structure for table 'BannerAddResults'
--

CREATE TABLE IF NOT EXISTS BannerAddResults (
  BaRID bigint(20) unsigned NOT NULL COMMENT 'Corresponds to Banner Ad ID',
  BaRYrMonth date NOT NULL COMMENT 'Year, Moth for which this reports',
  BaRViews bigint(20) unsigned NOT NULL default '0' COMMENT 'Number of views',
  BaRClicks bigint(20) unsigned NOT NULL default '0' COMMENT 'Number of Chick Throughs',
  BaRLastChg timestamp NOT NULL default CURRENT_TIMESTAMP COMMENT 'Last Update',
  PRIMARY KEY  (BaRID,BaRYrMonth)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

TOP↑

Entries in the site.tld.ph file in manage site




$sessionBit


     

 

 


$sessionBit

     

     

TOP↑

Sample CSS

/*
Theme Name: Thematic Options
Theme URI: http://wptheming.com/
Description: Thematic child theme with an options array to speed development.
Author: Devin Price
Author URI: http://wptheming.com/
Template: thematic
Version: 1.1.3
Tags: thematic
Thematic is © Ian Stewart http://themeshaper.com/

Initial development by Tristan Waddington.
AJAX and 1.1 updates by Aaron Jorbin.

Test for reset
*/

/* Reset browser defaults */
@import url('../thematic/library/styles/reset.css');

/* Apply basic typography styles */
@import url('../thematic/library/styles/typography.css');

/* Apply basic image styles */
@import url('../thematic/library/styles/images.css');

/* Prepare theme for plugins */
@import url('../thematic/library/styles/plugins.css');

#respond::before
{   color: #008800; font-style: italic;
    display: inline;
    content: "Comments are moderated, and will not appear until the author has approved them.";
}

/* =Global Elements

body {
    font: 15px Georgia,serif;
    line-height:22px;
    min-width:1024px;
    background-color: #CCFFCC;
}
input {
    font: 15px Georgia,serif;
    line-height:22px;
    min-width: 30px;
    background-color: #ffffff;
}
textarea {
    font: 15px Georgia,serif;
    line-height:22px;
    min-width: 920px;
    background-color: #ffffff;
}
p, ul, ol, dd, pre {
    margin-bottom:22px;
}
pre, code {
        font:14px Monaco, monospace;
        line-height:22px;
}
blockquote {
    color:#666;
    font-style:italic;
}
table {
    border:1px solid #ccc;
    border-width:1px 1px 0 1px;
    font-size:13px;
    line-height:18px;
    margin:0 0 22px 0;
    text-align:left;
}
caption {
    text-align:left;

}
tr {
    border-bottom:1px solid #ccc;
}
th, td {
    padding: .7em 1.25em;
}
hr {
    background-color:#ccc;
    border:0;
    color:#ccc;
    height:1px;
    margin-bottom:22px;
}
a:link {
    color:#004B91;
}
a:visited {
    color:#743399;
}
a:active,
a:hover {
    color: #FF4B33;
}


/* =Header
-------------------------------------------------------------- */

#header {
    z-index:2;
}
#branding {
        width:970px;
        background-image: url(http://brensan.com/wp-content/uploads/2010/11/blogbanner2.gif);
        background-repeat: no-repeat;
        background-position: center top;
        margin: 2px auto 200px auto;
        height: 178px;


}
#branding a { color: white;
    text-decoration: none;
    font-size: 1px;
}
#blog-title {
    font-family:Arial,sans-serif;
    font-size:1px;
    font-weight:lighter;
}
#blog-title a {
    color:#ffffff;
    text-decoration:none;

}

#blog-description {
    color:#666;
    font-size:13px;
    font-style:italic;
}


/* =Menu
-------------------------------------------------------------- */

.skip-link {
    display:none;
}
#access {
    border-bottom:1px solid #ccc;
    height:32px;
    font-size:13px;
    overflow:visible;
    z-index:100;
}
/*** ESSENTIAL STYLES ***/
.sf-menu, .sf-menu * {

        margin:                 0;
        padding:                0;
        list-style:             none;
}
.sf-menu {
        line-height:    1.0;
}
.sf-menu ul {
        position:               absolute;
        top:                    -999em;
        width:                  10em; /* left offset of submenus need to match (see below) */
}
.sf-menu ul li {
        width:                  100%;
}
.sf-menu li:hover {
        visibility:             inherit; /* fixes IE7 'sticky bug' */
}
.sf-menu li {
        float:                  left;
        position:               relative;
}
.sf-menu a {
        display:                block;
        position:               relative;
}
.sf-menu li:hover ul,
.sf-menu li.sfHover ul {
        left:                   0;
        top:                    2.5em; /* match top ul list item height */
        z-index:                99;
}
ul.sf-menu li:hover li ul,
ul.sf-menu li.sfHover li ul {
        top:                    -999em;
}
ul.sf-menu li li:hover ul,
ul.sf-menu li li.sfHover ul {
        left:                   10em; /* match ul width */

        top:                    0;
}
ul.sf-menu li li:hover li ul,
ul.sf-menu li li.sfHover li ul {
        top:                    -999em;
}
ul.sf-menu li li li:hover ul,
ul.sf-menu li li li.sfHover ul {
        left:                   10em; /* match ul width */
        top:                    0;
}

/*** THEMATIC SKIN ***/
.sf-menu {
    border-right:1px solid #ccc;
        float:left;
}
.sf-menu a {
        border-left:1px solid #ccc;
        border-top:1px solid #ccc;
        border-bottom:1px solid #ccc;
        padding:9px 13px;
        text-decoration:none;
}
.sf-menu .current_page_item a,
.sf-menu .current_page_ancestor a,
.sf-menu .current_page_parent a {
    border-bottom-color:#fff;
}
.sf-menu a, .sf-menu a:visited  { /* visited pseudo selector so IE6 applies text colour*/
        color:                  #666;
}
.sf-menu li {
        background:             #fff;
}
.sf-menu li li {
        background:             #fff;
}
.sf-menu li li li {

        background:             #9AAEDB;
}
.sf-menu li:hover, .sf-menu li.sfHover,
.sf-menu a:focus, .sf-menu a:hover, .sf-menu a:active {
    background:     #fafafa;
        outline:                0;
    border-bottom-color:#ccc;
}
.sf-menu ul {
    border-right:1px solid #ccc;
    border-bottom:1px solid #ccc;
}
.sf-menu li:hover ul,
.sf-menu li.sfHover ul {
        top:32px; /* overriding essential styles */
}
.sf-menu ul ul {
    margin-top:0;
}
.sf-menu ul a {
    background:#fafafa;
        border-bottom:none;
}
.sf-menu ul a:hover {
    color: #FF4B33;
}


/* =Content
-------------------------------------------------------------- */

#main {
    clear:both;
    padding:5px 0 22px 0;
    background: #ffffff;
    min-width: 1000px;
}
.page-title {
    font-size:1px;    line-height:1px;
    padding:0; color: #ffffff;
}
#container {
        width: 700px; margin: 10px auto;
        float: left;
}
.alignright { float: right; padding: 2px;}

.alignleft { float: left; padding: 2px;}

.attachment .page-title {
    font-style:italic;
}
.page-title a {
    color:#ffffff;
    text-decoration:none;
}
.page-title a:active,
.page-title a:hover {
    color: #FF4B33;
}
.page-title span {
    font-style:italic;
}
.page-title .meta-nav {
    font-style:normal;
}
.hentry {
    padding:0 0 22px 0;
}
.single .hentry {
    padding:0;
}
.home #content .sticky {
     margin:0 0 10px 0;
    padding:10px 10px 0 10px;
}
#content {

  border-left: solid #CCFFCC 4px;
  border-right: solid #CCFFCC 4px;
  margin-left: 5px;
  margin-right: 2px;
}
.entry-title {
    font-family:Arial,sans-serif;
    font-size:26px;
    font-weight:bold;
    line-height:26px;
    padding:0 0 7px 0;
}
.entry-title a {
    color:#000;
    text-decoration:none;
}
.entry-title a:active,
.entry-title a:hover {
    color: #FF4B33;
}
.entry-meta {
    color:#666;
    font-size:13px;
    font-style:italic;
    line-height:18px;
}
.entry-meta .author {
}
.entry-meta .n {
    font-size:11px;
    font-style:normal;
    letter-spacing:0.05em;
    text-transform:uppercase;
}
.entry-meta a {
    color:#666;
    text-decoration:none;
}
.entry-meta a:active,

.entry-meta a:hover {
    color: #FF4B33;
}
.entry-meta abbr {
    border:none;
    cursor:text;
    font-size:11px;
    font-style:normal;
    letter-spacing:0.05em;
    text-transform:uppercase;
}
.entry-content {
    padding:22px 0 0 0;
}
.entry-content h1,
.entry-content h2 {
    font-family:Arial,sans-serif;
    font-size:19px;
    font-weight:bold;
    padding:28px 0 14px 0;
}
.entry-content h3 {
    font-size:17px;
    font-style:italic;
    padding:28px 0 14px 0;
}
.entry-content h4 {
    font-size:11px;
    font-family:Arial,sans-serif;
    font-weight:bold;
    text-transform:uppercase;
    letter-spacing:0.05em;
}
.entry-content table {
    margin-left:1px;
}
.entry-content embed {
    margin:0 0 22px 0;
}

.entry-utility {
    color:#666;
    font-size:13px;
    line-height:18px;
    margin:0 0 44px 0;
}
.entry-utility a {
    color:#006600;
    font-weight: bold;
    font-style: italic;
    text-decoration:none;
}
.entry-utility a:active,
.entry-utility a:hover {
    color: #006600;
    font-weight: bold;
}
.page-link {
    font-size:13px;
    font-weight:bold;
    line-height:18px;
    margin:0 0 22px 0;
    padding:22px 0 0 0;
    word-spacing:0.5em;
}
.page-link a {
    border:1px solid #ccc;
    color:#666;
    font-weight:normal;
    padding:0.5em 0.75em;
    text-decoration:none;
}
.page-link a:active,
.page-link a:hover {
    color: #FF4B33;
}
ul#links-page,
ul#archives-page {
    list-style:none;

    margin-left:0;
    overflow:hidden;
}
li.content-column {
    float:left;
    margin-right:20px;
    width:45%;
}
.gallery {
    padding:0 0 22px 0;
}
.wp-caption-text,
.gallery-caption {
    color:#666;
    font-size:13px;
    line-height:18px;
    text-align:center;
}
#author-info {
    margin:0 0 44px 0;
    overflow:hidden;
}
#author-info .avatar {
    float:left;
    margin:.3em 1em 0 0;
}


/* =Attachments
-------------------------------------------------------------- */

.attachment-jpeg #container,
.attachment-png #container {
    width:100%;
}
.attachment-jpeg #content,
.attachment-png #content {
    width:930px;
}

.attachment-jpeg #comments,
.attachment-png #comments {
    width:540px;
    overflow:hidden;
}
.attachment-jpeg .main-aside,
.attachment-png .main-aside {
    display:none;
}
#content a img  { border: 2px blue solid;
}

/* =Navigation
-------------------------------------------------------------- */

.navigation {
    color:#666;
    font-size:13px;
    line-height:18px;
    margin:0px 0 22px 0;
    overflow:hidden;
}
.navigation a {
    color:#666;
    font-style:italic;
    text-decoration:none;
}
.navigation a:active,
.navigation a:hover {
    color: #FF4B33;
}
.navigation .meta-nav {
    font-style:normal;
}
.nav-previous {
        float: left;
        width:50%;
}
.nav-next {

        float: right;
        width:50%;
        text-align:right;
}
#nav-above,#nav-below {
        width: 100%;
}
#nav-above {
    display:none;
}
.paged #nav-above {
    display:block;
    padding:0 0 44px 0;
}


/* =Comments
-------------------------------------------------------------- */

#comments {
    padding:22px 0 0 0;
}
#comments,
#comments input,
#comments textarea {
    font-size:13px;
    line-height:18px;
}
#comments code {
    font-size:12px;
    line-height:18px;
}
#comments h3 {
    font-family:Arial,sans-serif;
    font-size:15px;
    font-weight:bold;
    line-height:22px;
    padding:0 0 18px 0;
}

#comments-list {
    padding:0 0 18px 0;
}
#comments-list ol,
#comments-list ul {
    list-style:none;
    margin:0;
}
#comments-list ol {
    border:1px solid #ccc;
    border-bottom:none;
    margin:0 0 18px 0;
}
#comments-list li {
    background:#fafafa;
    border-bottom:1px solid #ccc;
    padding:18px 1.5em 0 1.5em;
    position:relative;
}
#comments-list li.alt {
    background:#fff;
}
#comments-list li.bypostauthor {
    background:#FFFFCC;
}
#comments-list ul li {
    border:1px solid #ccc;
    margin:0 0 18px 0;
}
#comments-list li .avatar {
    position:absolute;
    top:22px;
    left:1.5em;
    width:36px;
    height:36px;
}
#comments-list .comment-author {
    font-weight:bold;
    padding:9px 0 0 46px;

}
#comments-list .comment-meta {
    color:#666;
    font-size:11px;
    padding:0 0 9px 46px;
}
#comments-list .comment-meta a {
    color:#666;
    font-style:italic;
    text-decoration:none;
}
#comments-list .comment-meta a:active,
#comments-list .comment-meta a:hover {
    color: #FF4B33;
}
.comment-reply-link {
    font-size:11px;
    padding:0 0 18px 0;
    text-align:right;
}
.comment-reply-link a {
    color:#666;
    font-style:italic;
    text-decoration:none;
}
.comment-reply-link a:active,
.comment-reply-link a:hover {
    color: #FF4B33;
}
.comment-navigation {
    font-weight:bold;
    padding:0 0 18px 0;
    margin-right:0.5em;
}
.comment-navigation a {
    border:1px solid #ccc;
    color:#666;
    font-weight:normal;
    padding:0.5em 0.75em;

    text-decoration:none;
}
.comment-navigation a:active,
.comment-navigation a:hover {
    color: #FF4B33;
}
.comment-navigation a,
.comment-navigation span {
    margin-right:0.5em;
}
#trackbacks-list .comment-content {
    position:absolute;
    left:-10000px;
}
#respond {
    background:#fff;
    margin-bottom:22px;
    overflow:hidden;
    padding:18px 0 0 0;
    position:relative;
}
#comments-list #respond {
    border-bottom:1px solid #ccc;
    margin:0 0 18px 0;
    padding:18px 1.5em;
}
#comments-list ul #respond {
    border:1px solid #ccc;
    margin:0;
}
#cancel-comment-reply {
    font-size:11px;
    position:absolute;
    top:18px;
    right:1.5em;
}
#cancel-comment-reply a {
    color:#666;
}

#respond .required {
    color:#FF4B33;
    font-weight:bold;
}
.form-section label {
    font-size:11px;
}
.form-section input {
    margin:0 0 18px 0;
    width:98%;
}
.form-section textarea {
    width:99%;
}
#form-allowed-tags p {
    color:#666;
    font-size:11px;
    margin:0;
}
#form-allowed-tags span {
    font-style:italic;
}
#form-allowed-tags code {
    font-size:11px;
    line-height:normal;
}
.form-submit {
    padding:18px 0 0 0;
    text-align:right;
}
.subscribe-to-comments {
    color:#666;
    float:left;
    font-size:11px;
    margin:0;
    padding:18px 0 0 0;
}
.solo-subscribe-to-comments {
    color:#666;

    font-size:11px;
    padding:18px 0 0 0;
}
.comment_license {
    color:#666;
    clear:both;
    font-size:11px;
    margin:0;
    padding:18px 0 0 0;
}


/* =Asides, Sidebars & Widget-Ready Areas
-------------------------------------------------------------- */

.aside {
    font-size:13px;
    line-height:18px;
    margin-bottom:6px;

}
.aside input {
    font-size:13px;
    line-height:18px;
    margin-bottom:6px;
}

.aside p,
.aside ul,
.aside ol,
.aside dd,
.aside pre {
    margin-bottom:18px;
}
.aside pre,
.aside code {
    font-size:12px;
    line-height:18px;
}

.aside .current_page_item a {
    color: #FF4B33;
}
.aside .current_page_item .page_item a {
    color:#666;
}
.aside .current_page_item .page_item a:hover,
.aside .current_page_item .page_item a:active {
    color: #FF4B33;
}
.aside {
    min-width:200px;
}
.aside a {
    color:#666;
}
.aside a:active,
.aside a:hover {
    color: #FF4B33;
}
.aside h3 {
    font-size:15px;
    font-style:italic;
    line-height:22px;
}
.aside h3 a {
    text-decoration:none;
}
.aside caption {
    font-size:11px;
    font-family:Arial,sans-serif;
    font-weight:bold;
    text-transform:uppercase;
    letter-spacing:0.05em;
}
.aside ul {
    list-style:none;
    margin-left:0;
}

.aside ul ul {
    list-style:disc;
    margin:0 0 22px 20px;
}
.aside ul ul li {
    padding:1px 0;
    font-size: 11pt;
    font-family: times, roman;
}
.aside ul ul ul {
    margin-bottom:0;
}
.aside form,
.aside table {
    margin-bottom:22px;
}
.aside table {
    border:none;
}
.aside thead {
    border:1px solid #ccc;
}
.aside tbody {
    border:1px solid #ccc;
}
.aside th, .aside td {
    border-right:1px solid #ccc;
    padding:.25em .8em;
}
.aside tfoot tr {
    border:none;
}
.aside tfoot td {
    border-color:transparent;
}
.widget_tag_cloud {
    margin:0 0 22px 0;
}
.aside #searchsubmit {

        display: none;
}
/*
    Main Asides
*/
.main-aside ul {
    padding:0 20px;
}
.main-aside h3 {
}
.main-aside ul ul {
    padding:0;
}
#secondary {
  width: 420px;
  background: #ffffff;
  position: relative;
  right: 20px;
 }
#primary {
    padding:18px 0 0 0;
    margin-bottom:22px;
    width: 150px;
}
#second {
  z-index: 99;
  position:absolute;
  top: 110px;
  text-align: center;
  min-width: 980px;
  min-height: 50px;
  margin: 0px auto 0px auto;
}
#second li { margin-left: -80px;
}
/*
    Content Asides
*/
.aside {

    margin:0 0 5px 0;
    padding:5px 0 0 0;
}
#content {
    border: 0px 5px solid #ffffcc;
    margin:0 0 5px 0;
    padding:5px 0 0 0;
}
#content .aside ul {
    padding:0 20px;
}
#content .aside h3 {
    font-family:Georgia,serif;
    font-weight:normal;
    font-size:17px;
    font-style:italic;
    padding:0 0 7px 0;
    text-transform:none;
}
#content .aside ul ul {
    padding:0;
}
/*
    Footer Asides
*/
#subsidiary {
    padding:33px 0 0 0;
}


/* =Footer
-------------------------------------------------------------- */

#footer {
    border-top:1px solid #ccc;
    margin-top:22px;
}
#siteinfo {
    color:#666;

    font-size:11px;
    line-height:18px;
    padding:22px 0 44px 0;
}
#siteinfo a {
    color:#666;
}
#siteinfo a:active,
#siteinfo a:hover {
    color: #FF4B33;
}
#calendar_wrap table { font-face: arial,sans; font-size: 10pt;}
#calendar_wrap tr td { padding: 1px; margin: 1px; }
#calendar_wrap a { font-weight: bold; text-decoration: none; color: blue;
        font-face: arial,sans;
}

Tweaks:

  • about line 111 look for background-image: url and insert full URL of the to banner and adjust the sizing. You can also add border etc.
  • about line 180: change the backround

TOP↑

blogname.BannerAd.ph put in manageSite/ directory

# Banner Ad Control File
sub initializevariables {
    my($fnameRef,$flengthRef,$ftypeRef,$freqRef,$pnameRef,$lfieldsRef,
        $sfieldsRef,$nfieldsRef,$listoptionsRef,$defaultRef,$notesRef,$dbh,
        $qkeyFieldRef)
        =@_;

#  $publicTableName = 'bannerAd';
    @$fnameRef =(
        'BaID','BaName','BaURL','BaImgURL','BaStart'
        ,'BaStop','BaHide'
    );

    @$ftypeRef        =(
        'S','c','h','h','d'
        ,'d','b'
    );
    @$flengthRef    =(
        20,100,255,255,10
        ,10,1
    );
    @$pnameRef      =(
        'Banner ID','Name','Site URL','Banner URL','Start Date'
        ,'Stop Date', 'Hide'
    );
    @$notesRef      =(
        '','','','','',''
        ,'',''
    );
#  @$gsourceRef = (
#        0,0,0,0,0,0

#  );
    @$freqRef        = (
        0,1,1,1,1,1
        ,1,1
    );
    @$defaultRef = (
        '0','','','',''

        ,'','N'
    );
#  @$gsizeRef =();
#  $graphicbase='';
    @$listoptionsRef = (
        '','','','','',''
        ,'',''
    );

    $$qkeyFieldRef = 0; # if field type includes quantity
    @$lfieldsRef = (0,1,4);
  @$sfieldsRef = (1,4);
  @$nfieldsRef = (0..6);
}
sub makekey {
     if($_[0])  { return "BaID = '$_[0]'";
    } else { return undef;
    }
}

sub clientcleanup {
    my ($dbh,$action,$key) = @_;
    if($action eq 'Delete' and $key and $dbh){
        $dbh->do("delete BannerAddResults where BaRID = $key");
    }
    return 1;
}

1;

 

TOP↑

forward.pl    set in cgi-bin root of site with blog.

#!/usr/bin/perl

=head1 NAME: $Id$

=head1 SYNOPSIS: Track click throughs and forward to designated site.

=head1 DESCRIPTION:

On call get Banner ID.  lock database and insert tracking record if none for that ID and year month is present. release lock

Update click count.

Issue Location Redirect to URL.

=cut

use DBI;
use CGI qw{-debug};
use CGI::Carp qw{fatalsToBrowser};

my $q = new CGI;

my ($dbh,$target);

my ($bid) = $q->param('BID') =~ /(\d+)/;

die "Improperly called no banner ID provided, I don't know where to go"
    if(!$bid);

setup();

eval {
    ($target) = $dbh->selectrow_array("select rtrim(BaURL) from BannerAd where BaID = $bid");
    if($target){
        $dbh->do("LOCK TABLES BannerAddResults WRITE");
        my($test) = $dbh->selectrow_array(
            "select 1 from BannerAddResults where BaRID = $bid and BaRYrMonth = DATE_FORMAT(CURRENT_DATE(),'%Y-%c-01')");
        if(!$test){
            $dbh->do("insert into BannerAddResults values($bid ,DATE_FORMAT(CURRENT_DATE(),'%Y-%c-01'),0,0,now())");

        }
        $dbh->do("UNLOCK TABLES");
        $dbh->do(
          "update BannerAddResults set BaRClicks = (BaRClicks+1) where  BaRID = $bid and BaRYrMonth = DATE_FORMAT(CURRENT_DATE(),'%Y-%c-01')");
        print $q->redirect($target);
        exit;
    } else {
        die "Invalid ID, no such banner";
    }


=pod
 SELECT `BaID`,`BaImgURL`, rand()  a FROM `BannerAd`
where `BaHide` = 'N' and Date(NOW()) BETWEEN`BaStart` AND `BaStop`
 order by a limit 5
=cut
};

sub setup {

    my $dbuser = 'brensanblogTrack';
    my $dbpasswd ="szfdNyVNzSSjSDsD";
    my $dbname = 'brensanblog';
    $dbh =  DBI->connect("DBI:mysql:database=$dbname;host=localhost;", $dbuser,$dbpasswd);

}

TOP↑