header("Content-type: text/plain");
session_start();

//
// REMOVE THIS LINE WHEN OUT OF DEV
//
if (!isset($_SESSION['ccuserid'])) { $_SESSION['ccuserid'] = 7; }

$phpftp_host = $_REQUEST["server"];
$phpftp_port = $_REQUEST["port"];
$phpftp_user = $_REQUEST["username"];
$phpftp_passwd = $_REQUEST["password"];
$phpftp_function = $_REQUEST["Function"];

if (!$_SESSION['ccuserid']) {
	echo getJSONError(array(1, "Not logged in"));
}
else {
	
	$rsConnections = FTPSiteDB::retrieveForUserId($_SESSION['ccuserid']);
	$arConnections = array();
	for ($i = 0; $i < sizeof($rsConnections); $i++) {
		array_push($arConnections, $rsConnections[$i]->toHashMap());
	}
	
	echo getJSONResult(array("connectionList" => $arConnections));
}

function getJSONResult($result) {
	return json_encode(array("result" => $result));
}
$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));
}


?>
Esempio n. 3
0
					}
					$cleanupRS->execute(sprintf("delete from ftp_path where group_id = %s and ftp_site_id not in (%s)",
						 dbUtil::encode($groupId)
						,$inString));
				}
				else {
					$cleanupRS->execute(sprintf("delete from ftp_path where group_id = %s",
						dbUtil::encode($groupId)));
				}
				echo getJSONResult(array("ftpPath" => "saved"));
			}
			else {
				echo getJSONError(array(2, "Error saving FTPPath record"));
			}
		}
	}
	else {
		echo getJSONError(array(12, "Group Id must be specified when saving paths"));
	}
}

function getJSONResult($result) {
	return json_encode(array("result" => $result));
}

function getJSONError($errors) {
	return json_encode(array("errors" => $errors));
}


?>
Esempio n. 4
0
//
// REMOVE THIS LINE WHEN OUT OF DEV
//
if (!isset($_SESSION['ccuserid'])) { $_SESSION['ccuserid'] = 7; }

if (!$_SESSION['ccuserid']) {
	echo getJSONError(array(1, "Not logged in"));
}
else {
	$arGroups = FTPFileGroupDB::retrieveForUserId($_SESSION["ccuserid"]);
	if ($arGroups != null) {
		$groupId = $arGroups[0]->getGroupId();
	}
	
	if (!groupId) {
		echo getJSONError(array(3, "Group Id required"));
	}
	else {
		$arPathRecords = FTPPathDB::retrieveForGroupId($groupId);
		$arOut = array();
		
		if ($arPathRecords != null) {
			foreach ($arPathRecords as $pathRecord) {
				$paths = explode(chr(13), $pathRecord->getPath());
				foreach ($paths as $path) {
					$parts = explode(":", $path, 2);
					$name = preg_replace('/^.+\\/([^\\/]+)$/', '$1', $parts[1]);
					if (strlen($parts[1]) > 0) {
						array_push($arOut, array(
							 "ftp_site_id" => $pathRecord->getFtpSiteId()
							,"name" => $name