The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
![]()
Hey guys. im having a little problem with a cron job.. this cron job is supposed to get stats of our players and put it in a table, when i run this script manually by hitting the run now button in the scheduled task manager it works great. but when it is supposed to run every ten minutes it looks like only part of the script works.... it seems to stop where all entries get deleted from the table before all new data gets re-entered and i end up with an empty table...
any ideas? Code:
<?php require_once('../../Connections/donations.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } // Delete existing Data $deleteSQL = sprintf("DELETE FROM roster"); mysql_select_db($database_donations, $donations); $Result1 = mysql_query($deleteSQL, $donations) or die(mysql_error()); // Get new data $clanid="13778"; function startTag($parser, $name, $attrs) { global $stack; $tag=array("name"=>$name,"attrs"=>$attrs); array_push($stack,$tag); } function cdata($parser, $cdata) { global $stack; $stack[count($stack)-1]['cdata'] .= $cdata; } function endTag($parser, $name) { global $stack; $stack[count($stack)-2]['children'][] = $stack[count($stack)-1]; array_pop($stack); } // Parse XML $stack = array(); $claninfo = array(); $clanstats = array(); $playerstats = array(); $xml_parser = xml_parser_create(); xml_set_element_handler($xml_parser, "startTag", "endTag"); xml_set_character_data_handler($xml_parser, "cdata"); $xmllink="http://aaotracker.com/livefeed/xml_clanprofile.php?clanid=$clanid"; $data = xml_parse($xml_parser,file_get_contents($xmllink)); if(!$data) die(sprintf("XML error: %s at line %d", xml_error_string(xml_get_error_code($xml_parser)), xml_get_current_line_number($xml_parser))); xml_parser_free($xml_parser); // Get Data // Get Clan Profile Data for($i = 0; $i < sizeof($stack[0][children][0][children]); $i++) { $valname=$stack[0][children][0][children][$i][name]; $claninfo[$valname]=$stack[0][children][0][children][$i][cdata]; } // Get Clan Stats Data for($i = 0; $i < sizeof($stack[0][children][1][children]); $i++) { $valname=$stack[0][children][1][children][$i][name]; $clanstats[$valname]=$stack[0][children][1][children][$i][cdata]; } // Get Player Data for($i = 0; $i < sizeof($stack[0][children][2][children]); $i++) { for($x = 0; $x < sizeof($stack[0][children][2][children][$i][children]); $x++) { $valname=$stack[0][children][2][children][$i][children][$x][name]; $value=$stack[0][children][2][children][$i][children][$x][cdata]; if($valname=="PLAYERID") $pid=$value; $playerstats[$pid][$valname]=$value; } } // Put new Data in the Table foreach($playerstats as $key => $value) { $playername=$playerstats[$key][PLAYERNAME]; $playerhonor=$playerstats[$key][PLAYERHONOR]; $playerurl=$playerstats[$key][PLAYERSTATSURL]; $playertime=($playerstats[$key][PLAYERTIME]/60)/60; $playerscore=$playerstats[$key][PLAYERSCORE]; $playergoalscore=$playerstats[$key][PLAYERGOALSCORE]; $playerleaderscore=$playerstats[$key][PLAYERLEADERSCORE]; $playerkills=$playerstats[$key][PLAYERKILLS]; $playerdeaths=$playerstats[$key][PLAYERDEATHS]; $playerfragrate= @round($playerstats[$key][PLAYERKILLS]/$playerstats[$key][PLAYERDEATHS], 2); $playerstatus=$playerstats[$key][PLAYERSTATUS]; $query= "INSERT INTO roster SET playername='$playername', playerhonor='$playerhonor', playerurl='$playerurl', playertime='$playertime', playerscore='$playerscore', playergoalscore='$playergoalscore', playerleaderscore='$playerleaderscore', playerkills='$playerkills', playerdeaths='4playerdeaths', playerfragrate='$playerfragrate', playerstatus='$playerstatus'"; mysql_select_db($database_donations, $donations); $Result2 = mysql_query($query, $donations) or die(mysql_error()); } ?> |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|