FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » FUDforum Development » Plugins and Code Hacks » Paypal Donate Plugin
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
Paypal Donate Plugin [message #186541] Thu, 25 September 2014 21:50 Go to next message
Kermit is currently offline  Kermit   United Kingdom
Messages: 35
Registered: November 2004
Karma: 0
Member
Hi, I wanted a Paypal donate button on my forum and discovered the Adsense plugin worked with the paypal generated code but I wanted both Very Happy

With this in mind, I've hacked (I'm not programmer) the google_adsense.plugin plugin to paypal_donate.plugin and changed the code were applicable to make it its own plugin which lives in /plugins/donate

I'd post the code as it works nicely but don't know given I hacked someone elses code (even though its a GNU license) if its ok to post the code here for someone to possibly properly publish or use on future releases.

If you want to have a look at it, its http://honda-forums.com/forum/index.php and the only thing I did after generating the code on paypal's donate wizard (I opted for a small logo and no pics of credit cards etc underneath) and pasting into the plugin was to add <div align="right"> and </div> to the end of paypals code to make it sit to the right.

So is it ok to post the code here for anyone to use as I know I could probably google if someone elses GNU code can be hacked and reposted as another plugin but its eaier to post a question as afterall thats what forums are for Cool

[Updated on: Thu, 25 September 2014 21:53]

Report message to a moderator

