coppermine-gallery.com/forum

No Support => Modifications/Add-Ons/Hacks => Mods: Convertors => Topic started by: Aditya Mooley on September 16, 2005, 11:09:23 AM

Title: [Outdated]: Menalto Gallery2 To Coppermine Converter
Post by: Aditya Mooley on September 16, 2005, 11:09:23 AM
This converter is outdated. Please use the newer and better converter which is available -> here (http://forum.coppermine-gallery.net/index.php/topic,51300.0.html)

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
Title: Re: Menalto Gallery2 To Coppermine Converter
Post by: Major Headache on October 07, 2005, 10:20:29 AM
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?
Title: Re: Menalto Gallery2 To Coppermine Converter
Post by: Aditya Mooley on October 07, 2005, 10:41:24 AM
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
Title: Re: Menalto Gallery2 To Coppermine Converter
Post by: Major Headache on October 07, 2005, 10:53:54 AM
Grr, sorry I missed that. I will install 1.4 tomorrow and have another go.

Thanks!
Title: Re: Menalto Gallery2 To Coppermine Converter
Post by: Major Headache on October 07, 2005, 07:20:06 PM
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
Title: Re: Menalto Gallery2 To Coppermine Converter
Post by: Enc0der on March 01, 2006, 07:37:58 PM
Hi !

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

thanks!
Title: Re: Menalto Gallery2 To Coppermine Converter
Post by: Aditya Mooley on March 02, 2006, 06:03:52 AM
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.
Title: Re: Menalto Gallery2 To Coppermine Converter
Post by: salewit on March 25, 2006, 06:19:23 AM
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.
Title: Re: Menalto Gallery2 To Coppermine Converter
Post by: Aditya Mooley on March 25, 2006, 07:07:20 AM
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.
Title: Re: Menalto Gallery2 To Coppermine Converter
Post by: salewit on March 25, 2006, 05:41:38 PM
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.
Title: Re: Menalto Gallery2 To Coppermine Converter
Post by: radianation on May 13, 2006, 04:48:51 AM
Does this only import one album at a time? Does it not import users as well?
Title: Re: Menalto Gallery2 To Coppermine Converter
Post by: Aditya Mooley on May 13, 2006, 07:04:36 AM
Yes, only 1 album at a time can be imported.
No, it doesn't import users and any other information.
Title: Re: Menalto Gallery2 To Coppermine Converter
Post by: radianation on May 13, 2006, 09:16:07 AM
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.
Title: Re: Menalto Gallery2 To Coppermine Converter
Post by: Aditya Mooley on May 13, 2006, 09:49:23 AM
No plans from me atleast. I am already busy developing Koppermine (http://koppermine.sf.net) and Coppermine API.
If someone is interested in extending this, I will provide as much help as I can.
Title: Re: Menalto Gallery2 To Coppermine Converter
Post by: dianoga7 on May 22, 2006, 07:23:09 PM
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?
Title: Re: Menalto Gallery2 To Coppermine Converter
Post by: Aditya Mooley on May 23, 2006, 07:10:30 AM
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.
Title: Re: Menalto Gallery2 To Coppermine Converter
Post by: dianoga7 on May 24, 2006, 07:12:54 AM
I am using gallery 2.
Title: Re: Menalto Gallery2 To Coppermine Converter
Post by: Aditya Mooley on May 24, 2006, 07:23:03 AM
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.
Title: Re: Menalto Gallery2 To Coppermine Converter
Post by: Aditya Mooley on May 24, 2006, 08:18:09 AM
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.
Title: Re: Menalto Gallery2 To Coppermine Converter
Post by: dianoga7 on May 24, 2006, 03:18:53 PM
I am still getting the same error.

Import Script: http://www.forsakenwanderers.net/gallery/import_gallery2.php
Gallery 2: http://www.forsakenwanderers.net/gallery2
Path: /home2/forsaken/public_html/gallery2
Title: Re: Menalto Gallery2 To Coppermine Converter
Post by: Aditya Mooley on May 25, 2006, 07:35:05 AM
Import script URL is of no use for us, since it requires ADMIN mode.
The error you are getting is not because of the import script. The add_picture function of Coppermine is unable to put the image in database.
Have you followed the instructions given in my first post? If yes, then you need to debug that function some more and see where exactly it fails.

To start with open include/picmgmt.inc.php
Find

return $result;


and add the following just before it

echo "<br />Adding Picture to database: $query";


Paste the result here.
Title: problem with albums within albums
Post by: anarcat on June 04, 2006, 03:29:28 AM
i had an album named "sansemploi" (nevermind the name) within a "shows" album in gallery. the script couldn't find it. i've done a symlink to workaround the problem, but i think it's a bug.

that's without mentionning the fact it took me around an hour to figure out that the script was failing to copy the images because i didn't setup the images path properly... here's the patch i've applied to the script to debug it:

note the mkdir() && false to avoid panicing when the directory already exists, since i was testing over and over again. :)

@@ -40,7 +40,7 @@
  * This must be the value after last slash.
  * ex. if value is -> /home/httpd/html/gallery2/g2images then enter just -> gallery2
  */
-$galleryAlbPath = "g2images";
+$galleryAlbPath = "../g2data";

pageheader("Import Albums from Menalto Gallery2");
//We need to flush periodically, so output buffering disabled.
@@ -131,7 +131,7 @@
   }

   list($galAlbum, $albumName)= explode ('^', $_POST['galAlbum']);
