Mwalker has uploaded a new change for review.
https://gerrit.wikimedia.org/r/54606
Change subject: Next Attempt at a Luhn Algorithm
......................................................................
Next Attempt at a Luhn Algorithm
Because apparently I cannot read english; this Luhn algorithm
should work a bit better :p
Change-Id: I1ed0b224bd129f7b5ed6092cf66c8104f3c39686
---
M gateway_common/DataValidator.php
1 file changed, 9 insertions(+), 7 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DonationInterface
refs/changes/06/54606/1
diff --git a/gateway_common/DataValidator.php b/gateway_common/DataValidator.php
index 3a8fc62..1301028 100644
--- a/gateway_common/DataValidator.php
+++ b/gateway_common/DataValidator.php
@@ -788,15 +788,17 @@
$sum = 0;
for( $i = 0; $i < strlen( $str ); $i++ ) {
- $n = 0 + $str[$i];
- $odd = !$odd;
-
- if( $odd ) {
- $sum += $n;
+ if ( $odd ) {
+ $sum += $str[$i];
} else {
- $x = 2 * $n;
- $sum += ($x > 9) ? ($x - 9) : $x;
+ if (( $str[$i] * 2 ) > 9 ) {
+ $sum += $str[$i] * 2 - 9;
+ } else {
+ $sum += $str[$i] * 2;
+ }
}
+
+ $odd = !$odd;
}
return( ( $sum % 10 ) == 0 );
}
--
To view, visit https://gerrit.wikimedia.org/r/54606
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I1ed0b224bd129f7b5ed6092cf66c8104f3c39686
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/DonationInterface
Gerrit-Branch: master
Gerrit-Owner: Mwalker <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits