diff --git a/.github/workflows/phpcs_on_pull_request.yml b/.github/workflows/phpcs_on_pull_request.yml new file mode 100644 index 000000000..1cc01b2a0 --- /dev/null +++ b/.github/workflows/phpcs_on_pull_request.yml @@ -0,0 +1,18 @@ +on: pull_request +name: Inspections +jobs: + runPHPCSInspection: + name: Run PHPCS inspection + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + ref: ${{ github.event.pull_request.head.sha }} + - name: Run PHPCS inspection + uses: rtCamp/action-phpcs-code-review@master + env: + SKIP_FOLDERS: "tests,.github,lib,node_modules,vendor" + GH_BOT_TOKEN: ${{ secrets.RTBOT_TOKEN }} + PHPCS_SNIFFS_EXCLUDE: "WordPress.Files.FileName" + with: + args: WordPress,WordPress-Core,WordPress-Docs \ No newline at end of file diff --git a/Gruntfile.js b/Gruntfile.js index 418ba7ce9..1ed487ea6 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -72,6 +72,26 @@ module.exports = function (grunt) { files: { 'app/assets/js/godam-ajax-refresh.min.js': ['app/assets/js/godam-ajax-refresh.js'] } + }, + rtmedia_admin: { + files: { + 'app/assets/admin/js/rtmedia-admin.min.js': ['app/assets/admin/js/rtmedia-admin.js'] + } + }, + importer: { + files: { + 'app/assets/admin/js/importer.min.js': ['app/assets/admin/js/importer.js'] + } + }, + wp67_media_element: { + files: { + 'app/assets/js/wp67-mediaelement-init.min.js': ['app/assets/js/wp67-mediaelement-init.js'] + } + }, + migration: { + files: { + 'app/assets/admin/js/migration.min.js': ['app/assets/admin/js/migration.js'] + } } } }); diff --git a/README.md b/README.md index c609d50f1..51ae3c669 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Add albums, photo, audio/video upload, privacy, sharing, front-end uploads & mor ![BrowserStack Status](https://www.browserstack.com/automate/badge.svg?badge_key=MU1JamdmRnppK0hhQy9QMU8wdDJ2MUEyb1ZuS0ljVFQvSHZ6anFvNzUxTT0tLXhUNnliTnZGcE5CcW93N0I1eXdnM3c9PQ==--8c124e667dd0c317618efde1bed2b260000916b6) -* **Contributors:** [rtcamp](http://profiles.wordpress.org/rtcamp), [mangeshp](http://profiles.wordpress.org/mangeshp), [sanket.parmar](http://profiles.wordpress.org/sanket.parmar), [pranalipatel](http://profiles.wordpress.org/pranalipatel), [jignesh.nakrani](http://profiles.wordpress.org/jignesh.nakrani), [manishsongirkar36](http://profiles.wordpress.org/manishsongirkar36), [kiranpotphode](http://profiles.wordpress.org/kiranpotphode), [yahil](http://profiles.wordpress.org/yahil), [1naveengiri](http://profiles.wordpress.org/1naveengiri), [bhargavbhandari90](http://profiles.wordpress.org/bhargavbhandari90), [deepak1191](http://profiles.wordpress.org/deepak1191), [rittesh.patel](http://profiles.wordpress.org/rittesh.patel), [sagarjadhav](http://profiles.wordpress.org/sagarjadhav), [pushpak.pop](http://profiles.wordpress.org/pushpak.pop), [faishal](http://profiles.wordpress.org/faishal), [desaiuditd](http://profiles.wordpress.org/desaiuditd), [rahul286](http://profiles.wordpress.org/rahul286), [JoshuaAbenazer](http://profiles.wordpress.org/JoshuaAbenazer), [gagan0123](http://profiles.wordpress.org/gagan0123), [saurabhshukla](http://profiles.wordpress.org/saurabhshukla), [nitun.lanjewar](http://profiles.wordpress.org/nitun.lanjewar), [umesh.nevase](http://profiles.wordpress.org/umesh.nevase), [suhasgirgaonkar](http://profiles.wordpress.org/suhasgirgaonkar), [neerukoul](http://profiles.wordpress.org/neerukoul), [hrishiv90](http://profiles.wordpress.org/hrishiv90), [kanakiyajay](http://profiles.wordpress.org/kanakiyajay), [jarretc](http://profiles.wordpress.org/jarretc), [tobiaskluge](http://profiles.wordpress.org/tobiaskluge), [rafaelfunchal](http://profiles.wordpress.org/rafaelfunchal), [UmeshSingla](http://profiles.wordpress.org/UmeshSingla), [mehulkaklotar](http://profiles.wordpress.org/mehulkaklotar), [tannermirabel](http://profiles.wordpress.org/tannermirabel), [kishores](http://profiles.wordpress.org/kishores), [chandrapatel](http://profiles.wordpress.org/chandrapatel), [rahul3883](http://profiles.wordpress.org/rahul3883/), [nomnom99](http://profiles.wordpress.org/nomnom99), [sayanchakraborty](https://profiles.wordpress.org/sayanchakraborty), [milindmore22](https://profiles.wordpress.org/milindmore22), [thrijith](https://profiles.wordpress.org/thrijith), [abhijitrakas](https://profiles.wordpress.org/abhijitrakas), [sid177](https://profiles.wordpress.org/sid177), [montu3366](https://profiles.wordpress.org/montu3366), [jashwini](https://profiles.wordpress.org/jashwini), [juhise](https://profiles.wordpress.org/juhise), [ravatparmar](https://profiles.wordpress.org/ravatparmar), [dharmin16](https://profiles.wordpress.org/dharmin16), [malavvasita](https://profiles.wordpress.org/malavvasita), [pooja1210](https://profiles.wordpress.org/pooja1210), [krupajnanda](https://profiles.wordpress.org/krupajnanda), [kanumalivad](https://profiles.wordpress.org/kanumalivad), [surajkumarsingh](https://profiles.wordpress.org/surajkumarsingh), [dishitpala](https://profiles.wordpress.org/dishitpala), [shobhit2412](https://profiles.wordpress.org/shobhit2412/), [vkd007](https://profiles.wordpress.org/vkd007/), [vaishu.agola27](https://profiles.wordpress.org/vaishuagola27/), [kapilpaul](https://profiles.wordpress.org/kapilpaul/), [opurockey](https://profiles.wordpress.org/opurockey/), [pavanpatil1](https://profiles.wordpress.org/pavanpatil1/), [pradeep1308](https://profiles.wordpress.org/pradeep1308/), [shardul200](https://profiles.wordpress.org/shardul200/), [ibnulk](https://profiles.wordpress.org/ibnulk/), [sabbir1991](https://profiles.wordpress.org/sabbir1991/), [kamalahmed](https://profiles.wordpress.org/kamalahmed/), [harshbarach](https://profiles.wordpress.org/harshbarach/), [mukulsingh27](https://profiles.wordpress.org/mukulsingh27/), [vishalkakadiya](https://profiles.wordpress.org/vishalkakadiya/), [elifvish](https://profiles.wordpress.org/elifvish/), [krupajnanda](https://profiles.wordpress.org/krupajnanda/), [utsavladani](https://profiles.wordpress.org/utsavladani/),[krishana79](https://profiles.wordpress.org/krishana79/), [rohitmathur7](https://profiles.wordpress.org/rohitmathur7/) +* **Contributors:** [rtcamp](http://profiles.wordpress.org/rtcamp), [mangeshp](http://profiles.wordpress.org/mangeshp), [sanket.parmar](http://profiles.wordpress.org/sanket.parmar), [pranalipatel](http://profiles.wordpress.org/pranalipatel), [jignesh.nakrani](http://profiles.wordpress.org/jignesh.nakrani), [manishsongirkar36](http://profiles.wordpress.org/manishsongirkar36), [kiranpotphode](http://profiles.wordpress.org/kiranpotphode), [yahil](http://profiles.wordpress.org/yahil), [1naveengiri](http://profiles.wordpress.org/1naveengiri), [bhargavbhandari90](http://profiles.wordpress.org/bhargavbhandari90), [deepak1191](http://profiles.wordpress.org/deepak1191), [rittesh.patel](http://profiles.wordpress.org/rittesh.patel), [sagarjadhav](http://profiles.wordpress.org/sagarjadhav), [pushpak.pop](http://profiles.wordpress.org/pushpak.pop), [faishal](http://profiles.wordpress.org/faishal), [desaiuditd](http://profiles.wordpress.org/desaiuditd), [rahul286](http://profiles.wordpress.org/rahul286), [JoshuaAbenazer](http://profiles.wordpress.org/JoshuaAbenazer), [gagan0123](http://profiles.wordpress.org/gagan0123), [saurabhshukla](http://profiles.wordpress.org/saurabhshukla), [nitun.lanjewar](http://profiles.wordpress.org/nitun.lanjewar), [umesh.nevase](http://profiles.wordpress.org/umesh.nevase), [suhasgirgaonkar](http://profiles.wordpress.org/suhasgirgaonkar), [neerukoul](http://profiles.wordpress.org/neerukoul), [hrishiv90](http://profiles.wordpress.org/hrishiv90), [kanakiyajay](http://profiles.wordpress.org/kanakiyajay), [jarretc](http://profiles.wordpress.org/jarretc), [tobiaskluge](http://profiles.wordpress.org/tobiaskluge), [rafaelfunchal](http://profiles.wordpress.org/rafaelfunchal), [UmeshSingla](http://profiles.wordpress.org/UmeshSingla), [mehulkaklotar](http://profiles.wordpress.org/mehulkaklotar), [tannermirabel](http://profiles.wordpress.org/tannermirabel), [kishores](http://profiles.wordpress.org/kishores), [chandrapatel](http://profiles.wordpress.org/chandrapatel), [rahul3883](http://profiles.wordpress.org/rahul3883/), [nomnom99](http://profiles.wordpress.org/nomnom99), [sayanchakraborty](https://profiles.wordpress.org/sayanchakraborty), [milindmore22](https://profiles.wordpress.org/milindmore22), [thrijith](https://profiles.wordpress.org/thrijith), [abhijitrakas](https://profiles.wordpress.org/abhijitrakas), [sid177](https://profiles.wordpress.org/sid177), [montu3366](https://profiles.wordpress.org/montu3366), [jashwini](https://profiles.wordpress.org/jashwini), [juhise](https://profiles.wordpress.org/juhise), [ravatparmar](https://profiles.wordpress.org/ravatparmar), [dharmin16](https://profiles.wordpress.org/dharmin16), [malavvasita](https://profiles.wordpress.org/malavvasita), [pooja1210](https://profiles.wordpress.org/pooja1210), [krupajnanda](https://profiles.wordpress.org/krupajnanda), [kanumalivad](https://profiles.wordpress.org/kanumalivad), [surajkumarsingh](https://profiles.wordpress.org/surajkumarsingh), [dishitpala](https://profiles.wordpress.org/dishitpala), [shobhit2412](https://profiles.wordpress.org/shobhit2412/), [vkd007](https://profiles.wordpress.org/vkd007/), [vaishu.agola27](https://profiles.wordpress.org/vaishuagola27/), [kapilpaul](https://profiles.wordpress.org/kapilpaul/), [opurockey](https://profiles.wordpress.org/opurockey/), [pavanpatil1](https://profiles.wordpress.org/pavanpatil1/), [pradeep1308](https://profiles.wordpress.org/pradeep1308/), [shardul200](https://profiles.wordpress.org/shardul200/), [ibnulk](https://profiles.wordpress.org/ibnulk/), [sabbir1991](https://profiles.wordpress.org/sabbir1991/), [kamalahmed](https://profiles.wordpress.org/kamalahmed/), [harshbarach](https://profiles.wordpress.org/harshbarach/), [mukulsingh27](https://profiles.wordpress.org/mukulsingh27/), [vishalkakadiya](https://profiles.wordpress.org/vishalkakadiya/), [elifvish](https://profiles.wordpress.org/elifvish/), [krupajnanda](https://profiles.wordpress.org/krupajnanda/), [utsavladani](https://profiles.wordpress.org/utsavladani/),[krishana79](https://profiles.wordpress.org/krishana79/), [rohitmathur7](https://profiles.wordpress.org/rohitmathur7/), [kuldipchaudhary](https://profiles.wordpress.org/kuldipchaudhary/), [mchirag2002](https://profiles.wordpress.org/mchirag2002/), [vedantgandhi28](https://profiles.wordpress.org/vedantgandhi28/) * **License:** [GPL v2 or later]( http://www.gnu.org/licenses/gpl-2.0.html) @@ -138,7 +138,7 @@ https://www.youtube.com/watch?v=dJrykKQGDcs 3. Media Types Settings 4. Media Size Settings 5. Privacy Settings -6. Other Setiings +6. Other Settings 7. Export/Import Settings 8. Media View 9. Album View @@ -151,6 +151,15 @@ https://www.youtube.com/watch?v=dJrykKQGDcs ## Changelog ## +### 4.7.4 +* FIXED + * Apply security recommendations and fixes. + * Restrict the media upload by its types based on selected tab in rtMedia gallery. + +* ENHANCEMENT + * Enhances media upload support by adding a broader set of commonly used video and audio formats. + * Replace PHP file system functions with WordPress alternative filesystem function to enhance security. + ### 4.7.3 * FIXED @@ -1984,7 +1993,7 @@ rtMedia includes [full translation support](https://rtmedia.io/docs/translations rtMedia uses the following projects/sources for some functionality * [MediaElement.js](http://mediaelementjs.com/) for html5 audio/video player -* [Maginific Popup](http://dimsemenov.com/plugins/magnific-popup/) for responsive lightbox +* [Magnific Popup](http://dimsemenov.com/plugins/magnific-popup/) for responsive lightbox * [getID3](http://getid3.sourceforge.net/) gets us some ID tags for the media * [Foundation](http://foundation.zurb.com/) for the media grid and layout * [Backbone.js](http://backbonejs.org/) for an MVC architecture for the frontend diff --git a/app/admin/RTMediaAdmin.php b/app/admin/RTMediaAdmin.php index 51aea3a04..a532b7206 100644 --- a/app/admin/RTMediaAdmin.php +++ b/app/admin/RTMediaAdmin.php @@ -48,12 +48,12 @@ class RTMediaAdmin { */ public $rtmedia_feed; - /* + /** * Static property to store the admin pages * * @var array */ - public static $rtmedia_pages = [ + public static $rtmedia_pages = array( 'rtmedia-settings', 'rtmedia-addons', 'rtmedia-pro-addons', @@ -64,7 +64,7 @@ class RTMediaAdmin { 'rtmedia-attributes', 'rtmedia-moderate', 'rtmedia-blocked-users', - ]; + ); /** * Constructor - get the plugin hooked in and ready @@ -131,11 +131,9 @@ public function __construct() { if ( isset( $rtmedia_option['general_showAdminMenu'] ) && 1 === intval( $rtmedia_option['general_showAdminMenu'] ) ) { add_action( 'admin_bar_menu', array( $this, 'admin_bar_menu' ), 100, 1 ); } - } else { - if ( is_array( $rtmedia->options ) ) { - if ( 1 === intval( $rtmedia->options['general_showAdminMenu'] ) ) { - add_action( 'admin_bar_menu', array( $this, 'admin_bar_menu' ), 100, 1 ); - } + } elseif ( is_array( $rtmedia->options ) ) { + if ( 1 === intval( $rtmedia->options['general_showAdminMenu'] ) ) { + add_action( 'admin_bar_menu', array( $this, 'admin_bar_menu' ), 100, 1 ); } } @@ -245,6 +243,7 @@ public function rtm_admin_templates() { */ $display = apply_filters( 'rtmedia_disable_media_in_commented_media', false ); if ( $display ) { + // No a security issue, so keeping the style here. ?> - +
+

diff --git a/app/importers/templates/media-size-importer.php b/app/importers/templates/media-size-importer.php index 0afcb01b0..c92840ab5 100644 --- a/app/importers/templates/media-size-importer.php +++ b/app/importers/templates/media-size-importer.php @@ -29,83 +29,13 @@ $temp = $prog->progress( $done, $total ); $prog->progress_ui( $temp, true ); ?> - +
+

diff --git a/app/main/RTMedia.php b/app/main/RTMedia.php index 8a16b3e59..8db7ce959 100755 --- a/app/main/RTMedia.php +++ b/app/main/RTMedia.php @@ -112,9 +112,9 @@ public function __construct() { add_action( 'plugins_loaded', array( $this, 'load_translation' ), 10 ); add_action( 'plugins_loaded', array( $this, 'init' ), 20 ); add_action( 'wp_enqueue_scripts', array( 'RTMediaGalleryShortcode', 'register_scripts' ) ); - add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts_styles' ), 999 ); + add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts_styles' ), 999 ); - // WordPress 6.7 compatibility + // WordPress 6.7 compatibility. add_action( 'wp_enqueue_scripts', array( $this, 'wp67_compatibility_scripts' ), 1 ); add_action( 'admin_enqueue_scripts', array( $this, 'wp67_compatibility_scripts' ), 1 ); @@ -192,7 +192,7 @@ public function fix_parent_id() { global $wpdb; $row = $album_row['result'][0]; if ( isset( $row['media_id'] ) ) { - // phpcs:disable WordPress.DB.PreparedSQL.NotPrepared + // phpcs:disable WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.PreparedSQL.InterpolatedNotPrepared $sql = $wpdb->prepare( "update $wpdb->posts p left join @@ -207,7 +207,8 @@ public function fix_parent_id() { get_current_blog_id(), $row['media_id'], '%/rtMedia/%' - ); + ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.PreparedSQL.InterpolatedNotPrepared + // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Direct query is required for custom table. $wpdb->query( $sql ); } } @@ -221,7 +222,8 @@ public function fix_privacy() { global $wpdb; $model = new RTMediaModel(); $update_sql = "UPDATE {$model->table_name} SET privacy = '80' where privacy = '-1' "; - $wpdb->query( $update_sql ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared + // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Direct query is required for custom table. + $wpdb->query( $update_sql ); } /** @@ -232,15 +234,17 @@ public function fix_group_media_privacy() { // if buddypress is active and groups are enabled. global $wpdb; $table_exist = false; - if ( $wpdb->query( "SHOW TABLES LIKE '{$wpdb->prefix}bp_groups'" ) ) { + // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Direct query is required for custom table. + $bp_groups_exists = $wpdb->query( "SHOW TABLES LIKE '{$wpdb->prefix}bp_groups'" ); + if ( $bp_groups_exists ) { $table_exist = true; } if ( class_exists( 'BuddyPress' ) && $table_exist ) { $model = new RTMediaModel(); $sql_group = " UPDATE $model->table_name m join {$wpdb->prefix}bp_groups bp on m.context_id = bp.id SET m.privacy = 0 where m.context = 'group' and bp.status = 'public' and m.privacy <> 80 "; - $wpdb->query( $sql_group ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared + $wpdb->query( $sql_group ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching $sql_group = " UPDATE $model->table_name m join {$wpdb->prefix}bp_groups bp on m.context_id = bp.id SET m.privacy = 20 where m.context = 'group' and ( bp.status = 'private' OR bp.status = 'hidden' ) and m.privacy <> 80 "; - $wpdb->query( $sql_group ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared + $wpdb->query( $sql_group ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching } } @@ -252,11 +256,11 @@ public function fix_db_collation() { $model = new RTMediaModel(); $interaction_model = new RTMediaInteractionModel(); $update_media_sql = 'ALTER TABLE ' . $model->table_name . ' CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci'; - $wpdb->query( $update_media_sql ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared + $wpdb->query( $update_media_sql ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- No caching required for altering table. $update_media_meta_sql = 'ALTER TABLE ' . $wpdb->base_prefix . $model->meta_table_name . ' CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci'; - $wpdb->query( $update_media_meta_sql ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared + $wpdb->query( $update_media_meta_sql ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- No caching required for altering table. $update_media_interaction_sql = 'ALTER TABLE ' . $interaction_model->table_name . ' CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci'; - $wpdb->query( $update_media_interaction_sql ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared + $wpdb->query( $update_media_interaction_sql ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- No caching required for altering table. } /** @@ -371,6 +375,7 @@ public function add_image_sizes() { */ public function custom_style_for_image_size() { if ( apply_filters( 'rtmedia_custom_image_style', true ) ) { + // No a security issue, so keeping the style here. ?> ' + . '' // No a security issue, so keeping the style here. . do_shortcode( '[godam_video id="' . $media_id . '"]' ) . ''; } @@ -2188,6 +2198,7 @@ function rtmedia_comment_form() { +