View Full Version : whats wrong with my code need help in gateway setting content locker

01-28-2012, 12:14 PM
I had created a gateway for my website. Its a content locker widget by a CPA network. I am using the following codes attached with this post. My website is based on file download. When a user completing a lead, page is refreshing but file downloading is not starting. I wanna know where is the bug in my coding. Please help me. All required files are attached with this post and instruction of gateway and post-back is included.





<div id="secondaryContent">

<div class="content-holder">

<div class="box-shadow-top"></div>

<div class="box-shadow-inner">

<h1>File Download</h1>

<div class="message_area">

<div><?php echo $core->showMessage(); $core->deleteMessage();?></div>


<div class="download">

<div class="download-inner">

<?php if(isset( $file_id) and $file->isFileExists( $file_id)){?>
<div class="share-image">
<a href="http://www.facebook.com/sharer.php?u=<?php echo $core->curPageURL();?>" target="_blank" title="Click to send this page to Facebook!" > <img alt="Share it on facebook" src="<?php echo $siteName?>images/fb_share.gif" border=0> </a>

<a href="http://twitter.com/home?status=Download Free <?php echo $core->curPageURL();?>" title="Click to send this page to Twitter!" target="_blank"><img src="<?php echo $siteName?>images/tw_share.jpg" border=0 alt="Tweet This!" /></a></div>

<div class="file-image"> <img src="<?php echo $siteName?>images/download-icon.png" alt=""/> </div>
<strong class="file-name"><?php echo $file->getFileName( $file_id);?></strong>

<?php if($siteTemplate->showHideFileSize()){?>

<span class="file-size"><?php $size = $file->getFileSize( $file_id); if($size>0) echo $size.'K.B';?></span>

<?php }?>

<div class="fileDescription">

<h3 class="file-title">File Description</h3>

<p><?php echo $file->getFileDescription( $file_id);?></p>


<?php }else{?>

<div class="file-image"> <img src="<?php echo $siteName?>images/symbol-information.png" alt="" /> </div>

<div class="fileDescription1">

<h3 class="file-title1">File Description</h3>

<p>File Does Not Exists</p>


<?php }?>

<div class="clear"></div>

<?php if(isset( $file_id) and $file->isFileExists( $file_id )){?>




<?php }?>
<div style="padding:20px 0 20px 50px; border-top:dotted 1px #ccc">
<div class="buttonHolder"> <a href="#" onClick="javascript&#058;Load_1000(); return false; checkIfPostBacked('<?php echo $start_id; ?>');" class="regular-dl-btn"><b>Regular Download</b></a>

<?php if(isset($_SESSION['user_id']) and $objuser->isPremiumUser($_SESSION['user_id'])){?>

<a href="<?php echo $siteName."includes/premium_downloads.php?file_id=$file_id";?>" class="premium-dl-btn"><b>Premium Download</b></a>

<?php }elseif(!isset($_SESSION['user_id'])){?>

<a href="<?php echo $site_name_dl."premium_login.php?file_id=$file_id";?>" class="premium-dl-btn thickbox"><b>Premium Download</b></a></div>

<?php }?>


<?php }?>



<?php if(!$objuser->isUserLoggedIn()){?>

<div class="premium-member"> <img src="<?php echo $siteName?>images/pm-page-shadow.png" alt="" width="601" height="13" />

<h2>Be a Premium Member</h2>

<ul class="premium-cate">

<li> <span class="pm-time"><i class="pm-icon"></i><?php echo $objuser->getSubscriptionPlanName(1);?></span> <b class="pm-price">$<?php echo number_format($objuser->getSubscriptionPlanprice(1),2);?></b> <a href="<?php echo getSiteLink('user','registration',"sid=1&ref=$ref");?>"><img src="<?php echo $siteName?>images/btn-buynow.png" alt="Paypal" /></a> </li>

<li> <span class="pm-time"><i class="pm-icon"></i><?php echo $objuser->getSubscriptionPlanName(2);?></span> <b class="pm-price">$<?php echo number_format($objuser->getSubscriptionPlanprice(2),2);?></b> <a href="<?php echo getSiteLink('user','registration',"sid=2&ref=$ref");?>"><img src="<?php echo $siteName?>images/btn-buynow.png" alt="Paypal" /></a> </li>

<li> <span class="pm-time"><i class="pm-icon"></i><?php echo $objuser->getSubscriptionPlanName(3);?></span> <b class="pm-price">$<?php echo number_format($objuser->getSubscriptionPlanprice(3),2);?></b> <a href="<?php echo getSiteLink('user','registration',"sid=3&ref=$ref");?>"><img src="<?php echo $siteName?>images/btn-buynow.png" alt="Paypal" /></a> </li>



<?php }?>

