LFAwikiMain Page | About | Help | FAQ | Special pages | Log in

Printable version | Disclaimers | Privacy policy

Paypal.php

From LFAwiki

<?php /* IpbWiki Paypal MediaWiki 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="btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"> <img alt="" border="0" src="pixel.gif" width="1" height="1"> </form>';

  $ipbwiki_paypal[2] = '<form action="https://... - it\'s fast, free and secure!"></form>';

}

  1. 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'

);

Retrieved from "http://livingstonfamily.org/wiki/Paypal.php"

This page has been accessed 1,177 times. This page was last modified on 9 February 2013, at 12:00.


Find

Browse
Wiki Home
Articles about People
Articles about Places
LFA Newsletters
LFA Reunions
References
Recent changes
Random page
Help
Edit
View source
Editing help
This page
Discuss this page
New section
Printable version
Context
Page history
What links here
Related changes
My pages
Log in / create account
Special pages
New pages
File list
Statistics
More...