Sync the phpBB joined date with the CB joined date

17 years 2 months ago #32724 by gump
The conenctor didn't sync phpBB's 'user joined date' with the CB joined date, so my mate wrote a script to do it automatically. Just edit the database info, save as a php file, upload then point your browser at the script.

Enjoy!
G

[code:1]<?php

//Database settings forum tables have to be on same db.
$dbhost = "localhost";
$dbuser = "";
$dbpass = "";
$db = "";

// table prefixs
$jom_pre = "jos_";
$php_pre = "phpbb_";

//Connect to db
$dbcnx = @mysql_connect($dbhost, $dbuser, $dbpass)
or die("The site database appears to be down."«»);
if ($db!="" and !@mysql_select_db($db))
die("The site database is unavailable."«»);

// Set counters to 0.
$failed=0;
$count=0;

$result = mysql_query('SELECT jom.id,php.user_regdate FROM ' . $jom_pre . 'users jom, ' . $php_pre . 'users php, ' . $jom_pre . 'comprofiler cb where jom.id = cb.user_id and cb.cb_phpbbid=php.user_id order by jom.id;');

while ($row = mysql_fetch_assoc($result)) {
$count++;
// Query for updating current user in loop to phpbb time.
mysql_query("UPDATE " . $jom_pre . "users SET registerDate='" . date('Y-m-d H:i:«»s', $row) . "' WHERE id='" . $row . "';"«») or die('Time update to joomla table failed: ' . mysql_error());
// Get new value in joomla table.
$result2 = mysql_query("SELECT registerDate FROM " . $jom_pre . "users WHERE id='" . $row . "';"«»);
$row2 = mysql_fetch_row($result2);
// do output and check value.
echo "Updating user: User id: " . $row . ".<br/>";
echo "PHPBB Time value: " . $row . ".<br/>";
echo "Converted Time: " . date('Y-m-d H:i:«»s', $row) . ".<br/>";
echo "New Joomla Value: " . $row2[0] . ".<br/>";
// check 2 dates
echo "RESULT = ";
if(date('Y-m-d H:i:«»s', $row) == $row2[0]) {
echo "PASS, dates now equal<br/>";
} else {
echo "FAIL, update failed time value not equal<br/>";
$failed++;
}
echo "
<br/>";
}
// Display stats.
echo "$count records done, $failed records failed!";
?>
[/code:1]

Post edited by: gump, at: 2007/03/08 02:32

Please Log in to join the conversation.

17 years 2 months ago #32803 by geeffland
Keep in mind this applies to v1.0.3 or prior. v2.0 has this already included (except for a small bug which I just fixed when verifying it was there... so next v2 release will set matching reg dates each direction ... also in v2 cb_phpbbid is now cb_forumid)

I think particularly the first SQL statement will need to be modified as well as it has some non-generic table names...


Thanks for the submission...

Greg

CB3PD Developer - CB Connector (formerly phpBB Connector) plugin

Please Log in to join the conversation.

Moderators: beatnantgeefflandmartijn189krileon
Time to create page: 0.282 seconds

Facebook Twitter LinkedIn