Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: Kto znajdzie mi tu błąd?
Forum PHP.pl > Forum > PHP
Nakhi
  1. <?php
  2.  
  3. /*
  4.  
  5. File name : includes/common.php
  6. Program : phpore
  7. Author : Jérémy FAIVRE (docteur.night)
  8. Email : docteurnight@hotmail.com
  9. Last modification : //
  10.  
  11. This program is free software; you can redistribute it and/or modify
  12. it under the terms of the GNU General Public License as published by
  13. the Free Software Foundation; either version 2 of the License, or
  14. (at your option) any later version.
  15.  
  16. */
  17.  
  18. if ( !defined('IN_PHPORE') )
  19. {
  20. }
  21.  
  22. //
  23. // constantes
  24. //
  25. define('CLASSES_TABLE', $config->table_prefix . 'classes');
  26. define('CHATBOX_TABLE', $config->table_prefix . 'chatbox');
  27. define('CONFIG_TABLE', $config->table_prefix . 'config');
  28. define('EVENTS_TABLE', $config->table_prefix . 'events');
  29. define('MAPS_TABLE', $config->table_prefix . 'maps');
  30. define('TILESETS_TABLE', $config->table_prefix . 'tilesets');
  31. define('USERS_TABLE', $config->table_prefix . 'users');
  32. define('VARS_TABLE', $config->table_prefix . 'vars');
  33.  
  34. //
  35. // fonctions
  36. //
  37.  
  38. // met en cache une variable
  39. function create_cache($var_name)
  40. {
  41. global $$var_name, $config;
  42.  
  43. $file = '<?php' . "\n\n" . 'if ( !defined(\'IN_PHPORE\') )' . "\n" . '{' . "\n\t" . 'exit;' . "\n" . '}' . "\n\n" . '$' . $var_name . ' = unserialize(\'' . quotes(serialize($$var_name)) . '\');' . "\n\n" . '?>';
  44.  
  45. $handle = fopen($config->path . $config->cache_dir . 'data_' . md5($var_name) . '.' . $config->phpex, 'w+');
  46. $result = fwrite($handle, $file);
  47. fclose($handle);
  48.  
  49. return $result;
  50. }
  51.  
  52. // récupčre une variable mise en cache
  53. function get_cache($var_name)
  54. {
  55. global $$var_name, $config;
  56.  
  57. if ( is_file($config->path . $config->cache_dir . 'data_' . $var_name . '.' . $config->phpex) )
  58. {
  59. include($config->path . $config->cache_dir . 'data_' . $var_name . '.' . $config->phpex);
  60. return true;
  61. }
  62. else
  63. {
  64. return false;
  65. }
  66. }
  67.  
  68. // la fonction inverse de htmlspecialchars()
  69. function htmlspecialchars_decode($text)
  70. {
  71. return strtr($text, array_flip(get_html_translation_table(HTML_SPECIALCHARS)));
  72. }
  73.  
  74. // remplace "'" par "\'" et "\" par "\\" pour utiliser des chaines sous la forme 'voici ma chaine : \'ma chaine\''
  75. function quotes($text)
  76. {
  77. return str_replace(array('\\', '\''), array('\\\\', '\\\''), $text);
  78. }
  79.  
  80. // retourne du code javascript lors d'un rafraichissement
  81. function js_eval($content, $id, $type = 0)
  82. {
  83. global $config, $user;
  84.  
  85. $user->update_db();
  86. $config->update_db();
  87.  
  88. $buffer = ob_get_contents();
  89.  
  90. if ( !empty($buffer) ) // erreur dans le script
  91. {
  92. $buffer = str_replace(array("\n", "\r"), '', $buffer);
  93. $content = 'document.write(\'' . quotes($buffer) . '\');' . $content;
  94. }
  95.  
  96. header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
  97. header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
  98. header('Cache-Control: no-cache, must-revalidate');
  99. header('Pragma: no-cache');
  100.  
  101. $refresh_forcing = ( !empty($_GET['refresh_forcing']) ) ? true : false;
  102.  
  103. if ( $type == 1 )
  104. {
  105. // rafraichissement par fenętre dans panneau d'admin
  106. die('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Style-Type" content="text/css" /><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /><title></title></head><body><script type="text/javascript">window.opener.parent.main.content_to_refresh_' . $id . ' = \'' . quotes($content) . '\';window.close();</script></body></html>');
  107. }
  108. elseif ( $type == 2 )
  109. {
  110. die('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Style-Type" content="text/css" /><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /><title></title></head><body><script type="text/javascript">' . $content . '</script></body></html>');
  111. }
  112. else
  113. {
  114. if ( $config->refresh_method == 0 || $refresh_forcing )
  115. {
  116. // rafraichissement par iframe
  117. die('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Style-Type" content="text/css" /><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /><title></title></head><body><script type="text/javascript">parent.content_to_refresh_' . $id . ' = \'' . quotes($content) . '\';</script></body></html>');
  118. }
  119. else
  120. {
  121. // rafraichissement par XMLHttpRequest
  122. die(utf8_encode($content));
  123. }
  124. }
  125. }
  126.  
  127. // création rapide d'une page pour afficher un message de notification ou d'erreur
  128. function message_die($title, $content)
  129. {
  130. global $template, $user, $config;
  131.  
  132. if ( isset($_GET['mod']) && substr($_GET['mod'], 0, 6) == 'admin.' )
  133. {
  134. $template->set_filenames(array(
  135. 'header' => 'admin_header.tpl',
  136. 'footer' => 'admin_footer.tpl',
  137. 'body' => 'die.tpl'
  138. ));
  139. }
  140. else
  141. {
  142. $template->set_filenames(array(
  143. 'header' => 'page_header.tpl',
  144. 'footer' => 'page_footer.tpl',
  145. 'body' => 'die.tpl'
  146. ));
  147. }
  148.  
  149. $template->assign_vars(array(
  150. 'PAGE_NAME' => $title,
  151. 'DIE_TITLE' => $title,
  152. 'DIE_CONTENT' => $content
  153. ));
  154.  
  155. $template->pparse('header');
  156. $template->pparse('body');
  157. $template->pparse('footer');
  158.  
  159. $user->update_db();
  160. $config->update_db();
  161.  
  162. }
nospor
Raczysz sobie żartować?

1) Tytuł
2) Opis problemu
3) Całokształt

4 - zamykam
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.