session_start();
define('AntiBK', true);
include("../engline/config.php");
include("../engline/dbsimple/Generic.php");
include("../engline/data/data.php");
include("../engline/functions/functions.php");
$guid = getGuid('ajax', '../');
$adb = DbSimple_Generic::connect($database['adb']);
$adb->query("SET NAMES ? ",$database['db_encoding']);
$adb->setErrorHandler("databaseErrorHandler");
$char = Char::initialization($guid, $adb);
$char->test->Guid('ajax', '../');
$char->test->Admin('ajax', '../');
$do = getVar('do');
switch ($do)
{
/*Отображение типов предметов*/
case 'showtypes':
$section = getVar('section');
if (!$section)
die('');
$types = $adb->selectCol("SELECT `type` AS ARRAY_KEY FROM `admin_item_create` WHERE `section` = ?s and `type` != 'lang';", $section);
$return = "
";
die($return);
break;
/*Отображение полей предмета*/
case 'showfields':
$type = getVar('type');
if (!$type)
die('');
$lang = $adb->selectRow("SELECT * FROM `admin_item_create` WHERE `type` = 'lang';");
$fields = $adb->selectRow("SELECT * FROM `admin_item_create` WHERE `type` = ?s", $type);
$table = "
";
$a = 0;
foreach ($fields as $field => $val)
{
if (!$val || $field == 'section' || $field == 'type')
continue;
$title = $field;
switch ($field)
{
case 'item_flags': $title .= " 1-Sellable, 2-Repairable, 4-Artefact, 8-Personal, 16-Left Hand"; break;
case 'name': $return = "$table"; $i = 0; $c = 7; break;
case 'min_level': $return .= "
$table"; $i = 0; $c = 11; break;
case 'add_str': $return .= "$table"; $i = 0; $c = 9; break;
case 'def_h':
case 'def_a':
case 'def_b':
case 'def_l':
case 'attack':
case 'add_hit_min': if(!$a){$return .= "$table"; $i = 0; $c = 7; $a = 1;} break;
case 'res_magic': $return .= "$table"; $i = 0; $c = 12; break;
case 'mf_dmg': $return .= "$table"; $i = 0; $c = 10; break;
case 'mf_acrit': $return .= "$table"; $i = 0; $c = 9; break;
case 'all_magic': $return .= "$table"; $i = 0; $c = 12; break;
case 'rep_magic': $return .= "$table"; $i = 0; $c = 7; break;
case 'ch_sting': $return .= "$table"; $i = 0; $c = 10; break;
case 'inc_count': $return .= "$table"; $i = 0; $c = 9; break;
case 'description': $return .= ''; break;
}
switch ($field)
{
case 'name':
case 'personal_owner':
case 'img': $size = 150; break;
case 'validity':
case 'price':
case 'price_euro': $size = 60; break;
case 'description': $size = 300; break;
default: $size = 30; break;
}
$return .= "$lang[$field]: | | ";
$i++;
if (!($i % $c))
$return .= '
';
}
$return .= "
";
die($return);
break;
/*Создание предмета*/
case 'createitem':
$fields = getVar('fields');
$sql = array();
$field = explode('$$', $fields);
unset($field[count($field) - 1]);
foreach ($field as $fill)
{
$f = explode('=', $fill);
$sql[$f[0]] = $f[1];
}
$adb->query("INSERT INTO `item_template` (?#) VALUES (?a);",array_keys($sql), array_values($sql));
die('complete');
break;
/*Удаление персонажа*/
case 'delete_char':
$d_guid = getVar('d_guid');
$adb->query("DELETE FROM `character_bank` WHERE `guid` = ?d", $d_guid);
$adb->query("DELETE FROM `character_bars` WHERE `guid` = ?d", $d_guid);
$adb->query("DELETE FROM `character_effects` WHERE `guid` = ?d", $d_guid);
$adb->query("DELETE FROM `character_equip` WHERE `guid` = ?d", $d_guid);
$adb->query("DELETE FROM `character_info` WHERE `guid` = ?d", $d_guid);
$adb->query("DELETE FROM `character_inventory` WHERE `guid` = ?d", $d_guid);
$adb->query("DELETE FROM `character_sets` WHERE `guid` = ?d", $d_guid);
$adb->query("DELETE FROM `character_stats` WHERE `guid` = ?d", $d_guid);
$adb->query("DELETE FROM `characters` WHERE `guid` = ?d", $d_guid);
$adb->query("DELETE FROM `history_auth` WHERE `guid` = ?d", $d_guid);
$adb->query("DELETE FROM `history_mail` WHERE `guid` = ?d", $d_guid);
$adb->query("DELETE FROM `history_items` WHERE `guid` = ?d", $d_guid);
die('complete');
break;
}
?>