#!/usr/local/bin/php
<?php if ( !empty($argv) && $argc == 5 ) {

        // Environment:
        define('ENVIRONMENT', basename($argv[0]));
        
        // User's login:
        if (isset($argv[1])) {
            define('LOGIN', $argv[1]);
        } else define('LOGIN', NULL);

        // Changed parameter:
        if (isset($argv[2])) {
            define('PARAMETER', $argv[2]);
        } else define('PARAMETER', NULL);

        // Old value:
        if (isset($argv[3])) {
            define('OLD_VALUE', $argv[3]);
        } else define('OLD_VALUE', NULL);

        // New value:
        if (isset($argv[4])) {
            define('NEW_VALUE', $argv[4]);
        } else define('NEW_VALUE', NULL);

        // Paths:
        define('BASEPATH', __DIR__ . '/');
        define('SYSTEM', BASEPATH . 'system/');
        define('DBPATH',  SYSTEM . 'database/');
        define('NASPATH', SYSTEM . 'executer/');
        define('LOGPATH', SYSTEM . 'log/');

        // Driver's extention:
        define('EXT', '.drv');

        // Turn off PHP error reporting:
        error_reporting(0);

        // Unset all resived arguments and their amount:
        unset($argv, $argc);
        
        // If changing parameter is `IP`:
        if ( PARAMETER == 'IP' && OLD_VALUE != '*' && NEW_VALUE != '*') {
            // Put old IP address to `IP` constant:
            define('IP', OLD_VALUE);
            // Continue...
            include_once(SYSTEM . 'ubilling.cls');
            new Ubilling();
        }
        
    } else exit('Only STG can run script!');
?>