1 (edited by keyes 2007-02-26 21:50)

Topic: Import avatars from PHPBB

Yo, here is a little PHP script to import users avatars from PHPBB forums. Copy it to the root of your punbb.

<?php
include ('config.php');

mysql_connect ($db_host, $db_username, $db_password) or die ('F*cK');
mysql_select_db ($db_name) or die ('f*ck');


$old = '/PATH/TO/PHPBB/images/avatars';
$new = 'img/avatars';

$query = 'SELECT * FROM users;';
$result = mysql_query ($query);

echo '<pre>'

while ($u = mysql_fetch_object ($result)) {
    $query = sprintf ('SELECT user_avatar FROM phpbb_users WHERE username=\'%s\';', $u->username);
    $res = mysql_query ($query);
    $p = mysql_fetch_object ($res);
    
    if ($p->user_avatar != '') {
        $n = strrpos ($p->user_avatar, '.');

        $name = substr ($p->user_avatar, 0, $n);
        $ext = substr ($p->user_avatar, $n);

        copy ($old . '/' . $p->user_avatar, $new . '/' . $u->id. $ext);
                $query = sprintf ('UPDATE users SET use_avatar=1 WHERE username=\'%s\';', $u->username);
                mysql_query ($query);

        echo '#!/bin/bash' . "\n";
        echo 'cp ' . $old . '/' . $p->user_avatar . ' ' . $new . '/' . $u->id. $ext . "\n";
    }
}

echo '</pre>';
?>