======$_SERVER Array====== Whenever a script is executed, a ''$_SERVER'' array is created and passed to the script. This provides information about the context of the script and environment. The elements of the array are read-only. You can actually modify them from code, but they will not have any effect on the system once the script terminates. The following table describes the various elements of the array. ^ Key ^ Description ^ | SCRIPT_NAME | Name of the script being executed | | SCRIPT_FILENAME | Full path and file name of script being executed | | SCRIPT_TYPE | Can be: http, cron or shell. | | ::: | ''http'' scripts are initiated via a web request. | | ::: | ''cron'' scripts are initiated via the scheduler or exec() | | ::: | ''shell'' scripts are executed via the telnet console. | | SCRIPT_FLAGS | Only valid for cron scripts. Flags for the script as follows:| | ::: | +-------+-------+-------+-------+-------+-------+---------+----------+--------+ | Bit 8 | Bit 7 | Bit 6 | Bit 5 | Bit 4 | Bit 3 | Bit 2 | Bit 1 | Bit 0 | | | | | | KILL | SHELL | RUN_NOW | ONE_SHOT | IN_MEM | +-------+-------+-------+-------+-------+-------+---------+----------+--------+ | | ::: | ''IN_MEM'' - The script is loading in memory and executing or ready to. | | ::: | ''ONE_SHOT'' - This script is not recurring, and has been triggered by a call to exec() or an action, or is the startup script. | | ::: | ''RUN_NOW'' - The script should be run immediately | | ::: | ''SHELL'' - The script is run from the telnet console | | ::: | ''KILL'' - Signals a kill to the script | | REMOTE_ADDR | Only valid for http scripts. IP address of device initiating request | | SERVER_ADDR | Only valid for http scripts. IP address of [[hardware:wattmons|Wattmon]] device | | REQUEST_METHOD | Only valid for http scripts. Can be: ''GET'', ''POST'', ''PUT'' | | HW_PLATFORM | Hardware platform currently executing on | | ::: | ''0'' - WM-60 (the original [[hardware:wattmons:Wattmon]]) | | ::: | ''1'' - WM-PRO [[hardware:wattmons:WattmonPRO]] | | ::: | ''2'' - WM-MINI [[hardware:wattmons:WattmonMINI]] | | ::: | ''10'' - WM-MEGA [[hardware:wattmons:WattmonMEGA]] | ====Examples==== ===Checking the Hardware Platform=== ===Checking the HTTP Method=== ===Checking the Script Initiator=== 0) { print("This was started with exec() or via an action, and will only run once."); } } ?>