$ftpSite->setUserId($_SESSION["ccuserid"]); $ftpSite->setFtpSiteId($_REQUEST["ftpSiteId"]); $ftpSite->setServer($_REQUEST["server"]); $ftpSite->setPort($_REQUEST["port"]); $ftpSite->setUsername($_REQUEST["username"]); $ftpSite->setPassword($_REQUEST["password"]); if (!$_SESSION['ccuserid']) { echo getJSONError(array(1, "Not logged in")); } else if (strlen(trim($ftpSite->getServer())) == 0) { echo getJSONError(array(11, "Host required for FTP site")); } else { if (FTPSiteDB::save($ftpSite)) { echo getJSONResult(array("ftpSite" => $ftpSite->toHashMap())); } else { echo getJSONError(array(2, "Error saving record")); } } function getJSONResult($result) { return json_encode(array("result" => $result)); } function getJSONError($errors) { return json_encode(array("errors" => $errors)); }