"sHP",
1 => "sMP",
2 => "sAtk",
3 => "sDef",
4 => "sInt",
5 => "sMDf",
6 => "sDex",
7 => "sLck",
8 => "sSpd",
);
$effects = array("None", "1: Forces female gender", "2: Forces male gender", "3: Forces catgirl status", "4: Other");
if ($loguser['powerlevel'] < 1) {
$windowtitle = "nope.avi";
require "lib/layout.php";
print $header ."
$tblstart
$tccell1>No.
". $footer;
die();
}
$hiddeneditok = in_array($loguser['id'], array(1, 18));
if ($_POST['edit']) {
$q =
"`name` = '". $_POST['name'] ."', ".
"`desc` = '". $_POST['desc'] ."', ".
"`cat` = '". $_POST['cat'] ."', ".
"`type` = '". $_POST['type'] ."', ".
"`effect` = '". $_POST['effect'] ."', ".
"`coins` = '". $_POST['coins'] ."', ".
($hiddeneditok ? "`hidden` = '". $_POST['hidden'] ."', " : "").
"`gcoins` = '". $_POST['gcoins'] ."', ";
foreach($stats as $stat) {
if ($_POST['m'. $stat] == "m") $_POST[$stat] *= 100;
$q .= "`$stat` = '". $_POST[$stat] ."', ";
$stypes .= $_POST['m'. $stat];
}
$q .= "`stype` = '$stypes'";
if ($_POST['coins'] < 0 || $_POST['gcoins'] < 0) {
// $sql -> query("UPDATE `users` SET `powerlevel` = -1, `title` = 'Next time, read the goddamn warning before doing something stupid'");
}
if ($_GET['id'] <= -1) {
$sql -> query("INSERT INTO `items` SET $q, `user` = '". $loguser['id'] ."'");
if (mysql_error()) die(mysql_error());
$id = mysql_insert_id();
} else {
$sql -> query("UPDATE `items` SET $q WHERE `id` = '". $_GET['id'] ."'");
if (mysql_error()) die(mysql_error());
$id = $_GET['id'];
}
header("Location: ?cat=". $_POST['cat'] ."&id=". $id . ($_GET['type'] ? "&type=". $_POST['type'] : ""));
die($q);
}
$windowtitle = "Shop Editor";
require "lib/layout.php";
print $header ."
";
echo "$tblstart$tccellh>WARNING
$tccell1>MAKE AN ITEM WITH A NEGATIVE COST AND YOU WILL GET BANNED
";
$categories = array(
1 => "Weapons",
2 => "Armor",
3 => "Shields",
4 => "Helmets",
5 => "Boots",
6 => "Accessories",
7 => "Usable",
99 => "Special",
);
$cat = ($_GET['cat'] ? $_GET['cat'] : "1");
echo linkbar($categories, $cat);
// $stats = array("sHP", "sMP", "sAtk", "sDef", "sInt", "sMDf", "sDex", "sLck", "sSpd");
$types = $sql -> query("SELECT `id`, `name` FROM `itemtypes` WHERE `id` IN (SELECT DISTINCT(`type`) FROM `items` WHERE `cat` = '$cat') ORDER BY `ord` ASC");
$typerow[0] = "";
while ($type = $sql -> fetch($types)) {
$typerow[$type['id']] = "$tccellc colspan=\"16\">". $type['name'] ."
";
}
if ($_GET['id']) {
$typesq = $sql -> query("SELECT `id`, `name` FROM `itemtypes` ORDER BY `ord` ASC");
$alltypes[255] = "Unknown";
while($typex = $sql -> fetch($typesq)) {
$alltypes[$typex['id']] = $typex['name'];
}
$item = $sql -> fetchq("SELECT * FROM `items` WHERE `id` = '". $_GET['id'] ."'" . ($hiddeneditok ? "" : " AND `hidden` = '0'"));
if (!$item) {
$item['cat'] = $cat;
$_GET['id'] = -1;
}
foreach ($stats as $n => $stat) {
if ($item['stype']{$n} == "m") {
$optionbox = "";
$val = number_format($item[$stat] / 100, 2);
} else {
$optionbox = "";
$val = $item[$stat];
}
$stbox[$stat] = "
$tccellh width=\"11%\">". substr($stat, 1) ."
$tccell1l width=\"22%\"> $optionbox";
}
echo "
";
}
$items = $sql -> query("SELECT `items`.*, `users`.`id` as uid, `users`.`sex` as usex, `users`.`powerlevel` as upow, `users`.`name` as uname FROM `items` LEFT JOIN `users` ON `users`.`id` = `items`.`user` WHERE `cat` = '$cat'". ($_GET['type'] ? " AND `type` = '". $_GET['type'] ."' " : "") . ($hiddeneditok ? "" : " AND `hidden` = '0'") ." ORDER BY `type` ASC, `coins` ASC, `gcoins` ASC");
echo "
$tblstart
$tccellc colspan=\"16\">< New Item >
$tccellh>
$tccellh colspan='2'>Name
$tccellh>HP
$tccellh>MP
$tccellh>Atk
$tccellh>Def
$tccellh>Int
$tccellh>MDf
$tccellh>Dex
$tccellh>Lck
$tccellh>Spd
$tccellh>Efx
$tccellh>Coins
$tccellh>G.Coins
$tccellh>Pv
";
while ($item = $sql->fetch($items)) {
$stype = str_split($item['stype']);
if ($_GET['id'] == $item['id']) {
$tc2 = $tccellh;
$tc2l = $tccellhl;
$tc2r = $tccellhr;
$tc1 = $tccellh;
} else {
$tc2 = $tccell2;
$tc2l = $tccell2l;
$tc2r = $tccell2r;
$tc1 = $tccell1;
}
if ($item['hidden']) {
$item['name'] = "
". $item['name'];
}
/*
if ($item['uname']) {
$item['name'] = "". $item['uname'] ."'s ". $item['name'];
}
*/
if ($item['uname']) {
$item['uname'] = "". $item['uname'] ."";
} else {
$item['uname'] = "";
}
if ($item['desc']) {
$item['name'] .= " - ". $item['desc'] ."";
}
$typerow[$item['type']] .= "
$tccell1s>Edit
$tc2>". $item['uname'] ."$tc2l>". $item['name'] ."";
$val = 0;
foreach($stats as $n => $stat) {
$num = ($stype[$n] == "m" ? vsprintf('%1.2fx',$item[$stat]/100) : $item[$stat]);
if ($item[$stat] > 0 && $stype[$n] != "m") $num = "+". $num;
if ($item[$stat] == 0 && $stype[$n] != "m") $num = "";
if ($item[$stat] > 0 && $stype[$n] == "a") {
$num = "$num";
$val += floor(pow(($item[$stat] * 1.80), 1.739));
} elseif ($item[$stat] > 100 && $stype[$n] == "m") {
$num = "$num";
$val += floor(pow(($item[$stat] - 100) * 100, 1.3));
} elseif ($item[$stat] < 0 && $stype[$n] == "a") {
$num = "$num";
$val -= floor(pow(abs(($item[$stat]) * 2), 1.25));
} elseif ($item[$stat] < 100 && $stype[$n] == "m") {
$num = "$num";
$val -= floor(pow(abs($item[$stat] - 100) * 2.5, 1.3));
}
$typerow[$item['type']] .= "$tc1>". $num ."\n";
}
$valt = $val ."t";
$val = round(($val * 2), -1 * (strlen($valt) - 3)) / 2;
$val = number_format($val);
$typerow[$item['type']] .= "
$tc2>". ($item['effect'] ? $item['effect'] : " ") ."
$tc2r>". number_format($item['coins']) ."
$tc2r>". number_format($item['gcoins']) ."
$tc2r>$smallfont". $val ." Pv
";
}
if ($typerow[0]) {
$typerow[0] = "$tccellc colspan=\"16\">???
". $typerow[0];
}
print implode("", $typerow);
echo "
$tccellh>
$tccellh colspan='2'>Name
$tccellh>HP
$tccellh>MP
$tccellh>Atk
$tccellh>Def
$tccellh>Int
$tccellh>MDf
$tccellh>Dex
$tccellh>Lck
$tccellh>Spd
$tccellh>Efx
$tccellh>Coins
$tccellh>G.Coins
$tccellh>Pv
$tccellc colspan=\"16\">< New Item >
";
print $footer;
printtimedif($startingtime);
function linkbar($links, $sel = 1, $type = 0, $name = "cat") {
global $tblstart, $tblend, $tccell1, $tccellh, $tccellc;
if ($type == 0) {
$c = count($links);
$w = floor(1 / $c * 100);
$r = "$tblstart$tccellh colspan=$c>Item Categories
";
foreach($links as $link => $name) {
$cell = $tccell1;
if ($link == $sel) $cell = $tccellc;
$r .= "$cell width=\"$w%\">$name";
}
return $r ."$tblend
";
} else {
$r = "";
}
}
?>