/webapp/conf/config.php

https://github.com/GrottoCenter/GrottoCenter · PHP · 87 lines · 37 code · 4 blank · 46 comment · 3 complexity · d19a38caf510c2ee1011962d17b8ce93 MD5 · raw file

  1. <?php
  2. /**
  3. * This file is part of GrottoCenter.
  4. *
  5. * GrottoCenter is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU Affero General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * GrottoCenter is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU Affero General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Affero General Public License
  16. * along with GrottoCenter. If not, see <http://www.gnu.org/licenses/>.
  17. *
  18. * @copyright Copyright (c) 2009-2012 Cl�ment Ronzon
  19. * @license http://www.gnu.org/licenses/agpl.txt
  20. */
  21. ob_start("ob_gzhandler");
  22. error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED);
  23. date_default_timezone_set('Europe/Paris');
  24. include("session.php");
  25. /*header("Cache-Control: no-cache, must-revalidate");
  26. $offset = 6 * 60 * 60;
  27. $ExpDate = gmdate("D, d M Y H:i:s", time() + $offset);
  28. header("Expires: ".$ExpDate." GMT");*/
  29. function logDBToFile($content, $filename)
  30. {
  31. return "";
  32. $path = substr(__FILE__, 0, strlen(__FILE__)-15)."log/";
  33. $handle = fopen($path.$filename.".".date("Y-m-d", time()).".log", "a+b");
  34. $date = date("r", time());
  35. fwrite($handle, $date.$content."\n");
  36. fclose($handle);
  37. }
  38. //on devrais tester aussi l'utilisation de $_SERVER['DOCUMENT_ROOT']
  39. function connect($only = false)
  40. {
  41. //global $host_db,$user_db,$password_db,$bdd_db;
  42. $host_db = "localhost"; // nom de votre serveur
  43. $user_db = ""; // nom d'utilisateur de connexion � votre bdd
  44. $password_db = ""; // mot de passe de connexion � votre bdd
  45. $bdd_db = "grottoce"; // nom de votre bdd
  46. $connect_db = mysql_connect($host_db,$user_db,$password_db);
  47. if ($only) {
  48. return $connect_db;
  49. }
  50. /*$filename = "mysql";
  51. if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
  52. $IP = $_SERVER['HTTP_X_FORWARDED_FOR'] ;
  53. } elseif(isset($_SERVER['HTTP_CLIENT_IP'])) {
  54. $IP = $_SERVER['HTTP_CLIENT_IP'] ;
  55. } else {
  56. $IP = $_SERVER['REMOTE_ADDR'] ;
  57. }
  58. $content = "|".$IP."|".session_id()."|".__FUNCTION__."|".$connect_db;
  59. logDBToFile($content, $filename);*/
  60. if (is_resource($connect_db)) {
  61. mysql_select_db($bdd_db,$connect_db);
  62. mysql_query("SET NAMES UTF8");
  63. return $connect_db;
  64. } else {
  65. reportError(mysql_error(),__FILE__, "function", __FUNCTION__, 'Connection Error');
  66. exit();
  67. }
  68. }
  69. function close($connect_db)
  70. {
  71. /*@mysql_close($connect_db);
  72. $filename = "mysql";
  73. if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
  74. $IP = $_SERVER['HTTP_X_FORWARDED_FOR'] ;
  75. } elseif(isset($_SERVER['HTTP_CLIENT_IP'])) {
  76. $IP = $_SERVER['HTTP_CLIENT_IP'] ;
  77. } else {
  78. $IP = $_SERVER['REMOTE_ADDR'] ;
  79. }
  80. $content = "|".$IP."|".session_id()."|".__FUNCTION__."|".$connect_db;
  81. logDBToFile($content, $filename);*/
  82. }
  83. ?>