Initial commit.
This commit is contained in:
83
lib/perl5/Selima/Guest.pm
Normal file
83
lib/perl5/Selima/Guest.pm
Normal file
@@ -0,0 +1,83 @@
|
||||
# Selima Website Content Management System
|
||||
# Guest.pm: The subroutines for anonymouse/guest operations.
|
||||
|
||||
# Copyright (c) 2004-2018 imacat.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# Author: imacat <imacat@mail.imacat.idv.tw>
|
||||
# First written: 2004-09-26
|
||||
|
||||
package Selima::Guest;
|
||||
use 5.008;
|
||||
use strict;
|
||||
use warnings;
|
||||
use base qw(Exporter);
|
||||
use vars qw(@EXPORT @EXPORT_OK);
|
||||
BEGIN {
|
||||
@EXPORT = qw(is_guest gactlog goutpage grmoldpage grmoldfile);
|
||||
@EXPORT_OK = @EXPORT;
|
||||
# Prototype declaration
|
||||
sub is_guest(;$);
|
||||
sub gactlog($;$);
|
||||
sub goutpage($$;$);
|
||||
sub grmoldpage($;$);
|
||||
sub grmoldfile($;$);
|
||||
}
|
||||
|
||||
use Selima::Array;
|
||||
use Selima::Cache qw(:guest);
|
||||
use Selima::ChkPriv;
|
||||
use Selima::DataVars qw(:input :groups);
|
||||
use Selima::Logging;
|
||||
use Selima::LogIn;
|
||||
use Selima::MkAllDir;
|
||||
use Selima::PageFunc;
|
||||
use Selima::UserName;
|
||||
use Selima::XFileIO;
|
||||
|
||||
# is_guest: If the user is a guest (by the user id)
|
||||
sub is_guest(;$) {
|
||||
local ($_, %_);
|
||||
$_ = $_[0];
|
||||
# Default to the current logged-in user
|
||||
return !is_su && in_array(GUEST_GROUP, get_login_groups)
|
||||
if !defined $_ || (defined get_login_sn && $_ == get_login_sn);
|
||||
# Super user is never a guest
|
||||
return ($Guest_is_guest{$_} = 0) if is_su($_);
|
||||
# Obtain the groups
|
||||
return ($Guest_is_guest{$_} = in_array(GUEST_GROUP,
|
||||
user_parent_groups($_)));
|
||||
}
|
||||
|
||||
# gactlog: Add an activity log record if the user is not a guest
|
||||
sub gactlog($;$) {
|
||||
actlog $_[0], $_[1] unless is_guest;
|
||||
}
|
||||
|
||||
# goutpage: outpage() if the user is not a guest
|
||||
sub goutpage($$;$) {
|
||||
outpage $_[0], $_[1], $_[2] unless is_guest;
|
||||
}
|
||||
|
||||
# grmoldpage: rmoldpage() if the user is not a guest
|
||||
sub grmoldpage($;$) {
|
||||
rmoldpage $_[0], $_[1] unless is_guest;
|
||||
}
|
||||
|
||||
# grmoldfile: rmoldfile() if the user is not a guest
|
||||
sub grmoldfile($;$) {
|
||||
rmoldfile $_[0], $_[1] unless is_guest;
|
||||
}
|
||||
|
||||
return 1;
|
||||
Reference in New Issue
Block a user