View Single Post
  #1  
Old 04-01-2006, 11:32 PM
Tory H Tory H is offline
 
Join Date: Mar 2006
Posts: 6
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01095 seconds
  • Memory Usage 1,770KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.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
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • 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
  • showpost_complete