Selador / sql.php

Full commit
header ("Content-Type: text/html; charset=UTF-8");

/* sql.php - Front-end code for doing Travian-compatible SQL dumps
 * Copyright (C) 2006, 2007, 2008 Kevin Read, Simone Schaefer
 * This file is part of Selador, a browser-based fantasy strategy game
 * This program is distributed under the terms of the GNU Affero General Public License.
 *   Selador is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU Affero General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   any later version.
 *   Selador is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   GNU Affero General Public License for more details.
 *   You should have received a copy of the GNU Affero General Public License
 *   along with Selador.  If not, see <>.

require_once ("php/base/");
// require_once ("../php/base/");

// $world = new World;

// DB-Initialisierung
$dblink=mysql_pconnect ('localhost', DB_USER, DB_PASS);
mysql_select_db (DB_NAME);

$query = 'select "s'.WORLDNAME.'" as world, B.y*400+B.x as z, B.x as x, B.y as y, A.race as volk, B.villageid as d, as dorf, A.uid as uid, A.user as spieler, C.aid as aid, C.tag as ally, floor(B.score/1000) as einwohner from user A, village B, allies C where A.uid=B.uid and A.aid=C.aid;';

if (!($res = mysql_query ($query)))
  return (1);

while ($row = mysql_fetch_array ($res))
  echo 'INSERT INTO x_world VALUES ("s'.WORLDNAME.'", '.$row['z'].', '.$row['x'].', '.$row['y'].', '.$row['volk'].', '.$row['d'].'," '.mysql_real_escape_string ($row['dorf']).'", ';
  echo $row['uid'].', "'.mysql_real_escape_string ($row['spieler']).'", '.$row['aid'].', "'.mysql_real_escape_string ($row['ally']).'", '.$row['einwohner'].');'."\n";