Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Forked Xestia Scanner Server!
[xestiascansrv/.git] / cgi-files / install.cgi
1 #!/usr/bin/perl -Tw
3 #################################################################################
4 # Xestia Scanner Server Installer Script (install.cgi)                          #
5 # Installation script for Xestia Scanner Server                                 #
6 #                                                                               #
7 # Version: 0.1.0                                                                #
8 #                                                                               #
9 # Copyright (C) 2005-2011 Steve Brokenshire <sbrokenshire@xestia.co.uk>         #
10 #                                                                               #
11 # This module is licensed under the same license as Xestia Scanner Server which #
12 # is licensed under the GPL version 3.                                          #
13 #                                                                               #
14 # This program is free software: you can redistribute it and/or modify          #
15 # it under the terms of the GNU General Public License as published by          #
16 # the Free Software Foundation, version 3 of the License.                       #
17 #                                                                               #
18 # This program is distributed in the hope that it will be useful,               #
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of                #
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                 #
21 # GNU General Public License for more details.                                  #
22 #                                                                               #
23 # You should have received a copy of the GNU General Public License             #
24 # along with this program.  If not, see <http://www.gnu.org/licenses/>.         #
25 ################################################################################# 
27 # TODO: ADD SCANNED IMAGES (FS & URI LOCATIONS) TO THE INSTALLED!!!
29 use strict;                             # Throw errors if there's something wrong.
30 use warnings;                           # Write warnings to the HTTP Server Log file.
32 use Cwd qw(abs_path cwd);
34 use utf8;
36 eval "use CGI::Lite";
38 if ($@){
39         print "Content-type: text/html; charset=utf-8;\r\n\r\n";
40         print "The CGI::Lite Perl Module is not installed. Please install CGI::Lite and then run this installation script again. CGI::Lite can be installed through CPAN.";
41         exit;
42 }
44 eval "use Tie::IxHash";
46 if ($@){
47         print "Content-type: text/html; charset=utf-8;\r\n\r\n";
48         print "The Tie::IxHash Perl Module is not installed. Please install Tie::IxHash and then run this installation script again. Tie::IxHash can be installed through CPAN.";
49         exit;
50 }
52 # Check if mod_perl is running and if it is then add a notice to say
53 # that additional configuration has to be made.
55 my $modperlenabled = 0;
56 my $installscriptname = "install.cgi";
57 my $multiuserinstallscriptname = "install-multiuser.cgi";
58 my $xestiascanscriptname = "xsdss.cgi";
60 #if ($ENV{'MOD_PERL'}){
62         # MOD_PERL 2.X SPECIFIC SECTION.
64 #       use lib '';
65 #       chdir('');
67 #       $modperlenabled         = 1;
68 #       $installscriptname      = "install.pl";
69 #       $xestiascanscriptname   = "kiriwrite.pl";
71 #}
73 # Setup strings in specific languages. Style should be no spacing for
74 # language title and one tabbed spacing for each string.
76 # Define some default settings.
78 my $default_language            = "en-GB";
79 my $default_imagesuri           = "/images/xestiascan";
80 my $default_scansuri            = "/images/xestiascan/scans";
82 my $default_scansfs             = abs_path("..") . "/images/xestiascan/scans";
84 my $default_outputmodule        = "Normal";
86 my $default_server              = "localhost";
87 my $default_port                = "5432";
88 my $default_protocol            = "tcp";
89 my $default_name                = "database";
90 my $default_username            = "username";
91 my $default_prefix              = "xestiascan";
93 my ($xestiascan_lang, %xestiascan_lang);
95 $xestiascan_lang{"en-GB"}{"languagename"}       = "English (British)";
96         $xestiascan_lang{"en-GB"}{"testpass"}           = "OK";
97         $xestiascan_lang{"en-GB"}{"testfail"}           = "Error";
99         $xestiascan_lang{"en-GB"}{"generic"}                    = "An error occured which is not known to the Xestia Scanner Server installer.";
100         $xestiascan_lang{"en-GB"}{"invalidvariable"}            = "The variable given was invalid.";
101         $xestiascan_lang{"en-GB"}{"invalidvalue"}               = "The value given was invalid.";
102         $xestiascan_lang{"en-GB"}{"invalidoption"}              = "The option given was invalid.";
103         $xestiascan_lang{"en-GB"}{"variabletoolong"}            = "The variable given is too long.";
104         $xestiascan_lang{"en-GB"}{"blankdirectory"}             = "The directory name given is blank.";
105         $xestiascan_lang{"en-GB"}{"invaliddirectory"}           = "The directory name given is invalid.";
106         $xestiascan_lang{"en-GB"}{"moduleblank"}                        = "The module filename given is blank.";
107         $xestiascan_lang{"en-GB"}{"moduleinvalid"}              = "The module filename given is invalid.";
109         $xestiascan_lang{"en-GB"}{"authdirectorytoolong"}       = "The authentication directory name given is too long.";
110         $xestiascan_lang{"en-GB"}{"outputdirectorytoolong"}     = "The output directory name given is too long.";
111         $xestiascan_lang{"en-GB"}{"imagesuripathtoolong"}       = "The images URI path name given is too long.";
112         $xestiascan_lang{"en-GB"}{"scansuripathtoolong"}        = "The scans URI path name given is too long.";
113         $xestiascan_lang{"en-GB"}{"scansfspathtoolong"}         = "The scans filesystem path name given is too long.";
114         $xestiascan_lang{"en-GB"}{"dateformattoolong"}          = "The date format given is too long.";
115         $xestiascan_lang{"en-GB"}{"customdateformattoolong"}    = "The custom date format given is too long.";
116         $xestiascan_lang{"en-GB"}{"languagefilenametoolong"}    = "The language filename given is too long.";
118         $xestiascan_lang{"en-GB"}{"dateformatblank"}            = "The date format given was blank.";
119         $xestiascan_lang{"en-GB"}{"dateformatinvalid"}          = "The date format given is invalid.";
120         $xestiascan_lang{"en-GB"}{"languagefilenameinvalid"}    = "The language filename given is invalid.";
122         $xestiascan_lang{"en-GB"}{"authdirectoryblank"}         = "The authentication directory name given is blank.";
123         $xestiascan_lang{"en-GB"}{"authdirectoryinvalid"}       = "The authentication directory name given is invalid.";
125         $xestiascan_lang{"en-GB"}{"outputdirectoryblank"}       = "The output directory name given is blank.";
126         $xestiascan_lang{"en-GB"}{"outputdirectoryinvalid"}     = "The output directory name given is invalid.";
128         $xestiascan_lang{"en-GB"}{"textarearowblank"}           = "The text area row value given is blank.";
129         $xestiascan_lang{"en-GB"}{"textarearowtoolong"}         = "The text area row value given is too long.";
130         $xestiascan_lang{"en-GB"}{"textarearowinvalid"}         = "The text area row value given is invalid.";
132         $xestiascan_lang{"en-GB"}{"textareacolsblank"}          = "The text area columns value given is blank.";
133         $xestiascan_lang{"en-GB"}{"textareacolstoolong"}                = "The text area columns value given is too long.";
134         $xestiascan_lang{"en-GB"}{"textareacolsinvalid"}                = "The text area columns value given is invalid.";
136         $xestiascan_lang{"en-GB"}{"presmoduleblank"}            = "The presentation module name given is blank.";
137         $xestiascan_lang{"en-GB"}{"presmoduleinvalid"}          = "The presentation module name given is invalid.";
139         $xestiascan_lang{"en-GB"}{"authmoduleblank"}            = "The authentication module name given is blank.";
140         $xestiascan_lang{"en-GB"}{"authmoduleinvalid"}          = "The authentication module name given is invalid.";
141  
142         $xestiascan_lang{"en-GB"}{"outputmoduleblank"}          = "The output module name given is blank.";
143         $xestiascan_lang{"en-GB"}{"outputmoduleinvalid"}        = "The output module name given is invalid.";
144  
145         $xestiascan_lang{"en-GB"}{"presmodulemissing"}          = "The presentation module with the filename given is missing.";
146         $xestiascan_lang{"en-GB"}{"outputmodulemissing"}                = "The output module with the filename given is missing.";
147         $xestiascan_lang{"en-GB"}{"authmodulemissing"}          = "The authentication module with the filename given is missing.";
148         $xestiascan_lang{"en-GB"}{"languagefilenamemissing"}    = "The language file with the filename given is missing.";
149  
150         $xestiascan_lang{"en-GB"}{"servernametoolong"}          = "The database server name given is too long.";
151         $xestiascan_lang{"en-GB"}{"servernameinvalid"}          = "The database server name given is invalid.";
152         $xestiascan_lang{"en-GB"}{"serverportnumbertoolong"}    = "The database server port number given is too long.";
153         $xestiascan_lang{"en-GB"}{"serverportnumberinvalidcharacters"}  = "The database server port number given contains invalid characters.";
154         $xestiascan_lang{"en-GB"}{"serverportnumberinvalid"}    = "The database server port number given is invalid.";
155         $xestiascan_lang{"en-GB"}{"serverprotocolnametoolong"}  = "The database server protocol name given is too long.";
156         $xestiascan_lang{"en-GB"}{"serverprotocolinvalid"}              = "The database server protocol name is invalid.";
157         $xestiascan_lang{"en-GB"}{"serverdatabasenametoolong"}  = "The database name given is too long.";
158         $xestiascan_lang{"en-GB"}{"serverdatabasenameinvalid"}  = "The database name given is invalid.";
159         $xestiascan_lang{"en-GB"}{"serverdatabaseusernametoolong"}      = "The database server username given is too long.";
160         $xestiascan_lang{"en-GB"}{"serverdatabaseusernameinvalid"}      = "The database server username given is invalid.";
161         $xestiascan_lang{"en-GB"}{"serverdatabasepasswordtoolong"}      = "The database server password is too long.";
162         $xestiascan_lang{"en-GB"}{"serverdatabasetableprefixtoolong"}   = "The database server table prefix given is too long.";
163         $xestiascan_lang{"en-GB"}{"serverdatabasetableprefixinvalid"}   = "The database server table prefix given is invalid.";
164  
165         $xestiascan_lang{"en-GB"}{"removeinstallscripttoolong"} = "The remove installer script value given is too long.";
166         $xestiascan_lang{"en-GB"}{"removemultiuserinstallscripttoolong"}        = "The remove multiuser installer script value given is too long.";
167         $xestiascan_lang{"en-GB"}{"cannotwriteconfigurationindirectory"}        = "The configuration file cannot be written because the directory the install script is running from has invalid permissions.";
168         $xestiascan_lang{"en-GB"}{"configurationfilereadpermissionsinvalid"}    = "The configuration that currently exists has invalid read permissions set.";
169         $xestiascan_lang{"en-GB"}{"configurationfilewritepermissionsinvalid"}   = "The configuration that currently exists has invalid write permissions set.";
171         $xestiascan_lang{"en-GB"}{"errormessagetext"}   = "Please press the back button on your browser or preform the command needed to return to the previous page.";
173         $xestiascan_lang{"en-GB"}{"switch"}             = "Switch";
174         $xestiascan_lang{"en-GB"}{"setting"}            = "Setting";
175         $xestiascan_lang{"en-GB"}{"value"}              = "Value";
176         $xestiascan_lang{"en-GB"}{"filename"}           = "Filename";
177         $xestiascan_lang{"en-GB"}{"module"}             = "Module";
178         $xestiascan_lang{"en-GB"}{"result"}             = "Result";
179         $xestiascan_lang{"en-GB"}{"requiredver"}        = "Required Version";
180         $xestiascan_lang{"en-GB"}{"installedver"}       = "Installed Version";
181         $xestiascan_lang{"en-GB"}{"error"}              = "Error!";
182         $xestiascan_lang{"en-GB"}{"criticalerror"}      = "Critical Error!";
183         $xestiascan_lang{"en-GB"}{"errormessage"}       = "Error: ";
184         $xestiascan_lang{"en-GB"}{"warningmessage"}     = "Warning: ";
186         $xestiascan_lang{"en-GB"}{"doesnotexist"}       = "Does not exist.";
187         $xestiascan_lang{"en-GB"}{"invalidpermissionsset"}      = "Invalid permissions set.";
189         $xestiascan_lang{"en-GB"}{"dependencyperlmodulesmissing"}       = "One or more Perl modules that are needed by Xestia Scanner Server are not installed or has problems. See the Xestia Scanner Server documentation for more information on this.";
190         $xestiascan_lang{"en-GB"}{"databaseperlmodulesmissing"} = "One or more Perl modules that are needed by the Xestia Scanner Server database modules are not installed or has problems. See the Xestia Scanner Server 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.";
191         $xestiascan_lang{"en-GB"}{"filepermissionsinvalid"}     = "One or more of the filenames checked does not exist or has invalid permissions set. See the Xestia Scanner Server documentation for more information on this.";
192         $xestiascan_lang{"en-GB"}{"dependencymodulesnotinstalled"}      = "One of the required Perl modules is not installed or has errors. See the Xestia Scanner Server documentation for more information on this.";
193         $xestiascan_lang{"en-GB"}{"databasemodulesnotinstalled"}        = "None of Perl modules that are used by the authentication modules are not installed. See the Xestia Scanner Server documentation for more information on this.";
194         $xestiascan_lang{"en-GB"}{"filepermissionerrors"}       = "One or more filenames checked has errors. See the Xestia Scanner Server documentation for more information on this.",
196         $xestiascan_lang{"en-GB"}{"installertitle"}     = "Xestia Scanner Server Installer";
197         $xestiascan_lang{"en-GB"}{"installertext"}      = "This installer script will setup the configuration file used for Xestia Scanner Server. The settings displayed here can be changed at a later date by selecting the Edit Settings link in the View Settings sub-menu.";
198         $xestiascan_lang{"en-GB"}{"modperlnotice"}      = "mod_perl has been detected. Please ensure that you have setup this script and the main Xestia Scanner Server script so that mod_perl can use Xestia Scanner Server properly. Please read the mod_perl specific part of Chapter 1: Installation in the Xestia Scanner Server documentation.";
199         $xestiascan_lang{"en-GB"}{"dependencytitle"}    = "Dependency and file testing results";
200         $xestiascan_lang{"en-GB"}{"requiredmodules"}    = "Required Modules";
201         $xestiascan_lang{"en-GB"}{"perlmodules"}        = "These Perl modules are used by Xestia Scanner Server and can be downloaded from CPAN if they are missing. Please check and compare the required and installed versions as installed modules that do not meet the required version may cause Xestia Scanner Server to not work properly.";
202         $xestiascan_lang{"en-GB"}{"databasemodules"}    = "Perl Database Modules";
203         $xestiascan_lang{"en-GB"}{"databasemodulestext"}= "These Perl modules are used by the authentication modules.";
204         $xestiascan_lang{"en-GB"}{"filepermissions"}    = "File permissions";
205         $xestiascan_lang{"en-GB"}{"filepermissionstext"}        = "The file permissions are for file and directories that are critical to Xestia Scanner Server such as module and language directories.";
206         
207         $xestiascan_lang{"en-GB"}{"settingstitle"}      = "Xestia Scanner Server Settings";
208         $xestiascan_lang{"en-GB"}{"settingstext"}       = "The settings given here will be used by Xestia Scanner Server. Some default settings are given here. Certain database modules (like SQLite) do not need the database server settings and can be left alone.";
209         $xestiascan_lang{"en-GB"}{"directories"}        = "Directories";
210         $xestiascan_lang{"en-GB"}{"databasedirectory"}  = "Database Directory";
211         $xestiascan_lang{"en-GB"}{"outputdirectory"}    = "Output Directory";
212         $xestiascan_lang{"en-GB"}{"imagesuripath"}      = "Images (URI path)";
213         $xestiascan_lang{"en-GB"}{"scansuripath"}       = "Scans (URI path)";
214         $xestiascan_lang{"en-GB"}{"scansfspath"}        = "Scans (Filesystem path)";
215         $xestiascan_lang{"en-GB"}{"display"}            = "Display";
216         $xestiascan_lang{"en-GB"}{"textareacols"}       = "Text Area Columns";
217         $xestiascan_lang{"en-GB"}{"textarearows"}       = "Text Area Rows";
218         $xestiascan_lang{"en-GB"}{"date"}               = "Date";
219         $xestiascan_lang{"en-GB"}{"dateformat"}         = "Date Format";
220         $xestiascan_lang{"en-GB"}{"language"}           = "Language";
221         $xestiascan_lang{"en-GB"}{"systemlanguage"}     = "System Language";
222         $xestiascan_lang{"en-GB"}{"modules"}            = "Modules";
223         $xestiascan_lang{"en-GB"}{"presentationmodule"} = "Presentation Module";
224         $xestiascan_lang{"en-GB"}{"outputmodule"}       = "Output Module";
225         $xestiascan_lang{"en-GB"}{"authmodule"}         = "Authentication Module";
226         $xestiascan_lang{"en-GB"}{"databaseserver"}     = "Database Server";
227         $xestiascan_lang{"en-GB"}{"databaseport"}       = "Database Port";
228         $xestiascan_lang{"en-GB"}{"databaseprotocol"}   = "Database Protocol";
229         $xestiascan_lang{"en-GB"}{"databasename"}       = "Database Name";
230         $xestiascan_lang{"en-GB"}{"databaseusername"}   = "Database Username";
231         $xestiascan_lang{"en-GB"}{"databasepassword"}   = "Database Password";
232         $xestiascan_lang{"en-GB"}{"databasetableprefix"}        = "Database Table Prefix";
233         $xestiascan_lang{"en-GB"}{"installationoptions"}        = "Installation Options";
234         $xestiascan_lang{"en-GB"}{"installoptions"}     = "Install Options";
235         $xestiascan_lang{"en-GB"}{"removeinstallscript"}        = "Delete this installer script after configuration file has been written.";
236         $xestiascan_lang{"en-GB"}{"removemultiuserinstallscript"}       = "Delete the multiuser installer script if not needed.";
237         $xestiascan_lang{"en-GB"}{"savesettingsbutton"} = "Save Settings";
238         $xestiascan_lang{"en-GB"}{"resetsettingsbutton"}        = "Reset Settings";
240         $xestiascan_lang{"en-GB"}{"installscriptremoved"}       = "The installer script was removed.";
241         $xestiascan_lang{"en-GB"}{"installedmessage"}   = "The configuration file for Xestia Scanner Server 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 Xestia Scanner Server.";
242         $xestiascan_lang{"en-GB"}{"cannotremovescript"} = "Unable to remove the installer script: %s. The installer script will have to be deleted manually.";
243         $xestiascan_lang{"en-GB"}{"cannotremovemultiuserscript"}        = "Unable to remove the multiuser installer script: %s. The installer script will have to be deleted manually.";
244         $xestiascan_lang{"en-GB"}{"usexestiascannerservertext"} = "To use Xestia Scanner Server click or select the link below (will not work if the Xestia Scanner Server script is not called xsdss.cgi):";
245         $xestiascan_lang{"en-GB"}{"usexestiascannerserverlink"} = "Start using Xestia Scanner Server.";
247         $xestiascan_lang{"en-GB"}{"multiuserinstall"} = "The authentication module selected requires additional setup. Please click on the multiuser installer link below for more instructions.";
248         $xestiascan_lang{"en-GB"}{"multiuserinstalllink"} = "Start the Multiuser Installer.";
250 my $query_lite = new CGI::Lite;
251 my $form_data = $query_lite->parse_form_data;
253 my $language_selected = "";
254 my $http_query_confirm = $form_data->{'confirm'};
255 my $http_query_installlanguage = $form_data->{'installlanguage'};
257 if (!$http_query_installlanguage){
259         $language_selected = $default_language;
261 } else {
263         $language_selected = $http_query_installlanguage;
267 # Process the list of available languages.
269 my $language_list_name;
270 my @language_list_short;
271 my @language_list_long;
273 foreach my $language (keys %xestiascan_lang){
275         $language_list_name = $xestiascan_lang{$language}{"languagename"} . " (" . $language .  ")";
276         push(@language_list_short, $language);
277         push(@language_list_long, $language_list_name);
281 # The CSS Stylesheet to use.
283 my $cssstyle = "
285 a {
286         color: #FFFFFF;
289 body {
290         margin: 0px; 
291         font-family: sans-serif; 
292         padding: 0px; 
293         font-size: 13px;
294         background-color: #402040;
295         color: #ffffff;
296         background-image: url('/images/xestiascan/pagebackground.png');
297         background-repeat: repeat-x;
300 td,table {
301         padding: 5px;
302         border-spacing: 0px;
305 .languagebar {
306         background-color: #204040;
307         vertical-align: top;
310 .languagebarselect {
311         text-align: right;
312         background-color: #204040;
315 .tablecellheader {
316         font-size: 12px;
317         background-color: #703570;      
318         font-weight: bold;
319         text-align: left;
320         background-image: url('/images/xestiascan/tabletop.png');
321         background-repeat: repeat-x;
324 .tabledata {
325         background-color: #603060;
328 .topbar {
329         padding: 3px;
330         background-color: #753575;
331         border-bottom-style: solid;
332         border-bottom-width: 1px;
333         border-bottom-color: #EE70EE;
334         text-align: right;
335         min-height: 17px;
336         background-image: url('/images/xestiascan/menutop.png');
337         background-repeat: repeat-x;
340 .title {
341         font-size: 16px;
342         font-weight: bold;
343         position: absolute;
344         text-align: left;
345         z-index: 0;
346         left: 0;
347         padding-left: 3px;
350 .pageheader {
351         font-size: 18px;
352         font-weight: bold;
355 .subheader {
356         font-size: 14px;
357         font-weight: bold;
360 .tablename {
362         background-color: #301530;
366 .pagespacing {
368         padding: 3px;
372 ";
375 #################################################################################
376 # Begin list of subroutines.                                                    #
377 #################################################################################
379 sub xestiascan_variablecheck{
380 #################################################################################
381 # xestiascan_variablecheck: Check to see if the data passed is valid.           #
382 #                                                                               #
383 # Usage:                                                                        #
384 #                                                                               #
385 # xestiascan_variablecheck(variablename, type, option, noerror);                #
386 #                                                                               #
387 # variablename  Specifies the variable to be checked.                           #
388 # type          Specifies what type the variable is.                            #
389 # option        Specifies the maximum/minimum length of the variable            #
390 #               (if minlength/maxlength is used) or if the filename should be   #
391 #               checked to see if it is blank.                                  #
392 # noerror       Specifies if Kiriwrite should return an error or not on         #
393 #               certain values.                                                 #
394 #################################################################################
396         # Get the values that were passed to the subroutine.
398         my ($variable_data, $variable_type, $variable_option, $variable_noerror) = @_;
400         if ($variable_type eq "numbers"){
402                 # Check for numbers and return an error if there is anything else than numebrs.
404                 my $variable_data_validated = $variable_data;   # Copy the variable_data to variable_data_validated.
405                 $variable_data_validated =~ tr/0-9//d;          # Take away all of the numbers and from the variable. 
406                                                                 # If it only contains numbers then it should be blank.
408                 if ($variable_data_validated eq ""){
409                         # The validated variable is blank. So continue to the end of this section where the return function should be.
410                 } else {
411                         # The variable is not blank, so check if the no error value is set
412                         # to 1 or not.
414                         if ($variable_noerror eq 1){
416                                 # The validated variable is not blank and the noerror
417                                 # value is set to 1. So return an value of 1.
418                                 # (meaning that the data is invalid).
420                                 return 1;
422                         } elsif ($variable_noerror eq 0) {
424                                 # The validated variable is not blank and the noerror
425                                 # value is set to 0.
427                                 xestiascan_error("invalidvariable");
429                         } else {
431                                 # The variable noerror value is something else
432                                 # pther than 1 or 0. So return an error.
434                                 xestiascan_error("invalidvariable");
436                         }
438                 }
440                 return 0;
442         } elsif ($variable_type eq "lettersnumbers"){
444                 # Check for letters and numbers and return an error if there is anything else other
445                 # than letters and numbers.
447                 my $variable_data_validated = $variable_data;   # Copy the variable_data to variable_data_validated
448                 $variable_data_validated =~ tr/a-zA-Z0-9.//d;
449                 $variable_data_validated =~ s/\s//g;
451                 if ($variable_data_validated eq ""){
452                         # The validated variable is blank. So continue to the end of this section where the return function should be.
453                 } else {
454                         # The variable is not blank, so check if the no error value is set
455                         # to 1 or not.
457                         if ($variable_noerror eq 1){
459                                 # The validated variable is not blank and the noerror
460                                 # value is set to 1. So return an value of 1.
461                                 # (meaning that the data is invalid).
463                                 return 1;
465                         } elsif ($variable_noerror eq 0) {
467                                 # The validated variable is not blank and the noerror
468                                 # value is set to 0.
470                                 xestiascan_error("invalidvariable");
472                         } else {
474                                 # The variable noerror value is something else
475                                 # pther than 1 or 0. So return an error.
477                                 xestiascan_error("invalidvariable");
479                         }
481                 }
483                 return 0;
485         } elsif ($variable_type eq "maxlength"){
486                 # Check for the length of the variable, return an error if it is longer than the length specified.
488                 # Check if the variable_data string is blank, if it is then set the variable_data_length
489                 # to '0'.
491                 my $variable_data_length = 0;
493                 if (!$variable_data){
495                         # Set variable_data_length to '0'.
496                         $variable_data_length = 0;
498                 } else {
500                         # Get the length of the variable recieved.
501                         $variable_data_length = length($variable_data);
503                 }
507                 if ($variable_data_length > $variable_option){
509                         # The variable length is longer than it should be so check if
510                         # the no error value is set 1.
512                         if ($variable_noerror eq 1){
514                                 # The no error value is set to 1, so return an
515                                 # value of 1 (meaning tha the variable is
516                                 # too long to be used).
518                                 return 1;
520                         } elsif ($variable_noerror eq 0){
522                                 # The no error value is set to 0, so return
523                                 # an error.
525                                 xestiascan_error("variabletoolong");
527                         } else {
529                                 # The no error value is something else other
530                                 # than 0 or 1, so return an error.
532                                 xestiascan_error("variabletoolong");
534                         }
536                 } else {
538                         # The variable length is exactly or shorter than specified, so continue to end of this section where
539                         # the return function should be.
541                 }
543                 return 0;
545         } elsif ($variable_type eq "datetime"){
546                 # Check if the date and time setting format is valid.
548                 if ($variable_data eq ""){
550                         if ($variable_noerror eq 1){
552                                 # The no error value is set to 1 so return
553                                 # a value of 1 (meaning that the date and
554                                 # time format was blank).
556                                 return 1;
558                         } elsif ($variable_noerror eq 0){
560                                 # The no error value is set to 1 so return
561                                 # an error.
563                                 xestiascan_error("dateformatblank");
565                         } else {
567                                 # The no error value is something else other
568                                 # than 0 or 1, so return an error.
570                                 xestiascan_error("invalidvariable");
572                         }
574                 }
576                 my $variable_data_validated = $variable_data;
577                 $variable_data_validated =~ tr|dDmMyYhms/():[ ]||d;
579                 if ($variable_data_validated eq ""){
581                         # The date and time format is valid. So
582                         # skip this bit.
584                 } else {
586                         # The validated data variable is not blank, meaning 
587                         # that it contains something else, so return an error
588                         # (or a value).
590                         if ($variable_noerror eq 1){
592                                 # The no error value is set to 1 so return
593                                 # an value of 2. (meaning that the date and
594                                 # time format was invalid).
596                                 return 2;
598                         } elsif ($variable_noerror eq 0){
600                                 # The no error value is set to 0 so return
601                                 # an error.
603                                 xestiascan_error("dateformatinvalid");
605                         } else {
607                                 # The no error value is something else other
608                                 # than 0 or 1 so return an error.
610                                 xestiascan_error("invalidvariable");
612                         }
614                 }
616                 return 0;
618         } elsif ($variable_type eq "directory"){
619                 # Check if the directory only contains letters and numbers and
620                 # return an error if anything else appears.
622                 my $variable_data_validated = $variable_data;
623                 $variable_data_validated =~ tr/a-zA-Z0-9//d;
625                 if ($variable_data eq ""){
627                         if ($variable_noerror eq 1){
629                                 # The no error value is set to 1 so return
630                                 # a value of 1 (meaning that the directory
631                                 # name was blank).
633                                 return 1;
635                         } elsif ($variable_noerror eq 0){
637                                 # The no error value is set to 1 so return
638                                 # an error.
640                                 xestiascan_error("blankdirectory");
642                         } else {
644                                 # The no error value is something else other
645                                 # than 0 or 1, so return an error.
647                                 xestiascan_error("invalidvariable");
649                         }
651                 }
653                 if ($variable_data_validated eq ""){
655                         # The validated data variable is blank, meaning that
656                         # it only contains letters and numbers.
658                 } else {
660                         # The validated data variable is not blank, meaning 
661                         # that it contains something else, so return an error
662                         # (or a value).
664                         if ($variable_noerror eq 1){
666                                 # The no error value is set to 1 so return
667                                 # an value of 2. (meaning that the directory
668                                 # name is invalid).
670                                 return 2;
672                         } elsif ($variable_noerror eq 0){
674                                 # The no error value is set to 0 so return
675                                 # an error.
677                                 xestiascan_error("invaliddirectory");
679                         } else {
681                                 # The no error value is something else other
682                                 # than 0 or 1 so return an error.
684                                 xestiascan_error("invalidvariable");
686                         }
688                 }
690                 return 0;
692         } elsif ($variable_type eq "language_filename"){
694                 # The variable type is a language filename type.
695                 # Check if the language file name is blank and 
696                 # if it is then return an error (or value).
698                 if ($variable_data eq ""){
700                         # The language filename is blank so check the
701                         # no error value and return an error (or value).
703                         if ($variable_noerror eq 1){
705                                 # Language filename is blank and the no error value
706                                 # is set as 1, so return a value of 1 (saying that
707                                 # the language filename is blank).
709                                 return 1;
711                         } elsif ($variable_noerror eq 0) {
713                                 # Language filename is blank and the no error value
714                                 # is not set as 1, so return an error.
716                                 xestiascan_error("languagefilenameblank");
718                         } else {
720                                 # The noerror value is something else other
721                                 # than 0 or 1 so return an error.
723                                 xestiascan_error("invalidvariable");
725                         }
727                 }
729                 # Set the following variables for later on.
731                 my $variable_data_length = 0;
732                 my $variable_data_char = "";
733                 my $variable_data_seek = 0;
735                 # Get the length of the language file name.
737                 $variable_data_length = length($variable_data);
739                 do {
741                         # Get a character from the language filename passed to this 
742                         # subroutine and the character the seek counter value is set
743                         # to.
745                         $variable_data_char = substr($variable_data, $variable_data_seek, 1);
747                         # Check if the language filename contains a forward slash or a dot, 
748                         # if the selected character is a forward slash then return an error
749                         # (or value).
751                         if ($variable_data_char eq "/" || $variable_data_char eq "."){
753                                 # The language filename contains a forward slash or
754                                 # a dot so depending on the no error value, return
755                                 # an error or a value.
757                                 if ($variable_noerror eq 1){
759                                         # Language filename contains a forward slash or a dot
760                                         # and the no error value has been set to 1, so return 
761                                         # an value of 2 (saying that the language file name is 
762                                         # invalid).
764                                         return 2;
766                                 } elsif ($variable_noerror eq 0) {
768                                         # Language filename contains a forward slash and the no
769                                         # error value has not been set to 1, so return an error.
771                                         xestiascan_error("languagefilenameinvalid");
773                                 } else {
775                                         # The noerror value is something else other than
776                                         # 1 or 0 so return an error.
778                                         xestiascan_error("invalidvariable");
780                                 }
782                         }
784                         # Increment the seek counter.
786                         $variable_data_seek++;
788                 } until ($variable_data_seek eq $variable_data_length);
790                 return 0;
792         } elsif ($variable_type eq "module"){
794                 # The variable type is a presentation module filename.
796                 # Check if the variable_data is blank and if it is
797                 # return an error.
799                 if ($variable_data eq ""){
801                         # The presentation module is blank so check if an error
802                         # value should be returned or a number should be
803                         # returned.
805                         if ($variable_noerror eq 1){
807                                 # Module name is blank and the no error value 
808                                 # is set to 1 so return a value of 2 (meaning 
809                                 # that the page filename is blank).
811                                 return 1;
813                         } elsif ($variable_noerror eq 0) {
815                                 # Module name contains is blank and the no error 
816                                 # value is set to 0 so return an error.
818                                 xestiascan_critical("moduleblank");
820                         } else {
822                                 # The no error value is something else other
823                                 # than 0 or 1 so return an error.
825                                 xestiascan_critical("invalidvalue");
827                         }
829                 } else {
831                 }
833                 my $variable_data_validated = $variable_data;
834                 $variable_data_validated =~ tr/a-zA-Z0-9//d;
836                 if ($variable_data_validated eq ""){
838                 } else {
840                         if ($variable_noerror eq 1){
842                                 # Module name contains invalid characters and
843                                 # the no error value is set to 1 so return a 
844                                 # value of 2 (meaning that the page filename
845                                 # is invalid).
847                                 return 2;
849                         } elsif ($variable_noerror eq 0) {
851                                 # Module name contains invalid characters and
852                                 # the no error value is set to 0 so return an
853                                 # error.
855                                 xestiascan_critical("moduleinvalid");
857                         } else {
859                                 # The no error value is something else other
860                                 # than 0 or 1 so return an error.
862                                 xestiascan_error("invalidvalue");
864                         }
866                 }
868                 return 0;
870         } elsif ($variable_type eq "serverprotocol"){
872                 # Check if the server protocol is TCP or UDP and return
873                 # an error if it isn't.
875                 if ($variable_data ne "tcp" && $variable_data ne "udp"){
877                         # The protocol given is not valid, check if the no
878                         # error value is set to 1 and return an error if it isn't.
880                         if ($variable_noerror eq 1){
882                                 # The no error value has been set to 1, so return a
883                                 # value of 1 (meaning that the server protocol is
884                                 # invalid).
886                                 return 1;
888                         } elsif ($variable_noerror eq 0){
890                                 # The no error value has been set to 0, so return
891                                 # an error.
893                                 xestiascan_error("serverprotocolinvalid");
895                         } else {
897                                 # The no error value is something else other than 0
898                                 # or 1, so return an error.
900                                 xestiascan_error("invalidoption");
902                         }
904                 }
906                 return 0;
908         } elsif ($variable_type eq "port"){
910                 # Check if the port number given is less than 0 or more than 65535
911                 # and return an error if it is.
913                 if ($variable_data < 0 || $variable_data > 65535){
915                         # The port number is less than 0 and more than 65535 so
916                         # check if the no error value is set to 1 and return an
917                         # error if it isn't.
919                         if ($variable_noerror eq 1){
921                                 # The no error value has been set to 1, so return a
922                                 # value of 1 (meaning that the port number is invalid).
924                                 return 1;
926                         } elsif ($variable_noerror eq 0){
928                                 # The no error value has been set to 0, so return
929                                 # an error.
931                                 xestiascan_error("serverportnumberinvalid");
933                         } else {
935                                 # The no error value is something else other than 0
936                                 # or 1, so return an error.
938                                 xestiascan_error("invalidoption");
940                         }
942                 }
944                 return 0;
946         }
948         # Another type than the valid ones above has been specified so return an error specifying an invalid option.
949         xestiascan_error("invalidoption");
953 sub xestiascan_error{
954 #################################################################################
955 # xestiascan_error: Subroutine for processing error messages.                   #
956 #                                                                               #
957 # Usage:                                                                        #
958 #                                                                               #
959 # xestiascan_error(errortype);                                                  #
960 #                                                                               #
961 # errortype     Specifies the error type to use.                                #
962 #################################################################################
964         my $error_type = shift;
966         # Load the list of error messages.
968         my (%xestiascan_error, $xestiascan_error);
970         %xestiascan_error = (
972                 # Generic Error Messages
974                 "generic"                       => $xestiascan_lang{$language_selected}{generic},
976                 "invalidvariable"               => $xestiascan_lang{$language_selected}{invalidvariable},
977                 "invalidvalue"                  => $xestiascan_lang{$language_selected}{invalidvalue},
978                 "invalidoption"                 => $xestiascan_lang{$language_selected}{invalidoption},
979                 "variabletoolong"               => $xestiascan_lang{$language_selected}{variabletoolong},
980                 "blankdirectory"                => $xestiascan_lang{$language_selected}{blankdirectory},
981                 "invaliddirectory"              => $xestiascan_lang{$language_selected}{invaliddirectory},
982                 "moduleblank"                   => $xestiascan_lang{$language_selected}{moduleblank},
983                 "moduleinvalid"                 => $xestiascan_lang{$language_selected}{moduleinvalid},
985                 # Specific Error Messages
987                 "authdirectorytoolong"          => $xestiascan_lang{$language_selected}{dbdirectorytoolong},
988                 "outputdirectorytoolong"        => $xestiascan_lang{$language_selected}{outputdirectorytoolong},
989                 "imagesuripathtoolong"          => $xestiascan_lang{$language_selected}{imagesuripathtoolong},
990                 "dateformattoolong"             => $xestiascan_lang{$language_selected}{dateformattoolong},
991                 "customdateformattoolong"       => $xestiascan_lang{$language_selected}{customdateformattoolong},
992                 "languagefilenametoolong"       => $xestiascan_lang{$language_selected}{languagefilenametoolong},
993                 
994                 "dateformatblank"               => $xestiascan_lang{$language_selected}{dateformatblank},
995                 "dateformatinvalid"             => $xestiascan_lang{$language_selected}{dateformatinvalid},
996                 "languagefilenameinvalid"       => $xestiascan_lang{$language_selected}{languagefilenameinvalid},
997                 
998                 "dbdirectoryblank"              => $xestiascan_lang{$language_selected}{dbdirectoryblank},
999                 "dbdirectoryinvalid"            => $xestiascan_lang{$language_selected}{dbdirectoryinvalid},
1001                 "textarearowblank"              => $xestiascan_lang{$language_selected}{textarearowblank},
1002                 "textarearowtoolong"            => $xestiascan_lang{$language_selected}{textarearowtoolong},
1003                 "textarearowinvalid"            => $xestiascan_lang{$language_selected}{textarearowinvalid},
1005                 "textareacolsblank"             => $xestiascan_lang{$language_selected}{textareacolsblank},
1006                 "textareacolstoolong"           => $xestiascan_lang{$language_selected}{textareacolstoolong},
1007                 "textareacolsinvalid"           => $xestiascan_lang{$language_selected}{textareacolsinvalid},
1009                 "outputdirectoryblank"          => $xestiascan_lang{$language_selected}{outputdirectoryblank},
1010                 "outputdirectoryinvalid"        => $xestiascan_lang{$language_selected}{outputdirectoryinvalid},
1012                 "presmoduleblank"               => $xestiascan_lang{$language_selected}{presmoduleblank},
1013                 "presmoduleinvalid"             => $xestiascan_lang{$language_selected}{presmoduleinvalid},
1015                 "authmoduleblank"               => $xestiascan_lang{$language_selected}{authmoduleblank},
1016                 "authmoduleinvalid"             => $xestiascan_lang{$language_selected}{authmoduleinvalid},
1018                 "presmodulemissing"             => $xestiascan_lang{$language_selected}{presmodulemissing},
1019                 "authmodulemissing"             => $xestiascan_lang{$language_selected}{authmodulemissing},
1020                 "languagefilenamemissing"       => $xestiascan_lang{$language_selected}{languagefilenamemissing},
1022                 "servernametoolong"             => $xestiascan_lang{$language_selected}{servernametoolong},
1023                 "servernameinvalid"             => $xestiascan_lang{$language_selected}{servernameinvalid},
1024                 "serverportnumbertoolong"       => $xestiascan_lang{$language_selected}{serverportnumbertoolong},
1025                 "serverportnumberinvalidcharacters"     => $xestiascan_lang{$language_selected}{serverportnumberinvalidcharacters},
1026                 "serverportnumberinvalid"       => $xestiascan_lang{$language_selected}{serverportnumberinvalid},
1027                 "serverprotocolnametoolong"     => $xestiascan_lang{$language_selected}{serverprotocolnametoolong},
1028                 "serverprotocolinvalid"         => $xestiascan_lang{$language_selected}{serverprotocolinvalid},
1029                 "serverdatabasenametoolong"     => $xestiascan_lang{$language_selected}{serverdatabasenametoolong},
1030                 "serverdatabasenameinvalid"     => $xestiascan_lang{$language_selected}{serverdatabasenameinvalid},
1031                 "serverdatabaseusernametoolong" => $xestiascan_lang{$language_selected}{serverdatabaseusernametoolong},
1032                 "serverdatabaseusernameinvalid" => $xestiascan_lang{$language_selected}{serverdatabaseusernameinvalid},
1033                 "serverdatabasepasswordtoolong" => $xestiascan_lang{$language_selected}{serverdatabasepasswordtoolong},
1034                 "serverdatabasetableprefixtoolong"      => $xestiascan_lang{$language_selected}{serverdatabasetableprefixtoolong},
1035                 "serverdatabasetableprefixinvalid"      => $xestiascan_lang{$language_selected}{serverdatabasetableprefixinvalid},
1037                 "removeinstallscripttoolong"    => $xestiascan_lang{$language_selected}{removeinstallscripttoolong},
1038                 "cannotwriteconfigurationindirectory"   => $xestiascan_lang{$language_selected}{cannotwriteconfigurationindirectory},
1039                 "configurationfilereadpermissionsinvalid"       => $xestiascan_lang{$language_selected}{configurationfilereadpermissionsinvalid},
1040                 "configurationfilewritepermissionsinvalid"      => $xestiascan_lang{$language_selected}{configurationfilewritepermissionsinvalid},
1042         );
1044         # Check if the specified error is blank and if it is
1045         # use the generic error messsage.
1047         if (!$xestiascan_error{$error_type}){
1048                 $error_type = "generic";
1049         }
1051         print "Content-type: text/html; charset=utf-8;\r\n\r\n";
1053         print "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
1054         print "<head>\n<title>$xestiascan_lang{$language_selected}{installertitle}</title>\n<style type=\"text/css\" media=\"screen\">$cssstyle</style>\n</head>\n<body>\n";
1056         print "<h2>$xestiascan_lang{$language_selected}{error}</h2>";
1058         print $xestiascan_error{$error_type};
1059         print "<br />\n";
1060         print $xestiascan_lang{$language_selected}{errormessagetext};
1062         print "</body>\n</html>";
1064         exit;
1068 sub xestiascan_writeconfig{
1069 #################################################################################
1070 # xestiascan_writeconfig: Writes a configuration file.                          #
1071 #                                                                               #
1072 # Usage:                                                                        #
1073 #                                                                               #
1074 # xestiascan_writeconfig();                                                     #
1075 #################################################################################
1077         my ($passedsettings) = @_;
1079         # Open the configuration file for writing.
1081         open (my $configfile, "> " . "xsdss.cfg");
1083         print $configfile "[config]
1084 directory_noncgi_images = $passedsettings->{ImagesURIPath}
1085 directory_noncgi_scans = $passedsettings->{ScansURIPath}
1086 directory_fs_scans = $passedsettings->{ScansFSPath}
1088 system_language = $passedsettings->{Language}
1089 system_presmodule = $passedsettings->{PresentationModule}
1090 system_outputmodule = $passedsettings->{OutputModule}
1091 system_authmodule = $passedsettings->{AuthModule}
1092 system_datetime = $passedsettings->{DateFormat}
1093                 
1094 database_server = $passedsettings->{DatabaseServer}
1095 database_port = $passedsettings->{DatabasePort}
1096 database_protocol = $passedsettings->{DatabaseProtocol}
1097 database_sqldatabase = $passedsettings->{DatabaseName}
1098 database_username = $passedsettings->{DatabaseUsername}
1099 database_password = $passedsettings->{DatabasePassword}
1100 database_tableprefix = $passedsettings->{DatabaseTablePrefix}
1101         ";
1103         close ($configfile);
1104         
1105         # Set the correct permissions for the file.
1106         
1107         chmod (0660, "xsdss.cfg");
1111 sub xestiascan_addtablerow{
1112 #################################################################################
1113 # xestiascan_addtablerow: Adds a table row.                                     #
1114 #                                                                               #
1115 # Usage:                                                                        #
1116 #                                                                               #
1117 # xestiascan_addtablerow(name, data);                                           #
1118 #                                                                               #
1119 # name          Specifies the name of the table row.                            #
1120 # namestyle     Specifies the style for the name of the table row.              #
1121 # data          Specifies the data to be used in the table row.                 #
1122 # datastyle     Specifies the style for the data of the table row.              #
1123 #################################################################################
1125         #my ($name, $namestyle, $data, $datastyle) = @_;
1127         my $tablecell;
1129         print "<tr>\n";
1130         
1131         my $data;
1132         my $datastyle;
1133         
1134         while (@_){
1136                 $data           = shift @_;
1137                 $datastyle      = shift @_;
1138                 
1139                 if (!$data){
1140                         
1141                         $data = "";
1142                         
1143                 }
1145                 if (!$datastyle){
1146                         
1147                         $datastyle = "";
1148                         
1149                 }
1150                 
1151                 print "<td class=\"$datastyle\">$data</td>\n";
1153                 $data = "";
1154                 $datastyle = "";
1155                 
1156                 
1157         }       
1159         print "</tr>\n";
1160         
1161         #print "<tr>\n";
1162         #print "<td class=\"$namestyle\">$name</td>\n";
1163         #print "<td class=\"$datastyle\">$data</td>\n";
1164         #print "</tr>\n";
1168 sub xestiascan_processconfig{
1169 #################################################################################
1170 # xestiascan_processconfig: Processes an INI style configuration file.          #
1171 #                                                                               #
1172 # Usage:                                                                        #
1173 #                                                                               #
1174 # xestiascan_processconfig(data);                                               #
1175 #                                                                               #
1176 # data  Specifies the data to process.                                          #
1177 #################################################################################
1179         my (@settings) = @_;
1181         my ($settings_line, %settings, $settings, $sectionname, $setting_name, $setting_value);
1183         foreach $settings_line (@settings){
1185                 next if !$settings_line;
1187                 # Check if the first character is a bracket.
1189                 if (substr($settings_line, 0, 1) eq "["){
1190                         $settings_line =~ s/\[//;
1191                         $settings_line =~ s/\](.*)//;
1192                         $settings_line =~ s/\n//;
1193                         $sectionname = $settings_line;
1194                         next;
1195                 }
1197                 $setting_name  = $settings_line;
1198                 $setting_value = $settings_line;
1199                 $setting_name  =~ s/\=(.*)//;
1200                 $setting_name  =~ s/\n//;
1201                 $setting_value =~ s/(.*)\=//;
1202                 $setting_value =~ s/\n//;
1204                 # Remove the spacing before and after the '=' sign.
1206                 $setting_name =~ s/\s+$//;
1207                 $setting_value =~ s/^\s+//;
1208                 $setting_value =~ s/\r//;
1210                 $settings{$sectionname}{$setting_name} = $setting_value;
1212         }
1214         return %settings;
1218 #################################################################################
1219 # End list of subroutines.                                                      #
1220 #################################################################################
1222 if (!$http_query_confirm){
1224         $http_query_confirm = 0;
1228 if ($http_query_confirm eq 1){
1230         # The confirm value has been given so get the data from the query.
1232         my $http_query_imagesuripath            = $form_data->{'imagesuripath'};
1233         my $http_query_scansuripath             = $form_data->{'scansuripath'};
1234         my $http_query_scansfspath              = $form_data->{'scansfspath'};
1236         my $http_query_dateformat               = $form_data->{'dateformat'};
1237         my $http_query_customdateformat         = $form_data->{'customdateformat'};
1239         my $http_query_language                 = $form_data->{'language'};
1241         my $http_query_presmodule               = $form_data->{'presmodule'};
1242         my $http_query_outputmodule             = $form_data->{'outputmodule'};
1243         my $http_query_authmodule               = $form_data->{'authmodule'};
1245         my $http_query_databaseserver           = $form_data->{'databaseserver'};
1246         my $http_query_databaseport             = $form_data->{'databaseport'};
1247         my $http_query_databaseprotocol         = $form_data->{'databaseprotocol'};
1248         my $http_query_databasename             = $form_data->{'databasename'};
1249         my $http_query_databaseusername         = $form_data->{'databaseusername'};
1250         my $http_query_databasepassword         = $form_data->{'databasepassword'};
1251         my $http_query_databasetableprefix      = $form_data->{'databasetableprefix'};
1252         
1253         my $http_query_removeinstallscript      = $form_data->{'removeinstallscript'};
1254         my $http_query_removemultiuserinstallscript     = $form_data->{'removemultiuserinstallscript'};
1256         # Check the length of the variables.
1258         my $xestiascan_imagesuripath_length_check       = xestiascan_variablecheck($http_query_imagesuripath, "maxlength", 512, 1);
1259         my $xestiascan_scansuripath_length_check        = xestiascan_variablecheck($http_query_scansuripath, "maxlength", 512, 1);
1260         my $xestiascan_scansfspath_length_check         = xestiascan_variablecheck($http_query_scansfspath, "maxlength", 4096, 1);
1261         my $xestiascan_dateformat_length_check          = xestiascan_variablecheck($http_query_dateformat, "maxlength", 32, 1);
1262         my $xestiascan_customdateformat_length_check    = xestiascan_variablecheck($http_query_customdateformat, "maxlength", 32, 1);
1263         my $xestiascan_language_length_check            = xestiascan_variablecheck($http_query_language, "maxlength", 16, 1);
1265         # Check if any errors occured while checking the
1266         # length of the variables.
1268         if ($xestiascan_imagesuripath_length_check eq 1){
1270                 # The images URI path given is too long
1271                 # so return an error.
1273                 xestiascan_error("imagesuripathtoolong");
1275         }
1276         
1277         if ($xestiascan_scansuripath_length_check eq 1){
1278                 
1279                 # The scans URI path given is too long
1280                 # so return an error.
1281                 
1282                 xestiascan_error("scansuripathtoolong");
1283                 
1284         }
1285         
1286         if ($xestiascan_scansfspath_length_check eq 1){
1287                 
1288                 # The scans filesystem path given is too long
1289                 # so return an error.
1290                 
1291                 xestiascan_error("scansfspathtoolong");
1292                 
1293         }
1295         if ($xestiascan_dateformat_length_check eq 1){
1297                 # The date format given is too long
1298                 # so return an error.
1300                 xestiascan_error("dateformattoolong");
1302         }
1304         if ($xestiascan_customdateformat_length_check eq 1){
1306                 # The date format given is too long
1307                 # so return an error.
1309                 xestiascan_error("customdateformattoolong");
1311         }
1313         if ($xestiascan_language_length_check eq 1){
1315                 # The language filename given is too long
1316                 # so return an error.
1318                 xestiascan_error("languagefilenametoolong");
1320         }
1322         # Check if the custom date and time setting has anything
1323         # set and if it doesn't then use the predefined one set.
1325         my $finaldateformat = "";
1327         if ($http_query_customdateformat ne ""){
1329                 $finaldateformat = $http_query_customdateformat;
1331         } else {
1333                 $finaldateformat = $http_query_dateformat;
1335         }
1337         my $xestiascan_datetime_check           = xestiascan_variablecheck($finaldateformat, "datetime", 0, 1);
1339         if ($xestiascan_datetime_check eq 1){
1341                 # The date and time format is blank so return
1342                 # an error.
1344                 xestiascan_error("dateformatblank");
1346         } elsif ($xestiascan_datetime_check eq 2){
1348                 # The date and time format is invalid so
1349                 # return an error.
1351                 xestiascan_error("dateformatinvalid");
1353         }
1355         # Check if the language filename given is valid.
1357         my $xestiascan_language_languagefilename_check = xestiascan_variablecheck($http_query_language, "language_filename", "", 1);
1359         if ($xestiascan_language_languagefilename_check eq 1) {
1361                 # The language filename given is blank so
1362                 # return an error.
1364                 xestiascan_error("languagefilenameblank");
1366         } elsif ($xestiascan_language_languagefilename_check eq 2){
1368                 # The language filename given is invalid so
1369                 # return an error.
1371                 xestiascan_error("languagefilenameinvalid");
1373         }
1375         # Check the module names to see if they're valid.
1377         my $xestiascan_presmodule_modulename_check      = xestiascan_variablecheck($http_query_presmodule, "module", 0, 1);
1378         my $xestiascan_outputmodule_modulename_check    = xestiascan_variablecheck($http_query_outputmodule, "module", 0, 1);
1379         my $xestiascan_authmodule_modulename_check              = xestiascan_variablecheck($http_query_authmodule, "module", 0, 1);
1381         if ($xestiascan_presmodule_modulename_check eq 1){
1383                 # The presentation module name is blank, so return
1384                 # an error.
1386                 xestiascan_error("presmoduleblank");
1388         }
1390         if ($xestiascan_presmodule_modulename_check eq 2){
1392                 # The presentation module name is invalid, so return
1393                 # an error.
1395                 xestiascan_error("presmoduleinvalid");
1397         }
1399         if ($xestiascan_outputmodule_modulename_check eq 1){
1401                 # The output module name is blank, so return
1402                 # an error.
1404                 xestiascan_error("outputmoduleblank");
1406         }
1408         if ($xestiascan_outputmodule_modulename_check eq 2){
1410                 # The output module name is invalid, so return
1411                 # an error.
1413                 xestiascan_error("outputmoduleinvalid");
1415         }
1417         if ($xestiascan_authmodule_modulename_check eq 1){
1419                 # The database module name is blank, so return
1420                 # an error.
1422                 xestiascan_error("authmoduleblank");
1424         }
1426         if ($xestiascan_authmodule_modulename_check eq 2){
1428                 # The database module name is invalid, so return
1429                 # an error.
1431                 xestiascan_error("authmoduleinvalid");
1433         }
1435         # Check if the database module, presentation module,
1436         # output module and language file exists.
1438         if (!-e "Modules/Presentation/" . $http_query_presmodule . ".pm"){
1440                 # The presentation module is missing so return an
1441                 # error.
1443                 xestiascan_error("presmodulemissing");
1445         }
1447         if (!-e "Modules/Output/" . $http_query_outputmodule . ".pm"){
1449                 # The database module is missing so return an
1450                 # error.
1452                 xestiascan_error("outputmodulemissing");
1454         }
1456         if (!-e "Modules/Auth/" . $http_query_authmodule . ".pm"){
1458                 # The database module is missing so return an
1459                 # error.
1461                 xestiascan_error("authmodulemissing");
1463         }
1465         if (!-e "lang/" . $http_query_language . ".lang"){
1467                 # The language file is missing so return an
1468                 # error.
1470                 xestiascan_error("languagefilenamemissing");
1472         }
1474         # Check the database server settings.
1476         my $xestiascan_databaseserver_length_check              = xestiascan_variablecheck($http_query_databaseserver, "maxlength", 128, 1);
1477         my $xestiascan_databaseserver_lettersnumbers_check      = xestiascan_variablecheck($http_query_databaseserver, "lettersnumbers", 0, 1);
1478         my $xestiascan_databaseport_length_check                        = xestiascan_variablecheck($http_query_databaseport, "maxlength", 5, 1);
1479         my $xestiascan_databaseport_numbers_check               = xestiascan_variablecheck($http_query_databaseport, "numbers", 0, 1);
1480         my $xestiascan_databaseport_port_check                  = xestiascan_variablecheck($http_query_databaseport, "port", 0, 1);
1481         my $xestiascan_databaseprotocol_length_check            = xestiascan_variablecheck($http_query_databaseprotocol, "maxlength", 5, 1);
1482         my $xestiascan_databaseprotocol_protocol_check          = xestiascan_variablecheck($http_query_databaseprotocol, "serverprotocol", 0, 1);
1483         my $xestiascan_databasename_length_check                        = xestiascan_variablecheck($http_query_databasename, "maxlength", 32, 1);
1484         my $xestiascan_databasename_lettersnumbers_check                = xestiascan_variablecheck($http_query_databasename, "lettersnumbers", 0, 1);
1485         my $xestiascan_databaseusername_length_check            = xestiascan_variablecheck($http_query_databaseusername, "maxlength", 16, 1);
1486         my $xestiascan_databaseusername_lettersnumbers_check    = xestiascan_variablecheck($http_query_databaseusername, "lettersnumbers", 0, 1);
1487         my $xestiascan_databasepassword_length_check            = xestiascan_variablecheck($http_query_databasepassword, "maxlength", 64, 1);
1488         my $xestiascan_databasetableprefix_length_check         = xestiascan_variablecheck($http_query_databasetableprefix, "maxlength", 16, 1);
1489         my $xestiascan_databasetableprefix_lettersnumbers_check = xestiascan_variablecheck($http_query_databasetableprefix, "lettersnumbers", 0, 1);
1491         if ($xestiascan_databaseserver_length_check eq 1){
1493                 # The length of the database server name is too long so
1494                 # return an error.
1496                 xestiascan_error("servernametoolong");
1498         }
1500         if ($xestiascan_databaseserver_lettersnumbers_check eq 1){
1502                 # The database server name contains characters other
1503                 # than letters and numbers, so return an error.
1505                 xestiascan_error("servernameinvalid");
1507         }
1509         if ($xestiascan_databaseport_length_check eq 1){
1511                 # The database port number length is too long so return
1512                 # an error.
1514                 xestiascan_error("serverportnumbertoolong");
1516         }
1518         if ($xestiascan_databaseport_numbers_check eq 1){
1520                 # The database port number contains characters other
1521                 # than numbers so return an error.
1523                 xestiascan_error("serverportnumberinvalidcharacters");
1525         }
1527         if ($xestiascan_databaseport_port_check eq 1){
1529                 # The database port number given is invalid so return
1530                 # an error.
1532                 xestiascan_error("serverportnumberinvalid");
1534         }
1536         if ($xestiascan_databaseprotocol_length_check eq 1){
1538                 # The database protocol name given is too long so
1539                 # return an error.
1541                 xestiascan_error("serverprotocolnametoolong");
1543         }
1545         if ($xestiascan_databaseprotocol_protocol_check eq 1){
1547                 # The server protcol given is invalid so return
1548                 # an error.
1550                 xestiascan_error("serverprotocolinvalid");
1552         }
1554         if ($xestiascan_databasename_length_check eq 1){
1556                 # The SQL database name is too long so return
1557                 # an error.
1559                 xestiascan_error("serverdatabasenametoolong");
1561         }
1563         if ($xestiascan_databasename_lettersnumbers_check eq 1){
1565                 # The database name contains invalid characters
1566                 # so return an error.
1568                 xestiascan_error("serverdatabasenameinvalid");
1570         }
1572         if ($xestiascan_databaseusername_length_check eq 1){
1574                 # The database username given is too long so
1575                 # return an error.
1577                 xestiascan_error("serverdatabaseusernametoolong");
1579         }
1581         if ($xestiascan_databaseusername_lettersnumbers_check eq 1){
1583                 # The database username contains invalid characters
1584                 # so return an error.
1586                 xestiascan_error("serverdatabaseusernameinvalid");
1588         }
1590         if ($xestiascan_databasepassword_length_check eq 1){
1592                 # The database password given is too long so return
1593                 # an error.
1595                 xestiascan_error("serverdatabasepasswordtoolong");
1597         }
1599         if ($xestiascan_databasetableprefix_length_check eq 1){
1601                 # The database table prefix given is too long so
1602                 # return an error.
1604                 xestiascan_error("serverdatabasetableprefixtoolong");
1606         }
1608         if ($xestiascan_databasetableprefix_lettersnumbers_check eq 1){
1610                 # The database table prefix given contains invalid
1611                 # characters so return an error.
1613                 xestiascan_error("serverdatabasetableprefixinvalid");
1615         }
1617         # Check the length of value of the checkboxes.
1619         my $xestiascan_removeinstallscript_length_check = xestiascan_variablecheck($http_query_removeinstallscript, "maxlength", 2, 1);
1621         if ($xestiascan_removeinstallscript_length_check eq 1){
1623                 # The remove install script value is too long
1624                 # so return an error.
1626                 xestiascan_error("removeinstallscripttoolong");
1628         }
1629         
1630         my $xestiascan_removemultiuserinstallscript_length_check        = xestiascan_variablecheck($http_query_removemultiuserinstallscript, "maxlength", 2, 1);
1631         
1632         if ($xestiascan_removemultiuserinstallscript_length_check eq 1){
1633                 
1634                 # The remove install script value is too long
1635                 # so return an error.
1636                 
1637                 xestiascan_error("removemultiuserinstallscripttoolong");
1638                 
1639         }
1641         # Check if there is write permissions for the directory.
1643         if (!-w '.'){
1645                 # No write permissions for the directory the
1646                 # script is running from so return an error.
1648                 xestiascan_error("cannotwriteconfigurationindirectory");
1650         }
1652         # Check if the configuration file already exists.
1654         if (-e 'xsdss.cfg'){
1656                 # Check if the configuration file has read permissions.
1658                 if (!-r 'xsdss.cfg'){
1660                         # The configuration file has invalid read permissions
1661                         # set so return an error.
1663                         xestiascan_error("configurationfilereadpermissionsinvalid");
1665                 }
1667                 # Check if the configuration file has write permissions.
1669                 if (!-w 'xsdss.cfg'){
1671                         # The configuration file has invalid write permissions
1672                         # set so return an error.
1674                         xestiascan_error("configurationfilewritepermissionsinvalid");
1676                 }
1678         }
1680         # Include the Modules directory.
1681         
1682         use lib "Modules/";
1683         
1684         # Load the authentication module.
1686         my %capabilities;
1687         my $multiuser = 0;
1688         my $encodedpassword = "";
1689         
1690         my $presmodulename = "Auth::" . $http_query_authmodule;
1691         ($presmodulename) = $presmodulename =~ m/^(.*)$/g; # CHECK THIS!!
1692         eval "use " . $presmodulename;
1693         $presmodulename = "Modules::Auth::" . $http_query_authmodule;
1694         
1695         # Work out if database module is 
1696         
1697         %capabilities = $presmodulename->capabilities();
1698         
1699         $multiuser = $capabilities{multiuser};
1700         
1701         if (!$multiuser){
1702         
1703                 $multiuser = 0;
1704                 
1705         }
1706         
1707         # Write the new configuration file.
1709         xestiascan_writeconfig({ ScansURIPath => $http_query_scansuripath, ScansFSPath => $http_query_scansfspath , ImagesURIPath => $http_query_imagesuripath, DateFormat => $finaldateformat, Language => $http_query_language, PresentationModule => $http_query_presmodule, OutputModule => $http_query_outputmodule, AuthModule => $http_query_authmodule, 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 });
1711         my $installscriptmessage        = "";
1712         
1713         # Check if the installation script should be deleted.
1715         if (!$http_query_removeinstallscript){
1717                 $http_query_removeinstallscript = "off";
1719         }
1720         
1721         if (!$http_query_removemultiuserinstallscript){
1722         
1723                 $http_query_removemultiuserinstallscript = "off";
1724                 
1725         }
1727         # Check to see if multiuser is enabled and go to the multiuser script if needed.
1728         
1729         if ($http_query_removeinstallscript eq "on" && $multiuser eq 0){
1731                 if (unlink($installscriptname)){
1733                         $installscriptmessage = $xestiascan_lang{$language_selected}{installscriptremoved};
1735                 } else {
1737                         $installscriptmessage = $xestiascan_lang{$language_selected}{cannotremovescript};
1738                         $installscriptmessage =~ s/%s/$!/g;
1740                 }
1742         }
1743         
1744         if ($http_query_removemultiuserinstallscript eq "on" && $multiuser eq 0){
1745         
1746                 if (unlink($installscriptname)){
1747                         
1748                         $installscriptmessage = $xestiascan_lang{$language_selected}{installscriptremoved};
1749                         
1750                 } else {
1751                         
1752                         $installscriptmessage = $xestiascan_lang{$language_selected}{cannotremovescript};
1753                         $installscriptmessage =~ s/%s/$!/g;
1754                         
1755                 }               
1756                 
1757         }
1758         
1759         if ($multiuser eq 1){
1760         
1761                 $installscriptmessage = $xestiascan_lang{$language_selected}{multiuserinstall};
1762                 
1763         }
1765         print "Content-type: text/html; charset=utf-8;\r\n\r\n";
1767         #print start_html({ -title => $xestiascan_lang{$language_selected}{installertitle}, -style => { -code => $cssstyle }});
1768         print "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
1769         print "<head>\n<title>$xestiascan_lang{$language_selected}{installertitle}</title>\n<style type=\"text/css\" media=\"screen\">$cssstyle</style>\n</head>\n<body>\n";
1770         print "<div class=\"topbar\"><span class=\"title\">Xestia Scanner Server Installer</span></div>";
1771         print "<div class=\"pagespacing\">\n";
1772         print $xestiascan_lang{$language_selected}{installedmessage};
1774         if ($installscriptmessage){
1776                 print "<br /><br />\n";
1777                 print $installscriptmessage;
1779         }
1781         print "<br /><br />\n";
1782         
1783         if ($multiuser eq 0){
1784         
1785                 print $xestiascan_lang{$language_selected}{usexestiascannerservertext};
1786                 print "<br /><br />\n";
1787                 print "<a href=\"" . $xestiascanscriptname . "\">$xestiascan_lang{$language_selected}{usexestiascannerserverlink}</a>";
1788         
1789         } elsif ($multiuser eq 1){
1790                         
1791                 print "<a href=\"" . $multiuserinstallscriptname . "\">$xestiascan_lang{$language_selected}{multiuserinstalllink}</a>";         
1792                 
1793         }
1794         
1795         print "</div>";
1796         print "</body>\n</html>";
1798         exit;
1802 # Create a list of common date and time formats.
1804 my @datetime_formats = ( 
1805         'DD/MM/YY (hh:mm:ss)', 'DD/MM/YY hh:mm:ss', 'D/M/Y (hh:mm:ss)',
1806         'D/M/Y hh:mm:ss', 'D/M/YY (hh:mm:ss)', 'D/M/YY hh:mm:ss',
1807         'DD/MM (hh:mm:ss)', 'D/M (hh:mm:ss)', 'DD/MM hh:mm:ss', 
1808         'D/M hh:mm:ss', 'DD/MM hh:mm', 'D/M hh:mm',
1809         'DD/MM/YY', 'D/M/Y', 'DD/MM',
1811         'YY-MM-DD (hh:mm:ss)', 'YY-MM-DD hh:mm:ss', 'Y-M-D (hh:mm:ss)',
1812         'Y-M-D hh:mm:ss', 'M-D (hh:mm:ss)', 'M-D hh:mm:ss',
1813         'YY-MM-DD', 'MM-DD' 
1814 );
1816 # Create the list of tests to do.
1818 my %test_list;
1819 my %dependency_results;
1820 my %database_results;
1821 my %file_results;
1823 tie(%test_list, "Tie::IxHash");
1824 tie(%dependency_results, "Tie::IxHash");
1825 tie(%database_results, "Tie::IxHash");
1826 tie(%file_results, "Tie::IxHash");
1828 my $test;
1829 my $date;
1831 my $dependency_error = 0;
1832 my $database_onemodule = 0;
1833 my $database_error = 0;
1834 my $file_error = 0;
1836 my $module_version;
1838 my $language_name;
1839 my $language_xml_data;
1840 my $language_file_friendly;
1842 my $presentation_file_friendly;
1844 # Check to see if the needed Perl modules are installed.
1846 $test_list{CheckDBI}{Name}              = "DBI";
1847 $test_list{CheckDBI}{Type}              = "dependency";
1848 $test_list{CheckDBI}{Code}              = "DBI";
1849 $test_list{CheckDBI}{Version}           = "1.605";
1851 $test_list{CheckCGILite}{Name}          = "CGI::Lite";
1852 $test_list{CheckCGILite}{Type}          = "dependency";
1853 $test_list{CheckCGILite}{Code}          = "CGI::Lite";
1854 $test_list{CheckCGILite}{Version}       = "2.02";
1856 $test_list{Encode}{Name}                = "Encode";
1857 $test_list{Encode}{Type}                = "dependency";
1858 $test_list{Encode}{Code}                = "Encode";
1859 $test_list{Encode}{Version}             = "2.23";
1861 $test_list{HashSearch}{Name}            = "Hash::Search";
1862 $test_list{HashSearch}{Type}            = "dependency";
1863 $test_list{HashSearch}{Code}            = "Hash::Search";
1864 $test_list{HashSearch}{Version}         = "0.03";
1866 $test_list{CheckTieHash}{Name}          = "Tie::IxHash";
1867 $test_list{CheckTieHash}{Type}          = "dependency";
1868 $test_list{CheckTieHash}{Code}          = "Tie::IxHash";
1869 $test_list{CheckTieHash}{Version}       = "1.22";
1871 $test_list{CheckMimeBase64}{Name}       = "MIME::Base64";
1872 $test_list{CheckMimeBase64}{Type}       = "dependency";
1873 $test_list{CheckMimeBase64}{Code}       = "MIME::Base64";
1874 $test_list{CheckMimeBase64}{Version}    = "3.13";
1876 $test_list{CheckSane}{Name}             = "Sane";
1877 $test_list{CheckSane}{Type}             = "dependency";
1878 $test_list{CheckSane}{Code}             = "Sane";
1879 $test_list{CheckSane}{Version}          = "0.03";
1881 $test_list{CheckFileCopy}{Name}         = "File::Copy";
1882 $test_list{CheckFileCopy}{Type}         = "dependency";
1883 $test_list{CheckFileCopy}{Code}         = "File::Copy";
1884 $test_list{CheckFileCopy}{Version}      = "2.11";
1886 $test_list{CheckFileBasename}{Name}             = "File::Basename";
1887 $test_list{CheckFileBasename}{Type}             = "dependency";
1888 $test_list{CheckFileBasename}{Code}             = "File::Basename";
1889 $test_list{CheckFileBasename}{Version}          = "2.76";
1891 $test_list{CheckSysHostname}{Name}              = "Sys::Hostname";
1892 $test_list{CheckSysHostname}{Type}              = "dependency";
1893 $test_list{CheckSysHostname}{Code}              = "Sys::Hostname";
1894 $test_list{CheckSysHostname}{Version}           = "1.11";
1896 $test_list{CheckImageMagick}{Name}              = "Image::Magick";
1897 $test_list{CheckImageMagick}{Type}              = "dependency";
1898 $test_list{CheckImageMagick}{Code}              = "Image::Magick";
1899 $test_list{CheckImageMagick}{Version}           = "6.3.7";
1901 $test_list{CheckDigest}{Name}           = "Digest";
1902 $test_list{CheckDigest}{Type}           = "dependency";
1903 $test_list{CheckDigest}{Code}           = "Digest";
1904 $test_list{CheckDigest}{Version}        = "1.15";
1906 $test_list{CheckNetSMTP}{Name}          = "Net::SMTP";
1907 $test_list{CheckNetSMTP}{Type}          = "dependency";
1908 $test_list{CheckNetSMTP}{Code}          = "Net::SMTP";
1909 $test_list{CheckNetSMTP}{Version}       = "2.31";
1911 $test_list{CheckFileMimeInfo}{Name}             = "File::MimeInfo";
1912 $test_list{CheckFileMimeInfo}{Type}             = "dependency";
1913 $test_list{CheckFileMimeInfo}{Code}             = "File::MimeInfo";
1914 $test_list{CheckFileMimeInfo}{Version}          = "0.15";
1917 $test_list{DBDPg}{Name}                 = "DBD::Pg";
1918 $test_list{DBDPg}{Type}                 = "database";
1919 $test_list{DBDPg}{Code}                 = "DBD::Pg";
1920 $test_list{DBDPg}{Version}              = "2.17.1";
1922 # Check the file and directory permissions to see if they are correct.
1924 $test_list{MainDirectory}{Name}         = "Xestia Scanner Server Directory (.)";
1925 $test_list{MainDirectory}{Type}         = "file";
1926 $test_list{MainDirectory}{Code}         = ".";
1927 $test_list{MainDirectory}{Writeable}    = "1";
1929 $test_list{LanguageDirectory}{Name}             = "Language Directory (lang)";
1930 $test_list{LanguageDirectory}{Type}             = "file";
1931 $test_list{LanguageDirectory}{Code}             = "lang";
1932 $test_list{LanguageDirectory}{Writeable}        = "0";
1934 $test_list{ModulesDirectory}{Name}              = "Modules Directory (Modules)";
1935 $test_list{ModulesDirectory}{Type}              = "file";
1936 $test_list{ModulesDirectory}{Code}              = "Modules";
1937 $test_list{ModulesDirectory}{Writeable}         = "0";
1939 $test_list{AuthModulesDirectory}{Name}          = "Authentication Modules Directory (Modules/Auth)";
1940 $test_list{AuthModulesDirectory}{Type}          = "file";
1941 $test_list{AuthModulesDirectory}{Code}          = "Modules/Auth";
1942 $test_list{AuthModulesDirectory}{Writeable}     = "0";
1944 $test_list{ExportModulesDirectory}{Name}        = "Export Modules Directory (Modules/Export)";
1945 $test_list{ExportModulesDirectory}{Type}        = "file";
1946 $test_list{ExportModulesDirectory}{Code}        = "Modules/Export";
1947 $test_list{ExportModulesDirectory}{Writeable}   = "0";
1949 $test_list{OutputModulesDirectory}{Name}        = "Output Modules Directory (Modules/Output)";
1950 $test_list{OutputModulesDirectory}{Type}        = "file";
1951 $test_list{OutputModulesDirectory}{Code}        = "Modules/Output";
1952 $test_list{OutputModulesDirectory}{Writeable}   = "0";
1954 $test_list{PresModulesDirectory}{Name}          = "Presentation Modules Directory (Modules/Presentation)";
1955 $test_list{PresModulesDirectory}{Type}          = "file";
1956 $test_list{PresModulesDirectory}{Code}          = "Modules/Presentation";
1957 $test_list{PresModulesDirectory}{Writeable}     = "0";
1959 $test_list{SystemModulesDirectory}{Name}        = "System Modules Directory (Modules/System)";
1960 $test_list{SystemModulesDirectory}{Type}        = "file";
1961 $test_list{SystemModulesDirectory}{Code}        = "Modules/System";
1962 $test_list{SystemModulesDirectory}{Writeable}   = "0";
1964 # Preform those tests.
1966 foreach $test (keys %test_list){
1968         # Check the type of test.
1970         $ENV{PATH}='/bin:/usr/bin';
1971         
1972         if ($test_list{$test}{Type} eq "dependency"){
1973                 
1974                 if (eval "require " . $test_list{$test}{Code}){
1975                         
1976                         # The module exists and is working correctly.
1978                         $dependency_results{$test_list{$test}{Name}}{result}    = $xestiascan_lang{$language_selected}{testpass};
1979                         
1980                         # Get the current version of the module (if possible);
1981                         
1982                         # Launch another copy of Perl, this probably is the only memory efficent way.
1983                         
1984                         my $command = "perl -M$test_list{$test}{Code} -e \'print \"\$$test_list{$test}{Code}::VERSION\"\'";
1985                         my $result = `$command`;
1986                         
1987                         $dependency_results{$test_list{$test}{Name}}{version}   = $result;
1988                         $dependency_results{$test_list{$test}{Name}}{testname}  = $test;
1989                         
1990                 } else {
1992                         # The module does not exist or has an error.
1994                         $dependency_error = 1;
1995                         $dependency_results{$test_list{$test}{Name}}{result}    = $xestiascan_lang{$language_selected}{testfail} . " ($!)";
1996                         $dependency_results{$test_list{$test}{Name}}{version}   = "N/A";
1997                         $dependency_results{$test_list{$test}{Name}}{testname}  = $test;
1999                 }
2000                 
2001         } elsif ($test_list{$test}{Type} eq "database"){
2003                 if (eval "require " . $test_list{$test}{Code}){
2005                         # The module exists and it is working correctly.
2007                         $database_results{$test_list{$test}{Name}}{result}      = $xestiascan_lang{$language_selected}{testpass};
2008                         $database_onemodule = 1;
2009                         
2010                         # Launch another copy of Perl, this probably is the only memory efficent way.
2011                         
2012                         my $command = "perl -M$test_list{$test}{Code} -e \'print \"\$$test_list{$test}{Code}::VERSION\"\'";
2013                         my $result = `$command`;
2014                         
2015                         $database_results{$test_list{$test}{Name}}{version}     = $result;
2016                         $database_results{$test_list{$test}{Name}}{testname}    = $test;
2018                 } else {
2020                         # The module does not exist or has an error.
2022                         $database_error = 1;
2023                         $database_results{$test_list{$test}{Name}}{result}      = $xestiascan_lang{$language_selected}{testfail};
2024                         $database_results{$test_list{$test}{Name}}{version}     = "N/A";
2025                         $database_results{$test_list{$test}{Name}}{testname}    = $test;
2027                 }
2029         } elsif ($test_list{$test}{Type} eq "file"){
2031                 if (-e $test_list{$test}{Code}){
2033                         # The filename given does exist.
2035                 } else {
2037                         # the filename given does not exist.
2039                         $file_error = 1;
2040                         $file_results{$test_list{$test}{Name}}{result}  = $xestiascan_lang{$language_selected}{errormessage} . $xestiascan_lang{$language_selected}{doesnotexist};
2042                 }       
2044                 # Test to see if the filename given has read
2045                 # permissions.
2047                 if (-r $test_list{$test}{Code}){
2049                         # The filename given has valid permissions set.
2051                         $file_results{$test_list{$test}{Name}}{result}  = $xestiascan_lang{$language_selected}{testpass};
2053                 } else {
2055                         # The filename given has invalid permissions set.
2057                         $file_error = 1;
2058                         $file_results{$test_list{$test}{Name}}{result} = $xestiascan_lang{$language_selected}{errormessage} . $xestiascan_lang{$language_selected}{invalidpermissionsset};
2060                 }
2062                 if ($test_list{$test}{Writeable} eq 1){
2064                         # Test to see if the filename given has write
2065                         # permissions.
2067                         if (-w $test_list{$test}{Code}){
2069                                 # The filename given has valid permissions set.
2071                                 $file_results{$test_list{$test}{Name}}{result}  = $xestiascan_lang{$language_selected}{testpass};
2073                         } else {
2075                                 # The filename given has invalid permissions set.
2077                                 $file_error = 1;
2078                                 $file_results{$test_list{$test}{Name}}{result}  = $xestiascan_lang{$language_selected}{errormessage} . $xestiascan_lang{$language_selected}{invalidpermissionsset};
2080                         }
2082                 }
2084         }
2088 # Print the header.
2090 print "Content-Type: text/html; charset=utf-8;\r\n\r\n";
2092 # Print the page for installing Kiriwrite.
2094 print "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
2095 print "<head>\n<title>$xestiascan_lang{$language_selected}{installertitle}</title>\n";
2096 print "<style type=\"text/css\" media=\"screen\">$cssstyle</style>\n</head>\n<body>";
2098 print "<div class=\"topbar\">
2099 <span class=\"title\">" . $xestiascan_lang{$language_selected}{installertitle} .  "</span>";
2100 my $language_name_short;
2101 my $language_list_seek = 0;
2102 my $installlanguage_out = "";
2104 $installlanguage_out = "<select name=\"installlanguage\">\n";
2106 foreach $language_name_short (@language_list_short){
2108         $installlanguage_out = $installlanguage_out . "<option value=\"" . $language_name_short . "\">" . $language_list_long[$language_list_seek] . "</option>\n";
2109         $language_list_seek++;
2113 $installlanguage_out = $installlanguage_out . "</select>\n";
2115 print "<form action=\"" . $installscriptname . "\" method=\"POST\">\n$installlanguage_out\n<input type=\"submit\" value=\"$xestiascan_lang{$language_selected}{switch}\">\n</form>\n";
2116 print "</div>";
2118 print "<div class=\"pagespacing\">\n";
2120 print "<span class=\"pageheader\">$xestiascan_lang{$language_selected}{installertitle}</span><br /><br />\n";
2121 print $xestiascan_lang{$language_selected}{installertext} . "<br /><br />\n";
2123 #if ($modperlenabled eq 1){
2124 #       print "<br /><br />";
2125 #       print $xestiascan_lang{$language_selected}{modperlnotice};
2126 #}
2128 print "<span class=\"subheader\">$xestiascan_lang{$language_selected}{dependencytitle}</span><br /><br />\n";
2129 print "<b>$xestiascan_lang{$language_selected}{requiredmodules}</b><br /><br />\n";
2130 print $xestiascan_lang{$language_selected}{perlmodules};
2131 print "<br /><br />\n";
2133 if ($dependency_error eq 1){
2135         print $xestiascan_lang{$language_selected}{errormessage};
2136         print $xestiascan_lang{$language_selected}{dependencyperlmodulesmissing};
2137         print "<br /><br />\n";
2141 print "<table>\n";
2143 xestiascan_addtablerow($xestiascan_lang{$language_selected}{module}, "tablecellheader", $xestiascan_lang{$language_selected}{result}, "tablecellheader", $xestiascan_lang{$language_selected}{requiredver}, "tablecellheader", $xestiascan_lang{$language_selected}{installedver}, "tablecellheader");
2145 foreach $test (keys %dependency_results) {
2146         
2147         xestiascan_addtablerow($test, "tablename", $dependency_results{$test}{result}, "tabledata", $test_list{$dependency_results{$test}{testname}}{Version}, "tabledata", $dependency_results{$test}{version}, "tabledata");
2151 print "</table>";
2153 print "<br /><b>$xestiascan_lang{$language_selected}{databasemodules}</b><br /><br />\n";
2154 print $xestiascan_lang{$language_selected}{databasemodulestext};
2155 print "<br /><br />\n";
2157 print "<table>\n";
2159 if ($database_error eq 1){
2161         print $xestiascan_lang{$language_selected}{warningmessage};
2162         print $xestiascan_lang{$language_selected}{databaseperlmodulesmissing};
2163         print "<br /><br />\n";
2167 xestiascan_addtablerow($xestiascan_lang{$language_selected}{module}, "tablecellheader", $xestiascan_lang{$language_selected}{result}, "tablecellheader", $xestiascan_lang{$language_selected}{requiredver}, "tablecellheader", $xestiascan_lang{$language_selected}{installedver}, "tablecellheader");
2169 foreach $test (keys %database_results) {
2171         xestiascan_addtablerow($test, "tablename", $database_results{$test}{result}, "tabledata", $test_list{$database_results{$test}{testname}}{Version}, "tabledata", $database_results{$test}{version}, "tabledata");
2175 print "</table><br />";
2177 print "<b>$xestiascan_lang{$language_selected}{filepermissions}</b><br /><br />\n";
2179 print $xestiascan_lang{$language_selected}{filepermissionstext};
2180 print "<br /><br />\n";
2182 if ($file_error eq 1){
2184         print $xestiascan_lang{$language_selected}{errormessage};
2185         print $xestiascan_lang{$language_selected}{filepermissionsinvalid};
2186         print "<br /><br />\n";
2190 print "<table>";
2192 xestiascan_addtablerow($xestiascan_lang{$language_selected}{filename}, "tablecellheader", "Result", "tablecellheader");
2194 foreach $test (keys %file_results) {
2196         xestiascan_addtablerow($test, "tablename", $file_results{$test}{result}, "tabledata");
2200 print "</table>";
2202 if ($dependency_error eq 1){
2204         print "<hr />\n";
2205         print "<b>$xestiascan_lang{$language_selected}{criticalerror}</b><br /><br />\n";
2206         print $xestiascan_lang{$language_selected}{dependencymodulesnotinstalled} . "\n";
2207         print "</body>\n</html>";
2208         exit;
2212 if ($database_onemodule eq 0){
2214         print "<hr />\n";
2215         print "<b>$xestiascan_lang{$language_selected}{criticalerror}</b><br /><br />\n";
2216         print $xestiascan_lang{$language_selected}{databasemodulesnotinstalled} . "\n";
2217         print "</body>\n</html>";
2218         exit;
2222 if ($file_error eq 1){
2224         print "<hr />\n";
2225         print "<b>$xestiascan_lang{$language_selected}{criticalerror}</b><br /><br />\n";
2226         print $xestiascan_lang{$language_selected}{filepermissionerrors} . "\n";
2227         print "</body>\n</html>";
2228         exit;
2232 my @language_short;
2233 my (%available_languages, $available_languages);
2234 my @presentation_modules;
2235 my @output_modules;
2236 my @auth_modules;
2237 my $select_data = "";
2238 my (%language_data, $language_data);
2239 my @lang_data;
2240 my $xestiascan_languagefilehandle;
2241 my $language_out = "";
2242 my ($presmodule_name, $presmodule_out) = "";
2243 my ($authmodule_name, $authmodule_out) = "";
2244 my ($outputmodule_name, $outputmodule_out) = "";
2246 # Get the list of available languages.
2248 tie(%available_languages, 'Tie::IxHash');
2250 opendir(LANGUAGEDIR, "lang");
2251 my @language_directory = grep /m*\.lang$/, readdir(LANGUAGEDIR);
2252 closedir(LANGUAGEDIR);
2254 foreach my $language_file (@language_directory){
2256         # Load the language file.
2258         next if $language_file =~ m/^\./;
2259         next if $language_file !~ m/.lang$/;
2260         
2261         open ($xestiascan_languagefilehandle, "lang/" . $language_file);
2262         @lang_data = <$xestiascan_languagefilehandle>;
2263         %language_data = xestiascan_processconfig(@lang_data);
2264         close ($xestiascan_languagefilehandle);
2266         # Get the friendly name for the language file.
2268         $language_file_friendly = $language_file;
2269         $language_file_friendly =~ s/.lang$//g;
2271         $language_name = $language_data{about}{name};
2273         $available_languages{$language_file_friendly} = $language_name . " (" . $language_file_friendly . ")";
2277 # Get the list of presentation modules.
2279 opendir(OUTPUTSYSTEMDIR, "Modules/Presentation");
2280 my @presmodule_directory = grep /m*\.pm$/, readdir(OUTPUTSYSTEMDIR);
2281 closedir(OUTPUTSYSTEMDIR);
2283 foreach my $presmodule_file (@presmodule_directory){
2285         # Get the friendly name for the database module.
2287         next if $presmodule_file =~ m/^\./;
2288         next if $presmodule_file !~ m/.pm$/;
2289         $presmodule_file =~ s/.pm$//g;
2290         push(@presentation_modules, $presmodule_file);
2294 # Get the list of output modules.
2296 opendir(OUTPUTDIR, "Modules/Output");
2297 my @outputmodule_directory = grep /m*\.pm$/, readdir(OUTPUTDIR);
2298 closedir(OUTPUTDIR);
2300 foreach my $outputmodule_file (@outputmodule_directory){
2302         # Get the friendly name for the database module.
2304         next if $outputmodule_file =~ m/^\./;
2305         next if $outputmodule_file !~ m/.pm$/;
2306         $outputmodule_file =~ s/.pm$//g;
2307         push(@output_modules, $outputmodule_file);
2311 # Get the list of database modules.
2313 opendir(DATABASEDIR, "Modules/Auth");
2314 my @authmodule_directory = grep /m*\.pm$/, readdir(DATABASEDIR);
2315 closedir(DATABASEDIR);
2317 foreach my $authmodule_file (@authmodule_directory){
2319         # Get the friendly name for the database module.
2321         next if $authmodule_file =~ m/^\./;
2322         next if $authmodule_file !~ m/.pm$/;
2323         $authmodule_file =~ s/.pm$//g;
2324         push(@auth_modules, $authmodule_file);
2328 print "<h3>$xestiascan_lang{$language_selected}{settingstitle}</h3>";
2329 print $xestiascan_lang{$language_selected}{settingstext};
2330 print "<br /><br />\n";
2332 print "<form action=\"" . $installscriptname . "\" method=\"POST\">";
2333 print "<input type=\"hidden\" name=\"confirm\" value=\"1\">\n<input type=\"hidden\" name=\"installlanguage\" value=\"$language_selected\">\n";
2335 print "<table width=\"100%\">";
2336 xestiascan_addtablerow($xestiascan_lang{$language_selected}{setting}, "tablecellheader", $xestiascan_lang{$language_selected}{value}, "tablecellheader");
2337 xestiascan_addtablerow($xestiascan_lang{$language_selected}{directories}, "tablecellheader", "", "tablecellheader");
2338 xestiascan_addtablerow($xestiascan_lang{$language_selected}{imagesuripath}, "tablename", "<input type=\"text\" name=\"imagesuripath\" size=\"32\" maxlength=\"512\" value=\"$default_imagesuri\">", "tabledata");
2339 xestiascan_addtablerow($xestiascan_lang{$language_selected}{scansuripath}, "tablename", "<input type=\"text\" name=\"scansuripath\" size=\"32\" maxlength=\"512\" value=\"$default_scansuri\">", "tabledata");
2340 xestiascan_addtablerow($xestiascan_lang{$language_selected}{scansfspath}, "tablename", "<input type=\"text\" name=\"scansfspath\" size=\"64\" maxlength=\"4096\" value=\"$default_scansfs\">", "tabledata");
2341 xestiascan_addtablerow($xestiascan_lang{$language_selected}{date}, "tablecellheader", "", "tablecellheader");
2343 foreach my $select_name (@datetime_formats){
2344         $select_data = $select_data . "<option value=\"$select_name\">" . $select_name . "</option>\n";
2347 xestiascan_addtablerow($xestiascan_lang{$language_selected}{dateformat}, "tablename", "<select name=\"dateformat\">$select_data</select>\n<input type=\"text\" size=\"32\" maxlength=\"64\" name=\"customdateformat\">", "tabledata");
2348 xestiascan_addtablerow($xestiascan_lang{$language_selected}{language}, "tablecellheader", "", "tablecellheader");
2350 foreach my $language (keys %available_languages){
2351         if ($language eq $language_selected){
2352                 $language_out = $language_out . "<option value=\"" . $language . "\" selected=selected>" . $available_languages{$language} . "</option>\n";
2353         } else {
2354                 $language_out = $language_out . "<option value=\"" . $language . "\">" . $available_languages{$language} . "</option>\n";
2355         }
2358 xestiascan_addtablerow($xestiascan_lang{$language_selected}{systemlanguage}, "tablename", "<select name=\"language\">\r\n$language_out\r\n</select>", "tabledata");
2360 xestiascan_addtablerow($xestiascan_lang{$language_selected}{modules}, "tablecellheader", "", "tablecellheader");
2362 foreach $presmodule_name (@presentation_modules){
2363         $presmodule_out = $presmodule_out . "<option value=\"$presmodule_name\">$presmodule_name</option>";
2365 xestiascan_addtablerow($xestiascan_lang{$language_selected}{presentationmodule}, "tablename", "<select name=\"presmodule\">$presmodule_out</select>", "tabledata");
2367 foreach $outputmodule_name (@output_modules){
2368         if ($default_outputmodule = $outputmodule_name){
2369                 $outputmodule_out = $outputmodule_out . "<option value=\"$outputmodule_name\" selected>$outputmodule_name</option>";            
2370         } else {
2371                 $outputmodule_out = $outputmodule_out . "<option value=\"$outputmodule_name\">$outputmodule_name</option>";
2372         }
2374 xestiascan_addtablerow($xestiascan_lang{$language_selected}{outputmodule}, "tablename", "<select name=\"outputmodule\">$outputmodule_out</select>", "tabledata");
2376 foreach $authmodule_name (@auth_modules){
2377         $authmodule_out = $authmodule_out . "<option value=\"$authmodule_name\">$authmodule_name</option>";
2379 xestiascan_addtablerow($xestiascan_lang{$language_selected}{authmodule}, "tablename", "<select name=\"authmodule\">$authmodule_out</select>", "tabledata");
2381 xestiascan_addtablerow($xestiascan_lang{$language_selected}{databaseserver}, "tablename", "<input type=\"text\" name=\"databaseserver\" size=\"32\" maxlength=\"128\" value=\"$default_server\">\n", "tabledata");
2382 xestiascan_addtablerow($xestiascan_lang{$language_selected}{databaseport}, "tablename", "<input type=\"text\" name=\"databaseport\" maxlength=\"5\" size=\"5\" value=\"$default_port\">\n", "tabledata");
2383 xestiascan_addtablerow($xestiascan_lang{$language_selected}{databaseprotocol}, "tablename", "<select name=\"databaseprotocol\">\n<option value=\"tcp\">tcp</option>\n<option value=\"udp\">udp</option>\n</select>\n", "tabledata");
2384 xestiascan_addtablerow($xestiascan_lang{$language_selected}{databasename}, "tablename", "<input type=\"text\" name=\"databasename\" size=\"32\" maxlength=\"32\" value=\"$default_name\">\n", "tabledata");
2385 xestiascan_addtablerow($xestiascan_lang{$language_selected}{databaseusername}, "tablename", "<input type=\"text\" name=\"databaseusername\" size=\"16\" maxlength=\"16\" value=\"$default_username\">\n", "tabledata");
2386 xestiascan_addtablerow($xestiascan_lang{$language_selected}{databasepassword}, "tablename", "<input type=\"password\" name=\"databasepassword\" size=\"32\" maxlength=\"64\">\n", "tabledata");
2387 xestiascan_addtablerow($xestiascan_lang{$language_selected}{databasetableprefix}, "tablename", "<input type=\"text\" name=\"databasetableprefix\" size=\"32\" maxlength=\"32\" value=\"$default_prefix\">\n", "tabledata");
2388 xestiascan_addtablerow($xestiascan_lang{$language_selected}{installationoptions}, "tablecellheader", "", "tablecellheader");
2389 xestiascan_addtablerow($xestiascan_lang{$language_selected}{installoptions}, "tablename", "<input type=\"checkbox\" name=\"removeinstallscript\" checked=checked value=\"on\"> $xestiascan_lang{$language_selected}{removeinstallscript}\n<br />\n<input type=\"checkbox\" name=\"removemultiuserinstallscript\" checked=checked value=\"on\"> $xestiascan_lang{$language_selected}{removemultiuserinstallscript}\n", "tabledata");
2391 print "</table>\n";
2393 print "<br />\n<input type=\"submit\" value=\"$xestiascan_lang{$language_selected}{savesettingsbutton}\"> | <input type=\"reset\" value=\"$xestiascan_lang{$language_selected}{resetsettingsbutton}\">\n";
2395 print "</form>\n</div>\n</body>\n</html>";
2396 exit;
2398 __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