View difference between Paste ID: TB6ThZKq and ShUWTzbb
SHOW: | | - or go back to the newest paste.
1
<?php
2
3
/*
4
Grab Encrypted ClickBank HopLink v 2.0
5
6
Please Flattr me if you like this:
7
http://flattr.com/thing/81448/Get-ClickBank-Encrypted-URL-PHP-Script
8
9
To use, simply call the function with the vendor and affiliate IDs, see the end.
10
Original post: http://www.clickbanksuccessforum.com/forum/viewtopic.php?p=52719#52719
11
*/
12
13
function getCBEncryptedURL($vendor, $affiliate, $debug = 0) {
14
15
$url = "https://accounts.clickbank.com/info/jmap.htm?affiliate=".trim(urlencode($affiliate))."&promocode=&submit=Create&vendor=".trim(urlencode($vendor))."&results=";
16
$ch = curl_init();
17
$timeout = 60; // set to zero for no timeout
18
curl_setopt($ch, CURLOPT_URL, $url);
19
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
20
curl_setopt($ch, CURLOPT_HEADER, false);
21
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
22
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);  // RETURN THE CONTENTS OF THE CALL
23
$result = trim(curl_exec($ch));
24
curl_close($ch);
25
if (!$result) die ("Error fetching CB page.");
26
if ($debug == 1) print $result;
27
28
$s_str = $result;
29
$i_indicatorL = 0;
30
$i_indicatorR = 0;
31
$s_tagOption = "";
32
$i_arrayCounter = 0;
33
$a_html = array();
34
// Search for a tag in string
35
while( is_int(($i_indicatorL=strpos($s_str,"<",$i_indicatorR))) ) {
36
// Get everything into tag...
37
$i_indicatorL++;
38
$i_indicatorR = strpos($s_str,">", $i_indicatorL);
39
$s_temp = substr($s_str, $i_indicatorL, ($i_indicatorR-$i_indicatorL) );
40
$a_tag = explode( ' ', $s_temp );
41
// Here we get the tag's name
42
list( ,$s_tagName,, ) = each($a_tag);
43
$s_tagName = strtolower($s_tagName);
44
// Well, I am not interesting in <br>, </font> or anything else like that...
45
// So, this is false for tags without options.
46
$b_boolOptions = is_array(($s_tagOption=each($a_tag))) && $s_tagOption[1];
47
if( $b_boolOptions ) {
48
// Without this, we will mess up the array
49
if (isset($a_html[$s_tagName]))
50
$i_arrayCounter = intval(count($a_html[$s_tagName]));
51
else $i_arrayCounter=0;
52
// get the tag options, like src="htt://". Here, s_tagTokOption is 'src'
53
//and s_tagTokValue is '"http://"'
54
55
do {
56
$s_tagTokOption = strtolower(strtok($s_tagOption[1], "="));
57
$s_tagTokValue = trim(strtok("="));
58
59
if (substr($s_tagTokValue,0,1)=='"' || substr($s_tagTokValue,0,1)=="'")
60
$s_tagTokValue=substr($s_tagTokValue,1);
61
62
if (substr($s_tagTokValue,-1)=='"' || substr($s_tagTokValue,-1)=="'")
63
$s_tagTokValue=substr($s_tagTokValue,0,-1);
64
65
$a_html[$s_tagName][$i_arrayCounter][$s_tagTokOption] =
66
$s_tagTokValue;
67
$b_boolOptions = is_array(($s_tagOption=each($a_tag))) &&
68
$s_tagOption[1];
69
} while( $b_boolOptions );
70
}
71
}
72
73
if ($debug == 1) print_r($a_html);
74
$parsedHTML = $a_html;
75
$encryptedURL = $parsedHTML[input][0][value];
76-
if (!$encryptedURL) die("Error parsing HTML.");
76+
if (!$encryptedURL) die("Error, please make sure you entered your affiliate ID correctly.");
77
return strtolower(trim($encryptedURL));
78
79
}
80
81
print getCBEncryptedURL("VENDOR", "AFFILIATE");
82
83
?>