ZontreckWebsite/php/MakeFolder.php

44 lines
No EOL
1.1 KiB
PHP

<?php
if(!defined("COMMON"))
require("Common.php");
$js = getJsonizedInput();
$DB = get_DB();
$clientKey = $js['client'];
$complete=false;
if($clientKey == md5(CLIENTPSK)) {
// Authorized
$complete=true;
$name = $js['name'];
$type = $js['invType'];
$parent = $js['parent'];
$owner = $js['owner'];
$id = $js['id'];
$res = $DB->query("INSERT INTO `inventoryfolders` (folderName, type, version, folderID, agentID, parentFolderID ) VALUES ('$name', '$type', 1, '$id', '$owner', '$parent');");
if(!$res) $complete=false;
else {
// Let's bump the parent folder version number now
$pfres = $DB->query("SELECT * FROM `inventoryfolders` WHERE folderID='$parent'");
if($pfres){
// The parent folder is valid.
$row = $pfres->fetch_assoc();
$parentVersion = $row['version'];
$parentVersion++;
$DB->query("UPDATE `inventoryfolders` SET `version` = '$parentVersion' WHERE folderID='$parent'");
}
}
}
die(json_encode(array(
"done" => $complete,
"type" => "S2CSimpleReply"
)));
?>