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.
%kiriwrite_version = (
"major" => 0,
- "minor" => 1,
+ "minor" => 2,
"revision" => 0
);
"display_textarearows" => $config->{config}{display_textarearows},
"display_textareacols" => $config->{config}{display_textareacols},
+ "display_pagecount" => $config->{config}{display_pagecount},
+ "display_templatecount" => $config->{config}{display_templatecount},
+ "display_filtercount" => $config->{config}{display_filtercount},
"database_server" => $config->{config}{database_server},
"database_port" => $config->{config}{database_port},
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);
+ my $kiriwrite_config_pagecount_maxlength = kiriwrite_variablecheck($kiriwrite_config{"display_pagecount"}, "maxlength", 4, 1);
+ my $kiriwrite_config_pagecount_number = kiriwrite_variablecheck($kiriwrite_config{"display_pagecount"}, "numbers", 0, 1);
+ my $kiriwrite_config_templatecount_maxlength = kiriwrite_variablecheck($kiriwrite_config{"display_templatecount"}, "maxlength", 4, 1);
+ my $kiriwrite_config_templatecount_number = kiriwrite_variablecheck($kiriwrite_config{"display_templatecount"}, "numbers", 0, 1);
+ my $kiriwrite_config_filtercount_maxlength = kiriwrite_variablecheck($kiriwrite_config{"display_filtercount"}, "maxlength", 4, 1);
+ my $kiriwrite_config_filtercount_number = kiriwrite_variablecheck($kiriwrite_config{"display_filtercount"}, "numbers", 0, 1);
# Check if the language filename is valid and return an critical error if
# they aren't.
}
+ # Check if the amount of items per view settings are blank and return a critical
+ # error if they are.
+
+ if (!$kiriwrite_config{"display_pagecount"}){
+
+ # The display page count is blank so return a
+ # critical error.
+
+ kiriwrite_critical("pagecountblank");
+
+ }
+
+ if (!$kiriwrite_config{"display_templatecount"}){
+
+ # The display template count is blank so return
+ # a critical error.
+
+ kiriwrite_critical("templatecountblank");
+
+ }
+
+ if (!$kiriwrite_config{"display_filtercount"}){
+
+ # The display filter count is blank so return a
+ # critical error.
+
+ kiriwrite_critical("filtercountblank");
+
+ }
+
+ # Check if the amount of items per view settings are valid and return a critical
+ # error message if they aren't.
+
+ if ($kiriwrite_config_pagecount_maxlength eq 1){
+
+ # The length of the page count value is too long
+ # so return a critical error.
+
+ kiriwrite_critical("pagecounttoolong");
+
+ }
+
+ if ($kiriwrite_config_pagecount_number eq 1){
+
+ # The page count value is invalid so return
+ # a critical error.
+
+ kiriwrite_critical("pagecountinvalid");
+
+ }
+
+ if ($kiriwrite_config_templatecount_maxlength eq 1){
+
+ # The length of the template count value is too
+ # long so return a critical error.
+
+ kiriwrite_critical("filtercounttoolong");
+
+ }
+
+ if ($kiriwrite_config_templatecount_number eq 1){
+
+ # The template count value is invalid so return
+ # a critical error.
+
+ kiriwrite_critical("filtercountinvalid");
+
+ }
+
+ if ($kiriwrite_config_filtercount_maxlength eq 1){
+
+ # The length of the filter count value is too
+ # long so return a critical error.
+
+ kiriwrite_critical("templatecounttoolong");
+
+ }
+
+ if ($kiriwrite_config_filtercount_number eq 1){
+
+ # The filter count value is invalid so return
+ # a critical error.
+
+ kiriwrite_critical("templatecountinvalid");
+
+ }
+
# Check if the language file does exist before loading it and return an critical error
# if it does not exist.
# Language file contains invalid permissions so return an critical error.
- kiriwrite_critical("languagefilepermissions");
+ kiriwrite_critical("languagefilenameinvalidpermissions");
}
}
- # 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).
+ my $chunk = 0;
+ my $process = 8192;
+ my $length = 0;
+ my $chunkdata = "";
- return 1;
-
- } elsif ($variable_noerror eq 0) {
+ while ($chunk < $length){
- # The no error value has been set to 0, so return
- # an error.
+ $chunkdata = substr($variable_data, $chunk, $process);
- kiriwrite_error("invalidutf8");
+ if ($chunkdata =~ m/\A(
+ [\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
+ )*\z/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");
+
+ }
+
+ }
- # The no error value is something else other than 0
- # or 1, so return an error.
-
- kiriwrite_error("invalidoption");
- }
+ $chunk = $chunk + $process;
}
+# # 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"){
# 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";
+ print "Content-Type: text/html; charset=utf-8;\r\n\r\n";
return;
}
"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"
+ "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", "filtercountinvalid", "filtercounttoolong", "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", "pagecountinvalid", "pagecounttoolong", "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", "templatecountinvalid", "templatecounttoolong", "templatenameblank", "templatefilenameexists", "templatefilenameinvalid", "templatedatabaseerror", "templatedatabaseinvalidpermissions", "templatedatabaseinvalidformat", "templatedirectoryblank", "templatedirectoryinvalid", "templatedatabasenotcreated", "templatefilenametoolong", "templatenametoolong", "templatedescriptiontoolong", "templatedatabasemissing", "templatedoesnotexist", "templatefilenameblank", "textarearowblank", "textarearowtoolong", "textarearowinvalid", "textareacolblank", "textareacoltoolong", "textareacolinvalid"
);
my $finalutf8 = Encode::decode_utf8( $utfstring );
return $finalutf8;
+ #return $utfstring;
}
"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.",
+ "textarearowblank" => "The text area row value given is blank. Running the installer script for Kiriwrite is recommended.",
"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.",
+ "textareacolblank" => "The text area row value given is blank. Running the installer script for Kiriwrite is recommended.",
"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.",
+ "pagecountblank" => "The page count value is blank. Running the installer script for Kiriwrite is recommended.",
+ "templatecountblank" => "The template count value is blank. Running the installer script for Kiriwrite is recommended.",
+ "filtercountblank" => "The filter count value is blank. Running the installer script for Kiriwrite is recommended.",
+ "pagecounttoolong" => "The page count value is too long. Running the installer script for Kiriwrite is recommended.",
+ "templatecounttoolong" => "The template count value is too long. Running the installer script for Kiriwrite is recommended.",
+ "filtercounttoolong" => "The filter count value is too long. Running the installer script for Kiriwrite is recommended.",
+ "pagecountinvalid" => "The page count value is invalid. Running the installer script for Kiriwrite is recommended.",
+ "templatecountinvalid" => "The template count value is invalid. Running the installer script for Kiriwrite is recommended.",
+ "filtercountinvalid" => "The filter count is invalid. Running the installer script for Kiriwrite is recommended."
);
}
print "Expires: Sun, 01 Jan 2006 00:00:00 GMT\r\n";
- print "Content-Type: charset=utf-8;\r\n\r\n";
+ print "Content-Type: text/html; charset=utf-8;\r\n\r\n";
print "Critical Error: " . $error_list{$error_type};
exit;
}
- binmode STDOUT, ':utf8';
-
print $pageoutput;
return;