initial commit
This commit is contained in:
58
Storage/Delete-SVC-Lun.php
Normal file
58
Storage/Delete-SVC-Lun.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
// Bypass Auth on API Call
|
||||
define('IS_API', true);
|
||||
$origin = $_SERVER['HTTP_ORIGIN'] ?? '';
|
||||
if (in_array($origin, ['http://infra-tools.appliarmony.net','https://infra-tools.appliarmony.net'], false)) {
|
||||
header("Access-Control-Allow-Origin: $origin");
|
||||
header("Vary: Origin");
|
||||
}
|
||||
header('Access-Control-Allow-Methods: POST, OPTIONS');
|
||||
header('Access-Control-Allow-Headers: Content-Type, Accept');
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') { http_response_code(204); exit; }
|
||||
|
||||
// Web-Service Common
|
||||
include $_SERVER['DOCUMENT_ROOT'] . "/include/all.php";
|
||||
$rc=999;$stdout="?";$actor=$_SERVER['COMPUTERNAME'];$done=0;
|
||||
$input = file_get_contents('php://input');
|
||||
$json = json_decode($input, true);
|
||||
$SourceUser = $json['source'] ?? $_SERVER['CURRENTUSER'] ?? null;
|
||||
|
||||
// Main
|
||||
$lun = $json['lun'];
|
||||
$pos = strrpos($lun, '_');
|
||||
if ($pos) {
|
||||
$hostname = substr($lun, 0, $pos);
|
||||
$extension = substr($lun, $pos + 1);
|
||||
$result = [
|
||||
'Hostname' => $hostname,
|
||||
'Extension' => $extension,
|
||||
];
|
||||
$json = json_encode($result, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||
|
||||
$answer = PostJson("$bdnuss/Storage/SVC/VOLUME/SVC_VOLUME_DELETE.php", $json);
|
||||
$rc = (int)json_decode($answer, true)['RC'] ?? 1;
|
||||
$stdout = json_decode($answer, true)['Msg'] ?? 'Unknown error';
|
||||
if ($rc === 0) {$done = 1;}
|
||||
$result = [
|
||||
'RC' => $rc,
|
||||
'StdOut' => $stdout,
|
||||
];
|
||||
$json = json_encode($result, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||
}else{
|
||||
$result = [
|
||||
'RC' => 1,
|
||||
'StdOut' => "Invalid LUN format",
|
||||
];
|
||||
$json = json_encode($result, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||
}
|
||||
|
||||
// Send Answer
|
||||
echo $json;
|
||||
|
||||
// Log to dedicated Table
|
||||
log2DB();
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user