Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Changes made in preperation for Kiriwrite 0.4.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"};
35         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{viewsettings}, { Style => "pageheader" });
36         $main::kiriwrite_presmodule->addlinebreak();
37         $main::kiriwrite_presmodule->addlinebreak();
38         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{currentsettings});
39         $main::kiriwrite_presmodule->addlinebreak();
40         $main::kiriwrite_presmodule->addlinebreak();
41         $main::kiriwrite_presmodule->starttable("", { CellPadding => 5, CellSpacing => 0 });
43         $main::kiriwrite_presmodule->startheader();
44         $main::kiriwrite_presmodule->addheader($main::kiriwrite_lang{common}{setting}, { Style => "tablecellheader" });
45         $main::kiriwrite_presmodule->addheader($main::kiriwrite_lang{common}{value}, { Style => "tablecellheader" });
46         $main::kiriwrite_presmodule->endheader();
48         $main::kiriwrite_presmodule->startrow();
49         $main::kiriwrite_presmodule->addcell("tablecellheader");
50         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{directories});
51         $main::kiriwrite_presmodule->endcell();
52         $main::kiriwrite_presmodule->addcell("tablecellheader");
53         $main::kiriwrite_presmodule->endcell();
54         $main::kiriwrite_presmodule->endrow();
56         $main::kiriwrite_presmodule->startrow();
57         $main::kiriwrite_presmodule->addcell("tablecell1");
58         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{databasedirectory});
59         $main::kiriwrite_presmodule->endcell();
60         $main::kiriwrite_presmodule->addcell("tablecell2");
61         $main::kiriwrite_presmodule->addtext($settings_directory_db);
62         $main::kiriwrite_presmodule->endcell();
63         $main::kiriwrite_presmodule->endrow();
65         $main::kiriwrite_presmodule->startrow();
66         $main::kiriwrite_presmodule->addcell("tablecell1");
67         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{outputdirectory});
68         $main::kiriwrite_presmodule->endcell();
69         $main::kiriwrite_presmodule->addcell("tablecell2");
70         $main::kiriwrite_presmodule->addtext($settings_directory_output);
71         $main::kiriwrite_presmodule->endcell();
72         $main::kiriwrite_presmodule->endrow();
74         $main::kiriwrite_presmodule->startrow();
75         $main::kiriwrite_presmodule->addcell("tablecell1");
76         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{imagesuripath});
77         $main::kiriwrite_presmodule->endcell();
78         $main::kiriwrite_presmodule->addcell("tablecell2");
79         $main::kiriwrite_presmodule->addtext($settings_noncgi_images);
80         $main::kiriwrite_presmodule->endcell();
81         $main::main::kiriwrite_presmodule->endrow();
83         $main::kiriwrite_presmodule->startrow();
84         $main::kiriwrite_presmodule->addcell("tablecellheader");
85         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{display});
86         $main::kiriwrite_presmodule->endcell();
87         $main::kiriwrite_presmodule->addcell("tablecellheader");
88         $main::kiriwrite_presmodule->endcell();
89         $main::kiriwrite_presmodule->endrow();
91         $main::kiriwrite_presmodule->startrow();
92         $main::kiriwrite_presmodule->addcell("tablecell1");
93         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{textareacols});
94         $main::kiriwrite_presmodule->endcell();
95         $main::kiriwrite_presmodule->addcell("tablecell2");
96         $main::kiriwrite_presmodule->addtext($settings_display_textareacols);
97         $main::kiriwrite_presmodule->endcell();
98         $main::kiriwrite_presmodule->endrow();
100         $main::kiriwrite_presmodule->startrow();
101         $main::kiriwrite_presmodule->addcell("tablecell1");
102         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{textarearows});
103         $main::kiriwrite_presmodule->endcell();
104         $main::kiriwrite_presmodule->addcell("tablecell2");
105         $main::kiriwrite_presmodule->addtext($settings_display_textarearows);
106         $main::kiriwrite_presmodule->endcell();
107         $main::kiriwrite_presmodule->endrow();
109         $main::kiriwrite_presmodule->startrow();
110         $main::kiriwrite_presmodule->addcell("tablecell1");
111         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{pagecount});
112         $main::kiriwrite_presmodule->endcell();
113         $main::kiriwrite_presmodule->addcell("tablecell2");
114         $main::kiriwrite_presmodule->addtext($settings_display_pagecount);
115         $main::kiriwrite_presmodule->endcell();
116         $main::kiriwrite_presmodule->endrow();
118         $main::kiriwrite_presmodule->startrow();
119         $main::kiriwrite_presmodule->addcell("tablecell1");
120         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{templatecount});
121         $main::kiriwrite_presmodule->endcell();
122         $main::kiriwrite_presmodule->addcell("tablecell2");
123         $main::kiriwrite_presmodule->addtext($settings_display_templatecount);
124         $main::kiriwrite_presmodule->endcell();
125         $main::kiriwrite_presmodule->endrow();
127         $main::kiriwrite_presmodule->startrow();
128         $main::kiriwrite_presmodule->addcell("tablecell1");
129         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{filtercount});
130         $main::kiriwrite_presmodule->endcell();
131         $main::kiriwrite_presmodule->addcell("tablecell2");
132         $main::kiriwrite_presmodule->addtext($settings_display_filtercount);
133         $main::kiriwrite_presmodule->endcell();
134         $main::kiriwrite_presmodule->endrow();
136         $main::kiriwrite_presmodule->startrow();
137         $main::kiriwrite_presmodule->addcell("tablecellheader");
138         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{date});
139         $main::kiriwrite_presmodule->endcell();
140         $main::kiriwrite_presmodule->addcell("tablecellheader");
141         $main::kiriwrite_presmodule->endcell();
142         $main::kiriwrite_presmodule->endrow();
144         $main::kiriwrite_presmodule->startrow();
145         $main::kiriwrite_presmodule->addcell("tablecell1");
146         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{dateformat});
147         $main::kiriwrite_presmodule->endcell();
148         $main::kiriwrite_presmodule->addcell("tablecell2");
149         $main::kiriwrite_presmodule->addtext($settings_system_datetime);
150         $main::kiriwrite_presmodule->endcell();
151         $main::kiriwrite_presmodule->endrow();
153         $main::kiriwrite_presmodule->startrow();
154         $main::kiriwrite_presmodule->addcell("tablecellheader");
155         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{language});
156         $main::kiriwrite_presmodule->endcell();
157         $main::kiriwrite_presmodule->addcell("tablecellheader");
158         $main::kiriwrite_presmodule->endcell();
159         $main::kiriwrite_presmodule->endrow();
161         $main::kiriwrite_presmodule->startrow();
162         $main::kiriwrite_presmodule->addcell("tablecell1");
163         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{systemlanguage});
164         $main::kiriwrite_presmodule->endcell();
165         $main::kiriwrite_presmodule->addcell("tablecell2");
166         $main::kiriwrite_presmodule->addtext($settings_system_language);
167         $main::kiriwrite_presmodule->endcell();
168         $main::kiriwrite_presmodule->endrow();
170         $main::kiriwrite_presmodule->startrow();
171         $main::kiriwrite_presmodule->addcell("tablecellheader");
172         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{modules});
173         $main::kiriwrite_presmodule->endcell();
174         $main::kiriwrite_presmodule->addcell("tablecellheader");
175         $main::kiriwrite_presmodule->endcell();
176         $main::kiriwrite_presmodule->endrow();
178         $main::kiriwrite_presmodule->startrow();
179         $main::kiriwrite_presmodule->addcell("tablecell1");
180         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{presentationmodule});
181         $main::kiriwrite_presmodule->endcell();
182         $main::kiriwrite_presmodule->addcell("tablecell2");
183         $main::kiriwrite_presmodule->addtext($settings_system_presentation);
184         $main::kiriwrite_presmodule->endcell();
185         $main::kiriwrite_presmodule->endrow();
187         $main::kiriwrite_presmodule->startrow();
188         $main::kiriwrite_presmodule->addcell("tablecell1");
189         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{databasemodule});
190         $main::kiriwrite_presmodule->endcell();
191         $main::kiriwrite_presmodule->addcell("tablecell2");
192         $main::kiriwrite_presmodule->addtext($settings_system_database);
193         $main::kiriwrite_presmodule->endcell();
194         $main::kiriwrite_presmodule->endrow();
196         $main::kiriwrite_presmodule->endtable();
198         $main::kiriwrite_presmodule->addlinebreak();
199         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{altersettings});
201         return $main::kiriwrite_presmodule->grab();
205 sub kiriwrite_settings_edit{
206 #################################################################################
207 # kiriwrite_settings_edit: Edits the options.                                   #
208 #                                                                               #
209 # Usage:                                                                        #
210 #                                                                               #
211 # kiriwrite_settings_edit(options);                                             #
212 #                                                                               #
213 # options               Specifies the following options in any order.           #
214 #                                                                               #
215 # DatabaseDirectory     Specifies the new database directory to use.            #
216 # OutputDirectory       Specifies the new output directory to use.              #
217 # ImagesURIPath         Specifies the new URI path for images.                  #
218 # DateTimeFormat        Specifies the new date and time format.                 #
219 # SystemLanguage        Specifies the new language to use for Kiriwrite.        #
220 # PrsentationModule     Specifies the new presentation module to use for        #
221 #                       Kiriwrite.                                              #
222 # DatabaseModule        Specifies the new database module to use for Kiriwrite. #
223 # TextAreaCols          Specifies the width of the text area.                   #
224 # TextAreaRows          Specifies the height of the text area.                  #
225 # PageCount             Specifies the amount of pages that should be viewed.    #
226 # FilterCount           Specifies the amount of filters that should be viewed.  #
227 # TemplateCount         Specifies the amount of templates that should be viewed.#
228 #                                                                               #
229 # Options for server-based database modules.                                    #
230 #                                                                               #
231 # DatabaseServer        Specifies the database server to use.                   #
232 # DaravasePort          Specifies the port the database server is running on.   #
233 # DatabaseProtocol      Specifies the protocol the database server is using.    #
234 # DatabaseSQLDatabase   Specifies the SQL database name to use.                 #
235 # DatabaseUsername      Specifies the database server username.                 #
236 # DatabasePasswordKeep  Keeps the current password in the configuration file.   #
237 # DatabasePassword      Specifies the password for the database server username.#
238 # DatabaseTablePrefix   Specifies the prefix used for tables.                   #
239 #################################################################################
241         # Get the values that have been passed to the subroutine.
243         my ($passedoptions) = @_;
245         # Get the values from the hash.
247         my $settings_dbdirectory                = $passedoptions->{"DatabaseDirectory"};
248         my $settings_outputdirectory            = $passedoptions->{"OutputDirectory"};
249         my $settings_imagesuri                  = $passedoptions->{"ImagesURIPath"};
250         my $settings_datetimeformat             = $passedoptions->{"DateTimeFormat"};
251         my $settings_languagesystem             = $passedoptions->{"SystemLanguage"};
252         my $settings_presmodule                 = $passedoptions->{"PresentationModule"};
253         my $settings_dbmodule                   = $passedoptions->{"DatabaseModule"};
254         my $settings_textareacols               = $passedoptions->{"TextAreaCols"};
255         my $settings_textarearows               = $passedoptions->{"TextAreaRows"};
256         my $settings_pagecount                  = $passedoptions->{"PageCount"};
257         my $settings_filtercount                = $passedoptions->{"FilterCount"};
258         my $settings_templatecount              = $passedoptions->{"TemplateCount"};
260         my $settings_database_server            = $passedoptions->{"DatabaseServer"};
261         my $settings_database_port              = $passedoptions->{"DatabasePort"};
262         my $settings_database_protocol          = $passedoptions->{"DatabaseProtocol"};
263         my $settings_database_sqldatabase       = $passedoptions->{"DatabaseSQLDatabase"};
264         my $settings_database_username          = $passedoptions->{"DatabaseUsername"};
265         my $settings_database_passwordkeep      = $passedoptions->{"DatabasePasswordKeep"};
266         my $settings_database_password          = $passedoptions->{"DatabasePassword"};
267         my $settings_database_tableprefix       = $passedoptions->{"DatabaseTablePrefix"};
269         my $confirm                             = $passedoptions->{"Confirm"};
271         if (!$confirm){
273                 # If the confirm value is blank, then set the confirm
274                 # value to 0.
276                 $confirm = 0;
278         }
280         if ($confirm eq "1"){
282                 # The action to edit the settings has been confirmed.
283                 # Start by checking each variable about to be placed
284                 # in the settings file is valid.
286                 # Deinfe some variables for later.
288                 my @kiriwrite_new_settings;
290                 # Check the length of the directory names.
292                 kiriwrite_variablecheck($settings_dbdirectory, "maxlength", 64, 0);
293                 kiriwrite_variablecheck($settings_outputdirectory, "maxlength", 64, 0);
294                 kiriwrite_variablecheck($settings_imagesuri, "maxlength", 512, 0);
295                 kiriwrite_variablecheck($settings_datetimeformat, "maxlength", 32, 0);
297                 kiriwrite_variablecheck($settings_languagesystem, "language_filename", "", 0);
299                 # Check the module names to see if they're valid.
301                 my $kiriwrite_presmodule_modulename_check       = kiriwrite_variablecheck($settings_presmodule, "module", 0, 1);
302                 my $kiriwrite_dbmodule_modulename_check         = kiriwrite_variablecheck($settings_dbmodule, "module", 0, 1);
304                 if ($kiriwrite_presmodule_modulename_check eq 1){
306                         # The presentation module name is blank, so return
307                         # an error.
309                         kiriwrite_error("presmoduleblank");
311                 }
313                 if ($kiriwrite_presmodule_modulename_check eq 2){
315                         # The presentation module name is invalid, so return
316                         # an error.
318                         kiriwrite_error("presmoduleinvalid");
320                 }
322                 if ($kiriwrite_dbmodule_modulename_check eq 1){
324                         # The database module name is blank, so return
325                         # an error.
327                         kiriwrite_error("dbmoduleblank");
329                 }
331                 if ($kiriwrite_dbmodule_modulename_check eq 2){
333                         # The database module name is invalid, so return
334                         # an error.
336                         kiriwrite_error("dbmoduleinvalid");
338                 }
340                 # Check if the directory names only contain letters and numbers and
341                 # return a specific error if they don't.
343                 my $kiriwrite_dbdirectory_check         = kiriwrite_variablecheck($settings_dbdirectory, "directory", 0, 1);
344                 my $kiriwrite_outputdirectory_check     = kiriwrite_variablecheck($settings_outputdirectory, "directory", 0, 1);
345                 kiriwrite_variablecheck($settings_datetimeformat, "datetime", 0, 0);
347                 my $kiriwrite_textarearows_maxlength            = kiriwrite_variablecheck($settings_textarearows, "maxlength", 3, 1);
348                 my $kiriwrite_textarearows_number               = kiriwrite_variablecheck($settings_textarearows, "numbers", 0, 1);
349                 my $kiriwrite_textareacols_maxlength            = kiriwrite_variablecheck($settings_textareacols, "maxlength", 3, 1);
350                 my $kiriwrite_textareacols_number               = kiriwrite_variablecheck($settings_textareacols, "numbers", 0, 1);
352                 my $kiriwrite_pagecount_maxlength               = kiriwrite_variablecheck($settings_pagecount, "maxlength", 4, 1);
353                 my $kiriwrite_pagecount_number                  = kiriwrite_variablecheck($settings_pagecount, "numbers", 0, 1);
354                 my $kiriwrite_filtercount_maxlength             = kiriwrite_variablecheck($settings_filtercount, "maxlength", 4, 1);
355                 my $kiriwrite_filtercount_number                = kiriwrite_variablecheck($settings_filtercount, "numbers", 0, 1);
356                 my $kiriwrite_templatecount_maxlength           = kiriwrite_variablecheck($settings_templatecount, "maxlength", 4, 1);
357                 my $kiriwrite_templatecount_number              = kiriwrite_variablecheck($settings_templatecount, "numbers", 0, 1);
359                 if ($kiriwrite_dbdirectory_check eq 1){
361                         # The database directory name is blank, so return
362                         # an error.
364                         kiriwrite_error("dbdirectoryblank");
366                 } elsif ($kiriwrite_dbdirectory_check eq 2){
368                         # The database directory name is invalid, so return
369                         # an error.
371                         kiriwrite_error("dbdirectoryinvalid");
373                 }
375                 if ($kiriwrite_outputdirectory_check eq 1){
377                         # The output directory name is blank, so return
378                         # an error.
380                         kiriwrite_error("outputdirectoryblank");
382                 } elsif ($kiriwrite_outputdirectory_check eq 2){
384                         # The output directory name is invalid, so return
385                         # an error.
387                         kiriwrite_error("outputdirectoryinvalid");
389                 }
391                 if (!$settings_textarearows){
393                         # The text area row value is blank so return an
394                         # error.
396                         kiriwrite_error("textarearowblank");
398                 }
400                 if ($kiriwrite_textarearows_maxlength eq 1){
402                         # The text area row value is too long, so return
403                         # an error.
405                         kiriwrite_error("textarearowtoolong");
407                 }
409                 if ($kiriwrite_textarearows_number eq 1){
411                         # The text area row value is invalid, so return
412                         # an error.
414                         kiriwrite_error("textarearowinvalid");
416                 }
418                 if (!$settings_textareacols){
420                         # The text area column value is blank so return
421                         # an error.
423                         kiriwrite_error("textareacolblank");
425                 }
427                 if ($kiriwrite_textareacols_maxlength eq 1){
429                         # The text area column value is too long, so return
430                         # an error.
432                         kiriwrite_error("textareacoltoolong");
434                 }
436                 if ($kiriwrite_textareacols_number eq 1){
438                         # The text area column value is invalid, so return
439                         # an error.
441                         kiriwrite_error("textareacolinvalid");
443                 }
445                 if ($kiriwrite_pagecount_maxlength eq 1){
447                         # The page count value is too long, so return
448                         # an error.
450                         kiriwrite_error("pagecounttoolong");
452                 }
454                 if ($kiriwrite_pagecount_number eq 1){
456                         # The page count value is invalid, so return
457                         # an error.
459                         kiriwrite_error("pagecountinvalid");
461                 }
463                 if ($kiriwrite_filtercount_maxlength eq 1){
465                         # The filter count value is too long, so return
466                         # an error.
468                         kiriwrite_error("filtercounttoolong");
470                 }
472                 if ($kiriwrite_filtercount_number eq 1){
474                         # The filter count value is invalid, so return
475                         # an error.
477                         kiriwrite_error("filtercountinvalid");
479                 }
481                 if ($kiriwrite_templatecount_maxlength eq 1){
483                         # The template count value is too long, so return
484                         # an error.
486                         kiriwrite_error("templatecounttoolong");
488                 }
490                 if ($kiriwrite_templatecount_number eq 1){
492                         # The template count value is invalid, so return
493                         # an error.
495                         kiriwrite_error("templatecountinvalid");
497                 }
499                 # Check if the presentation module with the filename given exists.
501                 my $presmodule_exists = kiriwrite_fileexists("Modules/Presentation/" . $settings_presmodule . ".pm");
503                 if ($presmodule_exists eq 1){
505                         # The presentation module does not exist so return an error.
507                         kiriwrite_error("presmodulemissing");
509                 }
511                 # Check if the database module with the filename given exists.
513                 my $dbmodule_exists = kiriwrite_fileexists("Modules/Database/" . $settings_dbmodule . ".pm");
515                 if ($dbmodule_exists eq 1){
517                         # The database module does not exist so return an error.
519                         kiriwrite_error("dbmodulemissing");
521                 }
523                 # Check if the language filename given exists.
525                 my $languagefile_exists = kiriwrite_fileexists("lang/" . $settings_languagesystem . ".lang");
527                 if ($languagefile_exists eq 1){
529                         # The language filename given does not exist so return an error.
531                         kiriwrite_error("languagefilenamemissing");             
533                 }
535                 # Check the database server options to see if they are valid.
537                 my $kiriwrite_databaseserver_length_check               = kiriwrite_variablecheck($settings_database_server, "maxlength", 128, 1);
538                 my $kiriwrite_databaseserver_lettersnumbers_check       = kiriwrite_variablecheck($settings_database_server, "lettersnumbers", 0, 1);
539                 my $kiriwrite_databaseport_length_check                 = kiriwrite_variablecheck($settings_database_port, "maxlength", 5, 1);
540                 my $kiriwrite_databaseport_numbers_check                = kiriwrite_variablecheck($settings_database_port, "numbers", 0, 1);
541                 my $kiriwrite_databaseport_port_check                   = kiriwrite_variablecheck($settings_database_port, "port", 0, 1);
542                 my $kiriwrite_databaseprotocol_length_check             = kiriwrite_variablecheck($settings_database_protocol, "maxlength", 5, 1);
543                 my $kiriwrite_databaseprotocol_protocol_check           = kiriwrite_variablecheck($settings_database_protocol, "serverprotocol", 0, 1);
544                 my $kiriwrite_databasename_length_check                 = kiriwrite_variablecheck($settings_database_sqldatabase, "maxlength", 32, 1);
545                 my $kiriwrite_databasename_lettersnumbers_check         = kiriwrite_variablecheck($settings_database_sqldatabase, "lettersnumbers", 0, 1);
546                 my $kiriwrite_databaseusername_length_check             = kiriwrite_variablecheck($settings_database_username, "maxlength", 16, 1);
547                 my $kiriwrite_databaseusername_lettersnumbers_check     = kiriwrite_variablecheck($settings_database_username, "lettersnumbers", 0, 1);
548                 my $kiriwrite_databasepassword_length_check             = kiriwrite_variablecheck($settings_database_password, "maxlength", 64, 1);
549                 my $kiriwrite_databasetableprefix_length_check          = kiriwrite_variablecheck($settings_database_tableprefix, "maxlength", 16, 1);
550                 my $kiriwrite_databasetableprefix_lettersnumbers_check  = kiriwrite_variablecheck($settings_database_tableprefix, "lettersnumbers", 0, 1);
552                 if ($kiriwrite_databaseserver_length_check eq 1){
554                         # The length of the database server name is too long so
555                         # return an error.
557                         kiriwrite_error("servernametoolong");
559                 }
561                 if ($kiriwrite_databaseserver_lettersnumbers_check eq 1){
563                         # The database server name contains characters other
564                         # than letters and numbers, so return an error.
566                         kiriwrite_error("servernameinvalid");
568                 }
570                 if ($kiriwrite_databaseport_length_check eq 1){
572                         # The database port number length is too long so return
573                         # an error.
575                         kiriwrite_error("serverportnumbertoolong");
577                 }
579                 if ($kiriwrite_databaseport_numbers_check eq 1){
581                         # The database port number contains characters other
582                         # than numbers so return an error.
584                         kiriwrite_error("serverportnumberinvalidcharacters");
586                 }
588                 if ($kiriwrite_databaseport_port_check eq 1){
590                         # The database port number given is invalid so return
591                         # an error.
593                         kiriwrite_error("serverportnumberinvalid");
595                 }
597                 if ($kiriwrite_databaseprotocol_length_check eq 1){
599                         # The database protocol name given is too long so
600                         # return an error.
602                         kiriwrite_error("serverprotocolnametoolong");
604                 }
606                 if ($kiriwrite_databaseprotocol_protocol_check eq 1){
608                         # The server protcol given is invalid so return
609                         # an error.
611                         kiriwrite_error("serverprotocolinvalid");
613                 }
615                 if ($kiriwrite_databasename_length_check eq 1){
617                         # The SQL database name is too long so return
618                         # an error.
620                         kiriwrite_error("serverdatabasenametoolong");
622                 }
624                 if ($kiriwrite_databasename_lettersnumbers_check eq 1){
626                         # The database name contains invalid characters
627                         # so return an error.
629                         kiriwrite_error("serverdatabasenameinvalid");
631                 }
633                 if ($kiriwrite_databaseusername_length_check eq 1){
635                         # The database username given is too long so
636                         # return an error.
638                         kiriwrite_error("serverdatabaseusernametoolong");
640                 }
642                 if ($kiriwrite_databaseusername_lettersnumbers_check eq 1){
644                         # The database username contains invalid characters
645                         # so return an error.
647                         kiriwrite_error("serverdatabaseusernameinvalid");
649                 }
651                 if ($kiriwrite_databasepassword_length_check eq 1){
653                         # The database password given is too long so return
654                         # an error.
656                         kiriwrite_error("serverdatabasepasswordtoolong");
658                 }
660                 if ($kiriwrite_databasetableprefix_length_check eq 1){
662                         # The database table prefix given is too long so
663                         # return an error.
665                         kiriwrite_error("serverdatabasetableprefixtoolong");
667                 }
669                 if ($kiriwrite_databasetableprefix_lettersnumbers_check eq 1){
671                         # The database table prefix given contains invalid
672                         # characters so return an error.
674                         kiriwrite_error("serverdatabasetableprefixinvalid");
676                 }
678                 # Check if the current password should be kept.
680                 if ($settings_database_passwordkeep eq "on"){
682                         # The current password in the configuration file should be used.
684                         $settings_database_password     = $main::kiriwrite_config{"database_password"};
686                 }
688                 # Write the new settings to the configuration file.
690                 kiriwrite_output_config({ DatabaseDirectory => $settings_dbdirectory, OutputDirectory => $settings_outputdirectory, ImagesURIPath => $settings_imagesuri, DateTimeFormat => $settings_datetimeformat, SystemLanguage => $settings_languagesystem, PresentationModule => $settings_presmodule, 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 });
692                 # Write a confirmation message.
694                 $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{settingsedited}, { Style => "pageheader" });
695                 $main::kiriwrite_presmodule->addlinebreak();
696                 $main::kiriwrite_presmodule->addlinebreak();
697                 $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{settingseditedmessage});
698                 $main::kiriwrite_presmodule->addlinebreak();
699                 $main::kiriwrite_presmodule->addlinebreak();
700                 $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{"script_filename"} . "?mode=settings", { Text => $main::kiriwrite_lang{setting}{returnsettingslist} });
702                 return $main::kiriwrite_presmodule->grab();
704         }
706         # Get the list of languages available.
708         my %language_list;
709         my @language_directory          = "";
710         my $language;
711         my ($language_file, %language_file);
712         my $language_filename           = "";
713         my $language_file_xml           = "";
714         my $language_file_systemname    = "";
715         my $language_file_localname     = "";
716         my $language_file_seek          = 0;
717         my $language_flie_dot           = 0;
718         my $language_file_length        = 0;
719         my $language_file_count         = 0;
720         my $language_file_char          = "";
721         my $language_file_friendly      = "";
722         my $language_config             = $main::kiriwrite_config{"system_language"};
723         my @lang_data;
724         my $kiriwrite_languagefilehandle;
726         tie(%language_list, 'Tie::IxHash');
728         opendir(LANGUAGEDIR, "lang");
729         @language_directory = grep /m*\.lang$/, readdir(LANGUAGEDIR);
730         closedir(LANGUAGEDIR);
732         # Process each language by loading the language file
733         # used for each language and then get the System name and 
734         # the local name of the language.
736         foreach $language_filename (@language_directory){
738                 # Load the language file currently selected.
740                 open($kiriwrite_languagefilehandle, "lang/" . $main::kiriwrite_config{"system_language"} . ".lang");
741                 @lang_data = <$kiriwrite_languagefilehandle>;
742                 %language_file = kiriwrite_processconfig(@lang_data);
743                 close($kiriwrite_languagefilehandle);
745                 # Get the system name and the local name of the language.
747                 $language_file_localname = $language_file{about}{name};
749                 # Check if either the system name or the local name of the language
750                 # is blank and if it is, then don't add the language to the list.
752                 if (!$language_file_localname){
754                         # The system name or the local name is blank so don't add
755                         # the language to the list.
756                 
757                 } else {
759                         # Get the 'friendly' name of the language file name (basically
760                         # remove the .lang part from the filename.
762                         $language_file_length = length($language_filename);
764                         do {
766                                 # Get a character from the language filename and currently
767                                 # set by the seek counter.
769                                 $language_file_char = substr($language_filename, $language_file_seek, 1);
771                                 # Check if the character is a dot and if it is then set the
772                                 # last dot value to the seek counter value.
774                                 if ($language_file_char eq "."){
776                                         # Current chatacter is a dot so set the last dot value 
777                                         # to what is currently the seek counter.
779                                         $language_flie_dot = $language_file_seek;
781                                 } else {
783                                         # Current character is not a dot, so do nothing.
785                                 }
787                                 # Increment the seek counter.
789                                 $language_file_seek++;
791                         } until ($language_file_seek eq $language_file_length);
793                         # Reset the seek counter.
795                         $language_file_seek = 0;
797                         # Process the file name again and this time process the file
798                         # name until it reaches the last dot found.
800                         do {
802                                 # Get the character the seek counter is currently set at.
804                                 $language_file_char = substr($language_filename, $language_file_seek, 1);
806                                 # Append the character to the friendly file name.
808                                 $language_file_friendly = $language_file_friendly . $language_file_char;
810                                 # Increment the seek counter.
811         
812                                 $language_file_seek++;
814                         } until ($language_file_seek eq $language_flie_dot);
816                         # Append the language to the available languages list.
818                         $language_list{$language_file_count}{Filename} = $language_file_friendly;
819                         $language_list{$language_file_count}{Name} = $language_file_localname;
820                         $language_file_count++;
822                         # Reset certain counters and values before continuing.
824                         $language_file_seek     = 0;
825                         $language_flie_dot      = 0;
826                         $language_file_length   = 0;
827                         $language_file_char     = "";
828                         $language_file_friendly = "";
830                 }
832                 undef $language_file;
834         }
836         # Get the list of presentation modules available.
838         my %presmodule_list;
839         my @presmodule_directory;
840         my $presmodule;
841         my $presmodule_file             = "";
842         my $presmodule_char             = "";
843         my $presmodule_dot              = 0;
844         my $presmodule_firstdot         = 0;
845         my $presmodule_firstdotfound    = "";
846         my $presmodule_seek             = 0;
847         my $presmodule_length           = 0;
848         my $presmodule_count            = 0;
849         my $presmodule_friendly         = "";
850         my $presmodule_selectlist       = "";
851         my $presmodule_config           = $main::kiriwrite_config{"system_presmodule"};
853         # Open and get the list of presentation modules (perl modules) by filtering
854         # out the 
856         opendir(OUTPUTSYSTEMDIR, "Modules/Presentation");
857         @presmodule_directory = grep /m*\.pm$/, readdir(OUTPUTSYSTEMDIR);
858         closedir(OUTPUTSYSTEMDIR);
860         # Process each presentation module and add them to the list of available
861         # presentation modules.
863         foreach $presmodule_file (@presmodule_directory){
865                 # Get the length of the presentation module (perl module) filename.
867                 $presmodule_length = length($presmodule_file);
869                 # Get the friendly name of the Perl module (by getting rid of the
870                 # .pm part of the filename).
872                 do {
874                         $presmodule_char = substr($presmodule_file, $presmodule_seek, 1);
876                         # Check if the current character is a dot and if it is then
877                         # set the last dot found number to the current seek number.
879                         if ($presmodule_char eq "."){
881                                 # Put the seek value as the last dot found number.
883                                 $presmodule_dot = $presmodule_seek;
885                         }
887                         # Increment the seek counter.
889                         $presmodule_seek++;
891                 } until ($presmodule_seek eq $presmodule_length);
893                 # Reset the seek counter as it is going to be used again.
895                 $presmodule_seek = 0;
897                 # Get the friendly name of the Perl module by the processing the file
898                 # name to the last dot the previous 'do' tried to find.
900                 do {
902                         # Get the character the seek counter is currently set at.
904                         $presmodule_char = substr($presmodule_file, $presmodule_seek, 1);
906                         # Append the character to the friendly name of the presentation module.
908                         $presmodule_friendly = $presmodule_friendly . $presmodule_char;
910                         # Increment the seek counter.
912                         $presmodule_seek++;
914                 } until ($presmodule_seek eq $presmodule_dot);
916                 # Append the option to tbe list of available presentation modules.
918                 $presmodule_list{$presmodule_count}{Filename} = $presmodule_friendly;
920                 # Reset the following values.
922                 $presmodule_seek        = 0;
923                 $presmodule_length      = 0;
924                 $presmodule_char        = "";
925                 $presmodule_friendly    = "";
926                 $presmodule_count++;
928         }
930         # Get the list of database modules available.
932         my %dbmodule_list;
933         my @dbmodule_directory;
934         my $dbmodule;
935         my $dbmodule_file               = "";
936         my $dbmodule_char               = "";
937         my $dbmodule_dot                = 0;
938         my $dbmodule_firstdot           = 0;
939         my $dbmodule_firstdotfound      = "";
940         my $dbmodule_seek               = 0;
941         my $dbmodule_length             = 0;
942         my $dbmodule_count              = 0;
943         my $dbmodule_friendly           = "";
944         my $dbmodule_selectlist         = "";
945         my $dbmodule_config             = $main::kiriwrite_config{"system_dbmodule"};
947         # Open and get the list of presentation modules (perl modules) by filtering
948         # out the 
950         opendir(DATABASEDIR, "Modules/Database");
951         @dbmodule_directory = grep /m*\.pm$/, readdir(DATABASEDIR);
952         closedir(DATABASEDIR);
954         # Process each presentation module and add them to the list of available
955         # presentation modules.
957         foreach $dbmodule_file (@dbmodule_directory){
959                 # Get the length of the database module (perl module) filename.
961                 $dbmodule_length = length($dbmodule_file);
963                 # Get the friendly name of the Perl module (by getting rid of the
964                 # .pm part of the filename).
966                 do {
968                         $dbmodule_char = substr($dbmodule_file, $dbmodule_seek, 1);
970                         # Check if the current character is a dot and if it is then
971                         # set the last dot found number to the current seek number.
973                         if ($dbmodule_char eq "."){
975                                 # Put the seek value as the last dot found number.
977                                 $dbmodule_dot = $dbmodule_seek;
979                         }
981                         # Increment the seek counter.
983                         $dbmodule_seek++;
985                 } until ($dbmodule_seek eq $dbmodule_length);
987                 # Reset the seek counter as it is going to be used again.
989                 $dbmodule_seek = 0;
991                 # Get the friendly name of the Perl module by the processing the file
992                 # name to the last dot the previous 'do' tried to find.
994                 do {
996                         # Get the character the seek counter is currently set at.
998                         $dbmodule_char = substr($dbmodule_file, $dbmodule_seek, 1);
1000                         # Append the character to the friendly name of the presentation module.
1002                         $dbmodule_friendly = $dbmodule_friendly . $dbmodule_char;
1004                         # Increment the seek counter.
1006                         $dbmodule_seek++;
1008                 } until ($dbmodule_seek eq $dbmodule_dot);
1010                 # Append the option to tbe list of available database modules.
1012                 $dbmodule_list{$dbmodule_count}{Filename} = $dbmodule_friendly;
1014                 # Reset the following values.
1016                 $dbmodule_seek  = 0;
1017                 $dbmodule_length        = 0;
1018                 $dbmodule_char          = "";
1019                 $dbmodule_friendly      = "";
1020                 $dbmodule_count++;
1022         }
1024         # Get the directory settings.
1026         my $directory_settings_database         = $main::kiriwrite_config{"directory_data_db"};
1027         my $directory_settings_output           = $main::kiriwrite_config{"directory_data_output"};
1028         my $directory_settings_imagesuri        = $main::kiriwrite_config{"directory_noncgi_images"};
1029         my $datetime_setting                    = $main::kiriwrite_config{"system_datetime"};
1031         my $display_textareacols                = $main::kiriwrite_config{"display_textareacols"};
1032         my $display_textarearows                = $main::kiriwrite_config{"display_textarearows"};
1033         my $display_pagecount                   = $main::kiriwrite_config{"display_pagecount"};
1034         my $display_templatecount               = $main::kiriwrite_config{"display_templatecount"};
1035         my $display_filtercount                 = $main::kiriwrite_config{"display_filtercount"};
1037         my $database_server                     = $main::kiriwrite_config{"database_server"};
1038         my $database_port                       = $main::kiriwrite_config{"database_port"};
1039         my $database_protocol                   = $main::kiriwrite_config{"database_protocol"};
1040         my $database_sqldatabase                = $main::kiriwrite_config{"database_sqldatabase"};
1041         my $database_username                   = $main::kiriwrite_config{"database_username"};
1042         my $database_passwordhash               = $main::kiriwrite_config{"database_passwordhash"};
1043         my $database_password                   = $main::kiriwrite_config{"database_password"};
1044         my $database_prefix                     = $main::kiriwrite_config{"database_tableprefix"};
1046         # Print out a form for editing the settings.
1048         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{editsettings}, { Style => "pageheader" });
1049         $main::kiriwrite_presmodule->addlinebreak();
1050         $main::kiriwrite_presmodule->addlinebreak();
1051         $main::kiriwrite_presmodule->addboldtext($main::kiriwrite_lang{setting}{warning});
1052         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{warningmessage});
1053         $main::kiriwrite_presmodule->addlinebreak();
1054         $main::kiriwrite_presmodule->addlinebreak();
1056         $main::kiriwrite_presmodule->startform($main::kiriwrite_env{"script_filename"}, "POST");
1057         $main::kiriwrite_presmodule->startbox();
1058         $main::kiriwrite_presmodule->addhiddendata("mode", "settings");
1059         $main::kiriwrite_presmodule->addhiddendata("action", "edit");
1060         $main::kiriwrite_presmodule->addhiddendata("confirm", 1);
1062         $main::kiriwrite_presmodule->starttable("", { CellPadding => 5, CellSpacing => 0 });
1064         $main::kiriwrite_presmodule->startheader();
1065         $main::kiriwrite_presmodule->addheader($main::kiriwrite_lang{common}{setting}, { Style => "tablecellheader" });
1066         $main::kiriwrite_presmodule->addheader($main::kiriwrite_lang{common}{value}, { Style => "tablecellheader" });
1067         $main::kiriwrite_presmodule->endheader();
1069         $main::kiriwrite_presmodule->startrow();
1070         $main::kiriwrite_presmodule->addcell("tablecellheader");
1071         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{directories});
1072         $main::kiriwrite_presmodule->endcell();
1073         $main::kiriwrite_presmodule->addcell("tablecellheader");
1074         $main::kiriwrite_presmodule->endcell();
1075         $main::kiriwrite_presmodule->endrow();
1077         $main::kiriwrite_presmodule->startrow();
1078         $main::kiriwrite_presmodule->addcell("tablecell1");
1079         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{databasedirectory});
1080         $main::kiriwrite_presmodule->endcell();
1081         $main::kiriwrite_presmodule->addcell("tablecell2");
1082         $main::kiriwrite_presmodule->addinputbox("databasedir", { Size => 32, MaxLength => 64, Value => $directory_settings_database });
1083         $main::kiriwrite_presmodule->endcell();
1084         $main::kiriwrite_presmodule->endrow();
1086         $main::kiriwrite_presmodule->startrow();
1087         $main::kiriwrite_presmodule->addcell("tablecell1");
1088         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{outputdirectory});
1089         $main::kiriwrite_presmodule->endcell();
1090         $main::kiriwrite_presmodule->addcell("tablecell2");
1091         $main::kiriwrite_presmodule->addinputbox("outputdir", { Size => 32, MaxLength => 64, Value => $directory_settings_output });
1092         $main::kiriwrite_presmodule->endcell();
1093         $main::kiriwrite_presmodule->endrow();
1095         $main::kiriwrite_presmodule->startrow();
1096         $main::kiriwrite_presmodule->addcell("tablecell1");
1097         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{imagesuripath});
1098         $main::kiriwrite_presmodule->endcell();
1099         $main::kiriwrite_presmodule->addcell("tablecell2");
1100         $main::kiriwrite_presmodule->addinputbox("imagesuripath", { Size => 32, MaxLength => 512, Value => $directory_settings_imagesuri });
1101         $main::kiriwrite_presmodule->endcell();
1102         $main::kiriwrite_presmodule->endrow();
1104         $main::kiriwrite_presmodule->startrow();
1105         $main::kiriwrite_presmodule->addcell("tablecellheader");
1106         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{display});
1107         $main::kiriwrite_presmodule->endcell();
1108         $main::kiriwrite_presmodule->addcell("tablecellheader");
1109         $main::kiriwrite_presmodule->endcell();
1110         $main::kiriwrite_presmodule->endrow();
1112         $main::kiriwrite_presmodule->startrow();
1113         $main::kiriwrite_presmodule->addcell("tablecell1");
1114         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{textareacols});
1115         $main::kiriwrite_presmodule->endcell();
1116         $main::kiriwrite_presmodule->addcell("tablecell2");
1117         $main::kiriwrite_presmodule->addinputbox("textareacols", { Size => 3, MaxLength => 3, Value => $display_textareacols });
1118         $main::kiriwrite_presmodule->endrow();
1120         $main::kiriwrite_presmodule->startrow();
1121         $main::kiriwrite_presmodule->addcell("tablecell1");
1122         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{textarearows});
1123         $main::kiriwrite_presmodule->endcell();
1124         $main::kiriwrite_presmodule->addcell("tablecell2");
1125         $main::kiriwrite_presmodule->addinputbox("textarearows", { Size => 3, MaxLength => 3, Value => $display_textarearows });
1126         $main::kiriwrite_presmodule->endrow();
1128         $main::kiriwrite_presmodule->startrow();
1129         $main::kiriwrite_presmodule->addcell("tablecell1");
1130         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{pagecount});
1131         $main::kiriwrite_presmodule->endcell();
1132         $main::kiriwrite_presmodule->addcell("tablecell2");
1133         $main::kiriwrite_presmodule->addinputbox("pagecount", { Size => 4, MaxLength => 4, Value => $display_pagecount });
1134         $main::kiriwrite_presmodule->endrow();
1136         $main::kiriwrite_presmodule->startrow();
1137         $main::kiriwrite_presmodule->addcell("tablecell1");
1138         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{filtercount});
1139         $main::kiriwrite_presmodule->endcell();
1140         $main::kiriwrite_presmodule->addcell("tablecell2");
1141         $main::kiriwrite_presmodule->addinputbox("filtercount", { Size => 4, MaxLength => 4, Value => $display_filtercount });
1142         $main::kiriwrite_presmodule->endrow();
1144         $main::kiriwrite_presmodule->startrow();
1145         $main::kiriwrite_presmodule->addcell("tablecell1");
1146         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{templatecount});
1147         $main::kiriwrite_presmodule->endcell();
1148         $main::kiriwrite_presmodule->addcell("tablecell2");
1149         $main::kiriwrite_presmodule->addinputbox("templatecount", { Size => 4, MaxLength => 4, Value => $display_templatecount });
1150         $main::kiriwrite_presmodule->endrow();
1152         $main::kiriwrite_presmodule->startrow();
1153         $main::kiriwrite_presmodule->addcell("tablecellheader");
1154         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{date});
1155         $main::kiriwrite_presmodule->endcell();
1156         $main::kiriwrite_presmodule->addcell("tablecellheader");
1157         $main::kiriwrite_presmodule->endcell();
1158         $main::kiriwrite_presmodule->endrow();
1160         $main::kiriwrite_presmodule->startrow();
1161         $main::kiriwrite_presmodule->addcell("tablecell1");
1162         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{dateformat});
1163         $main::kiriwrite_presmodule->endcell();
1164         $main::kiriwrite_presmodule->addcell("tablecell2");
1165         $main::kiriwrite_presmodule->addinputbox("datetime", { Size => 32, MaxLength => 64, Value => $datetime_setting });
1166         $main::kiriwrite_presmodule->addlinebreak();
1167         $main::kiriwrite_presmodule->addlinebreak();
1168         $main::kiriwrite_presmodule->startbox("datalist");
1170         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{singleday});
1171         $main::kiriwrite_presmodule->addlinebreak();
1172         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{doubleday});
1173         $main::kiriwrite_presmodule->addlinebreak();
1174         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{singlemonth});
1175         $main::kiriwrite_presmodule->addlinebreak();
1176         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{doublemonth});
1177         $main::kiriwrite_presmodule->addlinebreak();
1178         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{singleyear});
1179         $main::kiriwrite_presmodule->addlinebreak();
1180         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{doubleyear});
1181         $main::kiriwrite_presmodule->addlinebreak();
1182         $main::kiriwrite_presmodule->addlinebreak();
1183         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{singlehour});
1184         $main::kiriwrite_presmodule->addlinebreak();
1185         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{doublehour});
1186         $main::kiriwrite_presmodule->addlinebreak();
1187         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{singleminute});
1188         $main::kiriwrite_presmodule->addlinebreak();
1189         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{doubleminute});
1190         $main::kiriwrite_presmodule->addlinebreak();
1191         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{singlesecond});
1192         $main::kiriwrite_presmodule->addlinebreak();
1193         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{doublesecond});
1194         $main::kiriwrite_presmodule->addlinebreak();
1195         $main::kiriwrite_presmodule->addlinebreak();
1196         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{othercharacters});
1197         $main::kiriwrite_presmodule->endbox();
1198         $main::kiriwrite_presmodule->endcell();
1199         $main::kiriwrite_presmodule->endrow();
1201         $main::kiriwrite_presmodule->startrow();
1202         $main::kiriwrite_presmodule->addcell("tablecellheader");
1203         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{language});
1204         $main::kiriwrite_presmodule->endcell();
1205         $main::kiriwrite_presmodule->addcell("tablecellheader");
1206         $main::kiriwrite_presmodule->endcell();
1207         $main::kiriwrite_presmodule->endrow();
1209         $main::kiriwrite_presmodule->startrow();
1210         $main::kiriwrite_presmodule->addcell("tablecell1");
1211         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{systemlanguage});
1212         $main::kiriwrite_presmodule->endcell();
1213         $main::kiriwrite_presmodule->addcell("tablecell2");
1215         $main::kiriwrite_presmodule->addselectbox("language");
1217         # Process the list of available languages.
1219         foreach $language (keys %language_list){
1221                 # Check if the language filename matches the filename in the configuration
1222                 # file.
1224                 if ($language_list{$language}{Filename} eq $language_config){
1226                         $main::kiriwrite_presmodule->addoption($language_list{$language}{Name}, { Value => $language_list{$language}{Filename} , Selected => 1 });
1228                 } else {
1230                         $main::kiriwrite_presmodule->addoption($language_list{$language}{Name}, { Value => $language_list{$language}{Filename} });
1232                 }
1234         }
1236         $main::kiriwrite_presmodule->endselectbox();
1238         $main::kiriwrite_presmodule->startrow();
1239         $main::kiriwrite_presmodule->addcell("tablecellheader");
1240         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{modules});
1241         $main::kiriwrite_presmodule->endcell();
1242         $main::kiriwrite_presmodule->addcell("tablecellheader");
1243         $main::kiriwrite_presmodule->endcell();
1244         $main::kiriwrite_presmodule->endrow();
1246         $main::kiriwrite_presmodule->startrow();
1247         $main::kiriwrite_presmodule->addcell("tablecell1");
1248         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{presentationmodule});
1249         $main::kiriwrite_presmodule->endcell();
1250         $main::kiriwrite_presmodule->addcell("tablecell2");
1252         $main::kiriwrite_presmodule->addselectbox("presmodule");
1254         # Process the list of available presentation modules.
1256         foreach $presmodule (keys %presmodule_list){
1258                 # Check if the presentation module fileanme matches the filename in the 
1259                 # configuration file.
1261                 if ($presmodule_list{$presmodule}{Filename} eq $presmodule_config){
1263                         $main::kiriwrite_presmodule->addoption($presmodule_list{$presmodule}{Filename}, { Value => $presmodule_list{$presmodule}{Filename} , Selected => 1 });
1265                 } else {
1267                         $main::kiriwrite_presmodule->addoption($presmodule_list{$presmodule}{Filename}, { Value => $presmodule_list{$presmodule}{Filename} });
1269                 }
1271         }
1273         $main::kiriwrite_presmodule->endselectbox();
1275         $main::kiriwrite_presmodule->endcell();
1276         $main::kiriwrite_presmodule->endrow();
1278         $main::kiriwrite_presmodule->startrow();
1279         $main::kiriwrite_presmodule->addcell("tablecell1");
1280         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{databasemodule});
1281         $main::kiriwrite_presmodule->endcell();
1282         $main::kiriwrite_presmodule->addcell("tablecell2");
1284         # Process the list of available database modules.
1286         $main::kiriwrite_presmodule->addselectbox("dbmodule");
1288         foreach $dbmodule (keys %dbmodule_list){
1290                 # Check if the database module fileanme matches the filename in the 
1291                 # configuration file.
1293                 if ($dbmodule_list{$dbmodule}{Filename} eq $dbmodule_config){
1295                         $main::kiriwrite_presmodule->addoption($dbmodule_list{$dbmodule}{Filename}, { Value => $dbmodule_list{$dbmodule}{Filename} , Selected => 1 });
1297                 } else {
1299                         $main::kiriwrite_presmodule->addoption($dbmodule_list{$dbmodule}{Filename}, { Value => $dbmodule_list{$dbmodule}{Filename} });
1301                 }
1304         }
1306         $main::kiriwrite_presmodule->endselectbox();
1308         $main::kiriwrite_presmodule->endcell();
1309         $main::kiriwrite_presmodule->endrow();
1311         $main::kiriwrite_presmodule->startrow();
1312         $main::kiriwrite_presmodule->addcell("tablecell1");
1313         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{databaseserver});
1314         $main::kiriwrite_presmodule->endcell();
1315         $main::kiriwrite_presmodule->addcell("tablecell2");
1316         $main::kiriwrite_presmodule->addinputbox("database_server", { Size => 32, MaxLength => 128, Value => $database_server });
1317         $main::kiriwrite_presmodule->endcell();
1318         $main::kiriwrite_presmodule->endrow();
1320         $main::kiriwrite_presmodule->startrow();
1321         $main::kiriwrite_presmodule->addcell("tablecell1");
1322         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{databaseport});
1323         $main::kiriwrite_presmodule->endcell();
1324         $main::kiriwrite_presmodule->addcell("tablecell2");
1325         $main::kiriwrite_presmodule->addinputbox("database_port", { Size => 5, MaxLength => 5, Value => $database_port });
1326         $main::kiriwrite_presmodule->endcell();
1327         $main::kiriwrite_presmodule->endrow();
1329         $main::kiriwrite_presmodule->startrow();
1330         $main::kiriwrite_presmodule->addcell("tablecell1");
1331         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{databaseprotocol});
1332         $main::kiriwrite_presmodule->endcell();
1333         $main::kiriwrite_presmodule->addcell("tablecell2");
1335         # Check if TCP is being used.
1337         $main::kiriwrite_presmodule->addselectbox("database_protocol");
1339         if ($database_protocol eq "tcp"){
1341                 # The TCP protocol is selected so have the TCP option selected.
1343                 $main::kiriwrite_presmodule->addoption("TCP", { Value => "tcp", Selected => 1});
1345         } else {
1347                 # The TCP protocol is not selected.
1349                 $main::kiriwrite_presmodule->addoption("TCP", { Value => "tcp"});
1351         } 
1353         # Check if UDP is being used.
1355         if ($database_protocol eq "udp"){
1357                 # The UDP protocol is selected so have the UDP option selected.
1359                 $main::kiriwrite_presmodule->addoption("UDP", { Value => "udp", Selected => 1});
1361         } else {
1363                 # The UDP protocol is not selected.
1365                 $main::kiriwrite_presmodule->addoption("UDP", { Value => "udp"});
1367         }
1369         $main::kiriwrite_presmodule->endselectbox();
1371         $main::kiriwrite_presmodule->endcell();
1372         $main::kiriwrite_presmodule->endrow();
1374         $main::kiriwrite_presmodule->startrow();
1375         $main::kiriwrite_presmodule->addcell("tablecell1");
1376         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{databasename});
1377         $main::kiriwrite_presmodule->endcell();
1378         $main::kiriwrite_presmodule->addcell("tablecell2");
1379         $main::kiriwrite_presmodule->addinputbox("database_sqldatabase", { Size => 32, MaxLength => 32, Value => $database_sqldatabase });
1380         $main::kiriwrite_presmodule->endcell();
1381         $main::kiriwrite_presmodule->endrow();
1383         $main::kiriwrite_presmodule->startrow();
1384         $main::kiriwrite_presmodule->addcell("tablecell1");
1385         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{databaseusername});
1386         $main::kiriwrite_presmodule->endcell();
1387         $main::kiriwrite_presmodule->addcell("tablecell2");
1388         $main::kiriwrite_presmodule->addinputbox("database_username", { Size => 16, MaxLength => 16, Value => $database_username });
1389         $main::kiriwrite_presmodule->endcell();
1390         $main::kiriwrite_presmodule->endrow();
1392         $main::kiriwrite_presmodule->startrow();
1393         $main::kiriwrite_presmodule->addcell("tablecell1");
1394         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{databasepassword});
1395         $main::kiriwrite_presmodule->endcell();
1396         $main::kiriwrite_presmodule->addcell("tablecell2");
1397         $main::kiriwrite_presmodule->addinputbox("database_password", { Size => 16, MaxLength => 64, Password => 1 });
1398         $main::kiriwrite_presmodule->addtext(" ");
1399         $main::kiriwrite_presmodule->addcheckbox("database_password_keep", { OptionDescription => "Keep the current password", Checked => 1 });
1400         $main::kiriwrite_presmodule->endcell();
1401         $main::kiriwrite_presmodule->endrow();
1403         $main::kiriwrite_presmodule->startrow();
1404         $main::kiriwrite_presmodule->addcell("tablecell1");
1405         $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{tableprefix});
1406         $main::kiriwrite_presmodule->endcell();
1407         $main::kiriwrite_presmodule->addcell("tablecell2");
1408         $main::kiriwrite_presmodule->addinputbox("database_tableprefix", { Size => 16, MaxLength => 16, Value => $database_prefix });
1409         $main::kiriwrite_presmodule->endcell();
1410         $main::kiriwrite_presmodule->endrow();
1412         $main::kiriwrite_presmodule->endtable();
1414         $main::kiriwrite_presmodule->addlinebreak();
1415         $main::kiriwrite_presmodule->addsubmit($main::kiriwrite_lang{setting}{changesettingsbutton});
1416         $main::kiriwrite_presmodule->addtext(" | ");
1417         $main::kiriwrite_presmodule->addreset($main::kiriwrite_lang{common}{restorecurrent});
1418         $main::kiriwrite_presmodule->addtext(" | ");
1419         $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{"script_filename"} . "?mode=settings", { Text => $main::kiriwrite_lang{setting}->{returnsettingslist} });
1420         $main::kiriwrite_presmodule->endbox();
1421         $main::kiriwrite_presmodule->endform();
1423         return $main::kiriwrite_presmodule->grab();
1425
1427 sub kiriwrite_output_config{
1428 #################################################################################
1429 # kiriwrite_output_config: Outputs the configuration file.                      #
1430 #                                                                               #
1431 # Usage:                                                                        #
1432 #                                                                               #
1433 # kiriwrite_output_config(settings);                                            #
1434 #                                                                               #
1435 # settings      Specifies the following settings in any order.                  #
1436 #                                                                               #
1437 # Settings for Kiriwrite configuration files:                                   #
1438 #                                                                               #
1439 # DatabaseDirectory     Specifies the new database directory to use.            #
1440 # OutputDirectory       Specifies the new output directory to use.              #
1441 # ImagesURIPath         Specifies the new URI path for images.                  #
1442 # DateTimeFormat        Specifies the new date and time format.                 #
1443 # SystemLanguage        Specifies the new language to use for Kiriwrite.        #
1444 # PrsentationModule     Specifies the new presentation module to use for        #
1445 #                       Kiriwrite.                                              #
1446 # TextAreaCols          Specifies the width of the text area.                   #
1447 # TextAreaRows          Specifies the height of the text area.                  #
1448 # PageCount             Specifies the amount of pages to view.                  #
1449 # FilterCount           Specifies the amount of filters to view.                #
1450 # TemplateCount         Specifies the amount of templates to view.              #
1451 # DatabaseModule        Specifies the new database module to use for Kiriwrite. #
1452 # DatabaseServer        Specifies the database server to use.                   #
1453 # DaravasePort          Specifies the port the database server is running on.   #
1454 # DatabaseProtocol      Specifies the protocol the database server is using.    #
1455 # DatabaseSQLDatabase   Specifies the SQL database name to use.                 #
1456 # DatabaseUsername      Specifies the database server username.                 #
1457 # DatabasePassword      Specifies the password for the database server username.#
1458 # DatabaseTablePrefix   Specifies the table prefix to use.                      #
1459 #################################################################################
1461         # Get the variables passed from the subroutine.
1463         my ($passedsettings)    = @_;
1465         # Get the data from the hash.
1467         my $settings_databasedir                = $passedsettings->{"DatabaseDirectory"};
1468         my $settings_outputdir                  = $passedsettings->{"OutputDirectory"};
1469         my $settings_imagesuri                  = $passedsettings->{"ImagesURIPath"};
1470         my $settings_datetime                   = $passedsettings->{"DateTimeFormat"};
1471         my $settings_systemlanguage             = $passedsettings->{"SystemLanguage"};
1472         my $settings_presmodule                 = $passedsettings->{"PresentationModule"};
1473         my $settings_dbmodule                   = $passedsettings->{"DatabaseModule"};
1475         my $settings_textareacols               = $passedsettings->{"TextAreaCols"};
1476         my $settings_textarearows               = $passedsettings->{"TextAreaRows"};
1477         my $settings_pagecount                  = $passedsettings->{"PageCount"};
1478         my $settings_filtercount                = $passedsettings->{"FilterCount"};
1479         my $settings_templatecount              = $passedsettings->{"TemplateCount"};
1481         my $settings_database_server            = $passedsettings->{"DatabaseServer"};
1482         my $settings_database_port              = $passedsettings->{"DatabasePort"};
1483         my $settings_database_protocol          = $passedsettings->{"DatabaseProtocol"};
1484         my $settings_database_sqldatabase       = $passedsettings->{"DatabaseSQLDatabase"};
1485         my $settings_database_username          = $passedsettings->{"DatabaseUsername"};
1486         my $settings_database_password          = $passedsettings->{"DatabasePassword"};
1487         my $settings_database_tableprefix       = $passedsettings->{"DatabaseTablePrefix"};
1489         # Convert the password to make sure it can be read properly.
1491         if ($settings_database_password){
1493                 $settings_database_password =~ s/\0//g;
1494                 $settings_database_password =~ s/</&lt;/g;
1495                 $settings_database_password =~ s/>/&gt;/g;
1497         }
1499         # Convert the less than and greater than characters are there and
1500         # convert them.
1502         if ($settings_imagesuri){
1504                 $settings_imagesuri =~ s/</&lt;/g;
1505                 $settings_imagesuri =~ s/>/&gt;/g;
1506                 $settings_imagesuri =~ s/\r//g;
1507                 $settings_imagesuri =~ s/\n//g;
1509         }
1511         # Check if the database password value is undefined and if it is then
1512         # set it blank.
1514         if (!$settings_database_password){
1516                 $settings_database_password = "";
1518         }
1520         # Create the Kiriwrite configuration file layout.
1522         my $configdata = "[config]\r\n";
1524         $configdata = $configdata . "directory_data_db = " . $settings_databasedir . "\r\n";
1525         $configdata = $configdata . "directory_data_output = "  . $settings_outputdir . "\r\n";
1526         $configdata = $configdata . "directory_noncgi_images = "  . $settings_imagesuri . "\r\n\r\n";
1528         $configdata = $configdata . "system_language = "  . $settings_systemlanguage . "\r\n";
1529         $configdata = $configdata . "system_presmodule = "  . $settings_presmodule . "\r\n";
1530         $configdata = $configdata . "system_dbmodule = "  . $settings_dbmodule . "\r\n";
1531         $configdata = $configdata . "system_datetime = "  . $settings_datetime . "\r\n\r\n";
1533         $configdata = $configdata . "display_textareacols = "  . $settings_textareacols . "\r\n";
1534         $configdata = $configdata . "display_textarearows = "  . $settings_textarearows . "\r\n";
1535         $configdata = $configdata . "display_pagecount = " . $settings_pagecount . "\r\n";
1536         $configdata = $configdata . "display_filtercount = " . $settings_filtercount . "\r\n";
1537         $configdata = $configdata . "display_templatecount = " . $settings_templatecount . "\r\n\r\n";
1539         $configdata = $configdata . "database_server = "  . $settings_database_server . "\r\n";
1540         $configdata = $configdata . "database_port = "  . $settings_database_port . "\r\n";
1541         $configdata = $configdata . "database_protocol = "  . $settings_database_protocol . "\r\n";
1542         $configdata = $configdata . "database_sqldatabase = "  . $settings_database_sqldatabase . "\r\n";
1543         $configdata = $configdata . "database_username = "  . $settings_database_username . "\r\n";
1544         $configdata = $configdata . "database_password = "  . $settings_database_password . "\r\n";
1545         $configdata = $configdata . "database_tableprefix = "  . $settings_database_tableprefix . "\r\n\r\n";
1547         # Open the Kiriwrite configuration file and write the new settings to the
1548         # configuration file.
1550         open(my $filehandle_config, "> ", "kiriwrite.cfg");
1551         print $filehandle_config $configdata;
1552         close($filehandle_config);
1554         return;
1556 };
1558 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