Family & Friends | Mittineague Park | Home | Walk Photos | Wildflowers | Scripting | Sitemap | Blog | Contact |
Mittineague.com Home Mittineague
Welcome to the Mittineague Forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

some questions reagrding detection of plugins

 
Posting is closed between 03:00:00 and 06:00:00 (GMT - 4 Hours)
Post new topic   Reply to topic    Mittineague Forum Index -> WordPress
View previous topic :: View next topic  
Author Message
ovizii
Newcomer Level I
Newcomer Level I



Joined: 06 Nov 2008
Posts: 12

PostPosted: December 08 2008, 10:02    Post subject: some questions reagrding detection of plugins Reply with quote

hello.
I am not sure if this is a problem on your plugin side or on the side of the other plugins BUT:

I check for orphaned plugins and options are found, where I know for sure, I use currently the plugin.

i.e.
ak404_mailto
ak404_mail_enabled
ak404_rss_limit

are detected, but I am using this plugin: http://alexking.org/projects/wordpress

featurific_image_cache_write_access
featurific_root_write_access

are detected but I use http://featurific.com/ffw

I could go on with this list. Is tehre a solution? is something wrong with these plugins?
Back to top
View user's profile Send private message
Mittineague
Site Admin
Site Admin



Joined: 04 Jul 2006
Posts: 68
Location: West Springfield, Massachusetts

PostPosted: December 09 2008, 01:29    Post subject: Re: some questions reagrding detection of plugins Reply with quote

The Clean Options plugin uses a recursive directory search looking for .php files.

Possible causes of this problem could be
1: Instead of installing the cleanoptions.php file directly under the plugins folder, the folder was installed, thereby putting the file 1 level deeper.
2: Inadequate folder/file permissions.
3: The other plugin file does not have a .php extension.
4: The plugin's call to the options table doesn't meet the regex
Code:
#get_(?:option|settings)[ ]?\([ ]?[\'\"]([-\w]+)[\'\"][ ]?\)#


1: I don't suspect this is the case. This would mean that core WordPress files weren't searched, but the plugins folder would still be included in the search.
2: Not likely. The Clean Options plugin should show a warning if a folder or file can't be opened.
3. If there's anything possible other than a .php extension I don't know what it is.
4. I suspect this is the reason. I'm downloading the 404-notifier and featurific-for-wordpress plugins now and will take a look at them as soon as I get the chance and post back.

As stated on the Clean Options preview page
Quote:
Please review this information very carefully and only remove Options that you know for certain have been orphaned or deprecated.
It is strongly suggested that you BACKUP your database before removing any options.

but one can never be too careful and it would be naive to think everyone follows this advice. Thanks for bringing the matter to my attention.
Back to top
View user's profile Send private message
ovizii
Newcomer Level I
Newcomer Level I



Joined: 06 Nov 2008
Posts: 12

PostPosted: December 09 2008, 02:50    Post subject: Re: some questions reagrding detection of plugins Reply with quote

ahhh.

it was #1

I, as many others, have finally switched to using autoamated plugin isntallers, just giving the link to your zip file Sad so my plugin file was 1 fodler deeper...

But could you maybe change that in the next version so it starts from the current plugins location? would be a lot easier and make thigns safer, than hard coding the location to the plugins folder AND some people like to keep their plugins folder clean Wink

