Current trader config tool

This commit is contained in:
[VB]AWOL
2013-09-13 12:11:50 -05:00
parent bea2d1cfd4
commit 59004c5282
13 changed files with 9612 additions and 36 deletions

View File

@@ -1,3 +1,108 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>DayZ Epoch</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<!-- CSS -->
<link href="/bootstrap/css/bootstrap.css" rel="stylesheet">
<style type="text/css">
/* Sticky footer styles
-------------------------------------------------- */
html,
body {
height: 100%;
/* The html and body elements cannot have any padding or margin. */
background: #000 url(bg.jpg) no-repeat center 0;
}
/* Wrapper for page content to push down footer */
#wrap {
min-height: 100%;
height: auto !important;
height: 100%;
/* Negative indent footer by it's height */
margin: 0 auto -60px;
}
/* Set the fixed height of the footer here */
#push,
#footer {
height: 60px;
}
#footer {
background-color: #f5f5f5;
}
/* Lastly, apply responsive CSS fixes as necessary */
@media (max-width: 1200px) {
#footer {
margin-left: -20px;
margin-right: -20px;
padding-left: 20px;
padding-right: 20px;
}
}
/* Custom page CSS
-------------------------------------------------- */
/* Not required for template or sticky footer method. */
.container {
width: auto;
max-width: 1000px;
}
.container .credit {
margin: 20px 0;
}
</style>
<link href="/bootstrap/css/bootstrap-responsive.css" rel="stylesheet">
<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<!-- Fav and touch icons -->
<link rel="shortcut icon" href="/bootstrap/ico/favicon.ico">
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="/bootstrap/ico/apple-touch-icon-144-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="/bootstrap/ico/apple-touch-icon-114-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="/bootstrap/ico/apple-touch-icon-72-precomposed.png">
<link rel="apple-touch-icon-precomposed" href="/bootstrap/ico/apple-touch-icon-57-precomposed.png">
</head>
<body>
<!-- Part 1: Wrap all page content here -->
<div id="wrap">
<!-- Begin page content -->
<div class="container">
<div class="well">
<div class="page-header">
<img src="dayz_epoch_logo.png" alt="DayZ Epoch">
<a class="btn btn-inverse" href="?instance=17">Edit Traders</a>
<a class="btn btn-inverse" href="?show_dvs=1">Dynamic Vehicle Config</a>
<a class="btn btn-inverse" href="?instance=17&show_config=1">Show Trader Config</a>
</div>
<div class="well">
<?php
/*
Trader Config for DayZ Epoch
@@ -15,16 +120,9 @@ $pass = "PASS";
$mysqli = new mysqli($host, $user, $pass, $db, $port);
print("<br/>");
print("<a href='?instance=11'>Chernarus #11 Traders</a><br/>");
print("<a href='?instance=6'>Dingor #6 Traders</a><br/>");
print("<a href='?instance=1'>Takistan #1 Traders</a><br/>");
print("<a href='?instance=4'>Zargabad #4 Traders</a><br/>");
print("<a href='?instance=13'>Taviana #13 Traders</a><br/>");
// Currency Classnames
$bars_array = array("ItemAluminumBar","ItemTinBar","ItemCopperBar","ItemCopperBar10oz","ItemSilverBar","ItemSilverBar10oz","ItemGoldBar","ItemGoldBar10oz");
$bars_array = array("ItemAluminumBar","ItemTinBar","ItemCopperBar","ItemCopperBar10oz","ItemSilverBar","ItemSilverBar10oz","ItemGoldBar","ItemGoldBar10oz","ItemBriefcase100oz");
$humanity_array = array("friendly","neutral","hostile","hero");
function buildHTMLselect ($array,$name) {
$html_tmp = '<select name="'.$name.'">';
@@ -65,7 +163,7 @@ function traderConfigEnd ($static,$status) {
];";
}
function get_tids ($trader_id) {
function get_tids ($trader_id,$instance) {
global $host;
global $port;
global $user;
@@ -75,18 +173,24 @@ function get_tids ($trader_id) {
$mysqli = new mysqli($host, $user, $pass, $db, $port);
// Get Traders array from database
if ($stmt = $mysqli->prepare("SELECT `id`, `name`, `trader` FROM `trader_tids` WHERE trader=?")) {
if ($stmt = $mysqli->prepare("SELECT `id`, `name`, `trader` FROM `trader_tids` WHERE trader=? ORDER BY `name` ASC")) {
$stmt->bind_param("i", $trader_id);
$stmt->execute();
$stmt->bind_result($id, $name, $trader);
$format_output = "";
$format_output_tmp = "";
while ($stmt->fetch()) {
$format_output .= '["'.$name.'",'.$id.'],';
printf("<a target='_blank' href='?tid=%d'>%s</a><br/>", $id,$name);
$format_output_tmp .= $id.',';
if(isset($_GET['inst'])){
printf("<form method='post' action='?instance=%d&inst=%d'><a target='_blank' href='?tid=%d&inst=%d'>%s</a> <input type='submit' name='delete_tid' value='X'><input type='hidden' name='delete_id' value='%s'></form>", $instance,$_GET['inst'],$id,$_GET['inst'],$name,$id);
} else {
printf("<form method='post' action='?instance=%d'><a target='_blank' href='?tid=%d'>%s</a> <input type='submit' name='delete_tid' value='X'><input type='hidden' name='delete_id' value='%s'></form>", $instance,$id,$name,$id);
}
}
echo $format_output_tmp;
return $format_output;
$stmt->close();
} else {
@@ -102,7 +206,7 @@ function add_item($item_class,$item_type,$item_group,$item_afile) {
global $pass;
$mysqli = new mysqli($host, $user, $pass, $db, $port);
if ($stmt = $mysqli->prepare("INSERT INTO `trader_items` (`classname`,`type`,`group`,`afile`) VALUES (?,?,?,?)")) {
if ($stmt = $mysqli->prepare("INSERT IGNORE INTO `trader_items` (`classname`,`type`,`group`,`afile`) VALUES (?,?,?,?)")) {
$stmt->bind_param("siss", $item_class, $item_type, $item_group, $item_afile);
@@ -126,7 +230,7 @@ function add_traders_data($item,$qty,$buy,$sell,$order,$new_id,$afile) {
global $pass;
$mysqli = new mysqli($host, $user, $pass, $db, $port);
if ($stmt = $mysqli->prepare("INSERT INTO `traders_data` (`item`,`qty`,`buy`,`sell`,`order`,`tid`,`afile`) VALUES (?,?,?,?,?,?,?)")) {
if ($stmt = $mysqli->prepare("INSERT IGNORE INTO `traders_data` (`item`,`qty`,`buy`,`sell`,`order`,`tid`,`afile`) VALUES (?,?,?,?,?,?,?)")) {
$stmt->bind_param("sissiis", $item, $qty, $buy, $sell, $order, $new_id,$afile);
@@ -219,6 +323,30 @@ if(isset($_POST['cat_name']) && !empty($_POST['cat_name']) && isset($_POST['trad
}
}
// perform trader desc edits here
if(isset($_POST['cat_name_edit']) && !empty($_POST['cat_name_edit']) && isset($_POST['trader_id'])) {
if ($stmt = $mysqli->prepare("UPDATE `server_traders` SET `desc` = ?,`classname` = ?,`status` = ?,`static` = ? WHERE `id` = ?")) {
$cat_name_edit = $_POST['cat_name_edit'];
$cat_class_edit = $_POST['cat_class_edit'];
$static_edit = $_POST['static_edit'];
$new_trader_status = $_POST['new_trader_status'];
$trader_id = $_POST['trader_id'];
$stmt->bind_param("ssssi", $cat_name_edit, $cat_class_edit, $new_trader_status, $static_edit, $trader_id);
/* execute query */
$stmt->execute();
printf("%d Row Updated.\n", $stmt->affected_rows);
$stmt->close();
} else {
echo 'error';
}
}
// perform fill with template for existing tid
if(isset($_POST['trader_template']) && !empty($_POST['trader_template']) && isset($_POST['t_id'])) {
fill_with_template($_POST['trader_template'],$_POST['t_id']);
@@ -298,7 +426,7 @@ if(isset($_POST['add_item']) && !empty($_POST['add_item']) && isset($_GET['tid']
$afile = $add_item_raw[1];
if ($stmt = $mysqli->prepare("INSERT INTO `traders_data` (`id`, `item`, `qty`, `buy`, `sell`, `tid`, `afile`) VALUES (null, ?, ?, ?, ?, ?, ?)")) {
if ($stmt = $mysqli->prepare("INSERT IGNORE INTO `traders_data` (`id`, `item`, `qty`, `buy`, `sell`, `tid`, `afile`) VALUES (null, ?, ?, ?, ?, ?, ?)")) {
$stmt->bind_param("sissis", $name, $add_stock, $buy_formatted, $sell_formatted, $tid, $afile);
@@ -334,6 +462,9 @@ if(isset($_GET['show_dvs'])){
$number = 1;
}
// force everything to 1
$number = 1;
$counter = $counter + $number;
$build_DVS_html .= '['.$item[0].','.$number."],\n";
}
@@ -353,30 +484,78 @@ if(isset($_GET['show_dvs'])){
if(isset($_GET['instance'])){
$instance = (int)$_GET['instance'];
if(isset($_POST['delete_tid'])){
echo "REMOVED TID";
echo "<pre>".print_r($_POST,1)."</pre>";
if ($stmt = $mysqli->prepare("DELETE FROM `trader_tids` WHERE `id` = ?")) {
$stmt->bind_param("i", $_POST['delete_id']);
/* execute query */
$stmt->execute();
printf("%d Row Updated.\n", $stmt->affected_rows);
$stmt->close();
} else {
echo 'error';
}
}
$filter = "";
$traders_name = array();
// filter templates based on another instance
if(isset($_GET['inst'])) {
$inst_raw = (int)$_GET['inst'];
$filter = "&inst=".$inst_raw;
if ($stmt = $mysqli->prepare("SELECT `id`, `classname`, `instance`, `status`, `static`, `desc` FROM `server_traders` WHERE instance=?")) {
$stmt->bind_param("i", $_GET['inst']);
$stmt->execute();
$stmt->bind_result($idFilter, $nameFilter ,$instanceFilter, $statusFilter, $staticFilter, $descFilter);
$traders_id = "WHERE ";
while ($stmt->fetch()) {
$traders_id .= "`trader` = ".$idFilter." OR ";
$traders_name[$idFilter] = $nameFilter." ". $descFilter;
}
$stmt->close();
}
$traders_id = rtrim($traders_id," OR ");
} else {
$traders_id = "";
}
// get all tids for templates
if ($stmt = $mysqli->prepare("SELECT `id`, `name`, `trader` FROM `trader_tids` ORDER BY `name` ASC")) {
if ($stmt = $mysqli->prepare("SELECT `id`, `name`, `trader` FROM `trader_tids` ".$traders_id." ORDER BY `name` ASC")) {
$stmt->execute();
$stmt->bind_result($id, $name ,$trader);
$build_tid_html = '<select name="trader_template">';
while ($stmt->fetch()) {
if(isset($traders_name[$trader])){
$build_tid_html .= '<option value="'.$id.'">'.$name.' - #'.$id.' ('.$traders_name[$trader].')</option>';
} else {
$build_tid_html .= '<option value="'.$id.'">'.$name.' - #'.$id.'</option>';
}
}
$build_tid_html .= '</select>';
$stmt->close();
} else {
echo 'error 347';
}
// add trader html
echo "<form method='post' action='?instance=".$instance."'><input type='hidden' name='trader_instance' value='".$instance."'>
echo "<form method='post' action='?instance=".$instance.$filter."'><input type='hidden' name='trader_instance' value='".$instance."'>
Classname: <input type='text' name='trader_classname' value=''>
Description: <input type='text' name='trader_desc' value=''>
<select name=\"trader_status\">
<option value=\"friendly\">friendly</option>
<option value=\"neutral\">neutral</option>
<option value=\"hostile\">hostile</option>
<option value=\"friendly\">hero</option>
</select>
".buildHTMLselect($humanity_array,"trader_status")."<br/>
<input type='submit' value='Add Trader'></form>";
// Get Traders array from database
@@ -391,13 +570,21 @@ if(isset($_GET['instance'])){
while ($stmt->fetch()) {
printf("<h1>%s</h1><p>%s - %s</p>",$desc,$name,$status);
printf("<h1>%s<a name='%s'></a></h1><p>%s - %s</p>",$desc,$name,$name,$status);
echo "<form method='post' action='?instance=".$instance."'><input type='hidden' name='trader_id' value='".$id."'>
echo "<form method='post' action='?instance=".$instance.$filter."'><input type='hidden' name='trader_id' value='".$id."'>
<input type='text' name='cat_name_edit' value='$desc'>
<input type='text' name='cat_class_edit' value='$name'>
".buildHTMLselected($humanity_array,"new_trader_status",$status)."<br/>
<input type='text' size='50' name='static_edit' value='$static'>
<input type='submit' value='Edit'></form>";
echo "<form method='post' action='?instance=".$instance.$filter."'><input type='hidden' name='trader_id' value='".$id."'>
Add Trader Category <input type='text' name='cat_name' value=''>
<input type='submit' value='Add New TID'></form>";
echo "<form method='post' action='?instance=".$instance."'><input type='hidden' name='trader_id' value='".$id."'>
echo "<form method='post' action='?instance=".$instance.$filter."'><input type='hidden' name='trader_id' value='".$id."'>
Use Template Category: ".$build_tid_html."
<input type='submit' value='Add New TID Using Template'></form>";
@@ -405,7 +592,7 @@ if(isset($_GET['instance'])){
$per_trader_config .= traderConfigStart($desc,$name);
// find all tids for trader
$per_trader_config .= rtrim(get_tids ($id),",");
$per_trader_config .= rtrim(get_tids ($id,$instance),",");
$per_trader_config .= traderConfigEnd($static,$status);
}
$stmt->close();
@@ -429,8 +616,36 @@ serverTraders = [";
if(isset($_GET['tid'])){
$tid = (int)$_GET['tid'];
$traders_name = array();
$filter = "";
// filter templates based on another instance
if(isset($_GET['inst'])) {
$inst_raw = (int)$_GET['inst'];
$filter = "&inst=".$inst_raw;
if ($stmt = $mysqli->prepare("SELECT `id`, `classname`, `instance`, `status`, `static`, `desc` FROM `server_traders` WHERE instance=?")) {
$stmt->bind_param("i", $_GET['inst']);
$stmt->execute();
$stmt->bind_result($idFilter, $nameFilter ,$instanceFilter, $statusFilter, $staticFilter, $descFilter);
$traders_id = "WHERE ";
while ($stmt->fetch()) {
$traders_id .= "`trader` = ".$idFilter." OR ";
$traders_name[$idFilter] = $nameFilter." ". $descFilter;
}
$stmt->close();
}
$traders_id = rtrim($traders_id," OR ");
} else {
$traders_id = "";
}
// get all tids for templates
if ($stmt = $mysqli->prepare("SELECT `id`, `name`, `trader` FROM `trader_tids` ORDER BY `name` ASC")) {
if ($stmt = $mysqli->prepare("SELECT `id`, `name`, `trader` FROM `trader_tids` ".$traders_id." ORDER BY `name` ASC")) {
$stmt->execute();
$stmt->bind_result($id, $name ,$trader);
@@ -438,8 +653,12 @@ if(isset($_GET['tid'])){
$build_tid_html = '<select name="trader_template">';
while ($stmt->fetch()) {
if(isset($traders_name[$trader])){
$build_tid_html .= '<option value="'.$id.'">'.$name.' - #'.$id.' ('.$traders_name[$trader].')</option>';
} else {
$build_tid_html .= '<option value="'.$id.'">'.$name.' - #'.$id.'</option>';
}
}
$build_tid_html .= '</select>';
@@ -538,13 +757,13 @@ if(isset($_GET['tid'])){
echo 'error';
}
echo "<form method='post' action='?tid=".$tid."'><input type='hidden' name='t_id' value='".$tid."'>
echo "<form method='post' action='?tid=".$tid.$filter."'><input type='hidden' name='t_id' value='".$tid."'>
Use Template Category: ".$build_tid_html."
<input type='submit' value='Add All items from Template'></form>";
printf ("<div class=\"alert alert-info\">
<form method='post' action='?tid=".$tid."'>
<form method='post' action='?tid=".$tid.$filter."'>
<select name=\"add_item\">
".$item_templates."
</select>
@@ -580,9 +799,9 @@ if(isset($_GET['tid'])){
$buy_html = buildHTMLselected ($bars_array,"selected_buy_bar",$buy_item);
$sell_html = buildHTMLselected ($bars_array,"selected_sell_bar",$sell_item);
printf ("<h2><form method='post' action='?tid=".$tid."'> %s <input type='submit' name='delete_item' value='X'><input type='hidden' name='delete_id' value='%s'></form></h2> <form method='post' action='?tid=".$tid."'> Stock: <input type='hidden' name='item_id' value='%s'><input type='text' name='stock' value='%s'> <input type='submit' value='Update Stock'></form><br/>", trim($name[0], '"'), $id, $id, $qty );
printf ("<h2><form method='post' action='?tid=".$tid.$filter."'> %s <input type='submit' name='delete_item' value='X'><input type='hidden' name='delete_id' value='%s'></form></h2> <form method='post' action='?tid=".$tid.$filter."'> Stock: <input type='hidden' name='item_id' value='%s'><input type='text' name='stock' value='%s'> <input type='submit' value='Update Stock'></form><br/>", trim($name[0], '"'), $id, $id, $qty );
printf ("<form method='post' action='?tid=".$tid."'>
printf ("<form method='post' action='?tid=".$tid.$filter."'>
<input type='hidden' name='update_price' value='%s'>
<input type='hidden' name='update_id' value='%s'>
BUY <input type='text' name='buy' value='%s'> ".$buy_html."<br/>
@@ -597,3 +816,44 @@ if(isset($_GET['tid'])){
}
?>
</div>
</div>
</div>
<div id="push"></div>
</div>
<div id="footer">
<div class="container">
<p class="muted credit">Sponsored by <a href="http://eltexonline.com">ElTexOnline LLC</a> and <a
href="http://voicecommandcenter.com">VoiceCommandCenter.com</a>.</p>
</div>
</div>
<!-- Le javascript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="/bootstrap/js/jquery.js"></script>
<script src="/bootstrap/js/bootstrap.js"></script>
<script>
$('#myTab a').click(function (e) {
e.preventDefault();
$(this).tab('show');
})
</script>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 479 KiB

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB