Advertisement
Fwaky

Untitled

Dec 25th, 2015
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.44 KB | None | 0 0
  1. <?php
  2. ini_set('max_execution_time', 800);
  3. // This file updates: Vocation & Checks for deleted chars / name changes.
  4. include("../config.php");
  5. include("../library/tibiaparser.class.php");
  6. include("../library/mysql.db.class.php");
  7.  
  8. // BOF
  9. global $db;
  10. $db = new database($db_host, $db_name, $db_user, $db_pass);
  11. // Updates Tibia Worlds based on Tibia.com
  12. $tc = new TibiaDotCom();
  13. // Grab 1000 characters (1000 page requests!)
  14.     $date = date('Y-m-d');
  15.     $db->query("SELECT * FROM characters WHERE character_updated != :date ORDER BY id DESC LIMIT 0,10");
  16.     // Bind
  17.     $db->bind(":date", $date);
  18.    
  19.     $characters = $db->resultset();
  20.    
  21.  
  22. foreach($characters as $char){
  23.     $character_data = $tc->characterInfo($char["name"]);
  24.     if(!isset($character_data["not_found"])){
  25.     // Gather data
  26.    
  27.     $vocation = $character_data["vocation"];
  28.     if(isset($character_data["former_names"])){
  29.         $old_names = $character_data["former_names"];
  30.         $old_names = explode(", ", $old_names);
  31.         echo $char["name"];
  32.         print_r($old_names);
  33.         if(count($old_names) > 0){
  34.             // Check if old name is registred, if it is do nothing else save it
  35.            
  36.         }
  37.     }
  38.     if(isset($character_data["former_world"])){
  39.         $old_world = $character_data["former_world"];
  40.     }
  41.     // Grab world data
  42.     $charid = $char["id"];
  43.     $charworld = $char["world"];
  44.    
  45.     // Lets explode names and check if there are several older names.
  46.     } else {
  47.         // Uhoh! Character is no longer found, that means it has been deleted!
  48.     }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement