-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdeviceHandler.php
588 lines (534 loc) · 27.3 KB
/
deviceHandler.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
<?php
session_start();
include "class/db.class.php";
if(isset($_GET['action']) && $_GET['action']=='delete' && is_numeric($_GET['deviceID']))
{
$device = new device($_GET['deviceID']);
if($device)
{
// determine if the device has ports so we can decide how we show the text in the form
$portClass = new ports;
$ports=$portClass->getByDevice($device->deviceID);
$portCount=count($ports);
?>
<div class="sectionHeader" >
<strong>Deleting: <?php echo $device->name;?></strong>
<a href="#" class="closeLink closeDOMWindow"><img src="images/icons/close_module.gif" border="0" alt="Close" /></a>
</div>
<p style="padding: 5px;">
You are about to delete a device, this can remove it entirely from the system.<br/>
If you'd like to be able to use this system again, we strongly suggest moving it to the inventory.
</p>
<script type="text/javascript">
function deleteDeviceForm()
{
var action = $('input[name=deleteAction]:checked').val();
var delID = $('input[name=delID]').val();
if(action == "inventoryRemoveCables" || action == "inventoryLeaveCables")
{
// put it in the inventory and turn it into a stock item for future use
var invItem = "<li class='item' >" + $("span.device"+delID).parent().parent().html() + "</li>";
$(".inventory ul").append(invItem);
$("span.device"+delID).parent().addClass("stockItem");
// adjust the counter of inventory items
$('.inventoryTitle i').html($('#stock div').children().size()-2);
// remove the original and make new item draggable
$("#rackPanel span.device"+delID).parent().remove();
makedraggable("stock");
}
else
$("span.device"+delID).parent().remove();
$("#deviceID"+delID).parent().remove();
$("#menus").html("");
setTimeout("$('.closeDOMWindow').click();$('.success').hide(); ",1000);
}
</script>
<form method="get" action='deviceHandler.php?action=confirmDelete&deviceID=<?php echo $_GET['deviceID'];?>' id="deleteDeviceForm">
<input type='hidden' name='delID' value='<?php echo $_GET['deviceID'];?>' />
<ul style='padding-left:40px;background-color:#f3f3f3;list-style-type: none;border: 1px solid #cccccc;'>
<li style='padding: 6px;'><input type="radio" name="deleteAction" value="inventoryRemoveCables" id='invrem' style='margin-top: 2px;' checked="checked" /> <label for='invrem' >Move to <u>inventory</u><?php if($portCount) { ?> & <u>remove all</u> cables<?php } ?></label></li>
<li style='padding: 6px;'><input type="radio" name="deleteAction" value="deleteCables" id='delrem' /> <label for='delrem' ><u>Delete</u> forever<?php if($portCount) { ?> & <u>remove cables<?php } ?></label></u></li>
<?php if($portCount) { ?><li style='padding-left: 30px; padding-bottom: 5px;'><a href='#' onclick="$(this).parent().hide(); $('.hiddenoption').slideDown();" >More</a></li> <?php } ?>
<li class='hiddenoption' style='display:none;padding: 6px'><input type="radio" name="deleteAction" value="keepCables" id='delkep'/> <label for='delkep' ><u>Delete</u> & <u>leave cables </u> connected at other end</label></li>
<li class='hiddenoption' style='display:none;padding: 6px;'><input type="radio" name="deleteAction" value="inventoryLeaveCables" style='margin-top: 2px;' id='invkep' /> <label for='invkep' >Move to <u>inventory</u> for re-use, <u>leave cables</u> connected.</label></li>
</ul>
<input style='margin-left: 35px;' class='JSONsubmitForm' type="button" name="deleteDeviceForm" value="Delete" />
<input type="button" onclick="$('.closeDOMWindow').click();" name="cancel" value="Cancel" />
</form>
<?php
}
}
if(isset($_GET['action']) && $_GET['action']=='confirmDelete' && is_numeric($_GET['deviceID']))
{
// either way the device is deleted, check to make sure layout object is taken off the maps page
$layoutItems=new layoutItems;
$layoutItems->deleteByDevice($_GET['deviceID'], 'device');
if($_GET['deleteAction'] == 'inventoryLeaveCables')
{
$racks = new racks;
$racks->move_device($_GET['deviceID'],0,0);
echo json_encode(array("created"));
}
else if($_GET['deleteAction'] == 'inventoryRemoveCables')
{
$devices = new devices;
$devices->moveToInventory($_GET['deviceID'],1,0);
echo json_encode(array("created"));
}
else if($_GET['deleteAction'] == 'deleteCables')
{
$devices = new devices;
$devices->delete($_GET['deviceID'],1);
echo json_encode(array("created"));
}
else if($_GET['deleteAction'] == 'keepCables')
{
$devices = new devices;
$devices->delete($_GET['deviceID'],0);
echo json_encode(array("created"));
}
}
if(isset($_GET['action']) && $_GET['action']=='upgrade' && is_numeric($_GET['deviceID']))
{
$device = new device($_GET['deviceID']);
// get a list of the categories of this device, we dont need the values
// we use this to ensure new templates are the same floor/rack mountable
$device->fillCategories(0,0);
if($device)
{
?>
<script type="text/javascript">
function upgradeDeviceForm(results)
{
if(results[1]=='deviceSizeChanged')
{
$('#formHolder').html("The device you upgraded to is a different size to the previous.<br/>" +
"Please check the racks page to ensure its new position doesn't conflict with any other devices." +
"<center><br/><br/><input type='button' onclick='$(\"#menus\").html(\"\");$(\".closeDOMWindow\").click();' value='OK' /></center>");
}
else
{
$('#formHolder').html("<center><strong>Device Upgraded</strong></center><br/>" +
"<center><br/><br/><input type='button' onclick='$(\"#menus\").html(\"\");$(\".closeDOMWindow\").click();' value='OK' /></center>");
setTimeout("$('.closeDOMWindow').click();$('.success').hide(); ",1000);
}
$("#menus").html("");
}
</script>
<div class="sectionHeader" >
<strong>Upgrade: <?php echo $device->name;?></strong>
<a href="#" class="closeLink closeDOMWindow"><img src="images/icons/close_module.gif" border="0" alt="Close" /></a>
</div>
<div id='formHolder' >
<p class="note">
Upgrading a device maintains all port & cable associations but replaces the template and general device specifications.<br/><br/>
<i>Please note: </i> This process overrides any original settings and details such as OS, maintainer & ILO port are lost.
Port mapping and order(0-4..) are maintained.</p>
<p>
<form method="post" action='deviceHandler.php?action=confirmUpgrade&deviceID=<?php echo $_GET['deviceID'];?>' id="upgradeDeviceForm">
<strong>Move to Model:</strong> <select name='newTemplate' >
<?php $templates = new templates;
$newServers = $templates->getByDeviceType($device->deviceTypeID);
$validtemplate=0;
foreach($newServers as $server)
{
// we don't want deleted templates
if($server->deleted!=1)
{
// get the categories so we can match up floor/rack mountable for templates
$server->fillCategories(1,1,array(GENERIC,RACK_MOUNTABLE,FLOOR_DEVICE));
// if the template matches the existing item lets not show it
if($device->templateID==$server->templateID)
continue;
// check it mounts in the same format, if so print the option
if((isset($device->categories[RACK_MOUNTABLE]) && isset($server->categories[RACK_MOUNTABLE])) || (isset($device->categories[FLOOR_DEVICE]) && isset($server->categories[FLOOR_DEVICE])))
{
echo "<option value='".$server->templateID."' >".ucwords($server->getMeta(12,1)) . ' ' . $server->name."</option>\n";
$validtemplate++;
}
}
}
// if we had no templates just put a filler, ID 0 so that if they hit submit we fail
if(!$validtemplate)
echo "<option value='0' >No Templates Available</option>";
?>
</select>
</p>
<p>
<input style='margin-left: 35px;' class='JSONsubmitForm' type="submit" value="Upgrade" /> <input type="button" onclick="$('.closeDOMWindow').click();" value="Cancel" />
</p>
</div></form>
<?php
}
}
if(isset($_GET['action']) && $_GET['action']=='confirmUpgrade' && is_numeric($_GET['deviceID']))
{
// TODO: allow device upgrades in new system.. interface complete, form submission required
$return=array();
$device = new device($_GET['deviceID']);
if($_GET['newTemplate'] != 0)
{
$template = new template($_GET['newTemplate']);
$device->model = $template->modelName;
$device->vendor = $template->vendor;
$device->depth = $template->depth;
$device->PSUs = $template->PSUs;
$device->templateID = $template->templateID;
$device->PSUWattage = $template->PSUWattage;
$device->peakPSUWattage = $template->peakPSUWattage;
$device->averageBTU = $template->averageBTU;
$device->weight = $template->weight;
$device->copperPorts = $template->copperPorts;
$device->ILO = $template->ILO;
$device->frontPanelImage = $template->frontPanelImage;
if($device->RU != $template->RU)
$return[1]="deviceSizeChanged";
$device->RU = $template->RU;
$devices = new devices;
if($devices->replace($device))
$return[0]="created";
else
$return[0]="error";
}
else
$return[0]="error";
echo json_encode($return);
}
else if(isset($_GET['templateID']) && !isset($_GET['action']) && is_numeric($_GET['templateID']))
{
// as this form could be used for anything determine its parent details
$parentID=$_GET['parentID'];
$parentType=$_GET['parentType'];
if(isset($_GET['position']))
$position=$_GET['position'];
else
$position=0;
// flag used to determine how we submit the form
// either json submit or if there is a file we must do a post / refresh (for now)
$hasFileUpload=0;
$template = new template($_GET['templateID']);
$template->fillCategories(1,1);
if(!$template)
{ ?>
<div class="module" id="createDevice" >
<strong>Error</strong>
<a href="#" class="closeDOMWindow"><img src="images/icons/close_module.gif" border="0" alt="Close" /></a>
<br/><font color="red" >Unable to find the template you requested.<br/>Please refresh the page and try again.</font>
</div>
<?php
exit();
}?>
<script type="text/javascript">
function createDeviceForm(returnDetails)
{
if(returnDetails['parentType']=='rack')
{
var back=0;
if(back==1)
$("#racktbl_" + returnDetails['rackID'] + " .back.d" + returnDetails['position']).html("<div class='template"+returnDetails['templateID']+" r"+returnDetails['RU']+" drag' id='"+returnDetails['RU']+"' ><span class='device" + returnDetails['deviceID'] + "'>" + returnDetails['name'] + "</span></div>");
else
$("#racktbl_" + returnDetails['rackID'] + " .d" + returnDetails['position']+":not('.back')").html("<div class='template"+returnDetails['templateID']+" r"+returnDetails['RU']+" drag' id='"+returnDetails['RU']+"' ><span class='device" + returnDetails["deviceID"] + "'>" + returnDetails['name'] + "</span></div>");
$("#createDeviceForm .formError").removeClass("formError");
$("#createDeviceForm .error").html("");
// show the created message, make the rack draggable & close the window
$(".success").show();
makedraggable("racktbl_" + returnDetails['rackID']);
}
else if(returnDetails['parentType']=='room')
{
var query;
query = "action=insertLayoutItem&";
query += "height=32&";
query += "width=32&";
query += "itemID=" + returnDetails['deviceID'] + "&";
query += "itemName=" + returnDetails['name'] + "&";
query += "itemType=device&";
query += "parentName=room&";
query += "parentType="+returnDetails['parentType']+"&";
query += "parentID=" + returnDetails['parentID'] +"&";
query += "posx=" + returnDetails['posx'] + "&";
query += "posy=" + returnDetails['posy'] + "&";
query += "zindex=5";
$.post("handler.php",query,function(layoutItemID)
{
var content;
content = "<div title='" + returnDetails['name'] + "' id='layoutItemID" + layoutItemID + "' style='z-index:5;width:32px;height:32px;z-index:999; position:absolute; top: " + returnDetails['posy'] + "px; left: " + returnDetails['posx'] + "px' class='layoutItem deletable device draggable'>";
content += "<img style='float:left;' src='images/icons/delete_small.gif' />";
content += "<span>"+returnDetails['name']+"</span>";
content += "</div>";
$(".mapContent").append(content);
makeDraggable();
});
}
setTimeout("$('.closeDOMWindow').click();$('.success').hide(); ",1000);
return false;
}
</script>
<form method="POST" action="deviceHandler.php?action=create" id="createDeviceForm">
<input type="hidden" name="templateID" value="<?php echo $template->templateID; ?>" />
<input type="hidden" name="parentID" value="<?php echo $parentID; ?>" />
<input type="hidden" name="parentType" value="<?php echo $parentType; ?>" />
<input type="hidden" name="position" value="<?php echo $position; ?>"/>
<?php
if(isset($_GET['posx']) && is_numeric($_GET['posx']))
echo '<input type="hidden" name="posx" value="'.$_GET['posx'].'"/>';
if(isset($_GET['posx']) && is_numeric($_GET['posy']))
echo '<input type="hidden" name="posy" value="'.$_GET['posy'].'"/>';
?>
<div class="sectionHeader" id="createDevice" >
<strong>Create a new Device</strong>
<a href="#" class="closeLink closeDOMWindow"><img src="images/icons/close_module.gif" border="0" alt="Close" /></a>
</div>
<p>
<table width="80%" class="formTable">
<colgroup align="left" class="tblfirstRow"></colgroup>
<tr>
<td width="150px" align="right" valign="top"><label for="deviceType" >Device Type</label></td>
<td width="300px"><?php
$name = new deviceType($template->deviceTypeID);
echo $name->name;
?></td>
<td rowspan="4" valign="top"><strong>Un-configurable Traits</strong>
<ul>
<?php
$categoriesClass = new attrcategories;
$listOfCategories=$categoriesClass->getAll();
foreach($template->categories as $key=>$catCount)
{
if($key==HAS_NETWORK_PORTS||$key==IS_PATCH)
continue;
if(empty($catCount))
{
echo "<li>".$listOfCategories[$key]->name."</li>";
}
}
?>
</ul></td>
</tr>
<tr><td align="right" valign="top"><label for="name" >Template Name</label></td><td valign="top"><?php echo $template->name; ?></td></tr>
<tr><td align="right" ><label for="systemName" >System Name</label></td><td><input type="text" name="systemName" size="40"/> (required) </td></tr>
<tr><td align="right" ><label for="ownerid" >Owner</label></td><td><select name="ownerID" >
<?php
$owners = new owners;
foreach($owners->getAll() as $owner)
echo "<option value='".$owner->ownerID."' >".$owner->name."</option>";
?>
</select></td></tr>
</table>
</p>
<?php
$names = new attrnames;
foreach($listOfCategories as $category)
{
if(isset($template->categories[$category->attrcategoryid]))
echo "<div id='category".$category->attrcategoryid."' >
<input type='hidden' name='category".$category->attrcategoryid."' value='1' />";
else
continue;
?>
<strong style="display:block;padding:5px;"><?php echo $category->name; ?></strong>
<table class="formTable" cellpadding="5">
<colgroup class="tblfirstRow"></colgroup>
<?php
// pickup the custom forms for ports and patches
switch($category->attrcategoryid)
{
case HAS_NETWORK_PORTS:
echo "<tr><td colspan='2'><strong>Define the detault ports:</strong>";
$ports = new ports;
$ports->createForm($template->templateID);
echo "</td></tr>";
$attributesfound = true;
break;
case IS_PATCH:
echo "<tr><td colspan='2'><strong>Default Patch Ports:</strong>";
$joins = new joins;
$joins->createForm($template->templateID);
echo "</td></tr>";
$attributesfound = true;
break;
}
// we now have 2 lists of categories
// list of categories contains everything
// template->category[<catID>][<nameID>]-> contains registered values
foreach($names->getByParent($category->attrcategoryid, 'attrcategory') as $name)
{
// reset to prevent previous entry follow-on
$itemName="";
$itemValue="";
// display the title, hide it if the internal list of values doesnt exist (value isnt set)
if(isset($template->categories[$category->attrcategoryid]) && is_array($template->categories[$category->attrcategoryid]))
{
$itemName="name".$name->attrnameid;
if(isset($template->categories[$category->attrcategoryid][$name->attrnameid]->value))
$itemValue=$template->categories[$category->attrcategoryid][$name->attrnameid]->value;
}
echo "<tr><td width='150px' align='right'>".$name->name."</td><td>";
// Values that already exist we name differently in the form
// existing<attrvalueid> so we can simply update the existing record (or delete as needed)
// new values all get named name<attrnameid>
if($name->control==1)
echo "<input type='hidden' name='".$itemName."' value='".$itemValue."' />".$itemValue;
else
{
switch ($name->type)
{
case "Textbox":
echo "<input type='text' name='".$itemName."' value='".$itemValue."' />";
break;
case "Date":
echo "<input class='date' type='text' name='".$itemName."' value='".$itemValue."' />";
break;
case "Number":
echo "<input style='width:50px;' class='number' type='text' name='".$itemName."' value='".$itemValue."' /> " . $name->units;
break;
case "Text Area":
echo "<textarea class='number' rows='5' name='".$itemName."' >".$itemValue."</textarea>";
break;
case "Checkbox":
echo "<input type='checkbox' name='".$itemName."' "; if($itemValue) { echo "CHECKED"; } echo "/>";
break;
case "Radio Buttons":
$values = explode(",",$name->options);
foreach ($values as $key=>$value)
{
echo "<input id='radio_".$itemName."_".$key."' type='radio' name='".$itemName."' value='" . $value . "' "; if($itemValue==$value) { echo "CHECKED"; } echo "/> <label for='radio_".$itemName."_".$key."' >" . $value . "</label><br />";
}
break;
case "Checkbox List":
$values = explode(",",$name->options);
foreach ($values as $value)
{
echo "<input type='radio' name='".$itemName."' "; if($itemValue==$value) { echo "CHECKED"; } echo "/><br />";
}
break;
case "Dropdown List":
$values = explode(",",$name->options);
echo "<select name='".$itemName."'>";
foreach ($values as $value)
{
echo "<option>" . $name->name . "</option>";
}
echo "</select>";
break;
case "File":
$hasFileUpload=1;
break;
case "Image":
$hasFileUpload=1;
break;
}
if($name->desc)
echo " <span class='hoverDescTooltip'> ? <span class='desc' style='display:none;'>".$name->desc."</span></span>";
}
echo "</td></tr>";
}
echo "</table><hr/></div>";
}
echo "<p><input style='margin:10px;float:left;' type='button' value='Cancel & Close' class='closeDOMWindow' />
<input type='submit' style='margin:10px;float:right;' name='submit' value='Create Device' class='JSONform' /></p></form>";
?>
</div></form>
<?php
}
elseif(isset($_GET['action']) && $_GET['action']=="create")
{
$devices = new devices;
// determine if any required values are set/valid
$badFields=array();
if(isset($_POST['systemName']) || !$_POST['systemName']) {
$systemName = preg_replace("/[^a-zA-Z0-9 -]/", '', $_POST['systemName']);
if(!$systemName)
$badFields[]="systemName";
} else
$badFields[]="systemName";
if(!isset($_POST['templateID']) || !is_numeric($_POST['templateID']))
$badFields[]="templateID";
if(!isset($_POST['ownerID']))
$badFields[]='ownerID';
if(count($badFields)==0)
{
// make the items we need to pull values from and set
$template = new template($_POST['templateID']);
$newDevice = new device;
$newDevice->name=$_POST['systemName'];
$newDevice->ownerID=$_POST['ownerID'];
$newDevice->deviceTypeID=$template->deviceTypeID;
$newDevice->parentID=$_POST['parentID'];
$newDevice->parentType=$_POST['parentType'];
$newDevice->position=$_POST['position'];
$newDevice->templateID=$_POST['templateID'];
$deviceID = $devices->insert($newDevice);
// if not null the device was created and we continue
if($deviceID)
{
$catValues = new attrcategoryvalues;
$values = new attrvalues;
$names = new attrnames;
$selectedCategories=array();
foreach($_POST as $postKey=>$postVal)
if(preg_match("/category/i", $postKey))
$selectedCategories[]=preg_replace("/category/i","", $postKey);
$categoriesToCreate=array();
$valuesToCreate=array();
foreach($selectedCategories as $category)
{
$cat = new attrcategoryvalue;
$cat->parentID=$deviceID;
$cat->parentType="device";
$cat->categoryID=$category;
$categoriesToCreate[]=$cat;
// detect all the DB required fields for this category and add them to the list for creation
foreach($names->getByParent($category, 'attrcategory') as $name)
{
$value=new attrvalue();
$value->attrnameid=$name->attrnameid;
if(isset($_POST['name'.$name->attrnameid]))
$value->value=$_POST['name'.$name->attrnameid];
$value->parentid=$deviceID;
$value->parenttype='device';
$valuesToCreate[]=$value;
}
}
// Insert the categories and name values for this item
if(!$catValues->insertMultiple($categoriesToCreate) || !$values->insertMultiple($valuesToCreate))
$status[0]=0;
if(in_array(HAS_NETWORK_PORTS,$selectedCategories))
{
$ports = new ports;
if(!$ports->createPorts($deviceID,$_POST))
$status[0]=0;
}
if(in_array(IS_PATCH,$selectedCategories))
{
$joins = new joins;
if(!$joins->createJoins($deviceID,$_POST))
$status[0]=0;
}
}
else
$error=array(1,"Unable to create device");
}
// Determine the type of submission so we know how to redirect the user
if($_GET['typeOfSubmission']=='ajax')
{
$response=array();
$response['parentType']=$newDevice->parentType;
$response['parentID']=$newDevice->parentID;
$response['rackID']=$newDevice->parentID;
$response['position']=$newDevice->position;
$response['templateID']=$newDevice->templateID;
$response['deviceID']=$deviceID;
$response['name']=$newDevice->name;
if(isset($_POST['name5']) && is_numeric($_POST['name5']))
$response['RU']=$_POST['name5'];
if(isset($_POST['posx']) && is_numeric($_POST['posx']))
$response['posx']=$_POST['posx'];
if(isset($_POST['posy']) && is_numeric($_POST['posy']))
$response['posy']=$_POST['posy'];
echo json_encode(array(1,$response));
}
else
header("Location: racks.php");
}
?>