本文整理汇总了PHP中ftp_close函数的典型用法代码示例。如果您正苦于以下问题:PHP ftp_close函数的具体用法?PHP ftp_close怎么用?PHP ftp_close使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ftp_close函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: DeleteUpfile
function DeleteUpfile($R, $d)
{
global $g, $table;
$UPFILES = getArrayString($R['upload']);
foreach ($UPFILES['data'] as $_val) {
$U = getUidData($table['s_upload'], $_val);
if ($U['uid']) {
if ($U['url'] == $d['comment']['ftp_urlpath']) {
$FTP_CONNECT = ftp_connect($d['comment']['ftp_host'], $d['comment']['ftp_port']);
$FTP_CRESULT = ftp_login($FTP_CONNECT, $d['comment']['ftp_user'], $d['comment']['ftp_pass']);
if ($d['comment']['ftp_pasv']) {
ftp_pasv($FTP_CONNECT, true);
}
if (!$FTP_CONNECT) {
getLink('', '', 'FTP서버 연결에 문제가 발생했습니다.', '');
}
if (!$FTP_CRESULT) {
getLink('', '', 'FTP서버 아이디나 패스워드가 일치하지 않습니다.', '');
}
ftp_delete($FTP_CONNECT, $d['comment']['ftp_folder'] . $U['folder'] . '/' . $U['tmpname']);
if ($U['type'] == 2) {
ftp_delete($FTP_CONNECT, $d['comment']['ftp_folder'] . $U['folder'] . '/' . $U['thumbname']);
}
ftp_close($FTP_CONNECT);
} else {
unlink($U['url'] . $U['folder'] . '/' . $U['tmpname']);
if ($U['type'] == 2) {
unlink($U['url'] . $U['folder'] . '/' . $U['thumbname']);
}
}
getDbDelete($table['s_upload'], 'uid=' . $U['uid']);
}
}
}
示例2: xmlFtpTest
public function xmlFtpTest($xmlFileID)
{
$ftp_server = "117.55.235.145";
$conn_id = ftp_connect($ftp_server);
$ftp_user_name = "s1057223";
$ftp_user_pass = "526Ge0P4Ck8Jd937";
// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
// check connection
if (!$conn_id || !$login_result) {
// echo "FTP connection has failed!";
// echo "Attempted to connect to $ftp_server for user $ftp_user_name";
// exit;
} else {
// echo "Connected to $ftp_server, for user $ftp_user_name";
}
$target_dir = public_path('assets/data/');
$destination_file = "/public_html/test1/" . $xmlFileID . ".xml";
$source_file = $target_dir . $xmlFileID . ".xml";
// upload the file
$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);
// check upload status
if (!$upload) {
echo "FTP upload has failed!";
} else {
// echo "Uploaded $source_file to $ftp_server as $destination_file";
}
// close the FTP stream
ftp_close($conn_id);
}
示例3: ftp_put_file
function ftp_put_file($remote, $local)
{
$ftp_host = 'xungeng.vpaas.net';
$ftp_user = 'root';
$ftp_pass = 'zehin@123';
$code = 0;
$conn_id = ftp_connect($ftp_host);
if ($conn_id) {
// try to login
$login_result = ftp_login($conn_id, $ftp_user, $ftp_pass);
if ($login_result) {
$source_file = $local;
//源地址
$destination_file = $remote;
//目标地址
$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);
if ($upload) {
$msg = "success";
$code = 1;
} else {
$msg = "FTP upload has failed!";
}
} else {
$msg = "FTP connection has failed!" . "Attempted to connect to {$ftp_host} for user {$ftp_user}";
}
} else {
$msg = "无法连接到{$ftp_host}";
}
ftp_close($conn_id);
return array('code' => $code, 'msg' => $msg);
}
示例4: close
public function close()
{
if ($this->connected) {
return ftp_close($this->handle);
}
return false;
}
示例5: JSX_PHP_FTP_Directory_List_Get
function JSX_PHP_FTP_Directory_List_Get($p_aConnData, $p_aPathData)
{
// Connection settings.
$hostname = $p_aConnData['hostname'];
$username = $p_aConnData['username'];
$password = $p_aConnData['password'];
// Directory settings.
$startdir = $p_aPathData['startdir'];
// absolute path
$suffix = $p_aPathData['suffix'];
// suffixes to list
$g_levello = $p_aPathData['levello'];
// Livello di "nested directory".
// Data array.
$files = array();
// Ftp connection.
$conn_id = ftp_connect($hostname);
$login = ftp_login($conn_id, $username, $password);
if (!$conn_id) {
echo 'Wrong server!';
exit;
} else {
if (!$login) {
echo 'Wrong username/password!';
exit;
} else {
// Get data through FTP.
$files = JSX_PHP_FTP_raw_list($conn_id, $p_aConnData, $p_aPathData, $files);
}
}
// Close FTP connection.
ftp_close($conn_id);
// Return value.
return $files;
}
示例6: ftpBackupFile
function ftpBackupFile($source_file, $ftpserver, $ftpuser, $ftppassword)
{
global $log;
$FTPOK = 0;
$NOCONNECTION = 1;
$NOLOGIN = 2;
$NOUPLOAD = 3;
$log->debug("Entering ftpBackupFile(" . $source_file . ", " . $ftpserver . ", " . $ftpuser . ", " . $ftppassword . ") method ...");
// set up basic connection
$conn_id = @ftp_connect($ftpserver);
if (!$conn_id) {
$log->debug("Exiting ftpBackupFile method ...");
return $NOCONNECTION;
}
// login with username and password
$login_result = @ftp_login($conn_id, $ftpuser, $ftppassword);
if (!$login_result) {
ftp_close($conn_id);
$log->debug("Exiting ftpBackupFile method ...");
return $NOLOGIN;
}
// upload the file
$destination_file = basename($source_file);
$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);
// check upload status
if (!$upload) {
ftp_close($conn_id);
$log->debug("Exiting ftpBackupFile method ...");
return $NOUPLOAD;
}
// close the FTP stream
ftp_close($conn_id);
$log->debug("Exiting ftpBackupFile method ...");
return $FTPOK;
}
示例7: test_connection
function test_connection()
{
if ($this->input->is_ajax_request()) {
header('Content-Type: application/json', true);
$ftp_server = trim($this->input->post('address'));
$ftp_user = trim($this->input->post('user'));
$ftp_password = trim($this->input->post('password'));
$port = trim($this->input->post('port'));
// set up basic connection
if ($this->input->post('SFTP') == true) {
$conn_id = @ftp_ssl_connect($ftp_server, $port) or die(json_encode(array('status' => 'error', 'output' => '<span class="delete ftp-alert cmsicon" style="display: inline-block;float: none;"></span> Couldn\'t connect to ' . $ftp_server)));
} else {
$conn_id = @ftp_connect($ftp_server, $port) or die(json_encode(array('status' => 'error', 'output' => '<span class="delete ftp-alert cmsicon" style="display: inline-block;float: none;"></span> Couldn\'t connect to ' . $ftp_server)));
}
// login with username and password
if (!@ftp_login($conn_id, $ftp_user, $ftp_password)) {
$output = array('status' => 'error', 'output' => '<span class="cus-cross-octagon"></span> Username and Password is incorrect');
} else {
$output = array('status' => 'success', 'output' => '<span class="cus-accept"></span> Connection OK!');
}
ftp_close($conn_id);
echo json_encode($output);
} else {
show_404();
}
}
示例8: close
/**
* Closes an FTP connection
*
* @return boolean Returns true on success or false on failure
*/
public function close()
{
$result = ftp_close($this->connection);
$this->connection = null;
$this->loggedIn = false;
return $result;
}
示例9: Authenticate
/**
* Tries to logon to the FTP server with given id and password
*
* @access public
*
* @param string $source Authentication source to be used
* @param string $external_uid The ID entered
* @param string $external_passwd The password of the user
*
* @return boolean True if the authentication was a success, false
* otherwise
*/
public function Authenticate($source, $external_uid, $external_passwd)
{
$enc = ExternalAuthenticator::getAuthEnc($source);
$port = ExternalAuthenticator::getAuthPort($source);
if (is_null($port)) {
$port = self::$port;
}
ExternalAuthenticator::AuthLog($external_uid . '.ftp - Connecting to ' . ExternalAuthenticator::getAuthServer($source) . ' port ' . $port);
if ($enc == 'ssl') {
ExternalAuthenticator::AuthLog($external_uid . '.ftp - Connection type is SSL');
$conn = @ftp_ssl_connect(ExternalAuthenticator::getAuthServer($source), $port);
} else {
$conn = @ftp_connect(ExternalAuthenticator::getAuthServer($source), $port);
}
if (!$conn) {
ExternalAuthenticator::AuthLog($external_uid . '.ftp - Connection to server failed');
ExternalAuthenticator::setAuthMessage(_t('FTP_Authenticator.NoConnect', 'Could not connect to FTP server'));
return false;
} else {
ExternalAuthenticator::AuthLog($external_uid . '.ftp - Connection to server succeeded');
}
if (!@ftp_login($conn, $external_uid, $external_passwd)) {
ExternalAuthenticator::AuthLog($external_uid . '.ftp - User credentials failed at ftp server');
ftp_close($conn);
ExternalAuthenticator::setAuthMessage(_t('ExternalAuthenticator.Failed'));
return false;
} else {
ExternalAuthenticator::AuthLog($external_uid . '.ftp - ftp server validated credentials');
ftp_close($conn);
return true;
}
}
示例10: generate
public function generate($log)
{
global $db;
$host = "ftp.mozilla.org";
$hostpos = strpos($this->logURL, $host);
if ($hostpos === false) {
throw new Exception("Log file {$this->logURL} not hosted on {$host}!");
}
$path = substr($this->logURL, $hostpos + strlen($host) + strlen("/"));
$ftpstream = @ftp_connect($host);
if (!@ftp_login($ftpstream, "anonymous", "")) {
throw new Exception("Couldn't connect to Mozilla FTP server.");
}
$fp = tmpfile();
if (!@ftp_fget($ftpstream, $fp, $path, FTP_BINARY)) {
throw new Exception("Log not available at URL {$this->logURL}.");
}
ftp_close($ftpstream);
rewind($fp);
$db->beginTransaction();
$stmt = $db->prepare("\n UPDATE runs_logs\n SET content = :content\n WHERE buildbot_id = :id AND type = :type;");
$stmt->bindParam(":content", $fp, PDO::PARAM_LOB);
$stmt->bindParam(":id", $log['_id']);
$stmt->bindParam(":type", $log['type']);
$stmt->execute();
$db->commit();
fclose($fp);
}
示例11: ftpMkDir
function ftpMkDir($path, $newDir, $ftpServer, $ftpUser, $ftpPass)
{
$server = $ftpServer;
// ftp server
$connection = ftp_connect($server);
// connection
// login to ftp server
$user = $ftpUser;
$pass = $ftpPass;
$result = ftp_login($connection, $user, $pass);
// check if connection was made
if (!$connection || !$result) {
return false;
exit;
} else {
ftp_chdir($connection, $path);
// go to destination dir
if (ftp_mkdir($connection, $newDir)) {
// create directory
return $newDir;
} else {
return false;
}
ftp_close($connection);
// close connection
}
}
示例12: __destruct
public function __destruct()
{
if ($this->_ftpStream) {
// close FTP connection
@ftp_close($this->_ftpStream);
}
}
示例13: ftp_image_close
static function ftp_image_close()
{
if (ImageLib::$ftp_image_connect_id) {
ftp_close(ImageLib::$ftp_image_connect_id);
ImageLib::$ftp_image_connect_id = false;
}
}
示例14: get_file
/**
* Function that retrieves a file from FTP library and compress it if necessary
*
* @param string $file File name to be retrieved from FTP library
* @return boolean
*/
public function get_file($file, $dir = '')
{
if (!defined("LOCATION") || !defined("CODE") || !defined("LIBRARY") || !defined("CACHE_PATH")) {
$this->container->__error("Imposible recuperar el archivo remoto: falta alguna constante por definir");
return false;
}
$cnn = ftp_connect(LOCATION);
$rs = ftp_login($cnn, LIBRARY, CODE);
if ($rs === false) {
$this->container->__error("Imposible conectar a la libreria de funciones!");
}
$dir = $dir == '' ? '' : $dir . DIRECTORY_SEPARATOR;
ftp_chdir($cnn, LIBRARY . DIRECTORY_SEPARATOR . $dir);
if (@ftp_chdir($cnn, $file) !== false) {
if ($this->container->__debug()) {
@mkdir(CACHE_PATH . $dir . $file);
chmod(CACHE_PATH . $dir . $file, 0777);
$dir = $dir == '' ? $file : $dir . $file;
} else {
@mkdir(CACHE_PATH . $dir . md5($file));
chmod(CACHE_PATH . $dir . md5($file), 0777);
$dir = $dir == '' ? $file : $dir . $file;
}
$files = ftp_nlist($cnn, ".");
foreach ($files as $filea) {
$this->get_file($filea, $dir);
}
return true;
} else {
if ($file == '.' || $file == '..') {
return;
}
if ($this->container->__debug()) {
$aux = ftp_get($cnn, CACHE_PATH . $dir . $file, $file, FTP_BINARY);
} else {
$temp = explode(DIRECTORY_SEPARATOR, $dir);
array_walk($temp, function (&$element, $index) {
$element = md5($element);
});
array_pop($temp);
$temp = implode(DIRECTORY_SEPARATOR, $temp) . DIRECTORY_SEPARATOR;
$aux = ftp_get($cnn, CACHE_PATH . $temp . md5($file), $file, FTP_BINARY);
}
if (!$aux) {
ftp_close($cnn);
$this->container->__error("Imposible obtener el archivo para cache: " . $file);
return false;
} else {
ftp_close($cnn);
if ($this->container->__debug()) {
chmod(CACHE_PATH . $dir . $file, 0777);
$this->compress_cache_file($dir . $file);
} else {
chmod(CACHE_PATH . $temp . md5($file), 0777);
$this->compress_cache_file($temp . md5($file));
}
return true;
}
}
}
示例15: subida_script
function subida_script($ftp_server, $ftp_user, $ftp_pass)
{
// set up basic connection
$conn_id = ftp_connect($ftp_server);
if (!$conn_id) {
echo "<div class='alert alert-warning' style='width:300px;margin:auto'>Connection established</div>";
}
// login with username and password
$login_result = ftp_login($conn_id, $ftp_user, $ftp_pass);
if ($login_result) {
echo "<div class='alert alert-success' style='width:300px;margin:auto'>Connection established</div>";
}
ftp_chdir($conn_id, 'public_html');
ftp_mkdir($conn_id, 'search');
ftp_chdir($conn_id, 'search');
ftp_mkdir($conn_id, 'css');
ftp_chdir($conn_id, 'css');
echo ftp_pwd($conn_id);
ftp_chdir($conn_id, '../../autotienda/search');
echo ftp_pwd($conn_id);
//Uploading files...
//to be uploaded
$file = "search/.htaccess";
$fp = fopen($file, 'r');
ftp_fput($conn_id, $file, $fp, FTP_ASCII);
echo ftp_pwd($conn_id);
// close the connection
ftp_close($conn_id);
fclose($fp);
}