Changeset 2743703
- Timestamp:
- 06/16/2022 04:57:15 PM (4 years ago)
- Location:
- wp-oer
- Files:
-
- 6 edited
- 1 copied
-
tags/0.9.1 (copied) (copied from wp-oer/trunk)
-
tags/0.9.1/includes/oer-functions.php (modified) (14 diffs)
-
tags/0.9.1/open-educational-resources.php (modified) (5 diffs)
-
tags/0.9.1/readme.txt (modified) (2 diffs)
-
trunk/includes/oer-functions.php (modified) (14 diffs)
-
trunk/open-educational-resources.php (modified) (5 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-oer/tags/0.9.1/includes/oer-functions.php
r2742932 r2743703 1046 1046 $cnt = 0; 1047 1047 try{ 1048 // Register our path override. 1049 add_filter( 'upload_dir', 'oer_override_upload_dir' ); 1050 $upload_overrides = array( 1051 'test_form' => false, 1052 'unique_filename_callback' => 'oer_override_filename'); 1053 1048 1054 if ($default==true) { 1049 1055 //default resource filename … … 1066 1072 mkdir(OER_PATH."upload",0777); 1067 1073 } 1074 $_file = wp_handle_upload($_FILES["resource_import"], $upload_overrides); 1068 1075 "Upload: " . sanitize_file_name($_FILES["resource_import"]["name"]) . "<br>"; 1069 1076 "Type: " . sanitize_text_field($_FILES["resource_import"]["type"]) . "<br>"; 1070 1077 "Size: " . sanitize_text_field(($_FILES["resource_import"]["size"] / 1024)) . " kB<br>"; 1071 "stored in:" .move_uploaded_file($_FILES["resource_import"]["tmp_name"],OER_PATH."upload/".$filename) ; 1072 } 1073 $excl_obj->read(OER_PATH."upload/".$filename); 1078 "stored in:" . $_file['file']; 1079 } 1080 1081 $excl_obj->read($_file['file']); 1074 1082 } 1075 1083 } 1084 // Set upload dir to normal 1085 remove_filter( 'upload_dir', 'oer_override_upload_dir' ); 1076 1086 1077 1087 $fnldata = $excl_obj->sheets[0]; … … 1718 1728 } 1719 1729 1730 // Temporarily override upload dir of wp_handle_upload 1731 function oer_override_upload_dir( $dir ){ 1732 return array( 1733 'path' => OER_PATH."upload", 1734 'url' => OER_PATH."upload", 1735 'subdir' => '/upload', 1736 ) + $dir; 1737 } 1738 1739 // Override filename for wp_handle_upload 1740 function oer_override_filename($dir, $name, $ext){ 1741 $time = time(); 1742 $date = date($time); 1743 $file = pathinfo($name); 1744 $new_filename = $file['filename'] . "-" . $date . $ext; 1745 return $new_filename; 1746 } 1747 1720 1748 //Import Subject Areas 1721 1749 function oer_importSubjectAreas($default=false) { … … 1739 1767 1740 1768 global $wpdb; 1769 1770 // Register our path override. 1771 add_filter( 'upload_dir', 'oer_override_upload_dir' ); 1772 $upload_overrides = array( 1773 'test_form' => false, 1774 'unique_filename_callback' => 'oer_override_filename'); 1741 1775 1742 1776 try { … … 1758 1792 { 1759 1793 //Upload File 1760 "Upload: " . sanitize_file_name($_FILES["bulk_import"]["name"]) . "<br>"; 1794 $_file = wp_handle_upload($_FILES["bulk_import"], $upload_overrides); 1795 "Upload: " . sanitize_file_name($_FILES["bulk_import"]["name"]) . "<br>"; 1761 1796 "Type: " . sanitize_text_field($_FILES["bulk_import"]["type"]) . "<br>"; 1762 1797 "Size: " . sanitize_text_field(($_FILES["bulk_import"]["size"] / 1024)) . " kB<br>"; 1763 "stored in:" . move_uploaded_file($_FILES["bulk_import"]["tmp_name"],OER_PATH."upload/".$filename) ;1798 "stored in:" . esc_url_raw($_file['file']) ; 1764 1799 } 1765 1800 1766 1801 //Read Excel Data 1767 $excl_obj->read(OER_PATH."upload/".$filename); 1802 //$excl_obj->read(OER_PATH."upload/".$filename); 1803 $excl_obj->read($_file['file']); 1768 1804 } 1769 1805 } 1806 // Set upload dir to normal 1807 remove_filter( 'upload_dir', 'oer_override_upload_dir' ); 1770 1808 1771 1809 $fnldata = $excl_obj->sheets; … … 1852 1890 return $response; 1853 1891 } 1892 1893 1854 1894 1855 1895 //Import Default Grade Levels … … 2613 2653 $substandards = array(); 2614 2654 2615 $query = "SELECT * FROM {$wpdb->prefix}oer_sub_standards where parent_id ='%s'";2655 $query = "SELECT * FROM {$wpdb->prefix}oer_sub_standards where parent_id = %s"; 2616 2656 2617 2657 $substandards = $wpdb->get_results($wpdb->prepare($query, $std_id)); … … 2630 2670 $notations = array(); 2631 2671 2632 $query = "SELECT * FROM {$wpdb->prefix}oer_standard_notation where parent_id ='%s'";2672 $query = "SELECT * FROM {$wpdb->prefix}oer_standard_notation where parent_id = %s"; 2633 2673 2634 2674 $result = $wpdb->get_results($wpdb->prepare($query, $std_id)); … … 2649 2689 $std = null; 2650 2690 2651 $query = "SELECT * FROM {$wpdb->prefix}oer_standard_notation WHERE standard_notation = '%s'";2691 $query = "SELECT * FROM {$wpdb->prefix}oer_standard_notation WHERE standard_notation = %s"; 2652 2692 2653 2693 $substandards = $wpdb->get_results($wpdb->prepare($query, $notation)); … … 2668 2708 $std = null; 2669 2709 2670 $query = "SELECT * FROM {$wpdb->prefix}oer_standard_notation WHERE standard_notation = '%s'";2710 $query = "SELECT * FROM {$wpdb->prefix}oer_standard_notation WHERE standard_notation = %s"; 2671 2711 2672 2712 $standard_notation = $wpdb->get_results($wpdb->prepare($query, $notation)); … … 2697 2737 $std = null; 2698 2738 2699 $query = "SELECT * FROM {$wpdb->prefix}oer_standard_notation WHERE standard_notation = '%s'";2739 $query = "SELECT * FROM {$wpdb->prefix}oer_standard_notation WHERE standard_notation = %s"; 2700 2740 2701 2741 $standard_notation = $wpdb->get_results($wpdb->prepare($query, $notation)); … … 2759 2799 $notation = "standard_notation-".$notation_id; 2760 2800 2761 $query = "SELECT * FROM {$wpdb->prefix}oer_standard_notation WHERE parent_id = '%s'";2801 $query = "SELECT * FROM {$wpdb->prefix}oer_standard_notation WHERE parent_id = %s"; 2762 2802 2763 2803 $standard_notations = $wpdb->get_results($wpdb->prepare($query, $notation)); … … 2858 2898 $parent = explode("-",$parent_id); 2859 2899 if ($parent[0]=="sub_standards") { 2860 $query = "SELECT * FROM {$wpdb->prefix}oer_sub_standards WHERE id = '%s'";2900 $query = "SELECT * FROM {$wpdb->prefix}oer_sub_standards WHERE id = %s"; 2861 2901 $substandards = $wpdb->get_results($wpdb->prepare($query, $parent[1])); 2862 2902 … … 2865 2905 } 2866 2906 } else { 2867 $query = "SELECT * FROM {$wpdb->prefix}oer_core_standards WHERE id = '%s'";2907 $query = "SELECT * FROM {$wpdb->prefix}oer_core_standards WHERE id = %s"; 2868 2908 $standards = $wpdb->get_results($wpdb->prepare($query, $parent[1])); 2869 2909 foreach($standards as $std){ -
wp-oer/tags/0.9.1/open-educational-resources.php
r2742932 r2743703 4 4 Plugin URI: https://www.wp-oer.com 5 5 Description: Open Educational Resource management and curation, metadata publishing, and alignment to Common Core State Standards. 6 Version: 0.9. 06 Version: 0.9.1 7 7 Requires at least: 4.4 8 8 Requires PHP: 7.0 … … 39 39 define( 'OER_PLUGIN_NAME', 'WP OER Plugin' ); 40 40 define( 'OER_ADMIN_PLUGIN_NAME', 'WP OER Plugin'); 41 define( 'OER_VERSION', '0.9. 0' );41 define( 'OER_VERSION', '0.9.1' ); 42 42 define( 'OER_SITE_PATH', ABSPATH ); 43 43 … … 2156 2156 2157 2157 //Search in title 2158 $search .= $wpdb->prepare("($wpdb->posts.post_title LIKE '%s')", $term);2158 $search .= $wpdb->prepare("($wpdb->posts.post_title LIKE %s)", $term); 2159 2159 $OR = ' OR '; 2160 2160 2161 2161 //Search in content 2162 2162 $search .= $OR; 2163 $search .= $wpdb->prepare("($wpdb->posts.post_content LIKE '%s')", $term);2163 $search .= $wpdb->prepare("($wpdb->posts.post_content LIKE %s)", $term); 2164 2164 $OR = ' OR '; 2165 2165 … … 2190 2190 foreach ($meta_keys as $key_slug) { 2191 2191 $search .= $OR; 2192 $search .= $wpdb->prepare("$meta_key_OR (pm.meta_key = '%s' AND pm.meta_value LIKE '%s')", $key_slug, $term);2192 $search .= $wpdb->prepare("$meta_key_OR (pm.meta_key = %s AND pm.meta_value LIKE %s)", $key_slug, $term); 2193 2193 $OR = ''; 2194 2194 $meta_key_OR = ' OR '; … … 2202 2202 foreach($taxonomies as $tax) { 2203 2203 $search .= $OR; 2204 $search .= $wpdb->prepare("$tax_OR (tt.taxonomy = '%s' AND t.name LIKE '%s')", $tax, $term);2204 $search .= $wpdb->prepare("$tax_OR (tt.taxonomy = %s AND t.name LIKE %s)", $tax, $term); 2205 2205 $OR = ''; 2206 2206 $tax_OR = ' OR '; -
wp-oer/tags/0.9.1/readme.txt
r2742932 r2743703 5 5 Tested up to: 6.0 6 6 Requires PHP: 7.0 7 Stable tag: 0.9. 07 Stable tag: 0.9.1 8 8 License: GPLv3 9 9 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 42 42 43 43 == Changelog == 44 = 0.9.1 = 45 * Replaced move_uploaded_file with wp_handle_upload function when importing subject areas and resources 46 * Removed quote around string placeholders used in $wpdb->prepare statements 47 44 48 = 0.9.0 = 45 * Implement further sanitizing of input and escaping of displayed data49 * Implemented further sanitizing of input and escaping of displayed data 46 50 47 51 = 0.8.9 = -
wp-oer/trunk/includes/oer-functions.php
r2742932 r2743703 1046 1046 $cnt = 0; 1047 1047 try{ 1048 // Register our path override. 1049 add_filter( 'upload_dir', 'oer_override_upload_dir' ); 1050 $upload_overrides = array( 1051 'test_form' => false, 1052 'unique_filename_callback' => 'oer_override_filename'); 1053 1048 1054 if ($default==true) { 1049 1055 //default resource filename … … 1066 1072 mkdir(OER_PATH."upload",0777); 1067 1073 } 1074 $_file = wp_handle_upload($_FILES["resource_import"], $upload_overrides); 1068 1075 "Upload: " . sanitize_file_name($_FILES["resource_import"]["name"]) . "<br>"; 1069 1076 "Type: " . sanitize_text_field($_FILES["resource_import"]["type"]) . "<br>"; 1070 1077 "Size: " . sanitize_text_field(($_FILES["resource_import"]["size"] / 1024)) . " kB<br>"; 1071 "stored in:" .move_uploaded_file($_FILES["resource_import"]["tmp_name"],OER_PATH."upload/".$filename) ; 1072 } 1073 $excl_obj->read(OER_PATH."upload/".$filename); 1078 "stored in:" . $_file['file']; 1079 } 1080 1081 $excl_obj->read($_file['file']); 1074 1082 } 1075 1083 } 1084 // Set upload dir to normal 1085 remove_filter( 'upload_dir', 'oer_override_upload_dir' ); 1076 1086 1077 1087 $fnldata = $excl_obj->sheets[0]; … … 1718 1728 } 1719 1729 1730 // Temporarily override upload dir of wp_handle_upload 1731 function oer_override_upload_dir( $dir ){ 1732 return array( 1733 'path' => OER_PATH."upload", 1734 'url' => OER_PATH."upload", 1735 'subdir' => '/upload', 1736 ) + $dir; 1737 } 1738 1739 // Override filename for wp_handle_upload 1740 function oer_override_filename($dir, $name, $ext){ 1741 $time = time(); 1742 $date = date($time); 1743 $file = pathinfo($name); 1744 $new_filename = $file['filename'] . "-" . $date . $ext; 1745 return $new_filename; 1746 } 1747 1720 1748 //Import Subject Areas 1721 1749 function oer_importSubjectAreas($default=false) { … … 1739 1767 1740 1768 global $wpdb; 1769 1770 // Register our path override. 1771 add_filter( 'upload_dir', 'oer_override_upload_dir' ); 1772 $upload_overrides = array( 1773 'test_form' => false, 1774 'unique_filename_callback' => 'oer_override_filename'); 1741 1775 1742 1776 try { … … 1758 1792 { 1759 1793 //Upload File 1760 "Upload: " . sanitize_file_name($_FILES["bulk_import"]["name"]) . "<br>"; 1794 $_file = wp_handle_upload($_FILES["bulk_import"], $upload_overrides); 1795 "Upload: " . sanitize_file_name($_FILES["bulk_import"]["name"]) . "<br>"; 1761 1796 "Type: " . sanitize_text_field($_FILES["bulk_import"]["type"]) . "<br>"; 1762 1797 "Size: " . sanitize_text_field(($_FILES["bulk_import"]["size"] / 1024)) . " kB<br>"; 1763 "stored in:" . move_uploaded_file($_FILES["bulk_import"]["tmp_name"],OER_PATH."upload/".$filename) ;1798 "stored in:" . esc_url_raw($_file['file']) ; 1764 1799 } 1765 1800 1766 1801 //Read Excel Data 1767 $excl_obj->read(OER_PATH."upload/".$filename); 1802 //$excl_obj->read(OER_PATH."upload/".$filename); 1803 $excl_obj->read($_file['file']); 1768 1804 } 1769 1805 } 1806 // Set upload dir to normal 1807 remove_filter( 'upload_dir', 'oer_override_upload_dir' ); 1770 1808 1771 1809 $fnldata = $excl_obj->sheets; … … 1852 1890 return $response; 1853 1891 } 1892 1893 1854 1894 1855 1895 //Import Default Grade Levels … … 2613 2653 $substandards = array(); 2614 2654 2615 $query = "SELECT * FROM {$wpdb->prefix}oer_sub_standards where parent_id ='%s'";2655 $query = "SELECT * FROM {$wpdb->prefix}oer_sub_standards where parent_id = %s"; 2616 2656 2617 2657 $substandards = $wpdb->get_results($wpdb->prepare($query, $std_id)); … … 2630 2670 $notations = array(); 2631 2671 2632 $query = "SELECT * FROM {$wpdb->prefix}oer_standard_notation where parent_id ='%s'";2672 $query = "SELECT * FROM {$wpdb->prefix}oer_standard_notation where parent_id = %s"; 2633 2673 2634 2674 $result = $wpdb->get_results($wpdb->prepare($query, $std_id)); … … 2649 2689 $std = null; 2650 2690 2651 $query = "SELECT * FROM {$wpdb->prefix}oer_standard_notation WHERE standard_notation = '%s'";2691 $query = "SELECT * FROM {$wpdb->prefix}oer_standard_notation WHERE standard_notation = %s"; 2652 2692 2653 2693 $substandards = $wpdb->get_results($wpdb->prepare($query, $notation)); … … 2668 2708 $std = null; 2669 2709 2670 $query = "SELECT * FROM {$wpdb->prefix}oer_standard_notation WHERE standard_notation = '%s'";2710 $query = "SELECT * FROM {$wpdb->prefix}oer_standard_notation WHERE standard_notation = %s"; 2671 2711 2672 2712 $standard_notation = $wpdb->get_results($wpdb->prepare($query, $notation)); … … 2697 2737 $std = null; 2698 2738 2699 $query = "SELECT * FROM {$wpdb->prefix}oer_standard_notation WHERE standard_notation = '%s'";2739 $query = "SELECT * FROM {$wpdb->prefix}oer_standard_notation WHERE standard_notation = %s"; 2700 2740 2701 2741 $standard_notation = $wpdb->get_results($wpdb->prepare($query, $notation)); … … 2759 2799 $notation = "standard_notation-".$notation_id; 2760 2800 2761 $query = "SELECT * FROM {$wpdb->prefix}oer_standard_notation WHERE parent_id = '%s'";2801 $query = "SELECT * FROM {$wpdb->prefix}oer_standard_notation WHERE parent_id = %s"; 2762 2802 2763 2803 $standard_notations = $wpdb->get_results($wpdb->prepare($query, $notation)); … … 2858 2898 $parent = explode("-",$parent_id); 2859 2899 if ($parent[0]=="sub_standards") { 2860 $query = "SELECT * FROM {$wpdb->prefix}oer_sub_standards WHERE id = '%s'";2900 $query = "SELECT * FROM {$wpdb->prefix}oer_sub_standards WHERE id = %s"; 2861 2901 $substandards = $wpdb->get_results($wpdb->prepare($query, $parent[1])); 2862 2902 … … 2865 2905 } 2866 2906 } else { 2867 $query = "SELECT * FROM {$wpdb->prefix}oer_core_standards WHERE id = '%s'";2907 $query = "SELECT * FROM {$wpdb->prefix}oer_core_standards WHERE id = %s"; 2868 2908 $standards = $wpdb->get_results($wpdb->prepare($query, $parent[1])); 2869 2909 foreach($standards as $std){ -
wp-oer/trunk/open-educational-resources.php
r2742932 r2743703 4 4 Plugin URI: https://www.wp-oer.com 5 5 Description: Open Educational Resource management and curation, metadata publishing, and alignment to Common Core State Standards. 6 Version: 0.9. 06 Version: 0.9.1 7 7 Requires at least: 4.4 8 8 Requires PHP: 7.0 … … 39 39 define( 'OER_PLUGIN_NAME', 'WP OER Plugin' ); 40 40 define( 'OER_ADMIN_PLUGIN_NAME', 'WP OER Plugin'); 41 define( 'OER_VERSION', '0.9. 0' );41 define( 'OER_VERSION', '0.9.1' ); 42 42 define( 'OER_SITE_PATH', ABSPATH ); 43 43 … … 2156 2156 2157 2157 //Search in title 2158 $search .= $wpdb->prepare("($wpdb->posts.post_title LIKE '%s')", $term);2158 $search .= $wpdb->prepare("($wpdb->posts.post_title LIKE %s)", $term); 2159 2159 $OR = ' OR '; 2160 2160 2161 2161 //Search in content 2162 2162 $search .= $OR; 2163 $search .= $wpdb->prepare("($wpdb->posts.post_content LIKE '%s')", $term);2163 $search .= $wpdb->prepare("($wpdb->posts.post_content LIKE %s)", $term); 2164 2164 $OR = ' OR '; 2165 2165 … … 2190 2190 foreach ($meta_keys as $key_slug) { 2191 2191 $search .= $OR; 2192 $search .= $wpdb->prepare("$meta_key_OR (pm.meta_key = '%s' AND pm.meta_value LIKE '%s')", $key_slug, $term);2192 $search .= $wpdb->prepare("$meta_key_OR (pm.meta_key = %s AND pm.meta_value LIKE %s)", $key_slug, $term); 2193 2193 $OR = ''; 2194 2194 $meta_key_OR = ' OR '; … … 2202 2202 foreach($taxonomies as $tax) { 2203 2203 $search .= $OR; 2204 $search .= $wpdb->prepare("$tax_OR (tt.taxonomy = '%s' AND t.name LIKE '%s')", $tax, $term);2204 $search .= $wpdb->prepare("$tax_OR (tt.taxonomy = %s AND t.name LIKE %s)", $tax, $term); 2205 2205 $OR = ''; 2206 2206 $tax_OR = ' OR '; -
wp-oer/trunk/readme.txt
r2742932 r2743703 5 5 Tested up to: 6.0 6 6 Requires PHP: 7.0 7 Stable tag: 0.9. 07 Stable tag: 0.9.1 8 8 License: GPLv3 9 9 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 42 42 43 43 == Changelog == 44 = 0.9.1 = 45 * Replaced move_uploaded_file with wp_handle_upload function when importing subject areas and resources 46 * Removed quote around string placeholders used in $wpdb->prepare statements 47 44 48 = 0.9.0 = 45 * Implement further sanitizing of input and escaping of displayed data49 * Implemented further sanitizing of input and escaping of displayed data 46 50 47 51 = 0.8.9 =
Note: See TracChangeset
for help on using the changeset viewer.