If you want to develop a PHP script of your own that will be called by a scheduler such as CRON, and need to call nBill functions, or even CMS functions for that matter, there are security implications involved in providing an entry point into the application. nBill is designed to allow custom scripts to be called through the component itself - thus preserving the CMS as the entry point.

To create a file that can be called using the method described here, you must include a line containing a hash symbol, followed by the cron authorisation token - there should be nothing else on that line, but the line can appear anywhere in the file.

You should also do a check for the presence of certain constants (either _VALID_MOS or ABSPATH or _JEXEC or NBILL_VALID_NBF, and NBILL_CRON_ENTRY_CHECKED) BEFORE you do any processing. If either constant is not defined, processing should be abandoned. For example, the start of your file might look like this:

#nbill_cron
(defined('_VALID_MOS') || defined('_JEXEC') || defined('ABSPATH') || defined('NBILL_VALID_NBF')) or die('Access Denied.');
defined("NBILL_CRON_ENTRY_CHECKED") or die ("Access Denied");

//Now you can write your code here.

This will prevent anyone from executing your code by visiting the file directly in a browser. Note that the CRON scheduler also should NOT try to access the file directly - processing should be routed through the main index.php, for example, in the case of Joomla!: http://www.example.com/index.php?option=com_nbill&action=cron_entry&cron_file=nbill_cron_my_spiffing_cron_job_script.php or for Wordpress: http://www.example.com?nbill=my-account&action=cron_entry&cron_file=nbill_cron_my_spiffing_cron_job_script.php. Also note, that the actual cron authorisation token should be changed both here and in the nBillĀ global configuration page.

You can use nbf_cms::$interop->site_base_path to get the full file path ('absolute path') to Joomla! or Wordpress, in case you want to include any further files. All the normal Joomla! or Wordpress and nBill environment variables will be available for you to use.