Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions README.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
=== CrowdHandler virtual waiting room ===
Contributors: rickmutt
Tags: waiting room, traffic management, queue management, ecommerce, CrowdHandler,
Tested up to: 6.7.2
Stable tag: 1.1.13
Requires at least: 5.6
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.1.15
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -89,6 +91,16 @@ You can uninstall the plugin at any time to remove CrowdHandler from your site.


== Changelog ==
= 1.1.15 =
* Tested up to WordPress 7.1
* Fixed a PHP warning emitted on every front-end request when SERVER_ADDR is not set
* Fixed a PHP warning when no public key has been saved
* Declared Requires at least and Requires PHP in the plugin header and readme
* Updated the CrowdHandler PHP SDK to 1.0.10, clearing PHP 8.4 deprecations
= 1.1.14 =
* Updated the CrowdHandler PHP SDK
* Fixed the waiting room being skipped on sites behind a reverse proxy that terminates TLS upstream
* Diagnostics header now reports index override and enabled state as separate flags
= 1.1.13 =
* Compatibility change for crowdhandler-php-skd release 1.0.8
= 1.1.12 =
Expand Down
43 changes: 42 additions & 1 deletion admin/class-crowdhandler-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,14 @@ public function settings_page_html()

public function settings_init()
{
register_setting('crowdhandler', 'crowdhandler_settings');
register_setting(
'crowdhandler',
'crowdhandler_settings',
array(
'type' => 'array',
'sanitize_callback' => array($this, 'sanitize_settings'),
)
);
Comment thread
Copilot marked this conversation as resolved.

add_settings_section(
'crowdhandler_settings_section',
Expand Down Expand Up @@ -212,6 +219,40 @@ public function settings_init()

}

/**
* Sanitize the settings before they are stored.
*
* The public key is echoed back in the x-crowdhandler-info response header,
* so it must never carry line breaks. Checkboxes are stored as 'on' or
* omitted entirely, which is the shape the rest of the plugin expects.
*/
public function sanitize_settings($input)
{
$output = array();

if (!is_array($input)) {
return $output;
}

if (isset($input['crowdhandler_settings_field_public_key'])) {
$key = sanitize_text_field($input['crowdhandler_settings_field_public_key']);
$output['crowdhandler_settings_field_public_key'] = trim(str_replace(array("\r", "\n"), '', $key));
}

$checkboxes = array(
'crowdhandler_settings_field_override_index',
'crowdhandler_settings_field_is_enabled',
);

foreach ($checkboxes as $checkbox) {
if (isset($input[$checkbox]) && $input[$checkbox] === 'on') {
$output[$checkbox] = 'on';
}
}

return $output;
}

public function settings_section_callback($args)
{
?>
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name": "crowdhandler/crowdhandler-wordpress",
"type": "project",
"require": {
"php": ">=5.3",
"crowdhandler/sdk": "dev-master"
"php": ">=7.4",
"crowdhandler/sdk": "^1.0.10"
Comment thread
carl-wells-crowdhandler marked this conversation as resolved.
},
"license": "GPL-2.0-or-later",
"authors": [
Expand Down
23 changes: 10 additions & 13 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions crowdhandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
* Plugin Name: CrowdHandler virtual waiting room
* Plugin URI: https://signup.crowdhandler.com/?utm_source=WordPress&utm_medium=Plugin_Dir
* Description: During periods of heavy traffic, our queue management solution helps safeguard your website from crashing and protects your sales.
* Version: 1.1.13
* Version: 1.1.15
* Requires at least: 5.6
* Requires PHP: 7.4
* Author: CROWDHANDLER LTD
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
Expand All @@ -38,7 +40,7 @@
* Start at version 0.1.0 and use SemVer - https://semver.org
* Rename this for your plugin and update it as you release new versions.
*/
define('CROWDHANDLER_VERSION', '1.1.13');
define('CROWDHANDLER_VERSION', '1.1.15');

/**
* The code that runs during plugin activation.
Expand Down
15 changes: 11 additions & 4 deletions includes/class-crowdhandler-diagnostics.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,18 @@ public function __construct()
public function addCHDiagnostics($headers)
{
if($this->options){
$indexOverride = (isset($this->options['crowdhandler_settings_field_override_index'])) ? '1' : '0';
$isEnabled = (isset($this->options['crowdhandler_settings_field_is_enabled'])) ? '1' : '0';
$indexOverride = (isset($this->options['crowdhandler_settings_field_override_index'])) ? 'i' : '0';
$isEnabled = (isset($this->options['crowdhandler_settings_field_is_enabled'])) ? 'e' : '0';
$timestamp = new DateTime();
$formatedTime = $timestamp->format(DateTime::ISO8601);
$headers['x-crowdhandler-info'] = CROWDHANDLER_VERSION . '::' . $this->options['crowdhandler_settings_field_public_key'] . '::' . $indexOverride . '::' . $isEnabled . '::' . $formatedTime;
$formattedTime = $timestamp->format(DateTimeInterface::ATOM);
$publicKey = isset($this->options['crowdhandler_settings_field_public_key'])
? $this->options['crowdhandler_settings_field_public_key']
: '';
// PHP refuses to send any header containing CR/LF, so a stored key
// with line breaks would drop this header entirely and emit a
// warning. Strip them rather than rely on that being caught later.
$publicKey = str_replace(array("\r", "\n"), '', $publicKey);
$headers['x-crowdhandler-info'] = CROWDHANDLER_VERSION . '::' . $publicKey . '::' . $indexOverride . '::' . $isEnabled . '::' . $formattedTime;
}
return $headers;
}
Expand Down
5 changes: 4 additions & 1 deletion includes/class-crowdhandler-gatekeeper.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ public function checkRequest()
"/^((?!.*\?).*(\.(avi|css|eot|gif|ico|jpg|jpeg|js|json|mov|mp4|mpeg|mpg|og[g|v]|pdf|png|svg|tiff|ttf|txt|wmv|woff|woff2|xml))$)|.*(^.*w[c|p]-.+)|^((?!.*\?.*xmlrpc\.php).*xmlrpc.php)|\?rest_route=.+/"
);

$isHostServer = $this->gateKeeper->ip === $_SERVER["SERVER_ADDR"];
// SERVER_ADDR is not populated by every SAPI (CLI, WP-Cron loopbacks and some
// FastCGI setups omit it), so read it defensively to avoid a PHP warning.
$serverAddress = isset($_SERVER["SERVER_ADDR"]) ? $_SERVER["SERVER_ADDR"] : null;
$isHostServer = $serverAddress !== null && $this->gateKeeper->ip === $serverAddress;

if (!$isHostServer) {
$this->gateKeeper->setFailTrust(true);
Expand Down