├── README.md
├── changelog.txt
├── classes
├── Domainmap
│ ├── Module.php
│ ├── Module
│ │ ├── Admin.php
│ │ ├── Ajax.php
│ │ ├── Ajax
│ │ │ ├── Map.php
│ │ │ ├── Purchase.php
│ │ │ └── Register.php
│ │ ├── Cdsso.php
│ │ ├── Mapping.php
│ │ ├── Pages.php
│ │ ├── Setup.php
│ │ └── System.php
│ ├── Plugin.php
│ ├── Punycode.php
│ ├── Render.php
│ ├── Render
│ │ ├── Network.php
│ │ ├── Network
│ │ │ ├── Log.php
│ │ │ ├── MappedDomains.php
│ │ │ ├── Options.php
│ │ │ └── Resellers.php
│ │ ├── Reseller
│ │ │ ├── Enom
│ │ │ │ ├── Purchase.php
│ │ │ │ ├── Register.php
│ │ │ │ └── Settings.php
│ │ │ └── Iframe.php
│ │ ├── Site.php
│ │ ├── Site
│ │ │ ├── Map.php
│ │ │ └── Purchase.php
│ │ └── Tabbed.php
│ ├── Reseller.php
│ ├── Reseller
│ │ └── Enom.php
│ ├── Table.php
│ ├── Table
│ │ ├── ExcludedPages
│ │ │ └── Listing.php
│ │ ├── MappedDomains
│ │ │ └── Listing.php
│ │ └── Reseller
│ │ │ └── Log.php
│ └── Utils.php
├── Vendor
│ ├── CHttpRequest.php
│ └── Punycode.php
└── class.domainmap.php
├── css
├── admin.css
└── bootstrap-glyphs.min.css
├── domain-mapping.php
├── humans.txt
├── images
├── ajax-loader-big.gif
├── ajax-loader-small.gif
├── enom.png
├── glyphicons-halflings-white.png
├── glyphicons-halflings.png
└── texture.png
├── inc
├── DM_Currencies.php
└── sunrise.php
├── js
├── admin.js
└── jquery.payment.js
├── languages
├── domainmap-en_US.mo
└── domainmap-en_US.po
├── license.txt
└── sunrise.php
/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 |
--------------------------------------------------------------------------------
/classes/Domainmap/Module.php:
--------------------------------------------------------------------------------
1 | _wpdb = $wpdb;
74 | $this->_plugin = $plugin;
75 | $this->_http = new CHttpRequest();
76 | $this->_http->init();
77 |
78 | $this->_add_action("domainmapping_delete_mapped_domain", "delete_mapped_domain");
79 | }
80 |
81 | /**
82 | * Registers an action hook.
83 | *
84 | * @since 4.0.0
85 | * @uses add_action() To register action hook.
86 | *
87 | * @access protected
88 | * @param string $tag The name of the action to which the $method is hooked.
89 | * @param string $method The name of the method to be called.
90 | * @param int $priority optional. Used to specify the order in which the functions associated with a particular action are executed (default: 10). Lower numbers correspond with earlier execution, and functions with the same priority are executed in the order in which they were added to the action.
91 | * @param int $accepted_args optional. The number of arguments the function accept (default 1).
92 | * @return Domainmap_Module
93 | */
94 | protected function _add_action( $tag, $method = '', $priority = 10, $accepted_args = 1 ) {
95 | add_action( $tag, array( $this, empty( $method ) ? $tag : $method ), $priority, $accepted_args );
96 | return $this;
97 | }
98 |
99 | /**
100 | * Registers AJAX action hook.
101 | *
102 | * @since 4.0.0
103 | *
104 | * @access public
105 | * @param string $tag The name of the AJAX action to which the $method is hooked.
106 | * @param string $method Optional. The name of the method to be called. If the name of the method is not provided, tag name will be used as method name.
107 | * @param boolean $private Optional. Determines if we should register hook for logged in users.
108 | * @param boolean $public Optional. Determines if we should register hook for not logged in users.
109 | * @return Domainmap_Module
110 | */
111 | protected function _add_ajax_action( $tag, $method = '', $private = true, $public = false ) {
112 | if ( $private ) {
113 | $this->_add_action( 'wp_ajax_' . $tag, $method );
114 | }
115 |
116 | if ( $public ) {
117 | $this->_add_action( 'wp_ajax_nopriv_' . $tag, $method );
118 | }
119 |
120 | return $this;
121 | }
122 |
123 | /**
124 | * Registers a filter hook.
125 | *
126 | * @since 4.0.0
127 | * @uses add_filter() To register filter hook.
128 | *
129 | * @access protected
130 | * @param string $tag The name of the filter to hook the $method to.
131 | * @param type $method The name of the method to be called when the filter is applied.
132 | * @param int $priority optional. Used to specify the order in which the functions associated with a particular action are executed (default: 10). Lower numbers correspond with earlier execution, and functions with the same priority are executed in the order in which they were added to the action.
133 | * @param int $accepted_args optional. The number of arguments the function accept (default 1).
134 | * @return Domainmap_Module
135 | */
136 | protected function _add_filter( $tag, $method = '', $priority = 10, $accepted_args = 1 ) {
137 | add_filter( $tag, array( $this, empty( $method ) ? $tag : $method ), $priority, $accepted_args );
138 | return $this;
139 | }
140 |
141 | /**
142 | * Registers a hook for shortcode tag.
143 | *
144 | * @since 4.0.0
145 | * @uses add_shortcode() To register shortcode hook.
146 | *
147 | * @access protected
148 | * @param string $tag Shortcode tag to be searched in post content.
149 | * @param string $method Hook to run when shortcode is found.
150 | * @return Domainmap_Module
151 | */
152 | protected function _add_shortcode( $tag, $method ) {
153 | add_shortcode( $tag, array( $this, $method ) );
154 | return $this;
155 | }
156 |
157 |
158 |
159 | /**
160 | * Validates health status of a domain.
161 | *
162 | * @since 4.0.0
163 | *
164 | * @access private
165 | * @param string $domain The domain name to validate.
166 | * @return boolean TRUE if the domain name works, otherwise FALSE.
167 | */
168 | protected function _validate_health_status( $domain ) {
169 | $check = sha1( time() );
170 |
171 | switch_to_blog( 1 );
172 | $scheme = self::utils()->get_mapped_domain_scheme( $domain );
173 | $ajax_url = $scheme ? set_url_scheme( admin_url( 'admin-ajax.php' ), $scheme ) : set_url_scheme( admin_url( 'admin-ajax.php' ), "http" );
174 | $ajax_url = str_replace( parse_url( $ajax_url, PHP_URL_HOST ), $domain, $ajax_url );
175 | restore_current_blog();
176 | $response = wp_remote_request( esc_url_raw( add_query_arg( array(
177 | 'action' => Domainmap_Plugin::ACTION_HEARTBEAT_CHECK,
178 | 'check' => $check,
179 | ), $ajax_url )), array( 'sslverify' => false ) );
180 |
181 | $status = !is_wp_error( $response ) && wp_remote_retrieve_response_code( $response ) == 200 && preg_replace('/\W*/', '', wp_remote_retrieve_body( $response ) ) == $check ? 1 : 0;
182 | $this->set_valid_transient( $domain, $status );
183 | return $status;
184 | }
185 |
186 |
187 | /**
188 | * Checks if server supports ssl
189 | *
190 | * @since 4.2.0.4
191 | * @return bool
192 | */
193 | protected function server_supports_ssl(){
194 | $request = wp_remote_head( $this->_http->getHostInfo("https") );
195 |
196 | if( is_wp_error( $request ) ){
197 | if( isset( $request->errors['http_request_failed'] ) && isset( $request->errors['http_request_failed'][0] ) && ( strpos($request->errors['http_request_failed'][0], "SSL") !== false || strpos($request->errors['http_request_failed'][0], "ssl") !== false) )
198 | return true;
199 |
200 | return false;
201 | }else{
202 | return true;
203 | }
204 |
205 | }
206 |
207 | /**
208 | * Returns ajax url based on the main domain
209 | *
210 | * @since 4.2.0.4
211 | * @param string $scheme The scheme to use. Default is 'admin', which obeys force_ssl_admin() and is_ssl(). 'http' or 'https' can be passed to force those schemes.
212 | * @return mixed
213 | */
214 | protected function get_main_ajax_url( $scheme = 'admin' ){
215 | return $this->_replace_last_occurrence('network/', '', network_admin_url( 'admin-ajax.php', $scheme ) );
216 | }
217 |
218 | /**
219 | * Replaces last occurence of string with $replace string
220 | *
221 | * @since 4.2.0.5
222 | *
223 | * @param $search
224 | * @param $replace
225 | * @param $string
226 | *
227 | * @return mixed
228 | */
229 | private function _replace_last_occurrence($search, $replace, $string)
230 | {
231 | $pos = strrpos($string, $search);
232 |
233 | if($pos !== false)
234 | $string = substr_replace($string, $replace, $pos, strlen($search));
235 |
236 | return $string;
237 | }
238 |
239 |
240 | /**
241 | * Checks to see if domain is valid, then sets appropriate transient and returns validity boolean
242 | *
243 | * @since 4.3.0
244 | * @param $domain
245 | * @param $status bool to set as domain's health status
246 | *
247 | * @return bool
248 | */
249 | protected function set_valid_transient( $domain, $status = null ) {
250 | $valid = $status;
251 | if( is_null( $status ) ) {
252 | $valid = $this->_validate_health_status( $domain );
253 | }
254 | set_site_transient( "domainmapping-{$domain}-health", $valid, $valid ? 4 * WEEK_IN_SECONDS : 10 * MINUTE_IN_SECONDS );
255 |
256 | return $valid;
257 | }
258 |
259 |
260 | /**
261 | * Deletes a map domain
262 | *
263 | * @param $domain
264 | * @return bool
265 | */
266 | public function delete_mapped_domain($domain ){
267 | $result = (bool) $this->_wpdb->delete( DOMAINMAP_TABLE_MAP, array( 'domain' => $domain ), array( '%s' ) );
268 | delete_transient( "domainmapping-{$domain}-health" );
269 | return $result;
270 | }
271 | }
--------------------------------------------------------------------------------
/classes/Domainmap/Module/Admin.php:
--------------------------------------------------------------------------------
1 | _add_action( 'manage_sites_custom_column', 'render_mapped_domain_column', 1, 2 );
55 | $this->_add_action( 'delete_blog', 'delete_blog_mappings', 1, 2 );
56 | $this->_add_action( 'domainmapping_delete_blog_mappings', 'delete_blog_mappings', 1, 2 );
57 |
58 | $this->_add_filter( 'wpmu_blogs_columns', 'register_mapped_domain_column' );
59 | }
60 |
61 | /**
62 | * Registers "Mapped Domain" column for network sites table.
63 | *
64 | * @since 4.0.0
65 | * @filter wpmu_blogs_columns
66 | *
67 | * @access public
68 | * @param array $columns The array of already registered columns.
69 | * @return array Modified array of columns.
70 | */
71 | public function register_mapped_domain_column( $columns ) {
72 | return array_merge (
73 | array_splice( $columns, 0, 2 ),
74 | array( 'domainmap' => __( 'Mapped Domain', 'domainmap' ) ),
75 | $columns
76 | );
77 | }
78 |
79 | /**
80 | * Renders "Mapped Domain" column data.
81 | *
82 | * @since 4.0.0
83 | * @action manage_sites_custom_column
84 | *
85 | * @access public
86 | * @global stdClass $current_site The current site object.
87 | * @param string $column The column name to render.
88 | * @param int $blog_id The blog ID for which to render column data.
89 | */
90 | public function render_mapped_domain_column( $column, $blog_id ) {
91 | global $current_site;
92 |
93 | if ( $column != 'domainmap' ) {
94 | return;
95 | }
96 |
97 | // fetch mapped domains, if they haven't been fetched yet
98 | if ( is_null( $this->_mapped_domains ) ) {
99 | $this->_mapped_domains = array();
100 | $suffix = $current_site->path != '/' ? $current_site->path : '';
101 | $results = $this->_wpdb->get_results( "SELECT blog_id, domain, scheme FROM " . DOMAINMAP_TABLE_MAP );
102 | foreach ( $results as $result ) {
103 | if ( !isset( $this->_mapped_domains[$result->blog_id] ) ) {
104 | $this->_mapped_domains[$result->blog_id] = array();
105 | }
106 | $scheme = ($result->scheme == 1) ? 'https' : 'http';
107 | $this->_mapped_domains[$result->blog_id][] = sprintf( '%1$s%2$s ', Domainmap_Punycode::decode( $result->domain ), $suffix, $scheme );
108 | }
109 | }
110 |
111 | // render mapped domains
112 | if ( isset( $this->_mapped_domains[$blog_id] ) ) {
113 | echo implode( ' ', $this->_mapped_domains[$blog_id] );
114 | }
115 | }
116 |
117 | /**
118 | * Deletes mapped domains for removed blog.
119 | *
120 | * @since 4.0.0
121 | * @action delete_blog
122 | *
123 | * @access public
124 | * @param int $blog_id The blog id, which is going to be removed.
125 | * @param boolean $drop Determines whether the blog has to be deleted permanently (db tables will be removed).
126 | */
127 | public function delete_blog_mappings( $blog_id, $drop ) {
128 | if ( $blog_id && $drop ) {
129 | $this->_wpdb->delete( DOMAINMAP_TABLE_MAP, array( 'blog_id' => $blog_id ), array( '%d' ) );
130 | }
131 | }
132 |
133 | }
--------------------------------------------------------------------------------
/classes/Domainmap/Module/Ajax.php:
--------------------------------------------------------------------------------
1 | _plugin->get_option("map_verifydomain");
47 | if( !$map_verifydomain ) $is_valid = true;
48 |
49 | $is_valid = $this->_plugin->is_prohibited_domain( $domain ) ? 0 : true;
50 |
51 | if( $this->_plugin->get_option("map_disallow_subdomain") && $is_valid ){
52 | $is_valid = $is_valid && strpos( $domain, "." . $this->utils()->get_original_domain() ) === false;
53 | }
54 |
55 | if( !$is_valid ){
56 | return apply_filters('dm_validate_domain_name', $is_valid, $domain, $mapping);
57 | }
58 |
59 | $domain = Domainmap_Punycode::encode($domain);
60 |
61 | /**
62 | * If it's a mapping, check if mapped domain is similar to original domain or www.originaldomain
63 | */
64 |
65 | if( $mapping && in_array( $domain, array( $this->utils()->get_original_domain(), $this->utils()->get_original_domain( true ) ) ) ) $is_valid = false;
66 | $is_valid = preg_match( "/^([A-Za-z0-9](-*[A-Za-z0-9])*)(\.([a-z\d](-*[a-z\d])*))*$/i", $domain ) //valid chars check
67 | && preg_match( "/^.{1,253}$/", $domain ) //overall length check
68 | && preg_match( "/^[^\.]{1,63}(\.[^\.]{2,63})+$/", $domain ) //length of each label
69 | ;
70 |
71 | return apply_filters('dm_validate_domain_name', $is_valid, $domain, $mapping);
72 | }
73 |
74 | /**
75 | * Checks user permissions and block AJAX request if they don't match.
76 | *
77 | * @since 4.0.0
78 | * @uses status_header() To set response HTTP code.
79 | * @uses check_admin_referer() To avoid security exploits.
80 | * @uses current_user_can() To check user permissions.
81 | *
82 | * @static
83 | * @access protected
84 | * @param string $ajax_action Current action name.
85 | * @param string $credentials The capabilities, which an user has to have.
86 | */
87 | protected static function _check_premissions( $ajax_action, $credentials = 'manage_options' ) {
88 | // check if request has been made via jQuery
89 | if ( empty( $_SERVER['HTTP_X_REQUESTED_WITH'] ) || strtolower( $_SERVER['HTTP_X_REQUESTED_WITH'] ) != 'xmlhttprequest' ) {
90 | status_header( 404 );
91 | exit;
92 | }
93 |
94 | // check if user has permissions
95 | if ( !check_admin_referer( $ajax_action, 'nonce' ) || !current_user_can( $credentials ) ) {
96 | status_header( 403 );
97 | exit;
98 | }
99 | }
100 |
101 | /**
102 | * Redirects user to login form if he is not logged in.
103 | *
104 | * @since 4.1.0
105 | *
106 | * @access public
107 | */
108 | public function redirect_to_login_form() {
109 |
110 | wp_redirect( wp_login_url( esc_url_raw( add_query_arg() ) ) );
111 | exit;
112 | }
113 |
114 |
115 |
116 | }
--------------------------------------------------------------------------------
/classes/Domainmap/Module/Ajax/Purchase.php:
--------------------------------------------------------------------------------
1 | _add_ajax_action( Domainmap_Plugin::ACTION_CHECK_DOMAIN_AVAILABILITY, 'check_domain' );
47 | $this->_add_ajax_action( Domainmap_Plugin::ACTION_PAYPAL_PURCHASE, 'purchase_with_paypal' );
48 | $this->_add_ajax_action( Domainmap_Plugin::ACTION_PAYPAL_DO_EXPRESS_CHECKOUT, 'complete_paypal_checkout' );
49 |
50 | $this->_add_ajax_action( Domainmap_Plugin::ACTION_SHOW_PURCHASE_FORM, 'render_purchase_form' );
51 | $this->_add_ajax_action( Domainmap_Plugin::ACTION_SHOW_PURCHASE_FORM, 'redirect_to_login_form', false, true );
52 | }
53 |
54 | /**
55 | * Builds and returns user based transient name.
56 | *
57 | * @since 4.0.0
58 | *
59 | * @access private
60 | * @param string $transient Transient name.
61 | * @return string User based transient name.
62 | */
63 | private function _get_transient_name( $transient ) {
64 | return sprintf( 'domainmap-%s-%s', get_current_user_id(), $transient );
65 | }
66 |
67 | /**
68 | * Checks the domain availability and returns it's price.
69 | *
70 | * @since 4.0.0
71 | *
72 | * @access public
73 | */
74 | public function check_domain() {
75 | self::_check_premissions( Domainmap_Plugin::ACTION_CHECK_DOMAIN_AVAILABILITY );
76 |
77 | $sld = strtolower( trim( filter_input( INPUT_POST, 'sld' ) ) );
78 | $tld = strtolower( trim( filter_input( INPUT_POST, 'tld' ) ) );
79 |
80 | $message = false;
81 | $domain = "{$sld}.{$tld}";
82 | $is_valid = $this->_validate_domain_name( $domain );
83 | if ( $is_valid ) {
84 | $reseller = $this->_plugin->get_reseller();
85 | $price = false;
86 | $available = $reseller->check_domain( $tld, $sld );
87 | if ( $available ) {
88 | $price = '$' . number_format( floatval( $reseller->get_tld_price( $tld) ), 2 );
89 | }
90 |
91 | set_site_transient( $this->_get_transient_name( 'checkdomain' ), array(
92 | 'domain' => $domain,
93 | 'price' => $price,
94 | 'sld' => $sld,
95 | 'tld' => $tld
96 | ), HOUR_IN_SECONDS );
97 |
98 | wp_send_json_success( array(
99 | 'available' => $available,
100 | 'html' => $available
101 | ? $reseller->get_domain_available_response( $sld, $tld )
102 | : sprintf( '
%s %s.
', $domain, __( 'is not available to purchase', 'domainmap' ) ),
103 | ) );
104 | } else {
105 | if( $is_valid === false ){
106 | $message = __( 'Domain name is invalid.', 'domainmap' );
107 | }else{
108 | $message = __( 'Domain name is prohibited.', 'domainmap' );
109 | }
110 | }
111 |
112 | wp_send_json_error( array( 'message' => $message ) );
113 | }
114 |
115 | /**
116 | * Checks SSL connection and user permissions before render or process
117 | * purchase form.
118 | *
119 | * @since 4.1.0
120 | *
121 | * @access private
122 | */
123 | private function _check_ssl_and_security() {
124 | // check if ssl connection is not used
125 | if ( !is_ssl() ) {
126 | // ssl connection is not used, so if you logged in then redirect him
127 | // to https page, otherwise redirect him to login page
128 | $user_id = get_current_user_id();
129 | if ( $user_id ) {
130 | // propagate SSL auth cookie
131 | wp_set_auth_cookie( $user_id, true, true );
132 |
133 | // redirect to https version of this page
134 | wp_redirect( esc_url_raw( add_query_arg( array_map( 'urlencode', $_GET ), admin_url( 'admin-ajax.php', 'https' ) ) ) );
135 | exit;
136 | } else {
137 | // redirect to login form
138 | $this->redirect_to_login_form();
139 | }
140 | }
141 |
142 | // check if user has permissions
143 | if ( !check_admin_referer( Domainmap_Plugin::ACTION_SHOW_PURCHASE_FORM, 'nonce' ) || !current_user_can( 'manage_options' ) ) {
144 | status_header( 403 );
145 | exit;
146 | }
147 | }
148 |
149 | /**
150 | * Renders purchase form.
151 | *
152 | * @since 4.0.0
153 | *
154 | * @access public
155 | */
156 | public function render_purchase_form() {
157 | $this->_check_ssl_and_security();
158 | $reseller = $this->_plugin->get_reseller();
159 | $info = get_site_transient( $this->_get_transient_name( 'checkdomain' ) );
160 | if ( !$info || !$reseller ) {
161 | status_header( 404 );
162 | exit;
163 | }
164 |
165 | if ( $_SERVER['REQUEST_METHOD'] == 'POST' ) {
166 | $domain = $reseller->purchase();
167 | if ( $domain ) {
168 | $this->_map_domain( $domain, filter_input( INPUT_GET, 'blog', FILTER_VALIDATE_INT ) );
169 | wp_redirect( filter_input( INPUT_GET, 'success', FILTER_VALIDATE_URL, array( 'options' => array( 'default' => admin_url() ) ) ) );
170 | exit;
171 | }
172 | }
173 |
174 | define( 'IFRAME_REQUEST', true );
175 |
176 | // enqueue scripts
177 | wp_enqueue_script( 'jquery-payment' );
178 | wp_enqueue_script( 'domainmapping-admin' );
179 |
180 | // enqueue styles
181 | wp_enqueue_style( 'bootstrap-glyphs' );
182 | wp_enqueue_style( 'google-font-lato' );
183 | wp_enqueue_style( 'domainmapping-admin' );
184 |
185 | // render purchase form
186 | wp_iframe( array( $reseller, 'render_purchase_form' ), $info );
187 | exit;
188 | }
189 |
190 | /**
191 | * Proceeds PayPal checkout.
192 | *
193 | * @since 4.0.0
194 | *
195 | * @access public
196 | */
197 | public function purchase_with_paypal() {
198 | $reseller = $this->_plugin->get_reseller();
199 | if ( $reseller ) {
200 | $reseller->proceed_paypal_checkout();
201 | }
202 |
203 | wp_redirect( wp_get_referer() );
204 | exit;
205 | }
206 |
207 | /**
208 | * Maps already bought domain.
209 | *
210 | * @since 4.0.0
211 | *
212 | * @access private
213 | * @param string $domain The new domain name to map.
214 | * @param int $blog_id The blog ID to map domain to.
215 | */
216 | private function _map_domain( $domain, $blog_id = false ) {
217 | if ( !$blog_id ) {
218 | global $blog_id;
219 | $blog_id = intval( $blog_id );
220 | }
221 |
222 | // check if mapped domains are 0 or multi domains are enabled
223 | $count = $this->_wpdb->get_var( 'SELECT COUNT(*) FROM ' . DOMAINMAP_TABLE_MAP . ' WHERE blog_id = ' . $blog_id );
224 | $allowmulti = domain_map::allow_multiple();
225 | if ( $count == 0 || $allowmulti ) {
226 |
227 | // check if domain has not been mapped
228 | $blog = $this->_wpdb->get_row( $this->_wpdb->prepare( "SELECT blog_id FROM {$this->_wpdb->blogs} WHERE domain = %s AND path = '/'", $domain ) );
229 | $map = $this->_wpdb->get_row( $this->_wpdb->prepare( 'SELECT blog_id FROM ' . DOMAINMAP_TABLE_MAP . ' WHERE domain = %s', $domain ) );
230 |
231 | if( is_null( $blog ) && is_null( $map ) ) {
232 | $this->_wpdb->insert( DOMAINMAP_TABLE_MAP, array(
233 | 'blog_id' => $blog_id,
234 | 'domain' => $domain,
235 | 'active' => 1,
236 | ), array( '%d', '%s', '%d' ) );
237 |
238 | /**
239 | * Fires the action when a new domain is added
240 | *
241 | * @since 4.0.0
242 | * @param string $domain added domain
243 | * $param int $blog_id
244 | */
245 | do_action( 'domainmapping_added_domain', $domain, $blog_id );
246 | }
247 | }
248 | }
249 |
250 | /**
251 | * Completes PayPal checkout and purcheses a domain name.
252 | *
253 | * @since 4.0.0
254 | *
255 | * @access public
256 | */
257 | public function complete_paypal_checkout() {
258 | $reseller = $this->_plugin->get_reseller();
259 | if ( $reseller ) {
260 | $domain = $reseller->complete_paypal_checkout();
261 | if ( $domain ) {
262 | $this->_map_domain( $domain );
263 | }
264 | }
265 |
266 | wp_redirect( esc_url_raw( add_query_arg( 'page', 'domainmapping', admin_url( 'tools.php' ) ) ) );
267 | exit;
268 | }
269 |
270 |
271 |
272 | /**
273 | * Retrieve name servers for current hostname
274 | *
275 | * @since 4.2.0
276 | *
277 | * @return array
278 | */
279 | private function _get_current_domain_nameservers(){
280 | global $current_site;
281 | $name_servers = array();
282 | $ns_query = dns_get_record($current_site->domain);
283 | if( is_array($ns_query) ){
284 | $i = 1;
285 | foreach($ns_query as $val){
286 | if( isset($val['target']) ){
287 | $name_servers["nameserver" . $i] = $val['target'];
288 | }
289 | $i++;
290 | }
291 | }
292 |
293 | if( count($name_servers) === 0 ){
294 | $name_servers["nameserver1"] = "ns1." . $current_site->domain;
295 | $name_servers["nameserver2"] = "ns2." . $current_site->domain;
296 | }
297 |
298 | return $name_servers;
299 | }
300 | }
--------------------------------------------------------------------------------
/classes/Domainmap/Module/Ajax/Register.php:
--------------------------------------------------------------------------------
1 | _add_ajax_action( Domainmap_Plugin::ACTION_SHOW_REGISTRATION_FORM, 'render_registration_form' );
47 | $this->_add_ajax_action( Domainmap_Plugin::ACTION_SHOW_REGISTRATION_FORM, 'redirect_to_login_form', false, true );
48 | }
49 |
50 | /**
51 | * Checks SSL connection and user permissions before render or process
52 | * registration form.
53 | *
54 | * @since 4.1.0
55 | *
56 | * @access private
57 | * @param Domainmap_Reseller $reseller Current reseller.
58 | */
59 | private function _check_ssl_and_security( $reseller ) {
60 | // check if user has permissions
61 | if ( !check_admin_referer( Domainmap_Plugin::ACTION_SHOW_REGISTRATION_FORM, 'nonce' ) || !current_user_can( 'manage_network_options' ) ) {
62 | status_header( 403 );
63 | exit;
64 | }
65 |
66 | // check if ssl connection is not used
67 | if ( $reseller->registration_over_ssl() && !is_ssl() ) {
68 | // ssl connection is not used, so if you logged in then redirect him
69 | // to https page, otherwise redirect him to login page
70 | $user_id = get_current_user_id();
71 | if ( $user_id ) {
72 | // propagate SSL auth cookie
73 | wp_set_auth_cookie( $user_id, true, true );
74 |
75 | // redirect to https version of this registration page
76 | wp_redirect( esc_url_raw( add_query_arg( array(
77 | 'action' => Domainmap_Plugin::ACTION_SHOW_REGISTRATION_FORM,
78 | 'nonce' => wp_create_nonce( Domainmap_Plugin::ACTION_SHOW_REGISTRATION_FORM ),
79 | 'reseller' => filter_input( INPUT_GET, 'reseller' ),
80 | ), admin_url( 'admin-ajax.php', 'https' ) ) ) );
81 | exit;
82 | } else {
83 | // redirect to login form
84 | $this->redirect_to_login_form();
85 | }
86 | }
87 | }
88 |
89 | /**
90 | * Renders registration form.
91 | *
92 | * @since 4.1.0
93 | *
94 | * @access public
95 | */
96 | public function render_registration_form() {
97 | // check reseller
98 | $reseller = filter_input( INPUT_GET, 'reseller' );
99 | $resellers = $this->_plugin->get_resellers();
100 | if ( !isset( $resellers[$reseller] ) ) {
101 | status_header( 404 );
102 | exit;
103 | }
104 | // check whether reseller supports accounts registration
105 | $reseller = $resellers[$reseller];
106 | if ( !$reseller->support_account_registration() ) {
107 | _default_wp_die_handler( __( 'The reseller doesn\'t support account registration.', 'domainmap' ) );
108 | }
109 |
110 | // check ssl and security
111 | $this->_check_ssl_and_security( $reseller );
112 |
113 | // process post request
114 | if ( $_SERVER['REQUEST_METHOD'] == 'POST' && $reseller->regiser_account() ) {
115 | wp_redirect( esc_url_raw( add_query_arg( array(
116 | 'page' => 'domainmapping_options',
117 | 'tab' => 'reseller-options',
118 | 'registered' => 'true',
119 | ), network_admin_url( 'settings.php', 'http' ) ) ) );
120 | exit;
121 | }
122 |
123 | define( 'IFRAME_REQUEST', true );
124 |
125 | // enqueue scripts
126 | wp_enqueue_script( 'jquery-payment' );
127 | wp_enqueue_script( 'domainmapping-admin' );
128 |
129 | // enqueue styles
130 | wp_enqueue_style( 'bootstrap-glyphs' );
131 | wp_enqueue_style( 'google-font-lato' );
132 | wp_enqueue_style( 'domainmapping-admin' );
133 |
134 | // render registration form
135 | wp_iframe( array( $reseller, 'render_registration_form' ) );
136 | wp_die();
137 | }
138 |
139 |
140 | }
--------------------------------------------------------------------------------
/classes/Domainmap/Module/Setup.php:
--------------------------------------------------------------------------------
1 | _add_action( 'init', 'register_scripts' );
46 | $this->_add_action( 'plugins_loaded', 'load_text_domain' );
47 | $this->_add_filter( 'domainmapping_resellers', 'setup_resellers' );
48 | }
49 |
50 | /**
51 | * Loads plugin text domain.
52 | *
53 | * @since 4.0.0
54 | * @action plugins_loaded
55 | * @uses load_textdomain() To load translations for the plugin.
56 | *
57 | * @access public
58 | */
59 | public function load_text_domain() {
60 | load_plugin_textdomain( 'domainmap', false, dirname( plugin_basename( DOMAINMAP_BASEFILE ) ) . '/languages/' );
61 | }
62 |
63 | /**
64 | * Registers javascript and stylesheet files.
65 | *
66 | * @since 4.0.0
67 | * @action init
68 | * @uses plugins_url() To generate base URL of assets files.
69 | * @uses wp_register_script() To register javascript files.
70 | * @uses wp_localize_script() To localize javascript files.
71 | * @uses wp_register_style() To register CSS files.
72 | *
73 | * @access public
74 | */
75 | public function register_scripts() {
76 | $baseurl = plugins_url( '/', DOMAINMAP_BASEFILE );
77 |
78 | // enqueue scripts
79 | wp_register_script( 'jquery-payment', $baseurl . 'js/jquery.payment.js', array( 'jquery' ), '1.0.1', true );
80 | wp_register_script( 'domainmapping-admin', $baseurl . 'js/admin.js', array( 'jquery' ), Domainmap_Plugin::VERSION, true );
81 | wp_localize_script( 'domainmapping-admin', 'domainmapping', array(
82 | 'button' => array(
83 | 'close' => __( 'OK', 'domainmap' ),
84 | ),
85 | 'message' => array(
86 | 'unmap' => __( 'You are about to unmap selected domain. Do you really want to proceed?', 'domainmap' ),
87 | 'unmap_error' => __( 'Unmapping was not successful, please check your permissions and try again later', 'domainmap' ),
88 | 'empty' => __( 'Please enter a valid domain to be mapped to your site.', 'domainmap' ),
89 | 'empty_email_pass' => __( 'Please enter username and password', 'domainmap' ),
90 | 'deselect' => __( 'You are about to deselect your primary domain. Do you really want to proceed?', 'domainmap' ),
91 | 'valid_selection' => __( 'You are about to change your primary domain. Do you really want to proceed?', 'domainmap' ),
92 | 'invalid_selection' => __( 'You are about to make a invalid domain the primary domain. This could cause unexpected issues on the front-end of your site. Do you want to proceed?', 'domainmap' ),
93 | 'invalid_data' => __( 'Invalid data, please try again', 'domainmap' ),
94 |
95 | 'invalid' => array(
96 | 'card_number' => __( 'Credit card number is invalid.', 'domainmap' ),
97 | 'card_type' => __( 'Credit card type is invalid.', 'domainmap' ),
98 | 'card_expiry' => __( 'Credit card expiry date is invalid.', 'domainmap' ),
99 | 'card_cvv' => __( 'Credit card CVV2 code is invalid.', 'domainmap' ),
100 | ),
101 |
102 | 'purchase' => array(
103 | 'success' => __( 'Domain name has been purchased successfully.', 'domainmap' ),
104 | 'failed' => __( 'Domain name purchase has failed.', 'domainmap' ),
105 | ),
106 |
107 | 'order' => array(
108 | 'success' => __( 'Domain name has been ordered and successfully mapped', 'domainmap' ),
109 | 'failed' => __( 'Domain name order has failed.', 'domainmap' ),
110 | ),
111 |
112 | 'registration' => array(
113 | 'success' => __( 'Client account successfully registered, now you can go on with purchasing the domain.', 'domainmap' ),
114 | 'failed' => __( 'Client account registration failed.', 'domainmap' ),
115 | ),
116 | ),
117 | ) );
118 |
119 | // enqueue styles
120 | wp_register_style( 'bootstrap-glyphs', $baseurl . 'css/bootstrap-glyphs.min.css', array(), '2.3.2' );
121 | wp_register_style( 'google-font-lato', '//fonts.googleapis.com/css?family=Lato:300,400,700,400italic', array(), Domainmap_Plugin::VERSION );
122 | wp_register_style( 'domainmapping-admin', $baseurl . 'css/admin.css', array( 'google-font-lato', 'buttons' ), Domainmap_Plugin::VERSION );
123 | }
124 |
125 | /**
126 | * Setups resellers.
127 | * 4.4.2.4 - removed support for WHMCS
128 | *
129 | * @since 4.0.0
130 | * @filter domainmapping_resellers
131 | *
132 | * @access public
133 | * @param array $resellers The array of resellers.
134 | * @return array Updated array of resellers.
135 | */
136 | public function setup_resellers( $resellers ) {
137 | $resellers[] = new Domainmap_Reseller_Enom();
138 | return $resellers;
139 | }
140 |
141 | }
--------------------------------------------------------------------------------
/classes/Domainmap/Module/System.php:
--------------------------------------------------------------------------------
1 | _check_sunrise();
45 | $this->_upgrade();
46 | }
47 |
48 | /**
49 | * Checks sunrise.php file availability.
50 | *
51 | * @since 4.0.0
52 | *
53 | * @access private
54 | */
55 | private function _check_sunrise() {
56 | if ( defined( 'SUNRISE' ) ) {
57 | $dest = WP_CONTENT_DIR . '/sunrise.php';
58 | $source = DOMAINMAP_ABSPATH . '/sunrise.php';
59 |
60 | $need_update = false;
61 | $need_update |= !file_exists( $dest );
62 | $need_update |= !defined( 'DOMAINMAPPING_SUNRISE_VERSION' ) || version_compare( DOMAINMAPPING_SUNRISE_VERSION, Domainmap_Plugin::SUNRISE, '<' );
63 |
64 | if ( $need_update && is_writable( WP_CONTENT_DIR ) && is_readable( $source ) ) {
65 | @copy( $source, $dest );
66 | }
67 | }
68 | }
69 |
70 | /**
71 | * Executes an array of sql queries.
72 | *
73 | * @since 4.0.0
74 | *
75 | * @access private
76 | * @param array $queries The arrayof queries to execute.
77 | */
78 | private function _exec_queries( array $queries ) {
79 | foreach ( $queries as $query ) {
80 | $this->_wpdb->query( $query );
81 | }
82 | }
83 |
84 | /**
85 | * Generates CREATE TABLE sql script for provided table name and columns list.
86 | *
87 | * @since 4.0.0
88 | *
89 | * @access private
90 | * @param string $name The name of a table.
91 | * @param array $columns The array of columns, indexes, constraints.
92 | * @return string The sql script for table creation.
93 | */
94 | private function _create_table( $name, array $columns ) {
95 | $charset = '';
96 | if ( !empty( $this->_wpdb->charset ) ) {
97 | $charset = " DEFAULT CHARACTER SET " . $this->_wpdb->charset;
98 | }
99 |
100 | $collate = '';
101 | if ( !empty( $this->_wpdb->collate ) ) {
102 | $collate .= " COLLATE " . $this->_wpdb->collate;
103 | }
104 |
105 | return sprintf( 'CREATE TABLE IF NOT EXISTS `%s` (%s)%s%s', $name, implode( ', ', $columns ), $charset, $collate );
106 | }
107 |
108 | /**
109 | * Builds alter table script for provided table.
110 | *
111 | * @since 4.0.3
112 | *
113 | * @access private
114 | * @param string $name The name of a table.
115 | * @param array $alters The array of alters.
116 | * @return string The sql script to alter a table.
117 | */
118 | private function _alter_table( $name, array $alters ) {
119 | return sprintf( 'ALTER TABLE `%s` %s', $name, implode( ', ', $alters ) );
120 | }
121 |
122 | /**
123 | * Performs upgrade plugin environment to up to date version.
124 | *
125 | * @since 4.0.0
126 | *
127 | * @access private
128 | */
129 | private function _upgrade() {
130 | $filter = 'domainmaping_database_upgrade';
131 | $option = 'domainmaping_database_version';
132 |
133 | // Check if tables exist. If not, set db_version to false so it doesn't block database upgrade
134 | $exists = $this->table_exists( DOMAINMAP_TABLE_MAP, true );
135 | if ( !$exists ) {
136 | update_site_option( $option, false );
137 | }
138 |
139 | // fetch current database version
140 | $db_version = get_site_option( $option );
141 | if ( $db_version === false ) {
142 | $db_version = '0.0.0';
143 | update_site_option( $option, $db_version );
144 | }
145 |
146 | // check if current version is equal to database version, then there is nothing to upgrade
147 | if ( version_compare( $db_version, Domainmap_Plugin::VERSION, '=' ) ) {
148 | return;
149 | }
150 |
151 | // add upgrade functions
152 | $this->_add_filter( $filter, 'setup_database', 1 );
153 | $this->_add_filter( $filter, 'upgrade_to_4_0_3', 10 );
154 | $this->_add_filter( $filter, 'upgrade_to_4_2', 10 );
155 | $this->_add_filter( $filter, 'upgrade_to_4_4_0_8', 10 );
156 |
157 |
158 | /**
159 | * Filter version number
160 | *
161 | * @since 4.0.0
162 | * @param string $db_version plugin version number
163 | */
164 | $db_version = apply_filters( $filter, $db_version );
165 | // upgrade database version to current plugin version
166 | $db_version = version_compare( $db_version, Domainmap_Plugin::VERSION, '>=' )
167 | ? $db_version
168 | : Domainmap_Plugin::VERSION;
169 |
170 | update_site_option( $option, $db_version );
171 | }
172 |
173 | /**
174 | * Checks if tables already exist in db or not.
175 | *
176 | * @since 4.4.2.6
177 | *
178 | * @access public
179 | * @param string $table_name The current plugin version.
180 | * @param boolean $prefixed if the passed database already prefixed.
181 | * @return boolean.
182 | */
183 | public function table_exists( $table_name, $prefixed = false ) {
184 |
185 | $exists = false;
186 |
187 | // Add the prefix if already not prefixed
188 | if ( !$prefixed ) {
189 | $table_name = ( isset( $this->_wpdb->base_prefix ) ? $this->_wpdb->base_prefix : $this->_wpdb->prefix ) . $table_name;
190 | }
191 |
192 | if ( is_a( $this->_wpdb, 'm_wpdb' ) && isset( $this->_wpdb->dbhglobal ) ) {
193 | // multi db is used, so we need to use bare functions to escape m_wpdb compatibility issues
194 | $result = @mysqli_query( 'SHOW TABLES', $this->_wpdb->dbhglobal );
195 | if ( $result ) {
196 | while ( ( $row = @mysqli_fetch_array( $result, MYSQLI_NUM ) ) ) {
197 | if ( $row[0] == $table_name ) {
198 | $exists = true;
199 | break;
200 | }
201 | }
202 | @mysqli_free_result( $result );
203 | }
204 | } else {
205 | // standard wpdb is used
206 | $exists = in_array( $table_name, $this->_wpdb->get_col( 'SHOW TABLES' ) );
207 | }
208 |
209 | // In case we still couldn't find, try normal query.
210 | if ( ! $exists ) {
211 | global $wpdb;
212 |
213 | // Check if a matching table found.
214 | if ( $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE '%s'", $table_name ) ) == $table_name ) {
215 | $exists = true;
216 | }
217 | }
218 |
219 | return $exists;
220 | }
221 |
222 | /**
223 | * Creates tables if they do not exist.
224 | *
225 | * @since 4.0.2
226 | *
227 | * @access public
228 | * @param string $current_version The current plugin version.
229 | * @return string Unchanged version.
230 | */
231 | public function setup_database( $current_version ) {
232 | // check if old table exists
233 | $exists = $this->table_exists('domain_map');
234 |
235 | // if old table exists, rename it
236 | if ( $exists ) {
237 | $this->_wpdb->query( sprintf( 'RENAME TABLE %s TO %s', $old_table, DOMAINMAP_TABLE_MAP ) );
238 | }
239 |
240 | // create tables if not exists
241 | $this->_exec_queries( array(
242 | $this->_create_table( DOMAINMAP_TABLE_MAP, array(
243 | '`id` BIGINT NOT NULL AUTO_INCREMENT',
244 | '`blog_id` BIGINT NOT NULL',
245 | '`domain` VARCHAR(191) NOT NULL',
246 | '`active` TINYINT DEFAULT 1',
247 | 'PRIMARY KEY (`id`)',
248 | 'KEY `blog_id` (`blog_id`, `domain`, `active`)',
249 | ) ),
250 |
251 | $this->_create_table( DOMAINMAP_TABLE_RESELLER_LOG, array(
252 | '`id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT',
253 | '`user_id` BIGINT UNSIGNED NOT NULL',
254 | '`provider` VARCHAR(191) NOT NULL',
255 | '`requested_at` DATETIME NOT NULL',
256 | '`type` TINYINT UNSIGNED NOT NULL',
257 | '`valid` TINYINT UNSIGNED NOT NULL',
258 | '`errors` TEXT NOT NULL',
259 | '`response` TEXT NOT NULL',
260 | 'PRIMARY KEY (`id`)',
261 | 'KEY `idx_reseller_log` (`provider`, `valid`)',
262 | ) ),
263 | ) );
264 |
265 | return $current_version;
266 | }
267 |
268 | /**
269 | * Upgrades database to version 4.0.3
270 | *
271 | * @since 4.0.3
272 | *
273 | * @access public
274 | * @param string $current_version The current plugin version.
275 | * @return string Upgraded version if the current version is less, otherwise current version.
276 | */
277 | public function upgrade_to_4_0_3( $current_version ) {
278 | $this_version = '4.0.3';
279 | if ( version_compare( $current_version, $this_version, '>=' ) ) {
280 | return $current_version;
281 | }
282 |
283 | $this->_exec_queries( array(
284 | $this->_alter_table( DOMAINMAP_TABLE_MAP, array(
285 | 'CHANGE COLUMN `active` `active` TINYINT(4) UNSIGNED NOT NULL DEFAULT 1',
286 | 'ADD COLUMN `is_primary` TINYINT UNSIGNED NOT NULL DEFAULT 0 AFTER `blog_id`',
287 | ) ),
288 | ) );
289 |
290 | return $this_version;
291 | }
292 |
293 |
294 | /**
295 | * Upgrades database to version 4.2
296 | *
297 | * @since 4.2
298 | *
299 | * @param string $current_version The current plugin version.
300 | * @return string Upgraded version if the current version is less, otherwise current version.
301 | */
302 | public function upgrade_to_4_2( $current_version ) {
303 | $this_version = '4.2';
304 | if ( version_compare( $current_version, $this_version, '>=' ) ) {
305 | return $current_version;
306 | }
307 |
308 | $this->_exec_queries( array(
309 | $this->_alter_table( DOMAINMAP_TABLE_MAP, array(
310 | 'ADD COLUMN `scheme` TINYINT UNSIGNED NOT NULL DEFAULT 2 AFTER `active`',
311 | ) ),
312 | ) );
313 |
314 | return $this_version;
315 | }
316 |
317 | /**
318 | * Upgrades database to version 4.4.0.8
319 | *
320 | * Changes domain column's length to 191 to the max length in InnoDB for utf8mb4
321 | *
322 | * @since 4.4.0.8
323 | *
324 | * @access public
325 | * @param string $current_version The current plugin version.
326 | * @return string Upgraded version if the current version is less, otherwise current version.
327 | */
328 | public function upgrade_to_4_4_0_8( $current_version ) {
329 | $this_version = '4.4.0.8';
330 |
331 | if ( version_compare( $current_version, $this_version, '>=' ) ) {
332 | return $current_version;
333 | }
334 |
335 | $this->_exec_queries( array(
336 | $this->_alter_table( DOMAINMAP_TABLE_MAP, array(
337 | 'MODIFY COLUMN `domain` VARCHAR(191) NOT NULL',
338 | ) ),
339 | ) );
340 |
341 | $this->_exec_queries( array(
342 | $this->_alter_table( DOMAINMAP_TABLE_RESELLER_LOG, array(
343 | 'MODIFY COLUMN `provider` VARCHAR(191) NOT NULL',
344 | ) ),
345 | ) );
346 |
347 | return $this_version;
348 | }
349 | }
350 |
--------------------------------------------------------------------------------
/classes/Domainmap/Punycode.php:
--------------------------------------------------------------------------------
1 | decode( $domain );
44 | }
45 |
46 | /**
47 | * Encode a domain to its Punycode version
48 | *
49 | * @uses Punycode:encode
50 | * @since 4.2
51 | *
52 | * @param $domain
53 | * @return string
54 | */
55 | public static function encode( $domain ){
56 | $cls = new Punycode();
57 | return $cls->encode( $domain );
58 | }
59 | }
--------------------------------------------------------------------------------
/classes/Domainmap/Render.php:
--------------------------------------------------------------------------------
1 | _data = $data;
54 | }
55 |
56 | /**
57 | * Returns property associated with the render.
58 | *
59 | * @since 4.0.0
60 | *
61 | * @access public
62 | * @param string $name The name of a property.
63 | * @return mixed Returns mixed value of a property or NULL if a property doesn't exist.
64 | */
65 | public function __get( $name ) {
66 | return array_key_exists( $name, $this->_data ) ? $this->_data[$name] : null;
67 | }
68 |
69 | /**
70 | * Checks whether the render has specific property or not.
71 | *
72 | * @since 4.0.0
73 | *
74 | * @access public
75 | * @param string $name
76 | * @return boolean TRUE if the property exists, otherwise FALSE.
77 | */
78 | public function __isset( $name ) {
79 | return array_key_exists( $name, $this->_data );
80 | }
81 |
82 | /**
83 | * Associates the render with specific property.
84 | *
85 | * @since 4.0.0
86 | *
87 | * @access public
88 | * @param string $name The name of a property to associate.
89 | * @param mixed $value The value of a property.
90 | */
91 | public function __set( $name, $value ) {
92 | $this->_data[$name] = $value;
93 | }
94 |
95 | /**
96 | * Unassociates specific property from the render.
97 | *
98 | * @since 4.0.0
99 | *
100 | * @access public
101 | * @param string $name The name of the property to unassociate.
102 | */
103 | public function __unset( $name ) {
104 | unset( $this->_data[$name] );
105 | }
106 |
107 | /**
108 | * Renders template.
109 | *
110 | * @since 4.0.0
111 | *
112 | * @abstract
113 | * @access protected
114 | */
115 | protected abstract function _to_html();
116 |
117 | /**
118 | * Builds template and return it as string.
119 | *
120 | * @since 4.0.0
121 | *
122 | * @access public
123 | * @return string
124 | */
125 | public function to_html() {
126 | ob_start();
127 | $this->_to_html();
128 | return ob_get_clean();
129 | }
130 |
131 | /**
132 | * Returns built template as string.
133 | *
134 | * @since 4.0.0
135 | *
136 | * @access public
137 | * @return type
138 | */
139 | public function __toString() {
140 | return $this->to_html();
141 | }
142 |
143 | /**
144 | * Renders the template.
145 | *
146 | * @since 4.0.0
147 | *
148 | * @access public
149 | */
150 | public function render() {
151 | $this->_to_html();
152 | }
153 |
154 | }
--------------------------------------------------------------------------------
/classes/Domainmap/Render/Network.php:
--------------------------------------------------------------------------------
1 | _nonce_action = $nonce_action;
49 | }
50 |
51 | /**
52 | * Renders page header.
53 | *
54 | * @since 4.0.0
55 | *
56 | * @access protected
57 | */
58 | protected function _render_header() {
59 | echo '', __( 'Domain Mapping', 'domainmap' ), ' ';
60 | }
61 |
62 | /**
63 | * Renders template.
64 | *
65 | * @since 4.0.0
66 | *
67 | * @access protected
68 | */
69 | protected function _to_html() {
70 | ?>', __( 'Log records were deleted.', 'domainmap' ), '';
45 | endif;
46 | }
47 |
48 | /**
49 | * Renders tab content.
50 | *
51 | * @since 4.0.0
52 | *
53 | * @access protected
54 | */
55 | protected function _render_tab() {
56 | $this->table->prepare_items();
57 | echo '';
58 | $this->table->views();
59 | $this->table->display();
60 | echo '
';
61 | }
62 |
63 | }
--------------------------------------------------------------------------------
/classes/Domainmap/Render/Network/MappedDomains.php:
--------------------------------------------------------------------------------
1 | table->prepare_items();
47 | ?>
48 |
49 | table->views();
51 | $this->table->search_box(__('Search mapped domains', domain_map::Text_Domain), "mapped_domain");
52 | $this->table->display();
53 | ?>
54 |
55 | ', __( 'Options updated.', 'domainmap' ), '';
45 | endif;
46 |
47 | if ( filter_input( INPUT_GET, 'registered', FILTER_VALIDATE_BOOLEAN ) ) :
48 | echo '', __( 'Account was registered successfully.', 'domainmap' ), '
';
49 | endif;
50 | }
51 |
52 | /**
53 | * Renders tab content.
54 | *
55 | * @since 4.0.0
56 | *
57 | * @access protected
58 | */
59 | protected function _render_tab() {
60 | $selected = false;
61 |
62 | $log_levels = array(
63 | Domainmap_Reseller::LOG_LEVEL_ALL => __( 'All requests', 'domainmap' ),
64 | Domainmap_Reseller::LOG_LEVEL_ERRORS => __( 'Failed requests', 'domainmap' ),
65 | Domainmap_Reseller::LOG_LEVEL_DISABLED => __( 'Disable login', 'domainmap' ),
66 | );
67 |
68 | ?>
82 |
83 |
84 |
85 |
86 |
89 |
90 |
108 |
resellers as $hash => $reseller ) :
111 | ?>
112 | render_options() ?>
113 |
117 |
118 |
119 |
120 |
44 |
45 | eNom Help Center'
49 | )
50 | ?>
51 |
52 | 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 |
79 |
80 |
81 | valid === false ) : ?>
82 |
83 |
84 | errors ) ) : ?>
85 |
86 |
87 | ', array_map( 'esc_html', $this->errors->get_error_messages() ) ) ?>
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
114 |
115 | gateway == Domainmap_Reseller_Enom::GATEWAY_ENOM ) : ?>
116 |
119 |
120 |
121 | __( 'Test environment', 'domainmap' ),
145 | Domainmap_Reseller_Enom::ENVIRONMENT_PRODUCTION => __( 'Production environment', 'domainmap' ),
146 | );
147 |
148 | ?>
149 | sslverification ) ? $this->sslverification : 1;
173 |
174 | $options = array(
175 | 1 => __( 'Enable SSL verification', 'domainmap' ),
176 | 0 => __( 'Disable SSL verification', 'domainmap' ),
177 | );
178 |
179 | ?>
180 |
181 |
',
185 | ''
186 | )
187 | ?>
188 |
198 |
_render_notifications();
210 | $this->_render_account_settings();
211 | $this->_render_environment_settings();
212 | $this->_render_sslverification_settings();
213 | $this->_render_payment_settings();
214 | }
215 |
216 | }
--------------------------------------------------------------------------------
/classes/Domainmap/Render/Reseller/Iframe.php:
--------------------------------------------------------------------------------
1 | _render_page();
42 | }
43 |
44 | /**
45 | * Render template content.
46 | *
47 | * @since 4.0.0
48 | *
49 | * @abstract
50 | * @access protected
51 | */
52 | protected abstract function _render_page();
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/classes/Domainmap/Render/Site.php:
--------------------------------------------------------------------------------
1 |
42 | ', __( 'Options updated.', domain_map::Text_Domain ), '';
46 | endif;
47 | }
48 |
49 | }
--------------------------------------------------------------------------------
/classes/Domainmap/Render/Site/Purchase.php:
--------------------------------------------------------------------------------
1 | reseller->get_tld_list();
43 |
44 | $predefined_sld = trim( filter_input( INPUT_GET, 'sld' ) );
45 | $predefined_tld = trim( filter_input( INPUT_GET, 'tld' ) );
46 | if ( !in_array( $predefined_tld, $tlds ) ) {
47 | $predefined_tld = 'com';
48 | }
49 | ?>
52 |
53 | _tabs = $tabs;
50 | $this->_active_tab = $active;
51 | }
52 |
53 | /**
54 | * Renders template.
55 | *
56 | * @since 4.0.0
57 | *
58 | * @access protected
59 | */
60 | protected function _to_html() {
61 | $baseurl = esc_url_raw( add_query_arg( 'page', filter_input( INPUT_GET, 'page' ), current( explode( '?', $_SERVER['REQUEST_URI'] ) ) ) );
62 |
63 | ?>
64 | _render_header() ?>
65 |
66 |
78 |
79 |
_render_tab()
81 | ?>
82 |
__( 'Search' ),
45 | 'single' => 'item',
46 | 'plural' => 'items',
47 | 'ajax' => false,
48 | ), $args ) );
49 | }
50 |
51 | /**
52 | * Displays table navigation section.
53 | *
54 | * @since 4.0.0
55 | *
56 | * @access public
57 | * @param string $which The section where table navigation will be displayed.
58 | */
59 | public function display_tablenav( $which ) {
60 | echo '';
61 | echo '
';
62 | $this->bulk_actions( $which );
63 | echo '
';
64 | $this->extra_tablenav( $which );
65 | $this->pagination( $which );
66 | echo '
';
67 | echo '
';
68 | }
69 |
70 | /**
71 | * Returns column value.
72 | *
73 | * @since 4.0.0
74 | *
75 | * @access public
76 | * @param array $item The table row to display.
77 | * @param string $column_name The column id to render.
78 | * @return string The value to display.
79 | */
80 | public function column_default( $item, $column_name ) {
81 | if( is_object($item) ){
82 | $value = isset( $item->{$column_name} ) ? $item->{$column_name} : '';
83 | }else{
84 | $value = isset( $item[$column_name] ) ? $item[$column_name] : '';
85 | }
86 |
87 | return is_numeric( $value ) ? number_format( $value ) : $value;
88 | }
89 |
90 | /**
91 | * Returns checkbox column value.
92 | *
93 | * @since 4.0.0
94 | *
95 | * @access public
96 | * @param array $item The table row to display.
97 | * @return string The value to display.
98 | */
99 | public function column_cb( $item ) {
100 | if( is_object($item) ){
101 | return sprintf( ' ', $this->_args['plural'], $item->id );
102 | }else{
103 | return sprintf( ' ', $this->_args['plural'], $item['id'] );
104 | }
105 |
106 | }
107 |
108 | /**
109 | * Prepares the list of items for displaying.
110 | *
111 | * @since 4.0.0
112 | *
113 | * @access public
114 | */
115 | public function prepare_items() {
116 | $this->_column_headers = array(
117 | $this->get_columns(),
118 | array(),
119 | $this->get_sortable_columns()
120 | );
121 | }
122 |
123 | /**
124 | * Displays the search box if it was enabled in table arguments.
125 | *
126 | * @since 4.0.0
127 | *
128 | * @access public
129 | * @param string $text The search button text.
130 | * @param string $input_id The search input id.
131 | */
132 | public function search_box( $text, $input_id ) {
133 | if ( isset( $this->_args['search_box'] ) && $this->_args['search_box'] ) {
134 | parent::search_box( $text, $input_id );
135 | }
136 | }
137 |
138 | /**
139 | * Auto escapes all values and displays the table.
140 | *
141 | * @since 4.0.0
142 | *
143 | * @access public
144 | */
145 | public function display() {
146 | if ( is_array( $this->items ) ) {
147 | foreach ( $this->items as &$item ) {
148 | foreach ( $item as &$value ) {
149 | $value = esc_html( $value );
150 | }
151 | }
152 | }
153 |
154 | parent::display();
155 | }
156 |
157 | /**
158 | * Returns associative array with the list of bulk actions available on this table.
159 | *
160 | * @since 4.0.0
161 | *
162 | * @access protected
163 | * @return array The associative array of bulk actions.
164 | */
165 | public function get_bulk_actions() {
166 | return isset( $this->_args['actions'] )
167 | ? $this->_args['actions']
168 | : array();
169 | }
170 |
171 | }
--------------------------------------------------------------------------------
/classes/Domainmap/Table/ExcludedPages/Listing.php:
--------------------------------------------------------------------------------
1 | __( 'Search pages', domain_map::Text_Domain ),
54 | 'single' => 'Excluded page',
55 | 'plural' => 'Excluded pages',
56 | 'ajax' => true,
57 | 'search_box' => true
58 | ), $args ) );
59 |
60 |
61 |
62 | $this->_excluded_pages_array = Domainmap_Module_Mapping::get_excluded_pages(true);
63 | $this->_ssl_forced_pages_array = Domainmap_Module_Mapping::get_ssl_forced_pages(true);
64 | }
65 |
66 |
67 | /**
68 | * Returns table columns.
69 | *
70 | * @since 4.3.0
71 | *
72 | * @return array The array of table columns to display.
73 | */
74 | public function get_columns() {
75 | $cols = array(
76 | 'exclude' => __( 'Exclude', domain_map::Text_Domain ),
77 | 'force_ssl' => __( 'Force ssl', domain_map::Text_Domain ),
78 | 'title' => __( 'Title', domain_map::Text_Domain )
79 | );
80 |
81 | if( !Domainmap_Plugin::instance()->get_option("map_allow_excluded_pages", true) ){
82 | unset( $cols['exclude'] );
83 | }
84 |
85 | if( !Domainmap_Plugin::instance()->get_option("map_allow_forced_pages", true) ){
86 | unset( $cols['force_ssl'] );
87 | }
88 |
89 | return $cols;
90 | }
91 |
92 |
93 | /**
94 | * Returns sortable columns
95 | *
96 | * @since 4.3.0
97 | *
98 | * @return array
99 | */
100 | public function get_sortable_columns() {
101 | return array(
102 | 'title'=> "title"
103 | );
104 | }
105 |
106 | /**
107 | * Fetches records from database.
108 | *
109 | * @since 4.3.0
110 | *
111 | * @global wpdb $wpdb The database connection.
112 | */
113 | public function prepare_items() {
114 |
115 | parent::prepare_items();
116 |
117 | $per_page = 10;
118 |
119 | $search_term = "";
120 | if ( isset( $_REQUEST['s'] ) && !empty( $_REQUEST['s'] )) {
121 | $search_term = $_REQUEST['s'];
122 | }
123 |
124 |
125 | $query = new WP_Query(array(
126 | "post_type" => "page",
127 | "posts_per_page" => $per_page,
128 | "s" => $search_term,
129 | "orderby" => "title",
130 | "order" => isset( $_REQUEST['order'] ) ? $_REQUEST['order'] : "ASC",
131 | "paged" => isset( $_REQUEST['paged'] ) ? $_REQUEST['paged'] : 1,
132 | ));
133 |
134 | $this->items = $query->get_posts();
135 | $total_items = $query->found_posts;
136 | $this->set_pagination_args( array(
137 | 'total_items' => $total_items,
138 | 'per_page' => $per_page,
139 | 'total_pages' => $query->max_num_pages,
140 | 'orderby' => 'title',
141 | 'order' => isset( $_REQUEST['order'] ) ? $_REQUEST['order'] : 'asc'
142 | ) );
143 |
144 | }
145 |
146 | /**
147 | * Renders exclude columns
148 | *
149 | * @since 4.3.0
150 | * @param $page WP_Post
151 | */
152 | public function column_exclude( $page ) {
153 | $is_excluded = in_array( $page->ID, $this->_excluded_pages_array );
154 | ?>
155 | type="checkbox" data-id="ID ?>" class="dm_excluded_page_checkbox" value="ID ?>"/>
156 | ID, $this->_ssl_forced_pages_array );
167 | ?>
168 | type="checkbox" data-id="ID ?>" class="dm_ssl_forced_page_checkbox" value="ID ?>"/>
169 | ID );
179 | printf( '%2$s ', $url , $page->post_title );
180 | }
181 |
182 |
183 |
184 |
185 | /**
186 | * Renders single row
187 | *
188 | * @since 4.3.0
189 | *
190 | * @param WP_Post $page
191 | */
192 | public function single_row( $page ) {
193 | echo '';
194 | $this->single_row_columns( $page );
195 | echo ' ';
196 | }
197 |
198 | /**
199 | * Returns associative array with the list of bulk actions available on this table.
200 | *
201 | * @since 4.3.0
202 | *
203 | * @access protected
204 | * @return array The associative array of bulk actions.
205 | */
206 | public function get_bulk_actions() {
207 | return array();
208 | }
209 |
210 | /**
211 | * Adds footer or header to the table
212 | *
213 | * @since 4.3.0
214 | * @param string $which
215 | */
216 | public function extra_tablenav( $which ) {
217 |
218 | $s = filter_input( INPUT_GET, 's' );
219 |
220 | /**
221 | * For ajax calls
222 | */
223 | wp_nonce_field( 'excluded-pages-nonce', '_excluded_pages_nonce' );
224 | ?>
225 |
226 |
227 |
228 |
239 |
240 |
241 | _excluded_pages_array ); ?>
242 |
243 | _ssl_forced_pages_array ); ?>
244 |
245 |
246 |
247 |
248 |
249 |
250 | prepare_items();
263 | ob_start();
264 | if ( ! empty( $_REQUEST['no_placeholder'] ) )
265 | $this->display_rows();
266 | else
267 | $this->display_rows_or_placeholder();
268 | $rows = ob_get_clean();
269 | ob_start();
270 | $this->print_column_headers();
271 | $headers = ob_get_clean();
272 | ob_start();
273 | $this->pagination('top');
274 | $pagination_top = ob_get_clean();
275 | ob_start();
276 | $this->pagination('bottom');
277 | $pagination_bottom = ob_get_clean();
278 | $response = array( 'rows' => $rows );
279 | $response['pagination']['top'] = $pagination_top;
280 | $response['pagination']['bottom'] = $pagination_bottom;
281 | $response['column_headers'] = $headers;
282 | if ( isset( $total_items ) )
283 | $response['total_items_i18n'] = sprintf( _n( '1 item', '%s items', $total_items ), number_format_i18n( $total_items ) );
284 | if ( isset( $total_pages ) ) {
285 | $response['total_pages'] = $total_pages;
286 | $response['total_pages_i18n'] = number_format_i18n( $total_pages );
287 | }
288 | die( json_encode( $response ) );
289 | }
290 |
291 |
292 |
293 | }
294 |
295 |
296 |
--------------------------------------------------------------------------------
/classes/Domainmap/Table/MappedDomains/Listing.php:
--------------------------------------------------------------------------------
1 | __( 'Search mapped domains' ),
37 | 'single' => 'domain',
38 | 'plural' => 'domains',
39 | 'ajax' => false,
40 | 'search_box' => true
41 | ), $args ) );
42 | }
43 |
44 |
45 | /**
46 | * Returns table columns.
47 | *
48 | * @since 4.2.0
49 | *
50 | * @return array The array of table columns to display.
51 | */
52 | public function get_columns() {
53 | $cols = array(
54 | 'site_id' => __( 'Site ID', 'domainmap' ),
55 | 'mapped_domain' => __( 'Mapped Domain', 'domainmap' ),
56 | 'domain' => __( 'Original Address', 'domainmap' ),
57 | "health" => __( 'Health Status', 'domainmap' ),
58 | 'dns' => __( 'DNS Configuration', 'domainmap' ),
59 | 'primary' => __( 'Primary', 'domainmap' ),
60 | 'active' => __( 'Active', 'domainmap' ),
61 | 'actions' => __( 'Actions', 'domainmap' ),
62 | );
63 |
64 | if( !domain_map::allow_multiple() ){
65 | unset( $cols["primary"] ) ;
66 | }
67 |
68 | return $cols;
69 | }
70 |
71 |
72 |
73 |
74 | /**
75 | * Fetches records from database.
76 | *
77 | * @since 4.2.0
78 | *
79 | * @global wpdb $wpdb The database connection.
80 | */
81 | public function prepare_items() {
82 | global $wpdb;
83 |
84 | parent::prepare_items();
85 |
86 | $per_page = 20;
87 | $offset = ( $this->get_pagenum() - 1 ) * $per_page;
88 |
89 | $search_term = false;
90 | if ( isset( $_REQUEST['s'] ) && !empty( $_REQUEST['s'] )) {
91 | $search_term = "%" . $wpdb->esc_like($_REQUEST['s']) . "%";
92 | }
93 |
94 | $q = $wpdb->prepare( "
95 | SELECT SQL_CALC_FOUND_ROWS mapped.domain AS mapped_domain, blog.`blog_id`, blog.`domain`, mapped.`is_primary`, mapped.`scheme`, mapped.`active`, blog.`site_id`
96 | FROM " . DOMAINMAP_TABLE_MAP . " AS mapped
97 | LEFT JOIN {$wpdb->blogs} AS blog ON mapped.blog_id = blog.blog_id
98 | ORDER BY blog.blog_id DESC
99 | LIMIT %d
100 | OFFSET %d
101 | ", $per_page, $offset
102 | );
103 |
104 | if( $search_term ){
105 | $q = $wpdb->prepare( "
106 | SELECT SQL_CALC_FOUND_ROWS mapped.domain AS mapped_domain, blog.`blog_id`, blog.`domain`, mapped.`is_primary`, mapped.`scheme`, mapped.`active`, blog.`site_id`
107 | FROM " . DOMAINMAP_TABLE_MAP . " AS mapped
108 | LEFT JOIN {$wpdb->blogs} AS blog ON mapped.blog_id = blog.blog_id
109 | WHERE mapped.domain LIKE %s
110 | ORDER BY blog.blog_id DESC
111 | LIMIT %d
112 | OFFSET %d
113 | ", $search_term, $per_page, $offset
114 | );
115 | }
116 |
117 | $this->items = $wpdb->get_results( $q, OBJECT );
118 | $total_items = $wpdb->get_var( 'SELECT FOUND_ROWS()' );
119 | $this->set_pagination_args( array(
120 | 'total_items' => $total_items,
121 | 'per_page' => $per_page,
122 | 'total_pages' => ceil( $total_items / $per_page )
123 | ) );
124 |
125 | }
126 |
127 |
128 | /**
129 | * Returns site id column data to display.
130 | *
131 | * @since 4.2.0
132 | *
133 | * @param object $item current row's record
134 | */
135 | public function column_site_id( $item ) {
136 | echo $item->blog_id;
137 | }
138 |
139 | /**
140 | * Returns mapped column data to display.
141 | *
142 | * @since 4.2
143 | *
144 | * @param object $item current row's record
145 | */
146 | public function column_mapped_domain( $item ) {
147 | $scheme = $item->scheme == 1 ? "https" : "http";
148 | printf( '%1$s://%2$s ', $scheme , Domainmap_Punycode::decode( $item->mapped_domain ) );
149 | }
150 |
151 | /**
152 | * Returns domain column data to display.
153 | *
154 | * @since 4.2.0
155 | *
156 | * @param object $item current row's record
157 | */
158 | public function column_domain( $item ) {
159 | ?>
160 | blog_id}") ?>">blog_id); ?>
161 | is_primary ? __('Yes', "domainmap") : __('No', "domainmap");
172 | }
173 |
174 | /**
175 | * Renders active column data to display.
176 | *
177 | * @since 4.2
178 | *
179 | * @param object $item current row's record
180 | */
181 | public function column_active( $item ) {
182 | echo $item->active ? __('Yes', "domainmap") : __('No', "domainmap");
183 | }
184 |
185 |
186 | /**
187 | * Renders health column
188 | *
189 | * @since 4.2.0
190 | *
191 | * @param $item current row's record
192 | */
193 | public function column_health($item){
194 | $url = add_query_arg( array(
195 | 'action' => Domainmap_Plugin::ACTION_HEALTH_CHECK,
196 | 'nonce' => wp_create_nonce( Domainmap_Plugin::ACTION_HEALTH_CHECK ),
197 | 'domain' => $item->mapped_domain,
198 | ), set_url_scheme( admin_url( 'admin-ajax.php' ), domain_map::utils()->get_admin_scheme() ) );
199 |
200 | $health = get_site_transient( "domainmapping-{$item->mapped_domain}-health" );
201 | $health_message = __( 'needs revalidation', 'domainmap' );
202 | $health_class = ' domainmapping-need-revalidate';
203 | if ( $health !== false ) {
204 | if ( $health ) {
205 | $health_class = ' domainmapping-valid-domain';
206 | $health_message = __( 'valid', 'domainmap' );
207 | } else {
208 | $health_class = ' domainmapping-invalid-domain';
209 | $health_message = __( 'invalid', 'domainmap' );
210 | }
211 | }
212 |
213 | ?>
214 |
219 | get_dns_config( ( object ) $item );
235 | $dns_config = "";
236 |
237 | foreach ( $_records as $_record ) {
238 | if (ip2long($_record['target']) == 0) {
239 | $_record['target'] .= ".";
240 | }
241 | $dns_config .= "Host Name: {$_record['host']}
";
242 | $dns_config .= "Record Type: {$_record['type']} ";
243 | $dns_config .= "Value: {$_record['target']}
\n
";
244 | }
245 |
246 | return $dns_config;
247 | }
248 |
249 | /**
250 | * Renders domain column data to display.
251 | *
252 | * @since 4.2.0
253 | * @param $item current row's record
254 | */
255 |
256 | public function column_actions( $item ) {
257 |
258 | $remove_link = esc_url( add_query_arg( array(
259 | 'action' => Domainmap_Plugin::ACTION_UNMAP_DOMAIN,
260 | 'nonce' => wp_create_nonce( Domainmap_Plugin::ACTION_UNMAP_DOMAIN ),
261 | 'domain' => $item->mapped_domain,
262 | ), admin_url( 'admin-ajax.php' ) ) );
263 | $primary_class = $item->is_primary == 1 ? 'dashicons-star-filled' : 'dashicons-star-empty';
264 | $admin_ajax = admin_url( 'admin-ajax.php' ) ;
265 |
266 | $select_primary = esc_url( add_query_arg( array(
267 | 'action' => Domainmap_Plugin::ACTION_SELECT_PRIMARY_DOMAIN,
268 | 'nonce' => wp_create_nonce( Domainmap_Plugin::ACTION_SELECT_PRIMARY_DOMAIN ),
269 | 'domain' => $item->mapped_domain,
270 | ), $admin_ajax ) );
271 |
272 | $deselect_primary = esc_url( add_query_arg( array(
273 | 'action' => Domainmap_Plugin::ACTION_DESELECT_PRIMARY_DOMAIN,
274 | 'nonce' => wp_create_nonce( Domainmap_Plugin::ACTION_DESELECT_PRIMARY_DOMAIN ),
275 | 'domain' => $item->mapped_domain,
276 | ), $admin_ajax ) );
277 |
278 | $toggle_scheme_link = esc_url( add_query_arg( array(
279 | 'action' => Domainmap_Plugin::ACTION_TOGGLE_SCHEME,
280 | 'nonce' => wp_create_nonce( Domainmap_Plugin::ACTION_TOGGLE_SCHEME ),
281 | 'domain' => $item->mapped_domain
282 | ), $admin_ajax) );
283 | ?>
284 |
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 | }
--------------------------------------------------------------------------------
/classes/Domainmap/Table/Reseller/Log.php:
--------------------------------------------------------------------------------
1 | ', array_map( 'esc_html', explode( PHP_EOL, $item['errors'] ) ) );
44 | }
45 |
46 | /**
47 | * Returns valid column data to display.
48 | *
49 | * @since 4.0.0
50 | *
51 | * @access public
52 | * @param array $item The array of row data.
53 | * @return string The valid status.
54 | */
55 | public function column_valid( $item ) {
56 | return $item['valid'] == 0
57 | ? '' . __( 'failed', 'domainmap' ) . ' '
58 | : '' . __( 'success', 'domainmap' ) . ' ';
59 | }
60 |
61 | /**
62 | * Returns date and time when request was processed.
63 | *
64 | * @since 4.0.0
65 | *
66 | * @access public
67 | * @param array $item The array of row data.
68 | * @return string The date and time when the request was processed.
69 | */
70 | public function column_requested_at( $item ) {
71 | $timestamp = strtotime( $item['requested_at'] );
72 | if ( $timestamp === false ) {
73 | return '' . __( 'unknown', 'domainmap' ) . ' ';
74 | }
75 |
76 | $date_pattern = date( 'Y', $timestamp ) == date( 'Y' )
77 | ? 'l, d M'
78 | : 'l, d M y';
79 |
80 | $time_pattern = 'H:i T';
81 |
82 | return '' . date( $date_pattern, $timestamp ) . ' ' . date( $time_pattern, $timestamp ) . ' ';
83 | }
84 |
85 | /**
86 | * Returns user name, who has triggered the request.
87 | *
88 | * @since 4.0.0
89 | *
90 | * @access public
91 | * @param array $item The array of row data.
92 | * @return string The user name.
93 | */
94 | public function column_user_name( $item ) {
95 | $nonce = wp_create_nonce( $this->_args['nonce_action'] );
96 |
97 | $actions = array(
98 | 'view' => sprintf(
99 | '%s ',
100 | esc_url( add_query_arg( array(
101 | 'nonce' => $nonce,
102 | 'noheader' => 'true',
103 | 'action' => 'reseller-log-view',
104 | $this->_args['plural'] => $item['id'],
105 | ) ) ),
106 | __( 'View Details', 'domainmap' )
107 | ),
108 | 'delete' => sprintf(
109 | '%s ',
110 | esc_url(add_query_arg( array(
111 | 'nonce' => $nonce,
112 | 'noheader' => 'true',
113 | 'action' => 'reseller-log-delete',
114 | $this->_args['plural'] => $item['id'],
115 | ) ) ),
116 | __( 'Delete', 'domainmap' )
117 | ),
118 | );
119 |
120 | return sprintf(
121 | '%s %s',
122 | esc_url( add_query_arg( 's', $item['user_id'], network_admin_url( 'users.php' ) ) ),
123 | $item['user_name'],
124 | $this->row_actions( $actions )
125 | );
126 | }
127 |
128 | /**
129 | * Returns request type, which has been triggered.
130 | *
131 | * @since 4.0.0
132 | *
133 | * @access public
134 | * @param array $item The array of row data.
135 | * @return string The request type.
136 | */
137 | public function column_action( $item ) {
138 | $types = Domainmap_Reseller::get_request_types();
139 | return isset( $types[$item['type']] )
140 | ? $types[$item['type']]
141 | : '' . __( 'unknown', 'domainmap' ) . ' ';
142 | }
143 |
144 | /**
145 | * Returns tabel columns.
146 | *
147 | * @since 4.0.0
148 | *
149 | * @access public
150 | * @return array The array of table columns to display.
151 | */
152 | public function get_columns() {
153 | return array(
154 | 'cb' => ' ',
155 | 'user_name' => __( 'User', 'domainmap' ),
156 | 'action' => __( 'Action', 'domainmap' ),
157 | 'valid' => __( 'Status', 'doaminmap' ),
158 | 'requested_at' => __( 'Requested At', 'domainmap' ),
159 | 'errors' => __( 'Errors', 'domainmap' ),
160 | );
161 | }
162 |
163 | /**
164 | * Returns the associative array with the list of views available on this table.
165 | *
166 | * @since 4.0.0
167 | *
168 | * @access protected
169 | * @global wpdb $wpdb The database connection.
170 | * @return array The array of views.
171 | */
172 | public function get_views() {
173 | global $wpdb;
174 |
175 | $type = $this->_get_type_filter();
176 | $type = ( $type !== false ? ' AND type = ' . $type : '' );
177 |
178 | $valid = filter_input( INPUT_GET, 'valid', FILTER_VALIDATE_INT, array(
179 | 'options' => array(
180 | 'min_range' => 0,
181 | 'max_range' => 1,
182 | 'default' => false,
183 | ),
184 | ) );
185 |
186 | $provider = esc_sql( $this->_args['reseller'] );
187 | return array(
188 | 'all' => sprintf(
189 | '%s (%d) ',
190 | esc_url( add_query_arg( array( 'valid' => false, 'paged' => false ) ) ),
191 | !isseT( $_GET['valid'] ) ? ' class="current"' : '',
192 | __( 'All', 'domainmap' ),
193 | intval( $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM " . DOMAINMAP_TABLE_RESELLER_LOG . " WHERE provider = %s" . $type, $provider ) ) )
194 | ),
195 | 'valid' => sprintf(
196 | '%s (%d) ',
197 | esc_url( add_query_arg( array( 'valid' => '1', 'paged' => false ) ) ),
198 | $valid > 0 ? ' class="current"' : '',
199 | __( 'Success', 'domainmap' ),
200 | intval( $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM " . DOMAINMAP_TABLE_RESELLER_LOG . " WHERE provider = %s AND valid > 0" . $type, $provider ) ) )
201 | ),
202 | 'invalid' => sprintf(
203 | '%s (%d) ',
204 | esc_url( add_query_arg( array( 'valid' => '0', 'paged' => false ) ) ),
205 | $valid === 0 ? ' class="current"' : '',
206 | __( 'Failed', 'domainmap' ),
207 | intval( $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM " . DOMAINMAP_TABLE_RESELLER_LOG . " WHERE provider = %s AND valid = 0" . $type, $provider ) ) )
208 | ),
209 | );
210 | }
211 |
212 | /**
213 | * Returns type filter value.
214 | *
215 | * @since 4.0.0
216 | *
217 | * @access private
218 | * @return int Request type filter value.
219 | */
220 | private function _get_type_filter() {
221 | $types = array_keys( Domainmap_Reseller::get_request_types() );
222 | return filter_input( INPUT_GET, 'type', FILTER_VALIDATE_INT, array(
223 | 'options' => array(
224 | 'min_range' => min( $types ),
225 | 'max_range' => max( $types ),
226 | 'default' => false,
227 | ),
228 | ) );
229 | }
230 |
231 | /**
232 | * Fetches records from database.
233 | *
234 | * @since 4.0.0
235 | *
236 | * @access public
237 | * @global wpdb $wpdb The database connection.
238 | */
239 | public function prepare_items() {
240 | global $wpdb;
241 |
242 | parent::prepare_items();
243 | $per_page = 20;
244 | $offset = ( $this->get_pagenum() - 1 ) * $per_page;
245 |
246 | $type = $this->_get_type_filter();
247 | $type = $type !== false ? ' AND l.type = ' . $type : '';
248 |
249 | $valid = filter_input( INPUT_GET, 'valid', FILTER_VALIDATE_INT, array( 'options' => array( 'min_range' => 0, 'max_range' => 1, 'default' => false ) ) );
250 | $valid = $valid !== false ? ' AND l.valid = ' . $valid : '';
251 |
252 | $this->items = $wpdb->get_results( $wpdb->prepare( "
253 | SELECT SQL_CALC_FOUND_ROWS l.id, l.user_id, l.requested_at, l.type, l.valid, l.errors, u.display_name AS user_name
254 | FROM " . DOMAINMAP_TABLE_RESELLER_LOG . " AS l
255 | LEFT JOIN {$wpdb->users} AS u ON u.ID = l.user_id
256 | WHERE l.provider = %s{$type}{$valid}
257 | ORDER BY l.id DESC
258 | LIMIT {$per_page}
259 | OFFSET {$offset}
260 | ",
261 | $this->_args['reseller']
262 | ), ARRAY_A );
263 |
264 | $total_items = $wpdb->get_var( 'SELECT FOUND_ROWS()' );
265 | $this->set_pagination_args( array(
266 | 'total_items' => $total_items,
267 | 'per_page' => $per_page,
268 | 'total_pages' => ceil( $total_items / $per_page )
269 | ) );
270 | }
271 |
272 | /**
273 | * Generates content for a single row of the table.
274 | *
275 | * @since 4.0.0
276 | *
277 | * @access public
278 | * @param arra $item The current item.
279 | */
280 | public function single_row( $item ) {
281 | echo '';
282 | $this->single_row_columns( $item );
283 | echo ' ';
284 | }
285 |
286 | /**
287 | * Extra controls to be displayed between bulk actions and pagination
288 | *
289 | * @since 3.1.0
290 | * @access protected
291 | */
292 | public function extra_tablenav( $which ) {
293 | $current_type = filter_input( INPUT_GET, 'type' );
294 |
295 | ?>
299 |
300 | $label ) :
302 | printf( '%s ',
303 | selected( $type, $current_type, false ),
304 | esc_attr( $type ),
305 | esc_html( $label )
306 | );
307 | endforeach;
308 | ?>
309 | 'post-query-submit' ) );
312 | endif;
313 |
314 | ?>
0, 'b' => 1, 'c' => 2, 'd' => 3, 'e' => 4, 'f' => 5,
64 | 'g' => 6, 'h' => 7, 'i' => 8, 'j' => 9, 'k' => 10, 'l' => 11,
65 | 'm' => 12, 'n' => 13, 'o' => 14, 'p' => 15, 'q' => 16, 'r' => 17,
66 | 's' => 18, 't' => 19, 'u' => 20, 'v' => 21, 'w' => 22, 'x' => 23,
67 | 'y' => 24, 'z' => 25, '0' => 26, '1' => 27, '2' => 28, '3' => 29,
68 | '4' => 30, '5' => 31, '6' => 32, '7' => 33, '8' => 34, '9' => 35
69 | );
70 |
71 | /**
72 | * Encode a domain to its Punycode version
73 | *
74 | * @param string $input Domain name in Unicde to be encoded
75 | * @return string Punycode representation in ASCII
76 | */
77 | public function encode($input)
78 | {
79 | $parts = explode('.', $input);
80 | foreach ($parts as &$part) {
81 | $part = $this->_encodePart($part);
82 | }
83 | return implode('.', $parts);
84 | }
85 |
86 | /**
87 | * Encode a part of a domain name, such as tld, to its Punycode version
88 | *
89 | * @param string $input Part of a domain name
90 | * @return string Punycode representation of a domain part
91 | */
92 | protected function _encodePart($input)
93 | {
94 | $codePoints = $this->_codePoints($input);
95 |
96 | $n = self::INITIAL_N;
97 | $bias = self::INITIAL_BIAS;
98 | $delta = 0;
99 | $h = $b = count($codePoints['basic']);
100 |
101 | $output = '';
102 | foreach ($codePoints['basic'] as $code) {
103 | $output .= $this->_codePointToChar($code);
104 | }
105 | if ($input === $output) {
106 | return $output;
107 | }
108 | if ($b > 0) {
109 | $output .= self::DELIMITER;
110 | }
111 |
112 | $codePoints['nonBasic'] = array_unique($codePoints['nonBasic']);
113 | sort($codePoints['nonBasic']);
114 |
115 | $i = 0;
116 | $length = mb_strlen($input);
117 | while ($h < $length) {
118 | $m = $codePoints['nonBasic'][$i++];
119 | $delta = $delta + ($m - $n) * ($h + 1);
120 | $n = $m;
121 |
122 | foreach ($codePoints['all'] as $c) {
123 | if ($c < $n || $c < self::INITIAL_N) {
124 | $delta++;
125 | }
126 | if ($c === $n) {
127 | $q = $delta;
128 | for ($k = self::BASE;; $k += self::BASE) {
129 | if ($k <= $bias + self::TMIN) {
130 | $t = self::TMIN;
131 | } elseif ($k >= $bias + self::TMAX) {
132 | $t = self::TMAX;
133 | } else {
134 | $t = $k - $bias;
135 | }
136 | if ($q < $t) {
137 | break;
138 | }
139 |
140 | $code = $t + (($q - $t) % (self::BASE - $t));
141 | $output .= self::$_encodeTable[$code];
142 |
143 | $q = ($q - $t) / (self::BASE - $t);
144 | }
145 |
146 | $output .= self::$_encodeTable[$q];
147 | $bias = $this->_adapt($delta, $h + 1, ($h === $b));
148 | $delta = 0;
149 | $h++;
150 | }
151 | }
152 |
153 | $delta++;
154 | $n++;
155 | }
156 |
157 | return self::PREFIX . $output;
158 | }
159 |
160 | /**
161 | * Decode a Punycode domain name to its Unicode counterpart
162 | *
163 | * @param string $input Domain name in Punycode
164 | * @return string Unicode domain name
165 | */
166 | public function decode($input)
167 | {
168 | $parts = explode('.', $input);
169 | foreach ($parts as &$part) {
170 | $part = $this->_decodePart($part);
171 | }
172 | return implode('.', $parts);
173 | }
174 |
175 | /**
176 | * Decode a part of domain name, such as tld
177 | *
178 | * @param string $input Part of a domain name
179 | * @return string Unicode domain part
180 | */
181 | protected function _decodePart($input)
182 | {
183 | if (strpos($input, self::PREFIX) !== 0) {
184 | return $input;
185 | }
186 | $input = ltrim($input, self::PREFIX);
187 |
188 | $n = self::INITIAL_N;
189 | $i = 0;
190 | $bias = self::INITIAL_BIAS;
191 | $output = '';
192 |
193 | $pos = strrpos($input, self::DELIMITER);
194 | if ($pos !== false) {
195 | $output = substr($input, 0, $pos++);
196 | } else {
197 | $pos = 0;
198 | }
199 |
200 | $outputLength = strlen($output);
201 | $inputLength = strlen($input);
202 | while ($pos < $inputLength) {
203 | $oldi = $i;
204 | $w = 1;
205 |
206 | for ($k = self::BASE;; $k += self::BASE) {
207 | $digit = self::$_decodeTable[$input[$pos++]];
208 | $i = $i + ($digit * $w);
209 |
210 | if ($k <= $bias + self::TMIN) {
211 | $t = self::TMIN;
212 | } elseif ($k >= $bias + self::TMAX) {
213 | $t = self::TMAX;
214 | } else {
215 | $t = $k - $bias;
216 | }
217 | if ($digit < $t) {
218 | break;
219 | }
220 |
221 | $w = $w * (self::BASE - $t);
222 | }
223 |
224 | $bias = $this->_adapt($i - $oldi, ++$outputLength, ($oldi === 0));
225 | $n = $n + (int)($i / $outputLength);
226 | $i = $i % ($outputLength);
227 | $output = mb_substr($output, 0, $i) . $this->_codePointToChar($n) . mb_substr($output, $i, $outputLength - 1);
228 |
229 | $i++;
230 | }
231 |
232 | return $output;
233 | }
234 |
235 | /**
236 | * Bias adaptation
237 | *
238 | * @param integer $delta
239 | * @param integer $numPoints
240 | * @param boolean $firstTime
241 | * @return integer
242 | */
243 | protected function _adapt($delta, $numPoints, $firstTime)
244 | {
245 | $delta = (int)(
246 | ($firstTime)
247 | ? $delta / self::DAMP
248 | : $delta / 2
249 | );
250 | $delta += (int)($delta / $numPoints);
251 |
252 | $k = 0;
253 | while ($delta > ((self::BASE - self::TMIN) * self::TMAX) / 2) {
254 | $delta = (int)($delta / (self::BASE - self::TMIN));
255 | $k = $k + self::BASE;
256 | }
257 | $k = $k + (int)(((self::BASE - self::TMIN + 1) * $delta) / ($delta + self::SKEW));
258 |
259 | return $k;
260 | }
261 |
262 | /**
263 | * List code points for a given input
264 | *
265 | * @param string $input
266 | * @return array Multi-dimension array with basic, non-basic and aggregated code points
267 | */
268 | protected function _codePoints($input)
269 | {
270 | $codePoints = array(
271 | 'all' => array(),
272 | 'basic' => array(),
273 | 'nonBasic' => array(),
274 | );
275 |
276 | $length = mb_strlen($input);
277 | for ($i = 0; $i < $length; $i++) {
278 | $char = mb_substr($input, $i, 1);
279 | $code = $this->_charToCodePoint($char);
280 | if ($code < 128) {
281 | $codePoints['all'][] = $codePoints['basic'][] = $code;
282 | } else {
283 | $codePoints['all'][] = $codePoints['nonBasic'][] = $code;
284 | }
285 | }
286 |
287 | return $codePoints;
288 | }
289 |
290 | /**
291 | * Convert a single or multi-byte character to its code point
292 | *
293 | * @param string $char
294 | * @return integer
295 | */
296 | protected function _charToCodePoint($char)
297 | {
298 | $code = ord($char[0]);
299 | if ($code < 128) {
300 | return $code;
301 | } elseif ($code < 224) {
302 | return (($code - 192) * 64) + (ord($char[1]) - 128);
303 | } elseif ($code < 240) {
304 | return (($code - 224) * 4096) + ((ord($char[1]) - 128) * 64) + (ord($char[2]) - 128);
305 | } else {
306 | return (($code - 240) * 262144) + ((ord($char[1]) - 128) * 4096) + ((ord($char[2]) - 128) * 64) + (ord($char[3]) - 128);
307 | }
308 | }
309 |
310 | /**
311 | * Convert a code point to its single or multi-byte character
312 | *
313 | * @param integer $code
314 | * @return string
315 | */
316 | protected function _codePointToChar($code)
317 | {
318 | if ($code <= 0x7F) {
319 | return chr($code);
320 | } elseif ($code <= 0x7FF) {
321 | return chr(($code >> 6) + 192) . chr(($code & 63) + 128);
322 | } elseif ($code <= 0xFFFF) {
323 | return chr(($code >> 12) + 224) . chr((($code >> 6) & 63) + 128) . chr(($code & 63) + 128);
324 | } else {
325 | return chr(($code >> 18) + 240) . chr((($code >> 12) & 63) + 128) . chr((($code >> 6) & 63) + 128) . chr(($code & 63) + 128);
326 | }
327 | }
328 | }
329 |
330 | endif;
--------------------------------------------------------------------------------
/css/bootstrap-glyphs.min.css:
--------------------------------------------------------------------------------
1 | /*!
2 | * Bootstrap v2.3.2
3 | *
4 | * Copyright 2013 Twitter, Inc
5 | * Licensed under the Apache License v2.0
6 | * http://www.apache.org/licenses/LICENSE-2.0
7 | *
8 | * Designed and built with all the love in the world @twitter by @mdo and @fat.
9 | */
10 | .clearfix{*zoom:1;}.clearfix:before,.clearfix:after{display:table;content:"";line-height:0;}
11 | .clearfix:after{clear:both;}
12 | .hide-text{font:0/0 a;color:transparent;text-shadow:none;background-color:transparent;border:0;}
13 | .input-block-level{display:block;width:100%;min-height:30px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;}
14 | [class^="icon-"],[class*=" icon-"]{display:inline-block;width:14px;height:14px;*margin-right:.3em;line-height:14px;vertical-align:text-top;background-image:url("../images/glyphicons-halflings.png");background-position:14px 14px;background-repeat:no-repeat;margin-top:1px;}
15 | .icon-white{background-image:url("../images/glyphicons-halflings-white.png");}
16 | .icon-glass{background-position:0 0;}
17 | .icon-music{background-position:-24px 0;}
18 | .icon-search{background-position:-48px 0;}
19 | .icon-envelope{background-position:-72px 0;}
20 | .icon-heart{background-position:-96px 0;}
21 | .icon-star{background-position:-120px 0;}
22 | .icon-star-empty{background-position:-144px 0;}
23 | .icon-user{background-position:-168px 0;}
24 | .icon-film{background-position:-192px 0;}
25 | .icon-th-large{background-position:-216px 0;}
26 | .icon-th{background-position:-240px 0;}
27 | .icon-th-list{background-position:-264px 0;}
28 | .icon-ok{background-position:-288px 0;}
29 | .icon-remove{background-position:-312px 0;}
30 | .icon-zoom-in{background-position:-336px 0;}
31 | .icon-zoom-out{background-position:-360px 0;}
32 | .icon-off{background-position:-384px 0;}
33 | .icon-signal{background-position:-408px 0;}
34 | .icon-cog{background-position:-432px 0;}
35 | .icon-trash{background-position:-456px 0;}
36 | .icon-home{background-position:0 -24px;}
37 | .icon-file{background-position:-24px -24px;}
38 | .icon-time{background-position:-48px -24px;}
39 | .icon-road{background-position:-72px -24px;}
40 | .icon-download-alt{background-position:-96px -24px;}
41 | .icon-download{background-position:-120px -24px;}
42 | .icon-upload{background-position:-144px -24px;}
43 | .icon-inbox{background-position:-168px -24px;}
44 | .icon-play-circle{background-position:-192px -24px;}
45 | .icon-repeat{background-position:-216px -24px;}
46 | .icon-refresh{background-position:-240px -24px;}
47 | .icon-list-alt{background-position:-264px -24px;}
48 | .icon-lock{background-position:-287px -24px;}
49 | .icon-flag{background-position:-312px -24px;}
50 | .icon-headphones{background-position:-336px -24px;}
51 | .icon-volume-off{background-position:-360px -24px;}
52 | .icon-volume-down{background-position:-384px -24px;}
53 | .icon-volume-up{background-position:-408px -24px;}
54 | .icon-qrcode{background-position:-432px -24px;}
55 | .icon-barcode{background-position:-456px -24px;}
56 | .icon-tag{background-position:0 -48px;}
57 | .icon-tags{background-position:-25px -48px;}
58 | .icon-book{background-position:-48px -48px;}
59 | .icon-bookmark{background-position:-72px -48px;}
60 | .icon-print{background-position:-96px -48px;}
61 | .icon-camera{background-position:-120px -48px;}
62 | .icon-font{background-position:-144px -48px;}
63 | .icon-bold{background-position:-167px -48px;}
64 | .icon-italic{background-position:-192px -48px;}
65 | .icon-text-height{background-position:-216px -48px;}
66 | .icon-text-width{background-position:-240px -48px;}
67 | .icon-align-left{background-position:-264px -48px;}
68 | .icon-align-center{background-position:-288px -48px;}
69 | .icon-align-right{background-position:-312px -48px;}
70 | .icon-align-justify{background-position:-336px -48px;}
71 | .icon-list{background-position:-360px -48px;}
72 | .icon-indent-left{background-position:-384px -48px;}
73 | .icon-indent-right{background-position:-408px -48px;}
74 | .icon-facetime-video{background-position:-432px -48px;}
75 | .icon-picture{background-position:-456px -48px;}
76 | .icon-pencil{background-position:0 -72px;}
77 | .icon-map-marker{background-position:-24px -72px;}
78 | .icon-adjust{background-position:-48px -72px;}
79 | .icon-tint{background-position:-72px -72px;}
80 | .icon-edit{background-position:-96px -72px;}
81 | .icon-share{background-position:-120px -72px;}
82 | .icon-check{background-position:-144px -72px;}
83 | .icon-move{background-position:-168px -72px;}
84 | .icon-step-backward{background-position:-192px -72px;}
85 | .icon-fast-backward{background-position:-216px -72px;}
86 | .icon-backward{background-position:-240px -72px;}
87 | .icon-play{background-position:-264px -72px;}
88 | .icon-pause{background-position:-288px -72px;}
89 | .icon-stop{background-position:-312px -72px;}
90 | .icon-forward{background-position:-336px -72px;}
91 | .icon-fast-forward{background-position:-360px -72px;}
92 | .icon-step-forward{background-position:-384px -72px;}
93 | .icon-eject{background-position:-408px -72px;}
94 | .icon-chevron-left{background-position:-432px -72px;}
95 | .icon-chevron-right{background-position:-456px -72px;}
96 | .icon-plus-sign{background-position:0 -96px;}
97 | .icon-minus-sign{background-position:-24px -96px;}
98 | .icon-remove-sign{background-position:-48px -96px;}
99 | .icon-ok-sign{background-position:-72px -96px;}
100 | .icon-question-sign{background-position:-96px -96px;}
101 | .icon-info-sign{background-position:-120px -96px;}
102 | .icon-screenshot{background-position:-144px -96px;}
103 | .icon-remove-circle{background-position:-168px -96px;}
104 | .icon-ok-circle{background-position:-192px -96px;}
105 | .icon-ban-circle{background-position:-216px -96px;}
106 | .icon-arrow-left{background-position:-240px -96px;}
107 | .icon-arrow-right{background-position:-264px -96px;}
108 | .icon-arrow-up{background-position:-289px -96px;}
109 | .icon-arrow-down{background-position:-312px -96px;}
110 | .icon-share-alt{background-position:-336px -96px;}
111 | .icon-resize-full{background-position:-360px -96px;}
112 | .icon-resize-small{background-position:-384px -96px;}
113 | .icon-plus{background-position:-408px -96px;}
114 | .icon-minus{background-position:-433px -96px;}
115 | .icon-asterisk{background-position:-456px -96px;}
116 | .icon-exclamation-sign{background-position:0 -120px;}
117 | .icon-gift{background-position:-24px -120px;}
118 | .icon-leaf{background-position:-48px -120px;}
119 | .icon-fire{background-position:-72px -120px;}
120 | .icon-eye-open{background-position:-96px -120px;}
121 | .icon-eye-close{background-position:-120px -120px;}
122 | .icon-warning-sign{background-position:-144px -120px;}
123 | .icon-plane{background-position:-168px -120px;}
124 | .icon-calendar{background-position:-192px -120px;}
125 | .icon-random{background-position:-216px -120px;width:16px;}
126 | .icon-comment{background-position:-240px -120px;}
127 | .icon-magnet{background-position:-264px -120px;}
128 | .icon-chevron-up{background-position:-288px -120px;}
129 | .icon-chevron-down{background-position:-313px -119px;}
130 | .icon-retweet{background-position:-336px -120px;}
131 | .icon-shopping-cart{background-position:-360px -120px;}
132 | .icon-folder-close{background-position:-384px -120px;width:16px;}
133 | .icon-folder-open{background-position:-408px -120px;width:16px;}
134 | .icon-resize-vertical{background-position:-432px -119px;}
135 | .icon-resize-horizontal{background-position:-456px -118px;}
136 | .icon-hdd{background-position:0 -144px;}
137 | .icon-bullhorn{background-position:-24px -144px;}
138 | .icon-bell{background-position:-48px -144px;}
139 | .icon-certificate{background-position:-72px -144px;}
140 | .icon-thumbs-up{background-position:-96px -144px;}
141 | .icon-thumbs-down{background-position:-120px -144px;}
142 | .icon-hand-right{background-position:-144px -144px;}
143 | .icon-hand-left{background-position:-168px -144px;}
144 | .icon-hand-up{background-position:-192px -144px;}
145 | .icon-hand-down{background-position:-216px -144px;}
146 | .icon-circle-arrow-right{background-position:-240px -144px;}
147 | .icon-circle-arrow-left{background-position:-264px -144px;}
148 | .icon-circle-arrow-up{background-position:-288px -144px;}
149 | .icon-circle-arrow-down{background-position:-312px -144px;}
150 | .icon-globe{background-position:-336px -144px;}
151 | .icon-wrench{background-position:-360px -144px;}
152 | .icon-tasks{background-position:-384px -144px;}
153 | .icon-filter{background-position:-408px -144px;}
154 | .icon-briefcase{background-position:-432px -144px;}
155 | .icon-fullscreen{background-position:-456px -144px;}
--------------------------------------------------------------------------------
/domain-mapping.php:
--------------------------------------------------------------------------------
1 | base_prefix ) ? $wpdb->base_prefix : $wpdb->prefix;
109 | define( 'DOMAINMAP_TABLE_MAP', "{$prefix}domain_mapping" );
110 | define( 'DOMAINMAP_TABLE_RESELLER_LOG', "{$prefix}domain_mapping_reseller_log" );
111 |
112 | // MultiDB compatibility, register global tables
113 | if ( defined( 'MULTI_DB_VERSION' ) && function_exists( 'add_global_table' ) ) {
114 | add_global_table( 'domain_mapping' );
115 | add_global_table( 'domain_mapping_reseller_log' );
116 | }
117 | }
118 |
119 | /**
120 | * Instantiates the plugin and setup all modules.
121 | *
122 | * @since 4.0.0
123 | *
124 | * @global domain_map $dm_map The instance of domain_map class.
125 | */
126 | function domainmap_launch() {
127 | global $dm_map;
128 |
129 | domainmap_setup_constants();
130 |
131 | // set up the plugin core class
132 | $dm_map = new domain_map();
133 |
134 | // instantiate the plugin
135 | $plugin = Domainmap_Plugin::instance();
136 |
137 | // set general modules
138 | $plugin->set_module( Domainmap_Module_System::NAME );
139 | $plugin->set_module( Domainmap_Module_Setup::NAME );
140 | $plugin->set_module( Domainmap_Module_Mapping::NAME );
141 |
142 | // CDSSO module
143 | if ( defined( 'SUNRISE' ) && filter_var( SUNRISE, FILTER_VALIDATE_BOOLEAN ) && $plugin->get_option( 'map_crossautologin' ) ) {
144 | $plugin->set_module( Domainmap_Module_Cdsso::NAME );
145 | }
146 |
147 | // conditional modules
148 | if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
149 | // suppresses errors rendering to prevent unexpected issues
150 | set_error_handler( '__return_true' );
151 | set_exception_handler( '__return_true' );
152 |
153 | // set ajax modules
154 | $plugin->set_module( Domainmap_Module_Ajax_Map::NAME );
155 | $plugin->set_module( Domainmap_Module_Ajax_Purchase::NAME );
156 | $plugin->set_module( Domainmap_Module_Ajax_Register::NAME );
157 | } else {
158 | if ( is_admin() ) {
159 | // set admin modules
160 | $plugin->set_module( Domainmap_Module_Pages::NAME );
161 | $plugin->set_module( Domainmap_Module_Admin::NAME );
162 | }
163 | }
164 |
165 |
166 | }
167 |
168 | // register autoloader function
169 | spl_autoload_register( 'domainmap_autoloader' );
170 |
171 | // launch the plugin
172 | domainmap_launch();
173 |
174 | function domainmap_plugin_activate() {
175 | do_action("domainmap_plugin_activated");
176 | }
177 | register_activation_hook( __FILE__, 'domainmap_plugin_activate' );
178 |
179 | function domainmap_plugin_deactivate() {
180 | do_action("domainmap_plugin_deactivated");
181 | }
182 | register_deactivation_hook( __FILE__, 'domainmap_plugin_deactivate' );
183 | /*================== Global Functions =======================*/
184 |
185 | /**
186 | * Retrieves respective site url with original domain for current site checking weather it's an ssl connection
187 | *
188 | * Returns the 'site_url' option or unswapped site url if it's and ssl connection with the appropriate protocol, 'https' if
189 | * is_ssl() and 'http' otherwise. If $scheme is 'http' or 'https', is_ssl() is
190 | * overridden.
191 | *
192 | * @since 4.1.3
193 | *
194 | * @uses site_url()
195 | *
196 | * @param string $path Optional. Path relative to the site url.
197 | * @param string $scheme Optional. Scheme to give the site url context. See set_url_scheme().
198 | * @return string Site url link with optional path appended.
199 | */
200 | function dm_site_url( $path = '', $scheme = null ){
201 | $current_site_url = site_url( $path, $scheme );
202 | return domain_map::utils()->unswap_url( $current_site_url, false, (bool) $path );
203 | }
204 |
205 | /**
206 | * Retrieves respective home url with original domain for current site checking weather it's an ssl connection
207 | *
208 | * Returns the 'home' option or unswapped home url if it's and ssl connection with the appropriate protocol, 'https' if
209 | * is_ssl() and 'http' otherwise. If $scheme is 'http' or 'https', is_ssl() is
210 | * overridden.
211 | *
212 | * @since 4.1.3
213 | *
214 | * @uses home_url()
215 | *
216 | * @param string $path Optional. Path relative to the site url.
217 | * @param string $scheme Optional. Scheme to give the site url context. See set_url_scheme().
218 | * @return string Site url link with optional path appended.
219 | */
220 | function dm_home_url( $path = '', $scheme = null ){
221 | $current_home_url = home_url( $path, $scheme );
222 | return domain_map::utils()->unswap_url( $current_home_url, false, (bool) $path );
223 | }
224 |
225 |
--------------------------------------------------------------------------------
/humans.txt:
--------------------------------------------------------------------------------
1 | /* TEAM */
2 | Developer: Barry
3 | Contact:
4 | Twitter: @caffeinatedwp
5 | Location:
6 |
7 | Developer: Eugene Manuilov
8 | Location: Kiev, Ukraine
9 | Contact: eugene[at]incsub[dot]com
10 | Twitter: @eugene_manuilov
11 |
12 | Developer: Aaron Edwards
13 | Location: Dallas, TX
14 | Contact: aaron[at]incsub[dot]com
15 | Twitter: @UglyRobotDev
16 |
17 | Developer : Sam Najian
18 | Location : Tehran, Iran
19 | Contact : sam[at]incsub[dot]com
20 | Twitter : @samnajian
21 |
--------------------------------------------------------------------------------
/images/ajax-loader-big.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wpmudev/domain-mapping/215ee59e03844c80bb22ee0cc8838f4c44ab8fb8/images/ajax-loader-big.gif
--------------------------------------------------------------------------------
/images/ajax-loader-small.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wpmudev/domain-mapping/215ee59e03844c80bb22ee0cc8838f4c44ab8fb8/images/ajax-loader-small.gif
--------------------------------------------------------------------------------
/images/enom.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wpmudev/domain-mapping/215ee59e03844c80bb22ee0cc8838f4c44ab8fb8/images/enom.png
--------------------------------------------------------------------------------
/images/glyphicons-halflings-white.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wpmudev/domain-mapping/215ee59e03844c80bb22ee0cc8838f4c44ab8fb8/images/glyphicons-halflings-white.png
--------------------------------------------------------------------------------
/images/glyphicons-halflings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wpmudev/domain-mapping/215ee59e03844c80bb22ee0cc8838f4c44ab8fb8/images/glyphicons-halflings.png
--------------------------------------------------------------------------------
/images/texture.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wpmudev/domain-mapping/215ee59e03844c80bb22ee0cc8838f4c44ab8fb8/images/texture.png
--------------------------------------------------------------------------------
/inc/DM_Currencies.php:
--------------------------------------------------------------------------------
1 | array("Albania, Leke", "4c, 65, 6b"),
8 | "AFN"=> array("Afghanistan, Afghanis", "60b"),
9 | "ARS"=> array("Argentina, Pesos", "24"),
10 | "AWG"=> array("Aruba, Guilders (also called Florins)", "192"),
11 | "AUD"=> array("Australia, Dollars", "24"),
12 | "AZN"=> array("Azerbaijan, New Manats", "43c, 430, 43d"),
13 | "BSD"=> array("Bahamas, Dollars", "24"),
14 | "BBD"=> array("Barbados, Dollars", "24"),
15 | "BYR"=> array("Belarus, Rubles", "70, 2e"),
16 | "BZD"=> array("Belize, Dollars", "42, 5a, 24"),
17 | "BMD"=> array("Bermuda, Dollars", "24"),
18 | "BOB"=> array("Bolivia, Bolivianos", "24, 62"),
19 | "BAM"=> array("Bosnia and Herzegovina, Convertible Marka", "4b, 4d"),
20 | "BWP"=> array("Botswana, Pulas", "50"),
21 | "BGN"=> array("Bulgaria, Leva", "43b, 432"),
22 | "BRL"=> array("Brazil, Reais", "52, 24"),
23 | "BND"=> array("Brunei Darussalam, Dollars", "24"),
24 | "KHR"=> array("Cambodia, Riels", "17db"),
25 | "CAD"=> array("Canada, Dollars", "24"),
26 | "KYD"=> array("Cayman Islands, Dollars", "24"),
27 | "CLP"=> array("Chile, Pesos", "24"),
28 | "CNY"=> array("China, Yuan Renminbi", "a5"),
29 | "COP"=> array("Colombia, Pesos", "24"),
30 | "CRC"=> array("Costa Rica, Colon", "20a1"),
31 | "HRK"=> array("Croatia, Kuna", "6b, 6e"),
32 | "CUP"=> array("Cuba, Pesos", "20b1"),
33 | "CZK"=> array("Czech Republic, Koruny", "4b, 10d"),
34 | "DKK"=> array("Denmark, Kroner", "6b, 72"),
35 | "DOP"=> array("Dominican Republic, Pesos", "52, 44, 24"),
36 | "XCD"=> array("East Caribbean, Dollars", "24"),
37 | "EGP"=> array("Egypt, Pounds", "45, 47, 50"),
38 | "SVC"=> array("El Salvador, Colones", "24"),
39 | "EEK"=> array("Estonia, Krooni", "6b, 72"),
40 | "EUR"=> array("Euro", "20ac"),
41 | "FKP"=> array("Falkland Islands, Pounds", "a3"),
42 | "FJD"=> array("Fiji, Dollars", "24"),
43 | "GEL"=> array("Georgia, lari", "6c, 61, 72, 69"),
44 | "GHC"=> array("Ghana, Cedis", "a2"),
45 | "GIP"=> array("Gibraltar, Pounds", "a3"),
46 | "GTQ"=> array("Guatemala, Quetzales", "51"),
47 | "GGP"=> array("Guernsey, Pounds", "a3"),
48 | "GYD"=> array("Guyana, Dollars", "24"),
49 | "HNL"=> array("Honduras, Lempiras", "4c"),
50 | "HKD"=> array("Hong Kong, Dollars", "24"),
51 | "HUF"=> array("Hungary, Forint", "46, 74"),
52 | "ISK"=> array("Iceland, Kronur", "6b, 72"),
53 | "INR"=> array("India, Rupees", "20a8"),
54 | "IDR"=> array("Indonesia, Rupiahs", "52, 70"),
55 | "IRR"=> array("Iran, Rials", "fdfc"),
56 | "IMP"=> array("Isle of Man, Pounds", "a3"),
57 | "ILS"=> array("Israel, New Shekels", "20aa"),
58 | "JMD"=> array("Jamaica, Dollars", "4a, 24"),
59 | "JPY"=> array("Japan, Yen", "a5"),
60 | "JEP"=> array("Jersey, Pounds", "a3"),
61 | "KZT"=> array("Kazakhstan, Tenge", "43b, 432"),
62 | "KES"=> array("Kenyan Shilling", "4B, 73, 68, 73"),
63 | "KWD"=> array("Kuwait, dinar", "4B, 2E, 44, 2E"),
64 | "KGS"=> array("Kyrgyzstan, Soms", "43b, 432"),
65 | "LAK"=> array("Laos, Kips", "20ad"),
66 | "LVL"=> array("Latvia, Lati", "4c, 73"),
67 | "LBP"=> array("Lebanon, Pounds", "a3"),
68 | "LRD"=> array("Liberia, Dollars", "24"),
69 | "LTL"=> array("Lithuania, Litai", "4c, 74"),
70 | "MKD"=> array("Macedonia, Denars", "434, 435, 43d"),
71 | "MYR"=> array("Malaysia, Ringgits", "52, 4d"),
72 | "MUR"=> array("Mauritius, Rupees", "20a8"),
73 | "MXN"=> array("Mexico, Pesos", "24"),
74 | "MNT"=> array("Mongolia, Tugriks", "20ae"),
75 | "MAD"=> array("Morocco, dirhams", "64, 68"),
76 | "MZN"=> array("Mozambique, Meticais", "4d, 54"),
77 | "NAD"=> array("Namibia, Dollars", "24"),
78 | "NPR"=> array("Nepal, Rupees", "20a8"),
79 | "ANG"=> array("Netherlands Antilles, Guilders (also called Florins)", "192"),
80 | "NZD"=> array("New Zealand, Dollars", "24"),
81 | "NIO"=> array("Nicaragua, Cordobas", "43, 24"),
82 | "NGN"=> array("Nigeria, Nairas", "20a6"),
83 | "KPW"=> array("North Korea, Won", "20a9"),
84 | "NOK"=> array("Norway, Krone", "6b, 72"),
85 | "OMR"=> array("Oman, Rials", "fdfc"),
86 | "PKR"=> array("Pakistan, Rupees", "20a8"),
87 | "PAB"=> array("Panama, Balboa", "42, 2f, 2e"),
88 | "PYG"=> array("Paraguay, Guarani", "47, 73"),
89 | "PEN"=> array("Peru, Nuevos Soles", "53, 2f, 2e"),
90 | "PHP"=> array("Philippines, Pesos", "50, 68, 70"),
91 | "PLN"=> array("Poland, Zlotych", "7a, 142"),
92 | "QAR"=> array("Qatar, Rials", "fdfc"),
93 | "RON"=> array("Romania, New Lei", "6c, 65, 69"),
94 | "RUB"=> array("Russia, Rubles", "440, 443, 431"),
95 | "SHP"=> array("Saint Helena, Pounds", "a3"),
96 | "SAR"=> array("Saudi Arabia, Riyals", "fdfc"),
97 | "RSD"=> array("Serbia, Dinars", "414, 438, 43d, 2e"),
98 | "SCR"=> array("Seychelles, Rupees", "20a8"),
99 | "SGD"=> array("Singapore, Dollars", "24"),
100 | "SBD"=> array("Solomon Islands, Dollars", "24"),
101 | "SOS"=> array("Somalia, Shillings", "53"),
102 | "ZAR"=> array("South Africa, Rand", "52"),
103 | "KRW"=> array("South Korea, Won", "20a9"),
104 | "LKR"=> array("Sri Lanka, Rupees", "20a8"),
105 | "SEK"=> array("Sweden, Kronor", "6b, 72"),
106 | "CHF"=> array("Switzerland, Francs", "43, 48, 46"),
107 | "SRD"=> array("Suriname, Dollars", "24"),
108 | "SYP"=> array("Syria, Pounds", "a3"),
109 | "TWD"=> array("Taiwan, New Dollars", "4e, 54, 24"),
110 | "THB"=> array("Thailand, Baht", "e3f"),
111 | "TTD"=> array("Trinidad and Tobago, Dollars", "54, 54, 24"),
112 | "TRY"=> array("Turkey, Lira", "54, 4c"),
113 | "TRL"=> array("Turkey, Liras", "20a4"),
114 | "TVD"=> array("Tuvalu, Dollars", "24"),
115 | "UAH"=> array("Ukraine, Hryvnia", "20b4"),
116 | "AED"=> array("United Arab Emirates, dirhams", "64, 68"),
117 | "GBP"=> array("United Kingdom, Pounds", "a3"),
118 | "USD"=> array("United States of America, Dollars", "24"),
119 | "UYU"=> array("Uruguay, Pesos", "24, 55"),
120 | "UZS"=> array("Uzbekistan, Sums", "43b, 432"),
121 | "VEF"=> array("Venezuela, Bolivares Fuertes", "42, 73"),
122 | "VND"=> array("Vietnam, Dong", "20ab"),
123 | "XAF"=> array("BEAC, CFA Francs", "46, 43, 46, 41"),
124 | "XOF"=> array("BCEAO, CFA Francs", "46, 43, 46, 41"),
125 | "YER"=> array("Yemen, Rials", "fdfc"),
126 | "ZWD"=> array("Zimbabwe, Zimbabwe Dollars", "5a, 24"),
127 | "POINTS"=> array("Points (for point based stores)", "50, 6f, 69, 6e, 74, 73"),
128 | "CREDITS"=> array("Credits (for credit based stores)", "43, 72, 65, 64, 69, 74, 73")
129 | );
130 |
131 | public static function get_symbol($currency = '') {
132 |
133 | if ( !$currency ) {
134 | $currency = 'USD';
135 | }
136 |
137 | // get the currency symbol
138 | $symbol = self::$_currencies[ $currency ][1];
139 | // if many symbols are found, rebuild the full symbol
140 | $symbols = explode( ', ', $symbol );
141 | if ( is_array( $symbols ) ) {
142 | $symbol = "";
143 | foreach ( $symbols as $temp ) {
144 | $symbol .= '' . $temp . ';';
145 | }
146 | } else {
147 | $symbol = '' . $symbol . ';';
148 | }
149 | return $symbol;
150 | }
151 |
152 | public static function get_currency_list(){
153 | return self::$_currencies;
154 | }
155 | }
--------------------------------------------------------------------------------
/inc/sunrise.php:
--------------------------------------------------------------------------------
1 | get_var("SELECT `meta_value` FROM " . $wpdb->sitemeta ." WHERE `meta_key`='active_sitewide_plugins'") );
17 | // Set to cache.
18 | wp_cache_set( 'dm_active_plugins', $dmmd_active_plugins );
19 | }
20 |
21 | return is_array( $dmmd_active_plugins ) ? in_array( 'domain-mapping/domain-mapping.php', array_keys( $dmmd_active_plugins ) ) : false;
22 | }
23 |
24 | // If domain mapping is not active, bail.
25 | if ( ! domainmapping_is_dm_active() ) {
26 | return;
27 | }
28 |
29 | // Define the current version of file.
30 | define( 'DOMAINMAPPING_SUNRISE_VERSION', '1.0.3.1' );
31 |
32 | global $wpdb;
33 |
34 | // Domain mapping plugin to handle VHOST and non VHOST installation.
35 |
36 | // DM database table.
37 | $wpdb->dmtable = ( isset( $wpdb->base_prefix ) ? $wpdb->base_prefix : $wpdb->prefix ) . 'domain_mapping';
38 |
39 | // If cookie domain is not set.
40 | if ( defined( 'COOKIE_DOMAIN' ) ) {
41 | define( 'COOKIE_DOMAIN_ERROR', true );
42 | }
43 |
44 | // Get the current domain.
45 | $using_domain = strtolower( preg_replace( "/^www\./", "", $_SERVER['HTTP_HOST'] ) );
46 |
47 | // Set cookie domain.
48 | define( 'COOKIE_DOMAIN', $_SERVER['HTTP_HOST'] );
49 |
50 | $s_e = $wpdb->suppress_errors();
51 |
52 | // Check for the domain with and without the www. prefix
53 | $mapped = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->dmtable} WHERE active=1 AND ( domain = %s OR domain = %s ) LIMIT 1", $using_domain, "www.{$using_domain}" ), OBJECT );
54 |
55 | // Do not show db errors.
56 | $wpdb->suppress_errors( $s_e );
57 |
58 | // If not empty, continue.
59 | if ( ! empty( $mapped ) ) {
60 | // Set to globals.
61 | $GLOBALS['dm_mapped'] = $mapped;
62 |
63 | // Get blog data.
64 | $current_blog = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->blogs} WHERE blog_id = %d LIMIT 1", $mapped->blog_id ) );
65 | // Set the domain to current domain.
66 | $current_blog->domain = $_SERVER['HTTP_HOST'];
67 |
68 | // Get the blog id and site id.
69 | $blog_id = $mapped->blog_id;
70 | $site_id = $current_blog->site_id;
71 |
72 | // Get the site.
73 | $current_site = $wpdb->get_row( $wpdb->prepare( "SELECT * from {$wpdb->site} WHERE id = %d LIMIT 1", $current_blog->site_id ) );
74 | // Set the blog id.
75 | $current_site->blog_id = $wpdb->get_var( $wpdb->prepare( "SELECT blog_id FROM {$wpdb->blogs} WHERE domain = %s AND path = %s", $current_site->domain, $current_site->path ) );
76 |
77 | global $wp_version;
78 |
79 | // The function get_current_site_name is deprecated as of 3.9.
80 | if ( version_compare( $wp_version, '3.9', '<' ) && function_exists( 'get_current_site_name' ) ) {
81 | $current_site = get_current_site_name( $current_site );
82 | }
83 |
84 | // Set site_name value.
85 | if ( ! isset( $current_site->site_name ) || empty( $current_site->site_name ) ) {
86 | // Set from cache.
87 | $current_site->site_name = wp_cache_get( $current_site->id . ':site_name', 'site-options' );
88 | // If not available, get now.
89 | if ( ! $current_site->site_name ) {
90 | // Get from db.
91 | $current_site->site_name = $wpdb->get_var( $wpdb->prepare( "SELECT meta_value FROM $wpdb->sitemeta WHERE site_id = %d AND meta_key = 'site_name'", $current_site->id ) );
92 | // Use the domain name as fallback.
93 | if ( ! $current_site->site_name ) {
94 | $current_site->site_name = ucfirst( $current_site->domain );
95 | }
96 |
97 | // Set to cache.
98 | wp_cache_set( $current_site->id . ':site_name', $current_site->site_name, 'site-options' );
99 | }
100 | }
101 |
102 | // Set current path.
103 | $current_blog->path = $current_site->path;
104 |
105 | // Domain mapping flag.
106 | define( 'DOMAIN_MAPPING', 1 );
107 |
108 | // Added for belt and braces.
109 | if ( ! defined( 'WP_CONTENT_URL' ) ) {
110 | // Full url - WP_CONTENT_DIR is defined further up.
111 | define( 'WP_CONTENT_URL', ( is_ssl() ? 'https://' : 'http://' ) . $current_blog->domain . $current_blog->path . 'wp-content' );
112 | }
113 | }
114 |
115 | // Clean up temporary variables.
116 | unset( $s_e, $using_domain );
117 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/languages/domainmap-en_US.mo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wpmudev/domain-mapping/215ee59e03844c80bb22ee0cc8838f4c44ab8fb8/languages/domainmap-en_US.mo
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/sunrise.php:
--------------------------------------------------------------------------------
1 | defined("DM_CUSTOM_SUNRISE") ? DM_CUSTOM_SUNRISE : ( defined( "WP_PLUGIN_DIR" ) ? rtrim( WP_PLUGIN_DIR, '/\\' ) . "/domain-mapping/inc/sunrise.php" : dirname( __FILE__ ) . "/plugins/domain-mapping/inc/sunrise.php" ),
4 | "md_sunrise" => defined("MD_CUSTOM_SUNRISE") ? MD_CUSTOM_SUNRISE : ( defined( "WP_PLUGIN_DIR" ) ? rtrim( WP_PLUGIN_DIR, '/\\' ) . "/multi-domains/inc/sunrise.php" : dirname( __FILE__ ) . "/plugins/multi-domains/inc/sunrise.php" )
5 | );
6 |
7 | foreach( $sunrises as $sunrise ){
8 | if( is_readable( $sunrise ) ){
9 | include $sunrise;
10 | }
11 | }
--------------------------------------------------------------------------------