Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Changes made in preperation for Kiriwrite 0.4.0
[kiriwrite/.git] / cgi-files / install.cgi
1 #!/usr/bin/perl -Tw
3 #################################################################################
4 # Kiriwrite Installer Script (install.pl/install.cgi)                           #
5 # Installation script for Kiriwrite                                             #
6 #                                                                               #
7 # Version: 0.4.0                                                                #
8 # mod_perl 2.x compatabile version                                              #
9 #                                                                               #
10 # Copyright (C) 2005-2008 Steve Brokenshire <sbrokenshire@xestia.co.uk>         #
11 #                                                                               #
12 # This program is free software; you can redistribute it and/or modify it under #
13 # the terms of the GNU General Public License as published by the Free          #
14 # Software Foundation; as version 2 of the License.                             #
15 #                                                                               #
16 # This program is distributed in the hope that it will be useful, but WITHOUT   #
17 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS #
18 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.#
19 #                                                                               #
20 # You should have received a copy of the GNU General Public License along with  #
21 # this program; if not, write to the Free Software Foundation, Inc., 51         #
22 # Franklin St, Fifth Floor, Boston, MA 02110-1301 USA                           #
23 ################################################################################# 
25 use strict;                             # Throw errors if there's something wrong.
26 use warnings;                           # Write warnings to the HTTP Server Log file.
28 use utf8;
29 use CGI::Lite;
31 eval "use CGI::Lite";
33 if ($@){
34         print "Content-type: text/html;\r\n\r\n";
35         print "The CGI::Lite Perl Module is not installed. Please install CGI::Lite and then run this installation script again.";
36         exit;
37 }
39 # Check if mod_perl is running and if it is then add a notice to say
40 # that additional configuration has to be made.
42 my $modperlenabled = 0;
43 my $installscriptname = "install.cgi";
44 my $kiriwritescriptname = "kiriwrite.cgi";
46 if ($ENV{'MOD_PERL'}){
48         # MOD_PERL 2.X SPECIFIC SECTION.
50         use lib '';
51         chdir('');
53         $modperlenabled         = 1;
54         $installscriptname      = "install.pl";
55         $kiriwritescriptname    = "kiriwrite.pl";
57 }
59 # Setup strings in specific languages. Style should be no spacing for
60 # language title and one tabbed spacing for each string.
62 # Define some default settings.
64 my $default_language            = "en-GB";
65 my $default_dbdirectory         = "db";
66 my $default_outputdirectory     = "output";
67 my $default_imagesuri           = "/images/kiriwrite";
69 my $default_textarearows        = "10";
70 my $default_textareacols        = "50";
72 my $default_server              = "localhost";
73 my $default_port                = "3306";
74 my $default_protocol            = "tcp";
75 my $default_name                = "database";
76 my $default_username            = "username";
77 my $default_prefix              = "kiriwrite";
79 my ($kiriwrite_lang, %kiriwrite_lang);
81 $kiriwrite_lang{"en-GB"}{"languagename"}        = "English (British)";
82         $kiriwrite_lang{"en-GB"}{"testpass"}            = "OK";
83         $kiriwrite_lang{"en-GB"}{"testfail"}            = "Error";
85         $kiriwrite_lang{"en-GB"}{"generic"}                     = "An error occured which is not known to the Kiriwrite installer.";
86         $kiriwrite_lang{"en-GB"}{"invalidvariable"}             = "The variable given was invalid.";
87         $kiriwrite_lang{"en-GB"}{"invalidvalue"}                = "The value given was invalid.";
88         $kiriwrite_lang{"en-GB"}{"invalidoption"}               = "The option given was invalid.";
89         $kiriwrite_lang{"en-GB"}{"variabletoolong"}             = "The variable given is too long.";
90         $kiriwrite_lang{"en-GB"}{"blankdirectory"}              = "The directory name given is blank.";
91         $kiriwrite_lang{"en-GB"}{"invaliddirectory"}            = "The directory name given is invalid.";
92         $kiriwrite_lang{"en-GB"}{"moduleblank"}                 = "The module filename given is blank.";
93         $kiriwrite_lang{"en-GB"}{"moduleinvalid"}               = "The module filename given is invalid.";
95         $kiriwrite_lang{"en-GB"}{"dbdirectorytoolong"}          = "The database directory name given is too long.";
96         $kiriwrite_lang{"en-GB"}{"outputdirectorytoolong"}      = "The output directory name given is too long.";
97         $kiriwrite_lang{"en-GB"}{"imagesuripathtoolong"}        = "The images URI path name given is too long.";
98         $kiriwrite_lang{"en-GB"}{"dateformattoolong"}           = "The date format given is too long.";
99         $kiriwrite_lang{"en-GB"}{"customdateformattoolong"}     = "The custom date format given is too long.";
100         $kiriwrite_lang{"en-GB"}{"languagefilenametoolong"}     = "The language filename given is too long.";
102         $kiriwrite_lang{"en-GB"}{"dateformatblank"}             = "The date format given was blank.";
103         $kiriwrite_lang{"en-GB"}{"dateformatinvalid"}           = "The date format given is invalid.";
104         $kiriwrite_lang{"en-GB"}{"languagefilenameinvalid"}     = "The language filename given is invalid.";
106         $kiriwrite_lang{"en-GB"}{"dbdirectoryblank"}            = "The database directory name given is blank.";
107         $kiriwrite_lang{"en-GB"}{"dbdirectoryinvalid"}          = "The database directory name given is invalid.";
109         $kiriwrite_lang{"en-GB"}{"outputdirectoryblank"}        = "The output directory name given is blank.";
110         $kiriwrite_lang{"en-GB"}{"outputdirectoryinvalid"}      = "The output directory name given is invalid.";
112         $kiriwrite_lang{"en-GB"}{"textarearowblank"}            = "The text area row value given is blank.";
113         $kiriwrite_lang{"en-GB"}{"textarearowtoolong"}          = "The text area row value given is too long.";
114         $kiriwrite_lang{"en-GB"}{"textarearowinvalid"}          = "The text area row value given is invalid.";
116         $kiriwrite_lang{"en-GB"}{"textareacolsblank"}           = "The text area columns value given is blank.";
117         $kiriwrite_lang{"en-GB"}{"textareacolstoolong"}         = "The text area columns value given is too long.";
118         $kiriwrite_lang{"en-GB"}{"textareacolsinvalid"}         = "The text area columns value given is invalid.";
120         $kiriwrite_lang{"en-GB"}{"presmoduleblank"}             = "The presentation module name given is blank.";
121         $kiriwrite_lang{"en-GB"}{"presmoduleinvalid"}           = "The presentation module name given is invalid.";
122  
123         $kiriwrite_lang{"en-GB"}{"dbmoduleblank"}               = "The database module name given is blank.";
124         $kiriwrite_lang{"en-GB"}{"dbmoduleinvalid"}             = "The database module name given is invalid.";
125  
126         $kiriwrite_lang{"en-GB"}{"presmodulemissing"}           = "The presentation module with the filename given is missing.";
127         $kiriwrite_lang{"en-GB"}{"dbmodulemissing"}             = "The database module with the filename given is missing.";
128         $kiriwrite_lang{"en-GB"}{"languagefilenamemissing"}     = "The language file with the filename given is missing.";
129  
130         $kiriwrite_lang{"en-GB"}{"servernametoolong"}           = "The database server name given is too long.";
131         $kiriwrite_lang{"en-GB"}{"servernameinvalid"}           = "The database server name given is invalid.";
132         $kiriwrite_lang{"en-GB"}{"serverportnumbertoolong"}     = "The database server port number given is too long.";
133         $kiriwrite_lang{"en-GB"}{"serverportnumberinvalidcharacters"}   = "The database server port number given contains invalid characters.";
134         $kiriwrite_lang{"en-GB"}{"serverportnumberinvalid"}     = "The database server port number given is invalid.";
135         $kiriwrite_lang{"en-GB"}{"serverprotocolnametoolong"}   = "The database server protocol name given is too long.";
136         $kiriwrite_lang{"en-GB"}{"serverprotocolinvalid"}               = "The database server protocol name is invalid.";
137         $kiriwrite_lang{"en-GB"}{"serverdatabasenametoolong"}   = "The database name given is too long.";
138         $kiriwrite_lang{"en-GB"}{"serverdatabasenameinvalid"}   = "The database name given is invalid.";
139         $kiriwrite_lang{"en-GB"}{"serverdatabaseusernametoolong"}       = "The database server username given is too long.";
140         $kiriwrite_lang{"en-GB"}{"serverdatabaseusernameinvalid"}       = "The database server username given is invalid.";
141         $kiriwrite_lang{"en-GB"}{"serverdatabasepasswordtoolong"}       = "The database server password is too long.";
142         $kiriwrite_lang{"en-GB"}{"serverdatabasetableprefixtoolong"}    = "The database server table prefix given is too long.";
143         $kiriwrite_lang{"en-GB"}{"serverdatabasetableprefixinvalid"}    = "The database server table prefix given is invalid.";
144  
145         $kiriwrite_lang{"en-GB"}{"removeinstallscripttoolong"}  = "The remove install script value given is too long.";
146         $kiriwrite_lang{"en-GB"}{"cannotwriteconfigurationindirectory"} = "The configuration file cannot be written because the directory the install script is running from has invalid permissions.";
147         $kiriwrite_lang{"en-GB"}{"configurationfilereadpermissionsinvalid"}     = "The configuration that currently exists has invalid read permissions set.";
148         $kiriwrite_lang{"en-GB"}{"configurationfilewritepermissionsinvalid"}    = "The configuration that currently exists has invalid write permissions set.";
150         $kiriwrite_lang{"en-GB"}{"errormessagetext"}    = "Please press the back button on your browser or preform the command needed to return to the previous page.";
152         $kiriwrite_lang{"en-GB"}{"switch"}              = "Switch";
153         $kiriwrite_lang{"en-GB"}{"setting"}             = "Setting";
154         $kiriwrite_lang{"en-GB"}{"value"}               = "Value";
155         $kiriwrite_lang{"en-GB"}{"filename"}            = "Filename";
156         $kiriwrite_lang{"en-GB"}{"module"}              = "Module";
157         $kiriwrite_lang{"en-GB"}{"result"}              = "Result";
158         $kiriwrite_lang{"en-GB"}{"error"}               = "Error!";
159         $kiriwrite_lang{"en-GB"}{"criticalerror"}       = "Critical Error!";
160         $kiriwrite_lang{"en-GB"}{"errormessage"}        = "Error: ";
161         $kiriwrite_lang{"en-GB"}{"warningmessage"}      = "Warning: ";
163         $kiriwrite_lang{"en-GB"}{"doesnotexist"}        = "Does not exist.";
164         $kiriwrite_lang{"en-GB"}{"invalidpermissionsset"}       = "Invalid permissions set.";
166         $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.";
167         $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.";
168         $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.";
169         $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.";
170         $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.";
171         $kiriwrite_lang{"en-GB"}{"filepermissionerrors"}        = "One or more filenames checked has errors. See the Kiriwrite documentation for more information on this.",
173         $kiriwrite_lang{"en-GB"}{"installertitle"}      = "Kiriwrite Installer";
174         $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.";
175         $kiriwrite_lang{"en-GB"}{"modperlnotice"}       = "mod_perl has been detected. Please ensure that you have setup this script and the main Kiriwrite script so that mod_perl can use Kiriwrite properly. Please read the mod_perl specific part of Chapter 1: Installation in the Kiriwrite documentation.";
176         $kiriwrite_lang{"en-GB"}{"dependencytitle"}     = "Dependency and file testing results";
177         $kiriwrite_lang{"en-GB"}{"requiredmodules"}     = "Required Modules";
178         $kiriwrite_lang{"en-GB"}{"perlmodules"}         = "These Perl modules are used internally by Kiriwrite.";
179         $kiriwrite_lang{"en-GB"}{"databasemodules"}     = "Perl Database Modules";
180         $kiriwrite_lang{"en-GB"}{"databasemodulestext"} = "These Perl modules are used by the database modules.";
181         $kiriwrite_lang{"en-GB"}{"filepermissions"}     = "File permissions";
182         $kiriwrite_lang{"en-GB"}{"filepermissionstext"} = "The file permissions are for file and directories that are critical to Kiriwrite such as module and language directories.";
183         
184         $kiriwrite_lang{"en-GB"}{"settingstitle"}       = "Kiriwrite Settings";
185         $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.";
186         $kiriwrite_lang{"en-GB"}{"directories"}         = "Directories";
187         $kiriwrite_lang{"en-GB"}{"databasedirectory"}   = "Database Directory";
188         $kiriwrite_lang{"en-GB"}{"outputdirectory"}     = "Output Directory";
189         $kiriwrite_lang{"en-GB"}{"imagesuripath"}       = "Images (URI path)";
190         $kiriwrite_lang{"en-GB"}{"display"}             = "Display";
191         $kiriwrite_lang{"en-GB"}{"textareacols"}        = "Text Area Columns";
192         $kiriwrite_lang{"en-GB"}{"textarearows"}        = "Text Area Rows";
193         $kiriwrite_lang{"en-GB"}{"date"}                = "Date";
194         $kiriwrite_lang{"en-GB"}{"dateformat"}          = "Date Format";
195         $kiriwrite_lang{"en-GB"}{"language"}            = "Language";
196         $kiriwrite_lang{"en-GB"}{"systemlanguage"}      = "System Language";
197         $kiriwrite_lang{"en-GB"}{"modules"}             = "Modules";
198         $kiriwrite_lang{"en-GB"}{"presentationmodule"}  = "Presentation Module";
199         $kiriwrite_lang{"en-GB"}{"databasemodule"}      = "Database Module";
200         $kiriwrite_lang{"en-GB"}{"databaseserver"}      = "Database Server";
201         $kiriwrite_lang{"en-GB"}{"databaseport"}        = "Database Port";
202         $kiriwrite_lang{"en-GB"}{"databaseprotocol"}    = "Database Protocol";
203         $kiriwrite_lang{"en-GB"}{"databasename"}        = "Database Name";
204         $kiriwrite_lang{"en-GB"}{"databaseusername"}    = "Database Username";
205         $kiriwrite_lang{"en-GB"}{"databasepassword"}    = "Database Password";
206         $kiriwrite_lang{"en-GB"}{"databasetableprefix"} = "Database Table Prefix";
207         $kiriwrite_lang{"en-GB"}{"installationoptions"} = "Installation Options";
208         $kiriwrite_lang{"en-GB"}{"installoptions"}      = "Install Options";
209         $kiriwrite_lang{"en-GB"}{"removeinstallscript"} = "Delete this installer script after configuration file has been written.";
210         $kiriwrite_lang{"en-GB"}{"savesettingsbutton"}  = "Save Settings";
211         $kiriwrite_lang{"en-GB"}{"resetsettingsbutton"} = "Reset Settings";
213         $kiriwrite_lang{"en-GB"}{"installscriptremoved"}        = "The installer script was removed.";
214         $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.";
215         $kiriwrite_lang{"en-GB"}{"cannotremovescript"}  = "Unable to remove the installer script: %s. The installer script will have to be deleted manually.";
216         $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/kiriwrite.pl):";
217         $kiriwrite_lang{"en-GB"}{"usekiriwritelink"}    = "Start using Kiriwrite.";
219 my $query_lite = new CGI::Lite;
220 my $form_data = $query_lite->parse_form_data;
222 my $language_selected = "";
223 my $http_query_confirm = $form_data->{'confirm'};
224 my $http_query_installlanguage = $form_data->{'installlanguage'};
226 if (!$http_query_installlanguage){
228         $language_selected = $default_language;
230 } else {
232         $language_selected = $http_query_installlanguage;
236 # Process the list of available languages.
238 my $language_list_name;
239 my @language_list_short;
240 my @language_list_long;
242 foreach my $language (keys %kiriwrite_lang){
244         $language_list_name = $kiriwrite_lang{$language}{"languagename"} . " (" . $language .  ")";
245         push(@language_list_short, $language);
246         push(@language_list_long, $language_list_name);
250 # The CSS Stylesheet to use.
252 my $cssstyle = "
254 a {
255         color: #FFFFFF;
258 body {
259         background-color: #408080;
260         color: #FFFFFF;
261         font-family: sans-serif;
262         font-size: 12px;
265 input {
266         font-size: 12px;
267         background-color: #408080;
268         color: #FFFFFF;
269         border-color: #102020;
270         border-style: solid;
271         border-width: 1px;
272         padding: 3px;
276 select {
277         font-size: 12px;
278         padding: 3px;
279         background-color: #408080;
280         color: #FFFFFF;
281         border-color: #102020;
282         border-style: solid;
283         border-width: 1px;
284         padding: 3px;
287 td,table {
288         padding: 5px;
289         border-spacing: 0px;
292 .languagebar {
293         background-color: #204040;
294         vertical-align: top;
297 .languagebarselect {
298         text-align: right;
299         background-color: #204040;
302 .tablecellheader {
303         background-color: #204040;
304         font-weight: bold;
307 .tabledata {
308         background-color: #357070;
311 .tablename {
313         background-color: #306060;
317 ";
320 #################################################################################
321 # Begin list of subroutines.                                                    #
322 #################################################################################
324 sub kiriwrite_variablecheck{
325 #################################################################################
326 # kiriwrite_variablecheck: Check to see if the data passed is valid.            #
327 #                                                                               #
328 # Usage:                                                                        #
329 #                                                                               #
330 # kiriwrite_variablecheck(variablename, type, option, noerror);                 #
331 #                                                                               #
332 # variablename  Specifies the variable to be checked.                           #
333 # type          Specifies what type the variable is.                            #
334 # option        Specifies the maximum/minimum length of the variable            #
335 #               (if minlength/maxlength is used) or if the filename should be   #
336 #               checked to see if it is blank.                                  #
337 # noerror       Specifies if Kiriwrite should return an error or not on         #
338 #               certain values.                                                 #
339 #################################################################################
341         # Get the values that were passed to the subroutine.
343         my ($variable_data, $variable_type, $variable_option, $variable_noerror) = @_;
345         if ($variable_type eq "numbers"){
347                 # Check for numbers and return an error if there is anything else than numebrs.
349                 my $variable_data_validated = $variable_data;   # Copy the variable_data to variable_data_validated.
350                 $variable_data_validated =~ tr/0-9//d;          # Take away all of the numbers and from the variable. 
351                                                                 # If it only contains numbers then it should be blank.
353                 if ($variable_data_validated eq ""){
354                         # The validated variable is blank. So continue to the end of this section where the return function should be.
355                 } else {
356                         # The variable is not blank, so check if the no error value is set
357                         # to 1 or not.
359                         if ($variable_noerror eq 1){
361                                 # The validated variable is not blank and the noerror
362                                 # value is set to 1. So return an value of 1.
363                                 # (meaning that the data is invalid).
365                                 return 1;
367                         } elsif ($variable_noerror eq 0) {
369                                 # The validated variable is not blank and the noerror
370                                 # value is set to 0.
372                                 kiriwrite_error("invalidvariable");
374                         } else {
376                                 # The variable noerror value is something else
377                                 # pther than 1 or 0. So return an error.
379                                 kiriwrite_error("invalidvariable");
381                         }
383                 }
385                 return 0;
387         } elsif ($variable_type eq "lettersnumbers"){
389                 # Check for letters and numbers and return an error if there is anything else other
390                 # than letters and numbers.
392                 my $variable_data_validated = $variable_data;   # Copy the variable_data to variable_data_validated
393                 $variable_data_validated =~ tr/a-zA-Z0-9.//d;
394                 $variable_data_validated =~ s/\s//g;
396                 if ($variable_data_validated eq ""){
397                         # The validated variable is blank. So continue to the end of this section where the return function should be.
398                 } else {
399                         # The variable is not blank, so check if the no error value is set
400                         # to 1 or not.
402                         if ($variable_noerror eq 1){
404                                 # The validated variable is not blank and the noerror
405                                 # value is set to 1. So return an value of 1.
406                                 # (meaning that the data is invalid).
408                                 return 1;
410                         } elsif ($variable_noerror eq 0) {
412                                 # The validated variable is not blank and the noerror
413                                 # value is set to 0.
415                                 kiriwrite_error("invalidvariable");
417                         } else {
419                                 # The variable noerror value is something else
420                                 # pther than 1 or 0. So return an error.
422                                 kiriwrite_error("invalidvariable");
424                         }
426                 }
428                 return 0;
430         } elsif ($variable_type eq "maxlength"){
431                 # Check for the length of the variable, return an error if it is longer than the length specified.
433                 # Check if the variable_data string is blank, if it is then set the variable_data_length
434                 # to '0'.
436                 my $variable_data_length = 0;
438                 if (!$variable_data){
440                         # Set variable_data_length to '0'.
441                         $variable_data_length = 0;
443                 } else {
445                         # Get the length of the variable recieved.
446                         $variable_data_length = length($variable_data);
448                 }
452                 if ($variable_data_length > $variable_option){
454                         # The variable length is longer than it should be so check if
455                         # the no error value is set 1.
457                         if ($variable_noerror eq 1){
459                                 # The no error value is set to 1, so return an
460                                 # value of 1 (meaning tha the variable is
461                                 # too long to be used).
463                                 return 1;
465                         } elsif ($variable_noerror eq 0){
467                                 # The no error value is set to 0, so return
468                                 # an error.
470                                 kiriwrite_error("variabletoolong");
472                         } else {
474                                 # The no error value is something else other
475                                 # than 0 or 1, so return an error.
477                                 kiriwrite_error("variabletoolong");
479                         }
481                 } else {
483                         # The variable length is exactly or shorter than specified, so continue to end of this section where
484                         # the return function should be.
486                 }
488                 return 0;
490         } elsif ($variable_type eq "datetime"){
491                 # Check if the date and time setting format is valid.
493                 if ($variable_data eq ""){
495                         if ($variable_noerror eq 1){
497                                 # The no error value is set to 1 so return
498                                 # a value of 1 (meaning that the date and
499                                 # time format was blank).
501                                 return 1;
503                         } elsif ($variable_noerror eq 0){
505                                 # The no error value is set to 1 so return
506                                 # an error.
508                                 kiriwrite_error("dateformatblank");
510                         } else {
512                                 # The no error value is something else other
513                                 # than 0 or 1, so return an error.
515                                 kiriwrite_error("invalidvariable");
517                         }
519                 }
521                 my $variable_data_validated = $variable_data;
522                 $variable_data_validated =~ tr|dDmMyYhms/():[ ]||d;
524                 if ($variable_data_validated eq ""){
526                         # The date and time format is valid. So
527                         # skip this bit.
529                 } else {
531                         # The validated data variable is not blank, meaning 
532                         # that it contains something else, so return an error
533                         # (or a value).
535                         if ($variable_noerror eq 1){
537                                 # The no error value is set to 1 so return
538                                 # an value of 2. (meaning that the date and
539                                 # time format was invalid).
541                                 return 2;
543                         } elsif ($variable_noerror eq 0){
545                                 # The no error value is set to 0 so return
546                                 # an error.
548                                 kiriwrite_error("dateformatinvalid");
550                         } else {
552                                 # The no error value is something else other
553                                 # than 0 or 1 so return an error.
555                                 kiriwrite_error("invalidvariable");
557                         }
559                 }
561                 return 0;
563         } elsif ($variable_type eq "directory"){
564                 # Check if the directory only contains letters and numbers and
565                 # return an error if anything else appears.
567                 my $variable_data_validated = $variable_data;
568                 $variable_data_validated =~ tr/a-zA-Z0-9//d;
570                 if ($variable_data eq ""){
572                         if ($variable_noerror eq 1){
574                                 # The no error value is set to 1 so return
575                                 # a value of 1 (meaning that the directory
576                                 # name was blank).
578                                 return 1;
580                         } elsif ($variable_noerror eq 0){
582                                 # The no error value is set to 1 so return
583                                 # an error.
585                                 kiriwrite_error("blankdirectory");
587                         } else {
589                                 # The no error value is something else other
590                                 # than 0 or 1, so return an error.
592                                 kiriwrite_error("invalidvariable");
594                         }
596                 }
598                 if ($variable_data_validated eq ""){
600                         # The validated data variable is blank, meaning that
601                         # it only contains letters and numbers.
603                 } else {
605                         # The validated data variable is not blank, meaning 
606                         # that it contains something else, so return an error
607                         # (or a value).
609                         if ($variable_noerror eq 1){
611                                 # The no error value is set to 1 so return
612                                 # an value of 2. (meaning that the directory
613                                 # name is invalid).
615                                 return 2;
617                         } elsif ($variable_noerror eq 0){
619                                 # The no error value is set to 0 so return
620                                 # an error.
622                                 kiriwrite_error("invaliddirectory");
624                         } else {
626                                 # The no error value is something else other
627                                 # than 0 or 1 so return an error.
629                                 kiriwrite_error("invalidvariable");
631                         }
633                 }
635                 return 0;
637         } elsif ($variable_type eq "language_filename"){
639                 # The variable type is a language filename type.
640                 # Check if the language file name is blank and 
641                 # if it is then return an error (or value).
643                 if ($variable_data eq ""){
645                         # The language filename is blank so check the
646                         # no error value and return an error (or value).
648                         if ($variable_noerror eq 1){
650                                 # Language filename is blank and the no error value
651                                 # is set as 1, so return a value of 1 (saying that
652                                 # the language filename is blank).
654                                 return 1;
656                         } elsif ($variable_noerror eq 0) {
658                                 # Language filename is blank and the no error value
659                                 # is not set as 1, so return an error.
661                                 kiriwrite_error("languagefilenameblank");
663                         } else {
665                                 # The noerror value is something else other
666                                 # than 0 or 1 so return an error.
668                                 kiriwrite_error("invalidvariable");
670                         }
672                 }
674                 # Set the following variables for later on.
676                 my $variable_data_length = 0;
677                 my $variable_data_char = "";
678                 my $variable_data_seek = 0;
680                 # Get the length of the language file name.
682                 $variable_data_length = length($variable_data);
684                 do {
686                         # Get a character from the language filename passed to this 
687                         # subroutine and the character the seek counter value is set
688                         # to.
690                         $variable_data_char = substr($variable_data, $variable_data_seek, 1);
692                         # Check if the language filename contains a forward slash or a dot, 
693                         # if the selected character is a forward slash then return an error
694                         # (or value).
696                         if ($variable_data_char eq "/" || $variable_data_char eq "."){
698                                 # The language filename contains a forward slash or
699                                 # a dot so depending on the no error value, return
700                                 # an error or a value.
702                                 if ($variable_noerror eq 1){
704                                         # Language filename contains a forward slash or a dot
705                                         # and the no error value has been set to 1, so return 
706                                         # an value of 2 (saying that the language file name is 
707                                         # invalid).
709                                         return 2;
711                                 } elsif ($variable_noerror eq 0) {
713                                         # Language filename contains a forward slash and the no
714                                         # error value has not been set to 1, so return an error.
716                                         kiriwrite_error("languagefilenameinvalid");
718                                 } else {
720                                         # The noerror value is something else other than
721                                         # 1 or 0 so return an error.
723                                         kiriwrite_error("invalidvariable");
725                                 }
727                         }
729                         # Increment the seek counter.
731                         $variable_data_seek++;
733                 } until ($variable_data_seek eq $variable_data_length);
735                 return 0;
737         } elsif ($variable_type eq "module"){
739                 # The variable type is a presentation module filename.
741                 # Check if the variable_data is blank and if it is
742                 # return an error.
744                 if ($variable_data eq ""){
746                         # The presentation module is blank so check if an error
747                         # value should be returned or a number should be
748                         # returned.
750                         if ($variable_noerror eq 1){
752                                 # Module name is blank and the no error value 
753                                 # is set to 1 so return a value of 2 (meaning 
754                                 # that the page filename is blank).
756                                 return 1;
758                         } elsif ($variable_noerror eq 0) {
760                                 # Module name contains is blank and the no error 
761                                 # value is set to 0 so return an error.
763                                 kiriwrite_critical("moduleblank");
765                         } else {
767                                 # The no error value is something else other
768                                 # than 0 or 1 so return an error.
770                                 kiriwrite_critical("invalidvalue");
772                         }
774                 } else {
776                 }
778                 my $variable_data_validated = $variable_data;
779                 $variable_data_validated =~ tr/a-zA-Z0-9//d;
781                 if ($variable_data_validated eq ""){
783                 } else {
785                         if ($variable_noerror eq 1){
787                                 # Module name contains invalid characters and
788                                 # the no error value is set to 1 so return a 
789                                 # value of 2 (meaning that the page filename
790                                 # is invalid).
792                                 return 2;
794                         } elsif ($variable_noerror eq 0) {
796                                 # Module name contains invalid characters and
797                                 # the no error value is set to 0 so return an
798                                 # error.
800                                 kiriwrite_critical("moduleinvalid");
802                         } else {
804                                 # The no error value is something else other
805                                 # than 0 or 1 so return an error.
807                                 kiriwrite_error("invalidvalue");
809                         }
811                 }
813                 return 0;
815         } elsif ($variable_type eq "serverprotocol"){
817                 # Check if the server protocol is TCP or UDP and return
818                 # an error if it isn't.
820                 if ($variable_data ne "tcp" && $variable_data ne "udp"){
822                         # The protocol given is not valid, check if the no
823                         # error value is set to 1 and return an error if it isn't.
825                         if ($variable_noerror eq 1){
827                                 # The no error value has been set to 1, so return a
828                                 # value of 1 (meaning that the server protocol is
829                                 # invalid).
831                                 return 1;
833                         } elsif ($variable_noerror eq 0){
835                                 # The no error value has been set to 0, so return
836                                 # an error.
838                                 kiriwrite_error("serverprotocolinvalid");
840                         } else {
842                                 # The no error value is something else other than 0
843                                 # or 1, so return an error.
845                                 kiriwrite_error("invalidoption");
847                         }
849                 }
851                 return 0;
853         } elsif ($variable_type eq "port"){
855                 # Check if the port number given is less than 0 or more than 65535
856                 # and return an error if it is.
858                 if ($variable_data < 0 || $variable_data > 65535){
860                         # The port number is less than 0 and more than 65535 so
861                         # check if the no error value is set to 1 and return an
862                         # error if it isn't.
864                         if ($variable_noerror eq 1){
866                                 # The no error value has been set to 1, so return a
867                                 # value of 1 (meaning that the port number is invalid).
869                                 return 1;
871                         } elsif ($variable_noerror eq 0){
873                                 # The no error value has been set to 0, so return
874                                 # an error.
876                                 kiriwrite_error("serverportnumberinvalid");
878                         } else {
880                                 # The no error value is something else other than 0
881                                 # or 1, so return an error.
883                                 kiriwrite_error("invalidoption");
885                         }
887                 }
889                 return 0;
891         }
893         # Another type than the valid ones above has been specified so return an error specifying an invalid option.
894         kiriwrite_error("invalidoption");
898 sub kiriwrite_error{
899 #################################################################################
900 # kiriwrite_error: Subroutine for processing error messages.                    #
901 #                                                                               #
902 # Usage:                                                                        #
903 #                                                                               #
904 # kiriwrite_error(errortype);                                                   #
905 #                                                                               #
906 # errortype     Specifies the error type to use.                                #
907 #################################################################################
909         my $error_type = shift;
911         # Load the list of error messages.
913         my (%kiriwrite_error, $kiriwrite_error);
915         %kiriwrite_error = (
917                 # Generic Error Messages
919                 "generic"                       => $kiriwrite_lang{$language_selected}{generic},
921                 "invalidvariable"               => $kiriwrite_lang{$language_selected}{invalidvariable},
922                 "invalidvalue"                  => $kiriwrite_lang{$language_selected}{invalidvalue},
923                 "invalidoption"                 => $kiriwrite_lang{$language_selected}{invalidoption},
924                 "variabletoolong"               => $kiriwrite_lang{$language_selected}{variabletoolong},
925                 "blankdirectory"                => $kiriwrite_lang{$language_selected}{blankdirectory},
926                 "invaliddirectory"              => $kiriwrite_lang{$language_selected}{invaliddirectory},
927                 "moduleblank"                   => $kiriwrite_lang{$language_selected}{moduleblank},
928                 "moduleinvalid"                 => $kiriwrite_lang{$language_selected}{moduleinvalid},
930                 # Specific Error Messages
932                 "dbdirectorytoolong"            => $kiriwrite_lang{$language_selected}{dbdirectorytoolong},
933                 "outputdirectorytoolong"        => $kiriwrite_lang{$language_selected}{outputdirectorytoolong},
934                 "imagesuripathtoolong"          => $kiriwrite_lang{$language_selected}{imagesuripathtoolong},
935                 "dateformattoolong"             => $kiriwrite_lang{$language_selected}{dateformattoolong},
936                 "customdateformattoolong"       => $kiriwrite_lang{$language_selected}{customdateformattoolong},
937                 "languagefilenametoolong"       => $kiriwrite_lang{$language_selected}{languagefilenametoolong},
938                 
939                 "dateformatblank"               => $kiriwrite_lang{$language_selected}{dateformatblank},
940                 "dateformatinvalid"             => $kiriwrite_lang{$language_selected}{dateformatinvalid},
941                 "languagefilenameinvalid"       => $kiriwrite_lang{$language_selected}{languagefilenameinvalid},
942                 
943                 "dbdirectoryblank"              => $kiriwrite_lang{$language_selected}{dbdirectoryblank},
944                 "dbdirectoryinvalid"            => $kiriwrite_lang{$language_selected}{dbdirectoryinvalid},
946                 "textarearowblank"              => $kiriwrite_lang{$language_selected}{textarearowblank},
947                 "textarearowtoolong"            => $kiriwrite_lang{$language_selected}{textarearowtoolong},
948                 "textarearowinvalid"            => $kiriwrite_lang{$language_selected}{textarearowinvalid},
950                 "textareacolsblank"             => $kiriwrite_lang{$language_selected}{textareacolsblank},
951                 "textareacolstoolong"           => $kiriwrite_lang{$language_selected}{textareacolstoolong},
952                 "textareacolsinvalid"           => $kiriwrite_lang{$language_selected}{textareacolsinvalid},
954                 "outputdirectoryblank"          => $kiriwrite_lang{$language_selected}{outputdirectoryblank},
955                 "outputdirectoryinvalid"        => $kiriwrite_lang{$language_selected}{outputdirectoryinvalid},
957                 "presmoduleblank"               => $kiriwrite_lang{$language_selected}{presmoduleblank},
958                 "presmoduleinvalid"             => $kiriwrite_lang{$language_selected}{presmoduleinvalid},
960                 "dbmoduleblank"                 => $kiriwrite_lang{$language_selected}{dbmoduleblank},
961                 "dbmoduleinvalid"               => $kiriwrite_lang{$language_selected}{dbmoduleinvalid},
963                 "presmodulemissing"             => $kiriwrite_lang{$language_selected}{presmodulemissing},
964                 "dbmodulemissing"               => $kiriwrite_lang{$language_selected}{dbmodulemissing},
965                 "languagefilenamemissing"       => $kiriwrite_lang{$language_selected}{languagefilenamemissing},
967                 "servernametoolong"             => $kiriwrite_lang{$language_selected}{servernametoolong},
968                 "servernameinvalid"             => $kiriwrite_lang{$language_selected}{servernameinvalid},
969                 "serverportnumbertoolong"       => $kiriwrite_lang{$language_selected}{serverportnumbertoolong},
970                 "serverportnumberinvalidcharacters"     => $kiriwrite_lang{$language_selected}{serverportnumberinvalidcharacters},
971                 "serverportnumberinvalid"       => $kiriwrite_lang{$language_selected}{serverportnumberinvalid},
972                 "serverprotocolnametoolong"     => $kiriwrite_lang{$language_selected}{serverprotocolnametoolong},
973                 "serverprotocolinvalid"         => $kiriwrite_lang{$language_selected}{serverprotocolinvalid},
974                 "serverdatabasenametoolong"     => $kiriwrite_lang{$language_selected}{serverdatabasenametoolong},
975                 "serverdatabasenameinvalid"     => $kiriwrite_lang{$language_selected}{serverdatabasenameinvalid},
976                 "serverdatabaseusernametoolong" => $kiriwrite_lang{$language_selected}{serverdatabaseusernametoolong},
977                 "serverdatabaseusernameinvalid" => $kiriwrite_lang{$language_selected}{serverdatabaseusernameinvalid},
978                 "serverdatabasepasswordtoolong" => $kiriwrite_lang{$language_selected}{serverdatabasepasswordtoolong},
979                 "serverdatabasetableprefixtoolong"      => $kiriwrite_lang{$language_selected}{serverdatabasetableprefixtoolong},
980                 "serverdatabasetableprefixinvalid"      => $kiriwrite_lang{$language_selected}{serverdatabasetableprefixinvalid},
982                 "removeinstallscripttoolong"    => $kiriwrite_lang{$language_selected}{removeinstallscripttoolong},
983                 "cannotwriteconfigurationindirectory"   => $kiriwrite_lang{$language_selected}{cannotwriteconfigurationindirectory},
984                 "configurationfilereadpermissionsinvalid"       => $kiriwrite_lang{$language_selected}{configurationfilereadpermissionsinvalid},
985                 "configurationfilewritepermissionsinvalid"      => $kiriwrite_lang{$language_selected}{configurationfilewritepermissionsinvalid},
987         );
989         # Check if the specified error is blank and if it is
990         # use the generic error messsage.
992         if (!$kiriwrite_error{$error_type}){
993                 $error_type = "generic";
994         }
996         print "Content-type: text/html;\r\n\r\n";
998         print "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
999         print "<head>\n<title>$kiriwrite_lang{$language_selected}{installertitle}</title>\n<style type=\"text/css\" media=\"screen\">$cssstyle</style>\n</head>\n<body>\n";
1001         print "<h2>$kiriwrite_lang{$language_selected}{error}</h2>";
1003         print $kiriwrite_error{$error_type};
1004         print "<br />\n";
1005         print $kiriwrite_lang{$language_selected}{errormessagetext};
1007         print "</body>\n</html>";
1009         exit;
1013 sub kiriwrite_writeconfig{
1014 #################################################################################
1015 # kiriwrite_writeconfig: Writes a configuration file.                           #
1016 #                                                                               #
1017 # Usage:                                                                        #
1018 #                                                                               #
1019 # kiriwrite_writeconfig();                                                      #
1020 #################################################################################
1022         my ($passedsettings) = @_;
1024         # Open the configuration file for writing.
1026         open (my $configfile, "> " . "kiriwrite.cfg");
1028         print $configfile "[config]
1029 directory_data_db = $passedsettings->{DatabaseDirectory}
1030 directory_data_output = $passedsettings->{OutputDirectory}
1031 directory_noncgi_images = $passedsettings->{ImagesURIPath}
1033 system_language = $passedsettings->{Language}
1034 system_presmodule = $passedsettings->{PresentationModule}
1035 system_dbmodule = $passedsettings->{DatabaseModule}
1036 system_datetime = $passedsettings->{DateFormat}
1037                 
1038 display_textareacols = $passedsettings->{TextAreaCols}
1039 display_textarearows = $passedsettings->{TextAreaRows}
1040 display_pagecount = 50
1041 display_filtercount = 50
1042 display_templatecount = 50
1043                 
1044 database_server = $passedsettings->{DatabaseServer}
1045 database_port = $passedsettings->{DatabasePort}
1046 database_protocol = $passedsettings->{DatabaseProtocol}
1047 database_sqldatabase = $passedsettings->{DatabaseName}
1048 database_username = $passedsettings->{DatabaseUsername}
1049 database_password = $passedsettings->{DatabasePassword}
1050 database_tableprefix = $passedsettings->{DatabaseTablePrefix}
1051         ";
1053         close ($configfile);
1057 sub kiriwrite_addtablerow{
1058 #################################################################################
1059 # kiriwrite_addtablerow: Adds a table row.                                      #
1060 #                                                                               #
1061 # Usage:                                                                        #
1062 #                                                                               #
1063 # kiriwrite_addtablerow(name, data);                                            #
1064 #                                                                               #
1065 # name          Specifies the name of the table row.                            #
1066 # namestyle     Specifies the style for the name of the table row.              #
1067 # data          Specifies the data to be used in the table row.                 #
1068 # datastyle     Specifies the style for the data of the table row.              #
1069 #################################################################################
1071         my ($name, $namestyle, $data, $datastyle) = @_;
1073         if (!$data){
1075                 $data = "";
1077         }
1079         print "<tr>\n";
1080         print "<td class=\"$namestyle\">$name</td>\n";
1081         print "<td class=\"$datastyle\">$data</td>\n";
1082         print "</tr>\n";
1086 sub kiriwrite_processconfig{
1087 #################################################################################
1088 # kiriwrite_processconfig: Processes an INI style configuration file.           #
1089 #                                                                               #
1090 # Usage:                                                                        #
1091 #                                                                               #
1092 # kiriwrite_processconfig(data);                                                #
1093 #                                                                               #
1094 # data  Specifies the data to process.                                          #
1095 #################################################################################
1097         my (@settings) = @_;
1099         my ($settings_line, %settings, $settings, $sectionname, $setting_name, $setting_value);
1101         foreach $settings_line (@settings){
1103                 next if !$settings_line;
1105                 # Check if the first character is a bracket.
1107                 if (substr($settings_line, 0, 1) eq "["){
1108                         $settings_line =~ s/\[//;
1109                         $settings_line =~ s/\](.*)//;
1110                         $settings_line =~ s/\n//;
1111                         $sectionname = $settings_line;
1112                         next;
1113                 }
1115                 $setting_name  = $settings_line;
1116                 $setting_value = $settings_line;
1117                 $setting_name  =~ s/\=(.*)//;
1118                 $setting_name  =~ s/\n//;
1119                 $setting_value =~ s/(.*)\=//;
1120                 $setting_value =~ s/\n//;
1122                 # Remove the spacing before and after the '=' sign.
1124                 $setting_name =~ s/\s+$//;
1125                 $setting_value =~ s/^\s+//;
1126                 $setting_value =~ s/\r//;
1128                 $settings{$sectionname}{$setting_name} = $setting_value;
1130         }
1132         return %settings;
1136 #################################################################################
1137 # End list of subroutines.                                                      #
1138 #################################################################################
1140 if (!$http_query_confirm){
1142         $http_query_confirm = 0;
1146 if ($http_query_confirm eq 1){
1148         # The confirm value has been given so get the data from the query.
1150         my $http_query_dbdirectory              = $form_data->{'dbdirectory'};
1151         my $http_query_outputdirectory          = $form_data->{'outputdirectory'};
1152         my $http_query_imagesuripath            = $form_data->{'imagesuripath'};
1154         my $http_query_textarearows             = $form_data->{'textarearows'};
1155         my $http_query_textareacols             = $form_data->{'textareacols'};
1157         my $http_query_dateformat               = $form_data->{'dateformat'};
1158         my $http_query_customdateformat         = $form_data->{'customdateformat'};
1160         my $http_query_language                 = $form_data->{'language'};
1162         my $http_query_presmodule               = $form_data->{'presmodule'};
1163         my $http_query_dbmodule                 = $form_data->{'dbmodule'};
1165         my $http_query_databaseserver           = $form_data->{'databaseserver'};
1166         my $http_query_databaseport             = $form_data->{'databaseport'};
1167         my $http_query_databaseprotocol         = $form_data->{'databaseprotocol'};
1168         my $http_query_databasename             = $form_data->{'databasename'};
1169         my $http_query_databaseusername         = $form_data->{'databaseusername'};
1170         my $http_query_databasepassword         = $form_data->{'databasepassword'};
1171         my $http_query_databasetableprefix      = $form_data->{'databasetableprefix'};
1172         my $http_query_removeinstallscript      = $form_data->{'removeinstallscript'};
1174         # Check if the text area rows and column values are blank.
1176         if (!$http_query_textarearows){
1178                 # The text area rows value is blank so return
1179                 # an error.
1181                 kiriwrite_error("textarearowblank");
1183         }
1185         if (!$http_query_textareacols){
1187                 # The text area columns value is blank so
1188                 # return an error.
1190                 kiriwrite_error("textareacolsblank");
1192         }
1194         # Check the length of the variables.
1196         my $kiriwrite_dbdirectory_length_check          = kiriwrite_variablecheck($http_query_dbdirectory, "maxlength", 64, 1);
1197         my $kiriwrite_outputdirectory_length_check      = kiriwrite_variablecheck($http_query_outputdirectory, "maxlength", 64, 1);
1198         my $kiriwrite_imagesuripath_length_check        = kiriwrite_variablecheck($http_query_imagesuripath, "maxlength", 512, 1);
1199         my $kiriwrite_textarearow_length_check          = kiriwrite_variablecheck($http_query_textarearows, "maxlength", 3, 1);
1200         my $kiriwrite_textareacols_length_check         = kiriwrite_variablecheck($http_query_textareacols, "maxlength", 3, 1);
1201         my $kiriwrite_dateformat_length_check           = kiriwrite_variablecheck($http_query_dateformat, "maxlength", 32, 1);
1202         my $kiriwrite_customdateformat_length_check     = kiriwrite_variablecheck($http_query_customdateformat, "maxlength", 32, 1);
1203         my $kiriwrite_language_length_check             = kiriwrite_variablecheck($http_query_language, "maxlength", 16, 1);
1205         # Check if any errors occured while checking the
1206         # length of the variables.
1208         if ($kiriwrite_dbdirectory_length_check eq 1){
1210                 # The database directory given is too long
1211                 # so return an error.
1213                 kiriwrite_error("dbdirectorytoolong");
1215         }
1217         if ($kiriwrite_outputdirectory_length_check eq 1){
1219                 # The output directory given is too long
1220                 # so return an error.
1222                 kiriwrite_error("outputdirectorytoolong");
1224         }
1226         if ($kiriwrite_imagesuripath_length_check eq 1){
1228                 # The images URI path given is too long
1229                 # so return an error.
1231                 kiriwrite_error("imagesuripathtoolong");
1233         }
1235         if ($kiriwrite_dateformat_length_check eq 1){
1237                 # The date format given is too long
1238                 # so return an error.
1240                 kiriwrite_error("dateformattoolong");
1242         }
1244         if ($kiriwrite_customdateformat_length_check eq 1){
1246                 # The date format given is too long
1247                 # so return an error.
1249                 kiriwrite_error("customdateformattoolong");
1251         }
1253         if ($kiriwrite_language_length_check eq 1){
1255                 # The language filename given is too long
1256                 # so return an error.
1258                 kiriwrite_error("languagefilenametoolong");
1260         }
1262         if ($kiriwrite_textarearow_length_check eq 1){
1264                 # The text area rows length is too long
1265                 # so return an error.
1267                 kiriwrite_error("textarearowtoolong");
1269         }
1271         if ($kiriwrite_textareacols_length_check eq 1){
1273                 # The text area columns length is too long
1274                 # so return an error.
1276                 kiriwrite_error("textareacolstoolong");
1278         }
1280         # Check if the custom date and time setting has anything
1281         # set and if it doesn't then use the predefined one set.
1283         my $finaldateformat = "";
1285         if ($http_query_customdateformat ne ""){
1287                 $finaldateformat = $http_query_customdateformat;
1289         } else {
1291                 $finaldateformat = $http_query_dateformat;
1293         }
1295         my $kiriwrite_datetime_check            = kiriwrite_variablecheck($finaldateformat, "datetime", 0, 1);
1297         if ($kiriwrite_datetime_check eq 1){
1299                 # The date and time format is blank so return
1300                 # an error.
1302                 kiriwrite_error("dateformatblank");
1304         } elsif ($kiriwrite_datetime_check eq 2){
1306                 # The date and time format is invalid so
1307                 # return an error.
1309                 kiriwrite_error("dateformatinvalid");
1311         }
1313         # Check if the language filename given is valid.
1315         my $kiriwrite_language_languagefilename_check = kiriwrite_variablecheck($http_query_language, "language_filename", "", 1);
1317         if ($kiriwrite_language_languagefilename_check eq 1) {
1319                 # The language filename given is blank so
1320                 # return an error.
1322                 kiriwrite_error("languagefilenameblank");
1324         } elsif ($kiriwrite_language_languagefilename_check eq 2){
1326                 # The language filename given is invalid so
1327                 # return an error.
1329                 kiriwrite_error("languagefilenameinvalid");
1331         }
1333         # Check if the directory names only contain letters and numbers and
1334         # return a specific error if they don't.
1336         my $kiriwrite_dbdirectory_check         = kiriwrite_variablecheck($http_query_dbdirectory, "directory", 0, 1);
1337         my $kiriwrite_outputdirectory_check     = kiriwrite_variablecheck($http_query_outputdirectory, "directory", 0, 1);
1339         if ($kiriwrite_dbdirectory_check eq 1){
1341                 # The database directory name is blank, so return
1342                 # an error.
1344                 kiriwrite_error("dbdirectoryblank");
1346         } elsif ($kiriwrite_dbdirectory_check eq 2){
1348                 # The database directory name is invalid, so return
1349                 # an error.
1351                 kiriwrite_error("dbdirectoryinvalid");
1353         }
1355         if ($kiriwrite_outputdirectory_check eq 1){
1357                 # The output directory name is blank, so return
1358                 # an error.
1360                 kiriwrite_error("outputdirectoryblank");
1362         } elsif ($kiriwrite_outputdirectory_check eq 2){
1364                 # The output directory name is invalid, so return
1365                 # an error.
1367                 kiriwrite_error("outputdirectoryinvalid");
1369         }
1371         if ($kiriwrite_dbdirectory_check eq 1){
1373                 # The database directory name is blank, so return
1374                 # an error.
1376                 kiriwrite_error("dbdirectoryblank");
1378         } elsif ($kiriwrite_dbdirectory_check eq 2){
1380                 # The database directory name is invalid, so return
1381                 # an error.
1383                 kiriwrite_error("dbdirectoryinvalid");
1385         }
1387         if ($kiriwrite_outputdirectory_check eq 1){
1389                 # The output directory name is blank, so return
1390                 # an error.
1392                 kiriwrite_error("outputdirectoryblank");
1394         } elsif ($kiriwrite_outputdirectory_check eq 2){
1396                 # The output directory name is invalid, so return
1397                 # an error.
1399                 kiriwrite_error("outputdirectoryinvalid");
1401         }
1403         # Check to see if the text area rows and column values
1404         # are valid.
1406         my $kiriwrite_textarearow_number_check          = kiriwrite_variablecheck($http_query_textarearows, "numbers", 0, 1);
1407         my $kiriwrite_textareacols_number_check         = kiriwrite_variablecheck($http_query_textareacols, "numbers", 0, 1);
1409         if ($kiriwrite_textarearow_number_check eq 1){
1411                 # The text area row value is invalid so return
1412                 # an error.
1414                 kiriwrite_error("textarearowinvalid");
1416         }
1418         if ($kiriwrite_textareacols_number_check eq 1){
1420                 # The text area columns value is invalid so return
1421                 # an error.
1423                 kiriwrite_error("textareacolsinvalid");
1425         }
1427         # Check the module names to see if they're valid.
1429         my $kiriwrite_presmodule_modulename_check       = kiriwrite_variablecheck($http_query_presmodule, "module", 0, 1);
1430         my $kiriwrite_dbmodule_modulename_check         = kiriwrite_variablecheck($http_query_dbmodule, "module", 0, 1);
1432         if ($kiriwrite_presmodule_modulename_check eq 1){
1434                 # The presentation module name is blank, so return
1435                 # an error.
1437                 kiriwrite_error("presmoduleblank");
1439         }
1441         if ($kiriwrite_presmodule_modulename_check eq 2){
1443                 # The presentation module name is invalid, so return
1444                 # an error.
1446                 kiriwrite_error("presmoduleinvalid");
1448         }
1450         if ($kiriwrite_dbmodule_modulename_check eq 1){
1452                 # The database module name is blank, so return
1453                 # an error.
1455                 kiriwrite_error("dbmoduleblank");
1457         }
1459         if ($kiriwrite_dbmodule_modulename_check eq 2){
1461                 # The database module name is invalid, so return
1462                 # an error.
1464                 kiriwrite_error("dbmoduleinvalid");
1466         }
1468         # Check if the database module, presentation module and
1469         # language file exists.
1471         if (!-e "Modules/Presentation/" . $http_query_presmodule . ".pm"){
1473                 # The presentation module is missing so return an
1474                 # error.
1476                 kiriwrite_error("presmodulemissing");
1478         }
1480         if (!-e "Modules/Database/" . $http_query_dbmodule . ".pm"){
1482                 # The database module is missing so return an
1483                 # error.
1485                 kiriwrite_error("dbmodulemissing");
1487         }
1489         if (!-e "lang/" . $http_query_language . ".lang"){
1491                 # The language file is missing so return an
1492                 # error.
1494                 kiriwrite_error("languagefilenamemissing");
1496         }
1498         # Check the database server settings.
1500         my $kiriwrite_databaseserver_length_check               = kiriwrite_variablecheck($http_query_databaseserver, "maxlength", 128, 1);
1501         my $kiriwrite_databaseserver_lettersnumbers_check       = kiriwrite_variablecheck($http_query_databaseserver, "lettersnumbers", 0, 1);
1502         my $kiriwrite_databaseport_length_check                 = kiriwrite_variablecheck($http_query_databaseport, "maxlength", 5, 1);
1503         my $kiriwrite_databaseport_numbers_check                = kiriwrite_variablecheck($http_query_databaseport, "numbers", 0, 1);
1504         my $kiriwrite_databaseport_port_check                   = kiriwrite_variablecheck($http_query_databaseport, "port", 0, 1);
1505         my $kiriwrite_databaseprotocol_length_check             = kiriwrite_variablecheck($http_query_databaseprotocol, "maxlength", 5, 1);
1506         my $kiriwrite_databaseprotocol_protocol_check           = kiriwrite_variablecheck($http_query_databaseprotocol, "serverprotocol", 0, 1);
1507         my $kiriwrite_databasename_length_check                 = kiriwrite_variablecheck($http_query_databasename, "maxlength", 32, 1);
1508         my $kiriwrite_databasename_lettersnumbers_check         = kiriwrite_variablecheck($http_query_databasename, "lettersnumbers", 0, 1);
1509         my $kiriwrite_databaseusername_length_check             = kiriwrite_variablecheck($http_query_databaseusername, "maxlength", 16, 1);
1510         my $kiriwrite_databaseusername_lettersnumbers_check     = kiriwrite_variablecheck($http_query_databaseusername, "lettersnumbers", 0, 1);
1511         my $kiriwrite_databasepassword_length_check             = kiriwrite_variablecheck($http_query_databasepassword, "maxlength", 64, 1);
1512         my $kiriwrite_databasetableprefix_length_check          = kiriwrite_variablecheck($http_query_databasetableprefix, "maxlength", 16, 1);
1513         my $kiriwrite_databasetableprefix_lettersnumbers_check  = kiriwrite_variablecheck($http_query_databasetableprefix, "lettersnumbers", 0, 1);
1515         if ($kiriwrite_databaseserver_length_check eq 1){
1517                 # The length of the database server name is too long so
1518                 # return an error.
1520                 kiriwrite_error("servernametoolong");
1522         }
1524         if ($kiriwrite_databaseserver_lettersnumbers_check eq 1){
1526                 # The database server name contains characters other
1527                 # than letters and numbers, so return an error.
1529                 kiriwrite_error("servernameinvalid");
1531         }
1533         if ($kiriwrite_databaseport_length_check eq 1){
1535                 # The database port number length is too long so return
1536                 # an error.
1538                 kiriwrite_error("serverportnumbertoolong");
1540         }
1542         if ($kiriwrite_databaseport_numbers_check eq 1){
1544                 # The database port number contains characters other
1545                 # than numbers so return an error.
1547                 kiriwrite_error("serverportnumberinvalidcharacters");
1549         }
1551         if ($kiriwrite_databaseport_port_check eq 1){
1553                 # The database port number given is invalid so return
1554                 # an error.
1556                 kiriwrite_error("serverportnumberinvalid");
1558         }
1560         if ($kiriwrite_databaseprotocol_length_check eq 1){
1562                 # The database protocol name given is too long so
1563                 # return an error.
1565                 kiriwrite_error("serverprotocolnametoolong");
1567         }
1569         if ($kiriwrite_databaseprotocol_protocol_check eq 1){
1571                 # The server protcol given is invalid so return
1572                 # an error.
1574                 kiriwrite_error("serverprotocolinvalid");
1576         }
1578         if ($kiriwrite_databasename_length_check eq 1){
1580                 # The SQL database name is too long so return
1581                 # an error.
1583                 kiriwrite_error("serverdatabasenametoolong");
1585         }
1587         if ($kiriwrite_databasename_lettersnumbers_check eq 1){
1589                 # The database name contains invalid characters
1590                 # so return an error.
1592                 kiriwrite_error("serverdatabasenameinvalid");
1594         }
1596         if ($kiriwrite_databaseusername_length_check eq 1){
1598                 # The database username given is too long so
1599                 # return an error.
1601                 kiriwrite_error("serverdatabaseusernametoolong");
1603         }
1605         if ($kiriwrite_databaseusername_lettersnumbers_check eq 1){
1607                 # The database username contains invalid characters
1608                 # so return an error.
1610                 kiriwrite_error("serverdatabaseusernameinvalid");
1612         }
1614         if ($kiriwrite_databasepassword_length_check eq 1){
1616                 # The database password given is too long so return
1617                 # an error.
1619                 kiriwrite_error("serverdatabasepasswordtoolong");
1621         }
1623         if ($kiriwrite_databasetableprefix_length_check eq 1){
1625                 # The database table prefix given is too long so
1626                 # return an error.
1628                 kiriwrite_error("serverdatabasetableprefixtoolong");
1630         }
1632         if ($kiriwrite_databasetableprefix_lettersnumbers_check eq 1){
1634                 # The database table prefix given contains invalid
1635                 # characters so return an error.
1637                 kiriwrite_error("serverdatabasetableprefixinvalid");
1639         }
1641         # Check the length of value of the checkboxes.
1643         my $kiriwrite_removeinstallscript_length_check  = kiriwrite_variablecheck($http_query_removeinstallscript, "maxlength", 2, 1);
1645         if ($kiriwrite_removeinstallscript_length_check eq 1){
1647                 # The remove install script value is too long
1648                 # so return an error.
1650                 kiriwrite_error("removeinstallscripttoolong");
1652         }
1654         # Check if there is write permissions for the directory.
1656         if (!-w '.'){
1658                 # No write permissions for the directory the
1659                 # script is running from so return an error.
1661                 kiriwrite_error("cannotwriteconfigurationindirectory");
1663         }
1665         # Check if the configuration file already exists.
1667         if (-e 'kiriwrite.cfg'){
1669                 # Check if the configuration file has read permissions.
1671                 if (!-r 'kiriwrite.cfg'){
1673                         # The configuration file has invalid read permissions
1674                         # set so return an error.
1676                         kiriwrite("configurationfilereadpermissionsinvalid");
1678                 }
1680                 # Check if the configuration file has write permissions.
1682                 if (!-w 'kiriwrite.cfg'){
1684                         # The configuration file has invalid write permissions
1685                         # set so return an error.
1687                         kiriwrite("configurationfilewritepermissionsinvalid");
1689                 }
1691         }
1693         # Write the new configuration file.
1695         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 });
1697         my $installscriptmessage        = "";
1699         # Check if the installation script should be deleted.
1701         if (!$http_query_removeinstallscript){
1703                 $http_query_removeinstallscript = "off";
1705         }
1707         if ($http_query_removeinstallscript eq "on"){
1709                 if (unlink($installscriptname)){
1711                         $installscriptmessage = $kiriwrite_lang{$language_selected}{installscriptremoved};
1713                 } else {
1715                         $installscriptmessage = $kiriwrite_lang{$language_selected}{cannotremovescript};
1716                         $installscriptmessage =~ s/%s/$!/g;
1718                 }
1720         }
1722         print "Content-type: text/html\r\n\r\n";
1724         #print start_html({ -title => $kiriwrite_lang{$language_selected}{installertitle}, -style => { -code => $cssstyle }});
1725         print "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
1726         print "<head>\n<title>$kiriwrite_lang{$language_selected}{installertitle}</title>\n<style type=\"text/css\" media=\"screen\">$cssstyle</style>\n</head>\n<body>\n";
1727         print "<h2>$kiriwrite_lang{$language_selected}{installertitle}</h2>";
1728         print $kiriwrite_lang{$language_selected}{installedmessage};
1730         if ($installscriptmessage){
1732                 print "<br /><br />\n";
1733                 print $installscriptmessage;
1735         }
1737         print "<br /><br />\n";
1738         print $kiriwrite_lang{$language_selected}{usekiriwritetext};
1739         print "<br /><br />\n";
1740         print "<a href=\"" . $kiriwritescriptname . "\">$kiriwrite_lang{$language_selected}{usekiriwritelink}</a>";
1741         print "</body>\n</html>";
1743         exit;
1747 # Create a list of common date and time formats.
1749 my @datetime_formats = ( 
1750         'DD/MM/YY (hh:mm:ss)', 'DD/MM/YY hh:mm:ss', 'D/M/Y (hh:mm:ss)',
1751         'D/M/Y hh:mm:ss', 'D/M/YY (hh:mm:ss)', 'D/M/YY hh:mm:ss',
1752         'DD/MM (hh:mm:ss)', 'D/M (hh:mm:ss)', 'DD/MM hh:mm:ss', 
1753         'D/M hh:mm:ss', 'DD/MM hh:mm', 'D/M hh:mm',
1754         'DD/MM/YY', 'D/M/Y', 'DD/MM',
1756         'YY-MM-DD (hh:mm:ss)', 'YY-MM-DD hh:mm:ss', 'Y-M-D (hh:mm:ss)',
1757         'Y-M-D hh:mm:ss', 'M-D (hh:mm:ss)', 'M-D hh:mm:ss',
1758         'YY-MM-DD', 'MM-DD' 
1759 );
1761 # Create the list of tests to do.
1763 my ($test_list, %test_list);
1764 my %dependency_results;
1765 my %database_results;
1766 my %file_results;
1767 my $test;
1768 my $date;
1770 my $dependency_error = 0;
1771 my $database_onemodule = 0;
1772 my $database_error = 0;
1773 my $file_error = 0;
1775 my $language_name;
1776 my $language_xml_data;
1777 my $language_file_friendly;
1779 my $presentation_file_friendly;
1781 # Check to see if the needed Perl modules are installed.
1783 $test_list{CheckDBI}{Name}              = "DBI";
1784 $test_list{CheckDBI}{Type}              = "dependency";
1785 $test_list{CheckDBI}{Code}              = "DBI";
1787 $test_list{CheckTieHash}{Name}          = "Tie::IxHash";
1788 $test_list{CheckTieHash}{Type}          = "dependency";
1789 $test_list{CheckTieHash}{Code}          = "Tie::IxHash";
1791 $test_list{CheckCGILite}{Name}          = "CGI::Lite";
1792 $test_list{CheckCGILite}{Type}          = "dependency";
1793 $test_list{CheckCGILite}{Code}          = "CGI::Lite";
1795 $test_list{Encode}{Name}                = "Encode";
1796 $test_list{Encode}{Type}                = "dependency";
1797 $test_list{Encode}{Code}                = "Encode";
1799 $test_list{DBDmysql}{Name}              = "DBD::mysql";
1800 $test_list{DBDmysql}{Type}              = "database";
1801 $test_list{DBDmysql}{Code}              = "DBD::mysql";
1803 $test_list{DBDSQLite}{Name}             = "DBD::SQLite";
1804 $test_list{DBDSQLite}{Type}             = "database";
1805 $test_list{DBDSQLite}{Code}             = "DBD::SQLite";
1807 # Check the file and directory permissions to see if they are correct.
1809 $test_list{MainDirectory}{Name}         = "Kiriwrite Directory (.)";
1810 $test_list{MainDirectory}{Type}         = "file";
1811 $test_list{MainDirectory}{Code}         = ".";
1812 $test_list{MainDirectory}{Writeable}    = "1";
1814 $test_list{LanguageDirectory}{Name}             = "Language Directory (lang)";
1815 $test_list{LanguageDirectory}{Type}             = "file";
1816 $test_list{LanguageDirectory}{Code}             = "lang";
1817 $test_list{LanguageDirectory}{Writeable}        = "0";
1819 $test_list{ModulesDirectory}{Name}              = "Modules Directory (Modules)";
1820 $test_list{ModulesDirectory}{Type}              = "file";
1821 $test_list{ModulesDirectory}{Code}              = "Modules";
1822 $test_list{ModulesDirectory}{Writeable}         = "0";
1824 $test_list{DBModulesDirectory}{Name}            = "Database Modules Directory (Modules/Database)";
1825 $test_list{DBModulesDirectory}{Type}            = "file";
1826 $test_list{DBModulesDirectory}{Code}            = "Modules/Database";
1827 $test_list{DBModulesDirectory}{Writeable}       = "0";
1829 $test_list{PresModulesDirectory}{Name}          = "Presentation Modules Directory (Modules/Presentation)";
1830 $test_list{PresModulesDirectory}{Type}          = "file";
1831 $test_list{PresModulesDirectory}{Code}          = "Modules/Presentation";
1832 $test_list{PresModulesDirectory}{Writeable}     = "0";
1834 $test_list{SystemModulesDirectory}{Name}                = "System Modules Directory (Modules/System)";
1835 $test_list{SystemModulesDirectory}{Type}                = "file";
1836 $test_list{SystemModulesDirectory}{Code}                = "Modules/System";
1837 $test_list{SystemModulesDirectory}{Writeable}           = "0";
1839 # Preform those tests.
1841 foreach $test (keys %test_list){
1843         # Check the type of test.
1845         if ($test_list{$test}{Type} eq "dependency"){
1847                 if (eval "require " . $test_list{$test}{Code}){
1849                         # The module exists and is working correctly.
1851                         $dependency_results{$test_list{$test}{Name}}{result}    = $kiriwrite_lang{$language_selected}{testpass};
1853                 } else {
1855                         # The module does not exist or has an error.
1857                         $dependency_error = 1;
1858                         $dependency_results{$test_list{$test}{Name}}{result}    = $kiriwrite_lang{$language_selected}{testfail};
1860                 }
1862         } elsif ($test_list{$test}{Type} eq "database"){
1864                 if (eval "require " . $test_list{$test}{Code}){
1866                         # The module exists and it is working correctly.
1868                         $database_results{$test_list{$test}{Name}}{result}      = $kiriwrite_lang{$language_selected}{testpass};
1869                         $database_onemodule = 1;
1871                 } else {
1873                         # The module does not exist or has an error.
1875                         $database_error = 1;
1876                         $database_results{$test_list{$test}{Name}}{result}      = $kiriwrite_lang{$language_selected}{testfail};
1878                 }
1880         } elsif ($test_list{$test}{Type} eq "file"){
1882                 if (-e $test_list{$test}{Code}){
1884                         # The filename given does exist.
1886                 } else {
1888                         # the filename given does not exist.
1890                         $file_error = 1;
1891                         $file_results{$test_list{$test}{Name}}{result}  = $kiriwrite_lang{$language_selected}{errormessage} . $kiriwrite_lang{$language_selected}{doesnotexist};
1893                 }       
1895                 # Test to see if the filename given has read
1896                 # permissions.
1898                 if (-r $test_list{$test}{Code}){
1900                         # The filename given has valid permissions set.
1902                         $file_results{$test_list{$test}{Name}}{result}  = $kiriwrite_lang{$language_selected}{testpass};
1904                 } else {
1906                         # The filename given has invalid permissions set.
1908                         $file_error = 1;
1909                         $file_results{$test_list{$test}{Name}}{result} = $kiriwrite_lang{$language_selected}{errormessage} . $kiriwrite_lang{$language_selected}{invalidpermissionsset};
1911                 }
1913                 if ($test_list{$test}{Writeable} eq 1){
1915                         # Test to see if the filename given has write
1916                         # permissions.
1918                         if (-w $test_list{$test}{Code}){
1920                                 # The filename given has valid permissions set.
1922                                 $file_results{$test_list{$test}{Name}}{result}  = $kiriwrite_lang{$language_selected}{testpass};
1924                         } else {
1926                                 # The filename given has invalid permissions set.
1928                                 $file_error = 1;
1929                                 $file_results{$test_list{$test}{Name}}{result}  = $kiriwrite_lang{$language_selected}{errormessage} . $kiriwrite_lang{$language_selected}{invalidpermissionsset};
1931                         }
1933                 }
1935         }
1939 # Print the header.
1941 print "Content-Type: text/html;\r\n\r\n";
1943 # Print the page for installing Kiriwrite.
1945 print "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
1946 print "<head>\n<title>$kiriwrite_lang{$language_selected}{installertitle}</title>\n";
1947 print "<style type=\"text/css\" media=\"screen\">$cssstyle</style>\n</head>\n<body>";
1949 print "<table width=\"100%\">";
1950 my $language_name_short;
1951 my $language_list_seek = 0;
1952 my $installlanguage_out = "";
1954 $installlanguage_out = "<select name=\"installlanguage\">\n";
1956 foreach $language_name_short (@language_list_short){
1958         $installlanguage_out = $installlanguage_out . "<option value=\"" . $language_name_short . "\">" . $language_list_long[$language_list_seek] . "</option>\n";
1959         $language_list_seek++;
1963 $installlanguage_out = $installlanguage_out . "</select>\n";
1965 kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{installertitle}, "languagebar", "<form action=\"" . $installscriptname . "\" method=\"POST\">\n$installlanguage_out\n<input type=\"submit\" value=\"$kiriwrite_lang{$language_selected}{switch}\">\n</form>\n", "languagebarselect");
1966 print "</table>";
1968 print "<h2>$kiriwrite_lang{$language_selected}{installertitle}</h2>\n";
1969 print $kiriwrite_lang{$language_selected}{installertext};
1971 if ($modperlenabled eq 1){
1972         print "<br /><br />";
1973         print $kiriwrite_lang{$language_selected}{modperlnotice};
1976 print "<h3>$kiriwrite_lang{$language_selected}{dependencytitle}</h3>\n";
1977 print "<h4>$kiriwrite_lang{$language_selected}{requiredmodules}</h4>\n";
1978 print $kiriwrite_lang{$language_selected}{perlmodules};
1979 print "<br /><br />\n";
1981 if ($dependency_error eq 1){
1983         print $kiriwrite_lang{$language_selected}{errormessage};
1984         print $kiriwrite_lang{$language_selected}{dependencyperlmodulesmissing};
1985         print "<br /><br />\n";
1989 print "<table>\n";
1991 kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{module}, "tablecellheader", $kiriwrite_lang{$language_selected}{result}, "tablecellheader");
1993 foreach $test (keys %dependency_results) {
1995         kiriwrite_addtablerow($test, "tablename", $dependency_results{$test}{result}, "tabledata");
1999 print "</table>";
2001 print "<h4>$kiriwrite_lang{$language_selected}{databasemodules}</h4>\n";
2002 print $kiriwrite_lang{$language_selected}{databasemodulestext};
2003 print "<br /><br />\n";
2005 print "<table>\n";
2007 if ($database_error eq 1){
2009         print $kiriwrite_lang{$language_selected}{warningmessage};
2010         print $kiriwrite_lang{$language_selected}{databaseperlmodulesmissing};
2011         print "<br /><br />\n";
2015 kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{module}, "tablecellheader", $kiriwrite_lang{$language_selected}{result}, "tablecellheader");
2017 foreach $test (keys %database_results) {
2019         kiriwrite_addtablerow($test, "tablename", $database_results{$test}{result}, "tabledata");
2023 print "</table>";
2025 print "<h4>$kiriwrite_lang{$language_selected}{filepermissions}</h4>\n";
2027 print $kiriwrite_lang{$language_selected}{filepermissionstext};
2028 print "<br /><br />\n";
2030 if ($file_error eq 1){
2032         print $kiriwrite_lang{$language_selected}{errormessage};
2033         print $kiriwrite_lang{$language_selected}{filepermissionsinvalid};
2034         print "<br /><br />\n";
2038 print "<table>";
2040 kiriwrite_addtablerow("Filename", "tablecellheader", "Result", "tablecellheader");
2042 foreach $test (keys %file_results) {
2044         kiriwrite_addtablerow($test, "tablename", $file_results{$test}{result}, "tabledata");
2048 print "</table>";
2050 if ($dependency_error eq 1){
2052         print "<hr />\n";
2053         print "<h4>$kiriwrite_lang{$language_selected}{criticalerror}</h4>\n";
2054         print $kiriwrite_lang{$language_selected}{dependencymodulesnotinstalled} . "\n";
2055         print "</body>\n</html>";
2056         exit;
2060 if ($database_onemodule eq 0){
2062         print "<hr />\n";
2063         print "<h4>$kiriwrite_lang{$language_selected}{criticalerror}</h4>\n";
2064         print $kiriwrite_lang{$language_selected}{databasemodulesnotinstalled} . "\n";
2065         print "</body>\n</html>";
2066         exit;
2070 if ($file_error eq 1){
2072         print "<hr />\n";
2073         print "<h4>$kiriwrite_lang{$language_selected}{criticalerror}</h4>\n";
2074         print $kiriwrite_lang{$language_selected}{filepermissionerrors} . "\n";
2075         print "</body>\n</html>";
2076         exit;
2080 my @language_short;
2081 my (%available_languages, $available_languages);
2082 my @presentation_modules;
2083 my @database_modules;
2084 my $select_data = "";
2085 my (%language_data, $language_data);
2086 my @lang_data;
2087 my $kiriwrite_languagefilehandle;
2088 my $language_out = "";
2089 my ($presmodule_name, $presmodule_out) = "";
2090 my ($dbmodule_name, $dbmodule_out) = "";
2092 # Get the list of available languages.
2094 tie(%available_languages, 'Tie::IxHash');
2096 opendir(LANGUAGEDIR, "lang");
2097 my @language_directory = grep /m*\.lang$/, readdir(LANGUAGEDIR);
2098 closedir(LANGUAGEDIR);
2100 foreach my $language_file (@language_directory){
2102         # Load the language file.
2104         open ($kiriwrite_languagefilehandle, "lang/" . $language_file);
2105         @lang_data = <$kiriwrite_languagefilehandle>;
2106         %language_data = kiriwrite_processconfig(@lang_data);
2107         close ($kiriwrite_languagefilehandle);
2109         # Get the friendly name for the language file.
2111         $language_file_friendly = $language_file;
2112         $language_file_friendly =~ s/.lang$//g;
2114         $language_name = $language_data{about}{name};
2116         $available_languages{$language_file_friendly} = $language_name . " (" . $language_file_friendly . ")";
2120 # Get the list of presentation modules.
2122 opendir(OUTPUTSYSTEMDIR, "Modules/Presentation");
2123 my @presmodule_directory = grep /m*\.pm$/, readdir(OUTPUTSYSTEMDIR);
2124 closedir(OUTPUTSYSTEMDIR);
2126 foreach my $presmodule_file (@presmodule_directory){
2128         # Get the friendly name for the database module.
2130         $presmodule_file =~ s/.pm$//g;
2131         push(@presentation_modules, $presmodule_file);
2135 # Get the list of database modules.
2137 opendir(DATABASEDIR, "Modules/Database");
2138 my @dbmodule_directory = grep /m*\.pm$/, readdir(DATABASEDIR);
2139 closedir(DATABASEDIR);
2141 foreach my $dbmodule_file (@dbmodule_directory){
2143         # Get the friendly name for the database module.
2145         $dbmodule_file =~ s/.pm$//g;
2146         push(@database_modules, $dbmodule_file);
2150 print "<h3>$kiriwrite_lang{$language_selected}{settingstitle}</h3>";
2151 print $kiriwrite_lang{$language_selected}{settingstext};
2152 print "<br /><br />\n";
2154 print "<form action=\"" . $installscriptname . "\" method=\"POST\">";
2155 print "<input type=\"hidden\" name=\"confirm\" value=\"1\">\n<input type=\"hidden\" name=\"installlanguage\" value=\"$language_selected\">\n";
2157 print "<table width=\"100%\">";
2158 kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{setting}, "tablecellheader", $kiriwrite_lang{$language_selected}{value}, "tablecellheader");
2159 kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{directories}, "tablecellheader", "", "tablecellheader");
2160 kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{databasedirectory}, "tablename", "<input type=\"text\" name=\"dbdirectory\" size=\"32\" maxlength=\"64\" value=\"$default_dbdirectory\">", "tabledata");
2161 kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{outputdirectory}, "tablename", "<input type=\"text\" name=\"outputdirectory\" size=\"32\" maxlength=\"64\" value=\"$default_outputdirectory\">", "tabledata");
2162 kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{imagesuripath}, "tablename", "<input type=\"text\" name=\"imagesuripath\" size=\"32\" maxlength=\"64\" value=\"$default_imagesuri\">", "tabledata");
2163 kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{display}, "tablecellheader", "", "tablecellheader");
2164 kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{textarearows}, "tablename", "<input type=\"text\" name=\"textarearows\" size=\"3\" maxlength=\"3\" value=\"$default_textarearows\">", "tabledata");
2165 kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{textareacols}, "tablename", "<input type=\"text\" name=\"textareacols\" size=\"3\" maxlength=\"3\" value=\"$default_textareacols\">", "tabledata");
2166 kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{date}, "tablecellheader", "", "tablecellheader");
2168 foreach my $select_name (@datetime_formats){
2169         $select_data = $select_data . "<option value=\"$select_name\">" . $select_name . "</option>\n";
2172 kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{dateformat}, "tablename", "<select name=\"dateformat\">$select_data</select>\n<input type=\"text\" size=\"32\" maxlength=\"64\" name=\"customdateformat\">", "tabledata");
2173 kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{language}, "tablecellheader", "", "tablecellheader");
2175 foreach my $language (keys %available_languages){
2176         if ($language eq $language_selected){
2177                 $language_out = $language_out . "<option value=\"" . $language . "\" selected=selected>" . $available_languages{$language} . "</option>\n";
2178         } else {
2179                 $language_out = $language_out . "<option value=\"" . $language . "\">" . $available_languages{$language} . "</option>\n";
2180         }
2183 kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{systemlanguage}, "tablename", "<select name=\"language\">\r\n$language_out\r\n</select>", "tabledata");
2184 kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{modules}, "tablecellheader", "", "tablecellheader");
2185 foreach $presmodule_name (@presentation_modules){
2186         $presmodule_out = $presmodule_out . "<option value=\"$presmodule_name\">$presmodule_name</option>";
2188 kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{presentationmodule}, "tablename", "<select name=\"presmodule\">$presmodule_out</select>", "tabledata");
2189 foreach $dbmodule_name (@database_modules){
2190         $dbmodule_out = $dbmodule_out . "<option value=\"$dbmodule_name\">$dbmodule_name</option>";
2193 kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{databasemodule}, "tablename", "<select name=\"dbmodule\">$dbmodule_out</select>", "tabledata");
2194 kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{databaseserver}, "tablename", "<input type=\"text\" name=\"databaseserver\" size=\"32\" maxlength=\"128\" value=\"$default_server\">\n", "tabledata");
2195 kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{databaseport}, "tablename", "<input type=\"text\" name=\"databaseport\" maxlength=\"5\" size=\"5\" value=\"$default_port\">\n", "tabledata");
2196 kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{databaseprotocol}, "tablename", "<select name=\"databaseprotocol\">\n<option value=\"tcp\">tcp</option>\n<option value=\"udp\">udp</option>\n</select>\n", "tabledata");
2197 kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{databasename}, "tablename", "<input type=\"text\" name=\"databasename\" size=\"32\" maxlength=\"32\" value=\"$default_name\">\n", "tabledata");
2198 kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{databaseusername}, "tablename", "<input type=\"text\" name=\"databaseusername\" size=\"16\" maxlength=\"16\" value=\"$default_username\">\n", "tabledata");
2199 kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{databasepassword}, "tablename", "<input type=\"password\" name=\"databasepassword\" size=\"32\" maxlength=\"64\">\n", "tabledata");
2200 kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{databasetableprefix}, "tablename", "<input type=\"text\" name=\"databasetableprefix\" size=\"32\" maxlength=\"32\" value=\"$default_prefix\">\n", "tabledata");
2201 kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{installationoptions}, "tablecellheader", "", "tablecellheader");
2202 kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{installoptions}, "tablename", "<input type=\"checkbox\" name=\"removeinstallscript\" checked=checked value=\"on\"> $kiriwrite_lang{$language_selected}{removeinstallscript}\n", "tabledata");
2204 print "</table>\n";
2206 print "<br />\n<input type=\"submit\" value=\"$kiriwrite_lang{$language_selected}{savesettingsbutton}\"> | <input type=\"reset\" value=\"$kiriwrite_lang{$language_selected}{resetsettingsbutton}\">\n";
2208 print "</form>\n</body>\n</html>";
2209 exit;
2211 __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