closes #17, великое переименование классов для автозагрузчика, актуализация кода
This commit is contained in:
@@ -1,85 +1,78 @@
|
||||
<?
|
||||
<?php
|
||||
include_once('_incl_data/__config.php');
|
||||
define('GAME',true);
|
||||
const GAME = true;
|
||||
include_once('_incl_data/class/__db_connect.php');
|
||||
include_once('_incl_data/class/__user.php');
|
||||
|
||||
if(isset($_GET['for'])) {
|
||||
|
||||
//
|
||||
|
||||
function array_to_sql($t,$m,$id_name,$id) {
|
||||
$r = '';
|
||||
//
|
||||
$k = array_keys($m);
|
||||
$a = '';
|
||||
$b = '';
|
||||
$i = 0;
|
||||
while( $i < count($k) ) {
|
||||
$a .= ',`'.$k[$i].'`';
|
||||
if( $id != false && $k[$i] == $id_name ) {
|
||||
$b .= ','.$id.'';
|
||||
}else{
|
||||
$b .= ',"'.str_replace('"','"',$m[$k[$i]]).'"';
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
$a = ltrim($a,',');
|
||||
$b = ltrim($b,',');
|
||||
//
|
||||
$r = 'INSERT INTO `'.$t.'` ( '.$a.' ) VALUES ( '.$b.' );';
|
||||
//
|
||||
return $r;
|
||||
}
|
||||
|
||||
$dng = (int)$_GET['dng'];
|
||||
|
||||
$sql = '';
|
||||
|
||||
$test_bot = array();
|
||||
$dungeon_bots = array();
|
||||
$dungeon_items = array();
|
||||
$dungeon_obj = array();
|
||||
$dungeon_map = array();
|
||||
$items_main = array();
|
||||
$eff_main = array();
|
||||
|
||||
//
|
||||
|
||||
if( $_GET['step'] == 1 ) {
|
||||
$sp = mysql_query('SELECT * FROM `dungeon_map` WHERE `id_dng` = "'.mysql_real_escape_string($dng).'" ORDER BY `x` ASC, `y` ASC');
|
||||
while( $pl = mysql_fetch_assoc($sp) ) {
|
||||
$sql .= array_to_sql('dungeon_map',$pl,'id','NULL').'<hr>';
|
||||
}
|
||||
}elseif( $_GET['step'] == 2 ) {
|
||||
$sp = mysql_query('SELECT * FROM `dungeon_obj` WHERE `for_dn` = "'.mysql_real_escape_string($dng).'" ORDER BY `id` ASC');
|
||||
while( $pl = mysql_fetch_assoc($sp) ) {
|
||||
$sql .= array_to_sql('dungeon_obj',$pl,'id','NULL').'<hr>';
|
||||
}
|
||||
}elseif( $_GET['step'] == 3 ) {
|
||||
$sm = 200; // ñìåùåíèå áîòîâ
|
||||
$botadd = array();
|
||||
$sp = mysql_query('SELECT * FROM `dungeon_bots` WHERE `for_dn` = "'.mysql_real_escape_string($dng).'" ORDER BY `id2` ASC');
|
||||
while( $pl = mysql_fetch_assoc($sp) ) {
|
||||
$botsel = mysql_fetch_assoc(mysql_query('SELECT * FROM `test_bot` WHERE `id` = "'.$pl['id_bot'].'" LIMIT 1'));
|
||||
if(isset($botsel['id'])) {
|
||||
$pl['id_bot'] += $sm;
|
||||
if(!isset($botadd[$pl['id_bot']])) {
|
||||
$botadd[$pl['id_bot']] = true;
|
||||
$sql .= array_to_sql('test_bot',$botsel,'id','"'.$pl['id_bot'].'"').'<hr>';
|
||||
}
|
||||
$sql .= array_to_sql('dungeon_bots',$pl,'id2','NULL').'<hr>';
|
||||
}
|
||||
}
|
||||
}elseif( $_GET['setp'] == 4 ) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
echo $sql;
|
||||
|
||||
}else{
|
||||
die('Äîñòóï çàêðûò!');
|
||||
if (!isset($_GET['for'])) {
|
||||
die('Äîñòóï çàêðûò!');
|
||||
}
|
||||
function array_to_sql($t, $m, $id_name, $id)
|
||||
{
|
||||
$k = array_keys($m);
|
||||
$a = '';
|
||||
$b = '';
|
||||
$i = 0;
|
||||
while ($i < count($k)) {
|
||||
$a .= ',`' . $k[$i] . '`';
|
||||
if ($id && $k[$i] == $id_name) {
|
||||
$b .= ',' . $id;
|
||||
} else {
|
||||
$b .= ',"' . str_replace('"', '"', $m[$k[$i]]) . '"';
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
$a = ltrim($a, ',');
|
||||
$b = ltrim($b, ',');
|
||||
return 'INSERT INTO `' . $t . '` ( ' . $a . ' ) VALUES ( ' . $b . ' );';
|
||||
}
|
||||
|
||||
?>
|
||||
$dng = (int)$_GET['dng'];
|
||||
|
||||
$sql = '';
|
||||
|
||||
$test_bot = [];
|
||||
$dungeon_bots = [];
|
||||
$dungeon_items = [];
|
||||
$dungeon_obj = [];
|
||||
$dungeon_map = [];
|
||||
$items_main = [];
|
||||
$eff_main = [];
|
||||
|
||||
//
|
||||
if ($_GET['step'] == 1) {
|
||||
$sp = mysql_query(
|
||||
'SELECT * FROM `dungeon_map` WHERE `id_dng` = "' . mysql_real_escape_string(
|
||||
$dng
|
||||
) . '" ORDER BY `x`, `y`'
|
||||
);
|
||||
while ($pl = mysql_fetch_assoc($sp)) {
|
||||
$sql .= array_to_sql('dungeon_map', $pl, 'id', 'NULL') . '<hr>';
|
||||
}
|
||||
} elseif ($_GET['step'] == 2) {
|
||||
$sp = mysql_query(
|
||||
'SELECT * FROM `dungeon_obj` WHERE `for_dn` = "' . mysql_real_escape_string($dng) . '" ORDER BY `id` ASC'
|
||||
);
|
||||
while ($pl = mysql_fetch_assoc($sp)) {
|
||||
$sql .= array_to_sql('dungeon_obj', $pl, 'id', 'NULL') . '<hr>';
|
||||
}
|
||||
} elseif ($_GET['step'] == 3) {
|
||||
$sm = 200; // ñìåùåíèå áîòîâ
|
||||
$botadd = [];
|
||||
$sp = mysql_query(
|
||||
'SELECT * FROM `dungeon_bots` WHERE `for_dn` = "' . mysql_real_escape_string($dng) . '" ORDER BY `id2` ASC'
|
||||
);
|
||||
while ($pl = mysql_fetch_assoc($sp)) {
|
||||
$botsel = mysql_fetch_assoc(
|
||||
mysql_query('SELECT * FROM `test_bot` WHERE `id` = "' . $pl['id_bot'] . '" LIMIT 1')
|
||||
);
|
||||
if (isset($botsel['id'])) {
|
||||
$pl['id_bot'] += $sm;
|
||||
if (!isset($botadd[$pl['id_bot']])) {
|
||||
$botadd[$pl['id_bot']] = true;
|
||||
$sql .= array_to_sql('test_bot', $botsel, 'id', '"' . $pl['id_bot'] . '"') . '<hr>';
|
||||
}
|
||||
$sql .= array_to_sql('dungeon_bots', $pl, 'id2', 'NULL') . '<hr>';
|
||||
}
|
||||
}
|
||||
}
|
||||
echo $sql;
|
||||
|
||||
Reference in New Issue
Block a user