Hi,
Hope I'm posting this in the correct forum! I recently installed Coppermine 1.5 and wanted to import all my gallery2 items, so tried using the excellent tool posted here:
http://forum.coppermine-gallery.net/index.php/topic,51300.0.htmlIt seems that parts of Coppermine have changed so that the tool no longer works. Since I've spent some time fixing it, I thought it would be a good thing to share it with the rest of the world

This version also copies across the view counts for albums, not just for images.
Instructions:1. Download the
import_gallery2.php script mentioned in the link at start of this post and follow the instructions on where to place it and configuring access to the gallery you're migrating from, but skip the parts about replacing code.
2. Edit
import_gallery2.php and locate the following line:
$query = "INSERT INTO {$CONFIG['TABLE_ALBUMS']} SET title='".addslashes($row[0])."', description='".addslashes($row[1])."'";
and then replace it with this instead:
$query = "INSERT INTO {$CONFIG['TABLE_ALBUMS']} SET title='".addslashes($row[0])."', alb_hits='$numAlbumViews', description='".addslashes($row[1])."'";
3. Place this code just above the line you just changed:
# ----------------------------------
# Gets view counts for albums as well
$albumViewCountQuery = "SELECT {$cp}viewcount from {$tp}itemattributesmap WHERE {$cp}itemid = '$galAlbum'";
$albumViewCountResult = mysql_query($albumViewCountQuery);
if (!mysql_num_rows($albumViewCountResult)) {
cpg_die(ERROR, "Could not get view counts for selected album <B>$galAlbum</B>");
}
$albumViewCountRow = mysql_fetch_array($albumViewCountResult, MYSQL_NUM);
mysql_free_result($albumViewCountResult);
$numAlbumViews = $albumViewCountRow[0];
4. Locate this line:
$result1 = add_picture ($aid, $albPath."/", $imageFullName, 0, $imageTitle, $imageCaption, $imageKeywords, '', '', '', '', 0, $raw_ip, $hdr_ip, $viewCount);
and replace it with this line:
$result1 = add_picture ($aid, $albPath."/", $imageFullName, 0, $imageTitle, $imageCaption, $imageKeywords, '', '', '', '', 0, $raw_ip, $hdr_ip, 0, 0, $viewCount);
5. Create a backup of
include/picmgmt.inc.php6. Edit
include/picmgmt.inc.php and locate this line:
function add_picture($aid, $filepath, $filename, $position = 0, $title = '', $caption = '', $keywords = '', $user1 = '', $user2 = '', $user3 = '', $user4 = '', $category = 0, $raw_ip = '', $hdr_ip = '', $iwidth = 0, $iheight = 0)
and replace it with this line:
function add_picture($aid, $filepath, $filename, $position = 0, $title = '', $caption = '', $keywords = '', $user1 = '', $user2 = '', $user3 = '', $user4 = '', $category = 0, $raw_ip = '', $hdr_ip = '', $iwidth = 0, $iheight = 0, $hits = 0)
7. Locate this line:
$query = "INSERT INTO {$CONFIG['TABLE_PICTURES']} (aid, filepath, filename, filesize, total_filesize, pwidth, pheight, ctime, owner_id, approved, pic_raw_ip, pic_hdr_ip, position, guest_token) VALUES ('{$CURRENT_PIC_DATA['aid']}', '" . addslashes($CURRENT_PIC_DATA['filepath']) . "', '" . addslashes($CURRENT_PIC_DATA['filename']) . "', '{$CURRENT_PIC_DATA['filesize']}', '{$CURRENT_PIC_DATA['total_filesize']}', '{$CURRENT_PIC_DATA['pwidth']}', '{$CURRENT_PIC_DATA['pheight']}', '" . time() . "', '{$CURRENT_PIC_DATA['owner_id']}', '{$CURRENT_PIC_DATA['approved']}', '{$CURRENT_PIC_DATA['pic_raw_ip']}', '{$CURRENT_PIC_DATA['pic_hdr_ip']}', '{$CURRENT_PIC_DATA['position']}', '{$CURRENT_PIC_DATA['guest_token']}')";
and replace it with this line:
$query = "INSERT INTO {$CONFIG['TABLE_PICTURES']} (aid, filepath, filename, filesize, total_filesize, pwidth, pheight, ctime, owner_id, approved, pic_raw_ip, pic_hdr_ip, position, guest_token, hits) VALUES ('{$CURRENT_PIC_DATA['aid']}', '" . addslashes($CURRENT_PIC_DATA['filepath']) . "', '" . addslashes($CURRENT_PIC_DATA['filename']) . "', '{$CURRENT_PIC_DATA['filesize']}', '{$CURRENT_PIC_DATA['total_filesize']}', '{$CURRENT_PIC_DATA['pwidth']}', '{$CURRENT_PIC_DATA['pheight']}', '" . time() . "', '{$CURRENT_PIC_DATA['owner_id']}', '{$CURRENT_PIC_DATA['approved']}', '{$CURRENT_PIC_DATA['pic_raw_ip']}', '{$CURRENT_PIC_DATA['pic_hdr_ip']}', '{$CURRENT_PIC_DATA['position']}', '{$CURRENT_PIC_DATA['guest_token']}', $hits)";
Basically, all you're doing here is adding a "hits" parameter to the SQL query.
Hopefully this should work fine! I've tested it on Coppermine 1.5.20 and imported from Gallery 2.3.1.