Paypal.php
From LFAwiki
<?php /* IpbWiki Paypal MediaWiki extension
- IpbWiki (c) 2006
- Installation Instructions: http://www.ipbwiki.com/IpbWiki_Paypal_Extension
- /
$wgExtensionFunctions[] = "wfPayPalExtension";
function wfPayPalExtension() {
global $wgParser; global $ipbwiki_paypal; # register the extension with the WikiText parser $wgParser->setHook( "paypal", "renderPayPal" ); $ipbwiki_paypal = array(); # CHANGE THE LINES BELOW TO REFLECT TO YOUR PAYPAL BUTTONS!!! (there's no limit on the number of buttons you define) $ipbwiki_paypal[1] = '<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick"> <input type="hidden" name="hosted_button_id" value="76SCAUEPM9J76"> <input type="image" src="" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"> <img alt="" border="0" src="" width="1" height="1"> </form>';
$ipbwiki_paypal[2] = '<form action="https://... - it\'s fast, free and secure!"></form>';
}
- The callback function for converting the input text to HTML output
function renderPayPal( $input, $argv ) {
global $ipbwiki_paypal; global $wgAuth; $pos_space=strpos($input,' '); if (!$pos_space) { if (is_numeric($input)) { // format <paypal>number</paypal> $part1 = $input; $part2 = ; if (!$ipbwiki_paypal[$part1]) { print_r ('warning, specified paypal button not found, defaulting to button 1'); $part1 = 1; $part2 = $input; } } else { // format <paypal>text</paypal> & format <paypal></paypal> $part1 = 1; $part2 = $input; } } else { // format <paypal>number text</paypal> $part1=substr($input,0,$pos_space); $part2=substr($input,$pos_space+1); if (is_numeric($part1)) { if (!$ipbwiki_paypal[$part1]) { print_r ('warning, specified paypal button not found, defaulting to button 1'); $part1 = 1; } } else { // format <paypal>text</paypal> $part1 = 1; $part2 = $input; } } $form=$ipbwiki_paypal[$part1]; // if the ipbwiki interface is available, then use the clean function which is defined there, otherwise just clean the necessities... if (class_exists ('ipbwiki')) { $input = $wgAuth->ipbwiki->ipbwiki->clean_value ($part2); } else { $part2 = str_replace( ">" , ">" , $part2 ); $part2 = str_replace( "<" , "<" , $part2 ); $part2 = str_replace( "\"" , """ , $part2 ); $part2 = str_replace( "!" , "!" , $part2 ); $part2 = str_replace( "'" , "'" , $part2 ); $input = $part2; }$output = '
'.$form.' | '.$input.' |
return $output;
}
$wgExtensionCredits['parserhook'][] = array(
'name' => 'IpbWiki PayPal', 'version' => '1.0.2', 'author' => 'Peter De Decker', 'url' => 'http://www.ipbwiki.com/IpbWiki_Paypal_Extension', 'description' => 'Mediawiki PayPal Extension'
);