X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;f=cgi-files%2FModules%2FDatabase%2FSQLite.pm;h=31d0deeff1c511a51acb5716e95d428543a6e8b7;hb=1553f195cb1ca50f1409afec52b29002e03b4511;hp=f179a623883639c9367bb4b66d7588c44e809475;hpb=fae62c16cf66ea474ae619b0abf1b5e4af048978;p=kiriwrite%2F.git diff --git a/cgi-files/Modules/Database/SQLite.pm b/cgi-files/Modules/Database/SQLite.pm index f179a62..31d0dee 100644 --- a/cgi-files/Modules/Database/SQLite.pm +++ b/cgi-files/Modules/Database/SQLite.pm @@ -30,7 +30,7 @@ use warnings; # Load the following Perl modules. -use DBI; +use DBI qw(:sql_types); # Set the following values. @@ -38,10 +38,12 @@ our $VERSION = "0.1.0"; my ($options, %options); my $database_handle; my $string_handle; -my $second_database_handle; -my $second_string_handle; +my $error = ""; +my $errorext = ""; my $database_filename; my $second_database_filename; +my $second_database_handle; +my $second_string_handle; my $templatedb_loaded = 0; my $templatedb_exists = 1; my $template_string_handle; @@ -50,8 +52,7 @@ my $filterdb_loaded = 0; my $filterdb_exists = 1; my $filterdb_string_handle; my $filterdb_database_handle; -my $error = ""; -my $errorext = ""; + ################################################################################# # Generic Subroutines. # @@ -1481,6 +1482,33 @@ sub editpage{ } + # Check if there is a page that already exists with the new + # filename. + + if ($page_filename ne $page_newfilename){ + + $string_handle = $database_handle->prepare('SELECT filename FROM kiriwrite_database_pages WHERE filename = \'' . $class->convert($page_newfilename) . '\' LIMIT 1') or ( $error = "DatabaseError", $errorext = $database_handle->errstr, return ); + $string_handle->execute(); + + # Check if a page really is using the new filename. + + while (@page_info = $string_handle->fetchrow_array()){ + + # The page information is found. + + $page_found = 1; + + } + + if ($page_found eq 1){ + + $error = "PageExists"; + return; + + } + + } + # Get the current date. my ($created_second, $created_minute, $created_hour, $created_day, $created_month, $created_year, $created_weekday, $created_yearday, $created_dst) = localtime; @@ -1793,7 +1821,7 @@ sub connectfilter{ # Connect to the template database. $filterdb_database_handle = DBI->connect("dbi:SQLite:dbname=filters.db.sqlite"); - $database_handle->{unicode} = 1; + $filterdb_database_handle->{unicode} = 1; $filterdb_loaded = 1; } @@ -2317,7 +2345,7 @@ sub connecttemplate{ # Connect to the template database. $template_database_handle = DBI->connect("dbi:SQLite:dbname=templates.db.sqlite"); - $database_handle->{unicode} = 1; + $template_database_handle->{unicode} = 1; $templatedb_loaded = 1; }