- 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.