From a711e6d677257b64574fb5c377dfbde7127da3c3 Mon Sep 17 00:00:00 2001 From: "Paul S. Owen" Date: Mon, 1 Oct 2001 23:22:18 +0000 Subject: Changes related to private messaging + some bug fixes git-svn-id: file:///svn/phpbb/trunk@1111 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/develop/convert_privmsgs.php | 167 +++++++++++++++++++++++++++++++++++++ 1 file changed, 167 insertions(+) create mode 100644 phpBB/develop/convert_privmsgs.php (limited to 'phpBB/develop/convert_privmsgs.php') diff --git a/phpBB/develop/convert_privmsgs.php b/phpBB/develop/convert_privmsgs.php new file mode 100644 index 0000000000..847d3e20cc --- /dev/null +++ b/phpBB/develop/convert_privmsgs.php @@ -0,0 +1,167 @@ +sql_query($sql) ) +{ + die("Couldn't alter privmsgs table"); +} +echo $sql = "ALTER TABLE " . PRIVMSGS_TEXT_TABLE . " + ADD privmsgs_bbcode_uid CHAR(10) AFTER privmsgs_text_id"; +if( !$result = $db->sql_query($sql) ) +{ + die("Couldn't alter privmsgs text table"); +} +echo "COMPLETE
"; + +// +// Move bbcode ... +// +echo "Move bbcode uid's ... "; + +$sql = "SELECT privmsgs_id, privmsgs_bbcode_uid + FROM " . PRIVMSGS_TABLE; +if( $result = $db->sql_query($sql) ) +{ + $rowset = $db->sql_fetchrowset($result); + + for($i = 0; $i < count($rowset); $i++) + { + $sql = "UPDATE " . PRIVMSGS_TEXT_TABLE . " + SET privmsgs_bbcode_uid = '" . $rowset[$i]['privmsgs_bbcode_uid'] . "' + WHERE privmsgs_text_id = " . $rowset[$i]['privmsgs_id']; + if( !$result = $db->sql_query($sql) ) + { + die("Couldn't update privmsgs text bbcode - " . $i); + } + } + + $sql = "ALTER TABLE " . PRIVMSGS_TABLE . " + DROP privmsgs_bbcode_uid"; + if( !$result = $db->sql_query($sql) ) + { + die("Couldn't alter privmsgs table - drop privmsgs_bbcode_uid"); + } +} + +echo "COMPLETE
"; + +// +// Stripslashes from titles +// +echo "Strip subject slashes ... "; + +$sql = "SELECT privmsgs_subject , privmsgs_id, privmsgs_to_userid, privmsgs_from_userid + FROM " . PRIVMSGS_TABLE; +if( $result = $db->sql_query($sql) ) +{ + $rowset = $db->sql_fetchrowset($result); + + for($i = 0; $i < count($rowset); $i++) + { + $sql = "UPDATE " . PRIVMSGS_TABLE . " + SET privmsgs_subject = '" . addslashes(stripslashes($rowset[$i]['privmsgs_subject'])) . "' + WHERE privmsgs_id = " . $rowset[$i]['privmsgs_id']; + if( !$result = $db->sql_query($sql) ) + { + die("Couldn't update subjects - $i"); + } + } +} +echo "COMPLETE
"; + +// +// Update sigs +// +echo "Remove [addsig], stripslashes and update privmsgs table sig enable ..."; + +$sql = "SELECT privmsgs_text_id , privmsgs_text + FROM " . PRIVMSGS_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]['privmsgs_text'])) + { + if( $attach_sql != "" ) + { + $attach_sql .= ", "; + } + $attach_sql .= $rowset[$i]['privmsgs_text_id']; + + $sql = "UPDATE " . PRIVMSGS_TEXT_TABLE . " + SET privmsgs_text = '" . addslashes(preg_replace("/\[addsig\]/is", "", stripslashes($rowset[$i]['privmsgs_text']))) . "' + WHERE privmsgs_text_id = " . $rowset[$i]['privmsgs_text_id']; + if( !$result = $db->sql_query($sql) ) + { + die("Couldn't update privmsgs text - " . $i); + } + + } + else + { + $sql = "UPDATE " . PRIVMSGS_TEXT_TABLE . " + SET privmsgs_text = '" . addslashes(stripslashes($rowset[$i]['privmsgs_text'])) . "' + WHERE privmsgs_text_id = " . $rowset[$i]['privmsgs_text_id']; + if( !$result = $db->sql_query($sql) ) + { + die("Couldn't update privmsgs text - " . $i); + } + + if( $non_attach_sql != "" ) + { + $non_attach_sql .= ", "; + } + $non_attach_sql .= $rowset[$i]['privmsgs_text_id']; + } + } + + if( $attach_sql != "" ) + { + $sql = "UPDATE " . PRIVMSGS_TABLE . " + SET privmsgs_attach_sig = 1 + WHERE privmsgs_id IN ($attach_sql)"; + if( !$result = $db->sql_query($sql) ) + { + die("Couldn't update privmsgs table attach_sig - "); + } + } + + if( $non_attach_sql != "" ) + { + $sql = "UPDATE " . PRIVMSGS_TABLE . " + SET privmsgs_attach_sig = 0 + WHERE privmsgs_id IN ($non_attach_sql)"; + if( !$result = $db->sql_query($sql) ) + { + die("Couldn't update privmsgs table non_attach_sig - "); + } + } + +} + +echo "COMPLETE
"; + +$db->sql_close(); + +?> -- cgit v1.2.1