<? include("header.php"); ?>
!!! Beginning Script Output !!! <br/><br/>
<?
require_once("db-inc.php"); //load MySQL vars.
$sql = "SELECT `BaseURL`,`ClicksPath` FROM `$mysql_campaign_config` WHERE `ID` = '0' LIMIT 1";
$result = mysql_query($sql);
if(mysql_num_rows($result) < 1) {
echo "ERROR LOADING CONFIGURATION<br/>";
} else {
$row = mysql_fetch_array($result);
$baseurl = $row['BaseURL']; //base url of script installation
$cp = $row['ClicksPath']; //path to the directory to store generated files
}
$sql = "SELECT `ID` FROM `$mysql_campaign_table` WHERE `Rotate` = '1'"; //These campaigns need files generated
$result = mysql_query($sql);
echo mysql_num_rows($result) ." campaigns with rotation enabled.<br/>";
while($row = mysql_fetch_array($result)) {
$cid = $row['ID'];
$sql_1 = "SELECT `Name`,`URL`,`Image`,`ID` FROM `$mysql_link_table` WHERE `CID` = '$cid' ORDER BY `Clicks` DESC";
$result_1 = mysql_query($sql_1);
$total_ads = mysql_num_rows($result_1);
if($total_ads > 0) {
$ad = rand(0,$total_ads - 1);
echo "Ad $ad selected<br/>"; //most of this output is just to help keep track of script execution while debugging...fyi
} else {
echo "No ads found for CID $cid<br/>";
break;
}
for($i = 0; $row_1 = mysql_fetch_array($result_1); $i++) {
if($i == $ad) {
$name = stripslashes($row_1['Name']);
$url = $row_1['URL'];
$image = $row_1['Image'];
$id = $row_1['ID'];
$out_txt = "<a href=\"".$baseurl."?lid=$id&cid=$cid\" target=\"_blank\">$name</a>";
$out_img = "<a href=\"".$baseurl."?lid=$id&cid=$cid\" target=\"_blank\"><img src=\"".trim($image)."\" border=\"0\" ></a>";
$txt_file = $cp . $cid."_txt.htm"; //get proper file name
echo "Working with $txt_file<br/>";
$img_file = $cp . $cid."_img.htm"; //get proper file name
echo "Working with $img_file</br>";
$fp = fopen($txt_file,"w"); //write text link file (no problems here)
if(!fwrite($fp,$out_txt,strlen($out_txt))) {
echo "Error writing $txt_file. Please ensure the /go directory has permissions 777.<br/>";
} else {
echo "Successfully wrote $txt_file.<br/>";
}
$fp = fopen($img_file,"w"); //write the banner link file (this is the file with the issues)
if(!fwrite($fp,$out_img,strlen($out_img))) {
echo "Error writing $img_file. Please ensure the /go directory has permissions 777.<br/>";
} else {
echo "Successfully wrote $img_file.<br/>";
}
}
}
}
?>
<br/><br/>!!! End of Script Output !!!
<? include("footer.php"); ?>
The output of the script is...
!!! Beginning Script Output !!!
1 campaigns with rotation enabled.
Ad 0 selected
Working with /var/www/html/clicks/2_txt.htm
Working with /var/www/html/clicks/2_img.htmSuccessfully wrote /var/www/html/clicks/2_txt.htm.
Successfully wrote /var/www/html/clicks/2_img.htm.
!!! End of Script Output !!!
What seems even more interesting to me, is that until i add the final > for the img tag, it is working fine...so if i have a broken up image tag like this...
<img src="image.gif" border="0"
the link will be displayed as the text of the invalid img tag...bust as soon as the > is tagged onto the end, it is gone on a PC. Also, when editing the code in Dreamweaver (on a Mac), the HTML code appears fine. When using Contribute on a PC, it recognizes that there's HTML for an image.....
any help is greatly appreciated...
thanks,
-kevin