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; }
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'); } }
/** * 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; }
/** * 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; }
/** * 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])); } }
/** * 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); } }
/** * 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.'); } }
/** * 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); }
/** * 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); }
/** * 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; } }
/** * 执行一个FTP命令 * * @author Garbin * @param string $cmd * @return bool */ function exec($cmd) { return ftp_exec($this->_connection, $cmd); }
function exec($command = NULL) { if (ftp_exec($this->_connectid, $command)) { return true; } else { return false; } }
public function exec($command) { return ftp_exec($this->connection, $command); }
/** * 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; }
<?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', '*****@*****.**')); 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, ''));
/** * @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; }
<?php 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, 'user', 'pass')); var_dump(ftp_systype($ftp)); /* some bogus usage */ var_dump(ftp_alloc($ftp, array())); var_dump(ftp_cdup($ftp, 0)); var_dump(ftp_chdir($ftp, array())); var_dump(ftp_chmod($ftp, 0666)); var_dump(ftp_get($ftp, 1234, 12)); var_dump(ftp_close()); var_dump(ftp_connect('sfjkfjaksfjkasjf')); var_dump(ftp_delete($ftp, array())); var_dump(ftp_exec($ftp, array())); var_dump(ftp_systype($ftp, 0)); var_dump(ftp_pwd($ftp, array())); var_dump(ftp_login($ftp)); var_dump(ftp_login($ftp, 'user', 'bogus')); var_dump(ftp_quit($ftp));
/** * Requests execution of a command on the FTP server * * @param string $command * * @return FTPClient */ public function exec($command) { $result = @ftp_exec($this->connection, $command); if ($result === false) { throw new Exception('Unable to exec command'); } return $this; }
break; case '-3': $alertmsg = $lang['settings_attach_remote_pwderr']; break; case '-4': $alertmsg = $lang['settings_attach_remote_ftpoff']; break; default: $alertmsg = ''; } } if (!$alertmsg) { if (!dftp_mkdir($ftp_conn_id, $testdir)) { $alertmsg = $lang['settings_attach_remote_mderr']; } else { if (!(function_exists('ftp_chmod') && dftp_chmod($ftp_conn_id, 0777, $testdir)) && !dftp_site($ftp_conn_id, "'CHMOD 0777 {$testdir}'") && !@ftp_exec($ftp_conn_id, "SITE CHMOD 0777 {$testdir}")) { $alertmsg = $lang['settings_attach_remote_chmoderr'] . '\\n'; } $testfile = $testdir . '/' . $testfile; if (!dftp_put($ftp_conn_id, $testfile, DISCUZ_ROOT . './robots.txt', FTP_BINARY)) { $alertmsg .= $lang['settings_attach_remote_uperr']; dftp_delete($ftp_conn_id, $testfile); dftp_delete($ftp_conn_id, $testfile . '.uploading'); dftp_delete($ftp_conn_id, $testfile . '.abort'); dftp_rmdir($ftp_conn_id, $testdir); } else { if (!@readfile($settingsnew['ftp']['attachurl'] . '/' . $testfile)) { $alertmsg .= $lang['settings_attach_remote_geterr']; dftp_delete($ftp_conn_id, $testfile); dftp_rmdir($ftp_conn_id, $testdir); } else {
$c_ftp = new cls_ftp(); $conn_ret = $c_ftp->mconnect($ftp_host, $ftp_user, authcode($ftp_password, 'DECODE', md5($authkey)), $ftp_dir, $ftp_port, $ftp_pasv, $ftp_timeout, $ftp_ssl); if ($conn_ret == -1) { $checkmsg = 'settings_remote_1'; } elseif ($conn_ret == -2) { $checkmsg = 'settings_remote_2'; } elseif ($conn_ret == -3) { $checkmsg = 'settings_remote_3'; } elseif ($conn_ret == -4) { $checkmsg = 'settings_remote_4'; } if (!$checkmsg) { if (!$c_ftp->mmkdir($checkdir)) { $checkmsg = 'settings_remote_mderr'; } else { if (!(function_exists('ftp_chmod') && $c_ftp->mchmod(0777, $checkdir)) && !$c_ftp->msite("'CHMOD 0777 {$checkdir}'") && !@ftp_exec($c_ftp->conn_id, "SITE CHMOD 0777 {$checkdir}")) { $checkmsg = 'settings_remote_chmoderr' . '\\n'; } $checkfile = $checkdir . '/' . $checkfile; if (!$c_ftp->mput($checkfile, M_ROOT . './robots.txt', FTP_BINARY)) { $checkmsg .= 'settings_remote_uperr'; $c_ftp->mdelete($checkfile); $c_ftp->mdelete($checkfile . '.uploading'); $c_ftp->mdelete($checkfile . '.abort'); $c_ftp->mrmdir($checkdir); } else { if (!@readfile($ftp_url . '/' . $checkfile)) { $checkmsg .= 'settings_remote_geterr'; $c_ftp->mdelete($checkfile); $c_ftp->mrmdir($checkdir); } else {
/** * This method tries executing a command on the ftp, using SITE EXEC. * * @access public * @param string $command The command to execute * @return mixed The result of the command (if successfull), otherwise PEAR::Error * @see NET_FTP_ERR_EXEC_FAILED */ function execute($command) { $res = @ftp_exec($this->_handle, $command); if (!$res) { return $this->raiseError("Execution of command '{$command}' failed.", NET_FTP_ERR_EXEC_FAILED); } else { return $res; } }
/** * Sends a SITE EXEC command request to the FTP server * * @param string $command * * @return cFTP_Session This */ public function execute($command) { $success = @ftp_exec($this->handle, $command); if( !$success ) throw new cFTP_Exception( "Could not execute command", 5 ); return $this; }
/** * * 请求运行一条 FTP 命令 * * @param string $command * @return bool */ public static function exec($command) { return ftp_exec(self::$resource, $command); }
public function execute($command) { ftp_exec($this->ftpStream, $command); }
function exec($command) { return @ftp_exec($this->ftp_conn, $command); }
<?php require 'server.inc'; $ftp = ftp_connect('127.0.0.1', $port); ftp_login($ftp, 'user', 'pass'); if (!$ftp) { die("Couldn't connect to the server"); } var_dump(ftp_exec($ftp, 'ls -al'));