vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Run "Fix broken user profiles" as a scheduled task (https://vborg.vbsupport.ru/showthread.php?t=316798)

Chaya_ 01-20-2015 05:15 PM

Run "Fix broken user profiles" as a scheduled task
 
It this possible and how?

Dave 01-20-2015 05:24 PM

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.

Zachery 01-20-2015 05:52 PM

You shouldn't be running this task, really ever. What are you doing that you require to run it on a task?

Chaya_ 01-20-2015 05:53 PM

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 ?

Zachery 01-20-2015 06:01 PM

Why are you writing users directly into the database instead of using the datamanagers?

Chaya_ 01-20-2015 06:05 PM

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

Paul M 01-20-2015 06:11 PM

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.

Chaya_ 01-20-2015 06:13 PM

i use it ... it is a god way and it work...

Zachery 01-20-2015 08:53 PM

No, its not a good way. You should fix your scripts to work properly.

ozzy47 01-21-2015 01:16 AM

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


All times are GMT. The time now is 01:27 AM.

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.01033 seconds
  • Memory Usage 1,737KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete