Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- ini_set('max_execution_time', 6000);
- // This file updates EXP highscores only.
- // Other highscores are saved separatly, at diffrent times to even server load.
- include("../config.php");
- include("../library/tibiaparser.class.php");
- include("../library/mysql.db.class.php");
- $updated_worlds = array();
- // Pending
- // Last update: 2013-06-19 18:03 CEST
- // Set database object
- global $db;
- $db = new database($db_host, $db_name, $db_user, $db_pass);
- // Updates Tibia Worlds based on Tibia.com
- $tc = new TibiaDotCom();
- // First we get all worlds
- $date = date("Y-m-d");
- $db->query("SELECT name, id FROM worlds WHERE skills_updated != :updated LIMIT 0,5");
- $db->bind(":updated", $date);
- $worlds = $db->resultSet();
- $skills = array("magic", "shielding", "distance", "sword", "club", "axe", "fist", "fishing", "achievements");
- foreach($worlds as $w){
- $worldid = $w["id"];
- $world = $w["name"];
- $updated_worlds[] = $world;
- foreach($skills as $s){
- for($i = 0; $i < 12; $i++){
- $highscore = $tc->getHighscores($world, $s, $i);
- foreach($highscore as $h){
- $db->query("SELECT id FROM characters WHERE name = :name");
- // Bind
- $db->bind(":name", $h["name"]);
- $check = $db->single();
- if(empty($check)){
- // Char doesn't exist
- $db->query("INSERT INTO characters (name, world) VALUES(:name, :world)");
- // Bind
- $db->bind(":name", $h["name"]);
- $db->bind(":world", $worldid);
- // Execute and get ID
- $db->execute();
- $charid = $db->lastInsertId();
- } else {
- // Char exists
- $charid = $check["id"];
- }
- // Insert EXP record into history.
- $db->query("UPDATE characters SET ".$s." = :skill WHERE id = :charid");
- // Bind
- $db->bind(":charid", $charid);
- $db->bind(":skill", $h["value"]);
- // execute
- $db->execute();
- }
- set_time_limit(60);
- }
- }
- $db->query("UPDATE worlds SET skills_updated = :date WHERE id = :id");
- $db->bind(":date", $date);
- $db->bind(":id", $worldid);
- $db->execute();
- }
- unset($db);
- print_r($updated_worlds);
- ?>
Add Comment
Please, Sign In to add comment