summaryrefslogtreecommitdiff
path: root/admin.pl
blob: 9cf121f8f2f7a96b9571fdcd00b8270ce0524968 (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. require "common.pl";
  52. $| = 1;
  53. if ( $ENV{CONTENT_LENGTH} > $LedgerSMB::Sysconfig::max_post_size ) {
  54. print "Status: 413\n Request entity too large\n\n";
  55. die "Error: Request entity too large\n";
  56. }
  57. if ( $ENV{CONTENT_LENGTH} > 0 ) {
  58. read( STDIN, $_, $ENV{CONTENT_LENGTH} );
  59. }
  60. if ( $ENV{QUERY_STRING} ) {
  61. $_ = $ENV{QUERY_STRING};
  62. }
  63. if ( $ARGV[0] ) {
  64. $_ = $ARGV[0];
  65. }
  66. %form = split /[&=]/;
  67. # fix for apache 2.0 bug
  68. map { $form{$_} =~ s/\\$// } keys %form;
  69. # name of this script
  70. $0 =~ tr/\\/\//;
  71. $pos = rindex $0, '/';
  72. $script = substr( $0, $pos + 1 );
  73. #this needs to be a db based function
  74. #if (-e "${LedgerSMB::Sysconfig::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 "bin/$script";
  84. }
  85. else {
  86. $form{terminal} = "lynx";
  87. if ( $ENV{HTTP_USER_AGENT} !~ /lynx/i ) {
  88. $form{terminal} = "mozilla";
  89. }
  90. $ARGV[0] = "path=bin/$form{terminal}&script=$script";
  91. map { $ARGV[0] .= "&${_}=$form{$_}" } keys %form;
  92. require "bin/$script";
  93. }
  94. # end of main