Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Commit of recent work in preperation for Kiriwrite 0.5.0
[kiriwrite/.git] / cgi-files / Modules / System / Settings.pm
1 package Modules::System::Settings;
3 use Modules::System::Common;
4 use strict;
5 use warnings;
6 use Exporter;
8 our @ISA = qw(Exporter);
9 our @EXPORT = qw(kiriwrite_settings_view kiriwrite_settings_edit kiriwrite_output_config); 
11 sub kiriwrite_settings_view{
12 #################################################################################
13 # kiriwrite_options_view: Writes out the list of options and variables.         #
14 #                                                                               #
15 # Usage:                                                                        #
16 #                                                                               #
17 # kiriwrite_settings_view();                                                    #
18 #################################################################################
20         # Get the settings.
22         my $settings_directory_db               = $main::kiriwrite_config{"directory_data_db"};
23         my $settings_directory_output           = $main::kiriwrite_config{"directory_data_output"};
24         my $settings_noncgi_images              = $main::kiriwrite_config{"directory_noncgi_images"};
25         my $settings_display_textareacols       = $main::kiriwrite_config{"display_textareacols"};
26         my $settings_display_textarearows       = $main::kiriwrite_config{"display_textarearows"};
27         my $settings_display_pagecount          = $main::kiriwrite_config{"display_pagecount"};
28         my $settings_display_templatecount      = $main::kiriwrite_config{"display_templatecount"};
29         my $settings_display_filtercount        = $main::kiriwrite_config{"display_filtercount"};
30         my $settings_system_datetime            = $main::kiriwrite_config{"system_datetime"};
31         my $settings_system_language            = $main::kiriwrite_config{"system_language"};
32         my $settings_system_presentation        = $main::kiriwrite_config{"system_presmodule"};
33         my $settings_system_database            = $main::kiriwrite_config{"system_dbmodule"};
34         my $settings_system_output              = $main::kiriwrite_config{"system_outputmodule"};
37         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{viewsettings}, { Style => "pageheader" });
38         $main::kiriwrite_presmodule->addlinebreak();
39         $main::kiriwrite_presmodule->addlinebreak();
40         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{currentsettings});
41         $main::kiriwrite_presmodule->addlinebreak();
42         $main::kiriwrite_presmodule->addlinebreak();
43         $main::kiriwrite_presmodule->starttable("", { CellPadding => 5, CellSpacing => 0 });
45         $main::kiriwrite_presmodule->startheader();
46         $main::kiriwrite_presmodule->addheader($main::kiriwrite_lang{common}{setting}, { Style => "tablecellheader" });
47         $main::kiriwrite_presmodule->addheader($main::kiriwrite_lang{common}{value}, { Style => "tablecellheader" });
48         $main::kiriwrite_presmodule->endheader();
50         $main::kiriwrite_presmodule->startrow();
51         $main::kiriwrite_presmodule->addcell("tablecellheader");
52         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{directories});
53         $main::kiriwrite_presmodule->endcell();
54         $main::kiriwrite_presmodule->addcell("tablecellheader");
55         $main::kiriwrite_presmodule->endcell();
56         $main::kiriwrite_presmodule->endrow();
58         $main::kiriwrite_presmodule->startrow();
59         $main::kiriwrite_presmodule->addcell("tablecell1");
60         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{databasedirectory});
61         $main::kiriwrite_presmodule->endcell();
62         $main::kiriwrite_presmodule->addcell("tablecell2");
63         $main::kiriwrite_presmodule->addtext($settings_directory_db);
64         $main::kiriwrite_presmodule->endcell();
65         $main::kiriwrite_presmodule->endrow();
67         $main::kiriwrite_presmodule->startrow();
68         $main::kiriwrite_presmodule->addcell("tablecell1");
69         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{outputdirectory});
70         $main::kiriwrite_presmodule->endcell();
71         $main::kiriwrite_presmodule->addcell("tablecell2");
72         $main::kiriwrite_presmodule->addtext($settings_directory_output);
73         $main::kiriwrite_presmodule->endcell();
74         $main::kiriwrite_presmodule->endrow();
76         $main::kiriwrite_presmodule->startrow();
77         $main::kiriwrite_presmodule->addcell("tablecell1");
78         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{imagesuripath});
79         $main::kiriwrite_presmodule->endcell();
80         $main::kiriwrite_presmodule->addcell("tablecell2");
81         $main::kiriwrite_presmodule->addtext($settings_noncgi_images);
82         $main::kiriwrite_presmodule->endcell();
83         $main::main::kiriwrite_presmodule->endrow();
85         $main::kiriwrite_presmodule->startrow();
86         $main::kiriwrite_presmodule->addcell("tablecellheader");
87         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{display});
88         $main::kiriwrite_presmodule->endcell();
89         $main::kiriwrite_presmodule->addcell("tablecellheader");
90         $main::kiriwrite_presmodule->endcell();
91         $main::kiriwrite_presmodule->endrow();
93         $main::kiriwrite_presmodule->startrow();
94         $main::kiriwrite_presmodule->addcell("tablecell1");
95         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{textareacols});
96         $main::kiriwrite_presmodule->endcell();
97         $main::kiriwrite_presmodule->addcell("tablecell2");
98         $main::kiriwrite_presmodule->addtext($settings_display_textareacols);
99         $main::kiriwrite_presmodule->endcell();
100         $main::kiriwrite_presmodule->endrow();
102         $main::kiriwrite_presmodule->startrow();
103         $main::kiriwrite_presmodule->addcell("tablecell1");
104         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{textarearows});
105         $main::kiriwrite_presmodule->endcell();
106         $main::kiriwrite_presmodule->addcell("tablecell2");
107         $main::kiriwrite_presmodule->addtext($settings_display_textarearows);
108         $main::kiriwrite_presmodule->endcell();
109         $main::kiriwrite_presmodule->endrow();
111         $main::kiriwrite_presmodule->startrow();
112         $main::kiriwrite_presmodule->addcell("tablecell1");
113         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{pagecount});
114         $main::kiriwrite_presmodule->endcell();
115         $main::kiriwrite_presmodule->addcell("tablecell2");
116         $main::kiriwrite_presmodule->addtext($settings_display_pagecount);
117         $main::kiriwrite_presmodule->endcell();
118         $main::kiriwrite_presmodule->endrow();
120         $main::kiriwrite_presmodule->startrow();
121         $main::kiriwrite_presmodule->addcell("tablecell1");
122         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{templatecount});
123         $main::kiriwrite_presmodule->endcell();
124         $main::kiriwrite_presmodule->addcell("tablecell2");
125         $main::kiriwrite_presmodule->addtext($settings_display_templatecount);
126         $main::kiriwrite_presmodule->endcell();
127         $main::kiriwrite_presmodule->endrow();
129         $main::kiriwrite_presmodule->startrow();
130         $main::kiriwrite_presmodule->addcell("tablecell1");
131         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{filtercount});
132         $main::kiriwrite_presmodule->endcell();
133         $main::kiriwrite_presmodule->addcell("tablecell2");
134         $main::kiriwrite_presmodule->addtext($settings_display_filtercount);
135         $main::kiriwrite_presmodule->endcell();
136         $main::kiriwrite_presmodule->endrow();
138         $main::kiriwrite_presmodule->startrow();
139         $main::kiriwrite_presmodule->addcell("tablecellheader");
140         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{date});
141         $main::kiriwrite_presmodule->endcell();
142         $main::kiriwrite_presmodule->addcell("tablecellheader");
143         $main::kiriwrite_presmodule->endcell();
144         $main::kiriwrite_presmodule->endrow();
146         $main::kiriwrite_presmodule->startrow();
147         $main::kiriwrite_presmodule->addcell("tablecell1");
148         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{dateformat});
149         $main::kiriwrite_presmodule->endcell();
150         $main::kiriwrite_presmodule->addcell("tablecell2");
151         $main::kiriwrite_presmodule->addtext($settings_system_datetime);
152         $main::kiriwrite_presmodule->endcell();
153         $main::kiriwrite_presmodule->endrow();
155         $main::kiriwrite_presmodule->startrow();
156         $main::kiriwrite_presmodule->addcell("tablecellheader");
157         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{language});
158         $main::kiriwrite_presmodule->endcell();
159         $main::kiriwrite_presmodule->addcell("tablecellheader");
160         $main::kiriwrite_presmodule->endcell();
161         $main::kiriwrite_presmodule->endrow();
163         $main::kiriwrite_presmodule->startrow();
164         $main::kiriwrite_presmodule->addcell("tablecell1");
165         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{systemlanguage});
166         $main::kiriwrite_presmodule->endcell();
167         $main::kiriwrite_presmodule->addcell("tablecell2");
168         $main::kiriwrite_presmodule->addtext($settings_system_language);
169         $main::kiriwrite_presmodule->endcell();
170         $main::kiriwrite_presmodule->endrow();
172         $main::kiriwrite_presmodule->startrow();
173         $main::kiriwrite_presmodule->addcell("tablecellheader");
174         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{modules});
175         $main::kiriwrite_presmodule->endcell();
176         $main::kiriwrite_presmodule->addcell("tablecellheader");
177         $main::kiriwrite_presmodule->endcell();
178         $main::kiriwrite_presmodule->endrow();
180         $main::kiriwrite_presmodule->startrow();
181         $main::kiriwrite_presmodule->addcell("tablecell1");
182         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{presentationmodule});
183         $main::kiriwrite_presmodule->endcell();
184         $main::kiriwrite_presmodule->addcell("tablecell2");
185         $main::kiriwrite_presmodule->addtext($settings_system_presentation);
186         $main::kiriwrite_presmodule->endcell();
187         $main::kiriwrite_presmodule->endrow();
189         $main::kiriwrite_presmodule->startrow();
190         $main::kiriwrite_presmodule->addcell("tablecell1");
191         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{outputmodule});
192         $main::kiriwrite_presmodule->endcell();
193         $main::kiriwrite_presmodule->addcell("tablecell2");
194         $main::kiriwrite_presmodule->addtext($settings_system_output);
195         $main::kiriwrite_presmodule->endcell();
196         $main::kiriwrite_presmodule->endrow();
198         $main::kiriwrite_presmodule->startrow();
199         $main::kiriwrite_presmodule->addcell("tablecell1");
200         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{databasemodule});
201         $main::kiriwrite_presmodule->endcell();
202         $main::kiriwrite_presmodule->addcell("tablecell2");
203         $main::kiriwrite_presmodule->addtext($settings_system_database);
204         $main::kiriwrite_presmodule->endcell();
205         $main::kiriwrite_presmodule->endrow();
207         $main::kiriwrite_presmodule->endtable();
209         $main::kiriwrite_presmodule->addlinebreak();
210         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{altersettings});
212         return $main::kiriwrite_presmodule->grab();
216 sub kiriwrite_settings_edit{
217 #################################################################################
218 # kiriwrite_settings_edit: Edits the options.                                   #
219 #                                                                               #
220 # Usage:                                                                        #
221 #                                                                               #
222 # kiriwrite_settings_edit(options);                                             #
223 #                                                                               #
224 # options               Specifies the following options in any order.           #
225 #                                                                               #
226 # DatabaseDirectory     Specifies the new database directory to use.            #
227 # OutputDirectory       Specifies the new output directory to use.              #
228 # ImagesURIPath         Specifies the new URI path for images.                  #
229 # DateTimeFormat        Specifies the new date and time format.                 #
230 # SystemLanguage        Specifies the new language to use for Kiriwrite.        #
231 # PrsentationModule     Specifies the new presentation module to use for        #
232 #                       Kiriwrite.                                              #
233 # DatabaseModule        Specifies the new database module to use for Kiriwrite. #
234 # OutputModule          Specifies the new output module to use for Kiriwrite.   #
235 # TextAreaCols          Specifies the width of the text area.                   #
236 # TextAreaRows          Specifies the height of the text area.                  #
237 # PageCount             Specifies the amount of pages that should be viewed.    #
238 # FilterCount           Specifies the amount of filters that should be viewed.  #
239 # TemplateCount         Specifies the amount of templates that should be viewed.#
240 #                                                                               #
241 # Options for server-based database modules.                                    #
242 #                                                                               #
243 # DatabaseServer        Specifies the database server to use.                   #
244 # DaravasePort          Specifies the port the database server is running on.   #
245 # DatabaseProtocol      Specifies the protocol the database server is using.    #
246 # DatabaseSQLDatabase   Specifies the SQL database name to use.                 #
247 # DatabaseUsername      Specifies the database server username.                 #
248 # DatabasePasswordKeep  Keeps the current password in the configuration file.   #
249 # DatabasePassword      Specifies the password for the database server username.#
250 # DatabaseTablePrefix   Specifies the prefix used for tables.                   #
251 #################################################################################
253         # Get the values that have been passed to the subroutine.
255         my ($passedoptions) = @_;
257         # Get the values from the hash.
259         my $settings_dbdirectory                = $passedoptions->{"DatabaseDirectory"};
260         my $settings_outputdirectory            = $passedoptions->{"OutputDirectory"};
261         my $settings_imagesuri                  = $passedoptions->{"ImagesURIPath"};
262         my $settings_datetimeformat             = $passedoptions->{"DateTimeFormat"};
263         my $settings_languagesystem             = $passedoptions->{"SystemLanguage"};
264         my $settings_presmodule                 = $passedoptions->{"PresentationModule"};
265         my $settings_outputmodule               = $passedoptions->{"OutputModule"};
266         my $settings_dbmodule                   = $passedoptions->{"DatabaseModule"};
267         my $settings_textareacols               = $passedoptions->{"TextAreaCols"};
268         my $settings_textarearows               = $passedoptions->{"TextAreaRows"};
269         my $settings_pagecount                  = $passedoptions->{"PageCount"};
270         my $settings_filtercount                = $passedoptions->{"FilterCount"};
271         my $settings_templatecount              = $passedoptions->{"TemplateCount"};
273         my $settings_database_server            = $passedoptions->{"DatabaseServer"};
274         my $settings_database_port              = $passedoptions->{"DatabasePort"};
275         my $settings_database_protocol          = $passedoptions->{"DatabaseProtocol"};
276         my $settings_database_sqldatabase       = $passedoptions->{"DatabaseSQLDatabase"};
277         my $settings_database_username          = $passedoptions->{"DatabaseUsername"};
278         my $settings_database_passwordkeep      = $passedoptions->{"DatabasePasswordKeep"};
279         my $settings_database_password          = $passedoptions->{"DatabasePassword"};
280         my $settings_database_tableprefix       = $passedoptions->{"DatabaseTablePrefix"};
282         my $confirm                             = $passedoptions->{"Confirm"};
284         if (!$confirm){
286                 # If the confirm value is blank, then set the confirm
287                 # value to 0.
289                 $confirm = 0;
291         }
293         if ($confirm eq "1"){
295                 # The action to edit the settings has been confirmed.
296                 # Start by checking each variable about to be placed
297                 # in the settings file is valid.
299                 # Deinfe some variables for later.
301                 my @kiriwrite_new_settings;
303                 # Check the length of the directory names.
305                 kiriwrite_variablecheck($settings_dbdirectory, "maxlength", 64, 0);
306                 kiriwrite_variablecheck($settings_outputdirectory, "maxlength", 64, 0);
307                 kiriwrite_variablecheck($settings_imagesuri, "maxlength", 512, 0);
308                 kiriwrite_variablecheck($settings_datetimeformat, "maxlength", 32, 0);
310                 kiriwrite_variablecheck($settings_languagesystem, "language_filename", "", 0);
312                 # Check the module names to see if they're valid.
314                 my $kiriwrite_presmodule_modulename_check       = kiriwrite_variablecheck($settings_presmodule, "module", 0, 1);
315                 my $kiriwrite_dbmodule_modulename_check         = kiriwrite_variablecheck($settings_dbmodule, "module", 0, 1);
316                 my $kiriwrite_outputmodule_modulename_check     = kiriwrite_variablecheck($settings_outputmodule, "module", 0, 1);
318                 if ($kiriwrite_presmodule_modulename_check eq 1){
320                         # The presentation module name is blank, so return
321                         # an error.
323                         kiriwrite_error("presmoduleblank");
325                 }
327                 if ($kiriwrite_presmodule_modulename_check eq 2){
329                         # The presentation module name is invalid, so return
330                         # an error.
332                         kiriwrite_error("presmoduleinvalid");
334                 }
336                 if ($kiriwrite_dbmodule_modulename_check eq 1){
338                         # The database module name is blank, so return
339                         # an error.
341                         kiriwrite_error("dbmoduleblank");
343                 }
345                 if ($kiriwrite_dbmodule_modulename_check eq 2){
347                         # The database module name is invalid, so return
348                         # an error.
350                         kiriwrite_error("dbmoduleinvalid");
352                 }
354                 if ($kiriwrite_outputmodule_modulename_check eq 1){
356                         # The output module name is blank, so return
357                         # an error.
359                         kiriwrite_error("outputmoduleblank");
361                 }
363                 if ($kiriwrite_outputmodule_modulename_check eq 2){
365                         # The output module name is invalid, so return
366                         # an error.
368                         kiriwrite_error("outputmoduleinvalid");
370                 }
372                 # Check if the directory names only contain letters and numbers and
373                 # return a specific error if they don't.
375                 my $kiriwrite_dbdirectory_check         = kiriwrite_variablecheck($settings_dbdirectory, "directory", 0, 1);
376                 my $kiriwrite_outputdirectory_check     = kiriwrite_variablecheck($settings_outputdirectory, "directory", 0, 1);
377                 kiriwrite_variablecheck($settings_datetimeformat, "datetime", 0, 0);
379                 my $kiriwrite_textarearows_maxlength            = kiriwrite_variablecheck($settings_textarearows, "maxlength", 3, 1);
380                 my $kiriwrite_textarearows_number               = kiriwrite_variablecheck($settings_textarearows, "numbers", 0, 1);
381                 my $kiriwrite_textareacols_maxlength            = kiriwrite_variablecheck($settings_textareacols, "maxlength", 3, 1);
382                 my $kiriwrite_textareacols_number               = kiriwrite_variablecheck($settings_textareacols, "numbers", 0, 1);
384                 my $kiriwrite_pagecount_maxlength               = kiriwrite_variablecheck($settings_pagecount, "maxlength", 4, 1);
385                 my $kiriwrite_pagecount_number                  = kiriwrite_variablecheck($settings_pagecount, "numbers", 0, 1);
386                 my $kiriwrite_filtercount_maxlength             = kiriwrite_variablecheck($settings_filtercount, "maxlength", 4, 1);
387                 my $kiriwrite_filtercount_number                = kiriwrite_variablecheck($settings_filtercount, "numbers", 0, 1);
388                 my $kiriwrite_templatecount_maxlength           = kiriwrite_variablecheck($settings_templatecount, "maxlength", 4, 1);
389                 my $kiriwrite_templatecount_number              = kiriwrite_variablecheck($settings_templatecount, "numbers", 0, 1);
391                 if ($kiriwrite_dbdirectory_check eq 1){
393                         # The database directory name is blank, so return
394                         # an error.
396                         kiriwrite_error("dbdirectoryblank");
398                 } elsif ($kiriwrite_dbdirectory_check eq 2){
400                         # The database directory name is invalid, so return
401                         # an error.
403                         kiriwrite_error("dbdirectoryinvalid");
405                 }
407                 if ($kiriwrite_outputdirectory_check eq 1){
409                         # The output directory name is blank, so return
410                         # an error.
412                         kiriwrite_error("outputdirectoryblank");
414                 } elsif ($kiriwrite_outputdirectory_check eq 2){
416                         # The output directory name is invalid, so return
417                         # an error.
419                         kiriwrite_error("outputdirectoryinvalid");
421                 }
423                 if (!$settings_textarearows){
425                         # The text area row value is blank so return an
426                         # error.
428                         kiriwrite_error("textarearowblank");
430                 }
432                 if ($kiriwrite_textarearows_maxlength eq 1){
434                         # The text area row value is too long, so return
435                         # an error.
437                         kiriwrite_error("textarearowtoolong");
439                 }
441                 if ($kiriwrite_textarearows_number eq 1){
443                         # The text area row value is invalid, so return
444                         # an error.
446                         kiriwrite_error("textarearowinvalid");
448                 }
450                 if (!$settings_textareacols){
452                         # The text area column value is blank so return
453                         # an error.
455                         kiriwrite_error("textareacolblank");
457                 }
459                 if ($kiriwrite_textareacols_maxlength eq 1){
461                         # The text area column value is too long, so return
462                         # an error.
464                         kiriwrite_error("textareacoltoolong");
466                 }
468                 if ($kiriwrite_textareacols_number eq 1){
470                         # The text area column value is invalid, so return
471                         # an error.
473                         kiriwrite_error("textareacolinvalid");
475                 }
477                 if ($kiriwrite_pagecount_maxlength eq 1){
479                         # The page count value is too long, so return
480                         # an error.
482                         kiriwrite_error("pagecounttoolong");
484                 }
486                 if ($kiriwrite_pagecount_number eq 1){
488                         # The page count value is invalid, so return
489                         # an error.
491                         kiriwrite_error("pagecountinvalid");
493                 }
495                 if ($kiriwrite_filtercount_maxlength eq 1){
497                         # The filter count value is too long, so return
498                         # an error.
500                         kiriwrite_error("filtercounttoolong");
502                 }
504                 if ($kiriwrite_filtercount_number eq 1){
506                         # The filter count value is invalid, so return
507                         # an error.
509                         kiriwrite_error("filtercountinvalid");
511                 }
513                 if ($kiriwrite_templatecount_maxlength eq 1){
515                         # The template count value is too long, so return
516                         # an error.
518                         kiriwrite_error("templatecounttoolong");
520                 }
522                 if ($kiriwrite_templatecount_number eq 1){
524                         # The template count value is invalid, so return
525                         # an error.
527                         kiriwrite_error("templatecountinvalid");
529                 }
531                 # Check if the presentation module with the filename given exists.
533                 my $presmodule_exists = kiriwrite_fileexists("Modules/Presentation/" . $settings_presmodule . ".pm");
535                 if ($presmodule_exists eq 1){
537                         # The presentation module does not exist so return an error.
539                         kiriwrite_error("presmodulemissing");
541                 }
543                 # Check if the database module with the filename given exists.
545                 my $dbmodule_exists = kiriwrite_fileexists("Modules/Database/" . $settings_dbmodule . ".pm");
547                 if ($dbmodule_exists eq 1){
549                         # The database module does not exist so return an error.
551                         kiriwrite_error("dbmodulemissing");
553                 }
555                 # Check if the language filename given exists.
557                 my $languagefile_exists = kiriwrite_fileexists("lang/" . $settings_languagesystem . ".lang");
559                 if ($languagefile_exists eq 1){
561                         # The language filename given does not exist so return an error.
563                         kiriwrite_error("languagefilenamemissing");             
565                 }
567                 # Check the database server options to see if they are valid.
569                 my $kiriwrite_databaseserver_length_check               = kiriwrite_variablecheck($settings_database_server, "maxlength", 128, 1);
570                 my $kiriwrite_databaseserver_lettersnumbers_check       = kiriwrite_variablecheck($settings_database_server, "lettersnumbers", 0, 1);
571                 my $kiriwrite_databaseport_length_check                 = kiriwrite_variablecheck($settings_database_port, "maxlength", 5, 1);
572                 my $kiriwrite_databaseport_numbers_check                = kiriwrite_variablecheck($settings_database_port, "numbers", 0, 1);
573                 my $kiriwrite_databaseport_port_check                   = kiriwrite_variablecheck($settings_database_port, "port", 0, 1);
574                 my $kiriwrite_databaseprotocol_length_check             = kiriwrite_variablecheck($settings_database_protocol, "maxlength", 5, 1);
575                 my $kiriwrite_databaseprotocol_protocol_check           = kiriwrite_variablecheck($settings_database_protocol, "serverprotocol", 0, 1);
576                 my $kiriwrite_databasename_length_check                 = kiriwrite_variablecheck($settings_database_sqldatabase, "maxlength", 32, 1);
577                 my $kiriwrite_databasename_lettersnumbers_check         = kiriwrite_variablecheck($settings_database_sqldatabase, "lettersnumbers", 0, 1);
578                 my $kiriwrite_databaseusername_length_check             = kiriwrite_variablecheck($settings_database_username, "maxlength", 16, 1);
579                 my $kiriwrite_databaseusername_lettersnumbers_check     = kiriwrite_variablecheck($settings_database_username, "lettersnumbers", 0, 1);
580                 my $kiriwrite_databasepassword_length_check             = kiriwrite_variablecheck($settings_database_password, "maxlength", 64, 1);
581                 my $kiriwrite_databasetableprefix_length_check          = kiriwrite_variablecheck($settings_database_tableprefix, "maxlength", 16, 1);
582                 my $kiriwrite_databasetableprefix_lettersnumbers_check  = kiriwrite_variablecheck($settings_database_tableprefix, "lettersnumbers", 0, 1);
584                 if ($kiriwrite_databaseserver_length_check eq 1){
586                         # The length of the database server name is too long so
587                         # return an error.
589                         kiriwrite_error("servernametoolong");
591                 }
593                 if ($kiriwrite_databaseserver_lettersnumbers_check eq 1){
595                         # The database server name contains characters other
596                         # than letters and numbers, so return an error.
598                         kiriwrite_error("servernameinvalid");
600                 }
602                 if ($kiriwrite_databaseport_length_check eq 1){
604                         # The database port number length is too long so return
605                         # an error.
607                         kiriwrite_error("serverportnumbertoolong");
609                 }
611                 if ($kiriwrite_databaseport_numbers_check eq 1){
613                         # The database port number contains characters other
614                         # than numbers so return an error.
616                         kiriwrite_error("serverportnumberinvalidcharacters");
618                 }
620                 if ($kiriwrite_databaseport_port_check eq 1){
622                         # The database port number given is invalid so return
623                         # an error.
625                         kiriwrite_error("serverportnumberinvalid");
627                 }
629                 if ($kiriwrite_databaseprotocol_length_check eq 1){
631                         # The database protocol name given is too long so
632                         # return an error.
634                         kiriwrite_error("serverprotocolnametoolong");
636                 }
638                 if ($kiriwrite_databaseprotocol_protocol_check eq 1){
640                         # The server protcol given is invalid so return
641                         # an error.
643                         kiriwrite_error("serverprotocolinvalid");
645                 }
647                 if ($kiriwrite_databasename_length_check eq 1){
649                         # The SQL database name is too long so return
650                         # an error.
652                         kiriwrite_error("serverdatabasenametoolong");
654                 }
656                 if ($kiriwrite_databasename_lettersnumbers_check eq 1){
658                         # The database name contains invalid characters
659                         # so return an error.
661                         kiriwrite_error("serverdatabasenameinvalid");
663                 }
665                 if ($kiriwrite_databaseusername_length_check eq 1){
667                         # The database username given is too long so
668                         # return an error.
670                         kiriwrite_error("serverdatabaseusernametoolong");
672                 }
674                 if ($kiriwrite_databaseusername_lettersnumbers_check eq 1){
676                         # The database username contains invalid characters
677                         # so return an error.
679                         kiriwrite_error("serverdatabaseusernameinvalid");
681                 }
683                 if ($kiriwrite_databasepassword_length_check eq 1){
685                         # The database password given is too long so return
686                         # an error.
688                         kiriwrite_error("serverdatabasepasswordtoolong");
690                 }
692                 if ($kiriwrite_databasetableprefix_length_check eq 1){
694                         # The database table prefix given is too long so
695                         # return an error.
697                         kiriwrite_error("serverdatabasetableprefixtoolong");
699                 }
701                 if ($kiriwrite_databasetableprefix_lettersnumbers_check eq 1){
703                         # The database table prefix given contains invalid
704                         # characters so return an error.
706                         kiriwrite_error("serverdatabasetableprefixinvalid");
708                 }
710                 # Check if the current password should be kept.
712                 if ($settings_database_passwordkeep eq "on"){
714                         # The current password in the configuration file should be used.
716                         $settings_database_password     = $main::kiriwrite_config{"database_password"};
718                 }
720                 # Write the new settings to the configuration file.
722                 kiriwrite_output_config({ DatabaseDirectory => $settings_dbdirectory, OutputDirectory => $settings_outputdirectory, ImagesURIPath => $settings_imagesuri, DateTimeFormat => $settings_datetimeformat, SystemLanguage => $settings_languagesystem, PresentationModule => $settings_presmodule, OutputModule => $settings_outputmodule, TextAreaCols => $settings_textareacols, TextAreaRows => $settings_textarearows, PageCount => $settings_pagecount, FilterCount => $settings_filtercount, TemplateCount => $settings_templatecount, DatabaseModule => $settings_dbmodule, DatabaseServer => $settings_database_server, DatabasePort => $settings_database_port, DatabaseProtocol => $settings_database_protocol, DatabaseSQLDatabase => $settings_database_sqldatabase, DatabaseUsername => $settings_database_username, DatabasePassword => $settings_database_password, DatabaseTablePrefix => $settings_database_tableprefix });
724                 # Write a confirmation message.
726                 $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{settingsedited}, { Style => "pageheader" });
727                 $main::kiriwrite_presmodule->addlinebreak();
728                 $main::kiriwrite_presmodule->addlinebreak();
729                 $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{settingseditedmessage});
730                 $main::kiriwrite_presmodule->addlinebreak();
731                 $main::kiriwrite_presmodule->addlinebreak();
732                 $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{"script_filename"} . "?mode=settings", { Text => $main::kiriwrite_lang{setting}{returnsettingslist} });
734                 return $main::kiriwrite_presmodule->grab();
736         }
738         # Get the list of languages available.
740         my %language_list;
741         my @language_directory          = "";
742         my $language;
743         my ($language_file, %language_file);
744         my $language_filename           = "";
745         my $language_file_xml           = "";
746         my $language_file_systemname    = "";
747         my $language_file_localname     = "";
748         my $language_file_seek          = 0;
749         my $language_flie_dot           = 0;
750         my $language_file_length        = 0;
751         my $language_file_count         = 0;
752         my $language_file_char          = "";
753         my $language_file_friendly      = "";
754         my $language_config             = $main::kiriwrite_config{"system_language"};
755         my @lang_data;
756         my $kiriwrite_languagefilehandle;
758         tie(%language_list, 'Tie::IxHash');
760         opendir(LANGUAGEDIR, "lang");
761         @language_directory = grep /m*\.lang$/, readdir(LANGUAGEDIR);
762         closedir(LANGUAGEDIR);
764         # Process each language by loading the language file
765         # used for each language and then get the System name and 
766         # the local name of the language.
768         foreach $language_filename (@language_directory){
770                 # Load the language file currently selected.
772                 open($kiriwrite_languagefilehandle, "lang/" . $main::kiriwrite_config{"system_language"} . ".lang");
773                 @lang_data = <$kiriwrite_languagefilehandle>;
774                 %language_file = kiriwrite_processconfig(@lang_data);
775                 close($kiriwrite_languagefilehandle);
777                 # Get the system name and the local name of the language.
779                 $language_file_localname = $language_file{about}{name};
781                 # Check if either the system name or the local name of the language
782                 # is blank and if it is, then don't add the language to the list.
784                 if (!$language_file_localname){
786                         # The system name or the local name is blank so don't add
787                         # the language to the list.
788                 
789                 } else {
791                         # Get the 'friendly' name of the language file name (basically
792                         # remove the .lang part from the filename.
794                         $language_file_length = length($language_filename);
796                         do {
798                                 # Get a character from the language filename and currently
799                                 # set by the seek counter.
801                                 $language_file_char = substr($language_filename, $language_file_seek, 1);
803                                 # Check if the character is a dot and if it is then set the
804                                 # last dot value to the seek counter value.
806                                 if ($language_file_char eq "."){
808                                         # Current chatacter is a dot so set the last dot value 
809                                         # to what is currently the seek counter.
811                                         $language_flie_dot = $language_file_seek;
813                                 } else {
815                                         # Current character is not a dot, so do nothing.
817                                 }
819                                 # Increment the seek counter.
821                                 $language_file_seek++;
823                         } until ($language_file_seek eq $language_file_length);
825                         # Reset the seek counter.
827                         $language_file_seek = 0;
829                         # Process the file name again and this time process the file
830                         # name until it reaches the last dot found.
832                         do {
834                                 # Get the character the seek counter is currently set at.
836                                 $language_file_char = substr($language_filename, $language_file_seek, 1);
838                                 # Append the character to the friendly file name.
840                                 $language_file_friendly = $language_file_friendly . $language_file_char;
842                                 # Increment the seek counter.
843         
844                                 $language_file_seek++;
846                         } until ($language_file_seek eq $language_flie_dot);
848                         # Append the language to the available languages list.
850                         $language_list{$language_file_count}{Filename} = $language_file_friendly;
851                         $language_list{$language_file_count}{Name} = $language_file_localname;
852                         $language_file_count++;
854                         # Reset certain counters and values before continuing.
856                         $language_file_seek     = 0;
857                         $language_flie_dot      = 0;
858                         $language_file_length   = 0;
859                         $language_file_char     = "";
860                         $language_file_friendly = "";
862                 }
864                 undef $language_file;
866         }
868         # Get the list of presentation modules available.
870         my %presmodule_list;
871         my @presmodule_directory;
872         my $presmodule;
873         my $presmodule_file             = "";
874         my $presmodule_count            = 0;
875         my $presmodule_config           = $main::kiriwrite_config{"system_presmodule"};
877         # Open and get the list of presentation modules (perl modules) by getting
878         # only files which end in .pm.
880         opendir(OUTPUTSYSTEMDIR, "Modules/Presentation");
881         @presmodule_directory = grep /m*\.pm$/, readdir(OUTPUTSYSTEMDIR);
882         closedir(OUTPUTSYSTEMDIR);
884         foreach $presmodule_file (@presmodule_directory){
886                 # Remove the .pm suffix.
888                 $presmodule_file =~ s/.pm$//;
889                 $presmodule_list{$presmodule_count}{Filename} = $presmodule_file;
890                 $presmodule_count++;
892         }
894         # Get the list of database modules available.
896         my %dbmodule_list;
897         my @dbmodule_directory;
898         my $dbmodule;
899         my $dbmodule_file               = "";
900         my $dbmodule_count              = 0;
901         my $dbmodule_config             = $main::kiriwrite_config{"system_dbmodule"};
903         # Open and get the list of database modules (perl modules) by getting
904         # only files which end in .pm.
906         opendir(DATABASEDIR, "Modules/Database");
907         @dbmodule_directory = grep /m*\.pm$/, readdir(DATABASEDIR);
908         closedir(DATABASEDIR);
910         foreach $dbmodule_file (@dbmodule_directory){
912                 # Remove the .pm suffix.
914                 $dbmodule_file =~ s/.pm$//;
915                 $dbmodule_list{$dbmodule_count}{Filename} = $dbmodule_file;
916                 $dbmodule_count++;
918         }
920         my %outputmodule_list;
921         my @outputmodule_directory;
922         my $outputmodule;
923         my $outputmodule_file           = "";
924         my $outputmodule_count          = 0;
925         my $outputmodule_config         = $main::kiriwrite_config{"system_outputmodule"};
927         # Open and get the list of output modules (perl modules) by getting
928         # only files which end in .pm.
930         opendir(DATABASEDIR, "Modules/Output");
931         @outputmodule_directory = grep /m*\.pm$/, readdir(DATABASEDIR);
932         closedir(DATABASEDIR);
934         foreach $outputmodule_file (@outputmodule_directory){
936                 # Remove the .pm suffix.
938                 $outputmodule_file =~ s/.pm$//;
939                 $outputmodule_list{$outputmodule_count}{Filename} = $outputmodule_file;
940                 $outputmodule_count++;
942         }
944         # Get the directory settings.
946         my $directory_settings_database         = $main::kiriwrite_config{"directory_data_db"};
947         my $directory_settings_output           = $main::kiriwrite_config{"directory_data_output"};
948         my $directory_settings_imagesuri        = $main::kiriwrite_config{"directory_noncgi_images"};
949         my $datetime_setting                    = $main::kiriwrite_config{"system_datetime"};
951         my $display_textareacols                = $main::kiriwrite_config{"display_textareacols"};
952         my $display_textarearows                = $main::kiriwrite_config{"display_textarearows"};
953         my $display_pagecount                   = $main::kiriwrite_config{"display_pagecount"};
954         my $display_templatecount               = $main::kiriwrite_config{"display_templatecount"};
955         my $display_filtercount                 = $main::kiriwrite_config{"display_filtercount"};
957         my $database_server                     = $main::kiriwrite_config{"database_server"};
958         my $database_port                       = $main::kiriwrite_config{"database_port"};
959         my $database_protocol                   = $main::kiriwrite_config{"database_protocol"};
960         my $database_sqldatabase                = $main::kiriwrite_config{"database_sqldatabase"};
961         my $database_username                   = $main::kiriwrite_config{"database_username"};
962         my $database_passwordhash               = $main::kiriwrite_config{"database_passwordhash"};
963         my $database_password                   = $main::kiriwrite_config{"database_password"};
964         my $database_prefix                     = $main::kiriwrite_config{"database_tableprefix"};
966         # Print out a form for editing the settings.
968         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{editsettings}, { Style => "pageheader" });
969         $main::kiriwrite_presmodule->addlinebreak();
970         $main::kiriwrite_presmodule->addlinebreak();
971         $main::kiriwrite_presmodule->addboldtext($main::kiriwrite_lang{setting}{warning});
972         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{warningmessage});
973         $main::kiriwrite_presmodule->addlinebreak();
974         $main::kiriwrite_presmodule->addlinebreak();
976         $main::kiriwrite_presmodule->startform($main::kiriwrite_env{"script_filename"}, "POST");
977         $main::kiriwrite_presmodule->startbox();
978         $main::kiriwrite_presmodule->addhiddendata("mode", "settings");
979         $main::kiriwrite_presmodule->addhiddendata("action", "edit");
980         $main::kiriwrite_presmodule->addhiddendata("confirm", 1);
982         $main::kiriwrite_presmodule->starttable("", { CellPadding => 5, CellSpacing => 0 });
984         $main::kiriwrite_presmodule->startheader();
985         $main::kiriwrite_presmodule->addheader($main::kiriwrite_lang{common}{setting}, { Style => "tablecellheader" });
986         $main::kiriwrite_presmodule->addheader($main::kiriwrite_lang{common}{value}, { Style => "tablecellheader" });
987         $main::kiriwrite_presmodule->endheader();
989         $main::kiriwrite_presmodule->startrow();
990         $main::kiriwrite_presmodule->addcell("tablecellheader");
991         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{directories});
992         $main::kiriwrite_presmodule->endcell();
993         $main::kiriwrite_presmodule->addcell("tablecellheader");
994         $main::kiriwrite_presmodule->endcell();
995         $main::kiriwrite_presmodule->endrow();
997         $main::kiriwrite_presmodule->startrow();
998         $main::kiriwrite_presmodule->addcell("tablecell1");
999         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{databasedirectory});
1000         $main::kiriwrite_presmodule->endcell();
1001         $main::kiriwrite_presmodule->addcell("tablecell2");
1002         $main::kiriwrite_presmodule->addinputbox("databasedir", { Size => 32, MaxLength => 64, Value => $directory_settings_database });
1003         $main::kiriwrite_presmodule->endcell();
1004         $main::kiriwrite_presmodule->endrow();
1006         $main::kiriwrite_presmodule->startrow();
1007         $main::kiriwrite_presmodule->addcell("tablecell1");
1008         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{outputdirectory});
1009         $main::kiriwrite_presmodule->endcell();
1010         $main::kiriwrite_presmodule->addcell("tablecell2");
1011         $main::kiriwrite_presmodule->addinputbox("outputdir", { Size => 32, MaxLength => 64, Value => $directory_settings_output });
1012         $main::kiriwrite_presmodule->endcell();
1013         $main::kiriwrite_presmodule->endrow();
1015         $main::kiriwrite_presmodule->startrow();
1016         $main::kiriwrite_presmodule->addcell("tablecell1");
1017         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{imagesuripath});
1018         $main::kiriwrite_presmodule->endcell();
1019         $main::kiriwrite_presmodule->addcell("tablecell2");
1020         $main::kiriwrite_presmodule->addinputbox("imagesuripath", { Size => 32, MaxLength => 512, Value => $directory_settings_imagesuri });
1021         $main::kiriwrite_presmodule->endcell();
1022         $main::kiriwrite_presmodule->endrow();
1024         $main::kiriwrite_presmodule->startrow();
1025         $main::kiriwrite_presmodule->addcell("tablecellheader");
1026         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{display});
1027         $main::kiriwrite_presmodule->endcell();
1028         $main::kiriwrite_presmodule->addcell("tablecellheader");
1029         $main::kiriwrite_presmodule->endcell();
1030         $main::kiriwrite_presmodule->endrow();
1032         $main::kiriwrite_presmodule->startrow();
1033         $main::kiriwrite_presmodule->addcell("tablecell1");
1034         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{textareacols});
1035         $main::kiriwrite_presmodule->endcell();
1036         $main::kiriwrite_presmodule->addcell("tablecell2");
1037         $main::kiriwrite_presmodule->addinputbox("textareacols", { Size => 3, MaxLength => 3, Value => $display_textareacols });
1038         $main::kiriwrite_presmodule->endrow();
1040         $main::kiriwrite_presmodule->startrow();
1041         $main::kiriwrite_presmodule->addcell("tablecell1");
1042         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{textarearows});
1043         $main::kiriwrite_presmodule->endcell();
1044         $main::kiriwrite_presmodule->addcell("tablecell2");
1045         $main::kiriwrite_presmodule->addinputbox("textarearows", { Size => 3, MaxLength => 3, Value => $display_textarearows });
1046         $main::kiriwrite_presmodule->endrow();
1048         $main::kiriwrite_presmodule->startrow();
1049         $main::kiriwrite_presmodule->addcell("tablecell1");
1050         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{pagecount});
1051         $main::kiriwrite_presmodule->endcell();
1052         $main::kiriwrite_presmodule->addcell("tablecell2");
1053         $main::kiriwrite_presmodule->addinputbox("pagecount", { Size => 4, MaxLength => 4, Value => $display_pagecount });
1054         $main::kiriwrite_presmodule->endrow();
1056         $main::kiriwrite_presmodule->startrow();
1057         $main::kiriwrite_presmodule->addcell("tablecell1");
1058         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{filtercount});
1059         $main::kiriwrite_presmodule->endcell();
1060         $main::kiriwrite_presmodule->addcell("tablecell2");
1061         $main::kiriwrite_presmodule->addinputbox("filtercount", { Size => 4, MaxLength => 4, Value => $display_filtercount });
1062         $main::kiriwrite_presmodule->endrow();
1064         $main::kiriwrite_presmodule->startrow();
1065         $main::kiriwrite_presmodule->addcell("tablecell1");
1066         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{templatecount});
1067         $main::kiriwrite_presmodule->endcell();
1068         $main::kiriwrite_presmodule->addcell("tablecell2");
1069         $main::kiriwrite_presmodule->addinputbox("templatecount", { Size => 4, MaxLength => 4, Value => $display_templatecount });
1070         $main::kiriwrite_presmodule->endrow();
1072         $main::kiriwrite_presmodule->startrow();
1073         $main::kiriwrite_presmodule->addcell("tablecellheader");
1074         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{date});
1075         $main::kiriwrite_presmodule->endcell();
1076         $main::kiriwrite_presmodule->addcell("tablecellheader");
1077         $main::kiriwrite_presmodule->endcell();
1078         $main::kiriwrite_presmodule->endrow();
1080         $main::kiriwrite_presmodule->startrow();
1081         $main::kiriwrite_presmodule->addcell("tablecell1");
1082         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{dateformat});
1083         $main::kiriwrite_presmodule->endcell();
1084         $main::kiriwrite_presmodule->addcell("tablecell2");
1085         $main::kiriwrite_presmodule->addinputbox("datetime", { Size => 32, MaxLength => 64, Value => $datetime_setting });
1086         $main::kiriwrite_presmodule->addlinebreak();
1087         $main::kiriwrite_presmodule->addlinebreak();
1088         $main::kiriwrite_presmodule->startbox("datalist");
1090         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{singleday});
1091         $main::kiriwrite_presmodule->addlinebreak();
1092         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{doubleday});
1093         $main::kiriwrite_presmodule->addlinebreak();
1094         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{singlemonth});
1095         $main::kiriwrite_presmodule->addlinebreak();
1096         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{doublemonth});
1097         $main::kiriwrite_presmodule->addlinebreak();
1098         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{singleyear});
1099         $main::kiriwrite_presmodule->addlinebreak();
1100         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{doubleyear});
1101         $main::kiriwrite_presmodule->addlinebreak();
1102         $main::kiriwrite_presmodule->addlinebreak();
1103         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{singlehour});
1104         $main::kiriwrite_presmodule->addlinebreak();
1105         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{doublehour});
1106         $main::kiriwrite_presmodule->addlinebreak();
1107         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{singleminute});
1108         $main::kiriwrite_presmodule->addlinebreak();
1109         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{doubleminute});
1110         $main::kiriwrite_presmodule->addlinebreak();
1111         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{singlesecond});
1112         $main::kiriwrite_presmodule->addlinebreak();
1113         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{doublesecond});
1114         $main::kiriwrite_presmodule->addlinebreak();
1115         $main::kiriwrite_presmodule->addlinebreak();
1116         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{othercharacters});
1117         $main::kiriwrite_presmodule->endbox();
1118         $main::kiriwrite_presmodule->endcell();
1119         $main::kiriwrite_presmodule->endrow();
1121         $main::kiriwrite_presmodule->startrow();
1122         $main::kiriwrite_presmodule->addcell("tablecellheader");
1123         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{language});
1124         $main::kiriwrite_presmodule->endcell();
1125         $main::kiriwrite_presmodule->addcell("tablecellheader");
1126         $main::kiriwrite_presmodule->endcell();
1127         $main::kiriwrite_presmodule->endrow();
1129         $main::kiriwrite_presmodule->startrow();
1130         $main::kiriwrite_presmodule->addcell("tablecell1");
1131         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{systemlanguage});
1132         $main::kiriwrite_presmodule->endcell();
1133         $main::kiriwrite_presmodule->addcell("tablecell2");
1135         $main::kiriwrite_presmodule->addselectbox("language");
1137         # Process the list of available languages.
1139         foreach $language (keys %language_list){
1141                 # Check if the language filename matches the filename in the configuration
1142                 # file.
1144                 if ($language_list{$language}{Filename} eq $language_config){
1146                         $main::kiriwrite_presmodule->addoption($language_list{$language}{Name}, { Value => $language_list{$language}{Filename} , Selected => 1 });
1148                 } else {
1150                         $main::kiriwrite_presmodule->addoption($language_list{$language}{Name}, { Value => $language_list{$language}{Filename} });
1152                 }
1154         }
1156         $main::kiriwrite_presmodule->endselectbox();
1158         $main::kiriwrite_presmodule->startrow();
1159         $main::kiriwrite_presmodule->addcell("tablecellheader");
1160         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{modules});
1161         $main::kiriwrite_presmodule->endcell();
1162         $main::kiriwrite_presmodule->addcell("tablecellheader");
1163         $main::kiriwrite_presmodule->endcell();
1164         $main::kiriwrite_presmodule->endrow();
1166         $main::kiriwrite_presmodule->startrow();
1167         $main::kiriwrite_presmodule->addcell("tablecell1");
1168         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{presentationmodule});
1169         $main::kiriwrite_presmodule->endcell();
1170         $main::kiriwrite_presmodule->addcell("tablecell2");
1172         $main::kiriwrite_presmodule->addselectbox("presmodule");
1174         # Process the list of available presentation modules.
1176         foreach $presmodule (keys %presmodule_list){
1178                 # Check if the presentation module fileanme matches the filename in the 
1179                 # configuration file.
1181                 if ($presmodule_list{$presmodule}{Filename} eq $presmodule_config){
1183                         $main::kiriwrite_presmodule->addoption($presmodule_list{$presmodule}{Filename}, { Value => $presmodule_list{$presmodule}{Filename} , Selected => 1 });
1185                 } else {
1187                         $main::kiriwrite_presmodule->addoption($presmodule_list{$presmodule}{Filename}, { Value => $presmodule_list{$presmodule}{Filename} });
1189                 }
1191         }
1193         $main::kiriwrite_presmodule->endselectbox();
1195         $main::kiriwrite_presmodule->endcell();
1196         $main::kiriwrite_presmodule->endrow();
1198         $main::kiriwrite_presmodule->startrow();
1199         $main::kiriwrite_presmodule->addcell("tablecell1");
1200         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{outputmodule});
1201         $main::kiriwrite_presmodule->endcell();
1202         $main::kiriwrite_presmodule->addcell("tablecell2");
1204         # Process the list of available output modules.
1206         $main::kiriwrite_presmodule->addselectbox("outputmodule");
1208         foreach $outputmodule (keys %outputmodule_list){
1210                 # Check if the output module fileanme matches the filename in the 
1211                 # configuration file.
1213                 if ($outputmodule_list{$outputmodule}{Filename} eq $outputmodule_config){
1215                         $main::kiriwrite_presmodule->addoption($outputmodule_list{$outputmodule}{Filename}, { Value => $outputmodule_list{$outputmodule}{Filename} , Selected => 1 });
1217                 } else {
1219                         $main::kiriwrite_presmodule->addoption($outputmodule_list{$outputmodule}{Filename}, { Value => $outputmodule_list{$outputmodule}{Filename} });
1221                 }
1224         }
1226         $main::kiriwrite_presmodule->endselectbox();
1228         $main::kiriwrite_presmodule->endcell();
1229         $main::kiriwrite_presmodule->endrow();
1231         $main::kiriwrite_presmodule->startrow();
1232         $main::kiriwrite_presmodule->addcell("tablecell1");
1233         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{databasemodule});
1234         $main::kiriwrite_presmodule->endcell();
1235         $main::kiriwrite_presmodule->addcell("tablecell2");
1237         # Process the list of available database modules.
1239         $main::kiriwrite_presmodule->addselectbox("dbmodule");
1241         foreach $dbmodule (keys %dbmodule_list){
1243                 # Check if the database module fileanme matches the filename in the 
1244                 # configuration file.
1246                 if ($dbmodule_list{$dbmodule}{Filename} eq $dbmodule_config){
1248                         $main::kiriwrite_presmodule->addoption($dbmodule_list{$dbmodule}{Filename}, { Value => $dbmodule_list{$dbmodule}{Filename} , Selected => 1 });
1250                 } else {
1252                         $main::kiriwrite_presmodule->addoption($dbmodule_list{$dbmodule}{Filename}, { Value => $dbmodule_list{$dbmodule}{Filename} });
1254                 }
1257         }
1259         $main::kiriwrite_presmodule->endselectbox();
1261         $main::kiriwrite_presmodule->endcell();
1262         $main::kiriwrite_presmodule->endrow();
1264         $main::kiriwrite_presmodule->startrow();
1265         $main::kiriwrite_presmodule->addcell("tablecell1");
1266         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{databaseserver});
1267         $main::kiriwrite_presmodule->endcell();
1268         $main::kiriwrite_presmodule->addcell("tablecell2");
1269         $main::kiriwrite_presmodule->addinputbox("database_server", { Size => 32, MaxLength => 128, Value => $database_server });
1270         $main::kiriwrite_presmodule->endcell();
1271         $main::kiriwrite_presmodule->endrow();
1273         $main::kiriwrite_presmodule->startrow();
1274         $main::kiriwrite_presmodule->addcell("tablecell1");
1275         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{databaseport});
1276         $main::kiriwrite_presmodule->endcell();
1277         $main::kiriwrite_presmodule->addcell("tablecell2");
1278         $main::kiriwrite_presmodule->addinputbox("database_port", { Size => 5, MaxLength => 5, Value => $database_port });
1279         $main::kiriwrite_presmodule->endcell();
1280         $main::kiriwrite_presmodule->endrow();
1282         $main::kiriwrite_presmodule->startrow();
1283         $main::kiriwrite_presmodule->addcell("tablecell1");
1284         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{databaseprotocol});
1285         $main::kiriwrite_presmodule->endcell();
1286         $main::kiriwrite_presmodule->addcell("tablecell2");
1288         # Check if TCP is being used.
1290         $main::kiriwrite_presmodule->addselectbox("database_protocol");
1292         if ($database_protocol eq "tcp"){
1294                 # The TCP protocol is selected so have the TCP option selected.
1296                 $main::kiriwrite_presmodule->addoption("TCP", { Value => "tcp", Selected => 1});
1298         } else {
1300                 # The TCP protocol is not selected.
1302                 $main::kiriwrite_presmodule->addoption("TCP", { Value => "tcp"});
1304         } 
1306         # Check if UDP is being used.
1308         if ($database_protocol eq "udp"){
1310                 # The UDP protocol is selected so have the UDP option selected.
1312                 $main::kiriwrite_presmodule->addoption("UDP", { Value => "udp", Selected => 1});
1314         } else {
1316                 # The UDP protocol is not selected.
1318                 $main::kiriwrite_presmodule->addoption("UDP", { Value => "udp"});
1320         }
1322         $main::kiriwrite_presmodule->endselectbox();
1324         $main::kiriwrite_presmodule->endcell();
1325         $main::kiriwrite_presmodule->endrow();
1327         $main::kiriwrite_presmodule->startrow();
1328         $main::kiriwrite_presmodule->addcell("tablecell1");
1329         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{databasename});
1330         $main::kiriwrite_presmodule->endcell();
1331         $main::kiriwrite_presmodule->addcell("tablecell2");
1332         $main::kiriwrite_presmodule->addinputbox("database_sqldatabase", { Size => 32, MaxLength => 32, Value => $database_sqldatabase });
1333         $main::kiriwrite_presmodule->endcell();
1334         $main::kiriwrite_presmodule->endrow();
1336         $main::kiriwrite_presmodule->startrow();
1337         $main::kiriwrite_presmodule->addcell("tablecell1");
1338         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{databaseusername});
1339         $main::kiriwrite_presmodule->endcell();
1340         $main::kiriwrite_presmodule->addcell("tablecell2");
1341         $main::kiriwrite_presmodule->addinputbox("database_username", { Size => 16, MaxLength => 16, Value => $database_username });
1342         $main::kiriwrite_presmodule->endcell();
1343         $main::kiriwrite_presmodule->endrow();
1345         $main::kiriwrite_presmodule->startrow();
1346         $main::kiriwrite_presmodule->addcell("tablecell1");
1347         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{databasepassword});
1348         $main::kiriwrite_presmodule->endcell();
1349         $main::kiriwrite_presmodule->addcell("tablecell2");
1350         $main::kiriwrite_presmodule->addinputbox("database_password", { Size => 16, MaxLength => 64, Password => 1 });
1351         $main::kiriwrite_presmodule->addtext(" ");
1352         $main::kiriwrite_presmodule->addcheckbox("database_password_keep", { OptionDescription => "Keep the current password", Checked => 1 });
1353         $main::kiriwrite_presmodule->endcell();
1354         $main::kiriwrite_presmodule->endrow();
1356         $main::kiriwrite_presmodule->startrow();
1357         $main::kiriwrite_presmodule->addcell("tablecell1");
1358         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{tableprefix});
1359         $main::kiriwrite_presmodule->endcell();
1360         $main::kiriwrite_presmodule->addcell("tablecell2");
1361         $main::kiriwrite_presmodule->addinputbox("database_tableprefix", { Size => 16, MaxLength => 16, Value => $database_prefix });
1362         $main::kiriwrite_presmodule->endcell();
1363         $main::kiriwrite_presmodule->endrow();
1365         $main::kiriwrite_presmodule->endtable();
1367         $main::kiriwrite_presmodule->addlinebreak();
1368         $main::kiriwrite_presmodule->addsubmit($main::kiriwrite_lang{setting}{changesettingsbutton});
1369         $main::kiriwrite_presmodule->addtext(" | ");
1370         $main::kiriwrite_presmodule->addreset($main::kiriwrite_lang{common}{restorecurrent});
1371         $main::kiriwrite_presmodule->addtext(" | ");
1372         $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{"script_filename"} . "?mode=settings", { Text => $main::kiriwrite_lang{setting}->{returnsettingslist} });
1373         $main::kiriwrite_presmodule->endbox();
1374         $main::kiriwrite_presmodule->endform();
1376         return $main::kiriwrite_presmodule->grab();
1378
1380 sub kiriwrite_output_config{
1381 #################################################################################
1382 # kiriwrite_output_config: Outputs the configuration file.                      #
1383 #                                                                               #
1384 # Usage:                                                                        #
1385 #                                                                               #
1386 # kiriwrite_output_config(settings);                                            #
1387 #                                                                               #
1388 # settings      Specifies the following settings in any order.                  #
1389 #                                                                               #
1390 # Settings for Kiriwrite configuration files:                                   #
1391 #                                                                               #
1392 # DatabaseDirectory     Specifies the new database directory to use.            #
1393 # OutputDirectory       Specifies the new output directory to use.              #
1394 # ImagesURIPath         Specifies the new URI path for images.                  #
1395 # DateTimeFormat        Specifies the new date and time format.                 #
1396 # SystemLanguage        Specifies the new language to use for Kiriwrite.        #
1397 # PrsentationModule     Specifies the new presentation module to use for        #
1398 #                       Kiriwrite.                                              #
1399 # OutputModule          Specifies the new output module to use for Kiriwrite.   #
1400 # TextAreaCols          Specifies the width of the text area.                   #
1401 # TextAreaRows          Specifies the height of the text area.                  #
1402 # PageCount             Specifies the amount of pages to view.                  #
1403 # FilterCount           Specifies the amount of filters to view.                #
1404 # TemplateCount         Specifies the amount of templates to view.              #
1405 # DatabaseModule        Specifies the new database module to use for Kiriwrite. #
1406 # DatabaseServer        Specifies the database server to use.                   #
1407 # DaravasePort          Specifies the port the database server is running on.   #
1408 # DatabaseProtocol      Specifies the protocol the database server is using.    #
1409 # DatabaseSQLDatabase   Specifies the SQL database name to use.                 #
1410 # DatabaseUsername      Specifies the database server username.                 #
1411 # DatabasePassword      Specifies the password for the database server username.#
1412 # DatabaseTablePrefix   Specifies the table prefix to use.                      #
1413 #################################################################################
1415         # Get the variables passed from the subroutine.
1417         my ($passedsettings)    = @_;
1419         # Get the data from the hash.
1421         my $settings_databasedir                = $passedsettings->{"DatabaseDirectory"};
1422         my $settings_outputdir                  = $passedsettings->{"OutputDirectory"};
1423         my $settings_imagesuri                  = $passedsettings->{"ImagesURIPath"};
1424         my $settings_datetime                   = $passedsettings->{"DateTimeFormat"};
1425         my $settings_systemlanguage             = $passedsettings->{"SystemLanguage"};
1426         my $settings_presmodule                 = $passedsettings->{"PresentationModule"};
1427         my $settings_outputmodule               = $passedsettings->{"OutputModule"};
1428         my $settings_dbmodule                   = $passedsettings->{"DatabaseModule"};
1430         my $settings_textareacols               = $passedsettings->{"TextAreaCols"};
1431         my $settings_textarearows               = $passedsettings->{"TextAreaRows"};
1432         my $settings_pagecount                  = $passedsettings->{"PageCount"};
1433         my $settings_filtercount                = $passedsettings->{"FilterCount"};
1434         my $settings_templatecount              = $passedsettings->{"TemplateCount"};
1436         my $settings_database_server            = $passedsettings->{"DatabaseServer"};
1437         my $settings_database_port              = $passedsettings->{"DatabasePort"};
1438         my $settings_database_protocol          = $passedsettings->{"DatabaseProtocol"};
1439         my $settings_database_sqldatabase       = $passedsettings->{"DatabaseSQLDatabase"};
1440         my $settings_database_username          = $passedsettings->{"DatabaseUsername"};
1441         my $settings_database_password          = $passedsettings->{"DatabasePassword"};
1442         my $settings_database_tableprefix       = $passedsettings->{"DatabaseTablePrefix"};
1444         # Convert the password to make sure it can be read properly.
1446         if ($settings_database_password){
1448                 $settings_database_password =~ s/\0//g;
1449                 $settings_database_password =~ s/</&lt;/g;
1450                 $settings_database_password =~ s/>/&gt;/g;
1452         }
1454         # Convert the less than and greater than characters are there and
1455         # convert them.
1457         if ($settings_imagesuri){
1459                 $settings_imagesuri =~ s/</&lt;/g;
1460                 $settings_imagesuri =~ s/>/&gt;/g;
1461                 $settings_imagesuri =~ s/\r//g;
1462                 $settings_imagesuri =~ s/\n//g;
1464         }
1466         # Check if the database password value is undefined and if it is then
1467         # set it blank.
1469         if (!$settings_database_password){
1471                 $settings_database_password = "";
1473         }
1475         # Create the Kiriwrite configuration file layout.
1477         my $configdata = "[config]\r\n";
1479         $configdata = $configdata . "directory_data_db = " . $settings_databasedir . "\r\n";
1480         $configdata = $configdata . "directory_data_output = "  . $settings_outputdir . "\r\n";
1481         $configdata = $configdata . "directory_noncgi_images = "  . $settings_imagesuri . "\r\n\r\n";
1483         $configdata = $configdata . "system_language = "  . $settings_systemlanguage . "\r\n";
1484         $configdata = $configdata . "system_presmodule = "  . $settings_presmodule . "\r\n";
1485         $configdata = $configdata . "system_dbmodule = "  . $settings_dbmodule . "\r\n";
1486         $configdata = $configdata . "system_outputmodule = "  . $settings_outputmodule . "\r\n";
1487         $configdata = $configdata . "system_datetime = "  . $settings_datetime . "\r\n\r\n";
1489         $configdata = $configdata . "display_textareacols = "  . $settings_textareacols . "\r\n";
1490         $configdata = $configdata . "display_textarearows = "  . $settings_textarearows . "\r\n";
1491         $configdata = $configdata . "display_pagecount = " . $settings_pagecount . "\r\n";
1492         $configdata = $configdata . "display_filtercount = " . $settings_filtercount . "\r\n";
1493         $configdata = $configdata . "display_templatecount = " . $settings_templatecount . "\r\n\r\n";
1495         $configdata = $configdata . "database_server = "  . $settings_database_server . "\r\n";
1496         $configdata = $configdata . "database_port = "  . $settings_database_port . "\r\n";
1497         $configdata = $configdata . "database_protocol = "  . $settings_database_protocol . "\r\n";
1498         $configdata = $configdata . "database_sqldatabase = "  . $settings_database_sqldatabase . "\r\n";
1499         $configdata = $configdata . "database_username = "  . $settings_database_username . "\r\n";
1500         $configdata = $configdata . "database_password = "  . $settings_database_password . "\r\n";
1501         $configdata = $configdata . "database_tableprefix = "  . $settings_database_tableprefix . "\r\n\r\n";
1503         # Open the Kiriwrite configuration file and write the new settings to the
1504         # configuration file.
1506         open(my $filehandle_config, "> ", "kiriwrite.cfg");
1507         print $filehandle_config $configdata;
1508         close($filehandle_config);
1510         return;
1512 };
1514 1;
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