* Updated Tools->new() to check if it is being invoked in a browser and set the environment appropriately. It also sets the PWD environmental variable to the DOCUMENT_ROOT variable.
* Renamed 'defaults::languages' to 'defaults::language'.
* Created Storage->change_mode(), Storage->change_owner(), Storage->make_directory() and Storage->write_file() that does what their names imply, using the shell commands instead of the built-in commands (may switch to them later). The ->make_directory() method will create any needed parent directories.
* Moved System->read_file() to the Storage module as it made more sense there. For now, System is empty.
* Created Words->language to set or check the active output language.
* Fixed Template->get() to use Words->language.
* Updated Words->string() to take the new 'string' parameter which, when set, is used instead of the 'key' parameter and is treated as a pre-retrieved string, so replacement keys are directly injected.
* Updated Template->get() to take the 'variables' parameter and then uses Words->string({string => ...}) to process the replacement keys.
* Updated tools/scancore-update-states to write out the network interface states to the status.xml file.
Signed-off-by: Digimer <digimer@alteeve.ca>
print$THIS_FILE." ".__LINE__."; [ Warning ] - AN::Tools::Words->read()' asked to read: [$file] which was not readable by: [".getpwuid($<)."/".getpwuid($>)."] (uid/euid: [".$<."/".$>."]).\n";
print$THIS_FILE." ".__LINE__."; [ Warning ] - The passed in array: [$array] wasn't actually an array. Using \@INC + \$ENV{'PATH'} for the list of directories to search instead.\n";
# Not initializing and an array was passed that isn't.
print$THIS_FILE." ".__LINE__."; [ Error ] - The requested template file: [".$source."] is not readable. Please check that it is readable by the webserver user: [$user_name]\n";
print$THIS_FILE." ".__LINE__."; [ Warning ] - AN::Tools::Words->read()' called without a file name to read.\n";
# NOTE: Log the problem, do not translate.
$an->Log->entry({source=>$THIS_FILE,line=>__LINE__,level=>0,priority=>"err",raw=>"[ Error ] - Words->read()' called without a file name to read."});
$return_code=1;
}
elsif(not-e$file)
{
# TODO: Log the problem, do not translate.
print$THIS_FILE." ".__LINE__."; [ Warning ] - AN::Tools::Words->read()' asked to read: [$file] which was not found.\n";
# NOTE: Log the problem, do not translate.
$an->Log->entry({source=>$THIS_FILE,line=>__LINE__,level=>0,priority=>"err",raw=>"[ Error ] - Words->read()' asked to read: [$file] which was not found."});
$return_code=2;
}
elsif(not-r$file)
{
# TODO: Log the problem, do not translate.
print$THIS_FILE." ".__LINE__."; [ Warning ] - AN::Tools::Words->read()' asked to read: [$file] which was not readable by: [".getpwuid($<)."/".getpwuid($>)."] (uid/euid: [".$<."/".$>."]).\n";
# NOTE: Log the problem, do not translate.
$an->Log->entry({source=>$THIS_FILE,line=>__LINE__,level=>0,priority=>"err",raw=>"[ Error ] - Words->read()' asked to read: [$file] which was not readable by: [".getpwuid($<)."/".getpwuid($>)."] (uid/euid: [".$<."/".$>."])."});
$return_code=3;
}
else
@ -255,28 +294,16 @@ sub read
if($@)
{
chomp$@;
print$THIS_FILE." ".__LINE__."; [ Error ] - The was a problem reading: [$file]. The error was:\n";
<keyname="log_0018">About to open the directory: [#!variable!directory!#]</key>
<keyname="log_0019">Variables:</key>
<keyname="log_0020"><![CDATA[The module System->read_file() was called without a 'file' parameter, or the parameter was empty.]]></key>
<keyname="log_0021"><![CDATA[The module System->read_file() was asked to read the file: [#!variable!file!#], but that file does not exist.]]></key>
<keyname="log_0022"><![CDATA[The module System->read_file() was asked to read the file: [#!variable!file!#] which exists but can't be read.]]></key>
<keyname="log_0020"><![CDATA[[ Error ] - The module Storage->read_file() was called without a 'file' parameter, or the parameter was empty.]]></key>
<keyname="log_0021"><![CDATA[[ Error ] - The module Storage->read_file() was asked to read the file: [#!variable!file!#], but that file does not exist.]]></key>
<keyname="log_0022"><![CDATA[[ Error ] - The module Storage->read_file() was asked to read the file: [#!variable!file!#] which exists but can't be read.]]></key>
<keyname="log_0024"><![CDATA[[ Error ] - No template file passed to Template->get().]]></key>
<keyname="log_0025"><![CDATA[[ Error ] - No requested template file: [#!variable!source!#] does not exist. Is it missing in the active skin?]]></key>
<keyname="log_0026"><![CDATA[[ Error ] - The requested template file: [#!variable!source!#] is not readable. Please check that it is readable by the webserver user: [#!variable!user_name!#]]]></key>
<keyname="log_0027"><![CDATA[[ Error ] - No template name passed to Template->get().]]></key>
<keyname="log_0028">Successfully read the words file: [#!variable!file!#].</key>
<keyname="log_0029"><![CDATA[[ Error ] - Storage->find() failed to find: [#!variable!file!#].]]></key>
<keyname="log_0030"><![CDATA[[ Warning ] - Template->skin() was asked to set the skin: [#!variable!set!#], but the source directory: [#!variable!skin_directory!#] doesn't exist. Ignoring.]]></key>
<keyname="log_0031"><![CDATA[[ Warning ] - Storage->search_directories() was passed the array: [#!variable!array!#], but it wasn't actually an array. Using \@INC + path::directories::tools + \$ENV{'PATH'} for the list of directories to search instead.]]></key>
<keyname="log_0032"><![CDATA[[ Warning ] - Words->read()' called without a file name to read.]]></key>
<keyname="log_0033"><![CDATA[[ Warning ] - Words->read()' asked to read: [#!variable!file!#] which was not found.]]></key>
<keyname="log_0034"><![CDATA[[ Warning ] - AN::Tools::Words->read()' asked to read: [#!variable!file!#] which was not readable by: [#!variable!user!#] (uid/euid: [#!variable!uid!#]).]]></key>
<keyname="log_0035"><![CDATA[[ Warning ] - The config file: [#!variable!file!#] appears to have a malformed line: [#!variable!count!#:#!variable!line!#].]]></key>
<keyname="log_0036"><![CDATA[[ Error ] - The module Storage->change_mode() was called without a 'target' parameter, or the parameter was empty.]]></key>
<keyname="log_0037"><![CDATA[[ Error ] - The module Storage->change_mode() was called without a 'mode' parameter, or the parameter was empty.]]></key>
<keyname="log_0038"><![CDATA[[ Error ] - The module Storage->change_mode() was called without an invalid 'mode' parameter. It should have been three or four digits, but: [#!variable!mode!#] was passed.]]></key>
<keyname="log_0039"><![CDATA[[ Error ] - The module Storage->change_owner() was called without a 'target' parameter, or the parameter was empty.]]></key>
<keyname="log_0040"><![CDATA[[ Error ] - The module Storage->write_file() was asked to write the file: [#!variable!file!#] but it already exists and 'overwrite' was not set. Aborting.]]></key>
<keyname="log_0041"><![CDATA[[ Error ] - The module Storage->write_file() was asked to write the file: [#!variable!file!#] but it is not a full path. Aborting.]]></key>
<!-- Test words. Do NOT change unless you update 't/Words.t' or tests will needlessly fail. -->
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { full_path => $full_path }});
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { full_path => $full_path }});
if (-d $full_path)
{
# Pull out the data I want.
my $interface = $file;
my $mac_address = $an->System->read_file({file => $full_path."/address"});
my $link_state = $an->System->read_file({file => $full_path."/carrier"});
my $mtu = $an->System->read_file({file => $full_path."/mtu"});
my $duplex = $an->System->read_file({file => $full_path."/duplex"}); # full or half?
my $operational = $an->System->read_file({file => $full_path."/operstate"}); # up or down
my $speed = $an->System->read_file({file => $full_path."/speed"}); # Mbps (ie: 1000 = Gbps), gives a very high number for unplugged link
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
my $mac_address = $an->Storage->read_file({file => $full_path."/address"});
my $link_state = $an->Storage->read_file({file => $full_path."/carrier"});
my $mtu = $an->Storage->read_file({file => $full_path."/mtu"});
my $duplex = $an->Storage->read_file({file => $full_path."/duplex"}); # full or half?
my $operational = $an->Storage->read_file({file => $full_path."/operstate"}); # up or down
my $speed = $link_state ? $an->Storage->read_file({file => $full_path."/speed"}) : 0; # Mbps (ie: 1000 = Gbps), gives a very high number for unplugged link
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {