#!/usr/bin/perl # TmNetWiki version 0.4 (September 11, 2002) # Copyright (C) 2002 Adam Brate # # Based on the GPLed UseModWiki 0.92 # Copyright (C) 2000-2001 Clifford A. Adams # or # Based on the GPLed AtisWiki 0.3 (C) 1998 Markus Denker # # ...which was based on # the LGPLed CVWiki CVS-patches (C) 1997 Peter Merel # and The Original WikiWikiWeb (C) Ward Cunningham # (code reused with permission) # Email and ThinLine options by Jim Mahoney # # 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 Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the # Free Software Foundation, Inc. # 59 Temple Place, Suite 330 # Boston, MA 02111-1307 USA package Wiki; use strict; local $| = 1; # Do not buffer output (localized for mod_perl) #use base 'Exporter'; use Wiki::consts; use Wiki::init; use Wiki::browse; use Wiki::cache; use Wiki::special; use CGI; use CGI::Carp qw(fatalsToBrowser); use Template; use Wiki::file; use Wiki::error; use Wiki::translate; use Wiki::user; # The "main" program, called at the end of this script file. sub DoWikiRequest { if (!&DoCacheBrowse()) { eval $BrowseCode; &InitRequest() or return; if (!&DoBrowseRequest()) { eval $OtherCode; &DoOtherRequest(); } } } sub new { my $class = shift; my $self = {}; bless $self, $class; return $self; } sub start { my $self = shift; my $datadir = shift; &DoWikiConfig($datadir); &DoWikiRequest() if ($RunCGI && ($_ ne 'nocgi')); # Do everything. } # == Normal page-browsing and RecentChanges code ======================= $BrowseCode = ""; # Comment next line to always compile (slower) #$BrowseCode = <<'#END_OF_BROWSE_CODE'; sub InitRequest { my @scriptPath = split('/', "$ENV{SCRIPT_NAME}"); $CGI::POST_MAX = $Consts->{MaxPost}; $CGI::DISABLE_UPLOADS = 1; # no uploads $q = new CGI; $Template = Template->new({ INCLUDE_PATH => $TemplateDir, EVAL_PERL => 1, # evaluate Perl code blocks }); $Now = time; # Reset in case script is persistent $Consts->{Now} = $Now; $ScriptName = pop(@scriptPath); # Name used in links $Consts->{ScriptName} = $ScriptName; $IndexInit = 0; # Must be reset for each request $InterSiteInit = 0; %InterSite = (); $MainPage = "."; # For subpages only, the name of the top-level page $OpenPageName = ""; # Currently open page &CreateDir($DataDir); # Create directory if it doesn't exist if (!-d $DataDir) { &ReportError(Ts('Could not create %s', $DataDir) . ": $!"); return 0; } &InitCookie(); # Reads in user data return 1; } sub InitCookie { %SetCookie = (); $TimeZoneOffset = 0; undef $q->{'.cookies'}; # Clear cache if it exists (for SpeedyCGI) %UserCookie = $q->cookie($CookieName); $UserID = $UserCookie{'uid'}; $UserID =~ s/\D//g; # Numeric only if ($UserID < 200) { $UserID = 111; } else { &LoadUserData($UserID); } if ($UserID > 199) { if (($UserData{'uid'} != $UserCookie{'uid'}) || ($UserData{'randkey'} != $UserCookie{'randkey'})) { $UserID = 113; %UserData = (); # Invalid. Later consider warning message. } } if ($UserData{'tzoffset'} != 0) { $TimeZoneOffset = $UserData{'tzoffset'} * (60 * 60); } } # ==== Difference markup and HTML ==== # Wiki::diff # ==== Database (Page, Section, Text, Kept, User) functions ==== # Wiki::page # Wiki::section # Wiki::keep # Wiki::text # Wiki::user # Wiki::quotes # Wiki::area # ==== Misc. functions ==== # Wiki::utility # == Page-editing and other special-action code ======================== # Wiki::special # Wiki::edit # Wiki::index # Wiki::links # Wiki::admin # Wiki::login # Wiki::search # Wiki::lock #&DoWikiRequest() if ($RunCGI && ($_ ne 'nocgi')); # Do everything. 1; # In case we are loaded from elsewhere # == End of TmNetWiki script. ===========================================