array_push($arFtpSiteIds, $ftpSiteId); $ftpPath = new FTPPath(); // For Base64 decoding $path = str_replace("_", "+", $path); $path = str_replace(".", "/", $path); $path = str_replace("-", "=", $path); //$ftpPath->setFtpPathId($_SESSION["ftpPathId"]); $ftpPath->setFtpSiteId($ftpSiteId); $ftpPath->setGroupId($groupId); $ftpPath->setPath(base64_decode($path)); /*$ftpPath->setPath($path);*/ $successful = FTPPathDB::save($ftpPath); } } if ($successful) { $cleanupRS = new dbRS(); if (sizeof($arFtpSiteIds) > 0) { $inString = ''; foreach ($arFtpSiteIds as $ftpSiteId) { if (strlen($inString) > 0) { $inString .= ','; } $inString .= $ftpSiteId; } $cleanupRS->execute(sprintf("delete from ftp_path where group_id = %s and ftp_site_id not in (%s)", dbUtil::encode($groupId) ,$inString));
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 ,"type" => $parts[0] ,"path" => $parts[1] ));