Extension:Amazon
| This extension stores its source code on a wiki page. Please be aware that this code may be unreviewed or maliciously altered. They may contain security holes, outdated interfaces that are no longer compatible etc. Note: No localisation updates are provided for this extension by translatewiki.net. |
| WARNING: The code or configuration described here poses a major security risk.
Site administrators: You are advised against using it until this security issue is resolved. Problem: Vulnerable to Cross-site scripting attacks, because it passes user input directly to the browser. This may lead to user accounts being hijacked, among other things. Solution: strictly validate user input and/or apply escaping to all characters that have a special meaning in HTML |
|
Amazon Release status: experimental |
|
|---|---|
| Implementation | Tag |
| Description | This (simple) extension could be used for your booksources response page to offer the requested books via Amazon. The extension will output the given Amazon Affiliate Code. |
| Author(s) | Anonymous |
| License | No license specified |
| Download | see below |
| Check usage and version matrix; stats | |
This (simple) extension could be used for your booksources response page to offer the requested books via amazon.
The extension will output the given Amazon Affiliate Code.
Contents |
Installation[edit]
Create a new file in your extensions folder, named Amazon.php with the following content:
<?php # To activate the extension, include it from your LocalSettings.php # with: include("extensions/Amazon.php"); $wgExtensionFunctions[] = "wfAmazon"; function wfAmazon() { global $wgParser; $wgParser->setHook( "amazon", "renderAmazon" ); } # The callback function for converting the input text to HTML output function renderAmazon( $input ) { # Your Amazon Partner ID # <<<<< EDIT HERE <<<<< $partner = "EDIT HERE"; # Building the code $output = '<iframe src="http://rcm-de.amazon.de/e/cm?t=' . $partner. '&o=3&p=8&l=as1&asins=' . htmlspecialchars( $input ) . '&fc1=000000&IS2=1<1=_blank&lc1=0000ff&bc1=000000&bg1=ffffff&f=ifr" style="width:120px;height:240px;"></iframe>'; return $output; }
Give your Amazon Affiliate Partner ID to the variable $partner ("EDIT HERE").
If you want to use other code than this, replace it, but remember to replace your partner id in the amazon code with the variable $partner and most important replace the ISBN (ASIN) with the variable $input.
Open your LocalSettings.php, and insert at the end of file:
require_once ("extensions/Amazon.php");
You can then create a page Project:Booksources (The Booksources must be replaces with the translated word of your site language; "Buchhandlungen" for example in German MediaWikis) with the following content:
{{MediaWiki:Booksourcetext}}
<amazon>MAGICNUMBER</amazon>
Usage[edit]
Afterwards the call to Special:Booksources/ISBNNUMBER will end up to the above mentioned page with same layout as the original but displaying your Amazon affiliate code.
