Skip to content

Commit

Permalink
added ip addresses to settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Ethan Lin committed Nov 15, 2016
1 parent 95acf89 commit e698d76
Show file tree
Hide file tree
Showing 9 changed files with 115 additions and 37 deletions.
2 changes: 1 addition & 1 deletion build/assets/css/system-requirements-check-frontend.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
.icon-link:before {
content: "\E003"; }

icon-ip:before {
.icon-ip:before {
content: "\E004"; }

.icon-info:before {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,14 @@ protected function init_settings() {
'name' => 'flash',
'std' => '11'
),
array(
'name' => 'ip',
'std' => '0'
),
array(
'name' => 'host_ip',
'std' => '0'
)
),
)
)
Expand Down
28 changes: 22 additions & 6 deletions build/includes/admin/system-requirements-check-settings-form.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@

<div class="settings_box">

<h3>Settings</h3>

<form method="post" action="options.php">


<p class="submit">
<input type="submit" class="button-primary" value="<?php _e( 'Save Changes', 'system_requirements_check' ); ?>" />
</p>

<hr class="thick"/>

<h3>Settings</h3>

<?php

settings_fields($this->settings_group);
Expand All @@ -17,13 +23,13 @@
?>

<div class="settings_form">




<h4>Operating Systems</h4>

<p>Select the minimum operating systems required.</p>



<div class="callout danger">
<label class="src-cb"><input type="checkbox" name="disable_os_check" value="1" <?php checked('1', get_option('disable_os_check')); ?> />Disable operating systems check.</label><br>
If selected, operating systems will not be checked and displayed even if they are selected below.
Expand Down Expand Up @@ -76,6 +82,16 @@

<hr />

<h4>IP Addresses</h4>

<div class="callout danger"><strong>Important:</strong> Displaying IP address to the public may increase of the risk of a security breach. By choosing to display the IP address, you expressed or agreed that the author of this plugin will not be held responsible for any security breaches. Please use responsibly.</div>

<label>Display client's IP address? <input type="checkbox" name="ip" value="1" <?php checked('1', get_option('ip')); ?> /></label>
<br>
<label>Display host's IP address? <input type="checkbox" name="host_ip" value="1" <?php checked('1', get_option('host_ip')); ?> /></label>

<hr />

<h4>JavaScript</h4>
<label>Check for JavaScript? <input type="checkbox" name="js" value="1" <?php checked('1', get_option('js')); ?> /></label>

