Index: trunk/extensions/DonationInterface/donationinterface.php |
— | — | @@ -35,14 +35,16 @@ |
36 | 36 | |
37 | 37 | $optionalParts = array( //define as fail closed. This variable will be unset before we leave this file. |
38 | 38 | 'Extras' => false, //this one gets set in the next loop, so don't bother. |
| 39 | + 'CustomFilters' => false, //Also gets set in the next loop. |
39 | 40 | 'Stomp' => false, |
40 | | - 'CustomFilters' => false, //this is definitely an Extra |
41 | 41 | 'ConversionLog' => false, //this is definitely an Extra |
42 | 42 | 'Minfraud' => false, //this is definitely an Extra |
43 | | - 'Minfraud_as_filter' => false, //extra |
44 | 43 | 'Recaptcha' => false, //extra |
45 | 44 | 'PayflowPro' => false, |
46 | 45 | 'GlobalCollect' => false, |
| 46 | + 'ReferrerFilter' => false, //extra |
| 47 | + 'SourceFilter' => false, //extra |
| 48 | + 'Minfraud_as_filter' => false, //extra |
47 | 49 | |
48 | 50 | ); |
49 | 51 | |
— | — | @@ -51,13 +53,26 @@ |
52 | 54 | global $$globalname; |
53 | 55 | if ( isset( $$globalname ) && $$globalname === true ) { |
54 | 56 | $optionalParts[$subextension] = true; |
55 | | - if ( $subextension === 'CustomFilters' || |
| 57 | + //this is getting annoying. |
| 58 | + if ( $subextension === 'ReferrerFilter' || |
| 59 | + $subextension === 'SourceFilter' || |
| 60 | + $subextension === 'Minfraud_as_filter' || |
56 | 61 | $subextension === 'ConversionLog' || |
57 | 62 | $subextension === 'Minfraud' || |
58 | 63 | $subextension === 'Recaptcha' ) { |
59 | 64 | |
| 65 | + //we have extras |
60 | 66 | $optionalParts['Extras'] = true; |
| 67 | + |
| 68 | + if ( $subextension === 'ReferrerFilter' || |
| 69 | + $subextension === 'SourceFilter' || |
| 70 | + $subextension === 'Minfraud_as_filter' ){ |
| 71 | + |
| 72 | + //and at least one of them is a custom filter. |
| 73 | + $optionalParts['CustomFilters'] = true; |
| 74 | + } |
61 | 75 | } |
| 76 | + |
62 | 77 | } |
63 | 78 | } |
64 | 79 | |
— | — | @@ -134,6 +149,16 @@ |
135 | 150 | $wgAutoloadClasses['Gateway_Extras_CustomFilters_MinFraud'] = $donationinterface_dir . "extras/custom_filters/filters/minfraud/minfraud.body.php"; |
136 | 151 | } |
137 | 152 | |
| 153 | +//Referrer Filter classes |
| 154 | +if ( $optionalParts['ReferrerFilter'] === true ){ |
| 155 | + $wgAutoloadClasses['Gateway_Extras_CustomFilters_Referrer'] = $donationinterface_dir . "extras/custom_filters/filters/referrer/referrer.body.php"; |
| 156 | +} |
| 157 | + |
| 158 | +//Source Filter classes |
| 159 | +if ( $optionalParts['SourceFilter'] === true ){ |
| 160 | + $wgAutoloadClasses['Gateway_Extras_CustomFilters_Source'] = $donationinterface_dir . "extras/custom_filters/filters/source/source.body.php"; |
| 161 | +} |
| 162 | + |
138 | 163 | //Recaptcha classes |
139 | 164 | if ( $optionalParts['Recaptcha'] === true ){ |
140 | 165 | $wgAutoloadClasses['Gateway_Extras_ReCaptcha'] = $donationinterface_dir . "extras/recaptcha/recaptcha.body.php"; |
— | — | @@ -348,6 +373,16 @@ |
349 | 374 | $wgMinFraudStandalone = FALSE; |
350 | 375 | } |
351 | 376 | |
| 377 | +//Referrer Filter globals |
| 378 | +if ( $optionalParts['ReferrerFilter'] === true ){ |
| 379 | + $wgCustomFiltersRefRules = array( ); |
| 380 | +} |
| 381 | + |
| 382 | +//Source Filter globals |
| 383 | +if ( $optionalParts['SourceFilter'] === true ){ |
| 384 | + $wgCustomFiltersSrcRules = array( ); |
| 385 | +} |
| 386 | + |
352 | 387 | //Recaptcha globals |
353 | 388 | if ( $optionalParts['Recaptcha'] === true ){ |
354 | 389 | /** |
— | — | @@ -414,6 +449,16 @@ |
415 | 450 | $wgHooks["GatewayValidate"][] = array( 'Gateway_Extras_CustomFilters::onValidate' ); |
416 | 451 | } |
417 | 452 | |
| 453 | +//Referrer Filter hooks |
| 454 | +if ( $optionalParts['ReferrerFilter'] === true ){ |
| 455 | + $wgHooks["GatewayCustomFilter"][] = array( 'Gateway_Extras_CustomFilters_Referrer::onFilter' ); |
| 456 | +} |
| 457 | + |
| 458 | +//Source Filter hooks |
| 459 | +if ( $optionalParts['SourceFilter'] === true ){ |
| 460 | + $wgHooks["GatewayCustomFilter"][] = array( 'Gateway_Extras_CustomFilters_Source::onFilter' ); |
| 461 | +} |
| 462 | + |
418 | 463 | //Conversion Log hooks |
419 | 464 | if ($optionalParts['ConversionLog'] === true){ |
420 | 465 | // Sets the 'conversion log' as logger for post-processing |
Index: trunk/extensions/DonationInterface/extras/custom_filters/filters/source/source.php |
— | — | @@ -1,34 +0,0 @@ |
2 | | -<?php |
3 | | - |
4 | | -/** |
5 | | - * Provides a method for filtering transactions based on source |
6 | | - * |
7 | | - * To install: |
8 | | - * require_once( "$IP/extensions/DonationInterface/extras/custom_filters/filters/source/source.php" ); |
9 | | - */ |
10 | | -if ( !defined( 'MEDIAWIKI' ) ) { |
11 | | - die( "This file is part of the source custom filter part of the Gateway extension. It is not a valid entry point\n" ); |
12 | | -} |
13 | | - |
14 | | -$wgExtensionCredits['gateway_customfilters_source'][] = array( |
15 | | - 'name' => 'custom filter: source', |
16 | | - 'author' => 'Arthur Richards', |
17 | | - 'url' => '', |
18 | | - 'description' => 'This extension provides a way to filter transactions based on their source.' |
19 | | -); |
20 | | - |
21 | | -/** |
22 | | - * An array defining source strings and their associated risk score amount |
23 | | - * |
24 | | - * The key of the array is a regular expression to run against the source and the value is |
25 | | - * the amount to add to the risk score. The regex is run through preg_match and does not |
26 | | - * need to include staring/ending delimiters - be sure to escape your characters! |
27 | | - * |
28 | | - * eg: |
29 | | - * $wgCustomFiltersSrcRules['support.cc'] = "100"; |
30 | | - * // increases risk score for trxns with source of 'support.cc' referrals by 100 |
31 | | - */ |
32 | | -$wgCustomFiltersSrcRules = array( ); |
33 | | - |
34 | | -$wgAutoloadClasses['Gateway_Extras_CustomFilters_Source'] = dirname( __FILE__ ) . "/source.body.php"; |
35 | | -$wgHooks["GatewayCustomFilter"][] = array( 'Gateway_Extras_CustomFilters_Source::onFilter' ); |
Index: trunk/extensions/DonationInterface/extras/custom_filters/filters/minfraud/minfraud.body.php |
— | — | @@ -30,12 +30,12 @@ |
31 | 31 | |
32 | 32 | static function onFilter( &$gateway_adapter, &$custom_filter_object ) { |
33 | 33 | $gateway_adapter->debugarray[] = 'minfraud onFilter hook!'; |
34 | | - return self::singleton( &$gateway_adapter )->filter( $custom_filter_object ); |
| 34 | + return self::singleton( $gateway_adapter )->filter( $custom_filter_object ); |
35 | 35 | } |
36 | 36 | |
37 | 37 | static function singleton( &$gateway_adapter ) { |
38 | 38 | if ( !self::$instance ) { |
39 | | - self::$instance = new self( &$gateway_adapter ); |
| 39 | + self::$instance = new self( $gateway_adapter ); |
40 | 40 | } |
41 | 41 | return self::$instance; |
42 | 42 | } |
Index: trunk/extensions/DonationInterface/extras/custom_filters/filters/referrer/referrer.php |
— | — | @@ -1,34 +0,0 @@ |
2 | | -<?php |
3 | | - |
4 | | -/** |
5 | | - * Provides a method for filtering transactions based on referrer |
6 | | - * |
7 | | - * To install: |
8 | | - * require_once( "$IP/extensions/DonationInterface/extras/custom_filters/filters/referrer/referrer.php" ); |
9 | | - */ |
10 | | -if ( !defined( 'MEDIAWIKI' ) ) { |
11 | | - die( "This file is part of the referrer custom filter part of the Gateway extension. It is not a valid entry point\n" ); |
12 | | -} |
13 | | - |
14 | | -$wgExtensionCredits['gateway_customfilters_referrer'][] = array( |
15 | | - 'name' => 'custom filter: referrer', |
16 | | - 'author' => 'Arthur Richards', |
17 | | - 'url' => '', |
18 | | - 'description' => 'This extension provides a way to filter transactions based on their referrer.' |
19 | | -); |
20 | | - |
21 | | -/** |
22 | | - * An array defining a regex to match referrer URLs and their associated risk score amount |
23 | | - * |
24 | | - * The key of the array is a regular expression to run against the referrer and the value is |
25 | | - * the amount to add to the risk score. The regex is run through preg_match and does not |
26 | | - * need to include staring/ending delimiters - be sure to escape your characters! |
27 | | - * |
28 | | - * eg: |
29 | | - * $wgCustomFiltersRefRules['fraud\.com'] = "100"; |
30 | | - * // increases risk score for trxns with http://fraud.com referrals by 100 |
31 | | - */ |
32 | | -$wgCustomFiltersRefRules = array( ); |
33 | | - |
34 | | -$wgAutoloadClasses['Gateway_Extras_CustomFilters_Referrer'] = dirname( __FILE__ ) . "/referrer.body.php"; |
35 | | -$wgHooks["GatewayCustomFilter"][] = array( 'Gateway_Extras_CustomFilters_Referrer::onFilter' ); |
Index: trunk/extensions/DonationInterface/gateway_common/gateway.adapter.php |
— | — | @@ -1299,8 +1299,8 @@ |
1300 | 1300 | } |
1301 | 1301 | |
1302 | 1302 | function runPreProcess() { |
| 1303 | + global $wgHooks; |
1303 | 1304 | if ( $this->transaction_option( 'do_validation' ) ) { |
1304 | | - global $wgHooks; |
1305 | 1305 | if ( !isset( $wgHooks['GatewayValidate'] ) ) { |
1306 | 1306 | //if there ARE no validate hooks, we're okay. |
1307 | 1307 | $this->action = 'process'; |