summaryrefslogtreecommitdiff
path: root/admin.pl
blob: c4ae2d48b48a40d803740b66af13c8cb9e2b4f60 (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} ) {
  54. read( STDIN, $_, $ENV{CONTENT_LENGTH} );
  55. }
  56. if ( $ENV{QUERY_STRING} ) {
  57. $_ = $ENV{QUERY_STRING};
  58. }
  59. if ( $ARGV[0] ) {
  60. $_ = $ARGV[0];
  61. }
  62. %form = split /[&=]/;
  63. # fix for apache 2.0 bug
  64. map { $form{$_} =~ s/\\$// } keys %form;
  65. # name of this script
  66. $0 =~ tr/\\/\//;
  67. $pos = rindex $0, '/';
  68. $script = substr( $0, $pos + 1 );
  69. #this needs to be a db based function
  70. #if (-e "${LedgerSMB::Sysconfig::userspath}/nologin" && $script ne 'admin.pl') {
  71. # print "Content-Type: text/html\n\n<html><body><strong>";
  72. # print "\nLogin disabled!\n";
  73. # print "\n</strong></body></html>";
  74. # exit;
  75. #}
  76. if ( $form{path} ) {
  77. if ( $form{path} ne 'bin/lynx' ) { $form{path} = 'bin/mozilla'; }
  78. $ARGV[0] = "$_&script=$script";
  79. require "bin/$script";
  80. }
  81. else {
  82. $form{terminal} = "lynx";
  83. if ( $ENV{HTTP_USER_AGENT} !~ /lynx/i ) {
  84. $form{terminal} = "mozilla";
  85. }
  86. $ARGV[0] = "path=bin/$form{terminal}&script=$script";
  87. map { $ARGV[0] .= "&${_}=$form{$_}" } keys %form;
  88. require "bin/$script";
  89. }
  90. # end of main