pwd );
70 | // we save shuffle hash to see on POST if the password was changed by an user
71 | $pwd_hash = sha1( $pwd );
72 |
73 | ?>
74 |
75 | uid) || empty($this->pwd) ) : ?>
76 |
291 | domain. '">';
306 | $this->single_row_columns( $item );
307 | echo '';
308 | }
309 |
310 | /**
311 | * Returns associative array with the list of bulk actions available on this table.
312 | *
313 | * @since 4.2.0
314 | *
315 | * @access protected
316 | * @return array The associative array of bulk actions.
317 | */
318 | public function get_bulk_actions() {
319 | return array();
320 | }
321 |
322 | }
--------------------------------------------------------------------------------
/changelog.txt:
--------------------------------------------------------------------------------
1 | == 4.4.3.4 ==
2 | * Added: New filter dm_do_propagation to skip propagation script.
3 | * Added: New notice about SSL requirement for SSO.
4 | * Improved: Repair logout_redirect filter syntax.
5 | * Improved: Avoid using deprecated create_function function.
6 | * Improved: Avoid duplicate DB queries.
7 | * Improved: Update sunrise.php message.
8 | * Fixed: Cross domain url was generated based on force ssl settings.
9 | * Fixed: Wrong IP address in WPMUDEV hosting.
10 | * Fixed: DB error when Multi DB is active.
11 | * Fixed: Warnings on PHP 7.2.
12 | * Fixed: Wrong redirect url when adminitstration mapping is set to mapped domain.
13 | * Fixed: Enom registration is not working.
14 | * Fixed: Jetpack sitemap error on mapped domain.
15 | * Fixed: Cross Domain login on subdirectory multisite was not working.
16 | * Fixed: HTTPS was always forced.
17 | * Fixed: Divi builder was not loading.
18 | * Fixed: Conflict with Beaver Builder.
19 | * Fixed: Broken customize link.
20 | * Fixed: WPML language links for the mapped domain is wrong in WPML admin area.
21 | * Fixed: When logging into original domain, user is redirected to mapped frontend.
22 | * Fixed: Mapped domains show as invalid, although they appear to be working.
23 |
24 | == 4.4.3.3 ==
25 | * Fixed: Use original domain for admin section doesn't work for login
26 | * Fixed: http/https mapping redirect is not respected
27 | * Fixed: Enom PayPal Checkout Image is called via HTTP
28 | * Fixed: Reduce query workload for getting original domain
29 |
30 | == 4.4.3.2 ==
31 | * Fix mixed content issues with SSL when logging into a subsite.
32 |
33 | == 4.4.3.1 ==
34 | * Fixed: Prevent mapping defaulting to original when redirection has not yet
35 | been set.
36 |
37 | == 4.4.3 ==
38 | * Fixed: WordPress Rest URL
39 | * Fixed: Force admin https URL Redirect loop
40 | * Fixed: Multiple Mapped domains not mapping frontend links correctly.
41 | * Fixed: Login issues.
42 | * Fixed: Prevent admin_url from being relative to fix AJAX issues with some plugins.
43 | * Fixed: Upfront compatibility issues with not loading editor on original domain.
44 | * Fixed: Forcing SSL on root domain not working.
45 | * Fixed: Warning on DNS Configuration when multiple IP addresses are used.
46 | * Fixed: The plugins_url was being replaced by the mapped url, breaking site assets for some users.
47 | * Fixed: Force SSL settings not displaying the correct value.
48 | * Fixed: Multiple mapped domains without primary domain used the last mapped domain.
49 | * Fixed: Prevent incorrect cookies disabled warning when trying to login.
50 | * Fixed: Resolve conflict with Upfront Editor and Builder.
51 | * Fixed: Jetpack compatibility.
52 | * Fixed: Unexpected behavior for main site.
53 | * Fixed: Subsites display incorrect URL.
54 | * Fixed: Simplify Excluded pages instructions if user cannot change SSL per permissions.
55 |
56 | == 4.4.2.5 ==
57 | * Removed: Support for WHMCS
58 | * Added: Notification to Network admin about WHMCS
59 | * Fixed: Some minor typos
60 | * Fixed: Fatal error with newer versions of PHP
61 | * Fixed: Issue with logged out users on Pro Site not being redirected to mapped domain
62 | * Fixed: Various issues involving SSL and mismatched content
63 | * Fixed: Issue with theme customizer not working with mapped domains
64 | * Fixed: Issue with purchasing uk tld using PayPal
65 | errors when using the Customizer
66 | * Improved: Refactored mapping logic for easier troubleshooting mapping issues in
67 | development
68 |
69 | == 4.4.2.4 ==
70 | * Fixed: Issue when main site uses www
71 |
72 | == 4.4.2.3 ==
73 | * Improved: Overall sanity and stability
74 |
75 | == 4.4.2.2 ==
76 | * Improved: Mapping performance
77 | * Fixed: Issue with mapping scheme
78 | * Fixed: Issue with multiple mapped domains
79 | * Fixed: Multiple issues with translation files
80 |
81 | == 4.4.2.1 ==
82 | * Improved: Better compatibility with Upfront themes
83 | * Improved: Better scheme forcing
84 | * Fixed: Depreciated notices
85 |
86 | == 4.4.2.0 ==
87 | * Added: Ability to define redirect_to after SSO happens
88 | * Added: Hooks for other plugins to use
89 | * Improved: Upfront compatibility
90 | * Improved: Single sign on functionality
91 | * Improved: Request scheme handling in backend and frontend
92 | * Improved: Mapped domain validity and validity check
93 | * Improved: Compatibility with older versions of PHP
94 | * Fixed: Logging out from a user would log out on all users
95 |
96 | == 4.4.1.0 ==
97 | * Added: Cache scheme variables with transients
98 | * Added: Make sunrise inclusion smarter
99 | * Fixed: Scheme mismatch in admin_url hook under mapped domain
100 | * Fixed: Make sure purchase in whmcs reseller is logged
101 | * Fixed: Meaningful error message in case domain is not correctly added as mapped domain
102 | * Fixed: Less requests to db when checking force_ssl_on_mapped_domain for domain
103 | * Fixed: Bug in is_original_domain method
104 |
105 | == 4.4.0.9 ==
106 | * Fixed: Mixed urls in contents under ssl
107 |
108 | == 4.4.0.8 ==
109 | * Add dm_toggle_mapping action hook to toggle mapped domain active flag
110 | * Fix bug in domain mapping domain column length when used with InnoDB
111 |
112 | == 4.4.0.7 ==
113 | * Fixed: Blank page in sso reauthenticate function when redirect_to is null
114 | * Fixed: Bug in setting correct scheme for the endpoint
115 | * Fixed: Https admin ajax url in none https page
116 | * Fixed: Bug in sso endpoing url scheme,
117 | * Fixed: Inability to logout from mapped domain
118 | * Fixed: Bug in SSO that prevented it from working on slower installs
119 | * Fixed: Cross-login issue and cookie nag
120 |
121 |
122 |
123 | == 4.4.0.6 ==
124 | * Fixed: Issue in login functionality when both admin and login mappings are original
125 | * Fixed: Bugs in unswap url and login and sso from https pages
126 | * Fixed: Mapping bugs with https scheme
127 | * Fixed: Some domain validations issues
128 |
129 |
130 | == 4.4.0.5 ==
131 | * Fixed: Bug in login form action attribute on mapped domain
132 |
133 | == 4.4.0.4 ==
134 | * Fixed: Admin url issues on mapped site
135 | * Fixed: Sso endpoint resolution issues
136 | * Fixed: Bug in admin and login mapping uppon login
137 |
138 | == 4.4.0.3 ==
139 | * Fixed: Issue in login from mapped domain
140 | * Fixed: Issue in visiting admin with the secondary mapped domains
141 | * Fixed: Ability to remove prohibited domains from mapped domains table
142 |
143 | == 4.4.0.2 ==
144 | * Added: More control over excluded and ssl-forced pages and urls ( for super admin )
145 | * Fixed: Issue with prohibited domains and disallowed subdomains
146 | * Fixed: Issue with php v.5.2.x and Punycode Class ( used for International Domain Names )
147 | * Fixed: Some js issues in mapped domain table pagination
148 | * Fixed: Some typos
149 |
150 | == 4.4.0.1 ==
151 | * Fixed: Post preview link issue
152 | * Fixed: Bug in eNom purchase functionality
153 | * Fixed: Some minor bugs
154 |
155 | == 4.4.0 ==
156 | * Better integration with Multi-Domains plugin
157 | * Revamped SSO to improve performance and solve issue with out of date token nag, now fully async
158 | * Added: Ability to disable single url scheme forcing and mapping exclusion
159 | * Added: Better UX for adding and managing mapped domains
160 | * Added: Ability to enable multiple mapped domains from admin of the main site
161 | * Added: Support for multiple currencies
162 | * Fixed: Bug when going from an excluded page to the mapped domain
163 | * Fixed: Forcing https for admin and login
164 | * Fixed: Better UX for adding and managing mapped domains
165 | * Fixed: Punycode class compatibility when some extensions are not installed
166 | * Fixed: WP add_query_var and remove_query_var vulnerability
167 | * Removed: DM_FORCE_PROTOCOL_ON_MAPPED_DOMAIN, the schema forcing for mapped domains as well as original domain is only possible from the setting pages
168 |
169 | == 4.3.1 ==
170 | * Better integration with Multi-Domains plugin
171 | * Revamped SSO to improve performance and solve issue with out of date token nag, now fully async
172 | * Added: Ability to disable single url scheme forcing and mapping exclusion
173 | * Added: Better UX for adding and managing mapped domains
174 | * Added: Ability to enable multiple mapped domains from admin of the main site
175 | * Fixed: Bug when going from an excluded page to the mapped domain
176 | * Fixed: Forcing https for admin and login
177 | * Fixed: Better UX for adding and managing mapped domains
178 |
179 | == 4.3.0.4 ==
180 | * Fixed issue with excluded pages problem on homepage
181 |
182 | == 4.3.0.3 ==
183 | * Added ability to turn "Check domain propagation before mapping" on and off
184 | * Fixed issue with static content (image, css, ...) not showing up in some sub-sites
185 |
186 | == 4.3.0.2 ==
187 | * Fixed minor bug when sub-site doesn't have a mapped domain
188 |
189 | == 4.3.0.1 ==
190 | * Fixed double forward slash in urls
191 | * Fixed sub-site name missing in some urls
192 |
193 | == 4.3.0 ==
194 | * Added ability to disable sub-domains of the original domain to be used as sub-site’s primary (mapped) domain
195 | * Added ability to prohibit certain domains and their sub-domains
196 | * Added ability to exclude some pages to be mapped
197 | * Added ability to force https for each single page
198 | * Added not mapping to primary (mapped) domain when it’s not valid yet.
199 | * Added ability to define custom sunrise file
200 | * Added ability to include SSO asynchronously
201 | * Fixed bug in mapped domain scheme forcing
202 | * Fixed wrong urls in the admin of sub-site when the sub-site has mapped domain
203 | * Fixed problem in sunrise when IP addressed is used instead of a domain name for the main site
204 | * Fixed bug when frontend is forced to use https and redirect type is set to force primary domain
205 | * Fixed bug when front-end is to https forced in the main site’s settings page and it’s allowing both https and http for the mapped domain
206 | * Fixed problem in customizer when mapped domain is used with https
207 |
208 |
209 | == 4.2.0.6 ==
210 | * Fixed: bug in mapped domain scheme forcing
211 |
212 | == 4.2.0.5 ==
213 | * Fixed: bug causing redirect loop in sub-site's login when original admin/login pages are forced to have https and subdomain has mapped domain
214 |
215 | == 4.2.0.4 ==
216 | * Added: ability to force schema in admin of mapped domain when schema is forced for front-end of mapped domain
217 | * Added: ability to leave mapped domain schema unforced
218 | * Added: delete mapping record from db when blog is deleted
219 | * Fixed: bug in mapped domain schema forcing on nginx servers
220 | * Fixed: preventing original domain with www to be added as mapped domain
221 | * Fixed: bug in SSO when logging in subdomain and not getting logged in in mapped domain
222 |
223 | == 4.2.0.3 ==
224 | * Fixed: Domain validation issue
225 |
226 | == 4.2.0.2 ==
227 | * Fixed: bug that prevented some installs from adding a new domain
228 | * Fixed: domain validation when adding or removing a domain
229 |
230 | == 4.2.0.1 ==
231 | * Fixed: bug in Mapped domains table
232 | * Amended: sunrise inclusion
233 |
234 | == 4.2.0 ==
235 | * International domain names
236 | * List of mapped domains for network admin and inline actions
237 | * Ability to force front-end and admin schemes ( http / https )
238 | * Accepting one letter subdomain as mapped domain
239 | * Fixed: Blank page while purchasing a new domain in sub-site admin
240 | * Added: WHMCS integration
241 | * Changed how sunrise is maintained
242 |
243 |
244 | == 4.1.4.2 ==
245 | * Fixed redirect loop for mapped domains while SSO is active
246 |
247 | == 4.1.4.1 ==
248 | * Fixed redirect loop for some domain names when SSO is active
249 |
250 | == 4.1.4 ==
251 | * Added feature that would prevent from redirecting to mapped domain if in ssl connection
252 |
253 | == 4.1.3 ==
254 | * Added dm_home_url() to retrieve home url with original domain when in ssl connection
255 | * Added dm_site_url() to retrieve site url with original domain when in ssl connection
256 | * Fixed wording for error notifications while adding a new domain
257 | * Speed up DNS A record detection on network settings and allow disabling it via DM_SKIP_DNS_CHECK define
258 |
259 | == 4.1.2.1 ==
260 |
261 | * Fixed a minor issue Cdsso::update_login_url() when $redirect_to is empty
262 |
263 | == 4.1.2 ==
264 |
265 | * Fixed domain health status check process
266 | * Fixed front end SSL mapping issue
267 | * Fixed x-autocomplete fields for eNom forms
268 | * Fixed unexpected redirect issue due to canonical URL difference
269 | * Implemented ability to override standard domain mapping instructions
270 | * Implemented ability to set front end mapping for a certain blog
271 | * Reworked cross domain single sign on implementation + better SSL support
272 |
273 | == 4.1.1 ==
274 |
275 | * Fixed issue with password protected pages.
276 | * Fixed issue with wrongly replaced links a post/page content.
277 | * Fixed database query issue related to cookies building which appear on sign up page.
278 | * Implemented new version of WPMUDev Dashboard notices extension.
279 |
280 | == 4.1 ==
281 |
282 | * Fixed incorrect work of SSO via stylesheets
283 | * Fixed home domain mapping in case when primary domain is selected
284 | * Fixed allowed redirect hosts filtering issue
285 | * Fixed theme preview compatibility issue
286 | * Implemented ability to register eNom accounts via admin dashboard
287 | * Improved eNom domain purchase form
288 | * Improved stylesheets SSO
289 | * Added instruction how to enabled multiple domains mapping
290 |
291 | == 4.0.4 ==
292 |
293 | * Fixed SSL verification issue for health check validation
294 | * Fixed WPEngine compatibility issue
295 |
296 | == 4.0.3 ==
297 |
298 | * Fixed dedicated IP determination
299 | * Fixed ProSites compatibility issue
300 | * Implemented front end redirect to primary domain
301 | * Improved MultiDB compatibility by registering domain mapping tables as global
302 |
--------------------------------------------------------------------------------
/js/jquery.payment.js:
--------------------------------------------------------------------------------
1 | (function() {
2 | var $, cardFromNumber, cardFromType, cards, defaultFormat, formatBackCardNumber, formatBackExpiry, formatCardNumber, formatExpiry, formatForwardExpiry, formatForwardSlash, hasTextSelected, luhnCheck, reFormatCardNumber, restrictCVC, restrictCardNumber, restrictExpiry, restrictNumeric, setCardType,
3 | __slice = [].slice,
4 | __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; },
5 | _this = this;
6 |
7 | $ = jQuery;
8 |
9 | $.payment = {};
10 |
11 | $.payment.fn = {};
12 |
13 | $.fn.payment = function() {
14 | var args, method;
15 | method = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
16 | return $.payment.fn[method].apply(this, args);
17 | };
18 |
19 | defaultFormat = /(\d{1,4})/g;
20 |
21 | cards = [
22 | {
23 | type: 'maestro',
24 | pattern: /^(5018|5020|5038|6304|6759|676[1-3])/,
25 | format: defaultFormat,
26 | length: [12, 13, 14, 15, 16, 17, 18, 19],
27 | cvcLength: [3],
28 | luhn: true
29 | }, {
30 | type: 'dinersclub',
31 | pattern: /^(36|38|30[0-5])/,
32 | format: defaultFormat,
33 | length: [14],
34 | cvcLength: [3],
35 | luhn: true
36 | }, {
37 | type: 'laser',
38 | pattern: /^(6706|6771|6709)/,
39 | format: defaultFormat,
40 | length: [16, 17, 18, 19],
41 | cvcLength: [3],
42 | luhn: true
43 | }, {
44 | type: 'jcb',
45 | pattern: /^35/,
46 | format: defaultFormat,
47 | length: [16],
48 | cvcLength: [3],
49 | luhn: true
50 | }, {
51 | type: 'unionpay',
52 | pattern: /^62/,
53 | format: defaultFormat,
54 | length: [16, 17, 18, 19],
55 | cvcLength: [3],
56 | luhn: false
57 | }, {
58 | type: 'discover',
59 | pattern: /^(6011|65|64[4-9]|622)/,
60 | format: defaultFormat,
61 | length: [16],
62 | cvcLength: [3],
63 | luhn: true
64 | }, {
65 | type: 'mastercard',
66 | pattern: /^5[1-5]/,
67 | format: defaultFormat,
68 | length: [16],
69 | cvcLength: [3],
70 | luhn: true
71 | }, {
72 | type: 'amex',
73 | pattern: /^3[47]/,
74 | format: /(\d{1,4})(\d{1,6})?(\d{1,5})?/,
75 | length: [15],
76 | cvcLength: [3, 4],
77 | luhn: true
78 | }, {
79 | type: 'visa',
80 | pattern: /^4/,
81 | format: defaultFormat,
82 | length: [13, 14, 15, 16],
83 | cvcLength: [3],
84 | luhn: true
85 | }
86 | ];
87 |
88 | cardFromNumber = function(num) {
89 | var card, _i, _len;
90 | num = (num + '').replace(/\D/g, '');
91 | for (_i = 0, _len = cards.length; _i < _len; _i++) {
92 | card = cards[_i];
93 | if (card.pattern.test(num)) {
94 | return card;
95 | }
96 | }
97 | };
98 |
99 | cardFromType = function(type) {
100 | var card, _i, _len;
101 | for (_i = 0, _len = cards.length; _i < _len; _i++) {
102 | card = cards[_i];
103 | if (card.type === type) {
104 | return card;
105 | }
106 | }
107 | };
108 |
109 | luhnCheck = function(num) {
110 | var digit, digits, odd, sum, _i, _len;
111 | odd = true;
112 | sum = 0;
113 | digits = (num + '').split('').reverse();
114 | for (_i = 0, _len = digits.length; _i < _len; _i++) {
115 | digit = digits[_i];
116 | digit = parseInt(digit, 10);
117 | if ((odd = !odd)) {
118 | digit *= 2;
119 | }
120 | if (digit > 9) {
121 | digit -= 9;
122 | }
123 | sum += digit;
124 | }
125 | return sum % 10 === 0;
126 | };
127 |
128 | hasTextSelected = function($target) {
129 | var _ref;
130 | if (($target.prop('selectionStart') != null) && $target.prop('selectionStart') !== $target.prop('selectionEnd')) {
131 | return true;
132 | }
133 | if (typeof document !== "undefined" && document !== null ? (_ref = document.selection) != null ? typeof _ref.createRange === "function" ? _ref.createRange().text : void 0 : void 0 : void 0) {
134 | return true;
135 | }
136 | return false;
137 | };
138 |
139 | reFormatCardNumber = function(e) {
140 | var _this = this;
141 | return setTimeout(function() {
142 | var $target, value;
143 | $target = $(e.currentTarget);
144 | value = $target.val();
145 | value = $.payment.formatCardNumber(value);
146 | return $target.val(value);
147 | });
148 | };
149 |
150 | formatCardNumber = function(e) {
151 | var $target, card, digit, length, re, upperLength, value;
152 | digit = String.fromCharCode(e.which);
153 | if (!/^\d+$/.test(digit)) {
154 | return;
155 | }
156 | $target = $(e.currentTarget);
157 | value = $target.val();
158 | card = cardFromNumber(value + digit);
159 | length = (value.replace(/\D/g, '') + digit).length;
160 | upperLength = 16;
161 | if (card) {
162 | upperLength = card.length[card.length.length - 1];
163 | }
164 | if (length >= upperLength) {
165 | return;
166 | }
167 | if (($target.prop('selectionStart') != null) && $target.prop('selectionStart') !== value.length) {
168 | return;
169 | }
170 | if (card && card.type === 'amex') {
171 | re = /^(\d{4}|\d{4}\s\d{6})$/;
172 | } else {
173 | re = /(?:^|\s)(\d{4})$/;
174 | }
175 | if (re.test(value)) {
176 | e.preventDefault();
177 | return $target.val(value + ' ' + digit);
178 | } else if (re.test(value + digit)) {
179 | e.preventDefault();
180 | return $target.val(value + digit + ' ');
181 | }
182 | };
183 |
184 | formatBackCardNumber = function(e) {
185 | var $target, value;
186 | $target = $(e.currentTarget);
187 | value = $target.val();
188 | if (e.meta) {
189 | return;
190 | }
191 | if (e.which !== 8) {
192 | return;
193 | }
194 | if (($target.prop('selectionStart') != null) && $target.prop('selectionStart') !== value.length) {
195 | return;
196 | }
197 | if (/\d\s$/.test(value)) {
198 | e.preventDefault();
199 | return $target.val(value.replace(/\d\s$/, ''));
200 | } else if (/\s\d?$/.test(value)) {
201 | e.preventDefault();
202 | return $target.val(value.replace(/\s\d?$/, ''));
203 | }
204 | };
205 |
206 | formatExpiry = function(e) {
207 | var $target, digit, val;
208 | digit = String.fromCharCode(e.which);
209 | if (!/^\d+$/.test(digit)) {
210 | return;
211 | }
212 | $target = $(e.currentTarget);
213 | val = $target.val() + digit;
214 | if (/^\d$/.test(val) && (val !== '0' && val !== '1')) {
215 | e.preventDefault();
216 | return $target.val("0" + val + " / ");
217 | } else if (/^\d\d$/.test(val)) {
218 | e.preventDefault();
219 | return $target.val("" + val + " / ");
220 | }
221 | };
222 |
223 | formatForwardExpiry = function(e) {
224 | var $target, digit, val;
225 | digit = String.fromCharCode(e.which);
226 | if (!/^\d+$/.test(digit)) {
227 | return;
228 | }
229 | $target = $(e.currentTarget);
230 | val = $target.val();
231 | if (/^\d\d$/.test(val)) {
232 | return $target.val("" + val + " / ");
233 | }
234 | };
235 |
236 | formatForwardSlash = function(e) {
237 | var $target, slash, val;
238 | slash = String.fromCharCode(e.which);
239 | if (slash !== '/') {
240 | return;
241 | }
242 | $target = $(e.currentTarget);
243 | val = $target.val();
244 | if (/^\d$/.test(val) && val !== '0') {
245 | return $target.val("0" + val + " / ");
246 | }
247 | };
248 |
249 | formatBackExpiry = function(e) {
250 | var $target, value;
251 | if (e.meta) {
252 | return;
253 | }
254 | $target = $(e.currentTarget);
255 | value = $target.val();
256 | if (e.which !== 8) {
257 | return;
258 | }
259 | if (($target.prop('selectionStart') != null) && $target.prop('selectionStart') !== value.length) {
260 | return;
261 | }
262 | if (/\d(\s|\/)+$/.test(value)) {
263 | e.preventDefault();
264 | return $target.val(value.replace(/\d(\s|\/)*$/, ''));
265 | } else if (/\s\/\s?\d?$/.test(value)) {
266 | e.preventDefault();
267 | return $target.val(value.replace(/\s\/\s?\d?$/, ''));
268 | }
269 | };
270 |
271 | restrictNumeric = function(e) {
272 | var input;
273 | if (e.metaKey || e.ctrlKey) {
274 | return true;
275 | }
276 | if (e.which === 32) {
277 | return false;
278 | }
279 | if (e.which === 0) {
280 | return true;
281 | }
282 | if (e.which < 33) {
283 | return true;
284 | }
285 | input = String.fromCharCode(e.which);
286 | return !!/[\d\s]/.test(input);
287 | };
288 |
289 | restrictCardNumber = function(e) {
290 | var $target, card, digit, value;
291 | $target = $(e.currentTarget);
292 | digit = String.fromCharCode(e.which);
293 | if (!/^\d+$/.test(digit)) {
294 | return;
295 | }
296 | if (hasTextSelected($target)) {
297 | return;
298 | }
299 | value = ($target.val() + digit).replace(/\D/g, '');
300 | card = cardFromNumber(value);
301 | if (card) {
302 | return value.length <= card.length[card.length.length - 1];
303 | } else {
304 | return value.length <= 16;
305 | }
306 | };
307 |
308 | restrictExpiry = function(e) {
309 | var $target, digit, value;
310 | $target = $(e.currentTarget);
311 | digit = String.fromCharCode(e.which);
312 | if (!/^\d+$/.test(digit)) {
313 | return;
314 | }
315 | if (hasTextSelected($target)) {
316 | return;
317 | }
318 | value = $target.val() + digit;
319 | value = value.replace(/\D/g, '');
320 | if (value.length > 6) {
321 | return false;
322 | }
323 | };
324 |
325 | restrictCVC = function(e) {
326 | var $target, digit, val;
327 | $target = $(e.currentTarget);
328 | digit = String.fromCharCode(e.which);
329 | if (!/^\d+$/.test(digit)) {
330 | return;
331 | }
332 | val = $target.val() + digit;
333 | return val.length <= 4;
334 | };
335 |
336 | setCardType = function(e) {
337 | var $target, allTypes, card, cardType, val;
338 | $target = $(e.currentTarget);
339 | val = $target.val();
340 | cardType = $.payment.cardType(val) || 'unknown';
341 | if (!$target.hasClass(cardType)) {
342 | allTypes = (function() {
343 | var _i, _len, _results;
344 | _results = [];
345 | for (_i = 0, _len = cards.length; _i < _len; _i++) {
346 | card = cards[_i];
347 | _results.push(card.type);
348 | }
349 | return _results;
350 | })();
351 | $target.removeClass('unknown');
352 | $target.removeClass(allTypes.join(' '));
353 | $target.addClass(cardType);
354 | $target.toggleClass('identified', cardType !== 'unknown');
355 | return $target.trigger('payment.cardType', cardType);
356 | }
357 | };
358 |
359 | $.payment.fn.formatCardCVC = function() {
360 | this.payment('restrictNumeric');
361 | this.on('keypress', restrictCVC);
362 | return this;
363 | };
364 |
365 | $.payment.fn.formatCardExpiry = function() {
366 | this.payment('restrictNumeric');
367 | this.on('keypress', restrictExpiry);
368 | this.on('keypress', formatExpiry);
369 | this.on('keypress', formatForwardSlash);
370 | this.on('keypress', formatForwardExpiry);
371 | this.on('keydown', formatBackExpiry);
372 | return this;
373 | };
374 |
375 | $.payment.fn.formatCardNumber = function() {
376 | this.payment('restrictNumeric');
377 | this.on('keypress', restrictCardNumber);
378 | this.on('keypress', formatCardNumber);
379 | this.on('keydown', formatBackCardNumber);
380 | this.on('keyup', setCardType);
381 | this.on('paste', reFormatCardNumber);
382 | return this;
383 | };
384 |
385 | $.payment.fn.restrictNumeric = function() {
386 | this.on('keypress', restrictNumeric);
387 | return this;
388 | };
389 |
390 | $.payment.fn.cardExpiryVal = function() {
391 | return $.payment.cardExpiryVal($(this).val());
392 | };
393 |
394 | $.payment.cardExpiryVal = function(value) {
395 | var month, prefix, year, _ref;
396 | value = value.replace(/\s/g, '');
397 | _ref = value.split('/', 2), month = _ref[0], year = _ref[1];
398 | if ((year != null ? year.length : void 0) === 2 && /^\d+$/.test(year)) {
399 | prefix = (new Date).getFullYear();
400 | prefix = prefix.toString().slice(0, 2);
401 | year = prefix + year;
402 | }
403 | month = parseInt(month, 10);
404 | year = parseInt(year, 10);
405 | return {
406 | month: month,
407 | year: year
408 | };
409 | };
410 |
411 | $.payment.validateCardNumber = function(num) {
412 | var card, _ref;
413 | num = (num + '').replace(/\s+|-/g, '');
414 | if (!/^\d+$/.test(num)) {
415 | return false;
416 | }
417 | card = cardFromNumber(num);
418 | if (!card) {
419 | return false;
420 | }
421 | return (_ref = num.length, __indexOf.call(card.length, _ref) >= 0) && (card.luhn === false || luhnCheck(num));
422 | };
423 |
424 | $.payment.validateCardExpiry = function(month, year) {
425 | var currentTime, expiry, prefix, _ref;
426 | if (typeof month === 'object' && 'month' in month) {
427 | _ref = month, month = _ref.month, year = _ref.year;
428 | }
429 | if (!(month && year)) {
430 | return false;
431 | }
432 | month = $.trim(month);
433 | year = $.trim(year);
434 | if (!/^\d+$/.test(month)) {
435 | return false;
436 | }
437 | if (!/^\d+$/.test(year)) {
438 | return false;
439 | }
440 | if (!(parseInt(month, 10) <= 12)) {
441 | return false;
442 | }
443 | if (year.length === 2) {
444 | prefix = (new Date).getFullYear();
445 | prefix = prefix.toString().slice(0, 2);
446 | year = prefix + year;
447 | }
448 | expiry = new Date(year, month);
449 | currentTime = new Date;
450 | expiry.setMonth(expiry.getMonth() - 1);
451 | expiry.setMonth(expiry.getMonth() + 1, 1);
452 | return expiry > currentTime;
453 | };
454 |
455 | $.payment.validateCardCVC = function(cvc, type) {
456 | var _ref, _ref1;
457 | cvc = $.trim(cvc);
458 | if (!/^\d+$/.test(cvc)) {
459 | return false;
460 | }
461 | if (type) {
462 | return _ref = cvc.length, __indexOf.call((_ref1 = cardFromType(type)) != null ? _ref1.cvcLength : void 0, _ref) >= 0;
463 | } else {
464 | return cvc.length >= 3 && cvc.length <= 4;
465 | }
466 | };
467 |
468 | $.payment.cardType = function(num) {
469 | var _ref;
470 | if (!num) {
471 | return null;
472 | }
473 | return ((_ref = cardFromNumber(num)) != null ? _ref.type : void 0) || null;
474 | };
475 |
476 | $.payment.formatCardNumber = function(num) {
477 | var card, groups, upperLength, _ref;
478 | card = cardFromNumber(num);
479 | if (!card) {
480 | return num;
481 | }
482 | upperLength = card.length[card.length.length - 1];
483 | num = num.replace(/\D/g, '');
484 | num = num.slice(0, +upperLength + 1 || 9e9);
485 | if (card.format.global) {
486 | return (_ref = num.match(card.format)) != null ? _ref.join(' ') : void 0;
487 | } else {
488 | groups = card.format.exec(num);
489 | if (groups != null) {
490 | groups.shift();
491 | }
492 | return groups != null ? groups.join(' ') : void 0;
493 | }
494 | };
495 |
496 | }).call(this);
497 |
--------------------------------------------------------------------------------
/license.txt:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 2, June 1991
3 |
4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc.
5 | 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
6 |
7 | Everyone is permitted to copy and distribute verbatim copies
8 | of this license document, but changing it is not allowed.
9 |
10 | Preamble
11 |
12 | The licenses for most software are designed to take away your
13 | freedom to share and change it. By contrast, the GNU General Public
14 | License is intended to guarantee your freedom to share and change free
15 | software--to make sure the software is free for all its users. This
16 | General Public License applies to most of the Free Software
17 | Foundation's software and to any other program whose authors commit to
18 | using it. (Some other Free Software Foundation software is covered by
19 | the GNU Library General Public License instead.) You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | this service if you wish), that you receive source code or can get it
26 | if you want it, that you can change the software or use pieces of it
27 | in new free programs; and that you know you can do these things.
28 |
29 | To protect your rights, we need to make restrictions that forbid
30 | anyone to deny you these rights or to ask you to surrender the rights.
31 | These restrictions translate to certain responsibilities for you if you
32 | distribute copies of the software, or if you modify it.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must give the recipients all the rights that
36 | you have. You must make sure that they, too, receive or can get the
37 | source code. And you must show them these terms so they know their
38 | rights.
39 |
40 | We protect your rights with two steps: (1) copyright the software, and
41 | (2) offer you this license which gives you legal permission to copy,
42 | distribute and/or modify the software.
43 |
44 | Also, for each author's protection and ours, we want to make certain
45 | that everyone understands that there is no warranty for this free
46 | software. If the software is modified by someone else and passed on, we
47 | want its recipients to know that what they have is not the original, so
48 | that any problems introduced by others will not reflect on the original
49 | authors' reputations.
50 |
51 | Finally, any free program is threatened constantly by software
52 | patents. We wish to avoid the danger that redistributors of a free
53 | program will individually obtain patent licenses, in effect making the
54 | program proprietary. To prevent this, we have made it clear that any
55 | patent must be licensed for everyone's free use or not licensed at all.
56 |
57 | The precise terms and conditions for copying, distribution and
58 | modification follow.
59 |
60 | GNU GENERAL PUBLIC LICENSE
61 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
62 |
63 | 0. This License applies to any program or other work which contains
64 | a notice placed by the copyright holder saying it may be distributed
65 | under the terms of this General Public License. The "Program", below,
66 | refers to any such program or work, and a "work based on the Program"
67 | means either the Program or any derivative work under copyright law:
68 | that is to say, a work containing the Program or a portion of it,
69 | either verbatim or with modifications and/or translated into another
70 | language. (Hereinafter, translation is included without limitation in
71 | the term "modification".) Each licensee is addressed as "you".
72 |
73 | Activities other than copying, distribution and modification are not
74 | covered by this License; they are outside its scope. The act of
75 | running the Program is not restricted, and the output from the Program
76 | is covered only if its contents constitute a work based on the
77 | Program (independent of having been made by running the Program).
78 | Whether that is true depends on what the Program does.
79 |
80 | 1. You may copy and distribute verbatim copies of the Program's
81 | source code as you receive it, in any medium, provided that you
82 | conspicuously and appropriately publish on each copy an appropriate
83 | copyright notice and disclaimer of warranty; keep intact all the
84 | notices that refer to this License and to the absence of any warranty;
85 | and give any other recipients of the Program a copy of this License
86 | along with the Program.
87 |
88 | You may charge a fee for the physical act of transferring a copy, and
89 | you may at your option offer warranty protection in exchange for a fee.
90 |
91 | 2. You may modify your copy or copies of the Program or any portion
92 | of it, thus forming a work based on the Program, and copy and
93 | distribute such modifications or work under the terms of Section 1
94 | above, provided that you also meet all of these conditions:
95 |
96 | a) You must cause the modified files to carry prominent notices
97 | stating that you changed the files and the date of any change.
98 |
99 | b) You must cause any work that you distribute or publish, that in
100 | whole or in part contains or is derived from the Program or any
101 | part thereof, to be licensed as a whole at no charge to all third
102 | parties under the terms of this License.
103 |
104 | c) If the modified program normally reads commands interactively
105 | when run, you must cause it, when started running for such
106 | interactive use in the most ordinary way, to print or display an
107 | announcement including an appropriate copyright notice and a
108 | notice that there is no warranty (or else, saying that you provide
109 | a warranty) and that users may redistribute the program under
110 | these conditions, and telling the user how to view a copy of this
111 | License. (Exception: if the Program itself is interactive but
112 | does not normally print such an announcement, your work based on
113 | the Program is not required to print an announcement.)
114 |
115 | These requirements apply to the modified work as a whole. If
116 | identifiable sections of that work are not derived from the Program,
117 | and can be reasonably considered independent and separate works in
118 | themselves, then this License, and its terms, do not apply to those
119 | sections when you distribute them as separate works. But when you
120 | distribute the same sections as part of a whole which is a work based
121 | on the Program, the distribution of the whole must be on the terms of
122 | this License, whose permissions for other licensees extend to the
123 | entire whole, and thus to each and every part regardless of who wrote it.
124 | Thus, it is not the intent of this section to claim rights or contest
125 | your rights to work written entirely by you; rather, the intent is to
126 | exercise the right to control the distribution of derivative or
127 | collective works based on the Program.
128 |
129 | In addition, mere aggregation of another work not based on the Program
130 | with the Program (or with a work based on the Program) on a volume of
131 | a storage or distribution medium does not bring the other work under
132 | the scope of this License.
133 |
134 | 3. You may copy and distribute the Program (or a work based on it,
135 | under Section 2) in object code or executable form under the terms of
136 | Sections 1 and 2 above provided that you also do one of the following:
137 |
138 | a) Accompany it with the complete corresponding machine-readable
139 | source code, which must be distributed under the terms of Sections
140 | 1 and 2 above on a medium customarily used for software interchange; or,
141 |
142 | b) Accompany it with a written offer, valid for at least three
143 | years, to give any third party, for a charge no more than your
144 | cost of physically performing source distribution, a complete
145 | machine-readable copy of the corresponding source code, to be
146 | distributed under the terms of Sections 1 and 2 above on a medium
147 | customarily used for software interchange; or,
148 |
149 | c) Accompany it with the information you received as to the offer
150 | to distribute corresponding source code. (This alternative is
151 | allowed only for noncommercial distribution and only if you
152 | received the program in object code or executable form with such
153 | an offer, in accord with Subsection b above.)
154 |
155 | The source code for a work means the preferred form of the work for
156 | making modifications to it. For an executable work, complete source
157 | code means all the source code for all modules it contains, plus any
158 | associated interface definition files, plus the scripts used to
159 | control compilation and installation of the executable. However, as a
160 | special exception, the source code distributed need not include
161 | anything that is normally distributed (in either source or binary
162 | form) with the major components (compiler, kernel, and so on) of the
163 | operating system on which the executable runs, unless that component
164 | itself accompanies the executable.
165 |
166 | If distribution of executable or object code is made by offering
167 | access to copy from a designated place, then offering equivalent
168 | access to copy the source code from the same place counts as
169 | distribution of the source code, even though third parties are not
170 | compelled to copy the source along with the object code.
171 |
172 | 4. You may not copy, modify, sublicense, or distribute the Program
173 | except as expressly provided under this License. Any attempt
174 | otherwise to copy, modify, sublicense or distribute the Program is
175 | void, and will automatically terminate your rights under this License.
176 | However, parties who have received copies, or rights, from you under
177 | this License will not have their licenses terminated so long as such
178 | parties remain in full compliance.
179 |
180 | 5. You are not required to accept this License, since you have not
181 | signed it. However, nothing else grants you permission to modify or
182 | distribute the Program or its derivative works. These actions are
183 | prohibited by law if you do not accept this License. Therefore, by
184 | modifying or distributing the Program (or any work based on the
185 | Program), you indicate your acceptance of this License to do so, and
186 | all its terms and conditions for copying, distributing or modifying
187 | the Program or works based on it.
188 |
189 | 6. Each time you redistribute the Program (or any work based on the
190 | Program), the recipient automatically receives a license from the
191 | original licensor to copy, distribute or modify the Program subject to
192 | these terms and conditions. You may not impose any further
193 | restrictions on the recipients' exercise of the rights granted herein.
194 | You are not responsible for enforcing compliance by third parties to
195 | this License.
196 |
197 | 7. If, as a consequence of a court judgment or allegation of patent
198 | infringement or for any other reason (not limited to patent issues),
199 | conditions are imposed on you (whether by court order, agreement or
200 | otherwise) that contradict the conditions of this License, they do not
201 | excuse you from the conditions of this License. If you cannot
202 | distribute so as to satisfy simultaneously your obligations under this
203 | License and any other pertinent obligations, then as a consequence you
204 | may not distribute the Program at all. For example, if a patent
205 | license would not permit royalty-free redistribution of the Program by
206 | all those who receive copies directly or indirectly through you, then
207 | the only way you could satisfy both it and this License would be to
208 | refrain entirely from distribution of the Program.
209 |
210 | If any portion of this section is held invalid or unenforceable under
211 | any particular circumstance, the balance of the section is intended to
212 | apply and the section as a whole is intended to apply in other
213 | circumstances.
214 |
215 | It is not the purpose of this section to induce you to infringe any
216 | patents or other property right claims or to contest validity of any
217 | such claims; this section has the sole purpose of protecting the
218 | integrity of the free software distribution system, which is
219 | implemented by public license practices. Many people have made
220 | generous contributions to the wide range of software distributed
221 | through that system in reliance on consistent application of that
222 | system; it is up to the author/donor to decide if he or she is willing
223 | to distribute software through any other system and a licensee cannot
224 | impose that choice.
225 |
226 | This section is intended to make thoroughly clear what is believed to
227 | be a consequence of the rest of this License.
228 |
229 | 8. If the distribution and/or use of the Program is restricted in
230 | certain countries either by patents or by copyrighted interfaces, the
231 | original copyright holder who places the Program under this License
232 | may add an explicit geographical distribution limitation excluding
233 | those countries, so that distribution is permitted only in or among
234 | countries not thus excluded. In such case, this License incorporates
235 | the limitation as if written in the body of this License.
236 |
237 | 9. The Free Software Foundation may publish revised and/or new versions
238 | of the General Public License from time to time. Such new versions will
239 | be similar in spirit to the present version, but may differ in detail to
240 | address new problems or concerns.
241 |
242 | Each version is given a distinguishing version number. If the Program
243 | specifies a version number of this License which applies to it and "any
244 | later version", you have the option of following the terms and conditions
245 | either of that version or of any later version published by the Free
246 | Software Foundation. If the Program does not specify a version number of
247 | this License, you may choose any version ever published by the Free Software
248 | Foundation.
249 |
250 | 10. If you wish to incorporate parts of the Program into other free
251 | programs whose distribution conditions are different, write to the author
252 | to ask for permission. For software which is copyrighted by the Free
253 | Software Foundation, write to the Free Software Foundation; we sometimes
254 | make exceptions for this. Our decision will be guided by the two goals
255 | of preserving the free status of all derivatives of our free software and
256 | of promoting the sharing and reuse of software generally.
257 |
258 | NO WARRANTY
259 |
260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268 | REPAIR OR CORRECTION.
269 |
270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278 | POSSIBILITY OF SUCH DAMAGES.
279 |
280 | END OF TERMS AND CONDITIONS
281 |
--------------------------------------------------------------------------------