1
vinit
How to add avatars in bulk
  • 2004/6/20 16:52

  • vinit

  • Just can't stay away

  • Posts: 530

  • Since: 2004/1/10


hi i have more than 100 avatars for users that i would like to add. it would be a painful task to do manually.

i have avtars from fi_av_smiles_y_1.png to fi_av_smiles_y_100.png how can i add all of them at one go

2
Mikhail
Re: How to add avatars in bulk
  • 2004/6/20 17:16

  • Mikhail

  • Just can't stay away

  • Posts: 412

  • Since: 2003/1/19



3
vinit
Re: How to add avatars in bulk
  • 2004/6/20 17:17

  • vinit

  • Just can't stay away

  • Posts: 530

  • Since: 2004/1/10


Got this script from some earlier post at https://xoops.org/modules/newbb/viewtopic.php?topic_id=18677&forum=7#forumpost79400

include mainfile.php
$avatars = [Number of avatars] //write a number here
for ($i = 0; $i < $avatars; $i++) {
$k = $i;
if ($i < 100) { //add one zero in front of number
$k = "0".$k;
}
if ($i < 10) { //add another zero
$k = "0".$k;
}
$xoopsDB->query("INSERT INTO ".$xoopsDB->prefix("avatar")." VALUES ('ava$k.gif', 'ava$k', 'image/gif', ".time().", 1,0,'C')");
echo "ava$k inserted";
}
include footer.php
?>

I modified it as per my needs into

include '../../mainfile.php';
$avatars = 70; //write a number here
for ($i = 0; $i < $avatar ; $i++) {
$k = $i;
if ($i < 100) { //add one zero in front of number
$k = "0".$k;
}
if ($i < 10) { //add another zero
$k = "0".$k;
}
$xoopsDB->query("INSERT INTO ".$xoopsDB->prefix("avatar")." VALUES ('fi_av_smiles_y_$k.png', 'fi_av_smiles_y_$k', 'image/png', ".time().", 1,0,'C')");
echo "fi_av_smiles_y_$k inserted";
}
include '../../footer.php';
?>

I have my avatars kept in uploads/avtars directory
I kept this file in the same folder (uploads/avtars), but had no success.. got a blank page nothing more.

Any idea whats going sron in here....

4
vinit
Re: How to add avatars in bulk
  • 2004/6/20 18:21

  • vinit

  • Just can't stay away

  • Posts: 530

  • Since: 2004/1/10



5
sottwell
Re: How to add avatars in bulk
  • 2004/7/3 9:18

  • sottwell

  • Just popping in

  • Posts: 30

  • Since: 2004/6/23


use phpmyadmin or some other MySQL administration tool. With phpmyadmin, select your database from the choices on the left (possibly only one database and it will already be selected), select the xoops_avatars table, then select the SQL tab. Use the file selection field and browse to the .sql file on your machine. This will set all the files to be in the uploads directory, so using your ftp client or whatever means you have of uploading files to your site, dump all the images into your uploads directory.

Keep in mind that the filename can only be 30 characters; if you've created an avatars directory that part of the path must be added to the filename in the database; you can do a "find/change all" of the .sql file in any text editor to add the avatars/ part to the filename, but it will make the filenames too long with this particular package. Oddly, it was exactly 4 characters too long, causing the .jpg to be truncated, and the avatars still worked on my local system (Apache/OS X) but failed on my remote hosted site (Apache/Linux).

6
traysee
Re: How to add avatars in bulk
  • 2006/10/22 20:36

  • traysee

  • Just popping in

  • Posts: 12

  • Since: 2005/2/5 1


You can write a SQL script and run it from PHPAdmin:

Here's an example of the SQL script: Remember that the file name (the 2nd field) is limited to 30 characters.

INSERT INTO `xoops_avatar` VALUES (001,www.xoops.net.br-001.jpg,Avatar-001,image/jpeg,1000000000,1,1,S,);
INSERT INTO `xoops_avatar` VALUES (002,www.xoops.net.br-002.jpg,Avatar-002,image/jpeg,1000000000,1,1,S,);
INSERT INTO `xoops_avatar` VALUES (003,www.xoops.net.br-003.jpg,Avatar-003,image/jpeg,1000000000,1,1,S,);
INSERT INTO `xoops_avatar` VALUES (004,www.xoops.net.br-004.jpg,Avatar-004,image/jpeg,1000000000,1,1,S,);
INSERT INTO `xoops_avatar` VALUES (005,www.xoops.net.br-005.jpg,Avatar-005,image/jpeg,1000000000,1,1,S,);


To run it in PHPAdmin - do the following:

1. Make sure that all avatars are in the UPLOAD directory
2. Log into website as Web Administrator
3. Go to Administration Menu
4. Go to PHP myadmin module
5. Expand the Database
6. Select xoops_avatar Table
7. Select the SQL tab
8. Click on the "Insert data from a textfile into table" link
9. Browse to find the SQL file you created
10. Check the Replace box
11. Change the Fields terminated by to: ,
12. Clear the Fields enclosed by field
13. Clear the Fields escaped by field
14. Change the Lines terminated by to: ;
15. Click the Submit button
16. Check to make sure it worked.

7
Speed
Re: How to add avatars in bulk
  • 2006/10/22 21:31

  • Speed

  • Quite a regular

  • Posts: 310

  • Since: 2004/5/18


I use GIJOE's Avaman module myself. It's on the second page of his downloads. It also allows for smiley installation. You can upload single files or bulk.

http://www.peak.ne.jp/xoops/md/mydownloads/viewcat.php?cid=1
...

Login

Who's Online

298 user(s) are online (209 user(s) are browsing Support Forums)


Members: 0


Guests: 298


more...

Donat-O-Meter

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

Latest GitHub Commits