Re: Paypal Donate Plugin [message #186546 is a reply to message #186541] Sat, 27 September 2014 16:00 Go to previous messageGo to next message
naudefj is currently offline  naudefj   
Messages: 3772
Registered: December 2004
Karma: 28
Senior Member
Administrator
Core Developer
FUDforum is distributed under version 2 of the GNU General Public License, making it perfectly OK to publish the code:

"the GNU General Public License is intended to guarantee your freedom to share and change free software"

See: http://opensource.org/licenses/gpl-2.0.php
Re: Paypal Donate Plugin [message #186554 is a reply to message #186546] Sat, 27 September 2014 22:26 Go to previous messageGo to next message
Kermit is currently offline  Kermit   United Kingdom
Messages: 35
Registered: November 2004
Karma: 0
Member
Ok, thanks, here's the code then

Paypal_donate.plugin and locate in \plugins\donate\

<?php
/**
* copyright            : (C) 2001-2013 Advanced Internet Designs Inc.
* email                : forum(at)prohost(dot)org
* $Id: paypal_donate.plugin 25-09-2014 KermitX Honda-forums.com $
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; version 2 of the License.
**/

// Initialize plugin.
plugin_add_hook('COMPILER_EXPAND_TEMPLATE', 'plugin_paypal_donate');

function plugin_paypal_donate($array) {
	list($tmpl, $tag, $sec, $name, $file) = $array;

	if ((@include $GLOBALS['PLUGIN_PATH'] .'donate/paypal_donate.ini') === false) {
		die('ERROR: Please configure the paypal_donate plugin from the Plugin Manager Control panel.');
	}

	if ($name == 'usercp' && $ini['PAYPAL_DONATE_POS'] == 0) {
		$tmpl = $tmpl . $ini['PAYPAL_DONATE_CODE'];
	} else if ($name == 'header' && $ini['PAYPAL_DONATE_POS'] == 1) {
		$tmpl = $ini['PAYPAL_DONATE_CODE'] . $tmpl;
	} else if ($name == 'header' && $ini['PAYPAL_DONATE_POS'] == 2) {
		$tmpl = $tmpl . $ini['PAYPAL_DONATE_CODE'];
	} else if ($name == 'curtime' && $ini['PAYPAL_DONATE_POS'] == 3) {
		$tmpl = $ini['PAYPAL_DONATE_CODE'] . $tmpl;
	} else if ($name == 'curtime' && $ini['PAYPAL_DONATE_POS'] == 4) {
		$tmpl = $tmpl . $ini['PAYPAL_DONATE_CODE'];
	} else if ($name == 'footer' && $ini['PAYPAL_DONATE_POS'] == 5) {
		$tmpl = $ini['PAYPAL_DONATE_CODE'] . $tmpl;
	} else if ($name == 'footer' && $ini['PAYPAL_DONATE_POS'] == 6) {
		$tmpl = $tmpl . $ini['PAYPAL_DONATE_CODE'];
	}

	return array($tmpl, $tag, $sec, $name, $file);
}

function paypal_donate_info() {
	return array('name' => 'Paypal Donate',
				'desc' => 'Display Donate button on your forum\'s web pages.',
				'cat'  => 'Third-party Integration',
				'version' => '1.0');
}

function paypal_donate_enable() {
	if ((@include_once $GLOBALS['PLUGIN_PATH'] .'donate/paypal_donate.ini') === false) {
		return array(null, 'Please configure the paypal_donate plugin before enabling it.');	// OK, Err.
	}
	@define('REBUILD_THEMES', 1);
}

function paypal_donate_disable() {
	@define('REBUILD_THEMES', 1);
}

function paypal_donate_config() {
	if ((@include $GLOBALS['PLUGIN_PATH'] .'donate/paypal_donate.ini') === false) {
		$ini = NULL;
	}

	if (isset($_POST['Set'])) {
		foreach (array_keys($_POST) as $key) {
			if (substr($key,0,14) == 'PAYPAL_DONATE_') {
				$ini[$key] = trim($_POST[$key]);
			}
		}
		$fp = fopen($GLOBALS['PLUGIN_PATH'] .'donate/paypal_donate.ini', 'w');
		fwrite($fp, '<?php $ini = '. var_export($ini, 1) .'; ?>');
		fclose($fp);
		pf(successify('Settings successfully saved.'));
		compile_themes();
	}
	?>
<p>Where should it be displayed:<br />
<select name="PAYPAL_DONATE_POS">
<option value="0" <?php if($ini['PAYPAL_DONATE_POS']==0) echo 'selected="selected"'; ?>>After top level menu.</option>
<option value="1" <?php if($ini['PAYPAL_DONATE_POS']==1) echo 'selected="selected"'; ?>>Before page header.</option>
<option value="2" <?php if($ini['PAYPAL_DONATE_POS']==2) echo 'selected="selected"'; ?>>After page header.</option>
<option value="3" <?php if($ini['PAYPAL_DONATE_POS']==3) echo 'selected="selected"'; ?>>Before current time.</option>
<option value="4" <?php if($ini['PAYPAL_DONATE_POS']==4) echo 'selected="selected"'; ?>>After current time.</option>
<option value="5" <?php if($ini['PAYPAL_DONATE_POS']==5) echo 'selected="selected"'; ?>>Before page footer.</option>
<option value="6" <?php if($ini['PAYPAL_DONATE_POS']==6) echo 'selected="selected"'; ?>>After page footer.</option>
</select>
</p>

<p>Your Paypal Donate code (get it from <a href="https://www.paypal.com/">paypal.com</a>):<br />
<textarea name="PAYPAL_DONATE_CODE" cols="72" rows="10"><?php echo $ini['PAYPAL_DONATE_CODE'] ?></textarea>
<font size="-1">Tip: you can add additional HTML as well. For example, use the CENTRE tag to center your donate button.</font>
</p>
	<?php
}

?>
Re : Re: Paypal Donate Plugin [message #186555 is a reply to message #186554] Mon, 29 September 2014 05:57 Go to previous message
TheDude is currently offline  TheDude   France
Messages: 120
Registered: November 2012
Location: France
Karma: 2
Senior Member
Thanks for your plugin ! I may use it, even though people seem not so inclined to donate nowadays

  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Simplesamlphp plugin for fudforum
Next Topic: Trying to make SEO mods
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Thu Dec 26 14:48:55 GMT 2024

Total time taken to generate the page: 0.04962 seconds