Verzeichnisstruktur phpBB-2.0.0


Veröffentlicht
03.04.2002

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

bbcode_conversion.php

Zuletzt modifiziert: 09.10.2024, 12:51 - Dateigröße: 7.09 KiB


001  <?php
002  /***************************************************************************  
003   *                           bbcode_conversion.php  
004   *                            -------------------                         
005   *   begin                : Tuesday, March 20, 2001 
006   *   copyright            : (C) 2001 The phpBB Group        
007   *   email                : support@phpbb.com                           
008   *                                                          
009   *   $Id:
010   *                                                            
011   * 
012   ***************************************************************************/ 
013   
014   
015  /***************************************************************************  
016   *                                                     
017   *   This program is free software; you can redistribute it and/or modify    
018   *   it under the terms of the GNU General Public License as published by   
019   *   the Free Software Foundation; either version 2 of the License, or  
020   *   (at your option) any later version.                      
021   *                                                          
022   * 
023   ***************************************************************************/ 
024   
025  //
026  // Security message:
027  //
028  // This script is potentially dangerous.
029  // Remove or comment the next line (die(".... ) to enable this script.
030  // Do NOT FORGET to either remove this script or disable it after you have used it.
031  //
032  die("Please read the first lines of this script for instructions on how to enable it");
033   
034  //
035  // Do not change anything below this line.
036  //
037   
038  include('../extension.inc');
039  include('../config.'.$phpEx);
040  include('../includes/constants.'.$phpEx);
041  include('../functions/functions.'.$phpEx);
042  include('../includes/db.'.$phpEx);
043  include('../functions/bbcode.'.$phpEx);
044   
045  set_time_limit(60*60);  // Increase maximum execution time to 60 minutes. 
046   
047   
048   
049  $backup_name = "backup_post_text";
050  $table_name = POSTS_TEXT_TABLE;
051  $sql = "CREATE TABLE $backup_name (
052     post_id int(10) DEFAULT '0' NOT NULL,
053     post_text text,
054     PRIMARY KEY (post_id)
055  );";
056   
057  echo "<p>Creating backup table.. </p>\n";
058  flush();
059   
060  $result = $db->sql_query($sql);
061  if (!$result) 
062  {
063      $db_error = $db->sql_error();
064      die("Error doing DB backup table creation. Reason: " . $db_error["message"]);
065  }
066   
067  $sql = "insert into $backup_name select * from $table_name";
068   
069  echo "<p>Populating backup table.. </p>\n";
070  flush();
071   
072  $result = $db->sql_query($sql);
073  if (!$result) 
074  {
075      $db_error = $db->sql_error();
076      die("Error doing DB backup table data moving. Reason: " . $db_error["message"]);
077  }
078   
079   
080  $sql = "SELECT p.post_id, t.post_text FROM " . POSTS_TABLE . " p, " . POSTS_TEXT_TABLE . " t WHERE (p.post_id = t.post_id)";
081  if(!$result = $db->sql_query($sql))
082  {
083     die("error getting posts to work on");
084  }
085  if(!$total_rows = $db->sql_numrows($result))
086  {
087     die("error getting rowcount");
088  }
089   
090  echo "<p><b>Found $total_rows total rows to work on. </b></p>\n";
091  flush();
092   
093  $row = $db->sql_fetchrowset($result);
094   
095  for($i = 0; $i < $total_rows; $i++)
096  {
097      $post_id = $row[$i]['post_id'];
098      $text = $row[$i]['post_text'];
099   
100      // undo 1.2.x encoding..
101      $text = bbdecode($text);
102      $text = undo_make_clickable($text);
103      $text = str_replace("<BR>", "\n", $text);
104      
105      // make a uid
106      $uid = make_bbcode_uid();
107      
108      // do 2.x first-pass encoding..
109      $text = bbencode_first_pass($text, $uid);
110      
111      $text = addslashes($text);
112      
113      // put the uid in the database.
114      $sql = "UPDATE " . POSTS_TABLE . " SET bbcode_uid='" . $uid . "' WHERE (post_id = $post_id)";
115      $result = $db->sql_query($sql);
116    if (!$result) 
117      {
118          $db_error = $db->sql_error();
119          die("Error doing DB update in posts table. Reason: " . $db_error["message"] . " sql: $sql");
120      }
121      // Put the post text back in the database.
122      $sql = "UPDATE " . POSTS_TEXT_TABLE . " SET post_text='" . $text . "' WHERE (post_id = $post_id)";
123      $result = $db->sql_query($sql);
124    if (!$result) 
125      {
126          $db_error = $db->sql_error();
127          die("Error doing DB update in post text table. Reason: " . $db_error["message"] . " sql: $sql");
128      }
129      
130      if (($i % 100) == 0)
131      {
132          echo "Done post: <b> $i </b><br>\n";
133          flush();
134      }
135      
136      
137  }
138   
139   
140   
141  echo "<p><b>Done.</b></p>\n";
142   
143   
144   
145  // -------------------------------------------------------------------------------
146  // Everything below here is 1.x BBCode functions.
147  // -------------------------------------------------------------------------------
148   
149   
150  function bbdecode($message) {
151   
152          // Undo [code]
153          $code_start_html = "<!-- BBCode Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font size=-1>Code:</font><HR></TD></TR><TR><TD><FONT SIZE=-1><PRE>";
154          $code_end_html = "</PRE></FONT></TD></TR><TR><TD><HR></TD></TR></TABLE><!-- BBCode End -->";
155          $message = str_replace($code_start_html, "[code]", $message);
156          $message = str_replace($code_end_html, "[/code]", $message);
157   
158          // Undo [quote]
159          $quote_start_html = "<!-- BBCode Quote Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font size=-1>Quote:</font><HR></TD></TR><TR><TD><FONT SIZE=-1><BLOCKQUOTE>";
160          $quote_end_html = "</BLOCKQUOTE></FONT></TD></TR><TR><TD><HR></TD></TR></TABLE><!-- BBCode Quote End -->";
161          $message = str_replace($quote_start_html, "[quote]", $message);
162          $message = str_replace($quote_end_html, "[/quote]", $message);
163          
164          // Undo [b] and [i]
165          $message = preg_replace("#<!-- BBCode Start --><B>(.*?)</B><!-- BBCode End -->#s", "[b]\\1[/b]", $message);
166          $message = preg_replace("#<!-- BBCode Start --><I>(.*?)</I><!-- BBCode End -->#s", "[i]\\1[/i]", $message);
167          
168          // Undo [url] (long form)
169          $message = preg_replace("#<!-- BBCode u2 Start --><A HREF=\"([a-z]+?://)(.*?)\" TARGET=\"_blank\">(.*?)</A><!-- BBCode u2 End -->#s", "[url=\\1\\2]\\3[/url]", $message);
170          
171          // Undo [url] (short form)
172          $message = preg_replace("#<!-- BBCode u1 Start --><A HREF=\"([a-z]+?://)(.*?)\" TARGET=\"_blank\">(.*?)</A><!-- BBCode u1 End -->#s", "[url]\\3[/url]", $message);
173          
174          // Undo [email]
175          $message = preg_replace("#<!-- BBCode Start --><A HREF=\"mailto:(.*?)\">(.*?)</A><!-- BBCode End -->#s", "[email]\\1[/email]", $message);
176          
177          // Undo [img]
178          $message = preg_replace("#<!-- BBCode Start --><IMG SRC=\"(.*?)\" BORDER=\"0\"><!-- BBCode End -->#s", "[img]\\1[/img]", $message);
179          
180          // Undo lists (unordered/ordered)
181      
182          // <li> tags:
183          $message = str_replace("<!-- BBCode --><LI>", "[*]", $message);
184          
185          // [list] tags:
186          $message = str_replace("<!-- BBCode ulist Start --><UL>", "[list]", $message);
187          
188          // [list=x] tags:
189          $message = preg_replace("#<!-- BBCode olist Start --><OL TYPE=([A1])>#si", "[list=\\1]", $message);
190          
191          // [/list] tags:
192          $message = str_replace("</UL><!-- BBCode ulist End -->", "[/list]", $message);
193          $message = str_replace("</OL><!-- BBCode olist End -->", "[/list]", $message);
194   
195          return($message);
196  }
197   
198   
199  /**
200   * Nathan Codding - Feb 6, 2001
201   * Reverses the effects of make_clickable(), for use in editpost.
202   * - Does not distinguish between "www.xxxx.yyyy" and "http://aaaa.bbbb" type URLs.
203   *
204   */
205   
206  function undo_make_clickable($text) {
207      
208      $text = preg_replace("#<!-- BBCode auto-link start --><a href=\"(.*?)\" target=\"_blank\">.*?</a><!-- BBCode auto-link end -->#i", "\\1", $text);
209      $text = preg_replace("#<!-- BBcode auto-mailto start --><a href=\"mailto:(.*?)\">.*?</a><!-- BBCode auto-mailto end -->#i", "\\1", $text);
210      
211      return $text;
212      
213  }
214   
215   
216   
217   
218  ?>
219