XenoRyet has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/266456

Change subject: Nonsense Name Fraud Filter
......................................................................

Nonsense Name Fraud Filter

New anti-fraud test to detect gibberish names.
Devides keyboard into zones and assigns points based on a configurable 
percentage
of characters coming from one zone.

Bug: T120255
Change-Id: I2d664cb40d9cb1f8682101958ef00c1827299fc2
---
M gateway_common/gateway.adapter.php
1 file changed, 54 insertions(+), 0 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DonationInterface 
refs/changes/56/266456/1

diff --git a/gateway_common/gateway.adapter.php 
b/gateway_common/gateway.adapter.php
index 11da3c5..3672e9a 100644
--- a/gateway_common/gateway.adapter.php
+++ b/gateway_common/gateway.adapter.php
@@ -2840,6 +2840,59 @@
                return false;
        }
 
+     /**
+        * This custom filter function checks the global variable:
+        *
+        * KeyMapA
+        * KeyMapB
+        *
+        * How the score is tabulated:
+        *  - If the majority of letters in a name come from the same zone 
points are added.
+        *  - Returns an integer: 0 <= $score <= 100
+        *
+        * @see $wgDonationInterfaceCustomFiltersFunctions
+        * @see $wgDonationInterfaceKeyMapA* @see $wgDonationInterfaceKeyMapB
+        *
+        * @return integer
+        */
+        public function getScoreName(){
+
+            $fName = $this.getData_Unstaged_Escaped( 'fname' );
+                       $lName = $this.getData_Unstaged_Escaped( 'lname' );
+
+            $nameArray = str_split( $fName . $lName );
+            
+            $keyMapA = $this->getGlobal( 'KeyMapA' );
+            
+            $keyMapB = $this->getGlobal( 'KeyMapB' );
+            
+            $gibberishWeight = $this->getGlobal( 'NameGibberishWeight' );
+            
+            $failScore = $this->getGlobal( 'NameScore' );
+
+            $points = 0;
+
+            $score = 0;
+
+            if ( is_array( $nameArray ) && !empty( $nameArray ) ){
+                foreach($nameArray as $letter){
+                    // For each char in zone A add a point, zone B subtract.
+                    if( in_array( $letter, $keyMapA ) ){
+                        $points++;
+                    }
+                    if( in_array( $letter, $keyMapB ) ){
+                        $points--;
+                    }
+                }
+
+                if( abs( $points ) / count( $nameArray ) >= $gibberishWeight ){
+                    $score = $failScore;
+                }
+            }
+
+            return $score;
+            
+        }
        /**
         * This custom filter function checks the global variable:
         *
@@ -2857,6 +2910,7 @@
         */
        public function getScoreCountryMap() {
 
+            //declare your globals to DonationInterface.php, set them in 
localsettings
                $score = 0;
 
                $country = $this->getData_Unstaged_Escaped( 'country' );

-- 
To view, visit https://gerrit.wikimedia.org/r/266456
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2d664cb40d9cb1f8682101958ef00c1827299fc2
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/DonationInterface
Gerrit-Branch: master
Gerrit-Owner: XenoRyet <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to