summaryrefslogtreecommitdiff
path: root/admin.pl
blob: f49dacda60b3f08af9da508d4ef6af328b80b73e (plain)
  1. #!/usr/bin/perl
  2. #
  3. ######################################################################
  4. # LedgerSMB Accounting and ERP
  5. # http://sourceforge.net/projects/ledger-smb/
  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://sourceforge.net/projects/ledger-smb/
  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. # setup defaults, DO NOT CHANGE
  51. $userspath = "users";
  52. $spool = "spool";
  53. $templates = "templates";
  54. $memberfile = "users/members";
  55. $sendmail = "| /usr/sbin/sendmail -t";
  56. %printer = ( Printer => 'lpr' );
  57. ########## end ###########################################
  58. $| = 1;
  59. eval { require "ledger-smb.conf"; };
  60. if ($ENV{CONTENT_LENGTH}) {
  61. read(STDIN, $_, $ENV{CONTENT_LENGTH});
  62. }
  63. if ($ENV{QUERY_STRING}) {
  64. $_ = $ENV{QUERY_STRING};
  65. }
  66. if ($ARGV[0]) {
  67. $_ = $ARGV[0];
  68. }
  69. %form = split /[&=]/;
  70. # fix for apache 2.0 bug
  71. map { $form{$_} =~ s/\\$// } keys %form;
  72. # name of this script
  73. $0 =~ tr/\\/\//;
  74. $pos = rindex $0, '/';
  75. $script = substr($0, $pos + 1);
  76. if (-e "$userspath/nologin" && $script ne 'admin.pl') {
  77. print "Content-Type: text/html\n\n<html><body><strong>";
  78. print "\nLogin disabled!\n";
  79. print "\n</strong></body></html>";
  80. exit;
  81. }
  82. if ($form{path}) {
  83. if ($form{path} ne 'bin/lynx'){ $form{path} = 'bin/mozilla';}
  84. $ARGV[0] = "$_&script=$script";
  85. require "$form{path}/$script";
  86. } else {
  87. $form{terminal} = "lynx";
  88. if ($ENV{HTTP_USER_AGENT} !~ /lynx/i) {
  89. $form{terminal} = "mozilla";
  90. }
  91. $ARGV[0] = "path=bin/$form{terminal}&script=$script";
  92. map { $ARGV[0] .= "&${_}=$form{$_}" } keys %form;
  93. require "bin/$form{terminal}/$script";
  94. }
  95. # end of main