[Outdated]: Menalto Gallery2 To Coppermine Converter [Outdated]: Menalto Gallery2 To Coppermine Converter
 

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

[Outdated]: Menalto Gallery2 To Coppermine Converter

Started by Aditya Mooley, September 16, 2005, 11:09:23 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Aditya Mooley

This converter is outdated. Please use the newer and better converter which is available -> here

We are back again with yet another Gallery converter. This time Menalto Gallery2 to Coppermine.

Download the attached file, put it in your coppermine intall folder make the changes as suggested in the comments and that's it.
You must login as ADMIN to be able to run this file.

Also, you need to make following changes in include/picmgmt.inc.php file in your coppermine install. Please backup your original file before changing.

Find:

function add_picture($aid, $filepath, $filename, $position = 0, $title = '', $caption = '', $keywords = '', $user1 = '', $user2 = '', $user3 = '', $user4 = '', $category = 0, $raw_ip = '', $hdr_ip = '')


Replace with:

function add_picture($aid, $filepath, $filename, $position = 0, $title = '', $caption = '', $keywords = '', $user1 = '', $user2 = '', $user3 = '', $user4 =
'', $category = 0, $raw_ip = '', $hdr_ip = '', $hits=0)


Find:

$query = "INSERT INTO {$CONFIG['TABLE_PICTURES']} (pid, aid, filepath, filename, filesize, total_filesize, pwidth, pheight, ctime, owner_id, owner_name, title, caption, keywords, approved, user1, user2, user3, user4, pic_raw_ip, pic_hdr_ip, position) 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['owner_name']}','{$CURRENT_PIC_DATA['title']}', '{$CURRENT_PIC_DATA['caption']}', '{$CURRENT_PIC_DATA['keywords']}', '{$CURRENT_PIC_DATA['approved']}', '{$CURRENT_PIC_DATA['user1']}', '{$CURRENT_PIC_DATA['user2']}', '{$CURRENT_PIC_DATA['user3']}', '{$CURRENT_PIC_DATA['user4']}', '{$CURRENT_PIC_DATA['pic_raw_ip']}', '{$CURRENT_PIC_DATA['pic_hdr_ip']}', '{$CURRENT_PIC_DATA['position']}')";


Replace with:

$query = "INSERT INTO {$CONFIG['TABLE_PICTURES']} (pid, aid, filepath, filename, filesize, total_filesize, pwidth, pheight, ctime, owner_id, owner_name, title, caption, keywords, approved, user1, user2, user3, user4, pic_raw_ip, pic_hdr_ip, position, 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['owner_name']}','{$CURRENT_PIC_DATA['title']}', '{$CURRENT_PIC_DATA['caption']}', '{$CURRENT_PIC_DATA['keywords']}', '{$CURRENT_PIC_DATA['approved']}', '{$CURRENT_PIC_DATA['user1']}', '{$CURRENT_PIC_DATA['user2']}', '{$CURRENT_PIC_DATA['user3']}', '{$CURRENT_PIC_DATA['user4']}', '{$CURRENT_PIC_DATA['pic_raw_ip']}', '{$CURRENT_PIC_DATA['pic_hdr_ip']}', '{$CURRENT_PIC_DATA['position']}', '$hits')";



For CPG 1.4.6 use the following :

Find


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 with


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)


Find


$query = "INSERT INTO {$CONFIG['TABLE_PICTURES']} (aid, filepath, filename, filesize, total_filesize, pwidth, pheight, ctime, owner_id, owner_name, title, caption, keywords, approved, user1, user2, user3, user4, pic_raw_ip, pic_hdr_ip, position) 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['owner_name']}','{$CURRENT_PIC_DATA['title']}', '{$CURRENT_PIC_DATA['caption']}', '{$CURRENT_PIC_DATA['keywords']}', '{$CURRENT_PIC_DATA['approved']}', '{$CURRENT_PIC_DATA['user1']}', '{$CURRENT_PIC_DATA['user2']}', '{$CURRENT_PIC_DATA['user3']}', '{$CURRENT_PIC_DATA['user4']}', '{$CURRENT_PIC_DATA['pic_raw_ip']}', '{$CURRENT_PIC_DATA['pic_hdr_ip']}', '{$CURRENT_PIC_DATA['position']}')";


