1
sailjapan
Moving pics from one site's image manager to another...

Hi all, and a very happy new year to you. It's great to see that XOOPS is progressing steadily.

I was wondering, is there a way to move all the images and their description along with the categories from a site's image manager to the image manager of another site?
I know that the files themselves are stored in /uploads , but I don't really want to have to upload them individually and type in all the descriptions again...

Any hints? (I have the suspicion I'd need to mess around with PHPadmin and mySQl, but don't know where to start with that. Be gentle with me!).

I'm running xoops 2.5.0 on both sites, if that helps.

Yoroshiku!
Never let a man who does not believe something can be done, talk to a man that is doing it.

2
Mamba
Re: Moving pics from one site's image manager to another...
  • 2011/1/8 14:27

  • Mamba

  • Moderator

  • Posts: 11409

  • Since: 2004/4/23


Good to see you around, my friend!

How is sailing in Japan?

I think, it will be "image" and "image_category" tables, so yes, you'll need to deal with phpMyAdmin
Support XOOPS => DONATE
Use 2.5.11 | Docs | Modules | Bugs

3
sailjapan
Re: Moving pics from one site's image manager to another...

Sailing's good, thanks. A bit chilly, but the winds are blowing nicely

So, using phpadmin, I exported the image and image_category 'tables' (is that what they are called?) from the old site, and imported them to the new site. I then dropped the existing 'tables', renamed the ones I'd imported to have the right prefix, uploaded all the files to uploads/images/ directory, updated the system module and lo-and-behold...

a blank image manager.

No categories, no pics.

What am I missing?
Never let a man who does not believe something can be done, talk to a man that is doing it.

4
Mamba
Re: Moving pics from one site's image manager to another...
  • 2011/1/8 18:04

  • Mamba

  • Moderator

  • Posts: 11409

  • Since: 2004/4/23


Did you clear your cache?

Maybe you need to update your System module?

Without looking at the code I can't tell you more...
Support XOOPS => DONATE
Use 2.5.11 | Docs | Modules | Bugs

5
sailjapan
Re: Moving pics from one site's image manager to another...

Hey Mamba, thanks for the quick response.

Yup, both cleared caches, and updated the system. Also ran the table maintenance checks/optimisation stuff and emptied the session in the xoops control panel. All came through with green checks, but still no joy.

Maybe I should wait for ghia or some other sql superhero to come on line.

What code would be helpful to see, btw?
Never let a man who does not believe something can be done, talk to a man that is doing it.

6
Mamba
Re: Moving pics from one site's image manager to another...
  • 2011/1/8 18:59

  • Mamba

  • Moderator

  • Posts: 11409

  • Since: 2004/4/23


I guess, the imagemanager.php in the main directory.
Support XOOPS => DONATE
Use 2.5.11 | Docs | Modules | Bugs

7
dbman
Re: Moving pics from one site's image manager to another...
  • 2011/1/8 19:45

  • dbman

  • Friend of XOOPS

  • Posts: 172

  • Since: 2005/4/28


If the databases are on the same host you could use this for image category records:

