33 * Plugin Name: Check Plugins Vulnerability
44 * Plugin URI: https://haha.nl
55 * Description: Check the installed website plugins for vulnerability use the wordfence vulnerability data feed api.
6- * Version: 1.0.5
6+ * Version: 1.0.6
77 * Author: herbert hoekstra - haha!
88 * Author URI: https://haha.nl
99 * Documentation URI: https://haha.nl/wordpress-plug-in-op-maat/
@@ -100,6 +100,8 @@ function settings() {
100100 // ------------------------
101101 function activate_this_plugin () {
102102
103+ require_once __DIR__ .'/vendor/autoload.php ' ;
104+
103105 //Checking if the MainWP plugin is enabled. This filter will return true if the main plugin is activated.
104106 $ this ->mainwpMainActivated = apply_filters ('mainwp_activated_check ' , $ this ->mainwpMainActivated );
105107
@@ -169,11 +171,16 @@ public function hhdev_get_file_date(){
169171 }
170172
171173 // check version compare
174+ // if A < B -> -1
175+ // if A == B -> 0
176+ // if A > B -> 1
172177 // ----------------------
173- // By default, version_compare() returns -1 if the first version is lower than the second, 0 if they are equal, and 1 if the second is lower.
174- public function hhdev_plugin_needs_update ($ plugin_version , $ data_version ){
178+ public function hhdev_plugin_needs_update ($ plugin_version , $ data_version , $ compare ){
179+
180+ $ result = \Jelix \Version \VersionComparator::compareVersion ($ plugin_version , $ data_version );
175181
176- if ( version_compare ($ plugin_version ,$ data_version ) <= 0 ) return true ;
182+ if ($ compare == '< ' && $ result == -1 ) return true ;
183+ if ($ compare == '<= ' && $ result == 0 ) return true ;
177184
178185 return false ;
179186 }
@@ -202,10 +209,6 @@ public function hhdev_get_version_from_array($array) {
202209 // -----------------------------
203210 public function hhdev_make_adapted_file () {
204211
205- require_once __DIR__ .'/vendor/autoload.php ' ;
206-
207- // get updated last month
208-
209212 // get the current date
210213 date_default_timezone_set (get_option ( 'timezone_string ' ));
211214 $ cur_date = date ('Y-m-d ' );
@@ -228,7 +231,8 @@ public function hhdev_make_adapted_file() {
228231 if ($ plugin ->updated > $ date ) {
229232 // write to new array
230233 // check if type is plugin
231- if ($ plugin ->software [0 ]->type === 'plugin ' && !array_key_exists ($ plugin ->software [0 ]->slug , $ file )) $ file [$ plugin ->software [0 ]->slug ] = array (
234+ if ($ plugin ->software [0 ]->type === 'plugin ' ) $ file [] = array (
235+ 'slug ' => $ plugin ->software [0 ]->slug ,
232236 'title ' => $ plugin ->title ,
233237 'name ' => $ plugin ->software [0 ]->name ,
234238 'affected_versions ' => json_decode (json_encode ($ plugin ->software [0 ]->affected_versions ),true ),
@@ -241,7 +245,7 @@ public function hhdev_make_adapted_file() {
241245
242246 }
243247
244- // print_r($file['litespeed-cache'] );
248+ // print_r($file);
245249
246250 //echo wp_sprintf( '<p>', __('Records saved: %s','hhdev-mwpcpv'), count($file),'</p>');
247251
@@ -252,7 +256,6 @@ public function hhdev_make_adapted_file() {
252256
253257 }
254258
255-
256259 }
257260
258261 global $ MainWPCheckPluginVulnerabilityActivator ;
@@ -358,8 +361,9 @@ public function hhdev_make_adapted_file() {
358361
359362 /*
360363change log:
361- - 1.0.5 fixed missing entries in cleaned data file
362- - 1.0.4 removed gitignore from /vendor/
364+ - 1.0.6 fix: using to_inclusive to adjust version compare, fix: add all vulnerable versions in the clean data file, added: jellix version compare
365+ - 1.0.5 fix: missing entries in cleaned data file
366+ - 1.0.4 removed: gitignore from /vendor/
363367- 1.0.3 changed adapted file to hold only plugin data
364368- 1.0.2 split the file up into 2 files, plugin and dashboard
365369- 1.0.1 initial set up
0 commit comments