aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/develop/convert_sigs.php
blob: 501106fc1023c0d2a996acb3581a91354ce82a22 (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php

//
// Security message:
//
// This script is potentially dangerous.
// Remove or comment the next line (die(".... ) to enable this script.
// Do NOT FORGET to either remove this script or disable it after you have used it.
//
die("Please read the first lines of this script for instructions on how to enable it");

//
// Do not change anything below this line.
//

$phpbb_root_path = "../";

include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'config.'.$phpEx);
include($phpbb_root_path . 'includes/constants.'.$phpEx);
include($phpbb_root_path . 'includes/db.'.$phpEx);

$sql = "SELECT post_id, post_text 
	FROM " . POSTS_TEXT_TABLE;
if( $result = $db->sql_query($sql) )
{
	$rowset = $db->sql_fetchrowset($result);

	$attach_sql = "";
	$non_attach_sql = "";

	for($i = 0; $i < count($rowset); $i++)
	{
		if( ereg("\[addsig]$", $rowset[$i]['post_text']))
		{
			if( $attach_sql != "" )
			{
				$attach_sql .= ", ";
			}
			$attach_sql .= $rowset[$i]['post_id'];

			$sql = "UPDATE " . POSTS_TEXT_TABLE . " 
				SET post_text = '" . addslashes(preg_replace("/\[addsig\]/is", "", $rowset[$i]['post_text'])) . "'  
				WHERE post_id = " . $rowset[$i]['post_id'];
			if( !$result = $db->sql_query($sql) )
			{
				die("Couldn't update post_text - " . $i);
			}

		}
		else
		{
			if( $non_attach_sql != "" )
			{
				$non_attach_sql .= ", ";
			}
			$non_attach_sql .= $rowset[$i]['post_id'];
		}
	}

	echo "<BR>";

	if( $attach_sql != "" )
	{
		echo $sql = "UPDATE " . POSTS_TABLE . " 
			SET enable_sig = 1 
			WHERE post_id IN ($attach_sql)";
		if( !$result = $db->sql_query($sql) )
		{
			die("Couldn't update post table attach_sig - ");
		}
	}

	echo "<BR>";

	if( $non_attach_sql != "" )
	{
		echo $sql = "UPDATE " . POSTS_TABLE . " 
			SET enable_sig = 0 
			WHERE post_id IN ($non_attach_sql)";
		if( !$result = $db->sql_query($sql) )
		{
			die("Couldn't update post table non_attach_sig - ");
		}
	}

}

$db->sql_close();

	echo "<BR><BR>COMPLETE<BR>";

?>