aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/develop/convert_avatars.php
blob: f6069a1e4a3147a13309e7680a831b050e42a3b2 (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
<?php

$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 = "ALTER TABLE " . USERS_TABLE . " 
	ADD user_avatar_type TINYINT(4) DEFAULT '0' NOT NULL";
if( !$result = $db->sql_query($sql) )
{
	die("Couldn't alter users table");
}

$sql = "SELECT user_id, user_avatar 
	FROM " . USERS_TABLE;
if( $result = $db->sql_query($sql) )
{
	$rowset = $db->sql_fetchrowset($result);

	for($i = 0; $i < count($rowset); $i++)
	{
		if( ereg("^http", $rowset[$i]['user_avatar']))
		{
			$sql_type = USER_AVATAR_REMOTE;
		}
		else if( $rowset[$i]['user_avatar'] != "" )
		{
			$sql_type = USER_AVATAR_UPLOAD;
		}
		else
		{
			$sql_type = USER_AVATAR_NONE;
		}

		$sql = "UPDATE " . USERS_TABLE . " 
			SET user_avatar_type = $sql_type 
			WHERE user_id = " . $rowset[$i]['user_id'];
		if( !$result = $db->sql_query($sql) )
		{
			die("Couldn't update users table- " . $i);
		}
	}
}

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

?>