And replace with


$query = "INSERT INTO {$CONFIG['TABLE_PICTURES']} (aid, filepath, filename, filesize, total_filesize, pwidth, pheight, ctime, owner_id, owner_name, title, caption, keywords, approved, user1, user2, user3, user4, pic_raw_ip, pic_hdr_ip, position, 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['owner_name']}','{$CURRENT_PIC_DATA['title']}', '{$CURRENT_PIC_DATA['caption']}', '{$CURRENT_PIC_DATA['keywords']}', '{$CURRENT_PIC_DATA['approved']}', '{$CURRENT_PIC_DATA['user1']}', '{$CURRENT_PIC_DATA['user2']}', '{$CURRENT_PIC_DATA['user3']}', '{$CURRENT_PIC_DATA['user4']}', '{$CURRENT_PIC_DATA['pic_raw_ip']}', '{$CURRENT_PIC_DATA['pic_hdr_ip']}', '{$CURRENT_PIC_DATA['position']}', '$hits')";


Thats all. Happy Coppermining.  :)

Aditya
--- "Its Nice 2 BE Important but its more Important 2 Be NICE" ---
Follow Coppermine on Twitter

Major Headache

I just tried to use this but it didn't work...

Coppermine version 1.3.5 downloaded tonight from sourceforge.
Gallery2.0 final version downloaded tonight.

I found when making the changes to picmgmt.inc.php that the lines didn't quite match. In the first instance, it says the line will be

function add_picture($aid, $filepath, $filename, $position = 0, $title = '', $caption = '', $keywords = '', $user1 = '', $user2 = '', $user3 = '', $user4 = '', $category = 0, $raw_ip = '', $hdr_ip = '')

but it was really

function add_picture($aid, $filepath, $filename, $title = '', $caption = '', $keywords = '', $user1 = '', $user2 = '', $user3 = '', $user4 = '', $category = 0, $raw_ip = '', $hdr_ip = '',$iwidth=0,$iheight=0)

In this case I just replaced the old line with the new line.

For the second replacement, it says it will be

$query = "INSERT INTO {$CONFIG['TABLE_PICTURES']} (pid, aid, filepath, filename, filesize, total_filesize, pwidth, pheight, ctime, owner_id, owner_name, title, caption, keywords, approved, user1, user2, user3, user4, pic_raw_ip, pic_hdr_ip, position) 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['owner_name']}','{$CURRENT_PIC_DATA['title']}', '{$CURRENT_PIC_DATA['caption']}', '{$CURRENT_PIC_DATA['keywords']}', '{$CURRENT_PIC_DATA['approved']}', '{$CURRENT_PIC_DATA['user1']}', '{$CURRENT_PIC_DATA['user2']}', '{$CURRENT_PIC_DATA['user3']}', '{$CURRENT_PIC_DATA['user4']}', '{$CURRENT_PIC_DATA['pic_raw_ip']}', '{$CURRENT_PIC_DATA['pic_hdr_ip']}', '{$CURRENT_PIC_DATA['position']}')";


but it was actually

$query = "INSERT INTO {$CONFIG['TABLE_PICTURES']} (pid, aid, filepath, filename, filesize, total_filesize, pwidth, pheight, ctime, owner_id, owner_name, title, caption, keywords, approved, user1, user2, user3, user4, pic_raw_ip, pic_hdr_ip) VALUES ('', '$aid', '" . addslashes($filepath) . "', '" . addslashes($filename) . "', '$image_filesize', '$total_filesize', '{$imagesize[0]}', '{$imagesize[1]}', '" . time() . "', '$user_id', '$username', '" . addslashes($title) . "', '" . addslashes($caption) . "', '" . addslashes($keywords) . "', '$approved', '$user1', '$user2', '$user3', '$user4', '$raw_ip', '$hdr_ip')";

In this instance I noticed that the only change was the two added instances of "hits" so I just added them to the original code as they appeared in the new line.

I have no logical basis for those decisions, I'm just trying stuff because I don't know php  :\'(

The script appeared to work up to the point where I selected an album to import. After that, I got the following error:

Album directory Members_ created...

Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/mlparena/public_html/cpg135/import_gallery2.php on line 154

