[PHP-DEV] retrieving information about state of a function

Ask a Question related to PHP Development, Design and Development.

  1. #1

    Default [PHP-DEV] retrieving information about state of a function

    Hi,

    I recognized there isn't any built-in function which
    tells the disabled/enabled state of some function.
    I think of something like:

    if (function_enabled("shell_exec")) {
    $info = shell_exec("dig myname.com");
    }

    telling if shell_exec is disabled by php.ini setting
    or not.

    I already implemented a check which uses an ini_get() to
    retrieve the list of disabled functions, but I think it
    would be more smooth having a function provided by PHP
    for that purpose, because there are functions for all the
    other kinds of checks: included files, declared classes,
    defined constants/variables, defined functions, etc.

    Why not having a function which gives information about
    disabled/enabled state of a function?

    I think if the function was provided by PHP makes it
    faster. -Think of having to explode() and in_array() check
    for the function. The PHP engine could simply have the
    list of disabled functions to hand a true/false directly
    from C code. Which seems to be the more consequent and
    ideal solution.


    --
    Dennis Sterzenbach
    [url]www.darknoise.de[/url]

    --
    PHP Internals - PHP Runtime Development Mailing List
    To unsubscribe, visit: [url]http://www.php.net/unsub.php[/url]

    Dennis Sterzenbach Guest

  2. Similar Questions and Discussions

    1. Retrieving information from website
      Hi I have a very basic question regd retrieving information from website using a scripting language: Basically I am working on the development...
    2. cfquery errors on Package or function LIST is in an invalid state
      I am trying to understand an error I got from my cfquery I created a function using TOAD like: create or replace function list ( field1 number...
    3. more information for SRF function
      Hello, this is questions for hackers. Is possible put SRF functions more informations about context of calling SRF function? Not now. I know, but...
    4. How can I use session state information in a serveruser control
      Hi, once a user has logged in I want to use some variable in the other custom server controls I've developed. In the page, where the controls are...
    5. Setting a default state for Multi-State buttons
      I'm using the multi-state button behavior and would like to have one button set ON as the default when the app first runs. Is it possible to set the...
  3. #2

    Default Re: [PHP-DEV] retrieving information about state of a function

    On Wed, 1 Oct 2003, Dennis Sterzenbach wrote:
    > Hi,
    >
    > I recognized there isn't any built-in function which
    > tells the disabled/enabled state of some function.
    > I think of something like:
    >
    > if (function_enabled("shell_exec")) {
    > $info = shell_exec("dig myname.com");
    > }
    >
    > telling if shell_exec is disabled by php.ini setting
    > or not.
    You can either use function_exists() to check if a function is
    available, or use "ini_get('disabled_functions')".

    Derick

    --
    "Interpreting what the GPL actually means is a job best left to those
    that read the future by examining animal entrails."
    -------------------------------------------------------------------------
    Derick Rethans [url]http://derickrethans.nl/[/url]
    International PHP Magazine [url]http://php-mag.net/[/url]
    -------------------------------------------------------------------------

    --
    PHP Internals - PHP Runtime Development Mailing List
    To unsubscribe, visit: [url]http://www.php.net/unsub.php[/url]

    Derick Rethans Guest

  4. #3

    Default RE: [PHP-DEV] retrieving information about state of a function

    >
    > You can either use function_exists() to check if a function is
    > available, or use "ini_get('disabled_functions')".
    >
    > Derick
    >
    function_exists() NEVER informs about the function being
    disabled or not it does inform about (I cite the manual here:)
    "if the given function has been defined".

    So it does NOT tell me anything about state.

    If you had read my post, you knew I already do like you telling
    me, but do not agree with this solution, as it is better
    in performance etc. (see my post) to let PHP do so.
    Also it isn't consequent to have info about existance of a func
    but not about its disabled/enabled state.

    Regards
    Dennis

    --
    PHP Internals - PHP Runtime Development Mailing List
    To unsubscribe, visit: [url]http://www.php.net/unsub.php[/url]

    Dennis Sterzenbach Guest

  5. #4

    Default RE: [PHP-DEV] retrieving information about state of a function

    On Wed, 1 Oct 2003, Dennis Sterzenbach wrote:
    > >
    > > You can either use function_exists() to check if a function is
    > > available, or use "ini_get('disabled_functions')".
    > >
    > > Derick
    > >
    > function_exists() NEVER informs about the function being
    > disabled or not it does inform about (I cite the manual here:)
    > "if the given function has been defined".
    >
    > So it does NOT tell me anything about state.
    Of course... why do you NEED to know if it's not available or
    disabled... the result is the same: you can not use the function.
    > If you had read my post, you knew I already do like you telling
    > me, but do not agree with this solution, as it is better
    > in performance etc. (see my post) to let PHP do so.
    I did read it, I just don't see any point why it is useful.

    Derick

    --
    "Interpreting what the GPL actually means is a job best left to those
    that read the future by examining animal entrails."
    -------------------------------------------------------------------------
    Derick Rethans [url]http://derickrethans.nl/[/url]
    International PHP Magazine [url]http://php-mag.net/[/url]
    -------------------------------------------------------------------------

    --
    PHP Internals - PHP Runtime Development Mailing List
    To unsubscribe, visit: [url]http://www.php.net/unsub.php[/url]

    Derick Rethans Guest

  6. #5

    Default RE: [PHP-DEV] retrieving information about state of a function

    > Of course... why do you NEED to know if it's not available or
    > disabled... the result is the same: you can not use the function.
    >
    Sure.
    But still it is a difference if my code is stable or not. Using an
    own implementation telling about the disabled state makes it stable.
    Also code should be performant. It isn't when reading a list of
    comma seperated function names to a string, afterwards checking if
    strpos() !== false.
    I bet ZendEngine knows about all disabled functions, as it should to
    block the usage. Also I bet it doesn't read the list each time a
    function gets called, neither per request to some script.

    So the list is persistant, access per C code.
    And the performance and safety is layed down to PHP.
    IMHO that's more performant, more secure and even more professional.
    > > If you had read my post, you knew I already do like you telling
    > > me, but do not agree with this solution, as it is better
    > > in performance etc. (see my post) to let PHP do so.
    >
    > I did read it, I just don't see any point why it is useful.
    Sorry for the tone, didn't want to be rough.

    I hope you agree with my statement, now.

    Regards
    Dennis

    --
    PHP Internals - PHP Runtime Development Mailing List
    To unsubscribe, visit: [url]http://www.php.net/unsub.php[/url]

    Dennis Sterzenbach Guest

  7. #6

    Default RE: [PHP-DEV] retrieving information about state of a function

    Oh and what about having disabled the ini_get/ini_set methods:

    <?php
    print ini_get('disable_functions');
    ?>
    Warning: ini_get,ini_set() has been disabled for security reasons


    That's making the problem quite enormous.



    Dennis




    --
    PHP Internals - PHP Runtime Development Mailing List
    To unsubscribe, visit: [url]http://www.php.net/unsub.php[/url]

    Dennis Sterzenbach Guest

  8. #7

    Default Re: [PHP-DEV] retrieving information about state of a function

    Hi,
    > Oh and what about having disabled the ini_get/ini_set methods:
    > ...
    > print ini_get('disable_functions');
    > ...
    > Warning: ini_get,ini_set() has been disabled for security reasons
    This won't work in PHP 5.0 because it comes with print/echo disabled
    by default for security reasons.

    This will help getting rid of XSS vulnerabilities and unwanted
    errormessages.

    Just for your information.

    Stefan

    --
    PHP Internals - PHP Runtime Development Mailing List
    To unsubscribe, visit: [url]http://www.php.net/unsub.php[/url]

    Guest

  9. #8

    Default Re: [PHP-DEV] retrieving information about state of a function

    On Wed, 1 Oct 2003 [email]se@nopiracy.de[/email] wrote:
    > > Oh and what about having disabled the ini_get/ini_set methods:
    > > ...
    > > print ini_get('disable_functions');
    > > ...
    > > Warning: ini_get,ini_set() has been disabled for security reasons
    >
    > This won't work in PHP 5.0 because it comes with print/echo disabled
    > by default for security reasons.
    >
    > This will help getting rid of XSS vulnerabilities and unwanted
    > errormessages.
    >
    > Just for your information.
    What the hell are you talking about?

    Derick

    --
    "Interpreting what the GPL actually means is a job best left to those
    that read the future by examining animal entrails."
    -------------------------------------------------------------------------
    Derick Rethans [url]http://derickrethans.nl/[/url]
    International PHP Magazine [url]http://php-mag.net/[/url]
    -------------------------------------------------------------------------

    --
    PHP Internals - PHP Runtime Development Mailing List
    To unsubscribe, visit: [url]http://www.php.net/unsub.php[/url]

    Derick Rethans Guest

  10. #9

    Default Re: [PHP-DEV] retrieving information about state of a function

    Hi Derick,
    > What the hell are you talking about?
    I thought it would be obvious that I was ironically criticizing
    the idea of disabling ini_get etc... And that i was just kidding.

    Stefan

    --
    PHP Internals - PHP Runtime Development Mailing List
    To unsubscribe, visit: [url]http://www.php.net/unsub.php[/url]

    Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139