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