Warning: mysql_insert_id(): supplied argument is not a valid MySQL-Link resource in /home/mlparena/public_html/cpg135/import_gallery2.php on line 158

Warning: mysql_free_result(): 18 is not a valid MySQL result resource in /home/mlparena/public_html/cpg135/import_gallery2.php on line 159

Album created...
Importing images

Q: SELECT i.*, fs.g_pathComponent, ia.g_viewCount FROM g2_Item i, g2_ChildEntity ce, g2_FileSystemEntity fs, g2_ItemAttributesMap ia WHERE ce.g_id = i.g_id AND i.g_id = fs.g_id AND ia.g_itemId = i.g_id AND ce.g_parentId = '10' AND i.g_canContainChildren = 0

Warning: Cannot modify header information - headers already sent by (output started at /home/mlparena/public_html/cpg135/import_gallery2.php:47) in /home/mlparena/public_html/cpg135/themes/classic/theme.php on line 810

Warning: Cannot modify header information - headers already sent by (output started at /home/mlparena/public_html/cpg135/import_gallery2.php:47) in /home/mlparena/public_html/cpg135/themes/classic/theme.php on line 811

Warning: Cannot modify header information - headers already sent by (output started at /home/mlparena/public_html/cpg135/import_gallery2.php:47) in /home/mlparena/public_html/cpg135/include/functions.inc.php on line 51


Not sure what to do but I'm willing to try if you have any suggestions. I'd really like to be able to do this.

BTW, is there a converter for gallery 1.5 to coppermine?

Aditya Mooley

This convertor is written for CPG 1.4.x This is mentioned in the label attached with the topic subject.
Some one will have to modify the script to make it work with 1.3.x

Quote
BTW, is there a converter for gallery 1.5 to coppermine?

No. There's one converter which we tested on 1.4.3pl1 and 1.4.4 -> http://forum.coppermine-gallery.net/index.php?topic=7992.0
See if this works for Gallery 1.5 also
--- "Its Nice 2 BE Important but its more Important 2 Be NICE" ---
Follow Coppermine on Twitter

Major Headache

Grr, sorry I missed that. I will install 1.4 tomorrow and have another go.

Thanks!

Major Headache

OK, round two using Coppermine 1.4.1. It seemed to be working pretty good, then it said there was an error. It imported nine images out of 237.

The gallery2 install is here: http://www.mlparena.com/gallery2/main.php

The coppermine gallery is here: http://www.mlparena.com/cpg141/

and the output of the import script is here: http://www.mlparena.com/cpg141/logfile.txt

I don't see any error messages

Enc0der

Hi !

The text file attached is broken.. please upload it as .zip file..

thanks!

Aditya Mooley

Hmmm.
I was able to download the complete file properly. Still I have attached a Zip file for those who are not able to get the txt file.
--- "Its Nice 2 BE Important but its more Important 2 Be NICE" ---
Follow Coppermine on Twitter

salewit

Just wondering if anybody has been successful with this script. It imports a few images, and then just quits with a "Database errror".

Upon further investigation, I turned DEBUG mode on, and found that the MySQL INSERT failed because my data had a single quote in it and it didn't get escaped.

While executing query "INSERT INTO cpg143_pictures (pid, aid, filepath, filename, filesize, total_filesize, pwidth, pheight, ctime, owner_id, owner_name, title, caption, keywords, approved, user1, user2, user3, user4, pic_raw_ip, pic_hdr_ip, position, hits) VALUES ('', '12', 'postcards/', 'adj02B.jpg', '19943', '37460', '500', '314', '1143263175', '1', 'admin','Back of postcard overlooking lake with Phillips' looking on.', 'Back of postcard overlooking lake with Phillips' looking on.', '', 'YES', '', '', '', '', '71.131.215.33', '71.131.215.33', '', '469')" on 0

mySQL error:


Is this something coming from the import script of from Coppermine? Can I fix it? I just checked my phpinfo() and it's showing magic_quotes_gpc ENABLED.

Aditya Mooley

magic_quote_gpc won't escape the quotes here since the data is not coming from any of the G, P or C. Its totally internal to the script and needs to be escaped manually.

In import_gallery2.php
Replace