Expand Down
28 changes: 26 additions & 2 deletions build/includes/class-system-requirements-check-shortcodes.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ public function check_system_requirements() {

$osCallout = '';

if ( get_option('ip') == '1' ) {
$ipCallout = $this->getIP();
}

if ( get_option('disable_os_check') != '1' ) {
$osCallout = $this->checkOS();
}
Expand All @@ -54,10 +58,30 @@ public function check_system_requirements() {
$javaCallout = $this->checkJava();
$flashCallout = $this->checkFlash();

return '<div class="system_req_check">' . $osCallout . $browserCallout . $jsCallout . $cookieCallout . $javaCallout . $flashCallout . '</div>';
return '<div class="system_req_check">' . $ipCallout . $osCallout . $browserCallout . $jsCallout . $cookieCallout . $javaCallout . $flashCallout . '</div>';

}


/**
* getIP function
*
* @access public
* @return string
*
*/
public function getIP() {

$ip = $_SERVER['REMOTE_ADDR'];

if ( get_option('host_ip') == '1' ) {
$host = $_SERVER['SERVER_ADDR'];
return '<div class="callout success"><p><span class="icon-ip big"></span><strong>IP Addresses</strong></p><p>Your IP: ' . $ip . '<br>Host\'s IP: ' . $host . '</p></div>';
}

return '<div class="callout success"><p><span class="icon-ip big"></span><strong>IP Address: ' . $ip . '</strong></p></div>';

}

/**
* checkOS function
*
Expand Down
20 changes: 1 addition & 19 deletions config.codekit3
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,6 @@
"oS": 0,
"uL": 1
},
"\/source\/includes\/admin\/class-system-requirements-check-settings.php": {
"ft": 8192,
"oA": 2,
"oAP": "\/build\/includes\/admin\/class-system-requirements-check-settings.php",
"oF": 0
},
"\/source\/includes\/admin\/system-requirements-check-functions.php": {
"ft": 8192,
"oA": 2,
Expand All @@ -181,18 +175,6 @@
"oAP": "\/build\/includes\/admin\/system-requirements-check-settings-donation.php",
"oF": 0
},
"\/source\/includes\/admin\/system-requirements-check-settings-form.php": {
"ft": 8192,
"oA": 2,
"oAP": "\/build\/includes\/admin\/system-requirements-check-settings-form.php",
"oF": 0
},
"\/source\/includes\/class-system-requirements-check-shortcodes.php": {
"ft": 8192,
"oA": 2,
"oAP": "\/build\/includes\/class-system-requirements-check-shortcodes.php",
"oF": 0
},
"\/source\/includes\/class-system-requirements-check-system.php": {
"ft": 8192,
"oA": 2,
Expand Down Expand Up @@ -227,7 +209,7 @@
"displayValue": "system-requirements-check",
"displayValueWasSetByUser": 0,
"iconImageName": "meme-owl",
"lastBuiltDate": 500929542
"lastBuiltDate": 500937866
},
"projectSettings": {
"abortBuildOnError": 1,
Expand Down
2 changes: 1 addition & 1 deletion source/assets/scss/systemrequirementscheckfont.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
.icon-link:before {
content: "\E003";
}
icon-ip:before {
.icon-ip:before {
content: "\E004";
}
.icon-info:before {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,14 @@ protected function init_settings() {
'name' => 'flash',
'std' => '11'
),
array(
'name' => 'ip',
'std' => '0'
),
array(
'name' => 'host_ip',
'std' => '0'
)
),
)
)
Expand Down
28 changes: 22 additions & 6 deletions source/includes/admin/system-requirements-check-settings-form.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@

<div class="settings_box">

<h3>Settings</h3>

<form method="post" action="options.php">


<p class="submit">
<input type="submit" class="button-primary" value="<?php _e( 'Save Changes', 'system_requirements_check' ); ?>" />
</p>

<hr class="thick"/>

<h3>Settings</h3>

<?php

settings_fields($this->settings_group);
Expand All @@ -17,13 +23,13 @@
?>

<div class="settings_form">




<h4>Operating Systems</h4>

<p>Select the minimum operating systems required.</p>



<div class="callout danger">
<label class="src-cb"><input type="checkbox" name="disable_os_check" value="1" <?php checked('1', get_option('disable_os_check')); ?> />Disable operating systems check.</label><br>
If selected, operating systems will not be checked and displayed even if they are selected below.
Expand Down Expand Up @@ -76,6 +82,16 @@

<hr />

<h4>IP Addresses</h4>

<div class="callout danger"><strong>Important:</strong> Displaying IP address to the public may increase of the risk of a security breach. By choosing to display the IP address, you expressed or agreed that the author of this plugin will not be held responsible for any security breaches. Please use responsibly.</div>

<label>Display client's IP address? <input type="checkbox" name="ip" value="1" <?php checked('1', get_option('ip')); ?> /></label>
<br>
<label>Display host's IP address? <input type="checkbox" name="host_ip" value="1" <?php checked('1', get_option('host_ip')); ?> /></label>

<hr />

<h4>JavaScript</h4>
<label>Check for JavaScript? <input type="checkbox" name="js" value="1" <?php checked('1', get_option('js')); ?> /></label>

Expand Down
28 changes: 26 additions & 2 deletions source/includes/class-system-requirements-check-shortcodes.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ public function check_system_requirements() {

$osCallout = '';

if ( get_option('ip') == '1' ) {
$ipCallout = $this->getIP();
}

if ( get_option('disable_os_check') != '1' ) {
$osCallout = $this->checkOS();
}
Expand All @@ -54,10 +58,30 @@ public function check_system_requirements() {
$javaCallout = $this->checkJava();
$flashCallout = $this->checkFlash();

return '<div class="system_req_check">' . $osCallout . $browserCallout . $jsCallout . $cookieCallout . $javaCallout . $flashCallout . '</div>';
return '<div class="system_req_check">' . $ipCallout . $osCallout . $browserCallout . $jsCallout . $cookieCallout . $javaCallout . $flashCallout . '</div>';

}


/**
* getIP function
*
* @access public
* @return string
*
*/
public function getIP() {

$ip = $_SERVER['REMOTE_ADDR'];

if ( get_option('host_ip') == '1' ) {
$host = $_SERVER['SERVER_ADDR'];
return '<div class="callout success"><p><span class="icon-ip big"></span><strong>IP Addresses</strong></p><p>Your IP: ' . $ip . '<br>Host\'s IP: ' . $host . '</p></div>';
}

return '<div class="callout success"><p><span class="icon-ip big"></span><strong>IP Address: ' . $ip . '</strong></p></div>';

}

/**
* checkOS function
*
Expand Down

0 comments on commit e698d76

Please sign in to comment.