@@ -135,123 +135,15 @@ public function get_source_query() {
135
135
return '' ;
136
136
}
137
137
138
- /**
139
- * Returns an array of nameservers for the current site.
140
- *
141
- * @param string $domain The domain of the site to check.
142
- * @return array
143
- */
144
- public function get_nameserver_dns_records ( $ domain ) {
145
- if ( ! function_exists ( 'dns_get_record ' ) ) {
146
- return array ();
147
- }
148
-
149
- $ dns_records = dns_get_record ( $ domain , DNS_NS ); // Fetches the DNS records of type NS (Name Server)
150
- if ( false === $ dns_records ) {
151
- return array ();
152
- }
153
-
154
- $ nameservers = array ();
155
- foreach ( $ dns_records as $ record ) {
156
- if ( isset ( $ record ['target ' ] ) ) {
157
- $ nameservers [] = $ record ['target ' ]; // Adds the nameserver to the array
158
- }
159
- }
160
-
161
- return $ nameservers ; // Returns an array of nameserver names
162
- }
163
-
164
- /**
165
- * Given a DNS entry, will return a hosting provider if one can be determined. Otherwise, will return 'unknown'.
166
- * Sourced from: fbhepr%2Skers%2Sjcpbz%2Sjc%2Qpbagrag%2Syvo%2Subfgvat%2Qcebivqre%2Sanzrfreiref.cuc-og
167
- *
168
- * @param string $domain The domain of the site to check.
169
- * @return string The hosting provider of 'unknown'.
170
- */
171
- public function get_hosting_provider_by_nameserver ( $ domain ) {
172
- $ known_nameservers = array (
173
- 'bluehost ' => array (
174
- '.bluehost.com ' ,
175
- ),
176
- 'dreamhost ' => array (
177
- '.dreamhost.com ' ,
178
- ),
179
- 'mediatemple ' => array (
180
- '.mediatemple.net ' ,
181
- ),
182
- 'xserver ' => array (
183
- '.xserver.jp ' ,
184
- ),
185
- 'namecheap ' => array (
186
- '.namecheaphosting.com ' ,
187
- ),
188
- 'hostmonster ' => array (
189
- '.hostmonster.com ' ,
190
- ),
191
- 'justhost ' => array (
192
- '.justhost.com ' ,
193
- ),
194
- 'digitalocean ' => array (
195
- '.digitalocean.com ' ,
196
- ),
197
- 'one ' => array (
198
- '.one.com ' ,
199
- ),
200
- 'hostpapa ' => array (
201
- '.hostpapa.com ' ,
202
- ),
203
- 'siteground ' => array (
204
- '.sgcloud.net ' ,
205
- '.sgedu.site ' ,
206
- '.sgsrv1.com ' ,
207
- '.sgvps.net ' ,
208
- '.siteground.biz ' ,
209
- '.siteground.net ' ,
210
- '.siteground.eu ' ,
211
- ),
212
- 'inmotion ' => array (
213
- '.inmotionhosting.com ' ,
214
- ),
215
- 'ionos ' => array (
216
- '.ui-dns.org ' ,
217
- '.ui-dns.de ' ,
218
- '.ui-dns.biz ' ,
219
- '.ui-dns.com ' ,
220
- ),
221
- );
222
-
223
- $ dns_records = $ this ->get_nameserver_dns_records ( $ domain );
224
- $ dns_records = array_map ( 'strtolower ' , $ dns_records );
225
-
226
- foreach ( $ known_nameservers as $ host => $ ns_patterns ) {
227
- foreach ( $ ns_patterns as $ ns_pattern ) {
228
- foreach ( $ dns_records as $ record ) {
229
- if ( false !== strpos ( $ record , $ ns_pattern ) ) {
230
- return $ host ;
231
- }
232
- }
233
- }
234
- }
235
-
236
- return 'unknown ' ;
237
- }
238
-
239
138
/**
240
139
* Returns a guess of the hosting provider for the current site based on various checks.
241
140
*
242
141
* @since 5.0.4 Added $guess parameter.
243
- *
244
- * @param bool $guess Whether to guess the hosting provider.
142
+ * @since 5.4.1-alpha Removed $guess parameter.
245
143
*
246
144
* @return string
247
145
*/
248
- public function get_known_host_guess ( $ guess = true ) {
249
- $ host = Cache::get ( 'host_guess ' );
250
-
251
- if ( null !== $ host ) {
252
- return $ host ;
253
- }
254
-
146
+ public function get_known_host_guess () {
255
147
// First, let's check if we can recognize provider manually:
256
148
switch ( true ) {
257
149
case $ this ->is_woa_site ():
@@ -275,14 +167,6 @@ public function get_known_host_guess( $guess = true ) {
275
167
break ;
276
168
}
277
169
278
- // Second, let's check if we can recognize provider by nameservers.
279
- // Only do this if we're asked to guess.
280
- $ domain = isset ( $ _SERVER ['SERVER_NAME ' ] ) ? sanitize_text_field ( wp_unslash ( $ _SERVER ['SERVER_NAME ' ] ) ) : '' ;
281
- if ( $ provider === 'unknown ' && ! empty ( $ domain ) && $ guess ) {
282
- $ provider = $ this ->get_hosting_provider_by_nameserver ( $ domain );
283
- }
284
-
285
- Cache::set ( 'host_guess ' , $ provider );
286
170
return $ provider ;
287
171
}
288
172
0 commit comments