vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.6 Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=194)
-   -   Miscellaneous Hacks - Dynamic Amazon Links (https://vborg.vbsupport.ru/showthread.php?t=163393)

buro9 03-19-2009 06:13 PM

BTW. If anyone is using AME and has the definition file... whoever submitted the Amazon re-write for that is hijacking your affiliate earnings.

Hidden_Gamma 03-20-2009 03:43 AM

Quote:

Originally Posted by buro9 (Post 1771994)
BTW. If anyone is using AME and has the definition file... whoever submitted the Amazon re-write for that is hijacking your affiliate earnings.


What's AME?

buro9 03-20-2009 05:17 AM

Quote:

Originally Posted by Hidden_Gamma (Post 1772339)
What's AME?

https://vborg.vbsupport.ru/showthread.php?t=202476

And these are the definitions:
https://vborg.vbsupport.ru/showthread.php?t=195884

And someone with an Amazon affiliate of "citofgamonlco-20" is hijacking the earnings.

And you can see that here from the number of vBulletins he is earning from:
http://www.google.co.uk/search?q=citofgamonlco-20

Hidden_Gamma 03-20-2009 02:35 PM

Quote:

Originally Posted by buro9 (Post 1772357)
https://vborg.vbsupport.ru/showthread.php?t=202476

And these are the definitions:
https://vborg.vbsupport.ru/showthread.php?t=195884

And someone with an Amazon affiliate of "citofgamonlco-20" is hijacking the earnings.

And you can see that here from the number of vBulletins he is earning from:
http://www.google.co.uk/search?q=citofgamonlco-20

Oh, what a jackass. I hope he has been reported to Amazon and whatever other authorities handle that sort of thing. :mad: :erm:

Hidden_Gamma 03-20-2009 09:30 PM

Okay, I have this working, somewhat, under 3.8.1 PL1 using the hack to get multi-level domains, but the problem is, it is adding my affiliate IDs to all the URLs other than my my two multilevel domain affiliate IDs for Amazon UK and Amazon Japan.

I think it may have something to do with the preg_match section, which I keep trying to tweak to get working, but to no avail. Maybe someone here can help me out? Here's the code as I am using, with my affiliate IDs redacted:

PHP Code:

<?php
function amazon_links($text) {

    
/*
     * your partnernet ids
     */
    
$associate_id_co_uk 'azn-id'// or leave empty
    
$associate_id_co_jp 'azn-id'// or leave empty
    
$associate_id_de 'azn-id'// or leave empty    
    
$associate_id_com 'azn-id'// or leave empty
    
$associate_id_ca 'azn-id'// or leave empty

    /*
     * tag=xxx and ref=xxx will be replaced with your associate id in non asin links
     */
    
$replace_targt_urls true// true or false
          // reeplace arrays
    
$replace_src = array();
    
$replace_str = array();

    
// check for [url="amazon-link"]some text[/url]
    
if(preg_match_all("/\[url\=(?:\")?(http:\/\/(?:[A-z0-9\.]+)?amazon\.(co\.uk|co\.jp|de|com|ca)\/(?:.+))(?:\")?](.+)\[\/url\]/iU"$text$out)) {
        for(
$i=0;$i<count($out[1]);$i++) {
            
$associate_id = ${'associate_id_'.str_replace('.','_',$out[2][$i])};
            
$out[4][$i] = $out[1][$i];

            if(
$associate_id && !empty($associate_id)) {
                
// Look for an asin number
                
if(preg_match("/\/[A-Z0-9]{10}(\/)?/"$out[1][$i], $asin) && strpos($out[1][$i], '/review') === false) {
                    if(
substr($asin[0], -1) != '/') { $asin[0] .= '/'; }
                    
$out[1][$i] = 'http://www.amazon.'.$out[2][$i].'/exec/obidos/ASIN'.$asin[0].'ref=nosim/'.$associate_id;
                } else {
                    
$target_url $out[1][$i];
                    if(
$replace_targt_urls) {
                        
$target_url preg_replace('/ref\=([a-z0-9\-]{3,})\-([0-9]{2})/iU''ref='.$associate_id$target_url);
                        
$target_url preg_replace('/tag\=([a-z0-9\-]{3,})\-([0-9]{2})/iU''tag='.$associate_id$target_url);
                    }

                    
$out[1][$i] = 'http://www.amazon.'.$out[2][$i].'/exec/obidos/redirect?link_code=ur2&camp=1789&tag='.$associate_id.'&creative=9325&path='.urlencode($target_url);
                }

                
$replace_src[] = '[url="'.$out[4][$i].'"]';
                
$replace_str[] = '[url="'.$out[1][$i].'"]';

                
$replace_src[] = '[url='.$out[4][$i].']';
                
$replace_str[] = '[url='.$out[1][$i].']';

                
$replace_src[] = '[url="'.$out[4][$i].'"]';
                
$replace_str[] = '[url="'.$out[1][$i].'"]';

                
$replace_src[] = '[url='.$out[4][$i].']';
                
$replace_str[] = '[url='.$out[1][$i].']';
            }
        }
    } unset(
$out);
    
    
// check for [url]amazon-link[/url]
    
if(preg_match_all("/\[url\](http:\/\/(?:[A-z0-9\.]+)?amazon\.(co\.uk|co\.jp|de|com|ca)\/(?:.+))\[\/url\]/iU"$text$out)) {
        for(
$i=0;$i<count($out[1]);$i++) {
            
$associate_id = ${'associate_id_'.str_replace('.','_',$out[2][$i])};
            
$out[4][$i] = $out[1][$i];

            if(
$associate_id && !empty($associate_id)) {
                
// Look for an asin number
                
if(preg_match("/\/[A-Z0-9]{10}(\/)?/"$out[1][$i], $asin) && strpos($out[1][$i], '/review') === false) {
                    if(
substr($asin[0], -1) != '/') { $asin[0] .= '/'; }
                    
$out[1][$i] = 'http://www.amazon.'.$out[2][$i].'/exec/obidos/ASIN'.$asin[0].'ref=nosim/'.$associate_id;
                } else {
                    
$target_url $out[1][$i];
                    if(
$replace_targt_urls) {
                        
$target_url preg_replace('/ref\=([a-z0-9\-]{3,})\-([0-9]{2})/iU''ref='.$associate_id$target_url);
                        
$target_url preg_replace('/tag\=([a-z0-9\-]{3,})\-([0-9]{2})/iU''tag='.$associate_id$target_url);
                    }

                    
$out[1][$i] = 'http://www.amazon.'.$out[2][$i].'/exec/obidos/redirect?link_code=ur2&camp=1789&tag='.$associate_id.'&creative=9325&path='.urlencode($target_url);
                }

                
$displayed_link $out[4][$i];
                if(
strlen($displayed_link) > 55) {
                    
$displayed_link substr($displayed_link036).'...'.substr($displayed_link, -14);
                }


                
$replace_src[] = '[url]'.$out[4][$i].'[/url]';
                
$replace_str[] = '[url="'.$out[1][$i].'"]'.$displayed_link."[/url]";

                
$replace_src[] = '[url]'.$out[4][$i].'[/url]';
                
$replace_str[] = '[url="'.$out[1][$i].'"]'.$displayed_link."[/url]";
            }
        }
    } unset(
$out);


    
// replace the message
    
if(isset($replace_src[0])) {
        
$text str_replace($replace_src$replace_str$text);
    } unset(
$replace_src$replace_str);

    return 
$text;
}
?>


Hidden_Gamma 03-20-2009 10:04 PM

And now I'm getting this error message:

Quote:

Unable to add cookies, header already sent.
File: /home/bluray/public_html/forum/includes/functions_amazon_links.php
Line: 101
Okay, never mind, this error is fixed, but the piece of code above is working for everything, including embedded links, except for the multi-level .co.uk and .co.jp domains, which I can't seem to get to work no matter what I do.

Hidden_Gamma 03-23-2009 11:04 PM

One more update, this plugin also won't work on URLs in the Calendar. So, to sum up, it won't work for the multi-level .uk and .jp domains, and it won't add the affiliate ID's to URLs posted in the Calendar -- that's where I'm at with this on a 3.8.1 PL1 board using the hack for mutli-level domains.

RedWingFan 06-02-2009 05:11 AM

Can't get it to work on 3.7.2. The preg_match looks for the ASIN number, correct? If so, then the format of Amazon's link shouldn't matter, if the ASIN appears as below:

http://www.amazon.com/No-Line-Horizo...3921433&sr=1-1

Hidden_Gamma 06-02-2009 01:46 PM

I now have 3.8.2 installed and the status is still the same for me with this plugin -- it won't work for .uk and .jp multilevel domains or in te VB calendar.

RedWingFan 06-02-2009 08:46 PM

For now, I've disabled the plugin. When I get time, I may dissect the function and toss out some variables to see how it is working.

(EDIT: Disregard the following...my error...) For the .co.uk and .co.jp domains, I need those as well. I know that the regex for (co\.uk|co\.jp|de|com|ca) should work (syntax looks correct, and the dots are escaped properly), but I wonder how the script is parsing the $associate_id_co_uk and $associate_id_co_jp variable names, as they have one extra set of underscore and characters than the others. I wonder if that's where the problem lies...? That's why I want to look into the function more to see how it is setting the variables, if only for me to understand how it works overall. It's the regular expressions I sometimes get hung up on.


All times are GMT. The time now is 03:28 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01331 seconds
  • Memory Usage 1,817KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php_printable
  • (4)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete