Gallery2 import tool for Coppermine 1.5.x Gallery2 import tool for Coppermine 1.5.x
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

Gallery2 import tool for Coppermine 1.5.x

Started by Fippls, March 28, 2013, 05:06:06 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Fippls

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.html

It 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.php

6. 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.

phill104

Thanks for your excellent contribution. I am sure the community can make good use of this. The script was very popular for cpg1.4
It is a mistake to think you can solve any major problems just with potatoes.

google

Hi,

I tried this on 1.5.20 and the gallery version 2.3.1 and 2.3.3 . It didn't work for me. When I say import it just refreshes the page and I see nothing happening.

Also tried on 1.5.28

bpiermat

I have the same issue. Waiting for a solution! Please help

google

OK., I found a round about way. But works.

I installed 1.4.27 version from coppermine repository. You can later update this to latest 1.5.x

and edited the files with mix of information posted here by Fipplis and thread he pointed to.

I have attached files. Update config values in importer file and change extension to .php and place it in coppermine folder and the picmgmt (change extension to php) in include folder.

Let me know if it works for you. I have imported successfully from gallery v2.3.1

bpiermat

Thanks! How is the best way to downgrade? Upload over the top of 1.5.x?

bpiermat

I have a clean install, no photos or anything.....yet

bpiermat

OK I did what you suggested and the database/albums came over. But all the pictures did not transfer. Is there a trick?

bpiermat

Got it to WORK! I had to change the album directory in the import php file!!

google


f3red

What is the current status of this tool?

Thanks,
f3