Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Version 0.2.0 Import. Speed of Kiriwrite optimised and other alterations
[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::Carp('fatalsToBrowser');      # Output errors to the browser.
31 # Setup strings in specific languages. Style should be no spacing for
32 # language title and one tabbed spacing for each string.
34 # Define some default settings.
36 my $default_language            = "en-GB";
37 my $default_dbdirectory         = "db";
38 my $default_outputdirectory     = "output";
39 my $default_imagesuri           = "/images/kiriwrite";
41 my $default_textarearows        = "10";
42 my $default_textareacols        = "50";
44 my $default_server              = "localhost";
45 my $default_port                = "3306";
46 my $default_protocol            = "tcp";
47 my $default_name                = "database";
48 my $default_username            = "username";
49 my $default_prefix              = "kiriwrite";
51 my ($kiriwrite_lang, %kiriwrite_lang);
53 $kiriwrite_lang{"en-GB"}{"languagename"}        = "English (British)";
54         $kiriwrite_lang{"en-GB"}{"testpass"}            = "OK";
55         $kiriwrite_lang{"en-GB"}{"testfail"}            = "Error";
57         $kiriwrite_lang{"en-GB"}{"generic"}                     = "An error occured which is not known to the Kiriwrite installer.";
58         $kiriwrite_lang{"en-GB"}{"invalidvariable"}             = "The variable given was invalid.";
59         $kiriwrite_lang{"en-GB"}{"invalidvalue"}                = "The value given was invalid.";
60         $kiriwrite_lang{"en-GB"}{"invalidoption"}               = "The option given was invalid.";
61         $kiriwrite_lang{"en-GB"}{"variabletoolong"}             = "The variable given is too long.";
62         $kiriwrite_lang{"en-GB"}{"blankdirectory"}              = "The directory name given is blank.";
63         $kiriwrite_lang{"en-GB"}{"invaliddirectory"}            = "The directory name given is invalid.";
64         $kiriwrite_lang{"en-GB"}{"moduleblank"}                 = "The module filename given is blank.";
65         $kiriwrite_lang{"en-GB"}{"moduleinvalid"}               = "The module filename given is invalid.";
67         $kiriwrite_lang{"en-GB"}{"dbdirectorytoolong"}          = "The database directory name given is too long.";
68         $kiriwrite_lang{"en-GB"}{"outputdirectorytoolong"}      = "The output directory name given is too long.";
69         $kiriwrite_lang{"en-GB"}{"imagesuripathtoolong"}        = "The images URI path name given is too long.";
70         $kiriwrite_lang{"en-GB"}{"dateformattoolong"}           = "The date format given is too long.";
71         $kiriwrite_lang{"en-GB"}{"customdateformattoolong"}     = "The custom date format given is too long.";
72         $kiriwrite_lang{"en-GB"}{"languagefilenametoolong"}     = "The language filename given is too long.";
74         $kiriwrite_lang{"en-GB"}{"dateformatblank"}             = "The date format given was blank.";
75         $kiriwrite_lang{"en-GB"}{"dateformatinvalid"}           = "The date format given is invalid.";
76         $kiriwrite_lang{"en-GB"}{"languagefilenameinvalid"}     = "The language filename given is invalid.";
78         $kiriwrite_lang{"en-GB"}{"dbdirectoryblank"}            = "The database directory name given is blank.";
79         $kiriwrite_lang{"en-GB"}{"dbdirectoryinvalid"}          = "The database directory name given is invalid.";
81         $kiriwrite_lang{"en-GB"}{"outputdirectoryblank"}        = "The output directory name given is blank.";
82         $kiriwrite_lang{"en-GB"}{"outputdirectoryinvalid"}      = "The output directory name given is invalid.";
84         $kiriwrite_lang{"en-GB"}{"textarearowblank"}            = "The text area row value given is blank.";
85         $kiriwrite_lang{"en-GB"}{"textarearowtoolong"}          = "The text area row value given is too long.";
86         $kiriwrite_lang{"en-GB"}{"textarearowinvalid"}          = "The text area row value given is invalid.";
88         $kiriwrite_lang{"en-GB"}{"textareacolsblank"}           = "The text area columns value given is blank.";
89         $kiriwrite_lang{"en-GB"}{"textareacolstoolong"}         = "The text area columns value given is too long.";
90         $kiriwrite_lang{"en-GB"}{"textareacolsinvalid"}         = "The text area columns value given is invalid.";
92         $kiriwrite_lang{"en-GB"}{"presmoduleblank"}             = "The presentation module name given is blank.";
93         $kiriwrite_lang{"en-GB"}{"presmoduleinvalid"}           = "The presentation module name given is invalid.";
94  
95         $kiriwrite_lang{"en-GB"}{"dbmoduleblank"}               = "The database module name given is blank.";
96         $kiriwrite_lang{"en-GB"}{"dbmoduleinvalid"}             = "The database module name given is invalid.";
97  
98         $kiriwrite_lang{"en-GB"}{"presmodulemissing"}           = "The presentation module with the filename given is missing.";
99         $kiriwrite_lang{"en-GB"}{"dbmodulemissing"}             = "The database module with the filename given is missing.";
100         $kiriwrite_lang{"en-GB"}{"languagefilenamemissing"}     = "The language file with the filename given is missing.";
101  
102         $kiriwrite_lang{"en-GB"}{"servernametoolong"}           = "The database server name given is too long.";
103         $kiriwrite_lang{"en-GB"}{"servernameinvalid"}           = "The database server name given is invalid.";
104         $kiriwrite_lang{"en-GB"}{"serverportnumbertoolong"}     = "The database server port number given is too long.";
105         $kiriwrite_lang{"en-GB"}{"serverportnumberinvalidcharacters"}   = "The database server port number given contains invalid characters.";
106         $kiriwrite_lang{"en-GB"}{"serverportnumberinvalid"}     = "The database server port number given is invalid.";
107         $kiriwrite_lang{"en-GB"}{"serverprotocolnametoolong"}   = "The database server protocol name given is too long.";
108         $kiriwrite_lang{"en-GB"}{"serverprotocolinvalid"}               = "The database server protocol name is invalid.";
109         $kiriwrite_lang{"en-GB"}{"serverdatabasenametoolong"}   = "The database name given is too long.";
110         $kiriwrite_lang{"en-GB"}{"serverdatabasenameinvalid"}   = "The database name given is invalid.";
111         $kiriwrite_lang{"en-GB"}{"serverdatabaseusernametoolong"}       = "The database server username given is too long.";
112         $kiriwrite_lang{"en-GB"}{"serverdatabaseusernameinvalid"}       = "The database server username given is invalid.";
113         $kiriwrite_lang{"en-GB"}{"serverdatabasepasswordtoolong"}       = "The database server password is too long.";
114         $kiriwrite_lang{"en-GB"}{"serverdatabasetableprefixtoolong"}    = "The database server table prefix given is too long.";
115         $kiriwrite_lang{"en-GB"}{"serverdatabasetableprefixinvalid"}    = "The database server table prefix given is invalid.";
116  
117         $kiriwrite_lang{"en-GB"}{"removeinstallscripttoolong"}  = "The remove install script value given is too long.";
118         $kiriwrite_lang{"en-GB"}{"cannotwriteconfigurationindirectory"} = "The configuration file cannot be written because the directory the install script is running from has invalid permissions.";
119         $kiriwrite_lang{"en-GB"}{"configurationfilereadpermissionsinvalid"}     = "The configuration that currently exists has invalid read permissions set.";
120         $kiriwrite_lang{"en-GB"}{"configurationfilewritepermissionsinvalid"}    = "The configuration that currently exists has invalid write permissions set.";
122         $kiriwrite_lang{"en-GB"}{"errormessagetext"}    = "Please press the back button on your browser or preform the command needed to return to the previous page.";
124         $kiriwrite_lang{"en-GB"}{"switch"}              = "Switch";
125         $kiriwrite_lang{"en-GB"}{"setting"}             = "Setting";
126         $kiriwrite_lang{"en-GB"}{"value"}               = "Value";
127         $kiriwrite_lang{"en-GB"}{"filename"}            = "Filename";
128         $kiriwrite_lang{"en-GB"}{"module"}              = "Module";
129         $kiriwrite_lang{"en-GB"}{"result"}              = "Result";
130         $kiriwrite_lang{"en-GB"}{"error"}               = "Error!";
131         $kiriwrite_lang{"en-GB"}{"criticalerror"}       = "Critical Error!";
132         $kiriwrite_lang{"en-GB"}{"errormessage"}        = "Error: ";
133         $kiriwrite_lang{"en-GB"}{"warningmessage"}      = "Warning: ";
135         $kiriwrite_lang{"en-GB"}{"doesnotexist"}        = "Does not exist.";
136         $kiriwrite_lang{"en-GB"}{"invalidpermissionsset"}       = "Invalid permissions set.";
138         $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.";
139         $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.";
140         $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.";
141         $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.";
142         $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.";
143         $kiriwrite_lang{"en-GB"}{"filepermissionerrors"}        = "One or more filenames checked has errors. See the Kiriwrite documentation for more information on this.",
145         $kiriwrite_lang{"en-GB"}{"installertitle"}      = "Kiriwrite Installer";
146         $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.";
147         $kiriwrite_lang{"en-GB"}{"dependencytitle"}     = "Dependency and file testing results";
148         $kiriwrite_lang{"en-GB"}{"requiredmodules"}     = "Required Modules";
149         $kiriwrite_lang{"en-GB"}{"perlmodules"}         = "These Perl modules are used internally by Kiriwrite.";
150         $kiriwrite_lang{"en-GB"}{"databasemodules"}     = "Perl Database Modules";
151         $kiriwrite_lang{"en-GB"}{"databasemodulestext"} = "These Perl modules are used by the database modules.";
152         $kiriwrite_lang{"en-GB"}{"filepermissions"}     = "File permissions";
153         $kiriwrite_lang{"en-GB"}{"filepermissionstext"} = "The file permissions are for file and directories that are critical to Kiriwrite such as module and language directories.";
154         
155         $kiriwrite_lang{"en-GB"}{"settingstitle"}       = "Kiriwrite Settings";
156         $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.";
157         $kiriwrite_lang{"en-GB"}{"directories"}         = "Directories";
158         $kiriwrite_lang{"en-GB"}{"databasedirectory"}   = "Database Directory";
159         $kiriwrite_lang{"en-GB"}{"outputdirectory"}     = "Output Directory";
160         $kiriwrite_lang{"en-GB"}{"imagesuripath"}       = "Images (URI path)";
161         $kiriwrite_lang{"en-GB"}{"display"}             = "Display";
162         $kiriwrite_lang{"en-GB"}{"textareacols"}        = "Text Area Columns";
163         $kiriwrite_lang{"en-GB"}{"textarearows"}        = "Text Area Rows";
164         $kiriwrite_lang{"en-GB"}{"date"}                = "Date";
165         $kiriwrite_lang{"en-GB"}{"dateformat"}          = "Date Format";
166         $kiriwrite_lang{"en-GB"}{"language"}            = "Language";
167         $kiriwrite_lang{"en-GB"}{"systemlanguage"}      = "System Language";
168         $kiriwrite_lang{"en-GB"}{"modules"}             = "Modules";
169         $kiriwrite_lang{"en-GB"}{"presentationmodule"}  = "Presentation Module";
170         $kiriwrite_lang{"en-GB"}{"databasemodule"}      = "Database Module";
171         $kiriwrite_lang{"en-GB"}{"databaseserver"}      = "Database Server";
172         $kiriwrite_lang{"en-GB"}{"databaseport"}        = "Database Port";
173         $kiriwrite_lang{"en-GB"}{"databaseprotocol"}    = "Database Protocol";
174         $kiriwrite_lang{"en-GB"}{"databasename"}        = "Database Name";
175         $kiriwrite_lang{"en-GB"}{"databaseusername"}    = "Database Username";
176         $kiriwrite_lang{"en-GB"}{"databasepassword"}    = "Database Password";
177         $kiriwrite_lang{"en-GB"}{"databasetableprefix"} = "Database Table Prefix";
178         $kiriwrite_lang{"en-GB"}{"installationoptions"} = "Installation Options";
179         $kiriwrite_lang{"en-GB"}{"installoptions"}      = "Install Options";
180         $kiriwrite_lang{"en-GB"}{"removeinstallscript"} = "Delete this installer script after configuration file has been written.";
181         $kiriwrite_lang{"en-GB"}{"savesettingsbutton"}  = "Save Settings";
182         $kiriwrite_lang{"en-GB"}{"resetsettingsbutton"} = "Reset Settings";
184         $kiriwrite_lang{"en-GB"}{"installscriptremoved"}        = "The installer script was removed.";
185         $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.";
186         $kiriwrite_lang{"en-GB"}{"cannotremovescript"}  = "Unable to remove the installer script: %s. The installer script will have to be deleted manually.";
187         $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):";
188         $kiriwrite_lang{"en-GB"}{"usekiriwritelink"}    = "Start using Kiriwrite.";
190 my $query = new CGI;
192 my $language_selected = "";
193 my $http_query_confirm = $query->param('confirm');
194 my $http_query_installlanguage = $query->param('installlanguage');
196 if (!$http_query_installlanguage){
198         $language_selected = $default_language;
200 } else {
202         $language_selected = $http_query_installlanguage;
206 # Process the list of available languages.
208 my $language_list_name;
209 my @language_list_short;
210 my @language_list_long;
212 foreach my $language (keys %kiriwrite_lang){
214         $language_list_name = $kiriwrite_lang{$language}{"languagename"} . " (" . $language .  ")";
215         push(@language_list_short, $language);
216         push(@language_list_long, $language_list_name);
220 # The CSS Stylesheet to use.
222 my $cssstyle = "
224 a {
225         color: #FFFFFF;
228 body {
229         background-color: #408080;
230         color: #FFFFFF;
231         font-family: sans-serif;
232         font-size: 12px;
235 input {
236         font-size: 12px;
237         background-color: #408080;
238         color: #FFFFFF;
239         border-color: #102020;
240         border-style: solid;
241         border-width: 1px;
242         padding: 3px;
246 select {
247         font-size: 12px;
248         padding: 3px;
249         background-color: #408080;
250         color: #FFFFFF;
251         border-color: #102020;
252         border-style: solid;
253         border-width: 1px;
254         padding: 3px;
257 td,table {
258         padding: 5px;
259         border-spacing: 0px;
262 .languagebar {
263         background-color: #204040;
264         vertical-align: top;
267 .languagebarselect {
268         text-align: right;
269         background-color: #204040;
272 .tablecellheader {
273         background-color: #204040;
274         font-weight: bold;
277 .tabledata {
278         background-color: #357070;
281 .tablename {
283         background-color: #306060;
287 ";
290 #################################################################################
291 # Begin list of subroutines.                                                    #
292 #################################################################################
294 sub kiriwrite_variablecheck{
295 #################################################################################
296 # kiriwrite_variablecheck: Check to see if the data passed is valid.            #
297 #                                                                               #
298 # Usage:                                                                        #
299 #                                                                               #
300 # kiriwrite_variablecheck(variablename, type, option, noerror);                 #
301 #                                                                               #
302 # variablename  Specifies the variable to be checked.                           #
303 # type          Specifies what type the variable is.                            #
304 # option        Specifies the maximum/minimum length of the variable            #
305 #               (if minlength/maxlength is used) or if the filename should be   #
306 #               checked to see if it is blank.                                  #
307 # noerror       Specifies if Kiriwrite should return an error or not on         #
308 #               certain values.                                                 #
309 #################################################################################
311         # Get the values that were passed to the subroutine.
313         my ($variable_data, $variable_type, $variable_option, $variable_noerror) = @_;
315         if ($variable_type eq "numbers"){
317                 # Check for numbers and return an error if there is anything else than numebrs.
319                 my $variable_data_validated = $variable_data;   # Copy the variable_data to variable_data_validated.
320                 $variable_data_validated =~ tr/0-9//d;          # Take away all of the numbers and from the variable. 
321                                                                 # If it only contains numbers then it should be blank.
323                 if ($variable_data_validated eq ""){
324                         # The validated variable is blank. So continue to the end of this section where the return function should be.
325                 } else {
326                         # The variable is not blank, so check if the no error value is set
327                         # to 1 or not.
329                         if ($variable_noerror eq 1){
331                                 # The validated variable is not blank and the noerror
332                                 # value is set to 1. So return an value of 1.
333                                 # (meaning that the data is invalid).
335                                 return 1;
337                         } elsif ($variable_noerror eq 0) {
339                                 # The validated variable is not blank and the noerror
340                                 # value is set to 0.
342                                 kiriwrite_error("invalidvariable");
344                         } else {
346                                 # The variable noerror value is something else
347                                 # pther than 1 or 0. So return an error.
349                                 kiriwrite_error("invalidvariable");
351                         }
353                 }
355                 return 0;
357         } elsif ($variable_type eq "lettersnumbers"){
359                 # Check for letters and numbers and return an error if there is anything else other
360                 # than letters and numbers.
362                 my $variable_data_validated = $variable_data;   # Copy the variable_data to variable_data_validated
363                 $variable_data_validated =~ tr/a-zA-Z0-9.//d;
364                 $variable_data_validated =~ s/\s//g;
366                 if ($variable_data_validated eq ""){
367                         # The validated variable is blank. So continue to the end of this section where the return function should be.
368                 } else {
369                         # The variable is not blank, so check if the no error value is set
370                         # to 1 or not.
372                         if ($variable_noerror eq 1){
374                                 # The validated variable is not blank and the noerror
375                                 # value is set to 1. So return an value of 1.
376                                 # (meaning that the data is invalid).
378                                 return 1;
380                         } elsif ($variable_noerror eq 0) {
382                                 # The validated variable is not blank and the noerror
383                                 # value is set to 0.
385                                 kiriwrite_error("invalidvariable");
387                         } else {
389                                 # The variable noerror value is something else
390                                 # pther than 1 or 0. So return an error.
392                                 kiriwrite_error("invalidvariable");
394                         }
396                 }
398                 return 0;
400         } elsif ($variable_type eq "maxlength"){
401                 # Check for the length of the variable, return an error if it is longer than the length specified.
403                 # Check if the variable_data string is blank, if it is then set the variable_data_length
404                 # to '0'.
406                 my $variable_data_length = 0;
408                 if (!$variable_data){
410                         # Set variable_data_length to '0'.
411                         $variable_data_length = 0;
413                 } else {
415                         # Get the length of the variable recieved.
416                         $variable_data_length = length($variable_data);
418                 }
422                 if ($variable_data_length > $variable_option){
424                         # The variable length is longer than it should be so check if
425                         # the no error value is set 1.
427                         if ($variable_noerror eq 1){
429                                 # The no error value is set to 1, so return an
430                                 # value of 1 (meaning tha the variable is
431                                 # too long to be used).
433                                 return 1;
435                         } elsif ($variable_noerror eq 0){
437                                 # The no error value is set to 0, so return
438                                 # an error.
440                                 kiriwrite_error("variabletoolong");
442                         } else {
444                                 # The no error value is something else other
445                                 # than 0 or 1, so return an error.
447                                 kiriwrite_error("variabletoolong");
449                         }
451                 } else {
453                         # The variable length is exactly or shorter than specified, so continue to end of this section where
454                         # the return function should be.
456                 }
458                 return 0;
460         } elsif ($variable_type eq "datetime"){
461                 # Check if the date and time setting format is valid.
463                 if ($variable_data eq ""){
465                         if ($variable_noerror eq 1){
467                                 # The no error value is set to 1 so return
468                                 # a value of 1 (meaning that the date and
469                                 # time format was blank).
471                                 return 1;
473                         } elsif ($variable_noerror eq 0){
475                                 # The no error value is set to 1 so return
476                                 # an error.
478                                 kiriwrite_error("dateformatblank");
480                         } else {
482                                 # The no error value is something else other
483                                 # than 0 or 1, so return an error.
485                                 kiriwrite_error("invalidvariable");
487                         }
489                 }
491                 my $variable_data_validated = $variable_data;
492                 $variable_data_validated =~ tr|dDmMyYhms/():[ ]||d;
494                 if ($variable_data_validated eq ""){
496                         # The date and time format is valid. So
497                         # skip this bit.
499                 } else {
501                         # The validated data variable is not blank, meaning 
502                         # that it contains something else, so return an error
503                         # (or a value).
505                         if ($variable_noerror eq 1){
507                                 # The no error value is set to 1 so return
508                                 # an value of 2. (meaning that the date and
509                                 # time format was invalid).
511                                 return 2;
513                         } elsif ($variable_noerror eq 0){
515                                 # The no error value is set to 0 so return
516                                 # an error.
518                                 kiriwrite_error("dateformatinvalid");
520                         } else {
522                                 # The no error value is something else other
523                                 # than 0 or 1 so return an error.
525                                 kiriwrite_error("invalidvariable");
527                         }
529                 }
531                 return 0;
533         } elsif ($variable_type eq "directory"){
534                 # Check if the directory only contains letters and numbers and
535                 # return an error if anything else appears.
537                 my $variable_data_validated = $variable_data;
538                 $variable_data_validated =~ tr/a-zA-Z0-9//d;
540                 if ($variable_data eq ""){
542                         if ($variable_noerror eq 1){
544                                 # The no error value is set to 1 so return
545                                 # a value of 1 (meaning that the directory
546                                 # name was blank).
548                                 return 1;
550                         } elsif ($variable_noerror eq 0){
552                                 # The no error value is set to 1 so return
553                                 # an error.
555                                 kiriwrite_error("blankdirectory");
557                         } else {
559                                 # The no error value is something else other
560                                 # than 0 or 1, so return an error.
562                                 kiriwrite_error("invalidvariable");
564                         }
566                 }
568                 if ($variable_data_validated eq ""){
570                         # The validated data variable is blank, meaning that
571                         # it only contains letters and numbers.
573                 } else {
575                         # The validated data variable is not blank, meaning 
576                         # that it contains something else, so return an error
577                         # (or a value).
579                         if ($variable_noerror eq 1){
581                                 # The no error value is set to 1 so return
582                                 # an value of 2. (meaning that the directory
583                                 # name is invalid).
585                                 return 2;
587                         } elsif ($variable_noerror eq 0){
589                                 # The no error value is set to 0 so return
590                                 # an error.
592                                 kiriwrite_error("invaliddirectory");
594                         } else {
596                                 # The no error value is something else other
597                                 # than 0 or 1 so return an error.
599                                 kiriwrite_error("invalidvariable");
601                         }
603                 }
605                 return 0;
607         } elsif ($variable_type eq "language_filename"){
609                 # The variable type is a language filename type.
610                 # Check if the language file name is blank and 
611                 # if it is then return an error (or value).
613                 if ($variable_data eq ""){
615                         # The language filename is blank so check the
616                         # no error value and return an error (or value).
618                         if ($variable_noerror eq 1){
620                                 # Language filename is blank and the no error value
621                                 # is set as 1, so return a value of 1 (saying that
622                                 # the language filename is blank).
624                                 return 1;
626                         } elsif ($variable_noerror eq 0) {
628                                 # Language filename is blank and the no error value
629                                 # is not set as 1, so return an error.
631                                 kiriwrite_error("languagefilenameblank");
633                         } else {
635                                 # The noerror value is something else other
636                                 # than 0 or 1 so return an error.
638                                 kiriwrite_error("invalidvariable");
640                         }
642                 }
644                 # Set the following variables for later on.
646                 my $variable_data_length = 0;
647                 my $variable_data_char = "";
648                 my $variable_data_seek = 0;
650                 # Get the length of the language file name.
652                 $variable_data_length = length($variable_data);
654                 do {
656                         # Get a character from the language filename passed to this 
657                         # subroutine and the character the seek counter value is set
658                         # to.
660                         $variable_data_char = substr($variable_data, $variable_data_seek, 1);
662                         # Check if the language filename contains a forward slash or a dot, 
663                         # if the selected character is a forward slash then return an error
664                         # (or value).
666                         if ($variable_data_char eq "/" || $variable_data_char eq "."){
668                                 # The language filename contains a forward slash or
669                                 # a dot so depending on the no error value, return
670                                 # an error or a value.
672                                 if ($variable_noerror eq 1){
674                                         # Language filename contains a forward slash or a dot
675                                         # and the no error value has been set to 1, so return 
676                                         # an value of 2 (saying that the language file name is 
677                                         # invalid).
679                                         return 2;
681                                 } elsif ($variable_noerror eq 0) {
683                                         # Language filename contains a forward slash and the no
684                                         # error value has not been set to 1, so return an error.
686                                         kiriwrite_error("languagefilenameinvalid");
688                                 } else {
690                                         # The noerror value is something else other than
691                                         # 1 or 0 so return an error.
693                                         kiriwrite_error("invalidvariable");
695                                 }
697                         }
699                         # Increment the seek counter.
701                         $variable_data_seek++;
703                 } until ($variable_data_seek eq $variable_data_length);
705                 return 0;
707         } elsif ($variable_type eq "module"){
709                 # The variable type is a presentation module filename.
711                 # Check if the variable_data is blank and if it is
712                 # return an error.
714                 if ($variable_data eq ""){
716                         # The presentation module is blank so check if an error
717                         # value should be returned or a number should be
718                         # returned.
720                         if ($variable_noerror eq 1){
722                                 # Module name is blank and the no error value 
723                                 # is set to 1 so return a value of 2 (meaning 
724                                 # that the page filename is blank).
726                                 return 1;
728                         } elsif ($variable_noerror eq 0) {
730                                 # Module name contains is blank and the no error 
731                                 # value is set to 0 so return an error.
733                                 kiriwrite_critical("moduleblank");
735                         } else {
737                                 # The no error value is something else other
738                                 # than 0 or 1 so return an error.
740                                 kiriwrite_critical("invalidvalue");
742                         }
744                 } else {
746                 }
748                 my $variable_data_validated = $variable_data;
749                 $variable_data_validated =~ tr/a-zA-Z0-9//d;
751                 if ($variable_data_validated eq ""){
753                 } else {
755                         if ($variable_noerror eq 1){
757                                 # Module name contains invalid characters and
758                                 # the no error value is set to 1 so return a 
759                                 # value of 2 (meaning that the page filename
760                                 # is invalid).
762                                 return 2;
764                         } elsif ($variable_noerror eq 0) {
766                                 # Module name contains invalid characters and
767                                 # the no error value is set to 0 so return an
768                                 # error.
770                                 kiriwrite_critical("moduleinvalid");
772                         } else {
774                                 # The no error value is something else other
775                                 # than 0 or 1 so return an error.
777                                 kiriwrite_error("invalidvalue");
779                         }
781                 }
783                 return 0;
785         } elsif ($variable_type eq "serverprotocol"){
787                 # Check if the server protocol is TCP or UDP and return
788                 # an error if it isn't.
790                 if ($variable_data ne "tcp" && $variable_data ne "udp"){
792                         # The protocol given is not valid, check if the no
793                         # error value is set to 1 and return an error if it isn't.
795                         if ($variable_noerror eq 1){
797                                 # The no error value has been set to 1, so return a
798                                 # value of 1 (meaning that the server protocol is
799                                 # invalid).
801                                 return 1;
803                         } elsif ($variable_noerror eq 0){
805                                 # The no error value has been set to 0, so return
806                                 # an error.
808                                 kiriwrite_error("serverprotocolinvalid");
810                         } else {
812                                 # The no error value is something else other than 0
813                                 # or 1, so return an error.
815                                 kiriwrite_error("invalidoption");
817                         }
819                 }
821                 return 0;
823         } elsif ($variable_type eq "port"){
825                 # Check if the port number given is less than 0 or more than 65535
826                 # and return an error if it is.
828                 if ($variable_data < 0 || $variable_data > 65535){
830                         # The port number is less than 0 and more than 65535 so
831                         # check if the no error value is set to 1 and return an
832                         # error if it isn't.
834                         if ($variable_noerror eq 1){
836                                 # The no error value has been set to 1, so return a
837                                 # value of 1 (meaning that the port number is invalid).
839                                 return 1;
841                         } elsif ($variable_noerror eq 0){
843                                 # The no error value has been set to 0, so return
844                                 # an error.
846                                 kiriwrite_error("serverportnumberinvalid");
848                         } else {
850                                 # The no error value is something else other than 0
851                                 # or 1, so return an error.
853                                 kiriwrite_error("invalidoption");
855                         }
857                 }
859                 return 0;
861         }
863         # Another type than the valid ones above has been specified so return an error specifying an invalid option.
864         kiriwrite_error("invalidoption");
868 sub kiriwrite_error{
869 #################################################################################
870 # kiriwrite_error: Subroutine for processing error messages.                    #
871 #                                                                               #
872 # Usage:                                                                        #
873 #                                                                               #
874 # kiriwrite_error(errortype);                                                   #
875 #                                                                               #
876 # errortype     Specifies the error type to use.                                #
877 #################################################################################
879         my $error_type = shift;
881         # Load the list of error messages.
883         my (%kiriwrite_error, $kiriwrite_error);
885         %kiriwrite_error = (
887                 # Generic Error Messages
889                 "generic"                       => $kiriwrite_lang{$language_selected}{generic},
891                 "invalidvariable"               => $kiriwrite_lang{$language_selected}{invalidvariable},
892                 "invalidvalue"                  => $kiriwrite_lang{$language_selected}{invalidvalue},
893                 "invalidoption"                 => $kiriwrite_lang{$language_selected}{invalidoption},
894                 "variabletoolong"               => $kiriwrite_lang{$language_selected}{variabletoolong},
895                 "blankdirectory"                => $kiriwrite_lang{$language_selected}{blankdirectory},
896                 "invaliddirectory"              => $kiriwrite_lang{$language_selected}{invaliddirectory},
897                 "moduleblank"                   => $kiriwrite_lang{$language_selected}{moduleblank},
898                 "moduleinvalid"                 => $kiriwrite_lang{$language_selected}{moduleinvalid},
900                 # Specific Error Messages
902                 "dbdirectorytoolong"            => $kiriwrite_lang{$language_selected}{dbdirectorytoolong},
903                 "outputdirectorytoolong"        => $kiriwrite_lang{$language_selected}{outputdirectorytoolong},
904                 "imagesuripathtoolong"          => $kiriwrite_lang{$language_selected}{imagesuripathtoolong},
905                 "dateformattoolong"             => $kiriwrite_lang{$language_selected}{dateformattoolong},
906                 "customdateformattoolong"       => $kiriwrite_lang{$language_selected}{customdateformattoolong},
907                 "languagefilenametoolong"       => $kiriwrite_lang{$language_selected}{languagefilenametoolong},
908                 
909                 "dateformatblank"               => $kiriwrite_lang{$language_selected}{dateformatblank},
910                 "dateformatinvalid"             => $kiriwrite_lang{$language_selected}{dateformatinvalid},
911                 "languagefilenameinvalid"       => $kiriwrite_lang{$language_selected}{languagefilenameinvalid},
912                 
913                 "dbdirectoryblank"              => $kiriwrite_lang{$language_selected}{dbdirectoryblank},
914                 "dbdirectoryinvalid"            => $kiriwrite_lang{$language_selected}{dbdirectoryinvalid},
916                 "textarearowblank"              => $kiriwrite_lang{$language_selected}{textarearowblank},
917                 "textarearowtoolong"            => $kiriwrite_lang{$language_selected}{textarearowtoolong},
918                 "textarearowinvalid"            => $kiriwrite_lang{$language_selected}{textarearowinvalid},
920                 "textareacolsblank"             => $kiriwrite_lang{$language_selected}{textareacolsblank},
921                 "textareacolstoolong"           => $kiriwrite_lang{$language_selected}{textareacolstoolong},
922                 "textareacolsinvalid"           => $kiriwrite_lang{$language_selected}{textareacolsinvalid},
924                 "outputdirectoryblank"          => $kiriwrite_lang{$language_selected}{outputdirectoryblank},
925                 "outputdirectoryinvalid"        => $kiriwrite_lang{$language_selected}{outputdirectoryinvalid},
927                 "presmoduleblank"               => $kiriwrite_lang{$language_selected}{presmoduleblank},
928                 "presmoduleinvalid"             => $kiriwrite_lang{$language_selected}{presmoduleinvalid},
930                 "dbmoduleblank"                 => $kiriwrite_lang{$language_selected}{dbmoduleblank},
931                 "dbmoduleinvalid"               => $kiriwrite_lang{$language_selected}{dbmoduleinvalid},
933                 "presmodulemissing"             => $kiriwrite_lang{$language_selected}{presmodulemissing},
934                 "dbmodulemissing"               => $kiriwrite_lang{$language_selected}{dbmodulemissing},
935                 "languagefilenamemissing"       => $kiriwrite_lang{$language_selected}{languagefilenamemissing},
937                 "servernametoolong"             => $kiriwrite_lang{$language_selected}{servernametoolong},
938                 "servernameinvalid"             => $kiriwrite_lang{$language_selected}{servernameinvalid},
939                 "serverportnumbertoolong"       => $kiriwrite_lang{$language_selected}{serverportnumbertoolong},
940                 "serverportnumberinvalidcharacters"     => $kiriwrite_lang{$language_selected}{serverportnumberinvalidcharacters},
941                 "serverportnumberinvalid"       => $kiriwrite_lang{$language_selected}{serverportnumberinvalid},
942                 "serverprotocolnametoolong"     => $kiriwrite_lang{$language_selected}{serverprotocolnametoolong},
943                 "serverprotocolinvalid"         => $kiriwrite_lang{$language_selected}{serverprotocolinvalid},
944                 "serverdatabasenametoolong"     => $kiriwrite_lang{$language_selected}{serverdatabasenametoolong},
945                 "serverdatabasenameinvalid"     => $kiriwrite_lang{$language_selected}{serverdatabasenameinvalid},
946                 "serverdatabaseusernametoolong" => $kiriwrite_lang{$language_selected}{serverdatabaseusernametoolong},
947                 "serverdatabaseusernameinvalid" => $kiriwrite_lang{$language_selected}{serverdatabaseusernameinvalid},
948                 "serverdatabasepasswordtoolong" => $kiriwrite_lang{$language_selected}{serverdatabasepasswordtoolong},
949                 "serverdatabasetableprefixtoolong"      => $kiriwrite_lang{$language_selected}{serverdatabasetableprefixtoolong},
950                 "serverdatabasetableprefixinvalid"      => $kiriwrite_lang{$language_selected}{serverdatabasetableprefixinvalid},
952                 "removeinstallscripttoolong"    => $kiriwrite_lang{$language_selected}{removeinstallscripttoolong},
953                 "cannotwriteconfigurationindirectory"   => $kiriwrite_lang{$language_selected}{cannotwriteconfigurationindirectory},
954                 "configurationfilereadpermissionsinvalid"       => $kiriwrite_lang{$language_selected}{configurationfilereadpermissionsinvalid},
955                 "configurationfilewritepermissionsinvalid"      => $kiriwrite_lang{$language_selected}{configurationfilewritepermissionsinvalid},
957         );
959         # Check if the specified error is blank and if it is
960         # use the generic error messsage.
962         if (!$kiriwrite_error{$error_type}){
963                 $error_type = "generic";
964         }
966         print header();
968         print start_html({ -title => $kiriwrite_lang{$language_selected}{error}, -style => { -code => $cssstyle }});
970         print h2($kiriwrite_lang{$language_selected}{error});
972         print $kiriwrite_error{$error_type};
973         print br();
974         print $kiriwrite_lang{$language_selected}{errormessagetext};
976         print end_html();
978         exit;
982 sub kiriwrite_writeconfig{
983 #################################################################################
984 # kiriwrite_writeconfig: Writes a configuration file.                           #
985 #                                                                               #
986 # Usage:                                                                        #
987 #                                                                               #
988 # kiriwrite_writeconfig();                                                      #
989 #################################################################################
991         my ($passedsettings) = @_;
993         # Open the configuration file for writing.
995         open (my $configfile, "> " . "kiriwrite.cfg");
997         print $configfile "[config]
998                 directory_data_db = $passedsettings->{DatabaseDirectory}
999                 directory_data_output = $passedsettings->{OutputDirectory}
1000                 directory_noncgi_images = $passedsettings->{ImagesURIPath}
1001                 
1002                 system_language = $passedsettings->{Language}
1003                 system_presmodule = $passedsettings->{PresentationModule}
1004                 system_dbmodule = $passedsettings->{DatabaseModule}
1005                 system_datetime = $passedsettings->{DateFormat}
1006                 
1007                 display_textareacols = $passedsettings->{TextAreaCols}
1008                 display_textarearows = $passedsettings->{TextAreaRows}
1009                 
1010                 database_server = $passedsettings->{DatabaseServer}
1011                 database_port = $passedsettings->{DatabasePort}
1012                 database_protocol = $passedsettings->{DatabaseProtocol}
1013                 database_sqldatabase = $passedsettings->{DatabaseName}
1014                 database_username = $passedsettings->{DatabaseUsername}
1015                 database_password = $passedsettings->{DatabasePassword}
1016                 database_tableprefix = $passedsettings->{DatabaseTablePrefix}
1017         ";
1019         close ($configfile);
1023 #################################################################################
1024 # End list of subroutines.                                                      #
1025 #################################################################################
1027 if (!$http_query_confirm){
1029         $http_query_confirm = 0;
1033 if ($http_query_confirm eq 1){
1035         # The confirm value has been given so get the data from the query.
1037         my $http_query_dbdirectory              = $query->param('dbdirectory');
1038         my $http_query_outputdirectory          = $query->param('outputdirectory');
1039         my $http_query_imagesuripath            = $query->param('imagesuripath');
1041         my $http_query_textarearows             = $query->param('textarearows');
1042         my $http_query_textareacols             = $query->param('textareacols');
1044         my $http_query_dateformat               = $query->param('dateformat');
1045         my $http_query_customdateformat         = $query->param('customdateformat');
1047         my $http_query_language                 = $query->param('language');
1049         my $http_query_presmodule               = $query->param('presmodule');
1050         my $http_query_dbmodule                 = $query->param('dbmodule');
1052         my $http_query_databaseserver           = $query->param('databaseserver');
1053         my $http_query_databaseport             = $query->param('databaseport');
1054         my $http_query_databaseprotocol         = $query->param('databaseprotocol');
1055         my $http_query_databasename             = $query->param('databasename');
1056         my $http_query_databaseusername         = $query->param('databaseusername');
1057         my $http_query_databasepassword         = $query->param('databasepassword');
1058         my $http_query_databasetableprefix      = $query->param('databasetableprefix');
1059         my $http_query_removeinstallscript      = $query->param('removeinstallscript');
1061         # Check if the text area rows and column values are blank.
1063         if (!$http_query_textarearows){
1065                 # The text area rows value is blank so return
1066                 # an error.
1068                 kiriwrite_error("textarearowblank");
1070         }
1072         if (!$http_query_textareacols){
1074                 # The text area columns value is blank so
1075                 # return an error.
1077                 kiriwrite_error("textareacolsblank");
1079         }
1081         # Check the length of the variables.
1083         my $kiriwrite_dbdirectory_length_check          = kiriwrite_variablecheck($http_query_dbdirectory, "maxlength", 64, 1);
1084         my $kiriwrite_outputdirectory_length_check      = kiriwrite_variablecheck($http_query_outputdirectory, "maxlength", 64, 1);
1085         my $kiriwrite_imagesuripath_length_check        = kiriwrite_variablecheck($http_query_imagesuripath, "maxlength", 512, 1);
1086         my $kiriwrite_textarearow_length_check          = kiriwrite_variablecheck($http_query_textarearows, "maxlength", 3, 1);
1087         my $kiriwrite_textareacols_length_check         = kiriwrite_variablecheck($http_query_textareacols, "maxlength", 3, 1);
1088         my $kiriwrite_dateformat_length_check           = kiriwrite_variablecheck($http_query_dateformat, "maxlength", 32, 1);
1089         my $kiriwrite_customdateformat_length_check     = kiriwrite_variablecheck($http_query_customdateformat, "maxlength", 32, 1);
1090         my $kiriwrite_language_length_check             = kiriwrite_variablecheck($http_query_language, "maxlength", 16, 1);
1092         # Check if any errors occured while checking the
1093         # length of the variables.
1095         if ($kiriwrite_dbdirectory_length_check eq 1){
1097                 # The database directory given is too long
1098                 # so return an error.
1100                 kiriwrite_error("dbdirectorytoolong");
1102         }
1104         if ($kiriwrite_outputdirectory_length_check eq 1){
1106                 # The output directory given is too long
1107                 # so return an error.
1109                 kiriwrite_error("outputdirectorytoolong");
1111         }
1113         if ($kiriwrite_imagesuripath_length_check eq 1){
1115                 # The images URI path given is too long
1116                 # so return an error.
1118                 kiriwrite_error("imagesuripathtoolong");
1120         }
1122         if ($kiriwrite_dateformat_length_check eq 1){
1124                 # The date format given is too long
1125                 # so return an error.
1127                 kiriwrite_error("dateformattoolong");
1129         }
1131         if ($kiriwrite_customdateformat_length_check eq 1){
1133                 # The date format given is too long
1134                 # so return an error.
1136                 kiriwrite_error("customdateformattoolong");
1138         }
1140         if ($kiriwrite_language_length_check eq 1){
1142                 # The language filename given is too long
1143                 # so return an error.
1145                 kiriwrite_error("languagefilenametoolong");
1147         }
1149         if ($kiriwrite_textarearow_length_check eq 1){
1151                 # The text area rows length is too long
1152                 # so return an error.
1154                 kiriwrite_error("textarearowtoolong");
1156         }
1158         if ($kiriwrite_textareacols_length_check eq 1){
1160                 # The text area columns length is too long
1161                 # so return an error.
1163                 kiriwrite_error("textareacolstoolong");
1165         }
1167         # Check if the custom date and time setting has anything
1168         # set and if it doesn't then use the predefined one set.
1170         my $finaldateformat = "";
1172         if ($http_query_customdateformat ne ""){
1174                 $finaldateformat = $http_query_customdateformat;
1176         } else {
1178                 $finaldateformat = $http_query_dateformat;
1180         }
1182         my $kiriwrite_datetime_check            = kiriwrite_variablecheck($finaldateformat, "datetime", 0, 1);
1184         if ($kiriwrite_datetime_check eq 1){
1186                 # The date and time format is blank so return
1187                 # an error.
1189                 kiriwrite_error("dateformatblank");
1191         } elsif ($kiriwrite_datetime_check eq 2){
1193                 # The date and time format is invalid so
1194                 # return an error.
1196                 kiriwrite_error("dateformatinvalid");
1198         }
1200         # Check if the language filename given is valid.
1202         my $kiriwrite_language_languagefilename_check = kiriwrite_variablecheck($http_query_language, "language_filename", "", 1);
1204         if ($kiriwrite_language_languagefilename_check eq 1) {
1206                 # The language filename given is blank so
1207                 # return an error.
1209                 kiriwrite_error("languagefilenameblank");
1211         } elsif ($kiriwrite_language_languagefilename_check eq 2){
1213                 # The language filename given is invalid so
1214                 # return an error.
1216                 kiriwrite_error("languagefilenameinvalid");
1218         }
1220         # Check if the directory names only contain letters and numbers and
1221         # return a specific error if they don't.
1223         my $kiriwrite_dbdirectory_check         = kiriwrite_variablecheck($http_query_dbdirectory, "directory", 0, 1);
1224         my $kiriwrite_outputdirectory_check     = kiriwrite_variablecheck($http_query_outputdirectory, "directory", 0, 1);
1226         if ($kiriwrite_dbdirectory_check eq 1){
1228                 # The database directory name is blank, so return
1229                 # an error.
1231                 kiriwrite_error("dbdirectoryblank");
1233         } elsif ($kiriwrite_dbdirectory_check eq 2){
1235                 # The database directory name is invalid, so return
1236                 # an error.
1238                 kiriwrite_error("dbdirectoryinvalid");
1240         }
1242         if ($kiriwrite_outputdirectory_check eq 1){
1244                 # The output directory name is blank, so return
1245                 # an error.
1247                 kiriwrite_error("outputdirectoryblank");
1249         } elsif ($kiriwrite_outputdirectory_check eq 2){
1251                 # The output directory name is invalid, so return
1252                 # an error.
1254                 kiriwrite_error("outputdirectoryinvalid");
1256         }
1258         if ($kiriwrite_dbdirectory_check eq 1){
1260                 # The database directory name is blank, so return
1261                 # an error.
1263                 kiriwrite_error("dbdirectoryblank");
1265         } elsif ($kiriwrite_dbdirectory_check eq 2){
1267                 # The database directory name is invalid, so return
1268                 # an error.
1270                 kiriwrite_error("dbdirectoryinvalid");
1272         }
1274         if ($kiriwrite_outputdirectory_check eq 1){
1276                 # The output directory name is blank, so return
1277                 # an error.
1279                 kiriwrite_error("outputdirectoryblank");
1281         } elsif ($kiriwrite_outputdirectory_check eq 2){
1283                 # The output directory name is invalid, so return
1284                 # an error.
1286                 kiriwrite_error("outputdirectoryinvalid");
1288         }
1290         # Check to see if the text area rows and column values
1291         # are valid.
1293         my $kiriwrite_textarearow_number_check          = kiriwrite_variablecheck($http_query_textarearows, "numbers", 0, 1);
1294         my $kiriwrite_textareacols_number_check         = kiriwrite_variablecheck($http_query_textareacols, "numbers", 0, 1);
1296         if ($kiriwrite_textarearow_number_check eq 1){
1298                 # The text area row value is invalid so return
1299                 # an error.
1301                 kiriwrite_error("textarearowinvalid");
1303         }
1305         if ($kiriwrite_textareacols_number_check eq 1){
1307                 # The text area columns value is invalid so return
1308                 # an error.
1310                 kiriwrite_error("textareacolsinvalid");
1312         }
1314         # Check the module names to see if they're valid.
1316         my $kiriwrite_presmodule_modulename_check       = kiriwrite_variablecheck($http_query_presmodule, "module", 0, 1);
1317         my $kiriwrite_dbmodule_modulename_check         = kiriwrite_variablecheck($http_query_dbmodule, "module", 0, 1);
1319         if ($kiriwrite_presmodule_modulename_check eq 1){
1321                 # The presentation module name is blank, so return
1322                 # an error.
1324                 kiriwrite_error("presmoduleblank");
1326         }
1328         if ($kiriwrite_presmodule_modulename_check eq 2){
1330                 # The presentation module name is invalid, so return
1331                 # an error.
1333                 kiriwrite_error("presmoduleinvalid");
1335         }
1337         if ($kiriwrite_dbmodule_modulename_check eq 1){
1339                 # The database module name is blank, so return
1340                 # an error.
1342                 kiriwrite_error("dbmoduleblank");
1344         }
1346         if ($kiriwrite_dbmodule_modulename_check eq 2){
1348                 # The database module name is invalid, so return
1349                 # an error.
1351                 kiriwrite_error("dbmoduleinvalid");
1353         }
1355         # Check if the database module, presentation module and
1356         # language file exists.
1358         if (!-e "Modules/Presentation/" . $http_query_presmodule . ".pm"){
1360                 # The presentation module is missing so return an
1361                 # error.
1363                 kiriwrite_error("presmodulemissing");
1365         }
1367         if (!-e "Modules/Database/" . $http_query_dbmodule . ".pm"){
1369                 # The database module is missing so return an
1370                 # error.
1372                 kiriwrite_error("dbmodulemissing");
1374         }
1376         if (!-e "lang/" . $http_query_language . ".lang"){
1378                 # The language file is missing so return an
1379                 # error.
1381                 kiriwrite_error("languagefilenamemissing");
1383         }
1385         die();
1387         # Check the database server settings.
1389         my $kiriwrite_databaseserver_length_check               = kiriwrite_variablecheck($http_query_databaseserver, "maxlength", 128, 1);
1390         my $kiriwrite_databaseserver_lettersnumbers_check       = kiriwrite_variablecheck($http_query_databaseserver, "lettersnumbers", 0, 1);
1391         my $kiriwrite_databaseport_length_check                 = kiriwrite_variablecheck($http_query_databaseport, "maxlength", 5, 1);
1392         my $kiriwrite_databaseport_numbers_check                = kiriwrite_variablecheck($http_query_databaseport, "numbers", 0, 1);
1393         my $kiriwrite_databaseport_port_check                   = kiriwrite_variablecheck($http_query_databaseport, "port", 0, 1);
1394         my $kiriwrite_databaseprotocol_length_check             = kiriwrite_variablecheck($http_query_databaseprotocol, "maxlength", 5, 1);
1395         my $kiriwrite_databaseprotocol_protocol_check           = kiriwrite_variablecheck($http_query_databaseprotocol, "serverprotocol", 0, 1);
1396         my $kiriwrite_databasename_length_check                 = kiriwrite_variablecheck($http_query_databasename, "maxlength", 32, 1);
1397         my $kiriwrite_databasename_lettersnumbers_check         = kiriwrite_variablecheck($http_query_databasename, "lettersnumbers", 0, 1);
1398         my $kiriwrite_databaseusername_length_check             = kiriwrite_variablecheck($http_query_databaseusername, "maxlength", 16, 1);
1399         my $kiriwrite_databaseusername_lettersnumbers_check     = kiriwrite_variablecheck($http_query_databaseusername, "lettersnumbers", 0, 1);
1400         my $kiriwrite_databasepassword_length_check             = kiriwrite_variablecheck($http_query_databasepassword, "maxlength", 64, 1);
1401         my $kiriwrite_databasetableprefix_length_check          = kiriwrite_variablecheck($http_query_databasetableprefix, "maxlength", 16, 1);
1402         my $kiriwrite_databasetableprefix_lettersnumbers_check  = kiriwrite_variablecheck($http_query_databasetableprefix, "lettersnumbers", 0, 1);
1404         if ($kiriwrite_databaseserver_length_check eq 1){
1406                 # The length of the database server name is too long so
1407                 # return an error.
1409                 kiriwrite_error("servernametoolong");
1411         }
1413         if ($kiriwrite_databaseserver_lettersnumbers_check eq 1){
1415                 # The database server name contains characters other
1416                 # than letters and numbers, so return an error.
1418                 kiriwrite_error("servernameinvalid");
1420         }
1422         if ($kiriwrite_databaseport_length_check eq 1){
1424                 # The database port number length is too long so return
1425                 # an error.
1427                 kiriwrite_error("serverportnumbertoolong");
1429         }
1431         if ($kiriwrite_databaseport_numbers_check eq 1){
1433                 # The database port number contains characters other
1434                 # than numbers so return an error.
1436                 kiriwrite_error("serverportnumberinvalidcharacters");
1438         }
1440         if ($kiriwrite_databaseport_port_check eq 1){
1442                 # The database port number given is invalid so return
1443                 # an error.
1445                 kiriwrite_error("serverportnumberinvalid");
1447         }
1449         if ($kiriwrite_databaseprotocol_length_check eq 1){
1451                 # The database protocol name given is too long so
1452                 # return an error.
1454                 kiriwrite_error("serverprotocolnametoolong");
1456         }
1458         if ($kiriwrite_databaseprotocol_protocol_check eq 1){
1460                 # The server protcol given is invalid so return
1461                 # an error.
1463                 kiriwrite_error("serverprotocolinvalid");
1465         }
1467         if ($kiriwrite_databasename_length_check eq 1){
1469                 # The SQL database name is too long so return
1470                 # an error.
1472                 kiriwrite_error("serverdatabasenametoolong");
1474         }
1476         if ($kiriwrite_databasename_lettersnumbers_check eq 1){
1478                 # The database name contains invalid characters
1479                 # so return an error.
1481                 kiriwrite_error("serverdatabasenameinvalid");
1483         }
1485         if ($kiriwrite_databaseusername_length_check eq 1){
1487                 # The database username given is too long so
1488                 # return an error.
1490                 kiriwrite_error("serverdatabaseusernametoolong");
1492         }
1494         if ($kiriwrite_databaseusername_lettersnumbers_check eq 1){
1496                 # The database username contains invalid characters
1497                 # so return an error.
1499                 kiriwrite_error("serverdatabaseusernameinvalid");
1501         }
1503         if ($kiriwrite_databasepassword_length_check eq 1){
1505                 # The database password given is too long so return
1506                 # an error.
1508                 kiriwrite_error("serverdatabasepasswordtoolong");
1510         }
1512         if ($kiriwrite_databasetableprefix_length_check eq 1){
1514                 # The database table prefix given is too long so
1515                 # return an error.
1517                 kiriwrite_error("serverdatabasetableprefixtoolong");
1519         }
1521         if ($kiriwrite_databasetableprefix_lettersnumbers_check eq 1){
1523                 # The database table prefix given contains invalid
1524                 # characters so return an error.
1526                 kiriwrite_error("serverdatabasetableprefixinvalid");
1528         }
1530         # Check the length of value of the checkboxes.
1532         my $kiriwrite_removeinstallscript_length_check  = kiriwrite_variablecheck($http_query_removeinstallscript, "maxlength", 2, 1);
1534         if ($kiriwrite_removeinstallscript_length_check eq 1){
1536                 # The remove install script value is too long
1537                 # so return an error.
1539                 kiriwrite_error("removeinstallscripttoolong");
1541         }
1543         # Check if there is write permissions for the directory.
1545         if (!-w '.'){
1547                 # No write permissions for the directory the
1548                 # script is running from so return an error.
1550                 kiriwrite_error("cannotwriteconfigurationindirectory");
1552         }
1554         # Check if the configuration file already exists.
1556         if (-e 'kiriwrite.cfg'){
1558                 # Check if the configuration file has read permissions.
1560                 if (!-r 'kiriwrite.cfg'){
1562                         # The configuration file has invalid read permissions
1563                         # set so return an error.
1565                         kiriwrite("configurationfilereadpermissionsinvalid");
1567                 }
1569                 # Check if the configuration file has write permissions.
1571                 if (!-w 'kiriwrite.cfg'){
1573                         # The configuration file has invalid write permissions
1574                         # set so return an error.
1576                         kiriwrite("configurationfilewritepermissionsinvalid");
1578                 }
1580         }
1582         # Write the new configuration file.
1584         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 });
1586         my $installscriptmessage        = "";
1588         # Check if the installation script should be deleted.
1590         if (!$http_query_removeinstallscript){
1592                 $http_query_removeinstallscript = "off";
1594         }
1596         if ($http_query_removeinstallscript eq "on"){
1598                 if (unlink("install.cgi")){
1600                         $installscriptmessage = $kiriwrite_lang{$language_selected}{installscriptremoved};
1602                 } else {
1604                         $installscriptmessage = $kiriwrite_lang{$language_selected}{cannotremovescript};
1605                         $installscriptmessage =~ s/%s/$!/g;
1607                 }
1609         }
1611         print header();
1613         print start_html({ -title => $kiriwrite_lang{$language_selected}{installertitle}, -style => { -code => $cssstyle }});
1614         print h2($kiriwrite_lang{$language_selected}{installertitle});
1615         print $kiriwrite_lang{$language_selected}{installedmessage};
1617         if ($installscriptmessage){
1619                 print br();
1620                 print br();
1621                 print $installscriptmessage;
1623         }
1625         print br();
1626         print br();
1627         print $kiriwrite_lang{$language_selected}{usekiriwritetext};
1628         print br();
1629         print br();
1630         print a({-href=>'kiriwrite.cgi'}, $kiriwrite_lang{$language_selected}{usekiriwritelink});
1632         exit;
1636 # Create a list of common date and time formats.
1638 my @datetime_formats = [ 
1639         'DD/MM/YY (hh:mm:ss)', 'DD/MM/YY hh:mm:ss', 'D/M/Y (hh:mm:ss)',
1640         'D/M/Y hh:mm:ss', 'D/M/YY (hh:mm:ss)', 'D/M/YY hh:mm:ss',
1641         'DD/MM (hh:mm:ss)', 'D/M (hh:mm:ss)', 'DD/MM hh:mm:ss', 
1642         'D/M hh:mm:ss', 'DD/MM hh:mm', 'D/M hh:mm',
1643         'DD/MM/YY', 'D/M/Y', 'DD/MM',
1645         'YY-MM-DD (hh:mm:ss)', 'YY-MM-DD hh:mm:ss', 'Y-M-D (hh:mm:ss)',
1646         'Y-M-D hh:mm:ss', 'M-D (hh:mm:ss)', 'M-D hh:mm:ss',
1647         'YY-MM-DD', 'MM-DD' 
1648 ];
1650 # Create the list of tests to do.
1652 my ($test_list, %test_list);
1653 my %dependency_results;
1654 my %database_results;
1655 my %file_results;
1656 my $test;
1657 my $date;
1659 my $dependency_error = 0;
1660 my $database_onemodule = 0;
1661 my $database_error = 0;
1662 my $file_error = 0;
1664 my $language_name;
1665 my $language_xml_data;
1666 my $language_file_friendly;
1668 my $presentation_file_friendly;
1670 # Check to see if the needed Perl modules are installed.
1672 $test_list{CheckConfigAuto}{Name}       = "Config::Auto";
1673 $test_list{CheckConfigAuto}{Type}       = "dependency";
1674 $test_list{CheckConfigAuto}{Code}       = "Config::Auto";
1676 $test_list{CheckDBI}{Name}              = "DBI";
1677 $test_list{CheckDBI}{Type}              = "dependency";
1678 $test_list{CheckDBI}{Code}              = "DBI";
1680 $test_list{CheckTieHash}{Name}          = "Tie::IxHash";
1681 $test_list{CheckTieHash}{Type}          = "dependency";
1682 $test_list{CheckTieHash}{Code}          = "Tie::IxHash";
1684 $test_list{CheckCGILite}{Name}          = "CGI::Lite";
1685 $test_list{CheckCGILite}{Type}          = "dependency";
1686 $test_list{CheckCGILite}{Code}          = "CGI::Lite";
1688 $test_list{Encode}{Name}                = "Encode";
1689 $test_list{Encode}{Type}                = "dependency";
1690 $test_list{Encode}{Code}                = "Encode";
1692 $test_list{DBDmysql}{Name}              = "DBD::mysql";
1693 $test_list{DBDmysql}{Type}              = "database";
1694 $test_list{DBDmysql}{Code}              = "DBD::mysql";
1696 $test_list{DBDSQLite}{Name}             = "DBD::SQLite";
1697 $test_list{DBDSQLite}{Type}             = "database";
1698 $test_list{DBDSQLite}{Code}             = "DBD::SQLite";
1700 # Check the file and directory permissions to see if they are correct.
1702 $test_list{MainDirectory}{Name}         = "Kiriwrite Directory (.)";
1703 $test_list{MainDirectory}{Type}         = "file";
1704 $test_list{MainDirectory}{Code}         = ".";
1705 $test_list{MainDirectory}{Writeable}    = "1";
1707 $test_list{LanguageDirectory}{Name}             = "Language Directory (lang)";
1708 $test_list{LanguageDirectory}{Type}             = "file";
1709 $test_list{LanguageDirectory}{Code}             = "lang";
1710 $test_list{LanguageDirectory}{Writeable}        = "0";
1712 $test_list{LibraryDirectory}{Name}              = "Library Directory (lib)";
1713 $test_list{LibraryDirectory}{Type}              = "file";
1714 $test_list{LibraryDirectory}{Code}              = "lib";
1715 $test_list{LibraryDirectory}{Writeable}         = "0";
1717 $test_list{ModulesDirectory}{Name}              = "Modules Directory (Modules)";
1718 $test_list{ModulesDirectory}{Type}              = "file";
1719 $test_list{ModulesDirectory}{Code}              = "Modules";
1720 $test_list{ModulesDirectory}{Writeable}         = "0";
1722 $test_list{DBModulesDirectory}{Name}            = "Database Modules Directory (Modules/Database)";
1723 $test_list{DBModulesDirectory}{Type}            = "file";
1724 $test_list{DBModulesDirectory}{Code}            = "Modules/Database";
1725 $test_list{DBModulesDirectory}{Writeable}       = "0";
1727 $test_list{PresModulesDirectory}{Name}          = "Presentation Modules Directory (Modules/Presentation)";
1728 $test_list{PresModulesDirectory}{Type}          = "file";
1729 $test_list{PresModulesDirectory}{Code}          = "Modules/Presentation";
1730 $test_list{PresModulesDirectory}{Writeable}     = "0";
1732 # Preform those tests.
1734 foreach $test (keys %test_list){
1736         # Check the type of test.
1738         if ($test_list{$test}{Type} eq "dependency"){
1740                 if (eval "require " . $test_list{$test}{Code}){
1742                         # The module exists and is working correctly.
1744                         $dependency_results{$test_list{$test}{Name}}{result}    = $kiriwrite_lang{$language_selected}{testpass};
1746                 } else {
1748                         # The module does not exist or has an error.
1750                         $dependency_error = 1;
1751                         $dependency_results{$test_list{$test}{Name}}{result}    = $kiriwrite_lang{$language_selected}{testfail};
1753                 }
1755         } elsif ($test_list{$test}{Type} eq "database"){
1757                 if (eval "require " . $test_list{$test}{Code}){
1759                         # The module exists and it is working correctly.
1761                         $database_results{$test_list{$test}{Name}}{result}      = $kiriwrite_lang{$language_selected}{testpass};
1762                         $database_onemodule = 1;
1764                 } else {
1766                         # The module does not exist or has an error.
1768                         $database_error = 1;
1769                         $database_results{$test_list{$test}{Name}}{result}      = $kiriwrite_lang{$language_selected}{testfail};
1771                 }
1773         } elsif ($test_list{$test}{Type} eq "file"){
1775                 if (-e $test_list{$test}{Code}){
1777                         # The filename given does exist.
1779                 } else {
1781                         # the filename given does not exist.
1783                         $file_error = 1;
1784                         $file_results{$test_list{$test}{Name}}{result}  = $kiriwrite_lang{$language_selected}{errormessage} . $kiriwrite_lang{$language_selected}{doesnotexist};
1786                 }       
1788                 # Test to see if the filename given has read
1789                 # permissions.
1791                 if (-r $test_list{$test}{Code}){
1793                         # The filename given has valid permissions set.
1795                         $file_results{$test_list{$test}{Name}}{result}  = $kiriwrite_lang{$language_selected}{testpass};
1797                 } else {
1799                         # The filename given has invalid permissions set.
1801                         $file_error = 1;
1802                         $file_results{$test_list{$test}{Name}}{result} = $kiriwrite_lang{$language_selected}{errormessage} . $kiriwrite_lang{$language_selected}{invalidpermissionsset};
1804                 }
1806                 if ($test_list{$test}{Writeable} eq 1){
1808                         # Test to see if the filename given has write
1809                         # permissions.
1811                         if (-w $test_list{$test}{Code}){
1813                                 # The filename given has valid permissions set.
1815                                 $file_results{$test_list{$test}{Name}}{result}  = $kiriwrite_lang{$language_selected}{testpass};
1817                         } else {
1819                                 # The filename given has invalid permissions set.
1821                                 $file_error = 1;
1822                                 $file_results{$test_list{$test}{Name}}{result}  = $kiriwrite_lang{$language_selected}{errormessage} . $kiriwrite_lang{$language_selected}{invalidpermissionsset};
1824                         }
1826                 }
1828         }
1832 # Print the header.
1834 print header();
1836 # Print the page for installing Kiriwrite.
1838 print start_html( -title=> $kiriwrite_lang{$language_selected}{installertitle}, -style => { -code => $cssstyle });
1840 print start_table( { -width=> "100%" } );
1841 print start_Tr();
1842 print start_td({ -class => "languagebar" });
1843 print $kiriwrite_lang{$language_selected}{installertitle};
1844 print end_td();
1845 print start_td({ -class => "languagebarselect" });
1846 print start_form("POST", "install.cgi");
1848 # This is a bodge for the language list.
1850 my $language_name_short;
1851 my $language_list_seek = 0;
1853 print "<select name=\"installlanguage\">";
1855 foreach $language_name_short (@language_list_short){
1857         print "<option value=\"" . $language_name_short . "\">" . $language_list_long[$language_list_seek] . "</option>";
1858         $language_list_seek++;
1862 print "</select> ";
1863 print submit($kiriwrite_lang{$language_selected}{switch});
1865 print end_form;
1866 print end_td();
1867 print end_Tr();
1868 print end_table();
1870 print h2($kiriwrite_lang{$language_selected}{installertitle});
1872 print $kiriwrite_lang{$language_selected}{installertext};
1874 print h3($kiriwrite_lang{$language_selected}{dependencytitle});
1875 print h4($kiriwrite_lang{$language_selected}{requiredmodules});
1876 print $kiriwrite_lang{$language_selected}{perlmodules};
1877 print br();;
1878 print br();;
1880 if ($dependency_error eq 1){
1882         print $kiriwrite_lang{$language_selected}{errormessage};
1883         print $kiriwrite_lang{$language_selected}{dependencyperlmodulesmissing};
1884         print br();
1885         print br();
1889 print start_table();
1890 print start_Tr();
1891 print start_td({ -class => "tablecellheader" });
1892 print $kiriwrite_lang{$language_selected}{module};
1893 print end_td();
1894 print start_td({ -class => "tablecellheader" });
1895 print $kiriwrite_lang{$language_selected}{result};
1896 print end_td();
1897 print end_Tr();
1899 foreach $test (keys %dependency_results) {
1901         print start_Tr();
1902         print start_td({ -class => "tablename" });
1903                 print $test;
1904         print end_td();
1905         print start_td({ -class => "tabledata" });
1906                 print $dependency_results{$test}{result};
1907         print end_td();
1908         print end_Tr();
1912 print end_table();
1914 print h4($kiriwrite_lang{$language_selected}{databasemodules});
1915 print $kiriwrite_lang{$language_selected}{databasemodulestext};
1916 print br();
1917 print br();
1919 if ($database_error eq 1){
1921         print $kiriwrite_lang{$language_selected}{warningmessage};
1922         print $kiriwrite_lang{$language_selected}{databaseperlmodulesmissing};
1923         print br();
1924         print br();
1928 print start_table();
1929 print start_Tr();
1930 print start_td({ -class => "tablecellheader" });
1931 print $kiriwrite_lang{$language_selected}{module};
1932 print end_td();
1933 print start_td({ -class => "tablecellheader" });
1934 print $kiriwrite_lang{$language_selected}{result};
1935 print end_td();
1936 print end_Tr();
1938 foreach $test (keys %database_results) {
1940         print start_Tr();
1941         print start_td({ -class => "tablename" });
1942                 print $test;
1943         print end_td();
1944         print start_td({ -class => "tabledata" });
1945                 print $database_results{$test}{result};
1946         print end_td();
1947         print end_Tr();
1951 print end_table();
1953 print h4($kiriwrite_lang{$language_selected}{filepermissions});
1955 print $kiriwrite_lang{$language_selected}{filepermissionstext};
1956 print br();
1957 print br();
1959 if ($file_error eq 1){
1961         print $kiriwrite_lang{$language_selected}{errormessage};
1962         print $kiriwrite_lang{$language_selected}{filepermissionsinvalid};
1963         print br();
1964         print br();
1968 print start_table();
1969 print start_Tr();
1970 print start_td({ -class => "tablecellheader" });
1971 print "Filename";
1972 print end_td();
1973 print start_td({ -class => "tablecellheader" });
1974 print "Result";
1975 print end_td();
1976 print end_Tr();
1978 foreach $test (keys %file_results) {
1980         print start_Tr();
1981         print start_td({ -class => "tablename" });
1982                 print $test;
1983         print end_td();
1984         print start_td({ -class => "tabledata" });
1985                 print $file_results{$test}{result};
1986         print end_td();
1987         print end_Tr();
1991 print end_table();
1993 if ($dependency_error eq 1){
1995         print hr();
1996         print h4($kiriwrite_lang{$language_selected}{criticalerror});
1997         print $kiriwrite_lang{$language_selected}{dependencymodulesnotinstalled};
1998         print end_html;
1999         exit;
2003 if ($database_onemodule eq 0){
2005         print hr();
2006         print h4($kiriwrite_lang{$language_selected}{criticalerror});
2007         print $kiriwrite_lang{$language_selected}{databasemodulesnotinstalled};
2008         print end_html;
2009         exit;
2013 if ($file_error eq 1){
2015         print hr();
2016         print h4($kiriwrite_lang{$language_selected}{criticalerror});
2017         print $kiriwrite_lang{$language_selected}{filepermissionerrors};
2018         print end_html;
2019         exit;
2023 my @language_short;
2024 my (%available_languages, $available_languages);
2025 my @presentation_modules;
2026 my @database_modules;
2028 my $presentation_modules_ref = \@presentation_modules;
2029 my $database_modules_ref = \@database_modules;
2031 # Get the list of available languages.
2033 tie(%available_languages, 'Tie::IxHash');
2035 opendir(LANGUAGEDIR, "lang");
2036 my @language_directory = grep /m*\.lang$/, readdir(LANGUAGEDIR);
2037 closedir(LANGUAGEDIR);
2039 my $language_data;
2041 foreach my $language_file (@language_directory){
2043         # Load the language file.
2045         $language_data = Config::Auto::parse("lang/" . $language_file, format => "ini");
2047         # Load the XML data.
2048         #$language_xml_data = $xsl->XMLin("lang/" . $language_file);
2050         # Get the friendly name for the language file.
2052         $language_file_friendly = $language_file;
2053         $language_file_friendly =~ s/.lang$//g;
2055         $language_name = $language_data->{about}->{name};
2057         $available_languages{$language_file_friendly} = $language_name . " (" . $language_file_friendly . ")";
2061 # Get the list of presentation modules.
2063 opendir(OUTPUTSYSTEMDIR, "Modules/Presentation");
2064 my @presmodule_directory = grep /m*\.pm$/, readdir(OUTPUTSYSTEMDIR);
2065 closedir(OUTPUTSYSTEMDIR);
2067 foreach my $presmodule_file (@presmodule_directory){
2069         # Get the friendly name for the database module.
2071         $presmodule_file =~ s/.pm$//g;
2073         push(@presentation_modules, $presmodule_file);
2077 # Get the list of database modules.
2079 opendir(DATABASEDIR, "Modules/Database");
2080 my @dbmodule_directory = grep /m*\.pm$/, readdir(DATABASEDIR);
2081 closedir(DATABASEDIR);
2083 foreach my $dbmodule_file (@dbmodule_directory){
2085         # Get the friendly name for the database module.
2087         $dbmodule_file =~ s/.pm$//g;
2089         push(@database_modules, $dbmodule_file);
2093 print h3($kiriwrite_lang{$language_selected}{settingstitle});
2095 print $kiriwrite_lang{$language_selected}{settingstext};
2096 print br();
2097 print br();
2099 print start_form("POST", "install.cgi");
2100 print hidden( -name => 'confirm', -default => '1');
2101 print hidden( -name => 'installlanguage', -default => $language_selected);
2103 print start_table({ -width => "100%" });
2105 print start_Tr();
2106 print start_td({ -class => "tablecellheader" });
2107 print $kiriwrite_lang{$language_selected}{setting};
2108 print end_td();
2109 print start_td({ -class => "tablecellheader" });
2110 print $kiriwrite_lang{$language_selected}{value};
2111 print end_td();
2112 print end_Tr();
2114 print start_Tr();
2115 print start_td({ -class => "tablecellheader" });
2116 print $kiriwrite_lang{$language_selected}{directories};
2117 print end_td();
2118 print start_td({ -class => "tablecellheader" });
2119 print end_td();
2120 print end_Tr();
2122 print start_Tr();
2123 print start_td({ -class => "tablename" });
2124 print $kiriwrite_lang{$language_selected}{databasedirectory};
2125 print end_td();
2126 print start_td({ -class => "tabledata" });
2127 print textfield({ -name => "dbdirectory", -size => 32, -maxlength => 64, -value => $default_dbdirectory });
2128 print end_td();
2129 print end_Tr();
2131 print start_Tr();
2132 print start_td({ -class => "tablename" });
2133 print $kiriwrite_lang{$language_selected}{outputdirectory};
2134 print end_td();
2135 print start_td({ -class => "tabledata" });
2136 print textfield({ -name => "outputdirectory", -size => 32, -maxlength => 64, -value => $default_outputdirectory });
2137 print end_td();
2138 print end_Tr();
2140 print start_Tr();
2141 print start_td({ -class => "tablename" });
2142 print $kiriwrite_lang{$language_selected}{imagesuripath};
2143 print end_td();
2144 print start_td({ -class => "tabledata" });
2145 print textfield({ -name => "imagesuripath", -size => 32, -maxlength => 64, -value => $default_imagesuri });
2146 print end_td();
2147 print end_Tr();
2149 print start_Tr();
2150 print start_td({ -class => "tablecellheader" });
2151 print $kiriwrite_lang{$language_selected}{display};
2152 print end_td();
2153 print start_td({ -class => "tablecellheader" });
2154 print end_td();
2155 print end_Tr();
2157 print start_Tr();
2158 print start_td({ -class => "tablename" });
2159 print $kiriwrite_lang{$language_selected}{textarearows};
2160 print end_td();
2161 print start_td({ -class => "tabledata" });
2162 print textfield({ -name => "textarearows", -size => 3, -maxlength => 3, -value => $default_textarearows });
2163 print end_td();
2164 print end_Tr();
2166 print start_Tr();
2167 print start_td({ -class => "tablename" });
2168 print $kiriwrite_lang{$language_selected}{textareacols};
2169 print end_td();
2170 print start_td({ -class => "tabledata" });
2171 print textfield({ -name => "textareacols", -size => 3, -maxlength => 3, -value => $default_textareacols });
2172 print end_td();
2173 print end_Tr();
2175 print start_Tr();
2176 print start_td({ -class => "tablecellheader" });
2177 print $kiriwrite_lang{$language_selected}{date};
2178 print end_td();
2179 print start_td({ -class => "tablecellheader" });
2180 print "";
2181 print end_td();
2182 print end_Tr();
2184 print start_Tr();
2185 print start_td({ -class => "tablename" });
2186 print $kiriwrite_lang{$language_selected}{dateformat};
2187 print end_td();
2188 print start_td({ -class => "tabledata" });
2190 print popup_menu( -name => "dateformat", -values => @datetime_formats );
2191 print textfield({ -name => "customdateformat", -size => 32, -maxlength => 64, });
2193 print end_td();
2194 print end_Tr();
2196 print start_Tr();
2197 print start_td({ -class => "tablecellheader" });
2198 print $kiriwrite_lang{$language_selected}{language};
2199 print end_td();
2200 print start_td({ -class => "tablecellheader" });
2201 print end_td();
2202 print end_Tr();
2204 print start_Tr();
2205 print start_td({ -class => "tablename" });
2206 print $kiriwrite_lang{$language_selected}{systemlanguage};
2207 print end_td();
2208 print start_td({ -class => "tabledata" });
2210 # Note: This the following code is bodge. If anyone can fix it so that it all works
2211 # with popup_menu properly it will be appriciated.
2213 print "<select name=\"language\">";
2215 foreach my $language (keys %available_languages){
2217         if ($language eq $language_selected){
2219                 print "<option value=\"" . $language . "\" selected=selected>" . $available_languages{$language} . "</option>";
2221         } else {
2223                 print "<option value=\"" . $language . "\">" . $available_languages{$language} . "</option>";
2225         }
2229 print "</select>";
2231 print end_td();
2232 print end_Tr();
2234 print start_Tr();
2235 print start_td({ -class => "tablecellheader" });
2236 print $kiriwrite_lang{$language_selected}{modules};
2237 print end_td();
2238 print start_td({ -class => "tablecellheader" });
2239 print "";
2240 print end_td();
2241 print end_Tr();
2243 print start_Tr();
2244 print start_td({ -class => "tablename" });
2245 print $kiriwrite_lang{$language_selected}{presentationmodule};
2246 print end_td();
2247 print start_td({ -class => "tabledata" });
2248 print popup_menu({ -name => 'presmodule', -values => $presentation_modules_ref, -default => "HTML4S" });
2249 print end_td();
2250 print end_Tr();
2252 print start_Tr();
2253 print start_td({ -class => "tablename" });
2254 print $kiriwrite_lang{$language_selected}{databasemodule};
2255 print end_td();
2256 print start_td({ -class => "tabledata" });
2257 print popup_menu({ -name => 'dbmodule', -values => $database_modules_ref, -default => "SQLite" });
2258 print end_td();
2259 print end_Tr();
2261 print start_Tr();
2262 print start_td({ -class => "tablename" });
2263 print $kiriwrite_lang{$language_selected}{databaseserver};
2264 print end_td();
2265 print start_td({ -class => "tabledata" });
2266 print textfield({ -name => "databaseserver", -size => 32, -maxlength => 128, -value => $default_server });
2267 print end_td();
2268 print end_Tr();
2270 print start_Tr();
2271 print start_td({ -class => "tablename" });
2272 print $kiriwrite_lang{$language_selected}{databaseport};
2273 print end_td();
2274 print start_td({ -class => "tabledata" });
2275 print textfield({ -name => "databaseport", -maxlength => 5, -size => 5, -value => $default_port });
2276 print end_td();
2277 print end_Tr();
2279 print start_Tr();
2280 print start_td({ -class => "tablename" });
2281 print $kiriwrite_lang{$language_selected}{databaseprotocol};
2282 print end_td();
2283 print start_td({ -class => "tabledata" });
2284 print popup_menu( -name => "databaseprotocol", -values => [ 'tcp', 'udp' ], -default => $default_protocol);
2285 print end_td();
2286 print end_Tr();
2288 print start_Tr();
2289 print start_td({ -class => "tablename" });
2290 print $kiriwrite_lang{$language_selected}{databasename};
2291 print end_td();
2292 print start_td({ -class => "tabledata" });
2293 print textfield({ -name => "databasename", -size => 32, -maxlength => 32, -default => $default_name });
2294 print end_td();
2295 print end_Tr();
2297 print start_Tr();
2298 print start_td({ -class => "tablename" });
2299 print $kiriwrite_lang{$language_selected}{databaseusername};
2300 print end_td();
2301 print start_td({ -class => "tabledata" });
2302 print textfield({ -name => "databaseusername", -size => 16, -maxlength => 16, -default => $default_username });
2303 print end_td();
2304 print end_Tr();
2306 print start_Tr();
2307 print start_td({ -class => "tablename" });
2308 print $kiriwrite_lang{$language_selected}{databasepassword};
2309 print end_td();
2310 print start_td({ -class => "tabledata" });
2311 print password_field({ -name => "databasepassword", -size => 32, -maxlength => 64 });
2312 print end_td();
2313 print end_Tr();
2315 print start_Tr();
2316 print start_td({ -class => "tablename" });
2317 print $kiriwrite_lang{$language_selected}{databasetableprefix};
2318 print end_td();
2319 print start_td({ -class => "tabledata" });
2320 print textfield({ -name => "databasetableprefix", -size => 32, -maxlength => 32, -default => $default_prefix });
2321 print end_td();
2322 print end_Tr();
2324 print start_Tr();
2325 print start_td({ -class => "tablecellheader" });
2326 print $kiriwrite_lang{$language_selected}{installationoptions};
2327 print end_td();
2328 print start_td({ -class => "tablecellheader" });
2329 print "";
2330 print end_td();
2331 print end_Tr();
2333 print start_Tr();
2334 print start_td({ -class => "tablename" });
2335 print $kiriwrite_lang{$language_selected}{installoptions};
2336 print end_td();
2337 print start_td({ -class => "tabledata" });
2338 print checkbox( -name => 'removeinstallscript', -checked => 1, -label => " " . $kiriwrite_lang{$language_selected}{removeinstallscript});
2339 print end_td();
2340 print end_Tr();
2342 print end_table();
2344 print br();
2345 print submit($kiriwrite_lang{$language_selected}{savesettingsbutton});
2346 print " | ";
2347 print reset($kiriwrite_lang{$language_selected}{resetsettingsbutton});
2349 print end_form();
2351 print end_html;
2352 exit;
2354 __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