Download & Extend

admin settings can't be accessed if php's exec() is disabled

Project:Taxonomy VTN
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active

Issue Summary

Hi,

could it be possible to have a patch for users, who are not allowed to use exec()? Now admin area shows only a white screen if php's exec() is disabled. Error is "warning: exec() has been disabled for security reasons in" ... "/sites/all/modules/taxonomy_vtn/taxonomy_vtn.module on line 222."

To have access to admin area, I've simply uncommented the line exec('locale -a', $ar); and then set $ar empty in taxonomy_vtn.module. But then a locale can't be selected. Thank you:)

Regards,
Juhani

Comments

#1

Status:needs work» active

Could you try to wrap the code around a condition like this:

<?php
 
if (is_function('exec')) {
    ...
  }
?>

That way you can see whether it works and we can still call the function, it just will return an empty list of maybe FALSE.

Thank you.
Alexis

#2

Wrapping it like this

<?php
if (function_exists('exec')) {

 
exec('locale -a', $ar);
  if (!empty(
$ar)) {
    foreach (
$ar as $l) {
     
$locales[$l] = $l;
    }
  }

}
?>

prevents the error and white screen, but gives only an empty list and locale can't be selected. Don't know is it clever to provide just a list of locales without knowing does the server support them or not, or is there some other method to find them out without exec(). Could be useful to have some locales list there in any case.

However it's possible to set a locale directly with sql, for example for finnish in Finland:

UPDATE variable SET value='s:10:"fi_FI.UTF8";' WHERE name='taxonomy_vtn_locale_code';

#3

Okay, I put "our" fix in the code for now, so at least people can use the module. But I agree that a better solution would be a good idea.

Reading this page:

http://us2.php.net/manual/en/function.setlocale.php

It seems that the solution used by the previous author of Taxonomy VTN is from PHP.net.

Now, there is a Locale class in PHP and that could be a better bet.

http://us2.php.net/manual/en/class.locale.php

Another solution, I suppose, would be to provide a default list with all the locales, whether or not they are available on the server. Then the user can test and see whether it works.

Thank you.
Alexios

nobody click here