$imageFullName = $row["{$cp}pathComponent"];
$imageTitle = $row["{$cp}title"];
$imageCaption = $row["{$cp}description"];


with

$imageFullName = addslashes($row["{$cp}pathComponent"]);
$imageTitle = addslashes($row["{$cp}title"]);
$imageCaption = addslashes($row["{$cp}description"]);


This should probebly solve this issue.
--- "Its Nice 2 BE Important but its more Important 2 Be NICE" ---
Follow Coppermine on Twitter

salewit

Thank you! That did the trick.... to an extent. On a small category, it worked fine, but on the next category which was over 300 photos, it gave me this error:

Fatal error: Maximum execution time of 30 seconds exceeded in /home/lakeminn/public_html/copper/include/picmgmt.inc.php on line 258


I looked in that code and didn't recognize anything where I could change the timeout limit ?? Maybe it was because I had debug mode on (the screen had about 30 pages of debug code).

Another problem which I figured out how to deal with myself, but maybe this will help someone else. When you install Gallery, they recommend storing the photos BELOW the public root. This script asks you for the path of the Gallery script, and then the image folder name (which it tacks on in the script). So my layout is like this:

/home/g2images
/home/www/gallery2

So when I enter /home/www/gallery2 for the path of the script and then g2images for the image folder, it looks for the images in /home/www/gallery2/g2images. I simply moved the g2images folder temporarily to the gallery2 folder for the import, and then moved it back.

radianation

Does this only import one album at a time? Does it not import users as well?

Aditya Mooley

Yes, only 1 album at a time can be imported.
No, it doesn't import users and any other information.
--- "Its Nice 2 BE Important but its more Important 2 Be NICE" ---
Follow Coppermine on Twitter

radianation

Are there any plans to have a more powerful converter? I have several coppermine galleries and made the mistake of starting a new gallery for a client in Gallery2 instead of Coppermine. Now I want to convert it, but each user has an extensive gallery created with their own files etc, so this converter doesn't really solve my problem.

Aditya Mooley

No plans from me atleast. I am already busy developing Koppermine and Coppermine API.
If someone is interested in extending this, I will provide as much help as I can.
--- "Its Nice 2 BE Important but its more Important 2 Be NICE" ---
Follow Coppermine on Twitter

dianoga7

In 1.4.6, it doesn't seem to be working. It can find the albums and the pictures, but it skips inserting all of the pictures.

Q: SELECT i.*, fs.g_pathComponent, ia.g_viewCount FROM g2_Item i, g2_ChildEntity ce, g2_FileSystemEntity fs, g2_ItemAttributesMap ia WHERE ce.g_id = i.g_id AND i.g_id = fs.g_id AND ia.g_itemId = i.g_id AND ce.g_parentId = '33' AND i.g_canContainChildren = 0

Unable to insert file Alucard-fangs-post.jpg. Skipping...

Unable to insert file alucardavatar.jpg. Skipping...

Unable to insert file Hellsing-01_jpg.jpg. Skipping...

Unable to insert file hellsing.jpg. Skipping...

Unable to insert file hellsing_wallpaper01.jpg. Skipping...

Any ideas?

Aditya Mooley

You are trying to use converter for Gallery 2 for 1.x series. This is not going to work atall. They have started using database from version.
Try using the other converter script http://forum.coppermine-gallery.net/index.php?topic=7992.0 which comes for Gallery 1.4.4
So it may possibly work for your version also.
--- "Its Nice 2 BE Important but its more Important 2 Be NICE" ---
Follow Coppermine on Twitter

dianoga7


Aditya Mooley

So sorry. I thought you are using Gallery 1.4.6 :(
I haven't yet tried to use this converter with cpg 1.4.6
Will have to look into it first.
--- "Its Nice 2 BE Important but its more Important 2 Be NICE" ---
Follow Coppermine on Twitter

Aditya Mooley

Tested with my local setup. There is no change in the converter script. Just the code to Find and Replace the changes has changed a bit.

I have modified the first post and added the code which CPG 1.4.6 users should use. Check it out and let me know whether it works for you.
--- "Its Nice 2 BE Important but its more Important 2 Be NICE" ---
Follow Coppermine on Twitter

dianoga7