INSERT INTO database1.table1_imagecategory (imgcat_nameimgcat_maxsizeimgcat_maxwidthimgcat_maxheightimgcat_displayimgcat_weightimgcat_typeimgcat_storetypeSELECT imgcat_idimgcat_nameimgcat_maxsizeimgcat_maxwidthimgcat_maxheightimgcat_displayimgcat_weightimgcat_typeimgcat_storetype FROM database2.table2_imagecategory;


and this for the image records:
INSERT INTO database1.table1_image (image_idimage_nameimage_nicenameimage_mimetypeimage_createdimage_displayimage_weightimgcat_idSELECT image_idimage_nameimage_nicenameimage_mimetypeimage_createdimage_displayimage_weightimgcat_id FROM database2.table2_image;


If both databases are not accessible via sql, you may need to export and load using a csv file or a temporary table in your current database.

Note:
- database1 = your new xoops install
- table1 = your new table prefix
- database2= your old xoops install
- table2 = your old table prefix




8
sailjapan
Re: Moving pics from one site's image manager to another...

Thanks for the ideas.

What I did was (via phpadmin) a 'table' export/import.

I can see the 2 'tables' & their constituent 'records' in the new site's db and, to me at least, they appear identical to the ones I exported from the old db.

I think that what I've done is to correctly import the data to the new db, the trouble is that the new install of xoops isn't 'reading' them yet. I may be wrong, of course! Nothing new in that

Here's the code from the file (imagemanager.php) that Mamba asked for:
/**
3  * XOOPS image manager
4  *
5  * You may not change or alter any portion of this comment or credits
6  * of supporting developers from this source code or any supporting source code
7  * which is considered copyrighted (c) material of the original comment or credit authors.
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11  *
12  * @copyright       The XOOPS Project http://sourceforge.net/projects/xoops/
13  * @license         GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
14  * @package         core
15  * @since           2.0.0
16  * @version         $Id: imagemanager.php 4941 2010-07-22 17:13:36Z beckmi $
17  */
18 
19 
include dirname(__FILE__) . DIRECTORY_SEPARATOR 'mainfile.php';
20 
21 
if (!isset($_REQUEST['target'])) {
22     exit('Target not set');
23 }
24 
25 $target 
$_REQUEST['target'];
26 $op 'list';
27 if (isset($_GET['op']) && $_GET['op'] == 'upload') {
28     $op 'upload';
29 } elseif (isset($_POST['op']) && $_POST['op'] == 'doupload') {
30     $op 'doupload';
31 }
32 
33 
if (!is_object($xoopsUser)) {
34     $group = array(XOOPS_GROUP_ANONYMOUS);
35 } else {
36     $group $xoopsUser->getGroups();
37 }
38 if ($op == 'list') {
39     require_once $GLOBALS['xoops']->path('class/template.php');
40     $xoopsTpl = new XoopsTpl();
41     $xoopsTpl->assign('lang_imgmanager'_IMGMANAGER);
42     $xoopsTpl->assign('sitename'htmlspecialchars($xoopsConfig['sitename'], ENT_QUOTES));
43     $target htmlspecialchars($targetENT_QUOTES);
44     $xoopsTpl->assign('target'$target);
45     $imgcat_handler =& xoops_gethandler('imagecategory');
46     $catlist =& $imgcat_handler->getList($group'imgcat_read'1);
47     $catcount count($catlist);
48     $xoopsTpl->assign('lang_align'_ALIGN);
49     $xoopsTpl->assign('lang_add'_ADD);
50     $xoopsTpl->assign('lang_close'_CLOSE);
51     if ($catcount 0) {
52         $xoopsTpl->assign('lang_go'_GO);
53         $catshow = (!isset($_GET['cat_id'])) ? intval($_GET['cat_id']);
54         $catshow = (!empty($catshow) && in_array($catshowarray_keys($catlist))) ? $catshow 0;
55         $xoopsTpl->assign('show_cat'$catshow);
56         if ($catshow 0) {
57             $xoopsTpl->assign('lang_addimage'_ADDIMAGE);
58         }
59         $catlist = array('0' => '--') + $catlist;
60         $cat_options '';
61         foreach ($catlist as $c_id => $c_name) {
62             $sel '';
63             if ($c_id == $catshow) {
64                 $sel ' selected="selected"';
65             }
66             $cat_options .= '$c_id '"' $sel '>' $c_name '';
67         }
68         $xoopsTpl->assign('cat_options'$cat_options);
69         if ($catshow 0) {
70             $image_handler =& xoops_gethandler('image');
71             $criteria = new CriteriaCompo(new Criteria('imgcat_id'$catshow));
72             $criteria->add(new Criteria('image_display'1));
73             $total $image_handler->getCount($criteria);
74             if ($total 0) {
75                 $imgcat_handler =& xoops_gethandler('imagecategory');
76                 $imgcat =& $imgcat_handler->get($catshow);
77                 $xoopsTpl->assign('image_total'$total);
78                 $xoopsTpl->assign('lang_image'_IMAGE);
79                 $xoopsTpl->assign('lang_imagename'_IMAGENAME);
80                 $xoopsTpl->assign('lang_imagemime'_IMAGEMIME);
81                 $start = isset($_GET['start']) ? intval($_GET['start']) : 0;
82                 $criteria->setLimit(10);
83                 $criteria->setStart($start);
84                 $storetype $imgcat->getVar('imgcat_storetype');
85                 if ($storetype == 'db') {
86                     $criteria->setSort('i.image_weight ASC, i.image_id');
87                     $criteria->setOrder('DESC');
88                     $images $image_handler->getObjects($criteriafalsetrue);
89                 } else {
90                     $criteria->setSort('image_weight ASC, image_id');
91                     $criteria->setOrder('DESC');
92                     $images $image_handler->getObjects($criteriafalsefalse);
93                 }
94                 $imgcount count($images);
95                 $max = ($imgcount 10) ? 10 $imgcount;
96 
97                 
for ($i 0$i $max$i++) {
98                     if ($storetype == 'db') {
99                         $lcode '[img align=left id=' $images[$i]->getVar('image_id') . ']' $images[$i]->getVar('image_nicename') . '[/img]';
100                         $code  '[img align=center id=' $images[$i]->getVar('image_id') . ']' $images[$i]->getVar('image_nicename') . '[/img]';
101                         $rcode '[img align=right id=' $images[$i]->getVar('image_id') . ']' $images[$i]->getVar('image_nicename') . '[/img]';
102                         $src   XOOPS_URL "/image.php?id=" $images[$i]->getVar('image_id');
103                     } else {
104                         $lcode '[img align=left]' XOOPS_UPLOAD_URL '/' $images[$i]->getVar('image_name') . '[/img]';
105                         $code  '[img align=center]' XOOPS_UPLOAD_URL '/' $images[$i]->getVar('image_name') . '[/img]';
106                         $rcode '[img align=right]' XOOPS_UPLOAD_URL '/' $images[$i]->getVar('image_name') . '[/img]';
107                         $src   XOOPS_UPLOAD_URL '/' $images[$i]->getVar('image_name');
108                     }
109                     $xoopsTpl->append('images', array('id' => $images[$i]->getVar('image_id'), 'nicename' => $images[$i]->getVar('image_nicename'), 'mimetype' => $images[$i]->getVar('image_mimetype'), 'src' => $src'lxcode' => $lcode'xcode' => $code'rxcode' => $rcode));
110                 }
111                 if ($total 10) {
112                     include_once $GLOBALS['xoops']->path('class/pagenav.php');
113                     $nav = new XoopsPageNav($total10$start'start''target='.$target.'&cat_id='.$catshow);
114                     $xoopsTpl->assign('pagenav'$nav->renderNav());
115                 }
116             } else {
117                 $xoopsTpl->assign('image_total'0);
118             }
119         }
120         $xoopsTpl->assign('xsize'600);
121         $xoopsTpl->assign('ysize'400);
122     } else {
123         $xoopsTpl->assign('xsize'400);
124         $xoopsTpl->assign('ysize'180);
125     }
126     $xoopsTpl->display('db:system_imagemanager.html');
127     exit();
128 }
129 
130 
if ($op == 'upload') {
131     $imgcat_handler =& xoops_gethandler('imagecategory');
132     $imgcat_id intval($_GET['imgcat_id']);
133     $imgcat =& $imgcat_handler->get($imgcat_id);
134     $error false;
135     if (!is_object($imgcat)) {
136         $error true;
137     } else {
138         $imgcatperm_handler =& xoops_gethandler('groupperm');
139         if (is_object($xoopsUser)) {
140             if (! $imgcatperm_handler->checkRight('imgcat_write'$imgcat_id$xoopsUser->getGroups())) {
141                 $error true;
142             }
143         } else {
144             if (! $imgcatperm_handler->checkRight('imgcat_write'$imgcat_idXOOPS_GROUP_ANONYMOUS)) {
145                 $error true;
146             }
147         }
148     }
149     if ($error != false) {
150         xoops_header(false);
151         echo '._BACK.'" type="button" onclick="javascript:history.go(-1);" />
';
152         xoops_footer();
153         exit();
154     }
155     require_once $GLOBALS['xoops']->path('class/template.php');
156     $xoopsTpl = new XoopsTpl();
157     $xoopsTpl->assign('show_cat'$imgcat_id);
158     $xoopsTpl->assign('lang_imgmanager'_IMGMANAGER);
159     $xoopsTpl->assign('sitename'htmlspecialchars($xoopsConfig['sitename'], ENT_QUOTES));
160     $xoopsTpl->assign('target'htmlspecialchars($_GET['target'], ENT_QUOTES));
161     include_once $GLOBALS['xoops']->path('class/xoopsformloader.php');
162     $form = new XoopsThemeForm('''image_form''imagemanager.php''post'true);
163     $form->setExtra('enctype="multipart/form-data"');
164     $form->addElement(new XoopsFormText(_IMAGENAME'image_nicename'20255), true);
165     $form->addElement(new XoopsFormLabel(_IMAGECAT$imgcat->getVar('imgcat_name')));
166     $form->addElement(new XoopsFormFile(_IMAGEFILE'image_file'$imgcat->getVar('imgcat_maxsize')), true);
167     $form->addElement(new XoopsFormLabel(_IMGMAXSIZE$imgcat->getVar('imgcat_maxsize')));
168     $form->addElement(new XoopsFormLabel(_IMGMAXWIDTH$imgcat->getVar('imgcat_maxwidth')));
169     $form->addElement(new XoopsFormLabel(_IMGMAXHEIGHT$imgcat->getVar('imgcat_maxheight')));
170     $form->addElement(new XoopsFormHidden('imgcat_id'$imgcat_id));
171     $form->addElement(new XoopsFormHidden('op''doupload'));
172     $form->addElement(new XoopsFormHidden('target'$target));
173     $form->addElement(new XoopsFormButton('''img_button'_SUBMIT'submit'));
174     $form->assign($xoopsTpl);
175     $xoopsTpl->assign('lang_close'_CLOSE);
176     $xoopsTpl->display('db:system_imagemanager2.html');
177     exit();
178 }
179 
180 
if ($op == 'doupload') {
181     if ($GLOBALS['xoopsSecurity']->check()) {
182         $image_nicename = isset($_POST['image_nicename']) ? $_POST['image_nicename'] : '';
183         $xoops_upload_file = isset($_POST['xoops_upload_file']) ? $_POST['xoops_upload_file'] : array();
184         $imgcat_id = isset($_POST['imgcat_id']) ? intval($_POST['imgcat_id']) : 0;
185         include_once $GLOBALS['xoops']->path('class/uploader.php');
186         $imgcat_handler =& xoops_gethandler('imagecategory');
187         $imgcat =& $imgcat_handler->get($imgcat_id);
188         $error false;
189         if (!is_object($imgcat)) {
190             $error true;
191         } else {
192             $imgcatperm_handler =& xoops_gethandler('groupperm');
193             if (is_object($xoopsUser)) {
194                 if (!$imgcatperm_handler->checkRight('imgcat_write'$imgcat_id$xoopsUser->getGroups())) {
195                     $error true;
196                 }
197             } else {
198                 if (!$imgcatperm_handler->checkRight('imgcat_write'$imgcat_idXOOPS_GROUP_ANONYMOUS)) {
199                     $error true;
200                 }
201             }
202         }
203     }
204     else {
205         $error true;
206     }
207     if ($error != false) {
208         xoops_header(false);
209         echo 'implode(''$GLOBALS['xoopsSecurity']->getErrors()) . '_BACK '" type="button" onclick="javascript:history.go(-1);" />
';
210         xoops_footer();
211         exit();
212     }
213     $uploader = new XoopsMediaUploader(XOOPS_UPLOAD_PATH, array('image/gif''image/jpeg''image/pjpeg''image/x-png''image/png'), $imgcat->getVar('imgcat_maxsize'), $imgcat->getVar('imgcat_maxwidth'), $imgcat->getVar('imgcat_maxheight'));
214     $uploader->setPrefix('img');
215     if ($uploader->fetchMedia($xoops_upload_file[0])) {
216         if (!$uploader->upload()) {
217             $err $uploader->getErrors();
218         } else {
219             $image_handler =& xoops_gethandler('image');
220             $image =& $image_handler->create();
221             $image->setVar('image_name'$uploader->getSavedFileName());
222             $image->setVar('image_nicename'$image_nicename);
223             $image->setVar('image_mimetype'$uploader->getMediaType());
224             $image->setVar('image_created'time());
225             $image->setVar('image_display'1);
226             $image->setVar('image_weight'0);
227             $image->setVar('imgcat_id'$imgcat_id);
228             if ($imgcat->getVar('imgcat_storetype') == 'db') {
229                 $fp = @fopen($uploader->getSavedDestination(), 'rb');
230                 $fbinary = @fread($fpfilesize($uploader->getSavedDestination()));
231                 @fclose($fp);
232                 $image->setVar('image_body'$fbinarytrue);
233                 @unlink($uploader->getSavedDestination());
234             }
235             if (!$image_handler->insert($image)) {
236                 $err sprintf(_FAILSAVEIMG$image->getVar('image_nicename'));
237             }
238         }
239     } else {
240         $err sprintf(_FAILFETCHIMG0);
241         $err .= 'implode(''$uploader->getErrors(false));
242     }
243     if (isset($err)) {
244         xoops_header(false);
245         xoops_error($err);
246         echo '_BACK '" type="button" onclick="javascript:history.go(-1);" />
';
247         xoops_footer();
248         exit();
249     }
250     header('location: imagemanager.php?cat_id=' $imgcat_id '&target=' $target);
251 }
252 
253 ?>


Hope this helps
Never let a man who does not believe something can be done, talk to a man that is doing it.

9
sailjapan
Re: Moving pics from one site's image manager to another...

friendly bump
Never let a man who does not believe something can be done, talk to a man that is doing it.

10
sailjapan
Re: Moving pics from one site's image manager to another...

Ok, how about if I phrase the question differently:

Are there any tables other than xxx_image and xxx_imagecategory that I need to import to my db when transferring files from one image-manager to another? Do I need to find/edit/import something that refers to permissions, for example?
Another possibility, should I have created the categories in the new image-manager before importing the files?

Hope someone can help...

TIA
Never let a man who does not believe something can be done, talk to a man that is doing it.

Login

Who's Online

154 user(s) are online (91 user(s) are browsing Support Forums)


Members: 0


Guests: 154


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Dec 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits