Changeset 3475342
- Timestamp:
- 03/05/2026 09:09:17 AM (5 days ago)
- Location:
- appsero-helper
- Files:
-
- 26 edited
- 1 copied
-
tags/1.3.5 (copied) (copied from appsero-helper/trunk)
-
tags/1.3.5/appsero-helper.php (modified) (2 diffs)
-
tags/1.3.5/includes/Edd/Activations.php (modified) (1 diff)
-
tags/1.3.5/includes/Edd/Licenses.php (modified) (1 diff)
-
tags/1.3.5/includes/Edd/Orders.php (modified) (1 diff)
-
tags/1.3.5/includes/Edd/Subscriptions.php (modified) (2 diffs)
-
tags/1.3.5/includes/WooCommerce/Activations.php (modified) (3 diffs)
-
tags/1.3.5/includes/WooCommerce/Licenses.php (modified) (2 diffs)
-
tags/1.3.5/includes/WooCommerce/Orders.php (modified) (2 diffs)
-
tags/1.3.5/includes/WooCommerce/UseCases/SendRequestsHelper.php (modified) (1 diff)
-
tags/1.3.5/readme.txt (modified) (2 diffs)
-
tags/1.3.5/vendor/autoload.php (modified) (1 diff)
-
tags/1.3.5/vendor/composer/autoload_real.php (modified) (3 diffs)
-
tags/1.3.5/vendor/composer/autoload_static.php (modified) (2 diffs)
-
trunk/appsero-helper.php (modified) (2 diffs)
-
trunk/includes/Edd/Activations.php (modified) (1 diff)
-
trunk/includes/Edd/Licenses.php (modified) (1 diff)
-
trunk/includes/Edd/Orders.php (modified) (1 diff)
-
trunk/includes/Edd/Subscriptions.php (modified) (2 diffs)
-
trunk/includes/WooCommerce/Activations.php (modified) (3 diffs)
-
trunk/includes/WooCommerce/Licenses.php (modified) (2 diffs)
-
trunk/includes/WooCommerce/Orders.php (modified) (2 diffs)
-
trunk/includes/WooCommerce/UseCases/SendRequestsHelper.php (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/vendor/autoload.php (modified) (1 diff)
-
trunk/vendor/composer/autoload_real.php (modified) (3 diffs)
-
trunk/vendor/composer/autoload_static.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
appsero-helper/tags/1.3.5/appsero-helper.php
r3253142 r3475342 6 6 * Author: Appsero 7 7 * Author URI: https://appsero.com 8 * Version: 1.3. 48 * Version: 1.3.5 9 9 * Text Domain: appsero-helper 10 10 */ … … 25 25 * @var string 26 26 */ 27 public $version = '1.3. 4';27 public $version = '1.3.5'; 28 28 29 29 /** -
appsero-helper/tags/1.3.5/includes/Edd/Activations.php
r2022067 r3475342 53 53 // retrieve active sites count 54 54 global $wpdb; 55 $query = "SELECT COUNT(site_id) as `count` FROM {$wpdb->prefix}edd_license_activations WHERE license_id = {$license->id} "; 56 $query .= " AND activated = 1 AND is_local = 0 AND site_name <> '{$site_url}' "; 55 $query = $wpdb->prepare( 56 "SELECT COUNT(site_id) as `count` FROM {$wpdb->prefix}edd_license_activations WHERE license_id = %d AND activated = 1 AND is_local = 0 AND site_name <> %s", 57 intval( $license->id ), 58 $site_url 59 ); 57 60 $active_sites = $wpdb->get_row( $query, ARRAY_A ); 58 61 -
appsero-helper/tags/1.3.5/includes/Edd/Licenses.php
r2272800 r3475342 31 31 // `edd_software_licensing()->licenses_db->get_licenses()` not fulfill my need 32 32 global $wpdb; 33 $query = "SELECT SQL_CALC_FOUND_ROWS id FROM {$wpdb->prefix}edd_licenses WHERE download_id = {$download_id} "; 34 $query .= " ORDER BY id ASC LIMIT {$per_page} OFFSET {$offset}"; 35 $results = $wpdb->get_col( $query, 0 ); 33 $query = $wpdb->prepare( 34 "SELECT SQL_CALC_FOUND_ROWS id FROM {$wpdb->prefix}edd_licenses WHERE download_id = %d ORDER BY id ASC LIMIT %d OFFSET %d", 35 absint( $download_id ), 36 absint( $per_page ), 37 absint( $offset ) 38 ); 39 $results = $wpdb->get_col( $query, 0 ); 36 40 $total_items = $wpdb->get_var( 'SELECT FOUND_ROWS()' ); 37 41 -
appsero-helper/tags/1.3.5/includes/Edd/Orders.php
r2803348 r3475342 260 260 global $wpdb; 261 261 262 $query = "SELECT SQL_CALC_FOUND_ROWS `ID` FROM {$wpdb->posts} 263 WHERE `post_type` = 'edd_payment' AND 264 `ID` IN ( 265 SELECT `post_id` FROM {$wpdb->postmeta} 266 WHERE `meta_value` LIKE '%{s:2:\"id\";i:%d;s:8:\"quantity\";i%' 267 ) 268 AND `post_status` IN ( 269 'abandoned', 'edd_subscription', 'failed', 'pending', 'processing', 'publish', 'refunded', 'revoked' 270 ) 271 AND `post_modified_gmt` >= '{$after}' 272 ORDER BY `ID` ASC LIMIT %d OFFSET %d;"; 273 274 return $wpdb->prepare( $query, $this->download_id, $per_page, $offset ); 262 $query = $wpdb->prepare( 263 "SELECT SQL_CALC_FOUND_ROWS `ID` FROM {$wpdb->posts} 264 WHERE `post_type` = 'edd_payment' AND 265 `ID` IN ( 266 SELECT `post_id` FROM {$wpdb->postmeta} 267 WHERE `meta_value` LIKE %s 268 ) 269 AND `post_status` IN ( 270 'abandoned', 'edd_subscription', 'failed', 'pending', 'processing', 'publish', 'refunded', 'revoked' 271 ) 272 AND `post_modified_gmt` >= %s 273 ORDER BY `ID` ASC LIMIT %d OFFSET %d", 274 '%{s:2:\"id\";i:' . intval( $this->download_id ) . ';s:8:\"quantity\";i%', 275 $after, 276 intval( $per_page ), 277 intval( $offset ) 278 ); 279 280 return $query; 275 281 } 276 282 } -
appsero-helper/tags/1.3.5/includes/Edd/Subscriptions.php
r2147728 r3475342 24 24 global $wpdb; 25 25 $table_name = $wpdb->prefix . 'edd_subscriptions'; 26 $query = $wpdb->prepare( "SELECT SQL_CALC_FOUND_ROWS `id` FROM {$table_name} WHERE 27 `product_id` = {$product_id} ORDER BY `id` ASC LIMIT %d OFFSET %d;", 28 absint( $per_page ), absint( $offset ) ); 26 $query = $wpdb->prepare( 27 "SELECT SQL_CALC_FOUND_ROWS `id` FROM {$table_name} WHERE `product_id` = %d ORDER BY `id` ASC LIMIT %d OFFSET %d", 28 absint( $product_id ), 29 absint( $per_page ), 30 absint( $offset ) 31 ); 29 32 30 33 $items = $wpdb->get_col( $query ); … … 76 79 global $wpdb; 77 80 78 $query = "SELECT post_date_gmt FROM {$wpdb->posts} WHERE `post_parent` = {$subscription->parent_payment_id} 79 AND `ID` IN ( SELECT `post_id` FROM {$wpdb->postmeta} WHERE `meta_key` = 'subscription_id' 80 AND meta_value = {$subscription->id} ) AND `post_type` = 'edd_payment' 81 ORDER BY `ID` DESC LIMIT 1;"; 81 $query = $wpdb->prepare( 82 "SELECT post_date_gmt FROM {$wpdb->posts} WHERE `post_parent` = %d 83 AND `ID` IN ( SELECT `post_id` FROM {$wpdb->postmeta} WHERE `meta_key` = 'subscription_id' 84 AND meta_value = %d ) AND `post_type` = 'edd_payment' 85 ORDER BY `ID` DESC LIMIT 1", 86 intval( $subscription->parent_payment_id ), 87 intval( $subscription->id ) 88 ); 82 89 $last_renewal_date = $wpdb->get_var( $query ); 83 90 -
appsero-helper/tags/1.3.5/includes/WooCommerce/Activations.php
r2421271 r3475342 119 119 $meta_key = $wpdb->get_blog_prefix() . WC_AM_HELPERS()->user_meta_key_orders; 120 120 121 $query = "SELECT meta_value FROM {$wpdb->usermeta} WHERE meta_key = '{$meta_key}' "; 122 $query .= " AND meta_value LIKE '%{$license_key}%' "; 123 121 $query = $wpdb->prepare( 122 "SELECT meta_value FROM {$wpdb->usermeta} WHERE meta_key = %s AND meta_value LIKE %s", 123 $meta_key, 124 '%' . $wpdb->esc_like( $license_key ) . '%' 125 ); 124 126 $license_data = $wpdb->get_var( $query ); 125 127 $license_data = maybe_unserialize( $license_data ); … … 236 238 // retrieve active sites count 237 239 global $wpdb; 238 $query = "SELECT COUNT(activation_id) FROM {$wpdb->wc_software_activations} WHERE key_id = %s "; 239 $query .= " AND activation_active = 1 AND activation_platform <> '%s' "; 240 241 $active_sites = $wpdb->get_var( $wpdb->prepare( $query, $license['key_id'], $site_url ) ); 240 $query = $wpdb->prepare( 241 "SELECT COUNT(activation_id) FROM {$wpdb->wc_software_activations} 242 WHERE key_id = %s AND activation_active = 1 AND activation_platform <> %s", 243 $license['key_id'], 244 $site_url 245 ); 246 $active_sites = $wpdb->get_var( $query ); 242 247 243 248 if ( $limit > 0 && $active_sites >= $limit ) { … … 367 372 global $wpdb; 368 373 369 $query = "SELECT * FROM {$wpdb->wc_software_activations} "; 370 $query .= " WHERE key_id = %s AND activation_platform = '%s' "; 371 return $wpdb->get_row( $wpdb->prepare( $query, $key_id, $site_url ), ARRAY_A ); 374 $query = $wpdb->prepare( 375 "SELECT * FROM {$wpdb->wc_software_activations} WHERE key_id = %s AND activation_platform = %s", 376 $key_id, 377 $site_url 378 ); 379 return $wpdb->get_row( $query, ARRAY_A ); 372 380 } 373 381 -
appsero-helper/tags/1.3.5/includes/WooCommerce/Licenses.php
r2421271 r3475342 63 63 $table_order_items = $wpdb->prefix . 'woocommerce_order_items'; 64 64 65 $itemmetaQuery = " SELECT `{$table_order_itemmeta}`.`order_item_id` FROM `{$table_order_itemmeta}` "; 66 $itemmetaQuery .= " WHERE `meta_key` = '_product_id' AND `meta_value` = {$product_id} "; 67 68 $itemsQuery = " SELECT SQL_CALC_FOUND_ROWS postmeta.meta_value AS license_key from {$table_order_items} AS order_items "; 69 $itemsQuery .= " LEFT JOIN {$wpdb->posts} AS posts ON order_items.order_id = posts.ID "; 70 $itemsQuery .= " LEFT JOIN {$wpdb->postmeta} AS postmeta ON posts.ID = postmeta.post_id "; 71 $itemsQuery .= " WHERE `order_item_id` IN ( {$itemmetaQuery} ) "; 72 $itemsQuery .= " AND posts.post_status = 'wc-completed' "; 73 $itemsQuery .= " AND postmeta.meta_key LIKE '%_api_license_key_%' "; 74 $itemsQuery .= " ORDER BY order_items.order_id ASC LIMIT {$per_page} OFFSET {$offset} "; 65 $itemmetaQuery = $wpdb->prepare( 66 "SELECT `{$table_order_itemmeta}`.`order_item_id` FROM `{$table_order_itemmeta}` 67 WHERE `meta_key` = '_product_id' AND `meta_value` = %d", 68 intval( $product_id ) 69 ); 70 71 $itemsQuery = $wpdb->prepare( 72 "SELECT SQL_CALC_FOUND_ROWS postmeta.meta_value AS license_key 73 FROM {$table_order_items} AS order_items 74 LEFT JOIN {$wpdb->posts} AS posts ON order_items.order_id = posts.ID 75 LEFT JOIN {$wpdb->postmeta} AS postmeta ON posts.ID = postmeta.post_id 76 WHERE `order_item_id` IN ( {$itemmetaQuery} ) 77 AND posts.post_status = 'wc-completed' 78 AND postmeta.meta_key LIKE %s 79 ORDER BY order_items.order_id ASC LIMIT %d OFFSET %d", 80 '%_api_license_key_%', 81 intval( $per_page ), 82 intval( $offset ) 83 ); 75 84 76 85 $results = $wpdb->get_col( $itemsQuery, 0 ); … … 102 111 $meta_key = $wpdb->get_blog_prefix() . WC_AM_HELPERS()->user_meta_key_orders; 103 112 104 $query = "SELECT meta_value FROM {$wpdb->usermeta} WHERE meta_key = '{$meta_key}' "; 105 $query .= " AND meta_value LIKE '%{$license_key}%' "; 106 113 $query = $wpdb->prepare( 114 "SELECT meta_value FROM {$wpdb->usermeta} WHERE meta_key = %s AND meta_value LIKE %s", 115 $meta_key, 116 '%' . $wpdb->esc_like( $license_key ) . '%' 117 ); 107 118 $license_data = $wpdb->get_var( $query ); 108 119 $license_data = maybe_unserialize( $license_data ); -
appsero-helper/tags/1.3.5/includes/WooCommerce/Orders.php
r2695941 r3475342 61 61 global $wpdb; 62 62 $orders_statuses = array_keys( wc_get_order_statuses() ); 63 $orders_statuses = implode( "', '", $orders_statuses ); 64 65 $query = "SELECT SQL_CALC_FOUND_ROWS DISTINCT woi.order_id 66 FROM {$wpdb->prefix}woocommerce_order_itemmeta as woim, 67 {$wpdb->prefix}woocommerce_order_items as woi, 68 {$wpdb->prefix}posts as p 69 WHERE woi.order_item_id = woim.order_item_id 70 AND woi.order_id = p.ID 71 AND p.post_status IN ( '{$orders_statuses}' ) 72 AND p.post_type = 'shop_order' "; 73 74 if ( !empty($after) ) { 75 $query .= " AND p.post_modified_gmt >= '{$after}' "; 76 } 77 78 $query .= " AND woim.meta_key = '_product_id' 79 AND woim.meta_value = '{$this->product_id}' 80 ORDER BY woi.order_item_id ASC LIMIT {$limit} OFFSET {$offset}"; 63 $status_placeholders = implode( ', ', array_fill( 0, count( $orders_statuses ), '%s' ) ); 64 65 $params = array_merge( 66 $orders_statuses, 67 [ 68 intval( $this->product_id ), 69 intval( $limit ), 70 intval( $offset ), 71 ] 72 ); 73 74 if ( ! empty( $after ) ) { 75 $query = $wpdb->prepare( 76 "SELECT SQL_CALC_FOUND_ROWS DISTINCT woi.order_id 77 FROM {$wpdb->prefix}woocommerce_order_itemmeta as woim, 78 {$wpdb->prefix}woocommerce_order_items as woi, 79 {$wpdb->prefix}posts as p 80 WHERE woi.order_item_id = woim.order_item_id 81 AND woi.order_id = p.ID 82 AND p.post_status IN ( {$status_placeholders} ) 83 AND p.post_type = 'shop_order' 84 AND p.post_modified_gmt >= %s 85 AND woim.meta_key = '_product_id' 86 AND woim.meta_value = %d 87 ORDER BY woi.order_item_id ASC LIMIT %d OFFSET %d", 88 array_merge( 89 $orders_statuses, 90 [ 91 $after, 92 intval( $this->product_id ), 93 intval( $limit ), 94 intval( $offset ), 95 ] 96 ) 97 ); 98 } else { 99 $query = $wpdb->prepare( 100 "SELECT SQL_CALC_FOUND_ROWS DISTINCT woi.order_id 101 FROM {$wpdb->prefix}woocommerce_order_itemmeta as woim, 102 {$wpdb->prefix}woocommerce_order_items as woi, 103 {$wpdb->prefix}posts as p 104 WHERE woi.order_item_id = woim.order_item_id 105 AND woi.order_id = p.ID 106 AND p.post_status IN ( {$status_placeholders} ) 107 AND p.post_type = 'shop_order' 108 AND woim.meta_key = '_product_id' 109 AND woim.meta_value = %d 110 ORDER BY woi.order_item_id ASC LIMIT %d OFFSET %d", 111 $params 112 ); 113 } 81 114 82 115 $orders_ids = $wpdb->get_col( $query ); … … 186 219 private function get_order_type( $order_id, $subscription_id ) { 187 220 global $wpdb; 188 $query = "SELECT * FROM $wpdb->postmeta WHERE post_id = {$order_id} 189 AND ( 190 meta_key = '_subscription_renewal' 191 OR meta_key = '_subscription_resubscribe' 192 OR meta_key = '_subscription_switch' 193 ) 194 AND meta_value = {$subscription_id} 195 LIMIT 1"; 221 $query = $wpdb->prepare( 222 "SELECT * FROM {$wpdb->postmeta} 223 WHERE post_id = %d 224 AND ( 225 meta_key = '_subscription_renewal' 226 OR meta_key = '_subscription_resubscribe' 227 OR meta_key = '_subscription_switch' 228 ) 229 AND meta_value = %d 230 LIMIT 1", 231 intval( $order_id ), 232 intval( $subscription_id ) 233 ); 196 234 $result = $wpdb->get_row( $query, ARRAY_A ); 197 235 -
appsero-helper/tags/1.3.5/includes/WooCommerce/UseCases/SendRequestsHelper.php
r2364757 r3475342 54 54 $software_id = get_post_meta( $product_id, '_software_product_id', true); 55 55 56 $query = "SELECT * FROM {$wpdb->wc_software_licenses} WHERE `order_id` = {$order_id} AND `software_product_id` = '{$software_id}' "; 56 $query = $wpdb->prepare( 57 "SELECT * FROM {$wpdb->wc_software_licenses} WHERE `order_id` = %d AND `software_product_id` = %s", 58 intval( $order_id ), 59 $software_id 60 ); 57 61 $licenses = $wpdb->get_results( $query, ARRAY_A ); 58 62 -
appsero-helper/tags/1.3.5/readme.txt
r3253142 r3475342 4 4 Tags: licensing, release, analytics, deactivation 5 5 Requires at least: 4.0 6 Tested up to: 6. 77 Stable tag: 1.3. 46 Tested up to: 6.9 7 Stable tag: 1.3.5 8 8 Requires PHP: 5.4 9 9 License: GPLv2 or later … … 124 124 == Changelog == 125 125 126 = 1.3.5 - (5th March, 2026) = 127 - **Fix:** Improve SQL query preparation for better security and performance. 128 126 129 = 1.3.4 - (10th March, 2025) = 127 130 - **Fix:** Updated changelog for version 1.3.4 to correct version name and details. -
appsero-helper/tags/1.3.5/vendor/autoload.php
r3253142 r3475342 5 5 require_once __DIR__ . '/composer/autoload_real.php'; 6 6 7 return ComposerAutoloaderInit 03b5eb5f7842abfa606205e8065b89c4::getLoader();7 return ComposerAutoloaderInitf450d401a59fb00d11d99977c268f7f3::getLoader(); -
appsero-helper/tags/1.3.5/vendor/composer/autoload_real.php
r3253142 r3475342 3 3 // autoload_real.php @generated by Composer 4 4 5 class ComposerAutoloaderInit 03b5eb5f7842abfa606205e8065b89c45 class ComposerAutoloaderInitf450d401a59fb00d11d99977c268f7f3 6 6 { 7 7 private static $loader; … … 23 23 } 24 24 25 spl_autoload_register(array('ComposerAutoloaderInit 03b5eb5f7842abfa606205e8065b89c4', 'loadClassLoader'), true, true);25 spl_autoload_register(array('ComposerAutoloaderInitf450d401a59fb00d11d99977c268f7f3', 'loadClassLoader'), true, true); 26 26 self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__))); 27 spl_autoload_unregister(array('ComposerAutoloaderInit 03b5eb5f7842abfa606205e8065b89c4', 'loadClassLoader'));27 spl_autoload_unregister(array('ComposerAutoloaderInitf450d401a59fb00d11d99977c268f7f3', 'loadClassLoader')); 28 28 29 29 $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); … … 31 31 require __DIR__ . '/autoload_static.php'; 32 32 33 call_user_func(\Composer\Autoload\ComposerStaticInit 03b5eb5f7842abfa606205e8065b89c4::getInitializer($loader));33 call_user_func(\Composer\Autoload\ComposerStaticInitf450d401a59fb00d11d99977c268f7f3::getInitializer($loader)); 34 34 } else { 35 35 $map = require __DIR__ . '/autoload_namespaces.php'; -
appsero-helper/tags/1.3.5/vendor/composer/autoload_static.php
r3253142 r3475342 5 5 namespace Composer\Autoload; 6 6 7 class ComposerStaticInit 03b5eb5f7842abfa606205e8065b89c47 class ComposerStaticInitf450d401a59fb00d11d99977c268f7f3 8 8 { 9 9 public static $prefixLengthsPsr4 = array ( … … 72 72 { 73 73 return \Closure::bind(function () use ($loader) { 74 $loader->prefixLengthsPsr4 = ComposerStaticInit 03b5eb5f7842abfa606205e8065b89c4::$prefixLengthsPsr4;75 $loader->prefixDirsPsr4 = ComposerStaticInit 03b5eb5f7842abfa606205e8065b89c4::$prefixDirsPsr4;76 $loader->classMap = ComposerStaticInit 03b5eb5f7842abfa606205e8065b89c4::$classMap;74 $loader->prefixLengthsPsr4 = ComposerStaticInitf450d401a59fb00d11d99977c268f7f3::$prefixLengthsPsr4; 75 $loader->prefixDirsPsr4 = ComposerStaticInitf450d401a59fb00d11d99977c268f7f3::$prefixDirsPsr4; 76 $loader->classMap = ComposerStaticInitf450d401a59fb00d11d99977c268f7f3::$classMap; 77 77 78 78 }, null, ClassLoader::class); -
appsero-helper/trunk/appsero-helper.php
r3253142 r3475342 6 6 * Author: Appsero 7 7 * Author URI: https://appsero.com 8 * Version: 1.3. 48 * Version: 1.3.5 9 9 * Text Domain: appsero-helper 10 10 */ … … 25 25 * @var string 26 26 */ 27 public $version = '1.3. 4';27 public $version = '1.3.5'; 28 28 29 29 /** -
appsero-helper/trunk/includes/Edd/Activations.php
r2022067 r3475342 53 53 // retrieve active sites count 54 54 global $wpdb; 55 $query = "SELECT COUNT(site_id) as `count` FROM {$wpdb->prefix}edd_license_activations WHERE license_id = {$license->id} "; 56 $query .= " AND activated = 1 AND is_local = 0 AND site_name <> '{$site_url}' "; 55 $query = $wpdb->prepare( 56 "SELECT COUNT(site_id) as `count` FROM {$wpdb->prefix}edd_license_activations WHERE license_id = %d AND activated = 1 AND is_local = 0 AND site_name <> %s", 57 intval( $license->id ), 58 $site_url 59 ); 57 60 $active_sites = $wpdb->get_row( $query, ARRAY_A ); 58 61 -
appsero-helper/trunk/includes/Edd/Licenses.php
r2272800 r3475342 31 31 // `edd_software_licensing()->licenses_db->get_licenses()` not fulfill my need 32 32 global $wpdb; 33 $query = "SELECT SQL_CALC_FOUND_ROWS id FROM {$wpdb->prefix}edd_licenses WHERE download_id = {$download_id} "; 34 $query .= " ORDER BY id ASC LIMIT {$per_page} OFFSET {$offset}"; 35 $results = $wpdb->get_col( $query, 0 ); 33 $query = $wpdb->prepare( 34 "SELECT SQL_CALC_FOUND_ROWS id FROM {$wpdb->prefix}edd_licenses WHERE download_id = %d ORDER BY id ASC LIMIT %d OFFSET %d", 35 absint( $download_id ), 36 absint( $per_page ), 37 absint( $offset ) 38 ); 39 $results = $wpdb->get_col( $query, 0 ); 36 40 $total_items = $wpdb->get_var( 'SELECT FOUND_ROWS()' ); 37 41 -
appsero-helper/trunk/includes/Edd/Orders.php
r2803348 r3475342 260 260 global $wpdb; 261 261 262 $query = "SELECT SQL_CALC_FOUND_ROWS `ID` FROM {$wpdb->posts} 263 WHERE `post_type` = 'edd_payment' AND 264 `ID` IN ( 265 SELECT `post_id` FROM {$wpdb->postmeta} 266 WHERE `meta_value` LIKE '%{s:2:\"id\";i:%d;s:8:\"quantity\";i%' 267 ) 268 AND `post_status` IN ( 269 'abandoned', 'edd_subscription', 'failed', 'pending', 'processing', 'publish', 'refunded', 'revoked' 270 ) 271 AND `post_modified_gmt` >= '{$after}' 272 ORDER BY `ID` ASC LIMIT %d OFFSET %d;"; 273 274 return $wpdb->prepare( $query, $this->download_id, $per_page, $offset ); 262 $query = $wpdb->prepare( 263 "SELECT SQL_CALC_FOUND_ROWS `ID` FROM {$wpdb->posts} 264 WHERE `post_type` = 'edd_payment' AND 265 `ID` IN ( 266 SELECT `post_id` FROM {$wpdb->postmeta} 267 WHERE `meta_value` LIKE %s 268 ) 269 AND `post_status` IN ( 270 'abandoned', 'edd_subscription', 'failed', 'pending', 'processing', 'publish', 'refunded', 'revoked' 271 ) 272 AND `post_modified_gmt` >= %s 273 ORDER BY `ID` ASC LIMIT %d OFFSET %d", 274 '%{s:2:\"id\";i:' . intval( $this->download_id ) . ';s:8:\"quantity\";i%', 275 $after, 276 intval( $per_page ), 277 intval( $offset ) 278 ); 279 280 return $query; 275 281 } 276 282 } -
appsero-helper/trunk/includes/Edd/Subscriptions.php
r2147728 r3475342 24 24 global $wpdb; 25 25 $table_name = $wpdb->prefix . 'edd_subscriptions'; 26 $query = $wpdb->prepare( "SELECT SQL_CALC_FOUND_ROWS `id` FROM {$table_name} WHERE 27 `product_id` = {$product_id} ORDER BY `id` ASC LIMIT %d OFFSET %d;", 28 absint( $per_page ), absint( $offset ) ); 26 $query = $wpdb->prepare( 27 "SELECT SQL_CALC_FOUND_ROWS `id` FROM {$table_name} WHERE `product_id` = %d ORDER BY `id` ASC LIMIT %d OFFSET %d", 28 absint( $product_id ), 29 absint( $per_page ), 30 absint( $offset ) 31 ); 29 32 30 33 $items = $wpdb->get_col( $query ); … … 76 79 global $wpdb; 77 80 78 $query = "SELECT post_date_gmt FROM {$wpdb->posts} WHERE `post_parent` = {$subscription->parent_payment_id} 79 AND `ID` IN ( SELECT `post_id` FROM {$wpdb->postmeta} WHERE `meta_key` = 'subscription_id' 80 AND meta_value = {$subscription->id} ) AND `post_type` = 'edd_payment' 81 ORDER BY `ID` DESC LIMIT 1;"; 81 $query = $wpdb->prepare( 82 "SELECT post_date_gmt FROM {$wpdb->posts} WHERE `post_parent` = %d 83 AND `ID` IN ( SELECT `post_id` FROM {$wpdb->postmeta} WHERE `meta_key` = 'subscription_id' 84 AND meta_value = %d ) AND `post_type` = 'edd_payment' 85 ORDER BY `ID` DESC LIMIT 1", 86 intval( $subscription->parent_payment_id ), 87 intval( $subscription->id ) 88 ); 82 89 $last_renewal_date = $wpdb->get_var( $query ); 83 90 -
appsero-helper/trunk/includes/WooCommerce/Activations.php
r2421271 r3475342 119 119 $meta_key = $wpdb->get_blog_prefix() . WC_AM_HELPERS()->user_meta_key_orders; 120 120 121 $query = "SELECT meta_value FROM {$wpdb->usermeta} WHERE meta_key = '{$meta_key}' "; 122 $query .= " AND meta_value LIKE '%{$license_key}%' "; 123 121 $query = $wpdb->prepare( 122 "SELECT meta_value FROM {$wpdb->usermeta} WHERE meta_key = %s AND meta_value LIKE %s", 123 $meta_key, 124 '%' . $wpdb->esc_like( $license_key ) . '%' 125 ); 124 126 $license_data = $wpdb->get_var( $query ); 125 127 $license_data = maybe_unserialize( $license_data ); … … 236 238 // retrieve active sites count 237 239 global $wpdb; 238 $query = "SELECT COUNT(activation_id) FROM {$wpdb->wc_software_activations} WHERE key_id = %s "; 239 $query .= " AND activation_active = 1 AND activation_platform <> '%s' "; 240 241 $active_sites = $wpdb->get_var( $wpdb->prepare( $query, $license['key_id'], $site_url ) ); 240 $query = $wpdb->prepare( 241 "SELECT COUNT(activation_id) FROM {$wpdb->wc_software_activations} 242 WHERE key_id = %s AND activation_active = 1 AND activation_platform <> %s", 243 $license['key_id'], 244 $site_url 245 ); 246 $active_sites = $wpdb->get_var( $query ); 242 247 243 248 if ( $limit > 0 && $active_sites >= $limit ) { … … 367 372 global $wpdb; 368 373 369 $query = "SELECT * FROM {$wpdb->wc_software_activations} "; 370 $query .= " WHERE key_id = %s AND activation_platform = '%s' "; 371 return $wpdb->get_row( $wpdb->prepare( $query, $key_id, $site_url ), ARRAY_A ); 374 $query = $wpdb->prepare( 375 "SELECT * FROM {$wpdb->wc_software_activations} WHERE key_id = %s AND activation_platform = %s", 376 $key_id, 377 $site_url 378 ); 379 return $wpdb->get_row( $query, ARRAY_A ); 372 380 } 373 381 -
appsero-helper/trunk/includes/WooCommerce/Licenses.php
r2421271 r3475342 63 63 $table_order_items = $wpdb->prefix . 'woocommerce_order_items'; 64 64 65 $itemmetaQuery = " SELECT `{$table_order_itemmeta}`.`order_item_id` FROM `{$table_order_itemmeta}` "; 66 $itemmetaQuery .= " WHERE `meta_key` = '_product_id' AND `meta_value` = {$product_id} "; 67 68 $itemsQuery = " SELECT SQL_CALC_FOUND_ROWS postmeta.meta_value AS license_key from {$table_order_items} AS order_items "; 69 $itemsQuery .= " LEFT JOIN {$wpdb->posts} AS posts ON order_items.order_id = posts.ID "; 70 $itemsQuery .= " LEFT JOIN {$wpdb->postmeta} AS postmeta ON posts.ID = postmeta.post_id "; 71 $itemsQuery .= " WHERE `order_item_id` IN ( {$itemmetaQuery} ) "; 72 $itemsQuery .= " AND posts.post_status = 'wc-completed' "; 73 $itemsQuery .= " AND postmeta.meta_key LIKE '%_api_license_key_%' "; 74 $itemsQuery .= " ORDER BY order_items.order_id ASC LIMIT {$per_page} OFFSET {$offset} "; 65 $itemmetaQuery = $wpdb->prepare( 66 "SELECT `{$table_order_itemmeta}`.`order_item_id` FROM `{$table_order_itemmeta}` 67 WHERE `meta_key` = '_product_id' AND `meta_value` = %d", 68 intval( $product_id ) 69 ); 70 71 $itemsQuery = $wpdb->prepare( 72 "SELECT SQL_CALC_FOUND_ROWS postmeta.meta_value AS license_key 73 FROM {$table_order_items} AS order_items 74 LEFT JOIN {$wpdb->posts} AS posts ON order_items.order_id = posts.ID 75 LEFT JOIN {$wpdb->postmeta} AS postmeta ON posts.ID = postmeta.post_id 76 WHERE `order_item_id` IN ( {$itemmetaQuery} ) 77 AND posts.post_status = 'wc-completed' 78 AND postmeta.meta_key LIKE %s 79 ORDER BY order_items.order_id ASC LIMIT %d OFFSET %d", 80 '%_api_license_key_%', 81 intval( $per_page ), 82 intval( $offset ) 83 ); 75 84 76 85 $results = $wpdb->get_col( $itemsQuery, 0 ); … … 102 111 $meta_key = $wpdb->get_blog_prefix() . WC_AM_HELPERS()->user_meta_key_orders; 103 112 104 $query = "SELECT meta_value FROM {$wpdb->usermeta} WHERE meta_key = '{$meta_key}' "; 105 $query .= " AND meta_value LIKE '%{$license_key}%' "; 106 113 $query = $wpdb->prepare( 114 "SELECT meta_value FROM {$wpdb->usermeta} WHERE meta_key = %s AND meta_value LIKE %s", 115 $meta_key, 116 '%' . $wpdb->esc_like( $license_key ) . '%' 117 ); 107 118 $license_data = $wpdb->get_var( $query ); 108 119 $license_data = maybe_unserialize( $license_data ); -
appsero-helper/trunk/includes/WooCommerce/Orders.php
r2695941 r3475342 61 61 global $wpdb; 62 62 $orders_statuses = array_keys( wc_get_order_statuses() ); 63 $orders_statuses = implode( "', '", $orders_statuses ); 64 65 $query = "SELECT SQL_CALC_FOUND_ROWS DISTINCT woi.order_id 66 FROM {$wpdb->prefix}woocommerce_order_itemmeta as woim, 67 {$wpdb->prefix}woocommerce_order_items as woi, 68 {$wpdb->prefix}posts as p 69 WHERE woi.order_item_id = woim.order_item_id 70 AND woi.order_id = p.ID 71 AND p.post_status IN ( '{$orders_statuses}' ) 72 AND p.post_type = 'shop_order' "; 73 74 if ( !empty($after) ) { 75 $query .= " AND p.post_modified_gmt >= '{$after}' "; 76 } 77 78 $query .= " AND woim.meta_key = '_product_id' 79 AND woim.meta_value = '{$this->product_id}' 80 ORDER BY woi.order_item_id ASC LIMIT {$limit} OFFSET {$offset}"; 63 $status_placeholders = implode( ', ', array_fill( 0, count( $orders_statuses ), '%s' ) ); 64 65 $params = array_merge( 66 $orders_statuses, 67 [ 68 intval( $this->product_id ), 69 intval( $limit ), 70 intval( $offset ), 71 ] 72 ); 73 74 if ( ! empty( $after ) ) { 75 $query = $wpdb->prepare( 76 "SELECT SQL_CALC_FOUND_ROWS DISTINCT woi.order_id 77 FROM {$wpdb->prefix}woocommerce_order_itemmeta as woim, 78 {$wpdb->prefix}woocommerce_order_items as woi, 79 {$wpdb->prefix}posts as p 80 WHERE woi.order_item_id = woim.order_item_id 81 AND woi.order_id = p.ID 82 AND p.post_status IN ( {$status_placeholders} ) 83 AND p.post_type = 'shop_order' 84 AND p.post_modified_gmt >= %s 85 AND woim.meta_key = '_product_id' 86 AND woim.meta_value = %d 87 ORDER BY woi.order_item_id ASC LIMIT %d OFFSET %d", 88 array_merge( 89 $orders_statuses, 90 [ 91 $after, 92 intval( $this->product_id ), 93 intval( $limit ), 94 intval( $offset ), 95 ] 96 ) 97 ); 98 } else { 99 $query = $wpdb->prepare( 100 "SELECT SQL_CALC_FOUND_ROWS DISTINCT woi.order_id 101 FROM {$wpdb->prefix}woocommerce_order_itemmeta as woim, 102 {$wpdb->prefix}woocommerce_order_items as woi, 103 {$wpdb->prefix}posts as p 104 WHERE woi.order_item_id = woim.order_item_id 105 AND woi.order_id = p.ID 106 AND p.post_status IN ( {$status_placeholders} ) 107 AND p.post_type = 'shop_order' 108 AND woim.meta_key = '_product_id' 109 AND woim.meta_value = %d 110 ORDER BY woi.order_item_id ASC LIMIT %d OFFSET %d", 111 $params 112 ); 113 } 81 114 82 115 $orders_ids = $wpdb->get_col( $query ); … … 186 219 private function get_order_type( $order_id, $subscription_id ) { 187 220 global $wpdb; 188 $query = "SELECT * FROM $wpdb->postmeta WHERE post_id = {$order_id} 189 AND ( 190 meta_key = '_subscription_renewal' 191 OR meta_key = '_subscription_resubscribe' 192 OR meta_key = '_subscription_switch' 193 ) 194 AND meta_value = {$subscription_id} 195 LIMIT 1"; 221 $query = $wpdb->prepare( 222 "SELECT * FROM {$wpdb->postmeta} 223 WHERE post_id = %d 224 AND ( 225 meta_key = '_subscription_renewal' 226 OR meta_key = '_subscription_resubscribe' 227 OR meta_key = '_subscription_switch' 228 ) 229 AND meta_value = %d 230 LIMIT 1", 231 intval( $order_id ), 232 intval( $subscription_id ) 233 ); 196 234 $result = $wpdb->get_row( $query, ARRAY_A ); 197 235 -
appsero-helper/trunk/includes/WooCommerce/UseCases/SendRequestsHelper.php
r2364757 r3475342 54 54 $software_id = get_post_meta( $product_id, '_software_product_id', true); 55 55 56 $query = "SELECT * FROM {$wpdb->wc_software_licenses} WHERE `order_id` = {$order_id} AND `software_product_id` = '{$software_id}' "; 56 $query = $wpdb->prepare( 57 "SELECT * FROM {$wpdb->wc_software_licenses} WHERE `order_id` = %d AND `software_product_id` = %s", 58 intval( $order_id ), 59 $software_id 60 ); 57 61 $licenses = $wpdb->get_results( $query, ARRAY_A ); 58 62 -
appsero-helper/trunk/readme.txt
r3253142 r3475342 4 4 Tags: licensing, release, analytics, deactivation 5 5 Requires at least: 4.0 6 Tested up to: 6. 77 Stable tag: 1.3. 46 Tested up to: 6.9 7 Stable tag: 1.3.5 8 8 Requires PHP: 5.4 9 9 License: GPLv2 or later … … 124 124 == Changelog == 125 125 126 = 1.3.5 - (5th March, 2026) = 127 - **Fix:** Improve SQL query preparation for better security and performance. 128 126 129 = 1.3.4 - (10th March, 2025) = 127 130 - **Fix:** Updated changelog for version 1.3.4 to correct version name and details. -
appsero-helper/trunk/vendor/autoload.php
r3253142 r3475342 5 5 require_once __DIR__ . '/composer/autoload_real.php'; 6 6 7 return ComposerAutoloaderInit 03b5eb5f7842abfa606205e8065b89c4::getLoader();7 return ComposerAutoloaderInitf450d401a59fb00d11d99977c268f7f3::getLoader(); -
appsero-helper/trunk/vendor/composer/autoload_real.php
r3253142 r3475342 3 3 // autoload_real.php @generated by Composer 4 4 5 class ComposerAutoloaderInit 03b5eb5f7842abfa606205e8065b89c45 class ComposerAutoloaderInitf450d401a59fb00d11d99977c268f7f3 6 6 { 7 7 private static $loader; … … 23 23 } 24 24 25 spl_autoload_register(array('ComposerAutoloaderInit 03b5eb5f7842abfa606205e8065b89c4', 'loadClassLoader'), true, true);25 spl_autoload_register(array('ComposerAutoloaderInitf450d401a59fb00d11d99977c268f7f3', 'loadClassLoader'), true, true); 26 26 self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__))); 27 spl_autoload_unregister(array('ComposerAutoloaderInit 03b5eb5f7842abfa606205e8065b89c4', 'loadClassLoader'));27 spl_autoload_unregister(array('ComposerAutoloaderInitf450d401a59fb00d11d99977c268f7f3', 'loadClassLoader')); 28 28 29 29 $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); … … 31 31 require __DIR__ . '/autoload_static.php'; 32 32 33 call_user_func(\Composer\Autoload\ComposerStaticInit 03b5eb5f7842abfa606205e8065b89c4::getInitializer($loader));33 call_user_func(\Composer\Autoload\ComposerStaticInitf450d401a59fb00d11d99977c268f7f3::getInitializer($loader)); 34 34 } else { 35 35 $map = require __DIR__ . '/autoload_namespaces.php'; -
appsero-helper/trunk/vendor/composer/autoload_static.php
r3253142 r3475342 5 5 namespace Composer\Autoload; 6 6 7 class ComposerStaticInit 03b5eb5f7842abfa606205e8065b89c47 class ComposerStaticInitf450d401a59fb00d11d99977c268f7f3 8 8 { 9 9 public static $prefixLengthsPsr4 = array ( … … 72 72 { 73 73 return \Closure::bind(function () use ($loader) { 74 $loader->prefixLengthsPsr4 = ComposerStaticInit 03b5eb5f7842abfa606205e8065b89c4::$prefixLengthsPsr4;75 $loader->prefixDirsPsr4 = ComposerStaticInit 03b5eb5f7842abfa606205e8065b89c4::$prefixDirsPsr4;76 $loader->classMap = ComposerStaticInit 03b5eb5f7842abfa606205e8065b89c4::$classMap;74 $loader->prefixLengthsPsr4 = ComposerStaticInitf450d401a59fb00d11d99977c268f7f3::$prefixLengthsPsr4; 75 $loader->prefixDirsPsr4 = ComposerStaticInitf450d401a59fb00d11d99977c268f7f3::$prefixDirsPsr4; 76 $loader->classMap = ComposerStaticInitf450d401a59fb00d11d99977c268f7f3::$classMap; 77 77 78 78 }, null, ClassLoader::class);
Note: See TracChangeset
for help on using the changeset viewer.