View Full Version : Can anyone see anything wrong with this page

01-04-2008, 11:32 PM
It's a free affilliate script very simple easy admin, i can get it to register referrals site visits by adding the required code to the home page, but won't register sales to affiliates account or admin area when i put sale code on thankyou page.

here are the instructions

5. Open your landing page where you want affiliates to send the customers to, maybe
your home page or an order form page.
a. Enter the following code above the <html> tag and any other code:
include_once "your_folder/affiliate.php"; (where your_folder is the folder
you installed sonic_affiliate
b. Save the changes and exit the file

6. Open your sale confirmation page and add the following line of code. This code should be
placed in a portion of the page that is only executed when a sale is completed.
include_once "your_folder/sale.php";
b. Save the changes and exit the file.

sale.php code

//get the offer info based on the offerid and the
//break up the rid into the affiliate id and the offerid
//write code here to do the above
include "home/profitsh/public_html/affiliate/sa_config.php";
list($offerID, $affiliateID) = explode("sa", $HTTP_COOKIE_VARS['saref']);
$con = sa_db_connect();
echo "Database error on sale.php";
//security: make sure affiliate isn't selling the wrong offer
$q1 = "SELECT SalePHPSelf FROM Offers WHERE OfferID = '$offerID' ";
$result1 = mysql_query($q1);
$row1 = mysql_fetch_array($result1);
if($row1[SalePHPSelf] != $PHP_SELF){
//we have an affiliate sending sales from the wrong offer
//generate a message to us
echo "sale tracking error";
//we can continue the script
// Do not edit anything below this line

$ref = $HTTP_COOKIE_VARS["saref"];
if ($ref == ''){
echo "<br><font color=#ff0000>SonicAffiliate Debug Msg: No referrer found in cookie,
trying to use sessions.</font><br>";
$ref = $_SESSION["ref"];
if($ref == '' && $debugMessage)
echo "<br><font color=#ff0000>SonicAffiliate Debug Msg: No referrer found in session.</font><br>";
if ($ref != ''){
echo "<br><font color=#ff0000>SonicAffiliate Debug Msg: Referrer '$ref' found, registering sale.</font><br>";
//break the $ref into the AffiliateUsername and the OfferID
//get the amount of the payout
$timeNow = date("U");
$q1 = "SELECT PayOut, RefundDelay FROM Offers WHERE OfferID = '$offerID' ";
$result1 = mysql_query($q1);
$row1 = mysql_fetch_array($result1);
$qualDate = $timeNow + $row1[RefundDelay];
$q3 = mysql_query("SELECT UnixTime FROM Sales WHERE RemoteAddress = '$REMOTE_ADDR' AND OfferID = $offerID
ORDER BY UnixTime desc LIMIT 1 ");
$row3 = mysql_fetch_array($q3);
if(mysql_num_rows($q3) > 0 && $timeNow < $row3[UnixTime] + 600){
//do not record the sale, we should notify the admin of the attempted fraud
//less than 10 minutes between the last sale from this IP address on this offer
//record the sale
$q2 = "INSERT INTO Sales (AffiliateID, OfferID, UnixTime, QualTime, RemoteAddress)
VALUES ('$affiliateID', '$offerID', '$timeNow', '$qualDate', '$clickIP')";
$result2 = mysql_query($q2);
//echo $q2;

01-05-2008, 12:16 PM
The thing that jumps out at me is the mix of deprecated and no deprecated variables. For example you have $HTTP_COOKIE_VARS which is deprecated. You should use $_COOKIE. Try changing the variables to updated versions.

here is the manual that talks about variables.

01-05-2008, 07:33 PM
And put your code between [ PHP ] and [ / PHP ] tags!