PageRenderTime 46ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/www/index.php

https://gitlab.com/florianocomercial/centreon
PHP | 139 lines | 59 code | 20 blank | 60 comment | 13 complexity | 410673931995fc6fad40fe104b14855e MD5 | raw file
  1. <?php
  2. /*
  3. * Copyright 2005-2015 Centreon
  4. * Centreon is developped by : Julien Mathis and Romain Le Merlus under
  5. * GPL Licence 2.0.
  6. *
  7. * This program is free software; you can redistribute it and/or modify it under
  8. * the terms of the GNU General Public License as published by the Free Software
  9. * Foundation ; either version 2 of the License.
  10. *
  11. * This program is distributed in the hope that it will be useful, but WITHOUT ANY
  12. * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  13. * PARTICULAR PURPOSE. See the GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License along with
  16. * this program; if not, see <http://www.gnu.org/licenses>.
  17. *
  18. * Linking this program statically or dynamically with other modules is making a
  19. * combined work based on this program. Thus, the terms and conditions of the GNU
  20. * General Public License cover the whole combination.
  21. *
  22. * As a special exception, the copyright holders of this program give Centreon
  23. * permission to link this program with independent modules to produce an executable,
  24. * regardless of the license terms of these independent modules, and to copy and
  25. * distribute the resulting executable under terms of Centreon choice, provided that
  26. * Centreon also meet, for each linked independent module, the terms and conditions
  27. * of the license of that module. An independent module is a module which is not
  28. * derived from this program. If you modify this program, you may extend this
  29. * exception to your version of the program, but you are not obliged to do so. If you
  30. * do not wish to do so, delete this exception statement from your version.
  31. *
  32. * For more information : contact@centreon.com
  33. *
  34. *
  35. */
  36. require_once realpath(dirname(__FILE__).'/../config/centreon.config.php');
  37. $etc = _CENTREON_ETC_;
  38. define('SMARTY_DIR', realpath('../GPL_LIB/Smarty/libs/') . '/');
  39. ini_set('display_errors', 'Off');
  40. clearstatcache(true, "$etc/centreon.conf.php");
  41. if (!file_exists("$etc/centreon.conf.php") && is_dir('./install')) {
  42. header("Location: ./install/setup.php");
  43. return;
  44. } elseif (file_exists("$etc/centreon.conf.php") && is_dir('install')) {
  45. require_once ("$etc/centreon.conf.php");
  46. header("Location: ./install/upgrade.php");
  47. } else {
  48. if (file_exists("$etc/centreon.conf.php")) {
  49. require_once ("$etc/centreon.conf.php");
  50. $freeze = 0;
  51. } else {
  52. $freeze = 0;
  53. //require_once ("../centreon.conf.php");
  54. // $msg = _("You have to move centreon configuration file from temporary directory to final directory");
  55. }
  56. }
  57. require_once "$classdir/centreon.class.php";
  58. require_once "$classdir/centreonSession.class.php";
  59. require_once "$classdir/centreonAuth.SSO.class.php";
  60. require_once "$classdir/centreonLog.class.php";
  61. require_once "$classdir/centreonDB.class.php";
  62. require_once SMARTY_DIR."Smarty.class.php";
  63. /*
  64. * Get auth type
  65. */
  66. global $pearDB;
  67. $pearDB = new CentreonDB();
  68. $DBRESULT = $pearDB->query("SELECT * FROM `options`");
  69. while ($generalOption = $DBRESULT->fetchRow()) {
  70. $generalOptions[$generalOption["key"]] = $generalOption["value"];
  71. }
  72. $DBRESULT->free();
  73. /*
  74. * Set Skin For CSS properties
  75. */
  76. $skin = "./Themes/".$generalOptions["template"]."/";
  77. /*
  78. * detect installation dir
  79. */
  80. $file_install_acces = 0;
  81. if (file_exists("./install/setup.php")){
  82. $error_msg = "Installation Directory '". getcwd() ."/install/' is accessible. Delete this directory to prevent security problem.";
  83. $file_install_acces = 1;
  84. }
  85. /*
  86. * Set PHP Session Expiration time
  87. */
  88. ini_set("session.gc_maxlifetime", "31536000");
  89. CentreonSession::start();
  90. if (isset($_GET["disconnect"])) {
  91. $centreon = & $_SESSION["centreon"];
  92. /*
  93. * Init log class
  94. */
  95. if (is_object($centreon)) {
  96. $CentreonLog = new CentreonUserLog($centreon->user->get_id(), $pearDB);
  97. $CentreonLog->insertLog(1, "Contact '".$centreon->user->get_alias()."' logout");
  98. $pearDB->query("DELETE FROM session WHERE session_id = '".session_id()."'");
  99. CentreonSession::restart();
  100. }
  101. }
  102. /*
  103. * already connected
  104. */
  105. if (isset($_SESSION["centreon"])) {
  106. $centreon = & $_SESSION["centreon"];
  107. header('Location: main.php');
  108. }
  109. /*
  110. * Check PHP version
  111. *
  112. * Centreon 2.x doesn't support PHP < 5.3
  113. *
  114. */
  115. if (version_compare(phpversion(), '5.3') < 0){
  116. echo "<div class='msg'> PHP version is < 5.3. Please Upgrade PHP</div>";
  117. } else {
  118. include_once("./login.php");
  119. }