本文整理汇总了PHP中ftp_exec函数的典型用法代码示例。如果您正苦于以下问题:PHP ftp_exec函数的具体用法?PHP ftp_exec怎么用?PHP ftp_exec使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ftp_exec函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: exec
public function exec($command)
{
Logger::log('exec ' . $command);
$result = ftp_exec($this->connectionId, $command);
if (empty($result)) {
Logger::log('exec command return false');
}
return $result;
}
示例2: exec
public function exec($command)
{
if (!is_resource($this->resource)) {
throw new ConnectionException('Connection is not open');
}
if (@ftp_exec($this->resource, $command)) {
return '';
} else {
throw new ConnectionException('Unable to exec FTP command');
}
}
示例3: connect
/**
* Connect to ftp server
*
* @return bool
* @author Dmitry (dio) Levashov
* @author Naoki Sawada
**/
protected function connect()
{
if (!($this->connect = ftp_connect($this->options['host'], $this->options['port'], $this->options['timeout']))) {
return $this->setError('Unable to connect to FTP server ' . $this->options['host']);
}
if (!ftp_login($this->connect, $this->options['user'], $this->options['pass'])) {
$this->umount();
return $this->setError('Unable to login into ' . $this->options['host']);
}
// try switch utf8 mode
if ($this->encoding) {
@ftp_exec($this->connect, 'OPTS UTF8 OFF');
} else {
@ftp_exec($this->connect, 'OPTS UTF8 ON');
}
// switch off extended passive mode - may be usefull for some servers
@ftp_exec($this->connect, 'epsv4 off');
// enter passive mode if required
ftp_pasv($this->connect, $this->options['mode'] == 'passive');
// enter root folder
if (!@ftp_chdir($this->connect, $this->root) || $this->root != ftp_pwd($this->connect)) {
if (empty($this->options['is_local']) || !$this->setLocalRoot()) {
$this->umount();
return $this->setError('Unable to open root folder.');
}
}
// check for MLST support
$features = ftp_raw($this->connect, 'FEAT');
if (!is_array($features)) {
$this->umount();
return $this->setError('Server does not support command FEAT.');
}
foreach ($features as $feat) {
if (strpos(trim($feat), 'MLST') === 0) {
$this->MLSTsupprt = true;
break;
}
}
return true;
}
示例4: connect
/**
* Connect to ftp server
*
* @return bool
* @author Dmitry (dio) Levashov
*/
public function connect()
{
static $connected = false;
if ($connected) {
return true;
}
if (!($this->connect = ftp_connect($this->options['host'], $this->options['port'], $this->options['timeout']))) {
return $this->setError('Unable to connect to FTP server ' . $this->options['host']);
}
if (!ftp_login($this->connect, $this->options['user'], $this->options['pass'])) {
$this->umount();
return $this->setError('Unable to login into ' . $this->options['host']);
}
// switch off extended passive mode - may be usefull for some servers
@ftp_exec($this->connect, 'epsv4 off');
// enter passive mode if required
ftp_pasv($this->connect, $this->options['mode'] == 'passive');
// enter root folder
if (!ftp_chdir($this->connect, $this->root) || $this->root != ftp_pwd($this->connect)) {
$this->umount();
return $this->setError('Unable to open root folder.');
}
$connected = parent::connect();
return $connected;
}
示例5: exec
/**
* Sends a SITE EXEC command request to the FTP server.
*
* @param string $command FTP command (does not include <i>SITE EXEC</i> words).
*
* @throws FtpException If command execution fails.
*/
public function exec($command)
{
$this->connectIfNeeded();
$this->param = "SITE EXEC " . $command;
$exec = true;
if (!ftp_exec($this->handle, substr($command, strlen("SITE EXEC")))) {
throw new FtpException(Yii::t('gftp', 'Could not execute command "{command}" on "{host}"', ['host' => $this->host, '{command}' => $this->param]));
}
}
示例6: executeCommand
/**
* Sends a SITE EXEC command to a FTP server.
*
* @param string $command The command that is send to the server.
* @return bool
*/
public function executeCommand($command)
{
if (is_resource($this->cid)) {
return ftp_exec($this->cid, $command);
}
}
示例7: execute
/**
* Execute a remote command on the FTP server.
*
* @see http://us2.php.net/manual/en/function.ftp-exec.php
* @param string remote command
* @return boolean
*/
public function execute($command)
{
if ($this->getActive()) {
// Execute command
if (ftp_exec($this->_connection, $command)) {
return true;
} else {
return false;
}
} else {
throw new CDbException('EFtpComponent is inactive and cannot perform any FTP operations.');
}
}
示例8: exec
/**
* Requests execution of a command
* @link http://php.net/ftp_exec
*
* @param string $command The comman to execute
* @return boolean TRUE on success, FALSE on failure
*/
public function exec($command)
{
return ftp_exec($this->connection->getStream(), $command);
}
示例9: exec
/**
* Execute an arbitrary command on the FTP server
*
* @param string command
* @return mixed
*/
protected function exec($cmd = null)
{
return ftp_exec($this->ftp, (string) $cmd);
}
示例10: execCmd
/**
* Execute a remote command on the FTP server.
* @see http://us2.php.net/manual/en/function.ftp-exec.php
* @param string remote command
* @return boolean
*/
public function execCmd($command)
{
if (ftp_exec($this->_connection, $command)) {
return true;
} else {
return false;
}
}
示例11: exec
/**
* 执行一个FTP命令
*
* @author Garbin
* @param string $cmd
* @return bool
*/
function exec($cmd)
{
return ftp_exec($this->_connection, $cmd);
}
示例12: exec
public function exec($command)
{
return ftp_exec($this->connection, $command);
}
示例13: exec
/**
* execute commands on the server, ie. ls -al >files.txt
*
* @param $command string The command to be executed
*
* @return object
*/
public function exec($command)
{
//check if exec has been enabled by the config
if ($this->exec === false) {
throw new MeagrException('Exec is currently disabled, tried to execute: "' . $command . '"');
return false;
}
//see if the command was executed
if (!ftp_exec($this->connection, $command)) {
throw new MeagrException('Exec command "' . $command . '" could not be executed');
return false;
}
return $this;
}
示例14: ftp_connect
<?php
$bogus = 1;
require 'server.inc';
$ftp = ftp_connect('127.0.0.1', $port);
if (!$ftp) {
die("Couldn't connect to the server");
}
var_dump(ftp_login($ftp, 'anonymous', 'mail@example.com'));
var_dump(ftp_alloc($ftp, 400));
var_dump(ftp_cdup($ftp));
var_dump(ftp_chdir($ftp, '~'));
var_dump(ftp_chmod($ftp, 0666, 'x'));
var_dump(ftp_delete($ftp, 'x'));
var_dump(ftp_exec($ftp, 'x'));
var_dump(ftp_fget($ftp, STDOUT, 'x', 0));
var_dump(ftp_fput($ftp, 'x', fopen(__FILE__, 'r'), 0));
var_dump(ftp_get($ftp, 'x', 'y', 0));
var_dump(ftp_mdtm($ftp, 'x'));
var_dump(ftp_mkdir($ftp, 'x'));
var_dump(ftp_nb_continue($ftp));
var_dump(ftp_nb_fget($ftp, STDOUT, 'x', 0));
var_dump(ftp_nb_fput($ftp, 'x', fopen(__FILE__, 'r'), 0));
var_dump(ftp_systype($ftp));
var_dump(ftp_pwd($ftp));
var_dump(ftp_size($ftp, ''));
var_dump(ftp_rmdir($ftp, ''));
示例15: exec
/**
* @param $command
*
* @return string
*/
public function exec($command)
{
$sftpDir = $this->pwd();
switch ($this->_connType) {
case SftpHelper::TYPE_SFTP:
default:
$execOutput = $this->_connection->exec('cd ' . $sftpDir . ' && ' . $command);
$this->_lastExecExitStatus = $this->_connection->getExitStatus();
break;
case SftpHelper::TYPE_FTP:
// TODO: test ftp_exec on a server which supports it
$execOutput = '';
$res = @ftp_exec($this->_connection, 'cd ' . $sftpDir . ' && ' . $command);
$this->_lastExecExitStatus = $res ? 0 : 1;
break;
}
return $execOutput;
}