Chapter 2. WebTool Core API Reference

This section documents the core WebTool::* namespace. The main module, WebTool, contains general methods which are applicable across all of the modules (read_file, write_file, audit,etc.)

The WebTool::UI namespace contains methods for creating, translating, and drawing pages to the end-user.

Finally, the WebTool::ACL module provides an interface to the Guardian Digital WebTool Access Control subsystem, the WebTool::Constants module provides, well, constants, and the WebTool::MySQL module provides an interface to the MySQL daemon.

2.1. WebTool

2.1.1. NAME

WebTool - The core WebTool API.

2.1.2. SYNOPSIS

use WebTool;

2.1.3. DESCRIPTION

This module provides the core WebTool API. Functions for loading WebTool modules, creating temporary files and directories, auditing WebTool operations, and reading/writing files are all provided via a non-Object Oriented interface.

The audit($) interface is exported by default.

2.1.4. METHODS

audit($)

Basic function is to append WEBTOOL_AUDIT_LOG file. It receives one optional argument (message). In file log is written in order of Timestamp,user,filename,line.

Example usage:

$service = 'named';
if ($services->start($service) == 0) {
  audit("Successfully started the '$service' service.");
}

Entry in webtool-audit.log will be something like this:

[2006/07/17 09:33:02] admin modules/services/toggle_current.cgi:42
Successfully started the 'named' service.

load_module($)

Basic function is to load perticular module. It receives one argument (module). New module is loaded into its own namespace. This function must be called from within BEGIN{ } block. In a result module is actully loaded using "use $module" as return value.

Example usage:

BEGIN { WebTool::load_module('services');

mktemp($)

This function makes temporary filename. It takes a single, optional argument on what to use as the base filename(template). If you don't specify this base then 'webtool' will be used. It returns a result from running a mktemp command under WEBTOOL_TMPDIR/argument.XXXXXX .

mkdtemp($)

This function generates uniquely named temporary directory. It takes a single, optional argument on what to use as the base filename(template). If you don't specify this base then ' webtool' will be used. It returns a result from running a mkdtemp command under WEBTOOL_TMPDIR/argument.XXXXXX .

Example usage:

my $tmpfile   = WebTool::mktemp('apt-get');
my $ajax      = new CGI::Ajax('progress' => "progress.cgi?tempfile=$tmpfile");

output_ctl($)

One argument is passed(0 or 1) to this function, according to that value function open/close STDOUT/STDERR and flushes.

Example usage:

output_ctl(0);
output_ctl(1);

read_file($)

This function receives one argument(file). It opens the file and read it line by line and puts every line in array. It returns array.

Example usage:

my @file  = WebTool::read_file($file);

write_file($)

This function receives two argument(file and array). It opens the file and writes in line by line from array.

Example usage:

WebTool::write_file(UPS_CONF, @f);

2.1.5. AUTHORS

Ryan W. Maple <ryan@guardiandigital.com>

2.1.6. COPYRIGHT AND LICENSE

Copyright Guardian Digital, Inc., All Rights Reserved