Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<plugins>
<plugin active="1" product="vbulletin">
<title>Amazon Affiliate URL</title>
<hookname>bbcode_create</hookname>
<phpcode><![CDATA[$this->tag_list['no_option']['url']['callback'] = 'handle_external';
$this->tag_list['no_option']['url']['external_callback'] = 'handle_bbcode_url_amazon';
$this->tag_list['option']['url']['callback'] = 'handle_external';
$this->tag_list['option']['url']['external_callback'] = 'handle_bbcode_url_amazon';
if (!function_exists('handle_bbcode_url_amazon'))
{
function handle_bbcode_url_amazon(&$parser, $text, $link)
{
global $post;
$parsedurl = $parser->handle_bbcode_url($text, $link);
if (stristr($parsedurl, 'http://www.amazon.com')) {
$geturl = explode('"', $parsedurl);
$amazon_url = explode('/', $geturl[1]);
$size_url = count($amazon_url);
$i = 0;
while ($i <= $size_url) {
if ($amazon_url["$i"] == 'ASIN') {
$i++;
$parsedurl = preg_replace('/href="(.*)"/U', 'href="http://www.amazon.com'. $amazon_url["$i"] .'/myID"', $parsedurl);
break;
}
$i++;
}
}
return $parsedurl;
}
}]]></phpcode>
</plugin>
</plugins>
Here is my code. I cant seem to get it to work.
http://www.traderslaboratory.com/for...?p=117#post117
Can anyone help me figure this out? Thank you in advance.