Changeset 3763334
- Timestamp:
- 10/24/2026 01:47:30 PM (17 hours ago)
- Location:
- chat-ai-with-dispatcher/trunk
- Files:
-
- 3 edited
-
chat-ai-with-dispatcher.php (modified) (1 diff)
-
includes/frontend/frontend-chataiwd-module.php (modified) (8 diffs)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
chat-ai-with-dispatcher/trunk/chat-ai-with-dispatcher.php
r3451405 r3763334 16 16 * Plugin Name: Chat AI with Dispatcher 17 17 * Description: A free live chat solution with AI and human supervision. 18 * Version: 2. 218 * Version: 2.3 19 19 * Author: Csaba Váradi 20 20 * Author URI: https://www.vrcs.hu/ -
chat-ai-with-dispatcher/trunk/includes/frontend/frontend-chataiwd-module.php
r3451405 r3763334 737 737 'name' => isset( $_FILES['attachment']['name'] ) ? sanitize_file_name( wp_unslash( $_FILES['attachment']['name'] ) ) : '', 738 738 'type' => isset( $_FILES['attachment']['type'] ) ? sanitize_mime_type( wp_unslash( $_FILES['attachment']['type'] ) ) : '', 739 'tmp_name' => $tmp_name, // Itt az eredeti C:/wamp64/... útvonal marad meg739 'tmp_name' => $tmp_name, 740 740 'size' => isset( $_FILES['attachment']['size'] ) ? (int) $_FILES['attachment']['size'] : 0, 741 741 ); 742 742 743 744 745 746 // PDF gyors kezelése 743 // PDF gyors kezelése (változatlanul hagyva) 747 744 if ($file['type'] === 'application/pdf') { 748 $pdf_icon = plugins_url('assets/images/pdf_icon.png', dirname(__FILE__)); // Ellenőrizd az útvonalat!745 $pdf_icon = plugins_url('assets/images/pdf_icon.png', dirname(__FILE__)); 749 746 $json['success'] = true; 750 747 $json['thumbnail_url'] = $pdf_icon; … … 757 754 $base_dir = $upload_dir['basedir']; 758 755 759 // Mappa kezelése - JAVÍTVA760 756 $temp_sub_dir = 'chataiwd_temp/'; 761 757 $temp_dir = trailingslashit($base_dir) . $temp_sub_dir; … … 765 761 } 766 762 767 // Fájlnév generálása (érdemes egy egyedi ID-t elé tenni, mint OC-ben, hogy ne írják felül egymást)768 $filename = time() . '-' . $file['name'];763 // 1. JAVÍTÁS (AUTOMATTIC KÉRÉSE): A basename() hozzáadása a fájlnévhez, hogy ne lehessen ../ trükk: 764 $filename = time() . '-' . basename( $file['name'] ); 769 765 $copied_file_path = $temp_dir . $filename; 770 766 … … 774 770 } 775 771 776 // MIME ellenőrzés finfo-val 772 // MIME ellenőrzés finfo-val (változatlanul) 777 773 $finfo = finfo_open(FILEINFO_MIME_TYPE); 778 774 $mime_type = finfo_file($finfo, $copied_file_path); … … 782 778 783 779 if ( $is_image ) { 784 // Itt hívod meg a resizing funkciót785 780 $thumbnail_url = chataiwd_generate_resized_image( $copied_file_path, 160 ); 786 781 $preview_url = chataiwd_generate_resized_image( $copied_file_path, 500 ); … … 791 786 } 792 787 793 $json['success'] = true; 794 /*$json['thumbnail_url'] = $thumbnail_url; 795 $json['preview_url'] = $preview_url; 796 $json['copied_file_path'] = $temp_sub_dir . $filename; // Relatív útvonal 797 */ 798 799 $json['thumbnail'] = $thumbnail_url; 788 $json['success'] = true; 789 $json['thumbnail'] = $thumbnail_url; 800 790 $json['temp_file_path'] = $preview_url; 801 791 … … 803 793 804 794 } else { 795 // 2. JAVÍTÁS: Ha kiderül, hogy nem kép volt, azonnal letöröljük a másolatot a szerverről! 796 if ( file_exists( $copied_file_path ) ) { 797 wp_delete_file( $copied_file_path ); 798 } 799 805 800 $json['error'] = 'Invalid image format.'; 806 801 wp_send_json( $json ); … … 816 811 817 812 $json = array( 'success' => false ); 818 // FRISSÍTVE: A JS-ből 'copied_file_path'-ként kell érkeznie 819 $copied_file_path = isset( $_POST['copied_file_path'] ) ? sanitize_text_field( wp_unslash( $_POST['copied_file_path'] ) ) : ''; 820 821 if ( empty( $copied_file_path ) ) { 822 // ... 813 814 $raw_path = isset( $_POST['temp_file_path'] ) ? $_POST['temp_file_path'] : ( $_POST['copied_file_path'] ?? '' ); 815 $raw_path = sanitize_text_field( wp_unslash( $raw_path ) ); 816 817 if ( empty( $raw_path ) ) { 818 $json['error'] = 'Missing file path.'; 819 wp_send_json( $json ); 820 return; 823 821 } 824 822 825 823 $upload_dir = wp_upload_dir(); 826 // FRISSÍTVE: 'copied_file_path' használata 827 $file_to_delete = trailingslashit( $upload_dir['basedir'] ) . $copied_file_path; 828 $filename = basename( $file_to_delete ); 829 830 // Töröljük az eredeti másolatot 831 if ( file_exists( $file_to_delete ) ) { 832 wp_delete_file( $file_to_delete ); 833 834 // Próbáljuk törölni a hozzá tartozó ikont is 835 $resized_dir = dirname( $file_to_delete ) . '/resized/'; 836 837 $icon_file_name = pathinfo($filename,PATHINFO_FILENAME) . '_160.' . pathinfo($filename,PATHINFO_EXTENSION); 838 $resized_icon_path = $resized_dir . $icon_file_name; 839 840 if ( file_exists( $resized_icon_path ) ) { 841 wp_delete_file( $resized_icon_path ); // @ - hiba elnyomása, ha valamiért nem törölhető 842 } 843 844 // Törölhetjük a preview_500-at is, ha létezik (bár a JS hívás után ez elvileg a sendMessage-ben történik) 845 $preview_file_name = pathinfo($filename,PATHINFO_FILENAME) . '500.' . pathinfo($filename,PATHINFO_EXTENSION); 846 wp_delete_file( $resized_dir . $preview_file_name ); 824 $temp_dir = trailingslashit( $upload_dir['basedir'] ) . 'chataiwd_temp'; 825 $real_temp_dir = realpath( $temp_dir ); 826 827 $filename = basename( sanitize_file_name( $raw_path ) ); 828 $file_to_delete = trailingslashit( $temp_dir ) . $filename; 829 $real_file_path = realpath( $file_to_delete ); 830 831 if ( $real_temp_dir && $real_file_path && 0 === strpos( $real_file_path, $real_temp_dir ) && file_exists( $real_file_path ) ) { 832 833 wp_delete_file( $real_file_path ); 834 835 $resized_dir = trailingslashit( $temp_dir ) . 'resized/'; 836 $real_resized_dir = realpath( $resized_dir ); 837 838 if ( $real_resized_dir && is_dir( $real_resized_dir ) ) { 839 $ext = pathinfo( $filename, PATHINFO_EXTENSION ); 840 $name = pathinfo( $filename, PATHINFO_FILENAME ); 841 842 $icon_file_name = $name . '_160.' . $ext; 843 $resized_icon_path = trailingslashit( $real_resized_dir ) . $icon_file_name; 844 if ( file_exists( $resized_icon_path ) ) { 845 wp_delete_file( $resized_icon_path ); 846 } 847 848 $preview_file_name = $name . '500.' . $ext; 849 $preview_path = trailingslashit( $real_resized_dir ) . $preview_file_name; 850 if ( file_exists( $preview_path ) ) { 851 wp_delete_file( $preview_path ); 852 } 853 } 847 854 848 855 $json['success'] = true; 849 _wp_send_json( $json ); 850 } else { 851 $json['error'] = 'File not found.'; 852 wp_send_json( $json ); 853 } 856 wp_send_json( $json ); 857 return; 858 } 859 860 $json['error'] = 'File not found or access denied.'; 861 wp_send_json( $json ); 854 862 } 855 863 -
chat-ai-with-dispatcher/trunk/readme.txt
r3451708 r3763334 5 5 **Tested up to:** 6.9 6 6 **Requires PHP:** 7.4 7 **Stable tag:** 2. 27 **Stable tag:** 2.3 8 8 **License:** GPLv2 or later 9 9 **License URI:** https://www.gnu.org/licenses/gpl-2.0.html … … 23 23 - Mobile-friendly and easy to install. 24 24 25 [youtube https://youtu.be/ i5akM_zmMOE]25 [youtube https://youtu.be/3zQa2NOSucs] 26 26 27 27 --- … … 98 98 99 99 ## Changelog 100 ### 2.3.0 101 * Security fix: Path traversal prevention and directory containment check in temporary file handlers. (Credit: Muni Nitish Kumar Yaddala) 102 100 103 ### 2.2.0 101 104 * WhatsApp Integration: Direct WhatsApp contact button added to the chat interface with admin-configurable phone numbers.
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)