Text ad serving without scripts

So I’ve just been tasked with developing a quick application to serve some text ads to a third-party website. The catch is that this third-party site has nothing available. No PHP. No CFM. No ASP. No JavaScript allowed. So now what’s a guy to do? Well the search is definitely on. I’ll be developing the application on a platform of PHP & MySQL…this is the easy part. The challenging part now is to serve it and I’m not seeing a lot of viable options.

Option 1: Use an IFRAME. Not my preferred choice but perhaps the only real viable option. The IFRAME can contain a JavaScript snippet to resize the opening as required to accommodate the text, and of course the page will also display the text and style the IFRAME. A challenging implementation, but definitely a solution.

Option 2: Use an image and dynamically create the text ad as an image. The issue with this comes around the fact that the text will not be selectable and more importantly font styles and formats may not match. It violates aspects of CSS.

Option 3: Simply have the client place the text and links on their own to the website and just use an outbound tracking link that will record the hit. No way to track impressions, just outbound clicks. This option just came to me and a hybrid of this option and option 2 might work with creating a transparent 1×1 GIF and having it record the impression. The only issue doing it this way is there is NO control over deployment, expiration or randomization.

Option 4: Screw it. Tell the client there’s no way it will happen!

OK, so those four options (with number 3 coming after 4 in all honesty) are my plausible solutions. What are your thoughts? Oh, and I only have a 24 hour time frame to get this done as well…I knew there was something I forgot to mention! Thanks in advance.

This entry was posted on Tuesday, February 24th, 2009 at 1:35 pm and is filed under Code Development, Searches. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

One Response to “Text ad serving without scripts”

  1. Marshall Says:

    OK, here’s the solution that I’ve come up with. Let me know your thoughts.

    The outbound link tracker

    < ?PHP require("config.php"); require($docRoot."/opendb.php"); $id = $_GET["id"]; $today = date("Y-m-d H:i:s"); // $q = "SELECT url FROM textad WHERE id='".mysql_real_escape_string($id)."' AND deploy_date <= '$today' AND expire_date >= ‘$today'”;
    $q = “SELECT url FROM textad WHERE id='”.mysql_real_escape_string($id).”‘”;
    $r = mysql_query($q);

    $q1 = “UPDATE textad SET clicks=clicks+1 WHERE id='”.mysql_real_escape_string($id).”‘”;
    $r1 = mysql_query($q1);

    if( mysql_num_rows($r)==1 )
    {
    $destUrl = mysql_result( $r, 0, 0 );
    die( header(‘location:http://‘.$destUrl) );
    }
    else
    {
    die( header(‘location:’.$prodUrl) );
    }

    include(“closedb.php”); ?>

    The image for impressions:

    < ?php require("config.php"); require($docRoot."/opendb.php"); $id = $_GET["id"]; $today = date("Y-m-d H:i:s"); // $q = "UPDATE textad SET impressions=impressions+1 WHERE id='".mysql_real_escape_string($id)."' AND deploy_date <= '$today' AND expire_date >= ‘$today'”;
    $q = “UPDATE textad SET impressions=impressions+1 WHERE id='”.mysql_real_escape_string($id).”‘”;
    $r = mysql_query($q);

    require($docRoot.”/closedb.php”);

    // Create a new image instance
    $im = imagecreatetruecolor(1, 1);
    $black = imagecolorallocate($im, 0, 0, 0);

    // Make the background transparent
    imagecolortransparent($im, $black);

    // Output the image to browser
    header(‘Content-type: image/gif’);

    imagegif($im);
    imagedestroy($im);
    ?>

    And the MySQL structure:

    CREATE TABLE IF NOT EXISTS `textad` (
    `id` int(11) NOT NULL auto_increment,
    `ad` text NOT NULL,
    `url` varchar(180) NOT NULL,
    `deploy` datetime NOT NULL,
    `expire` datetime NOT NULL,
    `impressions` int(11) NOT NULL,
    `clicks` int(11) NOT NULL,
    PRIMARY KEY (`id`),
    KEY `deploy` (`deploy`,`expire`),
    KEY `expire` (`expire`)
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;

    And finally what the client adds to their site:

    <a href=http://DOMAIN.com/banners/text-ad.php?id=1 rel=”nofollow”>LINK TEXT</a><img src=http://DOMAIN.com/images/banners/text-ad.php?id=1 height=1 width=1 border=1 hspace=1 vspace=1 />

    This is the side that serves it up. It seems to make sense to me in implementation and theory and seems to actually track the impressions and clicks. It sucks there’s no way to randomize off the top of my head (though I could probably somehow figure out how to include the link and text alongside the image or something as a random aspect…but that’s a latter project).

    So, what are your thoughts?

Leave a Reply