Create your own scripts to be run by cron

From PhpCOIN Documentation

Jump to: navigation, search

phpCOIN v1.2.1b dated 2004-08-07 and later versions handles recurring processes (scripts to be run by cron) a little differently than previous versions.

1) All files to be run by cron must be placed in the /coin_cron folder

2) The header of the file must have some "where are we" code:

# Set cron filename
	$cronfile	= 'invoices.php';

# Change directory
	$_pth	= str_replace("\\", '/', realpath($argv[0]));
	$_pth	= str_replace($cronfile, , $_pth);
	$_pth	= str_replace('/coin_cron', , $_pth);
	chdir($_pth);

# include the "where are we" code
	require_once('cron_config.php');

Replace the $cronfile value with the filename of your script. The cron_config.php file will figure out where your script is located, and make available to your script the following DEFINEs:

    BASE_HREF is the complete URL to phpCOIN
    $_PACKAGE['PATH'] is the directory location of phpCOIN, relative to the web-server root
    PKG_PATH_BASE is the file-system location of the phpCOIN directory.
    When including files, this should prepend the path/filename to include
    because it will work on both Windows and *nix.

All path variables use forward slashes regardless of *nix or Windows. This makes it easier for you to parse these variables if your script needs to.

If you want your script to have access to all the phpCOIN variables and common functions, before you get into the rest of your code also insert:

    # Include core file
         require_once(PKG_PATH_INCL.'core.php');
Personal tools

Inscrita el Registro Mercantil de Mallorca Tomo 2140, Hoja No. PM-51034, Folio 135
This website owned and operated by: Technology Services RPVW S.L. CIF# B57345084
Avda Constitucion 48 Bajos Alaro 07340 Baleares SPAIN
Tel:+34 971518362    Fax: +34 971518368    eMail: support@phpcoin.com