Unexplained Javascript PopUp

Discussion in 'JavaScript' started by WPPJames, May 19, 2010.

  1. #1
    I have a php page (feed.php) with the following code:

    <?php
    require_once 'config.php';
    $v_uid = $_POST["uid"]; //unique software identifier
    $v_pid = $_POST["pid"]; //unique partner ID
    $v_url = $_POST["url"]; //URL encoded URL
    $v_ua = $_POST["ua"]; //User-Agent
    $v_ver = $_POST["ver"]; //BHO version number
    $Users_IP_address = $_SERVER["REMOTE_ADDR"];
    
    if ($v_uid == '')
    {
    //if end user's SoftwareID value isn't set, we have a tracking problem, so just exit without doing anything at all
    exit();
    }
    
    //Check if record exists in installs table for this SoftwareID
    $result = mysql_query("SELECT * FROM installs WHERE SoftwareId = '$v_uid'");
    $num = mysql_num_rows($result);
    if($num == 0)
    {
    	//If record does not exist -  add new record
    	$res = mysql_query("insert into installs(PartnerID,SoftwareID,IPAddress,BrowserAgent,Last_Activity_URL,BHOVer,last_ad_served) values('$v_pid','$v_uid','$Users_IP_address','$v_ua','$v_url','$v_ver',Now())");
    }
    else
    {
    	//If record exists, update select fields
    	$result = mysql_query("UPDATE installs SET Last_Activity = NOW() WHERE SoftwareID = '$v_uid'"); //or die(mysql_error());
    	$result = mysql_query("UPDATE installs SET Last_Activity_URL = '$v_url' WHERE SoftwareID = '$v_uid'"); //or die(mysql_error());
    	$result = mysql_query("UPDATE installs SET total_server_hits = total_server_hits + 1 WHERE SoftwareID = '$v_uid'"); //or die(mysql_error());
    }
    
    //Assign select field values from this record to php variables
    $result = mysql_query("SELECT * FROM installs WHERE SoftwareId = '$v_uid'");
    $row = mysql_fetch_assoc($result);
    $d_ast = $row["ads_served_today"];
    $d_las = strtotime($row["last_ad_served"]);
    	
    //check if user has already received 6 ads today
    if ($d_ast > 5) exit();
    
    //check if user has received ad within last 20 minutes
    $date1 = strtotime(date("Y-m-d H:i:s"));
    $mins = round(abs($date1 - $d_las) / 60,0);
    if ($mins < 20) exit();
    
    // make call to DirectCPV server and get XML results
    $v_url2 = urlencode($v_url); //URL encoded URL
    $v_ua2 = urlencode($v_ua); //User-Agent
    $request_url = "http://query.directrdr.com/ptrack?pid=458&v_url=" . $v_url2 . "&feed=1&said=" . $v_pid . "&ip=" . $Users_IP_address . "&ua=" . $v_ua2 . "&keyword=";
    //if ($v_uid == '{E8080993-BD42-4395-89FF-2C2D624628DA}') echo ("xxx $request_url");
    $xml = simplexml_load_file($request_url,'SimpleXMLElement', LIBXML_NOCDATA); // or die("feed not loading");
    $adtype = (string) $xml['Type'];
    $outurl = (string) $xml->ad->url;
    $cpvr = (string) $xml->ad->cpvrate;
    $crid = (string) $xml->ad->creativeid;
    $caid = (string) $xml->ad->campaignid;
    $mipu = (string) $xml->ad->{'max-imp-per-user'};
    $fp = (string) $xml->ad->{'frequency-period'};
    
    //Did DCPV return a pop-up ad to display, if not then exit
    if ($adtype != "Popup") exit();
    
    //SHOW POP-UP AD
    $ad_url = $outurl;
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link rel="stylesheet" type="text/css" href="interstitial.css" />
    <title>Welcome to our Page</title>
    <script type="text/javascript" src="interstitial.js.php?ad_url=<?php echo $ad_url; ?>&amp;v_url=<?php echo $v_url; ?>">
    </script>
    
    <!--
    <style type="text/css">
    html {overflow: auto;}
    html, body, div, iframe {margin: 0px; padding: 0px; height: 100%; border: none;}
    iframe {display: block; width: 100%; border: none; overflow-y: auto; overflow-x: hidden;}
    </style>
    -->
    
    </head>
    
    <body>
    
    <iframe width="100%" height="100%" marginwidth="0" marginheight="0" frameborder="0" vspace="0" hspace="0" scrolling="no" src="<?php echo $v_url; ?>"></iframe>
    
    </body>
    </html>
    <?php
    ///Update record in installs table for this user (based on SoftwareID)
    $result = mysql_query("UPDATE installs SET last_ad_served = NOW() WHERE SoftwareID = '$v_uid'"); // or die(mysql_error());
    $result = mysql_query("UPDATE installs SET total_ads = total_ads + 1 WHERE SoftwareID = '$v_uid'"); // or die(mysql_error());
    $result = mysql_query("UPDATE installs SET ads_served_today = ads_served_today + 1 WHERE SoftwareID = '$v_uid'"); // or die(mysql_error());
    
    //Add new record to ads table
    $res = mysql_query("insert into ads(PartnerID,SoftwareID,IPAddress,BrowserAgent,URL,BHOVer,dcpv_url,dcpv_rate,dcpv_creative_id,dcpv_campaign_id) values('$v_pid','$v_uid','$Users_IP_address','$v_ua','$v_url','$v_ver','$outurl','$cpvr','$crid','$caid')");
    
    ?>
    Code (markup):
    If the code reaches the //SHOW POP-UP AD section of the file, it should process the following code. Instead, it just displays the code in a pop-up box (JavaScript Alert box?) as shown below.

    [​IMG]

    What would be causing this behaviour?
     
    WPPJames, May 19, 2010 IP