OVERRIDING functions

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Guest's Avatar

    OVERRIDING functions

    I want that every time the built-in 'mysql_query' function is called another user function is also called.
    But i can't call the user function explicitly, I can only call the built-in function.

    Any idea?

    Much thx in advance.


  • Pedro Graca

    #2
    Re: OVERRIDING functions

    <someone@somedo main.com.invali d> wrote:[color=blue]
    > I want that every time the built-in 'mysql_query' function is called another user function is also called.
    > But i can't call the user function explicitly, I can only call the built-in function.
    >
    > Any idea?[/color]

    You mean apart from changing the PHP source and recompiling?
    No, no idea.
    --
    --= my mail box only accepts =--
    --= Content-Type: text/plain =--
    --= Size below 10001 bytes =--

    Comment

    • paul brown

      #3
      Re: OVERRIDING functions

      Pedro Graca wrote:
      [color=blue]
      > <someone@somedo main.com.invali d> wrote:
      >[color=green]
      >>I want that every time the built-in 'mysql_query' function is called another user function is also called.
      >>But i can't call the user function explicitly, I can only call the built-in function.
      >>
      >>Any idea?[/color]
      >
      >
      > You mean apart from changing the PHP source and recompiling?
      > No, no idea.[/color]

      Do the two functions have the same name?

      Comment

      • Pedro Graca

        #4
        Re: OVERRIDING functions

        paul brown wrote:[color=blue]
        > Pedro Graca wrote:[color=green]
        >> <someone@somedo main.com.invali d> wrote:[color=darkred]
        >>>I want that every time the built-in 'mysql_query' function is called another user function is also called.
        >>>But i can't call the user function explicitly, I can only call the built-in function.
        >>>
        >>>Any idea?[/color][/color][/color]
        [color=blue][color=green]
        >> You mean apart from changing the PHP source and recompiling?
        >> No, no idea.[/color][/color]
        [color=blue]
        > Do the two functions have the same name?[/color]

        What two functions?


        Get the PHP source: http://www.php.net/downloads.php

        Edit "php-src/ext/mysql/php_mysql.c".
        Compile.
        Voila!
        --
        --= my mail box only accepts =--
        --= Content-Type: text/plain =--
        --= Size below 10001 bytes =--

        Comment

        • Cecile Muller

          #5
          Re: OVERRIDING functions

          > What two functions?

          I'm guessing he's referring to both the built-in function and the user one.

          Comment

          • Chung Leong

            #6
            Re: OVERRIDING functions

            This is kinda clunky, but what you can do is dynamically rewrite the code,
            replacing calls to mysql_query with mysql_query_use r.

            Add this snippet to the beginning of your code:

            if(!$eval) {
            function mysql_query_use r() {
            $args = func_get_args() ;
            print_r($args);
            call_user_func_ array('mysql_qu ery', $args);
            }

            $eval = true;
            $code = file_get_conten ts($_SERVER['SCRIPT_FILENAM E']);
            $code = preg_replace('/(?<=\\s)mysql_q uery\\s*\\(/', 'mysql_query_cu stom(',
            $code);
            eval("?>$code") ;
            exit();
            }

            This won't work, of course, if the call to mysql_query is buried in an
            included file.

            Uzytkownik <someone@somedo main.com.invali d> napisal w wiadomosci
            news:btn0mk$kqh $1@nsnmrro2-gest.nuria.tele fonica-data.net...[color=blue]
            > I want that every time the built-in 'mysql_query' function is called[/color]
            another user function is also called.[color=blue]
            > But i can't call the user function explicitly, I can only call the[/color]
            built-in function.[color=blue]
            >
            > Any idea?
            >
            > Much thx in advance.
            >
            >[/color]


            Comment

            Working...