Verzeichnisstruktur phpBB-3.0.0


Veröffentlicht
12.12.2007

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

style.php

Zuletzt modifiziert: 09.10.2024, 12:50 - Dateigröße: 7.55 KiB


001  <?php
002  /**
003  *
004  * @package phpBB3
005  * @version $Id$
006  * @copyright (c) 2005 phpBB Group
007  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
008  *
009  */
010   
011  /**
012  * @ignore
013  */
014  define('IN_PHPBB', true);
015  $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
016  $phpEx = substr(strrchr(__FILE__, '.'), 1);
017  require($phpbb_root_path . 'config.' . $phpEx);
018   
019  if (version_compare(PHP_VERSION, '6.0.0-dev', '<'))
020  {
021      set_magic_quotes_runtime(0);
022  }
023   
024  // Load Extensions
025  if (!empty($load_extensions))
026  {
027      $load_extensions = explode(',', $load_extensions);
028   
029      foreach ($load_extensions as $extension)
030      {
031          @dl(trim($extension));
032      }
033  }
034   
035   
036  $sid = (isset($_GET['sid']) && !is_array($_GET['sid'])) ? htmlspecialchars($_GET['sid']) : '';
037  $id = (isset($_GET['id'])) ? intval($_GET['id']) : 0;
038   
039  if (strspn($sid, 'abcdefABCDEF0123456789') !== strlen($sid))
040  {
041      $sid = '';
042  }
043   
044  // This is a simple script to grab and output the requested CSS data stored in the DB
045  // We include a session_id check to try and limit 3rd party linking ... unless they
046  // happen to have a current session it will output nothing. We will also cache the
047  // resulting CSS data for five minutes ... anything to reduce the load on the SQL
048  // server a little
049  if ($id)
050  {
051      if (empty($acm_type) || empty($dbms))
052      {
053          die('Hacking attempt');
054      }
055   
056      // Include files
057      require($phpbb_root_path . 'includes/acm/acm_' . $acm_type . '.' . $phpEx);
058      require($phpbb_root_path . 'includes/cache.' . $phpEx);
059      require($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx);
060      require($phpbb_root_path . 'includes/constants.' . $phpEx);
061   
062      $db = new $sql_db();
063      $cache = new cache();
064   
065      // Connect to DB
066      if (!@$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, false))
067      {
068          exit;
069      }
070      unset($dbpasswd);
071   
072      $config = $cache->obtain_config();
073      $user = false;
074   
075      if ($sid)
076      {
077          $sql = 'SELECT u.user_id, u.user_lang
078              FROM ' . SESSIONS_TABLE . ' s, ' . USERS_TABLE . " u
079              WHERE s.session_id = '" . $db->sql_escape($sid) . "'
080                  AND s.session_user_id = u.user_id";
081          $result = $db->sql_query($sql);
082          $user = $db->sql_fetchrow($result);
083          $db->sql_freeresult($result);
084      }
085   
086      $recompile = $config['load_tplcompile'];
087      if (!$user)
088      {
089          $id            = $config['default_style'];
090          $recompile    = false;
091          $user        = array('user_id' => ANONYMOUS);
092      }
093   
094      $sql = 'SELECT s.style_id, c.theme_data, c.theme_path, c.theme_name, c.theme_mtime, i.*, t.template_path
095          FROM ' . STYLES_TABLE . ' s, ' . STYLES_TEMPLATE_TABLE . ' t, ' . STYLES_THEME_TABLE . ' c, ' . STYLES_IMAGESET_TABLE . ' i
096          WHERE s.style_id = ' . $id . '
097              AND t.template_id = s.template_id
098              AND c.theme_id = s.theme_id
099              AND i.imageset_id = s.imageset_id';
100      $result = $db->sql_query($sql, 300);
101      $theme = $db->sql_fetchrow($result);
102      $db->sql_freeresult($result);
103   
104      if (!$theme)
105      {
106          exit;
107      }
108   
109      if ($user['user_id'] == ANONYMOUS)
110      {
111          $user['user_lang'] = $config['default_lang'];
112      }
113   
114      $user_image_lang = (file_exists($phpbb_root_path . 'styles/' . $theme['imageset_path'] . '/imageset/' . $user['user_lang'])) ? $user['user_lang'] : $config['default_lang'];
115   
116      $sql = 'SELECT *
117          FROM ' . STYLES_IMAGESET_DATA_TABLE . '
118          WHERE imageset_id = ' . $theme['imageset_id'] . "
119          AND image_lang IN ('" . $db->sql_escape($user_image_lang) . "', '')";
120      $result = $db->sql_query($sql, 3600);
121   
122      $img_array = array();
123      while ($row = $db->sql_fetchrow($result))
124      {
125          $img_array[$row['image_name']] = $row;
126      }
127      $db->sql_freeresult($result);
128   
129      // gzip_compression
130      if ($config['gzip_compress'])
131      {
132          // IE6 is not able to compress the style (do not ask us why!)
133          $browser = (!empty($_SERVER['HTTP_USER_AGENT'])) ? strtolower(htmlspecialchars((string) $_SERVER['HTTP_USER_AGENT'])) : '';
134   
135          if ($browser && strpos($browser, 'msie 6.0') === false && @extension_loaded('zlib') && !headers_sent())
136          {
137              ob_start('ob_gzhandler');
138          }
139      }
140   
141      // Expire time of seven days if not recached
142      $expire_time = 7*86400;
143      $recache = false;
144   
145      // Re-cache stylesheet data if necessary
146      if ($recompile || empty($theme['theme_data']))
147      {
148          $recache = (empty($theme['theme_data'])) ? true : false;
149          $update_time = time();
150   
151          // We test for stylesheet.css because it is faster and most likely the only file changed on common themes
152          if (!$recache && $theme['theme_mtime'] < @filemtime("{$phpbb_root_path}styles/" . $theme['theme_path'] . '/theme/stylesheet.css'))
153          {
154              $recache = true;
155              $update_time = @filemtime("{$phpbb_root_path}styles/" . $theme['theme_path'] . '/theme/stylesheet.css');
156          }
157          else if (!$recache)
158          {
159              $last_change = $theme['theme_mtime'];
160              $dir = @opendir("{$phpbb_root_path}styles/{$theme['theme_path']}/theme");
161   
162              if ($dir)
163              {
164                  while (($entry = readdir($dir)) !== false)
165                  {
166                      if (substr(strrchr($entry, '.'), 1) == 'css' && $last_change < @filemtime("{$phpbb_root_path}styles/{$theme['theme_path']}/theme/{$entry}"))
167                      {
168                          $recache = true;
169                          break;
170                      }
171                  }
172                  closedir($dir);
173              }
174          }
175      }
176   
177      if ($recache)
178      {
179          include_once($phpbb_root_path . 'includes/acp/acp_styles.' . $phpEx);
180   
181          $theme['theme_data'] = acp_styles::db_theme_data($theme);
182          $theme['theme_mtime'] = $update_time;
183   
184          // Save CSS contents
185          $sql_ary = array(
186              'theme_mtime'    => $theme['theme_mtime'],
187              'theme_data'    => $theme['theme_data']
188          );
189   
190          $sql = 'UPDATE ' . STYLES_THEME_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . "
191              WHERE theme_id = $id";
192          $db->sql_query($sql);
193   
194          $cache->destroy('sql', STYLES_THEME_TABLE);
195      }
196   
197      // Only set the expire time if the theme changed data is older than 30 minutes - to cope with changes from the ACP
198      if ($recache || $theme['theme_mtime'] > (time() - 1800))
199      {
200          header('Expires: 0');
201      }
202      else
203      {
204          header('Expires: ' . gmdate('D, d M Y H:i:s \G\M\T', time() + $expire_time));
205      }
206   
207      header('Content-type: text/css; charset=UTF-8');
208   
209      // Parse Theme Data
210      $replace = array(
211          '{T_THEME_PATH}'            => "{$phpbb_root_path}styles/" . $theme['theme_path'] . '/theme',
212          '{T_TEMPLATE_PATH}'            => "{$phpbb_root_path}styles/" . $theme['template_path'] . '/template',
213          '{T_IMAGESET_PATH}'            => "{$phpbb_root_path}styles/" . $theme['imageset_path'] . '/imageset',
214          '{T_IMAGESET_LANG_PATH}'    => "{$phpbb_root_path}styles/" . $theme['imageset_path'] . '/imageset/' . $user_image_lang,
215          '{T_STYLESHEET_NAME}'        => $theme['theme_name'],
216          '{S_USER_LANG}'                => $user['user_lang']
217      );
218   
219      $theme['theme_data'] = str_replace(array_keys($replace), array_values($replace), $theme['theme_data']);
220   
221      $matches = array();
222      preg_match_all('#\{IMG_([A-Za-z0-9_]*?)_(WIDTH|HEIGHT|SRC)\}#', $theme['theme_data'], $matches);
223   
224      $imgs = $find = $replace = array();
225      if (isset($matches[0]) && sizeof($matches[0]))
226      {
227          foreach ($matches[1] as $i => $img)
228          {
229              $img = strtolower($img);
230              $find[] = $matches[0][$i];
231   
232              if (!isset($img_array[$img]))
233              {
234                  $replace[] = '';
235                  continue;
236              }
237   
238              if (!isset($imgs[$img]))
239              {
240                  $img_data = &$img_array[$img];
241                  $imgsrc = ($img_data['image_lang'] ? $img_data['image_lang'] . '/' : '') . $img_data['image_filename'];
242                  $imgs[$img] = array(
243                      'src'        => $phpbb_root_path . 'styles/' . $theme['imageset_path'] . '/imageset/' . $imgsrc,
244                      'width'        => $img_data['image_width'],
245                      'height'    => $img_data['image_height'],
246                  );
247              }
248   
249              switch ($matches[2][$i])
250              {
251                  case 'SRC':
252                      $replace[] = $imgs[$img]['src'];
253                  break;
254                  
255                  case 'WIDTH':
256                      $replace[] = $imgs[$img]['width'];
257                  break;
258      
259                  case 'HEIGHT':
260                      $replace[] = $imgs[$img]['height'];
261                  break;
262   
263                  default:
264                      continue;
265              }
266          }
267   
268          if (sizeof($find))
269          {
270              $theme['theme_data'] = str_replace($find, $replace, $theme['theme_data']);
271          }
272      }
273   
274      echo $theme['theme_data'];
275   
276      if (!empty($cache))
277      {
278          $cache->unload();
279      }
280      $db->sql_close();
281  }
282   
283  exit;
284   
285  ?>