Greenguy's Board


Go Back   Greenguy's Board > Programming & Scripting
Register FAQ Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Rating: Thread Rating: 1 votes, 5.00 average. Display Modes
Old 2004-10-01, 11:30 AM   #1
MadMax
"Without evil there can be no good, so it must be good to be evil sometimes" ~ Satan
 
MadMax's Avatar
 
Join Date: Aug 2004
Location: Motor City, baby, where carjacking was invented! Now GIMME THOSE SHOES!
Posts: 2,385
Looking for a way to insert affiliate codes into links

I need to find a method (as simple as possible) to script a page to add affiliate codes to links on the page by grabbing the affiliate code from the incoming URL. Basically the same thing our friendly sponsors use for FHGs and FH sites.

If I can get some direction I'm willing to do the work to learn what I need to.
MadMax is offline   Reply With Quote
Old 2004-10-01, 11:53 AM   #2
Chop Smith
Eighteen 'til I Die
 
Chop Smith's Avatar
 
Join Date: Apr 2003
Location: Mississippi
Posts: 2,168
Send a message via ICQ to Chop Smith
Check your private messages.
__________________
Chop Smith is offline   Reply With Quote
Old 2004-10-01, 01:00 PM   #3
Chop Smith
Eighteen 'til I Die
 
Chop Smith's Avatar
 
Join Date: Apr 2003
Location: Mississippi
Posts: 2,168
Send a message via ICQ to Chop Smith
MadMax, resend your reply. My private messages box was full.
__________________
Chop Smith is offline   Reply With Quote
Old 2004-10-03, 04:37 AM   #4
Rorschach
Shut up brain, or I'll stab you with a Q-tip!
 
Rorschach's Avatar
 
Join Date: Nov 2003
Posts: 115
Assuming you're changing the links on a dynamically generated free hosted gallery, eg. you're changing the links on:
http://www.fhgdomain.com/fhg.php?id=cocksmoker

On fhg.php:

PHP Code:
<?php

// Extract the affiliate id from the url
$affiliate_id $_GET['id'];

// Insert the affiliate id into the sponsor code
$link_url "http://www.sponsordomain.com/clickthrough.php?id=$id";

// Print the modified url
print "<a href=\"$link_url\">Click here to check out this fucking amazing sponsor</a>";

?>
Rorschach is offline   Reply With Quote
Old 2004-10-03, 01:13 PM   #5
Barron
You tried your best and you failed miserably. The lesson is 'never try'
 
Join Date: Oct 2004
Posts: 166
This is the first script I created. Its since been rewritten several times, but it will get you started with *static* FHG's. There is only basic error checking included. You can do more if you need to.

Put the template tag where your tour links are.
<a href="%%url%%">Click here for great sponsor</a>

Assumes FHG link:
http://www.fghdomain.com/index.php?id=affiliate&tour=membership_tour

Put the code in a file called index.php

Watch for line wrap.

<?php
// Gallery you want to show
$fhg_path='/path/to/fhg.html';
//
// Declare template tag
$tpl_tag="%%url%%";
//
// Default Gallery just in case
$default_gallery_path='/path/to/default/fhg.html';
//
// Starting building your link
$link_url="http://www.sponsordomain.com/clickthrough.php?";
//
// We need dummy value anyway so lets
// track hits to fhg galleries
$link_url .="fhg=1";
//
// Extract affiliate info from URI
// and rebuild for link
foreach ($HTTP_GET_VARS as $key=>$aff_info)
{
if ($aff_info)
{
$aff_info=addslashes($aff_info);
$link_url .="&".$key."=".$aff_info;
}
}
//
// Default tour
//
/**** DANGER WILL ROBINSON! ****/
// Change the tour variable to whatever variable
// clickthrough.php looks for
//
if (!$_GET['tour'])
{
$link_url .="&tour=mytour";
}
//
// Get contents of fhg.html
$fhg_gallery=@file($path);
//
// If fhg.html doesnt exist get default
if (!$fhg_gallery)
{
$fhg_gallery=@file($default_gallery_path);
}
//
// If default doesnt exist
// show the surfer something!
if (!$fhg_gallery)
{
// watch for line wrap
header("Location: $link_url");
header("Expires: Mon, 26 jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); //always modified
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false); // HTTP/1.0
header("P3P: CP=NOI DSP CURa PSAa PSDa OUR STP COM NAV STA");
header("Pragma: no-cache");
die();
}
//
// Do what we came here for.
// Replace the template tag
// and send gallery to browser
//
foreach ($fhg_gallery as $key=>$lines_in_fhg_gallery)
{
$lines_in_fhg_gallery=@str_replace($tpl_tag, $link_url, $lines_in_fhg_gallery);
echo "$lines_in_fhg_gallery";
}
?>
Barron is offline   Reply With Quote
Old 2004-10-15, 06:13 PM   #6
cykoe6
Internet! Is that thing still around?
 
Join Date: Oct 2004
Location: NYC
Posts: 3
Insert affilate codes into links

Quote:
Originally posted by Rorschach
Assuming you're changing the links on a dynamically generated free hosted gallery, eg. you're changing the links on:
http://www.fhgdomain.com/fhg.php?id=cocksmoker

On fhg.php:

PHP Code:
<?php

// Extract the affiliate id from the url
$affiliate_id $_GET['id'];

// Insert the affiliate id into the sponsor code
$link_url "http://www.sponsordomain.com/clickthrough.php?id=$id";

// Print the modified url
print "<a href=\"$link_url\">Click here to check out this fucking amazing sponsor</a>";

?>
This is a very usefull script but I had to make a simple modifaction to get it to work. It should read as follows:

PHP Code:
<?php

// Extract the affiliate id from the url
$affiliate_id $_GET['id'];

// Insert the affiliate id into the sponsor code
$link_url "http://www.sponsordomain.com/clickthrough.php?id=$affiliate_id";

// Print the modified url
print "<a href=\"$link_url\">$link_url</a>";

?>
Note the change on this line:

$link_url = "http://www.sponsordomain.com/clickthrough.php?id=$affiliate_id ";

Also if you want to use this script to insert codes into links from a form (so a reseller can insert his code and then have his ID insterted into all of your links, you can use the following:

PHP Code:
<?php

// Extract the affiliate id from the url
$affiliate_id $_POST['id'];

// Insert the affiliate id into the sponsor code
$link_url "http://www.sponsordomain.com/clickthrough.php?id=$affiliate_id";

// Print the modified url
print "<a href=\"$link_url\">$link_url</a>";

?>
I hope this helps.

This script can also serve as the basis for a POTD script using iframes.
__________________

Partydoll Teens!
cykoe6 is offline   Reply With Quote
Old 2004-10-16, 11:14 PM   #7
Rorschach
Shut up brain, or I'll stab you with a Q-tip!
 
Rorschach's Avatar
 
Join Date: Nov 2003
Posts: 115
Sorry about that, I just whacked it out and didn't test it before I posted.
Rorschach is offline   Reply With Quote
Old 2004-10-18, 09:25 PM   #8
MadMax
"Without evil there can be no good, so it must be good to be evil sometimes" ~ Satan
 
MadMax's Avatar
 
Join Date: Aug 2004
Location: Motor City, baby, where carjacking was invented! Now GIMME THOSE SHOES!
Posts: 2,385
Hey, no problem, and thanks for the help. Seems there are more ways of doing that then I thought |rasta|
MadMax is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:57 PM.


Mark Read
Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
© Greenguy Marketing Inc