#!/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::login; use strict; # needs subs Wiki::user: CreateUserDir, GetNewUserId, SaveUserData, LoadUserData # Wiki::template: GetHeader, GetFormStart, GetHiddenValue, GetGotoBar, # GetMinimumFooter, # Wiki::translate: T, Ts # Wiki::utility: GetParam # needs vars %UserCookie, %UserData, %SetCookie, q, $ENV{REMOTE_ADDR}, $UserID use base 'Exporter'; use Wiki::consts; use Wiki::user; use Wiki::template; use Wiki::translate; use Wiki::utility; #if ($^V and $^V gt v5.6.0) { # our @EXPORT; #else { use vars qw(@EXPORT); #} @EXPORT = qw( DoLogin DoEnterLogin DoNewLogin ); # Create a new user file/cookie pair sub DoNewLogin { # Later consider warning if cookie already exists # (maybe use "replace=1" parameter) &CreateUserDir(); $SetCookie{'uid'} = &GetNewUserId; $SetCookie{'randkey'} = int(rand(1000000000)); $SetCookie{'rev'} = 1; %UserCookie = %SetCookie; $UserID = $SetCookie{'uid'}; # The cookie will be transmitted in the next header %UserData = %UserCookie; $UserData{'createtime'} = $Now; $UserData{'createip'} = $ENV{REMOTE_ADDR}; &SaveUserData(); } sub DoEnterLogin { print &GetHeader('', T('Login'), ""); print &GetFormStart(); print &GetHiddenValue('enter_login', 1), "\n"; print '
', T('User ID number:'), ' ', $q->textfield(-name=>'p_userid', -value=>'', -size=>15, -maxlength=>50); print '
', T('Password:'), ' ', $q->password_field(-name=>'p_password', -value=>'', -size=>15, -maxlength=>50); print '
', $q->submit(-name=>'Login', -value=>T('Login')), "\n"; print "
\n"; print &GetGotoBar(''); print $q->endform; print &GetMinimumFooter(); } sub DoLogin { my ($uid, $password, $success); $success = 0; $uid = &GetParam("p_userid", ""); $uid =~ s/\D//g; $password = &GetParam("p_password", ""); if (($uid > 199) && ($password ne "") && ($password ne "*")) { $UserID = $uid; &LoadUserData(); if ($UserID > 199) { if (defined($UserData{'password'}) && ($UserData{'password'} eq $password)) { $SetCookie{'uid'} = $uid; $SetCookie{'randkey'} = $UserData{'randkey'}; $SetCookie{'rev'} = 1; $success = 1; } } } print &GetHeader('', T('Login Results'), ''); if ($success) { print Ts('Login for user ID %s complete.', $uid); } else { print Ts('Login for user ID %s failed.', $uid); } print "
\n"; print &GetGotoBar(''); print $q->endform; print &GetMinimumFooter(); }