Mass Import plugin for cpg1.5.x - Page 3 Mass Import plugin for cpg1.5.x - Page 3
 

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

Mass Import plugin for cpg1.5.x

Started by Joachim Müller, August 19, 2009, 10:27:12 AM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

phill104

Good idea on the PI, I may give that a whirl at the weekend.
It is a mistake to think you can solve any major problems just with potatoes.

ge-flopt

#41
I'm using a Raspberry Pi B (512 MB) it has an external harddisk, and for a "small" (not highly used, personal) coppermine installation, it works nice. :D The one thing that's slow is when you click search and it starts indexing all the words in every record.

Tip. Use Berryboot and an external harddisk. Berryboot boots the pi and then loads everything from the harddisk.

ge-flopt

Well the mass update didn't work as thought. Different PC's and browsers an all stopt working eventually.

Made a php script that imports all the files, checks if the album exist and if not creates it. In about 5 minutes it loaded 5000 images.
The main difference between mass import and my script is that my script is a "hack" and it only works on a directory tree that already was once loaded into a coppermine gallery.

Αndré

Would you be so kind and share your solution with the community? Thanks.

ge-flopt

Quote from: Αndré on July 13, 2015, 12:33:41 PM
Would you be so kind and share your solution with the community? Thanks.
Sure. Shall i place it in here or place it in a new topic?

Αndré

I think it's good placed here as a reply.

ge-flopt

Here it is!
Please note the following:
- Make sure you have a backup of your pictures!
- Use it on your own risk!
- Make sure you have a backup of your pictures!
- Do not use it in a functioning Coppermine installation
- Make sure you have a backup of your pictures!
- It is tested and created to be used with PHP CLI (command line interface) so you need shell access.
- Make sure you have a backup of your pictures!
- Modify the parts of the strings in capital letters to suite your own setup.
- Make sure you have a backup of your pictures!
- Everything will be inserted into the first users account.
- Make sure you have a backup of your pictures!
- I call this a hack because it's not using any CM functionality accept from the config.inc.php and it doesn't check if you have logged in to CM.
- Make sure you have a backup of your pictures!
- I slammed this script up to meet my settings and prefferences, they may not meet yours.
- Make sure you have a backup of your pictures!

Have any questions? Please post, then i'll try to answer them.
Did i already mention: "Make sure you have a backup of your pictures!"?

<?php
include '/FULL PATH TO THE FOLDER WHERE THE NEXT FILE IS LOCATED/config.inc.php';


