$ansi = new File_ANSI(); $sql = "UPDATE sshManagerQueue\n\t\t\t\tSET cmdOutput = 'Connected!',\n\t\t\t\t\tcmdTimestamp = UNIX_TIMESTAMP()\n\t\t\t\tWHERE memberID = '" . $connection["memberID"] . "'\n\t\t\t\t AND jobTemplateID = '" . $connection["jobTemplateID"] . "'\n\t\t\t\t AND cmdID = '" . $connection["cmdID"] . "'\n\t\t\t\t AND deviceID = '" . $connection["deviceID"] . "'"; if ($db_CS->query($sql)) { $ssh->enablePTY(); $fwCMD = "cat /http/default/_version.php | grep 'define' | grep 'PRODUCT_VERSION' | awk -F ',' '{print \$2}' | sed 's/[^[:alnum:]\\.[:space:]]\\+//g'"; $ssh->exec($fwCMD); $ansi->appendString($ssh->read()); $response["cmdOutput"] = trim(htmlspecialchars_decode(strip_tags($ansi->getHistory()))); //echo "Running sql success cmdID: ".$connection["cmdID"]."\n$sql"; if ($db_CS->query($sql)) { if ($connection["tDeviceFirmware"] != $response["cmdOutput"]) { $sql = "UPDATE sshManagerQueue\n\t\t\t\t\t\t\tSET cmdOutput = 'FW updated from " . $connection["tDeviceFirmware"] . " to " . $response["cmdOutput"] . "',\n\t\t\t\t\t\t\t\tcmdTimestamp = UNIX_TIMESTAMP()\n\t\t\t\t\t\t\tWHERE memberID = '" . $connection["memberID"] . "'\n\t\t\t\t\t\t\t AND jobTemplateID = '" . $connection["jobTemplateID"] . "'\n\t\t\t\t\t\t\t AND cmdID = '" . $connection["cmdID"] . "'\n\t\t\t\t\t\t\t AND deviceID = '" . $connection["deviceID"] . "'"; $db_CS->query($sql); $sql = "UPDATE DeviceList\n\t\t\t\t\t\t\tSET tDeviceFirmware = '" . $response["cmdOutput"] . "'\n\t\t\t\t\t\t\tWHERE id = '" . $connection["deviceID"] . "'"; if ($db_CS->query($sql) && $db_CS->affected_rows > 0) { if (updateDeviceHistoryMember($connection["deviceID"], 'tDeviceFirmware', $connection["memberID"])) { $db_CS->commit(); } else { $db_CS->rollback(); } } } else { $sql = "UPDATE sshManagerQueue\n\t\t\t\t\t\t\tSET cmdOutput = 'FW is up to date! (Answer: " . addslashes($response["cmdOutput"]) . ")',\n\t\t\t\t\t\t\t\tcmdTimestamp = UNIX_TIMESTAMP()\n\t\t\t\t\t\t\tWHERE memberID = '" . $connection["memberID"] . "'\n\t\t\t\t\t\t\t AND jobTemplateID = '" . $connection["jobTemplateID"] . "'\n\t\t\t\t\t\t\t AND cmdID = '" . $connection["cmdID"] . "'\n\t\t\t\t\t\t\t AND deviceID = '" . $connection["deviceID"] . "'"; if ($db_CS->query($sql)) { $db_CS->commit(); } else { $db_CS->rollback(); } } } }
$sourceRegionID = isset($_REQUEST["sourceRegionID"]) ? intval($_REQUEST["sourceRegionID"]) : ""; $sourceSubRegionID = isset($_REQUEST["sourceSubRegionID"]) ? intval($_REQUEST["sourceSubRegionID"]) : ""; if ($targetType == "regionID") { // We need to determine NoSubRegionID for this regionID $paramName = "nGroup"; $sql = "UPDATE DeviceList\n\t\t\t\tSET nSubGroup = (SELECT id FROM SubRegionList WHERE nRegionID = '{$targetID}' AND tSubRegionName = 'Без подгруппы' LIMIT 1),\n\t\t\t\t\tnRegionID = '{$targetID}',\n\t\t\t\t\tnGroup = '{$targetID}'\n\t\t\t\tWHERE id = '{$droppedDeviceID}'"; } if ($targetType == "subRegionID") { $paramName = "nSubGroup"; $sql = "UPDATE DeviceList \n\t\t\t\tSET nSubGroup = '{$targetID}',\n\t\t\t\t nGroup = (SELECT nRegionID FROM SubRegionList WHERE id = '{$targetID}' LIMIT 1),\n\t\t\t\t nRegionID = (SELECT nRegionID FROM SubRegionList WHERE id = '{$targetID}' LIMIT 1)\n\t\t\t\tWHERE id = '{$droppedDeviceID}'"; } //echo $sql; if ($db_CS->query($sql)) { if ($db_CS->affected_rows > 0) { //echo $db_CS->affected_rows; if (updateDeviceHistoryMember($droppedDeviceID, $paramName)) { $db_CS->commit(); $response["status"] = 'success'; $response["msg"] = 'Сохранено'; echo $db_CS->affected_rows; } else { $response["_sql"] = "Rollback!"; echo $db_CS->affected_rows; $db_CS->rollback(); } } else { echo 0; } } else { echo 0; }