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

convert_bbcodeuid.php

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


01  <?php
02   
03  //
04  // Security message:
05  //
06  // This script is potentially dangerous.
07  // Remove or comment the next line (die(".... ) to enable this script.
08  // Do NOT FORGET to either remove this script or disable it after you have used it.
09  //
10  die("Please read the first lines of this script for instructions on how to enable it");
11   
12  //
13  // Do not change anything below this line.
14  //
15   
16   
17  $phpbb_root_path = "../";
18   
19  include($phpbb_root_path . 'extension.inc');
20  include($phpbb_root_path . 'config.'.$phpEx);
21  include($phpbb_root_path . 'includes/constants.'.$phpEx);
22  include($phpbb_root_path . 'includes/db.'.$phpEx);
23   
24  function query($sql, $errormsg)
25  {
26      global $db;
27      if(!$result = $db->sql_query($sql))
28      {
29          print "<br><font color=\"red\">\n";
30          print "$errormsg<br>";
31          $sql_error = $db->sql_error();
32          print $sql_error['code'] .": ". $sql_error['message']. "<br>\n";
33          print "<pre>$sql</pre>";
34          print "</font>\n";
35          return FALSE;
36      }
37      else
38      {
39          return $result;
40      }
41  }
42   
43  if($HTTP_GET_VARS['delete'] == 'true')
44  {
45      $sql = "ALTER TABLE ".POSTS_TABLE."
46          DROP bbcode_uid";
47      query($sql, "Didn't manage to drop the bbcode_uid table in ".POSTS_TABLE);
48      print "All done now. Deleted the bbcode_uid column from the posts table.<p>";
49      exit;
50  }
51   
52   
53  $sql = "ALTER TABLE ".POSTS_TEXT_TABLE.
54      ADD bbcode_uid char(10) NOT NULL";
55  print "Adding bbcode_uid field to ".POSTS_TEXT_TABLE.".<br>\n";
56  $result = query($sql, "Couldn't get add bbcode_uid field to ".POSTS_TEXT_TABLE.".");
57   
58  $sql = "
59      SELECT 
60          count(*) as total,
61          max(post_id) as maxid 
62      FROM ". POSTS_TABLE;
63  $result = query($sql, "Couldn't get max post_id.");
64  $maxid = $db->sql_fetchrow($result);
65  $totalposts = $maxid['total'];
66  $maxid = $maxid['maxid'];
67   
68  $batchsize = 200;
69  print "Going to convert BBcode in posts with $batchsize messages at a time and $totalposts in total.<br>\n";
70  for($i = 0; $i <= $maxid; $i += $batchsize)
71  {
72      $batchstart = $i + 1;
73      $batchend = $i + $batchsize;
74      
75      print "Moving BBcode UID in post number $batchstart to $batchend<br>\n";
76      flush();
77      $sql = "
78          SELECT 
79              post_id,
80              bbcode_uid
81          FROM "
82              .POSTS_TABLE."
83          WHERE
84              post_id BETWEEN $batchstart AND $batchend";
85      $result = query($sql, "Couldn't get ". POSTS_TABLE .".post_id $batchstart to $batchend");
86      while($row = mysql_fetch_array($result))
87      {
88          query("UPDATE ".POSTS_TEXT_TABLE." set bbcode_uid = '". $row['bbcode_uid']. "' WHERE post_id = ".$row['post_id'], "Was unable to update the posts text table with the BBcode_uid");
89      }
90  }
91   
92  echo "Click <a href=\"$PHP_SELF?delete=true\">HERE</a> to remove the bbcode_uid table from the POSTS table (if you didn't get any serious error messages).<p>";
93   
94  $db->sql_close();
95   
96  ?>
97