Automatic Amazonlink Alteration 0.0.1
Verfasst: 27.05.2010 08:37
Seit einigen Wochen hab ich einen MOD gesucht, der mir von Usern gepostete Amazonlinks umwandelt und automatisch mit einer PartnerNet-ID versieht. Inspiriert vom Auto Video Embed MOD hab ich also einen hochbegabten Freund und Programmierer auf die Sache angesetzt. Noch ist das ganz rudimentär und noch nicht in die Form eines richtigen MODs gebracht, dennoch möchte ich den Code hier schonmal posten. Ich hoffe, die Form ist so ok.
MOD-Titel: Automatic Amazonlink Alteration
MOD-Version: 0.0.1
MOD-Autor: thiesm
Credits: 4seven für die Inspiration durch seinen Auto Video Embed MOD
Anfragen:
viewtopic.php?t=205960
MOD-Beschreibung: Der Mod wandelt von Usern gepostete Amazonlinks automatisch in um und integriert eine beliebige Amazon PartnerNet-ID.
phpBB-Version: phpBB 3.0.x
phpBB-Sprachen: multilingual
phpBB-Styles: alle Styles
Demo: http://www.ucount.de/topic66.html
Anleitung
1. Erstelle amazonlinks_view.php und ersetze "myPartnerNetID-21" jeweils durch die eigene PartnerNet-ID:
2. Erstelle amazonlinks_post.php und ersetze "myPartnerNetID-21" jeweils durch die eigene PartnerNet-ID:
3. Öffne
posting.php
Finde
Füge danach ein
4. Öffne
viewtopic.php
Finde
Füge danach ein
5. Kopiere
amazonlinks_view.php
amazonlinks_post.php
in
includes/amazonlinks_view.php
includes/amazonlinks_post.php
So, hoffe das ist verständlich. Anregungen sind herzlich Willkommen!
Viele Grüße
ballong
MOD-Titel: Automatic Amazonlink Alteration
MOD-Version: 0.0.1
MOD-Autor: thiesm
Credits: 4seven für die Inspiration durch seinen Auto Video Embed MOD
Anfragen:
viewtopic.php?t=205960
MOD-Beschreibung: Der Mod wandelt von Usern gepostete Amazonlinks automatisch in um und integriert eine beliebige Amazon PartnerNet-ID.
phpBB-Version: phpBB 3.0.x
phpBB-Sprachen: multilingual
phpBB-Styles: alle Styles
Demo: http://www.ucount.de/topic66.html
Anleitung
1. Erstelle amazonlinks_view.php und ersetze "myPartnerNetID-21" jeweils durch die eigene PartnerNet-ID:
Code: Alles auswählen
<?php
/* if (!defined('IN_PHPBB'))
{
exit;
} */
if ((strpos($message, 'www.amazon.') !== false)){
$pattern = '{href=\"http://(www\.)?amazon\.([a-z]+)/gp/product/(\w+)/(.*?)\"}';
$replace = '<a href="http://www.amazon.$2/gp/product/$3?ie=UTF8&tag=myPartnerNetID-21&linkCode=as2&camp=1638&creative=19454&creativeASIN=$3">Amazonlink</a>';
$message = preg_replace($pattern,$replace,$message);
$pattern = '{(^|\s|\>)http://(www\.)?amazon\.([a-z]+)/gp/product/(\w+)/(.*?)($|\s|\<)}';
$replace = '<a href="http://www.amazon.$3/gp/product/$4?ie=UTF8&tag=myPartnerNetID-21&linkCode=as2&camp=1638&creative=19454&creativeASIN=$4">Amazonlink</a>';
$message = preg_replace($pattern,$replace,$message);
$pattern = '{href=\"http://(www\.)?amazon\.([a-z]+)/(.*?)/dp/(\w+)/(.*?)\"}';
$replace = '<a href="http://www.amazon.$2/$3/dp/$4?ie=UTF8&tag=myPartnerNetID-21&linkCode=as2&camp=1638&creative=19454&creativeASIN=$4">Amazonlink</a>';
$message = preg_replace($pattern,$replace,$message);
$pattern = '{(^|\s|\>)http://(www\.)?amazon\.([a-z]+)/(.*?)/dp/(\w+)/(.*?)($|\s|\<)}';
$replace = '<a href="http://www.amazon.$3/$4/dp/$5?ie=UTF8&tag=myPartnerNetID-21&linkCode=as2&camp=1638&creative=19454&creativeASIN=$5">Amazonlink</a>';
$message = preg_replace($pattern,$replace,$message);
}
?>
Code: Alles auswählen
<?php
if (!defined('IN_PHPBB'))
{
exit;
}
if ((strpos($preview_message, 'www.amazon.') !== false)){
$pattern = '{href=\"http://(www\.)?amazon\.([a-z]+)/gp/product/(\w+)/(.*?)\"}';
$replace = '<a href="http://www.amazon.$2/gp/product/$3?ie=UTF8&tag=myPartnerNetID-21&linkCode=as2&camp=1638&creative=19454&creativeASIN=$3">Amazonlink</a>';
$preview_message = preg_replace($pattern,$replace,$preview_message);
$pattern = '{(^|\s|\>)http://(www\.)?amazon\.([a-z]+)/gp/product/(\w+)/(.*?)($|\s|\<)}';
$replace = '<a href="http://www.amazon.$3/gp/product/$4?ie=UTF8&tag=myPartnerNetID-21&linkCode=as2&camp=1638&creative=19454&creativeASIN=$4">Amazonlink</a>';
$preview_message = preg_replace($pattern,$replace,$preview_message);
$pattern = '{href=\"http://(www\.)?amazon\.([a-z]+)/(.*?)/dp/(\w+)/(.*?)\"}';
$replace = '<a href="http://www.amazon.$2/$3/dp/$4?ie=UTF8&tag=myPartnerNetID-21&linkCode=as2&camp=1638&creative=19454&creativeASIN=$4">Amazonlink</a>';
$preview_message = preg_replace($pattern,$replace,$preview_message);
$pattern = '{(^|\s|\>)http://(www\.)?amazon\.([a-z]+)/(.*?)/dp/(\w+)/(.*?)($|\s|\<)}';
$replace = '<a href="http://www.amazon.$3/$4/dp/$5?ie=UTF8&tag=myPartnerNetID-21&linkCode=as2&camp=1638&creative=19454&creativeASIN=$5">Amazonlink</a>';
$preview_message = preg_replace($pattern,$replace,$preview_message);
}
?>
posting.php
Finde
Code: Alles auswählen
if (!sizeof($error))
{
Code: Alles auswählen
// Amazon-Links umwandeln und mit PartnerID versehen
include($php_root_path . 'includes/amazonlinks_post.' . $phpEx);
// Amazon-Links umwandeln und mit PartnerID versehen
viewtopic.php
Finde
Code: Alles auswählen
// Parse the message and subject
$message = censor_text($row['post_text']);
Code: Alles auswählen
// Amazon-Links umwandeln und mit PartnerID versehen
include($php_root_path . 'includes/amazonlinks_view.' . $phpEx);
// Amazon-Links umwandeln und mit PartnerID versehen
amazonlinks_view.php
amazonlinks_post.php
in
includes/amazonlinks_view.php
includes/amazonlinks_post.php
So, hoffe das ist verständlich. Anregungen sind herzlich Willkommen!
Viele Grüße
ballong