Esempio n. 1
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));
				}
				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));
}
$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));
}

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


?>
session_start();

//
// 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 {
	
	$rsPaths = FTPFileGroupDB::retrieveForUserId($_SESSION['ccuserid']);
	$arPaths = array();
	for ($i = 0; $i < sizeof($rsPaths); $i++) {
		array_push($arPaths, $rsPaths[$i]->toHashMap());
	}
	
	echo getJSONResult(array("groupList" => $arPaths));
}

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

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


?>
Esempio n. 4
0
function phpftp_list($phpftp_user,$phpftp_passwd,$phpftp_dir) {
	global $phpftp_host;
	
	$ftp = @phpftp_connect($phpftp_user,$phpftp_passwd);
	
	if (!$ftp) {
		// FTP Login failed!
	} else {
		if (!$phpftp_dir) {
			$phpftp_dir=ftp_pwd($ftp);
		}
		if (!@ftp_chdir($ftp,$phpftp_dir)) {
			// Can't enter that directory!
			$phpftp_dir=ftp_pwd($ftp);
		}
		
		if ($phpftp_dir == "/") {
			$phpftp_dir="";
		}

		if ($contents = ftp_rawlist($ftp,"")) {
			$d_i=0;
			$f_i=0;
			$l_i=0;
			$i=0;
			while ($contents[$i]) {
				$item[] = split("[ ]+",$contents[$i],9);
				$item_type=substr($item[$i][0],0,1);
				if ($item_type == "d") {
					/* it's a directory */
					$nlist_dirs[$d_i]=$item[$i][8];
					$d_i++;
				} elseif ($item_type == "l") {
					/* it's a symlink */
					$nlist_links[$l_i]=$item[$i][8];
					$l_i++;
				} elseif ($item_type == "-") {
					/* it's a file */
					$nlist_files[$f_i]=$item[$i][8];
					$nlist_filesize[$f_i]=$item[$i][4];
					$f_i++;
				} elseif ($item_type == "+") {
					/* it's something on an anonftp server */
					$eplf=split(",",implode(" ",$item[$i]),5);
					if ($eplf[2] == "r") {
						/* it's a file */
						$nlist_files[$f_i]=trim($eplf[4]);
						$nlist_filesize[$f_i]=substr($eplf[3],1);
						$f_i++;
					} elseif ($eplf[2] == "/") {
						/* it's a directory */
						$nlist_dirs[$d_i]=trim($eplf[3]);
						$d_i++;
					}
				} /* ignore all others */
				$i++;
			}
			
			//if (count($nlist_dirs)>0) {
				//echo getJSONResult("dirs" => $nlist_dirs);
			//}
			
			//if (count($nlist_files)>0) {
				//echo getJSONResult($nlist_files);
			//}
			
			echo getJSONResult(array("dirs" => $nlist_dirs, "files" => $nlist_files));
		} else {
			//Directory empty or not readable
		}
		
		$cdup=dirname($phpftp_dir);
		if ($cdup == "") {
			$cdup="/";
		}
		
		ftp_quit($ftp);
	}
}
$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));
}

Esempio n. 6
0
					$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]
						));
					}
				}
			}
			
			echo getJSONResult(array("pathList" => $arOut));
		}
		else {
			echo getJSONResult(array("pathList" => null));
		}
	}
}

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

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


?>
Esempio n. 7
0
session_start();

//
// REMOVE THIS LINE WHEN OUT OF DEV
//
$gwtError = new GWTError();

//$gwtError->setUserId($_SESSION["ccuserid"]);
$gwtError->setStackTrace($_REQUEST["stack_trace"]);

if (strlen(trim($gwtError->getStackTrace())) == 0) {
	echo getJSONError(array(11, "Stack trace required for GWT error"));
}
else {
	if (GWTErrorDB::save($gwtError)) {
		echo getJSONResult(array("gwtError" => "saved"));
	}
	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));
}