bin/lynx wurde nie wirklich unterstuetzt und wird somit entfernt.
[kivitendo-erp.git] / login.pl
1 #!/usr/bin/perl
2 #
3 ######################################################################
4 # SQL-Ledger Accounting
5 # Copyright (C) 2001
6 #
7 #  Author: Dieter Simader
8 #   Email: dsimader@sql-ledger.org
9 #     Web: http://www.sql-ledger.org
10 #
11 #  Contributors:
12 #
13 # This program is free software; you can redistribute it and/or modify
14 # it under the terms of the GNU General Public License as published by
15 # the Free Software Foundation; either version 2 of the License, or
16 # (at your option) any later version.
17 #
18 # This program is distributed in the hope that it will be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 # GNU General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write to the Free Software
24 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 #######################################################################
26 #
27 # this script sets up the terminal and runs the scripts
28 # in bin/$terminal directory
29 # admin.pl is linked to this script
30 #
31 #######################################################################
32
33 # setup defaults, DO NOT CHANGE
34 $userspath  = "users";
35 $templates  = "templates";
36 $memberfile = "users/members";
37 $sendmail   = "| /usr/sbin/sendmail -t";
38 ########## end ###########################################
39
40 $| = 1;
41
42 use SL::LXDebug;
43 $lxdebug = LXDebug->new();
44
45 eval { require "lx-erp.conf"; };
46
47 if ($ENV{CONTENT_LENGTH}) {
48   read(STDIN, $_, $ENV{CONTENT_LENGTH});
49 }
50
51 if ($ENV{QUERY_STRING}) {
52   $_ = $ENV{QUERY_STRING};
53 }
54
55 if ($ARGV[0]) {
56   $_ = $ARGV[0];
57 }
58
59 %form = split /[&=]/;
60
61 # fix for apache 2.0 bug
62 map { $form{$_} =~ s/\\$// } keys %form;
63
64 # name of this script
65 $0 =~ tr/\\/\//;
66 $pos = rindex $0, '/';
67 $script = substr($0, $pos + 1);
68
69 if (-e "$userspath/nologin" && $script ne 'admin.pl') {
70   print "content-type: text/plain
71
72 Login disabled!\n";
73
74   exit;
75 }
76
77 if ($form{path}) {
78   $form{path} =~ s/%2f/\//gi;
79   $form{path} =~ s/\.\.\///g;
80
81   if ($form{path} !~ /^bin\//) {
82     print "content-type: text/plain
83
84 Invalid path!\n";
85     die;
86   }
87
88   $ARGV[0] = "$_&script=$script";
89   require "$form{path}/$script";
90 } else {
91
92   if (!$form{terminal}) {
93     if ($ENV{HTTP_USER_AGENT}) {
94
95       # web browser
96       if ($ENV{HTTP_USER_AGENT} =~ /(mozilla|links|opera|w3m)/i) {
97         $form{terminal} = "mozilla";
98       }
99
100     } else {
101       if ($ENV{TERM} =~ /xterm/) {
102         $form{terminal} = "xterm";
103       }
104       if ($ENV{TERM} =~ /(console|linux|vt.*)/i) {
105         $form{terminal} = "console";
106       }
107     }
108   }
109
110   if ($form{terminal}) {
111
112     $ARGV[0] = "path=bin/$form{terminal}&script=$script";
113     map { $ARGV[0] .= "&${_}=$form{$_}" } keys %form;
114
115     require "bin/$form{terminal}/$script";
116
117   } else {
118
119     print qq|
120   Unknown terminal
121   |;
122   }
123
124 }
125
126 # end of main
127