Advanced search  

News:

cpg1.5.46 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter recently discovered vulnerabilities. It is important that all users who run version cpg1.5.44 or older update to this latest version as soon as possible.
[more]

Pages: 1 2 [3]   Go Down

Author Topic: Mass Import plugin for cpg1.5.x  (Read 54683 times)

0 Members and 2 Guests are viewing this topic.

Phill Luckhurst

  • Administrator
  • Coppermine addict
  • *****
  • Country: gb
  • Offline Offline
  • Gender: Male
  • Posts: 4482
    • Windsurf.me
Re: Mass Import plugin for cpg1.5.x
« Reply #40 on: July 09, 2015, 12:03:07 pm »

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

ge-flopt

  • Contributor
  • Coppermine novice
  • ***
  • Offline Offline
  • Posts: 48
Re: Mass Import plugin for cpg1.5.x
« Reply #41 on: July 09, 2015, 04:27:56 pm »

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.
« Last Edit: July 10, 2015, 12:50:31 pm by ge-flopt »
Logged

ge-flopt

  • Contributor
  • Coppermine novice
  • ***
  • Offline Offline
  • Posts: 48
Re: Mass Import plugin for cpg1.5.x
« Reply #42 on: July 11, 2015, 10:16:19 pm »

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

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15415
Re: Mass Import plugin for cpg1.5.x
« Reply #43 on: July 13, 2015, 12:33:41 pm »

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

ge-flopt

  • Contributor
  • Coppermine novice
  • ***
  • Offline Offline
  • Posts: 48
Re: Re: Mass Import plugin for cpg1.5.x
« Reply #44 on: July 13, 2015, 09:43:27 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?
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15415
Re: Mass Import plugin for cpg1.5.x
« Reply #45 on: July 13, 2015, 10:06:29 pm »

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

ge-flopt

  • Contributor
  • Coppermine novice
  • ***
  • Offline Offline
  • Posts: 48
Re: Mass Import plugin for cpg1.5.x
« Reply #46 on: July 14, 2015, 05:07:18 pm »

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!"?

Code: [Select]
<?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);
?>

   
Logged

Surfer2010

  • Coppermine newbie
  • Offline Offline
  • Posts: 2
Re: Mass Import plugin for cpg1.5.x
« Reply #47 on: December 28, 2015, 04:26:20 pm »

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)
Logged

ge-flopt

  • Contributor
  • Coppermine novice
  • ***
  • Offline Offline
  • Posts: 48
Re: Mass Import plugin for cpg1.5.x
« Reply #48 on: February 23, 2016, 10:08:48 pm »

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
Logged

kylemj

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 25
Re: Mass Import plugin for cpg1.5.x
« Reply #49 on: April 10, 2016, 12:24:05 pm »

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
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15415
Re: Mass Import plugin for cpg1.5.x
« Reply #50 on: April 13, 2016, 11:51:41 am »

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.
Logged
Pages: 1 2 [3]   Go Up
 

Page created in 0.02 seconds with 21 queries.