• PHP Help PHP Coding
  • Can somebody get a constant & a variable name or value from a Zend encoded file?!

Hello,

I am coding a license system for my scripts (encoded by Zend encoder) and I have a file with the fallowing content:

<?PHP

$toto = 'moto';

define('FOTO', 'JOTO');

?>

And I am afraid if some tooot can get the variable and/or constant name and/or value!

Is that possible?!

Many thanks...

    I am not really sure if that possible. (nless the guy comes here and looks the code above 😃 )
    Try what happens if I do:

    <?php
    include("encoded_file.php");
    print_r($_GLOBALS);
    ?>

      Oh my god! I got the variable name and value 🙁

      What about the constant?!

      BTW $GLOBALS NOT $_GLOBALS 😉

        <?php
        print_r (get_defined_constants());
        ?>

        // ya it should have been $GLOBALS 🙂

          You saved my life 😃

          I used:

          unset($GLOBALS);

          To unset all the variables and it worked, what can I do to unset the constants?!

          Please don't say its impossible 🙁

          Many thanks...

            Originally posted by Angry Coder
            What can I do to unset the constants?!

            Please don't say its impossible 🙁

            Many thanks...

            You can't. 🙁

            They're constant. Hence the name. Like functions, once you create them they stay around.

            I thought Zend Encoder had a licensing system built in?

              <?php
              $arr = get_defined_constants();
              foreach($arr as $key => $value) {
                   unset($key); 
              }
              ?>

              unset might not work as it is for variables. could not find any equivalent of it that works with constants

                Thanks guys...

                What about creating an object instead of a constant. Is it possible to get its content also?!

                  I thought Zend Encoder had a licensing system built in?

                  Actually yes, but I like to use my own way.

                    Originally posted by Angry Coder
                    Thanks guys...

                    What about creating an object instead of a constant. Is it possible to get its content also?!

                    Objects are stored in variables so, no, not if you unset it when you're done! (There you go; bundle all your licensing code into a single class and keep all the sensitive stuff as properties within that.)

                    I dunno if the optimizer does this, but I wouldn't be surprised: if the sensitive values are declared in the class definition itself ("var $foo='bar';") any instances of "$this->foo" in the class definition may be replaced with 'bar' itself - then not only is there no constant with a value of 'bar' but there's no variable either - either inside or outside the class - because it's been hardwired directly into the code!)

                      Write a Reply...