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