NuSphere Corporation
BUY ONLINE
Support Services
Overview
KB
PHP Manual
CSS2 Manual
HTML Manual
JS Guide
JS Reference
Technical FAQ
PhpDock Manual
Nu-Coder Manual
PhpExpress Manual
PHP Joomla Development
Learn PHP
<Nu-Coder Command Line InterfaceDeploying Encoded PHP files with NuSphere PhpExpress>
Last updated: Tue, 03 Jun 2008

Nu-Coder License Manager

Nu-Coder's license manager helps you manage the distribution of PHP applications by generating license keys that can be required by encoded files to run. Using License Manager you can create trial and demo versions of PHP applications without any code changes. License Manager is typically used on the server where the encoded files are place for download by your customers. For this reason NuSphere supplies License Manager for all major platforms, including *BSD/x86 and x86_64, Linux/x86 and x86_64, Windows x86 and x64, Solaris/x86, x86_64 and Sparc.

Using Nu-Coder's license manager you can create various license models for both trial and commercial distributions:
  • Trial/Evaluation License - provides time expiry
  • Usage Restricted to specific hardware- linked to hardware id
  • Usage Restricted to specific virtual host - linked to Virtual Host Name
  • Usage Restricted to specific Network Segment - linked to ip address network card or MAC address of the network card

How to generate License Manager Licenses using Nu-Coder Command Line Interface

The interface to Nu-Coder's License Manager provides you with multiple options to generate License files for encoded PHP scripts. The similar syntax is used for generation of the License files as it is for encoding of php files, however the name of the executable is different. See how to encode the files to use generated licenses in the section "How to use License Manager generated licenses when encoding of PHP files" of this manual

Syntax

nu-licgen [options]


The following are the options used by Nu-Coder's License Manager

-k <keyword>,
--key <keyword>
generate license with provided keyword. It's recommended to use keywords of 6-16 or more alpha-numeric characters. It's necessary to encode PHP files with the same keyword or license will be ignored.
-d <fname>
--header <fname>
add custom header to the license file
-a <name1>=<value1>,<name2>=<value2>
Or
--attribute <name>=<value>,...
create attribute(s) to be stored in license file. These attributes all are encrypted with the license key. attributes can be read from the license at runtime with pelm_get_attribute() function call.
-x <name>
--expose <name>
make attribute's copy visible in the license
--lid <id> lock the license into server hardware identified by specified host ID(s).(See PhpExpress API on how to get host IDs). If multiple IDs are specified, license will require at least one ID to match server hardware
--lmac <mac> lock license into server hardware identified by specified Ethernet MAC addrress(es). For example --lmac 00-C0-44-11-33-A4,00-C0-44-11-33-A5
--lip <ip> lock the license into server software settings. License will work only for servers accessed with specified IP address(es). Wildcards are acceptable, for example --lip 217.217.217.5,217.217.216.*
--lvhost <vhost> lock the license into server software settings. License will work only for accessed with specified host name(s). Wildcards are acceptable, for example --lvhost *.mydomain.com,mydomain.com
--ldate <mm/dd/yyyy> set license expiration date. Generated license will stop working after it is expired and PHP script will stop running. Useful for creation of demo versions and trials. The date must be set in the future
--lperiod <days> alternative way of specifying license expiration date. Specified period should be at least one day long

How to load license

PHP scripts protected by the license will only run if the corresponding valid license file is loaded. You can load the License in one of the following ways:
  • Load license in php.ini file using the instruction:
  • phpexpress.add_license = license1.txt, license2.txt
  • This instruction is applicable to each virtual host, therefore different virtual hosts can use different licenses.
  • Load license in .htdocs file using the instruction (will only work with php module of Apache):
  • php_value phpexpress.add_license "license3.txt"
  • In a file not protected by the license call the function pelm_load_license("license4.txt"). While the file containing this call can not be license protected it can still be encoded. pelm_load_license() function is a part of PhpExpress API
  • Specify the name of the license file at the time of the encoding. For example:
    nu-coder -k longkeyword --licfile lic5.txt file1.php ../encoded/file1.php
Please note that if the relative path to the file is used, the system will search for the file in all directories listed in include_path.

How to handle expired or invalid license

If the license used for encryption of PHP files is not found or has expired or became invalid in any way, the loader (PhpExpress) will attempt to call the function pe_handle_error($errcode, $errmessage, $licfilename).

To handle the error of invalid license you should implement this function in a file not protected with the license, so it could be executed in this case and provide suitable information to the user (e.g. "Your Trial has expired"). For example, you can encode error handler with the following parameters:

--eh ./errorhandler.php


Note: For these and other API functions used to work with License Manager please see the section "How to use API provided by NuSphere PhpExpress to work with Nu-Coder" of this manual.

Examples

The following are some examples of using Nu-Coder Command Line Interface to generate licenses for encoded PHP files with Nu-Coder's License Manager:

Example #1

Generate license for an evaluator of the PHP application:

nu-licgen -k "super-store 1.1 trial" -a caption="super-store version 1.1" -x caption --lperiod 14 license_name.txt

Generated license file license_name.txt will be good for 14 days from the moment of creation and will have one attribute called "caption". Attribute caption is going to be visible in the license file.
To protect PHP files in c:\myproject\source with license_name.txt (generated with the command shown above) the following syntax should be used for encoding:

nu-coder.exe -k "super-store 1.1 trial" c:\myproject\source

Example #2

Generate the license for commercial PHP application and link it to host id HVCE42C-61936X (host id should be obtained from the client. PhpExpress provides API function phpexpress_hostid() that can be used for this purpose, described later in the this manual)

nu-licgen -k "1.1 super-store commercial" -a caption=" super-store version 1.1",licensee="John Doe" -x caption,licensee --lid HVCE42C-61936X license_name.txt

In this example, the license file generate will allow the execution of PHP files only on the host id HVCE42C-61936X.
To link PHP files from c:\myproject\source to license_name.txt the following syntax should be used for encoding (same as in the Example #1 of this section):

nu-coder.exe -k "super-store 1.1 trial" c:\myproject\source




<Nu-Coder Command Line InterfaceDeploying Encoded PHP files with NuSphere PhpExpress>
Last updated: Tue, 03 Jun 2008