-  if (!@mkdir ($CONFIG['fullpath']."/".$albumName, 0777)) {
+  if (!@mkdir ($CONFIG['fullpath']."/".$albumName, 0777) && false) {
     echo "<br />Unable to create album directory. Directory with the same name <b>".$CONFIG['fullpath'].$albumName."</b> already exists. Exiting ...<br />";
     endtable();
     pagefooter();
@@ -179,21 +179,25 @@
     }
     while ($row = mysql_fetch_array($result)) {
       $itemid = $row["{$cp}id"];
-      $imageFullName = $row["{$cp}pathComponent"];
-      $imageTitle = $row["{$cp}title"];
-      $imageCaption = $row["{$cp}description"];
+      $imageFullName = addslashes($row["{$cp}pathComponent"]);
+      $imageTitle = addslashes($row["{$cp}title"]);
+      $imageCaption = addslashes($row["{$cp}description"]);
       $viewCount = $row["{$cp}viewCount"];

       $source = "$galleryPath/$galleryAlbPath/albums/";
       $source .= ($albumName != 'Base') ? "$albumName/" : '';
       $source .= $imageFullName;
       $target = $CONFIG['fullpath'].$albumName."/$imageFullName";
-      //echo "<BR>IMAGE: SRC -> $source&nbsp;&nbsp;&nbsp;TGT -> $target<BR>";
+      echo "<BR>IMAGE: SRC -> $source&nbsp;&nbsp;&nbsp;TGT -> $target<BR>";
       flush();

-      @copy($source, $target);
+      if (!copy($source, $target)) {
+       echo "failed to copy $source to $target";
+      }

       //Call add_picture
+      flush();
+     
       $result1 = add_picture ($aid, $albumName."/", $imageFullName, '', $imageTitle, $imageCaption, $imageKeywords, '', '', '', '', 0, $raw_ip, $hdr_ip, $viewCount);

       if ($result1) {
Title: Re: Menalto Gallery2 To Coppermine Converter
Post by: radianation on September 06, 2006, 04:15:52 AM
What if I've since bridged G2 to Joomla? Can I use Coppermine bridge with Joomla to resync the users?
Title: Re: Menalto Gallery2 To Coppermine Converter
Post by: Aditya Mooley on September 06, 2006, 12:06:35 PM
This convertor doesn't resync users. It copies albums in G2 to Coppermine.
If you are looking for something different then start a new thread in a relevant board.
Title: Re: Menalto Gallery2 To Coppermine Converter
Post by: salewit on October 16, 2006, 03:22:32 AM
Not sure why nobody spotted this. I've got Gallery 2.1.2 and Coppermine 1.4.9.

The script can't find ANY images. When I turn on debug mode, I see that it's looking in the wrong place. My Gallery site has albums WITHIN albums and stores folders within folders, but this script is always looking in the root of the give data folder.


g2data/albums/MainAlbum1
g2data/albums/MainAlbum1/SubsetAlbums1
g2data/albums/MainAlbum1/SubsetAlbums2
g2data/albums/MainAlbum1/SubsetAlbums3
g2data/albums/MainAlbum2
g2data/albums/MainAlbum2/SubsetAlbums1
g2data/albums/MainAlbum2/SubsetAlbums2
etc.

But the script is looking for the images as:

g2data/albums/MainAlbum1
g2data/albums/SubsetAlbums1
g2data/albums/SubsetAlbums2
g2data/albums/SubsetAlbums3
g2data/albums/MainAlbum2
g2data/albums/SubsetAlbums1
g2data/albums/SubsetAlbums2
etc.



Warning line 194: copy(/home/www/gallery2/g2data/albums/USRailroads/3644.jpg) [function.copy]: failed to open stream: No such file or directory

^ The "USRailroads" album is under the "WorldRailroads", so the above line should read:
copy(/home/www/gallery2/g2data/albums/WorldRailroads/USRailroads/3644.jpg)

Maybe Gallery changed their ways. Any easy fix for this?
Title: Re: Menalto Gallery2 To Coppermine Converter
Post by: running_around on October 26, 2006, 09:51:37 PM
This is a very basic question. I have made the changes to the code, as suggested, and then what? How do I actually run this script? Nothing happens when I log in as admin. Where do I go? Anyone?
Title: Re: Menalto Gallery2 To Coppermine Converter
Post by: Aditya Mooley on October 27, 2006, 06:56:53 AM
Run the script by typing the URL in the address bar like -> http://yourdomain.com/cpginstall/import_gallery2.php
Title: Re: Menalto Gallery2 To Coppermine Converter
Post by: iwindsurf.co.uk on December 23, 2006, 05:35:02 PM
Quote from: salewit on October 16, 2006, 03:22:32 AM

The script can't find ANY images. When I turn on debug mode, I see that it's looking in the wrong place. My Gallery site has albums WITHIN albums and stores folders within folders, but this script is always looking in the root of the give data folder.

I am finding that I have to move all my galleries in gallery2 up to the root/base gallery before they will succesfully import - I intend to have a mooch through the code to see if I can find a way of altering it as I have quite a few levels of galleries....
will report back here if I am successful

I also changed the code for the albums drop down menu as the importer was using the album name which used to be the directory name in gallery 1.5 - eg album14 when all the views in the actual gallery quote the title - making it hard to know which gallery you were selecting....

new code almost at bottom of the file....

$query = "SELECT i.{$cp}id, i.{$cp}title, fs.{$cp}pathComponent
            FROM
              {$tp}Item i, {$tp}FileSystemEntity fs
            WHERE
              i.{$cp}canContainChildren = 1 AND
              i.{$cp}id = fs.{$cp}id
           ";
  $result = mysql_query($query, $link);
  $albumArr[$parentAlbum] = 'Base';
  $optionStr = '';
  while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
    $albumName = $row[2] ? $row[2] : 'Base';
    $albumTitle = $row[1] ? $row[1] : 'Base';
$optionStr .= "<option value='$row[0]^$albumName'>$albumTitle</option>";
  }
Title: Re: Menalto Gallery2 To Coppermine Converter
Post by: iwindsurf.co.uk on December 24, 2006, 05:23:54 PM
I have now made further alterations to the file so that it will import sub albums from gallery2 into the root/base of coppermine  :)
I'm sure it's the worst code you've ever seen but it seems to be functioning  ::) - after all I only need to use it this once and hopefully never again....
I have included most of the alterations described above. 
Title: Re: Menalto Gallery2 To Coppermine Converter
Post by: ncvettes on January 23, 2007, 01:54:16 AM
Will this work for 1.4.10?

iwindsurf: Have the issues been completely resolved for locating albums?

And lastly: G2's album structure is great (creates folder names of all albums from title...great for organizing/archiving stuff). Will this converter retain those user's directory names?

Tnx in advance.
Title: Re: Menalto Gallery2 To Coppermine Converter
Post by: SlaveToThis on April 09, 2007, 09:18:29 AM
I have 1.4.10 and Gallery2.1 and cannot get the convertor to work.
What happens is when I try and enter the path it just goes back to that screen again.

I'm not sure what it is looking for but it obviously doesn't seem to find it.
Title: Re: Menalto Gallery2 To Coppermine Converter
Post by: Aditya Mooley on April 10, 2007, 07:02:31 AM
Not yet tested with both these versions yet. So can't say anything right now. Will have to check it first.
Title: Re: Menalto Gallery2 To Coppermine Converter
Post by: alienex on April 15, 2007, 11:55:59 PM
Hi there!

Would be very interested in this as well. The script just reloads currently with 1.4.10

Thanks
Title: Re: Menalto Gallery2 To Coppermine Converter
Post by: Poncherelly on August 21, 2007, 06:45:23 PM
Quote from: radianation on May 13, 2006, 09:16:07 AM
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.

Sorry if this is clearer to others, but will this importer tool import just the top layer or all layers beneath?
eg
Main
-->Album1
          -->subalbum1
          -->subalbum2
-->Album2
          -->subalbum3
          -->subalbum3

Will this import every album under main or do I have to perform the import for each album within the album?
Title: Re: Menalto Gallery2 To Coppermine Converter
Post by: Alan S on December 10, 2007, 08:47:41 PM
I keep getting errors when trying to convert G2 to Coppermine.


I have the script set up correctly and the correct edits to the files ( Well not the exact ones since some of the code did not match )

In the picmgmt.inc.php file i found

$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 it 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')";
   


Which isnt the exact instruction but it was the closest code i could find.

I am using the latest version of coppermine , And G2

When i try to import any album i get

QuoteAlbum directory trugrit_gallery created...
parent filepath =

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 = '19' AND i.g_canContainChildren = 0

IMAGE: SRC -> /kunden/homepages/34/d118462030/htdocs/html/G2/gallery2//homepages/34/d118462030/htdocs/html/G2_data//albums//trugrit_gallery/mini-_POR5630.JPG   TGT -> albums/trugrit_gallery/mini-_POR5630.JPG
failed to copy /kunden/homepages/34/d118462030/htdocs/html/G2/gallery2//homepages/34/d118462030/htdocs/html/G2_data//albums//trugrit_gallery/mini-_POR5630.JPG to albums/trugrit_gallery/mini-_POR5630.JPG
Unable to insert file mini-_POR5630.JPG. Skipping...

IMAGE: SRC -> /kunden/homepages/34/d118462030/htdocs/html/G2/gallery2//homepages/34/d118462030/htdocs/html/G2_data//albums//trugrit_gallery/resized_POR5702.jpg   TGT -> albums/trugrit_gallery/resized_POR5702.jpg
failed to copy /kunden/homepages/34/d118462030/htdocs/html/G2/gallery2//homepages/34/d118462030/htdocs/html/G2_data//albums//trugrit_gallery/resized_POR5702.jpg to albums/trugrit_gallery/resized_POR5702.jpg
Unable to insert file resized_POR5702.jpg. Skipping...

IMAGE: SRC -> /kunden/homepages/34/d118462030/htdocs/html/G2/gallery2//homepages/34/d118462030/htdocs/html/G2_data//albums//trugrit_gallery/resized_POR5646.jpg   TGT -> albums/trugrit_gallery/resized_POR5646.jpg
failed to copy /kunden/homepages/34/d118462030/htdocs/html/G2/gallery2//homepages/34/d118462030/htdocs/html/G2_data//albums//trugrit_gallery/resized_POR5646.jpg to albums/trugrit_gallery/resized_POR5646.jpg
Unable to insert file resized_POR5646.jpg. Skipping...

IMAGE: SRC -> /kunden/homepages/34/d118462030/htdocs/html/G2/gallery2//homepages/34/d118462030/htdocs/html/G2_data//albums//trugrit_gallery/_POR5503 _402 x 601_.jpg   TGT -> albums/trugrit_gallery/_POR5503 _402 x 601_.jpg
failed to copy /kunden/homepages/34/d118462030/htdocs/html/G2/gallery2//homepages/34/d118462030/htdocs/html/G2_data//albums//trugrit_gallery/_POR5503 _402 x 601_.jpg to albums/trugrit_gallery/_POR5503 _402 x 601_.jpg
Unable to insert file _POR5503 _402 x 601_.jpg. Skipping...


Successfully imported album trugrit_gallery from Gallery2 to Coppermine

There are plenty more of the "Unable to insert file errors" but i cut it down because of the max post restriction on these forums.

Help would be appreciated!

- Alan S
Title: Re: Menalto Gallery2 To Coppermine Converter
Post by: nickjo on March 11, 2008, 06:05:46 PM
Has anybody found a solution?
Title: Re: Menalto Gallery2 To Coppermine Converter
Post by: Aditya Mooley on March 11, 2008, 07:03:13 PM
Post your Gallery and Coppermine versions. I will see if I can do something.
Title: Re: Menalto Gallery2 To Coppermine Converter
Post by: nickjo on March 11, 2008, 08:33:41 PM
The Gallery is version 2.0

==========================
VERSION INFO :
------------------
PHP version: 4.4.7 - OK
------------------
mySQL version: 4.1.22-standard-log
------------------
Coppermine version: 1.4.16(stable)
==========================
Module: GD
------------------
GD Version: bundled (2.0.28 compatible)
FreeType Support: 1
FreeType Linkage: with freetype
T1Lib Support:
GIF Read Support: 1
GIF Create Support: 1
JPG Support: 1
PNG Support: 1
WBMP Support: 1
XBM Support: 1
JIS-mapped Japanese Font Support:
Title: Re: Menalto Gallery2 To Coppermine Converter
Post by: nickjo on March 11, 2008, 08:35:15 PM
To be specific:

Gallery version = 2.2.1 core 1.2.0.1
Title: Re: [Outdated]: Menalto Gallery2 To Coppermine Converter
Post by: Aditya Mooley on March 21, 2008, 07:26:18 AM
The new converter is available for download (http://forum.coppermine-gallery.net/index.php/topic,51300.0.html) now.