index.cgi 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #!/usr/bin/env perl -wT
  2. # -*- Mode: perl; indent-tabs-mode: nil -*-
  3. #
  4. # The contents of this file are subject to the Mozilla Public
  5. # License Version 1.1 (the "License"); you may not use this file
  6. # except in compliance with the License. You may obtain a copy of
  7. # the License at http://www.mozilla.org/MPL/
  8. #
  9. # Software distributed under the License is distributed on an "AS
  10. # IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  11. # implied. See the License for the specific language governing
  12. # rights and limitations under the License.
  13. #
  14. # The Original Code is the Bugzilla Bug Tracking System.
  15. #
  16. # The Initial Developer of the Original Code is Netscape Communications
  17. # Corporation. Portions created by Netscape are
  18. # Copyright (C) 1998 Netscape Communications Corporation. All
  19. # Rights Reserved.
  20. #
  21. # Contributor(s): Jacob Steenhagen <jake@bugzilla.org>
  22. # Frédéric Buclin <LpSolit@gmail.com>
  23. ###############################################################################
  24. # Script Initialization
  25. ###############################################################################
  26. # Make it harder for us to do dangerous things in Perl.
  27. use strict;
  28. # Include the Bugzilla CGI and general utility library.
  29. use lib qw(. lib);
  30. use Bugzilla;
  31. use Bugzilla::Constants;
  32. use Bugzilla::Error;
  33. use Bugzilla::Update;
  34. # Check whether or not the user is logged in
  35. my $user = Bugzilla->login(LOGIN_OPTIONAL);
  36. ###############################################################################
  37. # Main Body Execution
  38. ###############################################################################
  39. my $cgi = Bugzilla->cgi;
  40. # Force to use HTTPS unless Bugzilla->params->{'ssl'} equals 'never'.
  41. # This is required because the user may want to log in from here.
  42. if ($cgi->protocol ne 'https' && Bugzilla->params->{'sslbase'} ne ''
  43. && Bugzilla->params->{'ssl'} ne 'never')
  44. {
  45. $cgi->require_https(Bugzilla->params->{'sslbase'});
  46. }
  47. my $template = Bugzilla->template;
  48. my $vars = {};
  49. # Return the appropriate HTTP response headers.
  50. print $cgi->header();
  51. if ($user->in_group('admin')) {
  52. # If 'urlbase' is not set, display the Welcome page.
  53. unless (Bugzilla->params->{'urlbase'}) {
  54. $template->process('welcome-admin.html.tmpl')
  55. || ThrowTemplateError($template->error());
  56. exit;
  57. }
  58. # Inform the administrator about new releases, if any.
  59. $vars->{'release'} = Bugzilla::Update::get_notifications();
  60. }
  61. # Generate and return the UI (HTML page) from the appropriate template.
  62. $template->process("index.html.tmpl", $vars)
  63. || ThrowTemplateError($template->error());