Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include("../config.php");
- include("../library/tibiaparser.class.php");
- include("../library/mysql.db.class.php");
- // Working
- // Last update: 2013-06-19 15:17 CEST
- // TEMP
- function getWorldType($t){
- $t = strtolower($t);
- if($t == 'optional pvp'){
- return 0;
- } elseif($t == 'open pvp'){
- return 1;
- } elseif($t == 'hardcore pvp'){
- return 2;
- }
- }
- function getLocation($l){
- $l = strtolower($l);
- if($l == "europe"){
- return 0;
- } elseif($l == "north america"){
- return 1;
- }
- }
- // 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();
- $worlds = $tc->getWorlds();
- foreach($worlds as $w){
- $name = $w["name"];
- $location = $w["location"];
- $type = $w["worldtype"];
- // Check if world exists, if not add it.
- $db->query("SELECT id FROM worlds WHERE name = :name");
- $db->bind(":name", $name);
- $data = $db->single();
- if(empty($data)){
- // Save world, if not already exists
- $db->query("INSERT INTO worlds (name, type, location) VALUES(:name, :type, :location)");
- // Bind data
- $db->bind(":name", $name);
- echo $name.' - '.$type.' - '.$location.'<br>';
- $db->bind(":type", getWorldType($type));
- $db->bind(":location", getLocation($location));
- // End bind data
- $db->execute();
- }
- }
- ?>
Add Comment
Please, Sign In to add comment