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

cache.php

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


 001  <?php
 002  /**
 003  *
 004  * @package acm
 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  if (!defined('IN_PHPBB'))
 015  {
 016      exit;
 017  }
 018   
 019  /**
 020  * Class for grabbing/handling cached entries, extends acm_file or acm_db depending on the setup
 021  * @package acm
 022  */
 023  class cache extends acm
 024  {
 025      /**
 026      * Get config values
 027      */
 028      function obtain_config()
 029      {
 030          global $db;
 031   
 032          if (($config = $this->get('config')) !== false)
 033          {
 034              $sql = 'SELECT config_name, config_value
 035                  FROM ' . CONFIG_TABLE . '
 036                  WHERE is_dynamic = 1';
 037              $result = $db->sql_query($sql);
 038   
 039              while ($row = $db->sql_fetchrow($result))
 040              {
 041                  $config[$row['config_name']] = $row['config_value'];
 042              }
 043              $db->sql_freeresult($result);
 044          }
 045          else
 046          {
 047              $config = $cached_config = array();
 048   
 049              $sql = 'SELECT config_name, config_value, is_dynamic
 050                  FROM ' . CONFIG_TABLE;
 051              $result = $db->sql_query($sql);
 052   
 053              while ($row = $db->sql_fetchrow($result))
 054              {
 055                  if (!$row['is_dynamic'])
 056                  {
 057                      $cached_config[$row['config_name']] = $row['config_value'];
 058                  }
 059   
 060                  $config[$row['config_name']] = $row['config_value'];
 061              }
 062              $db->sql_freeresult($result);
 063   
 064              $this->put('config', $cached_config);
 065          }
 066      
 067          return $config;
 068      }
 069   
 070      /**
 071      * Obtain list of naughty words and build preg style replacement arrays for use by the
 072      * calling script
 073      */
 074      function obtain_word_list()
 075      {
 076          global $db;
 077   
 078          if (($censors = $this->get('_word_censors')) === false)
 079          {
 080              $sql = 'SELECT word, replacement
 081                  FROM ' . WORDS_TABLE;
 082              $result = $db->sql_query($sql);
 083   
 084              $censors = array();
 085              while ($row = $db->sql_fetchrow($result))
 086              {
 087                  $censors['match'][] = '#(?<!\w)(' . str_replace('\*', '\w*?', preg_quote($row['word'], '#')) . ')(?!\w)#i';
 088                  $censors['replace'][] = $row['replacement'];
 089              }
 090              $db->sql_freeresult($result);
 091   
 092              $this->put('_word_censors', $censors);
 093          }
 094   
 095          return $censors;
 096      }
 097   
 098      /**
 099      * Obtain currently listed icons
 100      */
 101      function obtain_icons()
 102      {
 103          if (($icons = $this->get('_icons')) === false)
 104          {
 105              global $db;
 106      
 107              // Topic icons
 108              $sql = 'SELECT *
 109                  FROM ' . ICONS_TABLE . '
 110                  ORDER BY icons_order';
 111              $result = $db->sql_query($sql);
 112   
 113              $icons = array();
 114              while ($row = $db->sql_fetchrow($result))
 115              {
 116                  $icons[$row['icons_id']]['img'] = $row['icons_url'];
 117                  $icons[$row['icons_id']]['width'] = (int) $row['icons_width'];
 118                  $icons[$row['icons_id']]['height'] = (int) $row['icons_height'];
 119                  $icons[$row['icons_id']]['display'] = (bool) $row['display_on_posting'];
 120              }
 121              $db->sql_freeresult($result);
 122   
 123              $this->put('_icons', $icons);
 124          }
 125   
 126          return $icons;
 127      }
 128   
 129      /**
 130      * Obtain ranks
 131      */
 132      function obtain_ranks()
 133      {
 134          if (($ranks = $this->get('_ranks')) === false)
 135          {
 136              global $db;
 137      
 138              $sql = 'SELECT *
 139                  FROM ' . RANKS_TABLE . '
 140                  ORDER BY rank_min DESC';
 141              $result = $db->sql_query($sql);
 142   
 143              $ranks = array();
 144              while ($row = $db->sql_fetchrow($result))
 145              {
 146                  if ($row['rank_special'])
 147                  {
 148                      $ranks['special'][$row['rank_id']] = array(
 149                          'rank_title'    =>    $row['rank_title'],
 150                          'rank_image'    =>    $row['rank_image']
 151                      );
 152                  }
 153                  else
 154                  {
 155                      $ranks['normal'][] = array(
 156                          'rank_title'    =>    $row['rank_title'],
 157                          'rank_min'        =>    $row['rank_min'],
 158                          'rank_image'    =>    $row['rank_image']
 159                      );
 160                  }
 161              }
 162              $db->sql_freeresult($result);
 163   
 164              $this->put('_ranks', $ranks);
 165          }
 166   
 167          return $ranks;
 168      }
 169   
 170      /**
 171      * Obtain allowed extensions
 172      *
 173      * @param mixed $forum_id If false then check for private messaging, if int then check for forum id. If true, then only return extension informations.
 174      *
 175      * @return array allowed extensions array.
 176      */
 177      function obtain_attach_extensions($forum_id)
 178      {
 179          if (($extensions = $this->get('_extensions')) === false)
 180          {
 181              global $db;
 182   
 183              $extensions = array(
 184                  '_allowed_post'    => array(),
 185                  '_allowed_pm'    => array(),
 186              );
 187   
 188              // The rule is to only allow those extensions defined. ;)
 189              $sql = 'SELECT e.extension, g.*
 190                  FROM ' . EXTENSIONS_TABLE . ' e, ' . EXTENSION_GROUPS_TABLE . ' g
 191                  WHERE e.group_id = g.group_id
 192                      AND (g.allow_group = 1 OR g.allow_in_pm = 1)';
 193              $result = $db->sql_query($sql);
 194   
 195              while ($row = $db->sql_fetchrow($result))
 196              {
 197                  $extension = strtolower(trim($row['extension']));
 198   
 199                  $extensions[$extension] = array(
 200                      'display_cat'    => (int) $row['cat_id'],
 201                      'download_mode'    => (int) $row['download_mode'],
 202                      'upload_icon'    => trim($row['upload_icon']),
 203                      'max_filesize'    => (int) $row['max_filesize'],
 204                      'allow_group'    => $row['allow_group'],
 205                      'allow_in_pm'    => $row['allow_in_pm'],
 206                  );
 207   
 208                  $allowed_forums = ($row['allowed_forums']) ? unserialize(trim($row['allowed_forums'])) : array();
 209   
 210                  // Store allowed extensions forum wise
 211                  if ($row['allow_group'])
 212                  {
 213                      $extensions['_allowed_post'][$extension] = (!sizeof($allowed_forums)) ? 0 : $allowed_forums;
 214                  }
 215   
 216                  if ($row['allow_in_pm'])
 217                  {
 218                      $extensions['_allowed_pm'][$extension] = 0;
 219                  }
 220              }
 221              $db->sql_freeresult($result);
 222   
 223              $this->put('_extensions', $extensions);
 224          }
 225   
 226          // Forum post
 227          if ($forum_id === false)
 228          {
 229              // We are checking for private messages, therefore we only need to get the pm extensions...
 230              $return = array('_allowed_' => array());
 231   
 232              foreach ($extensions['_allowed_pm'] as $extension => $check)
 233              {
 234                  $return['_allowed_'][$extension] = 0;
 235                  $return[$extension] = $extensions[$extension];
 236              }
 237   
 238              $extensions = $return;
 239          }
 240          else if ($forum_id === true)
 241          {
 242              return $extensions;
 243          }
 244          else
 245          {
 246              $forum_id = (int) $forum_id;
 247              $return = array('_allowed_' => array());
 248   
 249              foreach ($extensions['_allowed_post'] as $extension => $check)
 250              {
 251                  // Check for allowed forums
 252                  if (is_array($check))
 253                  {
 254                      $allowed = (!in_array($forum_id, $check)) ? false : true;
 255                  }
 256                  else
 257                  {
 258                      $allowed = true;
 259                  }
 260   
 261                  if ($allowed)
 262                  {
 263                      $return['_allowed_'][$extension] = 0;
 264                      $return[$extension] = $extensions[$extension];
 265                  }
 266              }
 267   
 268              $extensions = $return;
 269          }
 270   
 271          if (!isset($extensions['_allowed_']))
 272          {
 273              $extensions['_allowed_'] = array();
 274          }
 275   
 276          return $extensions;
 277      }
 278   
 279      /**
 280      * Obtain active bots
 281      */
 282      function obtain_bots()
 283      {
 284          if (($bots = $this->get('_bots')) === false)
 285          {
 286              global $db;
 287      
 288              switch ($db->sql_layer)
 289              {
 290                  case 'mssql':
 291                  case 'mssql_odbc':
 292                      $sql = 'SELECT user_id, bot_agent, bot_ip
 293                          FROM ' . BOTS_TABLE . '
 294                          WHERE bot_active = 1
 295                      ORDER BY LEN(bot_agent) DESC';
 296                  break;
 297   
 298                  case 'firebird':
 299                      $sql = 'SELECT user_id, bot_agent, bot_ip
 300                          FROM ' . BOTS_TABLE . '
 301                          WHERE bot_active = 1
 302                      ORDER BY CHAR_LENGTH(bot_agent) DESC';
 303                  break;
 304   
 305                  // LENGTH supported by MySQL, IBM DB2 and Oracle for sure...
 306                  default:
 307                      $sql = 'SELECT user_id, bot_agent, bot_ip
 308                          FROM ' . BOTS_TABLE . '
 309                          WHERE bot_active = 1
 310                      ORDER BY LENGTH(bot_agent) DESC';
 311                  break;
 312              }
 313              $result = $db->sql_query($sql);
 314   
 315              $bots = array();
 316              while ($row = $db->sql_fetchrow($result))
 317              {
 318                  $bots[] = $row;
 319              }
 320              $db->sql_freeresult($result);
 321   
 322              $this->put('_bots', $bots);
 323          }
 324      
 325          return $bots;
 326      }
 327   
 328      /**
 329      * Obtain cfg file data
 330      */
 331      function obtain_cfg_items($theme)
 332      {
 333          global $config, $phpbb_root_path;
 334   
 335          $parsed_items = array(
 336              'theme'        => array(),
 337              'template'    => array(),
 338              'imageset'    => array()
 339          );
 340   
 341          foreach ($parsed_items as $key => $parsed_array)
 342          {
 343              $parsed_array = $this->get('_cfg_' . $key . '_' . $theme[$key . '_path']);
 344   
 345              if ($parsed_array === false)
 346              {
 347                  $parsed_array = array();
 348              }
 349   
 350              $reparse = false;
 351              $filename = $phpbb_root_path . 'styles/' . $theme[$key . '_path'] . '/' . $key . '/' . $key . '.cfg';
 352   
 353              if (!file_exists($filename))
 354              {
 355                  continue;
 356              }
 357   
 358              if (!isset($parsed_array['filetime']) || (($config['load_tplcompile'] && @filemtime($filename) > $parsed_array['filetime'])))
 359              {
 360                  $reparse = true;
 361              }
 362   
 363              // Re-parse cfg file
 364              if ($reparse)
 365              {
 366                  $parsed_array = parse_cfg_file($filename);
 367                  $parsed_array['filetime'] = @filemtime($filename);
 368   
 369                  $this->put('_cfg_' . $key . '_' . $theme[$key . '_path'], $parsed_array);
 370              }
 371              $parsed_items[$key] = $parsed_array;
 372          }
 373   
 374          return $parsed_items;
 375      }
 376   
 377      /**
 378      * Obtain disallowed usernames
 379      */
 380      function obtain_disallowed_usernames()
 381      {
 382          if (($usernames = $this->get('_disallowed_usernames')) === false)
 383          {
 384              global $db;
 385   
 386              $sql = 'SELECT disallow_username
 387                  FROM ' . DISALLOW_TABLE;
 388              $result = $db->sql_query($sql);
 389   
 390              $usernames = array();
 391              while ($row = $db->sql_fetchrow($result))
 392              {
 393                  $usernames[] = str_replace('%', '.*?', preg_quote(utf8_clean_string($row['disallow_username']), '#'));
 394              }
 395              $db->sql_freeresult($result);
 396   
 397              $this->put('_disallowed_usernames', $usernames);
 398          }
 399   
 400          return $usernames;
 401      }
 402   
 403      /**
 404      * Obtain hooks...
 405      */
 406      function obtain_hooks()
 407      {
 408          global $phpbb_root_path, $phpEx;
 409   
 410          if (($hook_files = $this->get('_hooks')) === false)
 411          {
 412              $hook_files = array();
 413   
 414              // Now search for hooks...
 415              $dh = @opendir($phpbb_root_path . 'includes/hooks/');
 416   
 417              if ($dh)
 418              {
 419                  while (($file = readdir($dh)) !== false)
 420                  {
 421                      if (strpos($file, 'hook_') === 0 && substr($file, -(strlen($phpEx) + 1)) === '.' . $phpEx)
 422                      {
 423                          $hook_files[] = substr($file, 0, -(strlen($phpEx) + 1));
 424                      }
 425                  }
 426                  closedir($dh);
 427              }
 428   
 429              $this->put('_hooks', $hook_files);
 430          }
 431   
 432          return $hook_files;
 433      }
 434  }
 435   
 436  ?>