Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9215085
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:07:22+00:00 2026-06-18T02:07:22+00:00

I have this function written by another programmer, but he quit long ago. I

  • 0

I have this function written by another programmer, but he quit long ago.

I was trying to understand this function that he wrote, but I don’t fully understand it.

It’s getting a token from the csv file, and the quantity should depend how much I choose. But what the force_plaform variable does?
Also what the $_GET x-parameter and $_COOKIE x-parameter do?

// Get a purchaselink from a given token (if one exists) and a given csv
function getPurchaseLink($token, $csvfile, $force_platform = "", $quantity = 1)
{
$fp = fopen($csvfile, 'r', true);
$columns = fgetcsv($fp, 1024, ',');

while (($row = fgetcsv($fp, 1024, ","))) {
    $row = array_combine($columns, $row);
    if ($row['purchaseToken'] == $token) {
        $purchaseLink = $row;
        break;
    }
}

// Default to pucharse link
$url = http://www.purchase.com//?p1=zzM5X9k4dF%2BDzrTnixoaKw3Fg7wZ8h5pkjp%2BLEidTXBg40xOjcFj5PtPlQniMskLm0W3ti65mE2KafUifZe9dZAcE&ref=purchase.com&style=146&ga=UA-2689090-1&C1=C01507;1;0&C2=C0508;0;0;
if ($url) {     
  // Convert GET x-parameters to cmp, mkey1 and mkey2 if they are present
  $append = "";
  if((isset($_GET["x-source"])) && ($_GET["x-source"] != "")) {
    $append = "&cmp=source_" . $_GET["x-source"];
    $nextParameter = "x-" . $_GET["x-source"];
    $counter = 1;
    $searching = TRUE;
    while(($searching) && ($counter <= 2)) {
      if((!isset($_GET[$nextParameter])) || ($_GET[$nextParameter] == "")) {
        $searching = FALSE;
      }
      else {
        $append .= "&mkey" . $counter . "=" . str_replace("x-", "", $nextParameter) . "_" . $_GET[$nextParameter];
        $nextParameter = "x-" . $_GET[$nextParameter];
    $counter += 1;
      }
    }
  }
  // Convert COOKIE x-parameters to cmp, mkey1 and mkey2 if they are present and there are no GET x-parameters
  if(($append == "") && (isset($_COOKIE["x-source"])) && ($_COOKIE["x-source"] != "")) {
    $append = "&cmp=source_" . $_COOKIE["x-source"];
    $nextParameter = "x-" . $_COOKIE["x-source"];
    $counter = 1;
    $searching = TRUE;
    while(($searching) && ($counter <= 2)) {
      if((!isset($_COOKIE[$nextParameter])) || ($_COOKIE[$nextParameter] == "")) {
        $searching = FALSE;
      }
      else {
        $append .= "&mkey" . $counter . "=" . str_replace("x-", "", $nextParameter) . "_" . $_COOKIE[$nextParameter];
        $nextParameter = "x-" . $_COOKIE[$nextParameter];
    $counter += 1;
      }
    }
  }
  // Return upclick purchase link   
  return $url . $append;
}

if ($quantity != 1) {
    $url .= "&quantity=" . $quantity;
}

// Pass on tracking parameters from URI query and cookies
$append = "";
foreach($_GET as $parameter => $value) {
    if(strpos($parameter, "x-") === 0 || $parameter == "tracking" || $parameter == "serial" || $parameter == "affiliate") {
        $append .= "&" . $parameter . "=" . $value;
    }
}
if (empty($append)) {
    foreach($_COOKIE as $parameter => $value) {
        if(strpos($parameter, "x-") === 0) {
            $append .= "&" . $parameter . "=" . $value;
        }
    }
}

$append = str_replace("x-tracking", "tracking", $append);
$append = str_replace("x-affiliate", "affiliate", $append);
$append = str_replace("&serial=", "&x-serial=", $append);

return $url . $append;
 }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T02:07:23+00:00Added an answer on June 18, 2026 at 2:07 am

    The function is building a query string (URL) and returning it. What the program does once it calls that URL is not up to this code, but the code on the page that gets called. This code just generates a URL. As to force_plaform, it does not appear to be being used in the function at all (just in the function header). It is an unused variable. As to the $_GET and $_COOKIE variables, the code is simply checking if they exist, and appending them to the query string if so.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this function, written from another post, except I am running into an
I need to modify a really long program that was written by another programmer.
I have written this function to auto correct gender to M or F from
I have written a function to print database table to an array like this
I have written a function for deleting object preiodically. function add(variable, expireSecond){ this.list[variable] =
I have a haskell file test.hs. In this file I have written a function
I have written my own function, which in C would be declared like this,
I have this function to create a request to another file to update the
I have written a function that will transform a number in base 10 to
I have written this function in C: void *PWNRetain(void *object) { PWNObject *obj =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.