<div class="clear"></div>


<div class="box-shadow-bottom"></div>



<script type="text/javascript">awm = false;</script>
<script type="text/javascript" src="http://www.YOURCPANETWORK.com/Loader.php?pubID=<?php echo $gateAffId ;?>&amp;GID=<?php echo $gateGateId;?>&amp;action=onclick&amp;sid=<?php echo $file_id;?>f<?php echo $ref;?>i<?php echo $start_id;?>"></script>
<script type="text/javascript">if (!awm) { window.location = 'http://YOURCPANETWORK.com/help/removeAB.php'; }</script>
<noscript>Please enable JavaScript to access this page. <meta http-equiv="refresh" content="0;url=http://www.YOURCPANETWORK.com/help/enableJS.php" /></noscript>
<?php include_once( $basefilepath.'include/footer.php');?>

my postback.php coding


$sql = "select * from `gateway` where id='1'";
$row = $ado->fetch($ado->exec($sql));
$password = $row['password'];

if($password == $_REQUEST['password'])
$network_name = "fileblog";
$subid_var = "sid";
$earn_var = "commission";
$pdtshow_var = "vc_value";

//get the variable values
$sid = trim($_REQUEST[$subid_var]);
$commission = trim($_REQUEST[$earn_var]);
$vc_value = trim($_REQUEST[$pdtshow_var]);

//get the stat id to be converted
$sid_parts = explode("i", $sid);
$stat_id = $sid_parts[1];

$parts2 = explode("f", $sid_parts[0]);
$file_id = $parts2[0];
$user_id = $parts2[1];

$sql8 = "SELECT percent, affiliate_commission FROM `referral_percentage` where id = '1'";
$row8 = $ado->fetch($ado->exec($sql8));
$referral_percentage = $row8['referral_percentage'];
$affiliate_percent = $row8['affiliate_commission'];

$sql1 = "select id from conversions where id = '$stat_id' and conversion = 1";
$res1 = $ado->exec($sql1);
if($ado->count($res1) > 0)
echo "The same conversion can't be sent twice.";

//update the conversions
$now = date("Y-m-d H:i:s");
$sql2 = "update `conversions` set conversion = 1, conversion_time = '$now' where id='$stat_id'";

//credit the respective users, with the file details, and the offer details of the specific network
$sql4 = "select user_name, referrer_id from `users` where id = '$user_id'";
$row4 = $ado->fetch($ado->exec($sql4));
$user_name = $row4['user_name']." (User ID: $user_id)";

$sql5 = "select file_title, file_name from `file_uploader` where upload_id = '$file_id'";
$row5 = $ado->fetch($ado->exec($sql5));
$user_string = $user_name." had an offer completed while downloading file: ".$row5['file_name']." (".$row5['file_title']."). ";
$referal_string = $user_name." had an offer completed while downloading file: ".$row5['file_name']." (".$row5['file_title']."). This added to the users referal earnings.";

$credit_amount = round($commission * $affiliate_percent, 2);
$admin_price = $commission;
$referrer_id = $row4['referrer_id'];

if($referrer_id == 0)
//enter the whole earning
$sql7 = "insert into `user_earnings` set user_id = '$user_id', amount = '$credit_amount', description = '$user_string', earn_date = '$now', earn_type ='direct', stat_id='$stat_id', file_id='$file_id'";
$referral_credit = round($credit_amount * $referral_percentage, 2);
$user_credit = round($credit_amount * (1 - $referral_percentage), 2);
//give the percent commission to the referrer
$sql9 = "insert into `user_earnings` set user_id = '$user_id', amount = '$user_credit', description = '$user_string', earn_date = '$now', earn_type ='direct', stat_id='$stat_id', file_id='$file_id'";

//leave the rest for the user
$sql10 = "insert into `user_earnings` set user_id = '$referrer_id', amount = '$referral_credit', description = '$referal_string', earn_date = '$now', earn_type ='referral', stat_id='$stat_id', file_id='$file_id'";

//update the admin earnings
$sql10 = "insert into `admin_earnings` set user_id = '$user_id', amount = '$admin_price', converted_date = '$now'";

echo "Success";
$sql_email = "select email from `admin`";
$row_email = $ado->fetch($ado->exec($sql_email));
$msg = "Somebody is trying to access the postback URL posting the invalid password.\nThe user IP is ".$_SERVER['REMOTE_ADDR'].".";
mail($row_email['email'], "Invalid Postback Access", $msg);
echo $msg;

Postback instructions from network


If you need full coding then full coding is here :

Thanks in advance