Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
  #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
Reply

Thread Tools
Display Modes

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 02:02 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.03125 seconds
  • Memory Usage 2,152KB
  • Queries Executed 13 (?)
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_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)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
  • (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_postinfo_query
  • fetch_postinfo
  • 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