escape(stripslashes($_POST['name'])); mysqli_query($database->dblink, "UPDATE " . TB_PREFIX . "hero SET `name`='" . $_POST['name'] . "' where `uid`='" . $database->escape($session->uid) . "' AND dead = 0") or die("ERROR:" . mysqli_error($database->dblink)); $hero_info['name'] = $_POST['name']; echo "" . NAME_CHANGED . ""; } // Explicit lookup: action from URL (?add=...) => column from `hero` table. // Used for both "(+)" links in the table and for the update // in the DB below. Single source of truth instead of 5 identical blocks. $heroStatColumns = [ 'off' => 'attack', 'deff' => 'defence', 'obonus' => 'attackbonus', 'dbonus' => 'defencebonus', 'reg' => 'regeneration', ]; // Render the "(+)" link for a stat, or "(+)" uneditable // if the hero has no more points or the stat is already at the top (100). // Identical behavior to the original 5 if/else blocks. $renderAddLink = function ($action) use ($hero_info, $id, $heroStatColumns) { $field = $heroStatColumns[$action]; if ($hero_info['points'] > 0 && $hero_info[$field] < 100) { return "(+)"; } return "(+)"; }; ?>
| uid."\">"; }else{ echo "".$hero_info['name'].""; } ?> ( getUnitName($hero_info['unit'])."\" title=\"".$technology->getUnitName($hero_info['unit'])."\" /> ".$technology->getUnitName($hero_info['unit']); ?> ) | |||||||||
|---|---|---|---|---|---|---|---|---|---|
![]() |
|||||||||
" title="" /> |
|||||||||
| % | ![]() |
||||||||
| % | ![]() |
||||||||
| / | ![]() |
||||||||
| : | % | ![]() |
: | 100% | ![]() |
||||