+Changes since version 0.3.0
+===========================
+
+- Added mod_perl support.
+- Config::Auto is no longer required as Kiriwrite uses it's own
+ mechanism for loading configuration and language files.
+- Fixed problem in Documentation where quotation marks were not showing
+ properly. This was prevalant in the Developer Documentation when
+ giving examples for subroutines.
+
Changes since version 0.2.0
===========================
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
- kiriwrite_compile_clean_helper(“directory”, 1);<br>\r
- $permissions = kiriwrite_compile_clean_helper(“directory”, 1);<br>\r
- kiriwrite_compile_clean_helper(“directory”, 1, 1);\r
+ kiriwrite_compile_clean_helper("directory", 1);<br>\r
+ $permissions = kiriwrite_compile_clean_helper("directory", 1);<br>\r
+ kiriwrite_compile_clean_helper("directory", 1, 1);\r
</div>\r
\r
<br>\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
- $pagedata = kiriwrite_compile_makepages(“single”, 0, 0, "", ['database1']);<br>\r
- $pagedata = kiriwrite_compile_makepages(“single”, 1, 0, "", ['database1']);<br>\r
- $pagedata = kiriwrite_compile_makepages(“multiple”, 0, 1, "template.html", ['database1','database2','database3','database4']);<br>\r
- $pagedata = kiriwrite_compile_makepages(“multiple”, 1, 0, "", ['database1','database2','database3','database4']);\r
+ $pagedata = kiriwrite_compile_makepages("single", 0, 0, "", ['database1']);<br>\r
+ $pagedata = kiriwrite_compile_makepages("single", 1, 0, "", ['database1']);<br>\r
+ $pagedata = kiriwrite_compile_makepages("multiple", 0, 1, "template.html", ['database1','database2','database3','database4']);<br>\r
+ $pagedata = kiriwrite_compile_makepages("multiple", 1, 0, "", ['database1','database2','database3','database4']);\r
</div>\r
\r
<br>\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
- kiriwrite_critical(“generic”);\r
+ kiriwrite_critical("generic");\r
</div>\r
\r
<br>\r
\r
<div class="code">\r
$pagedata = kiriwrite_database_add();<br>\r
-$pagedata = kiriwrite_database_add(“database”, “New Database”, “New Database Description”, “New Database Notes”, “new, database, categories”, 1);\r
+$pagedata = kiriwrite_database_add("database", "New Database", "New Database Description", "New Database Notes", "new, database, categories", 1);\r
</div>\r
\r
<br>\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
- $pagedata = kiriwrite_database_delete(“database”);<br>\r
- $pagedata = kiriwrite_database_delete(“database”, 1);\r
+ $pagedata = kiriwrite_database_delete("database");<br>\r
+ $pagedata = kiriwrite_database_delete("database", 1);\r
</div>\r
\r
<br>\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
- $pagedata = kiriwrite_database_edit(“database”);<br>\r
- $pagedata = kiriwrite_database_edit(“database”, “newdatabase”, “New Database Name”, “New Database Description”, “New Notes”, “new, edited, database, categories”, 1);\r
+ $pagedata = kiriwrite_database_edit("database");<br>\r
+ $pagedata = kiriwrite_database_edit("database", "newdatabase", "New Database Name", "New Database Description", "New Notes", "new, edited, database, categories", 1);\r
</div>\r
\r
<br>\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
- kiriwrite_error(“generic”);<br>\r
- kiriwrite_error(“databaseerror”, “Extended Error Information”);\r
+ kiriwrite_error("generic");<br>\r
+ kiriwrite_error("databaseerror", "Extended Error Information");\r
</div>\r
\r
<br>\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
- $file_exists = kiriwrite_fileexists(“filename”);\r
+ $file_exists = kiriwrite_fileexists("filename");\r
</div>\r
\r
<br>\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
- $file_permissions = kiriwrite_filepermissions(“test.html”, 1);<br>\r
- $file_permissions = kiriwrite_filepermissions(“test.html”, 1, 1);\r
- $file_permissions = kiriwrite_filepermissions(“test.html”, 1, 0, 1);\r
+ $file_permissions = kiriwrite_filepermissions("test.html", 1);<br>\r
+ $file_permissions = kiriwrite_filepermissions("test.html", 1, 1);\r
+ $file_permissions = kiriwrite_filepermissions("test.html", 1, 0, 1);\r
</div>\r
\r
<br>\r
\r
<div class="code">\r
$pagedata = kiriwrite_filter_add();<br>\r
- $pagedata = kiriwrite_filter_add(“Find this”, “And replace it with this”, 1, “Some notes about the filter itself for checking up later.”, 1);\r
+ $pagedata = kiriwrite_filter_add("Find this", "And replace it with this", 1, "Some notes about the filter itself for checking up later.", 1);\r
</div>\r
\r
<br>\r
\r
<div class="code">\r
$pagedata = kiriwrite_filter_edit(1);\r
- $pagedata = kiriwrite_filter_edit(1, “New filter find setting”, “New filter replace setting”, 1, “New filter notes”, 1);\r
+ $pagedata = kiriwrite_filter_edit(1, "New filter find setting", "New filter replace setting", 1, "New filter notes", 1);\r
</div>\r
\r
<br>\r
<head>\r
<link href="style.css" REL="stylesheet" TYPE="text/css" MEDIA="screen">\r
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">\r
- <title>Kiriwrite Documentation - Developer Documentation - 1.1: BEGIN</title>\r
+ <title>Kiriwrite Documentation - Developer Documentation - 1.1: kiriwrite_initalise</title>\r
</head>\r
<body>\r
<div class="menubarback">\r
</div>\r
</div>\r
<div class="pageinformation">\r
- <span class="pagetitle">1.1 BEGIN</span><br><br>\r
+ <span class="pagetitle">1.1 kiriwrite_initalise</span><br><br>\r
\r
-BEGIN is a subroutine that is used by the Perl interpreter to do things before running a script (Kiriwrite being the case). For Kiriwrite, it will process the script filename (as it's the full path name and only the last part which is the filename is needed). This allows Kiriwrite to be used with a different script filename.\r
+kiriwrite_initalise loads some variables before they are used throughout Kiriwrite (such as the script filename). This subroutine does not need to be called anywhere else.<br><br>\r
+\r
+<span class="heading">Parameters:</span><br><br>\r
+<div class="code">\r
+ kiriwrite_initalise();\r
+</div><br><br>\r
+\r
+<span class="heading">Usage:</span><br><br>\r
+<div class="code">\r
+ kiriwrite_initalise();\r
+</div>\r
</div>\r
</body>\r
</html>\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
- $string = kiriwrite_language(“%s, %s, %s, %s and %s!”, “one”, “two”, “three”, “four”, “five”);\r
+ $string = kiriwrite_language("%s, %s, %s, %s and %s!", "one", "two", "three", "four", "five");\r
</div>\r
\r
<br>\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
- kiriwrite_output_config({ DatabaseDirectory => “db”, OutputDirectory => “output”, ImagesURIPath => “/images/kiriwrite”, DateTimeFormat => “DD/MM/YY (hh:mm:ss)”, SystemLanguage => “en-GB”, PresentationModule => “HTML4S”, TextAreaCols => 50, TextAreaRows => 10, DatabaseModule => “SQLite”, DatabaseServer => “localhost”, DatabasePort => “3306”, DatabaseProtocol => “tcp”, DatabaseSQLDatabase => “database”, DatabaseUsername => “username”, DatabasePassword => “password”, DatabaseTablePrefix => “tableprefix” });\r
+ kiriwrite_output_config({ DatabaseDirectory => "db", OutputDirectory => "output", ImagesURIPath => "/images/kiriwrite", DateTimeFormat => "DD/MM/YY (hh:mm:ss)", SystemLanguage => "en-GB", PresentationModule => "HTML4S", TextAreaCols => 50, TextAreaRows => 10, DatabaseModule => "SQLite", DatabaseServer => "localhost", DatabasePort => "3306", DatabaseProtocol => "tcp", DatabaseSQLDatabase => "database", DatabaseUsername => "username", DatabasePassword => "password", DatabaseTablePrefix => "tableprefix" });\r
</div>\r
\r
<br>\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
- kiriwrite_output_page(“Page Title”, “This is the page data.”, “database”);\r
+ kiriwrite_output_page("Page Title", "This is the page data.", "database");\r
</div>\r
\r
<br>\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
-$pagedata = kiriwrite_page_add(“database”);<br>\r
-$pagedata = kiriwrite_page_add(“database”, “pagefilename.html”, “Page Name”, “Page Description”, “Page Section”, “pagetemplate.html”, 1, “Page Content, blah, blah, blah, blah”, 1);\r
+$pagedata = kiriwrite_page_add("database");<br>\r
+$pagedata = kiriwrite_page_add("database", "pagefilename.html", "Page Name", "Page Description", "Page Section", "pagetemplate.html", 1, "Page Content, blah, blah, blah, blah", 1);\r
</div>\r
\r
<br>\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
-$pagedata = kiriwrite_page_delete(“database”, “filename.html”);<br>\r
-$pagedata = kiriwrite_page_delete(“database”, “filename.html”, 1);\r
+$pagedata = kiriwrite_page_delete("database", "filename.html";<br>\r
+$pagedata = kiriwrite_page_delete("database", "filename.html", 1);\r
</div>\r
\r
<br>\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
-$pagedata = kiriwrite_page_edit(“database”, “oldfilename.html”);<br>\r
-$pagedata = kiriwrite_page_edit(“database”, “oldfilename.html”, “newfilename.html”, “New Page Filename”, “New Page Description”, “New Page Section”, “newtemplate.html”, 0, “New Page Content, blah, blah, blah, blah“, 1);\r
+$pagedata = kiriwrite_page_edit("database", "oldfilename.html");<br>\r
+$pagedata = kiriwrite_page_edit("database", "oldfilename.html", "newfilename.html", "New Page Filename", "New Page Description", "New Page Section", "newtemplate.html", 0, "New Page Content, blah, blah, blah, blah", 1);\r
</div>\r
\r
<br>\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
- $pagedata = kiriwrite_page_list(“database”, 1);\r
+ $pagedata = kiriwrite_page_list("database", 1);\r
</div>\r
\r
<br>\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
- $pagedata = kiriwrite_page_multicopy(“database”, “newdatabase”, 0, ['page1.html','page2.html','page3.html','page4.html']);<br>\r
- $pagedata = kiriwrite_page_multicopy(“database”, “newdatabase”, 1, ['page1.html','page2.html','page3.html','page4.html']);\r
+ $pagedata = kiriwrite_page_multicopy("database", "newdatabase", 0, ['page1.html','page2.html','page3.html','page4.html']);<br>\r
+ $pagedata = kiriwrite_page_multicopy("database", "newdatabase", 1, ['page1.html','page2.html','page3.html','page4.html']);\r
</div>\r
\r
<br>\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
-$pagedata = kiriwrite_page_multidelete(“database”, 0, ['page1.html','page2.html','page3.html','page4.html']);<br>\r
-$pagedata = kiriwrite_page_multidelete(“database”, 1, ['page1.html','page2.html','page3.html','page4.html']);\r
+$pagedata = kiriwrite_page_multidelete("database", 0, ['page1.html','page2.html','page3.html','page4.html']);<br>\r
+$pagedata = kiriwrite_page_multidelete("database", 1, ['page1.html','page2.html','page3.html','page4.html']);\r
</div>\r
\r
<br>\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
- $pagedata = kiriwrite_page_multiedit(“database”, “”, “”, “”, “”, “”, “”, 0, ['page1.html', 'page2.html', 'page3.html', 'page4.html']);<br>\r
- $pagedata = kiriwrite_page_multiedit(“database”, “New Section”, “on”, “newtemplate.html”, “on”, 0, “on”, 1, ['page1.html', 'page2.html', 'page3.html', 'page4.html']);\r
+ $pagedata = kiriwrite_page_multiedit("database", "", "", "", "", "", "", 0, ['page1.html', 'page2.html', 'page3.html', 'page4.html']);<br>\r
+ $pagedata = kiriwrite_page_multiedit("database", "New Section", "on", "newtemplate.html", "on", 0, "on", 1, ['page1.html', 'page2.html', 'page3.html', 'page4.html']);\r
</div>\r
\r
<br>\r
<spam class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
-$pagedata = kiriwrite_page_multimove(“olddatabase”, “newdatabase”, 0, ['page1.html','page2.html','page3.html','page4.html']);<br>\r
-$pagedata = kiriwrite_page_multimove(“olddatabase”, “newdatabase”, 1, ['page1.html','page2.html','page3.html','page4.html']);\r
+$pagedata = kiriwrite_page_multimove("olddatabase", "newdatabase", 0, ['page1.html','page2.html','page3.html','page4.html']);<br>\r
+$pagedata = kiriwrite_page_multimove("olddatabase", "newdatabase", 1, ['page1.html','page2.html','page3.html','page4.html']);\r
</div>\r
\r
<br>\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
- $filename = kiriwrite_processfilename(“For the 3rd time already”);\r
+ $filename = kiriwrite_processfilename("For the 3rd time already");\r
</div>\r
\r
<br>\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
- $pagedata = kiriwrite_settings_edit({ DatabaseDirectory => “db”, OutputDirectory => “output”, ImagesURIPath => “/images/kiriwrite”, DateTimeFormat => “DD/MM/YY (hh:mm:ss)”, SystemLanguage => “en-GB”, PresentationModule => “HTML4S”, TextAreaCols => 50, TextAreaRows => 10, DatabaseModule => “SQLite”, DatabaseServer => “localhost”, DatabasePort => “3306”, DatabaseProtocol => “tcp”, DatabaseSQLDatabase => “database”, DatabaseUsername => “username”, DatabasePasswordKeep => 0, DatabasePassword => “password”, DatabaseTablePrefix = “kiridev” });\r
+ $pagedata = kiriwrite_settings_edit({ DatabaseDirectory => "db", OutputDirectory => "output", ImagesURIPath => "/images/kiriwrite", DateTimeFormat => "DD/MM/YY (hh:mm:ss)", SystemLanguage => "en-GB", PresentationModule => "HTML4S", TextAreaCols => 50, TextAreaRows => 10, DatabaseModule => "SQLite", DatabaseServer => "localhost", DatabasePort => "3306", DatabaseProtocol => "tcp", DatabaseSQLDatabase => "database", DatabaseUsername => "username", DatabasePasswordKeep => 0, DatabasePassword => "password", DatabaseTablePrefix = "kiridev" });\r
</div>\r
\r
<br>\r
\r
<div class="code">\r
$pagedata = kiriwrite_template_add();<br>\r
- $pagedata = kiriwrite_template_add(“template.html”, “Template Filename”, “Template Description”, “This is the template layout, blah, blah, blah”, 1);\r
+ $pagedata = kiriwrite_template_add("template.html", "Template Filename", "Template Description", "This is the template layout, blah, blah, blah", 1);\r
</div>\r
\r
<br>\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
- $pagedata = kiriwrite_template_delete(“template.html”);<br>\r
- $pagedata = kiriwrite_template_delete(“template.html”, 1);\r
+ $pagedata = kiriwrite_template_delete("template.html");<br>\r
+ $pagedata = kiriwrite_template_delete("template.html", 1);\r
</div>\r
\r
<br>\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
- $pagedata = kiriwrite_template_edit(“template.html”);<br>\r
- $pagedata = kiriwrite_template_edit(“template.html”, “newtemplate.html”, “New Template Name”, “New Template Description”, “New Template Layout”, 1);\r
+ $pagedata = kiriwrite_template_edit("template.html");<br>\r
+ $pagedata = kiriwrite_template_edit("template.html", "newtemplate.html", "New Template Name", "New Template Description", "New Template Layout", 1);\r
</div>\r
\r
<br>\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
- $utf8_string = kiriwrite_convert(“This string should now be a UTF-8 formatted string.”);\r
+ $utf8_string = kiriwrite_convert("This string should now be a UTF-8 formatted string.");\r
</div>\r
\r
<br>\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
- kiriwrite_variablecheck(“Test 123”, “lettersnumbers”, “”, 0);<br>\r
- $letters_letnum_check = kiriwrite_variablecheck(“Test 123”, “lettersnumbers”, “”, 1);\r
+ kiriwrite_variablecheck("Test 123", "lettersnumbers", "", 0);<br>\r
+ $letters_letnum_check = kiriwrite_variablecheck("Test 123", "lettersnumbers", "", 1);\r
</div>\r
\r
<br>\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
- $kiriwrite_presmodule->addboldtext(“This is text but formatted in bold.”, { Style => “boldtext” });\r
+ $kiriwrite_presmodule->addboldtext("This is text but formatted in bold.", { Style => "boldtext" });\r
</div>\r
\r
<br>\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
- $kiriwrite_presmodule->addbutton(“button”, { Value => “clicked”, Description => “Click this button”, Style => “buttonstyle” });\r
+ $kiriwrite_presmodule->addbutton("button", { Value => "clicked", Description => "Click this button", Style => "buttonstyle" });\r
</div>\r
\r
<br>\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
-$kiriwrite_presmodule->addcell(“tablecellstyle”);\r
+$kiriwrite_presmodule->addcell("tablecellstyle");\r
</div>\r
\r
<br>\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
- $kiriwrite_presmodule->addcheckbox(“checkbox”, { OptionDescription => “Check box”, Style => “checkboxstyle”, LineBreak => 1 } );\r
+ $kiriwrite_presmodule->addcheckbox("checkbox", { OptionDescription => "Check box", Style => "checkboxstyle", LineBreak => 1 } );\r
</div>\r
\r
<br>\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
- $kiriwrite_presmodule->addheader(“Header Name”, { Style => “tableheader” });\r
+ $kiriwrite_presmodule->addheader("Header Name", { Style => "tableheader" });\r
</div>\r
\r
<br>\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
- $kiriwrite_presmodule->addhiddendata(“hidden”, “data”);\r
+ $kiriwrite_presmodule->addhiddendata("hidden", "data");\r
</div>\r
\r
<br>\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
- $kiriwrite_presmodule->addimage(“image.png”, { Width => “100”, Height => “100”, Description => “This is an image.” });\r
+ $kiriwrite_presmodule->addimage("image.png", { Width => "100", Height => "100", Description => "This is an image." });\r
</div>\r
\r
<br>\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
- $kiriwrite_presmodule->addinputbox(“inputbox”, { Size => “64”, MaxLength => “128”, Style => “inputbox”, Value => “Default” });\r
+ $kiriwrite_presmodule->addinputbox("inputbox", { Size => "64", MaxLength => "128", Style => "inputbox", Value => "Default" });\r
</div>\r
\r
<br>\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
- $kiriwrite_presmodule->additalictext(“This is italic formatted text.”, { Style => “italictext” });\r
+ $kiriwrite_presmodule->additalictext("This is italic formatted text.", { Style => "italictext" });\r
</div>\r
\r
<br>\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
- $kiriwrite_presmodule->additem(“This is an item”, { Style => “itemstyle” });\r
+ $kiriwrite_presmodule->additem("This is an item", { Style => "itemstyle" });\r
</div>\r
\r
<br>\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
- $kiriwrite_presmodule->addlink(“kiriwrite.cgi?mode=db”, { Text => “View the database list.” });\r
+ $kiriwrite_presmodule->addlink("kiriwrite.cgi?mode=db", { Text => "View the database list." });\r
</div>\r
\r
<br>\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
- $kiriwrite_presmodule->addoption(“Option Name”, { Style => “option”, Value => “optionvalue” });\r
+ $kiriwrite_presmodule->addoption("Option Name", { Style => "option", Value => "optionvalue" });\r
</div>\r
\r
<br>\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
- $kiriwrite_presmodule->addradiobox(“radiobox”, { Description => “Radio box”, Selected => 1, Value => “radioboxselected” } );\r
+ $kiriwrite_presmodule->addradiobox("radiobox", { Description => "Radio box", Selected => 1, Value => "radioboxselected" } );\r
</div>\r
\r
<br>\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
- $kiriwrite_presmodule->addreset(“Reset this”, { Style => “resetbutton” });\r
+ $kiriwrite_presmodule->addreset("Reset this", { Style => "resetbutton" });\r
</div>\r
\r
<br>\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
- $kiriwrite_presmodule->addselectbox(“selectbox”, { Style => “selectbox” });\r
+ $kiriwrite_presmodule->addselectbox("selectbox", { Style => "selectbox" });\r
</div>\r
\r
<br>\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
- $kiriwrite_presmodule->addsubmit(“Submit This”, { Style => “submitbutton” });\r
+ $kiriwrite_presmodule->addsubmit("Submit This", { Style => "submitbutton" });\r
</div>\r
\r
<br>\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
- $kiriwrite_presmodule->addtext(“Here's some text.”, { Style => “textformat” });\r
+ $kiriwrite_presmodule->addtext("Here's some text.", { Style => "textformat" });\r
</div>\r
\r
<br>\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
- $kiriwrite_presmodule->addtextbox(“textbox”, { Columns => 25, Rows => 5, Style => “textbox”, Value => “This is a text box.” });\r
+ $kiriwrite_presmodule->addtextbox("textbox", { Columns => 25, Rows => 5, Style => "textbox", Value => "This is a text box." });\r
</div>\r
\r
<br>\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
- $kiriwrite_presmodule->convert();\r
+ $kiriwrite_presmodule->convert("http://link/%7Epage%quot;, "link");\r
</div>\r
\r
<br>\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
- $kiriwrite_presmodule->enterdata(“Data for the information box.”);\r
+ $kiriwrite_presmodule->enterdata("Data for the information box.");\r
</div>\r
\r
<br>\r
use strict;<br>\r
use warnings;<br><br>\r
\r
- our $VERSION = “(version)”;<br>\r
- my $pagedata = “”;\r
+ our $VERSION = "(version)";<br>\r
+ my $pagedata = "";\r
</div>\r
\r
<br>\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
- $kiriwrite_presmodule->startbox(“boxstyle”);\r
+ $kiriwrite_presmodule->startbox("boxstyle");\r
</div>\r
\r
style<br>\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
- $kiriwrite_presmodule->startform(“kiriwrite.cgi”, “POST”);\r
+ $kiriwrite_presmodule->startform("kiriwrite.cgi", "POST");\r
</div>\r
\r
<br>\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
- $kiriwrite_presmodule->starttable(“tablestyle”);<br>\r
- $kiriwrite_presmodule->starttable(“tablestyle”, { CellSpacing => 1, CellPadding => 1});\r
+ $kiriwrite_presmodule->starttable("tablestyle");<br>\r
+ $kiriwrite_presmodule->starttable("tablestyle", { CellSpacing => 1, CellPadding => 1});\r
</div>\r
\r
<br>\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
- $kiriwrite_dbmodule->adddatabase({ DatabaseFilename => “database”, DatabaseName => “Database Name”, DatabaseDescription => “Database Description”, DatabaseNotes => “Some notes about the database”, DatabaseCategories => “database, new, categories”, VersionMajor => 0, VersionMinor => 1, VersionRevision => 0 });\r
+ $kiriwrite_dbmodule->adddatabase({ DatabaseFilename => "database", DatabaseName => "Database Name", DatabaseDescription => "Database Description", DatabaseNotes => "Some notes about the database", DatabaseCategories => "database, new, categories", VersionMajor => 0, VersionMinor => 4, VersionRevision => 0 });\r
</div>\r
\r
<br>\r
\r
<div class="code">\r
$kiriwrite_dbmodule->connectfilter(1);\r
- $kiriwrite_dbmodule->addfilter({ FindFilter => “This is the find filter.”, ReplaceFilter => “This is the replace filter.”, Priority => 1, Enabled => 1, Notes => “Some notes about the filter.” });\r
+ $kiriwrite_dbmodule->addfilter({ FindFilter => "This is the find filter.", ReplaceFilter => "This is the replace filter.", Priority => 1, Enabled => 1, Notes => "Some notes about the filter." });\r
</div>\r
\r
<br>\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
- $kiriwrite_dbmodule->selectdb(“database”);<br>\r
- $kiriwrite_dbmodule->addpage({ PageFilename => “newpage.html”, PageName => “New Page Name”, PageDescription => “New Page Description”, PageSection => “New Page Section”, PageTemplate => “pagetemplate.html”, PageContent => “This is the new page content.”, PageSettings => 0 });\r
+ $kiriwrite_dbmodule->selectdb("database");<br>\r
+ $kiriwrite_dbmodule->addpage({ PageFilename => "newpage.html", PageName => "New Page Name", PageDescription => "New Page Description", PageSection => "New Page Section", PageTemplate => "pagetemplate.html", PageContent => "This is the new page content.", PageSettings => 0 });\r
</div>\r
\r
<br>\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
- $kiriwrite_dbmodule->addtemplate({ TemplateFilename => “template.html”, TemplateName => “Template Name”, TemplateDescription => “Template Description”, TemplateLayout => “This is the template layout.” });\r
+ $kiriwrite_dbmodule->addtemplate({ TemplateFilename => "template.html", TemplateName => "Template Name", TemplateDescription => "Template Description", TemplateLayout => "This is the template layout." });\r
</div>\r
\r
<br>\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
- $data_sql = $kiriwrite_dbmodule->convert(“This 'data' should be SQL formatted.”);\r
+ $data_sql = $kiriwrite_dbmodule->convert("This 'data' should be SQL formatted.");\r
</div>\r
\r
<br>\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
- $kiriwrite_dbmodule->selectdb(“database”);<br>\r
- $kiriwrite_dbmodule->selectseconddb(“newdatabase”);<br>\r
- $kiriwrite_dbmodule->copypage({ PageFilename => “page.html” });\r
+ $kiriwrite_dbmodule->selectdb("database");<br>\r
+ $kiriwrite_dbmodule->selectseconddb("newdatabase");<br>\r
+ $kiriwrite_dbmodule->copypage({ PageFilename => "page.html" });\r
</div>\r
\r
<br>\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
- $date_converted = $kiriwrite_dbmodule->dateconvert(“2007-08-25 20:36:00”);\r
+ $date_converted = $kiriwrite_dbmodule->dateconvert("2007-08-25 20:36:00");\r
</div>\r
\r
<br>\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
- $db_exists = $kiriwrite_dbmodule->dbexists(“database”);\r
+ $db_exists = $kiriwrite_dbmodule->dbexists("database");\r
</div>\r
\r
<br>\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
- $database_permissions = $kiriwrite_dbmodule->dbpermissions(“database”, 1, 1);\r
+ $database_permissions = $kiriwrite_dbmodule->dbpermissions("database", 1, 1);\r
</div>\r
\r
<br>\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
- $kiriwrite_dbmodule->deletedatabase({ DatabaseName => “database” });\r
+ $kiriwrite_dbmodule->deletedatabase({ DatabaseName => "database" });\r
</div>\r
\r
<br>\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
- $kiriwrite_dbmodule->selectdb(“database”);<br>\r
- $kiriwrite_dbmodule->deletepage({ PageFilename => “page.html” });\r
+ $kiriwrite_dbmodule->selectdb("database");<br>\r
+ $kiriwrite_dbmodule->deletepage({ PageFilename => "page.html" });\r
</div>\r
\r
<br>\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
- $kiriwrite_dbmodule->deletetemplate({ TemplateFilename => “template.html” });\r
+ $kiriwrite_dbmodule->deletetemplate({ TemplateFilename => "template.html" });\r
</div>\r
\r
<br>\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
- $kiriwrite_dbmodule->selectdb(“database”);<br>\r
- $kiriwrite_dbmodule->editdatabase({ DatabaseNewFilename => “newdatabase”, DatabaseName => “New Database Name”, DatabaseDescription => “New Database Description”, DatabaseNotes => “New Database Notes”, DatabaseCategories => “new, database, categories” });\r
+ $kiriwrite_dbmodule->selectdb("database");<br>\r
+ $kiriwrite_dbmodule->editdatabase({ DatabaseNewFilename => "newdatabase", DatabaseName => "New Database Name", DatabaseDescription => "New Database Description", DatabaseNotes => "New Database Notes", DatabaseCategories => "new, database, categories" });\r
</div>\r
\r
<br>\r
\r
<div class="code">\r
$kiriwrite_dbmodule->connectfilter();<br>\r
- $kiriwrite_dbmodule->editfilter({ FilterID => 1, NewFindFilter => “The new find filter setting.”, NewReplaceFilter => “The new replace filter setting.”, NewFilterPriority => 2, NewEnabled => 1, NewFilterNotes => “The new notes of the filter.” });\r
+ $kiriwrite_dbmodule->editfilter({ FilterID => 1, NewFindFilter => "The new find filter setting.", NewReplaceFilter => "The new replace filter setting.", NewFilterPriority => 2, NewEnabled => 1, NewFilterNotes => "The new notes of the filter." });\r
</div>\r
\r
options<br>\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
- $kiriwrite_dbmodule->selectdb(“database”);<br>\r
- $kiriwrite_dbmodule->editpage({ PageFilename => “page.html”, PageNewFilename => “editedpage.html”, PageNewName => “Edited Page Name”, PageNewDescription => “Edited Page Description”, PageNewSection => “Edited Page Section”, PageNewTemplate => “editedpagetemplate.html”, PageNewContent => “This is the edited page content.”, PageNewSettings => 0 });\r
+ $kiriwrite_dbmodule->selectdb("database");<br>\r
+ $kiriwrite_dbmodule->editpage({ PageFilename => "page.html", PageNewFilename => "editedpage.html", PageNewName => "Edited Page Name", PageNewDescription => "Edited Page Description", PageNewSection => "Edited Page Section", PageNewTemplate => "editedpagetemplate.html", PageNewContent => "This is the edited page content.", PageNewSettings => 0 });\r
</div>\r
\r
<br>\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
- $kiriwrite_dbmodule->edittemplate({ TemplateFilename => “template.html”, NewTemplateFilename => “newtemplate.html”, NewTemplateName => “New Template Name”, NewTemplateDescription => “New Template Description”, NewTemplateLayout => “This is the new template layout.” });\r
+ $kiriwrite_dbmodule->edittemplate({ TemplateFilename => "template.html", NewTemplateFilename => "newtemplate.html", NewTemplateName => "New Template Name", NewTemplateDescription => "New Template Description", NewTemplateLayout => "This is the new template layout." });\r
</div>\r
\r
<br>\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
- $kiriwrite_dbmodule->selectdb(“database”);<br>\r
+ $kiriwrite_dbmodule->selectdb("database");<br>\r
%database_info = $kiriwrite_dbmodule->getdatabaseinfo();\r
</div>\r
\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
- $kiriwrite_dbmodule->selectdb(“database”);<br><br>\r
+ $kiriwrite_dbmodule->selectdb("database");<br><br>\r
$page_count = $kiriwrite_dbmodule->getpagecount();\r
</div>\r
\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
- $kiriwrite_dbmodule->selectdb(“database”);<br>\r
- %pageinfo = $kiriwrite_dbmodule->getpageinfo({ PageFilename => “pagefilename.html”, Reduced => 1 });\r
+ $kiriwrite_dbmodule->selectdb("database");<br>\r
+ %pageinfo = $kiriwrite_dbmodule->getpageinfo({ PageFilename => "pagefilename.html", Reduced => 1 });\r
</div>\r
\r
<br>\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
- $kiriwrite_dbmodule->selectdb(“database”);<br>\r
+ $kiriwrite_dbmodule->selectdb("database");<br>\r
@pagelist = $kiriwrite_dbmodule->getpagelist({ StartFrom => 0, Limit => 50 });\r
</div>\r
\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
- $kiriwrite_dbmodule->selectseconddatabase(“database”);<br>\r
+ $kiriwrite_dbmodule->selectseconddatabase("database");<br>\r
%database_info = $kiriwrite_dbmodule->getseconddatabaseinfo();\r
</div>\r
\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
- $kiriwrite_dbmodule->gettemplateinfo({ TemplateFilename => “template.html”, Reduced => 1 });\r
+ $kiriwrite_dbmodule->gettemplateinfo({ TemplateFilename => "template.html", Reduced => 1 });\r
</div>\r
\r
<br>\r
use strict;<br>\r
use warnings;<br><br>\r
\r
- our $VERSION = “(version)”;<br>\r
+ our $VERSION = "(version)";<br>\r
my ($options, %options);<br>\r
my $database_handle;<br>\r
my $string_handle;<br>\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
- $kiriwrite_dbmodule->loadsettings({ Directory => “db”, DateTime => “DD/MM/YY (hh:mm:ss)”, Server => “localhost”, Port => “3306”, Protocol => “tcp”, Database => “database”, Username => “username”, Password => “password”, TablePrefix => “tableprefix” });\r
+ $kiriwrite_dbmodule->loadsettings({ Directory => "db", DateTime => "DD/MM/YY (hh:mm:ss)", Server => "localhost", Port => "3306", Protocol => "tcp", Database => "database", Username => "username", Password => "password", TablePrefix => "tableprefix" });\r
</div>\r
\r
<br>\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
- $kiriwrite_dbmodule->selectdb(“olddatabase”);<br>\r
- $kiriwrite_dbmodule->selectseconddb(“newdatabase”);<br>\r
- $kiriwrite_dbmodule->movepage({ PageFilename => “page.html” });\r
+ $kiriwrite_dbmodule->selectdb("olddatabase");<br> $kiriwrite_dbmodule->selectseconddb("newdatabase");<br>\r
+ $kiriwrite_dbmodule->movepage({ PageFilename => "page.html" });\r
</div>\r
\r
<br>\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
- $kiriwrite_dbmodule->selectdb({ DatabaseName => “database” });\r
+ $kiriwrite_dbmodule->selectdb({ DatabaseName => "database" });\r
</div>\r
\r
<br>\r
<span class="heading">Usage:</span><br><br>\r
\r
<div class="code">\r
- $kiriwrite_dbmodule->selectseconddb({ DatabaseName => “database” });\r
+ $kiriwrite_dbmodule->selectseconddb({ DatabaseName => "database" });\r
</div>\r
\r
<br>\r
\r
<a href="developer-introduction.html">Introduction</a><br>\r
<a href="developer-chapter1.html">Chapter 1: Internal Kiriwrite Subroutines</a><br>\r
- <a href="developer-chapter1-begin.html">1.1 BEGIN</a><br>\r
+ <a href="developer-chapter1-kiriwriteinitalise.html">1.1 kiriwrite_initalise</a><br>\r
<a href="developer-chapter1-kiriwritepagelist.html">1.2 kiriwrite_page_list</a><br>\r
<a href="developer-chapter1-kiriwritepageadd.html">1.3 kiriwrite_page_add</a><br>\r
<a href="developer-chapter1-kiriwritepageedit.html">1.4 kiriwrite_page_edit</a><br>\r
<a href="developer-chapter1-kiriwriteoutputheader.html">1.39 kiriwrite_output_header</a><br>\r
<a href="developer-chapter1-kiriwriteoutputconfig.html">1.40 kiriwrite_output_config</a><br>\r
<a href="developer-chapter1-kiriwriteoutputpage.html">1.41 kiriwrite_output_page</a><br>\r
+ <a href="developer-chapter1-kiriwriteprocessconfig.html">1.42 kiriwrite_processconfig</a><br>\r
<a href="developer-chapter2.html">Chapter 2: Presentation Module</a><br>\r
<a href="developer-chapter2-guidance.html">2.1 Guidance</a><br>\r
<a href="developer-chapter2-new.html">2.2 new</a><br>\r
--- /dev/null
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">\r
+<html>\r
+ <head>\r
+ <link href="style.css" REL="stylesheet" TYPE="text/css" MEDIA="screen">\r
+ <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">\r
+ <title>Kiriwrite Documentation - User Documentation - 4.4: Kiriwrite under mod_perl 2.x</title>\r
+ </head>\r
+ <body>\r
+ <div class="menubarback">\r
+ <div class="menubar">\r
+ <span class="apptitle">Kiriwrite</span>\r
+ <a href="index.html">Index</a> | <a href="user.html">User \r
+Documentation</a> | <a href="tutorial.html">Tutorial Documentation</a> | \r
+<a href="developer.html">Developer Documentation</a>\r
+ </div>\r
+ </div>\r
+ <div class="pageinformation">\r
+ <span class="pagetitle">4.4 Kiriwrite under mod_perl 2.x</span><br><br>\r
+\r
+Kiriwrite under mod_perl 2.x can be made a little bit faster by pre-loading modules when the Apache Web Server starts up. After installing Kiriwrite and making sure that it runs properly, insert the following line into your httpd.conf file/VirtualHost section:<br><br>\r
+\r
+<div class="code">\r
+PerlModule CGI::Lite DBI DBD::SQLite Tie::IxHash Encode\r
+</div>\r
+<br>\r
+\r
+Then restart the web server. This will preload the modules that are in Perl's module directory which are used throughout Kiriwrite.\r
+ </div>\r
+ </body>\r
+</html>\r
That was when I wrote the original Kiriwrite script which was coded pretty much to my own needs and wasn't really well organised and was coded in Perl (although not that brilliantly as strict and warnings weren't used since I was learning Perl at the time) and by the time I finished coding it, I was able to do what I needed to do with Kiriwrite.<br><br>\r
Around the end of 2005 (and after a two-year spell at St. Austell College which is now Cornwall College St. Austell) I decided to rewrite the Kiriwrite code because the original Kiriwrite did not do any input validation and so little of the code was commented which meant I forgot what everything did and I wanted to add some new features which would become useful in the future.<br><br>\r
The rewritten Kiriwrite version was pretty much done in October 2006, following a suggestion from a good friend I decided to replace the flat-file based system which I used since the original Kiriwrite with a file-based database system called SQLite. Once that was done pretty much around the end of January 2007, I then separated the database code, presentation code and language strings into separate modules and files which meant that a MySQL 5.x server-based database could be used instead of file-based SQLite. The presentation code used to render internal output from Kiriwrite was separated and placed in the HTML4S (HTML 4.01 Strict) presentation module. The language strings that was hard-coded were separated and placed in the English (British) language file.<br><br>\r
-After some minor tweaks, the rewritten Kiriwrite code was pretty much ready and once the documentation was written Kiriwrite was ready for release. What I would like to see in the future for Kiriwrite is to make it work with mod_perl and add some extra customisable features as some settings are currently hard-coded when they could very well not be hard-coded.<br><br>\r
+After some minor tweaks, the rewritten Kiriwrite code was pretty much ready and once the documentation was written Kiriwrite was ready for release. What I would like to see in the future for Kiriwrite is to make it work with mod_perl and add some extra customisable features as some settings are currently hard-coded when they could very well not be hard-coded. Support for mod_perl 2.x has been available since version 0.4.0.<br><br>\r
I leave you with some advice, if you are going to design a website which uses a white background don't assume everyone will use a white background by default if no colour is specified and actually declare it as white background in the Cascading Style Sheet markup. You'd be amazed at how many commercial websites and some personal websites (that expect you to have) assume you have a white background when really you have a teal coloured background.\r
</div>\r
</body>\r
<a href="user-chapter4-securing.html">4.1: Securing your Kiriwrite installation</a><br>\r
<a href="user-chapter4-renaming.html">4.2: Renaming the Kiriwrite script (kiriwrite.cgi)</a><br>\r
<a href="user-chapter4-removing.html">4.3: Removing unneeded modules and language files</a><br>\r
+ <a href="user-chapter4-removing.html">4.4 Kiriwrite under mod_perl 2.x</a><br>\r
<a href="user-chapter5.html">Chapter 5: Troubleshooting</a><br>\r
<a href="user-chapter6.html">Chapter 6: Contributing to Kiriwrite</a>\r
\r
For information on installing Kiriwrite, see Chapter 1: Installation in
the User Documentation in the Documentation directory.
+
+mod_perl 2.x users please pay attention to the specific information for
+installing Kiriwrite under mod_perl 2.x in this Chapter.
\ No newline at end of file
# Define the package (perl module) name.
-package Kiriwrite::Database::MySQL5;
+package Modules::Database::MySQL5;
# Enable strict and use warnings.
priority int(5),
findsetting varchar(1024),
replacesetting varchar(1024),
+ enabled varchar(3),
notes text
) DEFAULT CHARSET=utf8') or ( $error = "FilterDatabaseError", $errorext = $database_handle->errstr, return );
$statement_handle->execute();
# Define the package (perl module) name.
-package Kiriwrite::Database::SQLite;
+package Modules::Database::SQLite;
# Enable strict and use warnings.
+use Modules::System::Common;
use strict;
use warnings;
# Check if the template database exists.
- my $filterdatabase_exists = main::kiriwrite_fileexists("filters.db.sqlite");
+ my $filterdatabase_exists = kiriwrite_fileexists("filters.db.sqlite");
if ($filterdatabase_exists eq 1){
# Check if the permission settings for the template database are valid.
- my $filterdb_permissions = main::kiriwrite_filepermissions("filters.db.sqlite", 1, 0);
+ my $filterdb_permissions = kiriwrite_filepermissions("filters.db.sqlite", 1, 0);
if ($filterdb_permissions eq 1){
# Check if the filter database permissions are valid.
- my $filterdb_exists = main::kiriwrite_fileexists("filters.db.sqlite", 1, 1);
- my $filterdb_permissions = main::kiriwrite_filepermissions("filters.db.sqlite", 1, 1);
+ my $filterdb_exists = kiriwrite_fileexists("filters.db.sqlite", 1, 1);
+ my $filterdb_permissions = kiriwrite_filepermissions("filters.db.sqlite", 1, 1);
if ($filterdb_permissions eq 1){
}
- my $directory_permissions = main::kiriwrite_filepermissions(".", 1, 1, 0);
+ my $directory_permissions = kiriwrite_filepermissions(".", 1, 1, 0);
if ($directory_permissions eq 1 && $filterdb_exists){
# Check if the filter database permissions are valid.
- my $filterdb_exists = main::kiriwrite_fileexists("filters.db.sqlite", 1, 1);
- my $filterdb_permissions = main::kiriwrite_filepermissions("filters.db.sqlite", 1, 1);
+ my $filterdb_exists = kiriwrite_fileexists("filters.db.sqlite", 1, 1);
+ my $filterdb_permissions = kiriwrite_filepermissions("filters.db.sqlite", 1, 1);
if ($filterdb_permissions eq 1){
# Check if the template database exists.
- my $templatedatabase_exists = main::kiriwrite_fileexists("templates.db.sqlite");
+ my $templatedatabase_exists = kiriwrite_fileexists("templates.db.sqlite");
if ($templatedatabase_exists eq 1){
# Check if the permission settings for the template database are valid.
- my $templatedb_permissions = main::kiriwrite_filepermissions("templates.db.sqlite", 1, 0);
+ my $templatedb_permissions = kiriwrite_filepermissions("templates.db.sqlite", 1, 0);
if ($templatedb_permissions eq 1){
# Check if the template database permissions are valid.
- my $templatedb_exists = main::kiriwrite_fileexists("templates.db.sqlite", 1, 1);
- my $templatedb_permissions = main::kiriwrite_filepermissions("templates.db.sqlite", 1, 1);
+ my $templatedb_exists = kiriwrite_fileexists("templates.db.sqlite", 1, 1);
+ my $templatedb_permissions = kiriwrite_filepermissions("templates.db.sqlite", 1, 1);
if ($templatedb_permissions eq 1){
}
- my $directory_permissions = main::kiriwrite_filepermissions(".", 1, 1, 0);
+ my $directory_permissions = kiriwrite_filepermissions(".", 1, 1, 0);
if ($directory_permissions eq 1 && $templatedb_exists){
# Create a template table.
- my $directory_permissions = main::kiriwrite_filepermissions(".", 1, 1, 0);
+ my $directory_permissions = kiriwrite_filepermissions(".", 1, 1, 0);
if ($directory_permissions eq 1){
# Check if the template database permissions are valid.
- my $templatedb_exists = main::kiriwrite_fileexists("templates.db.sqlite", 1, 1);
- my $templatedb_permissions = main::kiriwrite_filepermissions("templates.db.sqlite", 1, 1);
+ my $templatedb_exists = kiriwrite_fileexists("templates.db.sqlite", 1, 1);
+ my $templatedb_permissions = kiriwrite_filepermissions("templates.db.sqlite", 1, 1);
if ($templatedb_permissions eq 1){
# Define the package (perl module) name.
-package Kiriwrite::Presentation::HTML4S;
+package Modules::Presentation::HTML4S;
# Enable strict and use warnings.
--- /dev/null
+package Modules::System::Common;
+
+use strict;
+use warnings;
+use Exporter;
+use CGI::Lite;
+
+our @ISA = qw(Exporter);
+our @EXPORT = qw(kiriwrite_initalise kiriwrite_settings_load kiriwrite_fileexists kiriwrite_filepermissions kiriwrite_output_header kiriwrite_output_page kiriwrite_variablecheck kiriwrite_processconfig kiriwrite_processfilename kiriwrite_utf8convert kiriwrite_language kiriwrite_error kiriwrite_selectedlist);
+
+sub kiriwrite_selectedlist{
+#################################################################################
+# kiriwrite_page_selectedlist: Get the list of selected pages to use. #
+# #
+# Usage: #
+# #
+# kiriwrite_page_selectedlist(); #
+#################################################################################
+
+ my $form_data = shift;
+
+ my $count = $form_data->{'count'};
+
+ # Check if the list of files has a value and if not set it 0.
+
+ if (!$count){
+
+ $count = 0;
+
+ }
+
+ # Define some values for later.
+
+ my @filename_list;
+ my @selected_list;
+ my @final_list;
+
+ my $filename;
+ my $selected;
+
+ my $final_count = 0;
+ my $seek = 0;
+
+ # Get the list of filenames.
+
+ do {
+
+ # Get the values from id[]
+
+ $seek++;
+
+ $filename = $form_data->{'id[' . $seek . ']'};
+ $filename_list[$seek] = $filename;
+
+ } until ($seek eq $count || $count eq 0);
+
+ # Get the list of selected filenames.
+
+ $seek = 0;
+
+ do {
+
+ # Get the values from name[]
+
+ $seek++;
+
+ $selected = $form_data->{'name[' . $seek . ']'};
+
+ if (!$selected){
+
+ $selected = 'off';
+
+ }
+
+ $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"){
+
+ $filename = $filename_list[$seek];
+ $final_list[$final_count] = $filename;
+ $final_count++;
+
+ }
+
+ } until ($seek eq $count || $count eq 0);
+
+ return @final_list;
+
+}
+
+sub kiriwrite_initalise{
+#################################################################################
+# kiriwrite_initalise: 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.
+
+ %main::kiriwrite_env = (
+ "script_filename" => $script_filename,
+ );
+
+}
+
+sub kiriwrite_settings_load{
+#################################################################################
+# kiriwrite_settings_load: Load the configuration settings into the global #
+# variables. #
+# #
+# Usage: #
+# #
+# kiriwrite_settings_load(); #
+#################################################################################
+
+ # Check if the Kiriwrite configuration file exists before using it and
+ # return an critical error if it doesn't exist.
+
+ my ($kiriwrite_settingsfilehandle, @config_data, %config, $config);
+ 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';
+
+ open($kiriwrite_settingsfilehandle, $kiriwrite_conf_file);
+ binmode $kiriwrite_settingsfilehandle, ':utf8';
+ @config_data = <$kiriwrite_settingsfilehandle>;
+ %config = kiriwrite_processconfig(@config_data);
+ close($kiriwrite_settingsfilehandle);
+
+ # Go and fetch the settings and place them into a hash (that is global).
+
+ %main::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},
+ "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},
+ "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($main::kiriwrite_config{"directory_data_db"}, "maxlength", 64, 0);
+ kiriwrite_variablecheck($main::kiriwrite_config{"directory_data_output"}, "maxlength", 64, 0);
+ kiriwrite_variablecheck($main::kiriwrite_config{"directory_noncgi_images"}, "maxlength", 512, 0);
+ kiriwrite_variablecheck($main::kiriwrite_config{"directory_data_template"}, "maxlength", 64, 0);
+
+ my $kiriwrite_config_language_filename = kiriwrite_variablecheck($main::kiriwrite_config{"system_language"}, "language_filename", "", 1);
+ my $kiriwrite_config_presmodule_filename = kiriwrite_variablecheck($main::kiriwrite_config{"system_presmodule"}, "module", 0, 1);
+ my $kiriwrite_config_dbmodule_filename = kiriwrite_variablecheck($main::kiriwrite_config{"system_dbmodule"}, "module", 0, 1);
+
+ my $kiriwrite_config_textarearows_maxlength = kiriwrite_variablecheck($main::kiriwrite_config{"display_textarearows"}, "maxlength", 3, 1);
+ my $kiriwrite_config_textarearows_number = kiriwrite_variablecheck($main::kiriwrite_config{"display_textareacols"}, "numbers", 0, 1);
+ my $kiriwrite_config_textareacols_maxlength = kiriwrite_variablecheck($main::kiriwrite_config{"display_textareacols"}, "maxlength", 3, 1);
+ my $kiriwrite_config_textareacols_number = kiriwrite_variablecheck($main::kiriwrite_config{"display_textareacols"}, "numbers", 0, 1);
+ my $kiriwrite_config_pagecount_maxlength = kiriwrite_variablecheck($main::kiriwrite_config{"display_pagecount"}, "maxlength", 4, 1);
+ my $kiriwrite_config_pagecount_number = kiriwrite_variablecheck($main::kiriwrite_config{"display_pagecount"}, "numbers", 0, 1);
+ my $kiriwrite_config_templatecount_maxlength = kiriwrite_variablecheck($main::kiriwrite_config{"display_templatecount"}, "maxlength", 4, 1);
+ my $kiriwrite_config_templatecount_number = kiriwrite_variablecheck($main::kiriwrite_config{"display_templatecount"}, "numbers", 0, 1);
+ my $kiriwrite_config_filtercount_maxlength = kiriwrite_variablecheck($main::kiriwrite_config{"display_filtercount"}, "maxlength", 4, 1);
+ my $kiriwrite_config_filtercount_number = kiriwrite_variablecheck($main::kiriwrite_config{"display_filtercount"}, "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 (!$main::kiriwrite_config{"display_textarearows"}){
+
+ # The text area row value is blank so return
+ # a critical error.
+
+ kiriwrite_critical("textarearowblank");
+
+ }
+
+ if (!$main::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 amount of items per view settings are blank and return a critical
+ # error if they are.
+
+ if (!$main::kiriwrite_config{"display_pagecount"}){
+
+ # The display page count is blank so return a
+ # critical error.
+
+ kiriwrite_critical("pagecountblank");
+
+ }
+
+ if (!$main::kiriwrite_config{"display_templatecount"}){
+
+ # The display template count is blank so return
+ # a critical error.
+
+ kiriwrite_critical("templatecountblank");
+
+ }
+
+ if (!$main::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.
+
+ my $kiriwrite_config_language_fileexists = kiriwrite_fileexists("lang/" . $main::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/" . $main::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("languagefilenameinvalidpermissions");
+
+ }
+
+ # Load the language file.
+
+ my ($kiriwrite_languagefilehandle, @lang_data);
+
+ open($kiriwrite_languagefilehandle, "lang/" . $main::kiriwrite_config{"system_language"} . ".lang");
+ @lang_data = <$kiriwrite_languagefilehandle>;
+ %main::kiriwrite_lang = kiriwrite_processconfig(@lang_data);
+ close($kiriwrite_languagefilehandle);
+
+ # 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/" . $main::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/" . $main::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/" . $main::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/" . $main::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::" . $main::kiriwrite_config{"system_presmodule"};
+ ($presmodulename) = $presmodulename =~ m/^(.*)$/g;
+ eval "use " . $presmodulename;
+ $presmodulename = "Modules::Presentation::" . $main::kiriwrite_config{"system_presmodule"};
+ $main::kiriwrite_presmodule = $presmodulename->new();
+ $main::kiriwrite_presmodule->clear();
+
+ # Load the database module.
+
+ my $dbmodulename = "Database::" . $main::kiriwrite_config{"system_dbmodule"};
+ ($dbmodulename) = $dbmodulename =~ m/^(.*)$/g;
+ eval "use " . $dbmodulename;
+ $dbmodulename = "Modules::Database::" . $main::kiriwrite_config{"system_dbmodule"};
+ $main::kiriwrite_dbmodule = $dbmodulename->new();
+
+ ($main::kiriwrite_config{"directory_data_db"}) = $main::kiriwrite_config{"directory_data_db"} =~ /^([a-zA-Z0-9.]+)$/;
+ ($main::kiriwrite_config{"directory_data_output"}) = $main::kiriwrite_config{"directory_data_output"} =~ /^([a-zA-Z0-9.]+)$/;
+
+ # Load the following settings to the database module.
+
+ $main::kiriwrite_dbmodule->loadsettings({ Directory => $main::kiriwrite_config{"directory_data_db"}, DateTime => $main::kiriwrite_config{"system_datetime"}, Server => $main::kiriwrite_config{"database_server"}, Port => $main::kiriwrite_config{"database_port"}, Protocol => $main::kiriwrite_config{"database_protocol"}, Database => $main::kiriwrite_config{"database_sqldatabase"}, Username => $main::kiriwrite_config{"database_username"}, Password => $main::kiriwrite_config{"database_password"}, TablePrefix => $main::kiriwrite_config{"database_tableprefix"} });
+
+ return;
+
+}
+
+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 ($main::kiriwrite_dbmodule){
+ $main::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", "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"
+
+ );
+
+ # 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 = $main::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 = $main::kiriwrite_lang{error}{generic};
+
+ }
+
+ $main::kiriwrite_presmodule->clear();
+
+ $main::kiriwrite_presmodule->startbox("errorbox");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{error}{error}, { Style => "errorheader" });
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($error_string, { Style => "errortext" });
+
+ # Check to see if extended error information was passed.
+
+ if ($error_extended){
+
+ # Write the extended error information.
+
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{error}{extendederror});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->startbox("datalist");
+ $main::kiriwrite_presmodule->addtext($error_extended);
+ $main::kiriwrite_presmodule->endbox();
+
+ }
+
+ $main::kiriwrite_presmodule->endbox();
+
+ &kiriwrite_output_header;
+ kiriwrite_output_page($main::kiriwrite_lang{error}{error}, $main::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;
+ #return $utfstring;
+
+}
+
+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. 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. 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."
+
+ );
+
+ if (!$error_list{$error_type}){
+
+ $error_type = "generic";
+
+ }
+
+ print "Content-Type: text/html; charset=utf-8;\r\n";
+ print "Expires: Sun, 01 Jan 2008 00:00:00 GMT\r\n\r\n";
+ print "Critical Error: " . $error_list{$error_type};
+ exit;
+
+}
+
+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_data){
+ $variable_data = "";
+ }
+
+ 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 = "";
+
+ }
+
+ my $chunk = 0;
+ my $process = 8192;
+ my $length = 0;
+ my $chunkdata = "";
+
+ while ($chunk < $length){
+
+ $chunkdata = substr($variable_data, $chunk, $process);
+
+ 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");
+
+ }
+
+ }
+
+
+ $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"){
+
+ # 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 "Content-Type: text/html; charset=utf8\r\n";
+ print "Expires: Sun, 01 Jan 2007 00:00:00 GMT\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_processconfig{
+#################################################################################
+# kiriwrite_processconfig: Processes an INI style configuration file. #
+# #
+# Usage: #
+# #
+# kiriwrite_processconfig(data); #
+# #
+# data Specifies the data to process. #
+#################################################################################
+
+ my (@settings) = @_;
+
+ my ($settings_line, %settings, $settings, $sectionname, $setting_name, $setting_value);
+
+ foreach $settings_line (@settings){
+
+ next if !$settings_line;
+
+ # Check if the first character is a bracket.
+
+ if (substr($settings_line, 0, 1) eq "["){
+ $settings_line =~ s/\[//;
+ $settings_line =~ s/\](.*)//;
+ $settings_line =~ s/\n//;
+ $sectionname = $settings_line;
+ next;
+ }
+
+ $setting_name = $settings_line;
+ $setting_value = $settings_line;
+ $setting_name =~ s/\=(.*)//;
+ $setting_name =~ s/\n//;
+ $setting_value =~ s/(.*)\=//;
+ $setting_value =~ s/\n//;
+
+ # Remove the spacing before and after the '=' sign.
+
+ $setting_name =~ s/\s+$//;
+ $setting_value =~ s/^\s+//;
+ $setting_value =~ s/\r//;
+
+ $settings{$sectionname}{$setting_name} = $setting_value;
+
+ }
+
+ return %settings;
+
+}
+
+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, $db_filename) = @_;
+
+ # 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);
+
+ my $query_lite = new CGI::Lite;
+ my $form_data = $query_lite->parse_form_data;
+
+ # Define the variables required.
+
+ my $scriptpageline = "";
+ my $pageoutput = "";
+
+ $main::kiriwrite_presmodule->clear();
+
+ # Print out the main menu for Kiriwrite.
+
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{'script_filename'} . "?mode=db", { Text => $main::kiriwrite_lang{menu}{viewdatabases} });
+ $main::kiriwrite_presmodule->addtext(" | ");
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{'script_filename'} . "?mode=page", { Text => $main::kiriwrite_lang{menu}{viewpages} });
+ $main::kiriwrite_presmodule->addtext(" | ");
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{'script_filename'} . "?mode=filter", { Text => $main::kiriwrite_lang{menu}{viewfilters} });
+ $main::kiriwrite_presmodule->addtext(" | ");
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{'script_filename'} . "?mode=template", { Text => $main::kiriwrite_lang{menu}{viewtemplates} });
+ $main::kiriwrite_presmodule->addtext(" | ");
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{'script_filename'} . "?mode=compile", { Text => $main::kiriwrite_lang{menu}{compilepages} });
+ $main::kiriwrite_presmodule->addtext(" | ");
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{'script_filename'} . "?mode=settings", { Text => $main::kiriwrite_lang{menu}{viewsettings} });
+ $main::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.
+
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{'script_filename'} . "?mode=db", { Text => $main::kiriwrite_lang{database}{submenu_viewdatabases} });
+ $main::kiriwrite_presmodule->addtext(" | ");
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{'script_filename'} . "?mode=db&action=new", { Text => $main::kiriwrite_lang{database}{submenu_adddatabase} });
+
+ } elsif ($menutype eq "pages"){
+ # If the menu type is pages then print out the pages sub-menu.
+
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{'script_filename'} . "?mode=page&action=add&database=" . $db_filename, { Text => $main::kiriwrite_lang{pages}{submenu_addpage} });
+
+ } elsif ($menutype eq "filter"){
+
+ # If the menu type is filters then print out the filter sub-menu.
+
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{'script_filename'} . "?mode=filter", { Text => $main::kiriwrite_lang{filter}{submenu_showfilters} });
+ $main::kiriwrite_presmodule->addtext(" | ");
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{'script_filename'} . "?mode=filter&action=add", { Text => $main::kiriwrite_lang{filter}{submenu_addfilter} });
+
+ } elsif ($menutype eq "settings"){
+
+ # If the menu type is options then print out the options sub-menu.
+
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{'script_filename'} . "?mode=settings", { Text => $main::kiriwrite_lang{setting}{submenu_viewsettings} });
+ $main::kiriwrite_presmodule->addtext(" | ");
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{'script_filename'} . "?mode=settings&action=edit", { Text => $main::kiriwrite_lang{setting}{submenu_editsettings} });
+
+ } elsif ($menutype eq "template"){
+
+ # If the menu type is template then print out the template sub-menu.
+
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{'script_filename'} . "?mode=template", { Text => $main::kiriwrite_lang{template}{submenu_showtemplates} });
+ $main::kiriwrite_presmodule->addtext(" | ");
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{'script_filename'} . "?mode=template&action=add", { Text => $main::kiriwrite_lang{template}{submenu_addtemplate} });
+
+ } elsif ($menutype eq "compile"){
+
+ # If the menu type is compile then print out the compile sub-menu.
+
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{'script_filename'} . "?mode=compile", { Text => $main::kiriwrite_lang{compile}{submenu_listdatabases} });
+ $main::kiriwrite_presmodule->addtext(" | ");
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{'script_filename'} . "?mode=compile&action=all", { Text => $main::kiriwrite_lang{compile}{submenu_compileall} });
+ $main::kiriwrite_presmodule->addtext(" | ");
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{'script_filename'} . "?mode=compile&action=clean", { Text => $main::kiriwrite_lang{compile}{submenu_cleanoutputdirectory} });
+
+ }
+
+ my $menuoutput = $main::kiriwrite_presmodule->grab();
+
+ # Find <kiriwrite> tages and replace with the apporiate variables.
+
+ foreach $scriptpageline (@scriptpage){
+
+ $scriptpageline =~ s/<kiriwrite:menu>/$menuoutput/g;
+ $scriptpageline =~ s/<kiriwrite:imagespath>/$main::kiriwrite_config{"directory_noncgi_images"}/g;
+ $scriptpageline =~ s/<kiriwrite:pagedata>/$pagedata/g;
+
+ # Check if page title specified is blank, otherwise add a page title
+ # to the title.
+
+ if (!$pagetitle || $pagetitle eq ""){
+ $scriptpageline =~ s/<kiriwrite:title>//g;
+ } else {
+ $scriptpageline =~ s/<kiriwrite:title>/ ($pagetitle)/g;
+ }
+
+
+
+ # Append processed line to the pageoutput variable.
+
+ $pageoutput = $pageoutput . $scriptpageline;
+
+ }
+
+ print $pageoutput;
+
+
+ return;
+
+}
+
+1;
\ No newline at end of file
-#################################################################################
-# compile.lib: Kiriwrite Compile Library #
-# #
-# This library is under the same license as the main Kiriwrite script. #
-#################################################################################
-
-# This section of the file is for when the library is called from the main
-# Kiriwrite script.
-
-# If the action option is left blank, then print out a form where the list
-# of databases to compile are available.
-
-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 @selectedlist = kiriwrite_selectedlist();
- my $pagedata = kiriwrite_compile_makepages($http_query_type, $http_query_confirm, $http_query_override, $http_query_overridetemplate, @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.
-
- my @selectedlist = kiriwrite_selectedlist();
- my $pagedata = kiriwrite_compile_makepages($http_query_type, $http_query_confirm, "", "", @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 @selectedlist;
- $selectedlist[0] = $http_query_database;
- my $pagedata = kiriwrite_compile_makepages($http_query_type, $http_query_confirm, "", "", @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");
-
- }
+package Modules::System::Compile;
- } elsif ($http_query_action eq "all"){
+use Modules::System::Common;
+use strict;
+use warnings;
+use Exporter;
- # 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'};
-
- 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 compile all the databases has been confirmed.
-
- }
-
- my $pagedata = kiriwrite_compile_all();
-
- 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");
-
- }
-}
-
-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.
-
-#################################################################################
-# Begin list of relevant subroutines. #
-#################################################################################
+our @ISA = qw(Exporter);
+our @EXPORT = qw(kiriwrite_compile_makepages kiriwrite_compile_all kiriwrite_compile_list kiriwrite_compile_clean kiriwrite_compile_clean_helper);
sub kiriwrite_compile_makepages{
#################################################################################
kiriwrite_variablecheck($override_template, "utf8", 0, 0);
$override_template = kiriwrite_utf8convert($override_template);
- $kiriwrite_overridetemplatefilename_length_check = kiriwrite_variablecheck($override_template, "maxlength", 64, 1);
- $kiriwrite_overridetemplatefilename_filename_check = kiriwrite_variablecheck($override_template, "filename", "", 1);
+ my $kiriwrite_overridetemplatefilename_length_check = kiriwrite_variablecheck($override_template, "maxlength", 64, 1);
+ my $kiriwrite_overridetemplatefilename_filename_check = kiriwrite_variablecheck($override_template, "filename", "", 1);
if ($kiriwrite_overridetemplatefilename_length_check eq 1){
my $filters_skip = 0;
my $template;
my $templates_skip = 0;
- my $information_prefix = $kiriwrite_lang->{compile}->{informationprefix};
- my $error_prefix = $kiriwrite_lang->{compile}->{errorprefix};
- my $warning_prefix = $kiriwrite_lang->{compile}->{warningprefix};
+ my $information_prefix = $main::kiriwrite_lang{compile}{informationprefix};
+ my $error_prefix = $main::kiriwrite_lang{compile}{errorprefix};
+ my $warning_prefix = $main::kiriwrite_lang{compile}{warningprefix};
my $filehandle_page;
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{compile}->{compiledatabases}, { Style => "pageheader" });
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->startbox("datalist");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{compile}{compiledatabases}, { Style => "pageheader" });
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->startbox("datalist");
# Check if the output directory exists and has
# valid permissions set.
- $output_exists = kiriwrite_fileexists($kiriwrite_config{'directory_data_output'});
+ $output_exists = kiriwrite_fileexists($main::kiriwrite_config{'directory_data_output'});
if ($output_exists ne 0){
}
- $output_permissions = kiriwrite_filepermissions($kiriwrite_config{'directory_data_output'}, 1, 1);
+ $output_permissions = kiriwrite_filepermissions($main::kiriwrite_config{'directory_data_output'}, 1, 1);
if ($output_permissions ne 0){
# Connect to the database server.
- $kiriwrite_dbmodule->connect();
+ $main::kiriwrite_dbmodule->connect();
# Check if any errors occured while connecting to the database server.
- if ($kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
# A database connection error has occured so return
# an error.
- kiriwrite_error("databaseconnectionerror", $kiriwrite_dbmodule->geterror(1));
+ kiriwrite_error("databaseconnectionerror", $main::kiriwrite_dbmodule->geterror(1));
}
# Connect to the filter database.
- $kiriwrite_dbmodule->connectfilter();
+ $main::kiriwrite_dbmodule->connectfilter();
# Check if any error has occured while connecting to the filter
# database.
- if ($kiriwrite_dbmodule->geterror eq "FilterDatabaseDoesNotExist"){
+ if ($main::kiriwrite_dbmodule->geterror eq "FilterDatabaseDoesNotExist"){
# The filter database does not exist so write a warning message.
- $kiriwrite_presmodule->addtext($warning_prefix . $kiriwrite_lang->{compile}->{filterdatabasemissing});
- $kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($warning_prefix . $main::kiriwrite_lang{compile}{filterdatabasemissing});
+ $main::kiriwrite_presmodule->addlinebreak();
$filters_skip = 1;
$warning_count++;
- } elsif ($kiriwrite_dbmodule->geterror eq "FilterDatabaseInvalidPermissionsSet"){
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "FilterDatabaseInvalidPermissionsSet"){
# The filter database has invalid permissions set so write a
# an error message.
- $kiriwrite_presmodule->addtext($error_prefix . $kiriwrite_lang->{compile}->{filterdatabasepermissions});
- $kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($error_prefix . $main::kiriwrite_lang{compile}{filterdatabasepermissions});
+ $main::kiriwrite_presmodule->addlinebreak();
$filters_skip = 1;
$error_count++;
# Get the list of available filters.
- @database_filters = $kiriwrite_dbmodule->getfilterlist();
+ @database_filters = $main::kiriwrite_dbmodule->getfilterlist();
# Check if any errors occured while getting the list of filters.
- if ($kiriwrite_dbmodule->geterror eq "FilterDatabaseError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "FilterDatabaseError"){
# A database error has occured with the filter database.
- $kiriwrite_presmodule->addtext($error_prefix . kiriwrite_language($kiriwrite_lang->{compile}->{filterdatabaseerror}, $kiriwrite_dbmodule->geterror(1)));
- $kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($error_prefix . kiriwrite_language($main::kiriwrite_lang{compile}{filterdatabaseerror}, $main::kiriwrite_dbmodule->geterror(1)));
+ $main::kiriwrite_presmodule->addlinebreak();
$error_count++;
}
# Get the filter information.
- %filter_info = $kiriwrite_dbmodule->getfilterinfo({ FilterID => $filter, Reduced => 1 });
+ %filter_info = $main::kiriwrite_dbmodule->getfilterinfo({ FilterID => $filter, Reduced => 1 });
# Check if the filter is enabled and if it isn't then process
# the next filter.
# Check if any errors occured while getting the filter information.
- if ($kiriwrite_dbmodule->geterror eq "FilterDatabaseError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "FilterDatabaseError"){
# A database error occured while using the filter database.
- $kiriwrite_presmodule->addtext($error_prefix . kiriwrite_language($kiriwrite_lang->{compile}->{filterdatabaseerror}, $kiriwrite_dbmodule->geterror(1)));
- $kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($error_prefix . kiriwrite_language($main::kiriwrite_lang{compile}{filterdatabaseerror}, $main::kiriwrite_dbmodule->geterror(1)));
+ $main::kiriwrite_presmodule->addlinebreak();
$error_count++;
next;
- } elsif ($kiriwrite_dbmodule->geterror eq "FilterDoesNotExist"){
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "FilterDoesNotExist"){
# The filter does not exist so process the next filter.
if ($filters_find_blank_warning ne 1){
- $kiriwrite_presmodule->addtext($warning_prefix . $kiriwrite_lang->{compile}->{findfilterblank});
- $kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($warning_prefix . $main::kiriwrite_lang{compile}{findfilterblank});
+ $main::kiriwrite_presmodule->addlinebreak();
$filters_find_blank_warning = 1;
}
next;
}
- $kiriwrite_presmodule->addtext($information_prefix . $kiriwrite_lang->{compile}->{finishfilterdatabase});
- $kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($information_prefix . $main::kiriwrite_lang{compile}{finishfilterdatabase});
+ $main::kiriwrite_presmodule->addlinebreak();
}
# Disconnect from the filter database.
- $kiriwrite_dbmodule->disconnectfilter();
+ $main::kiriwrite_dbmodule->disconnectfilter();
# Connect to the template database.
- $kiriwrite_dbmodule->connecttemplate();
+ $main::kiriwrite_dbmodule->connecttemplate();
# Check if any errors occured while connecting to the template database.
- if ($kiriwrite_dbmodule->geterror eq "TemplateDatabaseDoesNotExist"){
+ if ($main::kiriwrite_dbmodule->geterror eq "TemplateDatabaseDoesNotExist"){
# The template database does not exist so set the template
# warning message.
- $kiriwrite_presmodule->addtext($warning_prefix . $kiriwrite_lang->{compile}->{templatedatabasemissing});
- $kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($warning_prefix . $main::kiriwrite_lang{compile}{templatedatabasemissing});
+ $main::kiriwrite_presmodule->addlinebreak();
$templates_skip = 1;
$warning_count++;
- } elsif ($kiriwrite_dbmodule->geterror eq "TemplateDatabaseInvalidPermissionsSet"){
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "TemplateDatabaseInvalidPermissionsSet"){
# The template database has invalid permissions set so write
# the template warning message.
- $kiriwrite_presmodule->addtext($error_prefix . $kiriwrite_lang->{compile}->{templatedatabasepermissions});
- $kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($error_prefix . $main::kiriwrite_lang{compile}{templatedatabasepermissions});
+ $main::kiriwrite_presmodule->addlinebreak();
$templates_skip = 1;
$error_count++;
if (!$templates_skip){
- @templateslist = $kiriwrite_dbmodule->gettemplatelist();
+ @templateslist = $main::kiriwrite_dbmodule->gettemplatelist();
# Check if any errors had occured.
- if ($kiriwrite_dbmodule->geterror eq "TemplateDatabaseError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "TemplateDatabaseError"){
# A database error occured while getting the list
# of templates so return a warning message with the
# extended error information.
- $kiriwrite_presmodule->addtext($error_prefix . kiriwrite_language($kiriwrite_lang->{compile}->{templatedatabaseerror}, $kiriwrite_dbmodule->geterror(1)));
+ $main::kiriwrite_presmodule->addtext($error_prefix . kiriwrite_language($main::kiriwrite_lang{compile}{templatedatabaseerror}, $main::kiriwrite_dbmodule->geterror(1)));
$templates_skip = 1;
$error_count++;
# Get information about the template.
- %template_info = $kiriwrite_dbmodule->gettemplateinfo({ TemplateFilename => $template });
+ %template_info = $main::kiriwrite_dbmodule->gettemplateinfo({ TemplateFilename => $template });
# Check if any error occured while getting the template information.
- if ($kiriwrite_dbmodule->geterror eq "TemplateDatabaseError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "TemplateDatabaseError"){
# A database error has occured, so return an error.
- $kiriwrite_presmodule->addtext($error_prefix . kiriwrite_language($kiriwrite_lang->{compile}->{templatedatabaseerror}, $kiriwrite_dbmodule->geterror(1)));
+ $main::kiriwrite_presmodule->addtext($error_prefix . kiriwrite_language($main::kiriwrite_lang{compile}{templatedatabaseerror}, $main::kiriwrite_dbmodule->geterror(1)));
$error_count++;
- } elsif ($kiriwrite_dbmodule->geterror eq "TemplateDoesNotExist"){
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "TemplateDoesNotExist"){
# The template does not exist, so process the next template.
}
- $kiriwrite_presmodule->addtext($information_prefix . $kiriwrite_lang->{compile}->{finishtemplatedatabase});
- $kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($information_prefix . $main::kiriwrite_lang{compile}{finishtemplatedatabase});
+ $main::kiriwrite_presmodule->addlinebreak();
}
# Disconnect from the template database.
- $kiriwrite_dbmodule->disconnecttemplate();
+ $main::kiriwrite_dbmodule->disconnecttemplate();
# Process each database.
# Check if the database filename and length
# are valid.
- $kiriwrite_presmodule->addhorizontalline();
+ $main::kiriwrite_presmodule->addhorizontalline();
$database_filename_check = kiriwrite_variablecheck($database, "page_filename", "", 1);
$database_maxlength_check = kiriwrite_variablecheck($database, "maxlength", 32, 1);
# The database filename is invalid, so process
# the next database.
- $kiriwrite_presmodule->addtext($error_prefix . kiriwrite_language($kiriwrite_lang->{compile}->{databasefilenameinvalidcharacters}, $database));
- $kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($error_prefix . kiriwrite_language($main::kiriwrite_lang{compile}{databasefilenameinvalidcharacters}, $database));
+ $main::kiriwrite_presmodule->addlinebreak();
$error_count++;
next;
# The database file is too long, so process the
# next database.
- $kiriwrite_presmodule->addtext($error_prefix . kiriwrite_language($kiriwrite_lang->{compile}->{databasefilenametoolong}, $database));
- $kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($error_prefix . kiriwrite_language($main::kiriwrite_lang{compile}{databasefilenametoolong}, $database));
+ $main::kiriwrite_presmodule->addlinebreak();
$error_count++;
next;
# Select the database.
- $kiriwrite_dbmodule->selectdb({ DatabaseName => $database });
+ $main::kiriwrite_dbmodule->selectdb({ DatabaseName => $database });
# Check if any errors had occured while selecting the database.
- if ($kiriwrite_dbmodule->geterror eq "DoesNotExist"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DoesNotExist"){
# The database does not exist, so write a warning message.
- $kiriwrite_presmodule->addtext($warning_prefix . kiriwrite_language($kiriwrite_lang->{compile}->{databasemissing}, $database));
- $kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($warning_prefix . kiriwrite_language($main::kiriwrite_lang{compile}{databasemissing}, $database));
+ $main::kiriwrite_presmodule->addlinebreak();
$warning_count++;
next;
- } elsif ($kiriwrite_dbmodule->geterror eq "InvalidPermissionsSet"){
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "InvalidPermissionsSet"){
# The database has invalid permissions set, so write
# an error message.
- $kiriwrite_presmodule->addtext($error_prefix . kiriwrite_language($kiriwrite_lang->{compile}->{databaseinvalidpermissions}, $database));
- $kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($error_prefix . kiriwrite_language($main::kiriwrite_lang{compile}{databaseinvalidpermissions}, $database));
+ $main::kiriwrite_presmodule->addlinebreak();
$error_count++;
next;
# Get information about the database.
- my %database_info = $kiriwrite_dbmodule->getdatabaseinfo();
+ my %database_info = $main::kiriwrite_dbmodule->getdatabaseinfo();
# Check if any error occured while getting the database information.
- if ($kiriwrite_dbmodule->geterror eq "DatabaseError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseError"){
# A database error has occured so write an error.
- $kiriwrite_presmodule->addtext($error_prefix . kiriwrite_language($kiriwrite_lang->{compile}->{databaseerror}, $database, $kiriwrite_dbmodule->geterror(1)));
- $kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($error_prefix . kiriwrite_language($main::kiriwrite_lang{compile}{databaseerror}, $database, $main::kiriwrite_dbmodule->geterror(1)));
+ $main::kiriwrite_presmodule->addlinebreak();
$error_count++;
next;
$database_name = $database_info{"DatabaseName"};
- $kiriwrite_presmodule->addtext($information_prefix . kiriwrite_language($kiriwrite_lang->{compile}->{compilingpages}, $database_name));
- $kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($information_prefix . kiriwrite_language($main::kiriwrite_lang{compile}{compilingpages}, $database_name));
+ $main::kiriwrite_presmodule->addlinebreak();
# Get the list of pages in the database.
- @databasepages = $kiriwrite_dbmodule->getpagelist();
+ @databasepages = $main::kiriwrite_dbmodule->getpagelist();
# Check if any errors occured while getting the list of pages.
- if ($kiriwrite_dbmodule->geterror eq "DatabaseError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseError"){
# A database error has occured so return an error and
# also the extended error information.
- $kiriwrite_presmodule->addtext($error_prefix . kiriwrite_language($kiriwrite_lang->{compile}->{databasepageerror}, $database, $kiriwrite_dbmodule->geterror(1)));
- $kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($error_prefix . kiriwrite_language($main::kiriwrite_lang{compile}{databasepageerror}, $database, $main::kiriwrite_dbmodule->geterror(1)));
+ $main::kiriwrite_presmodule->addlinebreak();
$error_count++;
next;
# Get information about the page.
- %page_info = $kiriwrite_dbmodule->getpageinfo({ PageFilename => $page });
+ %page_info = $main::kiriwrite_dbmodule->getpageinfo({ PageFilename => $page });
$page_filename = $page_info{"PageFilename"};
$page_name = $page_info{"PageName"};
# The file name is not valid so write a
# error and process the next page.
- $kiriwrite_presmodule->addtext($error_prefix . kiriwrite_language($kiriwrite_lang->{compile}->{invalidpagefilename}, $page_name));
- $kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($error_prefix . kiriwrite_language($main::kiriwrite_lang{compile}{invalidpagefilename}, $page_name));
+ $main::kiriwrite_presmodule->addlinebreak();
$error_count++;
next;
if (!$templatefiles{$page_template}{valid} && $page_template ne "!none" && $templates_skip eq 0){
- $kiriwrite_presmodule->addtext($error_prefix . kiriwrite_language($kiriwrite_lang->{compile}->{templatefilemissing}, $page_template, $page_name, $page_filename));
- $kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($error_prefix . kiriwrite_language($main::kiriwrite_lang{compile}{templatefilemissing}, $page_template, $page_name, $page_filename));
+ $main::kiriwrite_presmodule->addlinebreak();
$error_count++;
next;
$page_directory_path = $page_directory_path . '/' . $page_directory_name;
- mkdir($kiriwrite_config{"directory_data_output"} . '/' . $page_directory_path);
+ mkdir($main::kiriwrite_config{"directory_data_output"} . '/' . $page_directory_path);
}
# the permissions of the file and return an error if the
# permissions set are invalid.
- $page_filename_exists = kiriwrite_fileexists($kiriwrite_config{"directory_data_output"} . '/' . $page_filename);
+ $page_filename_exists = kiriwrite_fileexists($main::kiriwrite_config{"directory_data_output"} . '/' . $page_filename);
if ($page_filename_exists eq 0){
# The page filename exists, so check if the permissions given are
# valid.
- $page_filename_permissions = kiriwrite_filepermissions($kiriwrite_config{"directory_data_output"} . '/' . $page_filename, 1, 1);
+ $page_filename_permissions = kiriwrite_filepermissions($main::kiriwrite_config{"directory_data_output"} . '/' . $page_filename, 1, 1);
if ($page_filename_permissions eq 1){
# The file has invalid permissions set.
- $kiriwrite_presmodule->addtext($error_prefix . kiriwrite_language($kiriwrite_lang->{compile}->{pageinvalidpermissions}, $page_filename));
- $kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($error_prefix . kiriwrite_language($main::kiriwrite_lang{compile}{pageinvalidpermissions}, $page_filename));
+ $main::kiriwrite_presmodule->addlinebreak();
$error_count++;
# Reset certain values.
# Write the file to the output directory.
($page_filename) = $page_filename =~ m/^(.*)$/g;
- ($kiriwrite_config{"directory_data_output"}) = $kiriwrite_config{"directory_data_output"} =~ m/^(.*)$/g;
+ ($main::kiriwrite_config{"directory_data_output"}) = $main::kiriwrite_config{"directory_data_output"} =~ m/^(.*)$/g;
- open($filehandle_page, "> ", $kiriwrite_config{"directory_data_output"} . '/' . $page_filename) or ($kiriwrite_presmodule->addtext($error_prefix . kiriwrite_language($kiriwrite_lang->{compile}->{pagenotwritten}, $page_filename, $!)), $kiriwrite_presmodule->addlinebreak(), $error_count++, next);
+ open($filehandle_page, "> ", $main::kiriwrite_config{"directory_data_output"} . '/' . $page_filename) or ($main::kiriwrite_presmodule->addtext($error_prefix . kiriwrite_language($main::kiriwrite_lang{compile}{pagenotwritten}, $page_filename, $!)), $main::kiriwrite_presmodule->addlinebreak(), $error_count++, next);
if (!$page_final){
# saying there's no page name.
if (!$page_name){
- $kiriwrite_presmodule->addtext($information_prefix . ' ');
- $kiriwrite_presmodule->additalictext($kiriwrite_lang->{blank}->{noname} . ' ');
- $kiriwrite_presmodule->addtext(kiriwrite_language($kiriwrite_lang->{compile}->{compiledpageblankname}, $page_filename));
+ $main::kiriwrite_presmodule->addtext($information_prefix . ' ');
+ $main::kiriwrite_presmodule->additalictext($main::kiriwrite_lang{blank}{noname} . ' ');
+ $main::kiriwrite_presmodule->addtext(kiriwrite_language($main::kiriwrite_lang{compile}{compiledpageblankname}, $page_filename));
} else {
- $kiriwrite_presmodule->addtext($information_prefix . kiriwrite_language($kiriwrite_lang->{compile}->{compiledpage}, $page_name, $page_filename));
+ $main::kiriwrite_presmodule->addtext($information_prefix . kiriwrite_language($main::kiriwrite_lang{compile}{compiledpage}, $page_name, $page_filename));
}
- $kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
$pages_count++;
}
# Write a message saying that the database has
# been processed.
- $kiriwrite_presmodule->addtext($information_prefix . kiriwrite_language($kiriwrite_lang->{compile}->{databasefinish}, $database_name));
- $kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($information_prefix . kiriwrite_language($main::kiriwrite_lang{compile}{databasefinish}, $database_name));
+ $main::kiriwrite_presmodule->addlinebreak();
}
# Disconnect from the database server.
- $kiriwrite_dbmodule->disconnect();
+ $main::kiriwrite_dbmodule->disconnect();
- $kiriwrite_presmodule->addhorizontalline();
- $kiriwrite_presmodule->addtext(kiriwrite_language($kiriwrite_lang->{compile}->{compileresults}, $pages_count, $error_count, $warning_count));
- $kiriwrite_presmodule->endbox();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlink($kiriwrite_env{"script_filename"} . "?mode=compile", { Text => $kiriwrite_lang->{compile}->{returncompilelist} });
+ $main::kiriwrite_presmodule->addhorizontalline();
+ $main::kiriwrite_presmodule->addtext(kiriwrite_language($main::kiriwrite_lang{compile}{compileresults}, $pages_count, $error_count, $warning_count));
+ $main::kiriwrite_presmodule->endbox();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{"script_filename"} . "?mode=compile", { Text => $main::kiriwrite_lang{compile}{returncompilelist} });
- return $kiriwrite_presmodule->grab();
+ return $main::kiriwrite_presmodule->grab();
} elsif ($confirm eq 0){
my $templatedbwarning = "";
my @template_list;
my $template_filename;
+ my $template_file;
my %template_info;
my %template_dblist;
tie(%template_dblist, "Tie::IxHash");
# Connect to the database server.
- $kiriwrite_dbmodule->connect();
+ $main::kiriwrite_dbmodule->connect();
# Check if any errors occured while connecting to the database server.
- if ($kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
# A database connection error has occured so return
# an error.
- kiriwrite_error("databaseconnectionerror", $kiriwrite_dbmodule->geterror(1));
+ kiriwrite_error("databaseconnectionerror", $main::kiriwrite_dbmodule->geterror(1));
}
# Select the database.
- $kiriwrite_dbmodule->selectdb({ DatabaseName => $databasefilename });
+ $main::kiriwrite_dbmodule->selectdb({ DatabaseName => $databasefilename });
# Check if any errors had occured while selecting the database.
- if ($kiriwrite_dbmodule->geterror eq "DoesNotExist"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DoesNotExist"){
# The database does not exist, so return an error.
kiriwrite_error("databasemissingfile");
- } elsif ($kiriwrite_dbmodule->geterror eq "InvalidPermissionsSet"){
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "InvalidPermissionsSet"){
# The database has invalid permissions set, so return
# an error.
# Get information about the database.
- %database_info = $kiriwrite_dbmodule->getdatabaseinfo();
+ %database_info = $main::kiriwrite_dbmodule->getdatabaseinfo();
# Check if any error occured while getting the database information.
- if ($kiriwrite_dbmodule->geterror eq "DatabaseError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseError"){
# A database error has occured so return an error and
# also the extended error information.
- kiriwrite_error("databaseerror", $kiriwrite_dbmodule->geterror(1));
+ kiriwrite_error("databaseerror", $main::kiriwrite_dbmodule->geterror(1));
};
$database_name = $database_info{"DatabaseName"};
- $kiriwrite_dbmodule->connecttemplate();
+ $main::kiriwrite_dbmodule->connecttemplate();
# Check if any errors occured while connecting to the
# template database.
- if ($kiriwrite_dbmodule->geterror eq "TemplateDatabaseDoesNotExist"){
+ if ($main::kiriwrite_dbmodule->geterror eq "TemplateDatabaseDoesNotExist"){
# The template database does not exist so skip processing
# the list of templates in the template database.
$templateoverride_skip = 1;
- $templatedbwarning = $kiriwrite_lang->{compile}->{templatedbmissing};
+ $templatedbwarning = $main::kiriwrite_lang{compile}{templatedbmissing};
- } elsif ($kiriwrite_dbmodule->geterror eq "TemplateDatabaseInvalidPermissionsSet"){
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "TemplateDatabaseInvalidPermissionsSet"){
# The template database has invalid permissions set so
# skip processing the list of templates in the
# template database.
$templateoverride_skip = 1;
- $templatedbwarning = $kiriwrite_lang->{compile}->{templatedbinvalidpermissions};
+ $templatedbwarning = $main::kiriwrite_lang{compile}{templatedbinvalidpermissions};
}
if ($templateoverride_skip ne 1){
- @template_list = $kiriwrite_dbmodule->gettemplatelist();
+ @template_list = $main::kiriwrite_dbmodule->gettemplatelist();
# Check if any errors occured while getting the list of templates.
- if ($kiriwrite_dbmodule->geterror eq "TemplateDatabaseError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "TemplateDatabaseError"){
# A template database error has occured so skip processing the
# list of templates in the template database.
$templateoverride_skip = 1;
- $templatedbwarning = $kiriwrite_lang->{compile}->{templatedberror};
+ $templatedbwarning = $main::kiriwrite_lang{compile}{templatedberror};
}
foreach $template_file (@template_list){
- %template_info = $kiriwrite_dbmodule->gettemplateinfo({ TemplateFilename => $template_file });
+ %template_info = $main::kiriwrite_dbmodule->gettemplateinfo({ TemplateFilename => $template_file });
- if ($kiriwrite_dbmodule->geterror eq "TemplateDoesNotExist"){
+ if ($main::kiriwrite_dbmodule->geterror eq "TemplateDoesNotExist"){
next;
- } elsif ($kiriwrite_dbmodule->geterror eq "TemplateDatabaseError"){
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "TemplateDatabaseError"){
next;
# Disconnect from the template database and database server.
- $kiriwrite_dbmodule->disconnecttemplate();
- $kiriwrite_dbmodule->disconnect();
+ $main::kiriwrite_dbmodule->disconnecttemplate();
+ $main::kiriwrite_dbmodule->disconnect();
# Write out a form asking the user to confirm if the
# user wants to compile the selected database.
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{compile}->{compiledatabase}, { Style => "pageheader" });
- $kiriwrite_presmodule->startform($kiriwrite_env{"script_filename"}, "POST");
- $kiriwrite_presmodule->startbox();
- $kiriwrite_presmodule->addhiddendata("mode", "compile");
- $kiriwrite_presmodule->addhiddendata("action", "compile");
- $kiriwrite_presmodule->addhiddendata("type", "multiple");
- $kiriwrite_presmodule->addhiddendata("id[1]", $databasefilename);
- $kiriwrite_presmodule->addhiddendata("name[1]", "on");
- $kiriwrite_presmodule->addhiddendata("confirm", 1);
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext(kiriwrite_language($kiriwrite_lang->{compile}->{compiledatabasemessage}, $database_name));
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{compile}{compiledatabase}, { Style => "pageheader" });
+ $main::kiriwrite_presmodule->startform($main::kiriwrite_env{"script_filename"}, "POST");
+ $main::kiriwrite_presmodule->startbox();
+ $main::kiriwrite_presmodule->addhiddendata("mode", "compile");
+ $main::kiriwrite_presmodule->addhiddendata("action", "compile");
+ $main::kiriwrite_presmodule->addhiddendata("type", "multiple");
+ $main::kiriwrite_presmodule->addhiddendata("id[1]", $databasefilename);
+ $main::kiriwrite_presmodule->addhiddendata("name[1]", "on");
+ $main::kiriwrite_presmodule->addhiddendata("confirm", 1);
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext(kiriwrite_language($main::kiriwrite_lang{compile}{compiledatabasemessage}, $database_name));
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
if ($templateoverride_skip eq 1){
# Add message saying why template can't be overridden.
- $kiriwrite_presmodule->addtext($templatedbwarning);
+ $main::kiriwrite_presmodule->addtext($templatedbwarning);
} else {
# Add overwrite template data.
- $kiriwrite_presmodule->addcheckbox("enableoverride", { OptionDescription => $kiriwrite_lang->{compile}->{overridetemplate}, LineBreak => 1 });
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{compile}->{replacecurrenttemplate});
- $kiriwrite_presmodule->addselectbox("overridetemplate");
+ $main::kiriwrite_presmodule->addcheckbox("enableoverride", { OptionDescription => $main::kiriwrite_lang{compile}{overridetemplate}, LineBreak => 1 });
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{compile}{replacecurrenttemplate});
+ $main::kiriwrite_presmodule->addselectbox("overridetemplate");
foreach $template_file (keys %template_dblist){
- $kiriwrite_presmodule->addoption($template_dblist{$template_file} . " (" . $template_file . ")", { Value => $template_file });
+ $main::kiriwrite_presmodule->addoption($template_dblist{$template_file} . " (" . $template_file . ")", { Value => $template_file });
}
- $kiriwrite_presmodule->addoption($kiriwrite_lang->{compile}->{dontusetemplate}, { Value => "!none" });
- $kiriwrite_presmodule->endselectbox();
+ $main::kiriwrite_presmodule->addoption($main::kiriwrite_lang{compile}{dontusetemplate}, { Value => "!none" });
+ $main::kiriwrite_presmodule->endselectbox();
}
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addsubmit($kiriwrite_lang->{compile}->{compiledatabasebutton});
- $kiriwrite_presmodule->addtext(" | ");
- $kiriwrite_presmodule->addlink($kiriwrite_env{"script_filename"} . "?mode=compile", { Text => $kiriwrite_lang->{compile}->{returncompilelist} });
- $kiriwrite_presmodule->endbox();
- $kiriwrite_presmodule->endform();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addsubmit($main::kiriwrite_lang{compile}{compiledatabasebutton});
+ $main::kiriwrite_presmodule->addtext(" | ");
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{"script_filename"} . "?mode=compile", { Text => $main::kiriwrite_lang{compile}{returncompilelist} });
+ $main::kiriwrite_presmodule->endbox();
+ $main::kiriwrite_presmodule->endform();
- return $kiriwrite_presmodule->grab();
+ return $main::kiriwrite_presmodule->grab();
} elsif ($type eq "multiple"){
# Connect to the database server.
- $kiriwrite_dbmodule->connect();
+ $main::kiriwrite_dbmodule->connect();
# Check if any errors occured while connecting to the database server.
- if ($kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
# A database connection error has occured so return
# an error.
- kiriwrite_error("databaseconnectionerror", $kiriwrite_dbmodule->geterror(1));
+ kiriwrite_error("databaseconnectionerror", $main::kiriwrite_dbmodule->geterror(1));
}
# Select the database to add the page to.
- $kiriwrite_dbmodule->selectdb({ DatabaseName => $databasename });
+ $main::kiriwrite_dbmodule->selectdb({ DatabaseName => $databasename });
# Check if any errors had occured while selecting the database.
- if ($kiriwrite_dbmodule->geterror eq "DoesNotExist"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DoesNotExist"){
# The database does not exist, so process the next database.
next;
- } elsif ($kiriwrite_dbmodule->geterror eq "InvalidPermissionsSet"){
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "InvalidPermissionsSet"){
# The database has invalid permissions set, so process
# the next database.
# Get information about the database.
- my %database_info = $kiriwrite_dbmodule->getdatabaseinfo();
+ my %database_info = $main::kiriwrite_dbmodule->getdatabaseinfo();
# Check if any error occured while getting the database information.
- if ($kiriwrite_dbmodule->geterror eq "DatabaseError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseError"){
# A database error has occured so process the next
# database.
# Write out the form for compiling the database.
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{compile}->{compileselecteddatabases}, { Style => "pageheader" });
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->startform($kiriwrite_env{"script_filename"}, "POST");
- $kiriwrite_presmodule->startbox();
- $kiriwrite_presmodule->addhiddendata("mode", "compile");
- $kiriwrite_presmodule->addhiddendata("action", "compile");
- $kiriwrite_presmodule->addhiddendata("type", "multiple");
- $kiriwrite_presmodule->addhiddendata("count", $database_count);
- $kiriwrite_presmodule->addhiddendata("confirm", 1);
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{compile}->{compileselecteddatabasesmessage});
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->startbox("datalist");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{compile}{compileselecteddatabases}, { Style => "pageheader" });
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->startform($main::kiriwrite_env{"script_filename"}, "POST");
+ $main::kiriwrite_presmodule->startbox();
+ $main::kiriwrite_presmodule->addhiddendata("mode", "compile");
+ $main::kiriwrite_presmodule->addhiddendata("action", "compile");
+ $main::kiriwrite_presmodule->addhiddendata("type", "multiple");
+ $main::kiriwrite_presmodule->addhiddendata("count", $database_count);
+ $main::kiriwrite_presmodule->addhiddendata("confirm", 1);
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{compile}{compileselecteddatabasesmessage});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->startbox("datalist");
$database_count = 0;
$database_count++;
- $kiriwrite_presmodule->addhiddendata("id[" . $database_count . "]", $database_list{$database}{Filename});
- $kiriwrite_presmodule->addhiddendata("name[" . $database_count . "]", "on");
+ $main::kiriwrite_presmodule->addhiddendata("id[" . $database_count . "]", $database_list{$database}{Filename});
+ $main::kiriwrite_presmodule->addhiddendata("name[" . $database_count . "]", "on");
# Check if the database name is undefined and if it is
# then write a message saying the database name is blank.
if (!$database_list{$database}{Name}){
- $kiriwrite_presmodule->additalictext($kiriwrite_lang->{compile}->{blankdatabasename});
+ $main::kiriwrite_presmodule->additalictext($main::kiriwrite_lang{compile}{blankdatabasename});
} else {
- $kiriwrite_presmodule->addtext($database_list{$database}{Name});
+ $main::kiriwrite_presmodule->addtext($database_list{$database}{Name});
}
- $kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
}
- $kiriwrite_presmodule->endbox();
+ $main::kiriwrite_presmodule->endbox();
- $kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
- $kiriwrite_dbmodule->connecttemplate();
+ $main::kiriwrite_dbmodule->connecttemplate();
# Check if any errors occured while connecting to the
# template database.
- if ($kiriwrite_dbmodule->geterror eq "TemplateDatabaseDoesNotExist"){
+ if ($main::kiriwrite_dbmodule->geterror eq "TemplateDatabaseDoesNotExist"){
# The template database does not exist so skip processing
# the list of templates in the template database.
$templateoverride_skip = 1;
- $templatedbwarning = $kiriwrite_lang->{compile}->{templatedbmissing};
+ $templatedbwarning = $main::kiriwrite_lang{compile}{templatedbmissing};
- } elsif ($kiriwrite_dbmodule->geterror eq "TemplateDatabaseInvalidPermissionsSet"){
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "TemplateDatabaseInvalidPermissionsSet"){
# The template database has invalid permissions set so
# skip processing the list of templates in the
# template database.
$templateoverride_skip = 1;
- $templatedbwarning = $kiriwrite_lang->{compile}->{templatedbinvalidpermissions};
+ $templatedbwarning = $main::kiriwrite_lang{compile}{templatedbinvalidpermissions};
}
if ($templateoverride_skip ne 1){
- @template_list = $kiriwrite_dbmodule->gettemplatelist();
+ @template_list = $main::kiriwrite_dbmodule->gettemplatelist();
# Check if any errors occured while getting the list of templates.
- if ($kiriwrite_dbmodule->geterror eq "TemplateDatabaseError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "TemplateDatabaseError"){
# A template database error has occured so skip processing the
# list of templates in the template database.
$templateoverride_skip = 1;
- $templatedbwarning = $kiriwrite_lang->{compile}->{templatedberror};
+ $templatedbwarning = $main::kiriwrite_lang{compile}{templatedberror};
}
foreach $template_file (@template_list){
- %template_info = $kiriwrite_dbmodule->gettemplateinfo({ TemplateFilename => $template_file });
+ %template_info = $main::kiriwrite_dbmodule->gettemplateinfo({ TemplateFilename => $template_file });
- if ($kiriwrite_dbmodule->geterror eq "TemplateDoesNotExist"){
+ if ($main::kiriwrite_dbmodule->geterror eq "TemplateDoesNotExist"){
next;
- } elsif ($kiriwrite_dbmodule->geterror eq "TemplateDatabaseError"){
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "TemplateDatabaseError"){
next;
if ($templateoverride_skip eq 1){
# Add message saying why template can't be overridden.
- $kiriwrite_presmodule->addtext($templatedbwarning);
+ $main::kiriwrite_presmodule->addtext($templatedbwarning);
} else {
# Add overwrite template data.
- $kiriwrite_presmodule->addcheckbox("enableoverride", { OptionDescription => $kiriwrite_lang->{compile}->{overridetemplate}, LineBreak => 1 });
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{compile}->{replacecurrenttemplate});
- $kiriwrite_presmodule->addselectbox("overridetemplate");
+ $main::kiriwrite_presmodule->addcheckbox("enableoverride", { OptionDescription => $main::kiriwrite_lang{compile}{overridetemplate}, LineBreak => 1 });
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{compile}{replacecurrenttemplate});
+ $main::kiriwrite_presmodule->addselectbox("overridetemplate");
foreach $template_file (keys %template_dblist){
- $kiriwrite_presmodule->addoption($template_dblist{$template_file} . " (" . $template_file . ")", { Value => $template_file });
+ $main::kiriwrite_presmodule->addoption($template_dblist{$template_file} . " (" . $template_file . ")", { Value => $template_file });
}
- $kiriwrite_presmodule->addoption($kiriwrite_lang->{compile}->{dontusetemplate}, { Value => "!none" });
- $kiriwrite_presmodule->endselectbox();
+ $main::kiriwrite_presmodule->addoption($main::kiriwrite_lang{compile}{dontusetemplate}, { Value => "!none" });
+ $main::kiriwrite_presmodule->endselectbox();
}
# Disconnect from the template database and database server.
- $kiriwrite_dbmodule->disconnecttemplate();
- $kiriwrite_dbmodule->disconnect();
+ $main::kiriwrite_dbmodule->disconnecttemplate();
+ $main::kiriwrite_dbmodule->disconnect();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addsubmit($kiriwrite_lang->{compile}->{compileselecteddatabasesbutton});
- $kiriwrite_presmodule->addtext(" | ");
- $kiriwrite_presmodule->addlink($kiriwrite_env{"script_filename"} . "?mode=compile", { Text => $kiriwrite_lang->{compile}->{returncompilelist} });
- $kiriwrite_presmodule->endbox();
- $kiriwrite_presmodule->endform();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addsubmit($main::kiriwrite_lang{compile}{compileselecteddatabasesbutton});
+ $main::kiriwrite_presmodule->addtext(" | ");
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{"script_filename"} . "?mode=compile", { Text => $main::kiriwrite_lang{compile}{returncompilelist} });
+ $main::kiriwrite_presmodule->endbox();
+ $main::kiriwrite_presmodule->endform();
- return $kiriwrite_presmodule->grab();
+ return $main::kiriwrite_presmodule->grab();
} else {
# Connect to the database server.
- $kiriwrite_dbmodule->connect();
+ $main::kiriwrite_dbmodule->connect();
# Check if any errors occured while connecting to the database server.
- if ($kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
# A database connection error has occured so return
# an error.
- kiriwrite_error("databaseconnectionerror", $kiriwrite_dbmodule->geterror(1));
+ kiriwrite_error("databaseconnectionerror", $main::kiriwrite_dbmodule->geterror(1));
}
# Get the list of available databases.
- my @database_list = $kiriwrite_dbmodule->getdblist();
+ my @database_list = $main::kiriwrite_dbmodule->getdblist();
# Check if any errors occured while getting the databases.
- if ($kiriwrite_dbmodule->geterror eq "DataDirMissing"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DataDirMissing"){
# The database directory is missing so return an error.
kiriwrite_error("datadirectorymissing");
- } elsif ($kiriwrite_dbmodule->geterror eq "DataDirInvalidPermissions"){
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "DataDirInvalidPermissions"){
# The database directory has invalid permissions set so return
# an error.
# Write out a form for confirming the action to compile all of the databases.
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{compile}->{compilealldatabases}, { Style => "pageheader" });
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{compile}{compilealldatabases}, { Style => "pageheader" });
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->startform($kiriwrite_env{"script_filename"}, "POST");
- $kiriwrite_presmodule->startbox();
- $kiriwrite_presmodule->addhiddendata("mode", "compile");
- $kiriwrite_presmodule->addhiddendata("action", "compile");
- $kiriwrite_presmodule->addhiddendata("type", "multiple");
+ $main::kiriwrite_presmodule->startform($main::kiriwrite_env{"script_filename"}, "POST");
+ $main::kiriwrite_presmodule->startbox();
+ $main::kiriwrite_presmodule->addhiddendata("mode", "compile");
+ $main::kiriwrite_presmodule->addhiddendata("action", "compile");
+ $main::kiriwrite_presmodule->addhiddendata("type", "multiple");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{compile}->{compilealldatabasesmessage});
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{compile}{compilealldatabasesmessage});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
foreach $database (@database_list){
}
$database_count++;
- $kiriwrite_presmodule->addhiddendata("id[" . $database_count . "]", $database);
- $kiriwrite_presmodule->addhiddendata("name[" . $database_count . "]", "on");
+ $main::kiriwrite_presmodule->addhiddendata("id[" . $database_count . "]", $database);
+ $main::kiriwrite_presmodule->addhiddendata("name[" . $database_count . "]", "on");
}
- $kiriwrite_presmodule->addhiddendata("count", $database_count);
+ $main::kiriwrite_presmodule->addhiddendata("count", $database_count);
my $templateoverride_skip = 0;
my $templatedbwarning = "";
my $template_filename;
my %template_info;
my %template_dblist;
+ my $template_file;
tie(%template_dblist, "Tie::IxHash");
- $kiriwrite_dbmodule->connecttemplate();
+ $main::kiriwrite_dbmodule->connecttemplate();
# Check if any errors occured while connecting to the
# template database.
- if ($kiriwrite_dbmodule->geterror eq "TemplateDatabaseDoesNotExist"){
+ if ($main::kiriwrite_dbmodule->geterror eq "TemplateDatabaseDoesNotExist"){
# The template database does not exist so skip processing
# the list of templates in the template database.
$templateoverride_skip = 1;
- $templatedbwarning = $kiriwrite_lang->{compile}->{templatedbmissing};
+ $templatedbwarning = $main::kiriwrite_lang{compile}{templatedbmissing};
- } elsif ($kiriwrite_dbmodule->geterror eq "TemplateDatabaseInvalidPermissionsSet"){
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "TemplateDatabaseInvalidPermissionsSet"){
# The template database has invalid permissions set so
# skip processing the list of templates in the
# template database.
$templateoverride_skip = 1;
- $templatedbwarning = $kiriwrite_lang->{compile}->{templatedbinvalidpermissions};
+ $templatedbwarning = $main::kiriwrite_lang{compile}{templatedbinvalidpermissions};
}
if ($templateoverride_skip ne 1){
- @template_list = $kiriwrite_dbmodule->gettemplatelist();
+ @template_list = $main::kiriwrite_dbmodule->gettemplatelist();
# Check if any errors occured while getting the list of templates.
- if ($kiriwrite_dbmodule->geterror eq "TemplateDatabaseError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "TemplateDatabaseError"){
# A template database error has occured so skip processing the
# list of templates in the template database.
$templateoverride_skip = 1;
- $templatedbwarning = $kiriwrite_lang->{compile}->{templatedberror};
+ $templatedbwarning = $main::kiriwrite_lang{compile}{templatedberror};
}
foreach $template_file (@template_list){
- %template_info = $kiriwrite_dbmodule->gettemplateinfo({ TemplateFilename => $template_file });
+ %template_info = $main::kiriwrite_dbmodule->gettemplateinfo({ TemplateFilename => $template_file });
- if ($kiriwrite_dbmodule->geterror eq "TemplateDoesNotExist"){
+ if ($main::kiriwrite_dbmodule->geterror eq "TemplateDoesNotExist"){
next;
- } elsif ($kiriwrite_dbmodule->geterror eq "TemplateDatabaseError"){
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "TemplateDatabaseError"){
next;
if ($templateoverride_skip eq 1){
# Add message saying why template can't be overridden.
- $kiriwrite_presmodule->addtext($templatedbwarning);
+ $main::kiriwrite_presmodule->addtext($templatedbwarning);
} else {
# Add overwrite template data.
- $kiriwrite_presmodule->addcheckbox("enableoverride", { OptionDescription => $kiriwrite_lang->{compile}->{overridetemplate}, LineBreak => 1 });
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{compile}->{replacecurrenttemplate});
- $kiriwrite_presmodule->addselectbox("overridetemplate");
+ $main::kiriwrite_presmodule->addcheckbox("enableoverride", { OptionDescription => $main::kiriwrite_lang{compile}{overridetemplate}, LineBreak => 1 });
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{compile}{replacecurrenttemplate});
+ $main::kiriwrite_presmodule->addselectbox("overridetemplate");
foreach $template_file (keys %template_dblist){
- $kiriwrite_presmodule->addoption($template_dblist{$template_file} . " (" . $template_file . ")", { Value => $template_file });
+ $main::kiriwrite_presmodule->addoption($template_dblist{$template_file} . " (" . $template_file . ")", { Value => $template_file });
}
- $kiriwrite_presmodule->addoption($kiriwrite_lang->{compile}->{dontusetemplate}, { Value => "!none" });
- $kiriwrite_presmodule->endselectbox();
+ $main::kiriwrite_presmodule->addoption($main::kiriwrite_lang{compile}{dontusetemplate}, { Value => "!none" });
+ $main::kiriwrite_presmodule->endselectbox();
}
# Disconnect from the template database and database server.
- $kiriwrite_dbmodule->disconnecttemplate();
- $kiriwrite_dbmodule->disconnect();
+ $main::kiriwrite_dbmodule->disconnecttemplate();
+ $main::kiriwrite_dbmodule->disconnect();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addhiddendata("confirm", 1);
- $kiriwrite_presmodule->addsubmit($kiriwrite_lang->{compile}->{compilealldatabasesbutton});
- $kiriwrite_presmodule->addtext(" | ");
- $kiriwrite_presmodule->addlink($kiriwrite_env{"script_filename"} . "?mode=compile", { Text => $kiriwrite_lang->{compile}->{returncompilelist} });
- $kiriwrite_presmodule->endbox();
- $kiriwrite_presmodule->endform();
+ $main::kiriwrite_presmodule->addhiddendata("confirm", 1);
+ $main::kiriwrite_presmodule->addsubmit($main::kiriwrite_lang{compile}{compilealldatabasesbutton});
+ $main::kiriwrite_presmodule->addtext(" | ");
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{"script_filename"} . "?mode=compile", { Text => $main::kiriwrite_lang{compile}{returncompilelist} });
+ $main::kiriwrite_presmodule->endbox();
+ $main::kiriwrite_presmodule->endform();
- return $kiriwrite_presmodule->grab();
+ return $main::kiriwrite_presmodule->grab();
}
# Connect to the database server.
- $kiriwrite_dbmodule->connect();
+ $main::kiriwrite_dbmodule->connect();
# Check if any errors occured while connecting to the database server.
- if ($kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
# A database connection error has occured so return
# an error.
- kiriwrite_error("databaseconnectionerror", $kiriwrite_dbmodule->geterror(1));
+ kiriwrite_error("databaseconnectionerror", $main::kiriwrite_dbmodule->geterror(1));
}
# Get the list of available databases and process any errors that
# might have occured.
- my @database_list = $kiriwrite_dbmodule->getdblist();
+ my @database_list = $main::kiriwrite_dbmodule->getdblist();
- if ($kiriwrite_dbmodule->geterror eq "DataDirMissing"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DataDirMissing"){
# The database directory is missing so return an error.
kiriwrite_error("datadirectorymissing");
- } elsif ($kiriwrite_dbmodule->geterror eq "DataDirInvalidPermissions"){
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "DataDirInvalidPermissions"){
# The database directory has invalid permissions set so return
# an error.
# Select the database.
- $kiriwrite_dbmodule->selectdb({ DatabaseName => $data_file });
+ $main::kiriwrite_dbmodule->selectdb({ DatabaseName => $data_file });
# Check if any error occured while selecting the database.
- if ($kiriwrite_dbmodule->geterror eq "DoesNotExist"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DoesNotExist"){
# The database does not exist, so process the next
# database.
next;
- } elsif ($kiriwrite_dbmodule->geterror eq "InvalidPermissionsSet") {
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "InvalidPermissionsSet") {
# The database has invalid permissions settings, so
# add the database to the list of databases with
# Get information about the database.
- %database_info = $kiriwrite_dbmodule->getdatabaseinfo();
+ %database_info = $main::kiriwrite_dbmodule->getdatabaseinfo();
# Check if any error occured while getting information from the
# database.
- if ($kiriwrite_dbmodule->geterror eq "DatabaseError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseError"){
# A database error has occured, add the database and specific
# error message to the list of databases with errors and
# process the next database.
- push(@error_list, $data_file . ": " . $kiriwrite_dbmodule->geterror(1));
+ push(@error_list, $data_file . ": " . $main::kiriwrite_dbmodule->geterror(1));
next;
}
# valid databases then write a message saying that no
# valid databases are available.
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{compile}->{compilepages}, { Style => "pageheader" });
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{compile}{compilepages}, { Style => "pageheader" });
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
if ($database_count eq 0){
# There are no databases available for compiling so
# write a message instead.
- $kiriwrite_presmodule->startbox("errorbox");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{compile}->{nodatabasesavailable});
- $kiriwrite_presmodule->endbox();
+ $main::kiriwrite_presmodule->startbox("errorbox");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{compile}{nodatabasesavailable});
+ $main::kiriwrite_presmodule->endbox();
} else {
- $kiriwrite_presmodule->startform($kiriwrite_env{"script_filename"}, "POST");
- $kiriwrite_presmodule->startbox();
- $kiriwrite_presmodule->addhiddendata("mode", "compile");
- $kiriwrite_presmodule->addhiddendata("action", "compile");
- $kiriwrite_presmodule->addhiddendata("type", "multiple");
-
- $kiriwrite_presmodule->addreset($kiriwrite_lang->{common}->{selectnone});
- $kiriwrite_presmodule->addtext(" | ");
- $kiriwrite_presmodule->addsubmit($kiriwrite_lang->{compile}->{compileselectedbutton});
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addhiddendata("count", $database_count);
- $kiriwrite_presmodule->starttable("", { CellPadding => 5, CellSpacing => 0 });
-
- $kiriwrite_presmodule->startheader();
- $kiriwrite_presmodule->addheader("", { Style => "tablecellheader" });
- $kiriwrite_presmodule->addheader($kiriwrite_lang->{database}->{databasename}, { Style => "tablecellheader" });
- $kiriwrite_presmodule->addheader($kiriwrite_lang->{database}->{databasedescription}, { Style => "tablecellheader" });
- $kiriwrite_presmodule->addheader($kiriwrite_lang->{common}->{options}, { Style => "tablecellheader" });
- $kiriwrite_presmodule->endheader();
+ $main::kiriwrite_presmodule->startform($main::kiriwrite_env{"script_filename"}, "POST");
+ $main::kiriwrite_presmodule->startbox();
+ $main::kiriwrite_presmodule->addhiddendata("mode", "compile");
+ $main::kiriwrite_presmodule->addhiddendata("action", "compile");
+ $main::kiriwrite_presmodule->addhiddendata("type", "multiple");
+
+ $main::kiriwrite_presmodule->addreset($main::kiriwrite_lang{common}{selectnone});
+ $main::kiriwrite_presmodule->addtext(" | ");
+ $main::kiriwrite_presmodule->addsubmit($main::kiriwrite_lang{compile}{compileselectedbutton});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addhiddendata("count", $database_count);
+ $main::kiriwrite_presmodule->starttable("", { CellPadding => 5, CellSpacing => 0 });
+
+ $main::kiriwrite_presmodule->startheader();
+ $main::kiriwrite_presmodule->addheader("", { Style => "tablecellheader" });
+ $main::kiriwrite_presmodule->addheader($main::kiriwrite_lang{database}{databasename}, { Style => "tablecellheader" });
+ $main::kiriwrite_presmodule->addheader($main::kiriwrite_lang{database}{databasedescription}, { Style => "tablecellheader" });
+ $main::kiriwrite_presmodule->addheader($main::kiriwrite_lang{common}{options}, { Style => "tablecellheader" });
+ $main::kiriwrite_presmodule->endheader();
$database_count = 1;
# Add the template to the list of available
# templates to compile.
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell($table_style_name);
- $kiriwrite_presmodule->addhiddendata("id[" . $database_count . "]", $database_list{$database}{Filename});
- $kiriwrite_presmodule->addcheckbox("name[" . $database_count . "]");
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell($table_style_name);
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell($table_style_name);
+ $main::kiriwrite_presmodule->addhiddendata("id[" . $database_count . "]", $database_list{$database}{Filename});
+ $main::kiriwrite_presmodule->addcheckbox("name[" . $database_count . "]");
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell($table_style_name);
if (!$database_list{$database}{Name}){
- $kiriwrite_presmodule->addlink($kiriwrite_env{"script_filename"} . "?mode=compile&action=compile&type=single&database=" . $database_list{$database}{Filename}, { Text => $kiriwrite_presmodule->additalictext($kiriwrite_lang->{blank}->{noname}) });
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{"script_filename"} . "?mode=compile&action=compile&type=single&database=" . $database_list{$database}{Filename}, { Text => $main::kiriwrite_presmodule->additalictext($main::kiriwrite_lang{blank}{noname}) });
} else {
- $kiriwrite_presmodule->addlink($kiriwrite_env{"script_filename"} . "?mode=page&action=view&database=" . $database_list{$database}{Filename}, { Text => $database_list{$database}{Name} });
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{"script_filename"} . "?mode=page&action=view&database=" . $database_list{$database}{Filename}, { Text => $database_list{$database}{Name} });
}
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell($table_style_name);
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell($table_style_name);
if (!$database_list{$database}{Description}){
- $kiriwrite_presmodule->additalictext($kiriwrite_lang->{blank}->{nodescription});
+ $main::kiriwrite_presmodule->additalictext($main::kiriwrite_lang{blank}{nodescription});
} else {
- $kiriwrite_presmodule->addtext($database_list{$database}{Description});
+ $main::kiriwrite_presmodule->addtext($database_list{$database}{Description});
}
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell($table_style_name);
- $kiriwrite_presmodule->addlink($kiriwrite_env{"script_filename"} . "?mode=compile&action=compile&type=single&database=" . $database_list{$database}{Filename}, { Text => $kiriwrite_lang->{options}->{compile} });
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell($table_style_name);
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{"script_filename"} . "?mode=compile&action=compile&type=single&database=" . $database_list{$database}{Filename}, { Text => $main::kiriwrite_lang{options}{compile} });
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
$database_count++;
}
- $kiriwrite_presmodule->endtable();
- $kiriwrite_presmodule->endbox();
- $kiriwrite_presmodule->endform();
+ $main::kiriwrite_presmodule->endtable();
+ $main::kiriwrite_presmodule->endbox();
+ $main::kiriwrite_presmodule->endform();
}
# Disconnect from the database server.
- $kiriwrite_dbmodule->disconnect();
+ $main::kiriwrite_dbmodule->disconnect();
# Check if any databases with problems have appeared and if they
# have, print out a message saying which databases have problems.
if (@permissions_list){
- $kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{database}->{databaseinvalidpermissions}, { Style => "smallpageheader" });
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{database}->{databaseinvalidpermissionstext});
- $kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{database}{databaseinvalidpermissions}, { Style => "smallpageheader" });
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{database}{databaseinvalidpermissionstext});
+ $main::kiriwrite_presmodule->addlinebreak();
foreach $database (@permissions_list){
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext($database);
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($database);
}
- $kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
}
if (@error_list){
- $kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{database}->{databaseerrors}, { Style => "smallpageheader" });
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{database}->{databaseerrorstext});
- $kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{database}{databaseerrors}, { Style => "smallpageheader" });
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{database}{databaseerrorstext});
+ $main::kiriwrite_presmodule->addlinebreak();
foreach $database (@error_list){
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext($database);
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($database);
}
}
- return $kiriwrite_presmodule->grab();
+ return $main::kiriwrite_presmodule->grab();
}
# Check if the output directory exists.
- $output_directory_exists = kiriwrite_fileexists($kiriwrite_config{"directory_data_output"});
+ $output_directory_exists = kiriwrite_fileexists($main::kiriwrite_config{"directory_data_output"});
if ($output_directory_exists eq 1){
# Check if the output directory has invalid
# permissions set.
- $output_directory_permissions = kiriwrite_filepermissions($kiriwrite_config{"directory_data_output"});
+ $output_directory_permissions = kiriwrite_filepermissions($main::kiriwrite_config{"directory_data_output"});
if ($output_directory_permissions eq 1){
# Remove the list of files and directories from the
# output directory.
- $file_permissions = kiriwrite_compile_clean_helper($kiriwrite_config{"directory_data_output"}, 1);
+ $file_permissions = kiriwrite_compile_clean_helper($main::kiriwrite_config{"directory_data_output"}, 1);
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{compile}->{cleanoutputdirectory}, { Style => "pageheader" });
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{compile}{cleanoutputdirectory}, { Style => "pageheader" });
if ($file_permissions eq 1){
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{compile}->{somecontentnotremoved});
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{compile}{somecontentnotremoved});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
} else {
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{compile}->{contentremoved});
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{compile}{contentremoved});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
}
- $kiriwrite_presmodule->addlink($kiriwrite_env{"script_filename"} . "?mode=compile", { Text => $kiriwrite_lang->{compile}->{returncompilelist} });
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{"script_filename"} . "?mode=compile", { Text => $main::kiriwrite_lang{compile}{returncompilelist} });
- return $kiriwrite_presmodule->grab();
+ return $main::kiriwrite_presmodule->grab();
} else {
# Print out a form for cleaning the output directory.
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{compile}->{cleanoutputdirectory}, { Style => "pageheader" });
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->startform($kiriwrite_env{"script_filename"}, "POST");
- $kiriwrite_presmodule->startbox();
- $kiriwrite_presmodule->addhiddendata("mode", "compile");
- $kiriwrite_presmodule->addhiddendata("action", "clean");
- $kiriwrite_presmodule->addhiddendata("confirm", 1);
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{compile}->{cleanoutputdirectorymessage});
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addsubmit($kiriwrite_lang->{compile}->{cleanoutputdirectorybutton});
- $kiriwrite_presmodule->addtext(" | ");
- $kiriwrite_presmodule->addlink($kiriwrite_env{"script_filename"} . "?mode=compile", { Text => $kiriwrite_lang->{compile}->{returncompilelist}});
- $kiriwrite_presmodule->endbox();
- $kiriwrite_presmodule->endform();
-
- return $kiriwrite_presmodule->grab();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{compile}{cleanoutputdirectory}, { Style => "pageheader" });
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->startform($main::kiriwrite_env{"script_filename"}, "POST");
+ $main::kiriwrite_presmodule->startbox();
+ $main::kiriwrite_presmodule->addhiddendata("mode", "compile");
+ $main::kiriwrite_presmodule->addhiddendata("action", "clean");
+ $main::kiriwrite_presmodule->addhiddendata("confirm", 1);
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{compile}{cleanoutputdirectorymessage});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addsubmit($main::kiriwrite_lang{compile}{cleanoutputdirectorybutton});
+ $main::kiriwrite_presmodule->addtext(" | ");
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{"script_filename"} . "?mode=compile", { Text => $main::kiriwrite_lang{compile}{returncompilelist}});
+ $main::kiriwrite_presmodule->endbox();
+ $main::kiriwrite_presmodule->endform();
+
+ return $main::kiriwrite_presmodule->grab();
}
return $permissions;
-}
-
-
-1;
+}
\ No newline at end of file
--- /dev/null
+package Modules::System::Database;
+
+use Modules::System::Common;
+use strict;
+use warnings;
+use Exporter;
+
+our @ISA = qw(Exporter);
+our @EXPORT = qw(kiriwrite_database_list kiriwrite_database_add kiriwrite_database_edit kiriwrite_database_delete);
+
+sub kiriwrite_database_list{
+#################################################################################
+# kiriwrite_database_list: Lists the databases available. #
+# #
+# Usage: #
+# #
+# kiriwrite_database_list(); #
+#################################################################################
+
+ # Connect to the database server.
+
+ $main::kiriwrite_dbmodule->connect();
+
+ # Check if any errors occured while connecting to the database server.
+
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
+
+ # A database connection error has occured so return
+ # an error.
+
+ kiriwrite_error("databaseconnectionerror", $main::kiriwrite_dbmodule->geterror(1));
+
+ }
+
+ # Get the list of available databases and process any errors that
+ # might have occured.
+
+ my @database_list = $main::kiriwrite_dbmodule->getdblist();
+
+ if ($main::kiriwrite_dbmodule->geterror eq "DataDirMissing"){
+
+ # The database directory is missing so return an error.
+
+ kiriwrite_error("datadirectorymissing");
+
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "DataDirInvalidPermissions"){
+
+ # The database directory has invalid permissions set so return
+ # an error.
+
+ kiriwrite_error("datadirectoryinvalidpermissions");
+
+ }
+
+ # Declare the following variables that are going to be used before using
+ # the foreach function.
+
+ my ($database_info, %database_info);
+ my @error_list;
+ my @permissions_list;
+ my $database_count = 0;
+ my $database_filename = "";
+ my $database_filename_friendly = "";
+ my $database_filename_length = 0;
+ my $database_name = "";
+ my $database_description = "";
+ my $database_permissions = "";
+ my $nodescription = 0;
+ my $noname = 0;
+ my $data_file = "";
+ my $table_style = 0;
+ my $table_style_name = "";
+
+ # Begin creating the table for the list of databases.
+
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{database}{databaselist}, { Style => "pageheader" });
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->starttable("", { CellPadding => "5", CellSpacing => "0" });
+ $main::kiriwrite_presmodule->startheader();
+ $main::kiriwrite_presmodule->addheader($main::kiriwrite_lang{database}{databasename}, { Style => "tablecellheader" });
+ $main::kiriwrite_presmodule->addheader($main::kiriwrite_lang{database}{databasedescription}, { Style => "tablecellheader" });
+ $main::kiriwrite_presmodule->addheader($main::kiriwrite_lang{database}{databaseoptions}, { Style => "tablecellheader" });
+ $main::kiriwrite_presmodule->endheader();
+
+ foreach $data_file (@database_list){
+
+ # Select the database.
+
+ $main::kiriwrite_dbmodule->selectdb({ DatabaseName => $data_file });
+
+ # Check if any error occured while selecting the database.
+
+ if ($main::kiriwrite_dbmodule->geterror eq "DoesNotExist"){
+
+ # The database does not exist, so process the next
+ # database.
+
+ next;
+
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "InvalidPermissionsSet") {
+
+ # The database has invalid permissions settings, so
+ # add the database to the list of databases with
+ # invalid permissions set and process the next
+ # database.
+
+ push(@permissions_list, $data_file);
+ next;
+
+ }
+
+ # Get information about the database.
+
+ %database_info = $main::kiriwrite_dbmodule->getdatabaseinfo();
+
+ # Check if any error occured while getting information from the
+ # database.
+
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseError"){
+
+ # A database error has occured, add the database and specific
+ # error message to the list of databases with errors and
+ # process the next database.
+
+ push(@error_list, $data_file . ": " . $main::kiriwrite_dbmodule->geterror(1));
+ next;
+
+ }
+
+ $database_name = $database_info{"DatabaseName"};
+ $database_description = $database_info{"Description"};
+
+ # Check the style to be used with.
+
+ if ($table_style eq 0){
+
+ # Use the first style and set the style value
+ # to use the next style, the next time the
+ # if statement is checked.
+
+ $table_style_name = "tablecell1";
+ $table_style = 1;
+ } else {
+
+ # Use the second style and set the style
+ # value to use the first style, the next
+ # time if statement is checked.
+
+ $table_style_name = "tablecell2";
+ $table_style = 0;
+ }
+
+ # Create a friendly name for the database.
+
+ $database_filename_friendly = $data_file;
+
+ # Append the database information to the table.
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell($table_style_name);
+
+ if (!$database_name){
+ $main::kiriwrite_presmodule->additalictext($main::kiriwrite_lang->{blank}->{noname});
+ } else {
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{"script_filename"} . "?mode=page&action=view&database=" . $database_filename_friendly, { Text => $database_name });
+ }
+
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell($table_style_name);
+
+ if (!$database_description){
+ $main::kiriwrite_presmodule->additalictext($main::kiriwrite_lang{blank}{nodescription});
+ } else {
+ $main::kiriwrite_presmodule->addtext($database_description);
+ }
+
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell($table_style_name);
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{'script_filename'} . "?mode=db&action=edit&database=" . $database_filename_friendly, { Text => $main::kiriwrite_lang{options}{edit} });
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{'script_filename'} . "?mode=compile&action=compile&type=single&database=" . $database_filename_friendly, { Text => $main::kiriwrite_lang{options}{compile} });
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{'script_filename'} . "?mode=db&action=delete&database=" . $database_filename_friendly, { Text => $main::kiriwrite_lang{options}{delete} });
+ $main::kiriwrite_presmodule->endrow();
+
+ $database_count++;
+ $nodescription = 0;
+ $noname = 0;
+
+ }
+
+ $main::kiriwrite_presmodule->endtable();
+
+ # Disconnect from the database server.
+
+ $main::kiriwrite_dbmodule->disconnect();
+
+ # Check if there are no valid databases are if there is no
+ # valid databases then write a message saying that no
+ # valid databases are available.
+
+ if ($database_count eq 0){
+
+ $main::kiriwrite_presmodule->clear();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{database}{databaselist}, { Style => "pageheader" });
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->startbox("errorbox");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{database}{nodatabasesavailable});
+ $main::kiriwrite_presmodule->endbox();
+
+ }
+
+ # Check if any databases with problems have appeared and if they
+ # have, print out a message saying which databases have problems.
+
+ if (@permissions_list){
+
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{database}{databaseinvalidpermissions}, { Style => "smallpageheader" });
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{database}{databaseinvalidpermissionstext});
+ $main::kiriwrite_presmodule->addlinebreak();
+
+ foreach $data_file (@permissions_list){
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($data_file);
+ }
+
+ $main::kiriwrite_presmodule->addlinebreak();
+
+ }
+
+ if (@error_list){
+
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{database}{databaseerrors}, { Style => "smallpageheader" });
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{database}{databaseerrorstext});
+ $main::kiriwrite_presmodule->addlinebreak();
+
+ foreach $data_file (@error_list){
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($data_file);
+ }
+
+ $main::kiriwrite_presmodule->addlinebreak();
+
+ }
+
+ return $main::kiriwrite_presmodule->grab(); # Return to the main part of the script with the processed information.
+
+}
+
+sub kiriwrite_database_add{
+#################################################################################
+# kiriwrite_database_add: Creates a new database. #
+# #
+# Usage: #
+# #
+# kiriwrite_database_add(filename, name, description, notes, categories, #
+# [confirm]); #
+# #
+# filename Specifies the filename for the database. #
+# name Specifies a (friendly) name for the database. #
+# description Specifies a description for the database. #
+# notes Specifies the notes for the database. #
+# categories Specifies the categories for the database. #
+# confirm Confirms the action to create a database. #
+#################################################################################
+
+ # Get the variables passed from the subroutine.
+
+ my ($database_filename, $database_name, $database_description, $database_notes, $database_categories, $database_confirm) = @_;
+
+ # Check if the confirm value is blank and if it is then
+ # set the confirm value to 0.
+
+ if (!$database_confirm){
+
+ # The confirm value was blank so set the value to 0.
+
+ $database_confirm = 0;
+
+ }
+
+ if ($database_confirm eq 1){
+
+ # The action to create a new database is confirmed.
+
+ # Validate the database name and database descriptions.
+
+ my $database_name_check_utf8 = kiriwrite_variablecheck($database_name, "utf8", 0, 0);
+ my $database_description_check_utf8 = kiriwrite_variablecheck($database_description, "utf8", 0, 0);
+ my $database_notes_check_utf8 = kiriwrite_variablecheck($database_notes, "utf8", 0, 0);
+ my $database_categories_check_utf8 = kiriwrite_variablecheck($database_categories, "utf8", 0, 0);
+
+ # Convert the UTF8 strings before checking the length of the strings.
+
+ $database_name = kiriwrite_utf8convert($database_name);
+ $database_description = kiriwrite_utf8convert($database_description);
+ $database_notes = kiriwrite_utf8convert($database_notes);
+ $database_categories = kiriwrite_utf8convert($database_categories);
+
+ my $database_name_check_blank = kiriwrite_variablecheck($database_name, "blank", 0, 1);
+ my $database_name_check_length = kiriwrite_variablecheck($database_name, "maxlength", 256, 1);
+ my $database_description_check_length = kiriwrite_variablecheck($database_description, "maxlength", 512, 1);
+ my $database_filename_check_length = kiriwrite_variablecheck($database_filename, "maxlength", 32, 1);
+ my $database_categories_check_length = kiriwrite_variablecheck($database_categories, "maxlength", 512, 1);
+
+ # Check if values returned contains any values that would
+ # result in a specific error message being returned.
+
+ if ($database_name_check_length eq 1){
+
+ # The length of the database name is too long, so return an error.
+ kiriwrite_error("databasenametoolong");
+
+ }
+
+ if ($database_description_check_length eq 1){
+
+ # The database description length is too long, so return an error.
+ kiriwrite_error("databasedescriptiontoolong");
+
+ }
+
+ if ($database_name_check_blank eq 1){
+
+ # The database name is blank, so return an error.
+ kiriwrite_error("databasenameblank");
+
+ }
+
+ if ($database_filename_check_length eq 1){
+
+ # The database filename is to long, so return an error.
+ kiriwrite_error("databasefilenametoolong");
+
+ }
+
+ if ($database_categories_check_length eq 1){
+
+ # The database categories is too long, so return an error.
+ kiriwrite_error("databasecategoriestoolong");
+
+ }
+
+ # Check if the database filename is blank and if it is then
+ # generate a filename.
+
+ if ($database_filename eq ""){
+
+ # Filename is blank so generate a file name from
+ # the database name.
+
+ $database_filename = kiriwrite_processfilename($database_name);
+
+ } else {
+
+ # Filename is not blank so don't generate a filename.
+
+ }
+
+ kiriwrite_variablecheck($database_filename, "filename", "", 0);
+ kiriwrite_variablecheck($database_filename, "maxlength", 32, 0);
+
+ # Connect to the database server.
+
+ $main::kiriwrite_dbmodule->connect();
+
+ # Check if any errors occured while connecting to the database server.
+
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
+
+ # A database connection error has occured so return
+ # an error.
+
+ kiriwrite_error("databaseconnectionerror", $main::kiriwrite_dbmodule->geterror(1));
+
+ }
+
+ my $database_name_final = $database_name;
+
+ # Create the database.
+
+ $main::kiriwrite_dbmodule->adddatabase({ DatabaseFilename => $database_filename, DatabaseName => $database_name, DatabaseDescription => $database_description, DatabaseNotes => $database_notes, DatabaseCategories => $database_categories, VersionMajor => $main::kiriwrite_version{"major"}, VersionMinor => $main::kiriwrite_version{"minor"}, VersionRevision => $main::kiriwrite_version{"revision"} });
+
+ # Check if any errors have occured.
+
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseExists"){
+
+ # A database with the filename given already exists, so
+ # return an error.
+
+ kiriwrite_error("fileexists");
+
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "DatabaseError"){
+
+ # A database error has occured so return an error with
+ # the extended error information.
+
+ kiriwrite_error("databaseerror", $main::kiriwrite_dbmodule->geterror(1));
+
+ }
+
+ # Disconnect from the database server.
+
+ $main::kiriwrite_dbmodule->disconnect();
+
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{database}{adddatabase}, { Style => "pageheader" });
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext(kiriwrite_language($main::kiriwrite_lang{database}{databaseadded} , $database_name_final));
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{"script_filename"} . "?mode=db", { Text => $main::kiriwrite_lang{database}{databaselistreturnlink} });
+
+ return $main::kiriwrite_presmodule->grab();
+
+ }
+
+ # There is confirm value is not 1, so write a form for creating a database to
+ # store pages in.
+
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{database}{adddatabase}, { Style => "pageheader" });
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->startform($main::kiriwrite_env{"script_filename"}, "POST");
+ $main::kiriwrite_presmodule->startbox();
+ $main::kiriwrite_presmodule->addhiddendata("mode", "db");
+ $main::kiriwrite_presmodule->addhiddendata("action", "new");
+ $main::kiriwrite_presmodule->addhiddendata("confirm", "1");
+ $main::kiriwrite_presmodule->endbox();
+ $main::kiriwrite_presmodule->starttable("", { CellPadding => 5, CellSpacing => 0 });
+
+ $main::kiriwrite_presmodule->startheader();
+ $main::kiriwrite_presmodule->addheader($main::kiriwrite_lang{common}{setting}, { Style => "tablecellheader"});
+ $main::kiriwrite_presmodule->addheader($main::kiriwrite_lang{common}{value}, { Style => "tablecellheader"});
+ $main::kiriwrite_presmodule->endheader();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{database}{databasename});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addinputbox("databasename", { Size => 64, MaxLength => 256 });
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{database}{databasedescription});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addinputbox("databasedescription", { Size => 64, MaxLength => 512 });
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{database}{databasecategories});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addinputbox("databasecategories", { Size => 64, MaxLength => 512 });
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{database}{databasenotes});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addtextbox("databasenotes", { Columns => $main::kiriwrite_config{"display_textareacols"}, Rows => $main::kiriwrite_config{"display_textarearows"}, WordWrap => 0 });
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{database}{databasefilename});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addinputbox("databasefilename", { Size => 32, MaxLength => 32 });
+ $main::kiriwrite_presmodule->startlist();
+ $main::kiriwrite_presmodule->additem($main::kiriwrite_lang{database}{adddatabaseautogenerate});
+ $main::kiriwrite_presmodule->additem($main::kiriwrite_lang{database}{adddatabasenoextensions});
+ $main::kiriwrite_presmodule->additem($main::kiriwrite_lang{database}{adddatabasecharacterlength});
+ $main::kiriwrite_presmodule->additem($main::kiriwrite_lang{database}{adddatabasecharacters});
+ $main::kiriwrite_presmodule->endlist();
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->endtable();
+ $main::kiriwrite_presmodule->startbox();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addsubmit($main::kiriwrite_lang{database}{adddatabasebutton});
+ $main::kiriwrite_presmodule->addtext("|");
+ $main::kiriwrite_presmodule->addreset($main::kiriwrite_lang{database}{clearvaluesbutton});
+ $main::kiriwrite_presmodule->addtext("| ");
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{"script_filename"} . "?mode=db", { Text => $main::kiriwrite_lang{database}{databaselistreturnlink} });
+ $main::kiriwrite_presmodule->endbox();
+ $main::kiriwrite_presmodule->endform();
+
+ # Exit the subroutine taking the data in the pagadata variable with it.
+
+ return $main::kiriwrite_presmodule->grab();
+
+}
+
+sub kiriwrite_database_edit{
+#################################################################################
+# kiriwrite_database_edit: Edits an database. #
+# #
+# Usage: #
+# #
+# kiriwrite_database_edit(filename, newfilename, newname, newdescription, #
+# notes, categories, [confirm]); #
+# #
+# filename Specifies the filename of the database. #
+# newfilename Specifies the new filename of the database. #
+# newname Specifies the new name of the database. #
+# newdescription Specifies the new description of the database. #
+# notes Specifies the new notes of the database. #
+# categories Specifies the new categories of the database. #
+# confirm Confirms the action to edit a database. #
+#################################################################################
+
+ # First, get all the variables passed to the subroutine.
+
+ my ($database_shortname, $database_newfilename, $database_newname, $database_newdescription, $database_notes, $database_categories, $database_confirm) = @_;
+
+ # Check if the database confirm value is blank and if it is
+ # set the confirm value to 0.
+
+ if (!$database_confirm){
+
+ $database_confirm = 0;
+
+ }
+
+ # Check if the database filename given is valid and return an error
+ # if it isn't.
+
+ kiriwrite_variablecheck($database_shortname, "filename", "", 0);
+
+ # Check if the confirm variable has a value in it, if it has, check again to make sure it really is the correct value (Perl moans
+ # if $database_confirm was used directly).
+
+ if ($database_confirm eq 1){
+
+ # Check if the new data passes the validation tests below. First, check the length of the variables.
+
+ my $database_name_check_utf8 = kiriwrite_variablecheck($database_newname, "utf8", 0, 0);
+ my $database_description_check_utf8 = kiriwrite_variablecheck($database_newdescription, "utf8", 0, 0);
+ my $database_notes_check_utf8 = kiriwrite_variablecheck($database_notes, "utf8", 0, 0);
+ my $database_categories_check_utf8 = kiriwrite_variablecheck($database_categories, "utf8", 0, 0);
+
+ # Convert the UTF8 strings to make sure their length is accurate.
+
+ $database_newname = kiriwrite_utf8convert($database_newname);
+ $database_newdescription = kiriwrite_utf8convert($database_newdescription);
+ $database_notes = kiriwrite_utf8convert($database_notes);
+ $database_categories = kiriwrite_utf8convert($database_categories);
+
+ # Preform the following tests.
+
+ my $database_filename_check_length = kiriwrite_variablecheck($database_newfilename, "maxlength", 32, 1);
+ my $database_filename_letnum = kiriwrite_variablecheck($database_newfilename, "filename", 0, 0);
+ my $database_name_check_length = kiriwrite_variablecheck($database_newname, "maxlength", 256, 1);
+ my $database_description_check_length = kiriwrite_variablecheck($database_newdescription, "maxlength", 512, 1);
+ my $database_categories_check_length = kiriwrite_variablecheck($database_categories, "maxlength", 512, 1);
+ my $database_name_check_blank = kiriwrite_variablecheck($database_newname, "blank", 0, 1);
+
+ # Check if the data is valid and return a specific error if it doesn't.
+
+ if ($database_name_check_length eq 1){
+
+ # The length of the database name is too long, so return an error.
+ kiriwrite_error("databasenametoolong");
+
+ }
+
+ if ($database_description_check_length eq 1){
+
+ # The database description length is too long, so return an error.
+ kiriwrite_error("databasedescriptiontoolong");
+
+ }
+
+ if ($database_name_check_blank eq 1){
+
+ # The database name is blank, so return an error.
+ kiriwrite_error("databasenameblank");
+
+ }
+
+ if ($database_filename_check_length eq 1){
+
+ # The database filename is too long, so return an error.
+ kiriwrite_error("databasefilenametoolong");
+
+ }
+
+ if ($database_categories_check_length eq 1){
+
+ # The database categories is too long, so return an error.
+ kiriwrite_error("databasecategoriestoolong");
+
+ }
+
+ # Connect to the database server.
+
+ $main::kiriwrite_dbmodule->connect();
+
+ # Check if any errors occured while connecting to the database server.
+
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
+
+ # A database connection error has occured so return
+ # an error.
+
+ kiriwrite_error("databaseconnectionerror", $main::kiriwrite_dbmodule->geterror(1));
+
+ }
+
+ # Get the database.
+
+ $main::kiriwrite_dbmodule->selectdb({ DatabaseName => $database_shortname });
+
+ # Check if any errors had occured while selecting the database.
+
+ if ($main::kiriwrite_dbmodule->geterror eq "DoesNotExist"){
+
+ # The database does not exist, so return an error.
+
+ kiriwrite_error("databasemissingfile");
+
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "InvalidPermissionsSet"){
+
+ # The database has invalid permissions set, so return
+ # an error.
+
+ kiriwrite_error("databaseinvalidpermissions");
+
+ }
+
+ # FIX THIS!! >O
+
+ $main::kiriwrite_dbmodule->editdatabase({ DatabaseNewFilename => $database_newfilename, DatabaseName => $database_newname , DatabaseDescription => $database_newdescription , DatabaseNotes => $database_notes, DatabaseCategories => $database_categories });
+
+ # Check if any errors had occured while using the database.
+
+ if ($main::kiriwrite_dbmodule->geterror eq "DoesNotExist"){
+
+ # The database does not exist, so return an error.
+
+ kiriwrite_error("databasemissingfile");
+
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "InvalidPermissionsSet"){
+
+ # The database has invalid permissions set, so return
+ # an error.
+
+ kiriwrite_error("databaseinvalidpermissions");
+
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "DataDirInvalidPermissions"){
+
+ # The database directory has invalid permissions set, so
+ # return an error.
+
+ kiriwrite_error("datadirectoryinvalidpermissions");
+
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "DatabaseExists"){
+
+ # A database already exists with the new filename, so
+ # return an error.
+
+ kiriwrite_error("databasealreadyexists");
+
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "DatabaseError"){
+
+ # A database error has occured so return an error with
+ # the extended error information.
+
+ kiriwrite_error("databaseerror", $main::kiriwrite_dbmodule->geterror(1));
+
+ }
+
+ # Disconnect from the server.
+
+ $main::kiriwrite_dbmodule->disconnect();
+
+ # Write out a message saying that the database has been updated.
+
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{database}{editeddatabase}, { Style => "pageheader" } );
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext(kiriwrite_language($main::kiriwrite_lang{database}{databaseupdated}, $database_newname));
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{"script_filename"} . "?mode=db", { Text => $main::kiriwrite_lang{database}{databaselistreturnlink} });
+
+ return $main::kiriwrite_presmodule->grab();
+
+ } else {
+
+ my (%database_info);
+
+ # Check if the database filename given is valid and return an error
+ # if it isn't.
+
+ # Connect to the database server.
+
+ $main::kiriwrite_dbmodule->connect();
+
+ # Check if any errors occured while connecting to the database server.
+
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
+
+ # A database connection error has occured so return
+ # an error.
+
+ kiriwrite_error("databaseconnectionerror", $main::kiriwrite_dbmodule->geterror(1));
+
+ }
+
+ # Select the database.
+
+ $main::kiriwrite_dbmodule->selectdb({ DatabaseName => $database_shortname });
+
+ # Check if any errors had occured while setting the database.
+
+ if ($main::kiriwrite_dbmodule->geterror eq "DoesNotExist"){
+
+ # The database does not exist, so return an error.
+
+ kiriwrite_error("databasemissingfile");
+
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "InvalidPermissionsSet"){
+
+ # The database has invalid permissions set, so return
+ # an error.
+
+ kiriwrite_error("databaseinvalidpermissions");
+
+ }
+
+ # Get the database information.
+
+ %database_info = $main::kiriwrite_dbmodule->getdatabaseinfo();
+
+ # Check if any errors had occured while getting the database
+ # information.
+
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseError"){
+
+ # A database error has occured so return an error and
+ # also the extended error information.
+
+ kiriwrite_error("databaseerror", $main::kiriwrite_dbmodule->geterror(1));
+
+ }
+
+ # Get the values needed from the kiriwrite_database_info table.
+
+ my $database_oldname = $database_info{"DatabaseName"};
+ my $database_olddescription = $database_info{"Description"};
+ my $database_notes = $database_info{"Notes"};
+ my $database_categories = $database_info{"Categories"};
+
+ # Disconnect from the database server.
+
+ $main::kiriwrite_dbmodule->disconnect();
+
+ # Print out the form for editing a database's settings.
+
+ $main::kiriwrite_presmodule->addtext(kiriwrite_language($main::kiriwrite_lang{database}{editdatabase}, $database_oldname), { Style => "pageheader" });
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->startform($main::kiriwrite_env{"script_filename"}, "POST");
+ $main::kiriwrite_presmodule->startbox();
+ $main::kiriwrite_presmodule->addhiddendata("mode", "db");
+ $main::kiriwrite_presmodule->addhiddendata("action", "edit");
+ $main::kiriwrite_presmodule->addhiddendata("database", $database_shortname);
+ $main::kiriwrite_presmodule->addhiddendata("confirm", "1");
+ $main::kiriwrite_presmodule->endbox();
+
+ $main::kiriwrite_presmodule->starttable("", { CellPadding => 5, CellSpacing => 0 });
+ $main::kiriwrite_presmodule->startheader();
+ $main::kiriwrite_presmodule->addheader("Setting", { Style => "tablecellheader" });
+ $main::kiriwrite_presmodule->addheader("Value", { Style => "tablecellheader" });
+ $main::kiriwrite_presmodule->endheader();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{database}{databasename});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addinputbox("databasename", { Size => 64, MaxLength => 256, Value => $database_oldname } );
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{database}{databasedescription});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addinputbox("databasedescription", { Size => 64, MaxLength => 512, Value => $database_olddescription } );
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{database}{databasecategories});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addinputbox("databasecategories", { Size => 64, MaxLength => 512, Value => $database_categories } );
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{database}{databasenotes});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addtextbox("databasenotes", { Columns => $main::kiriwrite_config{"display_textareacols"}, Rows => $main::kiriwrite_config{"display_textarearows"}, Value => $database_notes } );
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{database}{databasefilename});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addinputbox("databasefilename", { Size => 32, MaxLength => 32, Value => $database_shortname } );
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->endtable();
+
+ $main::kiriwrite_presmodule->startbox();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addsubmit($main::kiriwrite_lang{database}{editdatabasebutton});
+ $main::kiriwrite_presmodule->addtext(" | ");
+ $main::kiriwrite_presmodule->addreset($main::kiriwrite_lang{common}{restorecurrent});
+ $main::kiriwrite_presmodule->addtext(" | ");
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{"script_filename"} . "?mode=db", { Text => $main::kiriwrite_lang{database}{databaselistreturnlink} });
+ $main::kiriwrite_presmodule->endbox();
+ $main::kiriwrite_presmodule->endform();
+
+ return $main::kiriwrite_presmodule->grab();
+
+ }
+
+ # The interpreter should not be here. So return an error saying invalid variable.
+
+ kiriwrite_error("invalidvariable");
+
+}
+
+sub kiriwrite_database_delete{
+#################################################################################
+# kiriwrite_database_delete: Deletes an database. #
+# #
+# Usage: #
+# #
+# kiriwrite_database_delete(filename, [confirm]); #
+# #
+# filename Specifies the filename for the database to be deleted. #
+# confirm Confirms the action to delete a database. #
+#################################################################################
+
+ my ($database_filename, $database_confirm) = @_;
+
+ # Check if the confirm value is blank and if it is then set the
+ # confirm value to 0.
+
+ if (!$database_confirm){
+
+ $database_confirm = 0;
+
+ }
+
+ # Connect to the database server.
+
+ $main::kiriwrite_dbmodule->connect();
+
+ # Check if any errors occured while connecting to the database server.
+
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
+
+ # A database connection error has occured so return
+ # an error.
+
+ kiriwrite_error("databaseconnectionerror", $main::kiriwrite_dbmodule->geterror(1));
+
+ }
+
+ # Check if the database filename given is valid and return an error
+ # if it isn't.
+
+ kiriwrite_variablecheck($database_filename, "filename", "", 0);
+
+ # Check if the request to delete a database has been confirmed. If it has,
+ # then delete the database itself.
+
+ if ($database_confirm eq 1){
+ # There is a value in the confirm variable of the HTTP query.
+
+ # Select the database to delete and get the database name.
+
+ $main::kiriwrite_dbmodule->selectdb({ DatabaseName => $database_filename });
+
+ # Check if any error occured while selecting the database.
+
+ if ($main::kiriwrite_dbmodule->geterror eq "DoesNotExist"){
+
+ # The database does not exist so return an error.
+
+ kiriwrite_error("databasemissingfile");
+
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "InvalidPermissionsSet") {
+
+ # The database has invalid permissions set so return
+ # an error.
+
+ kiriwrite_error("databaseinvalidpermissions");
+
+ }
+
+ my %database_info = $main::kiriwrite_dbmodule->getdatabaseinfo();
+
+ # Check if any errors have occured while getting the database
+ # name.
+
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseError"){
+
+ # A database error has occured so return an error with
+ # the extended error information.
+
+ kiriwrite_error("databaseerror", $main::kiriwrite_dbmodule->geterror(1));
+
+ }
+
+ my $database_name = $database_info{"DatabaseName"};
+
+ # Delete the selected database.
+
+ $main::kiriwrite_dbmodule->deletedatabase({ DatabaseName => $database_filename });
+
+ # Check if any error occured while deleting the database.
+
+ if ($main::kiriwrite_dbmodule->geterror eq "DoesNotExist"){
+
+ # The database does not exist so return an error.
+
+ kiriwrite_error("databasemissingfile");
+
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "InvalidPermissionsSet") {
+
+ # The database has invalid permissions set so return
+ # an error.
+
+ kiriwrite_error("databaseinvalidpermissions");
+
+ }
+
+ # Disconnect from the database server.
+
+ $main::kiriwrite_dbmodule->disconnect();
+
+ # Write a message saying that the database has been deleted.
+
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{database}{deleteddatabase}, { Style => "pageheader" });
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext(kiriwrite_language($main::kiriwrite_lang{database}{deleteddatabasemessage}, $database_name));
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{"script_filename"} . "?mode=db", { Text => $main::kiriwrite_lang{database}{databaselistreturnlink} });
+
+ return $main::kiriwrite_presmodule->grab();
+
+ }
+
+ # The action has not been confirmed, so write out a form asking the
+ # user to confirm.
+
+ # Get the database name.
+
+ $main::kiriwrite_dbmodule->selectdb({ DatabaseName => $database_filename });
+
+ # Check if any error occured while selecting the database.
+
+ if ($main::kiriwrite_dbmodule->geterror eq "DoesNotExist"){
+
+ # The database does not exist so return an error.
+
+ kiriwrite_error("databasemissingfile");
+
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "InvalidPermissionsSet") {
+
+ # The database has invalid permissions set so return
+ # an error.
+
+ kiriwrite_error("databaseinvalidpermissions");
+
+
+ }
+
+ # Check if any errors have occured.
+
+ my %database_info = $main::kiriwrite_dbmodule->getdatabaseinfo();
+
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseError"){
+
+ # A database error has occured so return an error with
+ # the extended error information.
+
+ kiriwrite_error("databaseerror", $main::kiriwrite_dbmodule->geterror(1));
+
+ }
+
+ my $database_name = $database_info{"DatabaseName"};
+
+ # Disconnect from the database server.
+
+ $main::kiriwrite_dbmodule->disconnect();
+
+ # Write out the form to ask the user to confirm the deletion of the
+ # selected database.
+
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{database}{deletedatabase}, { Style => "pageheader" });
+ $main::kiriwrite_presmodule->startform($main::kiriwrite_env{"script_filename"}, "POST");
+ $main::kiriwrite_presmodule->startbox();
+ $main::kiriwrite_presmodule->addhiddendata("mode", "db");
+ $main::kiriwrite_presmodule->addhiddendata("action", "delete");
+ $main::kiriwrite_presmodule->addhiddendata("database", $database_filename);
+ $main::kiriwrite_presmodule->addhiddendata("confirm", "1");
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext(kiriwrite_language($main::kiriwrite_lang{database}{deletedatabasemessage}, $database_name));
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addsubmit($main::kiriwrite_lang{database}{deletedatabasebutton});
+ $main::kiriwrite_presmodule->addtext(" | ");
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{"script_filename"} . "?mode=db", { Text => $main::kiriwrite_lang{database}{deletedatabasereturn} });
+ $main::kiriwrite_presmodule->endbox();
+ $main::kiriwrite_presmodule->endform();
+
+ return $main::kiriwrite_presmodule->grab();
+
+}
+
+1;
\ No newline at end of file
--- /dev/null
+package Modules::System::Filter;
+
+use Modules::System::Common;
+use strict;
+use warnings;
+use Exporter;
+
+our @ISA = qw(Exporter);
+our @EXPORT = qw(kiriwrite_filter_list kiriwrite_filter_add kiriwrite_filter_edit kiriwrite_filter_delete);
+
+sub kiriwrite_filter_list{
+#################################################################################
+# kiriwrite_filter_list: Lists the filters that will be used when compiling a #
+# webpage. #
+# #
+# Usage: #
+# #
+# kiriwrite_filter_list([browsenumber]); #
+# #
+# browsenumber Specifies the page browse number to use. #
+#################################################################################
+
+ my $filter_browsenumber = shift;
+
+ my $filtersdb_notexist = 0;
+
+ # Connect to the database server.
+
+ $main::kiriwrite_dbmodule->connect();
+
+ # Check if any errors occured while connecting to the database server.
+
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
+
+ # A database connection error has occured so return
+ # an error.
+
+ kiriwrite_error("databaseconnectionerror", $main::kiriwrite_dbmodule->geterror(1));
+
+ }
+
+ # Connect to the filter database.
+
+ $main::kiriwrite_dbmodule->connectfilter();
+
+ # Check if any error has occured while connecting to the filter
+ # database.
+
+ if ($main::kiriwrite_dbmodule->geterror eq "FilterDatabaseDoesNotExist"){
+
+ # The filter database does not exist.
+
+ $filtersdb_notexist = 1;
+
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "FilterDatabaseInvalidPermissionsSet"){
+
+ # The filter database has invalid permissions set so return
+ # an error.
+
+ kiriwrite_error("filtersdbpermissions");
+
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "FilterDatabaseError"){
+
+ # A database error has occured with the filter database.
+
+ kiriwrite_error("filtersdbdatabaseerror", $main::kiriwrite_dbmodule->geterror(1));
+
+ }
+
+ # Define some variables required for processing the filters list.
+
+ my %filter_list;
+ my %filter_info;
+ my @database_filters;
+ my $blankfindfilter = 0;
+ my $filterswarning = "";
+ my $filter;
+ my $filter_split = $main::kiriwrite_config{"display_filtercount"};
+ my $filter_list = 0;
+ my $filter_count = 0;
+ my $filter_style = 0;
+ my $filter_list_count = 0;
+ my $filter_total_count;
+ my $filter_style_name = "";
+
+ tie(%filter_list, 'Tie::IxHash');
+
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{filter}{viewfilters}, { Style => "pageheader" });
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+
+ # If the filter database exists then get the list of filters,
+ # otherwise write a message saying that the filter database
+ # does not exist and will be created when a filter is added.
+
+ if ($filtersdb_notexist eq 0){
+
+ if (!$filter_browsenumber || $filter_browsenumber eq 0){
+
+ $filter_browsenumber = 1;
+
+ }
+
+ # Check if the filter browse number is valid and if it isn't
+ # then return an error.
+
+ my $kiriwrite_browsenumber_length_check = kiriwrite_variablecheck($filter_browsenumber, "maxlength", 7, 1);
+ my $kiriwrite_browsenumber_number_check = kiriwrite_variablecheck($filter_browsenumber, "numbers", 0, 1);
+
+ if ($kiriwrite_browsenumber_length_check eq 1){
+
+ # The browse number was too long so return
+ # an error.
+
+ kiriwrite_error("browsenumbertoolong");
+
+ }
+
+ if ($kiriwrite_browsenumber_number_check eq 1){
+
+ # The browse number wasn't a number so
+ # return an error.
+
+ kiriwrite_error("browsenumberinvalid");
+
+ }
+
+ # Get the total count of filters in the filter database.
+
+ my $filter_total_count = $main::kiriwrite_dbmodule->getfiltercount();
+
+ # Check if any errors occured while getting the count of filters.
+
+ if ($main::kiriwrite_dbmodule->geterror eq "FilterDatabaseError"){
+
+ # A database error has occured with the filter database.
+
+ kiriwrite_error("filtersdbdatabaseerror", $main::kiriwrite_dbmodule->geterror(1));
+
+ }
+
+ if ($filter_total_count ne 0){
+
+ if ($filter_total_count eq $filter_split){
+
+ $filter_list = int(($filter_total_count / $filter_split));
+
+ } else {
+
+ $filter_list = int(($filter_total_count / $filter_split) + 1);
+
+ }
+
+ }
+
+ my $start_from = ($filter_browsenumber - 1) * $filter_split;
+
+ # Get the list of available filters.
+
+ @database_filters = $main::kiriwrite_dbmodule->getfilterlist({ StartFrom => $start_from, Limit => $filter_split });
+
+ # Check if any errors occured while getting the list of filters.
+
+ if ($main::kiriwrite_dbmodule->geterror eq "FilterDatabaseError"){
+
+ # A database error has occured with the filter database.
+
+ kiriwrite_error("filtersdbdatabaseerror", $main::kiriwrite_dbmodule->geterror(1));
+
+ }
+
+ # Process each filter getting the priority, find setting and
+ # replace setting.
+
+ foreach $filter (@database_filters){
+
+ # Get the information about the filter.
+
+ %filter_info = $main::kiriwrite_dbmodule->getfilterinfo({ FilterID => $filter });
+
+ # Check if any errors occured while getting the filter information.
+
+ if ($main::kiriwrite_dbmodule->geterror eq "FilterDatabaseError"){
+
+ # A database error occured while using the filter database.
+
+ kiriwrite_error("filtersdbdatabaseerror", $main::kiriwrite_dbmodule->geterror(1));
+
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "FilterDoesNotExist"){
+
+ # The filter does not exist so process the next filter.
+
+ next;
+
+ }
+
+ # Check if the find filter is blank.
+
+ if (!$filter_info{"FilterFind"}){
+
+ # The find filter is blank, so set the value to write a warning
+ # message saying that a find filter given is blank.
+
+ $blankfindfilter = 1;
+
+ }
+
+ $filter_list{$filter_count}{ID} = $filter_info{"FilterID"};
+ $filter_list{$filter_count}{Priority} = $filter_info{"FilterPriority"};
+ $filter_list{$filter_count}{Find} = $filter_info{"FilterFind"};
+ $filter_list{$filter_count}{Replace} = $filter_info{"FilterReplace"};
+ $filter_list{$filter_count}{Enabled} = $filter_info{"FilterEnabled"};
+ $filter_list{$filter_count}{Notes} = $filter_info{"FilterNotes"};
+
+ $filter_count++;
+
+ }
+
+ # Check if there are filters in the filter database and
+ # write a message if there isn't.
+
+ }
+
+ # Check if the database wasn't found and if it
+ # wasn't then write a message saying that the
+ # database will be created when a filter is
+ # added.
+
+ if ($filtersdb_notexist eq 1){
+
+ # The filter database doesn't exist so write
+ # a message.
+
+ $main::kiriwrite_presmodule->clear();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{filter}{viewfilters}, { Style => "pageheader" });
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->startbox("errorbox");
+ $main::kiriwrite_presmodule->enterdata($main::kiriwrite_lang{filter}{filterdatabasedoesnotexist});
+ $main::kiriwrite_presmodule->endbox();
+
+ # Disconnect from the filter database.
+
+ $main::kiriwrite_dbmodule->disconnectfilter();
+
+ # Disconnect from the database server.
+
+ $main::kiriwrite_dbmodule->disconnect();
+ return $main::kiriwrite_presmodule->grab();
+
+ }
+
+ # Check if there is a warning message and if
+ # there is then write that warning message
+ # else write the list of filters.
+
+ if ($filterswarning){
+
+ $main::kiriwrite_presmodule->startbox("errorbox");
+ $main::kiriwrite_presmodule->addtext($filterswarning);
+ $main::kiriwrite_presmodule->endbox();
+
+ } elsif ($filter_count) {
+
+ # The filter database exists so write out the
+ # list of filters.
+
+ if ($blankfindfilter eq 1){
+
+ $main::kiriwrite_presmodule->addboldtext($main::kiriwrite_lang{filter}{warningtitle});
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{filter}{blankfindfilters});
+ $main::kiriwrite_presmodule->addtext();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+
+ }
+
+ # Start a form for using the filter browsing list with.
+
+ $main::kiriwrite_presmodule->startform($main::kiriwrite_env{"script_filename"}, "GET");
+ $main::kiriwrite_presmodule->addhiddendata("mode", "filter");
+
+ # Write out the filter browsing list.
+
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{filter}{showlistpage});
+ $main::kiriwrite_presmodule->addselectbox("browsenumber");
+
+ # Write out the list of available pages to browse.
+
+ while ($filter_list_count ne $filter_list){
+
+ $filter_list_count++;
+
+ if ($filter_list_count eq 1 && !$filter_browsenumber){
+
+ $main::kiriwrite_presmodule->addoption($filter_list_count, { Value => $filter_list_count, Selected => 1 });
+
+ } else {
+
+ if ($filter_browsenumber eq $filter_list_count){
+
+ $main::kiriwrite_presmodule->addoption($filter_list_count, { Value => $filter_list_count, Selected => 1 });
+
+ } else {
+
+ $main::kiriwrite_presmodule->addoption($filter_list_count, { Value => $filter_list_count });
+
+ }
+
+ }
+
+ }
+
+ $main::kiriwrite_presmodule->endselectbox();
+ $main::kiriwrite_presmodule->addbutton("action", { Value => "view", Description => $main::kiriwrite_lang{filter}{show} });
+
+ if ($filter_list ne $filter_browsenumber){
+
+ $main::kiriwrite_presmodule->addtext(" | ");
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{"script_filename"} . "?mode=filter&action=view&browsenumber=" . ($filter_browsenumber + 1), { Text => $main::kiriwrite_lang{filter}{nextpage} });
+
+ }
+
+ # Check if the filter browse number is not blank and
+ # not set as 0 and hide the Previous page link if
+ # it is.
+
+ if ($filter_browsenumber > 1){
+
+ $main::kiriwrite_presmodule->addtext(" | ");
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{"script_filename"} . "?mode=filter&action=view&browsenumber=" . ($filter_browsenumber - 1), { Text => $main::kiriwrite_lang{filter}{previouspage} });
+
+ }
+
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+
+ $main::kiriwrite_presmodule->starttable("", { CellPadding => 5, CellSpacing => 0 });
+
+ $main::kiriwrite_presmodule->startheader();
+ $main::kiriwrite_presmodule->addheader($main::kiriwrite_lang{filter}{priority}, { Style => "tablecellheader" });
+ $main::kiriwrite_presmodule->addheader($main::kiriwrite_lang{filter}{findsetting}, { Style => "tablecellheader" });
+ $main::kiriwrite_presmodule->addheader($main::kiriwrite_lang{filter}{replacesetting}, { Style => "tablecellheader" });
+ $main::kiriwrite_presmodule->addheader($main::kiriwrite_lang{common}{options}, { Style => "tablecellheader" });
+ $main::kiriwrite_presmodule->endheader();
+
+ foreach $filter (keys %filter_list){
+
+ # Check which style should be used.
+
+ if ($filter_style eq 0){
+
+ $filter_style_name = "tablecell1";
+ $filter_style = 1;
+
+ } else {
+
+ $filter_style_name = "tablecell2";
+ $filter_style = 0;
+
+ }
+
+ # Check if the filter is disabled.
+
+ if (!$filter_list{$filter}{Enabled}){
+
+ $filter_style_name = "tablecelldisabled";
+
+ }
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell($filter_style_name);
+ $main::kiriwrite_presmodule->addtext($filter_list{$filter}{Priority});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell($filter_style_name);
+
+ # Check if the find filter is blank.
+
+ if (!$filter_list{$filter}{Find}){
+
+ # The find filter is blank.
+
+ $main::kiriwrite_presmodule->additalictext($main::kiriwrite_lang{filter}{blankfindsetting});
+
+ } else {
+
+ # The find filter is not blank.
+
+ $main::kiriwrite_presmodule->addtext($filter_list{$filter}{Find});
+
+ }
+
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell($filter_style_name);
+
+ # Check if the replace filter is blank.
+
+ if (!$filter_list{$filter}{Replace}){
+
+ # The replace filter is blank.
+
+ $main::kiriwrite_presmodule->additalictext($main::kiriwrite_lang{filter}{blankreplacesetting});
+
+ } else {
+
+ # The replace filter is not blank.
+
+ $main::kiriwrite_presmodule->addtext($filter_list{$filter}{Replace});
+
+ }
+
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell($filter_style_name);
+ $main::kiriwrite_presmodule->addlink("?mode=filter&action=edit&filter=" . $filter_list{$filter}{ID}, { Text => $main::kiriwrite_lang{options}{edit} });
+ $main::kiriwrite_presmodule->addlink("?mode=filter&action=delete&filter=" . $filter_list{$filter}{ID}, { Text => $main::kiriwrite_lang{options}{delete} });
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ }
+
+ $main::kiriwrite_presmodule->endtable();
+ $main::kiriwrite_presmodule->endform();
+
+ }
+
+ if (!$filter_total_count){
+
+ $filter_total_count = "";
+
+ }
+
+ if ($filter_browsenumber > 1 && !@database_filters){
+
+ # There were no values given for the page browse
+ # number given so write a message saying that
+ # there were no pages for the page browse number
+ # given.
+
+ $main::kiriwrite_presmodule->clear();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{filter}{viewfilters}, { Style => "pageheader" });
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->startbox("errorbox");
+ $main::kiriwrite_presmodule->enterdata($main::kiriwrite_lang{filter}{nofiltersinpagebrowse});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{"script_filename"} . "?mode=filter", { Text => $main::kiriwrite_lang{filter}{returntofirstpagebrowse} });
+ $main::kiriwrite_presmodule->endbox();
+
+ } elsif (!@database_filters || !$filter_count || $filter_total_count eq 0){
+
+ # There are no filters in the filter database.
+
+ $main::kiriwrite_presmodule->clear();
+ $main::kiriwrite_presmodule->addtext(kiriwrite_language($main::kiriwrite_lang{filter}{viewfilters}), { Style => "pageheader" });
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->startbox("errorbox");
+ $main::kiriwrite_presmodule->enterdata($main::kiriwrite_lang{filter}{nofiltersavailable});
+ $main::kiriwrite_presmodule->endbox();
+
+ }
+
+ # Disconnect from the filter database.
+
+ $main::kiriwrite_dbmodule->disconnectfilter();
+
+ # Disconnect from the database server.
+
+ $main::kiriwrite_dbmodule->disconnect();
+
+ return $main::kiriwrite_presmodule->grab();
+
+}
+
+sub kiriwrite_filter_add{
+#################################################################################
+# kiriwrite_filter_add: Adds a filter to the filter list. #
+# #
+# Usage: #
+# #
+# kiriwrite_filter_add(options); #
+# #
+# options Specifies the following options as a hash (in any order). #
+# #
+# FindFilter Specifies the find filter setting. #
+# ReplaceFilter Specifies the replace filter setting. #
+# Priority Specifies the priority of the filter. #
+# Enabled Specifies if the filter should be enabled. #
+# Notes Specifies some notes about the filter. #
+# Confirm Specifies if the filter should be added. #
+#################################################################################
+
+ # Get the values that have been passed to the subroutine.
+
+ my ($options) = @_;
+
+ my $confirm = $options->{"Confirm"};
+
+ # Check the confirm value to make sure it is no more than
+ # one character long.
+
+ kiriwrite_variablecheck($confirm, "maxlength", 1, 0);
+
+ if (!$confirm){
+
+ # The confirm value is undefined, so set the
+ # value of the confirm integer to '0'.
+
+ $confirm = 0;
+
+ }
+
+ if ($confirm eq 1){
+
+ # The confirm integer is '1', so add the word
+ # to the filter list.
+
+ # Get the values from the hashref.
+
+ my $filter_new_find = $options->{"FindFilter"};
+ my $filter_new_replace = $options->{"ReplaceFilter"};
+ my $filter_new_priority = $options->{"Priority"};
+ my $filter_new_enabled = $options->{"Enabled"};
+ my $filter_new_notes = $options->{"Notes"};
+
+ # First, check the variables recieved are UTF8
+ # copliant.
+
+ kiriwrite_variablecheck($filter_new_find, "utf8", 0, 0);
+ kiriwrite_variablecheck($filter_new_replace, "utf8", 0, 0);
+ kiriwrite_variablecheck($filter_new_priority, "utf8", 0, 0);
+ kiriwrite_variablecheck($filter_new_notes, "utf8", 0, 0);
+
+ # Convert the UTF8 values so that the length can
+ # checked properly.
+
+ $filter_new_find = kiriwrite_utf8convert($filter_new_find);
+ $filter_new_replace = kiriwrite_utf8convert($filter_new_replace);
+ $filter_new_priority = kiriwrite_utf8convert($filter_new_priority);
+ $filter_new_notes = kiriwrite_utf8convert($filter_new_notes);
+
+ # Check if the find filter is blank and return an error
+ # if it is.
+
+ if (!$filter_new_find){
+
+ # The find filter given is blank so return an
+ # error.
+
+ kiriwrite_error("blankfindfilter");
+
+ }
+
+ if (!$filter_new_priority){
+
+ # The filter priority is blank so set it
+ # to 1.
+
+ $filter_new_priority = 1;
+
+ }
+
+ # Check if the enabled value is either "on" or
+ # blank and return an error if it is something
+ # else.
+
+ if (!$filter_new_enabled || $filter_new_enabled ne "off"){
+
+ } else {
+
+ # FINISH THIS.
+
+ }
+
+ # Check if the new filter should be enabled.
+
+ my $filter_enable = 0;
+
+ if (!$filter_new_enabled){
+
+ $filter_new_enabled = "off";
+
+ }
+
+ if ($filter_new_enabled eq "on"){
+
+ # The filter is enabled.
+
+ $filter_enable = 1;
+
+ }
+
+ # Check the length and contents of the values given
+ # to make sure they are valid.
+
+ my $filterfind_maxlength_check = kiriwrite_variablecheck($filter_new_find, "maxlength", 1024, 1);
+ my $filterreplace_maxlength_check = kiriwrite_variablecheck($filter_new_replace, "maxlength", 1024, 1);
+ my $filterpriority_maxlength_check = kiriwrite_variablecheck($filter_new_priority, "maxlength", 5, 1);
+ my $filterpriority_numbers_check = kiriwrite_variablecheck($filter_new_priority, "numbers", 0, 1);
+
+ # Check if the result of the tests to see if they
+ # are valid.
+
+ if ($filterfind_maxlength_check eq 1){
+
+ # The find filter is too long, so return
+ # an error.
+
+ kiriwrite_error("findfiltertoolong");
+
+ }
+
+ if ($filterreplace_maxlength_check eq 1){
+
+ # The replace filter is too long, so
+ # return an error.
+
+ kiriwrite_error("replacefiltertoolong");
+
+ }
+
+ if ($filterpriority_maxlength_check eq 1){
+
+ # The length of the filter priority
+ # given is too long, so return an
+ # error.
+
+ kiriwrite_error("filterprioritytoolong");
+
+ }
+
+ if ($filterpriority_numbers_check eq 1){
+
+ # The priority of the filter given
+ # contains characters other than
+ # numbers.
+
+ kiriwrite_error("filterpriorityinvalidchars");
+
+ }
+
+ # Check if the filter priority is less than 1
+ # and more than 10000 and return an error
+ # if it is.
+
+ if ($filter_new_priority < 1 || $filter_new_priority > 50000){
+
+ # The filter priority is less than 1 and
+ # more than 10000, so return an error.
+
+ kiriwrite_error("filterpriorityinvalid");
+
+ }
+
+ # Connect to the database server.
+
+ $main::kiriwrite_dbmodule->connect();
+
+ # Check if any errors occured while connecting to the database server.
+
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
+
+ # A database connection error has occured so return
+ # an error.
+
+ kiriwrite_error("databaseconnectionerror", $main::kiriwrite_dbmodule->geterror(1));
+
+ }
+
+ # Connect to the filter database.
+
+ $main::kiriwrite_dbmodule->connectfilter(1);
+
+ # Check if any error has occured while connecting to the filter
+ # database.
+
+ if ($main::kiriwrite_dbmodule->geterror eq "FilterDatabaseDoesNotExist"){
+
+ # The filter database does not exist.
+
+ kiriwrite_error("filtersdbmissing");
+
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "FilterDatabaseInvalidPermissionsSet"){
+
+ # The filter database has invalid permissions set so return
+ # an error.
+
+ kiriwrite_error("filtersdbpermissions");
+
+ }
+
+ # Add the filter to the filter database.
+
+ $main::kiriwrite_dbmodule->addfilter({ FindFilter => $filter_new_find, ReplaceFilter => $filter_new_replace, Priority => $filter_new_priority, Enabled => $filter_enable, Notes => $filter_new_notes});
+
+ # Check if any errors have occured while adding the filter.
+
+ if ($main::kiriwrite_dbmodule->geterror eq "FilterDatabaseInvalidPermissionsSet"){
+
+ # The filter database has invalid permissions set so return
+ # an error.
+
+ kiriwrite_error("filtersdbpermissions");
+
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "FilterDatabaseUncreatable"){
+
+ # The filter database is uncreatable so return an error.
+
+ kiriwrite_error("filterdatabase");
+
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "FilterDatabaseError"){
+
+ # A database error with the filter database has occured so return
+ # an error with the extended error information.
+
+ kiriwrite_error("filtersdbdatabaseerror", $main::kiriwrite_dbmodule->geterror(1));
+
+ }
+
+ # Disconnect from the filter database.
+
+ $main::kiriwrite_dbmodule->disconnectfilter();
+
+ # Disconnect from the database server.
+
+ $main::kiriwrite_dbmodule->disconnect();
+
+ # Write out a message saying that the filter was added to the
+ # filter database.
+
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{filter}{filteradded}, { Style => "pageheader" });
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{filter}{filteraddedmessage});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{"script_filename"} . "?mode=filter", { Text => $main::kiriwrite_lang{filter}{returnfilterlist} });
+
+ return $main::kiriwrite_presmodule->grab();
+
+ } elsif ($confirm ne 0) {
+
+ # The confirm integer is another value (which
+ # it shouldn't be) so return an error.
+
+ kiriwrite_error("invalidvalue");
+
+ }
+
+ # The confirm integer was blank so print out a form
+ # for adding a new filter.
+
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{filter}{addfilter}, { Style => "pageheader" });
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->startform($main::kiriwrite_env{"script_filename"}, "POST");
+ $main::kiriwrite_presmodule->startbox();
+ $main::kiriwrite_presmodule->addhiddendata("mode", "filter");
+ $main::kiriwrite_presmodule->addhiddendata("action", "add");
+ $main::kiriwrite_presmodule->addhiddendata("confirm", 1);
+ $main::kiriwrite_presmodule->starttable("", { CellPadding => 5, CellSpacing => 0 });
+
+ $main::kiriwrite_presmodule->startheader();
+ $main::kiriwrite_presmodule->addheader($main::kiriwrite_lang{common}{setting}, { Style => "tablecellheader" });
+ $main::kiriwrite_presmodule->addheader($main::kiriwrite_lang{common}{value}, { Style => "tablecellheader" });
+ $main::kiriwrite_presmodule->endheader();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{filter}{findfilter});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addinputbox("findword", { Size => 64, MaxLength => 1024 });
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{filter}{replacefilter});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addinputbox("replaceword", { Size => 64, MaxLength => 1024 });
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{filter}{priority});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addinputbox("priority", { Size => 5, MaxLength => 5 });
+ $main::kiriwrite_presmodule->startlist();
+ $main::kiriwrite_presmodule->additem($main::kiriwrite_lang{filter}{noprioritygiven});
+ $main::kiriwrite_presmodule->endlist();
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{filter}{notes});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addtextbox("notes", { Columns => $main::kiriwrite_config{"display_textareacols"}, Rows => $main::kiriwrite_config{"display_textarearows"} });
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addcheckbox("enabled", { OptionDescription => $main::kiriwrite_lang{filter}{enabled}, Checked => 1 });
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->endtable();
+
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addsubmit($main::kiriwrite_lang{filter}{addfilterbutton});
+ $main::kiriwrite_presmodule->addtext(" | ");
+ $main::kiriwrite_presmodule->addreset($main::kiriwrite_lang{common}{clearvalues});
+ $main::kiriwrite_presmodule->addtext(" | ");
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{"script_filename"} . "?mode=filter", { Text => $main::kiriwrite_lang{filter}{returnfilterlist} });
+
+ $main::kiriwrite_presmodule->endbox();
+ $main::kiriwrite_presmodule->endform();
+
+ return $main::kiriwrite_presmodule->grab();
+
+}
+
+sub kiriwrite_filter_edit{
+#################################################################################
+# kiriwrite_filter_edit: Edits a filter from the filter list. #
+# #
+# Usage: #
+# #
+# kiriwrite_filter_edit(options); #
+# #
+# options Specifies the following options as hash (in any order). #
+# #
+# FilterID Specifies the filter number in the filter database. #
+# NewFindFilter Specifies the new find filter. #
+# NewReplaceFilter Specifies the new replace filter. #
+# NewPriority Specifies the new priority. #
+# NewEnabled Specifies the new enable setting. #
+# NewFilterNotes Specifies the new filter notes. #
+# Confirm Confirms the action to edit a filter. #
+#################################################################################
+
+ # Get the values that have been passed to the subroutine.
+
+ my ($options) = @_;
+ #my ($filter_id, $filter_new_find, $filter_new_replace, $filter_new_priority, $filter_new_notes, $confirm) = @_;
+
+ my $filter_id = $options->{"FilterID"};
+ my $confirm = $options->{"Confirm"};
+
+ # Check the confirm value to make sure it is no more than
+ # one character long.
+
+ kiriwrite_variablecheck($confirm, "maxlength", 1, 0);
+
+ # Check if the confirm value is blank and if it is
+ # srt the confirm value to 0.
+
+ if (!$confirm){
+
+ # The confirm value does not have any value
+ # set so set it to 0.
+
+ $confirm = 0;
+
+ }
+
+ # Check if the filter identification number is blank,
+ # contains characters other than numbers and is more
+ # than seven characters long.
+
+ if (!$filter_id){
+
+ # The filter identification number is blank,
+ # so return an error.
+
+ kiriwrite_error("filteridblank");
+
+ }
+
+ my $filter_id_numbers_check = kiriwrite_variablecheck($filter_id, "numbers", 0, 1);
+
+ if ($filter_id_numbers_check eq 1){
+
+ # The filter identification number contains
+ # characters other than numbers, so return
+ # an error.
+
+ kiriwrite_error("filteridinvalid");
+
+ }
+
+ my $filter_id_maxlength_check = kiriwrite_variablecheck($filter_id, "maxlength", 7, 1);
+
+ if ($filter_id_maxlength_check eq 1){
+
+ # The filter identification number given
+ # is more than seven characters long, so
+ # return an error.
+
+ kiriwrite_error("filteridtoolong");
+
+ }
+
+ my $filter_priority;
+ my $filter_find;
+ my $filter_replace;
+ my $filter_enabled;
+ my $filter_notes;
+
+ # Check if the action to edit a filter has been
+ # confirmed.
+
+ if ($confirm eq 1){
+
+ # The action to edit a filter has been confirmed so
+ # edit the selected filter.
+
+ # Get the values from the hashref.
+
+ my $filter_new_find = $options->{"NewFindFilter"};
+ my $filter_new_replace = $options->{"NewReplaceFilter"};
+ my $filter_new_priority = $options->{"NewPriority"};
+ my $filter_new_notes = $options->{"NewFilterNotes"};
+ my $filter_new_enabled = $options->{"NewEnabled"};
+
+ # First, check the variables recieved are UTF8
+ # copliant.
+
+ kiriwrite_variablecheck($filter_new_find, "utf8", 0, 0);
+ kiriwrite_variablecheck($filter_new_replace, "utf8", 0, 0);
+ kiriwrite_variablecheck($filter_new_priority, "utf8", 0, 0);
+ kiriwrite_variablecheck($filter_new_notes, "utf8", 0, 0);
+
+ # Convert the UTF8 values so that the length can
+ # checked properly.
+
+ $filter_find = kiriwrite_utf8convert($filter_new_find);
+ $filter_replace = kiriwrite_utf8convert($filter_new_replace);
+ $filter_priority = kiriwrite_utf8convert($filter_new_priority);
+ $filter_notes = kiriwrite_utf8convert($filter_new_notes);
+
+ # Check if the find filter is blank and return an error
+ # if it is.
+
+ if (!$filter_new_find){
+
+ # The find filter given is blank so return an
+ # error.
+
+ kiriwrite_error("blankfindfilter");
+
+ }
+
+ if (!$filter_new_priority){
+
+ # The filter priority is blank so set it
+ # to 1.
+
+ $filter_new_priority = 1;
+
+ }
+
+ # Check the length and contents of the values given
+ # to make sure they are valid.
+
+ my $filterfind_maxlength_check = kiriwrite_variablecheck($filter_new_find, "maxlength", 1024, 1);
+ my $filterreplace_maxlength_check = kiriwrite_variablecheck($filter_new_replace, "maxlength", 1024, 1);
+ my $filterpriority_maxlength_check = kiriwrite_variablecheck($filter_new_priority, "maxlength", 5, 1);
+ my $filterpriority_numbers_check = kiriwrite_variablecheck($filter_new_priority, "numbers", 0, 1);
+
+ # Check if the result of the tests to see if they
+ # are valid.
+
+ if ($filterfind_maxlength_check eq 1){
+
+ # The find filter is too long, so return
+ # an error.
+
+ kiriwrite_error("findfiltertoolong");
+
+ }
+
+ if ($filterreplace_maxlength_check eq 1){
+
+ # The replace filter is too long, so
+ # return an error.
+
+ kiriwrite_error("replacefiltertoolong");
+
+ }
+
+ if ($filterpriority_maxlength_check eq 1){
+
+ # The length of the filter priority
+ # given is too long, so return an
+ # error.
+
+ kiriwrite_error("filterprioritytoolong");
+
+ }
+
+ if ($filterpriority_numbers_check eq 1){
+
+ # The priority of the filter given
+ # contains characters other than
+ # numbers.
+
+ kiriwrite_error("filterpriorityinvalidchars");
+
+ }
+
+ # Check if the filter priority is less than 1
+ # and more than 10000 and return an error
+ # if it is.
+
+ if ($filter_new_priority < 1 || $filter_new_priority > 50000){
+
+ # The filter priority is less than 1 and
+ # more than 10000, so return an error.
+
+ kiriwrite_error("filterpriorityinvalid");
+
+ }
+
+ # Check to see if the filter should be enabled.
+
+ my $filter_enable = 0;
+
+ if (!$filter_new_enabled){
+
+ $filter_new_enabled = "off";
+
+ }
+
+ if ($filter_new_enabled eq "on"){
+
+ # The filter is enabled.
+
+ $filter_enable = 1;
+
+ }
+
+ # Connect to the database server.
+
+ $main::kiriwrite_dbmodule->connect();
+
+ # Check if any errors occured while connecting to the database server.
+
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
+
+ # A database connection error has occured so return
+ # an error.
+
+ kiriwrite_error("databaseconnectionerror", $main::kiriwrite_dbmodule->geterror(1));
+
+ }
+
+ # Connect to the filter database.
+
+ $main::kiriwrite_dbmodule->connectfilter();
+
+ # Check if any error has occured while connecting to the filter
+ # database.
+
+ if ($main::kiriwrite_dbmodule->geterror eq "FilterDatabaseDoesNotExist"){
+
+ # The filter database does not exist.
+
+ kiriwrite_error("filtersdbmissing");
+
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "FilterDatabaseInvalidPermissionsSet"){
+
+ # The filter database has invalid permissions set so return
+ # an error.
+
+ kiriwrite_error("filtersdbpermissions");
+
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "FilterDatabaseError"){
+
+ # A database error has occured with the filter database.
+
+ kiriwrite_error("filtersdbdatabaseerror", $main::kiriwrite_dbmodule->geterror(1));
+
+ }
+
+ # Edit the selected filter in the filter database.
+
+ $main::kiriwrite_dbmodule->editfilter({ FilterID => $filter_id, NewFindFilter => $filter_new_find, NewReplaceFilter => $filter_new_replace, NewFilterPriority => $filter_new_priority, NewEnabled => $filter_enable, NewFilterNotes => $filter_new_notes });
+
+ # Check if any errors occured while editing the filter.
+
+ if ($main::kiriwrite_dbmodule->geterror eq "FilterDatabaseInvalidPermissionsSet"){
+
+ # The filter database has invalid permissions set so return
+ # an error.
+
+ kiriwrite_error("filtersdbpermissions");
+
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "FilterDatabaseError"){
+
+ # A database error has occured while using the filter database
+ # so return an error.
+
+ kiriwrite_error("filtersdbdatabaseerror", $main::kiriwrite_dbmodule->geterror(1));
+
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "FilterDoesNotExist"){
+
+ # The specified filter does not exist so return an error.
+
+ kiriwrite_error("filterdoesnotexist");
+
+ }
+
+ # Disconnect from the filter database.
+
+ $main::kiriwrite_dbmodule->disconnectfilter();
+
+ # Disconnect from the database server.
+
+ $main::kiriwrite_dbmodule->disconnect();
+
+ # Write a message saying that the filter was edited.
+
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{filter}{editedfilter}, { Style => "pageheader" });
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{filter}{editedfiltermessage});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{"script_filename"} . "?mode=filter", { Text => $main::kiriwrite_lang{filter}{returnfilterlist}});
+
+ return $main::kiriwrite_presmodule->grab();
+
+ } elsif ($confirm eq 0){
+
+ # The action to edit a filter has not been confirmed
+ # so write a form for editing the filter with.
+
+ # Connect to the database server.
+
+ $main::kiriwrite_dbmodule->connect();
+
+ # Check if any errors occured while connecting to the database server.
+
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
+
+ # A database connection error has occured so return
+ # an error.
+
+ kiriwrite_error("databaseconnectionerror", $main::kiriwrite_dbmodule->geterror(1));
+
+ }
+
+ # Connect to the database server.
+
+ $main::kiriwrite_dbmodule->connect();
+
+ # Check if any errors occured while connecting to the database server.
+
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
+
+ # A database connection error has occured so return
+ # an error.
+
+ kiriwrite_error("databaseconnectionerror", $main::kiriwrite_dbmodule->geterror(1));
+
+ }
+
+ # Connect to the filter database.
+
+ $main::kiriwrite_dbmodule->connectfilter();
+
+ # Check if any error has occured while connecting to the filter
+ # database.
+
+ if ($main::kiriwrite_dbmodule->geterror eq "FilterDatabaseDoesNotExist"){
+
+ # The filter database does not exist.
+
+ kiriwrite_error("filtersdbmissing");
+
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "FilterDatabaseInvalidPermissionsSet"){
+
+ # The filter database has invalid permissions set so return
+ # an error.
+
+ kiriwrite_error("filtersdbpermissions");
+
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "FilterDatabaseError"){
+
+ # A database error has occured with the filter database.
+
+ kiriwrite_error("filtersdbdatabaseerror", $main::kiriwrite_dbmodule->geterror(1));
+
+ }
+
+ # Get information about the filter.
+
+ my %filter_info = $main::kiriwrite_dbmodule->getfilterinfo({ FilterID => $filter_id });
+
+ # Check if any errors occured while getting information about the filter.
+
+ if ($main::kiriwrite_dbmodule->geterror eq "FilterDatabaseError"){
+
+ # A database error occured while using the filter database so
+ # return an error.
+
+ kiriwrite_error("filtersdbdatabaseerror", $main::kiriwrite_dbmodule->geterror(1));
+
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "FilterDoesNotExist"){
+
+ # The filter does not exist so return an error.
+
+ kiriwrite_error("filterdoesnotexist");
+
+ }
+
+ # Get the required information.
+
+ $filter_priority = $filter_info{"FilterPriority"};
+ $filter_find = $filter_info{"FilterFind"};
+ $filter_replace = $filter_info{"FilterReplace"};
+ $filter_enabled = $filter_info{"FilterEnabled"};
+ $filter_notes = $filter_info{"FilterNotes"};
+
+ # Disconnect from the filter database.
+
+ $main::kiriwrite_dbmodule->disconnectfilter();
+
+ # Disconnect from the database server.
+
+ $main::kiriwrite_dbmodule->disconnect();
+
+ # Write out the form.
+
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{filter}{editfilter}, { Style => "pageheader" });
+ $main::kiriwrite_presmodule->startform($main::kiriwrite_env{"script_filename"}, "POST");
+ $main::kiriwrite_presmodule->startbox();
+ $main::kiriwrite_presmodule->addhiddendata("mode", "filter");
+ $main::kiriwrite_presmodule->addhiddendata("action", "edit");
+ $main::kiriwrite_presmodule->addhiddendata("filter", $filter_id);
+ $main::kiriwrite_presmodule->addhiddendata("confirm", 1);
+
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->starttable("", { CellPadding => 5, CellSpacing => 0 });
+
+ $main::kiriwrite_presmodule->startheader();
+ $main::kiriwrite_presmodule->addheader($main::kiriwrite_lang{common}{setting}, { Style => "tablecellheader" });
+ $main::kiriwrite_presmodule->addheader($main::kiriwrite_lang{common}{value}, { Style => "tablecellheader" });
+ $main::kiriwrite_presmodule->endheader();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{filter}{findfilter});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addinputbox("filterfind", { Size => 64, MaxLength => 1024, Value => $filter_find });
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{filter}{replacefilter});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addinputbox("filterreplace", { Size => 64, MaxLength => 1024, Value => $filter_replace });
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{filter}{priority});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addinputbox("priority", { Size => 5, MaxLength => 5, Value => $filter_priority });
+ $main::kiriwrite_presmodule->startlist();
+ $main::kiriwrite_presmodule->additem($main::kiriwrite_lang{filter}{noprioritygiven});
+ $main::kiriwrite_presmodule->endlist();
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{filter}{notes});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addtextbox("notes", { Columns => $main::kiriwrite_config{"display_textareacols"}, Rows => $main::kiriwrite_config{"display_textarearows"}, Value => $filter_notes});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+
+ if ($filter_enabled eq 1){
+
+ $main::kiriwrite_presmodule->addcheckbox("enabled", { OptionDescription => $main::kiriwrite_lang{filter}{enabled}, Checked => 1 });
+
+ } else {
+
+ $main::kiriwrite_presmodule->addcheckbox("enabled", { OptionDescription => $main::kiriwrite_lang{filter}{enabled} });
+
+ }
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->endtable();
+
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addsubmit($main::kiriwrite_lang{filter}{editfilterbutton});
+ $main::kiriwrite_presmodule->addtext(" | ");
+ $main::kiriwrite_presmodule->addreset($main::kiriwrite_lang{common}{restorecurrent});
+ $main::kiriwrite_presmodule->addtext(" | ");
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{"script_filename"} . "?mode=filter", { Text => $main::kiriwrite_lang{filter}{returnfilterlist} });
+ $main::kiriwrite_presmodule->endbox();
+ $main::kiriwrite_presmodule->endform();
+
+ return $main::kiriwrite_presmodule->grab();
+
+ } else {
+
+ # A confirm value other than 0 or 1 has been
+ # specified, so return an error.
+
+ kiriwrite_error("invalidvalue");
+
+ }
+
+}
+
+sub kiriwrite_filter_delete{
+#################################################################################
+# kiriwrite_filter_delete: Deletes a filter from the filter list. #
+# #
+# Usage: #
+# #
+# kiriwrite_filter_delete(filterid, confirm); #
+# #
+# filterid Specifies the filter line number to delete. #
+# confirm Confirms the deletion of the selected filter. #
+#################################################################################
+
+ # Get the values that were passed to this subroutine.
+
+ my ($filter_id, $confirm) = @_;
+
+ # Check the confirm value to make sure it is no more than
+ # one character long.
+
+ kiriwrite_variablecheck($confirm, "maxlength", 1, 0);
+
+ # Check if the confirm value is blank and if it is
+ # srt the confirm value to 0.
+
+ if (!$confirm){
+
+ # The confirm value does not have any value
+ # set so set it to 0.
+
+ $confirm = 0;
+
+ }
+
+ # Check if the filter identification number is blank,
+ # contains characters other than numbers and is more
+ # than seven characters long.
+
+ if (!$filter_id){
+
+ # The filter identification number is blank,
+ # so return an error.
+
+ kiriwrite_error("filteridblank");
+
+ }
+
+ my $filter_id_numbers_check = kiriwrite_variablecheck($filter_id, "numbers", 0, 1);
+
+ if ($filter_id_numbers_check eq 1){
+
+ # The filter identification number contains
+ # characters other than numbers, so return
+ # an error.
+
+ kiriwrite_error("filteridinvalid");
+
+ }
+
+ my $filter_id_maxlength_check = kiriwrite_variablecheck($filter_id, "maxlength", 7, 1);
+
+ if ($filter_id_maxlength_check eq 1){
+
+ # The filter identification number given
+ # is more than seven characters long, so
+ # return an error.
+
+ kiriwrite_error("filteridtoolong");
+
+ }
+
+ # Define some values for later.
+
+ my @database_filter;
+ my $filter_exists = 0;
+
+ # Check if the confirm integer has a value of '1'.
+
+ if ($confirm eq 1){
+
+ # The action to delete a filter has been confirmed.
+
+ # Connect to the database server.
+
+ $main::kiriwrite_dbmodule->connect();
+
+ # Check if any errors occured while connecting to the database server.
+
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
+
+ # A database connection error has occured so return
+ # an error.
+
+ kiriwrite_error("databaseconnectionerror", $main::kiriwrite_dbmodule->geterror(1));
+
+ }
+
+ # Connect to the filter database.
+
+ $main::kiriwrite_dbmodule->connectfilter();
+
+ # Check if any error has occured while connecting to the filter
+ # database.
+
+ if ($main::kiriwrite_dbmodule->geterror eq "FilterDatabaseDoesNotExist"){
+
+ # The filter database does not exist.
+
+ kiriwrite_error("filtersdbmissing");
+
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "FilterDatabaseInvalidPermissionsSet"){
+
+ # The filter database has invalid permissions set so return
+ # an error.
+
+ kiriwrite_error("filtersdbpermissions");
+
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "FilterDatabaseError"){
+
+ # A database error has occured with the filter database.
+
+ kiriwrite_error("filtersdbdatabaseerror", $main::kiriwrite_dbmodule->geterror(1));
+
+ }
+
+ # Delete the filter from the filter database.
+
+ $main::kiriwrite_dbmodule->deletefilter({ FilterID => $filter_id });
+
+ # Check if any errors occured while deleting the filter.
+
+ if ($main::kiriwrite_dbmodule->geterror eq "FilterDatabaseError"){
+
+ # A database error has occured while trying to delete a filter so
+ # return an error.
+
+ kiriwrite_error("filtersdbdatabaseerror", $main::kiriwrite_dbmodule->geterror(1));
+
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "FilterDoesNotExist"){
+
+ # The filter does not exist so return an error.
+
+ kiriwrite_error("filterdoesnotexist");
+
+ }
+
+ # Disconnect from the filter database.
+
+ $main::kiriwrite_dbmodule->disconnectfilter();
+
+ # Disconnect from the database server.
+
+ $main::kiriwrite_dbmodule->disconnect();
+
+ # Write a message saying that the filter was deleted
+ # from the filter database.
+
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{filter}{deletedfilter}, { Style => "pageheader" });
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{filter}{deletedfiltermessage});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{"script_filename"} . "?mode=filter", { Text => $main::kiriwrite_lang{filter}{returnfilterlist} });
+
+ } elsif ($confirm eq 0) {
+
+ # Connect to the database server.
+
+ $main::kiriwrite_dbmodule->connect();
+
+ # Check if any errors occured while connecting to the database server.
+
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
+
+ # A database connection error has occured so return
+ # an error.
+
+ kiriwrite_error("databaseconnectionerror", $main::kiriwrite_dbmodule->geterror(1));
+
+ }
+
+ # Connect to the filter database.
+
+ $main::kiriwrite_dbmodule->connectfilter();
+
+ # Check if any error has occured while connecting to the filter
+ # database.
+
+ if ($main::kiriwrite_dbmodule->geterror eq "FilterDatabaseDoesNotExist"){
+
+ # The filter database does not exist.
+
+ kiriwrite_error("filtersdbmissing");
+
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "FilterDatabaseInvalidPermissionsSet"){
+
+ # The filter database has invalid permissions set so return
+ # an error.
+
+ kiriwrite_error("filtersdbpermissions");
+
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "FilterDatabaseError"){
+
+ # A database error has occured with the filter database.
+
+ kiriwrite_error("filtersdbdatabaseerror", $main::kiriwrite_dbmodule->geterror(1));
+
+ }
+
+ # Get information about the filter (to check if it exists).
+
+ my %filter_info = $main::kiriwrite_dbmodule->getfilterinfo({ FilterID => $filter_id });
+
+ # Check if any errors occured while getting information about the filter.
+
+ if ($main::kiriwrite_dbmodule->geterror eq "FilterDatabaseError"){
+
+ # A database error occured while using the filter database so
+ # return an error.
+
+ kiriwrite_error("filtersdbdatabaseerror", $main::kiriwrite_dbmodule->geterror(1));
+
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "FilterDoesNotExist"){
+
+ # The filter does not exist so return an error.
+
+ kiriwrite_error("filterdoesnotexist");
+
+ }
+
+ # Disconnect from the filter database.
+
+ $main::kiriwrite_dbmodule->disconnectfilter();
+
+ # Disconnect from the database
+
+ # The confirm integer is '0', so continue write out
+ # a form asking the user to confirm the deletion
+ # pf the filter.
+
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{filter}{deletefilter}, { Style => "pageheader" });
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{filter}{deletefiltermessage});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->startform($main::kiriwrite_env{"script_filename"}, "POST");
+ $main::kiriwrite_presmodule->startbox();
+ $main::kiriwrite_presmodule->addhiddendata("mode", "filter");
+ $main::kiriwrite_presmodule->addhiddendata("action", "delete");
+ $main::kiriwrite_presmodule->addhiddendata("filter", $filter_id);
+ $main::kiriwrite_presmodule->addhiddendata("confirm", 1);
+ $main::kiriwrite_presmodule->addsubmit($main::kiriwrite_lang{filter}{deletefilterbutton});
+ $main::kiriwrite_presmodule->addtext(" | ");
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{"script_filename"} . "?mode=filter", { Text => $main::kiriwrite_lang{filter}{deletefilterreturn} });
+ $main::kiriwrite_presmodule->endbox();
+ $main::kiriwrite_presmodule->endform();
+
+ } else {
+
+ kiriwrite_error("invalidvalue");
+
+ }
+
+ return $main::kiriwrite_presmodule->grab();
+
+}
+
+1;
-#################################################################################
-# page.lib: Kiriwrite Page Library #
-# #
-# This library is under the same license as the main Kiriwrite script. #
-#################################################################################
-
-# This section of the file is for when the library is called from the main
-# Kiriwrite script.
-
-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.
-
- 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"); # 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.
-
-
- } elsif ($http_query_action eq "multidelete"){
-
- # 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;
-
- if ($http_query_confirm){
-
- # The action to delete multiple pages from the selected
- # database has been confirmed.
-
- @filelist = kiriwrite_selectedlist();
- $pagedata = kiriwrite_page_multidelete($http_query_database, $http_query_confirm, @filelist);
+package Modules::System::Page;
- 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.
+use Modules::System::Common;
+use strict;
+use warnings;
+use Exporter;
- }
-
- # Get the list of selected pages and pass them to the
- # multiple page delete subroutine.
-
- @filelist = kiriwrite_selectedlist();
- $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.
-
- } elsif ($http_query_action eq "multimove"){
-
- # 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();
- $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();
- $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.
-
- } elsif ($http_query_action eq "multicopy"){
-
- # 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();
- $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();
- $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.
-
- } elsif ($http_query_action eq "multiedit"){
-
- # 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();
- $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();
- $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.
-
- } else {
- kiriwrite_error("invalidaction");
- }
-
-} else {
-
- # 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, "pages"); # Output the page to browser/console/stdout.
- exit; # End the script.
-
-}
-
-#################################################################################
-# Begin list of relevant subroutines. #
-#################################################################################
+our @ISA = qw(Exporter);
+our @EXPORT = qw(kiriwrite_page_list kiriwrite_page_add kiriwrite_page_edit kiriwrite_page_delete kiriwrite_page_multidelete kiriwrite_page_multimove kiriwrite_page_multicopy kiriwrite_page_multiedit);
sub kiriwrite_page_list{
#################################################################################
# Connect to the database server.
- $kiriwrite_dbmodule->connect();
+ $main::kiriwrite_dbmodule->connect();
# Check if any errors occured while connecting to the database server.
- if ($kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
# A database connection error has occured so return
# an error.
- kiriwrite_error("databaseconnectionerror", $kiriwrite_dbmodule->geterror(1));
+ kiriwrite_error("databaseconnectionerror", $main::kiriwrite_dbmodule->geterror(1));
}
# Open the data directory and get all of the databases.
- @database_list = $kiriwrite_dbmodule->getdblist();
+ @database_list = $main::kiriwrite_dbmodule->getdblist();
# Check if any errors occured while trying to get the list of databases.
- if ($kiriwrite_dbmodule->geterror eq "DataDirMissing"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DataDirMissing"){
# The database directory is missing so return an error.
kiriwrite_error("datadirectorymissing");
- } elsif ($kiriwrite_dbmodule->geterror eq "DataDirInvalidPermissions"){
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "DataDirInvalidPermissions"){
# The database directory has invalid permissions set so return
# an error.
foreach $data_file (@database_list){
- $kiriwrite_dbmodule->selectdb({ DatabaseName => $data_file });
+ $main::kiriwrite_dbmodule->selectdb({ DatabaseName => $data_file });
# Check if any errors occured while selecting the database.
- if ($kiriwrite_dbmodule->geterror eq "DoesNotExist"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DoesNotExist"){
# The database does not exist, so process the next
# database.
next;
- } elsif ($kiriwrite_dbmodule->geterror eq "InvalidPermissionsSet"){
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "InvalidPermissionsSet"){
# The database has invalid permissions set, so process
# the next database.
# Get the database information.
- %database_info = $kiriwrite_dbmodule->getdatabaseinfo();
+ %database_info = $main::kiriwrite_dbmodule->getdatabaseinfo();
# Check if any errors had occured while getting the database
# information.
- if ($kiriwrite_dbmodule->geterror eq "DatabaseError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseError"){
# A database error has occured, so process the next
# database.
# Disconnect from the database server.
- $kiriwrite_dbmodule->disconnect();
+ $main::kiriwrite_dbmodule->disconnect();
# Write the page data.
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{pages}->{viewpages}, { Style => "pageheader" });
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{pages}->{nodatabaseselected});
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->startform($kiriwrite_env{"script_filename"});
- $kiriwrite_presmodule->startbox();
- $kiriwrite_presmodule->addhiddendata("mode", "page");
- $kiriwrite_presmodule->addhiddendata("action", "view");
- $kiriwrite_presmodule->addselectbox("database");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{pages}{viewpages}, { Style => "pageheader" });
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{pages}{nodatabaseselected});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->startform($main::kiriwrite_env{"script_filename"});
+ $main::kiriwrite_presmodule->startbox();
+ $main::kiriwrite_presmodule->addhiddendata("mode", "page");
+ $main::kiriwrite_presmodule->addhiddendata("action", "view");
+ $main::kiriwrite_presmodule->addselectbox("database");
foreach $dbfilename (@databasefilenames){
$dbname = $databasenames[$dbseek];
$dbseek++;
- $kiriwrite_presmodule->addoption($dbname . " (" . $dbfilename . ")", { Value => $dbfilename });
+ $main::kiriwrite_presmodule->addoption($dbname . " (" . $dbfilename . ")", { Value => $dbfilename });
}
- $kiriwrite_presmodule->endselectbox();
- $kiriwrite_presmodule->addtext(" | ");
- $kiriwrite_presmodule->addsubmit($kiriwrite_lang->{pages}->{viewbutton});
- $kiriwrite_presmodule->endbox();
- $kiriwrite_presmodule->endform();
+ $main::kiriwrite_presmodule->endselectbox();
+ $main::kiriwrite_presmodule->addtext(" | ");
+ $main::kiriwrite_presmodule->addsubmit($main::kiriwrite_lang{pages}{viewbutton});
+ $main::kiriwrite_presmodule->endbox();
+ $main::kiriwrite_presmodule->endform();
- return $kiriwrite_presmodule->grab();
+ return $main::kiriwrite_presmodule->grab();
} else {
my $tablestyletype = 0;
my $page_count = 0;
my $db_file_notblank = 0;
- my $page_split = $kiriwrite_config{"display_pagecount"};
+ my $page_split = $main::kiriwrite_config{"display_pagecount"};
my $page_list = 0;
my $page_list_count = 0;
# Connect to the database server.
- $kiriwrite_dbmodule->connect();
+ $main::kiriwrite_dbmodule->connect();
# Check if any errors occured while connecting to the database server.
- if ($kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
# A database connection error has occured so return
# an error.
- kiriwrite_error("databaseconnectionerror", $kiriwrite_dbmodule->geterror(1));
+ kiriwrite_error("databaseconnectionerror", $main::kiriwrite_dbmodule->geterror(1));
}
# Select the database.
- $kiriwrite_dbmodule->selectdb({ DatabaseName => $database_file });
+ $main::kiriwrite_dbmodule->selectdb({ DatabaseName => $database_file });
# Check if any errors had occured while selecting the database.
- if ($kiriwrite_dbmodule->geterror eq "DoesNotExist"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DoesNotExist"){
# The database does not exist, so return an error.
kiriwrite_error("databasemissingfile");
- } elsif ($kiriwrite_dbmodule->geterror eq "InvalidPermissionsSet"){
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "InvalidPermissionsSet"){
# The database has invalid permissions set, so return
# an error.
# Get information about the database.
- %database_info = $kiriwrite_dbmodule->getdatabaseinfo();
+ %database_info = $main::kiriwrite_dbmodule->getdatabaseinfo();
$db_name = $database_info{"DatabaseName"};
# Check if any errors had occured while getting the database
# information.
- if ($kiriwrite_dbmodule->geterror eq "DatabaseError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseError"){
# A database error has occured so return an error and
# also the extended error information.
- kiriwrite_error("databaseerror", $kiriwrite_dbmodule->geterror(1));
+ kiriwrite_error("databaseerror", $main::kiriwrite_dbmodule->geterror(1));
}
# Get the count of pages in the database.
- my $page_total_count = $kiriwrite_dbmodule->getpagecount();
+ my $page_total_count = $main::kiriwrite_dbmodule->getpagecount();
# Check if any errors had occured while getting the count of
# pages in the database.
- if ($kiriwrite_dbmodule->geterror eq "DatabaseError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseError"){
# A database error has occured so return an error and
# also the extended error information.
- kiriwrite_error("databaseerror", $kiriwrite_dbmodule->geterror(1));
+ kiriwrite_error("databaseerror", $main::kiriwrite_dbmodule->geterror(1));
}
# Get the list of pages.
- @database_pages = $kiriwrite_dbmodule->getpagelist({ StartFrom => $start_from, Limit => $page_split });
+ @database_pages = $main::kiriwrite_dbmodule->getpagelist({ StartFrom => $start_from, Limit => $page_split });
# Check if any errors had occured while getting the list of pages.
- if ($kiriwrite_dbmodule->geterror eq "DatabaseError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseError"){
# A database error has occured so return an error and
# also the extended error information.
- kiriwrite_error("databaseerror", $kiriwrite_dbmodule->geterror(1));
+ kiriwrite_error("databaseerror", $main::kiriwrite_dbmodule->geterror(1));
}
# Write the start of the page.
- $kiriwrite_presmodule->addtext(kiriwrite_language($kiriwrite_lang->{pages}->{pagelist}, $db_name), { Style => "pageheader" });
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->startform($kiriwrite_env{"script_filename"}, "POST");
- $kiriwrite_presmodule->startbox();
- $kiriwrite_presmodule->addhiddendata("mode", "page");
- $kiriwrite_presmodule->addhiddendata("database", $database_file);
- $kiriwrite_presmodule->addhiddendata("type", "multiple");
+ $main::kiriwrite_presmodule->addtext(kiriwrite_language($main::kiriwrite_lang{pages}{pagelist}, $db_name), { Style => "pageheader" });
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->startform($main::kiriwrite_env{"script_filename"}, "POST");
+ $main::kiriwrite_presmodule->startbox();
+ $main::kiriwrite_presmodule->addhiddendata("mode", "page");
+ $main::kiriwrite_presmodule->addhiddendata("database", $database_file);
+ $main::kiriwrite_presmodule->addhiddendata("type", "multiple");
# Write out the page browsing list.
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{pages}->{showlistpage});
- $kiriwrite_presmodule->addselectbox("browsenumber");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{pages}{showlistpage});
+ $main::kiriwrite_presmodule->addselectbox("browsenumber");
# Write out the list of available pages to browse.
if ($page_list_count eq 1 && !$page_browsenumber){
- $kiriwrite_presmodule->addoption($page_list_count, { Value => $page_list_count, Selected => 1 });
+ $main::kiriwrite_presmodule->addoption($page_list_count, { Value => $page_list_count, Selected => 1 });
} else {
if ($page_browsenumber eq $page_list_count){
- $kiriwrite_presmodule->addoption($page_list_count, { Value => $page_list_count, Selected => 1 });
+ $main::kiriwrite_presmodule->addoption($page_list_count, { Value => $page_list_count, Selected => 1 });
} else {
- $kiriwrite_presmodule->addoption($page_list_count, { Value => $page_list_count });
+ $main::kiriwrite_presmodule->addoption($page_list_count, { Value => $page_list_count });
}
}
- $kiriwrite_presmodule->endselectbox();
- $kiriwrite_presmodule->addbutton("action", { Value => "view", Description => $kiriwrite_lang->{pages}->{show} });
+ $main::kiriwrite_presmodule->endselectbox();
+ $main::kiriwrite_presmodule->addbutton("action", { Value => "view", Description => $main::kiriwrite_lang{pages}{show} });
if ($page_list ne $page_browsenumber){
- $kiriwrite_presmodule->addtext(" | ");
- $kiriwrite_presmodule->addlink($kiriwrite_env{"script_filename"} . "?mode=page&action=view&database=" . $database_file . "&browsenumber=" . ($page_browsenumber + 1), { Text => $kiriwrite_lang->{pages}->{nextpage} });
+ $main::kiriwrite_presmodule->addtext(" | ");
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{"script_filename"} . "?mode=page&action=view&database=" . $database_file . "&browsenumber=" . ($page_browsenumber + 1), { Text => $main::kiriwrite_lang{pages}{nextpage} });
}
if ($page_browsenumber > 1){
- $kiriwrite_presmodule->addtext(" | ");
- $kiriwrite_presmodule->addlink($kiriwrite_env{"script_filename"} . "?mode=page&action=view&database=" . $database_file . "&browsenumber=" . ($page_browsenumber - 1), { Text => $kiriwrite_lang->{pages}->{previouspage} });
+ $main::kiriwrite_presmodule->addtext(" | ");
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{"script_filename"} . "?mode=page&action=view&database=" . $database_file . "&browsenumber=" . ($page_browsenumber - 1), { Text => $main::kiriwrite_lang{pages}{previouspage} });
}
- $kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
# Write the list of multiple selection options.
- $kiriwrite_presmodule->addreset($kiriwrite_lang->{common}->{selectnone});
- $kiriwrite_presmodule->addtext(" | ");
- $kiriwrite_presmodule->addbutton("action", { Value => "multidelete", Description => $kiriwrite_lang->{pages}->{deleteselectedbutton} });
- $kiriwrite_presmodule->addtext(" | ");
- $kiriwrite_presmodule->addbutton("action", { Value => "multimove", Description => $kiriwrite_lang->{pages}->{moveselectedbutton} });
- $kiriwrite_presmodule->addtext(" | ");
- $kiriwrite_presmodule->addbutton("action", { Value => "multicopy", Description => $kiriwrite_lang->{pages}->{copyselectedbutton} });
- $kiriwrite_presmodule->addtext(" | ");
- $kiriwrite_presmodule->addbutton("action", { Value => "multiedit", Description => $kiriwrite_lang->{pages}->{editselectedbutton} });
+ $main::kiriwrite_presmodule->addreset($main::kiriwrite_lang{common}{selectnone});
+ $main::kiriwrite_presmodule->addtext(" | ");
+ $main::kiriwrite_presmodule->addbutton("action", { Value => "multidelete", Description => $main::kiriwrite_lang{pages}{deleteselectedbutton} });
+ $main::kiriwrite_presmodule->addtext(" | ");
+ $main::kiriwrite_presmodule->addbutton("action", { Value => "multimove", Description => $main::kiriwrite_lang{pages}{moveselectedbutton} });
+ $main::kiriwrite_presmodule->addtext(" | ");
+ $main::kiriwrite_presmodule->addbutton("action", { Value => "multicopy", Description => $main::kiriwrite_lang{pages}{copyselectedbutton} });
+ $main::kiriwrite_presmodule->addtext(" | ");
+ $main::kiriwrite_presmodule->addbutton("action", { Value => "multiedit", Description => $main::kiriwrite_lang{pages}{editselectedbutton} });
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->endbox();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->endbox();
# Write the table header.
- $kiriwrite_presmodule->starttable("", { CellPadding => 5, CellSpacing => 0 });
- $kiriwrite_presmodule->startheader();
- $kiriwrite_presmodule->addheader("", { Style => "tablecellheader" });
- $kiriwrite_presmodule->addheader($kiriwrite_lang->{pages}->{pagefilename}, { Style => "tablecellheader" });
- $kiriwrite_presmodule->addheader($kiriwrite_lang->{pages}->{pagename}, { Style => "tablecellheader" });
- $kiriwrite_presmodule->addheader($kiriwrite_lang->{pages}->{pagedescription}, { Style => "tablecellheader" });
- $kiriwrite_presmodule->addheader($kiriwrite_lang->{pages}->{lastmodified}, { Style => "tablecellheader" });
- $kiriwrite_presmodule->addheader($kiriwrite_lang->{common}->{options}, { Style => "tablecellheader" });
- $kiriwrite_presmodule->endheader();
+ $main::kiriwrite_presmodule->starttable("", { CellPadding => 5, CellSpacing => 0 });
+ $main::kiriwrite_presmodule->startheader();
+ $main::kiriwrite_presmodule->addheader("", { Style => "tablecellheader" });
+ $main::kiriwrite_presmodule->addheader($main::kiriwrite_lang{pages}{pagefilename}, { Style => "tablecellheader" });
+ $main::kiriwrite_presmodule->addheader($main::kiriwrite_lang{pages}{pagename}, { Style => "tablecellheader" });
+ $main::kiriwrite_presmodule->addheader($main::kiriwrite_lang{pages}{pagedescription}, { Style => "tablecellheader" });
+ $main::kiriwrite_presmodule->addheader($main::kiriwrite_lang{pages}{lastmodified}, { Style => "tablecellheader" });
+ $main::kiriwrite_presmodule->addheader($main::kiriwrite_lang{common}{options}, { Style => "tablecellheader" });
+ $main::kiriwrite_presmodule->endheader();
# Process each page filename and get the page information.
foreach $page_filename (@database_pages){
- %page_info = $kiriwrite_dbmodule->getpageinfo({ PageFilename => $page_filename, Reduced => 1 });
+ %page_info = $main::kiriwrite_dbmodule->getpageinfo({ PageFilename => $page_filename, Reduced => 1 });
# Check if any errors have occured.
- if ($kiriwrite_dbmodule->geterror eq "DatabaseError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseError"){
# A database error has occured so return an error and
# also the extended error information.
- kiriwrite_error("databaseerror", $kiriwrite_dbmodule->geterror(1));
+ kiriwrite_error("databaseerror", $main::kiriwrite_dbmodule->geterror(1));
- } elsif ($kiriwrite_dbmodule->geterror eq "PageDoesNotExist"){
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "PageDoesNotExist"){
# The page does not exist, so process the next page.
# Write out the row of data.
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell($tablestyle);
- $kiriwrite_presmodule->addhiddendata("id[" . $page_count . "]", $page_filename);
- $kiriwrite_presmodule->addcheckbox("name[" . $page_count . "]");
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell($tablestyle);
- $kiriwrite_presmodule->addtext($page_filename);
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell($tablestyle);
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell($tablestyle);
+ $main::kiriwrite_presmodule->addhiddendata("id[" . $page_count . "]", $page_filename);
+ $main::kiriwrite_presmodule->addcheckbox("name[" . $page_count . "]");
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell($tablestyle);
+ $main::kiriwrite_presmodule->addtext($page_filename);
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell($tablestyle);
if (!$page_name){
- $kiriwrite_presmodule->additalictext($kiriwrite_lang->{blank}->{noname});
+ $main::kiriwrite_presmodule->additalictext($main::kiriwrite_lang{blank}{noname});
} else {
- $kiriwrite_presmodule->addtext($page_name);
+ $main::kiriwrite_presmodule->addtext($page_name);
}
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell($tablestyle);
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell($tablestyle);
if (!$page_description){
- $kiriwrite_presmodule->additalictext($kiriwrite_lang->{blank}->{nodescription});
+ $main::kiriwrite_presmodule->additalictext($main::kiriwrite_lang{blank}{nodescription});
} else {
- $kiriwrite_presmodule->addtext($page_description);
+ $main::kiriwrite_presmodule->addtext($page_description);
}
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell($tablestyle);
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell($tablestyle);
if (!$page_modified){
- $kiriwrite_presmodule->additalictext("No Date");
+ $main::kiriwrite_presmodule->additalictext("No Date");
} else {
- $kiriwrite_presmodule->addtext($page_modified);
+ $main::kiriwrite_presmodule->addtext($page_modified);
}
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell($tablestyle);
- $kiriwrite_presmodule->addlink($kiriwrite_env{"script_filename"} . "?mode=page&action=edit&database=" . $database_file . "&page=" . $page_filename, { Text => $kiriwrite_lang->{options}->{edit} });
- $kiriwrite_presmodule->addlink($kiriwrite_env{"script_filename"} . "?mode=page&action=delete&database=" . $database_file . "&page=" . $page_filename, { Text => $kiriwrite_lang->{options}->{delete} });
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell($tablestyle);
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{"script_filename"} . "?mode=page&action=edit&database=" . $database_file . "&page=" . $page_filename, { Text => $main::kiriwrite_lang{options}{edit} });
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{"script_filename"} . "?mode=page&action=delete&database=" . $database_file . "&page=" . $page_filename, { Text => $main::kiriwrite_lang{options}{delete} });
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
# Increment the counter.
# Disconnect from the database server.
- $kiriwrite_dbmodule->disconnect();
+ $main::kiriwrite_dbmodule->disconnect();
- $kiriwrite_presmodule->endtable();
- $kiriwrite_presmodule->startbox();
- $kiriwrite_presmodule->addhiddendata("count", $page_count);
- $kiriwrite_presmodule->endbox();
- $kiriwrite_presmodule->endform();
+ $main::kiriwrite_presmodule->endtable();
+ $main::kiriwrite_presmodule->startbox();
+ $main::kiriwrite_presmodule->addhiddendata("count", $page_count);
+ $main::kiriwrite_presmodule->endbox();
+ $main::kiriwrite_presmodule->endform();
if (!@database_pages && $page_browsenumber > 1){
# there were no pages for the page browse number
# given.
- $kiriwrite_presmodule->clear();
- $kiriwrite_presmodule->addtext(kiriwrite_language($kiriwrite_lang->{pages}->{pagelist}, $db_name), { Style => "pageheader" });
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->startbox("errorbox");
- $kiriwrite_presmodule->enterdata($kiriwrite_lang->{pages}->{nopagesinpagebrowse});
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlink($kiriwrite_env{"script_filename"} . "?mode=page&action=view&database=" . $database_file, { Text => $kiriwrite_lang->{pages}->{returntofirstpagebrowse} });
- $kiriwrite_presmodule->endbox();
+ $main::kiriwrite_presmodule->clear();
+ $main::kiriwrite_presmodule->addtext(kiriwrite_language($main::kiriwrite_lang{pages}{pagelist}, $db_name), { Style => "pageheader" });
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->startbox("errorbox");
+ $main::kiriwrite_presmodule->enterdata($main::kiriwrite_lang{pages}{nopagesinpagebrowse});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{"script_filename"} . "?mode=page&action=view&database=" . $database_file, { Text => $main::kiriwrite_lang{pages}{returntofirstpagebrowse} });
+ $main::kiriwrite_presmodule->endbox();
} elsif (!@database_pages || !$page_count){
# message saying that there were no pages in the
# database.
- $kiriwrite_presmodule->clear();
- $kiriwrite_presmodule->addtext(kiriwrite_language($kiriwrite_lang->{pages}->{pagelist}, $db_name), { Style => "pageheader" });
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->startbox("errorbox");
- $kiriwrite_presmodule->enterdata($kiriwrite_lang->{pages}->{nopagesindatabase});
- $kiriwrite_presmodule->endbox();
+ $main::kiriwrite_presmodule->clear();
+ $main::kiriwrite_presmodule->addtext(kiriwrite_language($main::kiriwrite_lang{pages}{pagelist}, $db_name), { Style => "pageheader" });
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->startbox("errorbox");
+ $main::kiriwrite_presmodule->enterdata($main::kiriwrite_lang{pages}{nopagesindatabase});
+ $main::kiriwrite_presmodule->endbox();
}
- return $kiriwrite_presmodule->grab();
+ return $main::kiriwrite_presmodule->grab();
}
}
+ # Connect to the database server.
+
+ $main::kiriwrite_dbmodule->connect();
+
# Check if the database has write permissions.
- my $database_permissions = $kiriwrite_dbmodule->dbpermissions($pagedatabase, 1, 1);
+ my $database_permissions = $main::kiriwrite_dbmodule->dbpermissions($pagedatabase, 1, 1);
if ($database_permissions eq 1){
}
- # Connect to the database server.
-
- $kiriwrite_dbmodule->connect();
-
# Check if any errors occured while connecting to the database server.
- if ($kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
# A database connection error has occured so return
# an error.
- kiriwrite_error("databaseconnectionerror", $kiriwrite_dbmodule->geterror(1));
+ kiriwrite_error("databaseconnectionerror", $main::kiriwrite_dbmodule->geterror(1));
}
# Select the database to add the page to.
- $kiriwrite_dbmodule->selectdb({ DatabaseName => $pagedatabase });
+ $main::kiriwrite_dbmodule->selectdb({ DatabaseName => $pagedatabase });
# Check if any errors had occured while selecting the database.
- if ($kiriwrite_dbmodule->geterror eq "DoesNotExist"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DoesNotExist"){
# The database does not exist, so return an error.
kiriwrite_error("databasemissingfile");
- } elsif ($kiriwrite_dbmodule->geterror eq "InvalidPermissionsSet"){
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "InvalidPermissionsSet"){
# The database has invalid permissions set, so return
# an error.
# Get information about the database.
- my %database_info = $kiriwrite_dbmodule->getdatabaseinfo();
+ my %database_info = $main::kiriwrite_dbmodule->getdatabaseinfo();
# Check if any error occured while getting the database information.
- if ($kiriwrite_dbmodule->geterror eq "DatabaseError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseError"){
# A database error has occured so return an error and
# also the extended error information.
- kiriwrite_error("databaseerror", $kiriwrite_dbmodule->geterror(1));
+ kiriwrite_error("databaseerror", $main::kiriwrite_dbmodule->geterror(1));
};
# Add the page to the selected database.
- $kiriwrite_dbmodule->addpage({ PageFilename => $pagefilename, PageName => $pagetitle, PageDescription => $pagedescription, PageSection => $pagesection, PageTemplate => $pagetemplate, PageContent => $pagefiledata, PageSettings => $pagesettings });
+ $main::kiriwrite_dbmodule->addpage({ PageFilename => $pagefilename, PageName => $pagetitle, PageDescription => $pagedescription, PageSection => $pagesection, PageTemplate => $pagetemplate, PageContent => $pagefiledata, PageSettings => $pagesettings });
# Check if any errors occured while adding the page.
- if ($kiriwrite_dbmodule->geterror eq "PageExists"){
+ if ($main::kiriwrite_dbmodule->geterror eq "PageExists"){
# A page with the filename given already exists so
# return an error.
kiriwrite_error("pagefilenameexists");
- } elsif ($kiriwrite_dbmodule->geterror eq "DatabaseError"){
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "DatabaseError"){
# A database error has occured so return an error
# with extended error information.
- kiriwrite_error("databaseerror", $kiriwrite_dbmodule->geterror(1));
+ kiriwrite_error("databaseerror", $main::kiriwrite_dbmodule->geterror(1));
}
# Disconnect from the database server.
- $kiriwrite_dbmodule->disconnect();
+ $main::kiriwrite_dbmodule->disconnect();
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{pages}->{addpage}, { Style => "pageheader" });
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext(kiriwrite_language($kiriwrite_lang->{pages}->{pageaddedmessage}, $pagetitle, $database_name));
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlink($kiriwrite_env{"script_filename"} . "?mode=page&action=view&database=" . $pagedatabase, { Text => kiriwrite_language($kiriwrite_lang->{pages}->{returnpagelist}, $database_name) });
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{pages}{addpage}, { Style => "pageheader" });
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext(kiriwrite_language($main::kiriwrite_lang{pages}{pageaddedmessage}, $pagetitle, $database_name));
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{"script_filename"} . "?mode=page&action=view&database=" . $pagedatabase, { Text => kiriwrite_language($main::kiriwrite_lang{pages}{returnpagelist}, $database_name) });
- return $kiriwrite_presmodule->grab();
+ return $main::kiriwrite_presmodule->grab();
} elsif ($confirm eq 0) {
# Connect to the database server.
- $kiriwrite_dbmodule->connect();
+ $main::kiriwrite_dbmodule->connect();
# Check if any errors occured while connecting to the database server.
- if ($kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
# A database connection error has occured so return
# an error.
- kiriwrite_error("databaseconnectionerror", $kiriwrite_dbmodule->geterror(1));
+ kiriwrite_error("databaseconnectionerror", $main::kiriwrite_dbmodule->geterror(1));
}
# Select the database.
- $kiriwrite_dbmodule->selectdb({ DatabaseName => $pagedatabase });
+ $main::kiriwrite_dbmodule->selectdb({ DatabaseName => $pagedatabase });
# Check if any errors had occured while selecting the database.
- if ($kiriwrite_dbmodule->geterror eq "DoesNotExist"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DoesNotExist"){
# The database does not exist, so return an error.
kiriwrite_error("databasemissingfile");
- } elsif ($kiriwrite_dbmodule->geterror eq "InvalidPermissionsSet"){
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "InvalidPermissionsSet"){
# The database has invalid permissions set, so return
# an error.
# Check if the database has write permissions.
- my $database_permissions = $kiriwrite_dbmodule->dbpermissions($pagedatabase, 1, 1);
+ my $database_permissions = $main::kiriwrite_dbmodule->dbpermissions($pagedatabase, 1, 1);
if ($database_permissions eq 1){
# Get information about the database.
- %database_info = $kiriwrite_dbmodule->getdatabaseinfo();
+ %database_info = $main::kiriwrite_dbmodule->getdatabaseinfo();
# Check if any error occured while getting the database information.
- if ($kiriwrite_dbmodule->geterror eq "DatabaseError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseError"){
# A database error has occured so return an error and
# also the extended error information.
- kiriwrite_error("databaseerror", $kiriwrite_dbmodule->geterror(1));
+ kiriwrite_error("databaseerror", $main::kiriwrite_dbmodule->geterror(1));
};
# Connect to the template database.
- $kiriwrite_dbmodule->connecttemplate();
+ $main::kiriwrite_dbmodule->connecttemplate();
# Check if any errors occured while connecting to the template database.
- if ($kiriwrite_dbmodule->geterror eq "TemplateDatabaseDoesNotExist"){
+ if ($main::kiriwrite_dbmodule->geterror eq "TemplateDatabaseDoesNotExist"){
# The template database does not exist so set the template
# warning message.
- $template_warningmessage = $kiriwrite_lang->{pages}->{notemplatedatabase};
+ $template_warningmessage = $main::kiriwrite_lang{pages}{notemplatedatabase};
$template_warning = 1;
- } elsif ($kiriwrite_dbmodule->geterror eq "TemplateDatabaseInvalidPermissionsSet"){
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "TemplateDatabaseInvalidPermissionsSet"){
# The template database has invalid permissions set so write
# the template warning message.
- $template_warningmessage = $kiriwrite_lang->{pages}->{templatepermissionserror};
+ $template_warningmessage = $main::kiriwrite_lang{pages}{templatepermissionserror};
$template_warning = 1;
}
# Get the list of templates available.
- @templates_list = $kiriwrite_dbmodule->gettemplatelist();
+ @templates_list = $main::kiriwrite_dbmodule->gettemplatelist();
# Check if any errors had occured.
- if ($kiriwrite_dbmodule->geterror eq "TemplateDatabaseError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "TemplateDatabaseError"){
# A database error occured while getting the list
# of templates so return a warning message with the
# extended error information.
- $template_warningmessage = kiriwrite_language($kiriwrite_lang->{pages}->{templatedatabaseerror}, $kiriwrite_dbmodule->geterror(1));
+ $template_warningmessage = kiriwrite_language($main::kiriwrite_lang{pages}{templatedatabaseerror}, $main::kiriwrite_dbmodule->geterror(1));
$template_warning = 1;
}
# Get information about the template.
- %template_info = $kiriwrite_dbmodule->gettemplateinfo({ TemplateFilename => $template });
+ %template_info = $main::kiriwrite_dbmodule->gettemplateinfo({ TemplateFilename => $template });
# Check if any error occured while getting the template information.
- if ($kiriwrite_dbmodule->geterror eq "TemplateDatabaseError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "TemplateDatabaseError"){
# A database error has occured, so return an error.
- kiriwrite_error("templatedatabaseerror", $kiriwrite_dbmodule->geterror(1));
+ kiriwrite_error("templatedatabaseerror", $main::kiriwrite_dbmodule->geterror(1));
- } elsif ($kiriwrite_dbmodule->geterror eq "TemplateDoesNotExist"){
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "TemplateDoesNotExist"){
# The template does not exist, so process the next template.
# The template list is blank so write the template
# warning message.
- $template_warningmessage = $kiriwrite_lang->{pages}->{notemplatesavailable};
+ $template_warningmessage = $main::kiriwrite_lang->{pages}->{notemplatesavailable};
}
# Disconnect from the template database.
- $kiriwrite_dbmodule->disconnecttemplate();
+ $main::kiriwrite_dbmodule->disconnecttemplate();
# Disconnect from the database server.
- $kiriwrite_dbmodule->disconnect();
+ $main::kiriwrite_dbmodule->disconnect();
# write out the form for adding a page.
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{pages}->{addpage}, { Style => "pageheader" });
- $kiriwrite_presmodule->startform($kiriwrite_env{"script_filename"}, "POST");#
- $kiriwrite_presmodule->startbox();
- $kiriwrite_presmodule->addhiddendata("mode", "page");
- $kiriwrite_presmodule->addhiddendata("action", "add");
- $kiriwrite_presmodule->addhiddendata("database", $pagedatabase);
- $kiriwrite_presmodule->addhiddendata("confirm", "1");
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->endbox();
- $kiriwrite_presmodule->starttable("", { CellPadding => 5, CellSpacing => 0 });
-
- $kiriwrite_presmodule->startheader();
- $kiriwrite_presmodule->addcell("tablecellheader");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{common}->{setting});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecellheader");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{common}->{value});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endheader();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{pages}->{database});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addtext($database_name);
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{pages}->{pagename});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addinputbox("pagename", { Size => 64, MaxLength => 512 });
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{pages}->{pagedescription});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addinputbox("pagedescription", { Size => 64, MaxLength => 512 });
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{pages}->{pagesection});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addinputbox("pagesection", { Size => 64, MaxLength => 256 });
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{pages}->{pagetemplate});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{pages}{addpage}, { Style => "pageheader" });
+ $main::kiriwrite_presmodule->startform($main::kiriwrite_env{"script_filename"}, "POST");#
+ $main::kiriwrite_presmodule->startbox();
+ $main::kiriwrite_presmodule->addhiddendata("mode", "page");
+ $main::kiriwrite_presmodule->addhiddendata("action", "add");
+ $main::kiriwrite_presmodule->addhiddendata("database", $pagedatabase);
+ $main::kiriwrite_presmodule->addhiddendata("confirm", "1");
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->endbox();
+ $main::kiriwrite_presmodule->starttable("", { CellPadding => 5, CellSpacing => 0 });
+
+ $main::kiriwrite_presmodule->startheader();
+ $main::kiriwrite_presmodule->addcell("tablecellheader");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{common}{setting});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecellheader");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{common}{value});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endheader();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{pages}{database});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addtext($database_name);
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{pages}{pagename});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addinputbox("pagename", { Size => 64, MaxLength => 512 });
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{pages}{pagedescription});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addinputbox("pagedescription", { Size => 64, MaxLength => 512 });
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{pages}{pagesection});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addinputbox("pagesection", { Size => 64, MaxLength => 256 });
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{pages}{pagetemplate});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
# Check if the template warning value has been set
# and write the error message in place of the templates
if ($template_warning eq 1){
- $kiriwrite_presmodule->addhiddendata("pagetemplate", "!none");
- $kiriwrite_presmodule->addtext($template_warningmessage);
+ $main::kiriwrite_presmodule->addhiddendata("pagetemplate", "!none");
+ $main::kiriwrite_presmodule->addtext($template_warningmessage);
} else {
my $page_filename;
my $page_name;
- $kiriwrite_presmodule->addselectbox("pagetemplate");
+ $main::kiriwrite_presmodule->addselectbox("pagetemplate");
foreach $template_file (keys %template_list){
$page_filename = $template_list{$template_file}{Filename};
$page_name = $template_list{$template_file}{Name};
- $kiriwrite_presmodule->addoption($page_name . " (" . $page_filename . ")", { Value => $page_filename });
+ $main::kiriwrite_presmodule->addoption($page_name . " (" . $page_filename . ")", { Value => $page_filename });
$template_count++;
$template_count = 0;
}
- $kiriwrite_presmodule->addoption($kiriwrite_lang->{pages}->{usenotemplate}, { Value => "!none", Selected => 1 });
- $kiriwrite_presmodule->endselectbox();
-
- }
-
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{pages}->{pagefilename});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addinputbox("pagefilename", { Size => 64, MaxLength => 256 });
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{pages}->{pagecontent});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addtextbox("pagecontent", { Columns => $kiriwrite_config{"display_textareacols"}, Rows => $kiriwrite_config{"display_textarearows"} });
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->startbox("datalist");
- $kiriwrite_presmodule->addboldtext($kiriwrite_lang->{common}->{tags});
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{common}->{pagetitle});
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{common}->{pagename});
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{common}->{pagedescription});
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{common}->{pagesection});
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{common}->{pageautosection});
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{common}->{pageautotitle});
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->endbox();
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{pages}->{pagesettings});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addradiobox("pagesettings", { Description => $kiriwrite_lang->{pages}->{usepageandsection}, Value => "1", Selected => 1, LineBreak => 1});
- $kiriwrite_presmodule->addradiobox("pagesettings", { Description => $kiriwrite_lang->{pages}->{usepagename}, Value => "2", Selected => 0, LineBreak => 1});
- $kiriwrite_presmodule->addradiobox("pagesettings", { Description => $kiriwrite_lang->{pages}->{usesectionname}, Value => "3", Selected => 0, LineBreak => 1});
- $kiriwrite_presmodule->addradiobox("pagesettings", { Description => $kiriwrite_lang->{pages}->{nopagesection}, Value => "0", Selected => 0, LineBreak => 1});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->endtable();
-
- $kiriwrite_presmodule->startbox();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addsubmit($kiriwrite_lang->{pages}->{addpagebutton});
- $kiriwrite_presmodule->addtext(" | ");
- $kiriwrite_presmodule->addreset($kiriwrite_lang->{common}->{clearvalues});
- $kiriwrite_presmodule->addtext(" | ");
- $kiriwrite_presmodule->addlink($kiriwrite_env{"script_filename"} . "?mode=page&action=view&database=" . $pagedatabase, { Text => kiriwrite_language($kiriwrite_lang->{pages}->{returnpagelist}, $database_name) });
- $kiriwrite_presmodule->endbox();
- $kiriwrite_presmodule->endform();
-
-
- return $kiriwrite_presmodule->grab();
+ $main::kiriwrite_presmodule->addoption($main::kiriwrite_lang{pages}{usenotemplate}, { Value => "!none", Selected => 1 });
+ $main::kiriwrite_presmodule->endselectbox();
+
+ }
+
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{pages}{pagefilename});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addinputbox("pagefilename", { Size => 64, MaxLength => 256 });
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{pages}{pagecontent});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addtextbox("pagecontent", { Columns => $main::kiriwrite_config{"display_textareacols"}, Rows => $main::kiriwrite_config{"display_textarearows"} });
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->startbox("datalist");
+ $main::kiriwrite_presmodule->addboldtext($main::kiriwrite_lang{common}{tags});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{common}{pagetitle});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{common}{pagename});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{common}{pagedescription});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{common}{pagesection});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{common}{pageautosection});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{common}{pageautotitle});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->endbox();
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{pages}{pagesettings});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addradiobox("pagesettings", { Description => $main::kiriwrite_lang{pages}{usepageandsection}, Value => "1", Selected => 1, LineBreak => 1});
+ $main::kiriwrite_presmodule->addradiobox("pagesettings", { Description => $main::kiriwrite_lang{pages}{usepagename}, Value => "2", Selected => 0, LineBreak => 1});
+ $main::kiriwrite_presmodule->addradiobox("pagesettings", { Description => $main::kiriwrite_lang{pages}{usesectionname}, Value => "3", Selected => 0, LineBreak => 1});
+ $main::kiriwrite_presmodule->addradiobox("pagesettings", { Description => $main::kiriwrite_lang{pages}{nopagesection}, Value => "0", Selected => 0, LineBreak => 1});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->endtable();
+
+ $main::kiriwrite_presmodule->startbox();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addsubmit($main::kiriwrite_lang{pages}{addpagebutton});
+ $main::kiriwrite_presmodule->addtext(" | ");
+ $main::kiriwrite_presmodule->addreset($main::kiriwrite_lang{common}{clearvalues});
+ $main::kiriwrite_presmodule->addtext(" | ");
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{"script_filename"} . "?mode=page&action=view&database=" . $pagedatabase, { Text => kiriwrite_language($main::kiriwrite_lang{pages}{returnpagelist}, $database_name) });
+ $main::kiriwrite_presmodule->endbox();
+ $main::kiriwrite_presmodule->endform();
+
+
+ return $main::kiriwrite_presmodule->grab();
} else {
}
-
-
}
-sub kiriwrite_page_delete{
+sub kiriwrite_page_edit{
#################################################################################
-# kiriwrite_page_delete: Deletes a (single) page from a database. #
+# kiriwrite_page_edit: Edits a page from a database. #
# #
# Usage: #
# #
-# kiriwrite_page_delete(database, page, [confirm]); #
+# kiriwrite_page_edit(database, filename, newfilename, newname, newdescription, #
+# newsection, newtemplate, newsettings, newpagecontent #
+# confirm); #
# #
-# database Specifies the database to delete from. #
-# page Specifies the page to delete. #
-# confirm Confirms the action to delete the page. #
+# database Specifies the database to edit from. #
+# filename Specifies the filename to use. #
+# newfilename Specifies the new page filename to use. #
+# newname Specifies the new page name to use. #
+# newdescription Specifies the new description for the page. #
+# newsection Specifies the new section name to use. #
+# newtemplate Specifies the new template filename to use. #
+# newsettings Specifies the new page settings to use. #
+# newpagecontent Specifies the new page content to use. #
+# confirm Confirms the action to edit the page. #
#################################################################################
- my ($database, $page, $confirm) = @_;
+ # Get the values that have been passed to the subroutine.
+
+ my ($database, $pagefilename, $pagenewfilename, $pagenewtitle, $pagenewdescription, $pagenewsection, $pagenewtemplate, $pagenewsettings, $pagenewcontent, $confirm) = @_;
+
+ # Check if the confirm value is blank and if it is, then set it to '0'.
+
+ if (!$confirm){
+
+ $confirm = 0;
+
+ }
+
+ # Check if the confirm value is more than one character long and if it
+ # is then return an error.
+
+ kiriwrite_variablecheck($confirm, "maxlength", 1, 0);
# Check if the database filename is valid and return an error if
# it isn't.
}
- # Check if the page name is specified is blank and return an error if
- # it is.
-
- if (!$page){
+ # Check if the page identification number is blank (which it shouldn't
+ # be) and if it is, then return an error.
- # The page name is blank, so return an error.
+ if (!$pagefilename){
kiriwrite_error("blankfilename");
}
- # If the confirm value is blank, then set the confirm value to 0.
-
- if (!$confirm){
-
- $confirm = 0;
-
- }
+ # Check if the confirm value is '1' and if it is, edit the specified
+ # page in the database.
if ($confirm eq 1){
- # The action to delete the selected page from the database
- # has been confirmed.
+ # Check if the new page filename is blank.
- # Connect to the database server.
+ if (!$pagenewfilename){
- $kiriwrite_dbmodule->connect();
+ # The page filename is blank so return an error.
- # Check if any errors occured while connecting to the database server.
+ kiriwrite_error("pagefilenameblank");
- if ($kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
+ }
- # A database connection error has occured so return
- # an error.
+ # The action to edit a page has been confirmed so check the
+ # variables recieved are UTF8 compiliant before converting.
- kiriwrite_error("databaseconnectionerror", $kiriwrite_dbmodule->geterror(1));
+ kiriwrite_variablecheck($database, "utf8", 0, 0);
+ kiriwrite_variablecheck($pagefilename, "utf8", 0, 0);
+ kiriwrite_variablecheck($pagenewfilename, "utf8", 0, 0);
+ kiriwrite_variablecheck($pagenewtitle, "utf8", 0, 0);
+ kiriwrite_variablecheck($pagenewdescription, "utf8", 0, 0);
+ kiriwrite_variablecheck($pagenewsection, "utf8", 0, 0);
+ kiriwrite_variablecheck($pagenewsettings, "utf8", 0, 0);
+ kiriwrite_variablecheck($pagenewtemplate, "utf8", 0, 0);
+ kiriwrite_variablecheck($pagenewcontent, "utf8", 0, 0);
- }
+ # Convert the variables into proper UTF8 variables.
- # Select the database to delete the page from.
+ $database = kiriwrite_utf8convert($database);
+ $pagefilename = kiriwrite_utf8convert($pagefilename);
+ $pagenewfilename = kiriwrite_utf8convert($pagenewfilename);
+ $pagenewtitle = kiriwrite_utf8convert($pagenewtitle);
+ $pagenewdescription = kiriwrite_utf8convert($pagenewdescription);
+ $pagenewsection = kiriwrite_utf8convert($pagenewsection);
+ $pagenewsettings = kiriwrite_utf8convert($pagenewsettings);
+ $pagenewtemplate = kiriwrite_utf8convert($pagenewtemplate);
+ $pagenewcontent = kiriwrite_utf8convert($pagenewcontent);
- $kiriwrite_dbmodule->selectdb({ DatabaseName => $database });
+ # Check the lengths of the variables.
- # Check if any errors had occured while selecting the database.
+ my $pagenewfilename_maxlength_check = kiriwrite_variablecheck($pagenewfilename, "maxlength", 256, 1);
+ my $pagenewtitle_maxlength_check = kiriwrite_variablecheck($pagenewtitle, "maxlength", 512, 1);
+ my $pagenewdescription_maxlength_check = kiriwrite_variablecheck($pagenewdescription, "maxlength", 512, 1);
+ my $pagenewsection_maxlength_check = kiriwrite_variablecheck($pagenewsection, "maxlength", 256, 1);
+ my $pagenewsettings_maxlength_check = kiriwrite_variablecheck($pagenewsettings, "maxlength", 1, 1);
+ my $pagenewtemplate_maxlength_check = kiriwrite_variablecheck($pagenewtemplate, "maxlength", 64, 1);
- if ($kiriwrite_dbmodule->geterror eq "DoesNotExist"){
+ # Check each result to see if the length of the variable
+ # is valid and return an error if it isn't.
- # The database does not exist, so return an error.
+ if ($pagenewfilename_maxlength_check eq 1){
- kiriwrite_error("databasemissingfile");
+ # The new page filename given is too long, so return an error.
- } elsif ($kiriwrite_dbmodule->geterror eq "InvalidPermissionsSet"){
+ kiriwrite_error("pagefilenametoolong");
- # The database has invalid permissions set, so return
- # an error.
+ }
- kiriwrite_error("databaseinvalidpermissions");
+ if ($pagenewtitle_maxlength_check eq 1){
- }
+ # The new page title given is too long, so return an error.
- # Check if the database has write permissions.
+ kiriwrite_error("pagetitletoolong");
- my $database_permissions = $kiriwrite_dbmodule->dbpermissions($database, 1, 1);
+ }
- if ($database_permissions eq 1){
+ if ($pagenewdescription_maxlength_check eq 1){
- # The database permissions are invalid so return an error.
+ # The new page description given is too long, so return an error.
- kiriwrite_error("databaseinvalidpermissions");
+ kiriwrite_error("pagedescriptiontoolong");
}
- # Get the information about the database.
+ if ($pagenewsection_maxlength_check eq 1){
- my %database_info = $kiriwrite_dbmodule->getdatabaseinfo();
+ # The new page section given is too long, so return an error.
- # Check if any error occured while getting the database information.
+ kiriwrite_error("pagesectiontoolong");
- if ($kiriwrite_dbmodule->geterror eq "DatabaseError"){
+ }
- # A database error has occured so return an error and
- # also the extended error information.
+ if ($pagenewsettings_maxlength_check eq 1){
- kiriwrite_error("databaseerror", $kiriwrite_dbmodule->geterror(1));
-
- }
-
- # Get the information about the page that is going to be deleted.
-
- my %page_info = $kiriwrite_dbmodule->getpageinfo({ PageFilename => $page });
-
- # Check if any errors occured while getting the page information.
-
- if ($kiriwrite_dbmodule->geterror eq "DatabaseError"){
-
- # A database error has occured so return an error and
- # also the extended error information.
-
- kiriwrite_error("databaseerror", $kiriwrite_dbmodule->geterror(1));
-
- } elsif ($kiriwrite_dbmodule->geterror eq "PageDoesNotExist"){
-
- # The page does not exist, so return an error.
-
- kiriwrite_error("pagefilenamedoesnotexist");
-
- }
-
- # Delete the page from the database.
-
- $kiriwrite_dbmodule->deletepage({ PageFilename => $page });
-
- # Check if any errors occured while deleting the page from the database.
-
- if ($kiriwrite_dbmodule->geterror eq "DatabaseError"){
-
- # A database error has occured so return an error and
- # also the extended error information.
-
- kiriwrite_error("databaseerror", $kiriwrite_dbmodule->geterror(1));
-
- } elsif ($kiriwrite_dbmodule->geterror eq "PageDoesNotExist"){
-
- # The page does not exist, so return an error.
-
- kiriwrite_error("pagefilenamedoesnotexist");
-
- }
-
- # Get the database name and page name.
-
- my $database_name = $database_info{"DatabaseName"};
- my $page_name = $page_info{"PageName"};
-
- # Disconnect from the database server.
-
- $kiriwrite_dbmodule->disconnect();
-
- # Write out a message saying that the selected page from
- # the database has been deleted.
-
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{pages}->{pagedeleted}, { Style => "pageheader" });
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext(kiriwrite_language($kiriwrite_lang->{pages}->{pagedeletedmessage}, $page_name, $database_name));
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlink($kiriwrite_env{"script_filename"} . "?mode=page&action=view&database=" . $database, { Text => kiriwrite_language($kiriwrite_lang->{pages}->{returnpagelist}, $database_name)});
-
- return $kiriwrite_presmodule->grab();
-
- } elsif ($confirm eq 0){
-
- # Connect to the database server.
-
- $kiriwrite_dbmodule->connect();
-
- # Check if any errors occured while connecting to the database server.
-
- if ($kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
-
- # A database connection error has occured so return
- # an error.
-
- kiriwrite_error("databaseconnectionerror", $kiriwrite_dbmodule->geterror(1));
-
- }
-
- # Select the database.
-
- $kiriwrite_dbmodule->selectdb({ DatabaseName => $database });
-
- # Check if any errors had occured while selecting the database.
-
- if ($kiriwrite_dbmodule->geterror eq "DoesNotExist"){
-
- # The database does not exist, so return an error.
-
- kiriwrite_error("databasemissingfile");
-
- } elsif ($kiriwrite_dbmodule->geterror eq "InvalidPermissionsSet"){
-
- # The database has invalid permissions set, so return
- # an error.
-
- kiriwrite_error("databaseinvalidpermissions");
-
- }
-
- # Get information about the database.
-
- my %database_info = $kiriwrite_dbmodule->getdatabaseinfo();
-
- # Check if any errors occured while getting the database information.
-
- if ($kiriwrite_dbmodule->geterror eq "DatabaseError"){
-
- # A database error has occured so return an error and
- # also the extended error information.
-
- kiriwrite_error("databaseerror", $kiriwrite_dbmodule->geterror(1));
-
- }
-
- # Get information about the page that is going to be deleted.
-
- my %page_info = $kiriwrite_dbmodule->getpageinfo({ PageFilename => $page });
-
- # Check if any errors occured while getting the page information.
-
- if ($kiriwrite_dbmodule->geterror eq "DatabaseError"){
-
- # A database error has occured so return an error and
- # also the extended error information.
-
- kiriwrite_error("databaseerror", $kiriwrite_dbmodule->geterror(1));
-
- } elsif ($kiriwrite_dbmodule->geterror eq "PageDoesNotExist"){
-
- # The page does not exist, so return an error.
-
- kiriwrite_error("pagefilenamedoesnotexist");
-
- }
-
- my $database_name = $database_info{"DatabaseName"};
- my $page_name = $page_info{"PageName"};
-
- # Disconnect from the database server.
-
- $kiriwrite_dbmodule->disconnect();
-
- # Write a message asking the user to confirm the deletion of the
- # page.
-
- $kiriwrite_presmodule->addtext(kiriwrite_language($kiriwrite_lang->{pages}->{deletepage}, $page_name), { Style => "pageheader" });
- $kiriwrite_presmodule->startform($kiriwrite_env{"script_filename"}, "POST");
- $kiriwrite_presmodule->startbox();
- $kiriwrite_presmodule->addhiddendata("mode", "page");
- $kiriwrite_presmodule->addhiddendata("action", "delete");
- $kiriwrite_presmodule->addhiddendata("database", $database);
- $kiriwrite_presmodule->addhiddendata("page", $page);
- $kiriwrite_presmodule->addhiddendata("confirm", "1");
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext(kiriwrite_language($kiriwrite_lang->{pages}->{deletepagemessage}, $page_name, $database_name));
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addsubmit($kiriwrite_lang->{pages}->{deletepagebutton});
- $kiriwrite_presmodule->addtext(" | ");
- $kiriwrite_presmodule->addlink($kiriwrite_env{"script_filename"} . "?mode=page&action=view&database=" . $database, { Text => kiriwrite_language($kiriwrite_lang->{pages}->{deletepagesreturnlink}, $database_name)});
- $kiriwrite_presmodule->endbox();
- $kiriwrite_presmodule->endform();
-
- return $kiriwrite_presmodule->grab();
-
- } else {
-
- # Another page deletion type was specified, so return an error.
-
- kiriwrite_error("invalidoption");
-
- }
-
-}
-
-sub kiriwrite_page_edit{
-#################################################################################
-# kiriwrite_page_edit: Edits a page from a database. #
-# #
-# Usage: #
-# #
-# kiriwrite_page_edit(database, filename, newfilename, newname, newdescription, #
-# newsection, newtemplate, newsettings, newpagecontent #
-# confirm); #
-# #
-# database Specifies the database to edit from. #
-# filename Specifies the filename to use. #
-# newfilename Specifies the new page filename to use. #
-# newname Specifies the new page name to use. #
-# newdescription Specifies the new description for the page. #
-# newsection Specifies the new section name to use. #
-# newtemplate Specifies the new template filename to use. #
-# newsettings Specifies the new page settings to use. #
-# newpagecontent Specifies the new page content to use. #
-# confirm Confirms the action to edit the page. #
-#################################################################################
-
- # Get the values that have been passed to the subroutine.
-
- my ($database, $pagefilename, $pagenewfilename, $pagenewtitle, $pagenewdescription, $pagenewsection, $pagenewtemplate, $pagenewsettings, $pagenewcontent, $confirm) = @_;
-
- # Check if the confirm value is blank and if it is, then set it to '0'.
-
- if (!$confirm){
-
- $confirm = 0;
-
- }
-
- # Check if the confirm value is more than one character long and if it
- # is then return an error.
-
- kiriwrite_variablecheck($confirm, "maxlength", 1, 0);
-
- # Check if the database filename is valid and return an error if
- # it isn't.
-
- my $pagedatabase_filename_check = kiriwrite_variablecheck($database, "filename", 0, 1);
-
- if ($pagedatabase_filename_check eq 1){
-
- # The database filename is blank, so return an error.
-
- kiriwrite_error("blankdatabasepageadd");
-
- } elsif ($pagedatabase_filename_check eq 2){
-
- # The database filename is invalid, so return an error.
-
- kiriwrite_error("databasefilenameinvalid");
-
- }
-
- # Check the length the database name and return an error if it's
- # too long.
-
- my $pagedatabase_length_check = kiriwrite_variablecheck($database, "maxlength", 32, 1);
-
- if ($pagedatabase_length_check eq 1){
-
- # The database name is too long, so return an error.
-
- kiriwrite_error("databasefilenametoolong");
-
- }
-
- # Check if the page identification number is blank (which it shouldn't
- # be) and if it is, then return an error.
-
- if (!$pagefilename){
-
- kiriwrite_error("blankfilename");
-
- }
-
- # Check if the confirm value is '1' and if it is, edit the specified
- # page in the database.
-
- if ($confirm eq 1){
-
- # Check if the new page filename is blank.
-
- if (!$pagenewfilename){
-
- # The page filename is blank so return an error.
-
- kiriwrite_error("pagefilenameblank");
-
- }
-
- # The action to edit a page has been confirmed so check the
- # variables recieved are UTF8 compiliant before converting.
-
- kiriwrite_variablecheck($database, "utf8", 0, 0);
- kiriwrite_variablecheck($pagefilename, "utf8", 0, 0);
- kiriwrite_variablecheck($pagenewfilename, "utf8", 0, 0);
- kiriwrite_variablecheck($pagenewtitle, "utf8", 0, 0);
- kiriwrite_variablecheck($pagenewdescription, "utf8", 0, 0);
- kiriwrite_variablecheck($pagenewsection, "utf8", 0, 0);
- kiriwrite_variablecheck($pagenewsettings, "utf8", 0, 0);
- kiriwrite_variablecheck($pagenewtemplate, "utf8", 0, 0);
- kiriwrite_variablecheck($pagenewcontent, "utf8", 0, 0);
-
- # Convert the variables into proper UTF8 variables.
-
- $database = kiriwrite_utf8convert($database);
- $pagefilename = kiriwrite_utf8convert($pagefilename);
- $pagenewfilename = kiriwrite_utf8convert($pagenewfilename);
- $pagenewtitle = kiriwrite_utf8convert($pagenewtitle);
- $pagenewdescription = kiriwrite_utf8convert($pagenewdescription);
- $pagenewsection = kiriwrite_utf8convert($pagenewsection);
- $pagenewsettings = kiriwrite_utf8convert($pagenewsettings);
- $pagenewtemplate = kiriwrite_utf8convert($pagenewtemplate);
- $pagenewcontent = kiriwrite_utf8convert($pagenewcontent);
-
- # Check the lengths of the variables.
-
- my $pagenewfilename_maxlength_check = kiriwrite_variablecheck($pagenewfilename, "maxlength", 256, 1);
- my $pagenewtitle_maxlength_check = kiriwrite_variablecheck($pagenewtitle, "maxlength", 512, 1);
- my $pagenewdescription_maxlength_check = kiriwrite_variablecheck($pagenewdescription, "maxlength", 512, 1);
- my $pagenewsection_maxlength_check = kiriwrite_variablecheck($pagenewsection, "maxlength", 256, 1);
- my $pagenewsettings_maxlength_check = kiriwrite_variablecheck($pagenewsettings, "maxlength", 1, 1);
- my $pagenewtemplate_maxlength_check = kiriwrite_variablecheck($pagenewtemplate, "maxlength", 64, 1);
-
- # Check each result to see if the length of the variable
- # is valid and return an error if it isn't.
-
- if ($pagenewfilename_maxlength_check eq 1){
-
- # The new page filename given is too long, so return an error.
-
- kiriwrite_error("pagefilenametoolong");
-
- }
-
- if ($pagenewtitle_maxlength_check eq 1){
-
- # The new page title given is too long, so return an error.
-
- kiriwrite_error("pagetitletoolong");
-
- }
-
- if ($pagenewdescription_maxlength_check eq 1){
-
- # The new page description given is too long, so return an error.
-
- kiriwrite_error("pagedescriptiontoolong");
-
- }
-
- if ($pagenewsection_maxlength_check eq 1){
-
- # The new page section given is too long, so return an error.
-
- kiriwrite_error("pagesectiontoolong");
-
- }
-
- if ($pagenewsettings_maxlength_check eq 1){
-
- # The new page settings given is too long, so return an error.
+ # The new page settings given is too long, so return an error.
kiriwrite_error("pagesettingstoolong");
# Connect to the database server.
- $kiriwrite_dbmodule->connect();
+ $main::kiriwrite_dbmodule->connect();
# Check if any errors occured while connecting to the database server.
- if ($kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
# A database connection error has occured so return
# an error.
- kiriwrite_error("databaseconnectionerror", $kiriwrite_dbmodule->geterror(1));
+ kiriwrite_error("databaseconnectionerror", $main::kiriwrite_dbmodule->geterror(1));
}
# Select the database.
- $kiriwrite_dbmodule->selectdb({ DatabaseName => $database });
+ $main::kiriwrite_dbmodule->selectdb({ DatabaseName => $database });
# Check if any errors had occured while selecting the database.
- if ($kiriwrite_dbmodule->geterror eq "DoesNotExist"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DoesNotExist"){
# The database does not exist, so return an error.
kiriwrite_error("databasemissingfile");
- } elsif ($kiriwrite_dbmodule->geterror eq "InvalidPermissionsSet"){
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "InvalidPermissionsSet"){
# The database has invalid permissions set, so return
# an error.
# Check if the database has write permissions.
- my $database_permissions = $kiriwrite_dbmodule->dbpermissions($database, 1, 1);
+ my $database_permissions = $main::kiriwrite_dbmodule->dbpermissions($database, 1, 1);
if ($database_permissions eq 1){
# Get the database information.
- my %database_info = $kiriwrite_dbmodule->getdatabaseinfo();
+ my %database_info = $main::kiriwrite_dbmodule->getdatabaseinfo();
# Check if any errors had occured while getting the database information.
- if ($kiriwrite_dbmodule->geterror eq "DatabaseError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseError"){
# A database error has occured so return an error and
# also the extended error information.
- kiriwrite_error("databaseerror", $kiriwrite_dbmodule->geterror(1));
+ kiriwrite_error("databaseerror", $main::kiriwrite_dbmodule->geterror(1));
};
# Edit the selected page.
- $kiriwrite_dbmodule->editpage({ PageFilename => $pagefilename, PageNewFilename => $pagenewfilename, PageNewName => $pagenewtitle, PageNewDescription => $pagenewdescription, PageNewSection => $pagenewsection, PageNewTemplate => $pagenewtemplate, PageNewContent => $pagenewcontent, PageNewSettings => $pagenewsettings });
+ $main::kiriwrite_dbmodule->editpage({ PageFilename => $pagefilename, PageNewFilename => $pagenewfilename, PageNewName => $pagenewtitle, PageNewDescription => $pagenewdescription, PageNewSection => $pagenewsection, PageNewTemplate => $pagenewtemplate, PageNewContent => $pagenewcontent, PageNewSettings => $pagenewsettings });
# Check if any errors occured while editing the page.
- if ($kiriwrite_dbmodule->geterror eq "DatabaseError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseError"){
# A database error has occured so return an error and
# also the extended error information.
- kiriwrite_error("databaseerror", $kiriwrite_dbmodule->geterror(1));
+ kiriwrite_error("databaseerror", $main::kiriwrite_dbmodule->geterror(1));
- } elsif ($kiriwrite_dbmodule->geterror eq "PageDoesNotExist"){
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "PageDoesNotExist"){
# The pages does not exist in the database.
kiriwrite_error("pagefilenamedoesnotexist");
- } elsif ($kiriwrite_dbmodule->geterror eq "PageExists"){
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "PageExists"){
# A page already exists with the new filename.
# Disconnect from the database server.
- $kiriwrite_dbmodule->disconnect();
+ $main::kiriwrite_dbmodule->disconnect();
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{pages}->{editedpage}, { Style => "pageheader" });
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext(kiriwrite_language($kiriwrite_lang->{pages}->{editedpagemessage}, $pagenewtitle));
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlink($kiriwrite_env{"script_filename"} . "?mode=page&action=view&database=" . $database, { Text => kiriwrite_language($kiriwrite_lang->{pages}->{returnpagelist}, $database_name) });
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{pages}{editedpage}, { Style => "pageheader" });
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext(kiriwrite_language($main::kiriwrite_lang{pages}{editedpagemessage}, $pagenewtitle));
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{"script_filename"} . "?mode=page&action=view&database=" . $database, { Text => kiriwrite_language($main::kiriwrite_lang{pages}{returnpagelist}, $database_name) });
- return $kiriwrite_presmodule->grab();
+ return $main::kiriwrite_presmodule->grab();
} elsif ($confirm eq 0) {
# Connect to the database server.
- $kiriwrite_dbmodule->connect();
+ $main::kiriwrite_dbmodule->connect();
# Check if any errors occured while connecting to the database server.
- if ($kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
# A database connection error has occured so return
# an error.
- kiriwrite_error("databaseconnectionerror", $kiriwrite_dbmodule->geterror(1));
+ kiriwrite_error("databaseconnectionerror", $main::kiriwrite_dbmodule->geterror(1));
}
# Select the database.
- $kiriwrite_dbmodule->selectdb({ DatabaseName => $database });
+ $main::kiriwrite_dbmodule->selectdb({ DatabaseName => $database });
# Check if any errors had occured while selecting the database.
- if ($kiriwrite_dbmodule->geterror eq "DoesNotExist"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DoesNotExist"){
# The database does not exist, so return an error.
kiriwrite_error("databasemissingfile");
- } elsif ($kiriwrite_dbmodule->geterror eq "InvalidPermissionsSet"){
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "InvalidPermissionsSet"){
# The database has invalid permissions set, so return
# an error.
# Get the information about the database.
- my %database_info = $kiriwrite_dbmodule->getdatabaseinfo();
+ my %database_info = $main::kiriwrite_dbmodule->getdatabaseinfo();
# Check if any errors had occured while getting the database information.
- if ($kiriwrite_dbmodule->geterror eq "DatabaseError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseError"){
# A database error has occured so return an error and
# also the extended error information.
- kiriwrite_error("databaseerror", $kiriwrite_dbmodule->geterror(1));
+ kiriwrite_error("databaseerror", $main::kiriwrite_dbmodule->geterror(1));
};
# Get the page info.
- my %page_info = $kiriwrite_dbmodule->getpageinfo({ PageFilename => $pagefilename });
+ my %page_info = $main::kiriwrite_dbmodule->getpageinfo({ PageFilename => $pagefilename });
# Check if any errors occured while getting the page information.
- if ($kiriwrite_dbmodule->geterror eq "DatabaseError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseError"){
# A database error has occured so return an error and
# also the extended error information.
- kiriwrite_error("databaseerror", $kiriwrite_dbmodule->geterror(1));
+ kiriwrite_error("databaseerror", $main::kiriwrite_dbmodule->geterror(1));
- } elsif ($kiriwrite_dbmodule->geterror eq "PageDoesNotExist"){
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "PageDoesNotExist"){
# The page does not exist, so return an error.
# Connect to the template database.
- $kiriwrite_dbmodule->connecttemplate();
+ $main::kiriwrite_dbmodule->connecttemplate();
# Check if any errors occured while connecting to the template database.
- if ($kiriwrite_dbmodule->geterror eq "TemplateDatabaseDoesNotExist"){
+ if ($main::kiriwrite_dbmodule->geterror eq "TemplateDatabaseDoesNotExist"){
# The template database does not exist so set the template
# warning message.
- $template_warning = $kiriwrite_lang->{pages}->{notemplatedatabasekeep};
+ $template_warning = $main::kiriwrite_lang{pages}{notemplatedatabasekeep};
- } elsif ($kiriwrite_dbmodule->geterror eq "TemplateDatabaseInvalidPermissionsSet"){
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "TemplateDatabaseInvalidPermissionsSet"){
# The template database has invalid permissions set so write
# the template warning message.
- $template_warning = $kiriwrite_lang->{pages}->{templatepermissionserrorkeep};
+ $template_warning = $main::kiriwrite_lang{pages}{templatepermissionserrorkeep};
}
# Get the list of available templates.
- @template_filenames = $kiriwrite_dbmodule->gettemplatelist();
+ @template_filenames = $main::kiriwrite_dbmodule->gettemplatelist();
# Check if any errors had occured.
- if ($kiriwrite_dbmodule->geterror eq "TemplateDatabaseError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "TemplateDatabaseError"){
# A database error occured while getting the list
# of templates so return an error with the
# extended error information.
- $template_warning = kiriwrite_language($kiriwrite_lang->{pages}->{templatedatabaseerrorkeep} , $kiriwrite_dbmodule->geterror(1));
+ $template_warning = kiriwrite_language($main::kiriwrite_lang{pages}{templatedatabaseerrorkeep} , $main::kiriwrite_dbmodule->geterror(1));
}
# Get the information about each template.
- %template_info = $kiriwrite_dbmodule->gettemplateinfo({ TemplateFilename => $template_filename });
+ %template_info = $main::kiriwrite_dbmodule->gettemplateinfo({ TemplateFilename => $template_filename });
# Check if any errors occured while getting the template information.
- if ($kiriwrite_dbmodule->geterror eq "TemplateDatabaseError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "TemplateDatabaseError"){
# A template database error has occured so return a warning message
# with the extended error information.
- $template_warning = kiriwrite_language($kiriwrite_lang->{pages}->{templatedatabaseerrorkeep} , $kiriwrite_dbmodule->geterror(1));
+ $template_warning = kiriwrite_language($main::kiriwrite_lang{pages}{templatedatabaseerrorkeep} , $main::kiriwrite_dbmodule->geterror(1));
last;
- } elsif ($kiriwrite_dbmodule->geterror eq "TemplateDoesNotExist"){
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "TemplateDoesNotExist"){
# The template does not exist so process the next template.
# Begin writing out the form for editing the selected page.
- $kiriwrite_presmodule->addtext(kiriwrite_language($kiriwrite_lang->{pages}->{editpage}, $data_name), { Style => "pageheader" });
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
-
- $kiriwrite_presmodule->startform($kiriwrite_env{"script_filename"}, "POST");
- $kiriwrite_presmodule->startbox();
- $kiriwrite_presmodule->addhiddendata("mode", "page");
- $kiriwrite_presmodule->addhiddendata("action", "edit");
- $kiriwrite_presmodule->addhiddendata("database", $database);
- $kiriwrite_presmodule->addhiddendata("page", $pagefilename);
- $kiriwrite_presmodule->addhiddendata("confirm", 1);
- $kiriwrite_presmodule->endbox();
-
- $kiriwrite_presmodule->starttable("", { CellPadding => 5, CellSpacing => 0 });
-
- $kiriwrite_presmodule->startheader();
- $kiriwrite_presmodule->addheader($kiriwrite_lang->{common}->{setting}, { Style => "tablecellheader" });
- $kiriwrite_presmodule->addheader($kiriwrite_lang->{common}->{value}, { Style => "tablecellheader" });
- $kiriwrite_presmodule->endheader();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{pages}->{database});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addtext($database_name);
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{pages}->{pagename});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addinputbox("pagename", { Size => 64, MaxLength => 512, Value => $data_name });
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{pages}->{pagedescription});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addinputbox("pagedescription", { Size => 64, MaxLength => 512, Value => $data_description });
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{pages}->{pagesection});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addinputbox("pagesection", { Size => 64, MaxLength => 256, Value => $data_section });
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{pages}->{pagetemplate});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addtext(kiriwrite_language($main::kiriwrite_lang{pages}{editpage}, $data_name), { Style => "pageheader" });
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+
+ $main::kiriwrite_presmodule->startform($main::kiriwrite_env{"script_filename"}, "POST");
+ $main::kiriwrite_presmodule->startbox();
+ $main::kiriwrite_presmodule->addhiddendata("mode", "page");
+ $main::kiriwrite_presmodule->addhiddendata("action", "edit");
+ $main::kiriwrite_presmodule->addhiddendata("database", $database);
+ $main::kiriwrite_presmodule->addhiddendata("page", $pagefilename);
+ $main::kiriwrite_presmodule->addhiddendata("confirm", 1);
+ $main::kiriwrite_presmodule->endbox();
+
+ $main::kiriwrite_presmodule->starttable("", { CellPadding => 5, CellSpacing => 0 });
+
+ $main::kiriwrite_presmodule->startheader();
+ $main::kiriwrite_presmodule->addheader($main::kiriwrite_lang{common}{setting}, { Style => "tablecellheader" });
+ $main::kiriwrite_presmodule->addheader($main::kiriwrite_lang{common}{value}, { Style => "tablecellheader" });
+ $main::kiriwrite_presmodule->endheader();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{pages}{database});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addtext($database_name);
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{pages}{pagename});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addinputbox("pagename", { Size => 64, MaxLength => 512, Value => $data_name });
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{pages}{pagedescription});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addinputbox("pagedescription", { Size => 64, MaxLength => 512, Value => $data_description });
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{pages}{pagesection});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addinputbox("pagesection", { Size => 64, MaxLength => 256, Value => $data_section });
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{pages}{pagetemplate});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
# Check if any template warnings have occured.
if ($template_warning){
- $kiriwrite_presmodule->addtext($template_warning);
- $kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($template_warning);
+ $main::kiriwrite_presmodule->addlinebreak();
}
- $kiriwrite_presmodule->addselectbox("pagetemplate");
+ $main::kiriwrite_presmodule->addselectbox("pagetemplate");
# Process the list of templates, select one if the
# template filename for the page matches, else give
if ($template_list{$template_count}{Selected}){
- $kiriwrite_presmodule->addoption($template_list{$template_count}{Name} . " (" . $template_list{$template_count}{Filename} . ")", { Value => $template_list{$template_count}{Filename}, Selected => 1 });
+ $main::kiriwrite_presmodule->addoption($template_list{$template_count}{Name} . " (" . $template_list{$template_count}{Filename} . ")", { Value => $template_list{$template_count}{Filename}, Selected => 1 });
} else {
- $kiriwrite_presmodule->addoption($template_list{$template_count}{Name} . " (" . $template_list{$template_count}{Filename} . ")", { Value => $template_list{$template_count}{Filename} });
+ $main::kiriwrite_presmodule->addoption($template_list{$template_count}{Name} . " (" . $template_list{$template_count}{Filename} . ")", { Value => $template_list{$template_count}{Filename} });
}
if ($data_template eq "!none"){
- $kiriwrite_presmodule->addoption($kiriwrite_lang->{pages}->{usenotemplate}, { Value => "!none", Selected => 1 });
+ $main::kiriwrite_presmodule->addoption($main::kiriwrite_lang{pages}{usenotemplate}, { Value => "!none", Selected => 1 });
$template_found = 1;
} else {
- $kiriwrite_presmodule->addoption($kiriwrite_lang->{pages}->{usenotemplate}, { Value => "!none" });
+ $main::kiriwrite_presmodule->addoption($main::kiriwrite_lang{pages}{usenotemplate}, { Value => "!none" });
}
# The template with the filename given was not found.
- $kiriwrite_presmodule->addoption(kiriwrite_language($kiriwrite_lang->{pages}->{keeptemplatefilename}, $data_template), { Value => $data_template, Selected => 1, Style => "warningoption" });
+ $main::kiriwrite_presmodule->addoption(kiriwrite_language($main::kiriwrite_lang{pages}{keeptemplatefilename}, $data_template), { Value => $data_template, Selected => 1, Style => "warningoption" });
}
# Disconnect from the template database.
- $kiriwrite_dbmodule->disconnecttemplate();
+ $main::kiriwrite_dbmodule->disconnecttemplate();
# Disconnect from the database server.
- $kiriwrite_dbmodule->disconnect();
-
- $kiriwrite_presmodule->endselectbox();
-
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{pages}->{pagefilename});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addinputbox("pagefilename", { Size => 64, MaxLength => 256, Value => $data_filename });
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{pages}->{pagecontent});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addtextbox("pagecontent", { Columns => $kiriwrite_config{"display_textareacols"}, Rows => $kiriwrite_config{"display_textarearows"}, Value => $data_content });
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->startbox("datalist");
- $kiriwrite_presmodule->addboldtext($kiriwrite_lang->{common}->{tags});
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{common}->{pagetitle});
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{common}->{pagename});
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{common}->{pagedescription});
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{common}->{pagesection});
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{common}->{pageautosection});
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{common}->{pageautotitle});
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->endbox();
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{pages}->{pagesettings});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_dbmodule->disconnect();
+
+ $main::kiriwrite_presmodule->endselectbox();
+
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{pages}{pagefilename});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addinputbox("pagefilename", { Size => 64, MaxLength => 256, Value => $data_filename });
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{pages}{pagecontent});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addtextbox("pagecontent", { Columns => $main::kiriwrite_config{"display_textareacols"}, Rows => $main::kiriwrite_config{"display_textarearows"}, Value => $data_content });
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->startbox("datalist");
+ $main::kiriwrite_presmodule->addboldtext($main::kiriwrite_lang{common}{tags});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{common}{pagetitle});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{common}{pagename});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{common}{pagedescription});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{common}{pagesection});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{common}{pageautosection});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{common}{pageautotitle});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->endbox();
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{pages}{pagesettings});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
# Check if the page settings value is set to a
# certain number and select that option based
# on the number else set the value to 0.
if ($data_settings eq 1){
- $kiriwrite_presmodule->addradiobox("pagesettings", { Description => $kiriwrite_lang->{pages}->{usepageandsection}, Value => "1", Selected => 1, LineBreak => 1});
+ $main::kiriwrite_presmodule->addradiobox("pagesettings", { Description => $main::kiriwrite_lang{pages}{usepageandsection}, Value => "1", Selected => 1, LineBreak => 1});
} else {
- $kiriwrite_presmodule->addradiobox("pagesettings", { Description => $kiriwrite_lang->{pages}->{usepageandsection}, Value => "1", LineBreak => 1});
+ $main::kiriwrite_presmodule->addradiobox("pagesettings", { Description => $main::kiriwrite_lang{pages}{usepageandsection}, Value => "1", LineBreak => 1});
}
if ($data_settings eq 2){
- $kiriwrite_presmodule->addradiobox("pagesettings", { Description => $kiriwrite_lang->{pages}->{usepagename}, Value => "2", Selected => 1, LineBreak => 1});
+ $main::kiriwrite_presmodule->addradiobox("pagesettings", { Description => $main::kiriwrite_lang{pages}{usepagename}, Value => "2", Selected => 1, LineBreak => 1});
} else {
- $kiriwrite_presmodule->addradiobox("pagesettings", { Description => $kiriwrite_lang->{pages}->{usepagename}, Value => "2", LineBreak => 1});
+ $main::kiriwrite_presmodule->addradiobox("pagesettings", { Description => $main::kiriwrite_lang{pages}{usepagename}, Value => "2", LineBreak => 1});
}
if ($data_settings eq 3){
- $kiriwrite_presmodule->addradiobox("pagesettings", { Description => $kiriwrite_lang->{pages}->{usesectionname}, Value => "3", Selected => 1, LineBreak => 1});
+ $main::kiriwrite_presmodule->addradiobox("pagesettings", { Description => $main::kiriwrite_lang{pages}{usesectionname}, Value => "3", Selected => 1, LineBreak => 1});
} else {
- $kiriwrite_presmodule->addradiobox("pagesettings", { Description => $kiriwrite_lang->{pages}->{usesectionname}, Value => "3", LineBreak => 1});
+ $main::kiriwrite_presmodule->addradiobox("pagesettings", { Description => $main::kiriwrite_lang{pages}{usesectionname}, Value => "3", LineBreak => 1});
}
if ($data_settings eq 0 || ($data_settings ne 1 && $data_settings ne 2 && $data_settings ne 3)){
- $kiriwrite_presmodule->addradiobox("pagesettings", { Description => $kiriwrite_lang->{pages}->{nopagesection}, Value => "0", Selected => 1, LineBreak => 1});
+ $main::kiriwrite_presmodule->addradiobox("pagesettings", { Description => $main::kiriwrite_lang{pages}{nopagesection}, Value => "0", Selected => 1, LineBreak => 1});
} else {
- $kiriwrite_presmodule->addradiobox("pagesettings", { Description => $kiriwrite_lang->{pages}->{nopagesection}, Value => "0", LineBreak => 1});
+ $main::kiriwrite_presmodule->addradiobox("pagesettings", { Description => $main::kiriwrite_lang{pages}{nopagesection}, Value => "0", LineBreak => 1});
}
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
- $kiriwrite_presmodule->endtable();
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+ $main::kiriwrite_presmodule->endtable();
- $kiriwrite_presmodule->startbox();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addsubmit($kiriwrite_lang->{pages}->{editpagebutton});
- $kiriwrite_presmodule->addtext(" | ");
- $kiriwrite_presmodule->addreset($kiriwrite_lang->{common}->{restorecurrent});
- $kiriwrite_presmodule->addtext(" | ");
- $kiriwrite_presmodule->addlink($kiriwrite_env{"script_filename"} . "?mode=page&action=view&database=" . $database, { Text => kiriwrite_language($kiriwrite_lang->{pages}->{returnpagelist}, $database_name) } );
- $kiriwrite_presmodule->endbox();
+ $main::kiriwrite_presmodule->startbox();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addsubmit($main::kiriwrite_lang{pages}{editpagebutton});
+ $main::kiriwrite_presmodule->addtext(" | ");
+ $main::kiriwrite_presmodule->addreset($main::kiriwrite_lang{common}{restorecurrent});
+ $main::kiriwrite_presmodule->addtext(" | ");
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{"script_filename"} . "?mode=page&action=view&database=" . $database, { Text => kiriwrite_language($main::kiriwrite_lang{pages}{returnpagelist}, $database_name) } );
+ $main::kiriwrite_presmodule->endbox();
- $kiriwrite_presmodule->endform();
+ $main::kiriwrite_presmodule->endform();
- return $kiriwrite_presmodule->grab();
+ return $main::kiriwrite_presmodule->grab();
} else {
}
+sub kiriwrite_page_delete{
+#################################################################################
+# kiriwrite_page_delete: Deletes a (single) page from a database. #
+# #
+# Usage: #
+# #
+# kiriwrite_page_delete(database, page, [confirm]); #
+# #
+# database Specifies the database to delete from. #
+# page Specifies the page to delete. #
+# confirm Confirms the action to delete the page. #
+#################################################################################
+
+ my ($database, $page, $confirm) = @_;
+
+ # Check if the database filename is valid and return an error if
+ # it isn't.
+
+ my $pagedatabase_filename_check = kiriwrite_variablecheck($database, "filename", 0, 1);
+
+ if ($pagedatabase_filename_check eq 1){
+
+ # The database filename is blank, so return an error.
+
+ kiriwrite_error("blankdatabasepageadd");
+
+ } elsif ($pagedatabase_filename_check eq 2){
+
+ # The database filename is invalid, so return an error.
+
+ kiriwrite_error("databasefilenameinvalid");
+
+ }
+
+ # Check the length the database name and return an error if it's
+ # too long.
+
+ my $pagedatabase_length_check = kiriwrite_variablecheck($database, "maxlength", 32, 1);
+
+ if ($pagedatabase_length_check eq 1){
+
+ # The database name is too long, so return an error.
+
+ kiriwrite_error("databasefilenametoolong");
+
+ }
+
+ # Check if the page name is specified is blank and return an error if
+ # it is.
+
+ if (!$page){
+
+ # The page name is blank, so return an error.
+
+ kiriwrite_error("blankfilename");
+
+ }
+
+ # If the confirm value is blank, then set the confirm value to 0.
+
+ if (!$confirm){
+
+ $confirm = 0;
+
+ }
+
+ if ($confirm eq 1){
+
+ # The action to delete the selected page from the database
+ # has been confirmed.
+
+ # Connect to the database server.
+
+ $main::kiriwrite_dbmodule->connect();
+
+ # Check if any errors occured while connecting to the database server.
+
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
+
+ # A database connection error has occured so return
+ # an error.
+
+ kiriwrite_error("databaseconnectionerror", $main::kiriwrite_dbmodule->geterror(1));
+
+ }
+
+ # Select the database to delete the page from.
+
+ $main::kiriwrite_dbmodule->selectdb({ DatabaseName => $database });
+
+ # Check if any errors had occured while selecting the database.
+
+ if ($main::kiriwrite_dbmodule->geterror eq "DoesNotExist"){
+
+ # The database does not exist, so return an error.
+
+ kiriwrite_error("databasemissingfile");
+
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "InvalidPermissionsSet"){
+
+ # The database has invalid permissions set, so return
+ # an error.
+
+ kiriwrite_error("databaseinvalidpermissions");
+
+ }
+
+ # Check if the database has write permissions.
+
+ my $database_permissions = $main::kiriwrite_dbmodule->dbpermissions($database, 1, 1);
+
+ if ($database_permissions eq 1){
+
+ # The database permissions are invalid so return an error.
+
+ kiriwrite_error("databaseinvalidpermissions");
+
+ }
+
+ # Get the information about the database.
+
+ my %database_info = $main::kiriwrite_dbmodule->getdatabaseinfo();
+
+ # Check if any error occured while getting the database information.
+
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseError"){
+
+ # A database error has occured so return an error and
+ # also the extended error information.
+
+ kiriwrite_error("databaseerror", $main::kiriwrite_dbmodule->geterror(1));
+
+ }
+
+ # Get the information about the page that is going to be deleted.
+
+ my %page_info = $main::kiriwrite_dbmodule->getpageinfo({ PageFilename => $page });
+
+ # Check if any errors occured while getting the page information.
+
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseError"){
+
+ # A database error has occured so return an error and
+ # also the extended error information.
+
+ kiriwrite_error("databaseerror", $main::kiriwrite_dbmodule->geterror(1));
+
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "PageDoesNotExist"){
+
+ # The page does not exist, so return an error.
+
+ kiriwrite_error("pagefilenamedoesnotexist");
+
+ }
+
+ # Delete the page from the database.
+
+ $main::kiriwrite_dbmodule->deletepage({ PageFilename => $page });
+
+ # Check if any errors occured while deleting the page from the database.
+
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseError"){
+
+ # A database error has occured so return an error and
+ # also the extended error information.
+
+ kiriwrite_error("databaseerror", $main::kiriwrite_dbmodule->geterror(1));
+
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "PageDoesNotExist"){
+
+ # The page does not exist, so return an error.
+
+ kiriwrite_error("pagefilenamedoesnotexist");
+
+ }
+
+ # Get the database name and page name.
+
+ my $database_name = $database_info{"DatabaseName"};
+ my $page_name = $page_info{"PageName"};
+
+ # Disconnect from the database server.
+
+ $main::kiriwrite_dbmodule->disconnect();
+
+ # Write out a message saying that the selected page from
+ # the database has been deleted.
+
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{pages}{pagedeleted}, { Style => "pageheader" });
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext(kiriwrite_language($main::kiriwrite_lang{pages}{pagedeletedmessage}, $page_name, $database_name));
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{"script_filename"} . "?mode=page&action=view&database=" . $database, { Text => kiriwrite_language($main::kiriwrite_lang{pages}{returnpagelist}, $database_name)});
+
+ return $main::kiriwrite_presmodule->grab();
+
+ } elsif ($confirm eq 0){
+
+ # Connect to the database server.
+
+ $main::kiriwrite_dbmodule->connect();
+
+ # Check if any errors occured while connecting to the database server.
+
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
+
+ # A database connection error has occured so return
+ # an error.
+
+ kiriwrite_error("databaseconnectionerror", $main::kiriwrite_dbmodule->geterror(1));
+
+ }
+
+ # Select the database.
+
+ $main::kiriwrite_dbmodule->selectdb({ DatabaseName => $database });
+
+ # Check if any errors had occured while selecting the database.
+
+ if ($main::kiriwrite_dbmodule->geterror eq "DoesNotExist"){
+
+ # The database does not exist, so return an error.
+
+ kiriwrite_error("databasemissingfile");
+
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "InvalidPermissionsSet"){
+
+ # The database has invalid permissions set, so return
+ # an error.
+
+ kiriwrite_error("databaseinvalidpermissions");
+
+ }
+
+ # Get information about the database.
+
+ my %database_info = $main::kiriwrite_dbmodule->getdatabaseinfo();
+
+ # Check if any errors occured while getting the database information.
+
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseError"){
+
+ # A database error has occured so return an error and
+ # also the extended error information.
+
+ kiriwrite_error("databaseerror", $main::kiriwrite_dbmodule->geterror(1));
+
+ }
+
+ # Get information about the page that is going to be deleted.
+
+ my %page_info = $main::kiriwrite_dbmodule->getpageinfo({ PageFilename => $page });
+
+ # Check if any errors occured while getting the page information.
+
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseError"){
+
+ # A database error has occured so return an error and
+ # also the extended error information.
+
+ kiriwrite_error("databaseerror", $main::kiriwrite_dbmodule->geterror(1));
+
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "PageDoesNotExist"){
+
+ # The page does not exist, so return an error.
+
+ kiriwrite_error("pagefilenamedoesnotexist");
+
+ }
+
+ my $database_name = $database_info{"DatabaseName"};
+ my $page_name = $page_info{"PageName"};
+
+ # Disconnect from the database server.
+
+ $main::kiriwrite_dbmodule->disconnect();
+
+ # Write a message asking the user to confirm the deletion of the
+ # page.
+
+ $main::kiriwrite_presmodule->addtext(kiriwrite_language($main::kiriwrite_lang{pages}{deletepage}, $page_name), { Style => "pageheader" });
+ $main::kiriwrite_presmodule->startform($main::kiriwrite_env{"script_filename"}, "POST");
+ $main::kiriwrite_presmodule->startbox();
+ $main::kiriwrite_presmodule->addhiddendata("mode", "page");
+ $main::kiriwrite_presmodule->addhiddendata("action", "delete");
+ $main::kiriwrite_presmodule->addhiddendata("database", $database);
+ $main::kiriwrite_presmodule->addhiddendata("page", $page);
+ $main::kiriwrite_presmodule->addhiddendata("confirm", "1");
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext(kiriwrite_language($main::kiriwrite_lang{pages}{deletepagemessage}, $page_name, $database_name));
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addsubmit($main::kiriwrite_lang{pages}{deletepagebutton});
+ $main::kiriwrite_presmodule->addtext(" | ");
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{"script_filename"} . "?mode=page&action=view&database=" . $database, { Text => kiriwrite_language($main::kiriwrite_lang{pages}{deletepagesreturnlink}, $database_name)});
+ $main::kiriwrite_presmodule->endbox();
+ $main::kiriwrite_presmodule->endform();
+
+ return $main::kiriwrite_presmodule->grab();
+
+ } else {
+
+ # Another page deletion type was specified, so return an error.
+
+ kiriwrite_error("invalidoption");
+
+ }
+
+}
+
sub kiriwrite_page_multidelete{
#################################################################################
# kiriwrite_page_multidelete: Delete mulitple pages from the database. #
# Connect to the database server.
- $kiriwrite_dbmodule->connect();
+ $main::kiriwrite_dbmodule->connect();
# Check if any errors occured while connecting to the database server.
- if ($kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
# A database connection error has occured so return
# an error.
- kiriwrite_error("databaseconnectionerror", $kiriwrite_dbmodule->geterror(1));
+ kiriwrite_error("databaseconnectionerror", $main::kiriwrite_dbmodule->geterror(1));
}
# Select the database.
- $kiriwrite_dbmodule->selectdb({ DatabaseName => $database });
+ $main::kiriwrite_dbmodule->selectdb({ DatabaseName => $database });
# Check if any errors occured while selecting the database.
- if ($kiriwrite_dbmodule->geterror eq "DoesNotExist"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DoesNotExist"){
# The database does not exist, so return an error.
kiriwrite_error("databasemissingfile");
- } elsif ($kiriwrite_dbmodule->geterror eq "InvalidPermissionsSet"){
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "InvalidPermissionsSet"){
# The database has invalid permissions set, so return
# an error.
# Check if the database has read and write permissions.
- my $database_permissions = $kiriwrite_dbmodule->dbpermissions($database, 1, 1);
+ my $database_permissions = $main::kiriwrite_dbmodule->dbpermissions($database, 1, 1);
if ($database_permissions eq 1){
# Get information about the database.
- my %database_info = $kiriwrite_dbmodule->getdatabaseinfo();
+ my %database_info = $main::kiriwrite_dbmodule->getdatabaseinfo();
# Check if any errors had occured while getting the database
# information.
- if ($kiriwrite_dbmodule->geterror eq "DatabaseError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseError"){
# A database error has occured so return an error and
# also the extended error information.
- kiriwrite_error("databaseerror", $kiriwrite_dbmodule->geterror(1));
+ kiriwrite_error("databaseerror", $main::kiriwrite_dbmodule->geterror(1));
};
# Get the page information.
- %page_info = $kiriwrite_dbmodule->getpageinfo({ PageFilename => $filelist_filename });
+ %page_info = $main::kiriwrite_dbmodule->getpageinfo({ PageFilename => $filelist_filename });
# Check if any errors occured.
- if ($kiriwrite_dbmodule->geterror eq "DatabaseError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseError"){
# A database error has occured so return an error and
# also the extended error information.
- kiriwrite_error("databaseerror", $kiriwrite_dbmodule->geterror(1));
+ kiriwrite_error("databaseerror", $main::kiriwrite_dbmodule->geterror(1));
- } elsif ($kiriwrite_dbmodule->geterror eq "PageDoesNotExist"){
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "PageDoesNotExist"){
# The page does not exist, so process the next page.
# Delete the page.
- $kiriwrite_dbmodule->deletepage({ PageFilename => $filelist_filename });
+ $main::kiriwrite_dbmodule->deletepage({ PageFilename => $filelist_filename });
# Check if any errors occured while deleting the page from the database.
- if ($kiriwrite_dbmodule->geterror eq "DatabaseError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseError"){
# A database error has occured so return an error and
# also the extended error information.
- kiriwrite_error("databaseerror", $kiriwrite_dbmodule->geterror(1));
+ kiriwrite_error("databaseerror", $main::kiriwrite_dbmodule->geterror(1));
- } elsif ($kiriwrite_dbmodule->geterror eq "PageDoesNotExist"){
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "PageDoesNotExist"){
# The page does not exist, so process the next page.
# Disconnect from the database server.
- $kiriwrite_dbmodule->disconnect();
+ $main::kiriwrite_dbmodule->disconnect();
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{pages}->{selectedpagesdeleted}, { Style => "pageheader" });
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext(kiriwrite_language($kiriwrite_lang->{pages}->{selectedpagesdeletedmessage}, $database_name));
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->startbox("datalist");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{pages}{selectedpagesdeleted}, { Style => "pageheader" });
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext(kiriwrite_language($main::kiriwrite_lang{pages}{selectedpagesdeletedmessage}, $database_name));
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->startbox("datalist");
foreach $page (keys %deleted_list){
if (!$deleted_list{$page}{Name}){
- $kiriwrite_presmodule->additalictext($kiriwrite_lang->{blank}->{noname});
- $kiriwrite_presmodule->addtext(" (" . $deleted_list{$page}{Filename} . ")");
+ $main::kiriwrite_presmodule->additalictext($main::kiriwrite_lang{blank}{noname});
+ $main::kiriwrite_presmodule->addtext(" (" . $deleted_list{$page}{Filename} . ")");
} else {
- $kiriwrite_presmodule->addtext($deleted_list{$page}{Name} . " (" . $deleted_list{$page}{Filename} . ")");
+ $main::kiriwrite_presmodule->addtext($deleted_list{$page}{Name} . " (" . $deleted_list{$page}{Filename} . ")");
}
- $kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
}
- $kiriwrite_presmodule->endbox();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlink($kiriwrite_env{"script_filename"} . "?mode=page&action=view&database=" . $database, { Text => kiriwrite_language($kiriwrite_lang->{pages}->{returnpagelist}, $database_name)});
+ $main::kiriwrite_presmodule->endbox();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{"script_filename"} . "?mode=page&action=view&database=" . $database, { Text => kiriwrite_language($main::kiriwrite_lang{pages}{returnpagelist}, $database_name)});
- return $kiriwrite_presmodule->grab();
+ return $main::kiriwrite_presmodule->grab();
} elsif ($confirm eq 0){
# Connect to the database server.
- $kiriwrite_dbmodule->connect();
+ $main::kiriwrite_dbmodule->connect();
# Check if any errors occured while connecting to the database server.
- if ($kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
# A database connection error has occured so return
# an error.
- kiriwrite_error("databaseconnectionerror", $kiriwrite_dbmodule->geterror(1));
+ kiriwrite_error("databaseconnectionerror", $main::kiriwrite_dbmodule->geterror(1));
}
# Select the database.
- $kiriwrite_dbmodule->selectdb({ DatabaseName => $database });
+ $main::kiriwrite_dbmodule->selectdb({ DatabaseName => $database });
# Check if any errors occured while selecting the database.
- if ($kiriwrite_dbmodule->geterror eq "DoesNotExist"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DoesNotExist"){
# The database does not exist, so return an error.
kiriwrite_error("databasemissingfile");
- } elsif ($kiriwrite_dbmodule->geterror eq "InvalidPermissionsSet"){
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "InvalidPermissionsSet"){
# The database has invalid permissions set, so return
# an error.
# Check if the database has read and write permissions.
- my $database_permissions = $kiriwrite_dbmodule->dbpermissions($database, 1, 1);
+ my $database_permissions = $main::kiriwrite_dbmodule->dbpermissions($database, 1, 1);
if ($database_permissions eq 1){
# Get information about the database.
- my %database_info = $kiriwrite_dbmodule->getdatabaseinfo();
+ my %database_info = $main::kiriwrite_dbmodule->getdatabaseinfo();
# Check if any errors had occured while getting the database
# information.
- if ($kiriwrite_dbmodule->geterror eq "DatabaseError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseError"){
# A database error has occured so return an error and
# also the extended error information.
- kiriwrite_error("databaseerror", $kiriwrite_dbmodule->geterror(1));
+ kiriwrite_error("databaseerror", $main::kiriwrite_dbmodule->geterror(1));
};
# Get the page information.
- %page_info = $kiriwrite_dbmodule->getpageinfo({ PageFilename => $filelist_filename });
+ %page_info = $main::kiriwrite_dbmodule->getpageinfo({ PageFilename => $filelist_filename });
# Check if any errors occured.
- if ($kiriwrite_dbmodule->geterror eq "DatabaseError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseError"){
# A database error has occured so return an error and
# also the extended error information.
- kiriwrite_error("databaseerror", $kiriwrite_dbmodule->geterror(1));
+ kiriwrite_error("databaseerror", $main::kiriwrite_dbmodule->geterror(1));
- } elsif ($kiriwrite_dbmodule->geterror eq "PageDoesNotExist"){
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "PageDoesNotExist"){
# The page does not exist, so process the next page.
# Disconnect from the database server.
- $kiriwrite_dbmodule->disconnect();
+ $main::kiriwrite_dbmodule->disconnect();
# Check if any files were selected and return
# an error if there wasn't.
# Write the form for displaying pages.
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{pages}->{deletemultiplepages}, { Style => "pageheader" });
- $kiriwrite_presmodule->startform($kiriwrite_env{"script_filename"}, "POST");
- $kiriwrite_presmodule->startbox();
- $kiriwrite_presmodule->addhiddendata("mode", "page");
- $kiriwrite_presmodule->addhiddendata("action", "multidelete");
- $kiriwrite_presmodule->addhiddendata("database", $database);
- $kiriwrite_presmodule->addhiddendata("confirm", "1");
- $kiriwrite_presmodule->addhiddendata("count", $pageseek);
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{pages}{deletemultiplepages}, { Style => "pageheader" });
+ $main::kiriwrite_presmodule->startform($main::kiriwrite_env{"script_filename"}, "POST");
+ $main::kiriwrite_presmodule->startbox();
+ $main::kiriwrite_presmodule->addhiddendata("mode", "page");
+ $main::kiriwrite_presmodule->addhiddendata("action", "multidelete");
+ $main::kiriwrite_presmodule->addhiddendata("database", $database);
+ $main::kiriwrite_presmodule->addhiddendata("confirm", "1");
+ $main::kiriwrite_presmodule->addhiddendata("count", $pageseek);
$pageseek = 1;
foreach $page (keys %delete_list){
- $kiriwrite_presmodule->addhiddendata("name[" . $pageseek . "]", "on");
- $kiriwrite_presmodule->addhiddendata("id[" . $pageseek . "]", $delete_list{$page}{Filename});
+ $main::kiriwrite_presmodule->addhiddendata("name[" . $pageseek . "]", "on");
+ $main::kiriwrite_presmodule->addhiddendata("id[" . $pageseek . "]", $delete_list{$page}{Filename});
$pageseek++;
}
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext(kiriwrite_language($kiriwrite_lang->{pages}->{deletemultiplemessage}, $database_name));
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->startbox("datalist");
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext(kiriwrite_language($main::kiriwrite_lang{pages}{deletemultiplemessage}, $database_name));
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->startbox("datalist");
foreach $page (keys %delete_list){
if (!$delete_list{$page}{Name}){
- $kiriwrite_presmodule->additalictext($kiriwrite_lang->{blank}->{noname});
- $kiriwrite_presmodule->addtext(" (" . $delete_list{$page}{Filename} . ")");
+ $main::kiriwrite_presmodule->additalictext($main::kiriwrite_lang{blank}{noname});
+ $main::kiriwrite_presmodule->addtext(" (" . $delete_list{$page}{Filename} . ")");
} else {
- $kiriwrite_presmodule->addtext($delete_list{$page}{Name} . " (" . $delete_list{$page}{Filename} . ")");
+ $main::kiriwrite_presmodule->addtext($delete_list{$page}{Name} . " (" . $delete_list{$page}{Filename} . ")");
}
- $kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
}
- $kiriwrite_presmodule->endbox();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addsubmit($kiriwrite_lang->{pages}->{deletepagesbutton});
- $kiriwrite_presmodule->addtext(" | ");
- $kiriwrite_presmodule->addlink($kiriwrite_env{"script_filename"} . "?mode=page&action=view&database=" . $database, { Text => kiriwrite_language($kiriwrite_lang->{pages}->{deletepagesreturnlink}, $database_name)});
- $kiriwrite_presmodule->endbox();
- $kiriwrite_presmodule->endform();
+ $main::kiriwrite_presmodule->endbox();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addsubmit($main::kiriwrite_lang{pages}{deletepagesbutton});
+ $main::kiriwrite_presmodule->addtext(" | ");
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{"script_filename"} . "?mode=page&action=view&database=" . $database, { Text => kiriwrite_language($main::kiriwrite_lang{pages}{deletepagesreturnlink}, $database_name)});
+ $main::kiriwrite_presmodule->endbox();
+ $main::kiriwrite_presmodule->endform();
- return $kiriwrite_presmodule->grab();
+ return $main::kiriwrite_presmodule->grab();
} else {
# Connect to the database server.
- $kiriwrite_dbmodule->connect();
+ $main::kiriwrite_dbmodule->connect();
# Check if any errors occured while connecting to the database server.
- if ($kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
# A database connection error has occured so return
# an error.
- kiriwrite_error("databaseconnectionerror", $kiriwrite_dbmodule->geterror(1));
+ kiriwrite_error("databaseconnectionerror", $main::kiriwrite_dbmodule->geterror(1));
}
# Select the database the pages are going to be moved from.
- $kiriwrite_dbmodule->selectdb({ DatabaseName => $database });
+ $main::kiriwrite_dbmodule->selectdb({ DatabaseName => $database });
# Check if any errors had occured while selecting the database.
- if ($kiriwrite_dbmodule->geterror eq "DoesNotExist"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DoesNotExist"){
# The database does not exist, so return an error.
kiriwrite_error("oldmovedatabasedoesnotexist");
- } elsif ($kiriwrite_dbmodule->geterror eq "InvalidPermissionsSet"){
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "InvalidPermissionsSet"){
# The database has invalid permissions set, so return
# an error.
# Check if the database has read and write permissions.
- my $database_permissions = $kiriwrite_dbmodule->dbpermissions($database, 1, 1);
+ my $database_permissions = $main::kiriwrite_dbmodule->dbpermissions($database, 1, 1);
if ($database_permissions eq 1){
# Select the database the pages are going to be moved to.
- $kiriwrite_dbmodule->selectseconddb({ DatabaseName => $newdatabase });
+ $main::kiriwrite_dbmodule->selectseconddb({ DatabaseName => $newdatabase });
# Check if any errors had occured while selecting the database.
- if ($kiriwrite_dbmodule->geterror eq "DoesNotExist"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DoesNotExist"){
# The database does not exist, so return an error.
kiriwrite_error("newmovedatabasedoesnotexist");
- } elsif ($kiriwrite_dbmodule->geterror eq "InvalidPermissionsSet"){
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "InvalidPermissionsSet"){
# The database has invalid permissions set, so return
# an error.
# Check if the database has read and write permissions.
- $database_permissions = $kiriwrite_dbmodule->dbpermissions($newdatabase, 1, 1);
+ $database_permissions = $main::kiriwrite_dbmodule->dbpermissions($newdatabase, 1, 1);
if ($database_permissions eq 1){
# Get information about the database that the selected pages are moving from.
- my %olddatabase_info = $kiriwrite_dbmodule->getdatabaseinfo();
+ my %olddatabase_info = $main::kiriwrite_dbmodule->getdatabaseinfo();
# Check if any errors had occured while getting the database
# information.
- if ($kiriwrite_dbmodule->geterror eq "DatabaseError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseError"){
# A database error has occured so return an error and
# also the extended error information.
- kiriwrite_error("oldmovedatabasedatabaseerror", $kiriwrite_dbmodule->geterror(1));
+ kiriwrite_error("oldmovedatabasedatabaseerror", $main::kiriwrite_dbmodule->geterror(1));
};
# Get information about the database that the selected pages are moving to.
- my %newdatabase_info = $kiriwrite_dbmodule->getseconddatabaseinfo();
+ my %newdatabase_info = $main::kiriwrite_dbmodule->getseconddatabaseinfo();
# Check if any errors had occured while getting the database
# information.
- if ($kiriwrite_dbmodule->geterror eq "DatabaseError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseError"){
# A database error has occured so return an error and
# also the extended error information.
- kiriwrite_error("newmovedatabasedatabaseerror", $kiriwrite_dbmodule->geterror(1));
+ kiriwrite_error("newmovedatabasedatabaseerror", $main::kiriwrite_dbmodule->geterror(1));
};
# Get the page information.
- %page_info = $kiriwrite_dbmodule->getpageinfo({ PageFilename => $filename });
+ %page_info = $main::kiriwrite_dbmodule->getpageinfo({ PageFilename => $filename });
# Check if any errors occured.
- if ($kiriwrite_dbmodule->geterror eq "DatabaseError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseError"){
# A database error has occured so write a warning message and
# also the extended error information.
- $warning_list{$warning_count}{Message} = kiriwrite_language($kiriwrite_lang->{pages}->{databasepageerror}, $filename, $kiriwrite_dbmodule->geterror(1));
+ $warning_list{$warning_count}{Message} = kiriwrite_language($main::kiriwrite_lang{pages}{databasepageerror}, $filename, $main::kiriwrite_dbmodule->geterror(1));
$warning_count++;
next;
- } elsif ($kiriwrite_dbmodule->geterror eq "PageDoesNotExist"){
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "PageDoesNotExist"){
# The page does not exist, so process the next page.
- $warning_list{$warning_count}{Message} = kiriwrite_language($kiriwrite_lang->{pages}->{pagedoesnotexist}, $filename);
+ $warning_list{$warning_count}{Message} = kiriwrite_language($main::kiriwrite_lang{pages}{pagedoesnotexist}, $filename);
$warning_count++;
next;
# Move the selected page.
- $kiriwrite_dbmodule->movepage({ PageFilename => $filename });
+ $main::kiriwrite_dbmodule->movepage({ PageFilename => $filename });
# Check if any errors occured while moving the page.
- if ($kiriwrite_dbmodule->geterror eq "OldDatabaseError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "OldDatabaseError"){
# A database error has occured while moving the pages from
# the old database, so write a warning message.
- $warning_list{$warning_count}{Message} = kiriwrite_language($kiriwrite_lang->{pages}->{databasemovefrompageerror}, $filename, $kiriwrite_dbmodule->geterror(1));
+ $warning_list{$warning_count}{Message} = kiriwrite_language($main::kiriwrite_lang{pages}{databasemovefrompageerror}, $filename, $main::kiriwrite_dbmodule->geterror(1));
$warning_count++;
next;
- } elsif ($kiriwrite_dbmodule->geterror eq "NewDatabaseError"){
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "NewDatabaseError"){
# A database error has occured while moving the pages to
# the new database, so write a warning message.
- $warning_list{$warning_count}{Message} = kiriwrite_language($kiriwrite_lang->{pages}->{databasemovetopageerror}, $filename, $kiriwrite_dbmodule->geterror(1));
+ $warning_list{$warning_count}{Message} = kiriwrite_language($main::kiriwrite_lang{pages}{databasemovetopageerror}, $filename, $main::kiriwrite_dbmodule->geterror(1));
$warning_count++;
next;
- } elsif ($kiriwrite_dbmodule->geterror eq "PageDoesNotExist"){
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "PageDoesNotExist"){
# The page with the filename given in the database that
# the page is to be moved from doesn't exist so write
# a warning message.
- $warning_list{$warning_count}{Message} = kiriwrite_language($kiriwrite_lang->{pages}->{databasemovefrompagenotexist}, $filename);
+ $warning_list{$warning_count}{Message} = kiriwrite_language($main::kiriwrite_lang{pages}{databasemovefrompagenotexist}, $filename);
$warning_count++;
next;
- } elsif ($kiriwrite_dbmodule->geterror eq "PageAlreadyExists"){
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "PageAlreadyExists"){
# The page with the filename given in the database that
# the page is to be moved to already exists so write a
# warning message.
- $warning_list{$warning_count}{Message} = kiriwrite_language($kiriwrite_lang->{pages}->{databasemovetopageexists}, $filename);
+ $warning_list{$warning_count}{Message} = kiriwrite_language($main::kiriwrite_lang{pages}{databasemovetopageexists}, $filename);
$warning_count++;
next;
# Disconnect from the database server.
- $kiriwrite_dbmodule->disconnect();
+ $main::kiriwrite_dbmodule->disconnect();
# Write out a message saying that the pages were moved (if any)
# to the new database (and any warnings given).
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{pages}->{movepages}, { Style => "pageheader" });
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{pages}{movepages}, { Style => "pageheader" });
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
if (%moved_list){
- $kiriwrite_presmodule->addtext(kiriwrite_language($kiriwrite_lang->{pages}->{movedpagesmessage}, $olddatabase_name, $newdatabase_name));
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext(kiriwrite_language($main::kiriwrite_lang{pages}{movedpagesmessage}, $olddatabase_name, $newdatabase_name));
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->startbox("datalist");
+ $main::kiriwrite_presmodule->startbox("datalist");
foreach $page (keys %moved_list){
if (!$moved_list{$page}{Name}){
- $kiriwrite_presmodule->additalictext($kiriwrite_lang->{blank}->{noname});
- $kiriwrite_presmodule->addtext(" (" . $moved_list{$page}{Filename} . ")");
+ $main::kiriwrite_presmodule->additalictext($main::kiriwrite_lang{blank}{noname});
+ $main::kiriwrite_presmodule->addtext(" (" . $moved_list{$page}{Filename} . ")");
} else {
- $kiriwrite_presmodule->addtext($moved_list{$page}{Name} . " (" . $moved_list{$page}{Filename} . ")");
+ $main::kiriwrite_presmodule->addtext($moved_list{$page}{Name} . " (" . $moved_list{$page}{Filename} . ")");
}
- $kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
}
- $kiriwrite_presmodule->endbox();
+ $main::kiriwrite_presmodule->endbox();
} else {
- $kiriwrite_presmodule->addtext(kiriwrite_language($kiriwrite_lang->{pages}->{nopagesmoved}, $olddatabase_name, $newdatabase_name));
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext(kiriwrite_language($main::kiriwrite_lang{pages}{nopagesmoved}, $olddatabase_name, $newdatabase_name));
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
}
if (%warning_list){
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{pages}->{errormessages});
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->startbox("datalist");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{pages}{errormessages});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->startbox("datalist");
foreach $warning (keys %warning_list){
- $kiriwrite_presmodule->addtext($warning_list{$warning}{Message});
- $kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($warning_list{$warning}{Message});
+ $main::kiriwrite_presmodule->addlinebreak();
}
- $kiriwrite_presmodule->endbox();
+ $main::kiriwrite_presmodule->endbox();
}
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlink($kiriwrite_env{"script_filename"} . "?mode=page&action=view&database=" . $database, { Text => kiriwrite_language($kiriwrite_lang->{pages}->{returnpagelist}, $olddatabase_name)});
- $kiriwrite_presmodule->addtext(" | ");
- $kiriwrite_presmodule->addlink($kiriwrite_env{"script_filename"} . "?mode=page&action=view&database=" . $newdatabase, { Text => kiriwrite_language($kiriwrite_lang->{pages}->{viewpagelist}, $newdatabase_name)});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{"script_filename"} . "?mode=page&action=view&database=" . $database, { Text => kiriwrite_language($main::kiriwrite_lang{pages}{returnpagelist}, $olddatabase_name)});
+ $main::kiriwrite_presmodule->addtext(" | ");
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{"script_filename"} . "?mode=page&action=view&database=" . $newdatabase, { Text => kiriwrite_language($main::kiriwrite_lang{pages}{viewpagelist}, $newdatabase_name)});
- return $kiriwrite_presmodule->grab();
+ return $main::kiriwrite_presmodule->grab();
} elsif ($confirm eq 0) {
# Connect to the database server.
- $kiriwrite_dbmodule->connect();
+ $main::kiriwrite_dbmodule->connect();
# Check if any errors occured while connecting to the database server.
- if ($kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
# A database connection error has occured so return
# an error.
- kiriwrite_error("databaseconnectionerror", $kiriwrite_dbmodule->geterror(1));
+ kiriwrite_error("databaseconnectionerror", $main::kiriwrite_dbmodule->geterror(1));
}
# Select the database.
- $kiriwrite_dbmodule->selectdb({ DatabaseName => $database });
+ $main::kiriwrite_dbmodule->selectdb({ DatabaseName => $database });
# Check if any errors occured while selecting the database.
- if ($kiriwrite_dbmodule->geterror eq "DoesNotExist"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DoesNotExist"){
# The database does not exist, so return an error.
kiriwrite_error("databasemissingfile");
- } elsif ($kiriwrite_dbmodule->geterror eq "InvalidPermissionsSet"){
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "InvalidPermissionsSet"){
# The database has invalid permissions set, so return
# an error.
# Check if the database has read and write permissions.
- my $database_permissions = $kiriwrite_dbmodule->dbpermissions($database, 1, 1);
+ my $database_permissions = $main::kiriwrite_dbmodule->dbpermissions($database, 1, 1);
if ($database_permissions eq 1){
# Get information about the database.
- my %database_info = $kiriwrite_dbmodule->getdatabaseinfo();
+ my %database_info = $main::kiriwrite_dbmodule->getdatabaseinfo();
# Check if any errors had occured while getting the database
# information.
- if ($kiriwrite_dbmodule->geterror eq "DatabaseError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseError"){
# A database error has occured so return an error and
# also the extended error information.
- kiriwrite_error("databaseerror", $kiriwrite_dbmodule->geterror(1));
+ kiriwrite_error("databaseerror", $main::kiriwrite_dbmodule->geterror(1));
};
# Get the page information.
- %page_info = $kiriwrite_dbmodule->getpageinfo({ PageFilename => $filelist_filename });
+ %page_info = $main::kiriwrite_dbmodule->getpageinfo({ PageFilename => $filelist_filename });
# Check if any errors occured.
- if ($kiriwrite_dbmodule->geterror eq "DatabaseError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseError"){
# A database error has occured so return an error and
# also the extended error information.
- kiriwrite_error("databaseerror", $kiriwrite_dbmodule->geterror(1));
+ kiriwrite_error("databaseerror", $main::kiriwrite_dbmodule->geterror(1));
- } elsif ($kiriwrite_dbmodule->geterror eq "PageDoesNotExist"){
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "PageDoesNotExist"){
# The page does not exist, so process the next page.
# Get the list of databases.
- my @database_list = $kiriwrite_dbmodule->getdblist();
+ my @database_list = $main::kiriwrite_dbmodule->getdblist();
# Check if any errors occured while trying to get the list of databases.
- if ($kiriwrite_dbmodule->geterror eq "DataDirMissing"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DataDirMissing"){
# The database directory is missing so return an error.
kiriwrite_error("datadirectorymissing");
- } elsif ($kiriwrite_dbmodule->geterror eq "DataDirInvalidPermissions"){
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "DataDirInvalidPermissions"){
# The database directory has invalid permissions set so return
# an error.
foreach $data_file (@database_list){
- $kiriwrite_dbmodule->selectdb({ DatabaseName => $data_file });
+ $main::kiriwrite_dbmodule->selectdb({ DatabaseName => $data_file });
# Check if any errors occured while selecting the database.
- if ($kiriwrite_dbmodule->geterror eq "DoesNotExist"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DoesNotExist"){
# The database does not exist, so process the next
# database.
next;
- } elsif ($kiriwrite_dbmodule->geterror eq "InvalidPermissionsSet"){
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "InvalidPermissionsSet"){
# The database has invalid permissions set, so process
# the next database.
# Get the database information.
- %database_info = $kiriwrite_dbmodule->getdatabaseinfo();
+ %database_info = $main::kiriwrite_dbmodule->getdatabaseinfo();
# Check if any errors had occured while getting the database
# information.
- if ($kiriwrite_dbmodule->geterror eq "DatabaseError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseError"){
# A database error has occured so process the next
# database.
# Disconnect from the database server.
- $kiriwrite_dbmodule->disconnect();
+ $main::kiriwrite_dbmodule->disconnect();
# Write out the form.
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{pages}->{movepages}, { Style => "pageheader" });
- $kiriwrite_presmodule->startform($kiriwrite_env{"script_filename"}, "POST");
- $kiriwrite_presmodule->startbox();
- $kiriwrite_presmodule->addhiddendata("mode", "page");
- $kiriwrite_presmodule->addhiddendata("action", "multimove");
- $kiriwrite_presmodule->addhiddendata("database", $database);
- $kiriwrite_presmodule->addhiddendata("count", $pageseek);
- $kiriwrite_presmodule->addhiddendata("confirm", "1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{pages}{movepages}, { Style => "pageheader" });
+ $main::kiriwrite_presmodule->startform($main::kiriwrite_env{"script_filename"}, "POST");
+ $main::kiriwrite_presmodule->startbox();
+ $main::kiriwrite_presmodule->addhiddendata("mode", "page");
+ $main::kiriwrite_presmodule->addhiddendata("action", "multimove");
+ $main::kiriwrite_presmodule->addhiddendata("database", $database);
+ $main::kiriwrite_presmodule->addhiddendata("count", $pageseek);
+ $main::kiriwrite_presmodule->addhiddendata("confirm", "1");
# Write the page form data.
$pageseek = 1;
foreach $page (keys %move_list){
- $kiriwrite_presmodule->addhiddendata("name[" . $pageseek . "]", "on");
- $kiriwrite_presmodule->addhiddendata("id[" . $pageseek . "]", $move_list{$page}{Filename});
+ $main::kiriwrite_presmodule->addhiddendata("name[" . $pageseek . "]", "on");
+ $main::kiriwrite_presmodule->addhiddendata("id[" . $pageseek . "]", $move_list{$page}{Filename});
$pageseek++;
}
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext(kiriwrite_language($kiriwrite_lang->{pages}->{movepagesmessage}, $database_name));
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->startbox("datalist");
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext(kiriwrite_language($main::kiriwrite_lang{pages}{movepagesmessage}, $database_name));
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->startbox("datalist");
foreach $page (keys %move_list){
if (!$move_list{$page}{Name}){
- $kiriwrite_presmodule->additalictext($kiriwrite_lang->{blank}->{noname});
- $kiriwrite_presmodule->addtext(" (" . $move_list{$page}{Filename} . ")");
+ $main::kiriwrite_presmodule->additalictext($main::kiriwrite_lang{blank}{noname});
+ $main::kiriwrite_presmodule->addtext(" (" . $move_list{$page}{Filename} . ")");
} else {
- $kiriwrite_presmodule->addtext($move_list{$page}{Name} . " (" . $move_list{$page}{Filename} . ")");
+ $main::kiriwrite_presmodule->addtext($move_list{$page}{Name} . " (" . $move_list{$page}{Filename} . ")");
}
- $kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
}
- $kiriwrite_presmodule->endbox();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{pages}->{movepagesto});
+ $main::kiriwrite_presmodule->endbox();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{pages}{movepagesto});
- $kiriwrite_presmodule->addselectbox("newdatabase");
+ $main::kiriwrite_presmodule->addselectbox("newdatabase");
foreach $db_name (keys %db_list){
- $kiriwrite_presmodule->addoption($db_list{$db_name}{Name} . " (" . $db_list{$db_name}{Filename} . ")", { Value => $db_list{$db_name}{Filename}});
+ $main::kiriwrite_presmodule->addoption($db_list{$db_name}{Name} . " (" . $db_list{$db_name}{Filename} . ")", { Value => $db_list{$db_name}{Filename}});
}
- $kiriwrite_presmodule->endselectbox();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addsubmit($kiriwrite_lang->{pages}->{movepagesbutton});
- $kiriwrite_presmodule->addtext(" | ");
- $kiriwrite_presmodule->addlink($kiriwrite_env{"script_filename"} . "?mode=page&action=view&database=" . $database, { Text => kiriwrite_language($kiriwrite_lang->{pages}->{returnpagelist}, $database_name)});
- $kiriwrite_presmodule->endbox();
- $kiriwrite_presmodule->endform();
+ $main::kiriwrite_presmodule->endselectbox();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addsubmit($main::kiriwrite_lang{pages}{movepagesbutton});
+ $main::kiriwrite_presmodule->addtext(" | ");
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{"script_filename"} . "?mode=page&action=view&database=" . $database, { Text => kiriwrite_language($main::kiriwrite_lang{pages}{returnpagelist}, $database_name)});
+ $main::kiriwrite_presmodule->endbox();
+ $main::kiriwrite_presmodule->endform();
- return $kiriwrite_presmodule->grab();
+ return $main::kiriwrite_presmodule->grab();
} else {
# Connect to the database server.
- $kiriwrite_dbmodule->connect();
+ $main::kiriwrite_dbmodule->connect();
# Check if any errors occured while connecting to the database server.
- if ($kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
# A database connection error has occured so return
# an error.
- kiriwrite_error("databaseconnectionerror", $kiriwrite_dbmodule->geterror(1));
+ kiriwrite_error("databaseconnectionerror", $main::kiriwrite_dbmodule->geterror(1));
}
# Select the database the pages are going to be copied from.
- $kiriwrite_dbmodule->selectdb({ DatabaseName => $database });
+ $main::kiriwrite_dbmodule->selectdb({ DatabaseName => $database });
# Check if any errors had occured while selecting the database.
- if ($kiriwrite_dbmodule->geterror eq "DoesNotExist"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DoesNotExist"){
# The database does not exist, so return an error.
kiriwrite_error("oldcopydatabasedoesnotexist");
- } elsif ($kiriwrite_dbmodule->geterror eq "InvalidPermissionsSet"){
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "InvalidPermissionsSet"){
# The database has invalid permissions set, so return
# an error.
# Select the database the pages are going to be copied to.
- $kiriwrite_dbmodule->selectseconddb({ DatabaseName => $newdatabase });
+ $main::kiriwrite_dbmodule->selectseconddb({ DatabaseName => $newdatabase });
# Check if any errors had occured while selecting the database.
- if ($kiriwrite_dbmodule->geterror eq "DoesNotExist"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DoesNotExist"){
# The database does not exist, so return an error.
kiriwrite_error("newcopydatabasedoesnotexist");
- } elsif ($kiriwrite_dbmodule->geterror eq "InvalidPermissionsSet"){
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "InvalidPermissionsSet"){
# The database has invalid permissions set, so return
# an error.
# Check if the database has read and write permissions.
- my $database_permissions = $kiriwrite_dbmodule->dbpermissions($newdatabase, 1, 1);
+ my $database_permissions = $main::kiriwrite_dbmodule->dbpermissions($newdatabase, 1, 1);
if ($database_permissions eq 1){
# Get information about the database that the selected pages are moving from.
- my %olddatabase_info = $kiriwrite_dbmodule->getdatabaseinfo();
+ my %olddatabase_info = $main::kiriwrite_dbmodule->getdatabaseinfo();
# Check if any errors had occured while getting the database
# information.
- if ($kiriwrite_dbmodule->geterror eq "DatabaseError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseError"){
# A database error has occured so return an error and
# also the extended error information.
- kiriwrite_error("oldcopydatabasedatabaseerror", $kiriwrite_dbmodule->geterror(1));
+ kiriwrite_error("oldcopydatabasedatabaseerror", $main::kiriwrite_dbmodule->geterror(1));
};
# Get information about the database that the selected pages are moving to.
- my %newdatabase_info = $kiriwrite_dbmodule->getseconddatabaseinfo();
+ my %newdatabase_info = $main::kiriwrite_dbmodule->getseconddatabaseinfo();
# Check if any errors had occured while getting the database
# information.
- if ($kiriwrite_dbmodule->geterror eq "DatabaseError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseError"){
# A database error has occured so return an error and
# also the extended error information.
- kiriwrite_error("newcopydatabasedatabaseerror", $kiriwrite_dbmodule->geterror(1));
+ kiriwrite_error("newcopydatabasedatabaseerror", $main::kiriwrite_dbmodule->geterror(1));
};
# Get the page information.
- %page_info = $kiriwrite_dbmodule->getpageinfo({ PageFilename => $filename });
+ %page_info = $main::kiriwrite_dbmodule->getpageinfo({ PageFilename => $filename });
# Check if any errors occured.
- if ($kiriwrite_dbmodule->geterror eq "DatabaseError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseError"){
# A database error has occured so return an error and
# also the extended error information.
- $warning_list{$warning_count}{Message} = kiriwrite_language($kiriwrite_lang->{pages}->{databasepageerror}, $filename, $kiriwrite_dbmodule->geterror(1));
+ $warning_list{$warning_count}{Message} = kiriwrite_language($main::kiriwrite_lang{pages}{databasepageerror}, $filename, $main::kiriwrite_dbmodule->geterror(1));
$warning_count++;
next;
- } elsif ($kiriwrite_dbmodule->geterror eq "PageDoesNotExist"){
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "PageDoesNotExist"){
# The page does not exist, so process the next page.
- $warning_list{$warning_count}{Message} = kiriwrite_language($kiriwrite_lang->{pages}->{databasecopyfrompageerror}, $filename);
+ $warning_list{$warning_count}{Message} = kiriwrite_language($main::kiriwrite_lang{pages}{databasecopyfrompageerror}, $filename);
$warning_count++;
next;
}
- $kiriwrite_dbmodule->copypage({ PageFilename => $filename });
+ $main::kiriwrite_dbmodule->copypage({ PageFilename => $filename });
# Check if any errors occured while copying the page.
- if ($kiriwrite_dbmodule->geterror eq "OldDatabaseError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "OldDatabaseError"){
# A database error has occured while copying the pages from
# the old database, so write a warning message.
- $warning_list{$warning_count}{Message} = kiriwrite_language($kiriwrite_lang->{pages}->{databasecopyfromdatabaseerror}, $filename, $kiriwrite_dbmodule->geterror(1));
+ $warning_list{$warning_count}{Message} = kiriwrite_language($main::kiriwrite_lang{pages}{databasecopyfromdatabaseerror}, $filename, $main::kiriwrite_dbmodule->geterror(1));
$warning_count++;
next;
- } elsif ($kiriwrite_dbmodule->geterror eq "NewDatabaseError"){
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "NewDatabaseError"){
# A database error has occured while copying the pages to
# the new database, so write a warning message.
- $warning_list{$warning_count}{Message} = kiriwrite_language($kiriwrite_lang->{pages}->{databasecopytodatabaseerror}, $filename, $kiriwrite_dbmodule->geterror(1));
+ $warning_list{$warning_count}{Message} = kiriwrite_language($main::kiriwrite_lang{pages}{databasecopytodatabaseerror}, $filename, $main::kiriwrite_dbmodule->geterror(1));
$warning_count++;
next;
- } elsif ($kiriwrite_dbmodule->geterror eq "PageDoesNotExist"){
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "PageDoesNotExist"){
# The page with the filename given in the database that
# the page is to be copied from doesn't exist so write
# a warning message.
- $warning_list{$warning_count}{Message} = kiriwrite_language($kiriwrite_lang->{pages}->{databasecopyfrompagenotexist}, $filename);
+ $warning_list{$warning_count}{Message} = kiriwrite_language($main::kiriwrite_lang{pages}{databasecopyfrompagenotexist}, $filename);
$warning_count++;
next;
- } elsif ($kiriwrite_dbmodule->geterror eq "PageAlreadyExists"){
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "PageAlreadyExists"){
# The page with the filename given in the database that
# the page is to be copied to already exists so write a
# warning message.
- $warning_list{$warning_count}{Message} = kiriwrite_language($kiriwrite_lang->{pages}->{databasecopytopageexists}, $filename);
+ $warning_list{$warning_count}{Message} = kiriwrite_language($main::kiriwrite_lang{pages}{databasecopytopageexists}, $filename);
$warning_count++;
next;
# Disconnect from the database server.
- $kiriwrite_dbmodule->disconnect();
+ $main::kiriwrite_dbmodule->disconnect();
# Write out a message saying that the pages were moved (if any)
# to the new database (and any warnings given).
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{pages}->{copypages}, { Style => "pageheader" });
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{pages}{copypages}, { Style => "pageheader" });
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
if (%copied_list){
- $kiriwrite_presmodule->addtext(kiriwrite_language($kiriwrite_lang->{pages}->{copypagesresultmessage}, $olddatabase_name, $newdatabase_name));
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->startbox("datalist");
+ $main::kiriwrite_presmodule->addtext(kiriwrite_language($main::kiriwrite_lang{pages}{copypagesresultmessage}, $olddatabase_name, $newdatabase_name));
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->startbox("datalist");
foreach $page (keys %copied_list){
if (!$copied_list{$page}{Name}){
- $kiriwrite_presmodule->additalictext($kiriwrite_lang->{blank}->{noname});
- $kiriwrite_presmodule->addtext(" (" . $copied_list{$page}{Filename} . ")");
+ $main::kiriwrite_presmodule->additalictext($main::kiriwrite_lang{blank}{noname});
+ $main::kiriwrite_presmodule->addtext(" (" . $copied_list{$page}{Filename} . ")");
} else {
- $kiriwrite_presmodule->addtext($copied_list{$page}{Name} . " (" . $copied_list{$page}{Filename} . ")");
+ $main::kiriwrite_presmodule->addtext($copied_list{$page}{Name} . " (" . $copied_list{$page}{Filename} . ")");
}
- $kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
}
- $kiriwrite_presmodule->endbox();
+ $main::kiriwrite_presmodule->endbox();
} else {
- $kiriwrite_presmodule->addtext(kiriwrite_language($kiriwrite_lang->{pages}->{nopagescopied}, $olddatabase_name, $newdatabase_name));
+ $main::kiriwrite_presmodule->addtext(kiriwrite_language($main::kiriwrite_lang{pages}{nopagescopied}, $olddatabase_name, $newdatabase_name));
}
if (%warning_list){
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{pages}->{copypageswarnings});
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->startbox("datalist");
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{pages}{copypageswarnings});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->startbox("datalist");
foreach $warning (keys %warning_list){
- $kiriwrite_presmodule->addtext($warning_list{$warning}{Message});
- $kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($warning_list{$warning}{Message});
+ $main::kiriwrite_presmodule->addlinebreak();
}
- $kiriwrite_presmodule->endbox();
+ $main::kiriwrite_presmodule->endbox();
}
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlink($kiriwrite_env{"script_filename"} . "?mode=page&action=view&database=" . $database, { Text => kiriwrite_language($kiriwrite_lang->{pages}->{returnpagelist}, $olddatabase_name)});
- $kiriwrite_presmodule->addtext(" | ");
- $kiriwrite_presmodule->addlink($kiriwrite_env{"script_filename"} . "?mode=page&action=view&database=" . $newdatabase, { Text => kiriwrite_language($kiriwrite_lang->{pages}->{viewpagelist}, $newdatabase_name)});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{"script_filename"} . "?mode=page&action=view&database=" . $database, { Text => kiriwrite_language($main::kiriwrite_lang{pages}{returnpagelist}, $olddatabase_name)});
+ $main::kiriwrite_presmodule->addtext(" | ");
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{"script_filename"} . "?mode=page&action=view&database=" . $newdatabase, { Text => kiriwrite_language($main::kiriwrite_lang{pages}{viewpagelist}, $newdatabase_name)});
- return $kiriwrite_presmodule->grab();
+ return $main::kiriwrite_presmodule->grab();
} elsif ($confirm eq 0) {
# Connect to the database server.
- $kiriwrite_dbmodule->connect();
+ $main::kiriwrite_dbmodule->connect();
# Check if any errors occured while connecting to the database server.
- if ($kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
# A database connection error has occured so return
# an error.
- kiriwrite_error("databaseconnectionerror", $kiriwrite_dbmodule->geterror(1));
+ kiriwrite_error("databaseconnectionerror", $main::kiriwrite_dbmodule->geterror(1));
}
# Select the database to copy the pages from.
- $kiriwrite_dbmodule->selectdb({ DatabaseName => $database });
+ $main::kiriwrite_dbmodule->selectdb({ DatabaseName => $database });
# Check if any errors occured while selecting the database.
- if ($kiriwrite_dbmodule->geterror eq "DoesNotExist"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DoesNotExist"){
# The database does not exist, so return an error.
kiriwrite_error("databasemissingfile");
- } elsif ($kiriwrite_dbmodule->geterror eq "InvalidPermissionsSet"){
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "InvalidPermissionsSet"){
# The database has invalid permissions set, so return
# an error.
# Get information about the database.
- my %database_info = $kiriwrite_dbmodule->getdatabaseinfo();
+ my %database_info = $main::kiriwrite_dbmodule->getdatabaseinfo();
# Check if any errors had occured while getting the database
# information.
- if ($kiriwrite_dbmodule->geterror eq "DatabaseError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseError"){
# A database error has occured so return an error and
# also the extended error information.
- kiriwrite_error("databaseerror", $kiriwrite_dbmodule->geterror(1));
+ kiriwrite_error("databaseerror", $main::kiriwrite_dbmodule->geterror(1));
};
# Get the page information.
- %page_info = $kiriwrite_dbmodule->getpageinfo({ PageFilename => $filename });
+ %page_info = $main::kiriwrite_dbmodule->getpageinfo({ PageFilename => $filename });
# Check if any errors occured.
- if ($kiriwrite_dbmodule->geterror eq "DatabaseError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseError"){
# A database error has occured so return an error and
# also the extended error information.
- kiriwrite_error("databaseerror", $kiriwrite_dbmodule->geterror(1));
+ kiriwrite_error("databaseerror", $main::kiriwrite_dbmodule->geterror(1));
- } elsif ($kiriwrite_dbmodule->geterror eq "PageDoesNotExist"){
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "PageDoesNotExist"){
# The page does not exist, so process the next page.
# Get the database filenames and names.
- my @database_list = $kiriwrite_dbmodule->getdblist();
+ my @database_list = $main::kiriwrite_dbmodule->getdblist();
# Check if any errors occured while trying to get the list of databases.
- if ($kiriwrite_dbmodule->geterror eq "DataDirMissing"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DataDirMissing"){
# The database directory is missing so return an error.
kiriwrite_error("datadirectorymissing");
- } elsif ($kiriwrite_dbmodule->geterror eq "DataDirInvalidPermissions"){
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "DataDirInvalidPermissions"){
# The database directory has invalid permissions set so return
# an error.
foreach $data_file (@database_list){
- $kiriwrite_dbmodule->selectdb({ DatabaseName => $data_file });
+ $main::kiriwrite_dbmodule->selectdb({ DatabaseName => $data_file });
# Check if any errors occured while selecting the database.
- if ($kiriwrite_dbmodule->geterror eq "DoesNotExist"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DoesNotExist"){
# The database does not exist, so process the next
# database.
next;
- } elsif ($kiriwrite_dbmodule->geterror eq "InvalidPermissionsSet"){
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "InvalidPermissionsSet"){
# The database has invalid permissions set, so process
# the next database.
# Get the database information.
- %database_info = $kiriwrite_dbmodule->getdatabaseinfo();
+ %database_info = $main::kiriwrite_dbmodule->getdatabaseinfo();
# Check if any errors had occured while getting the database
# information.
- if ($kiriwrite_dbmodule->geterror eq "DatabaseError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseError"){
# A database error has occured so process the next
# database.
# Disconnect from the database server.
- $kiriwrite_dbmodule->disconnect();
+ $main::kiriwrite_dbmodule->disconnect();
# Write out the form.
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{pages}->{copypages}, { Style => "pageheader" });
- $kiriwrite_presmodule->startform($kiriwrite_env{"script_filename"}, "POST");
- $kiriwrite_presmodule->startbox();
- $kiriwrite_presmodule->addhiddendata("mode", "page");
- $kiriwrite_presmodule->addhiddendata("action", "multicopy");
- $kiriwrite_presmodule->addhiddendata("database", $database);
- $kiriwrite_presmodule->addhiddendata("count", $pageseek);
- $kiriwrite_presmodule->addhiddendata("confirm", 1);
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{pages}{copypages}, { Style => "pageheader" });
+ $main::kiriwrite_presmodule->startform($main::kiriwrite_env{"script_filename"}, "POST");
+ $main::kiriwrite_presmodule->startbox();
+ $main::kiriwrite_presmodule->addhiddendata("mode", "page");
+ $main::kiriwrite_presmodule->addhiddendata("action", "multicopy");
+ $main::kiriwrite_presmodule->addhiddendata("database", $database);
+ $main::kiriwrite_presmodule->addhiddendata("count", $pageseek);
+ $main::kiriwrite_presmodule->addhiddendata("confirm", 1);
$pageseek = 1;
foreach $page (keys %copy_list){
- $kiriwrite_presmodule->addhiddendata("name[" . $pageseek . "]", "on");
- $kiriwrite_presmodule->addhiddendata("id[" . $pageseek . "]", $copy_list{$page}{Filename});
+ $main::kiriwrite_presmodule->addhiddendata("name[" . $pageseek . "]", "on");
+ $main::kiriwrite_presmodule->addhiddendata("id[" . $pageseek . "]", $copy_list{$page}{Filename});
$pageseek++;
}
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext(kiriwrite_language($kiriwrite_lang->{pages}->{copypagesmessage}, $database_name));
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext(kiriwrite_language($main::kiriwrite_lang{pages}{copypagesmessage}, $database_name));
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->startbox("datalist");
+ $main::kiriwrite_presmodule->startbox("datalist");
foreach $page (keys %copy_list){
if (!$copy_list{$page}{Name}){
- $kiriwrite_presmodule->additalictext($kiriwrite_lang->{blank}->{noname});
- $kiriwrite_presmodule->addtext(" (" . $copy_list{$page}{Filename} . ")");
+ $main::kiriwrite_presmodule->additalictext($main::kiriwrite_lang{blank}{noname});
+ $main::kiriwrite_presmodule->addtext(" (" . $copy_list{$page}{Filename} . ")");
} else {
- $kiriwrite_presmodule->addtext($copy_list{$page}{Name} . " (" . $copy_list{$page}{Filename} . ")");
+ $main::kiriwrite_presmodule->addtext($copy_list{$page}{Name} . " (" . $copy_list{$page}{Filename} . ")");
}
- $kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
}
- $kiriwrite_presmodule->endbox();
+ $main::kiriwrite_presmodule->endbox();
- $kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{pages}->{copypagesto});
- $kiriwrite_presmodule->addselectbox("newdatabase");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{pages}{copypagesto});
+ $main::kiriwrite_presmodule->addselectbox("newdatabase");
foreach $dbname (keys %db_list){
- $kiriwrite_presmodule->addoption($db_list{$dbname}{Name} . " (" . $db_list{$dbname}{Filename} . ")", { Value => $db_list{$dbname}{Filename}});
+ $main::kiriwrite_presmodule->addoption($db_list{$dbname}{Name} . " (" . $db_list{$dbname}{Filename} . ")", { Value => $db_list{$dbname}{Filename}});
}
- $kiriwrite_presmodule->endselectbox();
+ $main::kiriwrite_presmodule->endselectbox();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addsubmit($kiriwrite_lang->{pages}->{copypagesbutton});
- $kiriwrite_presmodule->addtext(" | ");
- $kiriwrite_presmodule->addlink($kiriwrite_env{"script_filename"} . "?mode=page&action=view&database=" . $database, { Text => kiriwrite_language($kiriwrite_lang->{pages}->{returnpagelist}, $database_name) });
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addsubmit($main::kiriwrite_lang{pages}{copypagesbutton});
+ $main::kiriwrite_presmodule->addtext(" | ");
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{"script_filename"} . "?mode=page&action=view&database=" . $database, { Text => kiriwrite_language($main::kiriwrite_lang{pages}{returnpagelist}, $database_name) });
- $kiriwrite_presmodule->endbox();
- $kiriwrite_presmodule->endform();
+ $main::kiriwrite_presmodule->endbox();
+ $main::kiriwrite_presmodule->endform();
- return $kiriwrite_presmodule->grab();
+ return $main::kiriwrite_presmodule->grab();
} else {
# Connect to the database server.
- $kiriwrite_dbmodule->connect();
+ $main::kiriwrite_dbmodule->connect();
# Check if any errors occured while connecting to the database server.
- if ($kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
# A database connection error has occured so return
# an error.
- kiriwrite_error("databaseconnectionerror", $kiriwrite_dbmodule->geterror(1));
+ kiriwrite_error("databaseconnectionerror", $main::kiriwrite_dbmodule->geterror(1));
}
# Select the database.
- $kiriwrite_dbmodule->selectdb({ DatabaseName => $database });
+ $main::kiriwrite_dbmodule->selectdb({ DatabaseName => $database });
# Check if any errors occured while selecting the database.
- if ($kiriwrite_dbmodule->geterror eq "DoesNotExist"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DoesNotExist"){
# The database does not exist, so return an error.
kiriwrite_error("databasemissingfile");
- } elsif ($kiriwrite_dbmodule->geterror eq "InvalidPermissionsSet"){
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "InvalidPermissionsSet"){
# The database has invalid permissions set, so return
# an error.
# Check if the database has read and write permissions.
- my $database_permissions = $kiriwrite_dbmodule->dbpermissions($database, 1, 1);
+ my $database_permissions = $main::kiriwrite_dbmodule->dbpermissions($database, 1, 1);
if ($database_permissions eq 1){
# Get information about the database.
- %database_info = $kiriwrite_dbmodule->getdatabaseinfo();
+ %database_info = $main::kiriwrite_dbmodule->getdatabaseinfo();
# Check if any errors had occured while getting the database
# information.
- if ($kiriwrite_dbmodule->geterror eq "DatabaseError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseError"){
# A database error has occured so return an error and
# also the extended error information.
- kiriwrite_error("databaseerror", $kiriwrite_dbmodule->geterror(1));
+ kiriwrite_error("databaseerror", $main::kiriwrite_dbmodule->geterror(1));
};
# Get the page information.
- %page_info = $kiriwrite_dbmodule->getpageinfo({ PageFilename => $filename });
+ %page_info = $main::kiriwrite_dbmodule->getpageinfo({ PageFilename => $filename });
# Check if any errors occured.
- if ($kiriwrite_dbmodule->geterror eq "DatabaseError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseError"){
# A database error has occured so write a warning message.
- $warning_list{$warning_count}{Message} = kiriwrite_language($kiriwrite_lang->{pages}->{databasepageerror}, $filename, $kiriwrite_dbmodule->geterror(1));
+ $warning_list{$warning_count}{Message} = kiriwrite_language($main::kiriwrite_lang{pages}{databasepageerror}, $filename, $main::kiriwrite_dbmodule->geterror(1));
- } elsif ($kiriwrite_dbmodule->geterror eq "PageDoesNotExist"){
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "PageDoesNotExist"){
# The page does not exist, so write a warning message.
- $warning_list{$warning_count}{Message} = kiriwrite_language($kiriwrite_lang->{pages}->{databasepagedoesnotexist}, $filename);
+ $warning_list{$warning_count}{Message} = kiriwrite_language($main::kiriwrite_lang{pages}{databasepagedoesnotexist}, $filename);
$warning_count++;
next;
# Edit the selected page.
- $kiriwrite_dbmodule->editpage({ PageFilename => $page_info{"PageFilename"}, PageNewFilename => $page_info{"PageFilename"}, PageNewName => $page_info{"PageName"}, PageNewDescription => $page_info{"PageDescription"}, PageNewSection => $page_info{"PageSection"}, PageNewTemplate => $page_info{"PageTemplate"}, PageNewContent => $page_info{"PageContent"}, PageNewSettings => $page_info{"PageSettings"} });
+ $main::kiriwrite_dbmodule->editpage({ PageFilename => $page_info{"PageFilename"}, PageNewFilename => $page_info{"PageFilename"}, PageNewName => $page_info{"PageName"}, PageNewDescription => $page_info{"PageDescription"}, PageNewSection => $page_info{"PageSection"}, PageNewTemplate => $page_info{"PageTemplate"}, PageNewContent => $page_info{"PageContent"}, PageNewSettings => $page_info{"PageSettings"} });
# Check if any errors occured while editing the page.
- if ($kiriwrite_dbmodule->geterror eq "DatabaseError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseError"){
# A database error has occured so write a warning message
# with the extended error information.
- $warning_list{$warning_count}{Message} = kiriwrite_language($kiriwrite_lang->{pages}->{databasepageerror}, $filename, $kiriwrite_dbmodule->geterror(1));
+ $warning_list{$warning_count}{Message} = kiriwrite_language($main::kiriwrite_lang{pages}{databasepageerror}, $filename, $main::kiriwrite_dbmodule->geterror(1));
$warning_count++;
next;
- } elsif ($kiriwrite_dbmodule->geterror eq "PageDoesNotExist"){
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "PageDoesNotExist"){
# The pages does not exist in the database.
- $warning_list{$warning_count}{Message} = kiriwrite_language($kiriwrite_lang->{pages}->{databasepagedoesnotexist}, $filename);
+ $warning_list{$warning_count}{Message} = kiriwrite_language($main::kiriwrite_lang{pages}{databasepagedoesnotexist}, $filename);
$warning_count++;
next;
- } elsif ($kiriwrite_dbmodule->geterror eq "PageExists"){
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "PageExists"){
# A page already exists with the new filename.
# Disconnect from the database server.
- $kiriwrite_dbmodule->disconnect();
+ $main::kiriwrite_dbmodule->disconnect();
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{pages}->{multiedit}, { Style => "pageheader" });
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{pages}{multiedit}, { Style => "pageheader" });
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
# Check if the counter of edited pages is 0 and if it is
# then write a message saying that no pages were edited
if ($pageedited eq 0){
- $kiriwrite_presmodule->addtext(kiriwrite_language($kiriwrite_lang->{pages}->{nopagesedited}, $database_name));
+ $main::kiriwrite_presmodule->addtext(kiriwrite_language($main::kiriwrite_lang{pages}{nopagesedited}, $database_name));
} else {
# Write out the message saying that the selected pages
# were edited.
- $kiriwrite_presmodule->addtext(kiriwrite_language($kiriwrite_lang->{pages}->{pagesedited}, $database_name));
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->startbox("datalist");
+ $main::kiriwrite_presmodule->addtext(kiriwrite_language($main::kiriwrite_lang{pages}{pagesedited}, $database_name));
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->startbox("datalist");
foreach $page (keys %edited_list){
if (!$edited_list{$page}{Name}){
- $kiriwrite_presmodule->additalictext($kiriwrite_lang->{blank}->{noname});
- $kiriwrite_presmodule->addtext(" (" . $edited_list{$page}{Filename} . ")");
+ $main::kiriwrite_presmodule->additalictext($main::kiriwrite_lang{blank}{noname});
+ $main::kiriwrite_presmodule->addtext(" (" . $edited_list{$page}{Filename} . ")");
} else {
- $kiriwrite_presmodule->addtext($edited_list{$page}{Name});
- $kiriwrite_presmodule->addtext(" (" . $edited_list{$page}{Filename} . ")");
+ $main::kiriwrite_presmodule->addtext($edited_list{$page}{Name});
+ $main::kiriwrite_presmodule->addtext(" (" . $edited_list{$page}{Filename} . ")");
}
- $kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
}
- $kiriwrite_presmodule->endbox();
+ $main::kiriwrite_presmodule->endbox();
}
# One or several warnings have occured so
# write a message.
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{pages}->{editedpageswarnings});
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->startbox("datalist");
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{pages}{editedpageswarnings});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->startbox("datalist");
foreach $warning (keys %warning_list) {
- $kiriwrite_presmodule->addtext($warning_list{$warning}{Message});
- $kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($warning_list{$warning}{Message});
+ $main::kiriwrite_presmodule->addlinebreak();
}
- $kiriwrite_presmodule->endbox();
+ $main::kiriwrite_presmodule->endbox();
}
# Write a link going back to the page list for
# the selected database.
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlink($kiriwrite_env{"script_filename"} . "?mode=page&action=view&database=" . $database, { Text => kiriwrite_language($kiriwrite_lang->{pages}->{returnpagelist}, $database_name) });
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{"script_filename"} . "?mode=page&action=view&database=" . $database, { Text => kiriwrite_language($main::kiriwrite_lang{pages}{returnpagelist}, $database_name) });
- return $kiriwrite_presmodule->grab();
+ return $main::kiriwrite_presmodule->grab();
} elsif ($confirm eq 0){
# Connect to the database server.
- $kiriwrite_dbmodule->connect();
+ $main::kiriwrite_dbmodule->connect();
# Check if any errors occured while connecting to the database server.
- if ($kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
# A database connection error has occured so return
# an error.
- kiriwrite_error("databaseconnectionerror", $kiriwrite_dbmodule->geterror(1));
+ kiriwrite_error("databaseconnectionerror", $main::kiriwrite_dbmodule->geterror(1));
}
# Select the database.
- $kiriwrite_dbmodule->selectdb({ DatabaseName => $database });
+ $main::kiriwrite_dbmodule->selectdb({ DatabaseName => $database });
# Check if any errors occured while selecting the database.
- if ($kiriwrite_dbmodule->geterror eq "DoesNotExist"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DoesNotExist"){
# The database does not exist, so return an error.
kiriwrite_error("databasemissingfile");
- } elsif ($kiriwrite_dbmodule->geterror eq "InvalidPermissionsSet"){
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "InvalidPermissionsSet"){
# The database has invalid permissions set, so return
# an error.
# Check if the database has read and write permissions.
- my $database_permissions = $kiriwrite_dbmodule->dbpermissions($database, 1, 1);
+ my $database_permissions = $main::kiriwrite_dbmodule->dbpermissions($database, 1, 1);
if ($database_permissions eq 1){
# Get information about the database.
- my %database_info = $kiriwrite_dbmodule->getdatabaseinfo();
+ my %database_info = $main::kiriwrite_dbmodule->getdatabaseinfo();
# Check if any errors had occured while getting the database
# information.
- if ($kiriwrite_dbmodule->geterror eq "DatabaseError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseError"){
# A database error has occured so return an error and
# also the extended error information.
- kiriwrite_error("databaseerror", $kiriwrite_dbmodule->geterror(1));
+ kiriwrite_error("databaseerror", $main::kiriwrite_dbmodule->geterror(1));
};
foreach $filelist_filename (@filelist){
- %page_info = $kiriwrite_dbmodule->getpageinfo({ PageFilename => $filelist_filename });
+ %page_info = $main::kiriwrite_dbmodule->getpageinfo({ PageFilename => $filelist_filename });
# Check if any errors occured.
- if ($kiriwrite_dbmodule->geterror eq "DatabaseError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseError"){
# A database error has occured so return an error and
# also the extended error information.
- kiriwrite_error("databaseerror", $kiriwrite_dbmodule->geterror(1));
+ kiriwrite_error("databaseerror", $main::kiriwrite_dbmodule->geterror(1));
- } elsif ($kiriwrite_dbmodule->geterror eq "PageDoesNotExist"){
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "PageDoesNotExist"){
# The page does not exist, so process the next page.
# Connect to the template database.
- $kiriwrite_dbmodule->connecttemplate();
+ $main::kiriwrite_dbmodule->connecttemplate();
# Check if any errors had occured.
- if ($kiriwrite_dbmodule->geterror eq "TemplateDatabaseDoesNotExist"){
+ if ($main::kiriwrite_dbmodule->geterror eq "TemplateDatabaseDoesNotExist"){
# The template database does not exist so write a warning
# message.
- $template_warning = $kiriwrite_lang->{pages}->{templatedatabasenotexistmultieditkeep};
+ $template_warning = $main::kiriwrite_lang{pages}{templatedatabasenotexistmultieditkeep};
- } elsif ($kiriwrite_dbmodule->geterror eq "TemplateDatabaseInvalidPermissionsSet"){
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "TemplateDatabaseInvalidPermissionsSet"){
# The template database has invalid permissions set so
# return an error.
- $template_warning = $kiriwrite_lang->{pages}->{templatedatabasepermissionsinvalidmultieditkeep};
+ $template_warning = $main::kiriwrite_lang{pages}{templatedatabasepermissionsinvalidmultieditkeep};
}
# Get the list of templates available.
- @templates_list = $kiriwrite_dbmodule->gettemplatelist();
+ @templates_list = $main::kiriwrite_dbmodule->gettemplatelist();
# Check if any errors had occured.
- if ($kiriwrite_dbmodule->geterror eq "TemplateDatabaseError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "TemplateDatabaseError"){
# A database error occured while getting the list
# of templates so write a warning message with the
# extended error information.
- $template_warning = kiriwrite_language($kiriwrite_lang->{pages}->{templatedatabaseerrormultieditkeep}, $kiriwrite_dbmodule->geterror(1));
+ $template_warning = kiriwrite_language($main::kiriwrite_lang{pages}{templatedatabaseerrormultieditkeep}, $main::kiriwrite_dbmodule->geterror(1));
}
# Get the template data.
- %template_info = $kiriwrite_dbmodule->gettemplateinfo({ TemplateFilename => $template_filename });
+ %template_info = $main::kiriwrite_dbmodule->gettemplateinfo({ TemplateFilename => $template_filename });
# Check if any error occured while getting the template information.
- if ($kiriwrite_dbmodule->geterror eq "TemplateDatabaseError"){
+ if ($main::kiriwrite_dbmodule->geterror eq "TemplateDatabaseError"){
# A database error has occured, so write a warning message with
# the extended error information.
- $template_warning = kiriwrite_language($kiriwrite_lang->{pages}->{templatedatabaseerrormultieditkeep}, $kiriwrite_dbmodule->geterror(1));
+ $template_warning = kiriwrite_language($main::kiriwrite_lang{pages}{templatedatabaseerrormultieditkeep}, $main::kiriwrite_dbmodule->geterror(1));
- } elsif ($kiriwrite_dbmodule->geterror eq "TemplateDoesNotExist"){
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "TemplateDoesNotExist"){
# The template does not exist, so process the next page.
# Disconnect from the template database.
- $kiriwrite_dbmodule->disconnecttemplate();
+ $main::kiriwrite_dbmodule->disconnecttemplate();
# Disconnect from the database server.
- $kiriwrite_dbmodule->disconnect();
+ $main::kiriwrite_dbmodule->disconnect();
# Write a form for editing the selected pages.
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{pages}->{multiedit}, { Style => "pageheader" });
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->startform($kiriwrite_env{"script_filename"}, "POST");
- $kiriwrite_presmodule->startbox();
- $kiriwrite_presmodule->addhiddendata("mode", "page");
- $kiriwrite_presmodule->addhiddendata("action", "multiedit");
- $kiriwrite_presmodule->addhiddendata("database", $database);
- $kiriwrite_presmodule->addhiddendata("count", $pageseek);
- $kiriwrite_presmodule->addhiddendata("confirm", 1);
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{pages}{multiedit}, { Style => "pageheader" });
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->startform($main::kiriwrite_env{"script_filename"}, "POST");
+ $main::kiriwrite_presmodule->startbox();
+ $main::kiriwrite_presmodule->addhiddendata("mode", "page");
+ $main::kiriwrite_presmodule->addhiddendata("action", "multiedit");
+ $main::kiriwrite_presmodule->addhiddendata("database", $database);
+ $main::kiriwrite_presmodule->addhiddendata("count", $pageseek);
+ $main::kiriwrite_presmodule->addhiddendata("confirm", 1);
$pageseek = 1;
foreach $page (keys %edit_list){
- $kiriwrite_presmodule->addhiddendata("name[" . $pageseek . "]", "on");
- $kiriwrite_presmodule->addhiddendata("id[" . $pageseek . "]", $edit_list{$page}{Filename});
+ $main::kiriwrite_presmodule->addhiddendata("name[" . $pageseek . "]", "on");
+ $main::kiriwrite_presmodule->addhiddendata("id[" . $pageseek . "]", $edit_list{$page}{Filename});
$pageseek++;
}
- $kiriwrite_presmodule->addtext(kiriwrite_language($kiriwrite_lang->{pages}->{multieditmessage}, $database_name));
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->startbox("datalist");
+ $main::kiriwrite_presmodule->addtext(kiriwrite_language($main::kiriwrite_lang{pages}{multieditmessage}, $database_name));
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->startbox("datalist");
foreach $page (keys %edit_list){
if (!$edit_list{$page}{Name}){
- $kiriwrite_presmodule->additalictext("No Name");
- $kiriwrite_presmodule->addtext(" (" . $edit_list{$page}{Filename} . ")");
+ $main::kiriwrite_presmodule->additalictext($main::kiriwrite_lang{blank}{noname});
+ $main::kiriwrite_presmodule->addtext(" (" . $edit_list{$page}{Filename} . ")");
} else {
- $kiriwrite_presmodule->addtext($edit_list{$page}{Name} . " (" . $edit_list{$page}{Filename} . ")");
+ $main::kiriwrite_presmodule->addtext($edit_list{$page}{Name} . " (" . $edit_list{$page}{Filename} . ")");
}
- $kiriwrite_presmodule->addlinebreak();
- }
-
- $kiriwrite_presmodule->endbox();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{pages}->{multieditmessagevalues});
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->starttable("", { CellPadding => 5, CellSpacing => 0 });
-
- $kiriwrite_presmodule->startheader();
- $kiriwrite_presmodule->addheader($kiriwrite_lang->{common}->{alter}, { Style => "tablecellheader" });
- $kiriwrite_presmodule->addheader($kiriwrite_lang->{common}->{setting}, { Style => "tablecellheader" });
- $kiriwrite_presmodule->addheader($kiriwrite_lang->{common}->{value}, { Style => "tablecellheader" });
- $kiriwrite_presmodule->endheader();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addcheckbox("altersection");
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{pages}->{pagesection});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addinputbox("newsection", { Size => 64, MaxLength => 256 });
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addcheckbox("altertemplate");
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{pages}->{pagetemplate});
- $kiriwrite_presmodule->endcell();
-
- $kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addlinebreak();
+ }
+
+ $main::kiriwrite_presmodule->endbox();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{pages}{multieditmessagevalues});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->starttable("", { CellPadding => 5, CellSpacing => 0 });
+
+ $main::kiriwrite_presmodule->startheader();
+ $main::kiriwrite_presmodule->addheader($main::kiriwrite_lang{common}{alter}, { Style => "tablecellheader" });
+ $main::kiriwrite_presmodule->addheader($main::kiriwrite_lang{common}{setting}, { Style => "tablecellheader" });
+ $main::kiriwrite_presmodule->addheader($main::kiriwrite_lang{common}{value}, { Style => "tablecellheader" });
+ $main::kiriwrite_presmodule->endheader();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addcheckbox("altersection");
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{pages}{pagesection});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addinputbox("newsection", { Size => 64, MaxLength => 256 });
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addcheckbox("altertemplate");
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{pages}{pagetemplate});
+ $main::kiriwrite_presmodule->endcell();
+
+ $main::kiriwrite_presmodule->addcell("tablecell2");
if ($template_warning){
- $kiriwrite_presmodule->addhiddendata("newtemplate", "!skip");
- $kiriwrite_presmodule->addtext($template_warning);
+ $main::kiriwrite_presmodule->addhiddendata("newtemplate", "!skip");
+ $main::kiriwrite_presmodule->addtext($template_warning);
} else {
- $kiriwrite_presmodule->addselectbox("newtemplate");
+ $main::kiriwrite_presmodule->addselectbox("newtemplate");
foreach $template (keys %template_list){
- $kiriwrite_presmodule->addoption($template_list{$template}{Name} . " (" . $template_list{$template}{Filename} . ")", { Value => $template_list{$template}{Filename}});
+ $main::kiriwrite_presmodule->addoption($template_list{$template}{Name} . " (" . $template_list{$template}{Filename} . ")", { Value => $template_list{$template}{Filename}});
}
- $kiriwrite_presmodule->addoption($kiriwrite_lang->{pages}->{usenotemplate}, { Value => "!none", Selected => 1 });
- $kiriwrite_presmodule->endselectbox();
- }
-
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addcheckbox("altersettings");
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{pages}->{pagesettings});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addradiobox("newsettings", { Description => $kiriwrite_lang->{pages}->{usepageandsection}, Value => 1 , Selected => 1});
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addradiobox("newsettings", { Description => $kiriwrite_lang->{pages}->{usepagename}, Value => 2 });
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addradiobox("newsettings", { Description => $kiriwrite_lang->{pages}->{usesectionname}, Value => 3 });
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addradiobox("newsettings", { Description => $kiriwrite_lang->{pages}->{nopagesection}, Value => 0 });
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->endtable();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addsubmit($kiriwrite_lang->{pages}->{editpagesbutton});
- $kiriwrite_presmodule->addtext(" | ");
- $kiriwrite_presmodule->addreset($kiriwrite_lang->{common}->{clearvalues});
- $kiriwrite_presmodule->addtext(" | ");
- $kiriwrite_presmodule->addlink($kiriwrite_env{"script_filename"} . "?mode=page&action=view&database=" . $database, { Text => kiriwrite_language($kiriwrite_lang->{pages}->{returnpagelist}, $database_name) });
- $kiriwrite_presmodule->endbox();
- $kiriwrite_presmodule->endform();
-
- return $kiriwrite_presmodule->grab();
+ $main::kiriwrite_presmodule->addoption($main::kiriwrite_lang{pages}{usenotemplate}, { Value => "!none", Selected => 1 });
+ $main::kiriwrite_presmodule->endselectbox();
+ }
+
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addcheckbox("altersettings");
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{pages}{pagesettings});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addradiobox("newsettings", { Description => $main::kiriwrite_lang{pages}{usepageandsection}, Value => 1 , Selected => 1});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addradiobox("newsettings", { Description => $main::kiriwrite_lang{pages}{usepagename}, Value => 2 });
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addradiobox("newsettings", { Description => $main::kiriwrite_lang{pages}{usesectionname}, Value => 3 });
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addradiobox("newsettings", { Description => $main::kiriwrite_lang{pages}{nopagesection}, Value => 0 });
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->endtable();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addsubmit($main::kiriwrite_lang{pages}{editpagesbutton});
+ $main::kiriwrite_presmodule->addtext(" | ");
+ $main::kiriwrite_presmodule->addreset($main::kiriwrite_lang{common}{clearvalues});
+ $main::kiriwrite_presmodule->addtext(" | ");
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{"script_filename"} . "?mode=page&action=view&database=" . $database, { Text => kiriwrite_language($main::kiriwrite_lang{pages}{returnpagelist}, $database_name) });
+ $main::kiriwrite_presmodule->endbox();
+ $main::kiriwrite_presmodule->endform();
+
+ return $main::kiriwrite_presmodule->grab();
} else {
-#################################################################################
-# settings.lib: Kiriwrite Settings Library #
-# #
-# This library is under the same license as the main Kiriwrite script. #
-#################################################################################
-
-# This section of the file is for when the library is called from the main
-# Kiriwrite script.
-
-# If the action value has been left blank, then view the list of
-# current settings.
-
-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_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, 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");
+package Modules::System::Settings;
- }
-
-}
-
-# No action has been specified, so print out the list of settings currently being used.
+use Modules::System::Common;
+use strict;
+use warnings;
+use Exporter;
-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.
-
-#################################################################################
-# Begin list of relevant subroutines. #
-#################################################################################
+our @ISA = qw(Exporter);
+our @EXPORT = qw(kiriwrite_settings_view kiriwrite_settings_edit kiriwrite_output_config);
sub kiriwrite_settings_view{
#################################################################################
# Get the settings.
- my $settings_directory_db = $kiriwrite_config{"directory_data_db"};
- my $settings_directory_output = $kiriwrite_config{"directory_data_output"};
- my $settings_noncgi_images = $kiriwrite_config{"directory_noncgi_images"};
- my $settings_display_textareacols = $kiriwrite_config{"display_textareacols"};
- my $settings_display_textarearows = $kiriwrite_config{"display_textarearows"};
- my $settings_display_pagecount = $kiriwrite_config{"display_pagecount"};
- my $settings_display_templatecount = $kiriwrite_config{"display_templatecount"};
- my $settings_display_filtercount = $kiriwrite_config{"display_filtercount"};
- my $settings_system_datetime = $kiriwrite_config{"system_datetime"};
- my $settings_system_language = $kiriwrite_config{"system_language"};
- my $settings_system_presentation = $kiriwrite_config{"system_presmodule"};
- my $settings_system_database = $kiriwrite_config{"system_dbmodule"};
-
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{setting}->{viewsettings}, { Style => "pageheader" });
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{setting}->{currentsettings});
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->starttable("", { CellPadding => 5, CellSpacing => 0 });
-
- $kiriwrite_presmodule->startheader();
- $kiriwrite_presmodule->addheader($kiriwrite_lang->{common}->{setting}, { Style => "tablecellheader" });
- $kiriwrite_presmodule->addheader($kiriwrite_lang->{common}->{value}, { Style => "tablecellheader" });
- $kiriwrite_presmodule->endheader();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecellheader");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{setting}->{directories});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecellheader");
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{setting}->{databasedirectory});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addtext($settings_directory_db);
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{setting}->{outputdirectory});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addtext($settings_directory_output);
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{setting}->{imagesuripath});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addtext($settings_noncgi_images);
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecellheader");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{setting}->{display});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecellheader");
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{setting}->{textareacols});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addtext($settings_display_textareacols);
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{setting}->{textarearows});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addtext($settings_display_textarearows);
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{setting}->{pagecount});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addtext($settings_display_pagecount);
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{setting}->{templatecount});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addtext($settings_display_templatecount);
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{setting}->{filtercount});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addtext($settings_display_filtercount);
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecellheader");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{setting}->{date});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecellheader");
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{setting}->{dateformat});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addtext($settings_system_datetime);
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecellheader");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{setting}->{language});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecellheader");
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{setting}->{systemlanguage});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addtext($settings_system_language);
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecellheader");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{setting}->{modules});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecellheader");
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{setting}->{presentationmodule});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addtext($settings_system_presentation);
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{setting}->{databasemodule});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addtext($settings_system_database);
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->endtable();
-
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{setting}->{altersettings});
-
- return $kiriwrite_presmodule->grab();
+ my $settings_directory_db = $main::kiriwrite_config{"directory_data_db"};
+ my $settings_directory_output = $main::kiriwrite_config{"directory_data_output"};
+ my $settings_noncgi_images = $main::kiriwrite_config{"directory_noncgi_images"};
+ my $settings_display_textareacols = $main::kiriwrite_config{"display_textareacols"};
+ my $settings_display_textarearows = $main::kiriwrite_config{"display_textarearows"};
+ my $settings_display_pagecount = $main::kiriwrite_config{"display_pagecount"};
+ my $settings_display_templatecount = $main::kiriwrite_config{"display_templatecount"};
+ my $settings_display_filtercount = $main::kiriwrite_config{"display_filtercount"};
+ my $settings_system_datetime = $main::kiriwrite_config{"system_datetime"};
+ my $settings_system_language = $main::kiriwrite_config{"system_language"};
+ my $settings_system_presentation = $main::kiriwrite_config{"system_presmodule"};
+ my $settings_system_database = $main::kiriwrite_config{"system_dbmodule"};
+
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{viewsettings}, { Style => "pageheader" });
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{currentsettings});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->starttable("", { CellPadding => 5, CellSpacing => 0 });
+
+ $main::kiriwrite_presmodule->startheader();
+ $main::kiriwrite_presmodule->addheader($main::kiriwrite_lang{common}{setting}, { Style => "tablecellheader" });
+ $main::kiriwrite_presmodule->addheader($main::kiriwrite_lang{common}{value}, { Style => "tablecellheader" });
+ $main::kiriwrite_presmodule->endheader();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecellheader");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{directories});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecellheader");
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{databasedirectory});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addtext($settings_directory_db);
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{outputdirectory});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addtext($settings_directory_output);
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{imagesuripath});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addtext($settings_noncgi_images);
+ $main::kiriwrite_presmodule->endcell();
+ $main::main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecellheader");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{display});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecellheader");
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{textareacols});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addtext($settings_display_textareacols);
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{textarearows});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addtext($settings_display_textarearows);
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{pagecount});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addtext($settings_display_pagecount);
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{templatecount});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addtext($settings_display_templatecount);
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{filtercount});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addtext($settings_display_filtercount);
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecellheader");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{date});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecellheader");
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{dateformat});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addtext($settings_system_datetime);
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecellheader");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{language});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecellheader");
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{systemlanguage});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addtext($settings_system_language);
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecellheader");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{modules});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecellheader");
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{presentationmodule});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addtext($settings_system_presentation);
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{databasemodule});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addtext($settings_system_database);
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->endtable();
+
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{altersettings});
+
+ return $main::kiriwrite_presmodule->grab();
}
# The current password in the configuration file should be used.
- $settings_database_password = $kiriwrite_config{"database_password"};
+ $settings_database_password = $main::kiriwrite_config{"database_password"};
}
# Write a confirmation message.
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{setting}->{settingsedited}, { Style => "pageheader" });
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{setting}->{settingseditedmessage});
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlink($kiriwrite_env{"script_filename"} . "?mode=settings", { Text => $kiriwrite_lang->{setting}->{returnsettingslist} });
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{settingsedited}, { Style => "pageheader" });
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{settingseditedmessage});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{"script_filename"} . "?mode=settings", { Text => $main::kiriwrite_lang{setting}{returnsettingslist} });
- return $kiriwrite_presmodule->grab();
+ return $main::kiriwrite_presmodule->grab();
}
my %language_list;
my @language_directory = "";
my $language;
+ my ($language_file, %language_file);
my $language_filename = "";
my $language_file_xml = "";
my $language_file_systemname = "";
my $language_file_count = 0;
my $language_file_char = "";
my $language_file_friendly = "";
- my $language_config = $kiriwrite_config{"system_language"};
+ my $language_config = $main::kiriwrite_config{"system_language"};
+ my @lang_data;
+ my $kiriwrite_languagefilehandle;
tie(%language_list, 'Tie::IxHash');
# Load the language file currently selected.
- $language_file = Config::Auto::parse("lang/" . $kiriwrite_config{"system_language"} . ".lang");
+ open($kiriwrite_languagefilehandle, "lang/" . $main::kiriwrite_config{"system_language"} . ".lang");
+ @lang_data = <$kiriwrite_languagefilehandle>;
+ %language_file = kiriwrite_processconfig(@lang_data);
+ close($kiriwrite_languagefilehandle);
# Get the system name and the local name of the language.
- $language_file_localname = $language_file -> {about} -> {name};
+ $language_file_localname = $language_file{about}{name};
# Check if either the system name or the local name of the language
# is blank and if it is, then don't add the language to the list.
my $presmodule_count = 0;
my $presmodule_friendly = "";
my $presmodule_selectlist = "";
- my $presmodule_config = $kiriwrite_config{"system_presmodule"};
+ my $presmodule_config = $main::kiriwrite_config{"system_presmodule"};
# Open and get the list of presentation modules (perl modules) by filtering
# out the
my $dbmodule_count = 0;
my $dbmodule_friendly = "";
my $dbmodule_selectlist = "";
- my $dbmodule_config = $kiriwrite_config{"system_dbmodule"};
+ my $dbmodule_config = $main::kiriwrite_config{"system_dbmodule"};
# Open and get the list of presentation modules (perl modules) by filtering
# out the
# Get the directory settings.
- my $directory_settings_database = $kiriwrite_config{"directory_data_db"};
- my $directory_settings_output = $kiriwrite_config{"directory_data_output"};
- my $directory_settings_imagesuri = $kiriwrite_config{"directory_noncgi_images"};
- my $datetime_setting = $kiriwrite_config{"system_datetime"};
-
- my $display_textareacols = $kiriwrite_config{"display_textareacols"};
- my $display_textarearows = $kiriwrite_config{"display_textarearows"};
- my $display_pagecount = $kiriwrite_config{"display_pagecount"};
- my $display_templatecount = $kiriwrite_config{"display_templatecount"};
- my $display_filtercount = $kiriwrite_config{"display_filtercount"};
-
- my $database_server = $kiriwrite_config{"database_server"};
- my $database_port = $kiriwrite_config{"database_port"};
- my $database_protocol = $kiriwrite_config{"database_protocol"};
- my $database_sqldatabase = $kiriwrite_config{"database_sqldatabase"};
- my $database_username = $kiriwrite_config{"database_username"};
- my $database_passwordhash = $kiriwrite_config{"database_passwordhash"};
- my $database_password = $kiriwrite_config{"database_password"};
- my $database_prefix = $kiriwrite_config{"database_tableprefix"};
+ my $directory_settings_database = $main::kiriwrite_config{"directory_data_db"};
+ my $directory_settings_output = $main::kiriwrite_config{"directory_data_output"};
+ my $directory_settings_imagesuri = $main::kiriwrite_config{"directory_noncgi_images"};
+ my $datetime_setting = $main::kiriwrite_config{"system_datetime"};
+
+ my $display_textareacols = $main::kiriwrite_config{"display_textareacols"};
+ my $display_textarearows = $main::kiriwrite_config{"display_textarearows"};
+ my $display_pagecount = $main::kiriwrite_config{"display_pagecount"};
+ my $display_templatecount = $main::kiriwrite_config{"display_templatecount"};
+ my $display_filtercount = $main::kiriwrite_config{"display_filtercount"};
+
+ my $database_server = $main::kiriwrite_config{"database_server"};
+ my $database_port = $main::kiriwrite_config{"database_port"};
+ my $database_protocol = $main::kiriwrite_config{"database_protocol"};
+ my $database_sqldatabase = $main::kiriwrite_config{"database_sqldatabase"};
+ my $database_username = $main::kiriwrite_config{"database_username"};
+ my $database_passwordhash = $main::kiriwrite_config{"database_passwordhash"};
+ my $database_password = $main::kiriwrite_config{"database_password"};
+ my $database_prefix = $main::kiriwrite_config{"database_tableprefix"};
# Print out a form for editing the settings.
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{setting}->{editsettings}, { Style => "pageheader" });
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addboldtext($kiriwrite_lang->{setting}->{warning});
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{setting}->{warningmessage});
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
-
- $kiriwrite_presmodule->startform($kiriwrite_env{"script_filename"}, "POST");
- $kiriwrite_presmodule->startbox();
- $kiriwrite_presmodule->addhiddendata("mode", "settings");
- $kiriwrite_presmodule->addhiddendata("action", "edit");
- $kiriwrite_presmodule->addhiddendata("confirm", 1);
-
- $kiriwrite_presmodule->starttable("", { CellPadding => 5, CellSpacing => 0 });
-
- $kiriwrite_presmodule->startheader();
- $kiriwrite_presmodule->addheader($kiriwrite_lang->{common}->{setting}, { Style => "tablecellheader" });
- $kiriwrite_presmodule->addheader($kiriwrite_lang->{common}->{value}, { Style => "tablecellheader" });
- $kiriwrite_presmodule->endheader();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecellheader");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{setting}->{directories});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecellheader");
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{setting}->{databasedirectory});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addinputbox("databasedir", { Size => 32, MaxLength => 64, Value => $directory_settings_database });
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{setting}->{outputdirectory});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addinputbox("outputdir", { Size => 32, MaxLength => 64, Value => $directory_settings_output });
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{setting}->{imagesuripath});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addinputbox("imagesuripath", { Size => 32, MaxLength => 64, Value => $directory_settings_imagesuri });
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecellheader");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{setting}->{display});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecellheader");
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{setting}->{textareacols});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addinputbox("textareacols", { Size => 3, MaxLength => 3, Value => $display_textareacols });
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{setting}->{textarearows});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addinputbox("textarearows", { Size => 3, MaxLength => 3, Value => $display_textarearows });
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{setting}->{pagecount});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addinputbox("pagecount", { Size => 4, MaxLength => 4, Value => $display_pagecount });
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{setting}->{filtercount});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addinputbox("filtercount", { Size => 4, MaxLength => 4, Value => $display_filtercount });
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{setting}->{templatecount});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addinputbox("templatecount", { Size => 4, MaxLength => 4, Value => $display_templatecount });
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecellheader");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{setting}->{date});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecellheader");
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{setting}->{dateformat});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addinputbox("datetime", { Size => 32, MaxLength => 64, Value => $datetime_setting });
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->startbox("datalist");
-
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{setting}->{singleday});
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{setting}->{doubleday});
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{setting}->{singlemonth});
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{setting}->{doublemonth});
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{setting}->{singleyear});
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{setting}->{doubleyear});
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{setting}->{singlehour});
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{setting}->{doublehour});
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{setting}->{singleminute});
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{setting}->{doubleminute});
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{setting}->{singlesecond});
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{setting}->{doublesecond});
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{setting}->{othercharacters});
- $kiriwrite_presmodule->endbox();
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecellheader");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{setting}->{language});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecellheader");
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{setting}->{systemlanguage});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
-
- $kiriwrite_presmodule->addselectbox("language");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{editsettings}, { Style => "pageheader" });
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addboldtext($main::kiriwrite_lang{setting}{warning});
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{warningmessage});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+
+ $main::kiriwrite_presmodule->startform($main::kiriwrite_env{"script_filename"}, "POST");
+ $main::kiriwrite_presmodule->startbox();
+ $main::kiriwrite_presmodule->addhiddendata("mode", "settings");
+ $main::kiriwrite_presmodule->addhiddendata("action", "edit");
+ $main::kiriwrite_presmodule->addhiddendata("confirm", 1);
+
+ $main::kiriwrite_presmodule->starttable("", { CellPadding => 5, CellSpacing => 0 });
+
+ $main::kiriwrite_presmodule->startheader();
+ $main::kiriwrite_presmodule->addheader($main::kiriwrite_lang{common}{setting}, { Style => "tablecellheader" });
+ $main::kiriwrite_presmodule->addheader($main::kiriwrite_lang{common}{value}, { Style => "tablecellheader" });
+ $main::kiriwrite_presmodule->endheader();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecellheader");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{directories});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecellheader");
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{databasedirectory});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addinputbox("databasedir", { Size => 32, MaxLength => 64, Value => $directory_settings_database });
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{outputdirectory});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addinputbox("outputdir", { Size => 32, MaxLength => 64, Value => $directory_settings_output });
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{imagesuripath});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addinputbox("imagesuripath", { Size => 32, MaxLength => 512, Value => $directory_settings_imagesuri });
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecellheader");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{display});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecellheader");
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{textareacols});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addinputbox("textareacols", { Size => 3, MaxLength => 3, Value => $display_textareacols });
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{textarearows});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addinputbox("textarearows", { Size => 3, MaxLength => 3, Value => $display_textarearows });
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{pagecount});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addinputbox("pagecount", { Size => 4, MaxLength => 4, Value => $display_pagecount });
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{filtercount});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addinputbox("filtercount", { Size => 4, MaxLength => 4, Value => $display_filtercount });
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{templatecount});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addinputbox("templatecount", { Size => 4, MaxLength => 4, Value => $display_templatecount });
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecellheader");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{date});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecellheader");
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{dateformat});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addinputbox("datetime", { Size => 32, MaxLength => 64, Value => $datetime_setting });
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->startbox("datalist");
+
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{singleday});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{doubleday});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{singlemonth});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{doublemonth});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{singleyear});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{doubleyear});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{singlehour});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{doublehour});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{singleminute});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{doubleminute});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{singlesecond});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{doublesecond});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{othercharacters});
+ $main::kiriwrite_presmodule->endbox();
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecellheader");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{language});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecellheader");
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{systemlanguage});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+
+ $main::kiriwrite_presmodule->addselectbox("language");
# Process the list of available languages.
if ($language_list{$language}{Filename} eq $language_config){
- $kiriwrite_presmodule->addoption($language_list{$language}{Name}, { Value => $language_list{$language}{Filename} , Selected => 1 });
+ $main::kiriwrite_presmodule->addoption($language_list{$language}{Name}, { Value => $language_list{$language}{Filename} , Selected => 1 });
} else {
- $kiriwrite_presmodule->addoption($language_list{$language}{Name}, { Value => $language_list{$language}{Filename} });
+ $main::kiriwrite_presmodule->addoption($language_list{$language}{Name}, { Value => $language_list{$language}{Filename} });
}
}
- $kiriwrite_presmodule->endselectbox();
+ $main::kiriwrite_presmodule->endselectbox();
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecellheader");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{setting}->{modules});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecellheader");
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecellheader");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{modules});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecellheader");
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{setting}->{presentationmodule});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{presentationmodule});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addselectbox("presmodule");
+ $main::kiriwrite_presmodule->addselectbox("presmodule");
# Process the list of available presentation modules.
if ($presmodule_list{$presmodule}{Filename} eq $presmodule_config){
- $kiriwrite_presmodule->addoption($presmodule_list{$presmodule}{Filename}, { Value => $presmodule_list{$presmodule}{Filename} , Selected => 1 });
+ $main::kiriwrite_presmodule->addoption($presmodule_list{$presmodule}{Filename}, { Value => $presmodule_list{$presmodule}{Filename} , Selected => 1 });
} else {
- $kiriwrite_presmodule->addoption($presmodule_list{$presmodule}{Filename}, { Value => $presmodule_list{$presmodule}{Filename} });
+ $main::kiriwrite_presmodule->addoption($presmodule_list{$presmodule}{Filename}, { Value => $presmodule_list{$presmodule}{Filename} });
}
}
- $kiriwrite_presmodule->endselectbox();
+ $main::kiriwrite_presmodule->endselectbox();
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{setting}->{databasemodule});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{databasemodule});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
# Process the list of available database modules.
- $kiriwrite_presmodule->addselectbox("dbmodule");
+ $main::kiriwrite_presmodule->addselectbox("dbmodule");
foreach $dbmodule (keys %dbmodule_list){
if ($dbmodule_list{$dbmodule}{Filename} eq $dbmodule_config){
- $kiriwrite_presmodule->addoption($dbmodule_list{$dbmodule}{Filename}, { Value => $dbmodule_list{$dbmodule}{Filename} , Selected => 1 });
+ $main::kiriwrite_presmodule->addoption($dbmodule_list{$dbmodule}{Filename}, { Value => $dbmodule_list{$dbmodule}{Filename} , Selected => 1 });
} else {
- $kiriwrite_presmodule->addoption($dbmodule_list{$dbmodule}{Filename}, { Value => $dbmodule_list{$dbmodule}{Filename} });
+ $main::kiriwrite_presmodule->addoption($dbmodule_list{$dbmodule}{Filename}, { Value => $dbmodule_list{$dbmodule}{Filename} });
}
}
- $kiriwrite_presmodule->endselectbox();
-
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{setting}->{databaseserver});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addinputbox("database_server", { Size => 32, MaxLength => 128, Value => $database_server });
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{setting}->{databaseport});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addinputbox("database_port", { Size => 5, MaxLength => 5, Value => $database_port });
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{setting}->{databaseprotocol});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->endselectbox();
+
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{databaseserver});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addinputbox("database_server", { Size => 32, MaxLength => 128, Value => $database_server });
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{databaseport});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addinputbox("database_port", { Size => 5, MaxLength => 5, Value => $database_port });
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{databaseprotocol});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
# Check if TCP is being used.
- $kiriwrite_presmodule->addselectbox("database_protocol");
+ $main::kiriwrite_presmodule->addselectbox("database_protocol");
if ($database_protocol eq "tcp"){
# The TCP protocol is selected so have the TCP option selected.
- $kiriwrite_presmodule->addoption("TCP", { Value => "tcp", Selected => 1});
+ $main::kiriwrite_presmodule->addoption("TCP", { Value => "tcp", Selected => 1});
} else {
# The TCP protocol is not selected.
- $kiriwrite_presmodule->addoption("TCP", { Value => "tcp"});
+ $main::kiriwrite_presmodule->addoption("TCP", { Value => "tcp"});
}
# The UDP protocol is selected so have the UDP option selected.
- $kiriwrite_presmodule->addoption("UDP", { Value => "udp", Selected => 1});
+ $main::kiriwrite_presmodule->addoption("UDP", { Value => "udp", Selected => 1});
} else {
# The UDP protocol is not selected.
- $kiriwrite_presmodule->addoption("UDP", { Value => "udp"});
+ $main::kiriwrite_presmodule->addoption("UDP", { Value => "udp"});
}
- $kiriwrite_presmodule->endselectbox();
-
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{setting}->{databasename});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addinputbox("database_sqldatabase", { Size => 32, MaxLength => 32, Value => $database_sqldatabase });
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{setting}->{databaseusername});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addinputbox("database_username", { Size => 16, MaxLength => 16, Value => $database_username });
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{setting}->{databasepassword});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addinputbox("database_password", { Size => 16, MaxLength => 64, Password => 1 });
- $kiriwrite_presmodule->addtext(" ");
- $kiriwrite_presmodule->addcheckbox("database_password_keep", { OptionDescription => "Keep the current password", Checked => 1 });
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{setting}->{tableprefix});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addinputbox("database_tableprefix", { Size => 16, MaxLength => 16, Value => $database_prefix });
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->endtable();
-
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addsubmit($kiriwrite_lang->{setting}->{changesettingsbutton});
- $kiriwrite_presmodule->addtext(" | ");
- $kiriwrite_presmodule->addreset($kiriwrite_lang->{common}->{restorecurrent});
- $kiriwrite_presmodule->addtext(" | ");
- $kiriwrite_presmodule->addlink($kiriwrite_env{"script_filename"} . "?mode=settings", { Text => $kiriwrite_lang->{setting}->{returnsettingslist} });
- $kiriwrite_presmodule->endbox();
- $kiriwrite_presmodule->endform();
-
- return $kiriwrite_presmodule->grab();
+ $main::kiriwrite_presmodule->endselectbox();
+
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{databasename});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addinputbox("database_sqldatabase", { Size => 32, MaxLength => 32, Value => $database_sqldatabase });
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{databaseusername});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addinputbox("database_username", { Size => 16, MaxLength => 16, Value => $database_username });
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{databasepassword});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addinputbox("database_password", { Size => 16, MaxLength => 64, Password => 1 });
+ $main::kiriwrite_presmodule->addtext(" ");
+ $main::kiriwrite_presmodule->addcheckbox("database_password_keep", { OptionDescription => "Keep the current password", Checked => 1 });
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{setting}{tableprefix});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addinputbox("database_tableprefix", { Size => 16, MaxLength => 16, Value => $database_prefix });
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->endtable();
+
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addsubmit($main::kiriwrite_lang{setting}{changesettingsbutton});
+ $main::kiriwrite_presmodule->addtext(" | ");
+ $main::kiriwrite_presmodule->addreset($main::kiriwrite_lang{common}{restorecurrent});
+ $main::kiriwrite_presmodule->addtext(" | ");
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{"script_filename"} . "?mode=settings", { Text => $main::kiriwrite_lang{setting}->{returnsettingslist} });
+ $main::kiriwrite_presmodule->endbox();
+ $main::kiriwrite_presmodule->endform();
+
+ return $main::kiriwrite_presmodule->grab();
}
$settings_imagesuri =~ s/</</g;
$settings_imagesuri =~ s/>/>/g;
+ $settings_imagesuri =~ s/\r//g;
+ $settings_imagesuri =~ s/\n//g;
}
--- /dev/null
+package Modules::System::Template;
+
+use Modules::System::Common;
+use strict;
+use warnings;
+use Exporter;
+
+our @ISA = qw(Exporter);
+our @EXPORT = qw(kiriwrite_template_list kiriwrite_template_add kiriwrite_template_edit kiriwrite_template_delete);
+
+sub kiriwrite_template_add{
+#################################################################################
+# kiriwrite_template_add: Add a template to the template folder #
+# #
+# Usage: #
+# #
+# kiriwrite_template_add(filename, name, description, layout, confirm); #
+# #
+# filename The filename of the new template. #
+# name The name of the template. #
+# description The description of the template. #
+# layout The layout of the new template. #
+# confirm Confirm the action of creating a new template. #
+#################################################################################
+
+ # Get the variables that were passed to the subroutine.
+
+ my ($templatefilename, $templatename, $templatedescription, $templatelayout, $confirm) = @_;
+
+ # Check if the confirm value is blank and if it is then set confirm to 0.
+
+ if (!$confirm){
+
+ # The confirm value is blank, so set the value of confirm to 0.
+
+ $confirm = 0;
+
+ }
+
+ if ($confirm eq 1){
+
+ # Check (validate) each of the values.
+
+ kiriwrite_variablecheck($templatename, "utf8", 0, 0);
+ kiriwrite_variablecheck($templatedescription, "utf8", 0, 0);
+ kiriwrite_variablecheck($templatelayout, "utf8", 0, 0);
+
+ # Convert the values into proper UTF8 strings that can be used.
+
+ $templatename = kiriwrite_utf8convert($templatename);
+ $templatedescription = kiriwrite_utf8convert($templatedescription);
+ $templatelayout = kiriwrite_utf8convert($templatelayout);
+
+ # Check the length of the converted UTF8 strings.
+
+ my $templatefilename_length_check = kiriwrite_variablecheck($templatefilename, "maxlength", 64, 1);
+ my $templatename_length_check = kiriwrite_variablecheck($templatename, "maxlength", 512, 1);
+ my $templatedescription_length_check = kiriwrite_variablecheck($templatedescription, "maxlength", 512, 1);
+ kiriwrite_variablecheck($confirm, "maxlength", 1, 0);
+
+ if ($templatefilename_length_check eq 1){
+
+ # The template filename length is too long, so return an error.
+
+ kiriwrite_error("templatefilenametoolong");
+
+ }
+
+ if ($templatename_length_check eq 1){
+
+ # The template name length is too long, so return an error.
+
+ kiriwrite_error("templatenametoolong");
+
+ }
+
+
+ if ($templatedescription_length_check eq 1){
+
+ # The template description length is too long, so return an error.
+
+ kiriwrite_error("templatedescriptiontoolong");
+
+ }
+
+ # Check if the filename specified is a valid filename.
+
+ kiriwrite_variablecheck($templatefilename, "filename", "", 0);
+
+ # Connect to the template server.
+
+ $main::kiriwrite_dbmodule->connect();
+
+ # Connect to the template database.
+
+ $main::kiriwrite_dbmodule->connecttemplate(1);
+
+ # Check if any errors had occured.
+
+ if ($main::kiriwrite_dbmodule->geterror eq "TemplateDatabaseInvalidPermissionsSet"){
+
+ # The template database has invalid permissions set so
+ # return an error.
+
+ kiriwrite_error("templatedatabaseinvalidpermissions");
+
+ }
+
+ $main::kiriwrite_dbmodule->addtemplate({ TemplateFilename => $templatefilename, TemplateName => $templatename, TemplateDescription => $templatedescription, TemplateLayout => $templatelayout });
+
+ if ($main::kiriwrite_dbmodule->geterror eq "TemplateDatabaseError"){
+
+ # A database error has occured so return an error along
+ # with the extended error information.
+
+ kiriwrite_error("templatedatabaseerror", $main::kiriwrite_dbmodule->geterror(1));
+
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "TemplateDatabaseInvalidPermissionsSet"){
+
+ # The template database has invalid permissions set so return
+ # an error.
+
+ kiriwrite_error("templatedatabaseinvalidpermissions");
+
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "TemplatePageExists"){
+
+ # The template page already exists so return an error.
+
+ kiriwrite_error("templatefilenameexists");
+
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "TemplateDatabaseUncreateable"){
+
+ # The template databases is uncreatable so return an error.
+
+ kiriwrite_error("templatedatabasenotcreated");
+
+ }
+
+ $main::kiriwrite_dbmodule->disconnecttemplate();
+
+ # Disconnect from the template server.
+
+ $main::kiriwrite_dbmodule->disconnect();
+
+ # Print out the confirmation message.
+
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{template}{addedtemplate}, { Style => "pageheader" });
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext(kiriwrite_language($main::kiriwrite_lang{template}{addedtemplatemessage}, $templatename));
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{"script_filename"} . "?mode=template", { Text => $main::kiriwrite_lang{template}{returntemplatelist} });
+ return $main::kiriwrite_presmodule->grab();
+
+ } else {
+ # No confirmation was made, so print out a form for adding a template.
+
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{template}{addtemplate}, { Style => "pageheader" });
+ $main::kiriwrite_presmodule->startform($main::kiriwrite_env{"script_filename"}, "POST");
+ $main::kiriwrite_presmodule->startbox();
+ $main::kiriwrite_presmodule->addhiddendata("mode", "template");
+ $main::kiriwrite_presmodule->addhiddendata("action", "add");
+ $main::kiriwrite_presmodule->addhiddendata("confirm", 1);
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->starttable("", { CellSpacing => 0, CellPadding => 5 });
+
+ $main::kiriwrite_presmodule->startheader();
+ $main::kiriwrite_presmodule->addheader($main::kiriwrite_lang{common}{setting}, { Style => "tablecellheader" });
+ $main::kiriwrite_presmodule->addheader($main::kiriwrite_lang{common}{value}, { Style => "tablecellheader" });
+ $main::kiriwrite_presmodule->endheader();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{template}{templatename});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addinputbox("templatename", { Size => 64, MaxLength => 512 });
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{template}{templatedescription});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addinputbox("templatedescription", { Size => 64, MaxLength => 512 });
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{template}{templatefilename});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addinputbox("templatefilename", { Size => 32, MaxLength => 64 });
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{template}{templatelayout});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addtextbox("templatelayout", { Columns => $main::kiriwrite_config{"display_textareacols"}, Rows => $main::kiriwrite_config{"display_textarearows"} });
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->startbox("datalist");
+ $main::kiriwrite_presmodule->addboldtext($main::kiriwrite_lang{common}{tags});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{common}{pagecontent});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{common}{pagetitle});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{common}{pagename});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{common}{pagedescription});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{common}{pagesection});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{common}{pageautosection});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{common}{pageautotitle});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->endbox();
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+ $main::kiriwrite_presmodule->endtable();
+
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addsubmit($main::kiriwrite_lang{template}{addtemplatebutton});
+ $main::kiriwrite_presmodule->addtext(" | ");
+ $main::kiriwrite_presmodule->addreset($main::kiriwrite_lang{common}{clearvalues});
+ $main::kiriwrite_presmodule->addtext(" | ");
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{"script_filename"} . "?mode=template" , { Text => $main::kiriwrite_lang{template}{returntemplatelist} });
+
+ $main::kiriwrite_presmodule->endbox();
+ $main::kiriwrite_presmodule->endform();
+
+ return $main::kiriwrite_presmodule->grab();
+
+ }
+
+
+}
+
+sub kiriwrite_template_edit{
+#################################################################################
+# kiriwrite_template_edit: Edit a template from the template folder. #
+# #
+# Usage: #
+# #
+# kiriwrite_template_edit(filename, [newfilename], [newname], [newdescription], #
+# [templatelayout], [confirm]); #
+# #
+# filename The current filename of the template to edit. #
+# newfilename The new filename of the template to edit. #
+# newname The new name of the template being edited. #
+# newdescription The new description of the template being edited. #
+# templatelayout The modified/altered template layout. #
+# confirm Confirms the action to edit a template and its #
+# settings. #
+#################################################################################
+
+ # Get all the variables that have been passed to the subroutine.
+
+ my ($templatefilename, $templatenewfilename, $templatenewname, $templatenewdescription, $templatelayout, $confirm) = @_;
+
+ # Check if the confirm variable is blank, if it is then
+ # set confirm to '0'
+
+ if (!$confirm){
+
+ # confirm is uninitalised/blank, so set the value of confirm
+ # to '0'
+
+ $confirm = 0;
+
+ }
+
+ # Check if the template filename is blank and if it is, then return
+ # an error.
+
+ if (!$templatefilename){
+
+ kiriwrite_error("templatefilenameblank");
+
+ }
+
+ # Connect to the database server.
+
+ $main::kiriwrite_dbmodule->connect();
+
+ # Check if any errors occured while connecting to the database server.
+
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
+
+ # A database connection error has occured so return
+ # an error.
+
+ kiriwrite_error("databaseconnectionerror", $main::kiriwrite_dbmodule->geterror(1));
+
+ }
+
+ if ($confirm eq 1){
+
+ # Check certain strings to see if they UTF8 compiliant.
+
+ kiriwrite_variablecheck($templatenewname, "utf8", 0, 0);
+ kiriwrite_variablecheck($templatenewdescription, "utf8", 0, 0);
+ kiriwrite_variablecheck($templatelayout, "utf8", 0, 0);
+
+ # Convert the values into proper UTF8 strings.
+
+ $templatenewname = kiriwrite_utf8convert($templatenewname);
+ $templatenewdescription = kiriwrite_utf8convert($templatenewdescription);
+ $templatelayout = kiriwrite_utf8convert($templatelayout);
+
+ # Check if the filenames recieved are valid filenames.
+
+ kiriwrite_variablecheck($templatenewfilename, "maxlength", 64, 0);
+ kiriwrite_variablecheck($templatenewdescription, "maxlength", 512, 0);
+ kiriwrite_variablecheck($templatenewname, "maxlength", 512, 0);
+ kiriwrite_variablecheck($templatefilename, "maxlength", 64, 0);
+ kiriwrite_variablecheck($confirm, "maxlength", 1, 0);
+
+ kiriwrite_variablecheck($templatefilename, "filename", "", 0);
+ kiriwrite_variablecheck($templatenewfilename, "filename", "", 0);
+
+ # Connect to the template database.
+
+ $main::kiriwrite_dbmodule->connecttemplate();
+
+ # Check if any errors had occured.
+
+ if ($main::kiriwrite_dbmodule->geterror eq "TemplateDatabaseInvalidPermissionsSet"){
+
+ # The template database has invalid permissions set so
+ # return an error.
+
+ kiriwrite_error("templatedatabaseinvalidpermissions");
+
+ }
+
+ # Edit the template.
+
+ $main::kiriwrite_dbmodule->edittemplate({ TemplateFilename => $templatefilename, NewTemplateFilename => $templatenewfilename, NewTemplateName => $templatenewname, NewTemplateDescription => $templatenewdescription, NewTemplateLayout => $templatelayout });
+
+ # Check if any error occured while editing the template.
+
+ if ($main::kiriwrite_dbmodule->geterror eq "TemplateDatabaseError"){
+
+ # A database error has occured, so return an error.
+
+ kiriwrite_error("templatedatabaseerror", $main::kiriwrite_dbmodule->geterror(1));
+
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "TemplateDatabaseInvalidPermissionsSet"){
+
+ # The template database has invalid permissions set so return
+ # an error.
+
+ kiriwrite_error("templatedatabaseinvalidpermissions");
+
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "TemplateDoesNotExist"){
+
+ # The template does not exist, so process the next template.
+
+ kiriwrite_error("templatedoesnotexist");
+
+ }
+
+ # Disconnect from the database server.
+
+ $main::kiriwrite_dbmodule->disconnect();
+
+ # Disconnect from the template database.
+
+ $main::kiriwrite_dbmodule->disconnecttemplate();
+
+ # Append a link so that the user can return to the templates list.
+
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{template}{editedtemplate}, { Style => "pageheader" });
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext(kiriwrite_language($main::kiriwrite_lang{template}{editedtemplatemessage}, $templatenewname));
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{"script_filename"} . "?mode=template", { Text => $main::kiriwrite_lang{template}{returntemplatelist} });
+
+ } else {
+
+ # Connect to the template database.
+
+ $main::kiriwrite_dbmodule->connecttemplate();
+
+ # Check if any errors had occured.
+
+ if ($main::kiriwrite_dbmodule->geterror eq "TemplateDatabaseInvalidPermissionsSet"){
+
+ # The template database has invalid permissions set so
+ # return an error.
+
+ kiriwrite_error("templatedatabaseinvalidpermissions");
+
+ }
+
+ # Get the template information.
+
+ my %template_info = $main::kiriwrite_dbmodule->gettemplateinfo({ TemplateFilename => $templatefilename });
+
+ # Check if any error occured while getting the template information.
+
+ if ($main::kiriwrite_dbmodule->geterror eq "TemplateDatabaseError"){
+
+ # A database error has occured, so return an error.
+
+ kiriwrite_error("templatedatabaseerror", $main::kiriwrite_dbmodule->geterror(1));
+
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "TemplateDoesNotExist"){
+
+ # The template does not exist, so return an error.
+
+ kiriwrite_error("templatedoesnotexist");
+
+ }
+
+ # Disconnect from the template database.
+
+ $main::kiriwrite_dbmodule->disconnecttemplate();
+
+ # Get the values from the query results.
+
+ my $template_filename = $template_info{"TemplateFilename"};
+ my $template_name = $template_info{"TemplateName"};
+ my $template_description = $template_info{"TemplateDescription"};
+ my $template_layout = $template_info{"TemplateLayout"};
+ my $template_modified = $template_info{"TemplateLastModified"};
+
+ # Check if the values are undefined and set them blank
+ # if they are.
+
+ if (!$template_name){
+ $template_name = "";
+ }
+
+ if (!$template_description){
+ $template_description = "";
+ }
+
+ if (!$template_layout){
+ $template_layout = "";
+ }
+
+ # Write out the form for editing an template with the current template
+ # settings put into the correct place.
+
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{template}{edittemplate}, { Style => "pageheader" });
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->startform($main::kiriwrite_env{"script_filename"}, "POST");
+ $main::kiriwrite_presmodule->startbox();
+ $main::kiriwrite_presmodule->addhiddendata("mode", "template");
+ $main::kiriwrite_presmodule->addhiddendata("action", "edit");
+ $main::kiriwrite_presmodule->addhiddendata("confirm", 1);
+ $main::kiriwrite_presmodule->addhiddendata("template", $template_filename);
+ $main::kiriwrite_presmodule->starttable("", { CellSpacing => 0, CellPadding => 5});
+
+ $main::kiriwrite_presmodule->startheader();
+ $main::kiriwrite_presmodule->addheader($main::kiriwrite_lang{common}{setting}, { Style => "tablecellheader" });
+ $main::kiriwrite_presmodule->addheader($main::kiriwrite_lang{common}{value}, { Style => "tablecellheader" });
+ $main::kiriwrite_presmodule->endheader();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{template}{templatename});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addinputbox("newname", { Size => 64, MaxLength => 512, Value => $template_name });
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{template}{templatedescription});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addinputbox("newdescription", { Size => 64, MaxLength => 512, Value => $template_description });
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{template}{templatefilename});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addinputbox("newfilename", { Size => 32, MaxLength => 64, Value => $template_filename });
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell("tablecell1");
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{template}{templatelayout});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell("tablecell2");
+ $main::kiriwrite_presmodule->addtextbox("newlayout", { Columns => $main::kiriwrite_config{"display_textareacols"}, Rows => $main::kiriwrite_config{"display_textarearows"}, Value => $template_layout});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->startbox("datalist");
+ $main::kiriwrite_presmodule->addboldtext($main::kiriwrite_lang{common}{tags});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{common}{pagecontent});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{common}{pagetitle});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{common}{pagename});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{common}{pagedescription});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{common}{pagesection});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{common}{pageautosection});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{common}{pageautotitle});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->endbox();
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ $main::kiriwrite_presmodule->endtable();
+
+ $main::kiriwrite_presmodule->addlinebreak();
+
+ $main::kiriwrite_presmodule->addsubmit($main::kiriwrite_lang{template}{edittemplatebutton});
+ $main::kiriwrite_presmodule->addtext(" | ");
+ $main::kiriwrite_presmodule->addreset($main::kiriwrite_lang{common}{restorecurrent});
+ $main::kiriwrite_presmodule->addtext(" | ");
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{"script_filename"} . "?mode=template", { Text => $main::kiriwrite_lang{template}{returntemplatelist} });
+
+ $main::kiriwrite_presmodule->endbox();
+ $main::kiriwrite_presmodule->endform();
+
+ }
+
+ # Disconnect from the database server.
+
+ $main::kiriwrite_dbmodule->disconnect();
+
+ return $main::kiriwrite_presmodule->grab();
+
+}
+
+sub kiriwrite_template_delete{
+#################################################################################
+# kiriwrite_template_delete: Delete a template from the template folder. #
+# #
+# Usage: #
+# #
+# kiriwrite_template_delete(filename, confirm); #
+# #
+# filename Specifies the filename of the database to delete. #
+# confirm Confirms the action to delete a template. #
+#################################################################################
+
+ # Get the parameters that were passed to the subroutine.
+
+ my ($template_filename, $template_confirm) = @_;
+
+ if (!$template_confirm){
+ $template_confirm = 0;
+ }
+
+ # Check the length of the variables.
+ kiriwrite_variablecheck($template_filename, "maxlength", 64, 0);
+ kiriwrite_variablecheck($template_confirm, "maxlength", 1, 0);
+
+ # Check if the template_name string is blank and if it is then
+ # return an error (as the template_name string should not be
+ # blank.
+
+ if (!$template_filename){
+
+ # The template_filename string really is blank,
+ # so return an error saying that an empty
+ # filename was passed (to the subroutine).
+
+ kiriwrite_error("templatefilenameblank");
+
+ }
+
+ # Check if the template_confirm string is blank and if it is, write
+ # out a form asking the user to confirm the deletion.
+
+ if ($template_confirm eq 1){
+
+ # The action to delete the template from the template database has
+ # been confirmed so delete the template.
+
+ # Connect to the database server.
+
+ $main::kiriwrite_dbmodule->connect();
+
+ # Check if any errors occured while connecting to the database server.
+
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
+
+ # A database connection error has occured so return
+ # an error.
+
+ kiriwrite_error("databaseconnectionerror", $main::kiriwrite_dbmodule->geterror(1));
+
+ }
+
+ # Check if the template database exists and the file permissions
+ # are valid and return an error if they aren't.
+
+ $main::kiriwrite_dbmodule->connecttemplate();
+
+ if ($main::kiriwrite_dbmodule->geterror eq "TemplateDatabaseDoesNotExist"){
+
+ # The template database does not exist so write a warning
+ # message.
+
+ kiriwrite_error("templatedatabasemissing");
+
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "TemplateDatabaseInvalidPermissionsSet"){
+
+ # The template database has invalid permissions set so
+ # return an error.
+
+ kiriwrite_error("templatedatabaseinvalidpermissions");
+
+ }
+
+ my %template_info = $main::kiriwrite_dbmodule->gettemplateinfo({ TemplateFilename => $template_filename });
+
+ # Check if any error occured while getting the template information.
+
+ if ($main::kiriwrite_dbmodule->geterror eq "TemplateDatabaseError"){
+
+ # A database error has occured, so return an error.
+
+ kiriwrite_error("templatedatabaseerror", $main::kiriwrite_dbmodule->geterror(1));
+
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "TemplateDoesNotExist"){
+
+ # The template does not exist, so return an error.
+
+ kiriwrite_error("templatedoesnotexist");
+
+ }
+
+ # Delete the selected template.
+
+ $main::kiriwrite_dbmodule->deletetemplate({ TemplateFilename => $template_filename });
+
+ # Check if any error occured while deleting the template.
+
+ if ($main::kiriwrite_dbmodule->geterror eq "TemplateDatabaseError"){
+
+ # A database error has occured, so return an error.
+
+ kiriwrite_error("templatedatabaseerror", $main::kiriwrite_dbmodule->geterror(1));
+
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "TemplateDoesNotExist"){
+
+ # The template does not exist, so process the next template.
+
+ kiriwrite_error("templatedoesnotexist");
+
+ }
+
+ $main::kiriwrite_dbmodule->disconnecttemplate();
+
+ # Get the deleted database name.
+
+ my $database_template_name = $template_info{"TemplateName"};
+
+ # Disconnect from the database server.
+
+ $main::kiriwrite_dbmodule->disconnect();
+
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{template}{deletedtemplate}, { Style => "pageheader" });
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext(kiriwrite_language($main::kiriwrite_lang{template}{deletedtemplatemessage}, $database_template_name) );
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{"script_filename"} . "?mode=template", { Text => $main::kiriwrite_lang{template}{returntemplatelist} });
+
+ return $main::kiriwrite_presmodule->grab();
+
+ } elsif ($template_confirm eq 0) {
+
+ # The template confirm value is 0 (previously blank and then set to 0), so
+ # write out a form asking the user to confirm the deletion of the template.
+
+ # Connect to the database server.
+
+ $main::kiriwrite_dbmodule->connect();
+
+ # Check if any errors occured while connecting to the database server.
+
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
+
+ # A database connection error has occured so return
+ # an error.
+
+ kiriwrite_error("databaseconnectionerror", $main::kiriwrite_dbmodule->geterror(1));
+
+ }
+
+ # Connect to the template database.
+
+ $main::kiriwrite_dbmodule->connecttemplate();
+
+ if ($main::kiriwrite_dbmodule->geterror eq "TemplateDatabaseDoesNotExist"){
+
+ # The template database does not exist so write a warning
+ # message.
+
+ kiriwrite_error("templatedatabasemissing");
+
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "TemplateDatabaseInvalidPermissionsSet"){
+
+ # The template database has invalid permissions set so
+ # return an error.
+
+ kiriwrite_error("templatedatabaseinvalidpermissions");
+
+ }
+
+ my %template_info = $main::kiriwrite_dbmodule->gettemplateinfo({ TemplateFilename => $template_filename });
+
+ if ($main::kiriwrite_dbmodule->geterror eq "TemplateDatabaseError"){
+
+ # A database error has occured, so return an error.
+
+ kiriwrite_error("templatedatabaseerror", $main::kiriwrite_dbmodule->geterror(1));
+
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "TemplateDoesNotExist"){
+
+ # The template does not exist, so return an error.
+
+ kiriwrite_error("templatedoesnotexist");
+
+ }
+
+ my $template_data_filename = $template_info{"TemplateFilename"};
+ my $template_data_name = $template_info{"TemplateName"};
+
+ $main::kiriwrite_dbmodule->disconnecttemplate();
+
+ # Disconnect from the database server.
+
+ $main::kiriwrite_dbmodule->disconnect();
+
+ # Write out the confirmation form.
+
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{template}{deletetemplate}, { Style => "pageheader" });
+ $main::kiriwrite_presmodule->startform($main::kiriwrite_env{"script_filename"}, "POST");
+ $main::kiriwrite_presmodule->startbox();
+ $main::kiriwrite_presmodule->addhiddendata("mode", "template");
+ $main::kiriwrite_presmodule->addhiddendata("template", $template_filename);
+ $main::kiriwrite_presmodule->addhiddendata("action", "delete");
+ $main::kiriwrite_presmodule->addhiddendata("confirm", 1);
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addtext(kiriwrite_language($main::kiriwrite_lang{template}{deletetemplatemessage}, $template_data_name, $template_data_filename));
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addsubmit($main::kiriwrite_lang{template}{deletetemplatebutton});
+ $main::kiriwrite_presmodule->addtext(" | ");
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{"script_filename"} . "?mode=template", { Text => $main::kiriwrite_lang{template}{deletetemplatereturntolist} });
+ $main::kiriwrite_presmodule->endbox();
+ $main::kiriwrite_presmodule->endform();
+
+ return $main::kiriwrite_presmodule->grab();
+
+ } else {
+
+ kiriwrite_error("invalidvariable");
+
+ }
+
+}
+
+sub kiriwrite_template_list{
+#################################################################################
+# kiriwrite_template_list: List the templates in the template folder. #
+# #
+# Usage: #
+# #
+# kiriwrite_template_list([browsenumber]); #
+# #
+# browsenumber Specifies the page browse number to use. #
+#################################################################################
+
+ # Define certain values for later.
+
+ my $template_browsenumber = shift;
+
+ my %template_info;
+
+ my @templates_list;
+
+ my $template;
+ my $template_filename = "";
+ my $template_filename_list = "";
+ my $template_name = "";
+ my $template_description = "";
+ my $template_data = "";
+
+ my $template_split = $main::kiriwrite_config{"display_templatecount"};
+ my $template_list = 0;
+
+ my $template_count = 0;
+
+ my $template_style = 0;
+ my $template_stylename = "";
+
+ my $templatewarning = "";
+
+ # Connect to the database server.
+
+ $main::kiriwrite_dbmodule->connect();
+
+ # Check if any errors occured while connecting to the database server.
+
+ if ($main::kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
+
+ # A database connection error has occured so return
+ # an error.
+
+ kiriwrite_error("databaseconnectionerror", $main::kiriwrite_dbmodule->geterror(1));
+
+ }
+
+ # Connect to the template database.
+
+ $main::kiriwrite_dbmodule->connecttemplate();
+
+ # Check if any errors had occured.
+
+ if ($main::kiriwrite_dbmodule->geterror eq "TemplateDatabaseDoesNotExist"){
+
+ # The template database does not exist so write a warning
+ # message.
+
+ $templatewarning = $main::kiriwrite_lang{template}{templatedatabasedoesnotexist};
+
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "TemplateDatabaseInvalidPermissionsSet"){
+
+ # The template database has invalid permissions set so
+ # return an error.
+
+ kiriwrite_error("templatedatabaseinvalidpermissions");
+
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "TemplateDatabaseError"){
+
+ # A database error occured while getting the list of
+ # templates so return an error with the extended
+ # error information.
+
+ kiriwrite_error("templatedatabaseerror", $main::kiriwrite_dbmodule->geterror(1));
+
+ }
+
+ # Get the list of template databases.
+
+ if (!$templatewarning){
+
+ # Get the total count of filters in the filter database.
+
+ my $template_total_count = $main::kiriwrite_dbmodule->gettemplatecount;
+
+ # Check if any errors occured while getting the count of filters.
+
+ if ($main::kiriwrite_dbmodule->geterror eq "TemplateDatabaseError"){
+
+ # A database error has occured with the filter database.
+
+ kiriwrite_error("templatedatabaseerror", $main::kiriwrite_dbmodule->geterror(1));
+
+ }
+
+ if (!$template_browsenumber || $template_browsenumber eq 0){
+
+ $template_browsenumber = 1;
+
+ }
+
+ # Check if the template browse number is valid and if it isn't
+ # then return an error.
+
+ my $kiriwrite_browsenumber_length_check = kiriwrite_variablecheck($template_browsenumber, "maxlength", 7, 1);
+ my $kiriwrite_browsenumber_number_check = kiriwrite_variablecheck($template_browsenumber, "numbers", 0, 1);
+
+ if ($kiriwrite_browsenumber_length_check eq 1){
+
+ # The browse number was too long so return
+ # an error.
+
+ kiriwrite_error("browsenumbertoolong");
+
+ }
+
+ if ($kiriwrite_browsenumber_number_check eq 1){
+
+ # The browse number wasn't a number so
+ # return an error.
+
+ kiriwrite_error("browsenumberinvalid");
+
+ }
+
+ if ($template_total_count ne 0){
+
+ if ($template_total_count eq $template_split){
+
+ $template_list = int(($template_total_count / $template_split));
+
+ } else {
+
+ $template_list = int(($template_total_count / $template_split) + 1);
+
+ }
+
+ }
+
+ my $start_from = ($template_browsenumber - 1) * $template_split;
+
+ @templates_list = $main::kiriwrite_dbmodule->gettemplatelist({ StartFrom => $start_from, Limit => $template_split });
+
+ }
+
+ # Check if any errors had occured.
+
+ if ($main::kiriwrite_dbmodule->geterror eq "TemplateDatabaseError"){
+
+ # A database error occured while getting the list
+ # of templates so return an error with the
+ # extended error information.
+
+ kiriwrite_error("templatedatabaseerror", $main::kiriwrite_dbmodule->geterror(1));
+
+ }
+
+ my $template_list_count;
+
+ # Check if any templates are in the database and if there isn't
+ # then write a message saying that there are no templates in the
+ # database.
+
+ if (!@templates_list && $template_browsenumber > 1){
+
+ # There were no values given for the page browse
+ # number given so write a message saying that
+ # there were no pages for the page browse number
+ # given.
+
+ $main::kiriwrite_presmodule->clear();
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{template}{viewtemplates}, { Style => "pageheader" });
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->startbox("errorbox");
+ $main::kiriwrite_presmodule->enterdata($main::kiriwrite_lang{template}{notemplatesinpagebrowse});
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{"script_filename"} . "?mode=template", { Text => $main::kiriwrite_lang{template}{returntofirstpagebrowse} });
+ $main::kiriwrite_presmodule->endbox();
+
+ # Disconnect from the database server.
+
+ $main::kiriwrite_dbmodule->disconnect();
+ $main::kiriwrite_dbmodule->disconnecttemplate();
+
+ return $main::kiriwrite_presmodule->grab();
+
+ } elsif (!@templates_list && !$templatewarning){
+ $templatewarning = $main::kiriwrite_lang{template}{notemplatesavailable};
+ }
+
+ # Process the templates into a template list.
+
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{template}{viewtemplates}, { Style => "pageheader" });
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+
+ if ($templatewarning){
+
+ $main::kiriwrite_presmodule->startbox("errorbox");
+ $main::kiriwrite_presmodule->addtext($templatewarning);
+ $main::kiriwrite_presmodule->endbox();
+
+ } else {
+
+ if (!$template_browsenumber || $template_browsenumber eq 0){
+
+ $template_browsenumber = 1;
+
+ }
+
+ # Check if the template browse number is valid and if it isn't
+ # then return an error.
+
+ my $kiriwrite_browsenumber_length_check = kiriwrite_variablecheck($template_browsenumber, "maxlength", 7, 1);
+ my $kiriwrite_browsenumber_number_check = kiriwrite_variablecheck($template_browsenumber, "numbers", 0, 1);
+
+ if ($kiriwrite_browsenumber_length_check eq 1){
+
+ # The browse number was too long so return
+ # an error.
+
+ kiriwrite_error("browsenumbertoolong");
+
+ }
+
+ if ($kiriwrite_browsenumber_number_check eq 1){
+
+ # The browse number wasn't a number so
+ # return an error.
+
+ kiriwrite_error("browsenumberinvalid");
+
+ }
+
+ # Start a form for using the template browsing list with.
+
+ $main::kiriwrite_presmodule->startform($main::kiriwrite_env{"script_filename"}, "GET");
+ $main::kiriwrite_presmodule->addhiddendata("mode", "template");
+
+ # Write out the template browsing list.
+
+ $main::kiriwrite_presmodule->addtext($main::kiriwrite_lang{template}{showlistpage});
+ $main::kiriwrite_presmodule->addselectbox("browsenumber");
+
+ # Write out the list of available pages to browse.
+
+ if (!$template_list_count){
+
+ $template_list_count = 0;
+
+ }
+
+ while ($template_list_count ne $template_list){
+
+ $template_list_count++;
+
+ if ($template_list_count eq 1 && !$template_browsenumber){
+
+ $main::kiriwrite_presmodule->addoption($template_list_count, { Value => $template_list_count, Selected => 1 });
+
+ } else {
+
+ if ($template_browsenumber eq $template_list_count){
+
+ $main::kiriwrite_presmodule->addoption($template_list_count, { Value => $template_list_count, Selected => 1 });
+
+ } else {
+
+ $main::kiriwrite_presmodule->addoption($template_list_count, { Value => $template_list_count });
+
+ }
+
+ }
+
+ }
+
+ $main::kiriwrite_presmodule->endselectbox();
+ $main::kiriwrite_presmodule->addbutton("action", { Value => "view", Description => $main::kiriwrite_lang{template}{show} });
+
+ if ($template_list ne $template_browsenumber){
+
+ $main::kiriwrite_presmodule->addtext(" | ");
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{"script_filename"} . "?mode=template&action=view&browsenumber=" . ($template_browsenumber + 1), { Text => $main::kiriwrite_lang{template}{nextpage} });
+
+ }
+
+ # Check if the filter browse number is not blank and
+ # not set as 0 and hide the Previous page link if
+ # it is.
+
+ if ($template_browsenumber > 1){
+
+ $main::kiriwrite_presmodule->addtext(" | ");
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{"script_filename"} . "?mode=template&action=view&browsenumber=" . ($template_browsenumber - 1), { Text => $main::kiriwrite_lang{template}{previouspage} });
+
+ }
+
+ $main::kiriwrite_presmodule->addlinebreak();
+ $main::kiriwrite_presmodule->addlinebreak();
+
+ $main::kiriwrite_presmodule->starttable("", { CellPadding => 5, CellSpacing => 0 });
+ $main::kiriwrite_presmodule->startheader();
+ $main::kiriwrite_presmodule->addheader($main::kiriwrite_lang{template}{templatefilename}, { Style => "tablecellheader" });
+ $main::kiriwrite_presmodule->addheader($main::kiriwrite_lang{template}{templatename}, { Style => "tablecellheader" });
+ $main::kiriwrite_presmodule->addheader($main::kiriwrite_lang{template}{templatedescription}, { Style => "tablecellheader" });
+ $main::kiriwrite_presmodule->addheader($main::kiriwrite_lang{common}{options}, { Style => "tablecellheader" });
+ $main::kiriwrite_presmodule->endheader();
+
+ foreach $template (@templates_list){
+
+ # Get the template data.
+
+ %template_info = $main::kiriwrite_dbmodule->gettemplateinfo({ TemplateFilename => $template, Reduced => 1 });
+
+ # Check if any errors occured while trying to get the template
+ # data.
+
+ if ($main::kiriwrite_dbmodule->geterror eq "TemplateDatabaseError"){
+
+ # A database error has occured, so return an error.
+
+ kiriwrite_error("templatedatabaseerror", $main::kiriwrite_dbmodule->geterror(1));
+
+ } elsif ($main::kiriwrite_dbmodule->geterror eq "TemplateDoesNotExist"){
+
+ # The template does not exist, so process the next template.
+
+ next;
+
+ }
+
+ $template_filename = $template_info{"TemplateFileName"};
+ $template_name = $template_info{"TemplateName"};
+ $template_description = $template_info{"TemplateDescription"};
+
+ # Check what style the row of table cells should be.
+
+ if ($template_style eq 0){
+
+ $template_stylename = "tablecell1";
+ $template_style = 1;
+
+ } else {
+
+ $template_stylename = "tablecell2";
+ $template_style = 0;
+
+ }
+
+ $main::kiriwrite_presmodule->startrow();
+ $main::kiriwrite_presmodule->addcell($template_stylename);
+ $main::kiriwrite_presmodule->addtext($template_info{"TemplateFilename"});
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell($template_stylename);
+
+ # Check if the template name is blank and if it is
+ # write a message to say there's no name for the
+ # template.
+
+ if (!$template_info{"TemplateName"}){
+ $main::kiriwrite_presmodule->additalictext($main::kiriwrite_lang{blank}{noname});
+ } else {
+ $main::kiriwrite_presmodule->addtext($template_info{"TemplateName"});
+ }
+
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell($template_stylename);
+
+ # Check if the template description is blank and if
+ # it is then write a message to say there's no
+ # description for the template.
+
+ if (!$template_info{"TemplateDescription"}){
+ $main::kiriwrite_presmodule->additalictext($main::kiriwrite_lang{blank}{nodescription});
+ } else {
+ $main::kiriwrite_presmodule->addtext($template_info{"TemplateDescription"});
+ }
+
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->addcell($template_stylename);
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{"script_filename"} . "?mode=template&action=edit&template=" . $template_info{"TemplateFilename"}, { Text => $main::kiriwrite_lang{options}{edit} });
+ $main::kiriwrite_presmodule->addlink($main::kiriwrite_env{"script_filename"} . "?mode=template&action=delete&template=" . $template_info{"TemplateFilename"}, { Text => $main::kiriwrite_lang{options}{delete} });
+ $main::kiriwrite_presmodule->endcell();
+ $main::kiriwrite_presmodule->endrow();
+
+ }
+
+ $main::kiriwrite_presmodule->endtable();
+ $main::kiriwrite_presmodule->endform();
+
+ }
+
+ # Disconnect from the database server.
+
+ $main::kiriwrite_dbmodule->disconnect();
+
+ $main::kiriwrite_dbmodule->disconnecttemplate();
+ return $main::kiriwrite_presmodule->grab();
+
+
+}
+
+1;
\ No newline at end of file
#!/usr/bin/perl -Tw
#################################################################################
-# Kiriwrite Installer Script (install.cgi) #
+# Kiriwrite Installer Script (install.pl/install.cgi) #
# Installation script for Kiriwrite #
# #
-# Version: 0.1.0 #
+# Version: 0.4.0 #
+# mod_perl 2.x compatabile version #
# #
-# Copyright (C) 2005-2007 Steve Brokenshire <sbrokenshire@xestia.co.uk> #
+# Copyright (C) 2005-2008 Steve Brokenshire <sbrokenshire@xestia.co.uk> #
# #
# 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 #
use warnings; # Write warnings to the HTTP Server Log file.
use utf8;
-#use CGI qw(:standard *table *Tr *td);
use CGI::Lite;
-#use CGI::Carp('fatalsToBrowser'); # Output errors to the browser.
+
+eval "use CGI::Lite";
+
+if ($@){
+ print "Content-type: text/html;\r\n\r\n";
+ print "The CGI::Lite Perl Module is not installed. Please install CGI::Lite and then run this installation script again.";
+ exit;
+}
+
+# Check if mod_perl is running and if it is then add a notice to say
+# that additional configuration has to be made.
+
+my $modperlenabled = 0;
+my $installscriptname = "install.cgi";
+my $kiriwritescriptname = "kiriwrite.cgi";
+
+if ($ENV{'MOD_PERL'}){
+
+ # MOD_PERL 2.X SPECIFIC SECTION.
+
+ use lib '';
+ chdir('');
+
+ $modperlenabled = 1;
+ $installscriptname = "install.pl";
+ $kiriwritescriptname = "kiriwrite.pl";
+
+}
# Setup strings in specific languages. Style should be no spacing for
# language title and one tabbed spacing for each string.
$kiriwrite_lang{"en-GB"}{"installertitle"} = "Kiriwrite Installer";
$kiriwrite_lang{"en-GB"}{"installertext"} = "This installer script will setup the configuration file used for Kiriwrite. The settings displayed here can be changed at a later date by selecting the Edit Settings link in the View Settings sub-menu.";
+ $kiriwrite_lang{"en-GB"}{"modperlnotice"} = "mod_perl has been detected. Please ensure that you have setup this script and the main Kiriwrite script so that mod_perl can use Kiriwrite properly. Please read the mod_perl specific part of Chapter 1: Installation in the Kiriwrite documentation.";
$kiriwrite_lang{"en-GB"}{"dependencytitle"} = "Dependency and file testing results";
$kiriwrite_lang{"en-GB"}{"requiredmodules"} = "Required Modules";
$kiriwrite_lang{"en-GB"}{"perlmodules"} = "These Perl modules are used internally by Kiriwrite.";
$kiriwrite_lang{"en-GB"}{"installscriptremoved"} = "The installer script was removed.";
$kiriwrite_lang{"en-GB"}{"installedmessage"} = "The configuration file for Kiriwrite has been written. To change the settings in the configuration file at a later date use the Edit Settings link in the View Settings sub-menu at the top of the page when using Kiriwrite.";
$kiriwrite_lang{"en-GB"}{"cannotremovescript"} = "Unable to remove the installer script: %s. The installer script will have to be deleted manually.";
- $kiriwrite_lang{"en-GB"}{"usekiriwritetext"} = "To use Kiriwrite click or select the link below (will not work if the Kiriwrite script is not called kiriwrite.cgi):";
+ $kiriwrite_lang{"en-GB"}{"usekiriwritetext"} = "To use Kiriwrite click or select the link below (will not work if the Kiriwrite script is not called kiriwrite.cgi/kiriwrite.pl):";
$kiriwrite_lang{"en-GB"}{"usekiriwritelink"} = "Start using Kiriwrite.";
my $query_lite = new CGI::Lite;
open (my $configfile, "> " . "kiriwrite.cfg");
print $configfile "[config]
- directory_data_db = $passedsettings->{DatabaseDirectory}
- directory_data_output = $passedsettings->{OutputDirectory}
- directory_noncgi_images = $passedsettings->{ImagesURIPath}
-
- system_language = $passedsettings->{Language}
- system_presmodule = $passedsettings->{PresentationModule}
- system_dbmodule = $passedsettings->{DatabaseModule}
- system_datetime = $passedsettings->{DateFormat}
+directory_data_db = $passedsettings->{DatabaseDirectory}
+directory_data_output = $passedsettings->{OutputDirectory}
+directory_noncgi_images = $passedsettings->{ImagesURIPath}
+
+system_language = $passedsettings->{Language}
+system_presmodule = $passedsettings->{PresentationModule}
+system_dbmodule = $passedsettings->{DatabaseModule}
+system_datetime = $passedsettings->{DateFormat}
- display_textareacols = $passedsettings->{TextAreaCols}
- display_textarearows = $passedsettings->{TextAreaRows}
- display_pagecount = 50
- display_filtercount = 50
- display_templatecount = 50
+display_textareacols = $passedsettings->{TextAreaCols}
+display_textarearows = $passedsettings->{TextAreaRows}
+display_pagecount = 50
+display_filtercount = 50
+display_templatecount = 50
- database_server = $passedsettings->{DatabaseServer}
- database_port = $passedsettings->{DatabasePort}
- database_protocol = $passedsettings->{DatabaseProtocol}
- database_sqldatabase = $passedsettings->{DatabaseName}
- database_username = $passedsettings->{DatabaseUsername}
- database_password = $passedsettings->{DatabasePassword}
- database_tableprefix = $passedsettings->{DatabaseTablePrefix}
+database_server = $passedsettings->{DatabaseServer}
+database_port = $passedsettings->{DatabasePort}
+database_protocol = $passedsettings->{DatabaseProtocol}
+database_sqldatabase = $passedsettings->{DatabaseName}
+database_username = $passedsettings->{DatabaseUsername}
+database_password = $passedsettings->{DatabasePassword}
+database_tableprefix = $passedsettings->{DatabaseTablePrefix}
";
close ($configfile);
}
+sub kiriwrite_processconfig{
+#################################################################################
+# kiriwrite_processconfig: Processes an INI style configuration file. #
+# #
+# Usage: #
+# #
+# kiriwrite_processconfig(data); #
+# #
+# data Specifies the data to process. #
+#################################################################################
+
+ my (@settings) = @_;
+
+ my ($settings_line, %settings, $settings, $sectionname, $setting_name, $setting_value);
+
+ foreach $settings_line (@settings){
+
+ next if !$settings_line;
+
+ # Check if the first character is a bracket.
+
+ if (substr($settings_line, 0, 1) eq "["){
+ $settings_line =~ s/\[//;
+ $settings_line =~ s/\](.*)//;
+ $settings_line =~ s/\n//;
+ $sectionname = $settings_line;
+ next;
+ }
+
+ $setting_name = $settings_line;
+ $setting_value = $settings_line;
+ $setting_name =~ s/\=(.*)//;
+ $setting_name =~ s/\n//;
+ $setting_value =~ s/(.*)\=//;
+ $setting_value =~ s/\n//;
+
+ # Remove the spacing before and after the '=' sign.
+
+ $setting_name =~ s/\s+$//;
+ $setting_value =~ s/^\s+//;
+ $setting_value =~ s/\r//;
+
+ $settings{$sectionname}{$setting_name} = $setting_value;
+
+ }
+
+ return %settings;
+
+}
+
#################################################################################
# End list of subroutines. #
#################################################################################
if ($http_query_removeinstallscript eq "on"){
- if (unlink("install.cgi")){
+ if (unlink($installscriptname)){
$installscriptmessage = $kiriwrite_lang{$language_selected}{installscriptremoved};
print "<br /><br />\n";
print $installscriptmessage;
- }
+ }
print "<br /><br />\n";
print $kiriwrite_lang{$language_selected}{usekiriwritetext};
print "<br /><br />\n";
- print "<a href=\"kiriwrite.cgi\">$kiriwrite_lang{$language_selected}{usekiriwritelink}</a>";
+ print "<a href=\"" . $kiriwritescriptname . "\">$kiriwrite_lang{$language_selected}{usekiriwritelink}</a>";
print "</body>\n</html>";
exit;
# Check to see if the needed Perl modules are installed.
-$test_list{CheckConfigAuto}{Name} = "Config::Auto";
-$test_list{CheckConfigAuto}{Type} = "dependency";
-$test_list{CheckConfigAuto}{Code} = "Config::Auto";
-
$test_list{CheckDBI}{Name} = "DBI";
$test_list{CheckDBI}{Type} = "dependency";
$test_list{CheckDBI}{Code} = "DBI";
$test_list{LanguageDirectory}{Code} = "lang";
$test_list{LanguageDirectory}{Writeable} = "0";
-$test_list{LibraryDirectory}{Name} = "Library Directory (lib)";
-$test_list{LibraryDirectory}{Type} = "file";
-$test_list{LibraryDirectory}{Code} = "lib";
-$test_list{LibraryDirectory}{Writeable} = "0";
-
$test_list{ModulesDirectory}{Name} = "Modules Directory (Modules)";
$test_list{ModulesDirectory}{Type} = "file";
$test_list{ModulesDirectory}{Code} = "Modules";
$test_list{PresModulesDirectory}{Code} = "Modules/Presentation";
$test_list{PresModulesDirectory}{Writeable} = "0";
+$test_list{SystemModulesDirectory}{Name} = "System Modules Directory (Modules/System)";
+$test_list{SystemModulesDirectory}{Type} = "file";
+$test_list{SystemModulesDirectory}{Code} = "Modules/System";
+$test_list{SystemModulesDirectory}{Writeable} = "0";
+
# Preform those tests.
foreach $test (keys %test_list){
$installlanguage_out = $installlanguage_out . "</select>\n";
-kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{installertitle}, "languagebar", "<form action=\"install.cgi\" method=\"POST\">\n$installlanguage_out\n<input type=\"submit\" value=\"$kiriwrite_lang{$language_selected}{switch}\">\n</form>\n", "languagebarselect");
+kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{installertitle}, "languagebar", "<form action=\"" . $installscriptname . "\" method=\"POST\">\n$installlanguage_out\n<input type=\"submit\" value=\"$kiriwrite_lang{$language_selected}{switch}\">\n</form>\n", "languagebarselect");
print "</table>";
print "<h2>$kiriwrite_lang{$language_selected}{installertitle}</h2>\n";
print $kiriwrite_lang{$language_selected}{installertext};
+
+if ($modperlenabled eq 1){
+ print "<br /><br />";
+ print $kiriwrite_lang{$language_selected}{modperlnotice};
+}
+
print "<h3>$kiriwrite_lang{$language_selected}{dependencytitle}</h3>\n";
print "<h4>$kiriwrite_lang{$language_selected}{requiredmodules}</h4>\n";
print $kiriwrite_lang{$language_selected}{perlmodules};
print $kiriwrite_lang{$language_selected}{databasemodulestext};
print "<br /><br />\n";
+print "<table>\n";
+
if ($database_error eq 1){
print $kiriwrite_lang{$language_selected}{warningmessage};
my @presentation_modules;
my @database_modules;
my $select_data = "";
-my $language_data;
+my (%language_data, $language_data);
+my @lang_data;
+my $kiriwrite_languagefilehandle;
my $language_out = "";
my ($presmodule_name, $presmodule_out) = "";
my ($dbmodule_name, $dbmodule_out) = "";
# Load the language file.
- $language_data = Config::Auto::parse("lang/" . $language_file, format => "ini");
-
- # Load the XML data.
- #$language_xml_data = $xsl->XMLin("lang/" . $language_file);
+ open ($kiriwrite_languagefilehandle, "lang/" . $language_file);
+ @lang_data = <$kiriwrite_languagefilehandle>;
+ %language_data = kiriwrite_processconfig(@lang_data);
+ close ($kiriwrite_languagefilehandle);
# Get the friendly name for the language file.
$language_file_friendly = $language_file;
$language_file_friendly =~ s/.lang$//g;
- $language_name = $language_data->{about}->{name};
+ $language_name = $language_data{about}{name};
$available_languages{$language_file_friendly} = $language_name . " (" . $language_file_friendly . ")";
print $kiriwrite_lang{$language_selected}{settingstext};
print "<br /><br />\n";
-print "<form action=\"install.cgi\" method=\"POST\">";
+print "<form action=\"" . $installscriptname . "\" method=\"POST\">";
print "<input type=\"hidden\" name=\"confirm\" value=\"1\">\n<input type=\"hidden\" name=\"installlanguage\" value=\"$language_selected\">\n";
print "<table width=\"100%\">";
kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{setting}, "tablecellheader", $kiriwrite_lang{$language_selected}{value}, "tablecellheader");
kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{directories}, "tablecellheader", "", "tablecellheader");
-kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{databasedirectory}, "tablname", "<input type=\"text\" name=\"dbdirectory\" size=\"32\" maxlength=\"64\" value=\"$default_dbdirectory\">", "tabledata");
+kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{databasedirectory}, "tablename", "<input type=\"text\" name=\"dbdirectory\" size=\"32\" maxlength=\"64\" value=\"$default_dbdirectory\">", "tabledata");
kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{outputdirectory}, "tablename", "<input type=\"text\" name=\"outputdirectory\" size=\"32\" maxlength=\"64\" value=\"$default_outputdirectory\">", "tabledata");
kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{imagesuripath}, "tablename", "<input type=\"text\" name=\"imagesuripath\" size=\"32\" maxlength=\"64\" value=\"$default_imagesuri\">", "tabledata");
kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{display}, "tablecellheader", "", "tablecellheader");
$select_data = $select_data . "<option value=\"$select_name\">" . $select_name . "</option>\n";
}
-kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{dateformat}, "tablename", "<select>$select_data</select>\n<input type=\"text\" size=\"32\" maxlength=\"64\" name=\"customdateformat\">", "tabledata");
+kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{dateformat}, "tablename", "<select name=\"dateformat\">$select_data</select>\n<input type=\"text\" size=\"32\" maxlength=\"64\" name=\"customdateformat\">", "tabledata");
kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{language}, "tablecellheader", "", "tablecellheader");
foreach my $language (keys %available_languages){
}
}
-kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{systemlanguage}, "tablename", $language_out, "tabledata");
+kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{systemlanguage}, "tablename", "<select name=\"language\">\r\n$language_out\r\n</select>", "tabledata");
kiriwrite_addtablerow($kiriwrite_lang{$language_selected}{modules}, "tablecellheader", "", "tablecellheader");
foreach $presmodule_name (@presentation_modules){
$presmodule_out = $presmodule_out . "<option value=\"$presmodule_name\">$presmodule_name</option>";
#!/usr/bin/perl -Tw
#################################################################################
-# Kiriwrite (kiriwrite.cgi) #
+# Kiriwrite (kiriwrite.pl/kiriwrite.cgi) #
# Main program script #
# #
-# Version: 0.1.0 #
+# Version: 0.4.0 #
+# mod_perl 2.x compatabile version #
# #
-# Copyright (C) 2005-2007 Steve Brokenshire <sbrokenshire@xestia.co.uk> #
+# Copyright (C) 2005-2008 Steve Brokenshire <sbrokenshire@xestia.co.uk> #
# #
# 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 #
# 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;
# 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, $form_data, $kiriwrite_script_name, $kiriwrite_env_path);
+
+# 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" => 4,
"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);
+kiriwrite_initalise; # Initalise the Kiriwrite enviroment.
+kiriwrite_settings_load; # Load the configuration options.
- # Setup the needed enviroment variables for Kiriwrite.
+my $query_lite = new CGI::Lite;
- %kiriwrite_env = (
- "script_filename" => $script_filename,
- );
+# 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;
-#################################################################################
-# Begin listing the functions needed. #
-#################################################################################
+if ($form_data->{'mode'}){
+ my $http_query_mode = $form_data->{'mode'};
-sub kiriwrite_selectedlist{
-#################################################################################
-# kiriwrite_page_selectedlist: Get the list of selected pages to use. #
-# #
-# Usage: #
-# #
-# kiriwrite_page_selectedlist(); #
-#################################################################################
+ if ($http_query_mode eq "db"){
- my $count = $form_data->{'count'};
+ use Modules::System::Database;
- # Check if the list of files has a value and if not set it 0.
+ if ($form_data->{'action'}){
+ # An action has been specified, so find out what action has been specified.
- if (!$count){
+ 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");
+ }
- $count = 0;
+ } else {
- }
+ # 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.
- # Define some values for later.
+ }
- my @filename_list;
- my @selected_list;
- my @final_list;
+ } elsif ($http_query_mode eq "page"){
- my $filename;
- my $selected;
+ use Modules::System::Page;
- my $final_count = 0;
- my $seek = 0;
+ 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.
- # Get the list of filenames.
+ 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.
- do {
+
+ } 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.
+ } elsif ($http_query_mode eq "template"){
- $seek = 0;
+ use Modules::System::Template;
- do {
+ 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.
+
+ }
- # Check if the selected value is on and include
- # the filename in the final list.
+ } elsif ($http_query_mode eq "filter"){
- $seek++;
-
- $selected = $selected_list[$seek];
-
- if ($selected eq "on"){
-
- $filename = $filename_list[$seek];
- $final_list[$final_count] = $filename;
- $final_count++;
-
- }
-
- } until ($seek eq $count || $count eq 0);
-
- 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},
- "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},
- "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);
- 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.
-
- 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 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.
-
- 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("languagefilenameinvalidpermissions");
-
- }
-
- # 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 = "";
-
- }
-
- my $chunk = 0;
- my $process = 8192;
- my $length = 0;
- my $chunkdata = "";
-
- while ($chunk < $length){
-
- $chunkdata = substr($variable_data, $chunk, $process);
-
- 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");
-
- }
-
- }
-
-
- $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"){
-
- # 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: text/html; 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", "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"
-
- );
-
- # 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;
- #return $utfstring;
-
-}
-
-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. 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. 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."
-
- );
-
- if (!$error_list{$error_type}){
-
- $error_type = "generic";
-
- }
-
- print "Expires: Sun, 01 Jan 2006 00:00:00 GMT\r\n";
- print "Content-Type: text/html; 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 <kiriwrite> tages and replace with the apporiate variables.
-
- foreach $scriptpageline (@scriptpage){
-
- $scriptpageline =~ s/<kiriwrite:menu>/$menuoutput/g;
- $scriptpageline =~ s/<kiriwrite:imagespath>/$kiriwrite_config{"directory_noncgi_images"}/g;
- $scriptpageline =~ s/<kiriwrite:pagedata>/$pagedata/g;
+ } elsif ($http_query_mode eq "compile"){
- # Check if page title specified is blank, otherwise add a page title
- # to the title.
+ use Modules::System::Compile;
- if ($pagetitle eq ""){
- $scriptpageline =~ s/<kiriwrite:title>//g;
- } else {
- $scriptpageline =~ s/<kiriwrite:title>/ ($pagetitle)/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 @selectedlist = kiriwrite_selectedlist($form_data);
+ my $pagedata = kiriwrite_compile_makepages($http_query_type, $http_query_confirm, $http_query_override, $http_query_overridetemplate, @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.
+
+ my @selectedlist = kiriwrite_selectedlist($form_data);
+ my $pagedata = kiriwrite_compile_makepages($http_query_type, $http_query_confirm, "", "", @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 @selectedlist;
+ $selectedlist[0] = $http_query_database;
+ my $pagedata = kiriwrite_compile_makepages($http_query_type, $http_query_confirm, "", "", @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'};
+
+ 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 compile all the databases has been confirmed.
+
+ }
+
+ my $pagedata = kiriwrite_compile_all();
+
+ 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;
-
- }
-
- 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_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, 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 <sbrokenshire@xestia.co.uk>
-
-=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
-# English (British) Kiriwrite language file.
-
[about]
name = English (British)
creator = Steve Brokenshire
+++ /dev/null
-#################################################################################
-# database.lib: Kiriwrite Database Library #
-# #
-# This library is under the same license as the main Kiriwrite script. #
-#################################################################################
-
-# This section of the file is for when the library is called from the main
-# Kiriwrite script.
-
-if ($form_data->{'action'}){
- # An action has been specified, so find out what action has been specified.
-
- 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($kiriwrite_lang->{database}->{adddatabase}, $pagedata, "database");
- exit;
-
- } else {
- # Another option has been specified, so return an error.
-
- kiriwrite_error("invalidaction");
- }
-}
-
-# 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.
-
-#################################################################################
-# Begin list of relevant subroutines. #
-#################################################################################
-
-sub kiriwrite_database_add{
-#################################################################################
-# kiriwrite_database_add: Creates a new database. #
-# #
-# Usage: #
-# #
-# kiriwrite_database_add(filename, name, description, notes, categories, #
-# [confirm]); #
-# #
-# filename Specifies the filename for the database. #
-# name Specifies a (friendly) name for the database. #
-# description Specifies a description for the database. #
-# notes Specifies the notes for the database. #
-# categories Specifies the categories for the database. #
-# confirm Confirms the action to create a database. #
-#################################################################################
-
- # Get the variables passed from the subroutine.
-
- my ($database_filename, $database_name, $database_description, $database_notes, $database_categories, $database_confirm) = @_;
-
- # Check if the confirm value is blank and if it is then
- # set the confirm value to 0.
-
- if (!$database_confirm){
-
- # The confirm value was blank so set the value to 0.
-
- $database_confirm = 0;
-
- }
-
- if ($database_confirm eq 1){
-
- # The action to create a new database is confirmed.
-
- # Validate the database name and database descriptions.
-
- my $database_name_check_utf8 = kiriwrite_variablecheck($database_name, "utf8", 0, 0);
- my $database_description_check_utf8 = kiriwrite_variablecheck($database_description, "utf8", 0, 0);
- my $database_notes_check_utf8 = kiriwrite_variablecheck($database_notes, "utf8", 0, 0);
- my $database_categories_check_utf8 = kiriwrite_variablecheck($database_categories, "utf8", 0, 0);
-
- # Convert the UTF8 strings before checking the length of the strings.
-
- $database_name = kiriwrite_utf8convert($database_name);
- $database_description = kiriwrite_utf8convert($database_description);
- $database_notes = kiriwrite_utf8convert($database_notes);
- $database_categories = kiriwrite_utf8convert($database_categories);
-
- my $database_name_check_blank = kiriwrite_variablecheck($database_name, "blank", 0, 1);
- my $database_name_check_length = kiriwrite_variablecheck($database_name, "maxlength", 256, 1);
- my $database_description_check_length = kiriwrite_variablecheck($database_description, "maxlength", 512, 1);
- my $database_filename_check_length = kiriwrite_variablecheck($database_filename, "maxlength", 32, 1);
- my $database_categories_check_length = kiriwrite_variablecheck($database_categories, "maxlength", 512, 1);
-
- # Check if values returned contains any values that would
- # result in a specific error message being returned.
-
- if ($database_name_check_length eq 1){
-
- # The length of the database name is too long, so return an error.
- kiriwrite_error("databasenametoolong");
-
- }
-
- if ($database_description_check_length eq 1){
-
- # The database description length is too long, so return an error.
- kiriwrite_error("databasedescriptiontoolong");
-
- }
-
- if ($database_name_check_blank eq 1){
-
- # The database name is blank, so return an error.
- kiriwrite_error("databasenameblank");
-
- }
-
- if ($database_filename_check_length eq 1){
-
- # The database filename is to long, so return an error.
- kiriwrite_error("databasefilenametoolong");
-
- }
-
- if ($database_categories_check_length eq 1){
-
- # The database categories is too long, so return an error.
- kiriwrite_error("databasecategoriestoolong");
-
- }
-
- # Check if the database filename is blank and if it is then
- # generate a filename.
-
- if ($database_filename eq ""){
-
- # Filename is blank so generate a file name from
- # the database name.
-
- $database_filename = kiriwrite_processfilename($database_name);
-
- } else {
-
- # Filename is not blank so don't generate a filename.
-
- }
-
- kiriwrite_variablecheck($database_filename, "filename", "", 0);
- kiriwrite_variablecheck($database_filename, "maxlength", 32, 0);
-
- # Connect to the database server.
-
- $kiriwrite_dbmodule->connect();
-
- # Check if any errors occured while connecting to the database server.
-
- if ($kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
-
- # A database connection error has occured so return
- # an error.
-
- kiriwrite_error("databaseconnectionerror", $kiriwrite_dbmodule->geterror(1));
-
- }
-
- my $database_name_final = $database_name;
-
- # Create the database.
-
- $kiriwrite_dbmodule->adddatabase({ DatabaseFilename => $database_filename, DatabaseName => $database_name, DatabaseDescription => $database_description, DatabaseNotes => $database_notes, DatabaseCategories => $database_categories, VersionMajor => $kiriwrite_version{"major"}, VersionMinor => $kiriwrite_version{"minor"}, VersionRevision => $kiriwrite_version{"revision"} });
-
- # Check if any errors have occured.
-
- if ($kiriwrite_dbmodule->geterror eq "DatabaseExists"){
-
- # A database with the filename given already exists, so
- # return an error.
-
- kiriwrite_error("fileexists");
-
- } elsif ($kiriwrite_dbmodule->geterror eq "DatabaseError"){
-
- # A database error has occured so return an error with
- # the extended error information.
-
- kiriwrite_error("databaseerror", $kiriwrite_dbmodule->geterror(1));
-
- }
-
- # Disconnect from the database server.
-
- $kiriwrite_dbmodule->disconnect();
-
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{database}->{adddatabase}, { Style => "pageheader" });
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext(kiriwrite_language($kiriwrite_lang->{database}->{databaseadded} , $database_name_final));
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlink($kiriwrite_env{"script_filename"} . "?mode=db", { Text => $kiriwrite_lang->{database}->{databaselistreturnlink} });
-
- return $kiriwrite_presmodule->grab();
-
- }
-
- # There is confirm value is not 1, so write a form for creating a database to
- # store pages in.
-
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{database}->{adddatabase}, { Style => "pageheader" });
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->startform($kiriwrite_env{"script_filename"}, "POST");
- $kiriwrite_presmodule->startbox();
- $kiriwrite_presmodule->addhiddendata("mode", "db");
- $kiriwrite_presmodule->addhiddendata("action", "new");
- $kiriwrite_presmodule->addhiddendata("confirm", "1");
- $kiriwrite_presmodule->endbox();
- $kiriwrite_presmodule->starttable("", { CellPadding => 5, CellSpacing => 0 });
-
- $kiriwrite_presmodule->startheader();
- $kiriwrite_presmodule->addheader($kiriwrite_lang->{common}->{setting}, { Style => "tablecellheader"});
- $kiriwrite_presmodule->addheader($kiriwrite_lang->{common}->{value}, { Style => "tablecellheader"});
- $kiriwrite_presmodule->endheader();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{database}->{databasename});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addinputbox("databasename", { Size => 64, MaxLength => 256 });
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{database}->{databasedescription});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addinputbox("databasedescription", { Size => 64, MaxLength => 512 });
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{database}->{databasecategories});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addinputbox("databasecategories", { Size => 64, MaxLength => 512 });
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{database}->{databasenotes});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addtextbox("databasenotes", { Columns => $kiriwrite_config{"display_textareacols"}, Rows => $kiriwrite_config{"display_textarearows"}, WordWrap => 0 });
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{database}->{databasefilename});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addinputbox("databasefilename", { Size => 32, MaxLength => 32 });
- $kiriwrite_presmodule->startlist();
- $kiriwrite_presmodule->additem($kiriwrite_lang->{database}->{adddatabaseautogenerate});
- $kiriwrite_presmodule->additem($kiriwrite_lang->{database}->{adddatabasenoextensions});
- $kiriwrite_presmodule->additem($kiriwrite_lang->{database}->{adddatabasecharacterlength});
- $kiriwrite_presmodule->additem($kiriwrite_lang->{database}->{adddatabasecharacters});
- $kiriwrite_presmodule->endlist();
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->endtable();
- $kiriwrite_presmodule->startbox();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addsubmit($kiriwrite_lang->{database}->{adddatabasebutton});
- $kiriwrite_presmodule->addtext("|");
- $kiriwrite_presmodule->addreset($kiriwrite_lang->{database}->{clearvaluesbutton});
- $kiriwrite_presmodule->addtext("| ");
- $kiriwrite_presmodule->addlink($kiriwrite_env{"script_filename"} . "?mode=db", { Text => $kiriwrite_lang->{database}->{databaselistreturnlink} });
- $kiriwrite_presmodule->endbox();
- $kiriwrite_presmodule->endform();
-
- # Exit the subroutine taking the data in the pagadata variable with it.
-
- return $kiriwrite_presmodule->grab();
-
-}
-
-sub kiriwrite_database_edit{
-#################################################################################
-# kiriwrite_database_edit: Edits an database. #
-# #
-# Usage: #
-# #
-# kiriwrite_database_edit(filename, newfilename, newname, newdescription, #
-# notes, categories, [confirm]); #
-# #
-# filename Specifies the filename of the database. #
-# newfilename Specifies the new filename of the database. #
-# newname Specifies the new name of the database. #
-# newdescription Specifies the new description of the database. #
-# notes Specifies the new notes of the database. #
-# categories Specifies the new categories of the database. #
-# confirm Confirms the action to edit a database. #
-#################################################################################
-
- # First, get all the variables passed to the subroutine.
-
- my ($database_shortname, $database_newfilename, $database_newname, $database_newdescription, $database_notes, $database_categories, $database_confirm) = @_;
-
- # Check if the database confirm value is blank and if it is
- # set the confirm value to 0.
-
- if (!$database_confirm){
-
- $database_confirm = 0;
-
- }
-
- # Check if the database filename given is valid and return an error
- # if it isn't.
-
- kiriwrite_variablecheck($database_shortname, "filename", "", 0);
-
- # Check if the confirm variable has a value in it, if it has, check again to make sure it really is the correct value (Perl moans
- # if $database_confirm was used directly).
-
- if ($database_confirm eq 1){
-
- # Check if the new data passes the validation tests below. First, check the length of the variables.
-
- my $database_name_check_utf8 = kiriwrite_variablecheck($database_newname, "utf8", 0, 0);
- my $database_description_check_utf8 = kiriwrite_variablecheck($database_newdescription, "utf8", 0, 0);
- my $database_notes_check_utf8 = kiriwrite_variablecheck($database_notes, "utf8", 0, 0);
- my $database_categories_check_utf8 = kiriwrite_variablecheck($database_categories, "utf8", 0, 0);
-
- # Convert the UTF8 strings to make sure their length is accurate.
-
- $database_newname = kiriwrite_utf8convert($database_newname);
- $database_newdescription = kiriwrite_utf8convert($database_newdescription);
- $database_notes = kiriwrite_utf8convert($database_notes);
- $database_categories = kiriwrite_utf8convert($database_categories);
-
- # Preform the following tests.
-
- my $database_filename_check_length = kiriwrite_variablecheck($database_newfilename, "maxlength", 32, 1);
- my $database_filename_letnum = kiriwrite_variablecheck($database_newfilename, "filename", 0, 0);
- my $database_name_check_length = kiriwrite_variablecheck($database_newname, "maxlength", 256, 1);
- my $database_description_check_length = kiriwrite_variablecheck($database_newdescription, "maxlength", 512, 1);
- my $database_categories_check_length = kiriwrite_variablecheck($database_categories, "maxlength", 512, 1);
- my $database_name_check_blank = kiriwrite_variablecheck($database_newname, "blank", 0, 1);
-
- # Check if the data is valid and return a specific error if it doesn't.
-
- if ($database_name_check_length eq 1){
-
- # The length of the database name is too long, so return an error.
- kiriwrite_error("databasenametoolong");
-
- }
-
- if ($database_description_check_length eq 1){
-
- # The database description length is too long, so return an error.
- kiriwrite_error("databasedescriptiontoolong");
-
- }
-
- if ($database_name_check_blank eq 1){
-
- # The database name is blank, so return an error.
- kiriwrite_error("databasenameblank");
-
- }
-
- if ($database_filename_check_length eq 1){
-
- # The database filename is too long, so return an error.
- kiriwrite_error("databasefilenametoolong");
-
- }
-
- if ($database_categories_check_length eq 1){
-
- # The database categories is too long, so return an error.
- kiriwrite_error("databasecategoriestoolong");
-
- }
-
- # Connect to the database server.
-
- $kiriwrite_dbmodule->connect();
-
- # Check if any errors occured while connecting to the database server.
-
- if ($kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
-
- # A database connection error has occured so return
- # an error.
-
- kiriwrite_error("databaseconnectionerror", $kiriwrite_dbmodule->geterror(1));
-
- }
-
- # Get the database.
-
- $kiriwrite_dbmodule->selectdb({ DatabaseName => $database_shortname });
-
- # Check if any errors had occured while selecting the database.
-
- if ($kiriwrite_dbmodule->geterror eq "DoesNotExist"){
-
- # The database does not exist, so return an error.
-
- kiriwrite_error("databasemissingfile");
-
- } elsif ($kiriwrite_dbmodule->geterror eq "InvalidPermissionsSet"){
-
- # The database has invalid permissions set, so return
- # an error.
-
- kiriwrite_error("databaseinvalidpermissions");
-
- }
-
- # FIX THIS!! >O
-
- $kiriwrite_dbmodule->editdatabase({ DatabaseNewFilename => $database_newfilename, DatabaseName => $database_newname , DatabaseDescription => $database_newdescription , DatabaseNotes => $database_notes, DatabaseCategories => $database_categories });
-
- # Check if any errors had occured while using the database.
-
- if ($kiriwrite_dbmodule->geterror eq "DoesNotExist"){
-
- # The database does not exist, so return an error.
-
- kiriwrite_error("databasemissingfile");
-
- } elsif ($kiriwrite_dbmodule->geterror eq "InvalidPermissionsSet"){
-
- # The database has invalid permissions set, so return
- # an error.
-
- kiriwrite_error("databaseinvalidpermissions");
-
- } elsif ($kiriwrite_dbmodule->geterror eq "DataDirInvalidPermissions"){
-
- # The database directory has invalid permissions set, so
- # return an error.
-
- kiriwrite_error("datadirectoryinvalidpermissions");
-
- } elsif ($kiriwrite_dbmodule->geterror eq "DatabaseExists"){
-
- # A database already exists with the new filename, so
- # return an error.
-
- kiriwrite_error("databasealreadyexists");
-
- } elsif ($kiriwrite_dbmodule->geterror eq "DatabaseError"){
-
- # A database error has occured so return an error with
- # the extended error information.
-
- kiriwrite_error("databaseerror", $kiriwrite_dbmodule->geterror(1));
-
- }
-
- # Disconnect from the server.
-
- $kiriwrite_dbmodule->disconnect();
-
- # Write out a message saying that the database has been updated.
-
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{database}->{editeddatabase}, { Style => "pageheader" } );
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext(kiriwrite_language($kiriwrite_lang->{database}->{databaseupdated}, $database_newname));
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlink($kiriwrite_env{"script_filename"} . "?mode=db", { Text => $kiriwrite_lang->{database}->{databaselistreturnlink} });
-
- return $kiriwrite_presmodule->grab();
-
- } else {
-
- my (%database_info);
-
- # Check if the database filename given is valid and return an error
- # if it isn't.
-
- # Connect to the database server.
-
- $kiriwrite_dbmodule->connect();
-
- # Check if any errors occured while connecting to the database server.
-
- if ($kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
-
- # A database connection error has occured so return
- # an error.
-
- kiriwrite_error("databaseconnectionerror", $kiriwrite_dbmodule->geterror(1));
-
- }
-
- # Select the database.
-
- $kiriwrite_dbmodule->selectdb({ DatabaseName => $database_shortname });
-
- # Check if any errors had occured while setting the database.
-
- if ($kiriwrite_dbmodule->geterror eq "DoesNotExist"){
-
- # The database does not exist, so return an error.
-
- kiriwrite_error("databasemissingfile");
-
- } elsif ($kiriwrite_dbmodule->geterror eq "InvalidPermissionsSet"){
-
- # The database has invalid permissions set, so return
- # an error.
-
- kiriwrite_error("databaseinvalidpermissions");
-
- }
-
- # Get the database information.
-
- %database_info = $kiriwrite_dbmodule->getdatabaseinfo();
-
- # Check if any errors had occured while getting the database
- # information.
-
- if ($kiriwrite_dbmodule->geterror eq "DatabaseError"){
-
- # A database error has occured so return an error and
- # also the extended error information.
-
- kiriwrite_error("databaseerror", $kiriwrite_dbmodule->geterror(1));
-
- }
-
- # Get the values needed from the kiriwrite_database_info table.
-
- my $database_oldname = $database_info{"DatabaseName"};
- my $database_olddescription = $database_info{"Description"};
- my $database_notes = $database_info{"Notes"};
- my $database_categories = $database_info{"Categories"};
-
- # Disconnect from the database server.
-
- $kiriwrite_dbmodule->disconnect();
-
- # Print out the form for editing a database's settings.
-
- $kiriwrite_presmodule->addtext(kiriwrite_language($kiriwrite_lang->{database}->{editdatabase}, $database_oldname), { Style => "pageheader" });
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->startform($kiriwrite_env{"script_filename"}, "POST");
- $kiriwrite_presmodule->startbox();
- $kiriwrite_presmodule->addhiddendata("mode", "db");
- $kiriwrite_presmodule->addhiddendata("action", "edit");
- $kiriwrite_presmodule->addhiddendata("database", $database_shortname);
- $kiriwrite_presmodule->addhiddendata("confirm", "1");
- $kiriwrite_presmodule->endbox();
-
- $kiriwrite_presmodule->starttable("", { CellPadding => 5, CellSpacing => 0 });
- $kiriwrite_presmodule->startheader();
- $kiriwrite_presmodule->addheader("Setting", { Style => "tablecellheader" });
- $kiriwrite_presmodule->addheader("Value", { Style => "tablecellheader" });
- $kiriwrite_presmodule->endheader();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{database}->{databasename});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addinputbox("databasename", { Size => 64, MaxLength => 256, Value => $database_oldname } );
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{database}->{databasedescription});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addinputbox("databasedescription", { Size => 64, MaxLength => 512, Value => $database_olddescription } );
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{database}->{databasecategories});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addinputbox("databasecategories", { Size => 64, MaxLength => 512, Value => $database_categories } );
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{database}->{databasenotes});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addtextbox("databasenotes", { Columns => $kiriwrite_config{"display_textareacols"}, Rows => $kiriwrite_config{"display_textarearows"}, Value => $database_notes } );
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{database}->{databasefilename});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addinputbox("databasefilename", { Size => 32, MaxLength => 32, Value => $database_shortname } );
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->endtable();
-
- $kiriwrite_presmodule->startbox();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addsubmit($kiriwrite_lang->{database}->{editdatabasebutton});
- $kiriwrite_presmodule->addtext(" | ");
- $kiriwrite_presmodule->addreset($kiriwrite_lang->{common}->{restorecurrent});
- $kiriwrite_presmodule->addtext(" | ");
- $kiriwrite_presmodule->addlink($kiriwrite_env{"script_filename"} . "?mode=db", { Text => $kiriwrite_lang->{database}->{databaselistreturnlink} });
- $kiriwrite_presmodule->endbox();
- $kiriwrite_presmodule->endform();
-
- return $kiriwrite_presmodule->grab();
-
- }
-
- # The interpreter should not be here. So return an error saying invalid variable.
-
- kiriwrite_error("invalidvariable");
-
-}
-
-sub kiriwrite_database_delete{
-#################################################################################
-# kiriwrite_database_delete: Deletes an database. #
-# #
-# Usage: #
-# #
-# kiriwrite_database_delete(filename, [confirm]); #
-# #
-# filename Specifies the filename for the database to be deleted. #
-# confirm Confirms the action to delete a database. #
-#################################################################################
-
- my ($database_filename, $database_confirm) = @_;
-
- # Check if the confirm value is blank and if it is then set the
- # confirm value to 0.
-
- if (!$database_confirm){
-
- $database_confirm = 0;
-
- }
-
- # Connect to the database server.
-
- $kiriwrite_dbmodule->connect();
-
- # Check if any errors occured while connecting to the database server.
-
- if ($kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
-
- # A database connection error has occured so return
- # an error.
-
- kiriwrite_error("databaseconnectionerror", $kiriwrite_dbmodule->geterror(1));
-
- }
-
- # Check if the database filename given is valid and return an error
- # if it isn't.
-
- kiriwrite_variablecheck($database_filename, "filename", "", 0);
-
- # Check if the request to delete a database has been confirmed. If it has,
- # then delete the database itself.
-
- if ($database_confirm eq 1){
- # There is a value in the confirm variable of the HTTP query.
-
- # Select the database to delete and get the database name.
-
- $kiriwrite_dbmodule->selectdb({ DatabaseName => $database_filename });
-
- # Check if any error occured while selecting the database.
-
- if ($kiriwrite_dbmodule->geterror eq "DoesNotExist"){
-
- # The database does not exist so return an error.
-
- kiriwrite_error("databasemissingfile");
-
- } elsif ($kiriwrite_dbmodule->geterror eq "InvalidPermissionsSet") {
-
- # The database has invalid permissions set so return
- # an error.
-
- kiriwrite_error("databaseinvalidpermissions");
-
- }
-
- my %database_info = $kiriwrite_dbmodule->getdatabaseinfo();
-
- # Check if any errors have occured while getting the database
- # name.
-
- if ($kiriwrite_dbmodule->geterror eq "DatabaseError"){
-
- # A database error has occured so return an error with
- # the extended error information.
-
- kiriwrite_error("databaseerror", $kiriwrite_dbmodule->geterror(1));
-
- }
-
- my $database_name = $database_info{"DatabaseName"};
-
- # Delete the selected database.
-
- $kiriwrite_dbmodule->deletedatabase({ DatabaseName => $database_filename });
-
- # Check if any error occured while deleting the database.
-
- if ($kiriwrite_dbmodule->geterror eq "DoesNotExist"){
-
- # The database does not exist so return an error.
-
- kiriwrite_error("databasemissingfile");
-
- } elsif ($kiriwrite_dbmodule->geterror eq "InvalidPermissionsSet") {
-
- # The database has invalid permissions set so return
- # an error.
-
- kiriwrite_error("databaseinvalidpermissions");
-
- }
-
- # Disconnect from the database server.
-
- $kiriwrite_dbmodule->disconnect();
-
- # Write a message saying that the database has been deleted.
-
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{database}->{deleteddatabase}, { Style => "pageheader" });
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext(kiriwrite_language($kiriwrite_lang->{database}->{deleteddatabasemessage}, $database_name));
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlink($kiriwrite_env{"script_filename"} . "?mode=db", { Text => $kiriwrite_lang->{database}->{databaselistreturnlink} });
-
- return $kiriwrite_presmodule->grab();
-
- }
-
- # The action has not been confirmed, so write out a form asking the
- # user to confirm.
-
- # Get the database name.
-
- $kiriwrite_dbmodule->selectdb({ DatabaseName => $database_filename });
-
- # Check if any error occured while selecting the database.
-
- if ($kiriwrite_dbmodule->geterror eq "DoesNotExist"){
-
- # The database does not exist so return an error.
-
- kiriwrite_error("databasemissingfile");
-
- } elsif ($kiriwrite_dbmodule->geterror eq "InvalidPermissionsSet") {
-
- # The database has invalid permissions set so return
- # an error.
-
- kiriwrite_error("databaseinvalidpermissions");
-
-
- }
-
- # Check if any errors have occured.
-
- my %database_info = $kiriwrite_dbmodule->getdatabaseinfo();
-
- if ($kiriwrite_dbmodule->geterror eq "DatabaseError"){
-
- # A database error has occured so return an error with
- # the extended error information.
-
- kiriwrite_error("databaseerror", $kiriwrite_dbmodule->geterror(1));
-
- }
-
- my $database_name = $database_info{"DatabaseName"};
-
- # Disconnect from the database server.
-
- $kiriwrite_dbmodule->disconnect();
-
- # Write out the form to ask the user to confirm the deletion of the
- # selected database.
-
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{database}->{deletedatabase}, { Style => "pageheader" });
- $kiriwrite_presmodule->startform($kiriwrite_env{"script_filename"}, "POST");
- $kiriwrite_presmodule->startbox();
- $kiriwrite_presmodule->addhiddendata("mode", "db");
- $kiriwrite_presmodule->addhiddendata("action", "delete");
- $kiriwrite_presmodule->addhiddendata("database", $database_filename);
- $kiriwrite_presmodule->addhiddendata("confirm", "1");
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext(kiriwrite_language($kiriwrite_lang->{database}->{deletedatabasemessage}, $database_name));
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addsubmit($kiriwrite_lang->{database}->{deletedatabasebutton});
- $kiriwrite_presmodule->addtext(" | ");
- $kiriwrite_presmodule->addlink($kiriwrite_env{"script_filename"} . "?mode=db", { Text => $kiriwrite_lang->{database}->{deletedatabasereturn} });
- $kiriwrite_presmodule->endbox();
- $kiriwrite_presmodule->endform();
-
- return $kiriwrite_presmodule->grab();
-
-}
-
-sub kiriwrite_database_list{
-#################################################################################
-# kiriwrite_database_list: Lists the databases available. #
-# #
-# Usage: #
-# #
-# kiriwrite_database_list(); #
-#################################################################################
-
- # Connect to the database server.
-
- $kiriwrite_dbmodule->connect();
-
- # Check if any errors occured while connecting to the database server.
-
- if ($kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
-
- # A database connection error has occured so return
- # an error.
-
- kiriwrite_error("databaseconnectionerror", $kiriwrite_dbmodule->geterror(1));
-
- }
-
- # Get the list of available databases and process any errors that
- # might have occured.
-
- my @database_list = $kiriwrite_dbmodule->getdblist();
-
- if ($kiriwrite_dbmodule->geterror eq "DataDirMissing"){
-
- # The database directory is missing so return an error.
-
- kiriwrite_error("datadirectorymissing");
-
- } elsif ($kiriwrite_dbmodule->geterror eq "DataDirInvalidPermissions"){
-
- # The database directory has invalid permissions set so return
- # an error.
-
- kiriwrite_error("datadirectoryinvalidpermissions");
-
- }
-
- # Declare the following variables that are going to be used before using
- # the foreach function.
-
- my ($database_info, %database_info);
- my @error_list;
- my @permissions_list;
- my $database_count = 0;
- my $database_filename = "";
- my $database_filename_friendly = "";
- my $database_filename_length = 0;
- my $database_name = "";
- my $database_description = "";
- my $database_permissions = "";
- my $nodescription = 0;
- my $noname = 0;
- my $data_file = "";
- my $table_style = 0;
- my $table_style_name = "";
-
- # Begin creating the table for the list of databases.
-
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{database}->{databaselist}, { Style => "pageheader" });
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->starttable("", { CellPadding => "5", CellSpacing => "0" });
- $kiriwrite_presmodule->startheader();
- $kiriwrite_presmodule->addheader($kiriwrite_lang->{database}->{databasename}, { Style => "tablecellheader" });
- $kiriwrite_presmodule->addheader($kiriwrite_lang->{database}->{databasedescription}, { Style => "tablecellheader" });
- $kiriwrite_presmodule->addheader($kiriwrite_lang->{database}->{databaseoptions}, { Style => "tablecellheader" });
- $kiriwrite_presmodule->endheader();
-
- foreach $data_file (@database_list){
-
- # Select the database.
-
- $kiriwrite_dbmodule->selectdb({ DatabaseName => $data_file });
-
- # Check if any error occured while selecting the database.
-
- if ($kiriwrite_dbmodule->geterror eq "DoesNotExist"){
-
- # The database does not exist, so process the next
- # database.
-
- next;
-
- } elsif ($kiriwrite_dbmodule->geterror eq "InvalidPermissionsSet") {
-
- # The database has invalid permissions settings, so
- # add the database to the list of databases with
- # invalid permissions set and process the next
- # database.
-
- push(@permissions_list, $data_file);
- next;
-
- }
-
- # Get information about the database.
-
- %database_info = $kiriwrite_dbmodule->getdatabaseinfo();
-
- # Check if any error occured while getting information from the
- # database.
-
- if ($kiriwrite_dbmodule->geterror eq "DatabaseError"){
-
- # A database error has occured, add the database and specific
- # error message to the list of databases with errors and
- # process the next database.
-
- push(@error_list, $data_file . ": " . $kiriwrite_dbmodule->geterror(1));
- next;
-
- }
-
- $database_name = $database_info{"DatabaseName"};
- $database_description = $database_info{"Description"};
-
- # Check the style to be used with.
-
- if ($table_style eq 0){
-
- # Use the first style and set the style value
- # to use the next style, the next time the
- # if statement is checked.
-
- $table_style_name = "tablecell1";
- $table_style = 1;
- } else {
-
- # Use the second style and set the style
- # value to use the first style, the next
- # time if statement is checked.
-
- $table_style_name = "tablecell2";
- $table_style = 0;
- }
-
- # Create a friendly name for the database.
-
- $database_filename_friendly = $data_file;
-
- # Append the database information to the table.
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell($table_style_name);
-
- if (!$database_name){
- $kiriwrite_presmodule->additalictext($kiriwrite_lang->{blank}->{noname});
- } else {
- $kiriwrite_presmodule->addlink($kiriwrite_env{"script_filename"} . "?mode=page&action=view&database=" . $database_filename_friendly, { Text => $database_name });
- }
-
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell($table_style_name);
-
- if (!$database_description){
- $kiriwrite_presmodule->additalictext($kiriwrite_lang->{blank}->{nodescription});
- } else {
- $kiriwrite_presmodule->addtext($database_description);
- }
-
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell($table_style_name);
- $kiriwrite_presmodule->addlink($kiriwrite_env{'script_filename'} . "?mode=db&action=edit&database=" . $database_filename_friendly, { Text => $kiriwrite_lang->{options}->{edit} });
- $kiriwrite_presmodule->addlink($kiriwrite_env{'script_filename'} . "?mode=compile&action=compile&type=single&database=" . $database_filename_friendly, { Text => $kiriwrite_lang->{options}->{compile} });
- $kiriwrite_presmodule->addlink($kiriwrite_env{'script_filename'} . "?mode=db&action=delete&database=" . $database_filename_friendly, { Text => $kiriwrite_lang->{options}->{delete} });
- $kiriwrite_presmodule->endrow();
-
- $database_count++;
- $nodescription = 0;
- $noname = 0;
-
- }
-
- $kiriwrite_presmodule->endtable();
-
- # Disconnect from the database server.
-
- $kiriwrite_dbmodule->disconnect();
-
- # Check if there are no valid databases are if there is no
- # valid databases then write a message saying that no
- # valid databases are available.
-
- if ($database_count eq 0){
-
- $kiriwrite_presmodule->clear();
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{database}->{databaselist}, { Style => "pageheader" });
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->startbox("errorbox");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{database}->{nodatabasesavailable});
- $kiriwrite_presmodule->endbox();
-
- }
-
- # Check if any databases with problems have appeared and if they
- # have, print out a message saying which databases have problems.
-
- if (@permissions_list){
-
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{database}->{databaseinvalidpermissions}, { Style => "smallpageheader" });
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{database}->{databaseinvalidpermissionstext});
- $kiriwrite_presmodule->addlinebreak();
-
- foreach $data_file (@permissions_list){
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext($data_file);
- }
-
- $kiriwrite_presmodule->addlinebreak();
-
- }
-
- if (@error_list){
-
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{database}->{databaseerrors}, { Style => "smallpageheader" });
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{database}->{databaseerrorstext});
- $kiriwrite_presmodule->addlinebreak();
-
- foreach $data_file (@error_list){
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext($data_file);
- }
-
- $kiriwrite_presmodule->addlinebreak();
-
- }
-
- return $kiriwrite_presmodule->grab(); # Return to the main part of the script with the processed information.
-
-}
-
-1;
+++ /dev/null
-#################################################################################
-# filter.lib: Kiriwrite Filter Library #
-# #
-# This library is under the same license as the main Kiriwrite script. #
-#################################################################################
-
-# This section of the file is for when the library is called from the main
-# Kiriwrite script.
-
-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 {
-
- 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.
-
-}
-
-#################################################################################
-# Begin list of relevant subroutines. #
-#################################################################################
-
-sub kiriwrite_filter_list{
-#################################################################################
-# kiriwrite_filter_list: Lists the filters that will be used when compiling a #
-# webpage. #
-# #
-# Usage: #
-# #
-# kiriwrite_filter_list([browsenumber]); #
-# #
-# browsenumber Specifies the page browse number to use. #
-#################################################################################
-
- my $filter_browsenumber = shift;
-
- my $filtersdb_notexist = 0;
-
- # Connect to the database server.
-
- $kiriwrite_dbmodule->connect();
-
- # Check if any errors occured while connecting to the database server.
-
- if ($kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
-
- # A database connection error has occured so return
- # an error.
-
- kiriwrite_error("databaseconnectionerror", $kiriwrite_dbmodule->geterror(1));
-
- }
-
- # Connect to the filter database.
-
- $kiriwrite_dbmodule->connectfilter();
-
- # Check if any error has occured while connecting to the filter
- # database.
-
- if ($kiriwrite_dbmodule->geterror eq "FilterDatabaseDoesNotExist"){
-
- # The filter database does not exist.
-
- $filtersdb_notexist = 1;
-
- } elsif ($kiriwrite_dbmodule->geterror eq "FilterDatabaseInvalidPermissionsSet"){
-
- # The filter database has invalid permissions set so return
- # an error.
-
- kiriwrite_error("filtersdbpermissions");
-
- } elsif ($kiriwrite_dbmodule->geterror eq "FilterDatabaseError"){
-
- # A database error has occured with the filter database.
-
- kiriwrite_error("filtersdbdatabaseerror", $kiriwrite_dbmodule->geterror(1));
-
- }
-
- # Define some variables required for processing the filters list.
-
- my %filter_list;
- my %filter_info;
- my @database_filters;
- my $blankfindfilter = 0;
- my $filterswarning = "";
- my $filter;
- my $filter_split = $kiriwrite_config{"display_filtercount"};
- my $filter_list = 0;
- my $filter_count = 0;
- my $filter_style = 0;
- my $filter_list_count = 0;
- my $filter_style_name = "";
-
- tie(%filter_list, 'Tie::IxHash');
-
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{filter}->{viewfilters}, { Style => "pageheader" });
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
-
- # If the filter database exists then get the list of filters,
- # otherwise write a message saying that the filter database
- # does not exist and will be created when a filter is added.
-
- if ($filtersdb_notexist eq 0){
-
- if (!$filter_browsenumber || $filter_browsenumber eq 0){
-
- $filter_browsenumber = 1;
-
- }
-
- # Check if the filter browse number is valid and if it isn't
- # then return an error.
-
- my $kiriwrite_browsenumber_length_check = kiriwrite_variablecheck($filter_browsenumber, "maxlength", 7, 1);
- my $kiriwrite_browsenumber_number_check = kiriwrite_variablecheck($filter_browsenumber, "numbers", 0, 1);
-
- if ($kiriwrite_browsenumber_length_check eq 1){
-
- # The browse number was too long so return
- # an error.
-
- kiriwrite_error("browsenumbertoolong");
-
- }
-
- if ($kiriwrite_browsenumber_number_check eq 1){
-
- # The browse number wasn't a number so
- # return an error.
-
- kiriwrite_error("browsenumberinvalid");
-
- }
-
- # Get the total count of filters in the filter database.
-
- my $filter_total_count = $kiriwrite_dbmodule->getfiltercount();
-
- # Check if any errors occured while getting the count of filters.
-
- if ($kiriwrite_dbmodule->geterror eq "FilterDatabaseError"){
-
- # A database error has occured with the filter database.
-
- kiriwrite_error("filtersdbdatabaseerror", $kiriwrite_dbmodule->geterror(1));
-
- }
-
- if ($filter_total_count ne 0){
-
- if ($filter_total_count eq $filter_split){
-
- $filter_list = int(($filter_total_count / $filter_split));
-
- } else {
-
- $filter_list = int(($filter_total_count / $filter_split) + 1);
-
- }
-
- }
-
- my $start_from = ($filter_browsenumber - 1) * $filter_split;
-
- # Get the list of available filters.
-
- @database_filters = $kiriwrite_dbmodule->getfilterlist({ StartFrom => $start_from, Limit => $filter_split });
-
- # Check if any errors occured while getting the list of filters.
-
- if ($kiriwrite_dbmodule->geterror eq "FilterDatabaseError"){
-
- # A database error has occured with the filter database.
-
- kiriwrite_error("filtersdbdatabaseerror", $kiriwrite_dbmodule->geterror(1));
-
- }
-
- # Process each filter getting the priority, find setting and
- # replace setting.
-
- foreach $filter (@database_filters){
-
- # Get the information about the filter.
-
- %filter_info = $kiriwrite_dbmodule->getfilterinfo({ FilterID => $filter });
-
- # Check if any errors occured while getting the filter information.
-
- if ($kiriwrite_dbmodule->geterror eq "FilterDatabaseError"){
-
- # A database error occured while using the filter database.
-
- kiriwrite_error("filtersdbdatabaseerror", $kiriwrite_dbmodule->geterror(1));
-
- } elsif ($kiriwrite_dbmodule->geterror eq "FilterDoesNotExist"){
-
- # The filter does not exist so process the next filter.
-
- next;
-
- }
-
- # Check if the find filter is blank.
-
- if (!$filter_info{"FilterFind"}){
-
- # The find filter is blank, so set the value to write a warning
- # message saying that a find filter given is blank.
-
- $blankfindfilter = 1;
-
- }
-
- $filter_list{$filter_count}{ID} = $filter_info{"FilterID"};
- $filter_list{$filter_count}{Priority} = $filter_info{"FilterPriority"};
- $filter_list{$filter_count}{Find} = $filter_info{"FilterFind"};
- $filter_list{$filter_count}{Replace} = $filter_info{"FilterReplace"};
- $filter_list{$filter_count}{Enabled} = $filter_info{"FilterEnabled"};
- $filter_list{$filter_count}{Notes} = $filter_info{"FilterNotes"};
-
- $filter_count++;
-
- }
-
- # Check if there are filters in the filter database and
- # write a message if there isn't.
-
- }
-
- # Check if the database wasn't found and if it
- # wasn't then write a message saying that the
- # database will be created when a filter is
- # added.
-
- if ($filtersdb_notexist eq 1){
-
- # The filter database doesn't exist so write
- # a message.
-
- $kiriwrite_presmodule->clear();
- $kiriwrite_presmodule->addtext(kiriwrite_language($kiriwrite_lang->{filter}->{viewfilters}, $db_name), { Style => "pageheader" });
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->startbox("errorbox");
- $kiriwrite_presmodule->enterdata($kiriwrite_lang->{filter}->{filterdatabasedoesnotexist});
- $kiriwrite_presmodule->endbox();
-
- # Disconnect from the filter database.
-
- $kiriwrite_dbmodule->disconnectfilter();
-
- # Disconnect from the database server.
-
- $kiriwrite_dbmodule->disconnect();
- return $kiriwrite_presmodule->grab();
-
- }
-
- # Check if there is a warning message and if
- # there is then write that warning message
- # else write the list of filters.
-
- if ($filterswarning){
-
- $kiriwrite_presmodule->startbox("errorbox");
- $kiriwrite_presmodule->addtext($filterswarning);
- $kiriwrite_presmodule->endbox();
-
- } elsif ($filter_count) {
-
- # The filter database exists so write out the
- # list of filters.
-
- if ($blankfindfilter eq 1){
-
- $kiriwrite_presmodule->addboldtext($kiriwrite_lang->{filter}->{warningtitle});
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{filter}->{blankfindfilters});
- $kiriwrite_presmodule->addtext();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
-
- }
-
- # Start a form for using the filter browsing list with.
-
- $kiriwrite_presmodule->startform($kiriwrite_env{"script_filename"}, "GET");
- $kiriwrite_presmodule->addhiddendata("mode", "filter");
-
- # Write out the filter browsing list.
-
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{filter}->{showlistpage});
- $kiriwrite_presmodule->addselectbox("browsenumber");
-
- # Write out the list of available pages to browse.
-
- while ($filter_list_count ne $filter_list){
-
- $filter_list_count++;
-
- if ($filter_list_count eq 1 && !$filter_browsenumber){
-
- $kiriwrite_presmodule->addoption($filter_list_count, { Value => $filter_list_count, Selected => 1 });
-
- } else {
-
- if ($filter_browsenumber eq $filter_list_count){
-
- $kiriwrite_presmodule->addoption($filter_list_count, { Value => $filter_list_count, Selected => 1 });
-
- } else {
-
- $kiriwrite_presmodule->addoption($filter_list_count, { Value => $filter_list_count });
-
- }
-
- }
-
- }
-
- $kiriwrite_presmodule->endselectbox();
- $kiriwrite_presmodule->addbutton("action", { Value => "view", Description => $kiriwrite_lang->{filter}->{show} });
-
- if ($filter_list ne $filter_browsenumber){
-
- $kiriwrite_presmodule->addtext(" | ");
- $kiriwrite_presmodule->addlink($kiriwrite_env{"script_filename"} . "?mode=filter&action=view&browsenumber=" . ($filter_browsenumber + 1), { Text => $kiriwrite_lang->{filter}->{nextpage} });
-
- }
-
- # Check if the filter browse number is not blank and
- # not set as 0 and hide the Previous page link if
- # it is.
-
- if ($filter_browsenumber > 1){
-
- $kiriwrite_presmodule->addtext(" | ");
- $kiriwrite_presmodule->addlink($kiriwrite_env{"script_filename"} . "?mode=filter&action=view&browsenumber=" . ($filter_browsenumber - 1), { Text => $kiriwrite_lang->{filter}->{previouspage} });
-
- }
-
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
-
- $kiriwrite_presmodule->starttable("", { CellPadding => 5, CellSpacing => 0 });
-
- $kiriwrite_presmodule->startheader();
- $kiriwrite_presmodule->addheader($kiriwrite_lang->{filter}->{priority}, { Style => "tablecellheader" });
- $kiriwrite_presmodule->addheader($kiriwrite_lang->{filter}->{findsetting}, { Style => "tablecellheader" });
- $kiriwrite_presmodule->addheader($kiriwrite_lang->{filter}->{replacesetting}, { Style => "tablecellheader" });
- $kiriwrite_presmodule->addheader($kiriwrite_lang->{common}->{options}, { Style => "tablecellheader" });
- $kiriwrite_presmodule->endheader();
-
- foreach $filter (keys %filter_list){
-
- # Check which style should be used.
-
- if ($filter_style eq 0){
-
- $filter_style_name = "tablecell1";
- $filter_style = 1;
-
- } else {
-
- $filter_style_name = "tablecell2";
- $filter_style = 0;
-
- }
-
- # Check if the filter is disabled.
-
- if (!$filter_list{$filter}{Enabled}){
-
- $filter_style_name = "tablecelldisabled";
-
- }
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell($filter_style_name);
- $kiriwrite_presmodule->addtext($filter_list{$filter}{Priority});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell($filter_style_name);
-
- # Check if the find filter is blank.
-
- if (!$filter_list{$filter}{Find}){
-
- # The find filter is blank.
-
- $kiriwrite_presmodule->additalictext($kiriwrite_lang->{filter}->{blankfindsetting});
-
- } else {
-
- # The find filter is not blank.
-
- $kiriwrite_presmodule->addtext($filter_list{$filter}{Find});
-
- }
-
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell($filter_style_name);
-
- # Check if the replace filter is blank.
-
- if (!$filter_list{$filter}{Replace}){
-
- # The replace filter is blank.
-
- $kiriwrite_presmodule->additalictext($kiriwrite_lang->{filter}->{blankreplacesetting});
-
- } else {
-
- # The replace filter is not blank.
-
- $kiriwrite_presmodule->addtext($filter_list{$filter}{Replace});
-
- }
-
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell($filter_style_name);
- $kiriwrite_presmodule->addlink("?mode=filter&action=edit&filter=" . $filter_list{$filter}{ID}, { Text => $kiriwrite_lang->{options}->{edit} });
- $kiriwrite_presmodule->addlink("?mode=filter&action=delete&filter=" . $filter_list{$filter}{ID}, { Text => $kiriwrite_lang->{options}->{delete} });
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- }
-
- $kiriwrite_presmodule->endtable();
- $kiriwrite_presmodule->endform();
-
- }
-
- if (!$filter_total_count){
-
- $filter_total_count = "";
-
- }
-
- if ($filter_browsenumber > 1 && !@database_filters){
-
- # There were no values given for the page browse
- # number given so write a message saying that
- # there were no pages for the page browse number
- # given.
-
- $kiriwrite_presmodule->clear();
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{filter}->{viewfilters}, { Style => "pageheader" });
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->startbox("errorbox");
- $kiriwrite_presmodule->enterdata($kiriwrite_lang->{filter}->{nofiltersinpagebrowse});
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlink($kiriwrite_env{"script_filename"} . "?mode=filter", { Text => $kiriwrite_lang->{filter}->{returntofirstpagebrowse} });
- $kiriwrite_presmodule->endbox();
-
- } elsif (!@database_filters || !$filter_count || $filter_total_count eq 0){
-
- # There are no filters in the filter database.
-
- $kiriwrite_presmodule->clear();
- $kiriwrite_presmodule->addtext(kiriwrite_language($kiriwrite_lang->{filter}->{viewfilters}), { Style => "pageheader" });
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->startbox("errorbox");
- $kiriwrite_presmodule->enterdata($kiriwrite_lang->{filter}->{nofiltersavailable});
- $kiriwrite_presmodule->endbox();
-
- }
-
- # Disconnect from the filter database.
-
- $kiriwrite_dbmodule->disconnectfilter();
-
- # Disconnect from the database server.
-
- $kiriwrite_dbmodule->disconnect();
-
- return $kiriwrite_presmodule->grab();
-
-}
-
-sub kiriwrite_filter_add{
-#################################################################################
-# kiriwrite_filter_add: Adds a filter to the filter list. #
-# #
-# Usage: #
-# #
-# kiriwrite_filter_add(options); #
-# #
-# options Specifies the following options as a hash (in any order). #
-# #
-# FindFilter Specifies the find filter setting. #
-# ReplaceFilter Specifies the replace filter setting. #
-# Priority Specifies the priority of the filter. #
-# Enabled Specifies if the filter should be enabled. #
-# Notes Specifies some notes about the filter. #
-# Confirm Specifies if the filter should be added. #
-#################################################################################
-
- # Get the values that have been passed to the subroutine.
-
- my ($options) = @_;
-
- $confirm = $options->{"Confirm"};
-
- # Check the confirm value to make sure it is no more than
- # one character long.
-
- kiriwrite_variablecheck($confirm, "maxlength", 1, 0);
-
- if (!$confirm){
-
- # The confirm value is undefined, so set the
- # value of the confirm integer to '0'.
-
- $confirm = 0;
-
- }
-
- if ($confirm eq 1){
-
- # The confirm integer is '1', so add the word
- # to the filter list.
-
- # Get the values from the hashref.
-
- my $filter_new_find = $options->{"FindFilter"};
- my $filter_new_replace = $options->{"ReplaceFilter"};
- my $filter_new_priority = $options->{"Priority"};
- my $filter_new_enabled = $options->{"Enabled"};
- my $filter_new_notes = $options->{"Notes"};
-
- # First, check the variables recieved are UTF8
- # copliant.
-
- kiriwrite_variablecheck($filter_new_find, "utf8", 0, 0);
- kiriwrite_variablecheck($filter_new_replace, "utf8", 0, 0);
- kiriwrite_variablecheck($filter_new_priority, "utf8", 0, 0);
- kiriwrite_variablecheck($filter_new_notes, "utf8", 0, 0);
-
- # Convert the UTF8 values so that the length can
- # checked properly.
-
- $filter_new_find = kiriwrite_utf8convert($filter_new_find);
- $filter_new_replace = kiriwrite_utf8convert($filter_new_replace);
- $filter_new_priority = kiriwrite_utf8convert($filter_new_priority);
- $filter_new_notes = kiriwrite_utf8convert($filter_new_notes);
-
- # Check if the find filter is blank and return an error
- # if it is.
-
- if (!$filter_new_find){
-
- # The find filter given is blank so return an
- # error.
-
- kiriwrite_error("blankfindfilter");
-
- }
-
- if (!$filter_new_priority){
-
- # The filter priority is blank so set it
- # to 1.
-
- $filter_new_priority = 1;
-
- }
-
- # Check if the enabled value is either "on" or
- # blank and return an error if it is something
- # else.
-
- if (!$filter_new_enabled || $filter_new_enabled ne "off"){
-
- } else {
-
- # FINISH THIS.
-
- }
-
- # Check if the new filter should be enabled.
-
- my $filter_enable = 0;
-
- if (!$filter_new_enabled){
-
- $filter_new_enabled = "off";
-
- }
-
- if ($filter_new_enabled eq "on"){
-
- # The filter is enabled.
-
- $filter_enable = 1;
-
- }
-
- # Check the length and contents of the values given
- # to make sure they are valid.
-
- my $filterfind_maxlength_check = kiriwrite_variablecheck($filter_new_find, "maxlength", 1024, 1);
- my $filterreplace_maxlength_check = kiriwrite_variablecheck($filter_new_replace, "maxlength", 1024, 1);
- my $filterpriority_maxlength_check = kiriwrite_variablecheck($filter_new_priority, "maxlength", 5, 1);
- my $filterpriority_numbers_check = kiriwrite_variablecheck($filter_new_priority, "numbers", 0, 1);
-
- # Check if the result of the tests to see if they
- # are valid.
-
- if ($filterfind_maxlength_check eq 1){
-
- # The find filter is too long, so return
- # an error.
-
- kiriwrite_error("findfiltertoolong");
-
- }
-
- if ($filterreplace_maxlength_check eq 1){
-
- # The replace filter is too long, so
- # return an error.
-
- kiriwrite_error("replacefiltertoolong");
-
- }
-
- if ($filterpriority_maxlength_check eq 1){
-
- # The length of the filter priority
- # given is too long, so return an
- # error.
-
- kiriwrite_error("filterprioritytoolong");
-
- }
-
- if ($filterpriority_numbers_check eq 1){
-
- # The priority of the filter given
- # contains characters other than
- # numbers.
-
- kiriwrite_error("filterpriorityinvalidchars");
-
- }
-
- # Check if the filter priority is less than 1
- # and more than 10000 and return an error
- # if it is.
-
- if ($filter_new_priority < 1 || $filter_new_priority > 50000){
-
- # The filter priority is less than 1 and
- # more than 10000, so return an error.
-
- kiriwrite_error("filterpriorityinvalid");
-
- }
-
- # Connect to the database server.
-
- $kiriwrite_dbmodule->connect();
-
- # Check if any errors occured while connecting to the database server.
-
- if ($kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
-
- # A database connection error has occured so return
- # an error.
-
- kiriwrite_error("databaseconnectionerror", $kiriwrite_dbmodule->geterror(1));
-
- }
-
- # Connect to the filter database.
-
- $kiriwrite_dbmodule->connectfilter(1);
-
- # Check if any error has occured while connecting to the filter
- # database.
-
- if ($kiriwrite_dbmodule->geterror eq "FilterDatabaseDoesNotExist"){
-
- # The filter database does not exist.
-
- kiriwrite_error("filtersdbmissing");
-
- } elsif ($kiriwrite_dbmodule->geterror eq "FilterDatabaseInvalidPermissionsSet"){
-
- # The filter database has invalid permissions set so return
- # an error.
-
- kiriwrite_error("filtersdbpermissions");
-
- }
-
- # Add the filter to the filter database.
-
- $kiriwrite_dbmodule->addfilter({ FindFilter => $filter_new_find, ReplaceFilter => $filter_new_replace, Priority => $filter_new_priority, Enabled => $filter_enable, Notes => $filter_new_notes});
-
- # Check if any errors have occured while adding the filter.
-
- if ($kiriwrite_dbmodule->geterror eq "FilterDatabaseInvalidPermissionsSet"){
-
- # The filter database has invalid permissions set so return
- # an error.
-
- kiriwrite_error("filtersdbpermissions");
-
- } elsif ($kiriwrite_dbmodule->geterror eq "FilterDatabaseUncreatable"){
-
- # The filter database is uncreatable so return an error.
-
- kiriwrite_error("filterdatabase");
-
- } elsif ($kiriwrite_dbmodule->geterror eq "FilterDatabaseError"){
-
- # A database error with the filter database has occured so return
- # an error with the extended error information.
-
- kiriwrite_error("filtersdbdatabaseerror", $kiriwrite_dbmodule->geterror(1));
-
- }
-
- # Disconnect from the filter database.
-
- $kiriwrite_dbmodule->disconnectfilter();
-
- # Disconnect from the database server.
-
- $kiriwrite_dbmodule->disconnect();
-
- # Write out a message saying that the filter was added to the
- # filter database.
-
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{filter}->{filteradded}, { Style => "pageheader" });
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{filter}->{filteraddedmessage});
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlink($kiriwrite_env{"script_filename"} . "?mode=filter", { Text => $kiriwrite_lang->{filter}->{returnfilterlist} });
-
- return $kiriwrite_presmodule->grab();
-
- } elsif ($confirm ne 0) {
-
- # The confirm integer is another value (which
- # it shouldn't be) so return an error.
-
- kiriwrite_error("invalidvalue");
-
- }
-
- # The confirm integer was blank so print out a form
- # for adding a new filter.
-
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{filter}->{addfilter}, { Style => "pageheader" });
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->startform($kiriwrite_env{"script_filename"}, "POST");
- $kiriwrite_presmodule->startbox();
- $kiriwrite_presmodule->addhiddendata("mode", "filter");
- $kiriwrite_presmodule->addhiddendata("action", "add");
- $kiriwrite_presmodule->addhiddendata("confirm", 1);
- $kiriwrite_presmodule->starttable("", { CellPadding => 5, CellSpacing => 0 });
-
- $kiriwrite_presmodule->startheader();
- $kiriwrite_presmodule->addheader($kiriwrite_lang->{common}->{setting}, { Style => "tablecellheader" });
- $kiriwrite_presmodule->addheader($kiriwrite_lang->{common}->{value}, { Style => "tablecellheader" });
- $kiriwrite_presmodule->endheader();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{filter}->{findfilter});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addinputbox("findword", { Size => 64, MaxLength => 1024 });
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{filter}->{replacefilter});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addinputbox("replaceword", { Size => 64, MaxLength => 1024 });
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{filter}->{priority});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addinputbox("priority", { Size => 5, MaxLength => 5 });
- $kiriwrite_presmodule->startlist();
- $kiriwrite_presmodule->additem($kiriwrite_lang->{filter}->{noprioritygiven});
- $kiriwrite_presmodule->endlist();
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{filter}->{notes});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addtextbox("notes", { Columns => $kiriwrite_config{"display_textareacols"}, Rows => $kiriwrite_config{"display_textarearows"} });
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addcheckbox("enabled", { OptionDescription => $kiriwrite_lang->{filter}->{enabled}, Checked => 1 });
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->endtable();
-
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addsubmit($kiriwrite_lang->{filter}->{addfilterbutton});
- $kiriwrite_presmodule->addtext(" | ");
- $kiriwrite_presmodule->addreset($kiriwrite_lang->{common}->{clearvalues});
- $kiriwrite_presmodule->addtext(" | ");
- $kiriwrite_presmodule->addlink($kiriwrite_env{"script_filename"} . "?mode=filter", { Text => $kiriwrite_lang->{filter}->{returnfilterlist} });
-
- $kiriwrite_presmodule->endbox();
- $kiriwrite_presmodule->endform();
-
- return $kiriwrite_presmodule->grab();
-
-}
-
-sub kiriwrite_filter_edit{
-#################################################################################
-# kiriwrite_filter_edit: Edits a filter from the filter list. #
-# #
-# Usage: #
-# #
-# kiriwrite_filter_edit(options); #
-# #
-# options Specifies the following options as hash (in any order). #
-# #
-# FilterID Specifies the filter number in the filter database. #
-# NewFindFilter Specifies the new find filter. #
-# NewReplaceFilter Specifies the new replace filter. #
-# NewPriority Specifies the new priority. #
-# NewEnabled Specifies the new enable setting. #
-# NewFilterNotes Specifies the new filter notes. #
-# Confirm Confirms the action to edit a filter. #
-#################################################################################
-
- # Get the values that have been passed to the subroutine.
-
- my ($options) = @_;
- #my ($filter_id, $filter_new_find, $filter_new_replace, $filter_new_priority, $filter_new_notes, $confirm) = @_;
-
- my $filter_id = $options->{"FilterID"};
- my $confirm = $options->{"Confirm"};
-
- # Check the confirm value to make sure it is no more than
- # one character long.
-
- kiriwrite_variablecheck($confirm, "maxlength", 1, 0);
-
- # Check if the confirm value is blank and if it is
- # srt the confirm value to 0.
-
- if (!$confirm){
-
- # The confirm value does not have any value
- # set so set it to 0.
-
- $confirm = 0;
-
- }
-
- # Check if the filter identification number is blank,
- # contains characters other than numbers and is more
- # than seven characters long.
-
- if (!$filter_id){
-
- # The filter identification number is blank,
- # so return an error.
-
- kiriwrite_error("filteridblank");
-
- }
-
- my $filter_id_numbers_check = kiriwrite_variablecheck($filter_id, "numbers", 0, 1);
-
- if ($filter_id_numbers_check eq 1){
-
- # The filter identification number contains
- # characters other than numbers, so return
- # an error.
-
- kiriwrite_error("filteridinvalid");
-
- }
-
- my $filter_id_maxlength_check = kiriwrite_variablecheck($filter_id, "maxlength", 7, 1);
-
- if ($filter_id_maxlength_check eq 1){
-
- # The filter identification number given
- # is more than seven characters long, so
- # return an error.
-
- kiriwrite_error("filteridtoolong");
-
- }
-
- my $filter_priority;
- my $filter_find;
- my $filter_replace;
- my $filter_notes;
-
- # Check if the action to edit a filter has been
- # confirmed.
-
- if ($confirm eq 1){
-
- # The action to edit a filter has been confirmed so
- # edit the selected filter.
-
- # Get the values from the hashref.
-
- my $filter_new_find = $options->{"NewFindFilter"};
- my $filter_new_replace = $options->{"NewReplaceFilter"};
- my $filter_new_priority = $options->{"NewPriority"};
- my $filter_new_notes = $options->{"NewFilterNotes"};
- my $filter_new_enabled = $options->{"NewEnabled"};
-
- # First, check the variables recieved are UTF8
- # copliant.
-
- kiriwrite_variablecheck($filter_new_find, "utf8", 0, 0);
- kiriwrite_variablecheck($filter_new_replace, "utf8", 0, 0);
- kiriwrite_variablecheck($filter_new_priority, "utf8", 0, 0);
- kiriwrite_variablecheck($filter_new_notes, "utf8", 0, 0);
-
- # Convert the UTF8 values so that the length can
- # checked properly.
-
- $filter_find = kiriwrite_utf8convert($filter_new_find);
- $filter_replace = kiriwrite_utf8convert($filter_new_replace);
- $filter_priority = kiriwrite_utf8convert($filter_new_priority);
- $filter_notes = kiriwrite_utf8convert($filter_new_notes);
-
- # Check if the find filter is blank and return an error
- # if it is.
-
- if (!$filter_new_find){
-
- # The find filter given is blank so return an
- # error.
-
- kiriwrite_error("blankfindfilter");
-
- }
-
- if (!$filter_new_priority){
-
- # The filter priority is blank so set it
- # to 1.
-
- $filter_new_priority = 1;
-
- }
-
- # Check the length and contents of the values given
- # to make sure they are valid.
-
- my $filterfind_maxlength_check = kiriwrite_variablecheck($filter_new_find, "maxlength", 1024, 1);
- my $filterreplace_maxlength_check = kiriwrite_variablecheck($filter_new_replace, "maxlength", 1024, 1);
- my $filterpriority_maxlength_check = kiriwrite_variablecheck($filter_new_priority, "maxlength", 5, 1);
- my $filterpriority_numbers_check = kiriwrite_variablecheck($filter_new_priority, "numbers", 0, 1);
-
- # Check if the result of the tests to see if they
- # are valid.
-
- if ($filterfind_maxlength_check eq 1){
-
- # The find filter is too long, so return
- # an error.
-
- kiriwrite_error("findfiltertoolong");
-
- }
-
- if ($filterreplace_maxlength_check eq 1){
-
- # The replace filter is too long, so
- # return an error.
-
- kiriwrite_error("replacefiltertoolong");
-
- }
-
- if ($filterpriority_maxlength_check eq 1){
-
- # The length of the filter priority
- # given is too long, so return an
- # error.
-
- kiriwrite_error("filterprioritytoolong");
-
- }
-
- if ($filterpriority_numbers_check eq 1){
-
- # The priority of the filter given
- # contains characters other than
- # numbers.
-
- kiriwrite_error("filterpriorityinvalidchars");
-
- }
-
- # Check if the filter priority is less than 1
- # and more than 10000 and return an error
- # if it is.
-
- if ($filter_new_priority < 1 || $filter_new_priority > 50000){
-
- # The filter priority is less than 1 and
- # more than 10000, so return an error.
-
- kiriwrite_error("filterpriorityinvalid");
-
- }
-
- # Check to see if the filter should be enabled.
-
- my $filter_enable = 0;
-
- if (!$filter_new_enabled){
-
- $filter_new_enabled = "off";
-
- }
-
- if ($filter_new_enabled eq "on"){
-
- # The filter is enabled.
-
- $filter_enable = 1;
-
- }
-
- # Connect to the database server.
-
- $kiriwrite_dbmodule->connect();
-
- # Check if any errors occured while connecting to the database server.
-
- if ($kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
-
- # A database connection error has occured so return
- # an error.
-
- kiriwrite_error("databaseconnectionerror", $kiriwrite_dbmodule->geterror(1));
-
- }
-
- # Connect to the filter database.
-
- $kiriwrite_dbmodule->connectfilter();
-
- # Check if any error has occured while connecting to the filter
- # database.
-
- if ($kiriwrite_dbmodule->geterror eq "FilterDatabaseDoesNotExist"){
-
- # The filter database does not exist.
-
- kiriwrite_error("filtersdbmissing");
-
- } elsif ($kiriwrite_dbmodule->geterror eq "FilterDatabaseInvalidPermissionsSet"){
-
- # The filter database has invalid permissions set so return
- # an error.
-
- kiriwrite_error("filtersdbpermissions");
-
- } elsif ($kiriwrite_dbmodule->geterror eq "FilterDatabaseError"){
-
- # A database error has occured with the filter database.
-
- kiriwrite_error("filtersdbdatabaseerror", $kiriwrite_dbmodule->geterror(1));
-
- }
-
- # Edit the selected filter in the filter database.
-
- $kiriwrite_dbmodule->editfilter({ FilterID => $filter_id, NewFindFilter => $filter_new_find, NewReplaceFilter => $filter_new_replace, NewFilterPriority => $filter_new_priority, NewEnabled => $filter_enable, NewFilterNotes => $filter_new_notes });
-
- # Check if any errors occured while editing the filter.
-
- if ($kiriwrite_dbmodule->geterror eq "FilterDatabaseInvalidPermissionsSet"){
-
- # The filter database has invalid permissions set so return
- # an error.
-
- kiriwrite_error("filtersdbpermissions");
-
- } elsif ($kiriwrite_dbmodule->geterror eq "FilterDatabaseError"){
-
- # A database error has occured while using the filter database
- # so return an error.
-
- kiriwrite_error("filtersdbdatabaseerror", $kiriwrite_dbmodule->geterror(1));
-
- } elsif ($kiriwrite_dbmodule->geterror eq "FilterDoesNotExist"){
-
- # The specified filter does not exist so return an error.
-
- kiriwrite_error("filterdoesnotexist");
-
- }
-
- # Disconnect from the filter database.
-
- $kiriwrite_dbmodule->disconnectfilter();
-
- # Disconnect from the database server.
-
- $kiriwrite_dbmodule->disconnect();
-
- # Write a message saying that the filter was edited.
-
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{filter}->{editedfilter}, { Style => "pageheader" });
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{filter}->{editedfiltermessage});
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlink($kiriwrite_env{"script_filename"} . "?mode=filter", { Text => $kiriwrite_lang->{filter}->{returnfilterlist}});
-
- return $kiriwrite_presmodule->grab();
-
- } elsif ($confirm eq 0){
-
- # The action to edit a filter has not been confirmed
- # so write a form for editing the filter with.
-
- # Connect to the database server.
-
- $kiriwrite_dbmodule->connect();
-
- # Check if any errors occured while connecting to the database server.
-
- if ($kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
-
- # A database connection error has occured so return
- # an error.
-
- kiriwrite_error("databaseconnectionerror", $kiriwrite_dbmodule->geterror(1));
-
- }
-
- # Connect to the database server.
-
- $kiriwrite_dbmodule->connect();
-
- # Check if any errors occured while connecting to the database server.
-
- if ($kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
-
- # A database connection error has occured so return
- # an error.
-
- kiriwrite_error("databaseconnectionerror", $kiriwrite_dbmodule->geterror(1));
-
- }
-
- # Connect to the filter database.
-
- $kiriwrite_dbmodule->connectfilter();
-
- # Check if any error has occured while connecting to the filter
- # database.
-
- if ($kiriwrite_dbmodule->geterror eq "FilterDatabaseDoesNotExist"){
-
- # The filter database does not exist.
-
- kiriwrite_error("filtersdbmissing");
-
- } elsif ($kiriwrite_dbmodule->geterror eq "FilterDatabaseInvalidPermissionsSet"){
-
- # The filter database has invalid permissions set so return
- # an error.
-
- kiriwrite_error("filtersdbpermissions");
-
- } elsif ($kiriwrite_dbmodule->geterror eq "FilterDatabaseError"){
-
- # A database error has occured with the filter database.
-
- kiriwrite_error("filtersdbdatabaseerror", $kiriwrite_dbmodule->geterror(1));
-
- }
-
- # Get information about the filter.
-
- my %filter_info = $kiriwrite_dbmodule->getfilterinfo({ FilterID => $filter_id });
-
- # Check if any errors occured while getting information about the filter.
-
- if ($kiriwrite_dbmodule->geterror eq "FilterDatabaseError"){
-
- # A database error occured while using the filter database so
- # return an error.
-
- kiriwrite_error("filtersdbdatabaseerror", $kiriwrite_dbmodule->geterror(1));
-
- } elsif ($kiriwrite_dbmodule->geterror eq "FilterDoesNotExist"){
-
- # The filter does not exist so return an error.
-
- kiriwrite_error("filterdoesnotexist");
-
- }
-
- # Get the required information.
-
- $filter_priority = $filter_info{"FilterPriority"};
- $filter_find = $filter_info{"FilterFind"};
- $filter_replace = $filter_info{"FilterReplace"};
- $filter_enabled = $filter_info{"FilterEnabled"};
- $filter_notes = $filter_info{"FilterNotes"};
-
- # Disconnect from the filter database.
-
- $kiriwrite_dbmodule->disconnectfilter();
-
- # Disconnect from the database server.
-
- $kiriwrite_dbmodule->disconnect();
-
- # Write out the form.
-
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{filter}->{editfilter}, { Style => "pageheader" });
- $kiriwrite_presmodule->startform($kiriwrite_env{"script_filename"}, "POST");
- $kiriwrite_presmodule->startbox();
- $kiriwrite_presmodule->addhiddendata("mode", "filter");
- $kiriwrite_presmodule->addhiddendata("action", "edit");
- $kiriwrite_presmodule->addhiddendata("filter", $filter_id);
- $kiriwrite_presmodule->addhiddendata("confirm", 1);
-
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->starttable("", { CellPadding => 5, CellSpacing => 0 });
-
- $kiriwrite_presmodule->startheader();
- $kiriwrite_presmodule->addheader($kiriwrite_lang->{common}->{setting}, { Style => "tablecellheader" });
- $kiriwrite_presmodule->addheader($kiriwrite_lang->{common}->{value}, { Style => "tablecellheader" });
- $kiriwrite_presmodule->endheader();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{filter}->{findfilter});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addinputbox("filterfind", { Size => 64, MaxLength => 1024, Value => $filter_find });
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{filter}->{replacefilter});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addinputbox("filterreplace", { Size => 64, MaxLength => 1024, Value => $filter_replace });
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{filter}->{priority});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addinputbox("priority", { Size => 5, MaxLength => 5, Value => $filter_priority });
- $kiriwrite_presmodule->startlist();
- $kiriwrite_presmodule->additem($kiriwrite_lang->{filter}->{noprioritygiven});
- $kiriwrite_presmodule->endlist();
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{filter}->{notes});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addtextbox("notes", { Columns => $kiriwrite_config{"display_textareacols"}, Rows => $kiriwrite_config{"display_textarearows"}, Value => $filter_notes});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
-
- if ($filter_enabled eq 1){
-
- $kiriwrite_presmodule->addcheckbox("enabled", { OptionDescription => $kiriwrite_lang->{filter}->{enabled}, Checked => 1 });
-
- } else {
-
- $kiriwrite_presmodule->addcheckbox("enabled", { OptionDescription => $kiriwrite_lang->{filter}->{enabled} });
-
- }
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->endtable();
-
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addsubmit($kiriwrite_lang->{filter}->{editfilterbutton});
- $kiriwrite_presmodule->addtext(" | ");
- $kiriwrite_presmodule->addreset($kiriwrite_lang->{common}->{restorecurrent});
- $kiriwrite_presmodule->addtext(" | ");
- $kiriwrite_presmodule->addlink($kiriwrite_env{"script_filename"} . "?mode=filter", { Text => $kiriwrite_lang->{filter}->{returnfilterlist} });
- $kiriwrite_presmodule->endbox();
- $kiriwrite_presmodule->endform();
-
- return $kiriwrite_presmodule->grab();
-
- } else {
-
- # A confirm value other than 0 or 1 has been
- # specified, so return an error.
-
- kiriwrite_error("invalidvalue");
-
- }
-
-}
-
-sub kiriwrite_filter_delete{
-#################################################################################
-# kiriwrite_filter_delete: Deletes a filter from the filter list. #
-# #
-# Usage: #
-# #
-# kiriwrite_filter_delete(filterid, confirm); #
-# #
-# filterid Specifies the filter line number to delete. #
-# confirm Confirms the deletion of the selected filter. #
-#################################################################################
-
- # Get the values that were passed to this subroutine.
-
- my ($filter_id, $confirm) = @_;
-
- # Check the confirm value to make sure it is no more than
- # one character long.
-
- kiriwrite_variablecheck($confirm, "maxlength", 1, 0);
-
- # Check if the confirm value is blank and if it is
- # srt the confirm value to 0.
-
- if (!$confirm){
-
- # The confirm value does not have any value
- # set so set it to 0.
-
- $confirm = 0;
-
- }
-
- # Check if the filter identification number is blank,
- # contains characters other than numbers and is more
- # than seven characters long.
-
- if (!$filter_id){
-
- # The filter identification number is blank,
- # so return an error.
-
- kiriwrite_error("filteridblank");
-
- }
-
- my $filter_id_numbers_check = kiriwrite_variablecheck($filter_id, "numbers", 0, 1);
-
- if ($filter_id_numbers_check eq 1){
-
- # The filter identification number contains
- # characters other than numbers, so return
- # an error.
-
- kiriwrite_error("filteridinvalid");
-
- }
-
- my $filter_id_maxlength_check = kiriwrite_variablecheck($filter_id, "maxlength", 7, 1);
-
- if ($filter_id_maxlength_check eq 1){
-
- # The filter identification number given
- # is more than seven characters long, so
- # return an error.
-
- kiriwrite_error("filteridtoolong");
-
- }
-
- # Define some values for later.
-
- my @database_filter;
- my $filter_exists = 0;
-
- # Check if the confirm integer has a value of '1'.
-
- if ($confirm eq 1){
-
- # The action to delete a filter has been confirmed.
-
- # Connect to the database server.
-
- $kiriwrite_dbmodule->connect();
-
- # Check if any errors occured while connecting to the database server.
-
- if ($kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
-
- # A database connection error has occured so return
- # an error.
-
- kiriwrite_error("databaseconnectionerror", $kiriwrite_dbmodule->geterror(1));
-
- }
-
- # Connect to the filter database.
-
- $kiriwrite_dbmodule->connectfilter();
-
- # Check if any error has occured while connecting to the filter
- # database.
-
- if ($kiriwrite_dbmodule->geterror eq "FilterDatabaseDoesNotExist"){
-
- # The filter database does not exist.
-
- kiriwrite_error("filtersdbmissing");
-
- } elsif ($kiriwrite_dbmodule->geterror eq "FilterDatabaseInvalidPermissionsSet"){
-
- # The filter database has invalid permissions set so return
- # an error.
-
- kiriwrite_error("filtersdbpermissions");
-
- } elsif ($kiriwrite_dbmodule->geterror eq "FilterDatabaseError"){
-
- # A database error has occured with the filter database.
-
- kiriwrite_error("filtersdbdatabaseerror", $kiriwrite_dbmodule->geterror(1));
-
- }
-
- # Delete the filter from the filter database.
-
- $kiriwrite_dbmodule->deletefilter({ FilterID => $filter_id });
-
- # Check if any errors occured while deleting the filter.
-
- if ($kiriwrite_dbmodule->geterror eq "FilterDatabaseError"){
-
- # A database error has occured while trying to delete a filter so
- # return an error.
-
- kiriwrite_error("filtersdbdatabaseerror", $kiriwrite_dbmodule->geterror(1));
-
- } elsif ($kiriwrite_dbmodule->geterror eq "FilterDoesNotExist"){
-
- # The filter does not exist so return an error.
-
- kiriwrite_error("filterdoesnotexist");
-
- }
-
- # Disconnect from the filter database.
-
- $kiriwrite_dbmodule->disconnectfilter();
-
- # Disconnect from the database server.
-
- $kiriwrite_dbmodule->disconnect();
-
- # Write a message saying that the filter was deleted
- # from the filter database.
-
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{filter}->{deletedfilter}, { Style => "pageheader" });
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{filter}->{deletedfiltermessage});
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlink($kiriwrite_env{"script_filename"} . "?mode=filter", { Text => $kiriwrite_lang->{filter}->{returnfilterlist} });
-
- } elsif ($confirm eq 0) {
-
- # Connect to the database server.
-
- $kiriwrite_dbmodule->connect();
-
- # Check if any errors occured while connecting to the database server.
-
- if ($kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
-
- # A database connection error has occured so return
- # an error.
-
- kiriwrite_error("databaseconnectionerror", $kiriwrite_dbmodule->geterror(1));
-
- }
-
- # Connect to the filter database.
-
- $kiriwrite_dbmodule->connectfilter();
-
- # Check if any error has occured while connecting to the filter
- # database.
-
- if ($kiriwrite_dbmodule->geterror eq "FilterDatabaseDoesNotExist"){
-
- # The filter database does not exist.
-
- kiriwrite_error("filtersdbmissing");
-
- } elsif ($kiriwrite_dbmodule->geterror eq "FilterDatabaseInvalidPermissionsSet"){
-
- # The filter database has invalid permissions set so return
- # an error.
-
- kiriwrite_error("filtersdbpermissions");
-
- } elsif ($kiriwrite_dbmodule->geterror eq "FilterDatabaseError"){
-
- # A database error has occured with the filter database.
-
- kiriwrite_error("filtersdbdatabaseerror", $kiriwrite_dbmodule->geterror(1));
-
- }
-
- # Get information about the filter (to check if it exists).
-
- my %filter_info = $kiriwrite_dbmodule->getfilterinfo({ FilterID => $filter_id });
-
- # Check if any errors occured while getting information about the filter.
-
- if ($kiriwrite_dbmodule->geterror eq "FilterDatabaseError"){
-
- # A database error occured while using the filter database so
- # return an error.
-
- kiriwrite_error("filtersdbdatabaseerror", $kiriwrite_dbmodule->geterror(1));
-
- } elsif ($kiriwrite_dbmodule->geterror eq "FilterDoesNotExist"){
-
- # The filter does not exist so return an error.
-
- kiriwrite_error("filterdoesnotexist");
-
- }
-
- # Disconnect from the filter database.
-
- $kiriwrite_dbmodule->disconnectfilter();
-
- # Disconnect from the database
-
- # The confirm integer is '0', so continue write out
- # a form asking the user to confirm the deletion
- # pf the filter.
-
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{filter}->{deletefilter}, { Style => "pageheader" });
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{filter}->{deletefiltermessage});
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->startform($kiriwrite_env{"script_filename"}, "POST");
- $kiriwrite_presmodule->startbox();
- $kiriwrite_presmodule->addhiddendata("mode", "filter");
- $kiriwrite_presmodule->addhiddendata("action", "delete");
- $kiriwrite_presmodule->addhiddendata("filter", $filter_id);
- $kiriwrite_presmodule->addhiddendata("confirm", 1);
- $kiriwrite_presmodule->addsubmit($kiriwrite_lang->{filter}->{deletefilterbutton});
- $kiriwrite_presmodule->addtext(" | ");
- $kiriwrite_presmodule->addlink($kiriwrite_env{"script_filename"} . "?mode=filter", { Text => $kiriwrite_lang->{filter}->{deletefilterreturn} });
- $kiriwrite_presmodule->endbox();
- $kiriwrite_presmodule->endform();
-
- } else {
-
- kiriwrite_error("invalidvalue");
-
- }
-
- return $kiriwrite_presmodule->grab();
-
-}
-
-1;
+++ /dev/null
-#################################################################################
-# template.lib: Kiriwrite Template Library #
-# #
-# This library is under the same license as the main Kiriwrite script. #
-#################################################################################
-
-# This section of the file is for when the library is called from the main
-# Kiriwrite script.
-
-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.
-
-}
-
-#################################################################################
-# Begin list of relevant subroutines. #
-#################################################################################
-
-sub kiriwrite_template_add{
-#################################################################################
-# kiriwrite_template_add: Add a template to the template folder #
-# #
-# Usage: #
-# #
-# kiriwrite_template_add(filename, name, description, layout, confirm); #
-# #
-# filename The filename of the new template. #
-# name The name of the template. #
-# description The description of the template. #
-# layout The layout of the new template. #
-# confirm Confirm the action of creating a new template. #
-#################################################################################
-
- # Get the variables that were passed to the subroutine.
-
- my ($templatefilename, $templatename, $templatedescription, $templatelayout, $confirm) = @_;
-
- # Check if the confirm value is blank and if it is then set confirm to 0.
-
- if (!$confirm){
-
- # The confirm value is blank, so set the value of confirm to 0.
-
- $confirm = 0;
-
- }
-
- if ($confirm eq 1){
-
- # Check (validate) each of the values.
-
- kiriwrite_variablecheck($templatename, "utf8", 0, 0);
- kiriwrite_variablecheck($templatedescription, "utf8", 0, 0);
- kiriwrite_variablecheck($templatelayout, "utf8", 0, 0);
-
- # Convert the values into proper UTF8 strings that can be used.
-
- $templatename = kiriwrite_utf8convert($templatename);
- $templatedescription = kiriwrite_utf8convert($templatedescription);
- $templatelayout = kiriwrite_utf8convert($templatelayout);
-
- # Check the length of the converted UTF8 strings.
-
- my $templatefilename_length_check = kiriwrite_variablecheck($templatefilename, "maxlength", 64, 1);
- my $templatename_length_check = kiriwrite_variablecheck($templatename, "maxlength", 512, 1);
- my $templatedescription_length_check = kiriwrite_variablecheck($templatedescription, "maxlength", 512, 1);
- kiriwrite_variablecheck($confirm, "maxlength", 1, 0);
-
- if ($templatefilename_length_check eq 1){
-
- # The template filename length is too long, so return an error.
-
- kiriwrite_error("templatefilenametoolong");
-
- }
-
- if ($templatename_length_check eq 1){
-
- # The template name length is too long, so return an error.
-
- kiriwrite_error("templatenametoolong");
-
- }
-
-
- if ($templatedescription_length_check eq 1){
-
- # The template description length is too long, so return an error.
-
- kiriwrite_error("templatedescriptiontoolong");
-
- }
-
- # Check if the filename specified is a valid filename.
-
- kiriwrite_variablecheck($templatefilename, "filename", "", 0);
-
- # Connect to the template server.
-
- $kiriwrite_dbmodule->connect();
-
- # Connect to the template database.
-
- $kiriwrite_dbmodule->connecttemplate(1);
-
- # Check if any errors had occured.
-
- if ($kiriwrite_dbmodule->geterror eq "TemplateDatabaseInvalidPermissionsSet"){
-
- # The template database has invalid permissions set so
- # return an error.
-
- kiriwrite_error("templatedatabaseinvalidpermissions");
-
- }
-
- $kiriwrite_dbmodule->addtemplate({ TemplateFilename => $templatefilename, TemplateName => $templatename, TemplateDescription => $templatedescription, TemplateLayout => $templatelayout });
-
- if ($kiriwrite_dbmodule->geterror eq "TemplateDatabaseError"){
-
- # A database error has occured so return an error along
- # with the extended error information.
-
- kiriwrite_error("templatedatabaseerror", $kiriwrite_dbmodule->geterror(1));
-
- } elsif ($kiriwrite_dbmodule->geterror eq "TemplateDatabaseInvalidPermissionsSet"){
-
- # The template database has invalid permissions set so return
- # an error.
-
- kiriwrite_error("templatedatabaseinvalidpermissions");
-
- } elsif ($kiriwrite_dbmodule->geterror eq "TemplatePageExists"){
-
- # The template page already exists so return an error.
-
- kiriwrite_error("templatefilenameexists");
-
- } elsif ($kiriwrite_dbmodule->geterror eq "TemplateDatabaseUncreateable"){
-
- # The template databases is uncreatable so return an error.
-
- kiriwrite_error("templatedatabasenotcreated");
-
- }
-
- $kiriwrite_dbmodule->disconnecttemplate();
-
- # Disconnect from the template server.
-
- $kiriwrite_dbmodule->disconnect();
-
- # Print out the confirmation message.
-
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{template}->{addedtemplate}, { Style => "pageheader" });
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext(kiriwrite_language($kiriwrite_lang->{template}->{addedtemplatemessage}, $templatename));
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlink($kiriwrite_env{"script_filename"} . "?mode=template", { Text => $kiriwrite_lang->{template}->{returntemplatelist} });
- return $kiriwrite_presmodule->grab();
-
- } else {
- # No confirmation was made, so print out a form for adding a template.
-
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{template}->{addtemplate}, { Style => "pageheader" });
- $kiriwrite_presmodule->startform($kiriwrite_env{"script_filename"}, "POST");
- $kiriwrite_presmodule->startbox();
- $kiriwrite_presmodule->addhiddendata("mode", "template");
- $kiriwrite_presmodule->addhiddendata("action", "add");
- $kiriwrite_presmodule->addhiddendata("confirm", 1);
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->starttable("", { CellSpacing => 0, CellPadding => 5 });
-
- $kiriwrite_presmodule->startheader();
- $kiriwrite_presmodule->addheader($kiriwrite_lang->{common}->{setting}, { Style => "tablecellheader" });
- $kiriwrite_presmodule->addheader($kiriwrite_lang->{common}->{value}, { Style => "tablecellheader" });
- $kiriwrite_presmodule->endheader();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{template}->{templatename});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addinputbox("templatename", { Size => 64, MaxLength => 512 });
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{template}->{templatedescription});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addinputbox("templatedescription", { Size => 64, MaxLength => 512 });
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{template}->{templatefilename});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addinputbox("templatefilename", { Size => 32, MaxLength => 64 });
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{template}->{templatelayout});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addtextbox("templatelayout", { Columns => $kiriwrite_config{"display_textareacols"}, Rows => $kiriwrite_config{"display_textarearows"} });
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->startbox("datalist");
- $kiriwrite_presmodule->addboldtext($kiriwrite_lang->{common}->{tags});
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{common}->{pagecontent});
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{common}->{pagetitle});
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{common}->{pagename});
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{common}->{pagedescription});
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{common}->{pagesection});
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{common}->{pageautosection});
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{common}->{pageautotitle});
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->endbox();
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
- $kiriwrite_presmodule->endtable();
-
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addsubmit($kiriwrite_lang->{template}->{addtemplatebutton});
- $kiriwrite_presmodule->addtext(" | ");
- $kiriwrite_presmodule->addreset($kiriwrite_lang->{common}->{clearvalues});
- $kiriwrite_presmodule->addtext(" | ");
- $kiriwrite_presmodule->addlink($kiriwrite_env{"script_filename"} . "?mode=template" , { Text => $kiriwrite_lang->{template}->{returntemplatelist} });
-
- $kiriwrite_presmodule->endbox();
- $kiriwrite_presmodule->endform();
-
- return $kiriwrite_presmodule->grab();
-
- }
-
-
-}
-
-sub kiriwrite_template_edit{
-#################################################################################
-# kiriwrite_template_edit: Edit a template from the template folder. #
-# #
-# Usage: #
-# #
-# kiriwrite_template_edit(filename, [newfilename], [newname], [newdescription], #
-# [templatelayout], [confirm]); #
-# #
-# filename The current filename of the template to edit. #
-# newfilename The new filename of the template to edit. #
-# newname The new name of the template being edited. #
-# newdescription The new description of the template being edited. #
-# templatelayout The modified/altered template layout. #
-# confirm Confirms the action to edit a template and its #
-# settings. #
-#################################################################################
-
- # Get all the variables that have been passed to the subroutine.
-
- my ($templatefilename, $templatenewfilename, $templatenewname, $templatenewdescription, $templatelayout, $confirm) = @_;
-
- # Check if the confirm variable is blank, if it is then
- # set confirm to '0'
-
- if (!$confirm){
-
- # confirm is uninitalised/blank, so set the value of confirm
- # to '0'
-
- $confirm = 0;
-
- }
-
- # Check if the template filename is blank and if it is, then return
- # an error.
-
- if (!$templatefilename){
-
- kiriwrite_error("templatefilenameblank");
-
- }
-
- # Connect to the database server.
-
- $kiriwrite_dbmodule->connect();
-
- # Check if any errors occured while connecting to the database server.
-
- if ($kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
-
- # A database connection error has occured so return
- # an error.
-
- kiriwrite_error("databaseconnectionerror", $kiriwrite_dbmodule->geterror(1));
-
- }
-
- if ($confirm eq 1){
-
- # Check certain strings to see if they UTF8 compiliant.
-
- kiriwrite_variablecheck($templatenewname, "utf8", 0, 0);
- kiriwrite_variablecheck($templatenewdescription, "utf8", 0, 0);
- kiriwrite_variablecheck($templatelayout, "utf8", 0, 0);
-
- # Convert the values into proper UTF8 strings.
-
- $templatenewname = kiriwrite_utf8convert($templatenewname);
- $templatenewdescription = kiriwrite_utf8convert($templatenewdescription);
- $templatelayout = kiriwrite_utf8convert($templatelayout);
-
- # Check if the filenames recieved are valid filenames.
-
- kiriwrite_variablecheck($templatenewfilename, "maxlength", 64, 0);
- kiriwrite_variablecheck($templatenewdescription, "maxlength", 512, 0);
- kiriwrite_variablecheck($templatenewname, "maxlength", 512, 0);
- kiriwrite_variablecheck($templatefilename, "maxlength", 64, 0);
- kiriwrite_variablecheck($confirm, "maxlength", 1, 0);
-
- kiriwrite_variablecheck($templatefilename, "filename", "", 0);
- kiriwrite_variablecheck($templatenewfilename, "filename", "", 0);
-
- # Connect to the template database.
-
- $kiriwrite_dbmodule->connecttemplate();
-
- # Check if any errors had occured.
-
- if ($kiriwrite_dbmodule->geterror eq "TemplateDatabaseInvalidPermissionsSet"){
-
- # The template database has invalid permissions set so
- # return an error.
-
- kiriwrite_error("templatedatabaseinvalidpermissions");
-
- }
-
- # Edit the template.
-
- $kiriwrite_dbmodule->edittemplate({ TemplateFilename => $templatefilename, NewTemplateFilename => $templatenewfilename, NewTemplateName => $templatenewname, NewTemplateDescription => $templatenewdescription, NewTemplateLayout => $templatelayout });
-
- # Check if any error occured while editing the template.
-
- if ($kiriwrite_dbmodule->geterror eq "TemplateDatabaseError"){
-
- # A database error has occured, so return an error.
-
- kiriwrite_error("templatedatabaseerror", $kiriwrite_dbmodule->geterror(1));
-
- } elsif ($kiriwrite_dbmodule->geterror eq "TemplateDatabaseInvalidPermissionsSet"){
-
- # The template database has invalid permissions set so return
- # an error.
-
- kiriwrite_error("templatedatabaseinvalidpermissions");
-
- } elsif ($kiriwrite_dbmodule->geterror eq "TemplateDoesNotExist"){
-
- # The template does not exist, so process the next template.
-
- kiriwrite_error("templatedoesnotexist");
-
- }
-
- # Disconnect from the database server.
-
- $kiriwrite_dbmodule->disconnect();
-
- # Disconnect from the template database.
-
- $kiriwrite_dbmodule->disconnecttemplate();
-
- # Append a link so that the user can return to the templates list.
-
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{template}->{editedtemplate}, { Style => "pageheader" });
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext(kiriwrite_language($kiriwrite_lang->{template}->{editedtemplatemessage}, $templatenewname));
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlink($kiriwrite_env{"script_filename"} . "?mode=template", { Text => $kiriwrite_lang->{template}->{returntemplatelist} });
-
- } else {
-
- # Connect to the template database.
-
- $kiriwrite_dbmodule->connecttemplate();
-
- # Check if any errors had occured.
-
- if ($kiriwrite_dbmodule->geterror eq "TemplateDatabaseInvalidPermissionsSet"){
-
- # The template database has invalid permissions set so
- # return an error.
-
- kiriwrite_error("templatedatabaseinvalidpermissions");
-
- }
-
- # Get the template information.
-
- my %template_info = $kiriwrite_dbmodule->gettemplateinfo({ TemplateFilename => $templatefilename });
-
- # Check if any error occured while getting the template information.
-
- if ($kiriwrite_dbmodule->geterror eq "TemplateDatabaseError"){
-
- # A database error has occured, so return an error.
-
- kiriwrite_error("templatedatabaseerror", $kiriwrite_dbmodule->geterror(1));
-
- } elsif ($kiriwrite_dbmodule->geterror eq "TemplateDoesNotExist"){
-
- # The template does not exist, so return an error.
-
- kiriwrite_error("templatedoesnotexist");
-
- }
-
- # Disconnect from the template database.
-
- $kiriwrite_dbmodule->disconnecttemplate();
-
- # Get the values from the query results.
-
- my $template_filename = $template_info{"TemplateFilename"};
- my $template_name = $template_info{"TemplateName"};
- my $template_description = $template_info{"TemplateDescription"};
- my $template_layout = $template_info{"TemplateLayout"};
- my $template_modified = $template_info{"TemplateLastModified"};
-
- # Check if the values are undefined and set them blank
- # if they are.
-
- if (!$template_name){
- $template_name = "";
- }
-
- if (!$template_description){
- $template_description = "";
- }
-
- if (!$template_layout){
- $template_layout = "";
- }
-
- # Write out the form for editing an template with the current template
- # settings put into the correct place.
-
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{template}->{edittemplate}, { Style => "pageheader" });
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->startform($kiriwrite_env{"script_filename"}, "POST");
- $kiriwrite_presmodule->startbox();
- $kiriwrite_presmodule->addhiddendata("mode", "template");
- $kiriwrite_presmodule->addhiddendata("action", "edit");
- $kiriwrite_presmodule->addhiddendata("confirm", 1);
- $kiriwrite_presmodule->addhiddendata("template", $template_filename);
- $kiriwrite_presmodule->starttable("", { CellSpacing => 0, CellPadding => 5});
-
- $kiriwrite_presmodule->startheader();
- $kiriwrite_presmodule->addheader($kiriwrite_lang->{common}->{setting}, { Style => "tablecellheader" });
- $kiriwrite_presmodule->addheader($kiriwrite_lang->{common}->{value}, { Style => "tablecellheader" });
- $kiriwrite_presmodule->endheader();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{template}->{templatename});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addinputbox("newname", { Size => 64, MaxLength => 512, Value => $template_name });
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{template}->{templatedescription});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addinputbox("newdescription", { Size => 64, MaxLength => 512, Value => $template_description });
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{template}->{templatefilename});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addinputbox("newfilename", { Size => 32, MaxLength => 64, Value => $template_filename });
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell("tablecell1");
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{template}->{templatelayout});
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell("tablecell2");
- $kiriwrite_presmodule->addtextbox("newlayout", { Columns => $kiriwrite_config{"display_textareacols"}, Rows => $kiriwrite_config{"display_textarearows"}, Value => $template_layout});
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->startbox("datalist");
- $kiriwrite_presmodule->addboldtext($kiriwrite_lang->{common}->{tags});
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{common}->{pagecontent});
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{common}->{pagetitle});
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{common}->{pagename});
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{common}->{pagedescription});
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{common}->{pagesection});
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{common}->{pageautosection});
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{common}->{pageautotitle});
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->endbox();
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- $kiriwrite_presmodule->endtable();
-
- $kiriwrite_presmodule->addlinebreak();
-
- $kiriwrite_presmodule->addsubmit($kiriwrite_lang->{template}->{edittemplatebutton});
- $kiriwrite_presmodule->addtext(" | ");
- $kiriwrite_presmodule->addreset($kiriwrite_lang->{common}->{restorecurrent});
- $kiriwrite_presmodule->addtext(" | ");
- $kiriwrite_presmodule->addlink($kiriwrite_env{"script_filename"} . "?mode=template", { Text => $kiriwrite_lang->{template}->{returntemplatelist} });
-
- $kiriwrite_presmodule->endbox();
- $kiriwrite_presmodule->endform();
-
- }
-
- # Disconnect from the database server.
-
- $kiriwrite_dbmodule->disconnect();
-
- return $kiriwrite_presmodule->grab();
-
-}
-
-sub kiriwrite_template_delete{
-#################################################################################
-# kiriwrite_template_delete: Delete a template from the template folder. #
-# #
-# Usage: #
-# #
-# kiriwrite_template_delete(filename, confirm); #
-# #
-# filename Specifies the filename of the database to delete. #
-# confirm Confirms the action to delete a template. #
-#################################################################################
-
- # Get the parameters that were passed to the subroutine.
-
- my ($template_filename, $template_confirm) = @_;
-
- if (!$template_confirm){
- $template_confirm = 0;
- }
-
- # Check the length of the variables.
- kiriwrite_variablecheck($template_filename, "maxlength", 64, 0);
- kiriwrite_variablecheck($template_confirm, "maxlength", 1, 0);
-
- # Check if the template_name string is blank and if it is then
- # return an error (as the template_name string should not be
- # blank.
-
- if (!$template_filename){
-
- # The template_filename string really is blank,
- # so return an error saying that an empty
- # filename was passed (to the subroutine).
-
- kiriwrite_error("templatefilenameblank");
-
- }
-
- # Check if the template_confirm string is blank and if it is, write
- # out a form asking the user to confirm the deletion.
-
- if ($template_confirm eq 1){
-
- # The action to delete the template from the template database has
- # been confirmed so delete the template.
-
- # Connect to the database server.
-
- $kiriwrite_dbmodule->connect();
-
- # Check if any errors occured while connecting to the database server.
-
- if ($kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
-
- # A database connection error has occured so return
- # an error.
-
- kiriwrite_error("databaseconnectionerror", $kiriwrite_dbmodule->geterror(1));
-
- }
-
- # Check if the template database exists and the file permissions
- # are valid and return an error if they aren't.
-
- $kiriwrite_dbmodule->connecttemplate();
-
- if ($kiriwrite_dbmodule->geterror eq "TemplateDatabaseDoesNotExist"){
-
- # The template database does not exist so write a warning
- # message.
-
- kiriwrite_error("templatedatabasemissing");
-
- } elsif ($kiriwrite_dbmodule->geterror eq "TemplateDatabaseInvalidPermissionsSet"){
-
- # The template database has invalid permissions set so
- # return an error.
-
- kiriwrite_error("templatedatabaseinvalidpermissions");
-
- }
-
- my %template_info = $kiriwrite_dbmodule->gettemplateinfo({ TemplateFilename => $template_filename });
-
- # Check if any error occured while getting the template information.
-
- if ($kiriwrite_dbmodule->geterror eq "TemplateDatabaseError"){
-
- # A database error has occured, so return an error.
-
- kiriwrite_error("templatedatabaseerror", $kiriwrite_dbmodule->geterror(1));
-
- } elsif ($kiriwrite_dbmodule->geterror eq "TemplateDoesNotExist"){
-
- # The template does not exist, so return an error.
-
- kiriwrite_error("templatedoesnotexist");
-
- }
-
- # Delete the selected template.
-
- $kiriwrite_dbmodule->deletetemplate({ TemplateFilename => $template_filename });
-
- # Check if any error occured while deleting the template.
-
- if ($kiriwrite_dbmodule->geterror eq "TemplateDatabaseError"){
-
- # A database error has occured, so return an error.
-
- kiriwrite_error("templatedatabaseerror", $kiriwrite_dbmodule->geterror(1));
-
- } elsif ($kiriwrite_dbmodule->geterror eq "TemplateDoesNotExist"){
-
- # The template does not exist, so process the next template.
-
- kiriwrite_error("templatedoesnotexist");
-
- }
-
- $kiriwrite_dbmodule->disconnecttemplate();
-
- # Get the deleted database name.
-
- my $database_template_name = $template_info{"TemplateName"};
-
- # Disconnect from the database server.
-
- $kiriwrite_dbmodule->disconnect();
-
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{template}->{deletedtemplate}, { Style => "pageheader" });
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext(kiriwrite_language($kiriwrite_lang->{template}->{deletedtemplatemessage}, $database_template_name) );
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlink($kiriwrite_env{"script_filename"} . "?mode=template", { Text => $kiriwrite_lang->{template}->{returntemplatelist} });
-
- return $kiriwrite_presmodule->grab();
-
- } elsif ($template_confirm eq 0) {
-
- # The template confirm value is 0 (previously blank and then set to 0), so
- # write out a form asking the user to confirm the deletion of the template.
-
- # Connect to the database server.
-
- $kiriwrite_dbmodule->connect();
-
- # Check if any errors occured while connecting to the database server.
-
- if ($kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
-
- # A database connection error has occured so return
- # an error.
-
- kiriwrite_error("databaseconnectionerror", $kiriwrite_dbmodule->geterror(1));
-
- }
-
- # Connect to the template database.
-
- $kiriwrite_dbmodule->connecttemplate();
-
- if ($kiriwrite_dbmodule->geterror eq "TemplateDatabaseDoesNotExist"){
-
- # The template database does not exist so write a warning
- # message.
-
- kiriwrite_error("templatedatabasemissing");
-
- } elsif ($kiriwrite_dbmodule->geterror eq "TemplateDatabaseInvalidPermissionsSet"){
-
- # The template database has invalid permissions set so
- # return an error.
-
- kiriwrite_error("templatedatabaseinvalidpermissions");
-
- }
-
- my %template_info = $kiriwrite_dbmodule->gettemplateinfo({ TemplateFilename => $template_filename });
-
- if ($kiriwrite_dbmodule->geterror eq "TemplateDatabaseError"){
-
- # A database error has occured, so return an error.
-
- kiriwrite_error("templatedatabaseerror", $kiriwrite_dbmodule->geterror(1));
-
- } elsif ($kiriwrite_dbmodule->geterror eq "TemplateDoesNotExist"){
-
- # The template does not exist, so return an error.
-
- kiriwrite_error("templatedoesnotexist");
-
- }
-
- my $template_data_filename = $template_info{"TemplateFilename"};
- my $template_data_name = $template_info{"TemplateName"};
-
- $kiriwrite_dbmodule->disconnecttemplate();
-
- # Disconnect from the database server.
-
- $kiriwrite_dbmodule->disconnect();
-
- # Write out the confirmation form.
-
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{template}->{deletetemplate}, { Style => "pageheader" });
- $kiriwrite_presmodule->startform($kiriwrite_env{"script_filename"}, "POST");
- $kiriwrite_presmodule->startbox();
- $kiriwrite_presmodule->addhiddendata("mode", "template");
- $kiriwrite_presmodule->addhiddendata("template", $template_filename);
- $kiriwrite_presmodule->addhiddendata("action", "delete");
- $kiriwrite_presmodule->addhiddendata("confirm", 1);
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addtext(kiriwrite_language($kiriwrite_lang->{template}->{deletetemplatemessage}, $template_data_name, $template_data_filename));
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addsubmit($kiriwrite_lang->{template}->{deletetemplatebutton});
- $kiriwrite_presmodule->addtext(" | ");
- $kiriwrite_presmodule->addlink($kiriwrite_env{"script_filename"} . "?mode=template", { Text => $kiriwrite_lang->{template}->{deletetemplatereturntolist} });
- $kiriwrite_presmodule->endbox();
- $kiriwrite_presmodule->endform();
-
- return $kiriwrite_presmodule->grab();
-
- } else {
-
- kiriwrite_error("invalidvariable");
-
- }
-
-}
-
-sub kiriwrite_template_list{
-#################################################################################
-# kiriwrite_template_list: List the templates in the template folder. #
-# #
-# Usage: #
-# #
-# kiriwrite_template_list([browsenumber]); #
-# #
-# browsenumber Specifies the page browse number to use. #
-#################################################################################
-
- # Define certain values for later.
-
- my $template_browsenumber = shift;
-
- my %template_info;
-
- my @templates_list;
-
- my $template;
- my $template_filename = "";
- my $template_filename_list = "";
- my $template_name = "";
- my $template_description = "";
- my $template_data = "";
-
- my $template_split = $kiriwrite_config{"display_templatecount"};
- my $template_list = 0;
-
- my $template_count = 0;
-
- my $template_style = 0;
- my $template_stylename = "";
-
- my $templatewarning = "";
-
- # Connect to the database server.
-
- $kiriwrite_dbmodule->connect();
-
- # Check if any errors occured while connecting to the database server.
-
- if ($kiriwrite_dbmodule->geterror eq "DatabaseConnectionError"){
-
- # A database connection error has occured so return
- # an error.
-
- kiriwrite_error("databaseconnectionerror", $kiriwrite_dbmodule->geterror(1));
-
- }
-
- # Connect to the template database.
-
- $kiriwrite_dbmodule->connecttemplate();
-
- # Check if any errors had occured.
-
- if ($kiriwrite_dbmodule->geterror eq "TemplateDatabaseDoesNotExist"){
-
- # The template database does not exist so write a warning
- # message.
-
- $templatewarning = $kiriwrite_lang->{template}->{templatedatabasedoesnotexist};
-
- } elsif ($kiriwrite_dbmodule->geterror eq "TemplateDatabaseInvalidPermissionsSet"){
-
- # The template database has invalid permissions set so
- # return an error.
-
- kiriwrite_error("templatedatabaseinvalidpermissions");
-
- } elsif ($kiriwrite_dbmodule->geterror eq "TemplateDatabaseError"){
-
- # A database error occured while getting the list of
- # templates so return an error with the extended
- # error information.
-
- kiriwrite_error("templatedatabaseerror", $kiriwrite_dbmodule->geterror(1));
-
- }
-
- # Get the list of template databases.
-
- if (!$templatewarning){
-
- # Get the total count of filters in the filter database.
-
- my $template_total_count = $kiriwrite_dbmodule->gettemplatecount;
-
- # Check if any errors occured while getting the count of filters.
-
- if ($kiriwrite_dbmodule->geterror eq "TemplateDatabaseError"){
-
- # A database error has occured with the filter database.
-
- kiriwrite_error("templatedatabaseerror", $kiriwrite_dbmodule->geterror(1));
-
- }
-
- if (!$template_browsenumber || $template_browsenumber eq 0){
-
- $template_browsenumber = 1;
-
- }
-
- # Check if the template browse number is valid and if it isn't
- # then return an error.
-
- my $kiriwrite_browsenumber_length_check = kiriwrite_variablecheck($template_browsenumber, "maxlength", 7, 1);
- my $kiriwrite_browsenumber_number_check = kiriwrite_variablecheck($template_browsenumber, "numbers", 0, 1);
-
- if ($kiriwrite_browsenumber_length_check eq 1){
-
- # The browse number was too long so return
- # an error.
-
- kiriwrite_error("browsenumbertoolong");
-
- }
-
- if ($kiriwrite_browsenumber_number_check eq 1){
-
- # The browse number wasn't a number so
- # return an error.
-
- kiriwrite_error("browsenumberinvalid");
-
- }
-
- if ($template_total_count ne 0){
-
- if ($template_total_count eq $template_split){
-
- $template_list = int(($template_total_count / $template_split));
-
- } else {
-
- $template_list = int(($template_total_count / $template_split) + 1);
-
- }
-
- }
-
- my $start_from = ($template_browsenumber - 1) * $template_split;
-
- @templates_list = $kiriwrite_dbmodule->gettemplatelist({ StartFrom => $start_from, Limit => $template_split });
-
- }
-
- # Check if any errors had occured.
-
- if ($kiriwrite_dbmodule->geterror eq "TemplateDatabaseError"){
-
- # A database error occured while getting the list
- # of templates so return an error with the
- # extended error information.
-
- kiriwrite_error("templatedatabaseerror", $kiriwrite_dbmodule->geterror(1));
-
- }
-
- # Check if any templates are in the database and if there isn't
- # then write a message saying that there are no templates in the
- # database.
-
- if (!@templates_list && $template_browsenumber > 1){
-
- # There were no values given for the page browse
- # number given so write a message saying that
- # there were no pages for the page browse number
- # given.
-
- $kiriwrite_presmodule->clear();
- $kiriwrite_presmodule->addtext(kiriwrite_language($kiriwrite_lang->{template}->{viewtemplates}, $db_name), { Style => "pageheader" });
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->startbox("errorbox");
- $kiriwrite_presmodule->enterdata($kiriwrite_lang->{template}->{notemplatesinpagebrowse});
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlink($kiriwrite_env{"script_filename"} . "?mode=template", { Text => $kiriwrite_lang->{template}->{returntofirstpagebrowse} });
- $kiriwrite_presmodule->endbox();
-
- # Disconnect from the database server.
-
- $kiriwrite_dbmodule->disconnect();
- $kiriwrite_dbmodule->disconnecttemplate();
-
- return $kiriwrite_presmodule->grab();
-
- } elsif (!@templates_list && !$templatewarning){
- $templatewarning = $kiriwrite_lang->{template}->{notemplatesavailable};
- }
-
- # Process the templates into a template list.
-
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{template}->{viewtemplates}, { Style => "pageheader" });
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
-
- if ($templatewarning){
-
- $kiriwrite_presmodule->startbox("errorbox");
- $kiriwrite_presmodule->addtext($templatewarning);
- $kiriwrite_presmodule->endbox();
-
- } else {
-
- if (!$template_browsenumber || $template_browsenumber eq 0){
-
- $template_browsenumber = 1;
-
- }
-
- # Check if the template browse number is valid and if it isn't
- # then return an error.
-
- my $kiriwrite_browsenumber_length_check = kiriwrite_variablecheck($template_browsenumber, "maxlength", 7, 1);
- my $kiriwrite_browsenumber_number_check = kiriwrite_variablecheck($template_browsenumber, "numbers", 0, 1);
-
- if ($kiriwrite_browsenumber_length_check eq 1){
-
- # The browse number was too long so return
- # an error.
-
- kiriwrite_error("browsenumbertoolong");
-
- }
-
- if ($kiriwrite_browsenumber_number_check eq 1){
-
- # The browse number wasn't a number so
- # return an error.
-
- kiriwrite_error("browsenumberinvalid");
-
- }
-
- # Start a form for using the template browsing list with.
-
- $kiriwrite_presmodule->startform($kiriwrite_env{"script_filename"}, "GET");
- $kiriwrite_presmodule->addhiddendata("mode", "template");
-
- # Write out the template browsing list.
-
- $kiriwrite_presmodule->addtext($kiriwrite_lang->{template}->{showlistpage});
- $kiriwrite_presmodule->addselectbox("browsenumber");
-
- # Write out the list of available pages to browse.
-
- if (!$template_list_count){
-
- $template_list_count = 0;
-
- }
-
- while ($template_list_count ne $template_list){
-
- $template_list_count++;
-
- if ($template_list_count eq 1 && !$template_browsenumber){
-
- $kiriwrite_presmodule->addoption($template_list_count, { Value => $template_list_count, Selected => 1 });
-
- } else {
-
- if ($template_browsenumber eq $template_list_count){
-
- $kiriwrite_presmodule->addoption($template_list_count, { Value => $template_list_count, Selected => 1 });
-
- } else {
-
- $kiriwrite_presmodule->addoption($template_list_count, { Value => $template_list_count });
-
- }
-
- }
-
- }
-
- $kiriwrite_presmodule->endselectbox();
- $kiriwrite_presmodule->addbutton("action", { Value => "view", Description => $kiriwrite_lang->{template}->{show} });
-
- if ($template_list ne $template_browsenumber){
-
- $kiriwrite_presmodule->addtext(" | ");
- $kiriwrite_presmodule->addlink($kiriwrite_env{"script_filename"} . "?mode=template&action=view&browsenumber=" . ($template_browsenumber + 1), { Text => $kiriwrite_lang->{template}->{nextpage} });
-
- }
-
- # Check if the filter browse number is not blank and
- # not set as 0 and hide the Previous page link if
- # it is.
-
- if ($template_browsenumber > 1){
-
- $kiriwrite_presmodule->addtext(" | ");
- $kiriwrite_presmodule->addlink($kiriwrite_env{"script_filename"} . "?mode=template&action=view&browsenumber=" . ($template_browsenumber - 1), { Text => $kiriwrite_lang->{template}->{previouspage} });
-
- }
-
- $kiriwrite_presmodule->addlinebreak();
- $kiriwrite_presmodule->addlinebreak();
-
- $kiriwrite_presmodule->starttable("", { CellPadding => 5, CellSpacing => 0 });
- $kiriwrite_presmodule->startheader();
- $kiriwrite_presmodule->addheader($kiriwrite_lang->{template}->{templatefilename}, { Style => "tablecellheader" });
- $kiriwrite_presmodule->addheader($kiriwrite_lang->{template}->{templatename}, { Style => "tablecellheader" });
- $kiriwrite_presmodule->addheader($kiriwrite_lang->{template}->{templatedescription}, { Style => "tablecellheader" });
- $kiriwrite_presmodule->addheader($kiriwrite_lang->{common}->{options}, { Style => "tablecellheader" });
- $kiriwrite_presmodule->endheader();
-
- foreach $template (@templates_list){
-
- # Get the template data.
-
- %template_info = $kiriwrite_dbmodule->gettemplateinfo({ TemplateFilename => $template, Reduced => 1 });
-
- # Check if any errors occured while trying to get the template
- # data.
-
- if ($kiriwrite_dbmodule->geterror eq "TemplateDatabaseError"){
-
- # A database error has occured, so return an error.
-
- kiriwrite_error("templatedatabaseerror", $kiriwrite_dbmodule->geterror(1));
-
- } elsif ($kiriwrite_dbmodule->geterror eq "TemplateDoesNotExist"){
-
- # The template does not exist, so process the next template.
-
- next;
-
- }
-
- $template_filename = $template_info{"TemplateFileName"};
- $template_name = $template_info{"TemplateName"};
- $template_description = $template_info{"TemplateDescription"};
-
- # Check what style the row of table cells should be.
-
- if ($template_style eq 0){
-
- $template_stylename = "tablecell1";
- $template_style = 1;
-
- } else {
-
- $template_stylename = "tablecell2";
- $template_style = 0;
-
- }
-
- $kiriwrite_presmodule->startrow();
- $kiriwrite_presmodule->addcell($template_stylename);
- $kiriwrite_presmodule->addtext($template_info{"TemplateFilename"});
-
-# # Check if the blank template value was set.
-#
-# if (!$template_info{"TemplateLayout"}){
-# $kiriwrite_presmodule->additalictext(" " . "[Blank Template]");
-# }
-
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell($template_stylename);
-
- # Check if the template name is blank and if it is
- # write a message to say there's no name for the
- # template.
-
- if (!$template_info{"TemplateName"}){
- $kiriwrite_presmodule->additalictext($kiriwrite_lang->{blank}->{noname});
- } else {
- $kiriwrite_presmodule->addtext($template_info{"TemplateName"});
- }
-
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell($template_stylename);
-
- # Check if the template description is blank and if
- # it is then write a message to say there's no
- # description for the template.
-
- if (!$template_info{"TemplateDescription"}){
- $kiriwrite_presmodule->additalictext($kiriwrite_lang->{blank}->{nodescription});
- } else {
- $kiriwrite_presmodule->addtext($template_info{"TemplateDescription"});
- }
-
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->addcell($template_stylename);
- $kiriwrite_presmodule->addlink($kiriwrite_env{"script_filename"} . "?mode=template&action=edit&template=" . $template_info{"TemplateFilename"}, { Text => $kiriwrite_lang->{options}->{edit} });
- $kiriwrite_presmodule->addlink($kiriwrite_env{"script_filename"} . "?mode=template&action=delete&template=" . $template_info{"TemplateFilename"}, { Text => $kiriwrite_lang->{options}->{delete} });
- $kiriwrite_presmodule->endcell();
- $kiriwrite_presmodule->endrow();
-
- }
-
- $kiriwrite_presmodule->endtable();
- $kiriwrite_presmodule->endform();
-
- }
-
- # Disconnect from the database server.
-
- $kiriwrite_dbmodule->disconnect();
-
- $kiriwrite_dbmodule->disconnecttemplate();
- return $kiriwrite_presmodule->grab();
-
-
-}
-
-1;
<kiriwrite:pagedata>
</div>
<div class="copyrightbar">
- ©2005-2007 Steve Brokenshire<br />
+ ©2005-2008 Steve Brokenshire<br />
</div>
</div>
</body>