BUT still the same examples I gave before, show up.... it might be the plugins then ;-( sorry
Back to top
View user's profile Send private message
Mittineague
Site Admin
Site Admin



Joined: 04 Jul 2006
Posts: 68
Location: West Springfield, Massachusetts

PostPosted: December 09 2008, 17:26    Post subject: regex matches - directory search Reply with quote

As I noted before, the Clean Options plugin searches PHP files using the regular expression
Code:
#get_(?:option|settings)[ ]?\([ ]?[\'\"]([-\w]+)[\'\"][ ]?\)#

which matches get_option() calls in any of the following syntax:

Variations in use of spaces and quotes:
get_option ( 'opt_name' )
get_option( 'opt_name' )
get_option ('opt_name')
get_option('opt_name')
get_option ( "opt_name" )
get_option( "opt_name" )
get_option ("opt_name")
get_option("opt_name")

Non-symetrical use of spaces (not likely but possible):
get_option ('opt_name' )
get_option ( 'opt_name')
get_option('opt_name' )
get_option( 'opt_name')
get_option ("opt_name" )
get_option ( "opt_name")
get_option("opt_name" )
get_option( "opt_name")

It will also find mismatched quotes, which is not possible, because using a ' and a " is invalid syntax.

If finds "opt_names" where opt_name consists of "word" characters (underscore and alphanumeric characters), or a hyphen. eg. Ab_3Cdvf_Dwaqo-F6j54 would match.

It will similarly find get_settings(). Even though this has been deprecated for a while, WordPress still supports it's use, and many themes and plugins still use it.

The 404-notifier plugin assigns option names to a class array

Code:
      $this->options = array(
         'mailto' => 'email'
         , 'mail_enabled' => 'int'
         , 'rss_limit' => 'int'
      );


and then loops through the array appending the variable to the prefix "ak404_"

Code:
      foreach ($this->options as $option => $type) {
         $this->$option = get_option('ak404_'.$option);
         switch ($type) {
            case 'email':
               $this->$option = $this->$option;
               break;
            case 'int':
               $this->$option = intval($this->$option);
               break;
         }
      }


Because the regex matches a quote, followed by a possible space, followed by a closing parenthesis, the ".$option" between the quote and parenthesis causes the get_option call to not match.

The featurific-for-wordpress plugin has this

Code:
   $screen_assignment_opt_name = 'featurific_screen_assignment';
   $width_opt_name = 'featurific_width';
   $height_opt_name = 'featurific_height';
   $type_opt_name = 'featurific_type';
   $category_filter_opt_name = 'featurific_category_filter';
   $user_specified_posts_opt_name = 'featurific_user_specified_posts';
   $frequency_opt_name = 'featurific_generation_frequency';
   $data_xml_override_opt_name = 'featurific_data_xml_override';
   $template_opt_name = 'featurific_template';
   $num_posts_opt_name = 'featurific_num_posts';
   $popular_days_opt_name = 'featurific_popular_days';
   $auto_excerpt_length_opt_name = 'featurific_auto_excerpt_length';
   $screen_duration_opt_name = 'featurific_screen_duration';

   $screen_assignment_opt_val = get_option($screen_assignment_opt_name);
   $width_opt_val = get_option($width_opt_name);
   $height_opt_val = get_option($height_opt_name);
   $type_opt_val = get_option($type_opt_name);
   $category_filter_val = get_option($category_filter_opt_name);
   $user_specified_posts_opt_val = get_option($user_specified_posts_opt_name);
   $frequency_opt_val = get_option($frequency_opt_name);
   $data_xml_override_opt_val = get_option($data_xml_override_opt_name);
   $template_opt_val = get_option($template_opt_name);
   $num_posts_opt_val = get_option($num_posts_opt_name);
   $popular_days_opt_val = get_option($popular_days_opt_name);
   $auto_excerpt_length_opt_val = get_option($auto_excerpt_length_opt_name);
   $screen_duration_opt_val = get_option($screen_duration_opt_name);


I do not know why the plugin author assigns the option name to a variable and then uses the variable in the get_options call in this block of code. AFAIK, the rest of the code simply uses the option name in quotes. In any case, because the regex is looking for quotes inside the parentheses and does not match the $ character, it doesn't match. As for the "write_access" examples you posted, I found them used in update_option() but not get_option() anywhere, so I don't know what's up with those.

Finding a regular expression to match the syntax of these plugins would not be too difficult. But I do not need to match the prefix.$variable or the $variable, but rather, I need their values to use for comparison to option_names in the wp_options table. . Because of scope limitations, I can't think of a way to have the Clean Options plugin parse out their values. But I will add a regex that matches the "$" character and shows a warning something like "The 404-notifier.php file contains calls to the wp_options table where the option name can not be determined."

And you are correct about the recursive directory search. It would be better to start with something like "blog home" rather than assume the cleanoptions.php file is directly under the plugins folder and going up from that.
Back to top
View user's profile Send private message
ovizii
Newcomer Level I
Newcomer Level I



Joined: 06 Nov 2008
Posts: 12

PostPosted: December 09 2008, 17:45    Post subject: Re: some questions reagrding detection of plugins Reply with quote

wow!
now that was an extensive explanation!
Thanks.
although I am no coder, I udnerstand what you are talking about.

If I can be of any other debugging help, just let me know please Smile
Back to top
View user's profile Send private message
Display posts from previous:   
Posting is closed between 03:00:00 and 06:00:00 (GMT - 4 Hours)
Post new topic   Reply to topic    Mittineague Forum Index -> WordPress All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




P o w e r e d   b y   p h p B B   ©   2 0 0 1 ,   2 0 0 5   p h p B B   G r o u p
Family & Friends | Mittineague Park | Home | Walk Photos | Wildflowers | Scripting | Sitemap | Blog | Contact |