Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
  #1  
Old 03-26-2007, 04:49 AM
bulbasnore bulbasnore is offline
 
Join Date: Dec 2004
Posts: 95
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default check my evil plan: avatars

So, hypothetically, let's say its April 1.
  1. select userid,avatarid from user order by userid; (then save that as a file)
  2. back up the customavatar table
  3. update user set avatarid = 1337; (now everyone has the same avatar)
  4. *time passes: morning and evening, one day*
  5. use the list of avatarids from step 1 to update the avatarid field as per the value of each user (now everyone has the same avatarid value as they started with)
  6. restore the customavatar table (now those who have the rights to customavatar upload have the original avatar)

Is there any maintenance I need to do after this?
Is there something I'm not accounting for in vBulletin that will prevent me from putting everything back as it was?
Any indexes or whatever to rebuild?

Thanks... I promise not to reveal anyone who helps me to my users! And, of course, you bear no responsibility if I blow the whole thing up!
Reply With Quote
  #2  
Old 03-26-2007, 07:27 PM
WetWired's Avatar
WetWired WetWired is offline
 
Join Date: Jun 2002
Location: Texas
Posts: 669
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'd say just to it with template edits. Edit the modifyavatar template to be in a huge <if condition="0"></if>, then edit the MEMBERINFO, postbit, and postbit_legacy templates, doing the same to the normal avatar code and inserting an img tag with your replacement avatar. You may also want to edit the memberlist template, if you have avatars shown in the memberlist.

Styles are easily backed up and restored, too.
Reply With Quote
  #3  
Old 03-27-2007, 12:37 AM
bulbasnore bulbasnore is offline
 
Join Date: Dec 2004
Posts: 95
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

WetWired, that's interesting! Thanks for detailing the templates to edit if I go that route!

Its possible I may change the avatars to something random numbers in a range, too, instead of all the same.
Reply With Quote
  #4  
Old 04-02-2007, 02:16 PM
bulbasnore bulbasnore is offline
 
Join Date: Dec 2004
Posts: 95
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

WARNING: you could lose your whole board mucking with SQL and this procedure could more easily corrupt your data, so if you don't have enough experience or you don't have a backup, run for your life! (or use WetWired's cool trick above).

BTW, this will PROBABLY ONLY WORK if you store your custom avatars in your database!

Our board doesn't have much activity with custom avatars, only staff are allowed to have them, except for certain days when we open them up to regular members. For April Fools, we got a new set of Avatars and I wanted to randomly assign them to everyone. The problem is that if someone does have a custom avatar and then starts switching standard avatars after the random avatars are set, they will wipe out their custom avatar, so, you need a backup.

With that in mind, here's what I did:

In phpmyadmin:

1) Under OPERATIONS copy the customavatar table to customavatar070331
2) Under SQL:
Code:
SELECT userid,avatarid,avatarrevision FROM user
3) Use the export button on that result page.
3a) Select the SQL export (default)
3b) turn off (uncheck) Structure
3c) turn on (check) Data & for export type select UPDATE
3d) check zip (or some other compression you like)
3e) hit GO to download the file

OPEN the downloaded file and make sure its valid and shows the update statements that include all 3 fields.

To review, at this point, you've 1) backed up the customavatar table and 2) exported the avatarid/revision data from the user table by userid.

Now here's the fun part, where you randomize everyone's Avatars!

But first you'll test it on your avatar!!! In this case, I used userid 1997, put your test user's userid in place of that.

This statement let's you pick avatars by avatarid, where x is the lowest ID you want to use and z = (highest +1) - the lowest.

update user set `avatarid` = FLOOR( x + ( RAND( ) * z ) ) where userid = 1997;

To use avatars 1 to 100:

update user set `avatarid` = FLOOR( 1 + ( RAND( ) * 100 ) ) where userid = 1997;

To use avatars 819 to 1463:

update user set `avatarid` = FLOOR( 819 + ( RAND( ) *644 ) ) where userid = 1997;

After you check that it works right on your userid, just remove the 'where' clause at the end.

So, now your little prank is over, how do you put it back?

In phpmyadmin:
1) Select the user table, & use the INSERT function to upload the uncompressed SQL export. This will update all the avatar info to the way it was when you exported it.
2) Select the customavatar table:
2a) Under OPERATIONS rename it to customavatars070402
3) Select the customavatar070331 table:
3a) Under OPERATIONS rename it to customavatars

Done!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:05 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.08795 seconds
  • Memory Usage 2,188KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (4)post_thanks_box
  • (4)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (4)post_thanks_postbit_info
  • (4)postbit
  • (4)postbit_onlinestatus
  • (4)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete