Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Grab Encrypted ClickBank HopLink v 2.0
- Please Flattr me if you like this:
- http://flattr.com/thing/81448/Get-ClickBank-Encrypted-URL-PHP-Script
- To use, simply call the function with the vendor and affiliate IDs, see the end.
- Original post: http://www.clickbanksuccessforum.com/forum/viewtopic.php?p=52719#52719
- */
- function getCBEncryptedURL($vendor, $affiliate, $debug = 0) {
- $url = "https://accounts.clickbank.com/info/jmap.htm?affiliate=".trim(urlencode($affiliate))."&promocode=&submit=Create&vendor=".trim(urlencode($vendor))."&results=";
- $ch = curl_init();
- $timeout = 60; // set to zero for no timeout
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
- curl_setopt($ch, CURLOPT_HEADER, false);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); // RETURN THE CONTENTS OF THE CALL
- $result = trim(curl_exec($ch));
- curl_close($ch);
- if (!$result) die ("Error fetching CB page.");
- if ($debug == 1) print $result;
- $s_str = $result;
- $i_indicatorL = 0;
- $i_indicatorR = 0;
- $s_tagOption = "";
- $i_arrayCounter = 0;
- $a_html = array();
- // Search for a tag in string
- while( is_int(($i_indicatorL=strpos($s_str,"<",$i_indicatorR))) ) {
- // Get everything into tag...
- $i_indicatorL++;
- $i_indicatorR = strpos($s_str,">", $i_indicatorL);
- $s_temp = substr($s_str, $i_indicatorL, ($i_indicatorR-$i_indicatorL) );
- $a_tag = explode( ' ', $s_temp );
- // Here we get the tag's name
- list( ,$s_tagName,, ) = each($a_tag);
- $s_tagName = strtolower($s_tagName);
- // Well, I am not interesting in <br>, </font> or anything else like that...
- // So, this is false for tags without options.
- $b_boolOptions = is_array(($s_tagOption=each($a_tag))) && $s_tagOption[1];
- if( $b_boolOptions ) {
- // Without this, we will mess up the array
- if (isset($a_html[$s_tagName]))
- $i_arrayCounter = intval(count($a_html[$s_tagName]));
- else $i_arrayCounter=0;
- // get the tag options, like src="htt://". Here, s_tagTokOption is 'src'
- //and s_tagTokValue is '"http://"'
- do {
- $s_tagTokOption = strtolower(strtok($s_tagOption[1], "="));
- $s_tagTokValue = trim(strtok("="));
- if (substr($s_tagTokValue,0,1)=='"' || substr($s_tagTokValue,0,1)=="'")
- $s_tagTokValue=substr($s_tagTokValue,1);
- if (substr($s_tagTokValue,-1)=='"' || substr($s_tagTokValue,-1)=="'")
- $s_tagTokValue=substr($s_tagTokValue,0,-1);
- $a_html[$s_tagName][$i_arrayCounter][$s_tagTokOption] =
- $s_tagTokValue;
- $b_boolOptions = is_array(($s_tagOption=each($a_tag))) &&
- $s_tagOption[1];
- } while( $b_boolOptions );
- }
- }
- if ($debug == 1) print_r($a_html);
- $parsedHTML = $a_html;
- $encryptedURL = $parsedHTML[input][0][value];
- if (!$encryptedURL) die("Error, please make sure you entered your affiliate ID correctly.");
- return strtolower(trim($encryptedURL));
- }
- print getCBEncryptedURL("VENDOR", "AFFILIATE");
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement