Changeset 3835028
- Timestamp:
- 11/30/2026 12:04:28 PM (less than one hour ago)
- Location:
- 3d-print-pricing-calculator
- Files:
-
- 46 added
- 9 edited
-
tags/1.4.9.0 (added)
-
tags/1.4.9.0/3d-print-pricing-calculator.php (added)
-
tags/1.4.9.0/LICENSE.txt (added)
-
tags/1.4.9.0/LICENSE_APACHE.txt (added)
-
tags/1.4.9.0/css (added)
-
tags/1.4.9.0/css/admin-styles.css (added)
-
tags/1.4.9.0/css/modal-compatibility.css (added)
-
tags/1.4.9.0/css/modal-fixes.css (added)
-
tags/1.4.9.0/css/onboarding.css (added)
-
tags/1.4.9.0/css/style.css (added)
-
tags/1.4.9.0/css/view-transitions.css (added)
-
tags/1.4.9.0/images (added)
-
tags/1.4.9.0/images/blue-tooltip.svg (added)
-
tags/1.4.9.0/images/caret.png (added)
-
tags/1.4.9.0/images/fav-icon-dashboard.png (added)
-
tags/1.4.9.0/images/icon-256x256.png (added)
-
tags/1.4.9.0/images/order-success.png (added)
-
tags/1.4.9.0/images/properties-tooltip.svg (added)
-
tags/1.4.9.0/images/screenshot1.jpg (added)
-
tags/1.4.9.0/images/screenshot2.jpg (added)
-
tags/1.4.9.0/includes (added)
-
tags/1.4.9.0/includes/admin-email-templates.php (added)
-
tags/1.4.9.0/includes/admin-file-manager.php (added)
-
tags/1.4.9.0/includes/admin-settings.php (added)
-
tags/1.4.9.0/includes/bootstrap (added)
-
tags/1.4.9.0/includes/bootstrap/css (added)
-
tags/1.4.9.0/includes/bootstrap/css/bootstrap.min.css (added)
-
tags/1.4.9.0/includes/bootstrap/js (added)
-
tags/1.4.9.0/includes/bootstrap/js/bootstrap.min.js (added)
-
tags/1.4.9.0/includes/font-awesome (added)
-
tags/1.4.9.0/includes/font-awesome/all.min.css (added)
-
tags/1.4.9.0/includes/font-awesome/fontawesome.min.css (added)
-
tags/1.4.9.0/includes/onboarding.php (added)
-
tags/1.4.9.0/includes/stl-parser-engine.php (added)
-
tags/1.4.9.0/index.php (added)
-
tags/1.4.9.0/js (added)
-
tags/1.4.9.0/js/admin-script.js (added)
-
tags/1.4.9.0/js/admin-scripts.js (added)
-
tags/1.4.9.0/js/onboarding.js (added)
-
tags/1.4.9.0/js/script.js (added)
-
tags/1.4.9.0/js/view-transitions.js (added)
-
tags/1.4.9.0/readme.md (added)
-
tags/1.4.9.0/readme.txt (added)
-
tags/1.4.9.0/templates (added)
-
tags/1.4.9.0/templates/upload-form.php (added)
-
trunk/3d-print-pricing-calculator.php (modified) (22 diffs)
-
trunk/includes/admin-email-templates.php (modified) (1 diff)
-
trunk/includes/admin-file-manager.php (modified) (1 diff)
-
trunk/includes/admin-settings.php (modified) (19 diffs)
-
trunk/includes/stl-parser-engine.php (modified) (1 diff)
-
trunk/js/script.js (modified) (1 diff)
-
trunk/js/view-transitions.js (modified) (1 diff)
-
trunk/readme.md (modified) (4 diffs)
-
trunk/readme.txt (added)
-
trunk/templates/upload-form.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
3d-print-pricing-calculator/trunk/3d-print-pricing-calculator.php
r3632805 r3835028 5 5 * Author: odysse.io 6 6 * Author URI: https://odysse.io/ 7 * Version: 1.4. 8.97 * Version: 1.4.9.0 8 8 * Text Domain: 3d-print-pricing-calculator 9 9 * License: GPL-3.0 … … 28 28 29 29 // Define plugin version and constants 30 define('PPC3D_VERSION', '1.4. 8.9');30 define('PPC3D_VERSION', '1.4.9.0'); 31 31 define('PPC3D_PLUGIN_PATH', plugin_dir_path(__FILE__)); 32 32 define('PPC3D_PLUGIN_URL', plugin_dir_url(__FILE__)); … … 62 62 function ppc3d_stl_parser_enqueue_scripts() 63 63 { 64 wp_enqueue_script('babylon', 'https://cdn.babylonjs.com/ babylon.js', array(), '7.25.1', true);65 wp_enqueue_script('babylon-loader', 'https://cdn.babylonjs.com/ loaders/babylonjs.loaders.min.js', array(), '7.25.1', true);64 wp_enqueue_script('babylon', 'https://cdn.babylonjs.com/v7.25.1/babylon.js', array(), '7.25.1', true); 65 wp_enqueue_script('babylon-loader', 'https://cdn.babylonjs.com/v7.25.1/loaders/babylonjs.loaders.min.js', array(), '7.25.1', true); 66 66 67 67 if (!is_admin()) { … … 111 111 function ppc3d_enqueue_custom_admin_styles() 112 112 { 113 if (! current_user_can('manage_options')) { 114 return; 115 } 116 113 117 // Enqueue main admin styles 114 118 $style_path_admin = plugin_dir_path(__FILE__) . 'css/admin-style.css'; … … 124 128 wp_localize_script('stl-parser-admin-script', 'ppc3d_stl_parser_admin', array( 125 129 'ajaxurl' => admin_url('admin-ajax.php'), 126 'nonce' => wp_create_nonce('ppc3d_ upload_stl_nonce'),130 'nonce' => wp_create_nonce('ppc3d_admin_nonce'), 127 131 )); 128 132 … … 156 160 add_action('wp_ajax_ppc3d_upload_stl_file', 'ppc3d_upload_stl_file'); 157 161 add_action('wp_ajax_nopriv_ppc3d_upload_stl_file', 'ppc3d_upload_stl_file'); 158 add_action('wp_ajax_ppc3d_show_stl_file', 'ppc3d_show_stl_file');159 add_action('wp_ajax_nopriv_ppc3d_show_stl_file', 'ppc3d_show_stl_file');160 162 add_action('wp_ajax_ppc3d_send_purchase_emails', 'ppc3d_send_purchase_emails_callback'); 161 163 add_action('wp_ajax_ppc3d_complete_onboarding', 'ppc3d_complete_onboarding_callback'); … … 194 196 if (! check_ajax_referer('ppc3d_upload_stl_nonce', 'nonce', false)) { 195 197 wp_send_json_error('Nonce verification failed.'); 196 wp_die();197 198 } 198 199 … … 201 202 202 203 // Verify file upload exists 203 if (! isset($_FILES[$file_key])) {204 if (! isset($_FILES[$file_key]) || ! is_array($_FILES[$file_key]) || ! isset($_FILES[$file_key]['name'], $_FILES[$file_key]['tmp_name'])) { 204 205 wp_send_json_error('No file uploaded.'); 205 wp_die(); 206 } 207 208 // Use wp_handle_upload for sanitizing and handling the file upload 209 $upload_overrides = ['test_form' => false]; // Disable test for POST form field 210 $upload_dir = wp_upload_dir(); 211 $upload_path = trailingslashit($upload_dir['path']); // Directory path for uploads 212 213 // Get original file name and sanitize it 214 $file_name = sanitize_file_name($_FILES[$file_key]['name']); 215 $file_path = $upload_path . $file_name; 216 217 // Check if the file already exists and delete it 218 if (file_exists($file_path)) { 219 unlink($file_path); // Deletes the existing file 220 } 221 222 // Upload the new file 206 } 207 208 if (! is_string($_FILES[$file_key]['name']) || ! is_string($_FILES[$file_key]['tmp_name'])) { 209 wp_send_json_error('Invalid upload.'); 210 } 211 212 $original_name = sanitize_file_name(wp_unslash($_FILES[$file_key]['name'])); 213 if ('stl' !== strtolower(pathinfo($original_name, PATHINFO_EXTENSION))) { 214 wp_send_json_error('Invalid file type. Please upload an STL file.'); 215 } 216 217 $tmp_size = isset($_FILES[$file_key]['size']) ? (int) $_FILES[$file_key]['size'] : 0; 218 if ($tmp_size < 84) { 219 wp_send_json_error('Invalid STL file.'); 220 } 221 222 $upload_overrides = array( 223 'test_form' => false, 224 'mimes' => array('stl' => 'application/sla'), 225 ); 223 226 $uploaded_file = wp_handle_upload($_FILES[$file_key], $upload_overrides); 224 227 225 // Check if the file was uploaded successfully226 228 if (isset($uploaded_file['error'])) { 227 229 wp_send_json_error('File upload error: ' . $uploaded_file['error']); 228 wp_die(); 229 } 230 231 // Verify the file extension is STL 232 $file_extension = strtolower(pathinfo($file_name, PATHINFO_EXTENSION)); 233 if ($file_extension !== 'stl') { 234 // Delete the file if it's not an STL 230 } 231 232 $stored_name = wp_basename($uploaded_file['file']); 233 if ('stl' !== strtolower(pathinfo($stored_name, PATHINFO_EXTENSION))) { 235 234 wp_delete_file($uploaded_file['file']); 236 235 wp_send_json_error('Invalid file type. Please upload an STL file.'); 237 wp_die();238 } 239 240 // Return the file details 241 return [242 'file_name' => $file_name,243 'root_url' => trailingslashit($upload_dir['url']),236 } 237 238 $upload_dir = wp_upload_dir(); 239 240 return array( 241 'file_name' => $stored_name, 242 'root_url' => trailingslashit($upload_dir['url']), 244 243 'site_upload_path' => esc_url_raw($uploaded_file['url']), 245 'upload_path' => $uploaded_file['file'],246 ];244 'upload_path' => $uploaded_file['file'], 245 ); 247 246 } 248 247 … … 288 287 $parsed_data = ppc3d_parse_stl_file($file_data['upload_path'], $unit, $scale); 289 288 } catch (Exception $e) { 290 error_log('STL parse error: ' . $e->getMessage());291 289 wp_send_json_error('Unable to parse STL file.'); 292 290 return; … … 373 371 // Generate a unique transient key using wp_generate_uuid4 374 372 $transient_key = sanitize_key('ppc3d_data_' . wp_generate_uuid4()); 375 set_transient('ppc3d_transient_key', $transient_key, DAY_IN_SECONDS);376 373 377 374 $printing_technology_name = isset($_POST['printing_technology_name']) ? sanitize_text_field(wp_unslash($_POST['printing_technology_name'])) : ''; // Sanitize as string … … 401 398 // Make sure we have the expected structure 402 399 if (!isset($data['data']['formated_data']) || !is_array($data['data']['formated_data'])) { 403 error_log('Expected formated_data structure not found, creating it');404 400 405 401 // Initialize the structure if it doesn't exist … … 451 447 } 452 448 } else { 453 error_log('Found expected formated_data structure');454 449 } 455 450 456 451 // Ensure all values have proper formatting 457 452 if (isset($data['data']['formated_data'])) { 458 // Allow only valid currency symbols in the price string459 $currency_symbol = get_option('ppc3d_currency_symbol', '$');460 $currency_position = get_option('ppc3d_currency_position', 'before');461 $allowed_symbols = preg_quote($currency_symbol, '/') . '$£€¥₹₩';462 463 453 // Make sure price has currency symbol 464 if (isset($data['data']['formated_data']['price']) && !preg_match('/[^0-9.,\s' . $allowed_symbols . ']/u', $data['data']['formated_data']['price'])) { 454 if (isset($data['data']['formated_data']['price']) && !preg_match('/[^0-9.,\s]/', $data['data']['formated_data']['price'])) { 455 $currency_symbol = get_option('ppc3d_currency_symbol', '$'); 456 $currency_position = get_option('ppc3d_currency_position', 'before'); 457 465 458 $price_value = floatval(preg_replace('/[^0-9.]/', '', $data['data']['formated_data']['price'])); 466 459 467 460 if ($currency_position === 'before') { 468 461 $data['data']['formated_data']['price'] = $currency_symbol . number_format($price_value, 2); … … 611 604 function ppc3d_get_transient_data($request) { 612 605 // Get the transient key from the request 613 $transient_key = sanitize_ text_field($request->get_param('transient_key'));614 615 if (empty($transient_key) ) {606 $transient_key = sanitize_key($request->get_param('transient_key')); 607 608 if (empty($transient_key) || 0 !== strpos($transient_key, 'ppc3d_data_')) { 616 609 return new WP_REST_Response(array( 617 610 'success' => false, … … 619 612 ), 400); 620 613 } 621 614 622 615 // Get the transient data 623 616 $transient_data = get_transient($transient_key); 624 617 625 618 if (false === $transient_data) { 626 619 return new WP_REST_Response(array( … … 629 622 ), 404); 630 623 } 631 632 // Log the transient data for debugging 633 error_log('Transient key: ' . $transient_key); 634 error_log('Formatted data: ' . print_r($transient_data, true)); 635 624 636 625 return new WP_REST_Response(array( 637 626 'success' => true, … … 647 636 $customerEmail = sanitize_email($request->get_param('email')); 648 637 $shippingAddress = sanitize_text_field($request->get_param('shippingAddress')); 649 $transient_key = sanitize_ text_field($request->get_param('transient_key_field'));638 $transient_key = sanitize_key($request->get_param('transient_key_field')); 650 639 $admin_email = get_option('admin_email'); // WordPress admin email 640 641 if (! is_email($customerEmail)) { 642 return new WP_REST_Response(array( 643 'success' => false, 644 'data' => array('message' => 'A valid email address is required.') 645 ), 400); 646 } 647 648 if (empty($transient_key) || 0 !== strpos($transient_key, 'ppc3d_data_')) { 649 return new WP_REST_Response(array( 650 'success' => false, 651 'data' => array('message' => 'Invalid or expired quote. Please upload your file again.') 652 ), 400); 653 } 651 654 652 655 // Retrieve formatted data from the transient using the transient key 653 656 $formatted_data = get_transient($transient_key); 654 655 // Debug log to check what's in the transient 656 error_log('Transient key: ' . $transient_key); 657 error_log('Formatted data: ' . print_r($formatted_data, true)); 657 658 if (false === $formatted_data) { 659 return new WP_REST_Response(array( 660 'success' => false, 661 'data' => array('message' => 'Invalid or expired quote. Please upload your file again.') 662 ), 400); 663 } 664 665 $submitted_flag = 'ppc3d_sub_' . md5($transient_key); 666 if (get_transient($submitted_flag)) { 667 return new WP_REST_Response(array( 668 'success' => false, 669 'data' => array('message' => 'This quote has already been submitted.') 670 ), 429); 671 } 658 672 659 673 // Generate dynamic order number using timestamp and a random number 660 $orderNumber = 'ORD-' . time() . '-' . rand(1000, 9999);674 $orderNumber = 'ORD-' . time() . '-' . wp_rand(1000, 9999); 661 675 662 676 // Customer email subject … … 752 766 // Fallback to direct access if formated_data is not available 753 767 elseif (is_array($formatted_data)) { 754 error_log('Trying alternative data structure access - direct access');755 768 756 769 // Try to access fields directly … … 795 808 if ($orderDetails === "<ul>") { 796 809 $orderDetails .= "<li><em>No calculation data available</em></li>"; 797 error_log('No calculation data found in transient: ' . print_r($formatted_data, true));798 810 } 799 811 … … 832 844 // Try to access options directly from the formatted_data 833 845 elseif (is_array($formatted_data)) { 834 error_log('Trying alternative data structure for options - direct access');835 846 836 847 if (isset($formatted_data['printing_technology_name'])) { … … 862 873 if ($optionsDetails === "<ul>") { 863 874 $optionsDetails .= "<li><em>No options data available</em></li>"; 864 error_log('No options data found in transient');865 875 } 866 876 … … 899 909 // Handle email sending status and response 900 910 if ($email_sent_customer && $email_sent_admin) { 911 set_transient($submitted_flag, 1, DAY_IN_SECONDS); 901 912 return new WP_REST_Response(array( 902 913 'success' => true, … … 918 929 'data' => array( 919 930 'message' => 'An unexpected error occurred.', 920 'error' => $e->getMessage()931 'error' => 'Please try again later.' 921 932 ) 922 933 ), 500); -
3d-print-pricing-calculator/trunk/includes/admin-email-templates.php
r3572835 r3835028 12 12 { 13 13 // Save form 14 if (isset($_POST['ppc3d_email_template_nonce']) && wp_verify_nonce($_POST['ppc3d_email_template_nonce'], 'ppc3d_save_email_template')) { 15 $template_content = wp_unslash($_POST['email_template_content']); 14 if (! current_user_can('manage_options')) { 15 return; 16 } 17 18 if (isset($_POST['ppc3d_email_template_nonce'], $_POST['email_template_content']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['ppc3d_email_template_nonce'])), 'ppc3d_save_email_template')) { 19 $template_content = wp_kses_post(wp_unslash($_POST['email_template_content'])); 16 20 $use_default = isset($_POST['use_default_template']) ? 'yes' : 'no'; 17 18 remove_filter('pre_update_option_ppc3d_email_template', 'wp_filter_kses');19 remove_filter('pre_update_option_ppc3d_email_template', 'sanitize_text_field');20 21 21 22 update_option('ppc3d_email_template', $template_content); -
3d-print-pricing-calculator/trunk/includes/admin-file-manager.php
r3572835 r3835028 13 13 // Process file deletion if requested 14 14 if (isset($_POST['action']) && $_POST['action'] === 'delete_file' && isset($_POST['file_path']) && isset($_POST['nonce'])) { 15 if (wp_verify_nonce( $_POST['nonce'], 'ppc3d_delete_file_nonce')) {15 if (wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'ppc3d_delete_file_nonce')) { 16 16 $file_path = sanitize_text_field(wp_unslash($_POST['file_path'])); 17 17 $upload_dir = wp_upload_dir(); 18 $base_dir = $upload_dir['basedir']; 19 20 // Ensure the file is within the uploads directory 21 if (strpos($file_path, $base_dir) === 0 && file_exists($file_path)) { 18 $base_dir = wp_normalize_path(realpath($upload_dir['basedir'])); 19 $real_path = realpath($file_path); 20 $real_path = $real_path ? wp_normalize_path($real_path) : ''; 21 22 $is_tracked = false; 23 foreach ((array) get_option('ppc3d_uploaded_files', array()) as $tracked) { 24 if (isset($tracked['file_path']) && $tracked['file_path'] === $file_path) { 25 $is_tracked = true; 26 break; 27 } 28 } 29 30 if ( 31 $is_tracked 32 && $base_dir 33 && $real_path 34 && 0 === strpos($real_path, trailingslashit($base_dir)) 35 && 'stl' === strtolower(pathinfo($real_path, PATHINFO_EXTENSION)) 36 && is_file($real_path) 37 ) { 22 38 // Delete the physical file 23 if ( unlink($file_path)) {39 if (wp_delete_file($real_path) || ! file_exists($real_path)) { 24 40 // Remove the file from metadata 25 41 $uploaded_files = get_option('ppc3d_uploaded_files', array()); -
3d-print-pricing-calculator/trunk/includes/admin-settings.php
r3572835 r3835028 2 2 3 3 define('ppc3d_file', __FILE__); // Define the plugin file constant 4 5 function ppc3d_verify_admin_ajax() 6 { 7 $nonce = isset($_POST['nonce']) ? sanitize_text_field(wp_unslash($_POST['nonce'])) : ''; 8 9 if (! $nonce || ! wp_verify_nonce($nonce, 'ppc3d_admin_nonce')) { 10 wp_send_json_error('Security check failed. Please refresh the page and try again.', 403); 11 } 12 13 if (! current_user_can('manage_options')) { 14 wp_send_json_error('Insufficient permissions.', 403); 15 } 16 } 4 17 5 18 // AJAX handler for saving currency settings … … 233 246 wp_localize_script('ppc3d-admin-script', 'ppc3d_ajax', array( 234 247 'ajax_url' => admin_url('admin-ajax.php'), 235 'nonce' => wp_create_nonce('ppc3d_ upload_stl_nonce')248 'nonce' => wp_create_nonce('ppc3d_admin_nonce') 236 249 )); 237 250 … … 1142 1155 function ppc3d_add_printing_technology_option_callback() 1143 1156 { 1144 // Verify nonce 1145 if (! isset($_POST['nonce']) || ! wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'ppc3d_upload_stl_nonce')) { 1146 // Nonce verification failed 1147 wp_die('Nonce verification failed. Please refresh the page and try again.'); 1148 } 1157 ppc3d_verify_admin_ajax(); 1149 1158 1150 1159 // Ensure the required fields are set … … 1189 1198 function ppc3d_edit_printing_technology_option_callback() 1190 1199 { 1191 // Verify nonce 1192 if (!isset($_POST['nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'ppc3d_upload_stl_nonce')) { 1193 wp_send_json_error('Nonce verification failed.'); 1194 wp_die(); 1195 } 1200 ppc3d_verify_admin_ajax(); 1196 1201 1197 1202 // Validate required fields … … 1264 1269 function ppc3d_delete_printing_technology_option_callback() 1265 1270 { 1266 // Verify nonce 1267 if (! isset($_POST['nonce']) || ! wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'ppc3d_upload_stl_nonce')) { 1268 // Nonce verification failed 1269 wp_die('Nonce verification failed. Please refresh the page and try again.'); 1270 } 1271 ppc3d_verify_admin_ajax(); 1271 1272 if (isset($_POST['optionName'])) { 1272 1273 $optionName = sanitize_text_field(wp_unslash($_POST['optionName'])); … … 1326 1327 function ppc3d_add_material_option_callback() 1327 1328 { 1328 // Verify nonce 1329 if (! isset($_POST['nonce']) || ! wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'ppc3d_upload_stl_nonce')) { 1330 // Nonce verification failed 1331 wp_die('Nonce verification failed. Please refresh the page and try again.'); 1332 } 1329 ppc3d_verify_admin_ajax(); 1333 1330 // Ensure the required fields are set 1334 1331 if (isset($_POST['material'], $_POST['material_value'], $_POST['material_description'])) { … … 1371 1368 function ppc3d_edit_material_option_callback() 1372 1369 { 1373 // Verify nonce 1374 if (!isset($_POST['nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'ppc3d_upload_stl_nonce')) { 1375 wp_send_json_error('Nonce verification failed.'); 1376 wp_die(); 1377 } 1370 ppc3d_verify_admin_ajax(); 1378 1371 1379 1372 // Validate required fields … … 1447 1440 function ppc3d_delete_material_option_callback() 1448 1441 { 1449 // Verify nonce 1450 if (! isset($_POST['nonce']) || ! wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'ppc3d_upload_stl_nonce')) { 1451 // Nonce verification failed 1452 wp_die('Nonce verification failed. Please refresh the page and try again.'); 1453 } 1442 ppc3d_verify_admin_ajax(); 1454 1443 if (isset($_POST['optionName'])) { 1455 1444 $optionName = sanitize_text_field(wp_unslash($_POST['optionName'])); … … 1522 1511 function ppc3d_add_quality_option_callback() 1523 1512 { 1524 // Verify nonce 1525 if (!isset($_POST['nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'ppc3d_upload_stl_nonce')) { 1526 wp_send_json_error('Nonce verification failed.'); 1527 wp_die(); 1528 } 1513 ppc3d_verify_admin_ajax(); 1529 1514 1530 1515 // Check if required fields are set … … 1568 1553 function ppc3d_edit_quality_option_callback() 1569 1554 { 1570 // Verify nonce 1571 if (!isset($_POST['nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'ppc3d_upload_stl_nonce')) { 1572 wp_send_json_error('Nonce verification failed.'); 1573 wp_die(); 1574 } 1555 ppc3d_verify_admin_ajax(); 1575 1556 1576 1557 // Validate required fields … … 1643 1624 function ppc3d_delete_quality_option_callback() 1644 1625 { 1645 // Verify nonce 1646 if (! isset($_POST['nonce']) || ! wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'ppc3d_upload_stl_nonce')) { 1647 // Nonce verification failed 1648 wp_die('Nonce verification failed. Please refresh the page and try again.'); 1649 } 1626 ppc3d_verify_admin_ajax(); 1650 1627 if (isset($_POST['optionName'])) { 1651 1628 $optionName = sanitize_text_field(wp_unslash($_POST['optionName'])); … … 1699 1676 function ppc3d_add_infill_option_callback() 1700 1677 { 1701 // Verify nonce 1702 if (! isset($_POST['nonce']) || ! wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'ppc3d_upload_stl_nonce')) { 1703 // Nonce verification failed 1704 wp_die('Nonce verification failed. Please refresh the page and try again.'); 1705 } 1678 ppc3d_verify_admin_ajax(); 1706 1679 // Check if required fields are set 1707 1680 if (!isset($_POST['infill'], $_POST['infill_value'], $_POST['infill_description'])) { … … 1747 1720 function ppc3d_edit_infill_option_callback() 1748 1721 { 1749 // Verify nonce 1750 if (!isset($_POST['nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'ppc3d_upload_stl_nonce')) { 1751 wp_send_json_error('Nonce verification failed.'); 1752 wp_die(); 1753 } 1722 ppc3d_verify_admin_ajax(); 1754 1723 1755 1724 // Validate required fields … … 1808 1777 function ppc3d_delete_infill_option_callback() 1809 1778 { 1810 // Verify nonce 1811 if (! isset($_POST['nonce']) || ! wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'ppc3d_upload_stl_nonce')) { 1812 // Nonce verification failed 1813 wp_die('Nonce verification failed. Please refresh the page and try again.'); 1814 } 1779 ppc3d_verify_admin_ajax(); 1815 1780 if (isset($_POST['optionName'])) { 1816 1781 $optionName = sanitize_text_field(wp_unslash($_POST['optionName'])); … … 1884 1849 function ppc3d_add_color_option_callback() 1885 1850 { 1886 // Verify nonce 1887 if (! isset($_POST['nonce']) || ! wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'ppc3d_upload_stl_nonce')) { 1888 // Nonce verification failed 1889 wp_die('Nonce verification failed. Please refresh the page and try again.'); 1890 } 1851 ppc3d_verify_admin_ajax(); 1891 1852 // Check if required fields are set 1892 1853 if (!isset($_POST['color'], $_POST['color_value'], $_POST['color_description'], $_POST['color_price'])) { … … 1932 1893 function ppc3d_edit_color_option_callback() 1933 1894 { 1934 // Verify nonce 1935 if (!isset($_POST['nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'ppc3d_upload_stl_nonce')) { 1936 wp_send_json_error('Nonce verification failed.'); 1937 wp_die(); 1938 } 1895 ppc3d_verify_admin_ajax(); 1939 1896 1940 1897 // Validate required fields … … 2003 1960 function ppc3d_delete_color_option_callback() 2004 1961 { 2005 // Verify nonce 2006 if (! isset($_POST['nonce']) || ! wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['nonce'])), 'ppc3d_upload_stl_nonce')) { 2007 // Nonce verification failed 2008 wp_die('Nonce verification failed. Please refresh the page and try again.'); 2009 } 1962 ppc3d_verify_admin_ajax(); 2010 1963 if (isset($_POST['optionName'])) { 2011 1964 $optionName = sanitize_text_field(wp_unslash($_POST['optionName'])); … … 2038 1991 function ppc3d_save_setting_callback() 2039 1992 { 2040 // Check nonce for security 2041 if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'ppc3d_upload_stl_nonce')) { 2042 wp_send_json_error('Security check failed'); 2043 } 1993 ppc3d_verify_admin_ajax(); 2044 1994 2045 1995 // Get option name and value … … 4252 4202 function ppc3d_update_toggle_option_callback() 4253 4203 { 4254 // Check nonce for security 4255 if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'ppc3d_upload_stl_nonce')) { 4256 wp_send_json_error('Security check failed'); 4257 } 4204 ppc3d_verify_admin_ajax(); 4258 4205 4259 4206 // Get option name and value -
3d-print-pricing-calculator/trunk/includes/stl-parser-engine.php
r3572835 r3835028 31 31 $file = fopen($file_path, 'r'); 32 32 if (! $file) { 33 throw new RuntimeException('Unable to open STL file : ' . $file_path);33 throw new RuntimeException('Unable to open STL file.'); 34 34 } 35 35 36 36 fseek($file, 80); 37 $triangles = unpack('V', fread($file, 4))[1]; 37 $count_bytes = fread($file, 4); 38 if (false === $count_bytes || 4 !== strlen($count_bytes)) { 39 fclose($file); 40 throw new RuntimeException('Invalid STL file.'); 41 } 42 $triangles = unpack('V', $count_bytes)[1]; 43 44 $file_size = filesize($file_path); 45 if (false === $file_size || $triangles < 1 || $file_size < 84 + ($triangles * 50)) { 46 fclose($file); 47 throw new RuntimeException('Invalid STL file.'); 48 } 38 49 39 50 for ($i = 0; $i < $triangles; $i++) { -
3d-print-pricing-calculator/trunk/js/script.js
r3632805 r3835028 28 28 function disableGamepadAPI() { 29 29 if (!window.BABYLON) return; 30 30 31 31 try { 32 if (navigator && typeof navigator.getGamepads === "function") { 33 Object.defineProperty(navigator, "getGamepads", { 34 value: function () { 35 return []; 36 }, 37 writable: false, 38 configurable: true, 39 }); 40 } 41 32 // Create safe mock implementations 33 var noopFn = function() {}; 34 var emptyArray = function() { return []; }; 35 var mockObservable = { add: noopFn, remove: noopFn, clear: noopFn }; 36 37 // Completely disable GamepadManager 38 BABYLON.GamepadManager = function() { 39 this.onGamepadConnectedObservable = mockObservable; 40 this.onGamepadDisconnectedObservable = mockObservable; 41 this.getGamepads = emptyArray; 42 this.dispose = noopFn; 43 this.getGamepadByType = emptyArray; 44 }; 45 46 // Disable gamepad in Engine 47 if (BABYLON.Engine) { 48 var originalEngineConstructor = BABYLON.Engine; 49 BABYLON.Engine = function() { 50 var engine = originalEngineConstructor.apply(this, arguments); 51 if (engine.gamepadManager) { 52 engine.gamepadManager = new BABYLON.GamepadManager(); 53 } 54 return engine; 55 }; 56 BABYLON.Engine.prototype = originalEngineConstructor.prototype; 57 } 58 59 // Patch DeviceSourceManager 42 60 if (BABYLON.DeviceSourceManager) { 43 BABYLON.DeviceSourceManager.prototype.getGamepadSource = function () { 44 return null; 45 }; 46 BABYLON.DeviceSourceManager.prototype.getGamepads = function () { 47 return []; 48 }; 49 } 50 51 console.log("Gamepad API access disabled for Babylon.js"); 61 BABYLON.DeviceSourceManager.prototype.getGamepadSource = function() { return null; }; 62 BABYLON.DeviceSourceManager.prototype.getGamepads = emptyArray; 63 } 64 65 console.log('Gamepad API access disabled for Babylon.js'); 52 66 } catch (e) { 53 console.log("Error disabling Babylon.js gamepad API:", e); 54 } 55 } 56 67 console.log('Error disabling Babylon.js gamepad API:', e); 68 } 69 } 57 70 58 71 // Try to disable immediately -
3d-print-pricing-calculator/trunk/js/view-transitions.js
r3632805 r3835028 175 175 // Prepare the data for the API call 176 176 var requestData = { 177 fullName: fullName, 178 email: userEmail, 179 shippingAddress: shippingAddress, 180 transient_key_field: transientKey, 181 owner_email: ppc3d_stl_parser_3d.admin_email || "", 182 formated_data: transientData.data.formated_data || {}, 183 rootUrl: transientData.data.rootUrl || "", 184 url: transientData.data.url || "", 185 fileName: transientData.data.fileName || "", 186 selectedFormDataNames: transientData.data.selectedFormDataNames || {}, 177 fullName: fullName, 178 email: userEmail, 179 shippingAddress: shippingAddress, 180 transient_key_field: transientKey, 181 owner_email: ppc3d_stl_parser_3d.admin_email || "", 182 user_email: userEmail, 183 formated_data: transientData.data.formated_data || {}, 184 rootUrl: transientData.data.rootUrl || "", 185 url: transientData.data.url || "", 186 fileName: transientData.data.fileName || "", 187 selectedFormDataNames: 188 transientData.data.selectedFormDataNames || {}, 189 customer: { 190 name: fullName, 191 address: shippingAddress, 192 phone: "", // Not collected in the form, but required in the API structure 193 }, 187 194 }; 188 195 -
3d-print-pricing-calculator/trunk/readme.md
r3632805 r3835028 2 2 3 3 Contributors: odysse.io 4 Tested up to: 6.8.14 Tested up to: 7.1 5 5 Requires at least: 5.7 6 6 Requires PHP: 7.4 7 Stable tag: 1.4. 8.97 Stable tag: 1.4.9.0 8 8 License: GPL-3.0 9 9 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 89 89 == Changelog == 90 90 91 = 1.4.8.9 = 92 93 - Fixed rendering and checkout errors 94 95 = 1.4.8.8 = 96 97 - Fixed currency symbol issues. 91 = 1.4.9.0 = 92 93 - Security: Fixed an unauthenticated file deletion vulnerability in the STL upload handler (CVE-2026-119231). Existing files are no longer deleted before an upload is validated. 94 - Security: Updated uploads so WordPress validates the file first, only .stl files are accepted, and files are stored under a unique server-generated filename. 95 - Security: Fixed admin AJAX actions so they require the manage_options capability, and added a separate admin-only nonce. The public front-end nonce can no longer be used for admin actions. 96 - Security: Fixed the quote REST endpoint so it only returns this plugin's own quote data. 97 - Security: Updated the order endpoint to require a valid email address and a valid quote, and to accept one submission per quote. 98 - Security: Fixed the admin file manager so it can only delete tracked .stl files inside the uploads directory. 99 - Security: Updated the email template settings to check user capability and sanitize HTML. 100 - Security: Added STL file size and triangle count validation before parsing. 101 - Security: Removed debug logging of customer data, detailed error messages, and the global latest-quote transient. 102 - Removed unused AJAX hooks that pointed to a function that does not exist. 103 - Fixed the 3D viewer failing to load with newer Babylon.js builds by pinning Babylon.js to version 7.25.1. 104 - Fixed the checkout form so the customer name, email, shipping address, and quote key are sent in the format the server expects. 105 - Updated admin scripts to load only for users who can manage the plugin. 106 - Updated "Tested up to" to WordPress 7.1. 98 107 99 108 = 1.4.0 = … … 210 219 - Initial public release of the plugin, introducing core features and functionality. 211 220 221 == Upgrade Notice == 222 223 = 1.4.9.0 = 224 Security release. Fixes an unauthenticated file deletion vulnerability and missing permission checks on admin actions. Please update immediately. 225 212 226 == Screenshots == 213 227 … … 224 238 This plugin uses Babylon.js for 3D model rendering and loads it from the CDN for optimal performance and minimal plugin footprint: 225 239 226 - **Babylon.js CDN**: [https://cdn.babylonjs.com/ babylon.js](https://cdn.babylonjs.com/babylon.js)227 - **Babylon.js Loaders CDN**: [https://cdn.babylonjs.com/ loaders/babylonjs.loaders.min.js](https://cdn.babylonjs.com/loaders/babylonjs.loaders.min.js)240 - **Babylon.js CDN**: [https://cdn.babylonjs.com/v7.25.1/babylon.js](https://cdn.babylonjs.com/v7.25.1/babylon.js) 241 - **Babylon.js Loaders CDN**: [https://cdn.babylonjs.com/v7.25.1/loaders/babylonjs.loaders.min.js](https://cdn.babylonjs.com/v7.25.1/loaders/babylonjs.loaders.min.js) 228 242 229 243 Babylon.js is licensed under the Apache License 2.0. For more information, visit [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0). -
3d-print-pricing-calculator/trunk/templates/upload-form.php
r3591192 r3835028 102 102 <div class="form-selections"> 103 103 <div class="form-selections-heading"> 104 <span id="checkout-total-price"> <?php echo esc_html(get_option('ppc3d_currency_symbol', '$')); ?>00.00</span>104 <span id="checkout-total-price">$00.00</span> 105 105 106 106 <!-- <button id="removeMesh" type="button" class="reset-button">Reset</button> --> … … 295 295 <li class="price-item"> 296 296 <span class="price-label">Estimated Price:</span> 297 <span class="price-value" id="estimated-price-view"> <?php echo esc_html(get_option('ppc3d_currency_symbol', '$')); ?>0.00</span>297 <span class="price-value" id="estimated-price-view">$0.00</span> 298 298 </li> 299 299 <li class="price-item"> 300 300 <span class="price-label">Shipping Price:</span> 301 <span class="price-value" id="shipping-price-view"> <?php echo esc_html(get_option('ppc3d_currency_symbol', '$')); ?>0.00</span>301 <span class="price-value" id="shipping-price-view">$0.00</span> 302 302 </li> 303 303 </ul> 304 304 <div class="price-container"> 305 305 <span class="total-label">Total Price:</span> 306 <span class="total-value" id="checkout-total-price-view"> <?php echo esc_html(get_option('ppc3d_currency_symbol', '$')); ?>00.00</span>306 <span class="total-value" id="checkout-total-price-view">$00.00</span> 307 307 </div> 308 308 </div>
Note:
See TracChangeset
for help on using the changeset viewer.