Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 01-20-2015, 05:15 PM
Chaya_ Chaya_ is offline
 
Join Date: Apr 2014
Posts: 29
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Run "Fix broken user profiles" as a scheduled task

It this possible and how?
Reply With Quote
  #2  
Old 01-20-2015, 05:24 PM
Dave Dave is offline
 
Join Date: May 2010
Posts: 2,583
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Sure is possible, just copy the PHP code of /admincp/misc.php?do=lostusers in a new file, replace "$db->" by "$vbulletin->db->" and upload to /includes/cron/fixprofiles.php, then add a new scheduled task in the admincp which points to that file.
Reply With Quote
  #3  
Old 01-20-2015, 05:52 PM
Zachery's Avatar
Zachery Zachery is offline
 
Join Date: Jul 2002
Location: Ontario, Canada
Posts: 11,440
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You shouldn't be running this task, really ever. What are you doing that you require to run it on a task?
Reply With Quote
  #4  
Old 01-20-2015, 05:53 PM
Chaya_ Chaya_ is offline
 
Join Date: Apr 2014
Posts: 29
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:
// ###################### Start find lost users #######################
if ($_POST['do'] == 'lostusers')
{
    
$users $vbulletin->db->query_read("
        SELECT user.userid
        FROM " 
TABLE_PREFIX "user AS user
        LEFT JOIN " 
TABLE_PREFIX "userfield AS userfield USING(userid)
        WHERE userfield.userid IS NULL
    "
);

    
$userids = array();
    while (
$user $vbulletin->db->fetch_array($users))
    {
        
$userids[] = $user['userid'];
    }

    if (!empty(
$userids))
    {
        
/*insert query*/
        
$vbulletin->db->query_write("INSERT INTO " TABLE_PREFIX "userfield (userid) VALUES (" implode('),('$userids) . ")");
    }

    
$users $vbulletin->db->query_read("
        SELECT user.userid
        FROM " 
TABLE_PREFIX "user AS user
        LEFT JOIN " 
TABLE_PREFIX "usertextfield AS usertextfield USING(userid)
        WHERE usertextfield.userid IS NULL
    "
);

    
$userids = array();
    while (
$user $vbulletin->db->fetch_array($users))
    {
        
$userids[] = $user['userid'];
    }

    if (!empty(
$userids))
    {
        
/*insert query*/
        
$vbulletin->db->query_write("INSERT INTO " TABLE_PREFIX "usertextfield (userid) VALUES (" implode('),('$userids) . ")");
    }

    
define('CP_REDIRECT''misc.php');
    
print_stop_message('user_records_repaired');

Correct ?
Reply With Quote
  #5  
Old 01-20-2015, 06:01 PM
Zachery's Avatar
Zachery Zachery is offline
 
Join Date: Jul 2002
Location: Ontario, Canada
Posts: 11,440
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Why are you writing users directly into the database instead of using the datamanagers?
Reply With Quote
  #6  
Old 01-20-2015, 06:05 PM
Chaya_ Chaya_ is offline
 
Join Date: Apr 2014
Posts: 29
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I have deactivated my forum registration, i use a other cms to create a account into the forum. i am owner of a gameserver .... if you create a game account, at same time you create a forum account

But the Userprofiles not 100% complete, so i use a cron all 10 minutes, to fix broken user profiles
Reply With Quote
  #7  
Old 01-20-2015, 06:11 PM
Paul M's Avatar
Paul M Paul M is offline
 
Join Date: Sep 2004
Location: Nottingham, UK
Posts: 23,748
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

There should never be a need to run that, let alone on a cron.

You should add users properly with the datamanagers, not direct data inserts.
Fix profiles will not fix everything, its designed as a last resort.
Reply With Quote
  #8  
Old 01-20-2015, 06:13 PM
Chaya_ Chaya_ is offline
 
Join Date: Apr 2014
Posts: 29
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

i use it ... it is a god way and it work...
Reply With Quote
  #9  
Old 01-20-2015, 08:53 PM
Zachery's Avatar
Zachery Zachery is offline
 
Join Date: Jul 2002
Location: Ontario, Canada
Posts: 11,440
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

No, its not a good way. You should fix your scripts to work properly.
Reply With Quote
  #10  
Old 01-21-2015, 01:16 AM
ozzy47's Avatar
ozzy47 ozzy47 is offline
 
Join Date: Jul 2009
Location: USA
Posts: 10,929
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I agree, it is not a good way to do it, use the datamanagers as suggested.
Reply With Quote
Reply


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 07:39 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04869 seconds
  • Memory Usage 2,258KB
  • Queries Executed 11 (?)
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_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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_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