# Selima Website Content Management System # Server.pm: The server software identifiers. # 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 # First written: 2004-09-12 package Selima::Server; use 5.008; use strict; use warnings; use base qw(Exporter); use vars qw(@EXPORT @EXPORT_OK); BEGIN { @EXPORT = qw(is_apache is_iis); @EXPORT_OK = @EXPORT; # Prototype declaration sub is_apache(); sub is_iis(); } use Selima::DataVars qw(:env); # The result never changes in any circumstances use vars qw($IS_APACHE $IS_IIS); undef $IS_APACHE; undef $IS_IIS; # is_apache: If this server is Apache sub is_apache() { # Checked before return $IS_APACHE if defined $IS_APACHE; # mod_perl always run on Apache return ($IS_APACHE = 1) if $IS_MODPERL; # Check from SERVER_SOFTWARE return ($IS_APACHE = ($ENV{"SERVER_SOFTWARE"} =~ /^Apache\b/? 1: 0)); } # is_iis: If this server is Microsoft-IIS sub is_iis() { # Checked before return $IS_IIS if defined $IS_IIS; # mod_perl never run on Microsoft-IIS return ($IS_IIS = 0) if $IS_MODPERL; # Check from SERVER_SOFTWARE return ($IS_IIS = ($ENV{"SERVER_SOFTWARE"} =~ /^Microsoft-(?:IIS|PWS)\b/? 1: 0)); } return 1;