]> git.mjollnir.org Git - moodle.git/commitdiff
Added ABA validation funtion.
authorethem <ethem>
Wed, 30 Aug 2006 17:14:32 +0000 (17:14 +0000)
committerethem <ethem>
Wed, 30 Aug 2006 17:14:32 +0000 (17:14 +0000)
enrol/authorize/abaval.php [new file with mode: 0644]

diff --git a/enrol/authorize/abaval.php b/enrol/authorize/abaval.php
new file mode 100644 (file)
index 0000000..41712d9
--- /dev/null
@@ -0,0 +1,26 @@
+<?php // $Id$
+
+/**
+ * Validates the supplied ABA number
+ * using a simple mod 10 check digit routine.
+ *
+ * @param string $aba Bank ID
+ * @return bool true ABA is valid, false otherwise
+ */
+function ABAVal($aba)
+{
+    if (ereg("^[0-9]{9}$", $aba)) {
+        $n = 0;
+        for($i = 0; $i < 9; $i += 3) {
+            $n += (substr($aba, $i, 1) * 3) +
+                  (substr($aba, $i + 1, 1) * 7) +
+                  (substr($aba, $i + 2, 1));
+        }
+        if ($n != 0 and $n % 10 == 0) {
+            return true;
+        }
+    }
+    return false;
+}
+
+?>