vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Making this function a scheduled task (https://vborg.vbsupport.ru/showthread.php?t=111935)

Tory H 04-01-2006 11:32 PM

Making this function a scheduled task
 
Hi, there is the following function that I want to make a scheduled task, it's basically a function to update scores in the arcade leaderboard, here is (what I think) the function in question :-

Code:

function do_league_update($auto_run = 0)
{
        global $IN, $DB;

        $DB->query("DELETE FROM ibf_games_league");

        $game_query = $DB->query("SELECT * FROM ibf_games_list WHERE active=1");
        while ($ginfo = $DB->fetch_row($game_query))
        {
                $ordering = ($ginfo['highscore_type'] == "high") ? "DESC" : "ASC";
                $ctr = 1;
                $this_query = $DB->query("SELECT mid FROM ibf_games_scores WHERE gid='".$ginfo['gid']."' ORDER BY score ".$ordering.", datescored ASC LIMIT 0,10");
                if ($DB->get_num_rows($this_query))
                {
                        while($lboard = $DB->fetch_row($this_query))
                        {
                                switch($ctr)
                                {
                                        case 1: $points = $arcade['league_scores'][0];
                                        break;
                                        case 2: $points = $arcade['league_scores'][1];
                                        break;
                                        case 3: $points = $arcade['league_scores'][2];
                                        break;
                                        case 4: $points = $arcade['league_scores'][3];
                                        break;
                                        case 5: $points = $arcade['league_scores'][4];
                                        break;
                                        case 6: $points = $arcade['league_scores'][5];
                                        break;
                                        case 7: $points = $arcade['league_scores'][6];
                                        break;
                                        case 8: $points = $arcade['league_scores'][7];
                                        break;
                                        case 9: $points = $arcade['league_scores'][8];
                                        break;
                                        case 10: $points = $arcade['league_scores'][9];
                                        break;
                                        default: $points = $arcade['league_scores'][10];
                                }

                                if ($points > 0)
                                {
                                        extract($ginfo);
                                        $lid = $lboard['mid'];
                                        $db_string = $DB->compile_db_insert_string( array (            'mid'  => $lid,
                                                                                        'gid'  => $gid,
                                                                                        'position'  => $ctr,
                                                                                        'points'    => $points,
                                                                                        'cat'            => $gcat,
                                                                                        ) );
                                        $DB->query("INSERT INTO ibf_games_league (" .$db_string['FIELD_NAMES']. ") VALUES (". $db_string['FIELD_VALUES'] .")");
                                }
                                $ctr++;
                        }
                }
        }

        if (!$auto_run)
        {
/*
                if( $arcade['log'] )
                {
                        $ADMIN->save_log("Rangliste aktualisiert");
                }
*/
                define('CP_REDIRECT', 'arcade.php?code=score_tools');
                print_stop_message('saved_settings_successfully');
        }
}


Now, can I just copy and paste all that into a php file and save it in that directory and create it as a scheduled task? or do I need to add extra stuff like connect to the database or what?
any help much appreciated,
Thanks
Matt


All times are GMT. The time now is 10:03 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.01079 seconds
  • Memory Usage 1,728KB
  • 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_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (1)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