X-Git-Url: http://Server1/repobrowser/?p=kiriwrite%2F.git;a=blobdiff_plain;f=cgi-files%2Fkiriwrite.cgi;h=e351c2758aab592206b37bb7a5407826fe89c6a3;hp=1eb2657116d4cc0ea52c8752054274df0b1bcc7a;hb=820f8c72b5d3985b5c06b0ffa7def526064ee2d7;hpb=fb02a3c6cb60580a1dce80522a06168919460207 diff --git a/cgi-files/kiriwrite.cgi b/cgi-files/kiriwrite.cgi index 1eb2657..e351c27 100755 --- a/cgi-files/kiriwrite.cgi +++ b/cgi-files/kiriwrite.cgi @@ -1,12 +1,13 @@ #!/usr/bin/perl -Tw ################################################################################# -# Kiriwrite (kiriwrite.cgi) # +# Kiriwrite (kiriwrite.pl/kiriwrite.cgi) # # Main program script # # # -# Version: 0.1.0 # +# Version: 0.5.0 # +# mod_perl 2.x compatabile version # # # -# Copyright (C) 2005-2007 Steve Brokenshire # +# Copyright (C) 2005-2008 Steve Brokenshire # # # # This program is free software; you can redistribute it and/or modify it under # # the terms of the GNU General Public License as published by the Free # @@ -21,2289 +22,1096 @@ # Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # ################################################################################# -use strict; # Throw errors if there's something wrong. -use warnings; # Write warnings to the HTTP Server Log file. +use strict; +use warnings; use utf8; use CGI::Lite; use Tie::IxHash; +binmode STDOUT, ':utf8'; + # This is commented out because it uses a fair bit of CPU usage. #use CGI::Carp('fatalsToBrowser'); # Output errors to the browser. # Declare global variables for Kiriwrite settings and languages. -our ($kiriwrite_config, %kiriwrite_config, %kiriwrite_lang, $kiriwrite_lang, $kiriwrite_version, %kiriwrite_version, $kiriwrite_env, %kiriwrite_env, $kiriwrite_presmodule, $kiriwrite_dbmodule, $form_data); +our ($kiriwrite_config, %kiriwrite_config, %kiriwrite_lang, $kiriwrite_lang, $kiriwrite_version, %kiriwrite_version, $kiriwrite_env, %kiriwrite_env, $kiriwrite_presmodule, $kiriwrite_dbmodule, $kiriwrite_script_name, $kiriwrite_env_path); +our ($form_data, %form_data); + +# If you are using mod_perl please change these settings to the correct +# directory where this script is being run from. + +use lib '.'; +chdir('.'); + +# Load the common functions module. + +use Modules::System::Common; # Setup the version information for Kiriwrite. %kiriwrite_version = ( "major" => 0, - "minor" => 2, + "minor" => 5, "revision" => 0 ); -sub BEGIN{ -################################################################################# -# BEGIN: Get the enviroment stuff # -################################################################################# - - # Get the script filename. - - my $env_script_name = $ENV{'SCRIPT_NAME'}; - - # Process the script filename until there is only the - # filename itself. - - my $env_script_name_length = length($env_script_name); - my $filename_seek = 0; - my $filename_char = ""; - my $filename_last = 0; - - do { - $filename_char = substr($env_script_name, $filename_seek, 1); - if ($filename_char eq "/"){ - $filename_last = $filename_seek + 1; - } - $filename_seek++; - } until ($filename_seek eq $env_script_name_length || $env_script_name_length eq 0); - - my $env_script_name_finallength = $env_script_name_length - $filename_last; - my $script_filename = substr($env_script_name, $filename_last, $env_script_name_finallength); - - # Setup the needed enviroment variables for Kiriwrite. +kiriwrite_initalise; # Initalise the Kiriwrite enviroment. +kiriwrite_settings_load; # Load the configuration options. - %kiriwrite_env = ( - "script_filename" => $script_filename, - ); +my $query_lite = new CGI::Lite; -} +# Check if a mode has been specified and if a mode has been specified, continue +# and work out what mode has been specified. -################################################################################# -# Begin listing the functions needed. # -################################################################################# +$form_data = $query_lite->parse_form_data(); -sub kiriwrite_selectedlist{ -################################################################################# -# kiriwrite_page_selectedlist: Get the list of selected pages to use. # -# # -# Usage: # -# # -# kiriwrite_page_selectedlist(); # -################################################################################# +if ($form_data->{'mode'}){ + my $http_query_mode = $form_data->{'mode'}; - my $count = $form_data->{'count'}; + if ($http_query_mode eq "db"){ - # Check if the list of files has a value and if not set it 0. + use Modules::System::Database; - if (!$count){ + if ($form_data->{'action'}){ + # An action has been specified, so find out what action has been specified. - $count = 0; + my $http_query_action = $form_data->{'action'}; + + if ($http_query_action eq "edit"){ + # The edit action (which mean edit the settings for the selected database) has been specified, + # get the database name and check if the action to edit an database has been confirmed. + + if ($form_data->{'database'}){ + # If there is a value in the database variable check if it is a valid database. Otherwise, + # return an error. + + my $http_query_database = $form_data->{'database'}; + + # Check if a value for confirm has been specified, if there is, check if it is the correct + # value, otherwise return an error. + + if ($form_data->{'confirm'}){ + # A value for confirm has been specified, find out what value it is. If the value is correct + # then edit the database settings, otherwise return an error. + + my $http_query_confirm = $form_data->{'confirm'}; + + if ($http_query_confirm eq 1){ + # Value is correct, collect the variables to pass onto the database variable. + + # Get the variables from the HTTP query. + + my $newdatabasename = $form_data->{'databasename'}; + my $newdatabasedescription = $form_data->{'databasedescription'}; + my $newdatabasefilename = $form_data->{'databasefilename'}; + my $databaseshortname = $form_data->{'database'}; + my $databasenotes = $form_data->{'databasenotes'}; + my $databasecategories = $form_data->{'databasecategories'}; + + # Pass the variables to the database editing subroutine. + + my $pagedata = kiriwrite_database_edit($databaseshortname, $newdatabasefilename, $newdatabasename, $newdatabasedescription, $databasenotes, $databasecategories, 1); + + kiriwrite_output_header; + kiriwrite_output_page($kiriwrite_lang{database}{editdatabasetitle}, $pagedata, "database"); + exit; + + } else { + # Value is incorrect, return and error. + kiriwrite_error("invalidvariable"); + } + + } + + # Display the form for editing an database. + my $pagedata = kiriwrite_database_edit($http_query_database); + + kiriwrite_output_header; + kiriwrite_output_page($kiriwrite_lang{database}{editdatabasetitle}, $pagedata, "database"); + exit; + + } else { + + # If there is no value in the database variable, then return an error. + kiriwrite_error("invalidvariable"); + + } + + } elsif ($http_query_action eq "delete"){ + + # Action equested is to delete a database, find out if the user has already confirmed deletion of the database + # and if the deletion of the database has been confirmed, delete the database. + + if ($form_data->{'confirm'}){ + + # User has confirmed to delete a database, pass the parameters to the kiriwrite_database_delete + # subroutine. + + my $database_filename = $form_data->{'database'}; + my $database_confirm = $form_data->{'confirm'}; + my $pagedata = kiriwrite_database_delete($database_filename, $database_confirm); + + kiriwrite_output_header; + kiriwrite_output_page($kiriwrite_lang->{database}->{deleteddatabase}, $pagedata, "database"); + + exit; + + } + + # User has clicked on the delete link (thus hasn't confirmed the action to delete a database). + + my $database_filename = $form_data->{'database'}; + my $pagedata = kiriwrite_database_delete($database_filename); + + kiriwrite_output_header; + kiriwrite_output_page($kiriwrite_lang->{database}->{deletedatabase}, $pagedata, "database"); + + exit; + + } elsif ($http_query_action eq "new"){ + + # Action requested is to create a new database, find out if the user has already entered the information needed + # to create a database and see if the user has confirmed the action, otherwise printout a form for adding a + # database. + + my $http_query_confirm = $form_data->{'confirm'}; + + # Check if the confirm value is correct. + + if ($http_query_confirm){ + if ($http_query_confirm eq 1){ + + # User has confirmed to create a database, pass the parameters to the + # kiriwrite_database_add subroutine. + + my $http_query_confirm = $form_data->{'confirm'}; + + my $database_name = $form_data->{'databasename'}; + my $database_description = $form_data->{'databasedescription'}; + my $database_filename = $form_data->{'databasefilename'}; + my $database_notes = $form_data->{'databasenotes'}; + my $database_categories = $form_data->{'databasecategories'}; + + my $pagedata = kiriwrite_database_add($database_filename, $database_name, $database_description, $database_notes, $database_categories, $http_query_confirm); + + kiriwrite_output_header; + kiriwrite_output_page($kiriwrite_lang{database}{adddatabase}, $pagedata, "database"); + exit; + + } else { + + # The confirm value is something else other than 1 (which it shouldn't be), so + # return an error. + + } + } + + # User has clicked on the 'Add Database' link. + + my $pagedata = kiriwrite_database_add(); + + kiriwrite_output_header; + kiriwrite_output_page($main::kiriwrite_lang{database}{adddatabase}, $pagedata, "database"); + exit; + + } else { + # Another option has been specified, so return an error. + + kiriwrite_error("invalidaction"); + } - } + } else { - # Define some values for later. + # No action has been specified, do the default action of displaying a list + # of databases. + + my $pagedata = kiriwrite_database_list(); + + kiriwrite_output_header; # Output the header to browser/console/stdout. + kiriwrite_output_page("", $pagedata, "database"); # Output the page to browser/console/stdout. + exit; # End the script. - my @filename_list; - my @selected_list; - my @final_list; + } - my $filename; - my $selected; + } elsif ($http_query_mode eq "page"){ - my $final_count = 0; - my $seek = 0; + use Modules::System::Page; - # Get the list of filenames. + if ($form_data->{'action'}){ + my $http_query_action = $form_data->{'action'}; + + # Check if the action requested matches with one of the options below. If it does, + # go to that section, otherwise return an error. - do { + if ($http_query_action eq "view"){ + + # The action selected was to view pages from a database, + + my $http_query_database = $form_data->{'database'}; + my $http_query_browsenumber = $form_data->{'browsenumber'}; + my $pagedata = kiriwrite_page_list($http_query_database, $http_query_browsenumber); + + kiriwrite_output_header; # Output the header to browser/console/stdout. + kiriwrite_output_page($kiriwrite_lang->{pages}->{viewingdatabase}, $pagedata, "pages", $http_query_database); # Output the page to browser/console/stdout. + exit; # End the script. + + } elsif ($http_query_action eq "add"){ + + # The action selected was to add a page to the selected database. + + my $http_query_confirm = $form_data->{'confirm'}; + + if (!$http_query_confirm){ + + $http_query_confirm = 0; + + } + + if ($http_query_confirm eq 1){ + + my $http_query_database = $form_data->{'database'}; + my $http_query_filename = $form_data->{'pagefilename'}; + my $http_query_name = $form_data->{'pagename'}; + my $http_query_description = $form_data->{'pagedescription'}; + my $http_query_section = $form_data->{'pagesection'}; + my $http_query_template = $form_data->{'pagetemplate'}; + my $http_query_settings = $form_data->{'pagesettings'}; + my $http_query_content = $form_data->{'pagecontent'}; + + my $pagedata = kiriwrite_page_add($http_query_database, $http_query_filename, $http_query_name, $http_query_description, $http_query_section, $http_query_template, $http_query_settings, $http_query_content, $http_query_confirm); + + kiriwrite_output_header; # Output the header to browser/console/stdout. + kiriwrite_output_page($kiriwrite_lang{pages}{addpage}, $pagedata, "pages"); # Output the page to browser/console/stdout. + exit; # End the script. + + } + + my $http_query_database = $form_data->{'database'}; + my $pagedata = kiriwrite_page_add($http_query_database); + + kiriwrite_output_header; # Output the header to browser/console/stdout. + kiriwrite_output_page($kiriwrite_lang{pages}{addpage}, $pagedata, "pages"); # Output the page to browser/console/stdout. + exit; # End the script. + + } elsif ($http_query_action eq "edit"){ + + # The action selected was to edit a page from a database. + + my $http_query_confirm = $form_data->{'confirm'}; + + if (!$http_query_confirm){ + + $http_query_confirm = 0; + + } + + if ($http_query_confirm eq 1){ + + # Get the needed values from the HTTP query. + + my $http_query_database = $form_data->{'database'}; + my $http_query_filename = $form_data->{'page'}; + my $http_query_newfilename = $form_data->{'pagefilename'}; + my $http_query_name = $form_data->{'pagename'}; + my $http_query_description = $form_data->{'pagedescription'}; + my $http_query_section = $form_data->{'pagesection'}; + my $http_query_template = $form_data->{'pagetemplate'}; + my $http_query_settings = $form_data->{'pagesettings'}; + my $http_query_content = $form_data->{'pagecontent'}; + + # Pass the values to the editing pages subroutine. + + my $pagedata = kiriwrite_page_edit($http_query_database, $http_query_filename, $http_query_newfilename, $http_query_name, $http_query_description, $http_query_section, $http_query_template, $http_query_settings, $http_query_content, $http_query_confirm); + + kiriwrite_output_header; # Output the header to browser/console/stdout. + kiriwrite_output_page($kiriwrite_lang{pages}{editpagetitle}, $pagedata, "pages"); # Output the page to browser/console/stdout. + exit; # End the script. + + } + + # Get the needed values from the HTTP query. + + my $http_query_database = $form_data->{'database'}; + my $http_query_filename = $form_data->{'page'}; + + # Pass the values to the editing pages subroutine. + + my $pagedata = kiriwrite_page_edit($http_query_database, $http_query_filename); + + kiriwrite_output_header; # Output the header to browser/console/stdout. + kiriwrite_output_page($kiriwrite_lang{pages}{editpagetitle}, $pagedata, "pages"); # Output the page to browser/console/stdout. + exit; # End the script. + + } elsif ($http_query_action eq "delete"){ + + # The action selected was to delete a page from a database. + + my $http_query_database = $form_data->{'database'}; + my $http_query_page = $form_data->{'page'}; + my $http_query_confirm = $form_data->{'confirm'}; + + my $pagedata = ""; + my $selectionlist = ""; + + if ($http_query_confirm){ + + # The action has been confirmed, so try to delete the selected page + # from the database. + + $pagedata = kiriwrite_page_delete($http_query_database, $http_query_page, $http_query_confirm); + + kiriwrite_output_header; # Output the header to browser/console/stdout. + kiriwrite_output_page($kiriwrite_lang{pages}{deletepagetitle}, $pagedata, "pages"); # Output the page to browser/console/stdout. + exit; # End the script. + + } + + $pagedata = kiriwrite_page_delete($http_query_database, $http_query_page); + + kiriwrite_output_header; # Output the header to browser/console/stdout. + kiriwrite_output_page($kiriwrite_lang{pages}{deletepagetitle}, $pagedata, "pages"); # Output the page to browser/console/stdout. + exit; # End the script. - # Get the values from id[] + } elsif ($http_query_action eq "multidelete"){ - $seek++; + # The action selected was to delete multiple pages from a + # database. + + my $http_query_database = $form_data->{'database'}; + my $http_query_confirm = $form_data->{'confirm'}; + + my @filelist; + my $pagedata; - $filename = $form_data->{'id[' . $seek . ']'}; - $filename_list[$seek] = $filename; + if ($http_query_confirm eq 1){ + + # The action to delete multiple pages from the selected + # database has been confirmed. + + @filelist = kiriwrite_selectedlist($form_data); + $pagedata = kiriwrite_page_multidelete($http_query_database, $http_query_confirm, @filelist); + + kiriwrite_output_header; # Output the header to browser/console/stdout. + kiriwrite_output_page($kiriwrite_lang{pages}{deletemultiplepages}, $pagedata, "pages"); # Output the page to browser/console/stdout. + exit; # End the script. + + } + + # Get the list of selected pages and pass them to the + # multiple page delete subroutine. + + @filelist = kiriwrite_selectedlist($form_data); + $pagedata = kiriwrite_page_multidelete($http_query_database, $http_query_confirm, @filelist); + + kiriwrite_output_header; # Output the header to browser/console/stdout. + kiriwrite_output_page($kiriwrite_lang{pages}{deletemultiplepages}, $pagedata, "pages"); # Output the page to browser/console/stdout. + exit; # End the script. - } until ($seek eq $count || $count eq 0); + } elsif ($http_query_action eq "multimove"){ - # Get the list of selected filenames. + # The action selected was to move multiple pages from a + # database. + + my $http_query_database = $form_data->{'database'}; + my $http_query_newdatabase = $form_data->{'newdatabase'}; + my $http_query_confirm = $form_data->{'confirm'}; + + my @filelist; + my $pagedata; + + if ($http_query_confirm){ + + # The action to move multiple pages from the selected + # database has been confirmed. + + @filelist = kiriwrite_selectedlist($form_data); + $pagedata = kiriwrite_page_multimove($http_query_database, $http_query_newdatabase, $http_query_confirm, @filelist); + + kiriwrite_output_header; # Output the header to browser/console/stdout. + kiriwrite_output_page($kiriwrite_lang{pages}{movepages}, $pagedata, "pages"); # Output the page to browser/console/stdout. + exit; # End the script. + + } + + # Get the list of selected pages and pass them to the + # multiple page move subroutine. + + @filelist = kiriwrite_selectedlist($form_data); + $pagedata = kiriwrite_page_multimove($http_query_database, $http_query_newdatabase, $http_query_confirm, @filelist); + + kiriwrite_output_header; # Output the header to browser/console/stdout. + kiriwrite_output_page($kiriwrite_lang{pages}{movepages}, $pagedata, "pages"); # Output the page to browser/console/stdout. + exit; # End the script. - $seek = 0; + } elsif ($http_query_action eq "multicopy"){ - do { + # The action selected was to copy multiple pages from a + # database. + + my $http_query_database = $form_data->{'database'}; + my $http_query_newdatabase = $form_data->{'newdatabase'}; + my $http_query_confirm = $form_data->{'confirm'}; + + my @filelist; + my $pagedata; + + if ($http_query_confirm){ + + # The action to copy multiple pages from the selected + # database has been confirmed. + + @filelist = kiriwrite_selectedlist($form_data); + $pagedata = kiriwrite_page_multicopy($http_query_database, $http_query_newdatabase, $http_query_confirm, @filelist); + + kiriwrite_output_header; # Output the header to browser/console/stdout. + kiriwrite_output_page($kiriwrite_lang{pages}{copypages}, $pagedata, "pages"); # Output the page to browser/console/stdout. + exit; # End the script. + + } + + # Get the list of selected pages and pass them to the + # multiple page copy subroutine. + + @filelist = kiriwrite_selectedlist($form_data); + $pagedata = kiriwrite_page_multicopy($http_query_database, $http_query_newdatabase, $http_query_confirm, @filelist); + + kiriwrite_output_header; # Output the header to browser/console/stdout. + kiriwrite_output_page($kiriwrite_lang{pages}{copypages}, $pagedata, "pages"); # Output the page to browser/console/stdout. + exit; # End the script. - # Get the values from name[] + } elsif ($http_query_action eq "multiedit"){ - $seek++; + # The action selected was to edit multiple pages from a + # database. + + my $http_query_database = $form_data->{'database'}; + my $http_query_newsection = $form_data->{'newsection'}; + my $http_query_altersection = $form_data->{'altersection'}; + my $http_query_newtemplate = $form_data->{'newtemplate'}; + my $http_query_altertemplate = $form_data->{'altertemplate'}; + my $http_query_newsettings = $form_data->{'newsettings'}; + my $http_query_altersettings = $form_data->{'altersettings'}; + my $http_query_confirm = $form_data->{'confirm'}; + + my @filelist; + my $pagedata; + + if (!$http_query_confirm){ + + @filelist = kiriwrite_selectedlist($form_data); + $pagedata = kiriwrite_page_multiedit($http_query_database, $http_query_newsection, $http_query_altersection, $http_query_newtemplate, $http_query_altertemplate, $http_query_newsettings, $http_query_altersettings, $http_query_confirm, @filelist); + + kiriwrite_output_header; # Output the header to browser/console/stdout. + kiriwrite_output_page($kiriwrite_lang{pages}{multiedit}, $pagedata, "pages"); # Output the page to browser/console/stdout. + exit; + + } + + # Get the list of selected pages and pass them to the + # multiple page edit subroutine. + + @filelist = kiriwrite_selectedlist($form_data); + $pagedata = kiriwrite_page_multiedit($http_query_database, $http_query_newsection, $http_query_altersection, $http_query_newtemplate, $http_query_altertemplate, $http_query_newsettings, $http_query_altersettings, $http_query_confirm, @filelist); + + kiriwrite_output_header; # Output the header to browser/console/stdout. + kiriwrite_output_page($kiriwrite_lang{pages}{multiedit}, $pagedata, "pages"); # Output the page to browser/console/stdout. + exit; # End the script. - $selected = $form_data->{'name[' . $seek . ']'}; + } else { + kiriwrite_error("invalidaction"); + } - if (!$selected){ + } else { - $selected = 'off'; + # If there the action option is left blank, then print out a form where the database + # can be selected to view pages from. + + my $pagedata = kiriwrite_page_list(); + + kiriwrite_output_header; # Output the header to browser/console/stdout. + kiriwrite_output_page($kiriwrite_lang{pages}{databaseselecttitle}, $pagedata, ""); # Output the page to browser/console/stdout. + exit; # End the script. } - $selected_list[$seek] = $selected; - - } until ($seek eq $count || $count eq 0); - - # Create a final list of filenames to be used for - # processing. - - $seek = 0; - - do { - - # Check if the selected value is on and include - # the filename in the final list. - - $seek++; - - $selected = $selected_list[$seek]; - - if ($selected eq "on"){ + } elsif ($http_query_mode eq "template"){ - $filename = $filename_list[$seek]; - $final_list[$final_count] = $filename; - $final_count++; + use Modules::System::Template; + if ($form_data->{'action'}){ + + # An action has been specified in the HTTP query. + + my $http_query_action = $form_data->{'action'}; + + if ($http_query_action eq "delete"){ + # Get the required parameters from the HTTP query. + + my $http_query_template = $form_data->{'template'}; + my $http_query_confirm = $form_data->{'confirm'}; + + # Check if a value for confirm has been specified (it shouldn't) + # be blank. + + if (!$http_query_confirm){ + # The confirm parameter of the HTTP query is blank, so + # write out a form asking the user to confirm the deletion + # of the selected template. + + my $pagedata = kiriwrite_template_delete($http_query_template); + + kiriwrite_output_header; # Output the header to browser/console/stdout. + kiriwrite_output_page($kiriwrite_lang{template}{deletetemplate}, $pagedata, "template"); # Output the page to browser/console/stdout. + exit; # End the script. + + } else { + + my $pagedata = kiriwrite_template_delete($http_query_template, $http_query_confirm); + + kiriwrite_output_header; # Output the header to browser/console/stdout. + kiriwrite_output_page($kiriwrite_lang{template}{deletetemplate}, $pagedata, "template"); # Output the page to browser/console/stdout. + exit; # End the script. + + } + + } elsif ($http_query_action eq "add") { + + # Get the variables from the HTTP query in preperation for processing. + + my $http_query_confirm = $form_data->{'confirm'}; + my $http_query_templatelayout = $form_data->{'templatelayout'}; + my $http_query_templatename = $form_data->{'templatename'}; + my $http_query_templatedescription = $form_data->{'templatedescription'}; + my $http_query_templatefilename = $form_data->{'templatefilename'}; + + # Check if there is a confirmed value in the http_query_confirm variable. + + if (!$http_query_confirm){ + + # Since there is no confirm value, print out a form for creating a new + # template. + + my $pagedata = kiriwrite_template_add(); + + kiriwrite_output_header; # Output the header to browser/console/stdout. + kiriwrite_output_page($kiriwrite_lang{template}{addtemplate}, $pagedata, "template"); # Output the page to browser/console/stdout. + exit; # End the script. + + } else { + + # A value in the http_query_confirm value is specified, so pass the + # variables onto the kiriwrite_template_add subroutine. + + my $pagedata = kiriwrite_template_add($http_query_templatefilename, $http_query_templatename, $http_query_templatedescription, $http_query_templatelayout, $http_query_confirm); + + kiriwrite_output_header; # Output the header to browser/console/stdout. + kiriwrite_output_page($kiriwrite_lang{template}{addtemplate}, $pagedata, "template"); # Output the page to browser/console/stdout. + exit; # End the script. + + } + + } elsif ($http_query_action eq "edit") { + + # Get the required parameters from the HTTP query. + + my $http_query_templatefile = $form_data->{'template'}; + my $http_query_confirm = $form_data->{'confirm'}; + + # Check to see if http_query_confirm has a value of '1' in it and + # if it does, edit the template using the settings providied. + + if (!$http_query_confirm){ + + # Since there is no confirm value, open the template configuration + # file and the template file itself then print out the data on to + # the form. + + my $pagedata = kiriwrite_template_edit($http_query_templatefile); + kiriwrite_output_header; # Output the header to browser/console/stdout. + kiriwrite_output_page($kiriwrite_lang{template}{edittemplate}, $pagedata, "template"); # Output the page to browser/console/stdout. + exit; # End the script. + + } elsif ($http_query_confirm eq 1) { + + # Since there is a confirm value of 1, the user has confirm the + # action of editing of a template so get the other variables + # that were also sent and pass the variables to the subroutine. + + my $http_query_newfilename = $form_data->{'newfilename'}; + my $http_query_newname = $form_data->{'newname'}; + my $http_query_newdescription = $form_data->{'newdescription'}; + my $http_query_newlayout = $form_data->{'newlayout'}; + + my $pagedata = kiriwrite_template_edit($http_query_templatefile, $http_query_newfilename, $http_query_newname, $http_query_newdescription, $http_query_newlayout, $http_query_confirm); + kiriwrite_output_header; # Output the header to browser/console/stdout. + kiriwrite_output_page($kiriwrite_lang{template}{edittemplate}, $pagedata, "template"); # Output the page to browser/console/stdout. + exit; # End the script. + + } else { + + # Another confirm value is there instead of '0' or '1'. Return + # an error saying it is invalid. + + kiriwrite_error("invalidvariable"); + + } + + } elsif ($http_query_action eq "view"){ + + # Get the required parameters from the HTTP query. + + my $http_query_browsenumber = $form_data->{'browsenumber'}; + + my $pagedata = kiriwrite_template_list($http_query_browsenumber); + + kiriwrite_output_header; # Output the header to browser/console/stdout. + kiriwrite_output_page($kiriwrite_lang{template}{viewtemplates}, $pagedata, "template"); # Output the page to browser/console/stdout. + exit; # End the script. + + } else { + + # Another action was specified and was not one of the ones above, so + # return an error. + + kiriwrite_error("invalidaction"); + + } + + } else { + + # If the action option is left blank, then print out a form where the list + # of templates are available. + + my $pagedata = kiriwrite_template_list(); + + kiriwrite_output_header; # Output the header to browser/console/stdout. + kiriwrite_output_page($kiriwrite_lang{template}{viewtemplates}, $pagedata, "template"); # Output the page to browser/console/stdout. + exit; # End the script. + } - } until ($seek eq $count || $count eq 0); + } elsif ($http_query_mode eq "filter"){ - return @final_list; - -} - -sub kiriwrite_settings_load{ -################################################################################# -# kiriwrite_settings_load: Load the configuration settings into the global # -# variables. # -# # -# Usage: # -# # -# kiriwrite_settings_load(); # -################################################################################# - - # Load the required Perl modules. - - use Config::Auto; - - # Check if the Kiriwrite configuration file exists before using it and - # return an critical error if it doesn't exist. - - my $kiriwrite_conf_exist = kiriwrite_fileexists("kiriwrite.cfg"); - - if ($kiriwrite_conf_exist eq 1){ - - # The configuration really does not exist so return an critical error. - - kiriwrite_critical("configfilemissing"); - - } - - # Check if the Kiriwrite configuration file has valid permission settings - # before using it and return an critical error if it doesn't have the - # valid permission settings. - - my $kiriwrite_conf_permissions = kiriwrite_filepermissions("kiriwrite.cfg", 1, 0); - - if ($kiriwrite_conf_permissions eq 1){ - - # The permission settings for the Kiriwrite configuration file are - # invalid, so return an critical error. - - kiriwrite_critical("configfileinvalidpermissions"); - - } - - # Converts the XML file into meaningful data for later on in this subroutine. - - my $kiriwrite_conf_file = 'kiriwrite.cfg'; - my $config = Config::Auto::parse($kiriwrite_conf_file, format => "ini"); - - # Go and fetch the settings and place them into a hash (that is global). - - %kiriwrite_config = ( - - "directory_data_db" => $config->{config}{directory_data_db}, - "directory_data_output" => $config->{config}{directory_data_output}, - "directory_noncgi_images" => $config->{config}{directory_noncgi_images}, - - "system_language" => $config->{config}{system_language}, - "system_presmodule" => $config->{config}{system_presmodule}, - "system_dbmodule" => $config->{config}{system_dbmodule}, - "system_datetime" => $config->{config}{system_datetime}, - - "display_textarearows" => $config->{config}{display_textarearows}, - "display_textareacols" => $config->{config}{display_textareacols}, - - "database_server" => $config->{config}{database_server}, - "database_port" => $config->{config}{database_port}, - "database_protocol" => $config->{config}{database_protocol}, - "database_sqldatabase" => $config->{config}{database_sqldatabase}, - "database_username" => $config->{config}{database_username}, - "database_password" => $config->{config}{database_password}, - "database_tableprefix" => $config->{config}{database_tableprefix} - - ); - - # Do a validation check on all of the variables that were loaded into the global configuration hash. - - kiriwrite_variablecheck($kiriwrite_config{"directory_data_db"}, "maxlength", 64, 0); - kiriwrite_variablecheck($kiriwrite_config{"directory_data_output"}, "maxlength", 64, 0); - kiriwrite_variablecheck($kiriwrite_config{"directory_noncgi_images"}, "maxlength", 512, 0); - kiriwrite_variablecheck($kiriwrite_config{"directory_data_template"}, "maxlength", 64, 0); - - my $kiriwrite_config_language_filename = kiriwrite_variablecheck($kiriwrite_config{"system_language"}, "language_filename", "", 1); - my $kiriwrite_config_presmodule_filename = kiriwrite_variablecheck($kiriwrite_config{"system_presmodule"}, "module", 0, 1); - my $kiriwrite_config_dbmodule_filename = kiriwrite_variablecheck($kiriwrite_config{"system_dbmodule"}, "module", 0, 1); - - my $kiriwrite_config_textarearows_maxlength = kiriwrite_variablecheck($kiriwrite_config{"display_textarearows"}, "maxlength", 3, 1); - my $kiriwrite_config_textarearows_number = kiriwrite_variablecheck($kiriwrite_config{"display_textareacols"}, "numbers", 0, 1); - my $kiriwrite_config_textareacols_maxlength = kiriwrite_variablecheck($kiriwrite_config{"display_textareacols"}, "maxlength", 3, 1); - my $kiriwrite_config_textareacols_number = kiriwrite_variablecheck($kiriwrite_config{"display_textareacols"}, "numbers", 0, 1); - - # Check if the language filename is valid and return an critical error if - # they aren't. - - if ($kiriwrite_config_language_filename eq 1){ - - # The language filename is blank so return an critical error. - - kiriwrite_critical("languagefilenameblank"); - - } elsif ($kiriwrite_config_language_filename eq 2){ - - # The language filename is invalid so return an critical error. - - kiriwrite_critical("languagefilenameinvalid"); - - } - - # Check if the presentation and database module names are valid and return a critical - # error if they aren't. - - if ($kiriwrite_config_presmodule_filename eq 1){ - - # The presentation module filename given is blank so return an - # critical error. - - kiriwrite_critical("presmoduleblank"); - - } - - if ($kiriwrite_config_presmodule_filename eq 2){ - - # The presentation module filename is invalid so return an - # critical error. - - kiriwrite_critical("presmoduleinvalid"); - - } - - if ($kiriwrite_config_dbmodule_filename eq 1){ - - # The database module filename given is blank so return an - # critical error. - - kiriwrite_critical("dbmoduleblank"); - - } - - if ($kiriwrite_config_dbmodule_filename eq 2){ - - # The database module filename given is invalid so return - # an critical error. - - kiriwrite_critical("dbmoduleinvalid"); - - } - - # Check if the text area column and row values are blank and return a critical - # error if they are. - - if (!$kiriwrite_config{"display_textarearows"}){ - - # The text area row value is blank so return - # a critical error. - - kiriwrite_critical("textarearowblank"); - - } - - if (!$kiriwrite_config{"display_textareacols"}){ - - # The text area column value is blank so return - # a critical error. - - kiriwrite_critical("textareacolblank"); - - } - - # Check if the text area column and row values to see if they are valid and return - # a critical error if they aren't. - - if ($kiriwrite_config_textarearows_maxlength eq 1){ - - # The text area row value is too long so return an - # critical error. - - kiriwrite_critical("textarearowtoolong"); - - } - - if ($kiriwrite_config_textarearows_number eq 1){ - - # The text area row value is invalid so return an - # critical error. - - kiriwrite_critical("textarearowinvalid"); - - } - - if ($kiriwrite_config_textareacols_maxlength eq 1){ - - # The text area column value is too long so return - # an critical error. - - kiriwrite_critical("textareacoltoolong"); - - } - - if ($kiriwrite_config_textareacols_number eq 1){ - - # The text area column value is invalid so return - # an critical error. - - kiriwrite_critical("textareacolinvalid"); - - } - - # Check if the language file does exist before loading it and return an critical error - # if it does not exist. - - my $kiriwrite_config_language_fileexists = kiriwrite_fileexists("lang/" . $kiriwrite_config{"system_language"} . ".lang"); - - if ($kiriwrite_config_language_fileexists eq 1){ - - # Language file does not exist so return an critical error. - - kiriwrite_critical("languagefilemissing"); - - } - - # Check if the language file has valid permission settings and return an critical error if - # the language file has invalid permissions settings. - - my $kiriwrite_config_language_filepermissions = kiriwrite_filepermissions("lang/" . $kiriwrite_config{"system_language"} . ".lang", 1, 0); - - if ($kiriwrite_config_language_filepermissions eq 1){ - - # Language file contains invalid permissions so return an critical error. - - kiriwrite_critical("languagefilepermissions"); - - } - - # Load the language file. - - $kiriwrite_lang = Config::Auto::parse("lang/" . $kiriwrite_config{"system_language"} . ".lang", format => "ini"); - - # Check if the presentation module does exist before loading it and return an critical error - # if the presentation module does not exist. - - my $kiriwrite_config_presmodule_fileexists = kiriwrite_fileexists("Modules/Presentation/" . $kiriwrite_config{"system_presmodule"} . ".pm"); - - if ($kiriwrite_config_presmodule_fileexists eq 1){ - - # Presentation module does not exist so return an critical error. - - kiriwrite_critical("presmodulemissing"); - - } - - # Check if the presentation module does have the valid permission settings and return a - # critical error if the presentation module contains invalid permission settings. - - my $kiriwrite_config_presmodule_permissions = kiriwrite_filepermissions("Modules/Presentation/" . $kiriwrite_config{"system_presmodule"} . ".pm", 1, 0); - - if ($kiriwrite_config_presmodule_permissions eq 1){ - - # Presentation module contains invalid permissions so return an critical error. - - kiriwrite_critical("presmoduleinvalidpermissions"); - - } - - # Check if the database module does exist before loading it and return an critical error - # if the database module does not exist. - - my $kiriwrite_config_dbmodule_fileexists = kiriwrite_fileexists("Modules/Database/" . $kiriwrite_config{"system_dbmodule"} . ".pm"); - - if ($kiriwrite_config_dbmodule_fileexists eq 1){ - - # Database module does not exist so return an critical error. - - kiriwrite_critical("dbmodulemissing"); - - } - - # Check if the database module does have the valid permission settings and return an - # critical error if the database module contains invalid permission settings. - - my $kiriwrite_config_dbmodule_permissions = kiriwrite_filepermissions("Modules/Database/" . $kiriwrite_config{"system_dbmodule"} . ".pm", 1, 0); - - if ($kiriwrite_config_dbmodule_permissions eq 1){ - - # Presentation module contains invalid permissions so return an critical error. - - kiriwrite_critical("dbmoduleinvalidpermissions"); - - } - - # Include the Modules directory. - - use lib "Modules/"; - - # Load the presentation module. - - my $presmodulename = "Presentation::" . $kiriwrite_config{"system_presmodule"}; - ($presmodulename) = $presmodulename =~ m/^(.*)$/g; - eval "use " . $presmodulename; - $presmodulename = "Kiriwrite::Presentation::" . $kiriwrite_config{"system_presmodule"}; - $kiriwrite_presmodule = $presmodulename->new(); - - # Load the database module. - - my $dbmodulename = "Database::" . $kiriwrite_config{"system_dbmodule"}; - ($dbmodulename) = $dbmodulename =~ m/^(.*)$/g; - eval "use " . $dbmodulename; - $dbmodulename = "Kiriwrite::Database::" . $kiriwrite_config{"system_dbmodule"}; - $kiriwrite_dbmodule = $dbmodulename->new(); - - # Load the following settings to the database module. - - $kiriwrite_dbmodule->loadsettings({ Directory => $kiriwrite_config{"directory_data_db"}, DateTime => $kiriwrite_config{"system_datetime"}, Server => $kiriwrite_config{"database_server"}, Port => $kiriwrite_config{"database_port"}, Protocol => $kiriwrite_config{"database_protocol"}, Database => $kiriwrite_config{"database_sqldatabase"}, Username => $kiriwrite_config{"database_username"}, Password => $kiriwrite_config{"database_password"}, TablePrefix => $kiriwrite_config{"database_tableprefix"} }); - - return; - -} - -sub kiriwrite_variablecheck{ -################################################################################# -# kiriwrite_variablecheck: Checks the variables for any invalid characters. # -# # -# Usage: # -# # -# kiriwrite_variablecheck(variable, type, length, noerror); # -# # -# variable Specifies the variable to be checked. # -# type Specifies what type the variable is. # -# option Specifies the maximum/minimum length of the variable # -# (if minlength/maxlength is used) or if the filename should be # -# checked to see if it is blank. # -# noerror Specifies if Kiriwrite should return an error or not on # -# certain values. # -################################################################################# - - # Get the values that were passed to the subroutine. - - my ($variable_data, $variable_type, $variable_option, $variable_noerror) = @_; - - if ($variable_type eq "numbers"){ - - # Check for numbers and return an error if there is anything else than numebrs. - - my $variable_data_validated = $variable_data; # Copy the variable_data to variable_data_validated. - $variable_data_validated =~ tr/0-9//d; # Take away all of the numbers and from the variable. - # If it only contains numbers then it should be blank. - - if ($variable_data_validated eq ""){ - # The validated variable is blank. So continue to the end of this section where the return function should be. - } else { - # The variable is not blank, so check if the no error value is set - # to 1 or not. - - if ($variable_noerror eq 1){ - - # The validated variable is not blank and the noerror - # value is set to 1. So return an value of 1. - # (meaning that the data is invalid). - - return 1; - - } elsif ($variable_noerror eq 0) { - - # The validated variable is not blank and the noerror - # value is set to 0. - - kiriwrite_error("invalidvariable"); - - } else { - - # The variable noerror value is something else - # pther than 1 or 0. So return an error. - - kiriwrite_error("invalidvariable"); - - } - - } - - return 0; - - } elsif ($variable_type eq "lettersnumbers"){ - - # Check for letters and numbers and return an error if there is anything else other - # than letters and numbers. - - my $variable_data_validated = $variable_data; # Copy the variable_data to variable_data_validated - $variable_data_validated =~ tr/a-zA-Z0-9.//d; - $variable_data_validated =~ s/\s//g; - - if ($variable_data_validated eq ""){ - # The validated variable is blank. So continue to the end of this section where the return function should be. - } else { - # The variable is not blank, so check if the no error value is set - # to 1 or not. - - if ($variable_noerror eq 1){ - - # The validated variable is not blank and the noerror - # value is set to 1. So return an value of 1. - # (meaning that the data is invalid). - - return 1; - - } elsif ($variable_noerror eq 0) { - - # The validated variable is not blank and the noerror - # value is set to 0. - - kiriwrite_error("invalidvariable"); - - } else { - - # The variable noerror value is something else - # pther than 1 or 0. So return an error. - - kiriwrite_error("invalidvariable"); - - } - - } - - return 0; - - } elsif ($variable_type eq "maxlength"){ - # Check for the length of the variable, return an error if it is longer than the length specified. - - # Check if the variable_data string is blank, if it is then set the variable_data_length - # to '0'. - - my $variable_data_length = 0; - - if (!$variable_data){ - - # Set variable_data_length to '0'. - $variable_data_length = 0; - - } else { - - # Get the length of the variable recieved. - $variable_data_length = length($variable_data); - - } - - - - if ($variable_data_length > $variable_option){ - - # The variable length is longer than it should be so check if - # the no error value is set 1. - - if ($variable_noerror eq 1){ - - # The no error value is set to 1, so return an - # value of 1 (meaning tha the variable is - # too long to be used). - - return 1; - - } elsif ($variable_noerror eq 0){ - - # The no error value is set to 0, so return - # an error. - - kiriwrite_error("variabletoolong"); - - } else { - - # The no error value is something else other - # than 0 or 1, so return an error. - - kiriwrite_error("variabletoolong"); - - } - - } else { - - # The variable length is exactly or shorter than specified, so continue to end of this section where - # the return function should be. - - } - - return 0; - - } elsif ($variable_type eq "blank"){ - # Check if the variable is blank and if it is blank, then return an error. - - if (!$variable_data){ - - # The variable data really is blank, so check what - # the no error value is set. - - if ($variable_noerror eq 1){ - - # The no error value is set to 1, so return - # a value of 1 (saying that the variable was - # blank). - - return 1; - - } elsif ($variable_noerror eq 0){ - - # The no error value is set to 0, so return - # an error. - - kiriwrite_error("blankvariable"); - - } else { - - # The no error value is something else other - # than 0 or 1, so return an error. - - kiriwrite_error("invalidvariable"); - - } - - } - - return 0; - - } elsif ($variable_type eq "filename"){ - # Check for letters and numbers, if anything else than letters and numbers is there (including spaces) return - # an error. - - # Check if the filename passed is blank, if it is then return with an error. - - if ($variable_data eq ""){ - - # The filename specified is blank, so check what the - # noerror value is set. - - if ($variable_noerror eq 1){ - - # The no error value is set to 1 so return - # a value of 1 (meaning that the filename - # was blank). - - return 1; - - } elsif ($variable_noerror eq 0){ - - # The no error value is set to 1 so return - # an error. - - kiriwrite_error("blankfilename"); - - } else { - - # The no error value is something else other - # than 0 or 1, so return an error. - - kiriwrite_error("invalidvariable"); - - } - - } else { - - - } - - my $variable_data_validated = $variable_data; - $variable_data_validated =~ tr/a-zA-Z0-9\.//d; - - # Check if the validated data variable is blank, if it is - # then continue to the end of this section where the return - # function should be, otherwise return an error. - - if ($variable_data_validated eq ""){ - - # The validated data variable is blank, meaning that - # it only contained letters and numbers. - - } else { - - # The validated data variable is not blank, meaning - # that it contains something else, so return an error - # (or a value). - - if ($variable_noerror eq 1){ - - # The no error value is set to 1 so return - # an value of 2. (meaning that the filename - # is invalid). - - - return 2; - - } elsif ($variable_noerror eq 0){ - - # The no error value is set to 0 so return - # an error. - - kiriwrite_error("invalidfilename"); - - } else { - - # The no error value is something else other - # than 0 or 1 so return an error. - - kiriwrite_error("invalidvariable"); - - } - - } - - return 0; - - } elsif ($variable_type eq "filenameindir"){ - # Check if the filename is in the directory and return an - # error if it isn't. - - if ($variable_data eq ""){ - - # The filename specified is blank, so check what the - # noerror value is set. - - if ($variable_noerror eq 1){ - - # The no error value is set to 1 so return - # a value of 1 (meaning that the filename - # was blank). - - return 1; - - } elsif ($variable_noerror eq 0){ - - # The no error value is set to 1 so return - # an error. - - kiriwrite_error("blankfilename"); - - } else { - - # The no error value is something else other - # than 0 or 1, so return an error. - - kiriwrite_error("invalidvariable"); - - } - - } else { - - - } - - # Set the following variables for later on. - - my $variable_data_length = 0; - my $variable_data_char = ""; - my $variable_data_validated = ""; - my $variable_data_seek = 0; - my $variable_database_list = ""; - my $variable_database_listcurrent = ""; - my $variable_data_firstlevel = 1; - - # Get the length of the variable recieved. - - $variable_data_length = length($variable_data); - - # Check if the database filename contains the directory command - # for up a directory level and if it is, return an error - # or return with a number. - - do { - - # Get a character from the filename passed to this subroutine. - - $variable_data_char = substr($variable_data, $variable_data_seek, 1); - - # Check if the current character is the forward slash character. - - if ($variable_data_char eq "/"){ - - # Check if the current directory is blank (and on the first level), or if the - # current directory contains two dots or one dot, if it does return an error. - - if ($variable_database_listcurrent eq "" && $variable_data_firstlevel eq 1 || $variable_database_listcurrent eq ".." || $variable_database_listcurrent eq "."){ - - # Check if the noerror value is set to 1, if it is return an - # number, else return an proper error. - - if ($variable_noerror eq 1){ - - # Page filename contains invalid characters and - # the no error value is set to 1 so return a - # value of 2 (meaning that the page filename - # is invalid). - - return 2; - - } elsif ($variable_noerror eq 0) { - - # Page filename contains invalid characters and - # the no error value is set to 0 so return an - # error. - - kiriwrite_error("invalidfilename"); - - } else { - - # The no error value is something else other - # than 0 or 1 so return an error. - - kiriwrite_error("invalidvariable"); - - } - - } - - # Append the forward slash, clear the current directory name and set - # the first directory level value to 0. - - $variable_database_list = $variable_database_list . $variable_data_char; - $variable_database_listcurrent = ""; - $variable_data_firstlevel = 0; - - } else { - - # Append the current character to the directory name and to the current - # directory name. - - $variable_database_list = $variable_database_list . $variable_data_char; - $variable_database_listcurrent = $variable_database_listcurrent . $variable_data_char; - - } - - # Increment the seek counter. - - $variable_data_seek++; - - } until ($variable_data_seek eq $variable_data_length); - - return 0; - - } elsif ($variable_type eq "datetime"){ - # Check if the date and time setting format is valid. - - if ($variable_data eq ""){ - - if ($variable_noerror eq 1){ - - # The no error value is set to 1 so return - # a value of 1 (meaning that the date and - # time format was blank). - - return 1; - - } elsif ($variable_noerror eq 0){ - - # The no error value is set to 1 so return - # an error. - - kiriwrite_error("blankdatetimeformat"); - - } else { - - # The no error value is something else other - # than 0 or 1, so return an error. - - kiriwrite_error("invalidvariable"); - - } - - } - - my $variable_data_validated = $variable_data; - $variable_data_validated =~ tr|dDmMyYhms/():[ ]||d; - - if ($variable_data_validated eq ""){ - - # The date and time format is valid. So - # skip this bit. - - } else { - - # The validated data variable is not blank, meaning - # that it contains something else, so return an error - # (or a value). - - if ($variable_noerror eq 1){ - - # The no error value is set to 1 so return - # an value of 2. (meaning that the date and - # time format was invalid). - - return 2; - - } elsif ($variable_noerror eq 0){ - - # The no error value is set to 0 so return - # an error. - - kiriwrite_error("invaliddatetimeformat"); - - } else { - - # The no error value is something else other - # than 0 or 1 so return an error. - - kiriwrite_error("invalidvariable"); - - } - - } - - return 0; - - } elsif ($variable_type eq "directory"){ - # Check if the directory only contains letters and numbers and - # return an error if anything else appears. - - my $variable_data_validated = $variable_data; - $variable_data_validated =~ tr/a-zA-Z0-9//d; - - if ($variable_data eq ""){ - - if ($variable_noerror eq 1){ - - # The no error value is set to 1 so return - # a value of 1 (meaning that the directory - # name was blank). - - return 1; - - } elsif ($variable_noerror eq 0){ - - # The no error value is set to 1 so return - # an error. - - kiriwrite_error("blankdirectory"); - - } else { - - # The no error value is something else other - # than 0 or 1, so return an error. - - kiriwrite_error("invalidvariable"); - - } - - } - - if ($variable_data_validated eq ""){ - - # The validated data variable is blank, meaning that - # it only contains letters and numbers. - - } else { - - # The validated data variable is not blank, meaning - # that it contains something else, so return an error - # (or a value). - - if ($variable_noerror eq 1){ - - # The no error value is set to 1 so return - # an value of 2. (meaning that the directory - # name is invalid). - - return 2; - - } elsif ($variable_noerror eq 0){ - - # The no error value is set to 0 so return - # an error. - - kiriwrite_error("invaliddirectory"); - - } else { - - # The no error value is something else other - # than 0 or 1 so return an error. - - kiriwrite_error("invalidvariable"); - - } - - } - - return 0; - - } elsif ($variable_type eq "language_filename"){ - - # The variable type is a language filename type. - # Check if the language file name is blank and - # if it is then return an error (or value). - - if ($variable_data eq ""){ - - # The language filename is blank so check the - # no error value and return an error (or value). - - if ($variable_noerror eq 1){ - - # Language filename is blank and the no error value - # is set as 1, so return a value of 1 (saying that - # the language filename is blank). - - return 1; - - } elsif ($variable_noerror eq 0) { - - # Language filename is blank and the no error value - # is not set as 1, so return an error. - - kiriwrite_critical("languagefilenameblank"); - - } else { - - # The noerror value is something else other - # than 0 or 1 so return an error. - - kiriwrite_error("invalidvariable"); - - } - - } - - # Set the following variables for later on. - - my $variable_data_length = 0; - my $variable_data_char = ""; - my $variable_data_seek = 0; - - # Get the length of the language file name. - - $variable_data_length = length($variable_data); - - do { - - # Get a character from the language filename passed to this - # subroutine and the character the seek counter value is set - # to. - - $variable_data_char = substr($variable_data, $variable_data_seek, 1); - - # Check if the language filename contains a forward slash or a dot, - # if the selected character is a forward slash then return an error - # (or value). - - if ($variable_data_char eq "/" || $variable_data_char eq "."){ - - # The language filename contains a forward slash or - # a dot so depending on the no error value, return - # an error or a value. - - if ($variable_noerror eq 1){ - - # Language filename contains a forward slash or a dot - # and the no error value has been set to 1, so return - # an value of 2 (saying that the language file name is - # invalid). - - return 2; - - } elsif ($variable_noerror eq 0) { - - # Language filename contains a forward slash and the no - # error value has not been set to 1, so return an error. - - kiriwrite_critical("languagefilenameinvalid"); - - } else { - - # The noerror value is something else other than - # 1 or 0 so return an error. - - kiriwrite_error("invalidvariable"); - - } - - } - - # Increment the seek counter. - - $variable_data_seek++; - - } until ($variable_data_seek eq $variable_data_length); - - return 0; - - } elsif ($variable_type eq "pagesetting"){ - - # The variable type is a page setting, so check if the page - # setting has one of the valid options. - - if ($variable_data eq 0 || $variable_data eq 1 || $variable_data eq 2 || $variable_data eq 3){ - - # The variable is one of the options above, so continue - # to the end of this section. - - } else { - - # The variable is not one of the options above, so check - # and see if a error or a value should be returned. - - if ($variable_noerror eq 1){ - - # The page setting is invalid and the no error - # value is set 1, so return a value of 1 - # (saying that the page setting value is - # invalid). - - return 1; - - } elsif ($variable_noerror eq 0) { - - # Page setting is invalid and the no error value - # is not 1, so return an error. - - kiriwrite_error("invalidvariable"); - - } else { - - # The no error value is something else other - # than 0 or 1 so return an error. - - kiriwrite_error("invalidvariable"); - - } - - } - - return 0; - - } elsif ($variable_type eq "page_filename"){ - - # The variable type is a page filename type. Check - # if the data is empty and if it is then return an - # error (or value). - - if ($variable_data eq ""){ - - # The filename is blank so check the no error - # value and depending on it return an value - # or an error. - - if ($variable_noerror eq 1){ - - # Page filename is blank and the no error value - # is set as 1, so return a value of 1 (saying - # the filename is blank). - - return 1; - - } elsif ($variable_noerror eq 0) { - - # Page filename is blank and the no error value - # is not 1, so return an error. - - kiriwrite_error("emptypagefilename"); - - } else { - - # The no error value is something else other - # than 0 or 1 so return an error. - - kiriwrite_error("invalidvariable"); - - } - } - - # Set the following variables for later on. - - - my $variable_data_length = 0; - my $variable_data_slash = 0; - my $variable_data_char = ""; - my $variable_data_validated = ""; - my $variable_data_seek = 0; - my $variable_database_list = ""; - my $variable_database_listcurrent = ""; - my $variable_data_firstlevel = 1; - - # Get the length of the filename. - - $variable_data_length = length($variable_data); - - # Check that only valid characters should be appearing in - # the filename. - - $variable_data_validated = $variable_data; - $variable_data_validated =~ tr|a-zA-Z0-9\.\/\-_||d; - - if ($variable_data_validated ne ""){ - - # The validated variable is not blank, meaning the - # variable contains invalid characters, so return - # an error. - - if ($variable_noerror eq 1){ - - # Page filename contains invalid characters and - # the no error value is set to 1 so return a - # value of 2 (meaning that the page filename - # is invalid). - - return 2; - - } elsif ($variable_noerror eq 0) { - - # Page filename contains invalid characters and - # the no error value is set to 0 so return an - # error. - - kiriwrite_error("invalidfilename"); - - } else { - - # The no error value is something else other - # than 0 or 1 so return an error. - - kiriwrite_error("invalidvariable"); - - } - - } - - # Check if the page filename contains the directory command - # for up a directory level and if it is, return an error - # or return with a number. - - do { - - # Get a character from the filename passed to this subroutine. - - $variable_data_char = substr($variable_data, $variable_data_seek, 1); - - # Check if the current character is the forward slash character. - - if ($variable_data_char eq "/"){ - - # Check if the current directory is blank (and on the first level), or if the - # current directory contains two dots or one dot, if it does return an error. - - $variable_data_slash = 1; - - if ($variable_database_listcurrent eq "" && $variable_data_firstlevel eq 1 || $variable_database_listcurrent eq ".." || $variable_database_listcurrent eq "."){ - - # Check if the noerror value is set to 1, if it is return an - # number, else return an proper error. - - if ($variable_noerror eq 1){ - - # Page filename contains invalid characters and - # the no error value is set to 1 so return a - # value of 2 (meaning that the page filename - # is invalid). - - return 2; - - } elsif ($variable_noerror eq 0) { - - # Page filename contains invalid characters and - # the no error value is set to 0 so return an - # error. - - kiriwrite_error("invalidfilename"); - - } else { - - # The no error value is something else other - # than 0 or 1 so return an error. - - kiriwrite_error("invalidvariable"); - - } - - } - - # Append the forward slash, clear the current directory name and set - # the first directory level value to 0. - - $variable_database_list = $variable_database_list . $variable_data_char; - $variable_database_listcurrent = ""; - $variable_data_firstlevel = 0; - - } else { - - # Append the current character to the directory name and to the current - # directory name. - - $variable_data_slash = 0; - - $variable_database_list = $variable_database_list . $variable_data_char; - $variable_database_listcurrent = $variable_database_listcurrent . $variable_data_char; - - } - - # Increment the seek counter. - - $variable_data_seek++; - - } until ($variable_data_seek eq $variable_data_length); - - # Check if the last character is a slash and return an - # error if it is. - - if ($variable_data_slash eq 1){ - - if ($variable_noerror eq 1){ - - # Last character is a slash and the no error - # value is set to 1 so return a value of 2 - # (meaning that the page filename is invalid). - - return 2; - - } elsif ($variable_noerror eq 0) { - - # Page filename contains a slash for the last - # character and the no error value is set to 0 - # so return an error. - - kiriwrite_error("invalidfilename"); - - } else { - - # The no error value is something else other - # than 0 or 1 so return an error. - - kiriwrite_error("invalidvariable"); - - } - - } - - return 0; - - } elsif ($variable_type eq "module"){ - - # The variable type is a presentation module filename. - - # Check if the variable_data is blank and if it is - # return an error. - - if ($variable_data eq ""){ - - # The presentation module is blank so check if an error - # value should be returned or a number should be - # returned. - - if ($variable_noerror eq 1){ - - # Module name is blank and the no error value - # is set to 1 so return a value of 2 (meaning - # that the page filename is blank). - - return 1; - - } elsif ($variable_noerror eq 0) { - - # Module name contains is blank and the no error - # value is set to 0 so return an error. - - kiriwrite_critical("moduleblank"); - - } else { - - # The no error value is something else other - # than 0 or 1 so return an error. - - kiriwrite_critical("invalidvalue"); - - } - - } else { - - } - - my $variable_data_validated = $variable_data; - $variable_data_validated =~ tr/a-zA-Z0-9//d; - - if ($variable_data_validated eq ""){ - - } else { - - if ($variable_noerror eq 1){ - - # Module name contains invalid characters and - # the no error value is set to 1 so return a - # value of 2 (meaning that the page filename - # is invalid). - - return 2; - - } elsif ($variable_noerror eq 0) { - - # Module name contains invalid characters and - # the no error value is set to 0 so return an - # error. - - kiriwrite_critical("moduleinvalid"); - - } else { - - # The no error value is something else other - # than 0 or 1 so return an error. - - kiriwrite_error("invalidvalue"); - - } - - } - - return 0; - - } elsif ($variable_type eq "utf8"){ - - # The variable type is a UTF8 string. - - if (!$variable_data){ - - $variable_data = ""; - - } - - # Check if the string is a valid UTF8 string. - - if ($variable_data =~ m/^( - [\x09\x0A\x0D\x20-\x7E] # ASCII - | [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte - | \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs - | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte - | \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates - | \xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3 - | [\xF1-\xF3][\x80-\xBF]{3} # planes 4-15 - | \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16 - )*$/x){ - - # The UTF-8 string is valid. - - } else { - - # The UTF-8 string is not valid, check if the no error - # value is set to 1 and return an error if it isn't. - - if ($variable_noerror eq 1){ - - # The no error value has been set to 1, so return - # a value of 1 (meaning that the UTF-8 string is - # invalid). - - return 1; - - } elsif ($variable_noerror eq 0) { - - # The no error value has been set to 0, so return - # an error. - - kiriwrite_error("invalidutf8"); - - } else { - - # The no error value is something else other than 0 - # or 1, so return an error. - - kiriwrite_error("invalidoption"); - - } - - } - - return 0; - - } elsif ($variable_type eq "serverprotocol"){ - - # Check if the server protocol is TCP or UDP and return - # an error if it isn't. - - if ($variable_data ne "tcp" && $variable_data ne "udp"){ - - # The protocol given is not valid, check if the no - # error value is set to 1 and return an error if it isn't. - - if ($variable_noerror eq 1){ - - # The no error value has been set to 1, so return a - # value of 1 (meaning that the server protocol is - # invalid). - - return 1; - - } elsif ($variable_noerror eq 0){ - - # The no error value has been set to 0, so return - # an error. - - kiriwrite_error("serverprotocolinvalid"); - - } else { - - # The no error value is something else other than 0 - # or 1, so return an error. - - kiriwrite_error("invalidoption"); - - } - - } - - return 0; - - } elsif ($variable_type eq "port"){ - - # Check if the port number given is less than 0 or more than 65535 - # and return an error if it is. - - if ($variable_data < 0 || $variable_data > 65535){ - - # The port number is less than 0 and more than 65535 so - # check if the no error value is set to 1 and return an - # error if it isn't. - - if ($variable_noerror eq 1){ - - # The no error value has been set to 1, so return a - # value of 1 (meaning that the port number is invalid). - - return 1; - - } elsif ($variable_noerror eq 0){ - - # The no error value has been set to 0, so return - # an error. - - kiriwrite_error("serverportnumberinvalid"); - - } else { - - # The no error value is something else other than 0 - # or 1, so return an error. - - kiriwrite_error("invalidoption"); - - } - - } - - return 0; - - } - - # Another type than the valid ones above has been specified so return an error specifying an invalid option. - kiriwrite_error("invalidoption"); - -} - -sub kiriwrite_output_header{ -################################################################################# -# kiriwrite_output_header: Outputs the header to the browser/stdout/console. # -# # -# Usage: # -# # -# kiriwrite_output_header(); # -################################################################################# - - # Print a header saying that the page expires immediately since the - # date is set in the past. - - print "Expires: Sun, 01 Jan 2006 00:00:00 GMT\r\n"; - print "Content-Type: charset=utf-8;\r\n\r\n"; - return; -} - -sub kiriwrite_processfilename{ -################################################################################# -# kiriwrite_processfilename: Processes a name and turns it into a filename that # -# can be used by Kiriwrite. # -# # -# Usage: # -# # -# kiriwrite_processfilename(text); # -# # -# text Specifies the text to be used in the process for creating a new # -# filename. # -################################################################################# - - # Get the values that have been passed to the subroutine. - - my ($process_text) = @_; - - # Define some variables that will be used later on. - - my $processed_stageone = ""; - my $processed_stagetwo = ""; - my $processed_length = ""; - my $processed_char = ""; - my $processed_seek = 0; - my $processed_filename = ""; - - # Set the first stage value of the processed filename to the - # process filename and then filter it out to only contain - # numbers and letters (no spaces) and then convert the - # capitals to small letters. - - $processed_stageone = $process_text; - $processed_stageone =~ tr#a-zA-Z0-9##cd; - $processed_stageone =~ tr/A-Z/a-z/; - - # Now set the second stage value of the processed filename - # to the first stage value of the processed filename and - # then limit the filename down to 32 characters. - - $processed_stagetwo = $processed_stageone; - $processed_length = length($processed_stagetwo); - - # Process the second stage filename into the final - # filename and do so until the seek counter is 32 - # or reaches the length of the second stage filename. - - do { - - # Get the character that is the seek counter - # is set at. - - $processed_char = substr($processed_stagetwo, $processed_seek, 1); - - # Append to the final processed filename. - - $processed_filename = $processed_filename . $processed_char; - - # Increment the seek counter. - - $processed_seek++; - - } until ($processed_seek eq 32 || $processed_seek eq $processed_length); - - return $processed_filename; - -} - -sub kiriwrite_language{ -################################################################################# -# kiriwrite_language: Process language strings that needs certain text inserted.# -# # -# Usage: # -# # -# kiriwrite_language(string, [text, text, ...]); # -# # -# string Specifies the string to process. # -# text Specifies the text to pass to the string (can be repeated many # -# times). # -################################################################################# - - my $string = shift; - my $item; - - foreach $item (@_){ - - $string =~ s/%s/$item/; - - } - - return $string; - -} - -sub kiriwrite_error{ -################################################################################# -# kiriwrite_error: Prints out an error message. # -# # -# Usage: # -# # -# kiriwrite_error(errortype, errorext); # -# # -# errortype Specifies the type of error that occured. # -# errorext Specifies the extended error information. # -################################################################################# - - # Get the error type from the subroutine. - - my ($error_type, $error_extended) = @_; - - # Disconnect from the database server. - - if ($kiriwrite_dbmodule){ - $kiriwrite_dbmodule->disconnect(); - } - - # Load the list of error messages. - - my @kiriwrite_error = ( - - # Catch all error message. - "generic", - - # Standard error messages. - "blankfilename", "blankvariable", "fileexists", "internalerror", "invalidoption", "invalidaction", "invalidfilename", "invalidmode", "invalidutf8", "invalidvariable", "variabletoolong", - - # Specific error messages. - "blankcompiletype", "blankdatabasepageadd", "blankdirectory", "blankfindfilter", "blankdatetimeformat", "browsenumbertoolong", "browsenumberinvalid", "databaseconnectionerror", "databasecategoriestoolong", "databasecopysame", "databasealreadyexists", "datadirectorymissing", "datadirectoryinvalidpermissions", "databasedescriptiontoolong", "databasefilenameinvalid", "databasefilenametoolong", "databaseerror", "databaseinvalidpermissions", "databasenameinvalid", "databasenametoolong", "databasenameblank", "databasemissingfile", "databasemovemissingfile", "databasenorename", "databasemovesame", "dbmoduleblank", "dbmoduleinvalid", "dbdirectoryblank", "dbdirectoryinvalid", "dbmodulemissing", "filtersdatabasenotcreated", "filtersdbdatabaseerror", "filtersdbpermissions", "filtersdbmissing", "filteridblank", "filterdoesnotexist", "filteridinvalid", "filteridtoolong", "findfiltertoolong", "filterpriorityinvalid", "filterpriorityinvalidchars", "filterprioritytoolong", "invalidcompiletype", "invalidpagenumber", "nopagesselected", "invaliddirectory", "invaliddatetimeformat", "invalidlanguagefilename", "languagefilenamemissing", "moduleblank", "moduleinvalid", "newcopydatabasedatabaseerror", "newcopydatabasedoesnotexist", "newcopydatabasefileinvalidpermissions", "newmovedatabasedatabaseerror", "newmovedatabasedoesnotexist", "newmovedatabasefileinvalidpermissions", "nodatabasesavailable", "nodatabaseselected", "noeditvaluesselected", "oldcopydatabasedatabaseerror", "oldcopydatabasedoesnotexist", "oldcopydatabasefileinvalidpermissions", "oldmovedatabasedatabaseerror", "oldmovedatabasedoesnotexist", "oldmovedatabasefileinvalidpermissions", "outputdirectoryblank", "outputdirectoryinvalid", "outputdirectorymissing", "outputdirectoryinvalidpermissions", "overridetemplatevalueinvalid", "overridetemplatetoolong", "overridetemplateinvalid", "presmoduleblank", "presmoduleinvalid", "presmodulemissing", "pagefilenamedoesnotexist", "pagefilenameexists", "pagefilenameinvalid", "pagefilenametoolong", "pagefilenameblank", "pagetitletoolong", "pagedescriptiontoolong", "pagesectiontoolong", "pagedatabasefilenametoolong", "pagesettingstoolong", "pagesettingsinvalid", "pagetemplatefilenametoolong", "replacefiltertoolong", "servernameinvalid", "servernametoolong", "serverdatabasenameinvalid", "serverdatabasenametoolong", "serverdatabaseusernameinvalid", "serverdatabaseusernametoolong", "serverdatabasepasswordtoolong", "serverdatabasetableprefixinvalid", "serverdatabasetableprefixtoolong", "serverportnumberinvalid", "serverportnumberinvalidcharacters", "serverportnumbertoolong", "serverprotocolnametoolong", "serverprotocolinvalid", "templatenameblank", "templatefilenameexists", "templatefilenameinvalid", "templatedatabaseerror", "templatedatabaseinvalidpermissions", "templatedatabaseinvalidformat", "templatedirectoryblank", "templatedirectoryinvalid", "templatedatabasenotcreated", "templatefilenametoolong", "templatenametoolong", "templatedescriptiontoolong", "templatedatabasemissing", "templatedoesnotexist", "templatefilenameblank", "textarearowblank", "textarearowtoolong", "textarearowinvalid", "textareacolblank", "textareacoltoolong", "textareacolinvalid" - - ); - - # Check if the error message name is a valid error message name - # and return the generic error message if it isn't. - - my $error_string = ""; - - if (grep /^$error_type$/, @kiriwrite_error){ - - # The error type is valid so get the error language string - # associated with this error messsage name. - - $error_string = $kiriwrite_lang->{error}->{$error_type}; - - } else { - - # The error type is invalid so set the error language - # string using the generic error message name. - - $error_string = $kiriwrite_lang->{error}->{generic}; - - } - - $kiriwrite_presmodule->clear(); - - $kiriwrite_presmodule->startbox("errorbox"); - $kiriwrite_presmodule->addtext($kiriwrite_lang->{error}->{error}, { Style => "errorheader" }); - $kiriwrite_presmodule->addlinebreak(); - $kiriwrite_presmodule->addtext($error_string, { Style => "errortext" }); - - # Check to see if extended error information was passed. - - if ($error_extended){ - - # Write the extended error information. - - $kiriwrite_presmodule->addlinebreak(); - $kiriwrite_presmodule->addlinebreak(); - $kiriwrite_presmodule->addtext($kiriwrite_lang->{error}->{extendederror}); - $kiriwrite_presmodule->addlinebreak(); - $kiriwrite_presmodule->addlinebreak(); - $kiriwrite_presmodule->startbox("datalist"); - $kiriwrite_presmodule->addtext($error_extended); - $kiriwrite_presmodule->endbox(); - - } - - $kiriwrite_presmodule->endbox(); - - kiriwrite_output_header; - kiriwrite_output_page($kiriwrite_lang->{error}->{error}, $kiriwrite_presmodule->grab(), "none"); - - exit; - -} - -sub kiriwrite_fileexists{ -################################################################################# -# kiriwrite_fileexists: Check if a file exists and returns a value depending on # -# if the file exists or not. # -# # -# Usage: # -# # -# kiriwrite_fileexists(filename); # -# # -# filename Specifies the file name to check if it exists or not. # -################################################################################# - - # Get the value that was passed to the subroutine. - - my ($filename) = @_; - - # Check if the filename exists, if it does, return a value of 0, else - # return a value of 1, meaning that the file was not found. - - if (-e $filename){ - - # Specified file does exist so return a value of 0. - - return 0; - - } else { - - # Specified file does not exist so return a value of 1. - - return 1; - - } - -} - -sub kiriwrite_filepermissions{ -################################################################################# -# kiriwrite_filepermissions: Check if the file permissions of a file and return # -# either a 1 saying that the permissions are valid or return a 0 saying that # -# the permissions are invalid. # -# # -# Usage: # -# # -# kiriwrite_filepermissions(filename, [read], [write], [filemissingskip]); # -# # -# filename Specifies the filename to check for permissions. # -# read Preform check that the file is readable. # -# write Preform check that the file is writeable. # -# filemissingskip Skip the check of seeing if it can read or write if the # -# file is missing. # -################################################################################# - - # Get the values that was passed to the subroutine. - - my ($filename, $readpermission, $writepermission, $ignorechecks) = @_; - - # Check to make sure that the read permission and write permission values - # are only 1 character long. - - kiriwrite_variablecheck($readpermission, "maxlength", 1, 0); - kiriwrite_variablecheck($writepermission, "maxlength", 1, 0); - kiriwrite_variablecheck($ignorechecks, "maxlength", 1, 0); - - my $ignorechecks_result = 0; - - # Check if the file should be ignored for read and write checking if - # it doesn't exist. - - if ($ignorechecks){ - - if (-e $filename){ - - # The file exists so the checks are to be done. - - $ignorechecks_result = 0; - - } else { - - # The file does not exist so the checks don't need to - # be done to prevent false positives. - - $ignorechecks_result = 1; - - } - - } else { - - $ignorechecks_result = 0; - - } - - # Check if the file should be checked to see if it can be read. - - if ($readpermission && $ignorechecks_result eq 0){ - - # The file should be checked to see if it does contain read permissions - # and return a 0 if it is invalid. - - if (-r $filename){ - - # The file is readable, so do nothing. - - } else { - - # The file is not readable, so return 1. - - return 1; - - } - - } - - # Check if the file should be checked to see if it can be written. - - if ($writepermission && $ignorechecks_result eq 0){ - - # The file should be checked to see if it does contain write permissions - # and return a 0 if it is invalid. - - if (-w $filename){ - - # The file is writeable, so do nothing. - - } else { - - # The file is not writeable, so return 1. - - return 1; - - } - - } - - # No problems have occured, so return 0. - - return 0; - -} - -sub kiriwrite_utf8convert{ -################################################################################# -# kiriwrite_utf8convert: Properly converts values into UTF-8 values. # -# # -# Usage: # -# # -# utfstring # The UTF-8 string to convert. # -################################################################################# - - # Get the values passed to the subroutine. - - my ($utfstring) = @_; - - # Load the Encode perl module. - - use Encode qw(decode_utf8); - - # Convert the string. - - my $finalutf8 = Encode::decode_utf8( $utfstring ); - - return $finalutf8; - -} - -sub kiriwrite_critical{ -################################################################################# -# kiriwrite_critical: Displays an critical error message that cannot be # -# normally by the kiriwrite_error subroutine. # -# # -# Usage: # -# # -# errortype Specifies the type of critical error that has occured. # -################################################################################# - - # Get the value that was passed to the subroutine. - - my ($error_type) = @_; - - my %error_list; - - # Get the error type from the errortype string. - - %error_list = ( - - # Generic critical error message. - - "generic" => "A critical error has occured but the error is not known to Kiriwrite.", - - # Specific critical error messages. - - "configfilemissing" => "The Kiriwrite configuration file is missing! Running the installer script for Kiriwrite is recommended.", - "configfileinvalidpermissions" => "The Kiriwrite configuration file has invalid permission settings set! Please set the valid permission settings for the configuration file.", - "dbmodulemissing" => "The database module is missing! Running the installer script for Kiriwrite is recommended.", - "dbmoduleinvalidpermissions" => "The database module cannot be used as it has invalid permission settings set! Please set the valid permission settings for the configuration file.", - "dbmoduleinvalid" => "The database module name given is invalid. Running the installer script for Kiriwrite is recommended.", - "invalidvalue" => "An invalid value was passed.", - "languagefilenameblank" => "The language filename given is blank! Running the installer script for Kiriwrite is recommended.", - "languagefilenameinvalid" => "The language filename given is invalid! Running the installer script for Kiriwrite is recommended.", - "languagefilemissing" => "The language filename given does not exist. Running the installer script for Kiriwrite is recommended.", - "languagefilenameinvalidpermissions" => "The language file with the filename given has invalid permissions set. Please set the valid permission settings for the language file.", - "presmodulemissing" => "The presentation module is missing! Running the installer script for Kiriwrite is recommended.", - "presmoduleinvalidpermissions" => "The presentation module cannot be used as it has invalid permission settings set! Please set the valid permission settings for the presentation module.", - "presmoduleinvalid" => "The presentation module name given is invalid. Running the installer script for Kiriwrite is recommended.", - "textarearowblank" => "The text area row value given is blank.", - "textarearowtoolong" => "The text area row value is too long. Running the installer script for Kiriwrite is recommended.", - "textarearowinvalid" => "The text area row value is invalid. Running the installer script for Kiriwrite is recommended.", - "textareacolblank" => "The text area row value given is blank.", - "textareacoltoolong" => "The text area column value is too long. Running the installer script for Kiriwrite is recommended.", - "textareacolinvalid" => "The text area column value is invalid. Running the installer script for Kiriwrite is recommended.", - - ); - - if (!$error_list{$error_type}){ - - $error_type = "generic"; - - } - - print "Expires: Sun, 01 Jan 2006 00:00:00 GMT\r\n"; - print "Content-Type: charset=utf-8;\r\n\r\n"; - print "Critical Error: " . $error_list{$error_type}; - exit; - -} - -sub kiriwrite_output_page{ -################################################################################# -# kiriwrite_output_page: Outputs the page to the browser/stdout/console. # -# # -# Usage: # -# # -# kiriwrite_output_page(pagetitle, pagedata, menutype); # -# # -# pagetitle Specifies the page title. # -# pagedata Specifies the page data. # -# menutype Prints out which menu to use. # -################################################################################# - - my ($pagetitle, $pagedata, $menutype) = @_; - - # Open the script page template and load it into the scriptpage variable, - # while declaring the variable. - - open (my $filehandle_scriptpage, "<:utf8", 'page.html'); - my @scriptpage = <$filehandle_scriptpage>; - binmode $filehandle_scriptpage, ':utf8'; - close ($filehandle_scriptpage); - - # Define the variables required. - - my $scriptpageline = ""; - my $pageoutput = ""; - my $menuoutput = ""; - - $kiriwrite_presmodule->clear(); - - # Print out the main menu for Kiriwrite. - - $kiriwrite_presmodule->addlink($kiriwrite_env{'script_filename'} . "?mode=db", { Text => $kiriwrite_lang->{menu}->{viewdatabases} }); - $kiriwrite_presmodule->addtext(" | "); - $kiriwrite_presmodule->addlink($kiriwrite_env{'script_filename'} . "?mode=page", { Text => $kiriwrite_lang->{menu}->{viewpages} }); - $kiriwrite_presmodule->addtext(" | "); - $kiriwrite_presmodule->addlink($kiriwrite_env{'script_filename'} . "?mode=filter", { Text => $kiriwrite_lang->{menu}->{viewfilters} }); - $kiriwrite_presmodule->addtext(" | "); - $kiriwrite_presmodule->addlink($kiriwrite_env{'script_filename'} . "?mode=template", { Text => $kiriwrite_lang->{menu}->{viewtemplates} }); - $kiriwrite_presmodule->addtext(" | "); - $kiriwrite_presmodule->addlink($kiriwrite_env{'script_filename'} . "?mode=compile", { Text => $kiriwrite_lang->{menu}->{compilepages} }); - $kiriwrite_presmodule->addtext(" | "); - $kiriwrite_presmodule->addlink($kiriwrite_env{'script_filename'} . "?mode=settings", { Text => $kiriwrite_lang->{menu}->{viewsettings} }); - $kiriwrite_presmodule->addlinebreak(); - - # Check what menu is going to be printed along with the default 'top' menu. - - if ($menutype eq "database"){ - - # If the menu type is database then print out the database sub-menu. - - $kiriwrite_presmodule->addlink($kiriwrite_env{'script_filename'} . "?mode=db", { Text => $kiriwrite_lang->{database}->{submenu_viewdatabases} }); - $kiriwrite_presmodule->addtext(" | "); - $kiriwrite_presmodule->addlink($kiriwrite_env{'script_filename'} . "?mode=db&action=new", { Text => $kiriwrite_lang->{database}->{submenu_adddatabase} }); - - } elsif ($menutype eq "pages"){ - # If the menu type is pages then print out the pages sub-menu. - - # First, fetch the database name from the HTTP query string. - - my $db_filename = $form_data->{'database'}; - - # Check if a value has been placed in the db_filename string. - - if (!$db_filename){ - - # As the database filename is blank, don't add an option to add a page. + use Modules::System::Filter; + if ($form_data->{'action'}){ + + # There is a value for action in the HTTP query, + # so get the value from it. + + my $http_query_action = $form_data->{'action'}; + + if ($http_query_action eq "add"){ + + # The action the user requested is to add a filter to the + # filter database. + + # Check if there is a value in confirm and if there is + # then pass it on to the new find and replace words + # to add to the filter database. + + my $http_query_confirm = $form_data->{'confirm'}; + + if ($http_query_confirm){ + + # There is a value in http_query_confirm, so pass on the + # new find and replace words so that they can be added + # to the filter database. + + my $http_query_findwords = $form_data->{'findword'}; + my $http_query_replacewords = $form_data->{'replaceword'}; + my $http_query_priority = $form_data->{'priority'}; + my $http_query_enabled = $form_data->{'enabled'}; + my $http_query_notes = $form_data->{'notes'}; + + my $pagedata = kiriwrite_filter_add({ FindFilter => $http_query_findwords, ReplaceFilter => $http_query_replacewords, Priority => $http_query_priority, Enabled => $http_query_enabled, Notes => $http_query_notes, Confirm => $http_query_confirm }); + #my $pagedata = kiriwrite_filter_add($http_query_findwords, $http_query_replacewords, $http_query_priority, $http_query_notes, $http_query_confirm); + + kiriwrite_output_header; # Output the header to browser/console/stdout. + kiriwrite_output_page($kiriwrite_lang{filter}{addfilter}, $pagedata, "filter"); # Output the page to browser/console/stdout. + exit; # End the script. + + } + + my $pagedata = kiriwrite_filter_add(); + + kiriwrite_output_header; # Output the header to browser/console/stdout. + kiriwrite_output_page($kiriwrite_lang{filter}{addfilter}, $pagedata, "filter"); # Output the page to browser/console/stdout. + exit; # End the script. + + } elsif ($http_query_action eq "edit"){ + + # The action the user requested is to edit an filter from + # the filter database. + + my $http_query_number = $form_data->{'filter'}; + my $http_query_confirm = $form_data->{'confirm'}; + + if ($http_query_confirm){ + + # There is a value in http_query_confirm, so pass on the + # new find and replace words so that the filter database + # can be edited. + + my $http_query_findwords = $form_data->{'filterfind'}; + my $http_query_replacewords = $form_data->{'filterreplace'}; + my $http_query_priority = $form_data->{'priority'}; + my $http_query_notes = $form_data->{'notes'}; + my $http_query_enabled = $form_data->{'enabled'}; + + my $pagedata = kiriwrite_filter_edit({ FilterID => $http_query_number, NewFindFilter => $http_query_findwords, NewReplaceFilter => $http_query_replacewords, NewPriority => $http_query_priority, NewEnabled => $http_query_enabled, NewFilterNotes => $http_query_notes, Confirm => $http_query_confirm }); + + kiriwrite_output_header; # Output the header to browser/console/stdout. + kiriwrite_output_page($kiriwrite_lang{filter}{editfilter}, $pagedata, "filter"); # Output the page to browser/console/stdout. + exit; # End the script. + + } + + my $pagedata = kiriwrite_filter_edit({ FilterID => $http_query_number }); + + kiriwrite_output_header; # Output the header to browser/console/stdout. + kiriwrite_output_page($kiriwrite_lang{filter}{editfilter}, $pagedata, "filter"); # Output the page to browser/console/stdout. + exit; # End the script. + + } elsif ($http_query_action eq "delete"){ + + # The action the user requested is to delete an filter + # from the filter database. + + my $http_query_number = $form_data->{'filter'}; + my $http_query_confirm = $form_data->{'confirm'}; + + if ($http_query_confirm){ + + my $pagedata = kiriwrite_filter_delete($http_query_number, $http_query_confirm); + + kiriwrite_output_header; # Output the header to browser/console/stdout. + kiriwrite_output_page($kiriwrite_lang{filter}{deletefilter}, $pagedata, "filter"); # Output the page to browser/console/stdout. + exit; # End the script + + } + + my $pagedata = kiriwrite_filter_delete($http_query_number); + + kiriwrite_output_header; # Output the header to browser/console/stdout. + kiriwrite_output_page($kiriwrite_lang{filter}{deletefilter}, $pagedata, "filter"); # Output the page to browser/console/stdout. + exit; # End the script. + + } elsif ($http_query_action eq "view"){ + + # The action the user requested is to view the list + # filters on the filter database. + + my $http_query_browsenumber = $form_data->{'browsenumber'}; + + my $pagedata = kiriwrite_filter_list($http_query_browsenumber); + + kiriwrite_output_header; # Output the header to browser/console/stdout. + kiriwrite_output_page($kiriwrite_lang{filter}{viewfilters}, $pagedata, "filter"); # Output the page to browser/console/stdout. + exit; # End the script. + + } else { + + # Another action was requested that was not one of + # the ones prcedding this catch all, so return + # an error saying that an invalid option was + # specified. + + kiriwrite_error("invalidaction"); + + } + } else { - - # A database file has been specified so add an option to add a page to - # the selected database. - - $kiriwrite_presmodule->addlink($kiriwrite_env{'script_filename'} . "?mode=page&action=add&database=" . $db_filename, { Text => $kiriwrite_lang->{pages}->{submenu_addpage} }); - + + my $pagedata = kiriwrite_filter_list(); + + kiriwrite_output_header; # Output the header to browser/console/stdout. + kiriwrite_output_page($kiriwrite_lang{filter}{viewfilters}, $pagedata, "filter"); # Output the page to browser/console/stdout. + exit; # End the script. + } - } elsif ($menutype eq "filter"){ - - # If the menu type is filters then print out the filter sub-menu. - - $kiriwrite_presmodule->addlink($kiriwrite_env{'script_filename'} . "?mode=filter", { Text => $kiriwrite_lang->{filter}->{submenu_showfilters} }); - $kiriwrite_presmodule->addtext(" | "); - $kiriwrite_presmodule->addlink($kiriwrite_env{'script_filename'} . "?mode=filter&action=add", { Text => $kiriwrite_lang->{filter}->{submenu_addfilter} }); - - } elsif ($menutype eq "settings"){ - - # If the menu type is options then print out the options sub-menu. - - $kiriwrite_presmodule->addlink($kiriwrite_env{'script_filename'} . "?mode=settings", { Text => $kiriwrite_lang->{setting}->{submenu_viewsettings} }); - $kiriwrite_presmodule->addtext(" | "); - $kiriwrite_presmodule->addlink($kiriwrite_env{'script_filename'} . "?mode=settings&action=edit", { Text => $kiriwrite_lang->{setting}->{submenu_editsettings} }); - - } elsif ($menutype eq "template"){ - - # If the menu type is template then print out the template sub-menu. - - $kiriwrite_presmodule->addlink($kiriwrite_env{'script_filename'} . "?mode=template", { Text => $kiriwrite_lang->{template}->{submenu_showtemplates} }); - $kiriwrite_presmodule->addtext(" | "); - $kiriwrite_presmodule->addlink($kiriwrite_env{'script_filename'} . "?mode=template&action=add", { Text => $kiriwrite_lang->{template}->{submenu_addtemplate} }); - - } elsif ($menutype eq "compile"){ - - # If the menu type is compile then print out the compile sub-menu. - - $kiriwrite_presmodule->addlink($kiriwrite_env{'script_filename'} . "?mode=compile", { Text => $kiriwrite_lang->{compile}->{submenu_listdatabases} }); - $kiriwrite_presmodule->addtext(" | "); - $kiriwrite_presmodule->addlink($kiriwrite_env{'script_filename'} . "?mode=compile&action=all", { Text => $kiriwrite_lang->{compile}->{submenu_compileall} }); - $kiriwrite_presmodule->addtext(" | "); - $kiriwrite_presmodule->addlink($kiriwrite_env{'script_filename'} . "?mode=compile&action=clean", { Text => $kiriwrite_lang->{compile}->{submenu_cleanoutputdirectory} }); - - } - - $menuoutput = $kiriwrite_presmodule->grab(); - - # Find tages and replace with the apporiate variables. + } elsif ($http_query_mode eq "compile"){ - foreach $scriptpageline (@scriptpage){ + use Modules::System::Compile; - $scriptpageline =~ s//$menuoutput/g; - $scriptpageline =~ s//$kiriwrite_config{"directory_noncgi_images"}/g; - $scriptpageline =~ s//$pagedata/g; + if ($form_data->{'action'}){ + + my $http_query_action = $form_data->{'action'}; + + if ($http_query_action eq "compile"){ + + # The specified action is to compile the pages, check if the + # action to compile the page has been confirmed. + + my $http_query_confirm = $form_data->{'confirm'}; + my $http_query_type = $form_data->{'type'}; + + # If it is blank, set the confirm value to 0. + + if (!$http_query_confirm){ + + # The http_query_confirm variable is uninitalised, so place a + # '0' (meaning an unconfirmed action). + + $http_query_confirm = 0; + + } + + # If the compile type is blank then return an error. + + if (!$http_query_type){ + + # Compile type is blank so return an error. + + kiriwrite_error("blankcompiletype"); + + } + + if ($http_query_type eq "multiple"){ + + if ($http_query_confirm eq 1){ + + # The action to compile the pages has been confirmed so + # compile the pages. + + my $http_query_override = $form_data->{'enableoverride'}; + my $http_query_overridetemplate = $form_data->{'overridetemplate'}; + my $http_query_outputmodule = $form_data->{'outputmodule'}; + + my @selectedlist = kiriwrite_selectedlist($form_data); + my %form_data_hash = $query_lite->parse_form_data; + kiriwrite_compile_loadhash(%form_data_hash); + my $pagedata = kiriwrite_compile_makepages($http_query_type, $http_query_confirm, $http_query_override, $http_query_overridetemplate, $http_query_outputmodule, @selectedlist); + + kiriwrite_output_header; # Output the header to browser/console/stdout. + kiriwrite_output_page($kiriwrite_lang{compile}{compilepages}, $pagedata, "compile"); # Output the page to browser/console/stdout. + exit; # End the script. + + } else { + + # The action to compile the pages has not been confirmed + # so write a form asking the user to confirm the action + # of compiling the pages. - # Check if page title specified is blank, otherwise add a page title - # to the title. + my $http_query_outputmodule = $form_data->{'outputmodule'}; - if ($pagetitle eq ""){ - $scriptpageline =~ s///g; - } else { - $scriptpageline =~ s// ($pagetitle)/g; + my @selectedlist = kiriwrite_selectedlist($form_data); + my $pagedata = kiriwrite_compile_makepages($http_query_type, $http_query_confirm, "", "", $http_query_outputmodule, @selectedlist); + + kiriwrite_output_header; # Output the header to browser/console/stdout. + kiriwrite_output_page($kiriwrite_lang{compile}{compileselecteddatabases}, $pagedata, "compile"); # Output the page to browser/console/stdout. + exit; # End the script. + + } + + } elsif ($http_query_type eq "single"){ + + my $http_query_database = $form_data->{'database'}; + my $http_query_outputmodule = $form_data->{'outputmodule'}; + my @selectedlist; + $selectedlist[0] = $http_query_database; + my $pagedata = kiriwrite_compile_makepages($http_query_type, $http_query_confirm, "", "", $http_query_outputmodule, @selectedlist); + + kiriwrite_output_header; # Output the header to browser/console/stdout. + kiriwrite_output_page($kiriwrite_lang{compile}{compiledatabase}, $pagedata, "compile"); + exit; # End the script. + + } else { + + kiriwrite_error("invalidcompiletype"); + + } + + } elsif ($http_query_action eq "all"){ + + # The selected action is to compile all of the databases + # in the database directory. Check if the action to + # compile all of the databases has been confirmed. + + my $http_query_confirm = $form_data->{'confirm'}; + my $http_query_outputmodule = $form_data->{'outputmodule'}; + + if (!$http_query_confirm){ + + # The http_query_confirm variable is uninitalised, so place a + # '0' (meaning an unconfirmed action). + + $http_query_confirm = 0; + + } + + my $pagedata = kiriwrite_compile_all($http_query_outputmodule); + + kiriwrite_output_header; # Output the header to browser/console/stdout. + kiriwrite_output_page($kiriwrite_lang{compile}{compilealldatabases}, $pagedata, "compile"); + exit; + + } elsif ($http_query_action eq "clean") { + + # The selected action is to clean the output directory. + # Check if the action to clean the output directory + # has been confirmed. + + my $http_query_confirm = $form_data->{'confirm'}; + + if (!$http_query_confirm){ + + # The http_query_confirm variable is uninitalised, so place a + # '0' (meaning an unconfirmed action). + + $http_query_confirm = 0; + + } + + if ($http_query_confirm eq 1){ + + # The action to clean the output directory has been confirmed. + + my $pagedata = kiriwrite_compile_clean($http_query_confirm); + + kiriwrite_output_header; # Output the header to browser/console/stdout. + kiriwrite_output_page($kiriwrite_lang{compile}{cleanoutputdirectory}, $pagedata, "compile"); # Output the page to browser/console/stdout. + exit; # End the script. + + } + + # The action to clean the output directory is not + # confirmed, so write a page asking the user + # to confirm cleaning the output directory. + + my $pagedata = kiriwrite_compile_clean(); + + kiriwrite_output_header; # Output the header to browser/console/stdout. + kiriwrite_output_page($kiriwrite_lang{compile}{cleanoutputdirectory}, $pagedata, "compile"); # Output the page to browser/console/stdout. + exit; # End the script. + + } else { + + # The action specified was something else other than those + # above, so return an error. + + kiriwrite_error("invalidaction"); + + } } - - - # Append processed line to the pageoutput variable. - - $pageoutput = $pageoutput . $scriptpageline; - - } - - binmode STDOUT, ':utf8'; - - print $pageoutput; - - return; - -} - -################################################################################# -# End listing the functions needed. # -################################################################################# - -################################################################################# -# Begin proper script execution. # -################################################################################# - -kiriwrite_settings_load; # Load the configuration options. - -my $query_lite = new CGI::Lite; - -# Check if a mode has been specified and if a mode has been specified, continue -# and work out what mode has been specified. - -$form_data = $query_lite->parse_form_data; - -if ($form_data->{'mode'}){ - my $http_query_mode = $form_data->{'mode'}; - - if ($http_query_mode eq "db"){ - - # If mode is 'db' (database), then load the database perl library and - # check what action is required. - - require "./lib/database.lib"; - - } elsif ($http_query_mode eq "page"){ - - # If mode is 'page', load the page library and then check what - # action is required. - - require "./lib/page.lib"; - - } elsif ($http_query_mode eq "filter"){ - - # Load the filter perl library and then check the - # value of the action HTTP query. - - require "./lib/filter.lib"; - - } elsif ($http_query_mode eq "template"){ - - # Load the template perl library and check if an action has - # been specified in the HTTP query. - - require "./lib/template.lib"; - - } elsif ($http_query_mode eq "compile"){ - - # Load the compile perl library. - - require "./lib/compile.lib"; - + my $pagedata = kiriwrite_compile_list(); + + kiriwrite_output_header; # Output the header to browser/console/stdout. + kiriwrite_output_page($kiriwrite_lang{compile}{compilepages}, $pagedata, "compile"); # Output the page to browser/console/stdout. + exit; # End the script. + } elsif ($http_query_mode eq "settings"){ - # Load the settings perl library. + use Modules::System::Settings; - require "./lib/settings.lib"; + if ($form_data->{'action'}){ + my $http_query_action = $form_data->{'action'}; + + if ($http_query_action eq "edit"){ + + # The action specified is to edit the settings. Check if the action + # to edit the settings has been confirmed. + + my $http_query_confirm = $form_data->{'confirm'}; + + if (!$http_query_confirm){ + + # The confirm value is blank, so set it to 0. + + $http_query_confirm = 0; + + } + + if ($http_query_confirm eq 1){ + + # The action to edit the settings has been confirmed. Get the + # required settings from the HTTP query. + + my $http_query_database = $form_data->{'databasedir'}; + my $http_query_output = $form_data->{'outputdir'}; + my $http_query_imagesuri = $form_data->{'imagesuripath'}; + my $http_query_datetimeformat = $form_data->{'datetime'}; + my $http_query_systemlanguage = $form_data->{'language'}; + my $http_query_presmodule = $form_data->{'presmodule'}; + my $http_query_dbmodule = $form_data->{'dbmodule'}; + my $http_query_outputmodule = $form_data->{'outputmodule'}; + my $http_query_textareacols = $form_data->{'textareacols'}; + my $http_query_textarearows = $form_data->{'textarearows'}; + my $http_query_pagecount = $form_data->{'pagecount'}; + my $http_query_filtercount = $form_data->{'filtercount'}; + my $http_query_templatecount = $form_data->{'templatecount'}; + + my $http_query_database_server = $form_data->{'database_server'}; + my $http_query_database_port = $form_data->{'database_port'}; + my $http_query_database_protocol = $form_data->{'database_protocol'}; + my $http_query_database_sqldatabase = $form_data->{'database_sqldatabase'}; + my $http_query_database_username = $form_data->{'database_username'}; + my $http_query_database_passwordkeep = $form_data->{'database_password_keep'}; + my $http_query_database_password = $form_data->{'database_password'}; + my $http_query_database_tableprefix = $form_data->{'database_tableprefix'}; + + my $pagedata = kiriwrite_settings_edit({ DatabaseDirectory => $http_query_database, OutputDirectory => $http_query_output, ImagesURIPath => $http_query_imagesuri, DateTimeFormat => $http_query_datetimeformat, SystemLanguage => $http_query_systemlanguage, PresentationModule => $http_query_presmodule, OutputModule => $http_query_outputmodule, TextAreaCols => $http_query_textareacols, TextAreaRows => $http_query_textarearows, PageCount => $http_query_pagecount, FilterCount => $http_query_filtercount, TemplateCount => $http_query_templatecount, DatabaseModule => $http_query_dbmodule, DatabaseServer => $http_query_database_server, DatabasePort => $http_query_database_port, DatabaseProtocol => $http_query_database_protocol, DatabaseSQLDatabase => $http_query_database_sqldatabase, DatabaseUsername => $http_query_database_username, DatabasePasswordKeep => $http_query_database_passwordkeep, DatabasePassword => $http_query_database_password, DatabaseTablePrefix => $http_query_database_tableprefix, Confirm => 1 }); + + kiriwrite_output_header; # Output the header to browser/console/stdout. + kiriwrite_output_page($kiriwrite_lang{setting}{editsettings}, $pagedata, "settings"); # Output the page to browser/console/stdout. + exit; # End the script. + + } + + # The action to edit the settings has not been confirmed. + + my $pagedata = kiriwrite_settings_edit(); + + kiriwrite_output_header; # Output the header to browser/console/stdout. + kiriwrite_output_page($kiriwrite_lang{setting}{editsettings}, $pagedata, "settings"); # Output the page to browser/console/stdout. + exit; # End the script. + + } else { + + # The action specified was something else other than those + # above, so return an error. + + kiriwrite_error("invalidaction"); + + } + + } + + # No action has been specified, so print out the list of settings currently being used. + + my $pagedata = kiriwrite_settings_view(); + + kiriwrite_output_header; # Output the header to browser/console/stdout. + kiriwrite_output_page($kiriwrite_lang{setting}{viewsettings}, $pagedata, "settings"); # Output the page to browser/console/stdout. + exit; # End the script. } else { - # Another mode has been specified than the ones above, so return an error saying that - # an invalid option was specified. + + # An invalid mode has been specified so return + # an error. kiriwrite_error("invalidmode"); - } + } + } else { # No mode has been specified, so print the default "first-run" view of the # database list. - require "./lib/database.lib"; + use Modules::System::Database; my $pagedata = kiriwrite_database_list(); kiriwrite_output_header; # Output the header to browser/console/stdout. kiriwrite_output_page("", $pagedata, "database"); # Output the page to browser/console/stdout. - exit; # End the script. + exit; # End the script. } -__END__ - -=head1 NAME - -Kiriwrite - -=head1 DESCRIPTION - -Web-based webpage compiler. - -=head1 AUTHOR - -Steve Brokenshire - -=head1 USAGE - -This perl script is intended to be used on a web server which has CGI with Perl support or with mod_perl support. - -=head1 DOCUMENTATION - -For more information on how to use Kiriwrite, please see the documentation that was included with Kiriwrite. - -- From the Xestia Documentation website: http://documentation.xestia.co.uk and click on the Kiriwrite link on the page. - -- From the Documentation directory from the Kiriwrite source packages (.tar/.tar.gz/.tar.bz2). - -- In the /usr/share/doc/kiriwrite directory if you installed the distribution-specific packages (and also have access to the server itself). \ No newline at end of file +__END__ \ No newline at end of file