diff options
Diffstat (limited to 'OneClick.php')
| -rw-r--r-- | OneClick.php | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/OneClick.php b/OneClick.php new file mode 100644 index 0000000..515d2de --- /dev/null +++ b/OneClick.php @@ -0,0 +1,52 @@ +<?php + +/** + * This is just a wrapper/router for OneClick.class.php + */ + +// Fire up CiviCRM +require_once '../civicrm.config.php'; +require_once 'CRM/Core/Config.php'; +$config =& CRM_Core_Config::singleton(); + +// Only allow this to run one at a time to avoid overlap of database operations +// if IPN come in at nearly the same time. This is mostly here because of +// PayPal recurring contributions and the fact that subscr_payment and +// subscr_signup IPN come in at virtually the same time. +require_once 'CRM/Core/Lock.php'; +while ( ! $lock = new CRM_Core_Lock('OneClick') ) { + // Sleep for 1 second, then try again. + sleep(1); +} + +require 'OneClick.class.php'; +$oc = new OneClick($_REQUEST); + +// What are we doing? +switch ( $_REQUEST['oc_action'] ) { + case 'donate': + if ( isset($_REQUEST['premium']) && ! isset($_REQUEST['size']) ) { + // Javascript should prevent this, but as a failsafe send them back + // if for some reason there is a premium set yet no shirt size. + $err_msg = "You must select a shirt size."; + $err_msg = urlencode($err_msg); + header("Location: {$oc->_cancel_return}?{$_SERVER['QUERY_STRING']}&error=$err_msg"); + } else { + $oc->oc_donate(); + } + break; + case 'paypalipn': + $oc->oc_ipn('paypal'); + break; + case 'googleipn': + $oc->oc_ipn('google'); + break; + default: + $err_msg = "Unknown oc_action."; + $err_msg = urlencode($err_msg); + header("Location: {$oc->_cancel_return}?{$_SERVER['QUERY_STRING']}&error=$err_msg"); +} + +$lock->release(); + +?> |
