# Kiriwrite Installer Script (install.pl/install.cgi) #
# Installation script for Kiriwrite #
# #
-# Version: 0.4.0 #
+# Version: 0.5.0 #
# mod_perl 2.x compatabile version #
# #
# Copyright (C) 2005-2008 Steve Brokenshire <sbrokenshire@xestia.co.uk> #
use warnings; # Write warnings to the HTTP Server Log file.
use utf8;
-use CGI::Lite;
eval "use CGI::Lite";
if ($@){
print "Content-type: text/html;\r\n\r\n";
- print "The CGI::Lite Perl Module is not installed. Please install CGI::Lite and then run this installation script again.";
+ print "The CGI::Lite Perl Module is not installed. Please install CGI::Lite and then run this installation script again. CGI::Lite can be installed through CPAN.";
exit;
}
my $default_textarearows = "10";
my $default_textareacols = "50";
+my $default_outputmodule = "Normal";
+
my $default_server = "localhost";
my $default_port = "3306";
my $default_protocol = "tcp";
$kiriwrite_lang{"en-GB"}{"presmoduleblank"} = "The presentation module name given is blank.";
$kiriwrite_lang{"en-GB"}{"presmoduleinvalid"} = "The presentation module name given is invalid.";
-
+
$kiriwrite_lang{"en-GB"}{"dbmoduleblank"} = "The database module name given is blank.";
$kiriwrite_lang{"en-GB"}{"dbmoduleinvalid"} = "The database module name given is invalid.";
+ $kiriwrite_lang{"en-GB"}{"outputmoduleblank"} = "The output module name given is blank.";
+ $kiriwrite_lang{"en-GB"}{"outputmoduleinvalid"} = "The output module name given is invalid.";
+
$kiriwrite_lang{"en-GB"}{"presmodulemissing"} = "The presentation module with the filename given is missing.";
+ $kiriwrite_lang{"en-GB"}{"outputmodulemissing"} = "The output module with the filename given is missing.";
$kiriwrite_lang{"en-GB"}{"dbmodulemissing"} = "The database module with the filename given is missing.";
$kiriwrite_lang{"en-GB"}{"languagefilenamemissing"} = "The language file with the filename given is missing.";
$kiriwrite_lang{"en-GB"}{"systemlanguage"} = "System Language";
$kiriwrite_lang{"en-GB"}{"modules"} = "Modules";
$kiriwrite_lang{"en-GB"}{"presentationmodule"} = "Presentation Module";
+ $kiriwrite_lang{"en-GB"}{"outputmodule"} = "Output Module";
$kiriwrite_lang{"en-GB"}{"databasemodule"} = "Database Module";
$kiriwrite_lang{"en-GB"}{"databaseserver"} = "Database Server";
$kiriwrite_lang{"en-GB"}{"databaseport"} = "Database Port";
system_language = $passedsettings->{Language}
system_presmodule = $passedsettings->{PresentationModule}
+system_outputmodule = $passedsettings->{OutputModule}
system_dbmodule = $passedsettings->{DatabaseModule}
system_datetime = $passedsettings->{DateFormat}
my $http_query_language = $form_data->{'language'};
my $http_query_presmodule = $form_data->{'presmodule'};
+ my $http_query_outputmodule = $form_data->{'outputmodule'};
my $http_query_dbmodule = $form_data->{'dbmodule'};
my $http_query_databaseserver = $form_data->{'databaseserver'};
# Check the module names to see if they're valid.
my $kiriwrite_presmodule_modulename_check = kiriwrite_variablecheck($http_query_presmodule, "module", 0, 1);
+ my $kiriwrite_outputmodule_modulename_check = kiriwrite_variablecheck($http_query_outputmodule, "module", 0, 1);
my $kiriwrite_dbmodule_modulename_check = kiriwrite_variablecheck($http_query_dbmodule, "module", 0, 1);
if ($kiriwrite_presmodule_modulename_check eq 1){
}
+ if ($kiriwrite_outputmodule_modulename_check eq 1){
+
+ # The output module name is blank, so return
+ # an error.
+
+ kiriwrite_error("outputmoduleblank");
+
+ }
+
+ if ($kiriwrite_outputmodule_modulename_check eq 2){
+
+ # The output module name is invalid, so return
+ # an error.
+
+ kiriwrite_error("outputmoduleinvalid");
+
+ }
+
if ($kiriwrite_dbmodule_modulename_check eq 1){
# The database module name is blank, so return
}
- # Check if the database module, presentation module and
- # language file exists.
+ # Check if the database module, presentation module,
+ # output module and language file exists.
if (!-e "Modules/Presentation/" . $http_query_presmodule . ".pm"){
}
+ if (!-e "Modules/Output/" . $http_query_outputmodule . ".pm"){
+
+ # The database module is missing so return an
+ # error.
+
+ kiriwrite_error("outputmodulemissing");
+
+ }
+
if (!-e "Modules/Database/" . $http_query_dbmodule . ".pm"){
# The database module is missing so return an
# Write the new configuration file.
- kiriwrite_writeconfig({ DatabaseDirectory => $http_query_dbdirectory, OutputDirectory => $http_query_outputdirectory, ImagesURIPath => $http_query_imagesuripath, TextAreaCols => $http_query_textareacols, TextAreaRows => $http_query_textarearows, DateFormat => $finaldateformat, Language => $http_query_language, PresentationModule => $http_query_presmodule, DatabaseModule => $http_query_dbmodule, DatabaseServer => $http_query_databaseserver, DatabasePort => $http_query_databaseport, DatabaseProtocol => $http_query_databaseprotocol, DatabaseName => $http_query_databasename, DatabaseUsername => $http_query_databaseusername, DatabasePassword => $http_query_databasepassword, DatabaseTablePrefix => $http_query_databasetableprefix });
+ kiriwrite_writeconfig({ DatabaseDirectory => $http_query_dbdirectory, OutputDirectory => $http_query_outputdirectory, ImagesURIPath => $http_query_imagesuripath, TextAreaCols => $http_query_textareacols, TextAreaRows => $http_query_textarearows, DateFormat => $finaldateformat, Language => $http_query_language, PresentationModule => $http_query_presmodule, OutputModule => $http_query_outputmodule, DatabaseModule => $http_query_dbmodule, DatabaseServer => $http_query_databaseserver, DatabasePort => $http_query_databaseport, DatabaseProtocol => $http_query_databaseprotocol, DatabaseName => $http_query_databasename, DatabaseUsername => $http_query_databaseusername, DatabasePassword => $http_query_databasepassword, DatabaseTablePrefix => $http_query_databasetableprefix });
my $installscriptmessage = "";
$test_list{CheckDBI}{Type} = "dependency";
$test_list{CheckDBI}{Code} = "DBI";
-$test_list{CheckTieHash}{Name} = "Tie::IxHash";
-$test_list{CheckTieHash}{Type} = "dependency";
-$test_list{CheckTieHash}{Code} = "Tie::IxHash";
-
$test_list{CheckCGILite}{Name} = "CGI::Lite";
$test_list{CheckCGILite}{Type} = "dependency";
$test_list{CheckCGILite}{Code} = "CGI::Lite";
$test_list{Encode}{Type} = "dependency";
$test_list{Encode}{Code} = "Encode";
+$test_list{HashSearch}{Name} = "Hash::Search";
+$test_list{HashSearch}{Type} = "dependency";
+$test_list{HashSearch}{Code} = "Hash::Search";
+
+$test_list{CheckTieHash}{Name} = "Tie::IxHash";
+$test_list{CheckTieHash}{Type} = "dependency";
+$test_list{CheckTieHash}{Code} = "Tie::IxHash";
+
$test_list{DBDmysql}{Name} = "DBD::mysql";
$test_list{DBDmysql}{Type} = "database";
$test_list{DBDmysql}{Code} = "DBD::mysql";
print "<table>";
-kiriwrite_addtablerow("Filename", "tablecellheader", "Result", "tablecellheader");
+kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{filename}, "tablecellheader", "Result", "tablecellheader");
foreach $test (keys %file_results) {
my @language_short;
my (%available_languages, $available_languages);
my @presentation_modules;
+my @output_modules;
my @database_modules;
my $select_data = "";
my (%language_data, $language_data);
my $language_out = "";
my ($presmodule_name, $presmodule_out) = "";
my ($dbmodule_name, $dbmodule_out) = "";
+my ($outputmodule_name, $outputmodule_out) = "";
# Get the list of available languages.
}
+# Get the list of output modules.
+
+opendir(OUTPUTDIR, "Modules/Output");
+my @outputmodule_directory = grep /m*\.pm$/, readdir(OUTPUTDIR);
+closedir(OUTPUTDIR);
+
+foreach my $outputmodule_file (@outputmodule_directory){
+
+ # Get the friendly name for the database module.
+
+ $outputmodule_file =~ s/.pm$//g;
+ push(@output_modules, $outputmodule_file);
+
+}
+
# Get the list of database modules.
opendir(DATABASEDIR, "Modules/Database");
}
kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{systemlanguage}, "tablename", "<select name=\"language\">\r\n$language_out\r\n</select>", "tabledata");
+
kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{modules}, "tablecellheader", "", "tablecellheader");
+
foreach $presmodule_name (@presentation_modules){
$presmodule_out = $presmodule_out . "<option value=\"$presmodule_name\">$presmodule_name</option>";
}
kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{presentationmodule}, "tablename", "<select name=\"presmodule\">$presmodule_out</select>", "tabledata");
+
foreach $dbmodule_name (@database_modules){
$dbmodule_out = $dbmodule_out . "<option value=\"$dbmodule_name\">$dbmodule_name</option>";
}
-
kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{databasemodule}, "tablename", "<select name=\"dbmodule\">$dbmodule_out</select>", "tabledata");
+
+foreach $outputmodule_name (@output_modules){
+ if ($default_outputmodule = $outputmodule_name){
+ $outputmodule_out = $outputmodule_out . "<option value=\"$outputmodule_name\" selected>$outputmodule_name</option>";
+ } else {
+ $outputmodule_out = $outputmodule_out . "<option value=\"$outputmodule_name\">$outputmodule_name</option>";
+ }
+}
+kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{outputmodule}, "tablename", "<select name=\"outputmodule\">$outputmodule_out</select>", "tabledata");
+
kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{databaseserver}, "tablename", "<input type=\"text\" name=\"databaseserver\" size=\"32\" maxlength=\"128\" value=\"$default_server\">\n", "tabledata");
kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{databaseport}, "tablename", "<input type=\"text\" name=\"databaseport\" maxlength=\"5\" size=\"5\" value=\"$default_port\">\n", "tabledata");
kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{databaseprotocol}, "tablename", "<select name=\"databaseprotocol\">\n<option value=\"tcp\">tcp</option>\n<option value=\"udp\">udp</option>\n</select>\n", "tabledata");