Custom Constants

Top  Previous  Next

custom_constants

 

SourceGuardian let you define custom named constants during encoding process or within an external script license. Constant name/value pairs are stored internally in the encrypted area of the protected script or external

license. They may be used for custom script locking or any other actions if you need to store a custom value in protected script or script license file and then retrieve it from your PHP code.

 

To get a predefined constant value from the PHP code use sg_get_const() function. This function is defined in SourceGuardian loader.

 

Syntax: string sg_get_const( string )

 

       Will return a predefined SourceGuardian constant value or FALSE if

       constant with the specified name is not defined. SourceGuardian

       constants names are *case sensitive*.

 

There are 5 constants predefined for each protected script:

 

sg_get_const("encoder")

returns the name of encoder "SourceGuardian"

sg_get_const("version")

returns the encoder version number

sg_get_const("encode_date")

return UNIX timestamp when the script was encoded

sg_get_const("license_date")

return UNIX timestamp when the script license was created. It's may differ from "encode_date" when external script license is used

sg_get_const("expire_date")

returns script expiration date as UNIX timestamp if it's defined in the script license or internally via script binding options during encoding