PluginProbe
SureCart – Ecommerce Made Easy For Selling Physical Products, Digital Downloads, Subscriptions, Donations, & Payments / 1.0.4
SureCart – Ecommerce Made Easy For Selling Physical Products, Digital Downloads, Subscriptions, Donations, & Payments v1.0.4
4.7.2 4.7.1 4.7.0 4.6.6 4.6.5 4.6.4 4.6.3 4.6.2 4.6.1 4.6.0 4.5.1 4.5.0 4.4.2 4.4.1 4.4.0 4.3.3 4.3.2 4.3.1 4.3.0 4.2.3 4.2.2 4.2.1 1.0.3 1.0.4 1.0.5 All 281 releases
surecart / app / src / Support / Server.php
Server.php
63 lines 1.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace SureCart\Support;
4
5 /**
6 * Handles server functions
7 */
8 class Server {
9 /**
10 * The url of the site.
11 *
12 * @return string
13 */
14 protected $url = '';
15
16 /**
17 * Get the url of the site
18 *
19 * @param string $url The url for the site.
20 */
21 public function __construct( $url ) {
22 $this->url = $url;
23 }
24
25 /**
26 * Are we on the localhost?
27 *
28 * @return boolean
29 */
30 public function isLocalHost() {
31 // check the ip address.
32 if ( self::isLocalIP() ) {
33 return true;
34 }
35
36 // check the domain for .local or .test.
37 if ( self::isLocalDomain() ) {
38 return true;
39 }
40
41 return false;
42 }
43
44 /**
45 * Check if the site is a local domain (.local or .test.)
46 *
47 * @return boolean
48 */
49 public function isLocalDomain() {
50 $parsed = explode( '.', wp_parse_url( $this->url, PHP_URL_HOST ) );
51 return in_array( end( $parsed ), array( 'local', 'test' ), true );
52 }
53
54 /**
55 * Is this a local IP address?
56 *
57 * @return boolean
58 */
59 public function isLocalIP() {
60 return in_array( $_SERVER['REMOTE_ADDR'], array( '127.0.0.1', '::1' ), true );
61 }
62 }
63