Changeset 3451883
- Timestamp:
- 02/02/2026 09:09:46 AM (8 weeks ago)
- Location:
- showcase-idx/trunk
- Files:
-
- 7 edited
-
3/diagnostics.php (modified) (8 diffs)
-
3/opcache.php (modified) (6 diffs)
-
3/page.php (modified) (3 diffs)
-
3/routes.php (modified) (1 diff)
-
3/shortcodes.php (modified) (2 diffs)
-
readme.txt (modified) (2 diffs)
-
showcaseidx.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
showcase-idx/trunk/3/diagnostics.php
r2367883 r3451883 15 15 $active_plugins = []; 16 16 $showcaseidx_plugin = null; 17 foreach (get_option('active_plugins') as $plugin_file) { 17 $active_plugins_option = get_option('active_plugins'); 18 if (!is_array($active_plugins_option)) { 19 $active_plugins_option = []; 20 } 21 foreach ($active_plugins_option as $plugin_file) { 18 22 $data = get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin_file); 19 23 if (strpos($plugin_file, 'showcaseidx.php') !== false) { … … 25 29 26 30 global $wp_version; 31 $bootstrap_time = isset($_SERVER['REQUEST_TIME_FLOAT']) ? round(microtime(TRUE) - $_SERVER['REQUEST_TIME_FLOAT'], 3) : ''; 27 32 $data = [ 28 33 'wp_version' => $wp_version, … … 30 35 'php_sapi_name' => php_sapi_name(), 31 36 'php_memory_limit' => ini_get('memory_limit'), 32 'php_bootstrap_time' => round(microtime(TRUE) - $_SERVER['REQUEST_TIME_FLOAT'], 3),37 'php_bootstrap_time' => $bootstrap_time, 33 38 'wp_theme' => $wp_theme->get('Name'), 34 39 'wp_theme_version' => $wp_theme->get('Version'), … … 57 62 } 58 63 echo <<<HTML 59 <style type -="text/css">64 <style type="text/css"> 60 65 table td, table th { 61 66 word-break: normal; … … 86 91 <tr> 87 92 <td width="70%">Version</td> 88 <td width="30%">{$showcaseidx_plugin['Version']}</td> 93 <td width="30%"> 94 HTML; 95 echo isset($showcaseidx_plugin['Version']) ? $showcaseidx_plugin['Version'] : ''; 96 echo <<<HTML 97 </td> 89 98 </tr> 90 99 <tr> … … 173 182 <td>{$opcache['directives']['opcache.revalidate_freq']}</td> 174 183 </tr> 184 HTML; 185 if (!empty($opcache['overview'])) { 186 $hitRate = isset($opcache['overview']['hit_rate_percentage']) ? $opcache['overview']['hit_rate_percentage'] : 'N/A'; 187 $numCached = isset($opcache['overview']['num_cached_scripts']) ? $opcache['overview']['num_cached_scripts'] : 'N/A'; 188 $maxFiles = isset($opcache['directives']['opcache.max_accelerated_files']) ? $opcache['directives']['opcache.max_accelerated_files'] : 'N/A'; 189 echo <<<HTML 175 190 <tr> 176 191 <td> 177 192 Hit Rate 178 <div class=help>A "hit" is a compiled php script that is loaded from cache, rather than re-compiled each request. If cache is installed and working property, you should see a hit rate well above 50%. Below 10% indicates the cache isn ’t being used usefully.</div>179 </td> 180 <td>{$ opcache['overview']['hit_rate_percentage']}%</td>193 <div class=help>A "hit" is a compiled php script that is loaded from cache, rather than re-compiled each request. If cache is installed and working property, you should see a hit rate well above 50%. Below 10% indicates the cache isn't being used usefully.</div> 194 </td> 195 <td>{$hitRate}%</td> 181 196 </tr> 182 197 <tr> … … 185 200 <div class=help>Shows how many php scripts are in the cache. In a normally-functioning opcache, there should be many hundreds-to-thousands of files. Seeing less than this is an indicator that the cache isn't being used usefully.</div> 186 201 </td> 187 <td>{$opcache['overview']['num_cached_scripts']} (out of {$opcache['directives']['opcache.max_accelerated_files']} max)</td> 188 </tr> 189 HTML; 202 <td>{$numCached} (out of {$maxFiles} max)</td> 203 </tr> 204 HTML; 205 } 190 206 } else { 191 207 echo <<<HTML … … 207 223 echo "</body></html>"; 208 224 } 209 exit; 210 } 211 225 } 226 -
showcase-idx/trunk/3/opcache.php
r2030748 r3451883 15 15 protected $data; 16 16 protected $options; 17 protected $defaults = [17 protected $defaults = array( 18 18 'allow_filelist' => true, 19 19 'allow_invalidate' => true, … … 27 27 'cookie_name' => 'opcachegui', 28 28 'cookie_ttl' => 365 29 ];29 ); 30 30 31 private function __construct($options = [])31 private function __construct($options = array()) 32 32 { 33 33 $this->options = array_merge($this->defaults, $options); … … 35 35 } 36 36 37 public static function init($options = [])37 public static function init($options = array()) 38 38 { 39 39 $self = new self($options); … … 83 83 { 84 84 $enabled = false; 85 $version = [];86 $overview = [];87 $directives = [];85 $version = array(); 86 $overview = array(); 87 $directives = array(); 88 88 89 89 if (!extension_loaded('Zend OPcache')) { … … 91 91 } else { 92 92 $config = opcache_get_configuration(); 93 94 // Check if opcache_get_configuration() returned valid data 95 if ($config === false || !is_array($config) || !isset($config['version'])) { 96 $version['opcache_product_name'] = 'OPcache installed, but configuration unavailable (restricted by opcache.restrict_api).'; 97 return array( 98 'enabled' => $enabled, 99 'version' => $version, 100 'overview' => $overview, 101 'directives' => $directives 102 ); 103 } 104 93 105 $version = $config['version']; 94 106 … … 96 108 if ($ocEnabled == 1) { 97 109 $enabled = true; 98 $status = opcache_get_status( );110 $status = opcache_get_status(false); 99 111 100 $overview = array_merge( 101 $status['memory_usage'], $status['opcache_statistics'], [ 102 'used_memory_percentage' => round(100 * ( 103 ($status['memory_usage']['used_memory'] + $status['memory_usage']['wasted_memory']) 104 / $config['directives']['opcache.memory_consumption'])), 105 'hit_rate_percentage' => round($status['opcache_statistics']['opcache_hit_rate']), 106 'wasted_percentage' => round($status['memory_usage']['current_wasted_percentage'], 2), 107 'readable' => [ 108 'total_memory' => $this->size($config['directives']['opcache.memory_consumption']), 109 'used_memory' => $this->size($status['memory_usage']['used_memory']), 110 'free_memory' => $this->size($status['memory_usage']['free_memory']), 111 'wasted_memory' => $this->size($status['memory_usage']['wasted_memory']), 112 'num_cached_scripts' => number_format($status['opcache_statistics']['num_cached_scripts']), 113 'hits' => number_format($status['opcache_statistics']['hits']), 114 'misses' => number_format($status['opcache_statistics']['misses']), 115 'blacklist_miss' => number_format($status['opcache_statistics']['blacklist_misses']), 116 'num_cached_keys' => number_format($status['opcache_statistics']['num_cached_keys']), 117 'max_cached_keys' => number_format($status['opcache_statistics']['max_cached_keys']), 112 // Check if opcache_get_status() returned valid data 113 if ($status === false || !is_array($status) || !isset($status['memory_usage']) || !isset($status['opcache_statistics'])) { 114 $version['opcache_product_name'] .= ' enabled, but status unavailable (restricted by opcache.restrict_api).'; 115 } else { 116 $memoryConsumption = isset($config['directives']['opcache.memory_consumption']) ? $config['directives']['opcache.memory_consumption'] : 0; 117 $usedMemoryPercentage = 0; 118 if ($memoryConsumption > 0 && isset($status['memory_usage']['used_memory']) && isset($status['memory_usage']['wasted_memory'])) { 119 $usedMemoryPercentage = round(100 * ( 120 ($status['memory_usage']['used_memory'] + $status['memory_usage']['wasted_memory']) 121 / $memoryConsumption)); 122 } 123 124 $opcacheHitRate = isset($status['opcache_statistics']['opcache_hit_rate']) ? $status['opcache_statistics']['opcache_hit_rate'] : 0; 125 $wastedPercentage = isset($status['memory_usage']['current_wasted_percentage']) ? $status['memory_usage']['current_wasted_percentage'] : 0; 126 $startTime = isset($status['opcache_statistics']['start_time']) ? $status['opcache_statistics']['start_time'] : 0; 127 $lastRestartTime = isset($status['opcache_statistics']['last_restart_time']) ? $status['opcache_statistics']['last_restart_time'] : 0; 128 129 $overview = array_merge( 130 isset($status['memory_usage']) ? $status['memory_usage'] : array(), 131 isset($status['opcache_statistics']) ? $status['opcache_statistics'] : array(), 132 array( 133 'used_memory_percentage' => $usedMemoryPercentage, 134 'hit_rate_percentage' => round($opcacheHitRate), 135 'wasted_percentage' => round($wastedPercentage, 2), 136 'readable' => array( 137 'total_memory' => $this->size($memoryConsumption), 138 'used_memory' => $this->size(isset($status['memory_usage']['used_memory']) ? $status['memory_usage']['used_memory'] : 0), 139 'free_memory' => $this->size(isset($status['memory_usage']['free_memory']) ? $status['memory_usage']['free_memory'] : 0), 140 'wasted_memory' => $this->size(isset($status['memory_usage']['wasted_memory']) ? $status['memory_usage']['wasted_memory'] : 0), 141 'num_cached_scripts' => number_format(isset($status['opcache_statistics']['num_cached_scripts']) ? $status['opcache_statistics']['num_cached_scripts'] : 0), 142 'hits' => number_format(isset($status['opcache_statistics']['hits']) ? $status['opcache_statistics']['hits'] : 0), 143 'misses' => number_format(isset($status['opcache_statistics']['misses']) ? $status['opcache_statistics']['misses'] : 0), 144 'blacklist_miss' => number_format(isset($status['opcache_statistics']['blacklist_misses']) ? $status['opcache_statistics']['blacklist_misses'] : 0), 145 'num_cached_keys' => number_format(isset($status['opcache_statistics']['num_cached_keys']) ? $status['opcache_statistics']['num_cached_keys'] : 0), 146 'max_cached_keys' => number_format(isset($status['opcache_statistics']['max_cached_keys']) ? $status['opcache_statistics']['max_cached_keys'] : 0), 118 147 'interned' => null, 119 'start_time' => date('Y-m-d H:i:s', $status['opcache_statistics']['start_time']), 120 'last_restart_time' => ($status['opcache_statistics']['last_restart_time'] == 0 121 ? 'never' 122 : date('Y-m-d H:i:s', $status['opcache_statistics']['last_restart_time']) 123 ) 124 ] 125 ] 148 'start_time' => $startTime > 0 ? date('Y-m-d H:i:s', $startTime) : 'N/A', 149 'last_restart_time' => ($lastRestartTime == 0 ? 'never' : date('Y-m-d H:i:s', $lastRestartTime)) 150 ) 151 ) 126 152 ); 153 } 127 154 } else { 128 155 $version['opcache_product_name'] .= ' installed, but not enabled.'; 129 156 } 130 157 131 $directives = []; 132 ksort($config['directives']); 133 foreach ($config['directives'] as $k => $v) { 134 $directives[$k] = $v; 158 $directives = array(); 159 if (isset($config['directives']) && is_array($config['directives'])) { 160 ksort($config['directives']); 161 foreach ($config['directives'] as $k => $v) { 162 $directives[$k] = $v; 163 } 135 164 } 136 165 } 137 166 138 return [167 return array( 139 168 'enabled' => $enabled, 140 169 'version' => $version, 141 170 'overview' => $overview, 142 'directives' => $directives ,143 ];171 'directives' => $directives 172 ); 144 173 } 145 174 } -
showcase-idx/trunk/3/page.php
r3192504 r3451883 102 102 $http_status_code = wp_remote_retrieve_response_code( $response ); 103 103 if ( $http_status_code == 200 ) { 104 header( 'Set-Cookie: ' . wp_remote_retrieve_header( $response, 'set-cookie' ) ); 104 $cookies = wp_remote_retrieve_header( $response, 'set-cookie' ); 105 106 if ( $cookies ) { 107 showcaseidx_set_cookies( $cookies ); 108 } 105 109 106 110 $widget = json_decode( wp_remote_retrieve_body( $response ) ); … … 201 205 202 206 function showcase_retrieve_app( $path, $query ) { 203 $cookies = array(); 204 foreach ( $_COOKIE as $name => $value ) { 205 $cookies[] = new WP_Http_Cookie( array( 'name' => $name, 'value' => $value ) ); 206 } 207 $cookies = showcaseidx_get_cookies(); 207 208 208 209 parse_str( $query, $query_vars ); … … 211 212 $query_vars['bc_prune_widget'] = 1; 212 213 213 return wp_remote_post( 214 SHOWCASEIDX_SEARCH_HOST . '/app/render' . $path . '?' . http_build_query( $query_vars ), 215 array( 216 'timeout' => 10, 217 'httpversion' => '1.1', 218 'cookies' => $cookies, 219 'body' => array_map( 'stripslashes', $_POST ), 220 'headers' => array( 221 'X-Forwarded-For' => get_client_ip(), 222 'X-Client-User-Agent' => get_user_agent(), 223 ), 224 ) 225 ); 214 return wp_remote_post( 215 SHOWCASEIDX_SEARCH_HOST . '/app/render' . $path . '?' . http_build_query( $query_vars ), 216 array( 217 'timeout' => 10, 218 'httpversion' => '1.1', 219 'cookies' => $cookies, 220 'body' => array_map( 'stripslashes', $_POST ), 221 'headers' => array( 222 'X-Forwarded-For' => get_client_ip(), 223 'X-Client-User-Agent' => get_user_agent(), 224 'Origin' => home_url(), 225 ), 226 ) 227 ); 226 228 } 227 229 -
showcase-idx/trunk/3/routes.php
r2755119 r3451883 90 90 $api_url = SHOWCASEIDX_SEARCH_HOST . '/app/signin/image/'; 91 91 92 $response = wp_remote_get( $api_url . $lead_uuid, array( 'timeout' => 5, 'httpversion' => '1.1' ) ); 92 $response = wp_remote_get( $api_url . $lead_uuid, array( 93 'timeout' => 5, 94 'httpversion' => '1.1', 95 'headers' => [ 96 'Origin' => home_url(), 97 ] 98 ) ); 93 99 94 if ( wp_remote_retrieve_response_code( $response ) == 200 ) { 95 header( 'Set-Cookie: ' . wp_remote_retrieve_header( $response, 'set-cookie' ) ); 96 header( 'Content-Type: '. wp_remote_retrieve_header( $response, 'content-type' ) ); 100 if ( wp_remote_retrieve_response_code( $response ) == 200 ) { 101 $cookies = wp_remote_retrieve_header( $response, 'set-cookie' ); 97 102 98 print wp_remote_retrieve_body( $response ); 99 exit; 100 } 103 if ( $cookies ) { 104 showcaseidx_set_cookies( $cookies ); 105 } 106 107 header( 'Content-Type: ' . wp_remote_retrieve_header( $response, 'content-type' ) ); 108 echo wp_remote_retrieve_body( $response ); 109 exit; 110 } 101 111 } 112 113 function showcaseidx_set_cookies( $cookies ) { 114 $current_domain = parse_url( home_url(), PHP_URL_HOST ); 115 $default_expiry = time() + (90 * DAY_IN_SECONDS); // 3 months 116 117 foreach ( (array) $cookies as $cookie ) { 118 $parsed = showcaseidx_parse_cookie_header( $cookie ); 119 if ( ! $parsed ) { 120 continue; 121 } 122 123 $cookie_options = array( 124 'expires' => $parsed['expires'] ?: $default_expiry, 125 'path' => $parsed['path'], 126 'domain' => $current_domain, 127 'secure' => is_ssl(), 128 'httponly' => true, 129 'samesite' => 'Lax', 130 ); 131 132 if ( version_compare( PHP_VERSION, '7.3.0', '>=' ) ) { 133 setcookie( $parsed['name'], $parsed['value'], $cookie_options ); 134 } else { 135 $cookie_string = sprintf( 136 '%s=%s; expires=%s; path=%s; domain=%s; samesite=%s', 137 $parsed['name'], 138 $parsed['value'], 139 gmdate( 'D, d M Y H:i:s T', $cookie_options['expires'] ), 140 $cookie_options['path'], 141 $cookie_options['domain'], 142 $cookie_options['samesite'] 143 ); 144 if ( $cookie_options['secure'] ) { 145 $cookie_string .= '; secure'; 146 } 147 if ( $cookie_options['httponly'] ) { 148 $cookie_string .= '; httponly'; 149 } 150 header( 'Set-Cookie: ' . $cookie_string, false ); 151 } 152 } 153 } 154 155 function showcaseidx_parse_cookie_header( $cookie_header ) { 156 $parts = explode( ';', $cookie_header ); 157 $cookie = []; 158 foreach ( $parts as $index => $part ) { 159 $part = trim( $part ); 160 if ( $index === 0 ) { 161 // First part is always name=value 162 list( $name, $value ) = explode( '=', $part, 2 ); 163 $cookie['name'] = $name; 164 $cookie['value'] = $value; 165 } else { 166 if ( stripos( $part, 'expires=' ) === 0 ) { 167 $cookie['expires'] = strtotime( substr( $part, 8 ) ); 168 } elseif ( stripos( $part, 'path=' ) === 0 ) { 169 $cookie['path'] = substr( $part, 5 ); 170 } elseif ( stripos( $part, 'domain=' ) === 0 ) { 171 $cookie['domain'] = substr( $part, 7 ); 172 } 173 } 174 } 175 // Set defaults if not present 176 if ( !isset( $cookie['expires'] ) ) $cookie['expires'] = 0; 177 if ( !isset( $cookie['path'] ) ) $cookie['path'] = '/'; 178 return $cookie; 179 } 180 181 function showcaseidx_get_cookies() { 182 $wp_cookies = array(); 183 184 if ( isset( $_COOKIE['sidx_token'] ) ) { 185 $wp_cookie = new WP_Http_Cookie( array( 186 'name' => 'sidx_token', 187 'value' => $_COOKIE['sidx_token'], 188 'path' => '/', 189 'domain' => '', 190 ) ); 191 $wp_cookies[] = $wp_cookie; 192 } 193 194 return $wp_cookies; 195 } -
showcase-idx/trunk/3/shortcodes.php
r3192504 r3451883 106 106 107 107 function showcase_retrieve_widget( $widget, $attrs ) { 108 $cookies = array(); 109 foreach ( $_COOKIE as $name => $value ) { 110 $cookies[] = new WP_Http_Cookie( array( 'name' => $name, 'value' => $value ) ); 111 } 108 $cookies = showcaseidx_get_cookies(); 112 109 113 110 $query = $attrs; … … 124 121 'X-Forwarded-For' => get_client_ip(), 125 122 'X-Client-User-Agent' => get_user_agent(), 123 'Origin' => home_url(), 126 124 ), 127 125 ) -
showcase-idx/trunk/readme.txt
r3327660 r3451883 10 10 Requires PHP: 5.3.0 11 11 12 Stable tag: 3.3. 012 Stable tag: 3.3.1 13 13 14 14 … … 180 180 181 181 == Changelog == 182 183 = 3.3.1 = 184 185 * Fixed compatibility issues with PHP 8.3 and 8.4. 186 * Resolved issues related to the Sign-in and Sign-up workflows. 187 * Improved error handling and performance optimizations. 182 188 183 189 = 3.3.0 = -
showcase-idx/trunk/showcaseidx.php
r3327660 r3451883 6 6 * Author: Showcase IDX 7 7 * Author URI: https://showcaseidx.com/ 8 * Version: 3.3. 08 * Version: 3.3.1 9 9 * License: GPLv3 10 10 */ … … 12 12 // NOTE: documentation for the above header block is at https://developer.wordpress.org/plugins/plugin-basics/header-requirements/ 13 13 14 @ini_set( 'display_errors', '0' ); 15 @error_reporting(0 ); 14 16 15 17 add_option( 'showcaseidx_product_version', get_option( 'showcaseidx_api_key' ) != '' ? '2' : '3' );
Note: See TracChangeset
for help on using the changeset viewer.