SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Guru Angry Coder's Avatar
    Join Date
    May 2002
    Location
    Canada
    Posts
    599
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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 Code:
    <?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...
    Why It Doesn't Work?!

  2. #2
    eschew sesquipedalians silver trophy sweatje's Avatar
    Join Date
    Jun 2003
    Location
    Iowa, USA
    Posts
    3,749
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have never really tried it, but can you do:
    PHP Code:
    include zend_encoded_file.php;

    var_dump(get_defined_constants());
    var_dump(get_defined_vars()); 
    Jason Sweat ZCE - jsweat_php@yahoo.com
    Book: PHP Patterns
    Good Stuff: SimpleTest PHPUnit FireFox ADOdb YUI
    Detestable (adjective): software that isn't testable.

  3. #3
    SitePoint Guru Angry Coder's Avatar
    Join Date
    May 2002
    Location
    Canada
    Posts
    599
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)


    Can I unset a constant?!
    Why It Doesn't Work?!

  4. #4
    SitePoint Wizard silver trophy someonewhois's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    6,364
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No, once you have a define it's stuck. Why not use a variable and unset it? Constants are supposed to stay constant.

  5. #5
    SitePoint Guru Angry Coder's Avatar
    Join Date
    May 2002
    Location
    Canada
    Posts
    599
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)


    I will try that, thank you.

    By the way, anyone know how can I create a protected variable?!
    Why It Doesn't Work?!

  6. #6
    eschew sesquipedalians silver trophy sweatje's Avatar
    Join Date
    Jun 2003
    Location
    Iowa, USA
    Posts
    3,749
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Have you considered encrypting any variable or constant that you want to have persist outside of your code? You could write a function to decrypt your code, have your secret hash as a parameter to the function and always do something like:

    PHP Code:
    function mylib_good_stuff() {
      
    $foo mylib_decrypt(MYLIB_FOO'mylib_secret_key_that_is_alway_a_string_not_a_var_or_define');
      ...

    and so on. I would think this would take you one step further along.
    Jason Sweat ZCE - jsweat_php@yahoo.com
    Book: PHP Patterns
    Good Stuff: SimpleTest PHPUnit FireFox ADOdb YUI
    Detestable (adjective): software that isn't testable.

  7. #7
    SitePoint Guru Angry Coder's Avatar
    Join Date
    May 2002
    Location
    Canada
    Posts
    599
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks but as I know encrypting functions not available at any server. Am I wrong?!
    Why It Doesn't Work?!

  8. #8
    eschew sesquipedalians silver trophy sweatje's Avatar
    Join Date
    Jun 2003
    Location
    Iowa, USA
    Posts
    3,749
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    perhaps you could roll your own (or google for) RC4 class if real encryption is not installed

  9. #9
    SitePoint Wizard silver trophy someonewhois's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    6,364
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just write a simple encrypter (if you aren't able to do extensive encryption in math, then just swap some letters in a special way that only you know or something), and then just write a decrypt function. Basically, write an encrypt function that can change the word to a form that you know only, and then write a decrypt function, have the decrypt function Zend Encoded, then when you go to use it go mysql_connect(decrypt($localhost)... etc. (though I don't think you're using it for mysql_connect, but you get my point). In C, a lot of people don't realize this I think, but all strings you write are open in the binary file. So if you connect to an FTP account or MySQL table from C, you have to do exactly what I described, or your strings will be floating in the middle of the binary.

    Hope this helped.


Bookmarks

Posting Permissions

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