aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/develop/adjust_uids.php
blob: 3468475b8f39b82a6299ed76a33fd66bc7c89bad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?xml version='1.0' encoding='utf-8'?>

<section xmlns="http://docbook.org/ns/docbook" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:ns6="http://www.w3.org/1999/xlink" xmlns:ns5="http://www.w3.org/1998/Math/MathML" xmlns:ns4="http://www.w3.org/1999/xhtml" xmlns:ns3="http://www.w3.org/2000/svg" xmlns:ns="http://docbook.org/ns/docbook" xml:id="mcc-localdisks" version="5.0" xml:lang="pt_BR">

  <info>
    <title xml:id="mcc-localdisks-ti1">discos locais</title>
  </info>

  <mediaobject>
    <imageobject>
      <imagedata xml:id="mcc-localdisks-im1" revision="1" align="center" format="PNG"   fileref="mcc-localdisks.png"/>
    </imageobject>
  </mediaobject>

  <para>Nesta tela você pode escolher entre várias ferramentas para gerenciar ou
compartilhar seus discos locais. Clique no link abaixo para saber mais.</para>

  <orderedlist><title>discos locais</title>
		  <listitem><para><xref<<?php
/**
* Repair bbcodes converted with RC6
*
* You should make a backup from your users, posts and privmsgs table in case something goes wrong
* Forum descriptions and rules need to be re-submitted manually
*
*/
die("Please read the first lines of this script for instructions on how to enable it");

set_time_limit(0);
@ini_set('memory_limit', '512M');

define('IN_PHPBB', true);
$phpbb_root_path = './../';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.'.$phpEx);

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();

$echos = 0;


// Adjust user signatures
$sql = 'SELECT user_id, user_sig, user_sig_bbcode_uid
	FROM ' . USERS_TABLE . '
	ORDER BY user_id ASC';
$result = $db->sql_query($sql);

while ($row = $db->sql_fetchrow($result))
{
	$bbcode_uid = $row['user_sig_bbcode_uid'];

	// Only if a bbcode uid is present, the signature present and a size tag used...
	if (!empty($bbcode_uid) && strpos($row['user_sig'], $bbcode_uid) === false)
	{
		$row['user_sig'] = preg_replace('/\:[0-9a-z]{8}\]/', ":$bbcode_uid]", $row['user_sig']);

		$sql = 'UPDATE ' . USERS_TABLE . " SET user_sig = '" . $db->sql_escape($row['user_sig']) . "'
			WHERE user_id = " . $row['user_id'];
		$db->sql_query($sql);

		if ($echos > 200)
		{
			echo '<br />User: ' . "{$row['user_id']}\n";
			$echos = 0;
		}

		echo '.';
		$echos++;

		flush();
	}
}
$db->sql_freeresult($result);


// Now adjust posts
$sql = 'SELECT post_id, post_text, bbcode_uid, enable_bbcode
	FROM ' . POSTS_TABLE . '
	ORDER BY post_id ASC';
$result = $db->sql_query($sql);

while ($row = $db->sql_fetchrow($result))
{
	$bbcode_uid = $row['bbcode_uid'];

	// Only if a bbcode uid is present, bbcode enabled and a size tag used...
	if ($row['enable_bbcode'] && !empty($bbcode_uid) && strpos($row['post_text'], $bbcode_uid) === false)
	{
		$row['post_text'] = preg_replace('/\:[0-9a-z]{8}\]/', ":$bbcode_uid]", $row['post_text']);
		
		$sql = 'UPDATE ' . POSTS_TABLE . " SET post_text = '" . $db->sql_escape($row['post_text']) . "'
			WHERE post_id = " . $row['post_id'];
		$db->sql_query($sql);

		if ($echos > 200)
		{
			echo '<br />Post: ' . "{$row['post_id']} \n";
			$echos = 0;
		}

		echo '.';
		$echos++;

		flush();
	}
}
$db->sql_freeresult($result);

// Now to the private messages
$sql = 'SELECT msg_id, message_text, bbcode_uid, enable_bbcode
	FROM ' . PRIVMSGS_TABLE;
$result = $db->sql_query($sql);

while ($row = $db->sql_fetchrow($result))
{
	$bbcode_uid = $row['bbcode_uid'];

	// Only if a bbcode uid is present, bbcode enabled and a size tag used...
	if ($row['enable_bbcode'] && !empty($bbcode_uid) && strpos($row['message_text'], $bbcode_uid) === false)
	{
		$row['message_text'] = preg_replace('/\:[0-9a-z]{8}\]/', ":$bbcode_uid]", $row['message_text']);
		
		$sql = 'UPDATE ' . PRIVMSGS_TABLE . " SET message_text = '" . $db->sql_escape($row['message_text']) . "'
			WHERE msg_id = " . $row['msg_id'];
		$db->sql_query($sql);

		if ($echos > 200)
		{
			echo '<br />' . "\n";
			$echos = 0;
		}

		echo '.';
		$echos++;

		flush();
	}
}
$db->sql_freeresult($result);

// Done
$db->sql_close();
echo 'done';