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

adjust_sizes.php

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


001  <?php
002  /**
003  * Only adjust the [size] bbcode tag from pc to percent.
004  *
005  * You should make a backup from your users, posts and privmsgs table in case something goes wrong
006  * Forum descriptions and rules need to be re-submitted manually if they use the [size] tag.
007  *
008  * Since we limit the match to the sizes from 0 to 29 no newly applied sizes should be affected...
009  */
010  die("Please read the first lines of this script for instructions on how to enable it");
011   
012  set_time_limit(0);
013  @ini_set('memory_limit', '128M');
014   
015  define('IN_PHPBB', true);
016  $phpbb_root_path = './../';
017  $phpEx = substr(strrchr(__FILE__, '.'), 1);
018  include($phpbb_root_path . 'common.'.$phpEx);
019   
020  // Start session management
021  $user->session_begin();
022  $auth->acl($user->data);
023  $user->setup();
024   
025  $echos = 0;
026   
027  function replace_size($matches)
028  {
029      return '[size=' . ceil(100.0 * (((double) $matches[1])/12.0)) . ':' . $matches[2] . ']';
030  }
031   
032  // Adjust user signatures
033  $sql = 'SELECT user_id, user_sig, user_sig_bbcode_uid
034      FROM ' . USERS_TABLE;
035  $result = $db->sql_query($sql);
036   
037  while ($row = $db->sql_fetchrow($result))
038  {
039      $bbcode_uid = $row['user_sig_bbcode_uid'];
040   
041      // Only if a bbcode uid is present, the signature present and a size tag used...
042      if ($bbcode_uid && $row['user_sig'] && strpos($row['user_sig'], '[size=') !== false)
043      {
044          $row['user_sig'] = preg_replace_callback('/\[size=(\d*):(' . $bbcode_uid . ')\]/', 'replace_size', $row['user_sig']);
045   
046          $sql = 'UPDATE ' . USERS_TABLE . " SET user_sig = '" . $db->sql_escape($row['user_sig']) . "'
047              WHERE user_id = " . $row['user_id'];
048          $db->sql_query($sql);
049   
050          if ($echos > 200)
051          {
052              echo '<br />' . "\n";
053              $echos = 0;
054          }
055   
056          echo '.';
057          $echos++;
058   
059          flush();
060      }
061  }
062  $db->sql_freeresult($result);
063   
064   
065  // Now adjust posts
066  $sql = 'SELECT post_id, post_text, bbcode_uid, enable_bbcode
067      FROM ' . POSTS_TABLE;
068  $result = $db->sql_query($sql);
069   
070  while ($row = $db->sql_fetchrow($result))
071  {
072      $bbcode_uid = $row['bbcode_uid'];
073   
074      // Only if a bbcode uid is present, bbcode enabled and a size tag used...
075      if ($row['enable_bbcode'] && $bbcode_uid && strpos($row['post_text'], '[size=') !== false)
076      {
077          $row['post_text'] = preg_replace_callback('/\[size=(\d*):' . $bbcode_uid . '\]/', 'replace_size', $row['post_text']);
078   
079          $sql = 'UPDATE ' . POSTS_TABLE . " SET post_text = '" . $db->sql_escape($row['post_text']) . "'
080              WHERE post_id = " . $row['post_id'];
081          $db->sql_query($sql);
082   
083          if ($echos > 200)
084          {
085              echo '<br />' . "\n";
086              $echos = 0;
087          }
088   
089          echo '.';
090          $echos++;
091   
092          flush();
093      }
094  }
095  $db->sql_freeresult($result);
096   
097  // Now to the private messages
098  $sql = 'SELECT msg_id, message_text, bbcode_uid, enable_bbcode
099      FROM ' . PRIVMSGS_TABLE;
100  $result = $db->sql_query($sql);
101   
102  while ($row = $db->sql_fetchrow($result))
103  {
104      $bbcode_uid = $row['bbcode_uid'];
105   
106      // Only if a bbcode uid is present, bbcode enabled and a size tag used...
107      if ($row['enable_bbcode'] && $bbcode_uid && strpos($row['message_text'], '[size=') !== false)
108      {
109          $row['message_text'] = preg_replace_callback('/\[size=(\d*):' . $bbcode_uid . '\]/', 'replace_size', $row['message_text']);
110   
111          $sql = 'UPDATE ' . PRIVMSGS_TABLE . " SET message_text = '" . $db->sql_escape($row['message_text']) . "'
112              WHERE msg_id = " . $row['msg_id'];
113          $db->sql_query($sql);
114   
115          if ($echos > 200)
116          {
117              echo '<br />' . "\n";
118              $echos = 0;
119          }
120   
121          echo '.';
122          $echos++;
123   
124          flush();
125      }
126  }
127  $db->sql_freeresult($result);
128   
129  // Done
130  $db->sql_close();
131   
132  ?>