Improved Coppermine-phpBB3 Bridge
Posted January 6th 2014, 2:06pm
Coppermine is a great picture gallery application, but parts of its code leave something to be desired. One example is the bridging code.

For some reason, Coppermine assumes that all bridge applications are using MySQL. That may have been true ten years ago, but today, many applications use database servers such as PostGreSQL, MSSQL, and Oracle. If Coppermine attempts to bridge to an application that is using a database server other than MySQL, it will crash, and the only way to fix the crash is to manually change the Coppermine configuration in the database using phpMyAdmin.

Dion Designs to the rescue! The following ZIP file contains a rewritten bridge core, and a new bridge driver for phpBB3.

phpbb3_bridge.zip
10.65 KiB  |  Downloaded 338 times

Installation is easy. Un-ZIP the file and upload the two PHP files to the Coppermine /bridge directory. That's it! You will overwrite files of the same name, which is fine, since you never again want to use the old files. ;)

You will now be able to brige Coppermine to phpBB3, even if phpBB3 is using PostGreSQL databases!

As I mentioned above, the only bridge driver rewritten to use the new brodge core is for phpBB3. If anyone else would like to rewrite bridge drivers for other applications, I would be happy to provide some pointers, though looking at the phpBB3 bridge driver should provide all the information you need.

Note: in the following post, I will post some modifications you should make to Coppermine's include/functions.inc.php file. I strongly suggest that you make these modifications, because otherwise, Coppermine may crash when doing certain admin-related functions.

Enjoy!
φ
Posts: 1599
Joined: March 12th 2009, 11:00pm
Location: Uncertain due to momentum
Likes Given: 26
Likes Received: 357
Improved Coppermine-phpBB3 Bridge
Posted January 6th 2014, 2:11pm
Here are the modifications you should make to Coppermine's include/functions.inc.php file. First, find the following lines in the get_cat_data() function:

				$result2 = cpg_db_query("SELECT {$cpg_udb->field['user_id']} AS user_id, {$cpg_udb->field['username']} AS user_name FROM {$cpg_udb->usertable} ORDER BY user_name", $cpg_udb->link_id);
$rowset2 = cpg_db_fetch_rowset($result2);

Replace them with:

//	MODIFICATION by Dion Designs
// Add support for phpBB3 DBAL
// $result2 = cpg_db_query("SELECT {$cpg_udb->field['user_id']} AS user_id, {$cpg_udb->field['username']} AS user_name FROM {$cpg_udb->usertable} ORDER BY user_name", $cpg_udb->link_id);
// $rowset2 = cpg_db_fetch_rowset($result2);
$rowset2 = array();
if (UDB_INTEGRATION == 'phpbb3') {
$result2 = cpgudb_db_query("SELECT {$cpg_udb->field['user_id']} AS user_id, {$cpg_udb->field['username']} AS user_name FROM {$cpg_udb->usertable} ORDER BY user_name");
while ($row = cpgudb_db_fetch_row($result2)) {
$rowset2[] = $row;
}
cpgudb_db_free_result($result);
}
else {
$result2 = cpg_db_query("SELECT {$cpg_udb->field['user_id']} AS user_id, {$cpg_udb->field['username']} AS user_name FROM {$cpg_udb->usertable} ORDER BY user_name", $cpg_udb->link_id);
// cpg_db_fetch_rowset() creates memory leaks
while ($row = cpg_db_fetch_row($result2)) {
$rowset2[] = $row;
}
// fixing a CPG bug (free_result is missing), use new DBAL free result function
cpg_db_free_result($result2);
}
// END

Next, find the following lines in the album_selection_options() function:

				$result2 = cpg_db_query("SELECT {$cpg_udb->field['user_id']} AS user_id, {$cpg_udb->field['username']} AS user_name "
. "FROM {$cpg_udb->usertable} ORDER BY {$cpg_udb->field['username']}", $cpg_udb->link_id);
$users = cpg_db_fetch_rowset($result2);
mysql_free_result($result2);

Replace them with:

//	MODIFICATION by Dion Designs
// Add support for phpBB3 DBAL
// $result2 = cpg_db_query("SELECT {$cpg_udb->field['user_id']} AS user_id, {$cpg_udb->field['username']} AS user_name "
// . "FROM {$cpg_udb->usertable} ORDER BY {$cpg_udb->field['username']}", $cpg_udb->link_id);
// $users = cpg_db_fetch_rowset($result2);
// mysql_free_result($result2);
$users = array();
if (UDB_INTEGRATION == 'phpbb3') {
$result2 = cpgudb_db_query("SELECT {$cpg_udb->field['user_id']} AS user_id, {$cpg_udb->field['username']} AS user_name "
. "FROM {$cpg_udb->usertable} ORDER BY {$cpg_udb->field['username']}");
// cpg_db_fetch_rowset() creates memory leaks so no UDB version is available
while ($row = cpgudb_db_fetch_row($result2)) {
$users[] = $row;
}
cpgudb_db_free_result($result);
}
else {
$result2 = cpg_db_query("SELECT {$cpg_udb->field['user_id']} AS user_id, {$cpg_udb->field['username']} AS user_name "
. "FROM {$cpg_udb->usertable} ORDER BY {$cpg_udb->field['username']}", $cpg_udb->link_id);
// cpg_db_fetch_rowset() creates memory leaks
while ($row = cpg_db_fetch_row($result2)) {
$users[] = $row;
}
// use new DBAL free result function
cpg_db_free_result($result);
}
// END

Now save the file. The two admin functions will now properly work with the new bridge core.

IMPORTANT! The above code is set up exclusively for the phpBB3 bridge. It will need to be modified as additional bridge drivers are rewritten to support the new bridge core.
φ
Posts: 1599
Joined: March 12th 2009, 11:00pm
Location: Uncertain due to momentum
Likes Given: 26
Likes Received: 357

Who is online

Users browsing this forum: No registered users and 0 guests