Procedural File: util.php

Source Location: /util.php



Classes:

Page Details:

General utility functions

This file contains convenience functions used throughout the package.

Tags:


Includes:
require_once("./config.php") [line 15]

include global configuration definitions




error

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.

Tags:

  • note - This might look nicer using javascript to pop up a nice window with the error message. Style sheets would be nice too.

Parameters

  • where $where - the name of the caller routine or the process where the error occurred
  • what $what - a description of the abnormal condition that triggered the error

[ Top ]

letal

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.

Parameters

  • where $what - location (physical or logical) where the error was detected: a physical location (routine name/line number) may be helpful for debugging, a logical location (during which part of the processing it happened) will be more helful to the user.
  • what $where - a descrition of the abnormality detected.

[ Top ]

set_footer

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.

Parameters

[ Top ]

set_header

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.

Parameters

[ Top ]

ssh_copy

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.

Parameters

[ Top ]

ssh_open

void ssh_open( mixed $remote, mixed $password)

[line 224]

Parameters

[ Top ]

ssh_passthru

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.

Tags:

  • return - The output of the remote command.

Parameters

  • remote $remote - The remote end to run the command, in the form 'user@host' (or 'host' if the username is the same).
  • password $password - The remote password. Note that if direct RSA/DSA/.shosts/.rhosts login is enabled then the password should be ignored as SSH should not run the ASKPASS command).
  • command $command - The command to execute on the remote end NOTE: if you want to use redirection, the entire remote command line should be enclosed in additional quotes!
  • status $status - Optional, this will hold the termination status of SSH after invocation, which should be the exit status of the remote command or 255 if an error occurred

[ Top ]

warning

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.

Parameters

  • msg $msg - the warning message to send the user

[ Top ]


Documentation generated on Thu, 16 Jun 2005 11:03:54 +0200 by phpDocumentor 1.2.3