Advertisement
Guest User

init.php

a guest
Apr 13th, 2013
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.53 KB | None | 0 0
  1. <?php
  2. ##############################################################
  3. ##  RECUPERATION DU MICROTIME A L'INITIALISATION            ##
  4. ##############################################################
  5. $page_infos['microtime_start'] = microtime(true);
  6.  
  7. ##############################################################
  8. ##  INI_SET                                                 ##
  9. ##############################################################
  10. ini_set('safe_mode', 'On');
  11.  
  12. ##############################################################
  13. ##  CHARGEMENT DES FICHIERS DE CONF                         ##
  14. ##############################################################
  15. require_once(ROOT_PATH . 'core/connection.php');
  16. require_once(ROOT_PATH . 'core/config.php');
  17.  
  18. ##############################################################
  19. ##  RECUPERATION DE LA PAGE ACTUELLE                        ##
  20. ##############################################################
  21. $current_page = basename($_SERVER['SCRIPT_FILENAME']);
  22.  
  23. ##############################################################
  24. ##  CHARGEMENT DES TABLEAUX DE DONNEES                      ##
  25. ##############################################################
  26. require_once(ROOT_PATH . 'core/arrays/array.scripts.php');
  27.  
  28. ##############################################################
  29. ##  INITIALISATION DES TABLEAUX DE SCRIPTS/STYLES           ##
  30. ##############################################################
  31. $scripts_to_load = array();
  32. $styles_to_load = array();
  33.  
  34. ##############################################################
  35. ##  AUTOLOAD                                                ##
  36. ##############################################################
  37. function __autoload($class_name)
  38. {
  39.     require_once (ROOT_PATH . 'core/classes/class.' . strtolower($class_name) . '.php');
  40. }
  41.  
  42. ##############################################################
  43. ##  CHARGEMENT DES CLASSES                                  ##
  44. ##############################################################
  45. require_once(ROOT_PATH . 'core/classes/class.sql.php');
  46. require_once(ROOT_PATH . 'core/classes/class.session.php');
  47. require_once(ROOT_PATH . 'core/classes/class.object_model.php');
  48. require_once(ROOT_PATH . 'core/classes/class.config.php');
  49.  
  50. require_once(ROOT_PATH . 'core/classes/class.handler_notices.php');
  51. require_once(ROOT_PATH . 'core/classes/class.notice.php');
  52.  
  53. ##############################################################
  54. ## DECLARATION DES CLASSES                                  ##
  55. ##############################################################
  56. $sql                                = new Sql();
  57. $site                               = new Object_Model();
  58. $session                            = new Session();
  59. $handler_notices                    = new Handler_Notices();
  60.  
  61. ##############################################################
  62. ##  CONNEXION SQL                                           ##
  63. ##############################################################
  64. $connection = $sql->connection(BDD_HOST, BDD_USER, BDD_PASS);
  65. $sql->select_db(BDD_NAME);
  66.  
  67. ##############################################################
  68. ##  DEFINITION DE LA CONFIG SQL                             ##
  69. ##############################################################
  70. mysql_query( 'SET NAMES "utf8"' );
  71. // mysql_query( 'SET lc_time_names = "fr_FR"' );
  72.  
  73. ##############################################################
  74. ##  DEFINITION DE LA VARIABLE LOCALE                        ##
  75. ##############################################################
  76. // setlocale(LC_TIME, 'fr_FR.utf8', 'fra');
  77.  
  78. ##############################################################
  79. ## RECUPERATION DE LA CONFIG                                ##
  80. ##############################################################
  81. $config = new Config(1);
  82.  
  83. ##############################################################
  84. ## INITIALISATION DE LA LANGUE                              ##
  85. ##############################################################
  86. if (!isset($_SESSION['lang']))
  87. {
  88.     $_SESSION['lang'] = $config->site_default_lang;
  89. }
  90. DEFINE('LANG', $_SESSION['lang']);
  91.  
  92. ##############################################################
  93. ## GESTION DE LA MAINTENANCE                                ##
  94. ##############################################################
  95. if ($config->site_maintenance == 1 && $current_page != 'maintenance.php')
  96. {
  97.     header('Location: maintenance.php');
  98.     exit();
  99. }
  100. elseif ($config->site_maintenance == 0 && $current_page == 'maintenance.php')
  101. {
  102.     header('Location: index.php');
  103.     exit();
  104. }
  105.  
  106. ##############################################################
  107. ## OUVERTURE DE SESSION                                     ##
  108. ##############################################################
  109. if ((isset($_POST['action']) && $_POST['action'] == 'login') || (isset($_POST['subaction']) && $_POST['subaction'] == 'login'))
  110. {
  111.     $session->attempt_login($_POST['mail'], md5($_POST['password']));
  112.     if ($session->is_authed())
  113.     {
  114.         header('Location: ' . $config->site_url);
  115.         exit();
  116.     }
  117.     else
  118.     {
  119.        
  120.         header('Location: login.php');
  121.         exit();
  122.     }
  123. }
  124.  
  125. ##############################################################
  126. ## FERMETURE DE SESSION                                     ##
  127. ##############################################################
  128. if (isset($_GET['action']) && $_GET['action'] == 'logout')
  129. {
  130.     $session->destroy_session();
  131.     header('Location: ' . $config->site_url);
  132.     exit();
  133. }
  134.  
  135. ##############################################################
  136. ## TEST DE SESSION                                          ##
  137. ##############################################################
  138. // if( $session->is_authed() ) {
  139.     // $session_user = new User( $_SESSION['USER']['id'] );
  140. // }
  141.  
  142. ##############################################################
  143. ## DEBUG                                                    ##
  144. ##############################################################
  145. // $site->print_r_pre($config);
  146. // $site->print_r_pre($_POST);
  147. // $site->print_r_pre($_SESSION['USER']);
  148. // $site->print_r_pre($session_user);
  149. // $site->print_r_pre($_SESSION['temp_user_id']);
  150. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement