ocPortal Tutorial: OcCLE
Written by Philip Withnall, ocProducts
OcCLE, the ocPortal Command-Line Environment, is designed for experienced system administrators who find command-lines faster to use than GUI-based alternatives.We designed OcCLE to supplement the features of the Admin Zone, rather than to replace them. The interface allows you to enter commands in the form of:
- PHP code
- SQL database queries
- OcCLE-code scripts
- OcCLE-code commands, which you can use to fully interact with the OcCLE meta-filesystem
Table of contents
Commands
Although the system is very flexible, there are many commands to use, designed for interaction with the meta-filesystem and other systems designed specifically for OcCLE. Since UNIX is the grandfather of almost all of the operating systems where command-line use is most prevalent – and administrators comfortable with command-lines will probably be UNIX experts – many of the commands mirror their UNIX counterparts.The basic format for a command is as follows:
Code
command_name -o -long_option -o2=value -long_option2="value 2" parameter1 "parameter 2" parameter3
- A command name (no spaces)
- followed by a list of options (either in short or long format; this is decided by the command in question) with optional values (quoted if they contain spaces)
- then a list of parameter values (quoted if they contain spaces).
OcCLE supports backslashing, so you can escape any quotes in values you're passing:
Code
echo "Grandma said: \"Hello world!\""
For a full list of OcCLE commands, simply execute the commands command in OcCLE:
Code
commands
PHP code
PHP can be entered and executed by OcCLE, simply by prefixing the code to be executed with a colon (":"). The returned data will be displayed as best as possible (its type will be determined and outputted as appropriate). Multiple PHP commands may be executed (separated by semi-colons, as per normal PHP code).For example:
Code
:echo "Hello"; echo " World.";
OcCLE will attempt to store variables and included files between command requests (using a cookie) to make it possible to execute command sequences without having to put them all on one line.
SQL queries
SQL queries can also be executed by OcCLE, simply by prefixing the query to be executed with a semi-colon (";"). As with PHP commands, the query results will be outputted in an appropriate manner.Meta-filesystems
One of the main features of OcCLE is the fact that various facets of ocPortal can be manipulated through meta-filesystems. There are several included by default, but it is quite simple to write more as hooks if you know how to program. There are several different meta-filesystems for accessing the real file structure of the ocPortal installation, one for manipulating members (if you have OCF installed), one for manipulating the database, and a couple of others.To use these meta-filesystems, simply navigate around using the standard UNIX filesystem commands (cd, pwd, ls, etc.), and modify files in a similar fashion to change the appropriate behind-the-scenes value.
Each of the default meta-filesystems is mapped to a subdirectory of the OcCLE meta-root directory, with obvious mappings sometimes inspired by UNIX. These mappings are stored in an array in sources/occle.php, and if you know how to program you can easily change and customise the mappings to personalise your OcCLE installation.
The default meta-filesystems are as follows, and are all mapped as subdirectories of the root directory:
- bin: A place to store all your OcCLE scripts
- database: Access to the raw SQL database
- etc: Access to ocPortal configuration options
- home: Access to the filedump
- members: A listing of every member registered on the system, with their preferences and usergroups
- raw: A raw listing of the actual ocPortal installation directory
- root: A listing of the ocPortal installation directory, taking source code overrides into account
Scripts
Commands can be put together in scripts and saved for later use in the bin filesystem. These can be executed on the OcCLE command-line just by entering the name of the script, or can alternatively be scheduled for execution by the calendar to run at some point in the future (possibly routinely).OcCLEchat
The final feature of OcCLE is OcCLEchat, which allows users of OcCLE to chat with each other across the internet. It is used via the occlechat command, taking a website URL and message as parameters (remember to double-quote them if they contain spaces). The system is designed to be resistant to intrusions, as each message's validity is checked before it is displayed.OcCLEchat is designed to allow website administrators to communicate with each other and share tips, tricks and experiences with ocPortal.



