Actions / Affichages Commentaires Derniers commentaires Dossier vu à la loupe Rechercher Télécharger Télécharger Info Info S'authentifier Se connecter

Revenir à la racine Icone / Sources / init.php

1200 téléchargement(s)
  1. <?php
  2. /*
  3. This file is part of Hyla
  4. Copyright (c) 2004-2007 Charles Rincheval.
  5. All rights reserved
  6.  
  7. Hyla is free software; you can redistribute it and/or modify it
  8. under the terms of the GNU General Public License as published
  9. by the Free Software Foundation; either version 2 of the License,
  10. or (at your option) any later version.
  11.  
  12. Hyla is distributed in the hope that it will be useful, but
  13. WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. GNU General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with Hyla; if not, write to the Free Software
  19. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20.  */
  21.  
  22. if (!defined('PAGE_HOME'))
  23. header('location: ../index.php');
  24.  
  25. require 'src/inc/l10n.class.php';
  26. require 'src/db/mysql.class.php';
  27. require 'src/inc/users.class.php';
  28. require 'src/inc/file.class.php';
  29. require 'src/inc/obj.class.php';
  30. require 'src/inc/url.class.php';
  31. require 'src/lib/template.class.php';
  32. require 'src/inc/system.class.php';
  33. require 'src/inc/function.inc.php';
  34.  
  35. $starttime = system::chrono();
  36.  
  37. $msg_error = null;
  38.  
  39. define('DIR_CONF', 'conf/');
  40. define('CONFIG_FILE', DIR_CONF.'config.inc.php');
  41.  
  42. /* Modifiez ici l'affichage des erreurs
  43.  */
  44. error_reporting(E_ALL); // E_ERROR | E_USER_ERROR
  45.  
  46.  
  47. /* Atrapper les erreurs
  48.  */
  49. //register_shutdown_function(array('system', 'timeOut'));
  50.  
  51. ini_set('magic_quotes_runtime', 0);
  52. ini_set('magic_quotes_sybase', 0);
  53.  
  54.  
  55. // En attendant de trouver mieux...
  56. array_walk_recursive($_COOKIE, 'addslashes');
  57. array_walk_recursive($_POST, 'addslashes');
  58. array_walk_recursive($_GET, 'addslashes');
  59. }
  60.  
  61.  
  62. /* Vérification de sécurité
  63.  */
  64. if (basename($_SERVER['PHP_SELF']) != 'install.php') {
  65. if (!file_exists('conf/lock')) {
  66. if (file_exists('install.php'))
  67. header('location: install.php');
  68. else
  69. system::end('Install Hyla before : <a href="install.php">install.php</a>');
  70. }
  71.  
  72. if (!file_exists(CONFIG_FILE)) {
  73. system::end('The configuration file doesn\'t exist !');
  74. } else
  75. require CONFIG_FILE;
  76. }
  77.  
  78. define('DIR_ROOT', file::dirName($_SERVER['SCRIPT_FILENAME']).'/');
  79.  
  80. require 'src/inc/define.php';
  81. require 'src/lib/class.ini.file.php';
  82. require 'src/lib/XPath.class.php';
  83.  
  84. $conf = array();
  85. load_config();
  86.  
  87.  
  88. /* Rss ou non ?
  89.  */
  90. if (basename($_SERVER['PHP_SELF']) == 'rss.php') {
  91. $current_tpl = 'rss';
  92. } else {
  93.  
  94. // Modification dans /src/inc/plugin_auth.class.php
  95. // session_name('Hyla');
  96.  
  97. if (isset($_REQUEST['modifytpl']) && $_REQUEST['modifytpl'] == 'true') {
  98. switch ($_REQUEST['tplname']) {
  99. case 'default':
  100. $tpl = 'default';
  101. break;
  102. case 'noengreen':
  103. $tpl = 'noengreen';
  104. break;
  105. case 'crystal':
  106. default:
  107. $tpl = 'crystal';
  108. break;
  109. }
  110. $_SESSION['sess_tplname'] = $tpl;
  111. }
  112.  
  113. if (isset($_SESSION['sess_tplname']) && $_SESSION['sess_tplname']) {
  114. $conf['name_template'] = $_SESSION['sess_tplname'];
  115. } else {
  116. $conf['name_template'] = 'crystal';
  117. }
  118.  
  119. $_SESSION['sess_tplname'] = $conf['name_template'];
  120. $current_tpl = (file_exists(DIR_TPL.$conf['name_template']) ? $conf['name_template'] : 'default');
  121. }
  122. define('DIR_TEMPLATE', DIR_TPL.$current_tpl);
  123.  
  124.  
  125. /* ROOT_URL est spécifié dans config.inc.php ?
  126.  */
  127. if (!defined('ROOT_URL') || ROOT_URL == null) {
  128. $dirname = file::dirName($_SERVER['PHP_SELF']);
  129. $dirname = ($dirname == '/') ? null : $dirname;
  130. define('REAL_ROOT_URL', $dirname);
  131. unset($dirname);
  132. }
  133.  
  134. $styles = array();
  135.  
  136. // Entête envoyé en premier
  137. $xfile = DIR_TEMPLATE.'/info.xml';
  138. if (file_exists($xfile)) {
  139. $xml =& new XPath($xfile);
  140. $res = $xml->match('/template');
  141. if ($res) {
  142. header($xml->getData('/template/header'));
  143.  
  144. // Récupération du dossier contenant les images du modèle
  145. $dir_img = $xml->getData('/template/img-src');
  146. $dir_img = ($dir_img) ? str_replace('%s', $current_tpl, $dir_img) : './tpl/default/img';
  147. define('DIR_IMAGE', $dir_img);
  148.  
  149. // Inclusion du fichier de fonctions du modèle
  150. $file_func = $xml->getData('/template/php-function');
  151. $file_func = ($file_func) ? str_replace('%s', $current_tpl, $file_func) : './tpl/default/function.php';
  152. require $file_func;
  153.  
  154. // Récupération des différents style du modèle
  155. $res = $xml->match('/template/stylesheets/stylesheet');
  156. if ($res) {
  157. foreach ($res as $occ) {
  158. add_stylesheet(DIR_TEMPLATE.'/'.$xml->getData($occ.'/href'), $xml->getData($occ.'/title'), $xml->getData($occ.'/type'), $xml->getData($occ.'/media'));
  159. }
  160. }
  161. }
  162. unset($xml, $res, $dir_img);
  163. }
  164.  
  165.  
  166. /* Fichiers de langue
  167.  */
  168. $l10n = new l10n($conf['lng']);
  169. $l10n->sendHeader();
  170. $l10n->setFile('general.php');
  171. $l10n->setFile('messages.php');
  172. $l10n->setFile('icon.php');
  173.  
  174.  
  175. $tab_icon = array();
  176. load_icon_info();
  177.  
  178. ?>
  179.