Source Location: /util.php
General utility functions
This file contains convenience functions used throughout the package.
include global configuration definitions
void error(
where $where, what $what)
[line 104]
print an error message and exit
Whenever we detect something wrong, we must tell the user. This function will take an error message as its argument, format it suitably and spit it out.
[ Top ]
void letal(
where $what, what $where)
[line 138]
print a letal error message and die
This function is called whenever a letal error (one that prevents further processing) is detected. The function will spit out an error message, close the page and exit the program. It should seldomly be used, since it may potentially disrupt the page layout (e.g. amid a table) by not closing open tags of which it is unaware. Actually it is a wrapper for error + terminate.
[ Top ]
void set_footer(
)
[line 54]
close a web page
Make sure we end the page with all the appropriate formulisms: close the body, include copyright notice, state creator and any needed details, and close the page.
[ Top ]
void set_header(
)
[line 27]
Start the display of a www page
We have it as a function so we can customise all pages generated as needed. This routine will open HTML, create the page header, and include any needed style sheets (if any) to provide a common look-and-feel for all pages generated.
[ Top ]
void ssh_copy(
mixed $origin, mixed $destination, mixed $password)
[line 206]
Copy a file or directory from one source to a destination
This function copies source to dest, where one of them is a local filespec and the other a remote filespec of the form [user@]host:path
If the original source is a directory, it will be copied recursively to destination (hence easing file transfers).
The function returns TRUE on success or FALSE on failure.
[ Top ]
void ssh_open(
mixed $remote, mixed $password)
[line 224]
[ Top ]
output ssh_passthru(
remote $remote, password $password, command $command, status $status)
[line 178]
Execute a single command remotely using ssh and return its entire output (like passthru)
This might be done as well using a pipe on /tmp and making the command 'cat' the pipe: when ssh runs, it runs the command 'cat' on the pipe and hangs on read. Then we just need a thread to open the pipe, put the password and close the pipe. This other way the password is never wirtten down. But, OTOH, the file life is so ephemeral that most of the time it will only exist in the internal system cache, so this approach is not that bad either.
[ Top ]
void warning(
msg $msg)
[line 81]
print a warning
Prints a warning in a separate pop-up window. A warning is issued when a non-critical problem has been detected. Execution can be resumed using some defaults, but the user should be notified. In order to not disrupt the web page we are displaying we use a JavaScript pop-up alert to notify the user.
[ Top ]