$CONN mysql_connect($CONFIG["dbserver"],$CONFIG["dbuser"],$CONFIG["dbpass"]) or die ("dead!!");
$searchpath '/FULL PATH OF YOUR COPPERMINE INSTALL/albums/userpics/INCLUDING USERNAME OR ID';
$basepath '/FULL PATH OF YOUR COPPERMINE INSTALL/albums/';
$basealbumpath 'userpics/USERNAME OR ID/';
$it = new RecursiveDirectoryIterator($searchpath);
foreach(new 
RecursiveIteratorIterator($it) as $file
{
/* echo $file . "\n";*/
$shortfile str_replace ($basepath""$file);
if (substr($shortfile, -2) != '/.')
{ if (substr($shortfile, -3) != '/..')
{ $basefile basename($shortfile);
if ((substr($basefile,0,7) != 'normal_') and (substr($basefile,0,6) != 'thumb_')) 
{ $shortdir str_replace("/".$basefile,"",$shortfile);
$albumname str_replace($basealbumpath,""$shortdir);
$file_size filesize($file);
list($width,$height) = getimagesize($file);
$ctime filectime($file);
$NORMAL $searchpath."/".$shortdir."/normal_".$basefile;
$THUMB $searchpath."/".$shortdir."/thumb_".$basefile;
//echo $NORMAL ."\n";
$TOTALFILESIZE $file_size;
if (file_exists($NORMAL))
{ $TOTALFILESIZE $TOTALFILESIZE filesize($NORMAL);
}
if (file_exists($THUMB))
{ $TOTALFILESIZE $TOTALFILESIZE filesize($THUMB);
}
/*
echo "FILE:      ".$file . "\n";
echo "SHORTFILE: ".$shortfile . "\n";
echo "SHORTDIR:  ".$shortdir . "\n";
echo "FILE_SIZE: ".$file_size . "\n";
echo "WIDTH:     ".$width . "\n";
echo "HEIGHT:    ".$height . "\n";
echo "CTIME:     ".$ctime . "\n";
*/
$query 'select aid from `'.$CONFIG["dbname"].'`.'.$CONFIG["TABLE_PREFIX"].'albums where title = "'.$albumname.'"';
//echo $query . "\n";
$albumid mysql_fetch_assoc(mysql_query($query));
if (empty($albumid))
{ echo "Adding folder: ".$shortdir."\n";
$albumcreatequery 'insert into `'.$CONFIG["dbname"].'`.'.$CONFIG["TABLE_PREFIX"].'albums 
(title,description,visibility,uploads,comments,votes,pos,category,owner,thumb,keyword,alb_password,alb_password_hint, moderator_group,alb_hits)
values ("'
.$albumname.'","",0,"NO","YES","YES",1000,10001,1,0,NULL,NULL,NULL,0,0)';
// echo $albumcreatequery . "\n";
mysql_query($albumcreatequery);
$query 'select aid from `'.$CONFIG["dbname"].'`.'.$CONFIG["TABLE_PREFIX"].'albums where title = "'.$albumname.'"';
//echo $query . "\n";
$albumid mysql_fetch_assoc(mysql_query($query));
}
$query 'select pid from `'.$CONFIG["dbname"].'`.'.$CONFIG["TABLE_PREFIX"].'pictures where filepath = "'.$shortdir.'/" and filename = "'.$basefile.'"';
//print $query. "\n";
$pictureid mysql_fetch_assoc(mysql_query($query));
if (empty($pictureid))
{ echo "Adding file  : ".$basefile." - ".$shortdir."\n";
$filecreatequery 'insert into `'.$CONFIG["dbname"].'`.'.$CONFIG["TABLE_PREFIX"].'pictures 
(aid,filepath,filename,filesize,total_filesize,pwidth,pheight,hits,mtime,
ctime,owner_id,pic_rating,votes,title,caption,keywords,approved,galleryicon,
user1,user2,user3,user4,url_prefix,pic_raw_ip, pic_hdr_ip,lasthit_ip,position,guest_token )
values ("'
.$albumid["aid"].'","'.$shortdir.'/","'.$basefile.'","'.$file_size.'","'.$TOTALFILESIZE.'","'.$width.'","'.$height.'",0,"0000-00-00 00:00:00",
"'
.$ctime.'",1,0,0,"","","","YES",0,
"","","","",0,"","",NULL,0,"")'
;
// echo $filecreatequery . "\n";
mysql_query($filecreatequery);
}

}
}
}
}
mysql_close($conn);
?>

   

Surfer2010

Hello,

i tried to use this Plugin, but i had the effekt, that the existing folders were imported as cataloge and album alternating.
Folder1 --> catalog
Folder2 --> album
Folder3 --> catalog
Folder4 --> album ... and so on
Why is this (it's independent of the real file/folder structure.

Is there by now a new Plugin to import an entire file-folder structure? Would be a nice thing to have.

Thanks for your help and reply.

Surfer2010

(otherwise a great tool)

ge-flopt

Please note that my script isn't a plugin. It's just a hack to accommodate to my own preferences.

My script does the following:
Name1/Dir1/Dir2/image1.jpg
It places image1.jpg in folder Dir1/Dir2 for user Name1.

So "real" example:
Michael/2009/vacation/swimming.jpg
Will become:
swimming.jpg in folder 2009/vacation for user Michael

kylemj

Hi,
Hope this is being supported. I used the plugin and it created the album name but didn't add the photos but when going to "sort my pictures" all they photos are in the root directory (select album) but there seems to be no way of deleting them since i cannot access them via the gallery

Αndré

Not sure what happened, it usually seems to work well for other users. If it's a new gallery without any existing data I suggest to start from scratch and try again. You don't need to re-install the gallery in this case, but can just empty the "pictures" table in your MySQL database with a tool like phpMyAdmin. The same applies for the "albums" and "categories" tables.

sokya1

Sorry for reopen old topic but i am new in https://www.mknexusonline.com/cpg/ , I have installed this plugin for import images from my previoushttps://www.mknexusonline.com/gallery/ but when i clicked Mass import its show results 0, kindly advise

Αndré

You need to add the pictures and folders you want to import to Coppermine's albums directory before you start the mass import plugin.


Αndré

Quote from: Αndré on March 14, 2019, 09:31:13 PM
you need to copy the images from your old gallery to Coppermine's "albums" folder and then start to add them to Coppermine either with the mentioned plugin or manually via the batch-add feature.

Hhappy

any chance of this becoming available for 1.6?? Or is current version working with 1.6 as well??

Using the command line version which is super handy with the amount of pictures and folders I have and add.