1

I trying to use function ioncube_license_properties() to get encoded property at my project. But I have a trouble - function return false at class method and return actual value at procedure file.

I have next code. Class:

class User {
    /**
     * Check is can login with new user.
     * @return bool
     */
    public static function validateLicense()
    {
        if (function_exists('ioncube_license_properties')) {
            $count = ioncube_license_properties()['allowedUserCount']['value']; // ioncube_license_properties() returns false there
            if ($count === 10) {
                //info($message . 'User can login.');
            } else {
                //warning($message . 'Access denied for.');
            }
            return $isCanLogin;
        } else {
            //warning('Can\'t find Ioncube function `ioncube_license_properties()`.');
            return true;
        }
    }
}

simple php file (it's a view file on MVC model):

if(function_exists('ioncube_license_properties')) {
    var_dump(['validateLicense' => User::validateLicense()]); // false always
    var_dump(['$allowedUserCount' => $allowedUserCount = ioncube_license_properties()['allowedUserCount']['value']]); // returns actual value int(10)
}

Why function returns incorrect value at the class method and how to fix this?

Project use Yii2.

Faysal Ahmed
  • 7,501
  • 5
  • 28
  • 50
Oleg
  • 65
  • 9
  • Your code is poor as it's blindly assuming that the return value of ioncube_license_properties() is an array. What if it isn't? Check the user guide. Can it be anything else? – Nick Mar 20 '18 at 01:34
  • 1
    @Nick, I find what was wrong. I encode files with license file, but at class file didn't set it. Guide says, `ioncube_license_properties()` return `false` if file encoded without license file. I fool – Oleg Mar 20 '18 at 11:37
  • Great, glad that you solved it. License files are encrypted, and as well as the passphrase you can set, there is other information used for the key to prevent even the same passphrase used by someone else from working. So files need to be encoded to hold the relevant license file metadata. – Nick Mar 21 '18 at 14:58

0 Answers0