summaryrefslogtreecommitdiff
path: root/login.pl
blob: 10d0d826587bd4757e04a5b2572da3fbf26a5185 (plain)
  1. #!/usr/bin/perl
  2. #
  3. ######################################################################
  4. # LedgerSMB Accounting and ERP
  5. # http://www.ledgersmb.org/
  6. #
  7. # Copyright (C) 2006
  8. # This work contains copyrighted information from a number of sources all used
  9. # with permission.
  10. #
  11. # This file contains source code included with or based on SQL-Ledger which
  12. # is Copyright Dieter Simader and DWS Systems Inc. 2000-2005 and licensed
  13. # under the GNU General Public License version 2 or, at your option, any later
  14. # version. For a full list including contact information of contributors,
  15. # maintainers, and copyright holders, see the CONTRIBUTORS file.
  16. #
  17. # Original Copyright Notice from SQL-Ledger 2.6.17 (before the fork):
  18. # Copyright (C) 2001
  19. #
  20. # Author: Dieter Simader
  21. # Email: dsimader@sql-ledger.org
  22. # Web: http://www.sql-ledger.org
  23. #
  24. # Contributors:
  25. #
  26. #
  27. # Web: http://www.ledgersmb.org/
  28. #
  29. # Contributors:
  30. #
  31. # This program is free software; you can redistribute it and/or modify
  32. # it under the terms of the GNU General Public License as published by
  33. # the Free Software Foundation; either version 2 of the License, or
  34. # (at your option) any later version.
  35. #
  36. # This program is distributed in the hope that it will be useful,
  37. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  38. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  39. # GNU General Public License for more details.
  40. # You should have received a copy of the GNU General Public License
  41. # along with this program; if not, write to the Free Software
  42. # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  43. #######################################################################
  44. #
  45. # this script sets up the terminal and runs the scripts
  46. # in bin/$terminal directory
  47. # admin.pl is linked to this script
  48. #
  49. #######################################################################
  50. use LedgerSMB::Sysconfig;
  51. $| = 1;
  52. if ($ENV{CONTENT_LENGTH}) {
  53. read(STDIN, $_, $ENV{CONTENT_LENGTH});
  54. }
  55. if ($ENV{QUERY_STRING}) {
  56. $_ = $ENV{QUERY_STRING};
  57. }
  58. if ($ARGV[0]) {
  59. $_ = $ARGV[0];
  60. }
  61. %form = split /[&=]/;
  62. # fix for apache 2.0 bug
  63. map { $form{$_} =~ s/\\$// } keys %form;
  64. # name of this script
  65. $0 =~ tr/\\/\//;
  66. $pos = rindex $0, '/';
  67. $script = substr($0, $pos + 1);
  68. if (-e "${LedgerSMB::Sysconfig::userspath}/nologin" && $script ne 'admin.pl') {
  69. print "Content-Type: text/html\n\n<html><body><strong>";
  70. print "\nLogin disabled!\n";
  71. print "\n</strong></body></html>";
  72. exit;
  73. }
  74. if ($form{path}) {
  75. if ($form{path} ne 'bin/lynx'){ $form{path} = 'bin/mozilla';}
  76. $ARGV[0] = "$_&script=$script";
  77. require "bin/$script";
  78. } else {
  79. $form{terminal} = "lynx";
  80. if ($ENV{HTTP_USER_AGENT} !~ /lynx/i) {
  81. $form{terminal} = "mozilla";
  82. }
  83. $ARGV[0] = "path=bin/$form{terminal}&script=$script";
  84. map { $ARGV[0] .= "&${_}=$form{$_}" } keys %form;
  85. require "bin/$script";
  86. }
  87. # end of main