Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Version 0.3.0
[kiriwrite/.git] / cgi-files / install.cgi
1 #!/usr/bin/perl -Tw
3 #################################################################################
4 # Kiriwrite Installer Script (install.cgi)                                      #
5 # Installation script for Kiriwrite                                             #
6 #                                                                               #
7 # Version: 0.1.0                                                                #
8 #                                                                               #
9 # Copyright (C) 2005-2007 Steve Brokenshire <sbrokenshire@xestia.co.uk>         #
10 #                                                                               #
11 # This program is free software; you can redistribute it and/or modify it under #
12 # the terms of the GNU General Public License as published by the Free          #
13 # Software Foundation; as version 2 of the License.                             #
14 #                                                                               #
15 # This program is distributed in the hope that it will be useful, but WITHOUT   #
16 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS #
17 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.#
18 #                                                                               #
19 # You should have received a copy of the GNU General Public License along with  #
20 # this program; if not, write to the Free Software Foundation, Inc., 51         #
21 # Franklin St, Fifth Floor, Boston, MA 02110-1301 USA                           #
22 ################################################################################# 
24 use strict;                             # Throw errors if there's something wrong.
25 use warnings;                           # Write warnings to the HTTP Server Log file.
27 use utf8;
28 #use CGI qw(:standard *table *Tr *td);
29 use CGI::Lite;
30 #use CGI::Carp('fatalsToBrowser');      # Output errors to the browser.
32 # Setup strings in specific languages. Style should be no spacing for
33 # language title and one tabbed spacing for each string.
35 # Define some default settings.
37 my $default_language            = "en-GB";
38 my $default_dbdirectory         = "db";
39 my $default_outputdirectory     = "output";
40 my $default_imagesuri           = "/images/kiriwrite";
42 my $default_textarearows        = "10";
43 my $default_textareacols        = "50";
45 my $default_server              = "localhost";
46 my $default_port                = "3306";
47 my $default_protocol            = "tcp";
48 my $default_name                = "database";
49 my $default_username            = "username";
50 my $default_prefix              = "kiriwrite";
52 my ($kiriwrite_lang, %kiriwrite_lang);
54 $kiriwrite_lang{"en-GB"}{"languagename"}        = "English (British)";
55         $kiriwrite_lang{"en-GB"}{"testpass"}            = "OK";
56         $kiriwrite_lang{"en-GB"}{"testfail"}            = "Error";
58         $kiriwrite_lang{"en-GB"}{"generic"}                     = "An error occured which is not known to the Kiriwrite installer.";
59         $kiriwrite_lang{"en-GB"}{"invalidvariable"}             = "The variable given was invalid.";
60         $kiriwrite_lang{"en-GB"}{"invalidvalue"}                = "The value given was invalid.";
61         $kiriwrite_lang{"en-GB"}{"invalidoption"}               = "The option given was invalid.";
62         $kiriwrite_lang{"en-GB"}{"variabletoolong"}             = "The variable given is too long.";
63         $kiriwrite_lang{"en-GB"}{"blankdirectory"}              = "The directory name given is blank.";
64         $kiriwrite_lang{"en-GB"}{"invaliddirectory"}            = "The directory name given is invalid.";
65         $kiriwrite_lang{"en-GB"}{"moduleblank"}                 = "The module filename given is blank.";
66         $kiriwrite_lang{"en-GB"}{"moduleinvalid"}               = "The module filename given is invalid.";
68         $kiriwrite_lang{"en-GB"}{"dbdirectorytoolong"}          = "The database directory name given is too long.";
69         $kiriwrite_lang{"en-GB"}{"outputdirectorytoolong"}      = "The output directory name given is too long.";
70         $kiriwrite_lang{"en-GB"}{"imagesuripathtoolong"}        = "The images URI path name given is too long.";
71         $kiriwrite_lang{"en-GB"}{"dateformattoolong"}           = "The date format given is too long.";
72         $kiriwrite_lang{"en-GB"}{"customdateformattoolong"}     = "The custom date format given is too long.";
73         $kiriwrite_lang{"en-GB"}{"languagefilenametoolong"}     = "The language filename given is too long.";
75         $kiriwrite_lang{"en-GB"}{"dateformatblank"}             = "The date format given was blank.";
76         $kiriwrite_lang{"en-GB"}{"dateformatinvalid"}           = "The date format given is invalid.";
77         $kiriwrite_lang{"en-GB"}{"languagefilenameinvalid"}     = "The language filename given is invalid.";
79         $kiriwrite_lang{"en-GB"}{"dbdirectoryblank"}            = "The database directory name given is blank.";
80         $kiriwrite_lang{"en-GB"}{"dbdirectoryinvalid"}          = "The database directory name given is invalid.";
82         $kiriwrite_lang{"en-GB"}{"outputdirectoryblank"}        = "The output directory name given is blank.";
83         $kiriwrite_lang{"en-GB"}{"outputdirectoryinvalid"}      = "The output directory name given is invalid.";
85         $kiriwrite_lang{"en-GB"}{"textarearowblank"}            = "The text area row value given is blank.";
86         $kiriwrite_lang{"en-GB"}{"textarearowtoolong"}          = "The text area row value given is too long.";
87         $kiriwrite_lang{"en-GB"}{"textarearowinvalid"}          = "The text area row value given is invalid.";
89         $kiriwrite_lang{"en-GB"}{"textareacolsblank"}           = "The text area columns value given is blank.";
90         $kiriwrite_lang{"en-GB"}{"textareacolstoolong"}         = "The text area columns value given is too long.";
91         $kiriwrite_lang{"en-GB"}{"textareacolsinvalid"}         = "The text area columns value given is invalid.";
93         $kiriwrite_lang{"en-GB"}{"presmoduleblank"}             = "The presentation module name given is blank.";
94         $kiriwrite_lang{"en-GB"}{"presmoduleinvalid"}           = "The presentation module name given is invalid.";
95  
96         $kiriwrite_lang{"en-GB"}{"dbmoduleblank"}               = "The database module name given is blank.";
97         $kiriwrite_lang{"en-GB"}{"dbmoduleinvalid"}             = "The database module name given is invalid.";
98  
99         $kiriwrite_lang{"en-GB"}{"presmodulemissing"}           = "The presentation module with the filename given is missing.";
100         $kiriwrite_lang{"en-GB"}{"dbmodulemissing"}             = "The database module with the filename given is missing.";
101         $kiriwrite_lang{"en-GB"}{"languagefilenamemissing"}     = "The language file with the filename given is missing.";
102  
103         $kiriwrite_lang{"en-GB"}{"servernametoolong"}           = "The database server name given is too long.";
104         $kiriwrite_lang{"en-GB"}{"servernameinvalid"}           = "The database server name given is invalid.";
105         $kiriwrite_lang{"en-GB"}{"serverportnumbertoolong"}     = "The database server port number given is too long.";
106         $kiriwrite_lang{"en-GB"}{"serverportnumberinvalidcharacters"}   = "The database server port number given contains invalid characters.";
107         $kiriwrite_lang{"en-GB"}{"serverportnumberinvalid"}     = "The database server port number given is invalid.";
108         $kiriwrite_lang{"en-GB"}{"serverprotocolnametoolong"}   = "The database server protocol name given is too long.";
109         $kiriwrite_lang{"en-GB"}{"serverprotocolinvalid"}               = "The database server protocol name is invalid.";
110         $kiriwrite_lang{"en-GB"}{"serverdatabasenametoolong"}   = "The database name given is too long.";
111         $kiriwrite_lang{"en-GB"}{"serverdatabasenameinvalid"}   = "The database name given is invalid.";
112         $kiriwrite_lang{"en-GB"}{"serverdatabaseusernametoolong"}       = "The database server username given is too long.";
113         $kiriwrite_lang{"en-GB"}{"serverdatabaseusernameinvalid"}       = "The database server username given is invalid.";
114         $kiriwrite_lang{"en-GB"}{"serverdatabasepasswordtoolong"}       = "The database server password is too long.";
115         $kiriwrite_lang{"en-GB"}{"serverdatabasetableprefixtoolong"}    = "The database server table prefix given is too long.";
116         $kiriwrite_lang{"en-GB"}{"serverdatabasetableprefixinvalid"}    = "The database server table prefix given is invalid.";
117  
118         $kiriwrite_lang{"en-GB"}{"removeinstallscripttoolong"}  = "The remove install script value given is too long.";
119         $kiriwrite_lang{"en-GB"}{"cannotwriteconfigurationindirectory"} = "The configuration file cannot be written because the directory the install script is running from has invalid permissions.";
120         $kiriwrite_lang{"en-GB"}{"configurationfilereadpermissionsinvalid"}     = "The configuration that currently exists has invalid read permissions set.";
121         $kiriwrite_lang{"en-GB"}{"configurationfilewritepermissionsinvalid"}    = "The configuration that currently exists has invalid write permissions set.";
123         $kiriwrite_lang{"en-GB"}{"errormessagetext"}    = "Please press the back button on your browser or preform the command needed to return to the previous page.";
125         $kiriwrite_lang{"en-GB"}{"switch"}              = "Switch";
126         $kiriwrite_lang{"en-GB"}{"setting"}             = "Setting";
127         $kiriwrite_lang{"en-GB"}{"value"}               = "Value";
128         $kiriwrite_lang{"en-GB"}{"filename"}            = "Filename";
129         $kiriwrite_lang{"en-GB"}{"module"}              = "Module";
130         $kiriwrite_lang{"en-GB"}{"result"}              = "Result";
131         $kiriwrite_lang{"en-GB"}{"error"}               = "Error!";
132         $kiriwrite_lang{"en-GB"}{"criticalerror"}       = "Critical Error!";
133         $kiriwrite_lang{"en-GB"}{"errormessage"}        = "Error: ";
134         $kiriwrite_lang{"en-GB"}{"warningmessage"}      = "Warning: ";
136         $kiriwrite_lang{"en-GB"}{"doesnotexist"}        = "Does not exist.";
137         $kiriwrite_lang{"en-GB"}{"invalidpermissionsset"}       = "Invalid permissions set.";
139         $kiriwrite_lang{"en-GB"}{"dependencyperlmodulesmissing"}        = "One or more Perl modules that are needed by Kiriwrite are not installed or has problems. See the Kiriwrite documentation for more information on this.";
140         $kiriwrite_lang{"en-GB"}{"databaseperlmodulesmissing"}  = "One or more Perl modules that are needed by the Kiriwrite database modules are not installed or has problems. See the Kiriwrite documentation for more information on this. There should however, be no problems with the database modules which use the Perl modules that have been found.";
141         $kiriwrite_lang{"en-GB"}{"filepermissionsinvalid"}      = "One or more of the filenames checked does not exist or has invalid permissions set. See the Kiriwrite documentation for more information on this.";
142         $kiriwrite_lang{"en-GB"}{"dependencymodulesnotinstalled"}       = "One of the required Perl modules is not installed or has errors. See the Kiriwrite documentation for more information on this.";
143         $kiriwrite_lang{"en-GB"}{"databasemodulesnotinstalled"} = "None of Perl modules that are used by the database modules are not installed. See the Kiriwrite documentation for more information on this.";
144         $kiriwrite_lang{"en-GB"}{"filepermissionerrors"}        = "One or more filenames checked has errors. See the Kiriwrite documentation for more information on this.",
146         $kiriwrite_lang{"en-GB"}{"installertitle"}      = "Kiriwrite Installer";
147         $kiriwrite_lang{"en-GB"}{"installertext"}       = "This installer script will setup the configuration file used for Kiriwrite. The settings displayed here can be changed at a later date by selecting the Edit Settings link in the View Settings sub-menu.";
148         $kiriwrite_lang{"en-GB"}{"dependencytitle"}     = "Dependency and file testing results";
149         $kiriwrite_lang{"en-GB"}{"requiredmodules"}     = "Required Modules";
150         $kiriwrite_lang{"en-GB"}{"perlmodules"}         = "These Perl modules are used internally by Kiriwrite.";
151         $kiriwrite_lang{"en-GB"}{"databasemodules"}     = "Perl Database Modules";
152         $kiriwrite_lang{"en-GB"}{"databasemodulestext"} = "These Perl modules are used by the database modules.";
153         $kiriwrite_lang{"en-GB"}{"filepermissions"}     = "File permissions";
154         $kiriwrite_lang{"en-GB"}{"filepermissionstext"} = "The file permissions are for file and directories that are critical to Kiriwrite such as module and language directories.";
155         
156         $kiriwrite_lang{"en-GB"}{"settingstitle"}       = "Kiriwrite Settings";
157         $kiriwrite_lang{"en-GB"}{"settingstext"}        = "The settings given here will be used by Kiriwrite. Some default settings are given here. Certain database modules (like SQLite) do not need the database server settings and can be left alone.";
158         $kiriwrite_lang{"en-GB"}{"directories"}         = "Directories";
159         $kiriwrite_lang{"en-GB"}{"databasedirectory"}   = "Database Directory";
160         $kiriwrite_lang{"en-GB"}{"outputdirectory"}     = "Output Directory";
161         $kiriwrite_lang{"en-GB"}{"imagesuripath"}       = "Images (URI path)";
162         $kiriwrite_lang{"en-GB"}{"display"}             = "Display";
163         $kiriwrite_lang{"en-GB"}{"textareacols"}        = "Text Area Columns";
164         $kiriwrite_lang{"en-GB"}{"textarearows"}        = "Text Area Rows";
165         $kiriwrite_lang{"en-GB"}{"date"}                = "Date";
166         $kiriwrite_lang{"en-GB"}{"dateformat"}          = "Date Format";
167         $kiriwrite_lang{"en-GB"}{"language"}            = "Language";
168         $kiriwrite_lang{"en-GB"}{"systemlanguage"}      = "System Language";
169         $kiriwrite_lang{"en-GB"}{"modules"}             = "Modules";
170         $kiriwrite_lang{"en-GB"}{"presentationmodule"}  = "Presentation Module";
171         $kiriwrite_lang{"en-GB"}{"databasemodule"}      = "Database Module";
172         $kiriwrite_lang{"en-GB"}{"databaseserver"}      = "Database Server";
173         $kiriwrite_lang{"en-GB"}{"databaseport"}        = "Database Port";
174         $kiriwrite_lang{"en-GB"}{"databaseprotocol"}    = "Database Protocol";
175         $kiriwrite_lang{"en-GB"}{"databasename"}        = "Database Name";
176         $kiriwrite_lang{"en-GB"}{"databaseusername"}    = "Database Username";
177         $kiriwrite_lang{"en-GB"}{"databasepassword"}    = "Database Password";
178         $kiriwrite_lang{"en-GB"}{"databasetableprefix"} = "Database Table Prefix";
179         $kiriwrite_lang{"en-GB"}{"installationoptions"} = "Installation Options";
180         $kiriwrite_lang{"en-GB"}{"installoptions"}      = "Install Options";
181         $kiriwrite_lang{"en-GB"}{"removeinstallscript"} = "Delete this installer script after configuration file has been written.";
182         $kiriwrite_lang{"en-GB"}{"savesettingsbutton"}  = "Save Settings";
183         $kiriwrite_lang{"en-GB"}{"resetsettingsbutton"} = "Reset Settings";
185         $kiriwrite_lang{"en-GB"}{"installscriptremoved"}        = "The installer script was removed.";
186         $kiriwrite_lang{"en-GB"}{"installedmessage"}    = "The configuration file for Kiriwrite has been written. To change the settings in the configuration file at a later date use the Edit Settings link in the View Settings sub-menu at the top of the page when using Kiriwrite.";
187         $kiriwrite_lang{"en-GB"}{"cannotremovescript"}  = "Unable to remove the installer script: %s. The installer script will have to be deleted manually.";
188         $kiriwrite_lang{"en-GB"}{"usekiriwritetext"}    = "To use Kiriwrite click or select the link below (will not work if the Kiriwrite script is not called kiriwrite.cgi):";
189         $kiriwrite_lang{"en-GB"}{"usekiriwritelink"}    = "Start using Kiriwrite.";
191 my $query_lite = new CGI::Lite;
192 my $form_data = $query_lite->parse_form_data;
194 my $language_selected = "";
195 my $http_query_confirm = $form_data->{'confirm'};
196 my $http_query_installlanguage = $form_data->{'installlanguage'};
198 if (!$http_query_installlanguage){
200         $language_selected = $default_language;
202 } else {
204         $language_selected = $http_query_installlanguage;
208 # Process the list of available languages.
210 my $language_list_name;
211 my @language_list_short;
212 my @language_list_long;
214 foreach my $language (keys %kiriwrite_lang){
216         $language_list_name = $kiriwrite_lang{$language}{"languagename"} . " (" . $language .  ")";
217         push(@language_list_short, $language);
218         push(@language_list_long, $language_list_name);
222 # The CSS Stylesheet to use.
224 my $cssstyle = "
226 a {
227         color: #FFFFFF;
230 body {
231         background-color: #408080;
232         color: #FFFFFF;
233         font-family: sans-serif;
234         font-size: 12px;
237 input {
238         font-size: 12px;
239         background-color: #408080;
240         color: #FFFFFF;
241         border-color: #102020;
242         border-style: solid;
243         border-width: 1px;
244         padding: 3px;
248 select {
249         font-size: 12px;
250         padding: 3px;
251         background-color: #408080;
252         color: #FFFFFF;
253         border-color: #102020;
254         border-style: solid;
255         border-width: 1px;
256         padding: 3px;
259 td,table {
260         padding: 5px;
261         border-spacing: 0px;
264 .languagebar {
265         background-color: #204040;
266         vertical-align: top;
269 .languagebarselect {
270         text-align: right;
271         background-color: #204040;
274 .tablecellheader {
275         background-color: #204040;
276         font-weight: bold;
279 .tabledata {
280         background-color: #357070;
283 .tablename {
285         background-color: #306060;
289 ";
292 #################################################################################
293 # Begin list of subroutines.                                                    #
294 #################################################################################
296 sub kiriwrite_variablecheck{
297 #################################################################################
298 # kiriwrite_variablecheck: Check to see if the data passed is valid.            #
299 #                                                                               #
300 # Usage:                                                                        #
301 #                                                                               #
302 # kiriwrite_variablecheck(variablename, type, option, noerror);                 #
303 #                                                                               #
304 # variablename  Specifies the variable to be checked.                           #
305 # type          Specifies what type the variable is.                            #
306 # option        Specifies the maximum/minimum length of the variable            #
307 #               (if minlength/maxlength is used) or if the filename should be   #
308 #               checked to see if it is blank.                                  #
309 # noerror       Specifies if Kiriwrite should return an error or not on         #
310 #               certain values.                                                 #
311 #################################################################################
313         # Get the values that were passed to the subroutine.
315         my ($variable_data, $variable_type, $variable_option, $variable_noerror) = @_;
317         if ($variable_type eq "numbers"){
319                 # Check for numbers and return an error if there is anything else than numebrs.
321                 my $variable_data_validated = $variable_data;   # Copy the variable_data to variable_data_validated.
322                 $variable_data_validated =~ tr/0-9//d;          # Take away all of the numbers and from the variable. 
323                                                                 # If it only contains numbers then it should be blank.
325                 if ($variable_data_validated eq ""){
326                         # The validated variable is blank. So continue to the end of this section where the return function should be.
327                 } else {
328                         # The variable is not blank, so check if the no error value is set
329                         # to 1 or not.
331                         if ($variable_noerror eq 1){
333                                 # The validated variable is not blank and the noerror
334                                 # value is set to 1. So return an value of 1.
335                                 # (meaning that the data is invalid).
337                                 return 1;
339                         } elsif ($variable_noerror eq 0) {
341                                 # The validated variable is not blank and the noerror
342                                 # value is set to 0.
344                                 kiriwrite_error("invalidvariable");
346                         } else {
348                                 # The variable noerror value is something else
349                                 # pther than 1 or 0. So return an error.
351                                 kiriwrite_error("invalidvariable");
353                         }
355                 }
357                 return 0;
359         } elsif ($variable_type eq "lettersnumbers"){
361                 # Check for letters and numbers and return an error if there is anything else other
362                 # than letters and numbers.
364                 my $variable_data_validated = $variable_data;   # Copy the variable_data to variable_data_validated
365                 $variable_data_validated =~ tr/a-zA-Z0-9.//d;
366                 $variable_data_validated =~ s/\s//g;
368                 if ($variable_data_validated eq ""){
369                         # The validated variable is blank. So continue to the end of this section where the return function should be.
370                 } else {
371                         # The variable is not blank, so check if the no error value is set
372                         # to 1 or not.
374                         if ($variable_noerror eq 1){
376                                 # The validated variable is not blank and the noerror
377                                 # value is set to 1. So return an value of 1.
378                                 # (meaning that the data is invalid).
380                                 return 1;
382                         } elsif ($variable_noerror eq 0) {
384                                 # The validated variable is not blank and the noerror
385                                 # value is set to 0.
387                                 kiriwrite_error("invalidvariable");
389                         } else {
391                                 # The variable noerror value is something else
392                                 # pther than 1 or 0. So return an error.
394                                 kiriwrite_error("invalidvariable");
396                         }
398                 }
400                 return 0;
402         } elsif ($variable_type eq "maxlength"){
403                 # Check for the length of the variable, return an error if it is longer than the length specified.
405                 # Check if the variable_data string is blank, if it is then set the variable_data_length
406                 # to '0'.
408                 my $variable_data_length = 0;
410                 if (!$variable_data){
412                         # Set variable_data_length to '0'.
413                         $variable_data_length = 0;
415                 } else {
417                         # Get the length of the variable recieved.
418                         $variable_data_length = length($variable_data);
420                 }
424                 if ($variable_data_length > $variable_option){
426                         # The variable length is longer than it should be so check if
427                         # the no error value is set 1.
429                         if ($variable_noerror eq 1){
431                                 # The no error value is set to 1, so return an
432                                 # value of 1 (meaning tha the variable is
433                                 # too long to be used).
435                                 return 1;
437                         } elsif ($variable_noerror eq 0){
439                                 # The no error value is set to 0, so return
440                                 # an error.
442                                 kiriwrite_error("variabletoolong");
444                         } else {
446                                 # The no error value is something else other
447                                 # than 0 or 1, so return an error.
449                                 kiriwrite_error("variabletoolong");
451                         }
453                 } else {
455                         # The variable length is exactly or shorter than specified, so continue to end of this section where
456                         # the return function should be.
458                 }
460                 return 0;
462         } elsif ($variable_type eq "datetime"){
463                 # Check if the date and time setting format is valid.
465                 if ($variable_data eq ""){
467                         if ($variable_noerror eq 1){
469                                 # The no error value is set to 1 so return
470                                 # a value of 1 (meaning that the date and
471                                 # time format was blank).
473                                 return 1;
475                         } elsif ($variable_noerror eq 0){
477                                 # The no error value is set to 1 so return
478                                 # an error.
480                                 kiriwrite_error("dateformatblank");
482                         } else {
484                                 # The no error value is something else other
485                                 # than 0 or 1, so return an error.
487                                 kiriwrite_error("invalidvariable");
489                         }
491                 }
493                 my $variable_data_validated = $variable_data;
494                 $variable_data_validated =~ tr|dDmMyYhms/():[ ]||d;
496                 if ($variable_data_validated eq ""){
498                         # The date and time format is valid. So
499                         # skip this bit.
501                 } else {
503                         # The validated data variable is not blank, meaning 
504                         # that it contains something else, so return an error
505                         # (or a value).
507                         if ($variable_noerror eq 1){
509                                 # The no error value is set to 1 so return
510                                 # an value of 2. (meaning that the date and
511                                 # time format was invalid).
513                                 return 2;
515                         } elsif ($variable_noerror eq 0){
517                                 # The no error value is set to 0 so return
518                                 # an error.
520                                 kiriwrite_error("dateformatinvalid");
522                         } else {
524                                 # The no error value is something else other
525                                 # than 0 or 1 so return an error.
527                                 kiriwrite_error("invalidvariable");
529                         }
531                 }
533                 return 0;
535         } elsif ($variable_type eq "directory"){
536                 # Check if the directory only contains letters and numbers and
537                 # return an error if anything else appears.
539                 my $variable_data_validated = $variable_data;
540                 $variable_data_validated =~ tr/a-zA-Z0-9//d;
542                 if ($variable_data eq ""){
544                         if ($variable_noerror eq 1){
546                                 # The no error value is set to 1 so return
547                                 # a value of 1 (meaning that the directory
548                                 # name was blank).
550                                 return 1;
552                         } elsif ($variable_noerror eq 0){
554                                 # The no error value is set to 1 so return
555                                 # an error.
557                                 kiriwrite_error("blankdirectory");
559                         } else {
561                                 # The no error value is something else other
562                                 # than 0 or 1, so return an error.
564                                 kiriwrite_error("invalidvariable");
566                         }
568                 }
570                 if ($variable_data_validated eq ""){
572                         # The validated data variable is blank, meaning that
573                         # it only contains letters and numbers.
575                 } else {
577                         # The validated data variable is not blank, meaning 
578                         # that it contains something else, so return an error
579                         # (or a value).
581                         if ($variable_noerror eq 1){
583                                 # The no error value is set to 1 so return
584                                 # an value of 2. (meaning that the directory
585                                 # name is invalid).
587                                 return 2;
589                         } elsif ($variable_noerror eq 0){
591                                 # The no error value is set to 0 so return
592                                 # an error.
594                                 kiriwrite_error("invaliddirectory");
596                         } else {
598                                 # The no error value is something else other
599                                 # than 0 or 1 so return an error.
601                                 kiriwrite_error("invalidvariable");
603                         }
605                 }
607                 return 0;
609         } elsif ($variable_type eq "language_filename"){
611                 # The variable type is a language filename type.
612                 # Check if the language file name is blank and 
613                 # if it is then return an error (or value).
615                 if ($variable_data eq ""){
617                         # The language filename is blank so check the
618                         # no error value and return an error (or value).
620                         if ($variable_noerror eq 1){
622                                 # Language filename is blank and the no error value
623                                 # is set as 1, so return a value of 1 (saying that
624                                 # the language filename is blank).
626                                 return 1;
628                         } elsif ($variable_noerror eq 0) {
630                                 # Language filename is blank and the no error value
631                                 # is not set as 1, so return an error.
633                                 kiriwrite_error("languagefilenameblank");
635                         } else {
637                                 # The noerror value is something else other
638                                 # than 0 or 1 so return an error.
640                                 kiriwrite_error("invalidvariable");
642                         }
644                 }
646                 # Set the following variables for later on.
648                 my $variable_data_length = 0;
649                 my $variable_data_char = "";
650                 my $variable_data_seek = 0;
652                 # Get the length of the language file name.
654                 $variable_data_length = length($variable_data);
656                 do {
658                         # Get a character from the language filename passed to this 
659                         # subroutine and the character the seek counter value is set
660                         # to.
662                         $variable_data_char = substr($variable_data, $variable_data_seek, 1);
664                         # Check if the language filename contains a forward slash or a dot, 
665                         # if the selected character is a forward slash then return an error
666                         # (or value).
668                         if ($variable_data_char eq "/" || $variable_data_char eq "."){
670                                 # The language filename contains a forward slash or
671                                 # a dot so depending on the no error value, return
672                                 # an error or a value.
674                                 if ($variable_noerror eq 1){
676                                         # Language filename contains a forward slash or a dot
677                                         # and the no error value has been set to 1, so return 
678                                         # an value of 2 (saying that the language file name is 
679                                         # invalid).
681                                         return 2;
683                                 } elsif ($variable_noerror eq 0) {
685                                         # Language filename contains a forward slash and the no
686                                         # error value has not been set to 1, so return an error.
688                                         kiriwrite_error("languagefilenameinvalid");
690                                 } else {
692                                         # The noerror value is something else other than
693                                         # 1 or 0 so return an error.
695                                         kiriwrite_error("invalidvariable");
697                                 }
699                         }
701                         # Increment the seek counter.
703                         $variable_data_seek++;
705                 } until ($variable_data_seek eq $variable_data_length);
707                 return 0;
709         } elsif ($variable_type eq "module"){
711                 # The variable type is a presentation module filename.
713                 # Check if the variable_data is blank and if it is
714                 # return an error.
716                 if ($variable_data eq ""){
718                         # The presentation module is blank so check if an error
719                         # value should be returned or a number should be
720                         # returned.
722                         if ($variable_noerror eq 1){
724                                 # Module name is blank and the no error value 
725                                 # is set to 1 so return a value of 2 (meaning 
726                                 # that the page filename is blank).
728                                 return 1;
730                         } elsif ($variable_noerror eq 0) {
732                                 # Module name contains is blank and the no error 
733                                 # value is set to 0 so return an error.
735                                 kiriwrite_critical("moduleblank");
737                         } else {
739                                 # The no error value is something else other
740                                 # than 0 or 1 so return an error.
742                                 kiriwrite_critical("invalidvalue");
744                         }
746                 } else {
748                 }
750                 my $variable_data_validated = $variable_data;
751                 $variable_data_validated =~ tr/a-zA-Z0-9//d;
753                 if ($variable_data_validated eq ""){
755                 } else {
757                         if ($variable_noerror eq 1){
759                                 # Module name contains invalid characters and
760                                 # the no error value is set to 1 so return a 
761                                 # value of 2 (meaning that the page filename
762                                 # is invalid).
764                                 return 2;
766                         } elsif ($variable_noerror eq 0) {
768                                 # Module name contains invalid characters and
769                                 # the no error value is set to 0 so return an
770                                 # error.
772                                 kiriwrite_critical("moduleinvalid");
774                         } else {
776                                 # The no error value is something else other
777                                 # than 0 or 1 so return an error.
779                                 kiriwrite_error("invalidvalue");
781                         }
783                 }
785                 return 0;
787         } elsif ($variable_type eq "serverprotocol"){
789                 # Check if the server protocol is TCP or UDP and return
790                 # an error if it isn't.
792                 if ($variable_data ne "tcp" && $variable_data ne "udp"){
794                         # The protocol given is not valid, check if the no
795                         # error value is set to 1 and return an error if it isn't.
797                         if ($variable_noerror eq 1){
799                                 # The no error value has been set to 1, so return a
800                                 # value of 1 (meaning that the server protocol is
801                                 # invalid).
803                                 return 1;
805                         } elsif ($variable_noerror eq 0){
807                                 # The no error value has been set to 0, so return
808                                 # an error.
810                                 kiriwrite_error("serverprotocolinvalid");
812                         } else {
814                                 # The no error value is something else other than 0
815                                 # or 1, so return an error.
817                                 kiriwrite_error("invalidoption");
819                         }
821                 }
823                 return 0;
825         } elsif ($variable_type eq "port"){
827                 # Check if the port number given is less than 0 or more than 65535
828                 # and return an error if it is.
830                 if ($variable_data < 0 || $variable_data > 65535){
832                         # The port number is less than 0 and more than 65535 so
833                         # check if the no error value is set to 1 and return an
834                         # error if it isn't.
836                         if ($variable_noerror eq 1){
838                                 # The no error value has been set to 1, so return a
839                                 # value of 1 (meaning that the port number is invalid).
841                                 return 1;
843                         } elsif ($variable_noerror eq 0){
845                                 # The no error value has been set to 0, so return
846                                 # an error.
848                                 kiriwrite_error("serverportnumberinvalid");
850                         } else {
852                                 # The no error value is something else other than 0
853                                 # or 1, so return an error.
855                                 kiriwrite_error("invalidoption");
857                         }
859                 }
861                 return 0;
863         }
865         # Another type than the valid ones above has been specified so return an error specifying an invalid option.
866         kiriwrite_error("invalidoption");
870 sub kiriwrite_error{
871 #################################################################################
872 # kiriwrite_error: Subroutine for processing error messages.                    #
873 #                                                                               #
874 # Usage:                                                                        #
875 #                                                                               #
876 # kiriwrite_error(errortype);                                                   #
877 #                                                                               #
878 # errortype     Specifies the error type to use.                                #
879 #################################################################################
881         my $error_type = shift;
883         # Load the list of error messages.
885         my (%kiriwrite_error, $kiriwrite_error);
887         %kiriwrite_error = (
889                 # Generic Error Messages
891                 "generic"                       => $kiriwrite_lang{$language_selected}{generic},
893                 "invalidvariable"               => $kiriwrite_lang{$language_selected}{invalidvariable},
894                 "invalidvalue"                  => $kiriwrite_lang{$language_selected}{invalidvalue},
895                 "invalidoption"                 => $kiriwrite_lang{$language_selected}{invalidoption},
896                 "variabletoolong"               => $kiriwrite_lang{$language_selected}{variabletoolong},
897                 "blankdirectory"                => $kiriwrite_lang{$language_selected}{blankdirectory},
898                 "invaliddirectory"              => $kiriwrite_lang{$language_selected}{invaliddirectory},
899                 "moduleblank"                   => $kiriwrite_lang{$language_selected}{moduleblank},
900                 "moduleinvalid"                 => $kiriwrite_lang{$language_selected}{moduleinvalid},
902                 # Specific Error Messages
904                 "dbdirectorytoolong"            => $kiriwrite_lang{$language_selected}{dbdirectorytoolong},
905                 "outputdirectorytoolong"        => $kiriwrite_lang{$language_selected}{outputdirectorytoolong},
906                 "imagesuripathtoolong"          => $kiriwrite_lang{$language_selected}{imagesuripathtoolong},
907                 "dateformattoolong"             => $kiriwrite_lang{$language_selected}{dateformattoolong},
908                 "customdateformattoolong"       => $kiriwrite_lang{$language_selected}{customdateformattoolong},
909                 "languagefilenametoolong"       => $kiriwrite_lang{$language_selected}{languagefilenametoolong},
910                 
911                 "dateformatblank"               => $kiriwrite_lang{$language_selected}{dateformatblank},
912                 "dateformatinvalid"             => $kiriwrite_lang{$language_selected}{dateformatinvalid},
913                 "languagefilenameinvalid"       => $kiriwrite_lang{$language_selected}{languagefilenameinvalid},
914                 
915                 "dbdirectoryblank"              => $kiriwrite_lang{$language_selected}{dbdirectoryblank},
916                 "dbdirectoryinvalid"            => $kiriwrite_lang{$language_selected}{dbdirectoryinvalid},
918                 "textarearowblank"              => $kiriwrite_lang{$language_selected}{textarearowblank},
919                 "textarearowtoolong"            => $kiriwrite_lang{$language_selected}{textarearowtoolong},
920                 "textarearowinvalid"            => $kiriwrite_lang{$language_selected}{textarearowinvalid},
922                 "textareacolsblank"             => $kiriwrite_lang{$language_selected}{textareacolsblank},
923                 "textareacolstoolong"           => $kiriwrite_lang{$language_selected}{textareacolstoolong},
924                 "textareacolsinvalid"           => $kiriwrite_lang{$language_selected}{textareacolsinvalid},
926                 "outputdirectoryblank"          => $kiriwrite_lang{$language_selected}{outputdirectoryblank},
927                 "outputdirectoryinvalid"        => $kiriwrite_lang{$language_selected}{outputdirectoryinvalid},
929                 "presmoduleblank"               => $kiriwrite_lang{$language_selected}{presmoduleblank},
930                 "presmoduleinvalid"             => $kiriwrite_lang{$language_selected}{presmoduleinvalid},
932                 "dbmoduleblank"                 => $kiriwrite_lang{$language_selected}{dbmoduleblank},
933                 "dbmoduleinvalid"               => $kiriwrite_lang{$language_selected}{dbmoduleinvalid},
935                 "presmodulemissing"             => $kiriwrite_lang{$language_selected}{presmodulemissing},
936                 "dbmodulemissing"               => $kiriwrite_lang{$language_selected}{dbmodulemissing},
937                 "languagefilenamemissing"       => $kiriwrite_lang{$language_selected}{languagefilenamemissing},
939                 "servernametoolong"             => $kiriwrite_lang{$language_selected}{servernametoolong},
940                 "servernameinvalid"             => $kiriwrite_lang{$language_selected}{servernameinvalid},
941                 "serverportnumbertoolong"       => $kiriwrite_lang{$language_selected}{serverportnumbertoolong},
942                 "serverportnumberinvalidcharacters"     => $kiriwrite_lang{$language_selected}{serverportnumberinvalidcharacters},
943                 "serverportnumberinvalid"       => $kiriwrite_lang{$language_selected}{serverportnumberinvalid},
944                 "serverprotocolnametoolong"     => $kiriwrite_lang{$language_selected}{serverprotocolnametoolong},
945                 "serverprotocolinvalid"         => $kiriwrite_lang{$language_selected}{serverprotocolinvalid},
946                 "serverdatabasenametoolong"     => $kiriwrite_lang{$language_selected}{serverdatabasenametoolong},
947                 "serverdatabasenameinvalid"     => $kiriwrite_lang{$language_selected}{serverdatabasenameinvalid},
948                 "serverdatabaseusernametoolong" => $kiriwrite_lang{$language_selected}{serverdatabaseusernametoolong},
949                 "serverdatabaseusernameinvalid" => $kiriwrite_lang{$language_selected}{serverdatabaseusernameinvalid},
950                 "serverdatabasepasswordtoolong" => $kiriwrite_lang{$language_selected}{serverdatabasepasswordtoolong},
951                 "serverdatabasetableprefixtoolong"      => $kiriwrite_lang{$language_selected}{serverdatabasetableprefixtoolong},
952                 "serverdatabasetableprefixinvalid"      => $kiriwrite_lang{$language_selected}{serverdatabasetableprefixinvalid},
954                 "removeinstallscripttoolong"    => $kiriwrite_lang{$language_selected}{removeinstallscripttoolong},
955                 "cannotwriteconfigurationindirectory"   => $kiriwrite_lang{$language_selected}{cannotwriteconfigurationindirectory},
956                 "configurationfilereadpermissionsinvalid"       => $kiriwrite_lang{$language_selected}{configurationfilereadpermissionsinvalid},
957                 "configurationfilewritepermissionsinvalid"      => $kiriwrite_lang{$language_selected}{configurationfilewritepermissionsinvalid},
959         );
961         # Check if the specified error is blank and if it is
962         # use the generic error messsage.
964         if (!$kiriwrite_error{$error_type}){
965                 $error_type = "generic";
966         }
968         print "Content-type: text/html;\r\n\r\n";
970         print "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
971         print "<head>\n<title>$kiriwrite_lang{$language_selected}{installertitle}</title>\n<style type=\"text/css\" media=\"screen\">$cssstyle</style>\n</head>\n<body>\n";
973         print "<h2>$kiriwrite_lang{$language_selected}{error}</h2>";
975         print $kiriwrite_error{$error_type};
976         print "<br />\n";
977         print $kiriwrite_lang{$language_selected}{errormessagetext};
979         print "</body>\n</html>";
981         exit;
985 sub kiriwrite_writeconfig{
986 #################################################################################
987 # kiriwrite_writeconfig: Writes a configuration file.                           #
988 #                                                                               #
989 # Usage:                                                                        #
990 #                                                                               #
991 # kiriwrite_writeconfig();                                                      #
992 #################################################################################
994         my ($passedsettings) = @_;
996         # Open the configuration file for writing.
998         open (my $configfile, "> " . "kiriwrite.cfg");
1000         print $configfile "[config]
1001                 directory_data_db = $passedsettings->{DatabaseDirectory}
1002                 directory_data_output = $passedsettings->{OutputDirectory}
1003                 directory_noncgi_images = $passedsettings->{ImagesURIPath}
1004                 
1005                 system_language = $passedsettings->{Language}
1006                 system_presmodule = $passedsettings->{PresentationModule}
1007                 system_dbmodule = $passedsettings->{DatabaseModule}
1008                 system_datetime = $passedsettings->{DateFormat}
1009                 
1010                 display_textareacols = $passedsettings->{TextAreaCols}
1011                 display_textarearows = $passedsettings->{TextAreaRows}
1012                 display_pagecount = 50
1013                 display_filtercount = 50
1014                 display_templatecount = 50
1015                 
1016                 database_server = $passedsettings->{DatabaseServer}
1017                 database_port = $passedsettings->{DatabasePort}
1018                 database_protocol = $passedsettings->{DatabaseProtocol}
1019                 database_sqldatabase = $passedsettings->{DatabaseName}
1020                 database_username = $passedsettings->{DatabaseUsername}
1021                 database_password = $passedsettings->{DatabasePassword}
1022                 database_tableprefix = $passedsettings->{DatabaseTablePrefix}
1023         ";
1025         close ($configfile);
1029 sub kiriwrite_addtablerow{
1030 #################################################################################
1031 # kiriwrite_addtablerow: Adds a table row.                                      #
1032 #                                                                               #
1033 # Usage:                                                                        #
1034 #                                                                               #
1035 # kiriwrite_addtablerow(name, data);                                            #
1036 #                                                                               #
1037 # name          Specifies the name of the table row.                            #
1038 # namestyle     Specifies the style for the name of the table row.              #
1039 # data          Specifies the data to be used in the table row.                 #
1040 # datastyle     Specifies the style for the data of the table row.              #
1041 #################################################################################
1043         my ($name, $namestyle, $data, $datastyle) = @_;
1045         if (!$data){
1047                 $data = "";
1049         }
1051         print "<tr>\n";
1052         print "<td class=\"$namestyle\">$name</td>\n";
1053         print "<td class=\"$datastyle\">$data</td>\n";
1054         print "</tr>\n";
1058 #################################################################################
1059 # End list of subroutines.                                                      #
1060 #################################################################################
1062 if (!$http_query_confirm){
1064         $http_query_confirm = 0;
1068 if ($http_query_confirm eq 1){
1070         # The confirm value has been given so get the data from the query.
1072         my $http_query_dbdirectory              = $form_data->{'dbdirectory'};
1073         my $http_query_outputdirectory          = $form_data->{'outputdirectory'};
1074         my $http_query_imagesuripath            = $form_data->{'imagesuripath'};
1076         my $http_query_textarearows             = $form_data->{'textarearows'};
1077         my $http_query_textareacols             = $form_data->{'textareacols'};
1079         my $http_query_dateformat               = $form_data->{'dateformat'};
1080         my $http_query_customdateformat         = $form_data->{'customdateformat'};
1082         my $http_query_language                 = $form_data->{'language'};
1084         my $http_query_presmodule               = $form_data->{'presmodule'};
1085         my $http_query_dbmodule                 = $form_data->{'dbmodule'};
1087         my $http_query_databaseserver           = $form_data->{'databaseserver'};
1088         my $http_query_databaseport             = $form_data->{'databaseport'};
1089         my $http_query_databaseprotocol         = $form_data->{'databaseprotocol'};
1090         my $http_query_databasename             = $form_data->{'databasename'};
1091         my $http_query_databaseusername         = $form_data->{'databaseusername'};
1092         my $http_query_databasepassword         = $form_data->{'databasepassword'};
1093         my $http_query_databasetableprefix      = $form_data->{'databasetableprefix'};
1094         my $http_query_removeinstallscript      = $form_data->{'removeinstallscript'};
1096         # Check if the text area rows and column values are blank.
1098         if (!$http_query_textarearows){
1100                 # The text area rows value is blank so return
1101                 # an error.
1103                 kiriwrite_error("textarearowblank");
1105         }
1107         if (!$http_query_textareacols){
1109                 # The text area columns value is blank so
1110                 # return an error.
1112                 kiriwrite_error("textareacolsblank");
1114         }
1116         # Check the length of the variables.
1118         my $kiriwrite_dbdirectory_length_check          = kiriwrite_variablecheck($http_query_dbdirectory, "maxlength", 64, 1);
1119         my $kiriwrite_outputdirectory_length_check      = kiriwrite_variablecheck($http_query_outputdirectory, "maxlength", 64, 1);
1120         my $kiriwrite_imagesuripath_length_check        = kiriwrite_variablecheck($http_query_imagesuripath, "maxlength", 512, 1);
1121         my $kiriwrite_textarearow_length_check          = kiriwrite_variablecheck($http_query_textarearows, "maxlength", 3, 1);
1122         my $kiriwrite_textareacols_length_check         = kiriwrite_variablecheck($http_query_textareacols, "maxlength", 3, 1);
1123         my $kiriwrite_dateformat_length_check           = kiriwrite_variablecheck($http_query_dateformat, "maxlength", 32, 1);
1124         my $kiriwrite_customdateformat_length_check     = kiriwrite_variablecheck($http_query_customdateformat, "maxlength", 32, 1);
1125         my $kiriwrite_language_length_check             = kiriwrite_variablecheck($http_query_language, "maxlength", 16, 1);
1127         # Check if any errors occured while checking the
1128         # length of the variables.
1130         if ($kiriwrite_dbdirectory_length_check eq 1){
1132                 # The database directory given is too long
1133                 # so return an error.
1135                 kiriwrite_error("dbdirectorytoolong");
1137         }
1139         if ($kiriwrite_outputdirectory_length_check eq 1){
1141                 # The output directory given is too long
1142                 # so return an error.
1144                 kiriwrite_error("outputdirectorytoolong");
1146         }
1148         if ($kiriwrite_imagesuripath_length_check eq 1){
1150                 # The images URI path given is too long
1151                 # so return an error.
1153                 kiriwrite_error("imagesuripathtoolong");
1155         }
1157         if ($kiriwrite_dateformat_length_check eq 1){
1159                 # The date format given is too long
1160                 # so return an error.
1162                 kiriwrite_error("dateformattoolong");
1164         }
1166         if ($kiriwrite_customdateformat_length_check eq 1){
1168                 # The date format given is too long
1169                 # so return an error.
1171                 kiriwrite_error("customdateformattoolong");
1173         }
1175         if ($kiriwrite_language_length_check eq 1){
1177                 # The language filename given is too long
1178                 # so return an error.
1180                 kiriwrite_error("languagefilenametoolong");
1182         }
1184         if ($kiriwrite_textarearow_length_check eq 1){
1186                 # The text area rows length is too long
1187                 # so return an error.
1189                 kiriwrite_error("textarearowtoolong");
1191         }
1193         if ($kiriwrite_textareacols_length_check eq 1){
1195                 # The text area columns length is too long
1196                 # so return an error.
1198                 kiriwrite_error("textareacolstoolong");
1200         }
1202         # Check if the custom date and time setting has anything
1203         # set and if it doesn't then use the predefined one set.
1205         my $finaldateformat = "";
1207         if ($http_query_customdateformat ne ""){
1209                 $finaldateformat = $http_query_customdateformat;
1211         } else {
1213                 $finaldateformat = $http_query_dateformat;
1215         }
1217         my $kiriwrite_datetime_check            = kiriwrite_variablecheck($finaldateformat, "datetime", 0, 1);
1219         if ($kiriwrite_datetime_check eq 1){
1221                 # The date and time format is blank so return
1222                 # an error.
1224                 kiriwrite_error("dateformatblank");
1226         } elsif ($kiriwrite_datetime_check eq 2){
1228                 # The date and time format is invalid so
1229                 # return an error.
1231                 kiriwrite_error("dateformatinvalid");
1233         }
1235         # Check if the language filename given is valid.
1237         my $kiriwrite_language_languagefilename_check = kiriwrite_variablecheck($http_query_language, "language_filename", "", 1);
1239         if ($kiriwrite_language_languagefilename_check eq 1) {
1241                 # The language filename given is blank so
1242                 # return an error.
1244                 kiriwrite_error("languagefilenameblank");
1246         } elsif ($kiriwrite_language_languagefilename_check eq 2){
1248                 # The language filename given is invalid so
1249                 # return an error.
1251                 kiriwrite_error("languagefilenameinvalid");
1253         }
1255         # Check if the directory names only contain letters and numbers and
1256         # return a specific error if they don't.
1258         my $kiriwrite_dbdirectory_check         = kiriwrite_variablecheck($http_query_dbdirectory, "directory", 0, 1);
1259         my $kiriwrite_outputdirectory_check     = kiriwrite_variablecheck($http_query_outputdirectory, "directory", 0, 1);
1261         if ($kiriwrite_dbdirectory_check eq 1){
1263                 # The database directory name is blank, so return
1264                 # an error.
1266                 kiriwrite_error("dbdirectoryblank");
1268         } elsif ($kiriwrite_dbdirectory_check eq 2){
1270                 # The database directory name is invalid, so return
1271                 # an error.
1273                 kiriwrite_error("dbdirectoryinvalid");
1275         }
1277         if ($kiriwrite_outputdirectory_check eq 1){
1279                 # The output directory name is blank, so return
1280                 # an error.
1282                 kiriwrite_error("outputdirectoryblank");
1284         } elsif ($kiriwrite_outputdirectory_check eq 2){
1286                 # The output directory name is invalid, so return
1287                 # an error.
1289                 kiriwrite_error("outputdirectoryinvalid");
1291         }
1293         if ($kiriwrite_dbdirectory_check eq 1){
1295                 # The database directory name is blank, so return
1296                 # an error.
1298                 kiriwrite_error("dbdirectoryblank");
1300         } elsif ($kiriwrite_dbdirectory_check eq 2){
1302                 # The database directory name is invalid, so return
1303                 # an error.
1305                 kiriwrite_error("dbdirectoryinvalid");
1307         }
1309         if ($kiriwrite_outputdirectory_check eq 1){
1311                 # The output directory name is blank, so return
1312                 # an error.
1314                 kiriwrite_error("outputdirectoryblank");
1316         } elsif ($kiriwrite_outputdirectory_check eq 2){
1318                 # The output directory name is invalid, so return
1319                 # an error.
1321                 kiriwrite_error("outputdirectoryinvalid");
1323         }
1325         # Check to see if the text area rows and column values
1326         # are valid.
1328         my $kiriwrite_textarearow_number_check          = kiriwrite_variablecheck($http_query_textarearows, "numbers", 0, 1);
1329         my $kiriwrite_textareacols_number_check         = kiriwrite_variablecheck($http_query_textareacols, "numbers", 0, 1);
1331         if ($kiriwrite_textarearow_number_check eq 1){
1333                 # The text area row value is invalid so return
1334                 # an error.
1336                 kiriwrite_error("textarearowinvalid");
1338         }
1340         if ($kiriwrite_textareacols_number_check eq 1){
1342                 # The text area columns value is invalid so return
1343                 # an error.
1345                 kiriwrite_error("textareacolsinvalid");
1347         }
1349         # Check the module names to see if they're valid.
1351         my $kiriwrite_presmodule_modulename_check       = kiriwrite_variablecheck($http_query_presmodule, "module", 0, 1);
1352         my $kiriwrite_dbmodule_modulename_check         = kiriwrite_variablecheck($http_query_dbmodule, "module", 0, 1);
1354         if ($kiriwrite_presmodule_modulename_check eq 1){
1356                 # The presentation module name is blank, so return
1357                 # an error.
1359                 kiriwrite_error("presmoduleblank");
1361         }
1363         if ($kiriwrite_presmodule_modulename_check eq 2){
1365                 # The presentation module name is invalid, so return
1366                 # an error.
1368                 kiriwrite_error("presmoduleinvalid");
1370         }
1372         if ($kiriwrite_dbmodule_modulename_check eq 1){
1374                 # The database module name is blank, so return
1375                 # an error.
1377                 kiriwrite_error("dbmoduleblank");
1379         }
1381         if ($kiriwrite_dbmodule_modulename_check eq 2){
1383                 # The database module name is invalid, so return
1384                 # an error.
1386                 kiriwrite_error("dbmoduleinvalid");
1388         }
1390         # Check if the database module, presentation module and
1391         # language file exists.
1393         if (!-e "Modules/Presentation/" . $http_query_presmodule . ".pm"){
1395                 # The presentation module is missing so return an
1396                 # error.
1398                 kiriwrite_error("presmodulemissing");
1400         }
1402         if (!-e "Modules/Database/" . $http_query_dbmodule . ".pm"){
1404                 # The database module is missing so return an
1405                 # error.
1407                 kiriwrite_error("dbmodulemissing");
1409         }
1411         if (!-e "lang/" . $http_query_language . ".lang"){
1413                 # The language file is missing so return an
1414                 # error.
1416                 kiriwrite_error("languagefilenamemissing");
1418         }
1420         # Check the database server settings.
1422         my $kiriwrite_databaseserver_length_check               = kiriwrite_variablecheck($http_query_databaseserver, "maxlength", 128, 1);
1423         my $kiriwrite_databaseserver_lettersnumbers_check       = kiriwrite_variablecheck($http_query_databaseserver, "lettersnumbers", 0, 1);
1424         my $kiriwrite_databaseport_length_check                 = kiriwrite_variablecheck($http_query_databaseport, "maxlength", 5, 1);
1425         my $kiriwrite_databaseport_numbers_check                = kiriwrite_variablecheck($http_query_databaseport, "numbers", 0, 1);
1426         my $kiriwrite_databaseport_port_check                   = kiriwrite_variablecheck($http_query_databaseport, "port", 0, 1);
1427         my $kiriwrite_databaseprotocol_length_check             = kiriwrite_variablecheck($http_query_databaseprotocol, "maxlength", 5, 1);
1428         my $kiriwrite_databaseprotocol_protocol_check           = kiriwrite_variablecheck($http_query_databaseprotocol, "serverprotocol", 0, 1);
1429         my $kiriwrite_databasename_length_check                 = kiriwrite_variablecheck($http_query_databasename, "maxlength", 32, 1);
1430         my $kiriwrite_databasename_lettersnumbers_check         = kiriwrite_variablecheck($http_query_databasename, "lettersnumbers", 0, 1);
1431         my $kiriwrite_databaseusername_length_check             = kiriwrite_variablecheck($http_query_databaseusername, "maxlength", 16, 1);
1432         my $kiriwrite_databaseusername_lettersnumbers_check     = kiriwrite_variablecheck($http_query_databaseusername, "lettersnumbers", 0, 1);
1433         my $kiriwrite_databasepassword_length_check             = kiriwrite_variablecheck($http_query_databasepassword, "maxlength", 64, 1);
1434         my $kiriwrite_databasetableprefix_length_check          = kiriwrite_variablecheck($http_query_databasetableprefix, "maxlength", 16, 1);
1435         my $kiriwrite_databasetableprefix_lettersnumbers_check  = kiriwrite_variablecheck($http_query_databasetableprefix, "lettersnumbers", 0, 1);
1437         if ($kiriwrite_databaseserver_length_check eq 1){
1439                 # The length of the database server name is too long so
1440                 # return an error.
1442                 kiriwrite_error("servernametoolong");
1444         }
1446         if ($kiriwrite_databaseserver_lettersnumbers_check eq 1){
1448                 # The database server name contains characters other
1449                 # than letters and numbers, so return an error.
1451                 kiriwrite_error("servernameinvalid");
1453         }
1455         if ($kiriwrite_databaseport_length_check eq 1){
1457                 # The database port number length is too long so return
1458                 # an error.
1460                 kiriwrite_error("serverportnumbertoolong");
1462         }
1464         if ($kiriwrite_databaseport_numbers_check eq 1){
1466                 # The database port number contains characters other
1467                 # than numbers so return an error.
1469                 kiriwrite_error("serverportnumberinvalidcharacters");
1471         }
1473         if ($kiriwrite_databaseport_port_check eq 1){
1475                 # The database port number given is invalid so return
1476                 # an error.
1478                 kiriwrite_error("serverportnumberinvalid");
1480         }
1482         if ($kiriwrite_databaseprotocol_length_check eq 1){
1484                 # The database protocol name given is too long so
1485                 # return an error.
1487                 kiriwrite_error("serverprotocolnametoolong");
1489         }
1491         if ($kiriwrite_databaseprotocol_protocol_check eq 1){
1493                 # The server protcol given is invalid so return
1494                 # an error.
1496                 kiriwrite_error("serverprotocolinvalid");
1498         }
1500         if ($kiriwrite_databasename_length_check eq 1){
1502                 # The SQL database name is too long so return
1503                 # an error.
1505                 kiriwrite_error("serverdatabasenametoolong");
1507         }
1509         if ($kiriwrite_databasename_lettersnumbers_check eq 1){
1511                 # The database name contains invalid characters
1512                 # so return an error.
1514                 kiriwrite_error("serverdatabasenameinvalid");
1516         }
1518         if ($kiriwrite_databaseusername_length_check eq 1){
1520                 # The database username given is too long so
1521                 # return an error.
1523                 kiriwrite_error("serverdatabaseusernametoolong");
1525         }
1527         if ($kiriwrite_databaseusername_lettersnumbers_check eq 1){
1529                 # The database username contains invalid characters
1530                 # so return an error.
1532                 kiriwrite_error("serverdatabaseusernameinvalid");
1534         }
1536         if ($kiriwrite_databasepassword_length_check eq 1){
1538                 # The database password given is too long so return
1539                 # an error.
1541                 kiriwrite_error("serverdatabasepasswordtoolong");
1543         }
1545         if ($kiriwrite_databasetableprefix_length_check eq 1){
1547                 # The database table prefix given is too long so
1548                 # return an error.
1550                 kiriwrite_error("serverdatabasetableprefixtoolong");
1552         }
1554         if ($kiriwrite_databasetableprefix_lettersnumbers_check eq 1){
1556                 # The database table prefix given contains invalid
1557                 # characters so return an error.
1559                 kiriwrite_error("serverdatabasetableprefixinvalid");
1561         }
1563         # Check the length of value of the checkboxes.
1565         my $kiriwrite_removeinstallscript_length_check  = kiriwrite_variablecheck($http_query_removeinstallscript, "maxlength", 2, 1);
1567         if ($kiriwrite_removeinstallscript_length_check eq 1){
1569                 # The remove install script value is too long
1570                 # so return an error.
1572                 kiriwrite_error("removeinstallscripttoolong");
1574         }
1576         # Check if there is write permissions for the directory.
1578         if (!-w '.'){
1580                 # No write permissions for the directory the
1581                 # script is running from so return an error.
1583                 kiriwrite_error("cannotwriteconfigurationindirectory");
1585         }
1587         # Check if the configuration file already exists.
1589         if (-e 'kiriwrite.cfg'){
1591                 # Check if the configuration file has read permissions.
1593                 if (!-r 'kiriwrite.cfg'){
1595                         # The configuration file has invalid read permissions
1596                         # set so return an error.
1598                         kiriwrite("configurationfilereadpermissionsinvalid");
1600                 }
1602                 # Check if the configuration file has write permissions.
1604                 if (!-w 'kiriwrite.cfg'){
1606                         # The configuration file has invalid write permissions
1607                         # set so return an error.
1609                         kiriwrite("configurationfilewritepermissionsinvalid");
1611                 }
1613         }
1615         # Write the new configuration file.
1617         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 });
1619         my $installscriptmessage        = "";
1621         # Check if the installation script should be deleted.
1623         if (!$http_query_removeinstallscript){
1625                 $http_query_removeinstallscript = "off";
1627         }
1629         if ($http_query_removeinstallscript eq "on"){
1631                 if (unlink("install.cgi")){
1633                         $installscriptmessage = $kiriwrite_lang{$language_selected}{installscriptremoved};
1635                 } else {
1637                         $installscriptmessage = $kiriwrite_lang{$language_selected}{cannotremovescript};
1638                         $installscriptmessage =~ s/%s/$!/g;
1640                 }
1642         }
1644         print "Content-type: text/html\r\n\r\n";
1646         #print start_html({ -title => $kiriwrite_lang{$language_selected}{installertitle}, -style => { -code => $cssstyle }});
1647         print "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
1648         print "<head>\n<title>$kiriwrite_lang{$language_selected}{installertitle}</title>\n<style type=\"text/css\" media=\"screen\">$cssstyle</style>\n</head>\n<body>\n";
1649         print "<h2>$kiriwrite_lang{$language_selected}{installertitle}</h2>";
1650         print $kiriwrite_lang{$language_selected}{installedmessage};
1652         if ($installscriptmessage){
1654                 print "<br /><br />\n";
1655                 print $installscriptmessage;
1657         }
1659         print "<br /><br />\n";
1660         print $kiriwrite_lang{$language_selected}{usekiriwritetext};
1661         print "<br /><br />\n";
1662         print "<a href=\"kiriwrite.cgi\">$kiriwrite_lang{$language_selected}{usekiriwritelink}</a>";
1663         print "</body>\n</html>";
1665         exit;
1669 # Create a list of common date and time formats.
1671 my @datetime_formats = ( 
1672         'DD/MM/YY (hh:mm:ss)', 'DD/MM/YY hh:mm:ss', 'D/M/Y (hh:mm:ss)',
1673         'D/M/Y hh:mm:ss', 'D/M/YY (hh:mm:ss)', 'D/M/YY hh:mm:ss',
1674         'DD/MM (hh:mm:ss)', 'D/M (hh:mm:ss)', 'DD/MM hh:mm:ss', 
1675         'D/M hh:mm:ss', 'DD/MM hh:mm', 'D/M hh:mm',
1676         'DD/MM/YY', 'D/M/Y', 'DD/MM',
1678         'YY-MM-DD (hh:mm:ss)', 'YY-MM-DD hh:mm:ss', 'Y-M-D (hh:mm:ss)',
1679         'Y-M-D hh:mm:ss', 'M-D (hh:mm:ss)', 'M-D hh:mm:ss',
1680         'YY-MM-DD', 'MM-DD' 
1681 );
1683 # Create the list of tests to do.
1685 my ($test_list, %test_list);
1686 my %dependency_results;
1687 my %database_results;
1688 my %file_results;
1689 my $test;
1690 my $date;
1692 my $dependency_error = 0;
1693 my $database_onemodule = 0;
1694 my $database_error = 0;
1695 my $file_error = 0;
1697 my $language_name;
1698 my $language_xml_data;
1699 my $language_file_friendly;
1701 my $presentation_file_friendly;
1703 # Check to see if the needed Perl modules are installed.
1705 $test_list{CheckConfigAuto}{Name}       = "Config::Auto";
1706 $test_list{CheckConfigAuto}{Type}       = "dependency";
1707 $test_list{CheckConfigAuto}{Code}       = "Config::Auto";
1709 $test_list{CheckDBI}{Name}              = "DBI";
1710 $test_list{CheckDBI}{Type}              = "dependency";
1711 $test_list{CheckDBI}{Code}              = "DBI";
1713 $test_list{CheckTieHash}{Name}          = "Tie::IxHash";
1714 $test_list{CheckTieHash}{Type}          = "dependency";
1715 $test_list{CheckTieHash}{Code}          = "Tie::IxHash";
1717 $test_list{CheckCGILite}{Name}          = "CGI::Lite";
1718 $test_list{CheckCGILite}{Type}          = "dependency";
1719 $test_list{CheckCGILite}{Code}          = "CGI::Lite";
1721 $test_list{Encode}{Name}                = "Encode";
1722 $test_list{Encode}{Type}                = "dependency";
1723 $test_list{Encode}{Code}                = "Encode";
1725 $test_list{DBDmysql}{Name}              = "DBD::mysql";
1726 $test_list{DBDmysql}{Type}              = "database";
1727 $test_list{DBDmysql}{Code}              = "DBD::mysql";
1729 $test_list{DBDSQLite}{Name}             = "DBD::SQLite";
1730 $test_list{DBDSQLite}{Type}             = "database";
1731 $test_list{DBDSQLite}{Code}             = "DBD::SQLite";
1733 # Check the file and directory permissions to see if they are correct.
1735 $test_list{MainDirectory}{Name}         = "Kiriwrite Directory (.)";
1736 $test_list{MainDirectory}{Type}         = "file";
1737 $test_list{MainDirectory}{Code}         = ".";
1738 $test_list{MainDirectory}{Writeable}    = "1";
1740 $test_list{LanguageDirectory}{Name}             = "Language Directory (lang)";
1741 $test_list{LanguageDirectory}{Type}             = "file";
1742 $test_list{LanguageDirectory}{Code}             = "lang";
1743 $test_list{LanguageDirectory}{Writeable}        = "0";
1745 $test_list{LibraryDirectory}{Name}              = "Library Directory (lib)";
1746 $test_list{LibraryDirectory}{Type}              = "file";
1747 $test_list{LibraryDirectory}{Code}              = "lib";
1748 $test_list{LibraryDirectory}{Writeable}         = "0";
1750 $test_list{ModulesDirectory}{Name}              = "Modules Directory (Modules)";
1751 $test_list{ModulesDirectory}{Type}              = "file";
1752 $test_list{ModulesDirectory}{Code}              = "Modules";
1753 $test_list{ModulesDirectory}{Writeable}         = "0";
1755 $test_list{DBModulesDirectory}{Name}            = "Database Modules Directory (Modules/Database)";
1756 $test_list{DBModulesDirectory}{Type}            = "file";
1757 $test_list{DBModulesDirectory}{Code}            = "Modules/Database";
1758 $test_list{DBModulesDirectory}{Writeable}       = "0";
1760 $test_list{PresModulesDirectory}{Name}          = "Presentation Modules Directory (Modules/Presentation)";
1761 $test_list{PresModulesDirectory}{Type}          = "file";
1762 $test_list{PresModulesDirectory}{Code}          = "Modules/Presentation";
1763 $test_list{PresModulesDirectory}{Writeable}     = "0";
1765 # Preform those tests.
1767 foreach $test (keys %test_list){
1769         # Check the type of test.
1771         if ($test_list{$test}{Type} eq "dependency"){
1773                 if (eval "require " . $test_list{$test}{Code}){
1775                         # The module exists and is working correctly.
1777                         $dependency_results{$test_list{$test}{Name}}{result}    = $kiriwrite_lang{$language_selected}{testpass};
1779                 } else {
1781                         # The module does not exist or has an error.
1783                         $dependency_error = 1;
1784                         $dependency_results{$test_list{$test}{Name}}{result}    = $kiriwrite_lang{$language_selected}{testfail};
1786                 }
1788         } elsif ($test_list{$test}{Type} eq "database"){
1790                 if (eval "require " . $test_list{$test}{Code}){
1792                         # The module exists and it is working correctly.
1794                         $database_results{$test_list{$test}{Name}}{result}      = $kiriwrite_lang{$language_selected}{testpass};
1795                         $database_onemodule = 1;
1797                 } else {
1799                         # The module does not exist or has an error.
1801                         $database_error = 1;
1802                         $database_results{$test_list{$test}{Name}}{result}      = $kiriwrite_lang{$language_selected}{testfail};
1804                 }
1806         } elsif ($test_list{$test}{Type} eq "file"){
1808                 if (-e $test_list{$test}{Code}){
1810                         # The filename given does exist.
1812                 } else {
1814                         # the filename given does not exist.
1816                         $file_error = 1;
1817                         $file_results{$test_list{$test}{Name}}{result}  = $kiriwrite_lang{$language_selected}{errormessage} . $kiriwrite_lang{$language_selected}{doesnotexist};
1819                 }       
1821                 # Test to see if the filename given has read
1822                 # permissions.
1824                 if (-r $test_list{$test}{Code}){
1826                         # The filename given has valid permissions set.
1828                         $file_results{$test_list{$test}{Name}}{result}  = $kiriwrite_lang{$language_selected}{testpass};
1830                 } else {
1832                         # The filename given has invalid permissions set.
1834                         $file_error = 1;
1835                         $file_results{$test_list{$test}{Name}}{result} = $kiriwrite_lang{$language_selected}{errormessage} . $kiriwrite_lang{$language_selected}{invalidpermissionsset};
1837                 }
1839                 if ($test_list{$test}{Writeable} eq 1){
1841                         # Test to see if the filename given has write
1842                         # permissions.
1844                         if (-w $test_list{$test}{Code}){
1846                                 # The filename given has valid permissions set.
1848                                 $file_results{$test_list{$test}{Name}}{result}  = $kiriwrite_lang{$language_selected}{testpass};
1850                         } else {
1852                                 # The filename given has invalid permissions set.
1854                                 $file_error = 1;
1855                                 $file_results{$test_list{$test}{Name}}{result}  = $kiriwrite_lang{$language_selected}{errormessage} . $kiriwrite_lang{$language_selected}{invalidpermissionsset};
1857                         }
1859                 }
1861         }
1865 # Print the header.
1867 print "Content-Type: text/html;\r\n\r\n";
1869 # Print the page for installing Kiriwrite.
1871 print "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
1872 print "<head>\n<title>$kiriwrite_lang{$language_selected}{installertitle}</title>\n";
1873 print "<style type=\"text/css\" media=\"screen\">$cssstyle</style>\n</head>\n<body>";
1875 print "<table width=\"100%\">";
1876 my $language_name_short;
1877 my $language_list_seek = 0;
1878 my $installlanguage_out = "";
1880 $installlanguage_out = "<select name=\"installlanguage\">\n";
1882 foreach $language_name_short (@language_list_short){
1884         $installlanguage_out = $installlanguage_out . "<option value=\"" . $language_name_short . "\">" . $language_list_long[$language_list_seek] . "</option>\n";
1885         $language_list_seek++;
1889 $installlanguage_out = $installlanguage_out . "</select>\n";
1891 kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{installertitle}, "languagebar", "<form action=\"install.cgi\" method=\"POST\">\n$installlanguage_out\n<input type=\"submit\" value=\"$kiriwrite_lang{$language_selected}{switch}\">\n</form>\n", "languagebarselect");
1892 print "</table>";
1894 print "<h2>$kiriwrite_lang{$language_selected}{installertitle}</h2>\n";
1895 print $kiriwrite_lang{$language_selected}{installertext};
1896 print "<h3>$kiriwrite_lang{$language_selected}{dependencytitle}</h3>\n";
1897 print "<h4>$kiriwrite_lang{$language_selected}{requiredmodules}</h4>\n";
1898 print $kiriwrite_lang{$language_selected}{perlmodules};
1899 print "<br /><br />\n";
1901 if ($dependency_error eq 1){
1903         print $kiriwrite_lang{$language_selected}{errormessage};
1904         print $kiriwrite_lang{$language_selected}{dependencyperlmodulesmissing};
1905         print "<br /><br />\n";
1909 print "<table>\n";
1911 kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{module}, "tablecellheader", $kiriwrite_lang{$language_selected}{result}, "tablecellheader");
1913 foreach $test (keys %dependency_results) {
1915         kiriwrite_addtablerow($test, "tablename", $dependency_results{$test}{result}, "tabledata");
1919 print "</table>";
1921 print "<h4>$kiriwrite_lang{$language_selected}{databasemodules}</h4>\n";
1922 print $kiriwrite_lang{$language_selected}{databasemodulestext};
1923 print "<br /><br />\n";
1925 if ($database_error eq 1){
1927         print $kiriwrite_lang{$language_selected}{warningmessage};
1928         print $kiriwrite_lang{$language_selected}{databaseperlmodulesmissing};
1929         print "<br /><br />\n";
1933 kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{module}, "tablecellheader", $kiriwrite_lang{$language_selected}{result}, "tablecellheader");
1935 foreach $test (keys %database_results) {
1937         kiriwrite_addtablerow($test, "tablename", $database_results{$test}{result}, "tabledata");
1941 print "</table>";
1943 print "<h4>$kiriwrite_lang{$language_selected}{filepermissions}</h4>\n";
1945 print $kiriwrite_lang{$language_selected}{filepermissionstext};
1946 print "<br /><br />\n";
1948 if ($file_error eq 1){
1950         print $kiriwrite_lang{$language_selected}{errormessage};
1951         print $kiriwrite_lang{$language_selected}{filepermissionsinvalid};
1952         print "<br /><br />\n";
1956 print "<table>";
1958 kiriwrite_addtablerow("Filename", "tablecellheader", "Result", "tablecellheader");
1960 foreach $test (keys %file_results) {
1962         kiriwrite_addtablerow($test, "tablename", $file_results{$test}{result}, "tabledata");
1966 print "</table>";
1968 if ($dependency_error eq 1){
1970         print "<hr />\n";
1971         print "<h4>$kiriwrite_lang{$language_selected}{criticalerror}</h4>\n";
1972         print $kiriwrite_lang{$language_selected}{dependencymodulesnotinstalled} . "\n";
1973         print "</body>\n</html>";
1974         exit;
1978 if ($database_onemodule eq 0){
1980         print "<hr />\n";
1981         print "<h4>$kiriwrite_lang{$language_selected}{criticalerror}</h4>\n";
1982         print $kiriwrite_lang{$language_selected}{databasemodulesnotinstalled} . "\n";
1983         print "</body>\n</html>";
1984         exit;
1988 if ($file_error eq 1){
1990         print "<hr />\n";
1991         print "<h4>$kiriwrite_lang{$language_selected}{criticalerror}</h4>\n";
1992         print $kiriwrite_lang{$language_selected}{filepermissionerrors} . "\n";
1993         print "</body>\n</html>";
1994         exit;
1998 my @language_short;
1999 my (%available_languages, $available_languages);
2000 my @presentation_modules;
2001 my @database_modules;
2002 my $select_data = "";
2003 my $language_data;
2004 my $language_out = "";
2005 my ($presmodule_name, $presmodule_out) = "";
2006 my ($dbmodule_name, $dbmodule_out) = "";
2008 # Get the list of available languages.
2010 tie(%available_languages, 'Tie::IxHash');
2012 opendir(LANGUAGEDIR, "lang");
2013 my @language_directory = grep /m*\.lang$/, readdir(LANGUAGEDIR);
2014 closedir(LANGUAGEDIR);
2016 foreach my $language_file (@language_directory){
2018         # Load the language file.
2020         $language_data = Config::Auto::parse("lang/" . $language_file, format => "ini");
2022         # Load the XML data.
2023         #$language_xml_data = $xsl->XMLin("lang/" . $language_file);
2025         # Get the friendly name for the language file.
2027         $language_file_friendly = $language_file;
2028         $language_file_friendly =~ s/.lang$//g;
2030         $language_name = $language_data->{about}->{name};
2032         $available_languages{$language_file_friendly} = $language_name . " (" . $language_file_friendly . ")";
2036 # Get the list of presentation modules.
2038 opendir(OUTPUTSYSTEMDIR, "Modules/Presentation");
2039 my @presmodule_directory = grep /m*\.pm$/, readdir(OUTPUTSYSTEMDIR);
2040 closedir(OUTPUTSYSTEMDIR);
2042 foreach my $presmodule_file (@presmodule_directory){
2044         # Get the friendly name for the database module.
2046         $presmodule_file =~ s/.pm$//g;
2047         push(@presentation_modules, $presmodule_file);
2051 # Get the list of database modules.
2053 opendir(DATABASEDIR, "Modules/Database");
2054 my @dbmodule_directory = grep /m*\.pm$/, readdir(DATABASEDIR);
2055 closedir(DATABASEDIR);
2057 foreach my $dbmodule_file (@dbmodule_directory){
2059         # Get the friendly name for the database module.
2061         $dbmodule_file =~ s/.pm$//g;
2062         push(@database_modules, $dbmodule_file);
2066 print "<h3>$kiriwrite_lang{$language_selected}{settingstitle}</h3>";
2067 print $kiriwrite_lang{$language_selected}{settingstext};
2068 print "<br /><br />\n";
2070 print "<form action=\"install.cgi\" method=\"POST\">";
2071 print "<input type=\"hidden\" name=\"confirm\" value=\"1\">\n<input type=\"hidden\" name=\"installlanguage\" value=\"$language_selected\">\n";
2073 print "<table width=\"100%\">";
2074 kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{setting}, "tablecellheader", $kiriwrite_lang{$language_selected}{value}, "tablecellheader");
2075 kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{directories}, "tablecellheader", "", "tablecellheader");
2076 kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{databasedirectory}, "tablname", "<input type=\"text\" name=\"dbdirectory\" size=\"32\" maxlength=\"64\" value=\"$default_dbdirectory\">", "tabledata");
2077 kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{outputdirectory}, "tablename", "<input type=\"text\" name=\"outputdirectory\" size=\"32\" maxlength=\"64\" value=\"$default_outputdirectory\">", "tabledata");
2078 kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{imagesuripath}, "tablename", "<input type=\"text\" name=\"imagesuripath\" size=\"32\" maxlength=\"64\" value=\"$default_imagesuri\">", "tabledata");
2079 kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{display}, "tablecellheader", "", "tablecellheader");
2080 kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{textarearows}, "tablename", "<input type=\"text\" name=\"textarearows\" size=\"3\" maxlength=\"3\" value=\"$default_textarearows\">", "tabledata");
2081 kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{textareacols}, "tablename", "<input type=\"text\" name=\"textareacols\" size=\"3\" maxlength=\"3\" value=\"$default_textareacols\">", "tabledata");
2082 kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{date}, "tablecellheader", "", "tablecellheader");
2084 foreach my $select_name (@datetime_formats){
2085         $select_data = $select_data . "<option value=\"$select_name\">" . $select_name . "</option>\n";
2088 kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{dateformat}, "tablename", "<select>$select_data</select>\n<input type=\"text\" size=\"32\" maxlength=\"64\" name=\"customdateformat\">", "tabledata");
2089 kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{language}, "tablecellheader", "", "tablecellheader");
2091 foreach my $language (keys %available_languages){
2092         if ($language eq $language_selected){
2093                 $language_out = $language_out . "<option value=\"" . $language . "\" selected=selected>" . $available_languages{$language} . "</option>\n";
2094         } else {
2095                 $language_out = $language_out . "<option value=\"" . $language . "\">" . $available_languages{$language} . "</option>\n";
2096         }
2099 kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{systemlanguage}, "tablename", $language_out, "tabledata");
2100 kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{modules}, "tablecellheader", "", "tablecellheader");
2101 foreach $presmodule_name (@presentation_modules){
2102         $presmodule_out = $presmodule_out . "<option value=\"$presmodule_name\">$presmodule_name</option>";
2104 kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{presentationmodule}, "tablename", "<select name=\"presmodule\">$presmodule_out</select>", "tabledata");
2105 foreach $dbmodule_name (@database_modules){
2106         $dbmodule_out = $dbmodule_out . "<option value=\"$dbmodule_name\">$dbmodule_name</option>";
2109 kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{databasemodule}, "tablename", "<select name=\"dbmodule\">$dbmodule_out</select>", "tabledata");
2110 kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{databaseserver}, "tablename", "<input type=\"text\" name=\"databaseserver\" size=\"32\" maxlength=\"128\" value=\"$default_server\">\n", "tabledata");
2111 kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{databaseport}, "tablename", "<input type=\"text\" name=\"databaseport\" maxlength=\"5\" size=\"5\" value=\"$default_port\">\n", "tabledata");
2112 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");
2113 kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{databasename}, "tablename", "<input type=\"text\" name=\"databasename\" size=\"32\" maxlength=\"32\" value=\"$default_name\">\n", "tabledata");
2114 kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{databaseusername}, "tablename", "<input type=\"text\" name=\"databaseusername\" size=\"16\" maxlength=\"16\" value=\"$default_username\">\n", "tabledata");
2115 kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{databasepassword}, "tablename", "<input type=\"password\" name=\"databasepassword\" size=\"32\" maxlength=\"64\">\n", "tabledata");
2116 kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{databasetableprefix}, "tablename", "<input type=\"text\" name=\"databasetableprefix\" size=\"32\" maxlength=\"32\" value=\"$default_prefix\">\n", "tabledata");
2117 kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{installationoptions}, "tablecellheader", "", "tablecellheader");
2118 kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{installoptions}, "tablename", "<input type=\"checkbox\" name=\"removeinstallscript\" checked=checked value=\"on\"> $kiriwrite_lang{$language_selected}{removeinstallscript}\n", "tabledata");
2120 print "</table>\n";
2122 print "<br />\n<input type=\"submit\" value=\"$kiriwrite_lang{$language_selected}{savesettingsbutton}\"> | <input type=\"reset\" value=\"$kiriwrite_lang{$language_selected}{resetsettingsbutton}\">\n";
2124 print "</form>\n</body>\n</html>";
2125 exit;
2127 __END__
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy