Selador / sql.php

<?php
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
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   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 <http://www.gnu.org/licenses/>.
 **/

require_once ("php/base/config.inc.php");
// require_once ("../php/base/world.inc.php");

// $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, B.name 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";
}

?>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.